説明なし

jquery.dataTables.js 438KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334
  1. /*! DataTables 1.10.20
  2. * ©2008-2019 SpryMedia Ltd - datatables.net/license
  3. */
  4. /**
  5. * @summary DataTables
  6. * @description Paginate, search and order HTML tables
  7. * @version 1.10.20
  8. * @file jquery.dataTables.js
  9. * @author SpryMedia Ltd
  10. * @contact www.datatables.net
  11. * @copyright Copyright 2008-2019 SpryMedia Ltd.
  12. *
  13. * This source file is free software, available under the following license:
  14. * MIT license - http://datatables.net/license
  15. *
  16. * This source file is distributed in the hope that it will be useful, but
  17. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  18. * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
  19. *
  20. * For details please refer to: http://www.datatables.net
  21. */
  22. /*jslint evil: true, undef: true, browser: true */
  23. /*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*/
  24. (function( factory ) {
  25. "use strict";
  26. if ( typeof define === 'function' && define.amd ) {
  27. // AMD
  28. define( ['jquery'], function ( $ ) {
  29. return factory( $, window, document );
  30. } );
  31. }
  32. else if ( typeof exports === 'object' ) {
  33. // CommonJS
  34. module.exports = function (root, $) {
  35. if ( ! root ) {
  36. // CommonJS environments without a window global must pass a
  37. // root. This will give an error otherwise
  38. root = window;
  39. }
  40. if ( ! $ ) {
  41. $ = typeof window !== 'undefined' ? // jQuery's factory checks for a global window
  42. require('jquery') :
  43. require('jquery')( root );
  44. }
  45. return factory( $, root, root.document );
  46. };
  47. }
  48. else {
  49. // Browser
  50. factory( jQuery, window, document );
  51. }
  52. }
  53. (function( $, window, document, undefined ) {
  54. "use strict";
  55. /**
  56. * DataTables is a plug-in for the jQuery Javascript library. It is a highly
  57. * flexible tool, based upon the foundations of progressive enhancement,
  58. * which will add advanced interaction controls to any HTML table. For a
  59. * full list of features please refer to
  60. * [DataTables.net](href="http://datatables.net).
  61. *
  62. * Note that the `DataTable` object is not a global variable but is aliased
  63. * to `jQuery.fn.DataTable` and `jQuery.fn.dataTable` through which it may
  64. * be accessed.
  65. *
  66. * @class
  67. * @param {object} [init={}] Configuration object for DataTables. Options
  68. * are defined by {@link DataTable.defaults}
  69. * @requires jQuery 1.7+
  70. *
  71. * @example
  72. * // Basic initialisation
  73. * $(document).ready( function {
  74. * $('#example').dataTable();
  75. * } );
  76. *
  77. * @example
  78. * // Initialisation with configuration options - in this case, disable
  79. * // pagination and sorting.
  80. * $(document).ready( function {
  81. * $('#example').dataTable( {
  82. * "paginate": false,
  83. * "sort": false
  84. * } );
  85. * } );
  86. */
  87. var DataTable = function ( options )
  88. {
  89. /**
  90. * Perform a jQuery selector action on the table's TR elements (from the tbody) and
  91. * return the resulting jQuery object.
  92. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  93. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  94. * @param {string} [oOpts.filter=none] Select TR elements that meet the current filter
  95. * criterion ("applied") or all TR elements (i.e. no filter).
  96. * @param {string} [oOpts.order=current] Order of the TR elements in the processed array.
  97. * Can be either 'current', whereby the current sorting of the table is used, or
  98. * 'original' whereby the original order the data was read into the table is used.
  99. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  100. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  101. * 'current' and filter is 'applied', regardless of what they might be given as.
  102. * @returns {object} jQuery object, filtered by the given selector.
  103. * @dtopt API
  104. * @deprecated Since v1.10
  105. *
  106. * @example
  107. * $(document).ready(function() {
  108. * var oTable = $('#example').dataTable();
  109. *
  110. * // Highlight every second row
  111. * oTable.$('tr:odd').css('backgroundColor', 'blue');
  112. * } );
  113. *
  114. * @example
  115. * $(document).ready(function() {
  116. * var oTable = $('#example').dataTable();
  117. *
  118. * // Filter to rows with 'Webkit' in them, add a background colour and then
  119. * // remove the filter, thus highlighting the 'Webkit' rows only.
  120. * oTable.fnFilter('Webkit');
  121. * oTable.$('tr', {"search": "applied"}).css('backgroundColor', 'blue');
  122. * oTable.fnFilter('');
  123. * } );
  124. */
  125. this.$ = function ( sSelector, oOpts )
  126. {
  127. return this.api(true).$( sSelector, oOpts );
  128. };
  129. /**
  130. * Almost identical to $ in operation, but in this case returns the data for the matched
  131. * rows - as such, the jQuery selector used should match TR row nodes or TD/TH cell nodes
  132. * rather than any descendants, so the data can be obtained for the row/cell. If matching
  133. * rows are found, the data returned is the original data array/object that was used to
  134. * create the row (or a generated array if from a DOM source).
  135. *
  136. * This method is often useful in-combination with $ where both functions are given the
  137. * same parameters and the array indexes will match identically.
  138. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  139. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  140. * @param {string} [oOpts.filter=none] Select elements that meet the current filter
  141. * criterion ("applied") or all elements (i.e. no filter).
  142. * @param {string} [oOpts.order=current] Order of the data in the processed array.
  143. * Can be either 'current', whereby the current sorting of the table is used, or
  144. * 'original' whereby the original order the data was read into the table is used.
  145. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  146. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  147. * 'current' and filter is 'applied', regardless of what they might be given as.
  148. * @returns {array} Data for the matched elements. If any elements, as a result of the
  149. * selector, were not TR, TD or TH elements in the DataTable, they will have a null
  150. * entry in the array.
  151. * @dtopt API
  152. * @deprecated Since v1.10
  153. *
  154. * @example
  155. * $(document).ready(function() {
  156. * var oTable = $('#example').dataTable();
  157. *
  158. * // Get the data from the first row in the table
  159. * var data = oTable._('tr:first');
  160. *
  161. * // Do something useful with the data
  162. * alert( "First cell is: "+data[0] );
  163. * } );
  164. *
  165. * @example
  166. * $(document).ready(function() {
  167. * var oTable = $('#example').dataTable();
  168. *
  169. * // Filter to 'Webkit' and get all data for
  170. * oTable.fnFilter('Webkit');
  171. * var data = oTable._('tr', {"search": "applied"});
  172. *
  173. * // Do something with the data
  174. * alert( data.length+" rows matched the search" );
  175. * } );
  176. */
  177. this._ = function ( sSelector, oOpts )
  178. {
  179. return this.api(true).rows( sSelector, oOpts ).data();
  180. };
  181. /**
  182. * Create a DataTables Api instance, with the currently selected tables for
  183. * the Api's context.
  184. * @param {boolean} [traditional=false] Set the API instance's context to be
  185. * only the table referred to by the `DataTable.ext.iApiIndex` option, as was
  186. * used in the API presented by DataTables 1.9- (i.e. the traditional mode),
  187. * or if all tables captured in the jQuery object should be used.
  188. * @return {DataTables.Api}
  189. */
  190. this.api = function ( traditional )
  191. {
  192. return traditional ?
  193. new _Api(
  194. _fnSettingsFromNode( this[ _ext.iApiIndex ] )
  195. ) :
  196. new _Api( this );
  197. };
  198. /**
  199. * Add a single new row or multiple rows of data to the table. Please note
  200. * that this is suitable for client-side processing only - if you are using
  201. * server-side processing (i.e. "bServerSide": true), then to add data, you
  202. * must add it to the data source, i.e. the server-side, through an Ajax call.
  203. * @param {array|object} data The data to be added to the table. This can be:
  204. * <ul>
  205. * <li>1D array of data - add a single row with the data provided</li>
  206. * <li>2D array of arrays - add multiple rows in a single call</li>
  207. * <li>object - data object when using <i>mData</i></li>
  208. * <li>array of objects - multiple data objects when using <i>mData</i></li>
  209. * </ul>
  210. * @param {bool} [redraw=true] redraw the table or not
  211. * @returns {array} An array of integers, representing the list of indexes in
  212. * <i>aoData</i> ({@link DataTable.models.oSettings}) that have been added to
  213. * the table.
  214. * @dtopt API
  215. * @deprecated Since v1.10
  216. *
  217. * @example
  218. * // Global var for counter
  219. * var giCount = 2;
  220. *
  221. * $(document).ready(function() {
  222. * $('#example').dataTable();
  223. * } );
  224. *
  225. * function fnClickAddRow() {
  226. * $('#example').dataTable().fnAddData( [
  227. * giCount+".1",
  228. * giCount+".2",
  229. * giCount+".3",
  230. * giCount+".4" ]
  231. * );
  232. *
  233. * giCount++;
  234. * }
  235. */
  236. this.fnAddData = function( data, redraw )
  237. {
  238. var api = this.api( true );
  239. /* Check if we want to add multiple rows or not */
  240. var rows = $.isArray(data) && ( $.isArray(data[0]) || $.isPlainObject(data[0]) ) ?
  241. api.rows.add( data ) :
  242. api.row.add( data );
  243. if ( redraw === undefined || redraw ) {
  244. api.draw();
  245. }
  246. return rows.flatten().toArray();
  247. };
  248. /**
  249. * This function will make DataTables recalculate the column sizes, based on the data
  250. * contained in the table and the sizes applied to the columns (in the DOM, CSS or
  251. * through the sWidth parameter). This can be useful when the width of the table's
  252. * parent element changes (for example a window resize).
  253. * @param {boolean} [bRedraw=true] Redraw the table or not, you will typically want to
  254. * @dtopt API
  255. * @deprecated Since v1.10
  256. *
  257. * @example
  258. * $(document).ready(function() {
  259. * var oTable = $('#example').dataTable( {
  260. * "sScrollY": "200px",
  261. * "bPaginate": false
  262. * } );
  263. *
  264. * $(window).on('resize', function () {
  265. * oTable.fnAdjustColumnSizing();
  266. * } );
  267. * } );
  268. */
  269. this.fnAdjustColumnSizing = function ( bRedraw )
  270. {
  271. var api = this.api( true ).columns.adjust();
  272. var settings = api.settings()[0];
  273. var scroll = settings.oScroll;
  274. if ( bRedraw === undefined || bRedraw ) {
  275. api.draw( false );
  276. }
  277. else if ( scroll.sX !== "" || scroll.sY !== "" ) {
  278. /* If not redrawing, but scrolling, we want to apply the new column sizes anyway */
  279. _fnScrollDraw( settings );
  280. }
  281. };
  282. /**
  283. * Quickly and simply clear a table
  284. * @param {bool} [bRedraw=true] redraw the table or not
  285. * @dtopt API
  286. * @deprecated Since v1.10
  287. *
  288. * @example
  289. * $(document).ready(function() {
  290. * var oTable = $('#example').dataTable();
  291. *
  292. * // Immediately 'nuke' the current rows (perhaps waiting for an Ajax callback...)
  293. * oTable.fnClearTable();
  294. * } );
  295. */
  296. this.fnClearTable = function( bRedraw )
  297. {
  298. var api = this.api( true ).clear();
  299. if ( bRedraw === undefined || bRedraw ) {
  300. api.draw();
  301. }
  302. };
  303. /**
  304. * The exact opposite of 'opening' a row, this function will close any rows which
  305. * are currently 'open'.
  306. * @param {node} nTr the table row to 'close'
  307. * @returns {int} 0 on success, or 1 if failed (can't find the row)
  308. * @dtopt API
  309. * @deprecated Since v1.10
  310. *
  311. * @example
  312. * $(document).ready(function() {
  313. * var oTable;
  314. *
  315. * // 'open' an information row when a row is clicked on
  316. * $('#example tbody tr').click( function () {
  317. * if ( oTable.fnIsOpen(this) ) {
  318. * oTable.fnClose( this );
  319. * } else {
  320. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  321. * }
  322. * } );
  323. *
  324. * oTable = $('#example').dataTable();
  325. * } );
  326. */
  327. this.fnClose = function( nTr )
  328. {
  329. this.api( true ).row( nTr ).child.hide();
  330. };
  331. /**
  332. * Remove a row for the table
  333. * @param {mixed} target The index of the row from aoData to be deleted, or
  334. * the TR element you want to delete
  335. * @param {function|null} [callBack] Callback function
  336. * @param {bool} [redraw=true] Redraw the table or not
  337. * @returns {array} The row that was deleted
  338. * @dtopt API
  339. * @deprecated Since v1.10
  340. *
  341. * @example
  342. * $(document).ready(function() {
  343. * var oTable = $('#example').dataTable();
  344. *
  345. * // Immediately remove the first row
  346. * oTable.fnDeleteRow( 0 );
  347. * } );
  348. */
  349. this.fnDeleteRow = function( target, callback, redraw )
  350. {
  351. var api = this.api( true );
  352. var rows = api.rows( target );
  353. var settings = rows.settings()[0];
  354. var data = settings.aoData[ rows[0][0] ];
  355. rows.remove();
  356. if ( callback ) {
  357. callback.call( this, settings, data );
  358. }
  359. if ( redraw === undefined || redraw ) {
  360. api.draw();
  361. }
  362. return data;
  363. };
  364. /**
  365. * Restore the table to it's original state in the DOM by removing all of DataTables
  366. * enhancements, alterations to the DOM structure of the table and event listeners.
  367. * @param {boolean} [remove=false] Completely remove the table from the DOM
  368. * @dtopt API
  369. * @deprecated Since v1.10
  370. *
  371. * @example
  372. * $(document).ready(function() {
  373. * // This example is fairly pointless in reality, but shows how fnDestroy can be used
  374. * var oTable = $('#example').dataTable();
  375. * oTable.fnDestroy();
  376. * } );
  377. */
  378. this.fnDestroy = function ( remove )
  379. {
  380. this.api( true ).destroy( remove );
  381. };
  382. /**
  383. * Redraw the table
  384. * @param {bool} [complete=true] Re-filter and resort (if enabled) the table before the draw.
  385. * @dtopt API
  386. * @deprecated Since v1.10
  387. *
  388. * @example
  389. * $(document).ready(function() {
  390. * var oTable = $('#example').dataTable();
  391. *
  392. * // Re-draw the table - you wouldn't want to do it here, but it's an example :-)
  393. * oTable.fnDraw();
  394. * } );
  395. */
  396. this.fnDraw = function( complete )
  397. {
  398. // Note that this isn't an exact match to the old call to _fnDraw - it takes
  399. // into account the new data, but can hold position.
  400. this.api( true ).draw( complete );
  401. };
  402. /**
  403. * Filter the input based on data
  404. * @param {string} sInput String to filter the table on
  405. * @param {int|null} [iColumn] Column to limit filtering to
  406. * @param {bool} [bRegex=false] Treat as regular expression or not
  407. * @param {bool} [bSmart=true] Perform smart filtering or not
  408. * @param {bool} [bShowGlobal=true] Show the input global filter in it's input box(es)
  409. * @param {bool} [bCaseInsensitive=true] Do case-insensitive matching (true) or not (false)
  410. * @dtopt API
  411. * @deprecated Since v1.10
  412. *
  413. * @example
  414. * $(document).ready(function() {
  415. * var oTable = $('#example').dataTable();
  416. *
  417. * // Sometime later - filter...
  418. * oTable.fnFilter( 'test string' );
  419. * } );
  420. */
  421. this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal, bCaseInsensitive )
  422. {
  423. var api = this.api( true );
  424. if ( iColumn === null || iColumn === undefined ) {
  425. api.search( sInput, bRegex, bSmart, bCaseInsensitive );
  426. }
  427. else {
  428. api.column( iColumn ).search( sInput, bRegex, bSmart, bCaseInsensitive );
  429. }
  430. api.draw();
  431. };
  432. /**
  433. * Get the data for the whole table, an individual row or an individual cell based on the
  434. * provided parameters.
  435. * @param {int|node} [src] A TR row node, TD/TH cell node or an integer. If given as
  436. * a TR node then the data source for the whole row will be returned. If given as a
  437. * TD/TH cell node then iCol will be automatically calculated and the data for the
  438. * cell returned. If given as an integer, then this is treated as the aoData internal
  439. * data index for the row (see fnGetPosition) and the data for that row used.
  440. * @param {int} [col] Optional column index that you want the data of.
  441. * @returns {array|object|string} If mRow is undefined, then the data for all rows is
  442. * returned. If mRow is defined, just data for that row, and is iCol is
  443. * defined, only data for the designated cell is returned.
  444. * @dtopt API
  445. * @deprecated Since v1.10
  446. *
  447. * @example
  448. * // Row data
  449. * $(document).ready(function() {
  450. * oTable = $('#example').dataTable();
  451. *
  452. * oTable.$('tr').click( function () {
  453. * var data = oTable.fnGetData( this );
  454. * // ... do something with the array / object of data for the row
  455. * } );
  456. * } );
  457. *
  458. * @example
  459. * // Individual cell data
  460. * $(document).ready(function() {
  461. * oTable = $('#example').dataTable();
  462. *
  463. * oTable.$('td').click( function () {
  464. * var sData = oTable.fnGetData( this );
  465. * alert( 'The cell clicked on had the value of '+sData );
  466. * } );
  467. * } );
  468. */
  469. this.fnGetData = function( src, col )
  470. {
  471. var api = this.api( true );
  472. if ( src !== undefined ) {
  473. var type = src.nodeName ? src.nodeName.toLowerCase() : '';
  474. return col !== undefined || type == 'td' || type == 'th' ?
  475. api.cell( src, col ).data() :
  476. api.row( src ).data() || null;
  477. }
  478. return api.data().toArray();
  479. };
  480. /**
  481. * Get an array of the TR nodes that are used in the table's body. Note that you will
  482. * typically want to use the '$' API method in preference to this as it is more
  483. * flexible.
  484. * @param {int} [iRow] Optional row index for the TR element you want
  485. * @returns {array|node} If iRow is undefined, returns an array of all TR elements
  486. * in the table's body, or iRow is defined, just the TR element requested.
  487. * @dtopt API
  488. * @deprecated Since v1.10
  489. *
  490. * @example
  491. * $(document).ready(function() {
  492. * var oTable = $('#example').dataTable();
  493. *
  494. * // Get the nodes from the table
  495. * var nNodes = oTable.fnGetNodes( );
  496. * } );
  497. */
  498. this.fnGetNodes = function( iRow )
  499. {
  500. var api = this.api( true );
  501. return iRow !== undefined ?
  502. api.row( iRow ).node() :
  503. api.rows().nodes().flatten().toArray();
  504. };
  505. /**
  506. * Get the array indexes of a particular cell from it's DOM element
  507. * and column index including hidden columns
  508. * @param {node} node this can either be a TR, TD or TH in the table's body
  509. * @returns {int} If nNode is given as a TR, then a single index is returned, or
  510. * if given as a cell, an array of [row index, column index (visible),
  511. * column index (all)] is given.
  512. * @dtopt API
  513. * @deprecated Since v1.10
  514. *
  515. * @example
  516. * $(document).ready(function() {
  517. * $('#example tbody td').click( function () {
  518. * // Get the position of the current data from the node
  519. * var aPos = oTable.fnGetPosition( this );
  520. *
  521. * // Get the data array for this row
  522. * var aData = oTable.fnGetData( aPos[0] );
  523. *
  524. * // Update the data array and return the value
  525. * aData[ aPos[1] ] = 'clicked';
  526. * this.innerHTML = 'clicked';
  527. * } );
  528. *
  529. * // Init DataTables
  530. * oTable = $('#example').dataTable();
  531. * } );
  532. */
  533. this.fnGetPosition = function( node )
  534. {
  535. var api = this.api( true );
  536. var nodeName = node.nodeName.toUpperCase();
  537. if ( nodeName == 'TR' ) {
  538. return api.row( node ).index();
  539. }
  540. else if ( nodeName == 'TD' || nodeName == 'TH' ) {
  541. var cell = api.cell( node ).index();
  542. return [
  543. cell.row,
  544. cell.columnVisible,
  545. cell.column
  546. ];
  547. }
  548. return null;
  549. };
  550. /**
  551. * Check to see if a row is 'open' or not.
  552. * @param {node} nTr the table row to check
  553. * @returns {boolean} true if the row is currently open, false otherwise
  554. * @dtopt API
  555. * @deprecated Since v1.10
  556. *
  557. * @example
  558. * $(document).ready(function() {
  559. * var oTable;
  560. *
  561. * // 'open' an information row when a row is clicked on
  562. * $('#example tbody tr').click( function () {
  563. * if ( oTable.fnIsOpen(this) ) {
  564. * oTable.fnClose( this );
  565. * } else {
  566. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  567. * }
  568. * } );
  569. *
  570. * oTable = $('#example').dataTable();
  571. * } );
  572. */
  573. this.fnIsOpen = function( nTr )
  574. {
  575. return this.api( true ).row( nTr ).child.isShown();
  576. };
  577. /**
  578. * This function will place a new row directly after a row which is currently
  579. * on display on the page, with the HTML contents that is passed into the
  580. * function. This can be used, for example, to ask for confirmation that a
  581. * particular record should be deleted.
  582. * @param {node} nTr The table row to 'open'
  583. * @param {string|node|jQuery} mHtml The HTML to put into the row
  584. * @param {string} sClass Class to give the new TD cell
  585. * @returns {node} The row opened. Note that if the table row passed in as the
  586. * first parameter, is not found in the table, this method will silently
  587. * return.
  588. * @dtopt API
  589. * @deprecated Since v1.10
  590. *
  591. * @example
  592. * $(document).ready(function() {
  593. * var oTable;
  594. *
  595. * // 'open' an information row when a row is clicked on
  596. * $('#example tbody tr').click( function () {
  597. * if ( oTable.fnIsOpen(this) ) {
  598. * oTable.fnClose( this );
  599. * } else {
  600. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  601. * }
  602. * } );
  603. *
  604. * oTable = $('#example').dataTable();
  605. * } );
  606. */
  607. this.fnOpen = function( nTr, mHtml, sClass )
  608. {
  609. return this.api( true )
  610. .row( nTr )
  611. .child( mHtml, sClass )
  612. .show()
  613. .child()[0];
  614. };
  615. /**
  616. * Change the pagination - provides the internal logic for pagination in a simple API
  617. * function. With this function you can have a DataTables table go to the next,
  618. * previous, first or last pages.
  619. * @param {string|int} mAction Paging action to take: "first", "previous", "next" or "last"
  620. * or page number to jump to (integer), note that page 0 is the first page.
  621. * @param {bool} [bRedraw=true] Redraw the table or not
  622. * @dtopt API
  623. * @deprecated Since v1.10
  624. *
  625. * @example
  626. * $(document).ready(function() {
  627. * var oTable = $('#example').dataTable();
  628. * oTable.fnPageChange( 'next' );
  629. * } );
  630. */
  631. this.fnPageChange = function ( mAction, bRedraw )
  632. {
  633. var api = this.api( true ).page( mAction );
  634. if ( bRedraw === undefined || bRedraw ) {
  635. api.draw(false);
  636. }
  637. };
  638. /**
  639. * Show a particular column
  640. * @param {int} iCol The column whose display should be changed
  641. * @param {bool} bShow Show (true) or hide (false) the column
  642. * @param {bool} [bRedraw=true] Redraw the table or not
  643. * @dtopt API
  644. * @deprecated Since v1.10
  645. *
  646. * @example
  647. * $(document).ready(function() {
  648. * var oTable = $('#example').dataTable();
  649. *
  650. * // Hide the second column after initialisation
  651. * oTable.fnSetColumnVis( 1, false );
  652. * } );
  653. */
  654. this.fnSetColumnVis = function ( iCol, bShow, bRedraw )
  655. {
  656. var api = this.api( true ).column( iCol ).visible( bShow );
  657. if ( bRedraw === undefined || bRedraw ) {
  658. api.columns.adjust().draw();
  659. }
  660. };
  661. /**
  662. * Get the settings for a particular table for external manipulation
  663. * @returns {object} DataTables settings object. See
  664. * {@link DataTable.models.oSettings}
  665. * @dtopt API
  666. * @deprecated Since v1.10
  667. *
  668. * @example
  669. * $(document).ready(function() {
  670. * var oTable = $('#example').dataTable();
  671. * var oSettings = oTable.fnSettings();
  672. *
  673. * // Show an example parameter from the settings
  674. * alert( oSettings._iDisplayStart );
  675. * } );
  676. */
  677. this.fnSettings = function()
  678. {
  679. return _fnSettingsFromNode( this[_ext.iApiIndex] );
  680. };
  681. /**
  682. * Sort the table by a particular column
  683. * @param {int} iCol the data index to sort on. Note that this will not match the
  684. * 'display index' if you have hidden data entries
  685. * @dtopt API
  686. * @deprecated Since v1.10
  687. *
  688. * @example
  689. * $(document).ready(function() {
  690. * var oTable = $('#example').dataTable();
  691. *
  692. * // Sort immediately with columns 0 and 1
  693. * oTable.fnSort( [ [0,'asc'], [1,'asc'] ] );
  694. * } );
  695. */
  696. this.fnSort = function( aaSort )
  697. {
  698. this.api( true ).order( aaSort ).draw();
  699. };
  700. /**
  701. * Attach a sort listener to an element for a given column
  702. * @param {node} nNode the element to attach the sort listener to
  703. * @param {int} iColumn the column that a click on this node will sort on
  704. * @param {function} [fnCallback] callback function when sort is run
  705. * @dtopt API
  706. * @deprecated Since v1.10
  707. *
  708. * @example
  709. * $(document).ready(function() {
  710. * var oTable = $('#example').dataTable();
  711. *
  712. * // Sort on column 1, when 'sorter' is clicked on
  713. * oTable.fnSortListener( document.getElementById('sorter'), 1 );
  714. * } );
  715. */
  716. this.fnSortListener = function( nNode, iColumn, fnCallback )
  717. {
  718. this.api( true ).order.listener( nNode, iColumn, fnCallback );
  719. };
  720. /**
  721. * Update a table cell or row - this method will accept either a single value to
  722. * update the cell with, an array of values with one element for each column or
  723. * an object in the same format as the original data source. The function is
  724. * self-referencing in order to make the multi column updates easier.
  725. * @param {object|array|string} mData Data to update the cell/row with
  726. * @param {node|int} mRow TR element you want to update or the aoData index
  727. * @param {int} [iColumn] The column to update, give as null or undefined to
  728. * update a whole row.
  729. * @param {bool} [bRedraw=true] Redraw the table or not
  730. * @param {bool} [bAction=true] Perform pre-draw actions or not
  731. * @returns {int} 0 on success, 1 on error
  732. * @dtopt API
  733. * @deprecated Since v1.10
  734. *
  735. * @example
  736. * $(document).ready(function() {
  737. * var oTable = $('#example').dataTable();
  738. * oTable.fnUpdate( 'Example update', 0, 0 ); // Single cell
  739. * oTable.fnUpdate( ['a', 'b', 'c', 'd', 'e'], $('tbody tr')[0] ); // Row
  740. * } );
  741. */
  742. this.fnUpdate = function( mData, mRow, iColumn, bRedraw, bAction )
  743. {
  744. var api = this.api( true );
  745. if ( iColumn === undefined || iColumn === null ) {
  746. api.row( mRow ).data( mData );
  747. }
  748. else {
  749. api.cell( mRow, iColumn ).data( mData );
  750. }
  751. if ( bAction === undefined || bAction ) {
  752. api.columns.adjust();
  753. }
  754. if ( bRedraw === undefined || bRedraw ) {
  755. api.draw();
  756. }
  757. return 0;
  758. };
  759. /**
  760. * Provide a common method for plug-ins to check the version of DataTables being used, in order
  761. * to ensure compatibility.
  762. * @param {string} sVersion Version string to check for, in the format "X.Y.Z". Note that the
  763. * formats "X" and "X.Y" are also acceptable.
  764. * @returns {boolean} true if this version of DataTables is greater or equal to the required
  765. * version, or false if this version of DataTales is not suitable
  766. * @method
  767. * @dtopt API
  768. * @deprecated Since v1.10
  769. *
  770. * @example
  771. * $(document).ready(function() {
  772. * var oTable = $('#example').dataTable();
  773. * alert( oTable.fnVersionCheck( '1.9.0' ) );
  774. * } );
  775. */
  776. this.fnVersionCheck = _ext.fnVersionCheck;
  777. var _that = this;
  778. var emptyInit = options === undefined;
  779. var len = this.length;
  780. if ( emptyInit ) {
  781. options = {};
  782. }
  783. this.oApi = this.internal = _ext.internal;
  784. // Extend with old style plug-in API methods
  785. for ( var fn in DataTable.ext.internal ) {
  786. if ( fn ) {
  787. this[fn] = _fnExternApiFunc(fn);
  788. }
  789. }
  790. this.each(function() {
  791. // For each initialisation we want to give it a clean initialisation
  792. // object that can be bashed around
  793. var o = {};
  794. var oInit = len > 1 ? // optimisation for single table case
  795. _fnExtend( o, options, true ) :
  796. options;
  797. /*global oInit,_that,emptyInit*/
  798. var i=0, iLen, j, jLen, k, kLen;
  799. var sId = this.getAttribute( 'id' );
  800. var bInitHandedOff = false;
  801. var defaults = DataTable.defaults;
  802. var $this = $(this);
  803. /* Sanity check */
  804. if ( this.nodeName.toLowerCase() != 'table' )
  805. {
  806. _fnLog( null, 0, 'Non-table node initialisation ('+this.nodeName+')', 2 );
  807. return;
  808. }
  809. /* Backwards compatibility for the defaults */
  810. _fnCompatOpts( defaults );
  811. _fnCompatCols( defaults.column );
  812. /* Convert the camel-case defaults to Hungarian */
  813. _fnCamelToHungarian( defaults, defaults, true );
  814. _fnCamelToHungarian( defaults.column, defaults.column, true );
  815. /* Setting up the initialisation object */
  816. _fnCamelToHungarian( defaults, $.extend( oInit, $this.data() ), true );
  817. /* Check to see if we are re-initialising a table */
  818. var allSettings = DataTable.settings;
  819. for ( i=0, iLen=allSettings.length ; i<iLen ; i++ )
  820. {
  821. var s = allSettings[i];
  822. /* Base check on table node */
  823. if (
  824. s.nTable == this ||
  825. (s.nTHead && s.nTHead.parentNode == this) ||
  826. (s.nTFoot && s.nTFoot.parentNode == this)
  827. ) {
  828. var bRetrieve = oInit.bRetrieve !== undefined ? oInit.bRetrieve : defaults.bRetrieve;
  829. var bDestroy = oInit.bDestroy !== undefined ? oInit.bDestroy : defaults.bDestroy;
  830. if ( emptyInit || bRetrieve )
  831. {
  832. return s.oInstance;
  833. }
  834. else if ( bDestroy )
  835. {
  836. s.oInstance.fnDestroy();
  837. break;
  838. }
  839. else
  840. {
  841. _fnLog( s, 0, 'Cannot reinitialise DataTable', 3 );
  842. return;
  843. }
  844. }
  845. /* If the element we are initialising has the same ID as a table which was previously
  846. * initialised, but the table nodes don't match (from before) then we destroy the old
  847. * instance by simply deleting it. This is under the assumption that the table has been
  848. * destroyed by other methods. Anyone using non-id selectors will need to do this manually
  849. */
  850. if ( s.sTableId == this.id )
  851. {
  852. allSettings.splice( i, 1 );
  853. break;
  854. }
  855. }
  856. /* Ensure the table has an ID - required for accessibility */
  857. if ( sId === null || sId === "" )
  858. {
  859. sId = "DataTables_Table_"+(DataTable.ext._unique++);
  860. this.id = sId;
  861. }
  862. /* Create the settings object for this table and set some of the default parameters */
  863. var oSettings = $.extend( true, {}, DataTable.models.oSettings, {
  864. "sDestroyWidth": $this[0].style.width,
  865. "sInstance": sId,
  866. "sTableId": sId
  867. } );
  868. oSettings.nTable = this;
  869. oSettings.oApi = _that.internal;
  870. oSettings.oInit = oInit;
  871. allSettings.push( oSettings );
  872. // Need to add the instance after the instance after the settings object has been added
  873. // to the settings array, so we can self reference the table instance if more than one
  874. oSettings.oInstance = (_that.length===1) ? _that : $this.dataTable();
  875. // Backwards compatibility, before we apply all the defaults
  876. _fnCompatOpts( oInit );
  877. _fnLanguageCompat( oInit.oLanguage );
  878. // If the length menu is given, but the init display length is not, use the length menu
  879. if ( oInit.aLengthMenu && ! oInit.iDisplayLength )
  880. {
  881. oInit.iDisplayLength = $.isArray( oInit.aLengthMenu[0] ) ?
  882. oInit.aLengthMenu[0][0] : oInit.aLengthMenu[0];
  883. }
  884. // Apply the defaults and init options to make a single init object will all
  885. // options defined from defaults and instance options.
  886. oInit = _fnExtend( $.extend( true, {}, defaults ), oInit );
  887. // Map the initialisation options onto the settings object
  888. _fnMap( oSettings.oFeatures, oInit, [
  889. "bPaginate",
  890. "bLengthChange",
  891. "bFilter",
  892. "bSort",
  893. "bSortMulti",
  894. "bInfo",
  895. "bProcessing",
  896. "bAutoWidth",
  897. "bSortClasses",
  898. "bServerSide",
  899. "bDeferRender"
  900. ] );
  901. _fnMap( oSettings, oInit, [
  902. "asStripeClasses",
  903. "ajax",
  904. "fnServerData",
  905. "fnFormatNumber",
  906. "sServerMethod",
  907. "aaSorting",
  908. "aaSortingFixed",
  909. "aLengthMenu",
  910. "sPaginationType",
  911. "sAjaxSource",
  912. "sAjaxDataProp",
  913. "iStateDuration",
  914. "sDom",
  915. "bSortCellsTop",
  916. "iTabIndex",
  917. "fnStateLoadCallback",
  918. "fnStateSaveCallback",
  919. "renderer",
  920. "searchDelay",
  921. "rowId",
  922. [ "iCookieDuration", "iStateDuration" ], // backwards compat
  923. [ "oSearch", "oPreviousSearch" ],
  924. [ "aoSearchCols", "aoPreSearchCols" ],
  925. [ "iDisplayLength", "_iDisplayLength" ]
  926. ] );
  927. _fnMap( oSettings.oScroll, oInit, [
  928. [ "sScrollX", "sX" ],
  929. [ "sScrollXInner", "sXInner" ],
  930. [ "sScrollY", "sY" ],
  931. [ "bScrollCollapse", "bCollapse" ]
  932. ] );
  933. _fnMap( oSettings.oLanguage, oInit, "fnInfoCallback" );
  934. /* Callback functions which are array driven */
  935. _fnCallbackReg( oSettings, 'aoDrawCallback', oInit.fnDrawCallback, 'user' );
  936. _fnCallbackReg( oSettings, 'aoServerParams', oInit.fnServerParams, 'user' );
  937. _fnCallbackReg( oSettings, 'aoStateSaveParams', oInit.fnStateSaveParams, 'user' );
  938. _fnCallbackReg( oSettings, 'aoStateLoadParams', oInit.fnStateLoadParams, 'user' );
  939. _fnCallbackReg( oSettings, 'aoStateLoaded', oInit.fnStateLoaded, 'user' );
  940. _fnCallbackReg( oSettings, 'aoRowCallback', oInit.fnRowCallback, 'user' );
  941. _fnCallbackReg( oSettings, 'aoRowCreatedCallback', oInit.fnCreatedRow, 'user' );
  942. _fnCallbackReg( oSettings, 'aoHeaderCallback', oInit.fnHeaderCallback, 'user' );
  943. _fnCallbackReg( oSettings, 'aoFooterCallback', oInit.fnFooterCallback, 'user' );
  944. _fnCallbackReg( oSettings, 'aoInitComplete', oInit.fnInitComplete, 'user' );
  945. _fnCallbackReg( oSettings, 'aoPreDrawCallback', oInit.fnPreDrawCallback, 'user' );
  946. oSettings.rowIdFn = _fnGetObjectDataFn( oInit.rowId );
  947. /* Browser support detection */
  948. _fnBrowserDetect( oSettings );
  949. var oClasses = oSettings.oClasses;
  950. $.extend( oClasses, DataTable.ext.classes, oInit.oClasses );
  951. $this.addClass( oClasses.sTable );
  952. if ( oSettings.iInitDisplayStart === undefined )
  953. {
  954. /* Display start point, taking into account the save saving */
  955. oSettings.iInitDisplayStart = oInit.iDisplayStart;
  956. oSettings._iDisplayStart = oInit.iDisplayStart;
  957. }
  958. if ( oInit.iDeferLoading !== null )
  959. {
  960. oSettings.bDeferLoading = true;
  961. var tmp = $.isArray( oInit.iDeferLoading );
  962. oSettings._iRecordsDisplay = tmp ? oInit.iDeferLoading[0] : oInit.iDeferLoading;
  963. oSettings._iRecordsTotal = tmp ? oInit.iDeferLoading[1] : oInit.iDeferLoading;
  964. }
  965. /* Language definitions */
  966. var oLanguage = oSettings.oLanguage;
  967. $.extend( true, oLanguage, oInit.oLanguage );
  968. if ( oLanguage.sUrl )
  969. {
  970. /* Get the language definitions from a file - because this Ajax call makes the language
  971. * get async to the remainder of this function we use bInitHandedOff to indicate that
  972. * _fnInitialise will be fired by the returned Ajax handler, rather than the constructor
  973. */
  974. $.ajax( {
  975. dataType: 'json',
  976. url: oLanguage.sUrl,
  977. success: function ( json ) {
  978. _fnLanguageCompat( json );
  979. _fnCamelToHungarian( defaults.oLanguage, json );
  980. $.extend( true, oLanguage, json );
  981. _fnInitialise( oSettings );
  982. },
  983. error: function () {
  984. // Error occurred loading language file, continue on as best we can
  985. _fnInitialise( oSettings );
  986. }
  987. } );
  988. bInitHandedOff = true;
  989. }
  990. /*
  991. * Stripes
  992. */
  993. if ( oInit.asStripeClasses === null )
  994. {
  995. oSettings.asStripeClasses =[
  996. oClasses.sStripeOdd,
  997. oClasses.sStripeEven
  998. ];
  999. }
  1000. /* Remove row stripe classes if they are already on the table row */
  1001. var stripeClasses = oSettings.asStripeClasses;
  1002. var rowOne = $this.children('tbody').find('tr').eq(0);
  1003. if ( $.inArray( true, $.map( stripeClasses, function(el, i) {
  1004. return rowOne.hasClass(el);
  1005. } ) ) !== -1 ) {
  1006. $('tbody tr', this).removeClass( stripeClasses.join(' ') );
  1007. oSettings.asDestroyStripes = stripeClasses.slice();
  1008. }
  1009. /*
  1010. * Columns
  1011. * See if we should load columns automatically or use defined ones
  1012. */
  1013. var anThs = [];
  1014. var aoColumnsInit;
  1015. var nThead = this.getElementsByTagName('thead');
  1016. if ( nThead.length !== 0 )
  1017. {
  1018. _fnDetectHeader( oSettings.aoHeader, nThead[0] );
  1019. anThs = _fnGetUniqueThs( oSettings );
  1020. }
  1021. /* If not given a column array, generate one with nulls */
  1022. if ( oInit.aoColumns === null )
  1023. {
  1024. aoColumnsInit = [];
  1025. for ( i=0, iLen=anThs.length ; i<iLen ; i++ )
  1026. {
  1027. aoColumnsInit.push( null );
  1028. }
  1029. }
  1030. else
  1031. {
  1032. aoColumnsInit = oInit.aoColumns;
  1033. }
  1034. /* Add the columns */
  1035. for ( i=0, iLen=aoColumnsInit.length ; i<iLen ; i++ )
  1036. {
  1037. _fnAddColumn( oSettings, anThs ? anThs[i] : null );
  1038. }
  1039. /* Apply the column definitions */
  1040. _fnApplyColumnDefs( oSettings, oInit.aoColumnDefs, aoColumnsInit, function (iCol, oDef) {
  1041. _fnColumnOptions( oSettings, iCol, oDef );
  1042. } );
  1043. /* HTML5 attribute detection - build an mData object automatically if the
  1044. * attributes are found
  1045. */
  1046. if ( rowOne.length ) {
  1047. var a = function ( cell, name ) {
  1048. return cell.getAttribute( 'data-'+name ) !== null ? name : null;
  1049. };
  1050. $( rowOne[0] ).children('th, td').each( function (i, cell) {
  1051. var col = oSettings.aoColumns[i];
  1052. if ( col.mData === i ) {
  1053. var sort = a( cell, 'sort' ) || a( cell, 'order' );
  1054. var filter = a( cell, 'filter' ) || a( cell, 'search' );
  1055. if ( sort !== null || filter !== null ) {
  1056. col.mData = {
  1057. _: i+'.display',
  1058. sort: sort !== null ? i+'.@data-'+sort : undefined,
  1059. type: sort !== null ? i+'.@data-'+sort : undefined,
  1060. filter: filter !== null ? i+'.@data-'+filter : undefined
  1061. };
  1062. _fnColumnOptions( oSettings, i );
  1063. }
  1064. }
  1065. } );
  1066. }
  1067. var features = oSettings.oFeatures;
  1068. var loadedInit = function () {
  1069. /*
  1070. * Sorting
  1071. * @todo For modularisation (1.11) this needs to do into a sort start up handler
  1072. */
  1073. // If aaSorting is not defined, then we use the first indicator in asSorting
  1074. // in case that has been altered, so the default sort reflects that option
  1075. if ( oInit.aaSorting === undefined ) {
  1076. var sorting = oSettings.aaSorting;
  1077. for ( i=0, iLen=sorting.length ; i<iLen ; i++ ) {
  1078. sorting[i][1] = oSettings.aoColumns[ i ].asSorting[0];
  1079. }
  1080. }
  1081. /* Do a first pass on the sorting classes (allows any size changes to be taken into
  1082. * account, and also will apply sorting disabled classes if disabled
  1083. */
  1084. _fnSortingClasses( oSettings );
  1085. if ( features.bSort ) {
  1086. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  1087. if ( oSettings.bSorted ) {
  1088. var aSort = _fnSortFlatten( oSettings );
  1089. var sortedColumns = {};
  1090. $.each( aSort, function (i, val) {
  1091. sortedColumns[ val.src ] = val.dir;
  1092. } );
  1093. _fnCallbackFire( oSettings, null, 'order', [oSettings, aSort, sortedColumns] );
  1094. _fnSortAria( oSettings );
  1095. }
  1096. } );
  1097. }
  1098. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  1099. if ( oSettings.bSorted || _fnDataSource( oSettings ) === 'ssp' || features.bDeferRender ) {
  1100. _fnSortingClasses( oSettings );
  1101. }
  1102. }, 'sc' );
  1103. /*
  1104. * Final init
  1105. * Cache the header, body and footer as required, creating them if needed
  1106. */
  1107. // Work around for Webkit bug 83867 - store the caption-side before removing from doc
  1108. var captions = $this.children('caption').each( function () {
  1109. this._captionSide = $(this).css('caption-side');
  1110. } );
  1111. var thead = $this.children('thead');
  1112. if ( thead.length === 0 ) {
  1113. thead = $('<thead/>').appendTo($this);
  1114. }
  1115. oSettings.nTHead = thead[0];
  1116. var tbody = $this.children('tbody');
  1117. if ( tbody.length === 0 ) {
  1118. tbody = $('<tbody/>').appendTo($this);
  1119. }
  1120. oSettings.nTBody = tbody[0];
  1121. var tfoot = $this.children('tfoot');
  1122. if ( tfoot.length === 0 && captions.length > 0 && (oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "") ) {
  1123. // If we are a scrolling table, and no footer has been given, then we need to create
  1124. // a tfoot element for the caption element to be appended to
  1125. tfoot = $('<tfoot/>').appendTo($this);
  1126. }
  1127. if ( tfoot.length === 0 || tfoot.children().length === 0 ) {
  1128. $this.addClass( oClasses.sNoFooter );
  1129. }
  1130. else if ( tfoot.length > 0 ) {
  1131. oSettings.nTFoot = tfoot[0];
  1132. _fnDetectHeader( oSettings.aoFooter, oSettings.nTFoot );
  1133. }
  1134. /* Check if there is data passing into the constructor */
  1135. if ( oInit.aaData ) {
  1136. for ( i=0 ; i<oInit.aaData.length ; i++ ) {
  1137. _fnAddData( oSettings, oInit.aaData[ i ] );
  1138. }
  1139. }
  1140. else if ( oSettings.bDeferLoading || _fnDataSource( oSettings ) == 'dom' ) {
  1141. /* Grab the data from the page - only do this when deferred loading or no Ajax
  1142. * source since there is no point in reading the DOM data if we are then going
  1143. * to replace it with Ajax data
  1144. */
  1145. _fnAddTr( oSettings, $(oSettings.nTBody).children('tr') );
  1146. }
  1147. /* Copy the data index array */
  1148. oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
  1149. /* Initialisation complete - table can be drawn */
  1150. oSettings.bInitialised = true;
  1151. /* Check if we need to initialise the table (it might not have been handed off to the
  1152. * language processor)
  1153. */
  1154. if ( bInitHandedOff === false ) {
  1155. _fnInitialise( oSettings );
  1156. }
  1157. };
  1158. /* Must be done after everything which can be overridden by the state saving! */
  1159. if ( oInit.bStateSave )
  1160. {
  1161. features.bStateSave = true;
  1162. _fnCallbackReg( oSettings, 'aoDrawCallback', _fnSaveState, 'state_save' );
  1163. _fnLoadState( oSettings, oInit, loadedInit );
  1164. }
  1165. else {
  1166. loadedInit();
  1167. }
  1168. } );
  1169. _that = null;
  1170. return this;
  1171. };
  1172. /*
  1173. * It is useful to have variables which are scoped locally so only the
  1174. * DataTables functions can access them and they don't leak into global space.
  1175. * At the same time these functions are often useful over multiple files in the
  1176. * core and API, so we list, or at least document, all variables which are used
  1177. * by DataTables as private variables here. This also ensures that there is no
  1178. * clashing of variable names and that they can easily referenced for reuse.
  1179. */
  1180. // Defined else where
  1181. // _selector_run
  1182. // _selector_opts
  1183. // _selector_first
  1184. // _selector_row_indexes
  1185. var _ext; // DataTable.ext
  1186. var _Api; // DataTable.Api
  1187. var _api_register; // DataTable.Api.register
  1188. var _api_registerPlural; // DataTable.Api.registerPlural
  1189. var _re_dic = {};
  1190. var _re_new_lines = /[\r\n\u2028]/g;
  1191. var _re_html = /<.*?>/g;
  1192. // This is not strict ISO8601 - Date.parse() is quite lax, although
  1193. // implementations differ between browsers.
  1194. var _re_date = /^\d{2,4}[\.\/\-]\d{1,2}[\.\/\-]\d{1,2}([T ]{1}\d{1,2}[:\.]\d{2}([\.:]\d{2})?)?$/;
  1195. // Escape regular expression special characters
  1196. var _re_escape_regex = new RegExp( '(\\' + [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^', '-' ].join('|\\') + ')', 'g' );
  1197. // http://en.wikipedia.org/wiki/Foreign_exchange_market
  1198. // - \u20BD - Russian ruble.
  1199. // - \u20a9 - South Korean Won
  1200. // - \u20BA - Turkish Lira
  1201. // - \u20B9 - Indian Rupee
  1202. // - R - Brazil (R$) and South Africa
  1203. // - fr - Swiss Franc
  1204. // - kr - Swedish krona, Norwegian krone and Danish krone
  1205. // - \u2009 is thin space and \u202F is narrow no-break space, both used in many
  1206. // - Ƀ - Bitcoin
  1207. // - Ξ - Ethereum
  1208. // standards as thousands separators.
  1209. var _re_formatted_numeric = /[',$£€¥%\u2009\u202F\u20BD\u20a9\u20BArfkɃΞ]/gi;
  1210. var _empty = function ( d ) {
  1211. return !d || d === true || d === '-' ? true : false;
  1212. };
  1213. var _intVal = function ( s ) {
  1214. var integer = parseInt( s, 10 );
  1215. return !isNaN(integer) && isFinite(s) ? integer : null;
  1216. };
  1217. // Convert from a formatted number with characters other than `.` as the
  1218. // decimal place, to a Javascript number
  1219. var _numToDecimal = function ( num, decimalPoint ) {
  1220. // Cache created regular expressions for speed as this function is called often
  1221. if ( ! _re_dic[ decimalPoint ] ) {
  1222. _re_dic[ decimalPoint ] = new RegExp( _fnEscapeRegex( decimalPoint ), 'g' );
  1223. }
  1224. return typeof num === 'string' && decimalPoint !== '.' ?
  1225. num.replace( /\./g, '' ).replace( _re_dic[ decimalPoint ], '.' ) :
  1226. num;
  1227. };
  1228. var _isNumber = function ( d, decimalPoint, formatted ) {
  1229. var strType = typeof d === 'string';
  1230. // If empty return immediately so there must be a number if it is a
  1231. // formatted string (this stops the string "k", or "kr", etc being detected
  1232. // as a formatted number for currency
  1233. if ( _empty( d ) ) {
  1234. return true;
  1235. }
  1236. if ( decimalPoint && strType ) {
  1237. d = _numToDecimal( d, decimalPoint );
  1238. }
  1239. if ( formatted && strType ) {
  1240. d = d.replace( _re_formatted_numeric, '' );
  1241. }
  1242. return !isNaN( parseFloat(d) ) && isFinite( d );
  1243. };
  1244. // A string without HTML in it can be considered to be HTML still
  1245. var _isHtml = function ( d ) {
  1246. return _empty( d ) || typeof d === 'string';
  1247. };
  1248. var _htmlNumeric = function ( d, decimalPoint, formatted ) {
  1249. if ( _empty( d ) ) {
  1250. return true;
  1251. }
  1252. var html = _isHtml( d );
  1253. return ! html ?
  1254. null :
  1255. _isNumber( _stripHtml( d ), decimalPoint, formatted ) ?
  1256. true :
  1257. null;
  1258. };
  1259. var _pluck = function ( a, prop, prop2 ) {
  1260. var out = [];
  1261. var i=0, ien=a.length;
  1262. // Could have the test in the loop for slightly smaller code, but speed
  1263. // is essential here
  1264. if ( prop2 !== undefined ) {
  1265. for ( ; i<ien ; i++ ) {
  1266. if ( a[i] && a[i][ prop ] ) {
  1267. out.push( a[i][ prop ][ prop2 ] );
  1268. }
  1269. }
  1270. }
  1271. else {
  1272. for ( ; i<ien ; i++ ) {
  1273. if ( a[i] ) {
  1274. out.push( a[i][ prop ] );
  1275. }
  1276. }
  1277. }
  1278. return out;
  1279. };
  1280. // Basically the same as _pluck, but rather than looping over `a` we use `order`
  1281. // as the indexes to pick from `a`
  1282. var _pluck_order = function ( a, order, prop, prop2 )
  1283. {
  1284. var out = [];
  1285. var i=0, ien=order.length;
  1286. // Could have the test in the loop for slightly smaller code, but speed
  1287. // is essential here
  1288. if ( prop2 !== undefined ) {
  1289. for ( ; i<ien ; i++ ) {
  1290. if ( a[ order[i] ][ prop ] ) {
  1291. out.push( a[ order[i] ][ prop ][ prop2 ] );
  1292. }
  1293. }
  1294. }
  1295. else {
  1296. for ( ; i<ien ; i++ ) {
  1297. out.push( a[ order[i] ][ prop ] );
  1298. }
  1299. }
  1300. return out;
  1301. };
  1302. var _range = function ( len, start )
  1303. {
  1304. var out = [];
  1305. var end;
  1306. if ( start === undefined ) {
  1307. start = 0;
  1308. end = len;
  1309. }
  1310. else {
  1311. end = start;
  1312. start = len;
  1313. }
  1314. for ( var i=start ; i<end ; i++ ) {
  1315. out.push( i );
  1316. }
  1317. return out;
  1318. };
  1319. var _removeEmpty = function ( a )
  1320. {
  1321. var out = [];
  1322. for ( var i=0, ien=a.length ; i<ien ; i++ ) {
  1323. if ( a[i] ) { // careful - will remove all falsy values!
  1324. out.push( a[i] );
  1325. }
  1326. }
  1327. return out;
  1328. };
  1329. var _stripHtml = function ( d ) {
  1330. return d.replace( _re_html, '' );
  1331. };
  1332. /**
  1333. * Determine if all values in the array are unique. This means we can short
  1334. * cut the _unique method at the cost of a single loop. A sorted array is used
  1335. * to easily check the values.
  1336. *
  1337. * @param {array} src Source array
  1338. * @return {boolean} true if all unique, false otherwise
  1339. * @ignore
  1340. */
  1341. var _areAllUnique = function ( src ) {
  1342. if ( src.length < 2 ) {
  1343. return true;
  1344. }
  1345. var sorted = src.slice().sort();
  1346. var last = sorted[0];
  1347. for ( var i=1, ien=sorted.length ; i<ien ; i++ ) {
  1348. if ( sorted[i] === last ) {
  1349. return false;
  1350. }
  1351. last = sorted[i];
  1352. }
  1353. return true;
  1354. };
  1355. /**
  1356. * Find the unique elements in a source array.
  1357. *
  1358. * @param {array} src Source array
  1359. * @return {array} Array of unique items
  1360. * @ignore
  1361. */
  1362. var _unique = function ( src )
  1363. {
  1364. if ( _areAllUnique( src ) ) {
  1365. return src.slice();
  1366. }
  1367. // A faster unique method is to use object keys to identify used values,
  1368. // but this doesn't work with arrays or objects, which we must also
  1369. // consider. See jsperf.com/compare-array-unique-versions/4 for more
  1370. // information.
  1371. var
  1372. out = [],
  1373. val,
  1374. i, ien=src.length,
  1375. j, k=0;
  1376. again: for ( i=0 ; i<ien ; i++ ) {
  1377. val = src[i];
  1378. for ( j=0 ; j<k ; j++ ) {
  1379. if ( out[j] === val ) {
  1380. continue again;
  1381. }
  1382. }
  1383. out.push( val );
  1384. k++;
  1385. }
  1386. return out;
  1387. };
  1388. /**
  1389. * DataTables utility methods
  1390. *
  1391. * This namespace provides helper methods that DataTables uses internally to
  1392. * create a DataTable, but which are not exclusively used only for DataTables.
  1393. * These methods can be used by extension authors to save the duplication of
  1394. * code.
  1395. *
  1396. * @namespace
  1397. */
  1398. DataTable.util = {
  1399. /**
  1400. * Throttle the calls to a function. Arguments and context are maintained
  1401. * for the throttled function.
  1402. *
  1403. * @param {function} fn Function to be called
  1404. * @param {integer} freq Call frequency in mS
  1405. * @return {function} Wrapped function
  1406. */
  1407. throttle: function ( fn, freq ) {
  1408. var
  1409. frequency = freq !== undefined ? freq : 200,
  1410. last,
  1411. timer;
  1412. return function () {
  1413. var
  1414. that = this,
  1415. now = +new Date(),
  1416. args = arguments;
  1417. if ( last && now < last + frequency ) {
  1418. clearTimeout( timer );
  1419. timer = setTimeout( function () {
  1420. last = undefined;
  1421. fn.apply( that, args );
  1422. }, frequency );
  1423. }
  1424. else {
  1425. last = now;
  1426. fn.apply( that, args );
  1427. }
  1428. };
  1429. },
  1430. /**
  1431. * Escape a string such that it can be used in a regular expression
  1432. *
  1433. * @param {string} val string to escape
  1434. * @returns {string} escaped string
  1435. */
  1436. escapeRegex: function ( val ) {
  1437. return val.replace( _re_escape_regex, '\\$1' );
  1438. }
  1439. };
  1440. /**
  1441. * Create a mapping object that allows camel case parameters to be looked up
  1442. * for their Hungarian counterparts. The mapping is stored in a private
  1443. * parameter called `_hungarianMap` which can be accessed on the source object.
  1444. * @param {object} o
  1445. * @memberof DataTable#oApi
  1446. */
  1447. function _fnHungarianMap ( o )
  1448. {
  1449. var
  1450. hungarian = 'a aa ai ao as b fn i m o s ',
  1451. match,
  1452. newKey,
  1453. map = {};
  1454. $.each( o, function (key, val) {
  1455. match = key.match(/^([^A-Z]+?)([A-Z])/);
  1456. if ( match && hungarian.indexOf(match[1]+' ') !== -1 )
  1457. {
  1458. newKey = key.replace( match[0], match[2].toLowerCase() );
  1459. map[ newKey ] = key;
  1460. if ( match[1] === 'o' )
  1461. {
  1462. _fnHungarianMap( o[key] );
  1463. }
  1464. }
  1465. } );
  1466. o._hungarianMap = map;
  1467. }
  1468. /**
  1469. * Convert from camel case parameters to Hungarian, based on a Hungarian map
  1470. * created by _fnHungarianMap.
  1471. * @param {object} src The model object which holds all parameters that can be
  1472. * mapped.
  1473. * @param {object} user The object to convert from camel case to Hungarian.
  1474. * @param {boolean} force When set to `true`, properties which already have a
  1475. * Hungarian value in the `user` object will be overwritten. Otherwise they
  1476. * won't be.
  1477. * @memberof DataTable#oApi
  1478. */
  1479. function _fnCamelToHungarian ( src, user, force )
  1480. {
  1481. if ( ! src._hungarianMap ) {
  1482. _fnHungarianMap( src );
  1483. }
  1484. var hungarianKey;
  1485. $.each( user, function (key, val) {
  1486. hungarianKey = src._hungarianMap[ key ];
  1487. if ( hungarianKey !== undefined && (force || user[hungarianKey] === undefined) )
  1488. {
  1489. // For objects, we need to buzz down into the object to copy parameters
  1490. if ( hungarianKey.charAt(0) === 'o' )
  1491. {
  1492. // Copy the camelCase options over to the hungarian
  1493. if ( ! user[ hungarianKey ] ) {
  1494. user[ hungarianKey ] = {};
  1495. }
  1496. $.extend( true, user[hungarianKey], user[key] );
  1497. _fnCamelToHungarian( src[hungarianKey], user[hungarianKey], force );
  1498. }
  1499. else {
  1500. user[hungarianKey] = user[ key ];
  1501. }
  1502. }
  1503. } );
  1504. }
  1505. /**
  1506. * Language compatibility - when certain options are given, and others aren't, we
  1507. * need to duplicate the values over, in order to provide backwards compatibility
  1508. * with older language files.
  1509. * @param {object} oSettings dataTables settings object
  1510. * @memberof DataTable#oApi
  1511. */
  1512. function _fnLanguageCompat( lang )
  1513. {
  1514. // Note the use of the Hungarian notation for the parameters in this method as
  1515. // this is called after the mapping of camelCase to Hungarian
  1516. var defaults = DataTable.defaults.oLanguage;
  1517. // Default mapping
  1518. var defaultDecimal = defaults.sDecimal;
  1519. if ( defaultDecimal ) {
  1520. _addNumericSort( defaultDecimal );
  1521. }
  1522. if ( lang ) {
  1523. var zeroRecords = lang.sZeroRecords;
  1524. // Backwards compatibility - if there is no sEmptyTable given, then use the same as
  1525. // sZeroRecords - assuming that is given.
  1526. if ( ! lang.sEmptyTable && zeroRecords &&
  1527. defaults.sEmptyTable === "No data available in table" )
  1528. {
  1529. _fnMap( lang, lang, 'sZeroRecords', 'sEmptyTable' );
  1530. }
  1531. // Likewise with loading records
  1532. if ( ! lang.sLoadingRecords && zeroRecords &&
  1533. defaults.sLoadingRecords === "Loading..." )
  1534. {
  1535. _fnMap( lang, lang, 'sZeroRecords', 'sLoadingRecords' );
  1536. }
  1537. // Old parameter name of the thousands separator mapped onto the new
  1538. if ( lang.sInfoThousands ) {
  1539. lang.sThousands = lang.sInfoThousands;
  1540. }
  1541. var decimal = lang.sDecimal;
  1542. if ( decimal && defaultDecimal !== decimal ) {
  1543. _addNumericSort( decimal );
  1544. }
  1545. }
  1546. }
  1547. /**
  1548. * Map one parameter onto another
  1549. * @param {object} o Object to map
  1550. * @param {*} knew The new parameter name
  1551. * @param {*} old The old parameter name
  1552. */
  1553. var _fnCompatMap = function ( o, knew, old ) {
  1554. if ( o[ knew ] !== undefined ) {
  1555. o[ old ] = o[ knew ];
  1556. }
  1557. };
  1558. /**
  1559. * Provide backwards compatibility for the main DT options. Note that the new
  1560. * options are mapped onto the old parameters, so this is an external interface
  1561. * change only.
  1562. * @param {object} init Object to map
  1563. */
  1564. function _fnCompatOpts ( init )
  1565. {
  1566. _fnCompatMap( init, 'ordering', 'bSort' );
  1567. _fnCompatMap( init, 'orderMulti', 'bSortMulti' );
  1568. _fnCompatMap( init, 'orderClasses', 'bSortClasses' );
  1569. _fnCompatMap( init, 'orderCellsTop', 'bSortCellsTop' );
  1570. _fnCompatMap( init, 'order', 'aaSorting' );
  1571. _fnCompatMap( init, 'orderFixed', 'aaSortingFixed' );
  1572. _fnCompatMap( init, 'paging', 'bPaginate' );
  1573. _fnCompatMap( init, 'pagingType', 'sPaginationType' );
  1574. _fnCompatMap( init, 'pageLength', 'iDisplayLength' );
  1575. _fnCompatMap( init, 'searching', 'bFilter' );
  1576. // Boolean initialisation of x-scrolling
  1577. if ( typeof init.sScrollX === 'boolean' ) {
  1578. init.sScrollX = init.sScrollX ? '100%' : '';
  1579. }
  1580. if ( typeof init.scrollX === 'boolean' ) {
  1581. init.scrollX = init.scrollX ? '100%' : '';
  1582. }
  1583. // Column search objects are in an array, so it needs to be converted
  1584. // element by element
  1585. var searchCols = init.aoSearchCols;
  1586. if ( searchCols ) {
  1587. for ( var i=0, ien=searchCols.length ; i<ien ; i++ ) {
  1588. if ( searchCols[i] ) {
  1589. _fnCamelToHungarian( DataTable.models.oSearch, searchCols[i] );
  1590. }
  1591. }
  1592. }
  1593. }
  1594. /**
  1595. * Provide backwards compatibility for column options. Note that the new options
  1596. * are mapped onto the old parameters, so this is an external interface change
  1597. * only.
  1598. * @param {object} init Object to map
  1599. */
  1600. function _fnCompatCols ( init )
  1601. {
  1602. _fnCompatMap( init, 'orderable', 'bSortable' );
  1603. _fnCompatMap( init, 'orderData', 'aDataSort' );
  1604. _fnCompatMap( init, 'orderSequence', 'asSorting' );
  1605. _fnCompatMap( init, 'orderDataType', 'sortDataType' );
  1606. // orderData can be given as an integer
  1607. var dataSort = init.aDataSort;
  1608. if ( typeof dataSort === 'number' && ! $.isArray( dataSort ) ) {
  1609. init.aDataSort = [ dataSort ];
  1610. }
  1611. }
  1612. /**
  1613. * Browser feature detection for capabilities, quirks
  1614. * @param {object} settings dataTables settings object
  1615. * @memberof DataTable#oApi
  1616. */
  1617. function _fnBrowserDetect( settings )
  1618. {
  1619. // We don't need to do this every time DataTables is constructed, the values
  1620. // calculated are specific to the browser and OS configuration which we
  1621. // don't expect to change between initialisations
  1622. if ( ! DataTable.__browser ) {
  1623. var browser = {};
  1624. DataTable.__browser = browser;
  1625. // Scrolling feature / quirks detection
  1626. var n = $('<div/>')
  1627. .css( {
  1628. position: 'fixed',
  1629. top: 0,
  1630. left: $(window).scrollLeft()*-1, // allow for scrolling
  1631. height: 1,
  1632. width: 1,
  1633. overflow: 'hidden'
  1634. } )
  1635. .append(
  1636. $('<div/>')
  1637. .css( {
  1638. position: 'absolute',
  1639. top: 1,
  1640. left: 1,
  1641. width: 100,
  1642. overflow: 'scroll'
  1643. } )
  1644. .append(
  1645. $('<div/>')
  1646. .css( {
  1647. width: '100%',
  1648. height: 10
  1649. } )
  1650. )
  1651. )
  1652. .appendTo( 'body' );
  1653. var outer = n.children();
  1654. var inner = outer.children();
  1655. // Numbers below, in order, are:
  1656. // inner.offsetWidth, inner.clientWidth, outer.offsetWidth, outer.clientWidth
  1657. //
  1658. // IE6 XP: 100 100 100 83
  1659. // IE7 Vista: 100 100 100 83
  1660. // IE 8+ Windows: 83 83 100 83
  1661. // Evergreen Windows: 83 83 100 83
  1662. // Evergreen Mac with scrollbars: 85 85 100 85
  1663. // Evergreen Mac without scrollbars: 100 100 100 100
  1664. // Get scrollbar width
  1665. browser.barWidth = outer[0].offsetWidth - outer[0].clientWidth;
  1666. // IE6/7 will oversize a width 100% element inside a scrolling element, to
  1667. // include the width of the scrollbar, while other browsers ensure the inner
  1668. // element is contained without forcing scrolling
  1669. browser.bScrollOversize = inner[0].offsetWidth === 100 && outer[0].clientWidth !== 100;
  1670. // In rtl text layout, some browsers (most, but not all) will place the
  1671. // scrollbar on the left, rather than the right.
  1672. browser.bScrollbarLeft = Math.round( inner.offset().left ) !== 1;
  1673. // IE8- don't provide height and width for getBoundingClientRect
  1674. browser.bBounding = n[0].getBoundingClientRect().width ? true : false;
  1675. n.remove();
  1676. }
  1677. $.extend( settings.oBrowser, DataTable.__browser );
  1678. settings.oScroll.iBarWidth = DataTable.__browser.barWidth;
  1679. }
  1680. /**
  1681. * Array.prototype reduce[Right] method, used for browsers which don't support
  1682. * JS 1.6. Done this way to reduce code size, since we iterate either way
  1683. * @param {object} settings dataTables settings object
  1684. * @memberof DataTable#oApi
  1685. */
  1686. function _fnReduce ( that, fn, init, start, end, inc )
  1687. {
  1688. var
  1689. i = start,
  1690. value,
  1691. isSet = false;
  1692. if ( init !== undefined ) {
  1693. value = init;
  1694. isSet = true;
  1695. }
  1696. while ( i !== end ) {
  1697. if ( ! that.hasOwnProperty(i) ) {
  1698. continue;
  1699. }
  1700. value = isSet ?
  1701. fn( value, that[i], i, that ) :
  1702. that[i];
  1703. isSet = true;
  1704. i += inc;
  1705. }
  1706. return value;
  1707. }
  1708. /**
  1709. * Add a column to the list used for the table with default values
  1710. * @param {object} oSettings dataTables settings object
  1711. * @param {node} nTh The th element for this column
  1712. * @memberof DataTable#oApi
  1713. */
  1714. function _fnAddColumn( oSettings, nTh )
  1715. {
  1716. // Add column to aoColumns array
  1717. var oDefaults = DataTable.defaults.column;
  1718. var iCol = oSettings.aoColumns.length;
  1719. var oCol = $.extend( {}, DataTable.models.oColumn, oDefaults, {
  1720. "nTh": nTh ? nTh : document.createElement('th'),
  1721. "sTitle": oDefaults.sTitle ? oDefaults.sTitle : nTh ? nTh.innerHTML : '',
  1722. "aDataSort": oDefaults.aDataSort ? oDefaults.aDataSort : [iCol],
  1723. "mData": oDefaults.mData ? oDefaults.mData : iCol,
  1724. idx: iCol
  1725. } );
  1726. oSettings.aoColumns.push( oCol );
  1727. // Add search object for column specific search. Note that the `searchCols[ iCol ]`
  1728. // passed into extend can be undefined. This allows the user to give a default
  1729. // with only some of the parameters defined, and also not give a default
  1730. var searchCols = oSettings.aoPreSearchCols;
  1731. searchCols[ iCol ] = $.extend( {}, DataTable.models.oSearch, searchCols[ iCol ] );
  1732. // Use the default column options function to initialise classes etc
  1733. _fnColumnOptions( oSettings, iCol, $(nTh).data() );
  1734. }
  1735. /**
  1736. * Apply options for a column
  1737. * @param {object} oSettings dataTables settings object
  1738. * @param {int} iCol column index to consider
  1739. * @param {object} oOptions object with sType, bVisible and bSearchable etc
  1740. * @memberof DataTable#oApi
  1741. */
  1742. function _fnColumnOptions( oSettings, iCol, oOptions )
  1743. {
  1744. var oCol = oSettings.aoColumns[ iCol ];
  1745. var oClasses = oSettings.oClasses;
  1746. var th = $(oCol.nTh);
  1747. // Try to get width information from the DOM. We can't get it from CSS
  1748. // as we'd need to parse the CSS stylesheet. `width` option can override
  1749. if ( ! oCol.sWidthOrig ) {
  1750. // Width attribute
  1751. oCol.sWidthOrig = th.attr('width') || null;
  1752. // Style attribute
  1753. var t = (th.attr('style') || '').match(/width:\s*(\d+[pxem%]+)/);
  1754. if ( t ) {
  1755. oCol.sWidthOrig = t[1];
  1756. }
  1757. }
  1758. /* User specified column options */
  1759. if ( oOptions !== undefined && oOptions !== null )
  1760. {
  1761. // Backwards compatibility
  1762. _fnCompatCols( oOptions );
  1763. // Map camel case parameters to their Hungarian counterparts
  1764. _fnCamelToHungarian( DataTable.defaults.column, oOptions, true );
  1765. /* Backwards compatibility for mDataProp */
  1766. if ( oOptions.mDataProp !== undefined && !oOptions.mData )
  1767. {
  1768. oOptions.mData = oOptions.mDataProp;
  1769. }
  1770. if ( oOptions.sType )
  1771. {
  1772. oCol._sManualType = oOptions.sType;
  1773. }
  1774. // `class` is a reserved word in Javascript, so we need to provide
  1775. // the ability to use a valid name for the camel case input
  1776. if ( oOptions.className && ! oOptions.sClass )
  1777. {
  1778. oOptions.sClass = oOptions.className;
  1779. }
  1780. if ( oOptions.sClass ) {
  1781. th.addClass( oOptions.sClass );
  1782. }
  1783. $.extend( oCol, oOptions );
  1784. _fnMap( oCol, oOptions, "sWidth", "sWidthOrig" );
  1785. /* iDataSort to be applied (backwards compatibility), but aDataSort will take
  1786. * priority if defined
  1787. */
  1788. if ( oOptions.iDataSort !== undefined )
  1789. {
  1790. oCol.aDataSort = [ oOptions.iDataSort ];
  1791. }
  1792. _fnMap( oCol, oOptions, "aDataSort" );
  1793. }
  1794. /* Cache the data get and set functions for speed */
  1795. var mDataSrc = oCol.mData;
  1796. var mData = _fnGetObjectDataFn( mDataSrc );
  1797. var mRender = oCol.mRender ? _fnGetObjectDataFn( oCol.mRender ) : null;
  1798. var attrTest = function( src ) {
  1799. return typeof src === 'string' && src.indexOf('@') !== -1;
  1800. };
  1801. oCol._bAttrSrc = $.isPlainObject( mDataSrc ) && (
  1802. attrTest(mDataSrc.sort) || attrTest(mDataSrc.type) || attrTest(mDataSrc.filter)
  1803. );
  1804. oCol._setter = null;
  1805. oCol.fnGetData = function (rowData, type, meta) {
  1806. var innerData = mData( rowData, type, undefined, meta );
  1807. return mRender && type ?
  1808. mRender( innerData, type, rowData, meta ) :
  1809. innerData;
  1810. };
  1811. oCol.fnSetData = function ( rowData, val, meta ) {
  1812. return _fnSetObjectDataFn( mDataSrc )( rowData, val, meta );
  1813. };
  1814. // Indicate if DataTables should read DOM data as an object or array
  1815. // Used in _fnGetRowElements
  1816. if ( typeof mDataSrc !== 'number' ) {
  1817. oSettings._rowReadObject = true;
  1818. }
  1819. /* Feature sorting overrides column specific when off */
  1820. if ( !oSettings.oFeatures.bSort )
  1821. {
  1822. oCol.bSortable = false;
  1823. th.addClass( oClasses.sSortableNone ); // Have to add class here as order event isn't called
  1824. }
  1825. /* Check that the class assignment is correct for sorting */
  1826. var bAsc = $.inArray('asc', oCol.asSorting) !== -1;
  1827. var bDesc = $.inArray('desc', oCol.asSorting) !== -1;
  1828. if ( !oCol.bSortable || (!bAsc && !bDesc) )
  1829. {
  1830. oCol.sSortingClass = oClasses.sSortableNone;
  1831. oCol.sSortingClassJUI = "";
  1832. }
  1833. else if ( bAsc && !bDesc )
  1834. {
  1835. oCol.sSortingClass = oClasses.sSortableAsc;
  1836. oCol.sSortingClassJUI = oClasses.sSortJUIAscAllowed;
  1837. }
  1838. else if ( !bAsc && bDesc )
  1839. {
  1840. oCol.sSortingClass = oClasses.sSortableDesc;
  1841. oCol.sSortingClassJUI = oClasses.sSortJUIDescAllowed;
  1842. }
  1843. else
  1844. {
  1845. oCol.sSortingClass = oClasses.sSortable;
  1846. oCol.sSortingClassJUI = oClasses.sSortJUI;
  1847. }
  1848. }
  1849. /**
  1850. * Adjust the table column widths for new data. Note: you would probably want to
  1851. * do a redraw after calling this function!
  1852. * @param {object} settings dataTables settings object
  1853. * @memberof DataTable#oApi
  1854. */
  1855. function _fnAdjustColumnSizing ( settings )
  1856. {
  1857. /* Not interested in doing column width calculation if auto-width is disabled */
  1858. if ( settings.oFeatures.bAutoWidth !== false )
  1859. {
  1860. var columns = settings.aoColumns;
  1861. _fnCalculateColumnWidths( settings );
  1862. for ( var i=0 , iLen=columns.length ; i<iLen ; i++ )
  1863. {
  1864. columns[i].nTh.style.width = columns[i].sWidth;
  1865. }
  1866. }
  1867. var scroll = settings.oScroll;
  1868. if ( scroll.sY !== '' || scroll.sX !== '')
  1869. {
  1870. _fnScrollDraw( settings );
  1871. }
  1872. _fnCallbackFire( settings, null, 'column-sizing', [settings] );
  1873. }
  1874. /**
  1875. * Covert the index of a visible column to the index in the data array (take account
  1876. * of hidden columns)
  1877. * @param {object} oSettings dataTables settings object
  1878. * @param {int} iMatch Visible column index to lookup
  1879. * @returns {int} i the data index
  1880. * @memberof DataTable#oApi
  1881. */
  1882. function _fnVisibleToColumnIndex( oSettings, iMatch )
  1883. {
  1884. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  1885. return typeof aiVis[iMatch] === 'number' ?
  1886. aiVis[iMatch] :
  1887. null;
  1888. }
  1889. /**
  1890. * Covert the index of an index in the data array and convert it to the visible
  1891. * column index (take account of hidden columns)
  1892. * @param {int} iMatch Column index to lookup
  1893. * @param {object} oSettings dataTables settings object
  1894. * @returns {int} i the data index
  1895. * @memberof DataTable#oApi
  1896. */
  1897. function _fnColumnIndexToVisible( oSettings, iMatch )
  1898. {
  1899. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  1900. var iPos = $.inArray( iMatch, aiVis );
  1901. return iPos !== -1 ? iPos : null;
  1902. }
  1903. /**
  1904. * Get the number of visible columns
  1905. * @param {object} oSettings dataTables settings object
  1906. * @returns {int} i the number of visible columns
  1907. * @memberof DataTable#oApi
  1908. */
  1909. function _fnVisbleColumns( oSettings )
  1910. {
  1911. var vis = 0;
  1912. // No reduce in IE8, use a loop for now
  1913. $.each( oSettings.aoColumns, function ( i, col ) {
  1914. if ( col.bVisible && $(col.nTh).css('display') !== 'none' ) {
  1915. vis++;
  1916. }
  1917. } );
  1918. return vis;
  1919. }
  1920. /**
  1921. * Get an array of column indexes that match a given property
  1922. * @param {object} oSettings dataTables settings object
  1923. * @param {string} sParam Parameter in aoColumns to look for - typically
  1924. * bVisible or bSearchable
  1925. * @returns {array} Array of indexes with matched properties
  1926. * @memberof DataTable#oApi
  1927. */
  1928. function _fnGetColumns( oSettings, sParam )
  1929. {
  1930. var a = [];
  1931. $.map( oSettings.aoColumns, function(val, i) {
  1932. if ( val[sParam] ) {
  1933. a.push( i );
  1934. }
  1935. } );
  1936. return a;
  1937. }
  1938. /**
  1939. * Calculate the 'type' of a column
  1940. * @param {object} settings dataTables settings object
  1941. * @memberof DataTable#oApi
  1942. */
  1943. function _fnColumnTypes ( settings )
  1944. {
  1945. var columns = settings.aoColumns;
  1946. var data = settings.aoData;
  1947. var types = DataTable.ext.type.detect;
  1948. var i, ien, j, jen, k, ken;
  1949. var col, cell, detectedType, cache;
  1950. // For each column, spin over the
  1951. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  1952. col = columns[i];
  1953. cache = [];
  1954. if ( ! col.sType && col._sManualType ) {
  1955. col.sType = col._sManualType;
  1956. }
  1957. else if ( ! col.sType ) {
  1958. for ( j=0, jen=types.length ; j<jen ; j++ ) {
  1959. for ( k=0, ken=data.length ; k<ken ; k++ ) {
  1960. // Use a cache array so we only need to get the type data
  1961. // from the formatter once (when using multiple detectors)
  1962. if ( cache[k] === undefined ) {
  1963. cache[k] = _fnGetCellData( settings, k, i, 'type' );
  1964. }
  1965. detectedType = types[j]( cache[k], settings );
  1966. // If null, then this type can't apply to this column, so
  1967. // rather than testing all cells, break out. There is an
  1968. // exception for the last type which is `html`. We need to
  1969. // scan all rows since it is possible to mix string and HTML
  1970. // types
  1971. if ( ! detectedType && j !== types.length-1 ) {
  1972. break;
  1973. }
  1974. // Only a single match is needed for html type since it is
  1975. // bottom of the pile and very similar to string
  1976. if ( detectedType === 'html' ) {
  1977. break;
  1978. }
  1979. }
  1980. // Type is valid for all data points in the column - use this
  1981. // type
  1982. if ( detectedType ) {
  1983. col.sType = detectedType;
  1984. break;
  1985. }
  1986. }
  1987. // Fall back - if no type was detected, always use string
  1988. if ( ! col.sType ) {
  1989. col.sType = 'string';
  1990. }
  1991. }
  1992. }
  1993. }
  1994. /**
  1995. * Take the column definitions and static columns arrays and calculate how
  1996. * they relate to column indexes. The callback function will then apply the
  1997. * definition found for a column to a suitable configuration object.
  1998. * @param {object} oSettings dataTables settings object
  1999. * @param {array} aoColDefs The aoColumnDefs array that is to be applied
  2000. * @param {array} aoCols The aoColumns array that defines columns individually
  2001. * @param {function} fn Callback function - takes two parameters, the calculated
  2002. * column index and the definition for that column.
  2003. * @memberof DataTable#oApi
  2004. */
  2005. function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, fn )
  2006. {
  2007. var i, iLen, j, jLen, k, kLen, def;
  2008. var columns = oSettings.aoColumns;
  2009. // Column definitions with aTargets
  2010. if ( aoColDefs )
  2011. {
  2012. /* Loop over the definitions array - loop in reverse so first instance has priority */
  2013. for ( i=aoColDefs.length-1 ; i>=0 ; i-- )
  2014. {
  2015. def = aoColDefs[i];
  2016. /* Each definition can target multiple columns, as it is an array */
  2017. var aTargets = def.targets !== undefined ?
  2018. def.targets :
  2019. def.aTargets;
  2020. if ( ! $.isArray( aTargets ) )
  2021. {
  2022. aTargets = [ aTargets ];
  2023. }
  2024. for ( j=0, jLen=aTargets.length ; j<jLen ; j++ )
  2025. {
  2026. if ( typeof aTargets[j] === 'number' && aTargets[j] >= 0 )
  2027. {
  2028. /* Add columns that we don't yet know about */
  2029. while( columns.length <= aTargets[j] )
  2030. {
  2031. _fnAddColumn( oSettings );
  2032. }
  2033. /* Integer, basic index */
  2034. fn( aTargets[j], def );
  2035. }
  2036. else if ( typeof aTargets[j] === 'number' && aTargets[j] < 0 )
  2037. {
  2038. /* Negative integer, right to left column counting */
  2039. fn( columns.length+aTargets[j], def );
  2040. }
  2041. else if ( typeof aTargets[j] === 'string' )
  2042. {
  2043. /* Class name matching on TH element */
  2044. for ( k=0, kLen=columns.length ; k<kLen ; k++ )
  2045. {
  2046. if ( aTargets[j] == "_all" ||
  2047. $(columns[k].nTh).hasClass( aTargets[j] ) )
  2048. {
  2049. fn( k, def );
  2050. }
  2051. }
  2052. }
  2053. }
  2054. }
  2055. }
  2056. // Statically defined columns array
  2057. if ( aoCols )
  2058. {
  2059. for ( i=0, iLen=aoCols.length ; i<iLen ; i++ )
  2060. {
  2061. fn( i, aoCols[i] );
  2062. }
  2063. }
  2064. }
  2065. /**
  2066. * Add a data array to the table, creating DOM node etc. This is the parallel to
  2067. * _fnGatherData, but for adding rows from a Javascript source, rather than a
  2068. * DOM source.
  2069. * @param {object} oSettings dataTables settings object
  2070. * @param {array} aData data array to be added
  2071. * @param {node} [nTr] TR element to add to the table - optional. If not given,
  2072. * DataTables will create a row automatically
  2073. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  2074. * if nTr is.
  2075. * @returns {int} >=0 if successful (index of new aoData entry), -1 if failed
  2076. * @memberof DataTable#oApi
  2077. */
  2078. function _fnAddData ( oSettings, aDataIn, nTr, anTds )
  2079. {
  2080. /* Create the object for storing information about this new row */
  2081. var iRow = oSettings.aoData.length;
  2082. var oData = $.extend( true, {}, DataTable.models.oRow, {
  2083. src: nTr ? 'dom' : 'data',
  2084. idx: iRow
  2085. } );
  2086. oData._aData = aDataIn;
  2087. oSettings.aoData.push( oData );
  2088. /* Create the cells */
  2089. var nTd, sThisType;
  2090. var columns = oSettings.aoColumns;
  2091. // Invalidate the column types as the new data needs to be revalidated
  2092. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  2093. {
  2094. columns[i].sType = null;
  2095. }
  2096. /* Add to the display array */
  2097. oSettings.aiDisplayMaster.push( iRow );
  2098. var id = oSettings.rowIdFn( aDataIn );
  2099. if ( id !== undefined ) {
  2100. oSettings.aIds[ id ] = oData;
  2101. }
  2102. /* Create the DOM information, or register it if already present */
  2103. if ( nTr || ! oSettings.oFeatures.bDeferRender )
  2104. {
  2105. _fnCreateTr( oSettings, iRow, nTr, anTds );
  2106. }
  2107. return iRow;
  2108. }
  2109. /**
  2110. * Add one or more TR elements to the table. Generally we'd expect to
  2111. * use this for reading data from a DOM sourced table, but it could be
  2112. * used for an TR element. Note that if a TR is given, it is used (i.e.
  2113. * it is not cloned).
  2114. * @param {object} settings dataTables settings object
  2115. * @param {array|node|jQuery} trs The TR element(s) to add to the table
  2116. * @returns {array} Array of indexes for the added rows
  2117. * @memberof DataTable#oApi
  2118. */
  2119. function _fnAddTr( settings, trs )
  2120. {
  2121. var row;
  2122. // Allow an individual node to be passed in
  2123. if ( ! (trs instanceof $) ) {
  2124. trs = $(trs);
  2125. }
  2126. return trs.map( function (i, el) {
  2127. row = _fnGetRowElements( settings, el );
  2128. return _fnAddData( settings, row.data, el, row.cells );
  2129. } );
  2130. }
  2131. /**
  2132. * Take a TR element and convert it to an index in aoData
  2133. * @param {object} oSettings dataTables settings object
  2134. * @param {node} n the TR element to find
  2135. * @returns {int} index if the node is found, null if not
  2136. * @memberof DataTable#oApi
  2137. */
  2138. function _fnNodeToDataIndex( oSettings, n )
  2139. {
  2140. return (n._DT_RowIndex!==undefined) ? n._DT_RowIndex : null;
  2141. }
  2142. /**
  2143. * Take a TD element and convert it into a column data index (not the visible index)
  2144. * @param {object} oSettings dataTables settings object
  2145. * @param {int} iRow The row number the TD/TH can be found in
  2146. * @param {node} n The TD/TH element to find
  2147. * @returns {int} index if the node is found, -1 if not
  2148. * @memberof DataTable#oApi
  2149. */
  2150. function _fnNodeToColumnIndex( oSettings, iRow, n )
  2151. {
  2152. return $.inArray( n, oSettings.aoData[ iRow ].anCells );
  2153. }
  2154. /**
  2155. * Get the data for a given cell from the internal cache, taking into account data mapping
  2156. * @param {object} settings dataTables settings object
  2157. * @param {int} rowIdx aoData row id
  2158. * @param {int} colIdx Column index
  2159. * @param {string} type data get type ('display', 'type' 'filter' 'sort')
  2160. * @returns {*} Cell data
  2161. * @memberof DataTable#oApi
  2162. */
  2163. function _fnGetCellData( settings, rowIdx, colIdx, type )
  2164. {
  2165. var draw = settings.iDraw;
  2166. var col = settings.aoColumns[colIdx];
  2167. var rowData = settings.aoData[rowIdx]._aData;
  2168. var defaultContent = col.sDefaultContent;
  2169. var cellData = col.fnGetData( rowData, type, {
  2170. settings: settings,
  2171. row: rowIdx,
  2172. col: colIdx
  2173. } );
  2174. if ( cellData === undefined ) {
  2175. if ( settings.iDrawError != draw && defaultContent === null ) {
  2176. _fnLog( settings, 0, "Requested unknown parameter "+
  2177. (typeof col.mData=='function' ? '{function}' : "'"+col.mData+"'")+
  2178. " for row "+rowIdx+", column "+colIdx, 4 );
  2179. settings.iDrawError = draw;
  2180. }
  2181. return defaultContent;
  2182. }
  2183. // When the data source is null and a specific data type is requested (i.e.
  2184. // not the original data), we can use default column data
  2185. if ( (cellData === rowData || cellData === null) && defaultContent !== null && type !== undefined ) {
  2186. cellData = defaultContent;
  2187. }
  2188. else if ( typeof cellData === 'function' ) {
  2189. // If the data source is a function, then we run it and use the return,
  2190. // executing in the scope of the data object (for instances)
  2191. return cellData.call( rowData );
  2192. }
  2193. if ( cellData === null && type == 'display' ) {
  2194. return '';
  2195. }
  2196. return cellData;
  2197. }
  2198. /**
  2199. * Set the value for a specific cell, into the internal data cache
  2200. * @param {object} settings dataTables settings object
  2201. * @param {int} rowIdx aoData row id
  2202. * @param {int} colIdx Column index
  2203. * @param {*} val Value to set
  2204. * @memberof DataTable#oApi
  2205. */
  2206. function _fnSetCellData( settings, rowIdx, colIdx, val )
  2207. {
  2208. var col = settings.aoColumns[colIdx];
  2209. var rowData = settings.aoData[rowIdx]._aData;
  2210. col.fnSetData( rowData, val, {
  2211. settings: settings,
  2212. row: rowIdx,
  2213. col: colIdx
  2214. } );
  2215. }
  2216. // Private variable that is used to match action syntax in the data property object
  2217. var __reArray = /\[.*?\]$/;
  2218. var __reFn = /\(\)$/;
  2219. /**
  2220. * Split string on periods, taking into account escaped periods
  2221. * @param {string} str String to split
  2222. * @return {array} Split string
  2223. */
  2224. function _fnSplitObjNotation( str )
  2225. {
  2226. return $.map( str.match(/(\\.|[^\.])+/g) || [''], function ( s ) {
  2227. return s.replace(/\\\./g, '.');
  2228. } );
  2229. }
  2230. /**
  2231. * Return a function that can be used to get data from a source object, taking
  2232. * into account the ability to use nested objects as a source
  2233. * @param {string|int|function} mSource The data source for the object
  2234. * @returns {function} Data get function
  2235. * @memberof DataTable#oApi
  2236. */
  2237. function _fnGetObjectDataFn( mSource )
  2238. {
  2239. if ( $.isPlainObject( mSource ) )
  2240. {
  2241. /* Build an object of get functions, and wrap them in a single call */
  2242. var o = {};
  2243. $.each( mSource, function (key, val) {
  2244. if ( val ) {
  2245. o[key] = _fnGetObjectDataFn( val );
  2246. }
  2247. } );
  2248. return function (data, type, row, meta) {
  2249. var t = o[type] || o._;
  2250. return t !== undefined ?
  2251. t(data, type, row, meta) :
  2252. data;
  2253. };
  2254. }
  2255. else if ( mSource === null )
  2256. {
  2257. /* Give an empty string for rendering / sorting etc */
  2258. return function (data) { // type, row and meta also passed, but not used
  2259. return data;
  2260. };
  2261. }
  2262. else if ( typeof mSource === 'function' )
  2263. {
  2264. return function (data, type, row, meta) {
  2265. return mSource( data, type, row, meta );
  2266. };
  2267. }
  2268. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  2269. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  2270. {
  2271. /* If there is a . in the source string then the data source is in a
  2272. * nested object so we loop over the data for each level to get the next
  2273. * level down. On each loop we test for undefined, and if found immediately
  2274. * return. This allows entire objects to be missing and sDefaultContent to
  2275. * be used if defined, rather than throwing an error
  2276. */
  2277. var fetchData = function (data, type, src) {
  2278. var arrayNotation, funcNotation, out, innerSrc;
  2279. if ( src !== "" )
  2280. {
  2281. var a = _fnSplitObjNotation( src );
  2282. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  2283. {
  2284. // Check if we are dealing with special notation
  2285. arrayNotation = a[i].match(__reArray);
  2286. funcNotation = a[i].match(__reFn);
  2287. if ( arrayNotation )
  2288. {
  2289. // Array notation
  2290. a[i] = a[i].replace(__reArray, '');
  2291. // Condition allows simply [] to be passed in
  2292. if ( a[i] !== "" ) {
  2293. data = data[ a[i] ];
  2294. }
  2295. out = [];
  2296. // Get the remainder of the nested object to get
  2297. a.splice( 0, i+1 );
  2298. innerSrc = a.join('.');
  2299. // Traverse each entry in the array getting the properties requested
  2300. if ( $.isArray( data ) ) {
  2301. for ( var j=0, jLen=data.length ; j<jLen ; j++ ) {
  2302. out.push( fetchData( data[j], type, innerSrc ) );
  2303. }
  2304. }
  2305. // If a string is given in between the array notation indicators, that
  2306. // is used to join the strings together, otherwise an array is returned
  2307. var join = arrayNotation[0].substring(1, arrayNotation[0].length-1);
  2308. data = (join==="") ? out : out.join(join);
  2309. // The inner call to fetchData has already traversed through the remainder
  2310. // of the source requested, so we exit from the loop
  2311. break;
  2312. }
  2313. else if ( funcNotation )
  2314. {
  2315. // Function call
  2316. a[i] = a[i].replace(__reFn, '');
  2317. data = data[ a[i] ]();
  2318. continue;
  2319. }
  2320. if ( data === null || data[ a[i] ] === undefined )
  2321. {
  2322. return undefined;
  2323. }
  2324. data = data[ a[i] ];
  2325. }
  2326. }
  2327. return data;
  2328. };
  2329. return function (data, type) { // row and meta also passed, but not used
  2330. return fetchData( data, type, mSource );
  2331. };
  2332. }
  2333. else
  2334. {
  2335. /* Array or flat object mapping */
  2336. return function (data, type) { // row and meta also passed, but not used
  2337. return data[mSource];
  2338. };
  2339. }
  2340. }
  2341. /**
  2342. * Return a function that can be used to set data from a source object, taking
  2343. * into account the ability to use nested objects as a source
  2344. * @param {string|int|function} mSource The data source for the object
  2345. * @returns {function} Data set function
  2346. * @memberof DataTable#oApi
  2347. */
  2348. function _fnSetObjectDataFn( mSource )
  2349. {
  2350. if ( $.isPlainObject( mSource ) )
  2351. {
  2352. /* Unlike get, only the underscore (global) option is used for for
  2353. * setting data since we don't know the type here. This is why an object
  2354. * option is not documented for `mData` (which is read/write), but it is
  2355. * for `mRender` which is read only.
  2356. */
  2357. return _fnSetObjectDataFn( mSource._ );
  2358. }
  2359. else if ( mSource === null )
  2360. {
  2361. /* Nothing to do when the data source is null */
  2362. return function () {};
  2363. }
  2364. else if ( typeof mSource === 'function' )
  2365. {
  2366. return function (data, val, meta) {
  2367. mSource( data, 'set', val, meta );
  2368. };
  2369. }
  2370. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  2371. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  2372. {
  2373. /* Like the get, we need to get data from a nested object */
  2374. var setData = function (data, val, src) {
  2375. var a = _fnSplitObjNotation( src ), b;
  2376. var aLast = a[a.length-1];
  2377. var arrayNotation, funcNotation, o, innerSrc;
  2378. for ( var i=0, iLen=a.length-1 ; i<iLen ; i++ )
  2379. {
  2380. // Check if we are dealing with an array notation request
  2381. arrayNotation = a[i].match(__reArray);
  2382. funcNotation = a[i].match(__reFn);
  2383. if ( arrayNotation )
  2384. {
  2385. a[i] = a[i].replace(__reArray, '');
  2386. data[ a[i] ] = [];
  2387. // Get the remainder of the nested object to set so we can recurse
  2388. b = a.slice();
  2389. b.splice( 0, i+1 );
  2390. innerSrc = b.join('.');
  2391. // Traverse each entry in the array setting the properties requested
  2392. if ( $.isArray( val ) )
  2393. {
  2394. for ( var j=0, jLen=val.length ; j<jLen ; j++ )
  2395. {
  2396. o = {};
  2397. setData( o, val[j], innerSrc );
  2398. data[ a[i] ].push( o );
  2399. }
  2400. }
  2401. else
  2402. {
  2403. // We've been asked to save data to an array, but it
  2404. // isn't array data to be saved. Best that can be done
  2405. // is to just save the value.
  2406. data[ a[i] ] = val;
  2407. }
  2408. // The inner call to setData has already traversed through the remainder
  2409. // of the source and has set the data, thus we can exit here
  2410. return;
  2411. }
  2412. else if ( funcNotation )
  2413. {
  2414. // Function call
  2415. a[i] = a[i].replace(__reFn, '');
  2416. data = data[ a[i] ]( val );
  2417. }
  2418. // If the nested object doesn't currently exist - since we are
  2419. // trying to set the value - create it
  2420. if ( data[ a[i] ] === null || data[ a[i] ] === undefined )
  2421. {
  2422. data[ a[i] ] = {};
  2423. }
  2424. data = data[ a[i] ];
  2425. }
  2426. // Last item in the input - i.e, the actual set
  2427. if ( aLast.match(__reFn ) )
  2428. {
  2429. // Function call
  2430. data = data[ aLast.replace(__reFn, '') ]( val );
  2431. }
  2432. else
  2433. {
  2434. // If array notation is used, we just want to strip it and use the property name
  2435. // and assign the value. If it isn't used, then we get the result we want anyway
  2436. data[ aLast.replace(__reArray, '') ] = val;
  2437. }
  2438. };
  2439. return function (data, val) { // meta is also passed in, but not used
  2440. return setData( data, val, mSource );
  2441. };
  2442. }
  2443. else
  2444. {
  2445. /* Array or flat object mapping */
  2446. return function (data, val) { // meta is also passed in, but not used
  2447. data[mSource] = val;
  2448. };
  2449. }
  2450. }
  2451. /**
  2452. * Return an array with the full table data
  2453. * @param {object} oSettings dataTables settings object
  2454. * @returns array {array} aData Master data array
  2455. * @memberof DataTable#oApi
  2456. */
  2457. function _fnGetDataMaster ( settings )
  2458. {
  2459. return _pluck( settings.aoData, '_aData' );
  2460. }
  2461. /**
  2462. * Nuke the table
  2463. * @param {object} oSettings dataTables settings object
  2464. * @memberof DataTable#oApi
  2465. */
  2466. function _fnClearTable( settings )
  2467. {
  2468. settings.aoData.length = 0;
  2469. settings.aiDisplayMaster.length = 0;
  2470. settings.aiDisplay.length = 0;
  2471. settings.aIds = {};
  2472. }
  2473. /**
  2474. * Take an array of integers (index array) and remove a target integer (value - not
  2475. * the key!)
  2476. * @param {array} a Index array to target
  2477. * @param {int} iTarget value to find
  2478. * @memberof DataTable#oApi
  2479. */
  2480. function _fnDeleteIndex( a, iTarget, splice )
  2481. {
  2482. var iTargetIndex = -1;
  2483. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  2484. {
  2485. if ( a[i] == iTarget )
  2486. {
  2487. iTargetIndex = i;
  2488. }
  2489. else if ( a[i] > iTarget )
  2490. {
  2491. a[i]--;
  2492. }
  2493. }
  2494. if ( iTargetIndex != -1 && splice === undefined )
  2495. {
  2496. a.splice( iTargetIndex, 1 );
  2497. }
  2498. }
  2499. /**
  2500. * Mark cached data as invalid such that a re-read of the data will occur when
  2501. * the cached data is next requested. Also update from the data source object.
  2502. *
  2503. * @param {object} settings DataTables settings object
  2504. * @param {int} rowIdx Row index to invalidate
  2505. * @param {string} [src] Source to invalidate from: undefined, 'auto', 'dom'
  2506. * or 'data'
  2507. * @param {int} [colIdx] Column index to invalidate. If undefined the whole
  2508. * row will be invalidated
  2509. * @memberof DataTable#oApi
  2510. *
  2511. * @todo For the modularisation of v1.11 this will need to become a callback, so
  2512. * the sort and filter methods can subscribe to it. That will required
  2513. * initialisation options for sorting, which is why it is not already baked in
  2514. */
  2515. function _fnInvalidate( settings, rowIdx, src, colIdx )
  2516. {
  2517. var row = settings.aoData[ rowIdx ];
  2518. var i, ien;
  2519. var cellWrite = function ( cell, col ) {
  2520. // This is very frustrating, but in IE if you just write directly
  2521. // to innerHTML, and elements that are overwritten are GC'ed,
  2522. // even if there is a reference to them elsewhere
  2523. while ( cell.childNodes.length ) {
  2524. cell.removeChild( cell.firstChild );
  2525. }
  2526. cell.innerHTML = _fnGetCellData( settings, rowIdx, col, 'display' );
  2527. };
  2528. // Are we reading last data from DOM or the data object?
  2529. if ( src === 'dom' || ((! src || src === 'auto') && row.src === 'dom') ) {
  2530. // Read the data from the DOM
  2531. row._aData = _fnGetRowElements(
  2532. settings, row, colIdx, colIdx === undefined ? undefined : row._aData
  2533. )
  2534. .data;
  2535. }
  2536. else {
  2537. // Reading from data object, update the DOM
  2538. var cells = row.anCells;
  2539. if ( cells ) {
  2540. if ( colIdx !== undefined ) {
  2541. cellWrite( cells[colIdx], colIdx );
  2542. }
  2543. else {
  2544. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  2545. cellWrite( cells[i], i );
  2546. }
  2547. }
  2548. }
  2549. }
  2550. // For both row and cell invalidation, the cached data for sorting and
  2551. // filtering is nulled out
  2552. row._aSortData = null;
  2553. row._aFilterData = null;
  2554. // Invalidate the type for a specific column (if given) or all columns since
  2555. // the data might have changed
  2556. var cols = settings.aoColumns;
  2557. if ( colIdx !== undefined ) {
  2558. cols[ colIdx ].sType = null;
  2559. }
  2560. else {
  2561. for ( i=0, ien=cols.length ; i<ien ; i++ ) {
  2562. cols[i].sType = null;
  2563. }
  2564. // Update DataTables special `DT_*` attributes for the row
  2565. _fnRowAttributes( settings, row );
  2566. }
  2567. }
  2568. /**
  2569. * Build a data source object from an HTML row, reading the contents of the
  2570. * cells that are in the row.
  2571. *
  2572. * @param {object} settings DataTables settings object
  2573. * @param {node|object} TR element from which to read data or existing row
  2574. * object from which to re-read the data from the cells
  2575. * @param {int} [colIdx] Optional column index
  2576. * @param {array|object} [d] Data source object. If `colIdx` is given then this
  2577. * parameter should also be given and will be used to write the data into.
  2578. * Only the column in question will be written
  2579. * @returns {object} Object with two parameters: `data` the data read, in
  2580. * document order, and `cells` and array of nodes (they can be useful to the
  2581. * caller, so rather than needing a second traversal to get them, just return
  2582. * them from here).
  2583. * @memberof DataTable#oApi
  2584. */
  2585. function _fnGetRowElements( settings, row, colIdx, d )
  2586. {
  2587. var
  2588. tds = [],
  2589. td = row.firstChild,
  2590. name, col, o, i=0, contents,
  2591. columns = settings.aoColumns,
  2592. objectRead = settings._rowReadObject;
  2593. // Allow the data object to be passed in, or construct
  2594. d = d !== undefined ?
  2595. d :
  2596. objectRead ?
  2597. {} :
  2598. [];
  2599. var attr = function ( str, td ) {
  2600. if ( typeof str === 'string' ) {
  2601. var idx = str.indexOf('@');
  2602. if ( idx !== -1 ) {
  2603. var attr = str.substring( idx+1 );
  2604. var setter = _fnSetObjectDataFn( str );
  2605. setter( d, td.getAttribute( attr ) );
  2606. }
  2607. }
  2608. };
  2609. // Read data from a cell and store into the data object
  2610. var cellProcess = function ( cell ) {
  2611. if ( colIdx === undefined || colIdx === i ) {
  2612. col = columns[i];
  2613. contents = $.trim(cell.innerHTML);
  2614. if ( col && col._bAttrSrc ) {
  2615. var setter = _fnSetObjectDataFn( col.mData._ );
  2616. setter( d, contents );
  2617. attr( col.mData.sort, cell );
  2618. attr( col.mData.type, cell );
  2619. attr( col.mData.filter, cell );
  2620. }
  2621. else {
  2622. // Depending on the `data` option for the columns the data can
  2623. // be read to either an object or an array.
  2624. if ( objectRead ) {
  2625. if ( ! col._setter ) {
  2626. // Cache the setter function
  2627. col._setter = _fnSetObjectDataFn( col.mData );
  2628. }
  2629. col._setter( d, contents );
  2630. }
  2631. else {
  2632. d[i] = contents;
  2633. }
  2634. }
  2635. }
  2636. i++;
  2637. };
  2638. if ( td ) {
  2639. // `tr` element was passed in
  2640. while ( td ) {
  2641. name = td.nodeName.toUpperCase();
  2642. if ( name == "TD" || name == "TH" ) {
  2643. cellProcess( td );
  2644. tds.push( td );
  2645. }
  2646. td = td.nextSibling;
  2647. }
  2648. }
  2649. else {
  2650. // Existing row object passed in
  2651. tds = row.anCells;
  2652. for ( var j=0, jen=tds.length ; j<jen ; j++ ) {
  2653. cellProcess( tds[j] );
  2654. }
  2655. }
  2656. // Read the ID from the DOM if present
  2657. var rowNode = row.firstChild ? row : row.nTr;
  2658. if ( rowNode ) {
  2659. var id = rowNode.getAttribute( 'id' );
  2660. if ( id ) {
  2661. _fnSetObjectDataFn( settings.rowId )( d, id );
  2662. }
  2663. }
  2664. return {
  2665. data: d,
  2666. cells: tds
  2667. };
  2668. }
  2669. /**
  2670. * Create a new TR element (and it's TD children) for a row
  2671. * @param {object} oSettings dataTables settings object
  2672. * @param {int} iRow Row to consider
  2673. * @param {node} [nTrIn] TR element to add to the table - optional. If not given,
  2674. * DataTables will create a row automatically
  2675. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  2676. * if nTr is.
  2677. * @memberof DataTable#oApi
  2678. */
  2679. function _fnCreateTr ( oSettings, iRow, nTrIn, anTds )
  2680. {
  2681. var
  2682. row = oSettings.aoData[iRow],
  2683. rowData = row._aData,
  2684. cells = [],
  2685. nTr, nTd, oCol,
  2686. i, iLen, create;
  2687. if ( row.nTr === null )
  2688. {
  2689. nTr = nTrIn || document.createElement('tr');
  2690. row.nTr = nTr;
  2691. row.anCells = cells;
  2692. /* Use a private property on the node to allow reserve mapping from the node
  2693. * to the aoData array for fast look up
  2694. */
  2695. nTr._DT_RowIndex = iRow;
  2696. /* Special parameters can be given by the data source to be used on the row */
  2697. _fnRowAttributes( oSettings, row );
  2698. /* Process each column */
  2699. for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
  2700. {
  2701. oCol = oSettings.aoColumns[i];
  2702. create = nTrIn ? false : true;
  2703. nTd = create ? document.createElement( oCol.sCellType ) : anTds[i];
  2704. nTd._DT_CellIndex = {
  2705. row: iRow,
  2706. column: i
  2707. };
  2708. cells.push( nTd );
  2709. // Need to create the HTML if new, or if a rendering function is defined
  2710. if ( create || ((!nTrIn || oCol.mRender || oCol.mData !== i) &&
  2711. (!$.isPlainObject(oCol.mData) || oCol.mData._ !== i+'.display')
  2712. )) {
  2713. nTd.innerHTML = _fnGetCellData( oSettings, iRow, i, 'display' );
  2714. }
  2715. /* Add user defined class */
  2716. if ( oCol.sClass )
  2717. {
  2718. nTd.className += ' '+oCol.sClass;
  2719. }
  2720. // Visibility - add or remove as required
  2721. if ( oCol.bVisible && ! nTrIn )
  2722. {
  2723. nTr.appendChild( nTd );
  2724. }
  2725. else if ( ! oCol.bVisible && nTrIn )
  2726. {
  2727. nTd.parentNode.removeChild( nTd );
  2728. }
  2729. if ( oCol.fnCreatedCell )
  2730. {
  2731. oCol.fnCreatedCell.call( oSettings.oInstance,
  2732. nTd, _fnGetCellData( oSettings, iRow, i ), rowData, iRow, i
  2733. );
  2734. }
  2735. }
  2736. _fnCallbackFire( oSettings, 'aoRowCreatedCallback', null, [nTr, rowData, iRow, cells] );
  2737. }
  2738. // Remove once webkit bug 131819 and Chromium bug 365619 have been resolved
  2739. // and deployed
  2740. row.nTr.setAttribute( 'role', 'row' );
  2741. }
  2742. /**
  2743. * Add attributes to a row based on the special `DT_*` parameters in a data
  2744. * source object.
  2745. * @param {object} settings DataTables settings object
  2746. * @param {object} DataTables row object for the row to be modified
  2747. * @memberof DataTable#oApi
  2748. */
  2749. function _fnRowAttributes( settings, row )
  2750. {
  2751. var tr = row.nTr;
  2752. var data = row._aData;
  2753. if ( tr ) {
  2754. var id = settings.rowIdFn( data );
  2755. if ( id ) {
  2756. tr.id = id;
  2757. }
  2758. if ( data.DT_RowClass ) {
  2759. // Remove any classes added by DT_RowClass before
  2760. var a = data.DT_RowClass.split(' ');
  2761. row.__rowc = row.__rowc ?
  2762. _unique( row.__rowc.concat( a ) ) :
  2763. a;
  2764. $(tr)
  2765. .removeClass( row.__rowc.join(' ') )
  2766. .addClass( data.DT_RowClass );
  2767. }
  2768. if ( data.DT_RowAttr ) {
  2769. $(tr).attr( data.DT_RowAttr );
  2770. }
  2771. if ( data.DT_RowData ) {
  2772. $(tr).data( data.DT_RowData );
  2773. }
  2774. }
  2775. }
  2776. /**
  2777. * Create the HTML header for the table
  2778. * @param {object} oSettings dataTables settings object
  2779. * @memberof DataTable#oApi
  2780. */
  2781. function _fnBuildHead( oSettings )
  2782. {
  2783. var i, ien, cell, row, column;
  2784. var thead = oSettings.nTHead;
  2785. var tfoot = oSettings.nTFoot;
  2786. var createHeader = $('th, td', thead).length === 0;
  2787. var classes = oSettings.oClasses;
  2788. var columns = oSettings.aoColumns;
  2789. if ( createHeader ) {
  2790. row = $('<tr/>').appendTo( thead );
  2791. }
  2792. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  2793. column = columns[i];
  2794. cell = $( column.nTh ).addClass( column.sClass );
  2795. if ( createHeader ) {
  2796. cell.appendTo( row );
  2797. }
  2798. // 1.11 move into sorting
  2799. if ( oSettings.oFeatures.bSort ) {
  2800. cell.addClass( column.sSortingClass );
  2801. if ( column.bSortable !== false ) {
  2802. cell
  2803. .attr( 'tabindex', oSettings.iTabIndex )
  2804. .attr( 'aria-controls', oSettings.sTableId );
  2805. _fnSortAttachListener( oSettings, column.nTh, i );
  2806. }
  2807. }
  2808. if ( column.sTitle != cell[0].innerHTML ) {
  2809. cell.html( column.sTitle );
  2810. }
  2811. _fnRenderer( oSettings, 'header' )(
  2812. oSettings, cell, column, classes
  2813. );
  2814. }
  2815. if ( createHeader ) {
  2816. _fnDetectHeader( oSettings.aoHeader, thead );
  2817. }
  2818. /* ARIA role for the rows */
  2819. $(thead).find('>tr').attr('role', 'row');
  2820. /* Deal with the footer - add classes if required */
  2821. $(thead).find('>tr>th, >tr>td').addClass( classes.sHeaderTH );
  2822. $(tfoot).find('>tr>th, >tr>td').addClass( classes.sFooterTH );
  2823. // Cache the footer cells. Note that we only take the cells from the first
  2824. // row in the footer. If there is more than one row the user wants to
  2825. // interact with, they need to use the table().foot() method. Note also this
  2826. // allows cells to be used for multiple columns using colspan
  2827. if ( tfoot !== null ) {
  2828. var cells = oSettings.aoFooter[0];
  2829. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  2830. column = columns[i];
  2831. column.nTf = cells[i].cell;
  2832. if ( column.sClass ) {
  2833. $(column.nTf).addClass( column.sClass );
  2834. }
  2835. }
  2836. }
  2837. }
  2838. /**
  2839. * Draw the header (or footer) element based on the column visibility states. The
  2840. * methodology here is to use the layout array from _fnDetectHeader, modified for
  2841. * the instantaneous column visibility, to construct the new layout. The grid is
  2842. * traversed over cell at a time in a rows x columns grid fashion, although each
  2843. * cell insert can cover multiple elements in the grid - which is tracks using the
  2844. * aApplied array. Cell inserts in the grid will only occur where there isn't
  2845. * already a cell in that position.
  2846. * @param {object} oSettings dataTables settings object
  2847. * @param array {objects} aoSource Layout array from _fnDetectHeader
  2848. * @param {boolean} [bIncludeHidden=false] If true then include the hidden columns in the calc,
  2849. * @memberof DataTable#oApi
  2850. */
  2851. function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
  2852. {
  2853. var i, iLen, j, jLen, k, kLen, n, nLocalTr;
  2854. var aoLocal = [];
  2855. var aApplied = [];
  2856. var iColumns = oSettings.aoColumns.length;
  2857. var iRowspan, iColspan;
  2858. if ( ! aoSource )
  2859. {
  2860. return;
  2861. }
  2862. if ( bIncludeHidden === undefined )
  2863. {
  2864. bIncludeHidden = false;
  2865. }
  2866. /* Make a copy of the master layout array, but without the visible columns in it */
  2867. for ( i=0, iLen=aoSource.length ; i<iLen ; i++ )
  2868. {
  2869. aoLocal[i] = aoSource[i].slice();
  2870. aoLocal[i].nTr = aoSource[i].nTr;
  2871. /* Remove any columns which are currently hidden */
  2872. for ( j=iColumns-1 ; j>=0 ; j-- )
  2873. {
  2874. if ( !oSettings.aoColumns[j].bVisible && !bIncludeHidden )
  2875. {
  2876. aoLocal[i].splice( j, 1 );
  2877. }
  2878. }
  2879. /* Prep the applied array - it needs an element for each row */
  2880. aApplied.push( [] );
  2881. }
  2882. for ( i=0, iLen=aoLocal.length ; i<iLen ; i++ )
  2883. {
  2884. nLocalTr = aoLocal[i].nTr;
  2885. /* All cells are going to be replaced, so empty out the row */
  2886. if ( nLocalTr )
  2887. {
  2888. while( (n = nLocalTr.firstChild) )
  2889. {
  2890. nLocalTr.removeChild( n );
  2891. }
  2892. }
  2893. for ( j=0, jLen=aoLocal[i].length ; j<jLen ; j++ )
  2894. {
  2895. iRowspan = 1;
  2896. iColspan = 1;
  2897. /* Check to see if there is already a cell (row/colspan) covering our target
  2898. * insert point. If there is, then there is nothing to do.
  2899. */
  2900. if ( aApplied[i][j] === undefined )
  2901. {
  2902. nLocalTr.appendChild( aoLocal[i][j].cell );
  2903. aApplied[i][j] = 1;
  2904. /* Expand the cell to cover as many rows as needed */
  2905. while ( aoLocal[i+iRowspan] !== undefined &&
  2906. aoLocal[i][j].cell == aoLocal[i+iRowspan][j].cell )
  2907. {
  2908. aApplied[i+iRowspan][j] = 1;
  2909. iRowspan++;
  2910. }
  2911. /* Expand the cell to cover as many columns as needed */
  2912. while ( aoLocal[i][j+iColspan] !== undefined &&
  2913. aoLocal[i][j].cell == aoLocal[i][j+iColspan].cell )
  2914. {
  2915. /* Must update the applied array over the rows for the columns */
  2916. for ( k=0 ; k<iRowspan ; k++ )
  2917. {
  2918. aApplied[i+k][j+iColspan] = 1;
  2919. }
  2920. iColspan++;
  2921. }
  2922. /* Do the actual expansion in the DOM */
  2923. $(aoLocal[i][j].cell)
  2924. .attr('rowspan', iRowspan)
  2925. .attr('colspan', iColspan);
  2926. }
  2927. }
  2928. }
  2929. }
  2930. /**
  2931. * Insert the required TR nodes into the table for display
  2932. * @param {object} oSettings dataTables settings object
  2933. * @memberof DataTable#oApi
  2934. */
  2935. function _fnDraw( oSettings )
  2936. {
  2937. /* Provide a pre-callback function which can be used to cancel the draw is false is returned */
  2938. var aPreDraw = _fnCallbackFire( oSettings, 'aoPreDrawCallback', 'preDraw', [oSettings] );
  2939. if ( $.inArray( false, aPreDraw ) !== -1 )
  2940. {
  2941. _fnProcessingDisplay( oSettings, false );
  2942. return;
  2943. }
  2944. var i, iLen, n;
  2945. var anRows = [];
  2946. var iRowCount = 0;
  2947. var asStripeClasses = oSettings.asStripeClasses;
  2948. var iStripes = asStripeClasses.length;
  2949. var iOpenRows = oSettings.aoOpenRows.length;
  2950. var oLang = oSettings.oLanguage;
  2951. var iInitDisplayStart = oSettings.iInitDisplayStart;
  2952. var bServerSide = _fnDataSource( oSettings ) == 'ssp';
  2953. var aiDisplay = oSettings.aiDisplay;
  2954. oSettings.bDrawing = true;
  2955. /* Check and see if we have an initial draw position from state saving */
  2956. if ( iInitDisplayStart !== undefined && iInitDisplayStart !== -1 )
  2957. {
  2958. oSettings._iDisplayStart = bServerSide ?
  2959. iInitDisplayStart :
  2960. iInitDisplayStart >= oSettings.fnRecordsDisplay() ?
  2961. 0 :
  2962. iInitDisplayStart;
  2963. oSettings.iInitDisplayStart = -1;
  2964. }
  2965. var iDisplayStart = oSettings._iDisplayStart;
  2966. var iDisplayEnd = oSettings.fnDisplayEnd();
  2967. /* Server-side processing draw intercept */
  2968. if ( oSettings.bDeferLoading )
  2969. {
  2970. oSettings.bDeferLoading = false;
  2971. oSettings.iDraw++;
  2972. _fnProcessingDisplay( oSettings, false );
  2973. }
  2974. else if ( !bServerSide )
  2975. {
  2976. oSettings.iDraw++;
  2977. }
  2978. else if ( !oSettings.bDestroying && !_fnAjaxUpdate( oSettings ) )
  2979. {
  2980. return;
  2981. }
  2982. if ( aiDisplay.length !== 0 )
  2983. {
  2984. var iStart = bServerSide ? 0 : iDisplayStart;
  2985. var iEnd = bServerSide ? oSettings.aoData.length : iDisplayEnd;
  2986. for ( var j=iStart ; j<iEnd ; j++ )
  2987. {
  2988. var iDataIndex = aiDisplay[j];
  2989. var aoData = oSettings.aoData[ iDataIndex ];
  2990. if ( aoData.nTr === null )
  2991. {
  2992. _fnCreateTr( oSettings, iDataIndex );
  2993. }
  2994. var nRow = aoData.nTr;
  2995. /* Remove the old striping classes and then add the new one */
  2996. if ( iStripes !== 0 )
  2997. {
  2998. var sStripe = asStripeClasses[ iRowCount % iStripes ];
  2999. if ( aoData._sRowStripe != sStripe )
  3000. {
  3001. $(nRow).removeClass( aoData._sRowStripe ).addClass( sStripe );
  3002. aoData._sRowStripe = sStripe;
  3003. }
  3004. }
  3005. // Row callback functions - might want to manipulate the row
  3006. // iRowCount and j are not currently documented. Are they at all
  3007. // useful?
  3008. _fnCallbackFire( oSettings, 'aoRowCallback', null,
  3009. [nRow, aoData._aData, iRowCount, j, iDataIndex] );
  3010. anRows.push( nRow );
  3011. iRowCount++;
  3012. }
  3013. }
  3014. else
  3015. {
  3016. /* Table is empty - create a row with an empty message in it */
  3017. var sZero = oLang.sZeroRecords;
  3018. if ( oSettings.iDraw == 1 && _fnDataSource( oSettings ) == 'ajax' )
  3019. {
  3020. sZero = oLang.sLoadingRecords;
  3021. }
  3022. else if ( oLang.sEmptyTable && oSettings.fnRecordsTotal() === 0 )
  3023. {
  3024. sZero = oLang.sEmptyTable;
  3025. }
  3026. anRows[ 0 ] = $( '<tr/>', { 'class': iStripes ? asStripeClasses[0] : '' } )
  3027. .append( $('<td />', {
  3028. 'valign': 'top',
  3029. 'colSpan': _fnVisbleColumns( oSettings ),
  3030. 'class': oSettings.oClasses.sRowEmpty
  3031. } ).html( sZero ) )[0];
  3032. }
  3033. /* Header and footer callbacks */
  3034. _fnCallbackFire( oSettings, 'aoHeaderCallback', 'header', [ $(oSettings.nTHead).children('tr')[0],
  3035. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  3036. _fnCallbackFire( oSettings, 'aoFooterCallback', 'footer', [ $(oSettings.nTFoot).children('tr')[0],
  3037. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  3038. var body = $(oSettings.nTBody);
  3039. body.children().detach();
  3040. body.append( $(anRows) );
  3041. /* Call all required callback functions for the end of a draw */
  3042. _fnCallbackFire( oSettings, 'aoDrawCallback', 'draw', [oSettings] );
  3043. /* Draw is complete, sorting and filtering must be as well */
  3044. oSettings.bSorted = false;
  3045. oSettings.bFiltered = false;
  3046. oSettings.bDrawing = false;
  3047. }
  3048. /**
  3049. * Redraw the table - taking account of the various features which are enabled
  3050. * @param {object} oSettings dataTables settings object
  3051. * @param {boolean} [holdPosition] Keep the current paging position. By default
  3052. * the paging is reset to the first page
  3053. * @memberof DataTable#oApi
  3054. */
  3055. function _fnReDraw( settings, holdPosition )
  3056. {
  3057. var
  3058. features = settings.oFeatures,
  3059. sort = features.bSort,
  3060. filter = features.bFilter;
  3061. if ( sort ) {
  3062. _fnSort( settings );
  3063. }
  3064. if ( filter ) {
  3065. _fnFilterComplete( settings, settings.oPreviousSearch );
  3066. }
  3067. else {
  3068. // No filtering, so we want to just use the display master
  3069. settings.aiDisplay = settings.aiDisplayMaster.slice();
  3070. }
  3071. if ( holdPosition !== true ) {
  3072. settings._iDisplayStart = 0;
  3073. }
  3074. // Let any modules know about the draw hold position state (used by
  3075. // scrolling internally)
  3076. settings._drawHold = holdPosition;
  3077. _fnDraw( settings );
  3078. settings._drawHold = false;
  3079. }
  3080. /**
  3081. * Add the options to the page HTML for the table
  3082. * @param {object} oSettings dataTables settings object
  3083. * @memberof DataTable#oApi
  3084. */
  3085. function _fnAddOptionsHtml ( oSettings )
  3086. {
  3087. var classes = oSettings.oClasses;
  3088. var table = $(oSettings.nTable);
  3089. var holding = $('<div/>').insertBefore( table ); // Holding element for speed
  3090. var features = oSettings.oFeatures;
  3091. // All DataTables are wrapped in a div
  3092. var insert = $('<div/>', {
  3093. id: oSettings.sTableId+'_wrapper',
  3094. 'class': classes.sWrapper + (oSettings.nTFoot ? '' : ' '+classes.sNoFooter)
  3095. } );
  3096. oSettings.nHolding = holding[0];
  3097. oSettings.nTableWrapper = insert[0];
  3098. oSettings.nTableReinsertBefore = oSettings.nTable.nextSibling;
  3099. /* Loop over the user set positioning and place the elements as needed */
  3100. var aDom = oSettings.sDom.split('');
  3101. var featureNode, cOption, nNewNode, cNext, sAttr, j;
  3102. for ( var i=0 ; i<aDom.length ; i++ )
  3103. {
  3104. featureNode = null;
  3105. cOption = aDom[i];
  3106. if ( cOption == '<' )
  3107. {
  3108. /* New container div */
  3109. nNewNode = $('<div/>')[0];
  3110. /* Check to see if we should append an id and/or a class name to the container */
  3111. cNext = aDom[i+1];
  3112. if ( cNext == "'" || cNext == '"' )
  3113. {
  3114. sAttr = "";
  3115. j = 2;
  3116. while ( aDom[i+j] != cNext )
  3117. {
  3118. sAttr += aDom[i+j];
  3119. j++;
  3120. }
  3121. /* Replace jQuery UI constants @todo depreciated */
  3122. if ( sAttr == "H" )
  3123. {
  3124. sAttr = classes.sJUIHeader;
  3125. }
  3126. else if ( sAttr == "F" )
  3127. {
  3128. sAttr = classes.sJUIFooter;
  3129. }
  3130. /* The attribute can be in the format of "#id.class", "#id" or "class" This logic
  3131. * breaks the string into parts and applies them as needed
  3132. */
  3133. if ( sAttr.indexOf('.') != -1 )
  3134. {
  3135. var aSplit = sAttr.split('.');
  3136. nNewNode.id = aSplit[0].substr(1, aSplit[0].length-1);
  3137. nNewNode.className = aSplit[1];
  3138. }
  3139. else if ( sAttr.charAt(0) == "#" )
  3140. {
  3141. nNewNode.id = sAttr.substr(1, sAttr.length-1);
  3142. }
  3143. else
  3144. {
  3145. nNewNode.className = sAttr;
  3146. }
  3147. i += j; /* Move along the position array */
  3148. }
  3149. insert.append( nNewNode );
  3150. insert = $(nNewNode);
  3151. }
  3152. else if ( cOption == '>' )
  3153. {
  3154. /* End container div */
  3155. insert = insert.parent();
  3156. }
  3157. // @todo Move options into their own plugins?
  3158. else if ( cOption == 'l' && features.bPaginate && features.bLengthChange )
  3159. {
  3160. /* Length */
  3161. featureNode = _fnFeatureHtmlLength( oSettings );
  3162. }
  3163. else if ( cOption == 'f' && features.bFilter )
  3164. {
  3165. /* Filter */
  3166. featureNode = _fnFeatureHtmlFilter( oSettings );
  3167. }
  3168. else if ( cOption == 'r' && features.bProcessing )
  3169. {
  3170. /* pRocessing */
  3171. featureNode = _fnFeatureHtmlProcessing( oSettings );
  3172. }
  3173. else if ( cOption == 't' )
  3174. {
  3175. /* Table */
  3176. featureNode = _fnFeatureHtmlTable( oSettings );
  3177. }
  3178. else if ( cOption == 'i' && features.bInfo )
  3179. {
  3180. /* Info */
  3181. featureNode = _fnFeatureHtmlInfo( oSettings );
  3182. }
  3183. else if ( cOption == 'p' && features.bPaginate )
  3184. {
  3185. /* Pagination */
  3186. featureNode = _fnFeatureHtmlPaginate( oSettings );
  3187. }
  3188. else if ( DataTable.ext.feature.length !== 0 )
  3189. {
  3190. /* Plug-in features */
  3191. var aoFeatures = DataTable.ext.feature;
  3192. for ( var k=0, kLen=aoFeatures.length ; k<kLen ; k++ )
  3193. {
  3194. if ( cOption == aoFeatures[k].cFeature )
  3195. {
  3196. featureNode = aoFeatures[k].fnInit( oSettings );
  3197. break;
  3198. }
  3199. }
  3200. }
  3201. /* Add to the 2D features array */
  3202. if ( featureNode )
  3203. {
  3204. var aanFeatures = oSettings.aanFeatures;
  3205. if ( ! aanFeatures[cOption] )
  3206. {
  3207. aanFeatures[cOption] = [];
  3208. }
  3209. aanFeatures[cOption].push( featureNode );
  3210. insert.append( featureNode );
  3211. }
  3212. }
  3213. /* Built our DOM structure - replace the holding div with what we want */
  3214. holding.replaceWith( insert );
  3215. oSettings.nHolding = null;
  3216. }
  3217. /**
  3218. * Use the DOM source to create up an array of header cells. The idea here is to
  3219. * create a layout grid (array) of rows x columns, which contains a reference
  3220. * to the cell that that point in the grid (regardless of col/rowspan), such that
  3221. * any column / row could be removed and the new grid constructed
  3222. * @param array {object} aLayout Array to store the calculated layout in
  3223. * @param {node} nThead The header/footer element for the table
  3224. * @memberof DataTable#oApi
  3225. */
  3226. function _fnDetectHeader ( aLayout, nThead )
  3227. {
  3228. var nTrs = $(nThead).children('tr');
  3229. var nTr, nCell;
  3230. var i, k, l, iLen, jLen, iColShifted, iColumn, iColspan, iRowspan;
  3231. var bUnique;
  3232. var fnShiftCol = function ( a, i, j ) {
  3233. var k = a[i];
  3234. while ( k[j] ) {
  3235. j++;
  3236. }
  3237. return j;
  3238. };
  3239. aLayout.splice( 0, aLayout.length );
  3240. /* We know how many rows there are in the layout - so prep it */
  3241. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  3242. {
  3243. aLayout.push( [] );
  3244. }
  3245. /* Calculate a layout array */
  3246. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  3247. {
  3248. nTr = nTrs[i];
  3249. iColumn = 0;
  3250. /* For every cell in the row... */
  3251. nCell = nTr.firstChild;
  3252. while ( nCell ) {
  3253. if ( nCell.nodeName.toUpperCase() == "TD" ||
  3254. nCell.nodeName.toUpperCase() == "TH" )
  3255. {
  3256. /* Get the col and rowspan attributes from the DOM and sanitise them */
  3257. iColspan = nCell.getAttribute('colspan') * 1;
  3258. iRowspan = nCell.getAttribute('rowspan') * 1;
  3259. iColspan = (!iColspan || iColspan===0 || iColspan===1) ? 1 : iColspan;
  3260. iRowspan = (!iRowspan || iRowspan===0 || iRowspan===1) ? 1 : iRowspan;
  3261. /* There might be colspan cells already in this row, so shift our target
  3262. * accordingly
  3263. */
  3264. iColShifted = fnShiftCol( aLayout, i, iColumn );
  3265. /* Cache calculation for unique columns */
  3266. bUnique = iColspan === 1 ? true : false;
  3267. /* If there is col / rowspan, copy the information into the layout grid */
  3268. for ( l=0 ; l<iColspan ; l++ )
  3269. {
  3270. for ( k=0 ; k<iRowspan ; k++ )
  3271. {
  3272. aLayout[i+k][iColShifted+l] = {
  3273. "cell": nCell,
  3274. "unique": bUnique
  3275. };
  3276. aLayout[i+k].nTr = nTr;
  3277. }
  3278. }
  3279. }
  3280. nCell = nCell.nextSibling;
  3281. }
  3282. }
  3283. }
  3284. /**
  3285. * Get an array of unique th elements, one for each column
  3286. * @param {object} oSettings dataTables settings object
  3287. * @param {node} nHeader automatically detect the layout from this node - optional
  3288. * @param {array} aLayout thead/tfoot layout from _fnDetectHeader - optional
  3289. * @returns array {node} aReturn list of unique th's
  3290. * @memberof DataTable#oApi
  3291. */
  3292. function _fnGetUniqueThs ( oSettings, nHeader, aLayout )
  3293. {
  3294. var aReturn = [];
  3295. if ( !aLayout )
  3296. {
  3297. aLayout = oSettings.aoHeader;
  3298. if ( nHeader )
  3299. {
  3300. aLayout = [];
  3301. _fnDetectHeader( aLayout, nHeader );
  3302. }
  3303. }
  3304. for ( var i=0, iLen=aLayout.length ; i<iLen ; i++ )
  3305. {
  3306. for ( var j=0, jLen=aLayout[i].length ; j<jLen ; j++ )
  3307. {
  3308. if ( aLayout[i][j].unique &&
  3309. (!aReturn[j] || !oSettings.bSortCellsTop) )
  3310. {
  3311. aReturn[j] = aLayout[i][j].cell;
  3312. }
  3313. }
  3314. }
  3315. return aReturn;
  3316. }
  3317. /**
  3318. * Create an Ajax call based on the table's settings, taking into account that
  3319. * parameters can have multiple forms, and backwards compatibility.
  3320. *
  3321. * @param {object} oSettings dataTables settings object
  3322. * @param {array} data Data to send to the server, required by
  3323. * DataTables - may be augmented by developer callbacks
  3324. * @param {function} fn Callback function to run when data is obtained
  3325. */
  3326. function _fnBuildAjax( oSettings, data, fn )
  3327. {
  3328. // Compatibility with 1.9-, allow fnServerData and event to manipulate
  3329. _fnCallbackFire( oSettings, 'aoServerParams', 'serverParams', [data] );
  3330. // Convert to object based for 1.10+ if using the old array scheme which can
  3331. // come from server-side processing or serverParams
  3332. if ( data && $.isArray(data) ) {
  3333. var tmp = {};
  3334. var rbracket = /(.*?)\[\]$/;
  3335. $.each( data, function (key, val) {
  3336. var match = val.name.match(rbracket);
  3337. if ( match ) {
  3338. // Support for arrays
  3339. var name = match[0];
  3340. if ( ! tmp[ name ] ) {
  3341. tmp[ name ] = [];
  3342. }
  3343. tmp[ name ].push( val.value );
  3344. }
  3345. else {
  3346. tmp[val.name] = val.value;
  3347. }
  3348. } );
  3349. data = tmp;
  3350. }
  3351. var ajaxData;
  3352. var ajax = oSettings.ajax;
  3353. var instance = oSettings.oInstance;
  3354. var callback = function ( json ) {
  3355. _fnCallbackFire( oSettings, null, 'xhr', [oSettings, json, oSettings.jqXHR] );
  3356. fn( json );
  3357. };
  3358. if ( $.isPlainObject( ajax ) && ajax.data )
  3359. {
  3360. ajaxData = ajax.data;
  3361. var newData = typeof ajaxData === 'function' ?
  3362. ajaxData( data, oSettings ) : // fn can manipulate data or return
  3363. ajaxData; // an object object or array to merge
  3364. // If the function returned something, use that alone
  3365. data = typeof ajaxData === 'function' && newData ?
  3366. newData :
  3367. $.extend( true, data, newData );
  3368. // Remove the data property as we've resolved it already and don't want
  3369. // jQuery to do it again (it is restored at the end of the function)
  3370. delete ajax.data;
  3371. }
  3372. var baseAjax = {
  3373. "data": data,
  3374. "success": function (json) {
  3375. var error = json.error || json.sError;
  3376. if ( error ) {
  3377. _fnLog( oSettings, 0, error );
  3378. }
  3379. oSettings.json = json;
  3380. callback( json );
  3381. },
  3382. "dataType": "json",
  3383. "cache": false,
  3384. "type": oSettings.sServerMethod,
  3385. "error": function (xhr, error, thrown) {
  3386. var ret = _fnCallbackFire( oSettings, null, 'xhr', [oSettings, null, oSettings.jqXHR] );
  3387. if ( $.inArray( true, ret ) === -1 ) {
  3388. if ( error == "parsererror" ) {
  3389. _fnLog( oSettings, 0, 'Invalid JSON response', 1 );
  3390. }
  3391. else if ( xhr.readyState === 4 ) {
  3392. _fnLog( oSettings, 0, 'Ajax error', 7 );
  3393. }
  3394. }
  3395. _fnProcessingDisplay( oSettings, false );
  3396. }
  3397. };
  3398. // Store the data submitted for the API
  3399. oSettings.oAjaxData = data;
  3400. // Allow plug-ins and external processes to modify the data
  3401. _fnCallbackFire( oSettings, null, 'preXhr', [oSettings, data] );
  3402. if ( oSettings.fnServerData )
  3403. {
  3404. // DataTables 1.9- compatibility
  3405. oSettings.fnServerData.call( instance,
  3406. oSettings.sAjaxSource,
  3407. $.map( data, function (val, key) { // Need to convert back to 1.9 trad format
  3408. return { name: key, value: val };
  3409. } ),
  3410. callback,
  3411. oSettings
  3412. );
  3413. }
  3414. else if ( oSettings.sAjaxSource || typeof ajax === 'string' )
  3415. {
  3416. // DataTables 1.9- compatibility
  3417. oSettings.jqXHR = $.ajax( $.extend( baseAjax, {
  3418. url: ajax || oSettings.sAjaxSource
  3419. } ) );
  3420. }
  3421. else if ( typeof ajax === 'function' )
  3422. {
  3423. // Is a function - let the caller define what needs to be done
  3424. oSettings.jqXHR = ajax.call( instance, data, callback, oSettings );
  3425. }
  3426. else
  3427. {
  3428. // Object to extend the base settings
  3429. oSettings.jqXHR = $.ajax( $.extend( baseAjax, ajax ) );
  3430. // Restore for next time around
  3431. ajax.data = ajaxData;
  3432. }
  3433. }
  3434. /**
  3435. * Update the table using an Ajax call
  3436. * @param {object} settings dataTables settings object
  3437. * @returns {boolean} Block the table drawing or not
  3438. * @memberof DataTable#oApi
  3439. */
  3440. function _fnAjaxUpdate( settings )
  3441. {
  3442. if ( settings.bAjaxDataGet ) {
  3443. settings.iDraw++;
  3444. _fnProcessingDisplay( settings, true );
  3445. _fnBuildAjax(
  3446. settings,
  3447. _fnAjaxParameters( settings ),
  3448. function(json) {
  3449. _fnAjaxUpdateDraw( settings, json );
  3450. }
  3451. );
  3452. return false;
  3453. }
  3454. return true;
  3455. }
  3456. /**
  3457. * Build up the parameters in an object needed for a server-side processing
  3458. * request. Note that this is basically done twice, is different ways - a modern
  3459. * method which is used by default in DataTables 1.10 which uses objects and
  3460. * arrays, or the 1.9- method with is name / value pairs. 1.9 method is used if
  3461. * the sAjaxSource option is used in the initialisation, or the legacyAjax
  3462. * option is set.
  3463. * @param {object} oSettings dataTables settings object
  3464. * @returns {bool} block the table drawing or not
  3465. * @memberof DataTable#oApi
  3466. */
  3467. function _fnAjaxParameters( settings )
  3468. {
  3469. var
  3470. columns = settings.aoColumns,
  3471. columnCount = columns.length,
  3472. features = settings.oFeatures,
  3473. preSearch = settings.oPreviousSearch,
  3474. preColSearch = settings.aoPreSearchCols,
  3475. i, data = [], dataProp, column, columnSearch,
  3476. sort = _fnSortFlatten( settings ),
  3477. displayStart = settings._iDisplayStart,
  3478. displayLength = features.bPaginate !== false ?
  3479. settings._iDisplayLength :
  3480. -1;
  3481. var param = function ( name, value ) {
  3482. data.push( { 'name': name, 'value': value } );
  3483. };
  3484. // DataTables 1.9- compatible method
  3485. param( 'sEcho', settings.iDraw );
  3486. param( 'iColumns', columnCount );
  3487. param( 'sColumns', _pluck( columns, 'sName' ).join(',') );
  3488. param( 'iDisplayStart', displayStart );
  3489. param( 'iDisplayLength', displayLength );
  3490. // DataTables 1.10+ method
  3491. var d = {
  3492. draw: settings.iDraw,
  3493. columns: [],
  3494. order: [],
  3495. start: displayStart,
  3496. length: displayLength,
  3497. search: {
  3498. value: preSearch.sSearch,
  3499. regex: preSearch.bRegex
  3500. }
  3501. };
  3502. for ( i=0 ; i<columnCount ; i++ ) {
  3503. column = columns[i];
  3504. columnSearch = preColSearch[i];
  3505. dataProp = typeof column.mData=="function" ? 'function' : column.mData ;
  3506. d.columns.push( {
  3507. data: dataProp,
  3508. name: column.sName,
  3509. searchable: column.bSearchable,
  3510. orderable: column.bSortable,
  3511. search: {
  3512. value: columnSearch.sSearch,
  3513. regex: columnSearch.bRegex
  3514. }
  3515. } );
  3516. param( "mDataProp_"+i, dataProp );
  3517. if ( features.bFilter ) {
  3518. param( 'sSearch_'+i, columnSearch.sSearch );
  3519. param( 'bRegex_'+i, columnSearch.bRegex );
  3520. param( 'bSearchable_'+i, column.bSearchable );
  3521. }
  3522. if ( features.bSort ) {
  3523. param( 'bSortable_'+i, column.bSortable );
  3524. }
  3525. }
  3526. if ( features.bFilter ) {
  3527. param( 'sSearch', preSearch.sSearch );
  3528. param( 'bRegex', preSearch.bRegex );
  3529. }
  3530. if ( features.bSort ) {
  3531. $.each( sort, function ( i, val ) {
  3532. d.order.push( { column: val.col, dir: val.dir } );
  3533. param( 'iSortCol_'+i, val.col );
  3534. param( 'sSortDir_'+i, val.dir );
  3535. } );
  3536. param( 'iSortingCols', sort.length );
  3537. }
  3538. // If the legacy.ajax parameter is null, then we automatically decide which
  3539. // form to use, based on sAjaxSource
  3540. var legacy = DataTable.ext.legacy.ajax;
  3541. if ( legacy === null ) {
  3542. return settings.sAjaxSource ? data : d;
  3543. }
  3544. // Otherwise, if legacy has been specified then we use that to decide on the
  3545. // form
  3546. return legacy ? data : d;
  3547. }
  3548. /**
  3549. * Data the data from the server (nuking the old) and redraw the table
  3550. * @param {object} oSettings dataTables settings object
  3551. * @param {object} json json data return from the server.
  3552. * @param {string} json.sEcho Tracking flag for DataTables to match requests
  3553. * @param {int} json.iTotalRecords Number of records in the data set, not accounting for filtering
  3554. * @param {int} json.iTotalDisplayRecords Number of records in the data set, accounting for filtering
  3555. * @param {array} json.aaData The data to display on this page
  3556. * @param {string} [json.sColumns] Column ordering (sName, comma separated)
  3557. * @memberof DataTable#oApi
  3558. */
  3559. function _fnAjaxUpdateDraw ( settings, json )
  3560. {
  3561. // v1.10 uses camelCase variables, while 1.9 uses Hungarian notation.
  3562. // Support both
  3563. var compat = function ( old, modern ) {
  3564. return json[old] !== undefined ? json[old] : json[modern];
  3565. };
  3566. var data = _fnAjaxDataSrc( settings, json );
  3567. var draw = compat( 'sEcho', 'draw' );
  3568. var recordsTotal = compat( 'iTotalRecords', 'recordsTotal' );
  3569. var recordsFiltered = compat( 'iTotalDisplayRecords', 'recordsFiltered' );
  3570. if ( draw ) {
  3571. // Protect against out of sequence returns
  3572. if ( draw*1 < settings.iDraw ) {
  3573. return;
  3574. }
  3575. settings.iDraw = draw * 1;
  3576. }
  3577. _fnClearTable( settings );
  3578. settings._iRecordsTotal = parseInt(recordsTotal, 10);
  3579. settings._iRecordsDisplay = parseInt(recordsFiltered, 10);
  3580. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  3581. _fnAddData( settings, data[i] );
  3582. }
  3583. settings.aiDisplay = settings.aiDisplayMaster.slice();
  3584. settings.bAjaxDataGet = false;
  3585. _fnDraw( settings );
  3586. if ( ! settings._bInitComplete ) {
  3587. _fnInitComplete( settings, json );
  3588. }
  3589. settings.bAjaxDataGet = true;
  3590. _fnProcessingDisplay( settings, false );
  3591. }
  3592. /**
  3593. * Get the data from the JSON data source to use for drawing a table. Using
  3594. * `_fnGetObjectDataFn` allows the data to be sourced from a property of the
  3595. * source object, or from a processing function.
  3596. * @param {object} oSettings dataTables settings object
  3597. * @param {object} json Data source object / array from the server
  3598. * @return {array} Array of data to use
  3599. */
  3600. function _fnAjaxDataSrc ( oSettings, json )
  3601. {
  3602. var dataSrc = $.isPlainObject( oSettings.ajax ) && oSettings.ajax.dataSrc !== undefined ?
  3603. oSettings.ajax.dataSrc :
  3604. oSettings.sAjaxDataProp; // Compatibility with 1.9-.
  3605. // Compatibility with 1.9-. In order to read from aaData, check if the
  3606. // default has been changed, if not, check for aaData
  3607. if ( dataSrc === 'data' ) {
  3608. return json.aaData || json[dataSrc];
  3609. }
  3610. return dataSrc !== "" ?
  3611. _fnGetObjectDataFn( dataSrc )( json ) :
  3612. json;
  3613. }
  3614. /**
  3615. * Generate the node required for filtering text
  3616. * @returns {node} Filter control element
  3617. * @param {object} oSettings dataTables settings object
  3618. * @memberof DataTable#oApi
  3619. */
  3620. function _fnFeatureHtmlFilter ( settings )
  3621. {
  3622. var classes = settings.oClasses;
  3623. var tableId = settings.sTableId;
  3624. var language = settings.oLanguage;
  3625. var previousSearch = settings.oPreviousSearch;
  3626. var features = settings.aanFeatures;
  3627. var input = '<input type="search" class="'+classes.sFilterInput+'"/>';
  3628. var str = language.sSearch;
  3629. str = str.match(/_INPUT_/) ?
  3630. str.replace('_INPUT_', input) :
  3631. str+input;
  3632. var filter = $('<div/>', {
  3633. 'id': ! features.f ? tableId+'_filter' : null,
  3634. 'class': classes.sFilter
  3635. } )
  3636. .append( $('<label/>' ).append( str ) );
  3637. var searchFn = function() {
  3638. /* Update all other filter input elements for the new display */
  3639. var n = features.f;
  3640. var val = !this.value ? "" : this.value; // mental IE8 fix :-(
  3641. /* Now do the filter */
  3642. if ( val != previousSearch.sSearch ) {
  3643. _fnFilterComplete( settings, {
  3644. "sSearch": val,
  3645. "bRegex": previousSearch.bRegex,
  3646. "bSmart": previousSearch.bSmart ,
  3647. "bCaseInsensitive": previousSearch.bCaseInsensitive
  3648. } );
  3649. // Need to redraw, without resorting
  3650. settings._iDisplayStart = 0;
  3651. _fnDraw( settings );
  3652. }
  3653. };
  3654. var searchDelay = settings.searchDelay !== null ?
  3655. settings.searchDelay :
  3656. _fnDataSource( settings ) === 'ssp' ?
  3657. 400 :
  3658. 0;
  3659. var jqFilter = $('input', filter)
  3660. .val( previousSearch.sSearch )
  3661. .attr( 'placeholder', language.sSearchPlaceholder )
  3662. .on(
  3663. 'keyup.DT search.DT input.DT paste.DT cut.DT',
  3664. searchDelay ?
  3665. _fnThrottle( searchFn, searchDelay ) :
  3666. searchFn
  3667. )
  3668. .on( 'keypress.DT', function(e) {
  3669. /* Prevent form submission */
  3670. if ( e.keyCode == 13 ) {
  3671. return false;
  3672. }
  3673. } )
  3674. .attr('aria-controls', tableId);
  3675. // Update the input elements whenever the table is filtered
  3676. $(settings.nTable).on( 'search.dt.DT', function ( ev, s ) {
  3677. if ( settings === s ) {
  3678. // IE9 throws an 'unknown error' if document.activeElement is used
  3679. // inside an iframe or frame...
  3680. try {
  3681. if ( jqFilter[0] !== document.activeElement ) {
  3682. jqFilter.val( previousSearch.sSearch );
  3683. }
  3684. }
  3685. catch ( e ) {}
  3686. }
  3687. } );
  3688. return filter[0];
  3689. }
  3690. /**
  3691. * Filter the table using both the global filter and column based filtering
  3692. * @param {object} oSettings dataTables settings object
  3693. * @param {object} oSearch search information
  3694. * @param {int} [iForce] force a research of the master array (1) or not (undefined or 0)
  3695. * @memberof DataTable#oApi
  3696. */
  3697. function _fnFilterComplete ( oSettings, oInput, iForce )
  3698. {
  3699. var oPrevSearch = oSettings.oPreviousSearch;
  3700. var aoPrevSearch = oSettings.aoPreSearchCols;
  3701. var fnSaveFilter = function ( oFilter ) {
  3702. /* Save the filtering values */
  3703. oPrevSearch.sSearch = oFilter.sSearch;
  3704. oPrevSearch.bRegex = oFilter.bRegex;
  3705. oPrevSearch.bSmart = oFilter.bSmart;
  3706. oPrevSearch.bCaseInsensitive = oFilter.bCaseInsensitive;
  3707. };
  3708. var fnRegex = function ( o ) {
  3709. // Backwards compatibility with the bEscapeRegex option
  3710. return o.bEscapeRegex !== undefined ? !o.bEscapeRegex : o.bRegex;
  3711. };
  3712. // Resolve any column types that are unknown due to addition or invalidation
  3713. // @todo As per sort - can this be moved into an event handler?
  3714. _fnColumnTypes( oSettings );
  3715. /* In server-side processing all filtering is done by the server, so no point hanging around here */
  3716. if ( _fnDataSource( oSettings ) != 'ssp' )
  3717. {
  3718. /* Global filter */
  3719. _fnFilter( oSettings, oInput.sSearch, iForce, fnRegex(oInput), oInput.bSmart, oInput.bCaseInsensitive );
  3720. fnSaveFilter( oInput );
  3721. /* Now do the individual column filter */
  3722. for ( var i=0 ; i<aoPrevSearch.length ; i++ )
  3723. {
  3724. _fnFilterColumn( oSettings, aoPrevSearch[i].sSearch, i, fnRegex(aoPrevSearch[i]),
  3725. aoPrevSearch[i].bSmart, aoPrevSearch[i].bCaseInsensitive );
  3726. }
  3727. /* Custom filtering */
  3728. _fnFilterCustom( oSettings );
  3729. }
  3730. else
  3731. {
  3732. fnSaveFilter( oInput );
  3733. }
  3734. /* Tell the draw function we have been filtering */
  3735. oSettings.bFiltered = true;
  3736. _fnCallbackFire( oSettings, null, 'search', [oSettings] );
  3737. }
  3738. /**
  3739. * Apply custom filtering functions
  3740. * @param {object} oSettings dataTables settings object
  3741. * @memberof DataTable#oApi
  3742. */
  3743. function _fnFilterCustom( settings )
  3744. {
  3745. var filters = DataTable.ext.search;
  3746. var displayRows = settings.aiDisplay;
  3747. var row, rowIdx;
  3748. for ( var i=0, ien=filters.length ; i<ien ; i++ ) {
  3749. var rows = [];
  3750. // Loop over each row and see if it should be included
  3751. for ( var j=0, jen=displayRows.length ; j<jen ; j++ ) {
  3752. rowIdx = displayRows[ j ];
  3753. row = settings.aoData[ rowIdx ];
  3754. if ( filters[i]( settings, row._aFilterData, rowIdx, row._aData, j ) ) {
  3755. rows.push( rowIdx );
  3756. }
  3757. }
  3758. // So the array reference doesn't break set the results into the
  3759. // existing array
  3760. displayRows.length = 0;
  3761. $.merge( displayRows, rows );
  3762. }
  3763. }
  3764. /**
  3765. * Filter the table on a per-column basis
  3766. * @param {object} oSettings dataTables settings object
  3767. * @param {string} sInput string to filter on
  3768. * @param {int} iColumn column to filter
  3769. * @param {bool} bRegex treat search string as a regular expression or not
  3770. * @param {bool} bSmart use smart filtering or not
  3771. * @param {bool} bCaseInsensitive Do case insenstive matching or not
  3772. * @memberof DataTable#oApi
  3773. */
  3774. function _fnFilterColumn ( settings, searchStr, colIdx, regex, smart, caseInsensitive )
  3775. {
  3776. if ( searchStr === '' ) {
  3777. return;
  3778. }
  3779. var data;
  3780. var out = [];
  3781. var display = settings.aiDisplay;
  3782. var rpSearch = _fnFilterCreateSearch( searchStr, regex, smart, caseInsensitive );
  3783. for ( var i=0 ; i<display.length ; i++ ) {
  3784. data = settings.aoData[ display[i] ]._aFilterData[ colIdx ];
  3785. if ( rpSearch.test( data ) ) {
  3786. out.push( display[i] );
  3787. }
  3788. }
  3789. settings.aiDisplay = out;
  3790. }
  3791. /**
  3792. * Filter the data table based on user input and draw the table
  3793. * @param {object} settings dataTables settings object
  3794. * @param {string} input string to filter on
  3795. * @param {int} force optional - force a research of the master array (1) or not (undefined or 0)
  3796. * @param {bool} regex treat as a regular expression or not
  3797. * @param {bool} smart perform smart filtering or not
  3798. * @param {bool} caseInsensitive Do case insenstive matching or not
  3799. * @memberof DataTable#oApi
  3800. */
  3801. function _fnFilter( settings, input, force, regex, smart, caseInsensitive )
  3802. {
  3803. var rpSearch = _fnFilterCreateSearch( input, regex, smart, caseInsensitive );
  3804. var prevSearch = settings.oPreviousSearch.sSearch;
  3805. var displayMaster = settings.aiDisplayMaster;
  3806. var display, invalidated, i;
  3807. var filtered = [];
  3808. // Need to take account of custom filtering functions - always filter
  3809. if ( DataTable.ext.search.length !== 0 ) {
  3810. force = true;
  3811. }
  3812. // Check if any of the rows were invalidated
  3813. invalidated = _fnFilterData( settings );
  3814. // If the input is blank - we just want the full data set
  3815. if ( input.length <= 0 ) {
  3816. settings.aiDisplay = displayMaster.slice();
  3817. }
  3818. else {
  3819. // New search - start from the master array
  3820. if ( invalidated ||
  3821. force ||
  3822. regex ||
  3823. prevSearch.length > input.length ||
  3824. input.indexOf(prevSearch) !== 0 ||
  3825. settings.bSorted // On resort, the display master needs to be
  3826. // re-filtered since indexes will have changed
  3827. ) {
  3828. settings.aiDisplay = displayMaster.slice();
  3829. }
  3830. // Search the display array
  3831. display = settings.aiDisplay;
  3832. for ( i=0 ; i<display.length ; i++ ) {
  3833. if ( rpSearch.test( settings.aoData[ display[i] ]._sFilterRow ) ) {
  3834. filtered.push( display[i] );
  3835. }
  3836. }
  3837. settings.aiDisplay = filtered;
  3838. }
  3839. }
  3840. /**
  3841. * Build a regular expression object suitable for searching a table
  3842. * @param {string} sSearch string to search for
  3843. * @param {bool} bRegex treat as a regular expression or not
  3844. * @param {bool} bSmart perform smart filtering or not
  3845. * @param {bool} bCaseInsensitive Do case insensitive matching or not
  3846. * @returns {RegExp} constructed object
  3847. * @memberof DataTable#oApi
  3848. */
  3849. function _fnFilterCreateSearch( search, regex, smart, caseInsensitive )
  3850. {
  3851. search = regex ?
  3852. search :
  3853. _fnEscapeRegex( search );
  3854. if ( smart ) {
  3855. /* For smart filtering we want to allow the search to work regardless of
  3856. * word order. We also want double quoted text to be preserved, so word
  3857. * order is important - a la google. So this is what we want to
  3858. * generate:
  3859. *
  3860. * ^(?=.*?\bone\b)(?=.*?\btwo three\b)(?=.*?\bfour\b).*$
  3861. */
  3862. var a = $.map( search.match( /"[^"]+"|[^ ]+/g ) || [''], function ( word ) {
  3863. if ( word.charAt(0) === '"' ) {
  3864. var m = word.match( /^"(.*)"$/ );
  3865. word = m ? m[1] : word;
  3866. }
  3867. return word.replace('"', '');
  3868. } );
  3869. search = '^(?=.*?'+a.join( ')(?=.*?' )+').*$';
  3870. }
  3871. return new RegExp( search, caseInsensitive ? 'i' : '' );
  3872. }
  3873. /**
  3874. * Escape a string such that it can be used in a regular expression
  3875. * @param {string} sVal string to escape
  3876. * @returns {string} escaped string
  3877. * @memberof DataTable#oApi
  3878. */
  3879. var _fnEscapeRegex = DataTable.util.escapeRegex;
  3880. var __filter_div = $('<div>')[0];
  3881. var __filter_div_textContent = __filter_div.textContent !== undefined;
  3882. // Update the filtering data for each row if needed (by invalidation or first run)
  3883. function _fnFilterData ( settings )
  3884. {
  3885. var columns = settings.aoColumns;
  3886. var column;
  3887. var i, j, ien, jen, filterData, cellData, row;
  3888. var fomatters = DataTable.ext.type.search;
  3889. var wasInvalidated = false;
  3890. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  3891. row = settings.aoData[i];
  3892. if ( ! row._aFilterData ) {
  3893. filterData = [];
  3894. for ( j=0, jen=columns.length ; j<jen ; j++ ) {
  3895. column = columns[j];
  3896. if ( column.bSearchable ) {
  3897. cellData = _fnGetCellData( settings, i, j, 'filter' );
  3898. if ( fomatters[ column.sType ] ) {
  3899. cellData = fomatters[ column.sType ]( cellData );
  3900. }
  3901. // Search in DataTables 1.10 is string based. In 1.11 this
  3902. // should be altered to also allow strict type checking.
  3903. if ( cellData === null ) {
  3904. cellData = '';
  3905. }
  3906. if ( typeof cellData !== 'string' && cellData.toString ) {
  3907. cellData = cellData.toString();
  3908. }
  3909. }
  3910. else {
  3911. cellData = '';
  3912. }
  3913. // If it looks like there is an HTML entity in the string,
  3914. // attempt to decode it so sorting works as expected. Note that
  3915. // we could use a single line of jQuery to do this, but the DOM
  3916. // method used here is much faster http://jsperf.com/html-decode
  3917. if ( cellData.indexOf && cellData.indexOf('&') !== -1 ) {
  3918. __filter_div.innerHTML = cellData;
  3919. cellData = __filter_div_textContent ?
  3920. __filter_div.textContent :
  3921. __filter_div.innerText;
  3922. }
  3923. if ( cellData.replace ) {
  3924. cellData = cellData.replace(/[\r\n\u2028]/g, '');
  3925. }
  3926. filterData.push( cellData );
  3927. }
  3928. row._aFilterData = filterData;
  3929. row._sFilterRow = filterData.join(' ');
  3930. wasInvalidated = true;
  3931. }
  3932. }
  3933. return wasInvalidated;
  3934. }
  3935. /**
  3936. * Convert from the internal Hungarian notation to camelCase for external
  3937. * interaction
  3938. * @param {object} obj Object to convert
  3939. * @returns {object} Inverted object
  3940. * @memberof DataTable#oApi
  3941. */
  3942. function _fnSearchToCamel ( obj )
  3943. {
  3944. return {
  3945. search: obj.sSearch,
  3946. smart: obj.bSmart,
  3947. regex: obj.bRegex,
  3948. caseInsensitive: obj.bCaseInsensitive
  3949. };
  3950. }
  3951. /**
  3952. * Convert from camelCase notation to the internal Hungarian. We could use the
  3953. * Hungarian convert function here, but this is cleaner
  3954. * @param {object} obj Object to convert
  3955. * @returns {object} Inverted object
  3956. * @memberof DataTable#oApi
  3957. */
  3958. function _fnSearchToHung ( obj )
  3959. {
  3960. return {
  3961. sSearch: obj.search,
  3962. bSmart: obj.smart,
  3963. bRegex: obj.regex,
  3964. bCaseInsensitive: obj.caseInsensitive
  3965. };
  3966. }
  3967. /**
  3968. * Generate the node required for the info display
  3969. * @param {object} oSettings dataTables settings object
  3970. * @returns {node} Information element
  3971. * @memberof DataTable#oApi
  3972. */
  3973. function _fnFeatureHtmlInfo ( settings )
  3974. {
  3975. var
  3976. tid = settings.sTableId,
  3977. nodes = settings.aanFeatures.i,
  3978. n = $('<div/>', {
  3979. 'class': settings.oClasses.sInfo,
  3980. 'id': ! nodes ? tid+'_info' : null
  3981. } );
  3982. if ( ! nodes ) {
  3983. // Update display on each draw
  3984. settings.aoDrawCallback.push( {
  3985. "fn": _fnUpdateInfo,
  3986. "sName": "information"
  3987. } );
  3988. n
  3989. .attr( 'role', 'status' )
  3990. .attr( 'aria-live', 'polite' );
  3991. // Table is described by our info div
  3992. $(settings.nTable).attr( 'aria-describedby', tid+'_info' );
  3993. }
  3994. return n[0];
  3995. }
  3996. /**
  3997. * Update the information elements in the display
  3998. * @param {object} settings dataTables settings object
  3999. * @memberof DataTable#oApi
  4000. */
  4001. function _fnUpdateInfo ( settings )
  4002. {
  4003. /* Show information about the table */
  4004. var nodes = settings.aanFeatures.i;
  4005. if ( nodes.length === 0 ) {
  4006. return;
  4007. }
  4008. var
  4009. lang = settings.oLanguage,
  4010. start = settings._iDisplayStart+1,
  4011. end = settings.fnDisplayEnd(),
  4012. max = settings.fnRecordsTotal(),
  4013. total = settings.fnRecordsDisplay(),
  4014. out = total ?
  4015. lang.sInfo :
  4016. lang.sInfoEmpty;
  4017. if ( total !== max ) {
  4018. /* Record set after filtering */
  4019. out += ' ' + lang.sInfoFiltered;
  4020. }
  4021. // Convert the macros
  4022. out += lang.sInfoPostFix;
  4023. out = _fnInfoMacros( settings, out );
  4024. var callback = lang.fnInfoCallback;
  4025. if ( callback !== null ) {
  4026. out = callback.call( settings.oInstance,
  4027. settings, start, end, max, total, out
  4028. );
  4029. }
  4030. $(nodes).html( out );
  4031. }
  4032. function _fnInfoMacros ( settings, str )
  4033. {
  4034. // When infinite scrolling, we are always starting at 1. _iDisplayStart is used only
  4035. // internally
  4036. var
  4037. formatter = settings.fnFormatNumber,
  4038. start = settings._iDisplayStart+1,
  4039. len = settings._iDisplayLength,
  4040. vis = settings.fnRecordsDisplay(),
  4041. all = len === -1;
  4042. return str.
  4043. replace(/_START_/g, formatter.call( settings, start ) ).
  4044. replace(/_END_/g, formatter.call( settings, settings.fnDisplayEnd() ) ).
  4045. replace(/_MAX_/g, formatter.call( settings, settings.fnRecordsTotal() ) ).
  4046. replace(/_TOTAL_/g, formatter.call( settings, vis ) ).
  4047. replace(/_PAGE_/g, formatter.call( settings, all ? 1 : Math.ceil( start / len ) ) ).
  4048. replace(/_PAGES_/g, formatter.call( settings, all ? 1 : Math.ceil( vis / len ) ) );
  4049. }
  4050. /**
  4051. * Draw the table for the first time, adding all required features
  4052. * @param {object} settings dataTables settings object
  4053. * @memberof DataTable#oApi
  4054. */
  4055. function _fnInitialise ( settings )
  4056. {
  4057. var i, iLen, iAjaxStart=settings.iInitDisplayStart;
  4058. var columns = settings.aoColumns, column;
  4059. var features = settings.oFeatures;
  4060. var deferLoading = settings.bDeferLoading; // value modified by the draw
  4061. /* Ensure that the table data is fully initialised */
  4062. if ( ! settings.bInitialised ) {
  4063. setTimeout( function(){ _fnInitialise( settings ); }, 200 );
  4064. return;
  4065. }
  4066. /* Show the display HTML options */
  4067. _fnAddOptionsHtml( settings );
  4068. /* Build and draw the header / footer for the table */
  4069. _fnBuildHead( settings );
  4070. _fnDrawHead( settings, settings.aoHeader );
  4071. _fnDrawHead( settings, settings.aoFooter );
  4072. /* Okay to show that something is going on now */
  4073. _fnProcessingDisplay( settings, true );
  4074. /* Calculate sizes for columns */
  4075. if ( features.bAutoWidth ) {
  4076. _fnCalculateColumnWidths( settings );
  4077. }
  4078. for ( i=0, iLen=columns.length ; i<iLen ; i++ ) {
  4079. column = columns[i];
  4080. if ( column.sWidth ) {
  4081. column.nTh.style.width = _fnStringToCss( column.sWidth );
  4082. }
  4083. }
  4084. _fnCallbackFire( settings, null, 'preInit', [settings] );
  4085. // If there is default sorting required - let's do it. The sort function
  4086. // will do the drawing for us. Otherwise we draw the table regardless of the
  4087. // Ajax source - this allows the table to look initialised for Ajax sourcing
  4088. // data (show 'loading' message possibly)
  4089. _fnReDraw( settings );
  4090. // Server-side processing init complete is done by _fnAjaxUpdateDraw
  4091. var dataSrc = _fnDataSource( settings );
  4092. if ( dataSrc != 'ssp' || deferLoading ) {
  4093. // if there is an ajax source load the data
  4094. if ( dataSrc == 'ajax' ) {
  4095. _fnBuildAjax( settings, [], function(json) {
  4096. var aData = _fnAjaxDataSrc( settings, json );
  4097. // Got the data - add it to the table
  4098. for ( i=0 ; i<aData.length ; i++ ) {
  4099. _fnAddData( settings, aData[i] );
  4100. }
  4101. // Reset the init display for cookie saving. We've already done
  4102. // a filter, and therefore cleared it before. So we need to make
  4103. // it appear 'fresh'
  4104. settings.iInitDisplayStart = iAjaxStart;
  4105. _fnReDraw( settings );
  4106. _fnProcessingDisplay( settings, false );
  4107. _fnInitComplete( settings, json );
  4108. }, settings );
  4109. }
  4110. else {
  4111. _fnProcessingDisplay( settings, false );
  4112. _fnInitComplete( settings );
  4113. }
  4114. }
  4115. }
  4116. /**
  4117. * Draw the table for the first time, adding all required features
  4118. * @param {object} oSettings dataTables settings object
  4119. * @param {object} [json] JSON from the server that completed the table, if using Ajax source
  4120. * with client-side processing (optional)
  4121. * @memberof DataTable#oApi
  4122. */
  4123. function _fnInitComplete ( settings, json )
  4124. {
  4125. settings._bInitComplete = true;
  4126. // When data was added after the initialisation (data or Ajax) we need to
  4127. // calculate the column sizing
  4128. if ( json || settings.oInit.aaData ) {
  4129. _fnAdjustColumnSizing( settings );
  4130. }
  4131. _fnCallbackFire( settings, null, 'plugin-init', [settings, json] );
  4132. _fnCallbackFire( settings, 'aoInitComplete', 'init', [settings, json] );
  4133. }
  4134. function _fnLengthChange ( settings, val )
  4135. {
  4136. var len = parseInt( val, 10 );
  4137. settings._iDisplayLength = len;
  4138. _fnLengthOverflow( settings );
  4139. // Fire length change event
  4140. _fnCallbackFire( settings, null, 'length', [settings, len] );
  4141. }
  4142. /**
  4143. * Generate the node required for user display length changing
  4144. * @param {object} settings dataTables settings object
  4145. * @returns {node} Display length feature node
  4146. * @memberof DataTable#oApi
  4147. */
  4148. function _fnFeatureHtmlLength ( settings )
  4149. {
  4150. var
  4151. classes = settings.oClasses,
  4152. tableId = settings.sTableId,
  4153. menu = settings.aLengthMenu,
  4154. d2 = $.isArray( menu[0] ),
  4155. lengths = d2 ? menu[0] : menu,
  4156. language = d2 ? menu[1] : menu;
  4157. var select = $('<select/>', {
  4158. 'name': tableId+'_length',
  4159. 'aria-controls': tableId,
  4160. 'class': classes.sLengthSelect
  4161. } );
  4162. for ( var i=0, ien=lengths.length ; i<ien ; i++ ) {
  4163. select[0][ i ] = new Option(
  4164. typeof language[i] === 'number' ?
  4165. settings.fnFormatNumber( language[i] ) :
  4166. language[i],
  4167. lengths[i]
  4168. );
  4169. }
  4170. var div = $('<div><label/></div>').addClass( classes.sLength );
  4171. if ( ! settings.aanFeatures.l ) {
  4172. div[0].id = tableId+'_length';
  4173. }
  4174. div.children().append(
  4175. settings.oLanguage.sLengthMenu.replace( '_MENU_', select[0].outerHTML )
  4176. );
  4177. // Can't use `select` variable as user might provide their own and the
  4178. // reference is broken by the use of outerHTML
  4179. $('select', div)
  4180. .val( settings._iDisplayLength )
  4181. .on( 'change.DT', function(e) {
  4182. _fnLengthChange( settings, $(this).val() );
  4183. _fnDraw( settings );
  4184. } );
  4185. // Update node value whenever anything changes the table's length
  4186. $(settings.nTable).on( 'length.dt.DT', function (e, s, len) {
  4187. if ( settings === s ) {
  4188. $('select', div).val( len );
  4189. }
  4190. } );
  4191. return div[0];
  4192. }
  4193. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  4194. * Note that most of the paging logic is done in
  4195. * DataTable.ext.pager
  4196. */
  4197. /**
  4198. * Generate the node required for default pagination
  4199. * @param {object} oSettings dataTables settings object
  4200. * @returns {node} Pagination feature node
  4201. * @memberof DataTable#oApi
  4202. */
  4203. function _fnFeatureHtmlPaginate ( settings )
  4204. {
  4205. var
  4206. type = settings.sPaginationType,
  4207. plugin = DataTable.ext.pager[ type ],
  4208. modern = typeof plugin === 'function',
  4209. redraw = function( settings ) {
  4210. _fnDraw( settings );
  4211. },
  4212. node = $('<div/>').addClass( settings.oClasses.sPaging + type )[0],
  4213. features = settings.aanFeatures;
  4214. if ( ! modern ) {
  4215. plugin.fnInit( settings, node, redraw );
  4216. }
  4217. /* Add a draw callback for the pagination on first instance, to update the paging display */
  4218. if ( ! features.p )
  4219. {
  4220. node.id = settings.sTableId+'_paginate';
  4221. settings.aoDrawCallback.push( {
  4222. "fn": function( settings ) {
  4223. if ( modern ) {
  4224. var
  4225. start = settings._iDisplayStart,
  4226. len = settings._iDisplayLength,
  4227. visRecords = settings.fnRecordsDisplay(),
  4228. all = len === -1,
  4229. page = all ? 0 : Math.ceil( start / len ),
  4230. pages = all ? 1 : Math.ceil( visRecords / len ),
  4231. buttons = plugin(page, pages),
  4232. i, ien;
  4233. for ( i=0, ien=features.p.length ; i<ien ; i++ ) {
  4234. _fnRenderer( settings, 'pageButton' )(
  4235. settings, features.p[i], i, buttons, page, pages
  4236. );
  4237. }
  4238. }
  4239. else {
  4240. plugin.fnUpdate( settings, redraw );
  4241. }
  4242. },
  4243. "sName": "pagination"
  4244. } );
  4245. }
  4246. return node;
  4247. }
  4248. /**
  4249. * Alter the display settings to change the page
  4250. * @param {object} settings DataTables settings object
  4251. * @param {string|int} action Paging action to take: "first", "previous",
  4252. * "next" or "last" or page number to jump to (integer)
  4253. * @param [bool] redraw Automatically draw the update or not
  4254. * @returns {bool} true page has changed, false - no change
  4255. * @memberof DataTable#oApi
  4256. */
  4257. function _fnPageChange ( settings, action, redraw )
  4258. {
  4259. var
  4260. start = settings._iDisplayStart,
  4261. len = settings._iDisplayLength,
  4262. records = settings.fnRecordsDisplay();
  4263. if ( records === 0 || len === -1 )
  4264. {
  4265. start = 0;
  4266. }
  4267. else if ( typeof action === "number" )
  4268. {
  4269. start = action * len;
  4270. if ( start > records )
  4271. {
  4272. start = 0;
  4273. }
  4274. }
  4275. else if ( action == "first" )
  4276. {
  4277. start = 0;
  4278. }
  4279. else if ( action == "previous" )
  4280. {
  4281. start = len >= 0 ?
  4282. start - len :
  4283. 0;
  4284. if ( start < 0 )
  4285. {
  4286. start = 0;
  4287. }
  4288. }
  4289. else if ( action == "next" )
  4290. {
  4291. if ( start + len < records )
  4292. {
  4293. start += len;
  4294. }
  4295. }
  4296. else if ( action == "last" )
  4297. {
  4298. start = Math.floor( (records-1) / len) * len;
  4299. }
  4300. else
  4301. {
  4302. _fnLog( settings, 0, "Unknown paging action: "+action, 5 );
  4303. }
  4304. var changed = settings._iDisplayStart !== start;
  4305. settings._iDisplayStart = start;
  4306. if ( changed ) {
  4307. _fnCallbackFire( settings, null, 'page', [settings] );
  4308. if ( redraw ) {
  4309. _fnDraw( settings );
  4310. }
  4311. }
  4312. return changed;
  4313. }
  4314. /**
  4315. * Generate the node required for the processing node
  4316. * @param {object} settings dataTables settings object
  4317. * @returns {node} Processing element
  4318. * @memberof DataTable#oApi
  4319. */
  4320. function _fnFeatureHtmlProcessing ( settings )
  4321. {
  4322. return $('<div/>', {
  4323. 'id': ! settings.aanFeatures.r ? settings.sTableId+'_processing' : null,
  4324. 'class': settings.oClasses.sProcessing
  4325. } )
  4326. .html( settings.oLanguage.sProcessing )
  4327. .insertBefore( settings.nTable )[0];
  4328. }
  4329. /**
  4330. * Display or hide the processing indicator
  4331. * @param {object} settings dataTables settings object
  4332. * @param {bool} show Show the processing indicator (true) or not (false)
  4333. * @memberof DataTable#oApi
  4334. */
  4335. function _fnProcessingDisplay ( settings, show )
  4336. {
  4337. if ( settings.oFeatures.bProcessing ) {
  4338. $(settings.aanFeatures.r).css( 'display', show ? 'block' : 'none' );
  4339. }
  4340. _fnCallbackFire( settings, null, 'processing', [settings, show] );
  4341. }
  4342. /**
  4343. * Add any control elements for the table - specifically scrolling
  4344. * @param {object} settings dataTables settings object
  4345. * @returns {node} Node to add to the DOM
  4346. * @memberof DataTable#oApi
  4347. */
  4348. function _fnFeatureHtmlTable ( settings )
  4349. {
  4350. var table = $(settings.nTable);
  4351. // Add the ARIA grid role to the table
  4352. table.attr( 'role', 'grid' );
  4353. // Scrolling from here on in
  4354. var scroll = settings.oScroll;
  4355. if ( scroll.sX === '' && scroll.sY === '' ) {
  4356. return settings.nTable;
  4357. }
  4358. var scrollX = scroll.sX;
  4359. var scrollY = scroll.sY;
  4360. var classes = settings.oClasses;
  4361. var caption = table.children('caption');
  4362. var captionSide = caption.length ? caption[0]._captionSide : null;
  4363. var headerClone = $( table[0].cloneNode(false) );
  4364. var footerClone = $( table[0].cloneNode(false) );
  4365. var footer = table.children('tfoot');
  4366. var _div = '<div/>';
  4367. var size = function ( s ) {
  4368. return !s ? null : _fnStringToCss( s );
  4369. };
  4370. if ( ! footer.length ) {
  4371. footer = null;
  4372. }
  4373. /*
  4374. * The HTML structure that we want to generate in this function is:
  4375. * div - scroller
  4376. * div - scroll head
  4377. * div - scroll head inner
  4378. * table - scroll head table
  4379. * thead - thead
  4380. * div - scroll body
  4381. * table - table (master table)
  4382. * thead - thead clone for sizing
  4383. * tbody - tbody
  4384. * div - scroll foot
  4385. * div - scroll foot inner
  4386. * table - scroll foot table
  4387. * tfoot - tfoot
  4388. */
  4389. var scroller = $( _div, { 'class': classes.sScrollWrapper } )
  4390. .append(
  4391. $(_div, { 'class': classes.sScrollHead } )
  4392. .css( {
  4393. overflow: 'hidden',
  4394. position: 'relative',
  4395. border: 0,
  4396. width: scrollX ? size(scrollX) : '100%'
  4397. } )
  4398. .append(
  4399. $(_div, { 'class': classes.sScrollHeadInner } )
  4400. .css( {
  4401. 'box-sizing': 'content-box',
  4402. width: scroll.sXInner || '100%'
  4403. } )
  4404. .append(
  4405. headerClone
  4406. .removeAttr('id')
  4407. .css( 'margin-left', 0 )
  4408. .append( captionSide === 'top' ? caption : null )
  4409. .append(
  4410. table.children('thead')
  4411. )
  4412. )
  4413. )
  4414. )
  4415. .append(
  4416. $(_div, { 'class': classes.sScrollBody } )
  4417. .css( {
  4418. position: 'relative',
  4419. overflow: 'auto',
  4420. width: size( scrollX )
  4421. } )
  4422. .append( table )
  4423. );
  4424. if ( footer ) {
  4425. scroller.append(
  4426. $(_div, { 'class': classes.sScrollFoot } )
  4427. .css( {
  4428. overflow: 'hidden',
  4429. border: 0,
  4430. width: scrollX ? size(scrollX) : '100%'
  4431. } )
  4432. .append(
  4433. $(_div, { 'class': classes.sScrollFootInner } )
  4434. .append(
  4435. footerClone
  4436. .removeAttr('id')
  4437. .css( 'margin-left', 0 )
  4438. .append( captionSide === 'bottom' ? caption : null )
  4439. .append(
  4440. table.children('tfoot')
  4441. )
  4442. )
  4443. )
  4444. );
  4445. }
  4446. var children = scroller.children();
  4447. var scrollHead = children[0];
  4448. var scrollBody = children[1];
  4449. var scrollFoot = footer ? children[2] : null;
  4450. // When the body is scrolled, then we also want to scroll the headers
  4451. if ( scrollX ) {
  4452. $(scrollBody).on( 'scroll.DT', function (e) {
  4453. var scrollLeft = this.scrollLeft;
  4454. scrollHead.scrollLeft = scrollLeft;
  4455. if ( footer ) {
  4456. scrollFoot.scrollLeft = scrollLeft;
  4457. }
  4458. } );
  4459. }
  4460. $(scrollBody).css(
  4461. scrollY && scroll.bCollapse ? 'max-height' : 'height',
  4462. scrollY
  4463. );
  4464. settings.nScrollHead = scrollHead;
  4465. settings.nScrollBody = scrollBody;
  4466. settings.nScrollFoot = scrollFoot;
  4467. // On redraw - align columns
  4468. settings.aoDrawCallback.push( {
  4469. "fn": _fnScrollDraw,
  4470. "sName": "scrolling"
  4471. } );
  4472. return scroller[0];
  4473. }
  4474. /**
  4475. * Update the header, footer and body tables for resizing - i.e. column
  4476. * alignment.
  4477. *
  4478. * Welcome to the most horrible function DataTables. The process that this
  4479. * function follows is basically:
  4480. * 1. Re-create the table inside the scrolling div
  4481. * 2. Take live measurements from the DOM
  4482. * 3. Apply the measurements to align the columns
  4483. * 4. Clean up
  4484. *
  4485. * @param {object} settings dataTables settings object
  4486. * @memberof DataTable#oApi
  4487. */
  4488. function _fnScrollDraw ( settings )
  4489. {
  4490. // Given that this is such a monster function, a lot of variables are use
  4491. // to try and keep the minimised size as small as possible
  4492. var
  4493. scroll = settings.oScroll,
  4494. scrollX = scroll.sX,
  4495. scrollXInner = scroll.sXInner,
  4496. scrollY = scroll.sY,
  4497. barWidth = scroll.iBarWidth,
  4498. divHeader = $(settings.nScrollHead),
  4499. divHeaderStyle = divHeader[0].style,
  4500. divHeaderInner = divHeader.children('div'),
  4501. divHeaderInnerStyle = divHeaderInner[0].style,
  4502. divHeaderTable = divHeaderInner.children('table'),
  4503. divBodyEl = settings.nScrollBody,
  4504. divBody = $(divBodyEl),
  4505. divBodyStyle = divBodyEl.style,
  4506. divFooter = $(settings.nScrollFoot),
  4507. divFooterInner = divFooter.children('div'),
  4508. divFooterTable = divFooterInner.children('table'),
  4509. header = $(settings.nTHead),
  4510. table = $(settings.nTable),
  4511. tableEl = table[0],
  4512. tableStyle = tableEl.style,
  4513. footer = settings.nTFoot ? $(settings.nTFoot) : null,
  4514. browser = settings.oBrowser,
  4515. ie67 = browser.bScrollOversize,
  4516. dtHeaderCells = _pluck( settings.aoColumns, 'nTh' ),
  4517. headerTrgEls, footerTrgEls,
  4518. headerSrcEls, footerSrcEls,
  4519. headerCopy, footerCopy,
  4520. headerWidths=[], footerWidths=[],
  4521. headerContent=[], footerContent=[],
  4522. idx, correction, sanityWidth,
  4523. zeroOut = function(nSizer) {
  4524. var style = nSizer.style;
  4525. style.paddingTop = "0";
  4526. style.paddingBottom = "0";
  4527. style.borderTopWidth = "0";
  4528. style.borderBottomWidth = "0";
  4529. style.height = 0;
  4530. };
  4531. // If the scrollbar visibility has changed from the last draw, we need to
  4532. // adjust the column sizes as the table width will have changed to account
  4533. // for the scrollbar
  4534. var scrollBarVis = divBodyEl.scrollHeight > divBodyEl.clientHeight;
  4535. if ( settings.scrollBarVis !== scrollBarVis && settings.scrollBarVis !== undefined ) {
  4536. settings.scrollBarVis = scrollBarVis;
  4537. _fnAdjustColumnSizing( settings );
  4538. return; // adjust column sizing will call this function again
  4539. }
  4540. else {
  4541. settings.scrollBarVis = scrollBarVis;
  4542. }
  4543. /*
  4544. * 1. Re-create the table inside the scrolling div
  4545. */
  4546. // Remove the old minimised thead and tfoot elements in the inner table
  4547. table.children('thead, tfoot').remove();
  4548. if ( footer ) {
  4549. footerCopy = footer.clone().prependTo( table );
  4550. footerTrgEls = footer.find('tr'); // the original tfoot is in its own table and must be sized
  4551. footerSrcEls = footerCopy.find('tr');
  4552. }
  4553. // Clone the current header and footer elements and then place it into the inner table
  4554. headerCopy = header.clone().prependTo( table );
  4555. headerTrgEls = header.find('tr'); // original header is in its own table
  4556. headerSrcEls = headerCopy.find('tr');
  4557. headerCopy.find('th, td').removeAttr('tabindex');
  4558. /*
  4559. * 2. Take live measurements from the DOM - do not alter the DOM itself!
  4560. */
  4561. // Remove old sizing and apply the calculated column widths
  4562. // Get the unique column headers in the newly created (cloned) header. We want to apply the
  4563. // calculated sizes to this header
  4564. if ( ! scrollX )
  4565. {
  4566. divBodyStyle.width = '100%';
  4567. divHeader[0].style.width = '100%';
  4568. }
  4569. $.each( _fnGetUniqueThs( settings, headerCopy ), function ( i, el ) {
  4570. idx = _fnVisibleToColumnIndex( settings, i );
  4571. el.style.width = settings.aoColumns[idx].sWidth;
  4572. } );
  4573. if ( footer ) {
  4574. _fnApplyToChildren( function(n) {
  4575. n.style.width = "";
  4576. }, footerSrcEls );
  4577. }
  4578. // Size the table as a whole
  4579. sanityWidth = table.outerWidth();
  4580. if ( scrollX === "" ) {
  4581. // No x scrolling
  4582. tableStyle.width = "100%";
  4583. // IE7 will make the width of the table when 100% include the scrollbar
  4584. // - which is shouldn't. When there is a scrollbar we need to take this
  4585. // into account.
  4586. if ( ie67 && (table.find('tbody').height() > divBodyEl.offsetHeight ||
  4587. divBody.css('overflow-y') == "scroll")
  4588. ) {
  4589. tableStyle.width = _fnStringToCss( table.outerWidth() - barWidth);
  4590. }
  4591. // Recalculate the sanity width
  4592. sanityWidth = table.outerWidth();
  4593. }
  4594. else if ( scrollXInner !== "" ) {
  4595. // legacy x scroll inner has been given - use it
  4596. tableStyle.width = _fnStringToCss(scrollXInner);
  4597. // Recalculate the sanity width
  4598. sanityWidth = table.outerWidth();
  4599. }
  4600. // Hidden header should have zero height, so remove padding and borders. Then
  4601. // set the width based on the real headers
  4602. // Apply all styles in one pass
  4603. _fnApplyToChildren( zeroOut, headerSrcEls );
  4604. // Read all widths in next pass
  4605. _fnApplyToChildren( function(nSizer) {
  4606. headerContent.push( nSizer.innerHTML );
  4607. headerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  4608. }, headerSrcEls );
  4609. // Apply all widths in final pass
  4610. _fnApplyToChildren( function(nToSize, i) {
  4611. // Only apply widths to the DataTables detected header cells - this
  4612. // prevents complex headers from having contradictory sizes applied
  4613. if ( $.inArray( nToSize, dtHeaderCells ) !== -1 ) {
  4614. nToSize.style.width = headerWidths[i];
  4615. }
  4616. }, headerTrgEls );
  4617. $(headerSrcEls).height(0);
  4618. /* Same again with the footer if we have one */
  4619. if ( footer )
  4620. {
  4621. _fnApplyToChildren( zeroOut, footerSrcEls );
  4622. _fnApplyToChildren( function(nSizer) {
  4623. footerContent.push( nSizer.innerHTML );
  4624. footerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  4625. }, footerSrcEls );
  4626. _fnApplyToChildren( function(nToSize, i) {
  4627. nToSize.style.width = footerWidths[i];
  4628. }, footerTrgEls );
  4629. $(footerSrcEls).height(0);
  4630. }
  4631. /*
  4632. * 3. Apply the measurements
  4633. */
  4634. // "Hide" the header and footer that we used for the sizing. We need to keep
  4635. // the content of the cell so that the width applied to the header and body
  4636. // both match, but we want to hide it completely. We want to also fix their
  4637. // width to what they currently are
  4638. _fnApplyToChildren( function(nSizer, i) {
  4639. nSizer.innerHTML = '<div class="dataTables_sizing">'+headerContent[i]+'</div>';
  4640. nSizer.childNodes[0].style.height = "0";
  4641. nSizer.childNodes[0].style.overflow = "hidden";
  4642. nSizer.style.width = headerWidths[i];
  4643. }, headerSrcEls );
  4644. if ( footer )
  4645. {
  4646. _fnApplyToChildren( function(nSizer, i) {
  4647. nSizer.innerHTML = '<div class="dataTables_sizing">'+footerContent[i]+'</div>';
  4648. nSizer.childNodes[0].style.height = "0";
  4649. nSizer.childNodes[0].style.overflow = "hidden";
  4650. nSizer.style.width = footerWidths[i];
  4651. }, footerSrcEls );
  4652. }
  4653. // Sanity check that the table is of a sensible width. If not then we are going to get
  4654. // misalignment - try to prevent this by not allowing the table to shrink below its min width
  4655. if ( table.outerWidth() < sanityWidth )
  4656. {
  4657. // The min width depends upon if we have a vertical scrollbar visible or not */
  4658. correction = ((divBodyEl.scrollHeight > divBodyEl.offsetHeight ||
  4659. divBody.css('overflow-y') == "scroll")) ?
  4660. sanityWidth+barWidth :
  4661. sanityWidth;
  4662. // IE6/7 are a law unto themselves...
  4663. if ( ie67 && (divBodyEl.scrollHeight >
  4664. divBodyEl.offsetHeight || divBody.css('overflow-y') == "scroll")
  4665. ) {
  4666. tableStyle.width = _fnStringToCss( correction-barWidth );
  4667. }
  4668. // And give the user a warning that we've stopped the table getting too small
  4669. if ( scrollX === "" || scrollXInner !== "" ) {
  4670. _fnLog( settings, 1, 'Possible column misalignment', 6 );
  4671. }
  4672. }
  4673. else
  4674. {
  4675. correction = '100%';
  4676. }
  4677. // Apply to the container elements
  4678. divBodyStyle.width = _fnStringToCss( correction );
  4679. divHeaderStyle.width = _fnStringToCss( correction );
  4680. if ( footer ) {
  4681. settings.nScrollFoot.style.width = _fnStringToCss( correction );
  4682. }
  4683. /*
  4684. * 4. Clean up
  4685. */
  4686. if ( ! scrollY ) {
  4687. /* IE7< puts a vertical scrollbar in place (when it shouldn't be) due to subtracting
  4688. * the scrollbar height from the visible display, rather than adding it on. We need to
  4689. * set the height in order to sort this. Don't want to do it in any other browsers.
  4690. */
  4691. if ( ie67 ) {
  4692. divBodyStyle.height = _fnStringToCss( tableEl.offsetHeight+barWidth );
  4693. }
  4694. }
  4695. /* Finally set the width's of the header and footer tables */
  4696. var iOuterWidth = table.outerWidth();
  4697. divHeaderTable[0].style.width = _fnStringToCss( iOuterWidth );
  4698. divHeaderInnerStyle.width = _fnStringToCss( iOuterWidth );
  4699. // Figure out if there are scrollbar present - if so then we need a the header and footer to
  4700. // provide a bit more space to allow "overflow" scrolling (i.e. past the scrollbar)
  4701. var bScrolling = table.height() > divBodyEl.clientHeight || divBody.css('overflow-y') == "scroll";
  4702. var padding = 'padding' + (browser.bScrollbarLeft ? 'Left' : 'Right' );
  4703. divHeaderInnerStyle[ padding ] = bScrolling ? barWidth+"px" : "0px";
  4704. if ( footer ) {
  4705. divFooterTable[0].style.width = _fnStringToCss( iOuterWidth );
  4706. divFooterInner[0].style.width = _fnStringToCss( iOuterWidth );
  4707. divFooterInner[0].style[padding] = bScrolling ? barWidth+"px" : "0px";
  4708. }
  4709. // Correct DOM ordering for colgroup - comes before the thead
  4710. table.children('colgroup').insertBefore( table.children('thead') );
  4711. /* Adjust the position of the header in case we loose the y-scrollbar */
  4712. divBody.trigger('scroll');
  4713. // If sorting or filtering has occurred, jump the scrolling back to the top
  4714. // only if we aren't holding the position
  4715. if ( (settings.bSorted || settings.bFiltered) && ! settings._drawHold ) {
  4716. divBodyEl.scrollTop = 0;
  4717. }
  4718. }
  4719. /**
  4720. * Apply a given function to the display child nodes of an element array (typically
  4721. * TD children of TR rows
  4722. * @param {function} fn Method to apply to the objects
  4723. * @param array {nodes} an1 List of elements to look through for display children
  4724. * @param array {nodes} an2 Another list (identical structure to the first) - optional
  4725. * @memberof DataTable#oApi
  4726. */
  4727. function _fnApplyToChildren( fn, an1, an2 )
  4728. {
  4729. var index=0, i=0, iLen=an1.length;
  4730. var nNode1, nNode2;
  4731. while ( i < iLen ) {
  4732. nNode1 = an1[i].firstChild;
  4733. nNode2 = an2 ? an2[i].firstChild : null;
  4734. while ( nNode1 ) {
  4735. if ( nNode1.nodeType === 1 ) {
  4736. if ( an2 ) {
  4737. fn( nNode1, nNode2, index );
  4738. }
  4739. else {
  4740. fn( nNode1, index );
  4741. }
  4742. index++;
  4743. }
  4744. nNode1 = nNode1.nextSibling;
  4745. nNode2 = an2 ? nNode2.nextSibling : null;
  4746. }
  4747. i++;
  4748. }
  4749. }
  4750. var __re_html_remove = /<.*?>/g;
  4751. /**
  4752. * Calculate the width of columns for the table
  4753. * @param {object} oSettings dataTables settings object
  4754. * @memberof DataTable#oApi
  4755. */
  4756. function _fnCalculateColumnWidths ( oSettings )
  4757. {
  4758. var
  4759. table = oSettings.nTable,
  4760. columns = oSettings.aoColumns,
  4761. scroll = oSettings.oScroll,
  4762. scrollY = scroll.sY,
  4763. scrollX = scroll.sX,
  4764. scrollXInner = scroll.sXInner,
  4765. columnCount = columns.length,
  4766. visibleColumns = _fnGetColumns( oSettings, 'bVisible' ),
  4767. headerCells = $('th', oSettings.nTHead),
  4768. tableWidthAttr = table.getAttribute('width'), // from DOM element
  4769. tableContainer = table.parentNode,
  4770. userInputs = false,
  4771. i, column, columnIdx, width, outerWidth,
  4772. browser = oSettings.oBrowser,
  4773. ie67 = browser.bScrollOversize;
  4774. var styleWidth = table.style.width;
  4775. if ( styleWidth && styleWidth.indexOf('%') !== -1 ) {
  4776. tableWidthAttr = styleWidth;
  4777. }
  4778. /* Convert any user input sizes into pixel sizes */
  4779. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4780. column = columns[ visibleColumns[i] ];
  4781. if ( column.sWidth !== null ) {
  4782. column.sWidth = _fnConvertToWidth( column.sWidthOrig, tableContainer );
  4783. userInputs = true;
  4784. }
  4785. }
  4786. /* If the number of columns in the DOM equals the number that we have to
  4787. * process in DataTables, then we can use the offsets that are created by
  4788. * the web- browser. No custom sizes can be set in order for this to happen,
  4789. * nor scrolling used
  4790. */
  4791. if ( ie67 || ! userInputs && ! scrollX && ! scrollY &&
  4792. columnCount == _fnVisbleColumns( oSettings ) &&
  4793. columnCount == headerCells.length
  4794. ) {
  4795. for ( i=0 ; i<columnCount ; i++ ) {
  4796. var colIdx = _fnVisibleToColumnIndex( oSettings, i );
  4797. if ( colIdx !== null ) {
  4798. columns[ colIdx ].sWidth = _fnStringToCss( headerCells.eq(i).width() );
  4799. }
  4800. }
  4801. }
  4802. else
  4803. {
  4804. // Otherwise construct a single row, worst case, table with the widest
  4805. // node in the data, assign any user defined widths, then insert it into
  4806. // the DOM and allow the browser to do all the hard work of calculating
  4807. // table widths
  4808. var tmpTable = $(table).clone() // don't use cloneNode - IE8 will remove events on the main table
  4809. .css( 'visibility', 'hidden' )
  4810. .removeAttr( 'id' );
  4811. // Clean up the table body
  4812. tmpTable.find('tbody tr').remove();
  4813. var tr = $('<tr/>').appendTo( tmpTable.find('tbody') );
  4814. // Clone the table header and footer - we can't use the header / footer
  4815. // from the cloned table, since if scrolling is active, the table's
  4816. // real header and footer are contained in different table tags
  4817. tmpTable.find('thead, tfoot').remove();
  4818. tmpTable
  4819. .append( $(oSettings.nTHead).clone() )
  4820. .append( $(oSettings.nTFoot).clone() );
  4821. // Remove any assigned widths from the footer (from scrolling)
  4822. tmpTable.find('tfoot th, tfoot td').css('width', '');
  4823. // Apply custom sizing to the cloned header
  4824. headerCells = _fnGetUniqueThs( oSettings, tmpTable.find('thead')[0] );
  4825. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4826. column = columns[ visibleColumns[i] ];
  4827. headerCells[i].style.width = column.sWidthOrig !== null && column.sWidthOrig !== '' ?
  4828. _fnStringToCss( column.sWidthOrig ) :
  4829. '';
  4830. // For scrollX we need to force the column width otherwise the
  4831. // browser will collapse it. If this width is smaller than the
  4832. // width the column requires, then it will have no effect
  4833. if ( column.sWidthOrig && scrollX ) {
  4834. $( headerCells[i] ).append( $('<div/>').css( {
  4835. width: column.sWidthOrig,
  4836. margin: 0,
  4837. padding: 0,
  4838. border: 0,
  4839. height: 1
  4840. } ) );
  4841. }
  4842. }
  4843. // Find the widest cell for each column and put it into the table
  4844. if ( oSettings.aoData.length ) {
  4845. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4846. columnIdx = visibleColumns[i];
  4847. column = columns[ columnIdx ];
  4848. $( _fnGetWidestNode( oSettings, columnIdx ) )
  4849. .clone( false )
  4850. .append( column.sContentPadding )
  4851. .appendTo( tr );
  4852. }
  4853. }
  4854. // Tidy the temporary table - remove name attributes so there aren't
  4855. // duplicated in the dom (radio elements for example)
  4856. $('[name]', tmpTable).removeAttr('name');
  4857. // Table has been built, attach to the document so we can work with it.
  4858. // A holding element is used, positioned at the top of the container
  4859. // with minimal height, so it has no effect on if the container scrolls
  4860. // or not. Otherwise it might trigger scrolling when it actually isn't
  4861. // needed
  4862. var holder = $('<div/>').css( scrollX || scrollY ?
  4863. {
  4864. position: 'absolute',
  4865. top: 0,
  4866. left: 0,
  4867. height: 1,
  4868. right: 0,
  4869. overflow: 'hidden'
  4870. } :
  4871. {}
  4872. )
  4873. .append( tmpTable )
  4874. .appendTo( tableContainer );
  4875. // When scrolling (X or Y) we want to set the width of the table as
  4876. // appropriate. However, when not scrolling leave the table width as it
  4877. // is. This results in slightly different, but I think correct behaviour
  4878. if ( scrollX && scrollXInner ) {
  4879. tmpTable.width( scrollXInner );
  4880. }
  4881. else if ( scrollX ) {
  4882. tmpTable.css( 'width', 'auto' );
  4883. tmpTable.removeAttr('width');
  4884. // If there is no width attribute or style, then allow the table to
  4885. // collapse
  4886. if ( tmpTable.width() < tableContainer.clientWidth && tableWidthAttr ) {
  4887. tmpTable.width( tableContainer.clientWidth );
  4888. }
  4889. }
  4890. else if ( scrollY ) {
  4891. tmpTable.width( tableContainer.clientWidth );
  4892. }
  4893. else if ( tableWidthAttr ) {
  4894. tmpTable.width( tableWidthAttr );
  4895. }
  4896. // Get the width of each column in the constructed table - we need to
  4897. // know the inner width (so it can be assigned to the other table's
  4898. // cells) and the outer width so we can calculate the full width of the
  4899. // table. This is safe since DataTables requires a unique cell for each
  4900. // column, but if ever a header can span multiple columns, this will
  4901. // need to be modified.
  4902. var total = 0;
  4903. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4904. var cell = $(headerCells[i]);
  4905. var border = cell.outerWidth() - cell.width();
  4906. // Use getBounding... where possible (not IE8-) because it can give
  4907. // sub-pixel accuracy, which we then want to round up!
  4908. var bounding = browser.bBounding ?
  4909. Math.ceil( headerCells[i].getBoundingClientRect().width ) :
  4910. cell.outerWidth();
  4911. // Total is tracked to remove any sub-pixel errors as the outerWidth
  4912. // of the table might not equal the total given here (IE!).
  4913. total += bounding;
  4914. // Width for each column to use
  4915. columns[ visibleColumns[i] ].sWidth = _fnStringToCss( bounding - border );
  4916. }
  4917. table.style.width = _fnStringToCss( total );
  4918. // Finished with the table - ditch it
  4919. holder.remove();
  4920. }
  4921. // If there is a width attr, we want to attach an event listener which
  4922. // allows the table sizing to automatically adjust when the window is
  4923. // resized. Use the width attr rather than CSS, since we can't know if the
  4924. // CSS is a relative value or absolute - DOM read is always px.
  4925. if ( tableWidthAttr ) {
  4926. table.style.width = _fnStringToCss( tableWidthAttr );
  4927. }
  4928. if ( (tableWidthAttr || scrollX) && ! oSettings._reszEvt ) {
  4929. var bindResize = function () {
  4930. $(window).on('resize.DT-'+oSettings.sInstance, _fnThrottle( function () {
  4931. _fnAdjustColumnSizing( oSettings );
  4932. } ) );
  4933. };
  4934. // IE6/7 will crash if we bind a resize event handler on page load.
  4935. // To be removed in 1.11 which drops IE6/7 support
  4936. if ( ie67 ) {
  4937. setTimeout( bindResize, 1000 );
  4938. }
  4939. else {
  4940. bindResize();
  4941. }
  4942. oSettings._reszEvt = true;
  4943. }
  4944. }
  4945. /**
  4946. * Throttle the calls to a function. Arguments and context are maintained for
  4947. * the throttled function
  4948. * @param {function} fn Function to be called
  4949. * @param {int} [freq=200] call frequency in mS
  4950. * @returns {function} wrapped function
  4951. * @memberof DataTable#oApi
  4952. */
  4953. var _fnThrottle = DataTable.util.throttle;
  4954. /**
  4955. * Convert a CSS unit width to pixels (e.g. 2em)
  4956. * @param {string} width width to be converted
  4957. * @param {node} parent parent to get the with for (required for relative widths) - optional
  4958. * @returns {int} width in pixels
  4959. * @memberof DataTable#oApi
  4960. */
  4961. function _fnConvertToWidth ( width, parent )
  4962. {
  4963. if ( ! width ) {
  4964. return 0;
  4965. }
  4966. var n = $('<div/>')
  4967. .css( 'width', _fnStringToCss( width ) )
  4968. .appendTo( parent || document.body );
  4969. var val = n[0].offsetWidth;
  4970. n.remove();
  4971. return val;
  4972. }
  4973. /**
  4974. * Get the widest node
  4975. * @param {object} settings dataTables settings object
  4976. * @param {int} colIdx column of interest
  4977. * @returns {node} widest table node
  4978. * @memberof DataTable#oApi
  4979. */
  4980. function _fnGetWidestNode( settings, colIdx )
  4981. {
  4982. var idx = _fnGetMaxLenString( settings, colIdx );
  4983. if ( idx < 0 ) {
  4984. return null;
  4985. }
  4986. var data = settings.aoData[ idx ];
  4987. return ! data.nTr ? // Might not have been created when deferred rendering
  4988. $('<td/>').html( _fnGetCellData( settings, idx, colIdx, 'display' ) )[0] :
  4989. data.anCells[ colIdx ];
  4990. }
  4991. /**
  4992. * Get the maximum strlen for each data column
  4993. * @param {object} settings dataTables settings object
  4994. * @param {int} colIdx column of interest
  4995. * @returns {string} max string length for each column
  4996. * @memberof DataTable#oApi
  4997. */
  4998. function _fnGetMaxLenString( settings, colIdx )
  4999. {
  5000. var s, max=-1, maxIdx = -1;
  5001. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  5002. s = _fnGetCellData( settings, i, colIdx, 'display' )+'';
  5003. s = s.replace( __re_html_remove, '' );
  5004. s = s.replace( /&nbsp;/g, ' ' );
  5005. if ( s.length > max ) {
  5006. max = s.length;
  5007. maxIdx = i;
  5008. }
  5009. }
  5010. return maxIdx;
  5011. }
  5012. /**
  5013. * Append a CSS unit (only if required) to a string
  5014. * @param {string} value to css-ify
  5015. * @returns {string} value with css unit
  5016. * @memberof DataTable#oApi
  5017. */
  5018. function _fnStringToCss( s )
  5019. {
  5020. if ( s === null ) {
  5021. return '0px';
  5022. }
  5023. if ( typeof s == 'number' ) {
  5024. return s < 0 ?
  5025. '0px' :
  5026. s+'px';
  5027. }
  5028. // Check it has a unit character already
  5029. return s.match(/\d$/) ?
  5030. s+'px' :
  5031. s;
  5032. }
  5033. function _fnSortFlatten ( settings )
  5034. {
  5035. var
  5036. i, iLen, k, kLen,
  5037. aSort = [],
  5038. aiOrig = [],
  5039. aoColumns = settings.aoColumns,
  5040. aDataSort, iCol, sType, srcCol,
  5041. fixed = settings.aaSortingFixed,
  5042. fixedObj = $.isPlainObject( fixed ),
  5043. nestedSort = [],
  5044. add = function ( a ) {
  5045. if ( a.length && ! $.isArray( a[0] ) ) {
  5046. // 1D array
  5047. nestedSort.push( a );
  5048. }
  5049. else {
  5050. // 2D array
  5051. $.merge( nestedSort, a );
  5052. }
  5053. };
  5054. // Build the sort array, with pre-fix and post-fix options if they have been
  5055. // specified
  5056. if ( $.isArray( fixed ) ) {
  5057. add( fixed );
  5058. }
  5059. if ( fixedObj && fixed.pre ) {
  5060. add( fixed.pre );
  5061. }
  5062. add( settings.aaSorting );
  5063. if (fixedObj && fixed.post ) {
  5064. add( fixed.post );
  5065. }
  5066. for ( i=0 ; i<nestedSort.length ; i++ )
  5067. {
  5068. srcCol = nestedSort[i][0];
  5069. aDataSort = aoColumns[ srcCol ].aDataSort;
  5070. for ( k=0, kLen=aDataSort.length ; k<kLen ; k++ )
  5071. {
  5072. iCol = aDataSort[k];
  5073. sType = aoColumns[ iCol ].sType || 'string';
  5074. if ( nestedSort[i]._idx === undefined ) {
  5075. nestedSort[i]._idx = $.inArray( nestedSort[i][1], aoColumns[iCol].asSorting );
  5076. }
  5077. aSort.push( {
  5078. src: srcCol,
  5079. col: iCol,
  5080. dir: nestedSort[i][1],
  5081. index: nestedSort[i]._idx,
  5082. type: sType,
  5083. formatter: DataTable.ext.type.order[ sType+"-pre" ]
  5084. } );
  5085. }
  5086. }
  5087. return aSort;
  5088. }
  5089. /**
  5090. * Change the order of the table
  5091. * @param {object} oSettings dataTables settings object
  5092. * @memberof DataTable#oApi
  5093. * @todo This really needs split up!
  5094. */
  5095. function _fnSort ( oSettings )
  5096. {
  5097. var
  5098. i, ien, iLen, j, jLen, k, kLen,
  5099. sDataType, nTh,
  5100. aiOrig = [],
  5101. oExtSort = DataTable.ext.type.order,
  5102. aoData = oSettings.aoData,
  5103. aoColumns = oSettings.aoColumns,
  5104. aDataSort, data, iCol, sType, oSort,
  5105. formatters = 0,
  5106. sortCol,
  5107. displayMaster = oSettings.aiDisplayMaster,
  5108. aSort;
  5109. // Resolve any column types that are unknown due to addition or invalidation
  5110. // @todo Can this be moved into a 'data-ready' handler which is called when
  5111. // data is going to be used in the table?
  5112. _fnColumnTypes( oSettings );
  5113. aSort = _fnSortFlatten( oSettings );
  5114. for ( i=0, ien=aSort.length ; i<ien ; i++ ) {
  5115. sortCol = aSort[i];
  5116. // Track if we can use the fast sort algorithm
  5117. if ( sortCol.formatter ) {
  5118. formatters++;
  5119. }
  5120. // Load the data needed for the sort, for each cell
  5121. _fnSortData( oSettings, sortCol.col );
  5122. }
  5123. /* No sorting required if server-side or no sorting array */
  5124. if ( _fnDataSource( oSettings ) != 'ssp' && aSort.length !== 0 )
  5125. {
  5126. // Create a value - key array of the current row positions such that we can use their
  5127. // current position during the sort, if values match, in order to perform stable sorting
  5128. for ( i=0, iLen=displayMaster.length ; i<iLen ; i++ ) {
  5129. aiOrig[ displayMaster[i] ] = i;
  5130. }
  5131. /* Do the sort - here we want multi-column sorting based on a given data source (column)
  5132. * and sorting function (from oSort) in a certain direction. It's reasonably complex to
  5133. * follow on it's own, but this is what we want (example two column sorting):
  5134. * fnLocalSorting = function(a,b){
  5135. * var iTest;
  5136. * iTest = oSort['string-asc']('data11', 'data12');
  5137. * if (iTest !== 0)
  5138. * return iTest;
  5139. * iTest = oSort['numeric-desc']('data21', 'data22');
  5140. * if (iTest !== 0)
  5141. * return iTest;
  5142. * return oSort['numeric-asc']( aiOrig[a], aiOrig[b] );
  5143. * }
  5144. * Basically we have a test for each sorting column, if the data in that column is equal,
  5145. * test the next column. If all columns match, then we use a numeric sort on the row
  5146. * positions in the original data array to provide a stable sort.
  5147. *
  5148. * Note - I know it seems excessive to have two sorting methods, but the first is around
  5149. * 15% faster, so the second is only maintained for backwards compatibility with sorting
  5150. * methods which do not have a pre-sort formatting function.
  5151. */
  5152. if ( formatters === aSort.length ) {
  5153. // All sort types have formatting functions
  5154. displayMaster.sort( function ( a, b ) {
  5155. var
  5156. x, y, k, test, sort,
  5157. len=aSort.length,
  5158. dataA = aoData[a]._aSortData,
  5159. dataB = aoData[b]._aSortData;
  5160. for ( k=0 ; k<len ; k++ ) {
  5161. sort = aSort[k];
  5162. x = dataA[ sort.col ];
  5163. y = dataB[ sort.col ];
  5164. test = x<y ? -1 : x>y ? 1 : 0;
  5165. if ( test !== 0 ) {
  5166. return sort.dir === 'asc' ? test : -test;
  5167. }
  5168. }
  5169. x = aiOrig[a];
  5170. y = aiOrig[b];
  5171. return x<y ? -1 : x>y ? 1 : 0;
  5172. } );
  5173. }
  5174. else {
  5175. // Depreciated - remove in 1.11 (providing a plug-in option)
  5176. // Not all sort types have formatting methods, so we have to call their sorting
  5177. // methods.
  5178. displayMaster.sort( function ( a, b ) {
  5179. var
  5180. x, y, k, l, test, sort, fn,
  5181. len=aSort.length,
  5182. dataA = aoData[a]._aSortData,
  5183. dataB = aoData[b]._aSortData;
  5184. for ( k=0 ; k<len ; k++ ) {
  5185. sort = aSort[k];
  5186. x = dataA[ sort.col ];
  5187. y = dataB[ sort.col ];
  5188. fn = oExtSort[ sort.type+"-"+sort.dir ] || oExtSort[ "string-"+sort.dir ];
  5189. test = fn( x, y );
  5190. if ( test !== 0 ) {
  5191. return test;
  5192. }
  5193. }
  5194. x = aiOrig[a];
  5195. y = aiOrig[b];
  5196. return x<y ? -1 : x>y ? 1 : 0;
  5197. } );
  5198. }
  5199. }
  5200. /* Tell the draw function that we have sorted the data */
  5201. oSettings.bSorted = true;
  5202. }
  5203. function _fnSortAria ( settings )
  5204. {
  5205. var label;
  5206. var nextSort;
  5207. var columns = settings.aoColumns;
  5208. var aSort = _fnSortFlatten( settings );
  5209. var oAria = settings.oLanguage.oAria;
  5210. // ARIA attributes - need to loop all columns, to update all (removing old
  5211. // attributes as needed)
  5212. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  5213. {
  5214. var col = columns[i];
  5215. var asSorting = col.asSorting;
  5216. var sTitle = col.sTitle.replace( /<.*?>/g, "" );
  5217. var th = col.nTh;
  5218. // IE7 is throwing an error when setting these properties with jQuery's
  5219. // attr() and removeAttr() methods...
  5220. th.removeAttribute('aria-sort');
  5221. /* In ARIA only the first sorting column can be marked as sorting - no multi-sort option */
  5222. if ( col.bSortable ) {
  5223. if ( aSort.length > 0 && aSort[0].col == i ) {
  5224. th.setAttribute('aria-sort', aSort[0].dir=="asc" ? "ascending" : "descending" );
  5225. nextSort = asSorting[ aSort[0].index+1 ] || asSorting[0];
  5226. }
  5227. else {
  5228. nextSort = asSorting[0];
  5229. }
  5230. label = sTitle + ( nextSort === "asc" ?
  5231. oAria.sSortAscending :
  5232. oAria.sSortDescending
  5233. );
  5234. }
  5235. else {
  5236. label = sTitle;
  5237. }
  5238. th.setAttribute('aria-label', label);
  5239. }
  5240. }
  5241. /**
  5242. * Function to run on user sort request
  5243. * @param {object} settings dataTables settings object
  5244. * @param {node} attachTo node to attach the handler to
  5245. * @param {int} colIdx column sorting index
  5246. * @param {boolean} [append=false] Append the requested sort to the existing
  5247. * sort if true (i.e. multi-column sort)
  5248. * @param {function} [callback] callback function
  5249. * @memberof DataTable#oApi
  5250. */
  5251. function _fnSortListener ( settings, colIdx, append, callback )
  5252. {
  5253. var col = settings.aoColumns[ colIdx ];
  5254. var sorting = settings.aaSorting;
  5255. var asSorting = col.asSorting;
  5256. var nextSortIdx;
  5257. var next = function ( a, overflow ) {
  5258. var idx = a._idx;
  5259. if ( idx === undefined ) {
  5260. idx = $.inArray( a[1], asSorting );
  5261. }
  5262. return idx+1 < asSorting.length ?
  5263. idx+1 :
  5264. overflow ?
  5265. null :
  5266. 0;
  5267. };
  5268. // Convert to 2D array if needed
  5269. if ( typeof sorting[0] === 'number' ) {
  5270. sorting = settings.aaSorting = [ sorting ];
  5271. }
  5272. // If appending the sort then we are multi-column sorting
  5273. if ( append && settings.oFeatures.bSortMulti ) {
  5274. // Are we already doing some kind of sort on this column?
  5275. var sortIdx = $.inArray( colIdx, _pluck(sorting, '0') );
  5276. if ( sortIdx !== -1 ) {
  5277. // Yes, modify the sort
  5278. nextSortIdx = next( sorting[sortIdx], true );
  5279. if ( nextSortIdx === null && sorting.length === 1 ) {
  5280. nextSortIdx = 0; // can't remove sorting completely
  5281. }
  5282. if ( nextSortIdx === null ) {
  5283. sorting.splice( sortIdx, 1 );
  5284. }
  5285. else {
  5286. sorting[sortIdx][1] = asSorting[ nextSortIdx ];
  5287. sorting[sortIdx]._idx = nextSortIdx;
  5288. }
  5289. }
  5290. else {
  5291. // No sort on this column yet
  5292. sorting.push( [ colIdx, asSorting[0], 0 ] );
  5293. sorting[sorting.length-1]._idx = 0;
  5294. }
  5295. }
  5296. else if ( sorting.length && sorting[0][0] == colIdx ) {
  5297. // Single column - already sorting on this column, modify the sort
  5298. nextSortIdx = next( sorting[0] );
  5299. sorting.length = 1;
  5300. sorting[0][1] = asSorting[ nextSortIdx ];
  5301. sorting[0]._idx = nextSortIdx;
  5302. }
  5303. else {
  5304. // Single column - sort only on this column
  5305. sorting.length = 0;
  5306. sorting.push( [ colIdx, asSorting[0] ] );
  5307. sorting[0]._idx = 0;
  5308. }
  5309. // Run the sort by calling a full redraw
  5310. _fnReDraw( settings );
  5311. // callback used for async user interaction
  5312. if ( typeof callback == 'function' ) {
  5313. callback( settings );
  5314. }
  5315. }
  5316. /**
  5317. * Attach a sort handler (click) to a node
  5318. * @param {object} settings dataTables settings object
  5319. * @param {node} attachTo node to attach the handler to
  5320. * @param {int} colIdx column sorting index
  5321. * @param {function} [callback] callback function
  5322. * @memberof DataTable#oApi
  5323. */
  5324. function _fnSortAttachListener ( settings, attachTo, colIdx, callback )
  5325. {
  5326. var col = settings.aoColumns[ colIdx ];
  5327. _fnBindAction( attachTo, {}, function (e) {
  5328. /* If the column is not sortable - don't to anything */
  5329. if ( col.bSortable === false ) {
  5330. return;
  5331. }
  5332. // If processing is enabled use a timeout to allow the processing
  5333. // display to be shown - otherwise to it synchronously
  5334. if ( settings.oFeatures.bProcessing ) {
  5335. _fnProcessingDisplay( settings, true );
  5336. setTimeout( function() {
  5337. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  5338. // In server-side processing, the draw callback will remove the
  5339. // processing display
  5340. if ( _fnDataSource( settings ) !== 'ssp' ) {
  5341. _fnProcessingDisplay( settings, false );
  5342. }
  5343. }, 0 );
  5344. }
  5345. else {
  5346. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  5347. }
  5348. } );
  5349. }
  5350. /**
  5351. * Set the sorting classes on table's body, Note: it is safe to call this function
  5352. * when bSort and bSortClasses are false
  5353. * @param {object} oSettings dataTables settings object
  5354. * @memberof DataTable#oApi
  5355. */
  5356. function _fnSortingClasses( settings )
  5357. {
  5358. var oldSort = settings.aLastSort;
  5359. var sortClass = settings.oClasses.sSortColumn;
  5360. var sort = _fnSortFlatten( settings );
  5361. var features = settings.oFeatures;
  5362. var i, ien, colIdx;
  5363. if ( features.bSort && features.bSortClasses ) {
  5364. // Remove old sorting classes
  5365. for ( i=0, ien=oldSort.length ; i<ien ; i++ ) {
  5366. colIdx = oldSort[i].src;
  5367. // Remove column sorting
  5368. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  5369. .removeClass( sortClass + (i<2 ? i+1 : 3) );
  5370. }
  5371. // Add new column sorting
  5372. for ( i=0, ien=sort.length ; i<ien ; i++ ) {
  5373. colIdx = sort[i].src;
  5374. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  5375. .addClass( sortClass + (i<2 ? i+1 : 3) );
  5376. }
  5377. }
  5378. settings.aLastSort = sort;
  5379. }
  5380. // Get the data to sort a column, be it from cache, fresh (populating the
  5381. // cache), or from a sort formatter
  5382. function _fnSortData( settings, idx )
  5383. {
  5384. // Custom sorting function - provided by the sort data type
  5385. var column = settings.aoColumns[ idx ];
  5386. var customSort = DataTable.ext.order[ column.sSortDataType ];
  5387. var customData;
  5388. if ( customSort ) {
  5389. customData = customSort.call( settings.oInstance, settings, idx,
  5390. _fnColumnIndexToVisible( settings, idx )
  5391. );
  5392. }
  5393. // Use / populate cache
  5394. var row, cellData;
  5395. var formatter = DataTable.ext.type.order[ column.sType+"-pre" ];
  5396. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  5397. row = settings.aoData[i];
  5398. if ( ! row._aSortData ) {
  5399. row._aSortData = [];
  5400. }
  5401. if ( ! row._aSortData[idx] || customSort ) {
  5402. cellData = customSort ?
  5403. customData[i] : // If there was a custom sort function, use data from there
  5404. _fnGetCellData( settings, i, idx, 'sort' );
  5405. row._aSortData[ idx ] = formatter ?
  5406. formatter( cellData ) :
  5407. cellData;
  5408. }
  5409. }
  5410. }
  5411. /**
  5412. * Save the state of a table
  5413. * @param {object} oSettings dataTables settings object
  5414. * @memberof DataTable#oApi
  5415. */
  5416. function _fnSaveState ( settings )
  5417. {
  5418. if ( !settings.oFeatures.bStateSave || settings.bDestroying )
  5419. {
  5420. return;
  5421. }
  5422. /* Store the interesting variables */
  5423. var state = {
  5424. time: +new Date(),
  5425. start: settings._iDisplayStart,
  5426. length: settings._iDisplayLength,
  5427. order: $.extend( true, [], settings.aaSorting ),
  5428. search: _fnSearchToCamel( settings.oPreviousSearch ),
  5429. columns: $.map( settings.aoColumns, function ( col, i ) {
  5430. return {
  5431. visible: col.bVisible,
  5432. search: _fnSearchToCamel( settings.aoPreSearchCols[i] )
  5433. };
  5434. } )
  5435. };
  5436. _fnCallbackFire( settings, "aoStateSaveParams", 'stateSaveParams', [settings, state] );
  5437. settings.oSavedState = state;
  5438. settings.fnStateSaveCallback.call( settings.oInstance, settings, state );
  5439. }
  5440. /**
  5441. * Attempt to load a saved table state
  5442. * @param {object} oSettings dataTables settings object
  5443. * @param {object} oInit DataTables init object so we can override settings
  5444. * @param {function} callback Callback to execute when the state has been loaded
  5445. * @memberof DataTable#oApi
  5446. */
  5447. function _fnLoadState ( settings, oInit, callback )
  5448. {
  5449. var i, ien;
  5450. var columns = settings.aoColumns;
  5451. var loaded = function ( s ) {
  5452. if ( ! s || ! s.time ) {
  5453. callback();
  5454. return;
  5455. }
  5456. // Allow custom and plug-in manipulation functions to alter the saved data set and
  5457. // cancelling of loading by returning false
  5458. var abStateLoad = _fnCallbackFire( settings, 'aoStateLoadParams', 'stateLoadParams', [settings, s] );
  5459. if ( $.inArray( false, abStateLoad ) !== -1 ) {
  5460. callback();
  5461. return;
  5462. }
  5463. // Reject old data
  5464. var duration = settings.iStateDuration;
  5465. if ( duration > 0 && s.time < +new Date() - (duration*1000) ) {
  5466. callback();
  5467. return;
  5468. }
  5469. // Number of columns have changed - all bets are off, no restore of settings
  5470. if ( s.columns && columns.length !== s.columns.length ) {
  5471. callback();
  5472. return;
  5473. }
  5474. // Store the saved state so it might be accessed at any time
  5475. settings.oLoadedState = $.extend( true, {}, s );
  5476. // Restore key features - todo - for 1.11 this needs to be done by
  5477. // subscribed events
  5478. if ( s.start !== undefined ) {
  5479. settings._iDisplayStart = s.start;
  5480. settings.iInitDisplayStart = s.start;
  5481. }
  5482. if ( s.length !== undefined ) {
  5483. settings._iDisplayLength = s.length;
  5484. }
  5485. // Order
  5486. if ( s.order !== undefined ) {
  5487. settings.aaSorting = [];
  5488. $.each( s.order, function ( i, col ) {
  5489. settings.aaSorting.push( col[0] >= columns.length ?
  5490. [ 0, col[1] ] :
  5491. col
  5492. );
  5493. } );
  5494. }
  5495. // Search
  5496. if ( s.search !== undefined ) {
  5497. $.extend( settings.oPreviousSearch, _fnSearchToHung( s.search ) );
  5498. }
  5499. // Columns
  5500. //
  5501. if ( s.columns ) {
  5502. for ( i=0, ien=s.columns.length ; i<ien ; i++ ) {
  5503. var col = s.columns[i];
  5504. // Visibility
  5505. if ( col.visible !== undefined ) {
  5506. columns[i].bVisible = col.visible;
  5507. }
  5508. // Search
  5509. if ( col.search !== undefined ) {
  5510. $.extend( settings.aoPreSearchCols[i], _fnSearchToHung( col.search ) );
  5511. }
  5512. }
  5513. }
  5514. _fnCallbackFire( settings, 'aoStateLoaded', 'stateLoaded', [settings, s] );
  5515. callback();
  5516. };
  5517. if ( ! settings.oFeatures.bStateSave ) {
  5518. callback();
  5519. return;
  5520. }
  5521. var state = settings.fnStateLoadCallback.call( settings.oInstance, settings, loaded );
  5522. if ( state !== undefined ) {
  5523. loaded( state );
  5524. }
  5525. // otherwise, wait for the loaded callback to be executed
  5526. }
  5527. /**
  5528. * Return the settings object for a particular table
  5529. * @param {node} table table we are using as a dataTable
  5530. * @returns {object} Settings object - or null if not found
  5531. * @memberof DataTable#oApi
  5532. */
  5533. function _fnSettingsFromNode ( table )
  5534. {
  5535. var settings = DataTable.settings;
  5536. var idx = $.inArray( table, _pluck( settings, 'nTable' ) );
  5537. return idx !== -1 ?
  5538. settings[ idx ] :
  5539. null;
  5540. }
  5541. /**
  5542. * Log an error message
  5543. * @param {object} settings dataTables settings object
  5544. * @param {int} level log error messages, or display them to the user
  5545. * @param {string} msg error message
  5546. * @param {int} tn Technical note id to get more information about the error.
  5547. * @memberof DataTable#oApi
  5548. */
  5549. function _fnLog( settings, level, msg, tn )
  5550. {
  5551. msg = 'DataTables warning: '+
  5552. (settings ? 'table id='+settings.sTableId+' - ' : '')+msg;
  5553. if ( tn ) {
  5554. msg += '. For more information about this error, please see '+
  5555. 'http://datatables.net/tn/'+tn;
  5556. }
  5557. if ( ! level ) {
  5558. // Backwards compatibility pre 1.10
  5559. var ext = DataTable.ext;
  5560. var type = ext.sErrMode || ext.errMode;
  5561. if ( settings ) {
  5562. _fnCallbackFire( settings, null, 'error', [ settings, tn, msg ] );
  5563. }
  5564. if ( type == 'alert' ) {
  5565. alert( msg );
  5566. }
  5567. else if ( type == 'throw' ) {
  5568. throw new Error(msg);
  5569. }
  5570. else if ( typeof type == 'function' ) {
  5571. type( settings, tn, msg );
  5572. }
  5573. }
  5574. else if ( window.console && console.log ) {
  5575. console.log( msg );
  5576. }
  5577. }
  5578. /**
  5579. * See if a property is defined on one object, if so assign it to the other object
  5580. * @param {object} ret target object
  5581. * @param {object} src source object
  5582. * @param {string} name property
  5583. * @param {string} [mappedName] name to map too - optional, name used if not given
  5584. * @memberof DataTable#oApi
  5585. */
  5586. function _fnMap( ret, src, name, mappedName )
  5587. {
  5588. if ( $.isArray( name ) ) {
  5589. $.each( name, function (i, val) {
  5590. if ( $.isArray( val ) ) {
  5591. _fnMap( ret, src, val[0], val[1] );
  5592. }
  5593. else {
  5594. _fnMap( ret, src, val );
  5595. }
  5596. } );
  5597. return;
  5598. }
  5599. if ( mappedName === undefined ) {
  5600. mappedName = name;
  5601. }
  5602. if ( src[name] !== undefined ) {
  5603. ret[mappedName] = src[name];
  5604. }
  5605. }
  5606. /**
  5607. * Extend objects - very similar to jQuery.extend, but deep copy objects, and
  5608. * shallow copy arrays. The reason we need to do this, is that we don't want to
  5609. * deep copy array init values (such as aaSorting) since the dev wouldn't be
  5610. * able to override them, but we do want to deep copy arrays.
  5611. * @param {object} out Object to extend
  5612. * @param {object} extender Object from which the properties will be applied to
  5613. * out
  5614. * @param {boolean} breakRefs If true, then arrays will be sliced to take an
  5615. * independent copy with the exception of the `data` or `aaData` parameters
  5616. * if they are present. This is so you can pass in a collection to
  5617. * DataTables and have that used as your data source without breaking the
  5618. * references
  5619. * @returns {object} out Reference, just for convenience - out === the return.
  5620. * @memberof DataTable#oApi
  5621. * @todo This doesn't take account of arrays inside the deep copied objects.
  5622. */
  5623. function _fnExtend( out, extender, breakRefs )
  5624. {
  5625. var val;
  5626. for ( var prop in extender ) {
  5627. if ( extender.hasOwnProperty(prop) ) {
  5628. val = extender[prop];
  5629. if ( $.isPlainObject( val ) ) {
  5630. if ( ! $.isPlainObject( out[prop] ) ) {
  5631. out[prop] = {};
  5632. }
  5633. $.extend( true, out[prop], val );
  5634. }
  5635. else if ( breakRefs && prop !== 'data' && prop !== 'aaData' && $.isArray(val) ) {
  5636. out[prop] = val.slice();
  5637. }
  5638. else {
  5639. out[prop] = val;
  5640. }
  5641. }
  5642. }
  5643. return out;
  5644. }
  5645. /**
  5646. * Bind an event handers to allow a click or return key to activate the callback.
  5647. * This is good for accessibility since a return on the keyboard will have the
  5648. * same effect as a click, if the element has focus.
  5649. * @param {element} n Element to bind the action to
  5650. * @param {object} oData Data object to pass to the triggered function
  5651. * @param {function} fn Callback function for when the event is triggered
  5652. * @memberof DataTable#oApi
  5653. */
  5654. function _fnBindAction( n, oData, fn )
  5655. {
  5656. $(n)
  5657. .on( 'click.DT', oData, function (e) {
  5658. $(n).blur(); // Remove focus outline for mouse users
  5659. fn(e);
  5660. } )
  5661. .on( 'keypress.DT', oData, function (e){
  5662. if ( e.which === 13 ) {
  5663. e.preventDefault();
  5664. fn(e);
  5665. }
  5666. } )
  5667. .on( 'selectstart.DT', function () {
  5668. /* Take the brutal approach to cancelling text selection */
  5669. return false;
  5670. } );
  5671. }
  5672. /**
  5673. * Register a callback function. Easily allows a callback function to be added to
  5674. * an array store of callback functions that can then all be called together.
  5675. * @param {object} oSettings dataTables settings object
  5676. * @param {string} sStore Name of the array storage for the callbacks in oSettings
  5677. * @param {function} fn Function to be called back
  5678. * @param {string} sName Identifying name for the callback (i.e. a label)
  5679. * @memberof DataTable#oApi
  5680. */
  5681. function _fnCallbackReg( oSettings, sStore, fn, sName )
  5682. {
  5683. if ( fn )
  5684. {
  5685. oSettings[sStore].push( {
  5686. "fn": fn,
  5687. "sName": sName
  5688. } );
  5689. }
  5690. }
  5691. /**
  5692. * Fire callback functions and trigger events. Note that the loop over the
  5693. * callback array store is done backwards! Further note that you do not want to
  5694. * fire off triggers in time sensitive applications (for example cell creation)
  5695. * as its slow.
  5696. * @param {object} settings dataTables settings object
  5697. * @param {string} callbackArr Name of the array storage for the callbacks in
  5698. * oSettings
  5699. * @param {string} eventName Name of the jQuery custom event to trigger. If
  5700. * null no trigger is fired
  5701. * @param {array} args Array of arguments to pass to the callback function /
  5702. * trigger
  5703. * @memberof DataTable#oApi
  5704. */
  5705. function _fnCallbackFire( settings, callbackArr, eventName, args )
  5706. {
  5707. var ret = [];
  5708. if ( callbackArr ) {
  5709. ret = $.map( settings[callbackArr].slice().reverse(), function (val, i) {
  5710. return val.fn.apply( settings.oInstance, args );
  5711. } );
  5712. }
  5713. if ( eventName !== null ) {
  5714. var e = $.Event( eventName+'.dt' );
  5715. $(settings.nTable).trigger( e, args );
  5716. ret.push( e.result );
  5717. }
  5718. return ret;
  5719. }
  5720. function _fnLengthOverflow ( settings )
  5721. {
  5722. var
  5723. start = settings._iDisplayStart,
  5724. end = settings.fnDisplayEnd(),
  5725. len = settings._iDisplayLength;
  5726. /* If we have space to show extra rows (backing up from the end point - then do so */
  5727. if ( start >= end )
  5728. {
  5729. start = end - len;
  5730. }
  5731. // Keep the start record on the current page
  5732. start -= (start % len);
  5733. if ( len === -1 || start < 0 )
  5734. {
  5735. start = 0;
  5736. }
  5737. settings._iDisplayStart = start;
  5738. }
  5739. function _fnRenderer( settings, type )
  5740. {
  5741. var renderer = settings.renderer;
  5742. var host = DataTable.ext.renderer[type];
  5743. if ( $.isPlainObject( renderer ) && renderer[type] ) {
  5744. // Specific renderer for this type. If available use it, otherwise use
  5745. // the default.
  5746. return host[renderer[type]] || host._;
  5747. }
  5748. else if ( typeof renderer === 'string' ) {
  5749. // Common renderer - if there is one available for this type use it,
  5750. // otherwise use the default
  5751. return host[renderer] || host._;
  5752. }
  5753. // Use the default
  5754. return host._;
  5755. }
  5756. /**
  5757. * Detect the data source being used for the table. Used to simplify the code
  5758. * a little (ajax) and to make it compress a little smaller.
  5759. *
  5760. * @param {object} settings dataTables settings object
  5761. * @returns {string} Data source
  5762. * @memberof DataTable#oApi
  5763. */
  5764. function _fnDataSource ( settings )
  5765. {
  5766. if ( settings.oFeatures.bServerSide ) {
  5767. return 'ssp';
  5768. }
  5769. else if ( settings.ajax || settings.sAjaxSource ) {
  5770. return 'ajax';
  5771. }
  5772. return 'dom';
  5773. }
  5774. /**
  5775. * Computed structure of the DataTables API, defined by the options passed to
  5776. * `DataTable.Api.register()` when building the API.
  5777. *
  5778. * The structure is built in order to speed creation and extension of the Api
  5779. * objects since the extensions are effectively pre-parsed.
  5780. *
  5781. * The array is an array of objects with the following structure, where this
  5782. * base array represents the Api prototype base:
  5783. *
  5784. * [
  5785. * {
  5786. * name: 'data' -- string - Property name
  5787. * val: function () {}, -- function - Api method (or undefined if just an object
  5788. * methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  5789. * propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  5790. * },
  5791. * {
  5792. * name: 'row'
  5793. * val: {},
  5794. * methodExt: [ ... ],
  5795. * propExt: [
  5796. * {
  5797. * name: 'data'
  5798. * val: function () {},
  5799. * methodExt: [ ... ],
  5800. * propExt: [ ... ]
  5801. * },
  5802. * ...
  5803. * ]
  5804. * }
  5805. * ]
  5806. *
  5807. * @type {Array}
  5808. * @ignore
  5809. */
  5810. var __apiStruct = [];
  5811. /**
  5812. * `Array.prototype` reference.
  5813. *
  5814. * @type object
  5815. * @ignore
  5816. */
  5817. var __arrayProto = Array.prototype;
  5818. /**
  5819. * Abstraction for `context` parameter of the `Api` constructor to allow it to
  5820. * take several different forms for ease of use.
  5821. *
  5822. * Each of the input parameter types will be converted to a DataTables settings
  5823. * object where possible.
  5824. *
  5825. * @param {string|node|jQuery|object} mixed DataTable identifier. Can be one
  5826. * of:
  5827. *
  5828. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5829. * with be found and used.
  5830. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5831. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5832. * * `object` - DataTables settings object
  5833. * * `DataTables.Api` - API instance
  5834. * @return {array|null} Matching DataTables settings objects. `null` or
  5835. * `undefined` is returned if no matching DataTable is found.
  5836. * @ignore
  5837. */
  5838. var _toSettings = function ( mixed )
  5839. {
  5840. var idx, jq;
  5841. var settings = DataTable.settings;
  5842. var tables = $.map( settings, function (el, i) {
  5843. return el.nTable;
  5844. } );
  5845. if ( ! mixed ) {
  5846. return [];
  5847. }
  5848. else if ( mixed.nTable && mixed.oApi ) {
  5849. // DataTables settings object
  5850. return [ mixed ];
  5851. }
  5852. else if ( mixed.nodeName && mixed.nodeName.toLowerCase() === 'table' ) {
  5853. // Table node
  5854. idx = $.inArray( mixed, tables );
  5855. return idx !== -1 ? [ settings[idx] ] : null;
  5856. }
  5857. else if ( mixed && typeof mixed.settings === 'function' ) {
  5858. return mixed.settings().toArray();
  5859. }
  5860. else if ( typeof mixed === 'string' ) {
  5861. // jQuery selector
  5862. jq = $(mixed);
  5863. }
  5864. else if ( mixed instanceof $ ) {
  5865. // jQuery object (also DataTables instance)
  5866. jq = mixed;
  5867. }
  5868. if ( jq ) {
  5869. return jq.map( function(i) {
  5870. idx = $.inArray( this, tables );
  5871. return idx !== -1 ? settings[idx] : null;
  5872. } ).toArray();
  5873. }
  5874. };
  5875. /**
  5876. * DataTables API class - used to control and interface with one or more
  5877. * DataTables enhanced tables.
  5878. *
  5879. * The API class is heavily based on jQuery, presenting a chainable interface
  5880. * that you can use to interact with tables. Each instance of the API class has
  5881. * a "context" - i.e. the tables that it will operate on. This could be a single
  5882. * table, all tables on a page or a sub-set thereof.
  5883. *
  5884. * Additionally the API is designed to allow you to easily work with the data in
  5885. * the tables, retrieving and manipulating it as required. This is done by
  5886. * presenting the API class as an array like interface. The contents of the
  5887. * array depend upon the actions requested by each method (for example
  5888. * `rows().nodes()` will return an array of nodes, while `rows().data()` will
  5889. * return an array of objects or arrays depending upon your table's
  5890. * configuration). The API object has a number of array like methods (`push`,
  5891. * `pop`, `reverse` etc) as well as additional helper methods (`each`, `pluck`,
  5892. * `unique` etc) to assist your working with the data held in a table.
  5893. *
  5894. * Most methods (those which return an Api instance) are chainable, which means
  5895. * the return from a method call also has all of the methods available that the
  5896. * top level object had. For example, these two calls are equivalent:
  5897. *
  5898. * // Not chained
  5899. * api.row.add( {...} );
  5900. * api.draw();
  5901. *
  5902. * // Chained
  5903. * api.row.add( {...} ).draw();
  5904. *
  5905. * @class DataTable.Api
  5906. * @param {array|object|string|jQuery} context DataTable identifier. This is
  5907. * used to define which DataTables enhanced tables this API will operate on.
  5908. * Can be one of:
  5909. *
  5910. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5911. * with be found and used.
  5912. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5913. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5914. * * `object` - DataTables settings object
  5915. * @param {array} [data] Data to initialise the Api instance with.
  5916. *
  5917. * @example
  5918. * // Direct initialisation during DataTables construction
  5919. * var api = $('#example').DataTable();
  5920. *
  5921. * @example
  5922. * // Initialisation using a DataTables jQuery object
  5923. * var api = $('#example').dataTable().api();
  5924. *
  5925. * @example
  5926. * // Initialisation as a constructor
  5927. * var api = new $.fn.DataTable.Api( 'table.dataTable' );
  5928. */
  5929. _Api = function ( context, data )
  5930. {
  5931. if ( ! (this instanceof _Api) ) {
  5932. return new _Api( context, data );
  5933. }
  5934. var settings = [];
  5935. var ctxSettings = function ( o ) {
  5936. var a = _toSettings( o );
  5937. if ( a ) {
  5938. settings.push.apply( settings, a );
  5939. }
  5940. };
  5941. if ( $.isArray( context ) ) {
  5942. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  5943. ctxSettings( context[i] );
  5944. }
  5945. }
  5946. else {
  5947. ctxSettings( context );
  5948. }
  5949. // Remove duplicates
  5950. this.context = _unique( settings );
  5951. // Initial data
  5952. if ( data ) {
  5953. $.merge( this, data );
  5954. }
  5955. // selector
  5956. this.selector = {
  5957. rows: null,
  5958. cols: null,
  5959. opts: null
  5960. };
  5961. _Api.extend( this, this, __apiStruct );
  5962. };
  5963. DataTable.Api = _Api;
  5964. // Don't destroy the existing prototype, just extend it. Required for jQuery 2's
  5965. // isPlainObject.
  5966. $.extend( _Api.prototype, {
  5967. any: function ()
  5968. {
  5969. return this.count() !== 0;
  5970. },
  5971. concat: __arrayProto.concat,
  5972. context: [], // array of table settings objects
  5973. count: function ()
  5974. {
  5975. return this.flatten().length;
  5976. },
  5977. each: function ( fn )
  5978. {
  5979. for ( var i=0, ien=this.length ; i<ien; i++ ) {
  5980. fn.call( this, this[i], i, this );
  5981. }
  5982. return this;
  5983. },
  5984. eq: function ( idx )
  5985. {
  5986. var ctx = this.context;
  5987. return ctx.length > idx ?
  5988. new _Api( ctx[idx], this[idx] ) :
  5989. null;
  5990. },
  5991. filter: function ( fn )
  5992. {
  5993. var a = [];
  5994. if ( __arrayProto.filter ) {
  5995. a = __arrayProto.filter.call( this, fn, this );
  5996. }
  5997. else {
  5998. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  5999. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  6000. if ( fn.call( this, this[i], i, this ) ) {
  6001. a.push( this[i] );
  6002. }
  6003. }
  6004. }
  6005. return new _Api( this.context, a );
  6006. },
  6007. flatten: function ()
  6008. {
  6009. var a = [];
  6010. return new _Api( this.context, a.concat.apply( a, this.toArray() ) );
  6011. },
  6012. join: __arrayProto.join,
  6013. indexOf: __arrayProto.indexOf || function (obj, start)
  6014. {
  6015. for ( var i=(start || 0), ien=this.length ; i<ien ; i++ ) {
  6016. if ( this[i] === obj ) {
  6017. return i;
  6018. }
  6019. }
  6020. return -1;
  6021. },
  6022. iterator: function ( flatten, type, fn, alwaysNew ) {
  6023. var
  6024. a = [], ret,
  6025. i, ien, j, jen,
  6026. context = this.context,
  6027. rows, items, item,
  6028. selector = this.selector;
  6029. // Argument shifting
  6030. if ( typeof flatten === 'string' ) {
  6031. alwaysNew = fn;
  6032. fn = type;
  6033. type = flatten;
  6034. flatten = false;
  6035. }
  6036. for ( i=0, ien=context.length ; i<ien ; i++ ) {
  6037. var apiInst = new _Api( context[i] );
  6038. if ( type === 'table' ) {
  6039. ret = fn.call( apiInst, context[i], i );
  6040. if ( ret !== undefined ) {
  6041. a.push( ret );
  6042. }
  6043. }
  6044. else if ( type === 'columns' || type === 'rows' ) {
  6045. // this has same length as context - one entry for each table
  6046. ret = fn.call( apiInst, context[i], this[i], i );
  6047. if ( ret !== undefined ) {
  6048. a.push( ret );
  6049. }
  6050. }
  6051. else if ( type === 'column' || type === 'column-rows' || type === 'row' || type === 'cell' ) {
  6052. // columns and rows share the same structure.
  6053. // 'this' is an array of column indexes for each context
  6054. items = this[i];
  6055. if ( type === 'column-rows' ) {
  6056. rows = _selector_row_indexes( context[i], selector.opts );
  6057. }
  6058. for ( j=0, jen=items.length ; j<jen ; j++ ) {
  6059. item = items[j];
  6060. if ( type === 'cell' ) {
  6061. ret = fn.call( apiInst, context[i], item.row, item.column, i, j );
  6062. }
  6063. else {
  6064. ret = fn.call( apiInst, context[i], item, i, j, rows );
  6065. }
  6066. if ( ret !== undefined ) {
  6067. a.push( ret );
  6068. }
  6069. }
  6070. }
  6071. }
  6072. if ( a.length || alwaysNew ) {
  6073. var api = new _Api( context, flatten ? a.concat.apply( [], a ) : a );
  6074. var apiSelector = api.selector;
  6075. apiSelector.rows = selector.rows;
  6076. apiSelector.cols = selector.cols;
  6077. apiSelector.opts = selector.opts;
  6078. return api;
  6079. }
  6080. return this;
  6081. },
  6082. lastIndexOf: __arrayProto.lastIndexOf || function (obj, start)
  6083. {
  6084. // Bit cheeky...
  6085. return this.indexOf.apply( this.toArray.reverse(), arguments );
  6086. },
  6087. length: 0,
  6088. map: function ( fn )
  6089. {
  6090. var a = [];
  6091. if ( __arrayProto.map ) {
  6092. a = __arrayProto.map.call( this, fn, this );
  6093. }
  6094. else {
  6095. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  6096. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  6097. a.push( fn.call( this, this[i], i ) );
  6098. }
  6099. }
  6100. return new _Api( this.context, a );
  6101. },
  6102. pluck: function ( prop )
  6103. {
  6104. return this.map( function ( el ) {
  6105. return el[ prop ];
  6106. } );
  6107. },
  6108. pop: __arrayProto.pop,
  6109. push: __arrayProto.push,
  6110. // Does not return an API instance
  6111. reduce: __arrayProto.reduce || function ( fn, init )
  6112. {
  6113. return _fnReduce( this, fn, init, 0, this.length, 1 );
  6114. },
  6115. reduceRight: __arrayProto.reduceRight || function ( fn, init )
  6116. {
  6117. return _fnReduce( this, fn, init, this.length-1, -1, -1 );
  6118. },
  6119. reverse: __arrayProto.reverse,
  6120. // Object with rows, columns and opts
  6121. selector: null,
  6122. shift: __arrayProto.shift,
  6123. slice: function () {
  6124. return new _Api( this.context, this );
  6125. },
  6126. sort: __arrayProto.sort, // ? name - order?
  6127. splice: __arrayProto.splice,
  6128. toArray: function ()
  6129. {
  6130. return __arrayProto.slice.call( this );
  6131. },
  6132. to$: function ()
  6133. {
  6134. return $( this );
  6135. },
  6136. toJQuery: function ()
  6137. {
  6138. return $( this );
  6139. },
  6140. unique: function ()
  6141. {
  6142. return new _Api( this.context, _unique(this) );
  6143. },
  6144. unshift: __arrayProto.unshift
  6145. } );
  6146. _Api.extend = function ( scope, obj, ext )
  6147. {
  6148. // Only extend API instances and static properties of the API
  6149. if ( ! ext.length || ! obj || ( ! (obj instanceof _Api) && ! obj.__dt_wrapper ) ) {
  6150. return;
  6151. }
  6152. var
  6153. i, ien,
  6154. struct,
  6155. methodScoping = function ( scope, fn, struc ) {
  6156. return function () {
  6157. var ret = fn.apply( scope, arguments );
  6158. // Method extension
  6159. _Api.extend( ret, ret, struc.methodExt );
  6160. return ret;
  6161. };
  6162. };
  6163. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  6164. struct = ext[i];
  6165. // Value
  6166. obj[ struct.name ] = struct.type === 'function' ?
  6167. methodScoping( scope, struct.val, struct ) :
  6168. struct.type === 'object' ?
  6169. {} :
  6170. struct.val;
  6171. obj[ struct.name ].__dt_wrapper = true;
  6172. // Property extension
  6173. _Api.extend( scope, obj[ struct.name ], struct.propExt );
  6174. }
  6175. };
  6176. // @todo - Is there need for an augment function?
  6177. // _Api.augment = function ( inst, name )
  6178. // {
  6179. // // Find src object in the structure from the name
  6180. // var parts = name.split('.');
  6181. // _Api.extend( inst, obj );
  6182. // };
  6183. // [
  6184. // {
  6185. // name: 'data' -- string - Property name
  6186. // val: function () {}, -- function - Api method (or undefined if just an object
  6187. // methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  6188. // propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  6189. // },
  6190. // {
  6191. // name: 'row'
  6192. // val: {},
  6193. // methodExt: [ ... ],
  6194. // propExt: [
  6195. // {
  6196. // name: 'data'
  6197. // val: function () {},
  6198. // methodExt: [ ... ],
  6199. // propExt: [ ... ]
  6200. // },
  6201. // ...
  6202. // ]
  6203. // }
  6204. // ]
  6205. _Api.register = _api_register = function ( name, val )
  6206. {
  6207. if ( $.isArray( name ) ) {
  6208. for ( var j=0, jen=name.length ; j<jen ; j++ ) {
  6209. _Api.register( name[j], val );
  6210. }
  6211. return;
  6212. }
  6213. var
  6214. i, ien,
  6215. heir = name.split('.'),
  6216. struct = __apiStruct,
  6217. key, method;
  6218. var find = function ( src, name ) {
  6219. for ( var i=0, ien=src.length ; i<ien ; i++ ) {
  6220. if ( src[i].name === name ) {
  6221. return src[i];
  6222. }
  6223. }
  6224. return null;
  6225. };
  6226. for ( i=0, ien=heir.length ; i<ien ; i++ ) {
  6227. method = heir[i].indexOf('()') !== -1;
  6228. key = method ?
  6229. heir[i].replace('()', '') :
  6230. heir[i];
  6231. var src = find( struct, key );
  6232. if ( ! src ) {
  6233. src = {
  6234. name: key,
  6235. val: {},
  6236. methodExt: [],
  6237. propExt: [],
  6238. type: 'object'
  6239. };
  6240. struct.push( src );
  6241. }
  6242. if ( i === ien-1 ) {
  6243. src.val = val;
  6244. src.type = typeof val === 'function' ?
  6245. 'function' :
  6246. $.isPlainObject( val ) ?
  6247. 'object' :
  6248. 'other';
  6249. }
  6250. else {
  6251. struct = method ?
  6252. src.methodExt :
  6253. src.propExt;
  6254. }
  6255. }
  6256. };
  6257. _Api.registerPlural = _api_registerPlural = function ( pluralName, singularName, val ) {
  6258. _Api.register( pluralName, val );
  6259. _Api.register( singularName, function () {
  6260. var ret = val.apply( this, arguments );
  6261. if ( ret === this ) {
  6262. // Returned item is the API instance that was passed in, return it
  6263. return this;
  6264. }
  6265. else if ( ret instanceof _Api ) {
  6266. // New API instance returned, want the value from the first item
  6267. // in the returned array for the singular result.
  6268. return ret.length ?
  6269. $.isArray( ret[0] ) ?
  6270. new _Api( ret.context, ret[0] ) : // Array results are 'enhanced'
  6271. ret[0] :
  6272. undefined;
  6273. }
  6274. // Non-API return - just fire it back
  6275. return ret;
  6276. } );
  6277. };
  6278. /**
  6279. * Selector for HTML tables. Apply the given selector to the give array of
  6280. * DataTables settings objects.
  6281. *
  6282. * @param {string|integer} [selector] jQuery selector string or integer
  6283. * @param {array} Array of DataTables settings objects to be filtered
  6284. * @return {array}
  6285. * @ignore
  6286. */
  6287. var __table_selector = function ( selector, a )
  6288. {
  6289. // Integer is used to pick out a table by index
  6290. if ( typeof selector === 'number' ) {
  6291. return [ a[ selector ] ];
  6292. }
  6293. // Perform a jQuery selector on the table nodes
  6294. var nodes = $.map( a, function (el, i) {
  6295. return el.nTable;
  6296. } );
  6297. return $(nodes)
  6298. .filter( selector )
  6299. .map( function (i) {
  6300. // Need to translate back from the table node to the settings
  6301. var idx = $.inArray( this, nodes );
  6302. return a[ idx ];
  6303. } )
  6304. .toArray();
  6305. };
  6306. /**
  6307. * Context selector for the API's context (i.e. the tables the API instance
  6308. * refers to.
  6309. *
  6310. * @name DataTable.Api#tables
  6311. * @param {string|integer} [selector] Selector to pick which tables the iterator
  6312. * should operate on. If not given, all tables in the current context are
  6313. * used. This can be given as a jQuery selector (for example `':gt(0)'`) to
  6314. * select multiple tables or as an integer to select a single table.
  6315. * @returns {DataTable.Api} Returns a new API instance if a selector is given.
  6316. */
  6317. _api_register( 'tables()', function ( selector ) {
  6318. // A new instance is created if there was a selector specified
  6319. return selector ?
  6320. new _Api( __table_selector( selector, this.context ) ) :
  6321. this;
  6322. } );
  6323. _api_register( 'table()', function ( selector ) {
  6324. var tables = this.tables( selector );
  6325. var ctx = tables.context;
  6326. // Truncate to the first matched table
  6327. return ctx.length ?
  6328. new _Api( ctx[0] ) :
  6329. tables;
  6330. } );
  6331. _api_registerPlural( 'tables().nodes()', 'table().node()' , function () {
  6332. return this.iterator( 'table', function ( ctx ) {
  6333. return ctx.nTable;
  6334. }, 1 );
  6335. } );
  6336. _api_registerPlural( 'tables().body()', 'table().body()' , function () {
  6337. return this.iterator( 'table', function ( ctx ) {
  6338. return ctx.nTBody;
  6339. }, 1 );
  6340. } );
  6341. _api_registerPlural( 'tables().header()', 'table().header()' , function () {
  6342. return this.iterator( 'table', function ( ctx ) {
  6343. return ctx.nTHead;
  6344. }, 1 );
  6345. } );
  6346. _api_registerPlural( 'tables().footer()', 'table().footer()' , function () {
  6347. return this.iterator( 'table', function ( ctx ) {
  6348. return ctx.nTFoot;
  6349. }, 1 );
  6350. } );
  6351. _api_registerPlural( 'tables().containers()', 'table().container()' , function () {
  6352. return this.iterator( 'table', function ( ctx ) {
  6353. return ctx.nTableWrapper;
  6354. }, 1 );
  6355. } );
  6356. /**
  6357. * Redraw the tables in the current context.
  6358. */
  6359. _api_register( 'draw()', function ( paging ) {
  6360. return this.iterator( 'table', function ( settings ) {
  6361. if ( paging === 'page' ) {
  6362. _fnDraw( settings );
  6363. }
  6364. else {
  6365. if ( typeof paging === 'string' ) {
  6366. paging = paging === 'full-hold' ?
  6367. false :
  6368. true;
  6369. }
  6370. _fnReDraw( settings, paging===false );
  6371. }
  6372. } );
  6373. } );
  6374. /**
  6375. * Get the current page index.
  6376. *
  6377. * @return {integer} Current page index (zero based)
  6378. *//**
  6379. * Set the current page.
  6380. *
  6381. * Note that if you attempt to show a page which does not exist, DataTables will
  6382. * not throw an error, but rather reset the paging.
  6383. *
  6384. * @param {integer|string} action The paging action to take. This can be one of:
  6385. * * `integer` - The page index to jump to
  6386. * * `string` - An action to take:
  6387. * * `first` - Jump to first page.
  6388. * * `next` - Jump to the next page
  6389. * * `previous` - Jump to previous page
  6390. * * `last` - Jump to the last page.
  6391. * @returns {DataTables.Api} this
  6392. */
  6393. _api_register( 'page()', function ( action ) {
  6394. if ( action === undefined ) {
  6395. return this.page.info().page; // not an expensive call
  6396. }
  6397. // else, have an action to take on all tables
  6398. return this.iterator( 'table', function ( settings ) {
  6399. _fnPageChange( settings, action );
  6400. } );
  6401. } );
  6402. /**
  6403. * Paging information for the first table in the current context.
  6404. *
  6405. * If you require paging information for another table, use the `table()` method
  6406. * with a suitable selector.
  6407. *
  6408. * @return {object} Object with the following properties set:
  6409. * * `page` - Current page index (zero based - i.e. the first page is `0`)
  6410. * * `pages` - Total number of pages
  6411. * * `start` - Display index for the first record shown on the current page
  6412. * * `end` - Display index for the last record shown on the current page
  6413. * * `length` - Display length (number of records). Note that generally `start
  6414. * + length = end`, but this is not always true, for example if there are
  6415. * only 2 records to show on the final page, with a length of 10.
  6416. * * `recordsTotal` - Full data set length
  6417. * * `recordsDisplay` - Data set length once the current filtering criterion
  6418. * are applied.
  6419. */
  6420. _api_register( 'page.info()', function ( action ) {
  6421. if ( this.context.length === 0 ) {
  6422. return undefined;
  6423. }
  6424. var
  6425. settings = this.context[0],
  6426. start = settings._iDisplayStart,
  6427. len = settings.oFeatures.bPaginate ? settings._iDisplayLength : -1,
  6428. visRecords = settings.fnRecordsDisplay(),
  6429. all = len === -1;
  6430. return {
  6431. "page": all ? 0 : Math.floor( start / len ),
  6432. "pages": all ? 1 : Math.ceil( visRecords / len ),
  6433. "start": start,
  6434. "end": settings.fnDisplayEnd(),
  6435. "length": len,
  6436. "recordsTotal": settings.fnRecordsTotal(),
  6437. "recordsDisplay": visRecords,
  6438. "serverSide": _fnDataSource( settings ) === 'ssp'
  6439. };
  6440. } );
  6441. /**
  6442. * Get the current page length.
  6443. *
  6444. * @return {integer} Current page length. Note `-1` indicates that all records
  6445. * are to be shown.
  6446. *//**
  6447. * Set the current page length.
  6448. *
  6449. * @param {integer} Page length to set. Use `-1` to show all records.
  6450. * @returns {DataTables.Api} this
  6451. */
  6452. _api_register( 'page.len()', function ( len ) {
  6453. // Note that we can't call this function 'length()' because `length`
  6454. // is a Javascript property of functions which defines how many arguments
  6455. // the function expects.
  6456. if ( len === undefined ) {
  6457. return this.context.length !== 0 ?
  6458. this.context[0]._iDisplayLength :
  6459. undefined;
  6460. }
  6461. // else, set the page length
  6462. return this.iterator( 'table', function ( settings ) {
  6463. _fnLengthChange( settings, len );
  6464. } );
  6465. } );
  6466. var __reload = function ( settings, holdPosition, callback ) {
  6467. // Use the draw event to trigger a callback
  6468. if ( callback ) {
  6469. var api = new _Api( settings );
  6470. api.one( 'draw', function () {
  6471. callback( api.ajax.json() );
  6472. } );
  6473. }
  6474. if ( _fnDataSource( settings ) == 'ssp' ) {
  6475. _fnReDraw( settings, holdPosition );
  6476. }
  6477. else {
  6478. _fnProcessingDisplay( settings, true );
  6479. // Cancel an existing request
  6480. var xhr = settings.jqXHR;
  6481. if ( xhr && xhr.readyState !== 4 ) {
  6482. xhr.abort();
  6483. }
  6484. // Trigger xhr
  6485. _fnBuildAjax( settings, [], function( json ) {
  6486. _fnClearTable( settings );
  6487. var data = _fnAjaxDataSrc( settings, json );
  6488. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6489. _fnAddData( settings, data[i] );
  6490. }
  6491. _fnReDraw( settings, holdPosition );
  6492. _fnProcessingDisplay( settings, false );
  6493. } );
  6494. }
  6495. };
  6496. /**
  6497. * Get the JSON response from the last Ajax request that DataTables made to the
  6498. * server. Note that this returns the JSON from the first table in the current
  6499. * context.
  6500. *
  6501. * @return {object} JSON received from the server.
  6502. */
  6503. _api_register( 'ajax.json()', function () {
  6504. var ctx = this.context;
  6505. if ( ctx.length > 0 ) {
  6506. return ctx[0].json;
  6507. }
  6508. // else return undefined;
  6509. } );
  6510. /**
  6511. * Get the data submitted in the last Ajax request
  6512. */
  6513. _api_register( 'ajax.params()', function () {
  6514. var ctx = this.context;
  6515. if ( ctx.length > 0 ) {
  6516. return ctx[0].oAjaxData;
  6517. }
  6518. // else return undefined;
  6519. } );
  6520. /**
  6521. * Reload tables from the Ajax data source. Note that this function will
  6522. * automatically re-draw the table when the remote data has been loaded.
  6523. *
  6524. * @param {boolean} [reset=true] Reset (default) or hold the current paging
  6525. * position. A full re-sort and re-filter is performed when this method is
  6526. * called, which is why the pagination reset is the default action.
  6527. * @returns {DataTables.Api} this
  6528. */
  6529. _api_register( 'ajax.reload()', function ( callback, resetPaging ) {
  6530. return this.iterator( 'table', function (settings) {
  6531. __reload( settings, resetPaging===false, callback );
  6532. } );
  6533. } );
  6534. /**
  6535. * Get the current Ajax URL. Note that this returns the URL from the first
  6536. * table in the current context.
  6537. *
  6538. * @return {string} Current Ajax source URL
  6539. *//**
  6540. * Set the Ajax URL. Note that this will set the URL for all tables in the
  6541. * current context.
  6542. *
  6543. * @param {string} url URL to set.
  6544. * @returns {DataTables.Api} this
  6545. */
  6546. _api_register( 'ajax.url()', function ( url ) {
  6547. var ctx = this.context;
  6548. if ( url === undefined ) {
  6549. // get
  6550. if ( ctx.length === 0 ) {
  6551. return undefined;
  6552. }
  6553. ctx = ctx[0];
  6554. return ctx.ajax ?
  6555. $.isPlainObject( ctx.ajax ) ?
  6556. ctx.ajax.url :
  6557. ctx.ajax :
  6558. ctx.sAjaxSource;
  6559. }
  6560. // set
  6561. return this.iterator( 'table', function ( settings ) {
  6562. if ( $.isPlainObject( settings.ajax ) ) {
  6563. settings.ajax.url = url;
  6564. }
  6565. else {
  6566. settings.ajax = url;
  6567. }
  6568. // No need to consider sAjaxSource here since DataTables gives priority
  6569. // to `ajax` over `sAjaxSource`. So setting `ajax` here, renders any
  6570. // value of `sAjaxSource` redundant.
  6571. } );
  6572. } );
  6573. /**
  6574. * Load data from the newly set Ajax URL. Note that this method is only
  6575. * available when `ajax.url()` is used to set a URL. Additionally, this method
  6576. * has the same effect as calling `ajax.reload()` but is provided for
  6577. * convenience when setting a new URL. Like `ajax.reload()` it will
  6578. * automatically redraw the table once the remote data has been loaded.
  6579. *
  6580. * @returns {DataTables.Api} this
  6581. */
  6582. _api_register( 'ajax.url().load()', function ( callback, resetPaging ) {
  6583. // Same as a reload, but makes sense to present it for easy access after a
  6584. // url change
  6585. return this.iterator( 'table', function ( ctx ) {
  6586. __reload( ctx, resetPaging===false, callback );
  6587. } );
  6588. } );
  6589. var _selector_run = function ( type, selector, selectFn, settings, opts )
  6590. {
  6591. var
  6592. out = [], res,
  6593. a, i, ien, j, jen,
  6594. selectorType = typeof selector;
  6595. // Can't just check for isArray here, as an API or jQuery instance might be
  6596. // given with their array like look
  6597. if ( ! selector || selectorType === 'string' || selectorType === 'function' || selector.length === undefined ) {
  6598. selector = [ selector ];
  6599. }
  6600. for ( i=0, ien=selector.length ; i<ien ; i++ ) {
  6601. // Only split on simple strings - complex expressions will be jQuery selectors
  6602. a = selector[i] && selector[i].split && ! selector[i].match(/[\[\(:]/) ?
  6603. selector[i].split(',') :
  6604. [ selector[i] ];
  6605. for ( j=0, jen=a.length ; j<jen ; j++ ) {
  6606. res = selectFn( typeof a[j] === 'string' ? $.trim(a[j]) : a[j] );
  6607. if ( res && res.length ) {
  6608. out = out.concat( res );
  6609. }
  6610. }
  6611. }
  6612. // selector extensions
  6613. var ext = _ext.selector[ type ];
  6614. if ( ext.length ) {
  6615. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  6616. out = ext[i]( settings, opts, out );
  6617. }
  6618. }
  6619. return _unique( out );
  6620. };
  6621. var _selector_opts = function ( opts )
  6622. {
  6623. if ( ! opts ) {
  6624. opts = {};
  6625. }
  6626. // Backwards compatibility for 1.9- which used the terminology filter rather
  6627. // than search
  6628. if ( opts.filter && opts.search === undefined ) {
  6629. opts.search = opts.filter;
  6630. }
  6631. return $.extend( {
  6632. search: 'none',
  6633. order: 'current',
  6634. page: 'all'
  6635. }, opts );
  6636. };
  6637. var _selector_first = function ( inst )
  6638. {
  6639. // Reduce the API instance to the first item found
  6640. for ( var i=0, ien=inst.length ; i<ien ; i++ ) {
  6641. if ( inst[i].length > 0 ) {
  6642. // Assign the first element to the first item in the instance
  6643. // and truncate the instance and context
  6644. inst[0] = inst[i];
  6645. inst[0].length = 1;
  6646. inst.length = 1;
  6647. inst.context = [ inst.context[i] ];
  6648. return inst;
  6649. }
  6650. }
  6651. // Not found - return an empty instance
  6652. inst.length = 0;
  6653. return inst;
  6654. };
  6655. var _selector_row_indexes = function ( settings, opts )
  6656. {
  6657. var
  6658. i, ien, tmp, a=[],
  6659. displayFiltered = settings.aiDisplay,
  6660. displayMaster = settings.aiDisplayMaster;
  6661. var
  6662. search = opts.search, // none, applied, removed
  6663. order = opts.order, // applied, current, index (original - compatibility with 1.9)
  6664. page = opts.page; // all, current
  6665. if ( _fnDataSource( settings ) == 'ssp' ) {
  6666. // In server-side processing mode, most options are irrelevant since
  6667. // rows not shown don't exist and the index order is the applied order
  6668. // Removed is a special case - for consistency just return an empty
  6669. // array
  6670. return search === 'removed' ?
  6671. [] :
  6672. _range( 0, displayMaster.length );
  6673. }
  6674. else if ( page == 'current' ) {
  6675. // Current page implies that order=current and fitler=applied, since it is
  6676. // fairly senseless otherwise, regardless of what order and search actually
  6677. // are
  6678. for ( i=settings._iDisplayStart, ien=settings.fnDisplayEnd() ; i<ien ; i++ ) {
  6679. a.push( displayFiltered[i] );
  6680. }
  6681. }
  6682. else if ( order == 'current' || order == 'applied' ) {
  6683. if ( search == 'none') {
  6684. a = displayMaster.slice();
  6685. }
  6686. else if ( search == 'applied' ) {
  6687. a = displayFiltered.slice();
  6688. }
  6689. else if ( search == 'removed' ) {
  6690. // O(n+m) solution by creating a hash map
  6691. var displayFilteredMap = {};
  6692. for ( var i=0, ien=displayFiltered.length ; i<ien ; i++ ) {
  6693. displayFilteredMap[displayFiltered[i]] = null;
  6694. }
  6695. a = $.map( displayMaster, function (el) {
  6696. return ! displayFilteredMap.hasOwnProperty(el) ?
  6697. el :
  6698. null;
  6699. } );
  6700. }
  6701. }
  6702. else if ( order == 'index' || order == 'original' ) {
  6703. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  6704. if ( search == 'none' ) {
  6705. a.push( i );
  6706. }
  6707. else { // applied | removed
  6708. tmp = $.inArray( i, displayFiltered );
  6709. if ((tmp === -1 && search == 'removed') ||
  6710. (tmp >= 0 && search == 'applied') )
  6711. {
  6712. a.push( i );
  6713. }
  6714. }
  6715. }
  6716. }
  6717. return a;
  6718. };
  6719. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6720. * Rows
  6721. *
  6722. * {} - no selector - use all available rows
  6723. * {integer} - row aoData index
  6724. * {node} - TR node
  6725. * {string} - jQuery selector to apply to the TR elements
  6726. * {array} - jQuery array of nodes, or simply an array of TR nodes
  6727. *
  6728. */
  6729. var __row_selector = function ( settings, selector, opts )
  6730. {
  6731. var rows;
  6732. var run = function ( sel ) {
  6733. var selInt = _intVal( sel );
  6734. var i, ien;
  6735. var aoData = settings.aoData;
  6736. // Short cut - selector is a number and no options provided (default is
  6737. // all records, so no need to check if the index is in there, since it
  6738. // must be - dev error if the index doesn't exist).
  6739. if ( selInt !== null && ! opts ) {
  6740. return [ selInt ];
  6741. }
  6742. if ( ! rows ) {
  6743. rows = _selector_row_indexes( settings, opts );
  6744. }
  6745. if ( selInt !== null && $.inArray( selInt, rows ) !== -1 ) {
  6746. // Selector - integer
  6747. return [ selInt ];
  6748. }
  6749. else if ( sel === null || sel === undefined || sel === '' ) {
  6750. // Selector - none
  6751. return rows;
  6752. }
  6753. // Selector - function
  6754. if ( typeof sel === 'function' ) {
  6755. return $.map( rows, function (idx) {
  6756. var row = aoData[ idx ];
  6757. return sel( idx, row._aData, row.nTr ) ? idx : null;
  6758. } );
  6759. }
  6760. // Selector - node
  6761. if ( sel.nodeName ) {
  6762. var rowIdx = sel._DT_RowIndex; // Property added by DT for fast lookup
  6763. var cellIdx = sel._DT_CellIndex;
  6764. if ( rowIdx !== undefined ) {
  6765. // Make sure that the row is actually still present in the table
  6766. return aoData[ rowIdx ] && aoData[ rowIdx ].nTr === sel ?
  6767. [ rowIdx ] :
  6768. [];
  6769. }
  6770. else if ( cellIdx ) {
  6771. return aoData[ cellIdx.row ] && aoData[ cellIdx.row ].nTr === sel.parentNode ?
  6772. [ cellIdx.row ] :
  6773. [];
  6774. }
  6775. else {
  6776. var host = $(sel).closest('*[data-dt-row]');
  6777. return host.length ?
  6778. [ host.data('dt-row') ] :
  6779. [];
  6780. }
  6781. }
  6782. // ID selector. Want to always be able to select rows by id, regardless
  6783. // of if the tr element has been created or not, so can't rely upon
  6784. // jQuery here - hence a custom implementation. This does not match
  6785. // Sizzle's fast selector or HTML4 - in HTML5 the ID can be anything,
  6786. // but to select it using a CSS selector engine (like Sizzle or
  6787. // querySelect) it would need to need to be escaped for some characters.
  6788. // DataTables simplifies this for row selectors since you can select
  6789. // only a row. A # indicates an id any anything that follows is the id -
  6790. // unescaped.
  6791. if ( typeof sel === 'string' && sel.charAt(0) === '#' ) {
  6792. // get row index from id
  6793. var rowObj = settings.aIds[ sel.replace( /^#/, '' ) ];
  6794. if ( rowObj !== undefined ) {
  6795. return [ rowObj.idx ];
  6796. }
  6797. // need to fall through to jQuery in case there is DOM id that
  6798. // matches
  6799. }
  6800. // Get nodes in the order from the `rows` array with null values removed
  6801. var nodes = _removeEmpty(
  6802. _pluck_order( settings.aoData, rows, 'nTr' )
  6803. );
  6804. // Selector - jQuery selector string, array of nodes or jQuery object/
  6805. // As jQuery's .filter() allows jQuery objects to be passed in filter,
  6806. // it also allows arrays, so this will cope with all three options
  6807. return $(nodes)
  6808. .filter( sel )
  6809. .map( function () {
  6810. return this._DT_RowIndex;
  6811. } )
  6812. .toArray();
  6813. };
  6814. return _selector_run( 'row', selector, run, settings, opts );
  6815. };
  6816. _api_register( 'rows()', function ( selector, opts ) {
  6817. // argument shifting
  6818. if ( selector === undefined ) {
  6819. selector = '';
  6820. }
  6821. else if ( $.isPlainObject( selector ) ) {
  6822. opts = selector;
  6823. selector = '';
  6824. }
  6825. opts = _selector_opts( opts );
  6826. var inst = this.iterator( 'table', function ( settings ) {
  6827. return __row_selector( settings, selector, opts );
  6828. }, 1 );
  6829. // Want argument shifting here and in __row_selector?
  6830. inst.selector.rows = selector;
  6831. inst.selector.opts = opts;
  6832. return inst;
  6833. } );
  6834. _api_register( 'rows().nodes()', function () {
  6835. return this.iterator( 'row', function ( settings, row ) {
  6836. return settings.aoData[ row ].nTr || undefined;
  6837. }, 1 );
  6838. } );
  6839. _api_register( 'rows().data()', function () {
  6840. return this.iterator( true, 'rows', function ( settings, rows ) {
  6841. return _pluck_order( settings.aoData, rows, '_aData' );
  6842. }, 1 );
  6843. } );
  6844. _api_registerPlural( 'rows().cache()', 'row().cache()', function ( type ) {
  6845. return this.iterator( 'row', function ( settings, row ) {
  6846. var r = settings.aoData[ row ];
  6847. return type === 'search' ? r._aFilterData : r._aSortData;
  6848. }, 1 );
  6849. } );
  6850. _api_registerPlural( 'rows().invalidate()', 'row().invalidate()', function ( src ) {
  6851. return this.iterator( 'row', function ( settings, row ) {
  6852. _fnInvalidate( settings, row, src );
  6853. } );
  6854. } );
  6855. _api_registerPlural( 'rows().indexes()', 'row().index()', function () {
  6856. return this.iterator( 'row', function ( settings, row ) {
  6857. return row;
  6858. }, 1 );
  6859. } );
  6860. _api_registerPlural( 'rows().ids()', 'row().id()', function ( hash ) {
  6861. var a = [];
  6862. var context = this.context;
  6863. // `iterator` will drop undefined values, but in this case we want them
  6864. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  6865. for ( var j=0, jen=this[i].length ; j<jen ; j++ ) {
  6866. var id = context[i].rowIdFn( context[i].aoData[ this[i][j] ]._aData );
  6867. a.push( (hash === true ? '#' : '' )+ id );
  6868. }
  6869. }
  6870. return new _Api( context, a );
  6871. } );
  6872. _api_registerPlural( 'rows().remove()', 'row().remove()', function () {
  6873. var that = this;
  6874. this.iterator( 'row', function ( settings, row, thatIdx ) {
  6875. var data = settings.aoData;
  6876. var rowData = data[ row ];
  6877. var i, ien, j, jen;
  6878. var loopRow, loopCells;
  6879. data.splice( row, 1 );
  6880. // Update the cached indexes
  6881. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  6882. loopRow = data[i];
  6883. loopCells = loopRow.anCells;
  6884. // Rows
  6885. if ( loopRow.nTr !== null ) {
  6886. loopRow.nTr._DT_RowIndex = i;
  6887. }
  6888. // Cells
  6889. if ( loopCells !== null ) {
  6890. for ( j=0, jen=loopCells.length ; j<jen ; j++ ) {
  6891. loopCells[j]._DT_CellIndex.row = i;
  6892. }
  6893. }
  6894. }
  6895. // Delete from the display arrays
  6896. _fnDeleteIndex( settings.aiDisplayMaster, row );
  6897. _fnDeleteIndex( settings.aiDisplay, row );
  6898. _fnDeleteIndex( that[ thatIdx ], row, false ); // maintain local indexes
  6899. // For server-side processing tables - subtract the deleted row from the count
  6900. if ( settings._iRecordsDisplay > 0 ) {
  6901. settings._iRecordsDisplay--;
  6902. }
  6903. // Check for an 'overflow' they case for displaying the table
  6904. _fnLengthOverflow( settings );
  6905. // Remove the row's ID reference if there is one
  6906. var id = settings.rowIdFn( rowData._aData );
  6907. if ( id !== undefined ) {
  6908. delete settings.aIds[ id ];
  6909. }
  6910. } );
  6911. this.iterator( 'table', function ( settings ) {
  6912. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  6913. settings.aoData[i].idx = i;
  6914. }
  6915. } );
  6916. return this;
  6917. } );
  6918. _api_register( 'rows.add()', function ( rows ) {
  6919. var newRows = this.iterator( 'table', function ( settings ) {
  6920. var row, i, ien;
  6921. var out = [];
  6922. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  6923. row = rows[i];
  6924. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  6925. out.push( _fnAddTr( settings, row )[0] );
  6926. }
  6927. else {
  6928. out.push( _fnAddData( settings, row ) );
  6929. }
  6930. }
  6931. return out;
  6932. }, 1 );
  6933. // Return an Api.rows() extended instance, so rows().nodes() etc can be used
  6934. var modRows = this.rows( -1 );
  6935. modRows.pop();
  6936. $.merge( modRows, newRows );
  6937. return modRows;
  6938. } );
  6939. /**
  6940. *
  6941. */
  6942. _api_register( 'row()', function ( selector, opts ) {
  6943. return _selector_first( this.rows( selector, opts ) );
  6944. } );
  6945. _api_register( 'row().data()', function ( data ) {
  6946. var ctx = this.context;
  6947. if ( data === undefined ) {
  6948. // Get
  6949. return ctx.length && this.length ?
  6950. ctx[0].aoData[ this[0] ]._aData :
  6951. undefined;
  6952. }
  6953. // Set
  6954. var row = ctx[0].aoData[ this[0] ];
  6955. row._aData = data;
  6956. // If the DOM has an id, and the data source is an array
  6957. if ( $.isArray( data ) && row.nTr.id ) {
  6958. _fnSetObjectDataFn( ctx[0].rowId )( data, row.nTr.id );
  6959. }
  6960. // Automatically invalidate
  6961. _fnInvalidate( ctx[0], this[0], 'data' );
  6962. return this;
  6963. } );
  6964. _api_register( 'row().node()', function () {
  6965. var ctx = this.context;
  6966. return ctx.length && this.length ?
  6967. ctx[0].aoData[ this[0] ].nTr || null :
  6968. null;
  6969. } );
  6970. _api_register( 'row.add()', function ( row ) {
  6971. // Allow a jQuery object to be passed in - only a single row is added from
  6972. // it though - the first element in the set
  6973. if ( row instanceof $ && row.length ) {
  6974. row = row[0];
  6975. }
  6976. var rows = this.iterator( 'table', function ( settings ) {
  6977. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  6978. return _fnAddTr( settings, row )[0];
  6979. }
  6980. return _fnAddData( settings, row );
  6981. } );
  6982. // Return an Api.rows() extended instance, with the newly added row selected
  6983. return this.row( rows[0] );
  6984. } );
  6985. var __details_add = function ( ctx, row, data, klass )
  6986. {
  6987. // Convert to array of TR elements
  6988. var rows = [];
  6989. var addRow = function ( r, k ) {
  6990. // Recursion to allow for arrays of jQuery objects
  6991. if ( $.isArray( r ) || r instanceof $ ) {
  6992. for ( var i=0, ien=r.length ; i<ien ; i++ ) {
  6993. addRow( r[i], k );
  6994. }
  6995. return;
  6996. }
  6997. // If we get a TR element, then just add it directly - up to the dev
  6998. // to add the correct number of columns etc
  6999. if ( r.nodeName && r.nodeName.toLowerCase() === 'tr' ) {
  7000. rows.push( r );
  7001. }
  7002. else {
  7003. // Otherwise create a row with a wrapper
  7004. var created = $('<tr><td/></tr>').addClass( k );
  7005. $('td', created)
  7006. .addClass( k )
  7007. .html( r )
  7008. [0].colSpan = _fnVisbleColumns( ctx );
  7009. rows.push( created[0] );
  7010. }
  7011. };
  7012. addRow( data, klass );
  7013. if ( row._details ) {
  7014. row._details.detach();
  7015. }
  7016. row._details = $(rows);
  7017. // If the children were already shown, that state should be retained
  7018. if ( row._detailsShow ) {
  7019. row._details.insertAfter( row.nTr );
  7020. }
  7021. };
  7022. var __details_remove = function ( api, idx )
  7023. {
  7024. var ctx = api.context;
  7025. if ( ctx.length ) {
  7026. var row = ctx[0].aoData[ idx !== undefined ? idx : api[0] ];
  7027. if ( row && row._details ) {
  7028. row._details.remove();
  7029. row._detailsShow = undefined;
  7030. row._details = undefined;
  7031. }
  7032. }
  7033. };
  7034. var __details_display = function ( api, show ) {
  7035. var ctx = api.context;
  7036. if ( ctx.length && api.length ) {
  7037. var row = ctx[0].aoData[ api[0] ];
  7038. if ( row._details ) {
  7039. row._detailsShow = show;
  7040. if ( show ) {
  7041. row._details.insertAfter( row.nTr );
  7042. }
  7043. else {
  7044. row._details.detach();
  7045. }
  7046. __details_events( ctx[0] );
  7047. }
  7048. }
  7049. };
  7050. var __details_events = function ( settings )
  7051. {
  7052. var api = new _Api( settings );
  7053. var namespace = '.dt.DT_details';
  7054. var drawEvent = 'draw'+namespace;
  7055. var colvisEvent = 'column-visibility'+namespace;
  7056. var destroyEvent = 'destroy'+namespace;
  7057. var data = settings.aoData;
  7058. api.off( drawEvent +' '+ colvisEvent +' '+ destroyEvent );
  7059. if ( _pluck( data, '_details' ).length > 0 ) {
  7060. // On each draw, insert the required elements into the document
  7061. api.on( drawEvent, function ( e, ctx ) {
  7062. if ( settings !== ctx ) {
  7063. return;
  7064. }
  7065. api.rows( {page:'current'} ).eq(0).each( function (idx) {
  7066. // Internal data grab
  7067. var row = data[ idx ];
  7068. if ( row._detailsShow ) {
  7069. row._details.insertAfter( row.nTr );
  7070. }
  7071. } );
  7072. } );
  7073. // Column visibility change - update the colspan
  7074. api.on( colvisEvent, function ( e, ctx, idx, vis ) {
  7075. if ( settings !== ctx ) {
  7076. return;
  7077. }
  7078. // Update the colspan for the details rows (note, only if it already has
  7079. // a colspan)
  7080. var row, visible = _fnVisbleColumns( ctx );
  7081. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  7082. row = data[i];
  7083. if ( row._details ) {
  7084. row._details.children('td[colspan]').attr('colspan', visible );
  7085. }
  7086. }
  7087. } );
  7088. // Table destroyed - nuke any child rows
  7089. api.on( destroyEvent, function ( e, ctx ) {
  7090. if ( settings !== ctx ) {
  7091. return;
  7092. }
  7093. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  7094. if ( data[i]._details ) {
  7095. __details_remove( api, i );
  7096. }
  7097. }
  7098. } );
  7099. }
  7100. };
  7101. // Strings for the method names to help minification
  7102. var _emp = '';
  7103. var _child_obj = _emp+'row().child';
  7104. var _child_mth = _child_obj+'()';
  7105. // data can be:
  7106. // tr
  7107. // string
  7108. // jQuery or array of any of the above
  7109. _api_register( _child_mth, function ( data, klass ) {
  7110. var ctx = this.context;
  7111. if ( data === undefined ) {
  7112. // get
  7113. return ctx.length && this.length ?
  7114. ctx[0].aoData[ this[0] ]._details :
  7115. undefined;
  7116. }
  7117. else if ( data === true ) {
  7118. // show
  7119. this.child.show();
  7120. }
  7121. else if ( data === false ) {
  7122. // remove
  7123. __details_remove( this );
  7124. }
  7125. else if ( ctx.length && this.length ) {
  7126. // set
  7127. __details_add( ctx[0], ctx[0].aoData[ this[0] ], data, klass );
  7128. }
  7129. return this;
  7130. } );
  7131. _api_register( [
  7132. _child_obj+'.show()',
  7133. _child_mth+'.show()' // only when `child()` was called with parameters (without
  7134. ], function ( show ) { // it returns an object and this method is not executed)
  7135. __details_display( this, true );
  7136. return this;
  7137. } );
  7138. _api_register( [
  7139. _child_obj+'.hide()',
  7140. _child_mth+'.hide()' // only when `child()` was called with parameters (without
  7141. ], function () { // it returns an object and this method is not executed)
  7142. __details_display( this, false );
  7143. return this;
  7144. } );
  7145. _api_register( [
  7146. _child_obj+'.remove()',
  7147. _child_mth+'.remove()' // only when `child()` was called with parameters (without
  7148. ], function () { // it returns an object and this method is not executed)
  7149. __details_remove( this );
  7150. return this;
  7151. } );
  7152. _api_register( _child_obj+'.isShown()', function () {
  7153. var ctx = this.context;
  7154. if ( ctx.length && this.length ) {
  7155. // _detailsShown as false or undefined will fall through to return false
  7156. return ctx[0].aoData[ this[0] ]._detailsShow || false;
  7157. }
  7158. return false;
  7159. } );
  7160. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  7161. * Columns
  7162. *
  7163. * {integer} - column index (>=0 count from left, <0 count from right)
  7164. * "{integer}:visIdx" - visible column index (i.e. translate to column index) (>=0 count from left, <0 count from right)
  7165. * "{integer}:visible" - alias for {integer}:visIdx (>=0 count from left, <0 count from right)
  7166. * "{string}:name" - column name
  7167. * "{string}" - jQuery selector on column header nodes
  7168. *
  7169. */
  7170. // can be an array of these items, comma separated list, or an array of comma
  7171. // separated lists
  7172. var __re_column_selector = /^([^:]+):(name|visIdx|visible)$/;
  7173. // r1 and r2 are redundant - but it means that the parameters match for the
  7174. // iterator callback in columns().data()
  7175. var __columnData = function ( settings, column, r1, r2, rows ) {
  7176. var a = [];
  7177. for ( var row=0, ien=rows.length ; row<ien ; row++ ) {
  7178. a.push( _fnGetCellData( settings, rows[row], column ) );
  7179. }
  7180. return a;
  7181. };
  7182. var __column_selector = function ( settings, selector, opts )
  7183. {
  7184. var
  7185. columns = settings.aoColumns,
  7186. names = _pluck( columns, 'sName' ),
  7187. nodes = _pluck( columns, 'nTh' );
  7188. var run = function ( s ) {
  7189. var selInt = _intVal( s );
  7190. // Selector - all
  7191. if ( s === '' ) {
  7192. return _range( columns.length );
  7193. }
  7194. // Selector - index
  7195. if ( selInt !== null ) {
  7196. return [ selInt >= 0 ?
  7197. selInt : // Count from left
  7198. columns.length + selInt // Count from right (+ because its a negative value)
  7199. ];
  7200. }
  7201. // Selector = function
  7202. if ( typeof s === 'function' ) {
  7203. var rows = _selector_row_indexes( settings, opts );
  7204. return $.map( columns, function (col, idx) {
  7205. return s(
  7206. idx,
  7207. __columnData( settings, idx, 0, 0, rows ),
  7208. nodes[ idx ]
  7209. ) ? idx : null;
  7210. } );
  7211. }
  7212. // jQuery or string selector
  7213. var match = typeof s === 'string' ?
  7214. s.match( __re_column_selector ) :
  7215. '';
  7216. if ( match ) {
  7217. switch( match[2] ) {
  7218. case 'visIdx':
  7219. case 'visible':
  7220. var idx = parseInt( match[1], 10 );
  7221. // Visible index given, convert to column index
  7222. if ( idx < 0 ) {
  7223. // Counting from the right
  7224. var visColumns = $.map( columns, function (col,i) {
  7225. return col.bVisible ? i : null;
  7226. } );
  7227. return [ visColumns[ visColumns.length + idx ] ];
  7228. }
  7229. // Counting from the left
  7230. return [ _fnVisibleToColumnIndex( settings, idx ) ];
  7231. case 'name':
  7232. // match by name. `names` is column index complete and in order
  7233. return $.map( names, function (name, i) {
  7234. return name === match[1] ? i : null;
  7235. } );
  7236. default:
  7237. return [];
  7238. }
  7239. }
  7240. // Cell in the table body
  7241. if ( s.nodeName && s._DT_CellIndex ) {
  7242. return [ s._DT_CellIndex.column ];
  7243. }
  7244. // jQuery selector on the TH elements for the columns
  7245. var jqResult = $( nodes )
  7246. .filter( s )
  7247. .map( function () {
  7248. return $.inArray( this, nodes ); // `nodes` is column index complete and in order
  7249. } )
  7250. .toArray();
  7251. if ( jqResult.length || ! s.nodeName ) {
  7252. return jqResult;
  7253. }
  7254. // Otherwise a node which might have a `dt-column` data attribute, or be
  7255. // a child or such an element
  7256. var host = $(s).closest('*[data-dt-column]');
  7257. return host.length ?
  7258. [ host.data('dt-column') ] :
  7259. [];
  7260. };
  7261. return _selector_run( 'column', selector, run, settings, opts );
  7262. };
  7263. var __setColumnVis = function ( settings, column, vis ) {
  7264. var
  7265. cols = settings.aoColumns,
  7266. col = cols[ column ],
  7267. data = settings.aoData,
  7268. row, cells, i, ien, tr;
  7269. // Get
  7270. if ( vis === undefined ) {
  7271. return col.bVisible;
  7272. }
  7273. // Set
  7274. // No change
  7275. if ( col.bVisible === vis ) {
  7276. return;
  7277. }
  7278. if ( vis ) {
  7279. // Insert column
  7280. // Need to decide if we should use appendChild or insertBefore
  7281. var insertBefore = $.inArray( true, _pluck(cols, 'bVisible'), column+1 );
  7282. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  7283. tr = data[i].nTr;
  7284. cells = data[i].anCells;
  7285. if ( tr ) {
  7286. // insertBefore can act like appendChild if 2nd arg is null
  7287. tr.insertBefore( cells[ column ], cells[ insertBefore ] || null );
  7288. }
  7289. }
  7290. }
  7291. else {
  7292. // Remove column
  7293. $( _pluck( settings.aoData, 'anCells', column ) ).detach();
  7294. }
  7295. // Common actions
  7296. col.bVisible = vis;
  7297. };
  7298. _api_register( 'columns()', function ( selector, opts ) {
  7299. // argument shifting
  7300. if ( selector === undefined ) {
  7301. selector = '';
  7302. }
  7303. else if ( $.isPlainObject( selector ) ) {
  7304. opts = selector;
  7305. selector = '';
  7306. }
  7307. opts = _selector_opts( opts );
  7308. var inst = this.iterator( 'table', function ( settings ) {
  7309. return __column_selector( settings, selector, opts );
  7310. }, 1 );
  7311. // Want argument shifting here and in _row_selector?
  7312. inst.selector.cols = selector;
  7313. inst.selector.opts = opts;
  7314. return inst;
  7315. } );
  7316. _api_registerPlural( 'columns().header()', 'column().header()', function ( selector, opts ) {
  7317. return this.iterator( 'column', function ( settings, column ) {
  7318. return settings.aoColumns[column].nTh;
  7319. }, 1 );
  7320. } );
  7321. _api_registerPlural( 'columns().footer()', 'column().footer()', function ( selector, opts ) {
  7322. return this.iterator( 'column', function ( settings, column ) {
  7323. return settings.aoColumns[column].nTf;
  7324. }, 1 );
  7325. } );
  7326. _api_registerPlural( 'columns().data()', 'column().data()', function () {
  7327. return this.iterator( 'column-rows', __columnData, 1 );
  7328. } );
  7329. _api_registerPlural( 'columns().dataSrc()', 'column().dataSrc()', function () {
  7330. return this.iterator( 'column', function ( settings, column ) {
  7331. return settings.aoColumns[column].mData;
  7332. }, 1 );
  7333. } );
  7334. _api_registerPlural( 'columns().cache()', 'column().cache()', function ( type ) {
  7335. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7336. return _pluck_order( settings.aoData, rows,
  7337. type === 'search' ? '_aFilterData' : '_aSortData', column
  7338. );
  7339. }, 1 );
  7340. } );
  7341. _api_registerPlural( 'columns().nodes()', 'column().nodes()', function () {
  7342. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7343. return _pluck_order( settings.aoData, rows, 'anCells', column ) ;
  7344. }, 1 );
  7345. } );
  7346. _api_registerPlural( 'columns().visible()', 'column().visible()', function ( vis, calc ) {
  7347. var that = this;
  7348. var ret = this.iterator( 'column', function ( settings, column ) {
  7349. if ( vis === undefined ) {
  7350. return settings.aoColumns[ column ].bVisible;
  7351. } // else
  7352. __setColumnVis( settings, column, vis );
  7353. } );
  7354. // Group the column visibility changes
  7355. if ( vis !== undefined ) {
  7356. this.iterator( 'table', function ( settings ) {
  7357. // Redraw the header after changes
  7358. _fnDrawHead( settings, settings.aoHeader );
  7359. _fnDrawHead( settings, settings.aoFooter );
  7360. // Update colspan for no records display. Child rows and extensions will use their own
  7361. // listeners to do this - only need to update the empty table item here
  7362. if ( ! settings.aiDisplay.length ) {
  7363. $(settings.nTBody).find('td[colspan]').attr('colspan', _fnVisbleColumns(settings));
  7364. }
  7365. _fnSaveState( settings );
  7366. // Second loop once the first is done for events
  7367. that.iterator( 'column', function ( settings, column ) {
  7368. _fnCallbackFire( settings, null, 'column-visibility', [settings, column, vis, calc] );
  7369. } );
  7370. if ( calc === undefined || calc ) {
  7371. that.columns.adjust();
  7372. }
  7373. });
  7374. }
  7375. return ret;
  7376. } );
  7377. _api_registerPlural( 'columns().indexes()', 'column().index()', function ( type ) {
  7378. return this.iterator( 'column', function ( settings, column ) {
  7379. return type === 'visible' ?
  7380. _fnColumnIndexToVisible( settings, column ) :
  7381. column;
  7382. }, 1 );
  7383. } );
  7384. _api_register( 'columns.adjust()', function () {
  7385. return this.iterator( 'table', function ( settings ) {
  7386. _fnAdjustColumnSizing( settings );
  7387. }, 1 );
  7388. } );
  7389. _api_register( 'column.index()', function ( type, idx ) {
  7390. if ( this.context.length !== 0 ) {
  7391. var ctx = this.context[0];
  7392. if ( type === 'fromVisible' || type === 'toData' ) {
  7393. return _fnVisibleToColumnIndex( ctx, idx );
  7394. }
  7395. else if ( type === 'fromData' || type === 'toVisible' ) {
  7396. return _fnColumnIndexToVisible( ctx, idx );
  7397. }
  7398. }
  7399. } );
  7400. _api_register( 'column()', function ( selector, opts ) {
  7401. return _selector_first( this.columns( selector, opts ) );
  7402. } );
  7403. var __cell_selector = function ( settings, selector, opts )
  7404. {
  7405. var data = settings.aoData;
  7406. var rows = _selector_row_indexes( settings, opts );
  7407. var cells = _removeEmpty( _pluck_order( data, rows, 'anCells' ) );
  7408. var allCells = $( [].concat.apply([], cells) );
  7409. var row;
  7410. var columns = settings.aoColumns.length;
  7411. var a, i, ien, j, o, host;
  7412. var run = function ( s ) {
  7413. var fnSelector = typeof s === 'function';
  7414. if ( s === null || s === undefined || fnSelector ) {
  7415. // All cells and function selectors
  7416. a = [];
  7417. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  7418. row = rows[i];
  7419. for ( j=0 ; j<columns ; j++ ) {
  7420. o = {
  7421. row: row,
  7422. column: j
  7423. };
  7424. if ( fnSelector ) {
  7425. // Selector - function
  7426. host = data[ row ];
  7427. if ( s( o, _fnGetCellData(settings, row, j), host.anCells ? host.anCells[j] : null ) ) {
  7428. a.push( o );
  7429. }
  7430. }
  7431. else {
  7432. // Selector - all
  7433. a.push( o );
  7434. }
  7435. }
  7436. }
  7437. return a;
  7438. }
  7439. // Selector - index
  7440. if ( $.isPlainObject( s ) ) {
  7441. // Valid cell index and its in the array of selectable rows
  7442. return s.column !== undefined && s.row !== undefined && $.inArray( s.row, rows ) !== -1 ?
  7443. [s] :
  7444. [];
  7445. }
  7446. // Selector - jQuery filtered cells
  7447. var jqResult = allCells
  7448. .filter( s )
  7449. .map( function (i, el) {
  7450. return { // use a new object, in case someone changes the values
  7451. row: el._DT_CellIndex.row,
  7452. column: el._DT_CellIndex.column
  7453. };
  7454. } )
  7455. .toArray();
  7456. if ( jqResult.length || ! s.nodeName ) {
  7457. return jqResult;
  7458. }
  7459. // Otherwise the selector is a node, and there is one last option - the
  7460. // element might be a child of an element which has dt-row and dt-column
  7461. // data attributes
  7462. host = $(s).closest('*[data-dt-row]');
  7463. return host.length ?
  7464. [ {
  7465. row: host.data('dt-row'),
  7466. column: host.data('dt-column')
  7467. } ] :
  7468. [];
  7469. };
  7470. return _selector_run( 'cell', selector, run, settings, opts );
  7471. };
  7472. _api_register( 'cells()', function ( rowSelector, columnSelector, opts ) {
  7473. // Argument shifting
  7474. if ( $.isPlainObject( rowSelector ) ) {
  7475. // Indexes
  7476. if ( rowSelector.row === undefined ) {
  7477. // Selector options in first parameter
  7478. opts = rowSelector;
  7479. rowSelector = null;
  7480. }
  7481. else {
  7482. // Cell index objects in first parameter
  7483. opts = columnSelector;
  7484. columnSelector = null;
  7485. }
  7486. }
  7487. if ( $.isPlainObject( columnSelector ) ) {
  7488. opts = columnSelector;
  7489. columnSelector = null;
  7490. }
  7491. // Cell selector
  7492. if ( columnSelector === null || columnSelector === undefined ) {
  7493. return this.iterator( 'table', function ( settings ) {
  7494. return __cell_selector( settings, rowSelector, _selector_opts( opts ) );
  7495. } );
  7496. }
  7497. // The default built in options need to apply to row and columns
  7498. var internalOpts = opts ? {
  7499. page: opts.page,
  7500. order: opts.order,
  7501. search: opts.search
  7502. } : {};
  7503. // Row + column selector
  7504. var columns = this.columns( columnSelector, internalOpts );
  7505. var rows = this.rows( rowSelector, internalOpts );
  7506. var i, ien, j, jen;
  7507. var cellsNoOpts = this.iterator( 'table', function ( settings, idx ) {
  7508. var a = [];
  7509. for ( i=0, ien=rows[idx].length ; i<ien ; i++ ) {
  7510. for ( j=0, jen=columns[idx].length ; j<jen ; j++ ) {
  7511. a.push( {
  7512. row: rows[idx][i],
  7513. column: columns[idx][j]
  7514. } );
  7515. }
  7516. }
  7517. return a;
  7518. }, 1 );
  7519. // There is currently only one extension which uses a cell selector extension
  7520. // It is a _major_ performance drag to run this if it isn't needed, so this is
  7521. // an extension specific check at the moment
  7522. var cells = opts && opts.selected ?
  7523. this.cells( cellsNoOpts, opts ) :
  7524. cellsNoOpts;
  7525. $.extend( cells.selector, {
  7526. cols: columnSelector,
  7527. rows: rowSelector,
  7528. opts: opts
  7529. } );
  7530. return cells;
  7531. } );
  7532. _api_registerPlural( 'cells().nodes()', 'cell().node()', function () {
  7533. return this.iterator( 'cell', function ( settings, row, column ) {
  7534. var data = settings.aoData[ row ];
  7535. return data && data.anCells ?
  7536. data.anCells[ column ] :
  7537. undefined;
  7538. }, 1 );
  7539. } );
  7540. _api_register( 'cells().data()', function () {
  7541. return this.iterator( 'cell', function ( settings, row, column ) {
  7542. return _fnGetCellData( settings, row, column );
  7543. }, 1 );
  7544. } );
  7545. _api_registerPlural( 'cells().cache()', 'cell().cache()', function ( type ) {
  7546. type = type === 'search' ? '_aFilterData' : '_aSortData';
  7547. return this.iterator( 'cell', function ( settings, row, column ) {
  7548. return settings.aoData[ row ][ type ][ column ];
  7549. }, 1 );
  7550. } );
  7551. _api_registerPlural( 'cells().render()', 'cell().render()', function ( type ) {
  7552. return this.iterator( 'cell', function ( settings, row, column ) {
  7553. return _fnGetCellData( settings, row, column, type );
  7554. }, 1 );
  7555. } );
  7556. _api_registerPlural( 'cells().indexes()', 'cell().index()', function () {
  7557. return this.iterator( 'cell', function ( settings, row, column ) {
  7558. return {
  7559. row: row,
  7560. column: column,
  7561. columnVisible: _fnColumnIndexToVisible( settings, column )
  7562. };
  7563. }, 1 );
  7564. } );
  7565. _api_registerPlural( 'cells().invalidate()', 'cell().invalidate()', function ( src ) {
  7566. return this.iterator( 'cell', function ( settings, row, column ) {
  7567. _fnInvalidate( settings, row, src, column );
  7568. } );
  7569. } );
  7570. _api_register( 'cell()', function ( rowSelector, columnSelector, opts ) {
  7571. return _selector_first( this.cells( rowSelector, columnSelector, opts ) );
  7572. } );
  7573. _api_register( 'cell().data()', function ( data ) {
  7574. var ctx = this.context;
  7575. var cell = this[0];
  7576. if ( data === undefined ) {
  7577. // Get
  7578. return ctx.length && cell.length ?
  7579. _fnGetCellData( ctx[0], cell[0].row, cell[0].column ) :
  7580. undefined;
  7581. }
  7582. // Set
  7583. _fnSetCellData( ctx[0], cell[0].row, cell[0].column, data );
  7584. _fnInvalidate( ctx[0], cell[0].row, 'data', cell[0].column );
  7585. return this;
  7586. } );
  7587. /**
  7588. * Get current ordering (sorting) that has been applied to the table.
  7589. *
  7590. * @returns {array} 2D array containing the sorting information for the first
  7591. * table in the current context. Each element in the parent array represents
  7592. * a column being sorted upon (i.e. multi-sorting with two columns would have
  7593. * 2 inner arrays). The inner arrays may have 2 or 3 elements. The first is
  7594. * the column index that the sorting condition applies to, the second is the
  7595. * direction of the sort (`desc` or `asc`) and, optionally, the third is the
  7596. * index of the sorting order from the `column.sorting` initialisation array.
  7597. *//**
  7598. * Set the ordering for the table.
  7599. *
  7600. * @param {integer} order Column index to sort upon.
  7601. * @param {string} direction Direction of the sort to be applied (`asc` or `desc`)
  7602. * @returns {DataTables.Api} this
  7603. *//**
  7604. * Set the ordering for the table.
  7605. *
  7606. * @param {array} order 1D array of sorting information to be applied.
  7607. * @param {array} [...] Optional additional sorting conditions
  7608. * @returns {DataTables.Api} this
  7609. *//**
  7610. * Set the ordering for the table.
  7611. *
  7612. * @param {array} order 2D array of sorting information to be applied.
  7613. * @returns {DataTables.Api} this
  7614. */
  7615. _api_register( 'order()', function ( order, dir ) {
  7616. var ctx = this.context;
  7617. if ( order === undefined ) {
  7618. // get
  7619. return ctx.length !== 0 ?
  7620. ctx[0].aaSorting :
  7621. undefined;
  7622. }
  7623. // set
  7624. if ( typeof order === 'number' ) {
  7625. // Simple column / direction passed in
  7626. order = [ [ order, dir ] ];
  7627. }
  7628. else if ( order.length && ! $.isArray( order[0] ) ) {
  7629. // Arguments passed in (list of 1D arrays)
  7630. order = Array.prototype.slice.call( arguments );
  7631. }
  7632. // otherwise a 2D array was passed in
  7633. return this.iterator( 'table', function ( settings ) {
  7634. settings.aaSorting = order.slice();
  7635. } );
  7636. } );
  7637. /**
  7638. * Attach a sort listener to an element for a given column
  7639. *
  7640. * @param {node|jQuery|string} node Identifier for the element(s) to attach the
  7641. * listener to. This can take the form of a single DOM node, a jQuery
  7642. * collection of nodes or a jQuery selector which will identify the node(s).
  7643. * @param {integer} column the column that a click on this node will sort on
  7644. * @param {function} [callback] callback function when sort is run
  7645. * @returns {DataTables.Api} this
  7646. */
  7647. _api_register( 'order.listener()', function ( node, column, callback ) {
  7648. return this.iterator( 'table', function ( settings ) {
  7649. _fnSortAttachListener( settings, node, column, callback );
  7650. } );
  7651. } );
  7652. _api_register( 'order.fixed()', function ( set ) {
  7653. if ( ! set ) {
  7654. var ctx = this.context;
  7655. var fixed = ctx.length ?
  7656. ctx[0].aaSortingFixed :
  7657. undefined;
  7658. return $.isArray( fixed ) ?
  7659. { pre: fixed } :
  7660. fixed;
  7661. }
  7662. return this.iterator( 'table', function ( settings ) {
  7663. settings.aaSortingFixed = $.extend( true, {}, set );
  7664. } );
  7665. } );
  7666. // Order by the selected column(s)
  7667. _api_register( [
  7668. 'columns().order()',
  7669. 'column().order()'
  7670. ], function ( dir ) {
  7671. var that = this;
  7672. return this.iterator( 'table', function ( settings, i ) {
  7673. var sort = [];
  7674. $.each( that[i], function (j, col) {
  7675. sort.push( [ col, dir ] );
  7676. } );
  7677. settings.aaSorting = sort;
  7678. } );
  7679. } );
  7680. _api_register( 'search()', function ( input, regex, smart, caseInsen ) {
  7681. var ctx = this.context;
  7682. if ( input === undefined ) {
  7683. // get
  7684. return ctx.length !== 0 ?
  7685. ctx[0].oPreviousSearch.sSearch :
  7686. undefined;
  7687. }
  7688. // set
  7689. return this.iterator( 'table', function ( settings ) {
  7690. if ( ! settings.oFeatures.bFilter ) {
  7691. return;
  7692. }
  7693. _fnFilterComplete( settings, $.extend( {}, settings.oPreviousSearch, {
  7694. "sSearch": input+"",
  7695. "bRegex": regex === null ? false : regex,
  7696. "bSmart": smart === null ? true : smart,
  7697. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7698. } ), 1 );
  7699. } );
  7700. } );
  7701. _api_registerPlural(
  7702. 'columns().search()',
  7703. 'column().search()',
  7704. function ( input, regex, smart, caseInsen ) {
  7705. return this.iterator( 'column', function ( settings, column ) {
  7706. var preSearch = settings.aoPreSearchCols;
  7707. if ( input === undefined ) {
  7708. // get
  7709. return preSearch[ column ].sSearch;
  7710. }
  7711. // set
  7712. if ( ! settings.oFeatures.bFilter ) {
  7713. return;
  7714. }
  7715. $.extend( preSearch[ column ], {
  7716. "sSearch": input+"",
  7717. "bRegex": regex === null ? false : regex,
  7718. "bSmart": smart === null ? true : smart,
  7719. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7720. } );
  7721. _fnFilterComplete( settings, settings.oPreviousSearch, 1 );
  7722. } );
  7723. }
  7724. );
  7725. /*
  7726. * State API methods
  7727. */
  7728. _api_register( 'state()', function () {
  7729. return this.context.length ?
  7730. this.context[0].oSavedState :
  7731. null;
  7732. } );
  7733. _api_register( 'state.clear()', function () {
  7734. return this.iterator( 'table', function ( settings ) {
  7735. // Save an empty object
  7736. settings.fnStateSaveCallback.call( settings.oInstance, settings, {} );
  7737. } );
  7738. } );
  7739. _api_register( 'state.loaded()', function () {
  7740. return this.context.length ?
  7741. this.context[0].oLoadedState :
  7742. null;
  7743. } );
  7744. _api_register( 'state.save()', function () {
  7745. return this.iterator( 'table', function ( settings ) {
  7746. _fnSaveState( settings );
  7747. } );
  7748. } );
  7749. /**
  7750. * Provide a common method for plug-ins to check the version of DataTables being
  7751. * used, in order to ensure compatibility.
  7752. *
  7753. * @param {string} version Version string to check for, in the format "X.Y.Z".
  7754. * Note that the formats "X" and "X.Y" are also acceptable.
  7755. * @returns {boolean} true if this version of DataTables is greater or equal to
  7756. * the required version, or false if this version of DataTales is not
  7757. * suitable
  7758. * @static
  7759. * @dtopt API-Static
  7760. *
  7761. * @example
  7762. * alert( $.fn.dataTable.versionCheck( '1.9.0' ) );
  7763. */
  7764. DataTable.versionCheck = DataTable.fnVersionCheck = function( version )
  7765. {
  7766. var aThis = DataTable.version.split('.');
  7767. var aThat = version.split('.');
  7768. var iThis, iThat;
  7769. for ( var i=0, iLen=aThat.length ; i<iLen ; i++ ) {
  7770. iThis = parseInt( aThis[i], 10 ) || 0;
  7771. iThat = parseInt( aThat[i], 10 ) || 0;
  7772. // Parts are the same, keep comparing
  7773. if (iThis === iThat) {
  7774. continue;
  7775. }
  7776. // Parts are different, return immediately
  7777. return iThis > iThat;
  7778. }
  7779. return true;
  7780. };
  7781. /**
  7782. * Check if a `<table>` node is a DataTable table already or not.
  7783. *
  7784. * @param {node|jquery|string} table Table node, jQuery object or jQuery
  7785. * selector for the table to test. Note that if more than more than one
  7786. * table is passed on, only the first will be checked
  7787. * @returns {boolean} true the table given is a DataTable, or false otherwise
  7788. * @static
  7789. * @dtopt API-Static
  7790. *
  7791. * @example
  7792. * if ( ! $.fn.DataTable.isDataTable( '#example' ) ) {
  7793. * $('#example').dataTable();
  7794. * }
  7795. */
  7796. DataTable.isDataTable = DataTable.fnIsDataTable = function ( table )
  7797. {
  7798. var t = $(table).get(0);
  7799. var is = false;
  7800. if ( table instanceof DataTable.Api ) {
  7801. return true;
  7802. }
  7803. $.each( DataTable.settings, function (i, o) {
  7804. var head = o.nScrollHead ? $('table', o.nScrollHead)[0] : null;
  7805. var foot = o.nScrollFoot ? $('table', o.nScrollFoot)[0] : null;
  7806. if ( o.nTable === t || head === t || foot === t ) {
  7807. is = true;
  7808. }
  7809. } );
  7810. return is;
  7811. };
  7812. /**
  7813. * Get all DataTable tables that have been initialised - optionally you can
  7814. * select to get only currently visible tables.
  7815. *
  7816. * @param {boolean} [visible=false] Flag to indicate if you want all (default)
  7817. * or visible tables only.
  7818. * @returns {array} Array of `table` nodes (not DataTable instances) which are
  7819. * DataTables
  7820. * @static
  7821. * @dtopt API-Static
  7822. *
  7823. * @example
  7824. * $.each( $.fn.dataTable.tables(true), function () {
  7825. * $(table).DataTable().columns.adjust();
  7826. * } );
  7827. */
  7828. DataTable.tables = DataTable.fnTables = function ( visible )
  7829. {
  7830. var api = false;
  7831. if ( $.isPlainObject( visible ) ) {
  7832. api = visible.api;
  7833. visible = visible.visible;
  7834. }
  7835. var a = $.map( DataTable.settings, function (o) {
  7836. if ( !visible || (visible && $(o.nTable).is(':visible')) ) {
  7837. return o.nTable;
  7838. }
  7839. } );
  7840. return api ?
  7841. new _Api( a ) :
  7842. a;
  7843. };
  7844. /**
  7845. * Convert from camel case parameters to Hungarian notation. This is made public
  7846. * for the extensions to provide the same ability as DataTables core to accept
  7847. * either the 1.9 style Hungarian notation, or the 1.10+ style camelCase
  7848. * parameters.
  7849. *
  7850. * @param {object} src The model object which holds all parameters that can be
  7851. * mapped.
  7852. * @param {object} user The object to convert from camel case to Hungarian.
  7853. * @param {boolean} force When set to `true`, properties which already have a
  7854. * Hungarian value in the `user` object will be overwritten. Otherwise they
  7855. * won't be.
  7856. */
  7857. DataTable.camelToHungarian = _fnCamelToHungarian;
  7858. /**
  7859. *
  7860. */
  7861. _api_register( '$()', function ( selector, opts ) {
  7862. var
  7863. rows = this.rows( opts ).nodes(), // Get all rows
  7864. jqRows = $(rows);
  7865. return $( [].concat(
  7866. jqRows.filter( selector ).toArray(),
  7867. jqRows.find( selector ).toArray()
  7868. ) );
  7869. } );
  7870. // jQuery functions to operate on the tables
  7871. $.each( [ 'on', 'one', 'off' ], function (i, key) {
  7872. _api_register( key+'()', function ( /* event, handler */ ) {
  7873. var args = Array.prototype.slice.call(arguments);
  7874. // Add the `dt` namespace automatically if it isn't already present
  7875. args[0] = $.map( args[0].split( /\s/ ), function ( e ) {
  7876. return ! e.match(/\.dt\b/) ?
  7877. e+'.dt' :
  7878. e;
  7879. } ).join( ' ' );
  7880. var inst = $( this.tables().nodes() );
  7881. inst[key].apply( inst, args );
  7882. return this;
  7883. } );
  7884. } );
  7885. _api_register( 'clear()', function () {
  7886. return this.iterator( 'table', function ( settings ) {
  7887. _fnClearTable( settings );
  7888. } );
  7889. } );
  7890. _api_register( 'settings()', function () {
  7891. return new _Api( this.context, this.context );
  7892. } );
  7893. _api_register( 'init()', function () {
  7894. var ctx = this.context;
  7895. return ctx.length ? ctx[0].oInit : null;
  7896. } );
  7897. _api_register( 'data()', function () {
  7898. return this.iterator( 'table', function ( settings ) {
  7899. return _pluck( settings.aoData, '_aData' );
  7900. } ).flatten();
  7901. } );
  7902. _api_register( 'destroy()', function ( remove ) {
  7903. remove = remove || false;
  7904. return this.iterator( 'table', function ( settings ) {
  7905. var orig = settings.nTableWrapper.parentNode;
  7906. var classes = settings.oClasses;
  7907. var table = settings.nTable;
  7908. var tbody = settings.nTBody;
  7909. var thead = settings.nTHead;
  7910. var tfoot = settings.nTFoot;
  7911. var jqTable = $(table);
  7912. var jqTbody = $(tbody);
  7913. var jqWrapper = $(settings.nTableWrapper);
  7914. var rows = $.map( settings.aoData, function (r) { return r.nTr; } );
  7915. var i, ien;
  7916. // Flag to note that the table is currently being destroyed - no action
  7917. // should be taken
  7918. settings.bDestroying = true;
  7919. // Fire off the destroy callbacks for plug-ins etc
  7920. _fnCallbackFire( settings, "aoDestroyCallback", "destroy", [settings] );
  7921. // If not being removed from the document, make all columns visible
  7922. if ( ! remove ) {
  7923. new _Api( settings ).columns().visible( true );
  7924. }
  7925. // Blitz all `DT` namespaced events (these are internal events, the
  7926. // lowercase, `dt` events are user subscribed and they are responsible
  7927. // for removing them
  7928. jqWrapper.off('.DT').find(':not(tbody *)').off('.DT');
  7929. $(window).off('.DT-'+settings.sInstance);
  7930. // When scrolling we had to break the table up - restore it
  7931. if ( table != thead.parentNode ) {
  7932. jqTable.children('thead').detach();
  7933. jqTable.append( thead );
  7934. }
  7935. if ( tfoot && table != tfoot.parentNode ) {
  7936. jqTable.children('tfoot').detach();
  7937. jqTable.append( tfoot );
  7938. }
  7939. settings.aaSorting = [];
  7940. settings.aaSortingFixed = [];
  7941. _fnSortingClasses( settings );
  7942. $( rows ).removeClass( settings.asStripeClasses.join(' ') );
  7943. $('th, td', thead).removeClass( classes.sSortable+' '+
  7944. classes.sSortableAsc+' '+classes.sSortableDesc+' '+classes.sSortableNone
  7945. );
  7946. // Add the TR elements back into the table in their original order
  7947. jqTbody.children().detach();
  7948. jqTbody.append( rows );
  7949. // Remove the DataTables generated nodes, events and classes
  7950. var removedMethod = remove ? 'remove' : 'detach';
  7951. jqTable[ removedMethod ]();
  7952. jqWrapper[ removedMethod ]();
  7953. // If we need to reattach the table to the document
  7954. if ( ! remove && orig ) {
  7955. // insertBefore acts like appendChild if !arg[1]
  7956. orig.insertBefore( table, settings.nTableReinsertBefore );
  7957. // Restore the width of the original table - was read from the style property,
  7958. // so we can restore directly to that
  7959. jqTable
  7960. .css( 'width', settings.sDestroyWidth )
  7961. .removeClass( classes.sTable );
  7962. // If the were originally stripe classes - then we add them back here.
  7963. // Note this is not fool proof (for example if not all rows had stripe
  7964. // classes - but it's a good effort without getting carried away
  7965. ien = settings.asDestroyStripes.length;
  7966. if ( ien ) {
  7967. jqTbody.children().each( function (i) {
  7968. $(this).addClass( settings.asDestroyStripes[i % ien] );
  7969. } );
  7970. }
  7971. }
  7972. /* Remove the settings object from the settings array */
  7973. var idx = $.inArray( settings, DataTable.settings );
  7974. if ( idx !== -1 ) {
  7975. DataTable.settings.splice( idx, 1 );
  7976. }
  7977. } );
  7978. } );
  7979. // Add the `every()` method for rows, columns and cells in a compact form
  7980. $.each( [ 'column', 'row', 'cell' ], function ( i, type ) {
  7981. _api_register( type+'s().every()', function ( fn ) {
  7982. var opts = this.selector.opts;
  7983. var api = this;
  7984. return this.iterator( type, function ( settings, arg1, arg2, arg3, arg4 ) {
  7985. // Rows and columns:
  7986. // arg1 - index
  7987. // arg2 - table counter
  7988. // arg3 - loop counter
  7989. // arg4 - undefined
  7990. // Cells:
  7991. // arg1 - row index
  7992. // arg2 - column index
  7993. // arg3 - table counter
  7994. // arg4 - loop counter
  7995. fn.call(
  7996. api[ type ](
  7997. arg1,
  7998. type==='cell' ? arg2 : opts,
  7999. type==='cell' ? opts : undefined
  8000. ),
  8001. arg1, arg2, arg3, arg4
  8002. );
  8003. } );
  8004. } );
  8005. } );
  8006. // i18n method for extensions to be able to use the language object from the
  8007. // DataTable
  8008. _api_register( 'i18n()', function ( token, def, plural ) {
  8009. var ctx = this.context[0];
  8010. var resolved = _fnGetObjectDataFn( token )( ctx.oLanguage );
  8011. if ( resolved === undefined ) {
  8012. resolved = def;
  8013. }
  8014. if ( plural !== undefined && $.isPlainObject( resolved ) ) {
  8015. resolved = resolved[ plural ] !== undefined ?
  8016. resolved[ plural ] :
  8017. resolved._;
  8018. }
  8019. return resolved.replace( '%d', plural ); // nb: plural might be undefined,
  8020. } );
  8021. /**
  8022. * Version string for plug-ins to check compatibility. Allowed format is
  8023. * `a.b.c-d` where: a:int, b:int, c:int, d:string(dev|beta|alpha). `d` is used
  8024. * only for non-release builds. See http://semver.org/ for more information.
  8025. * @member
  8026. * @type string
  8027. * @default Version number
  8028. */
  8029. DataTable.version = "1.10.20";
  8030. /**
  8031. * Private data store, containing all of the settings objects that are
  8032. * created for the tables on a given page.
  8033. *
  8034. * Note that the `DataTable.settings` object is aliased to
  8035. * `jQuery.fn.dataTableExt` through which it may be accessed and
  8036. * manipulated, or `jQuery.fn.dataTable.settings`.
  8037. * @member
  8038. * @type array
  8039. * @default []
  8040. * @private
  8041. */
  8042. DataTable.settings = [];
  8043. /**
  8044. * Object models container, for the various models that DataTables has
  8045. * available to it. These models define the objects that are used to hold
  8046. * the active state and configuration of the table.
  8047. * @namespace
  8048. */
  8049. DataTable.models = {};
  8050. /**
  8051. * Template object for the way in which DataTables holds information about
  8052. * search information for the global filter and individual column filters.
  8053. * @namespace
  8054. */
  8055. DataTable.models.oSearch = {
  8056. /**
  8057. * Flag to indicate if the filtering should be case insensitive or not
  8058. * @type boolean
  8059. * @default true
  8060. */
  8061. "bCaseInsensitive": true,
  8062. /**
  8063. * Applied search term
  8064. * @type string
  8065. * @default <i>Empty string</i>
  8066. */
  8067. "sSearch": "",
  8068. /**
  8069. * Flag to indicate if the search term should be interpreted as a
  8070. * regular expression (true) or not (false) and therefore and special
  8071. * regex characters escaped.
  8072. * @type boolean
  8073. * @default false
  8074. */
  8075. "bRegex": false,
  8076. /**
  8077. * Flag to indicate if DataTables is to use its smart filtering or not.
  8078. * @type boolean
  8079. * @default true
  8080. */
  8081. "bSmart": true
  8082. };
  8083. /**
  8084. * Template object for the way in which DataTables holds information about
  8085. * each individual row. This is the object format used for the settings
  8086. * aoData array.
  8087. * @namespace
  8088. */
  8089. DataTable.models.oRow = {
  8090. /**
  8091. * TR element for the row
  8092. * @type node
  8093. * @default null
  8094. */
  8095. "nTr": null,
  8096. /**
  8097. * Array of TD elements for each row. This is null until the row has been
  8098. * created.
  8099. * @type array nodes
  8100. * @default []
  8101. */
  8102. "anCells": null,
  8103. /**
  8104. * Data object from the original data source for the row. This is either
  8105. * an array if using the traditional form of DataTables, or an object if
  8106. * using mData options. The exact type will depend on the passed in
  8107. * data from the data source, or will be an array if using DOM a data
  8108. * source.
  8109. * @type array|object
  8110. * @default []
  8111. */
  8112. "_aData": [],
  8113. /**
  8114. * Sorting data cache - this array is ostensibly the same length as the
  8115. * number of columns (although each index is generated only as it is
  8116. * needed), and holds the data that is used for sorting each column in the
  8117. * row. We do this cache generation at the start of the sort in order that
  8118. * the formatting of the sort data need be done only once for each cell
  8119. * per sort. This array should not be read from or written to by anything
  8120. * other than the master sorting methods.
  8121. * @type array
  8122. * @default null
  8123. * @private
  8124. */
  8125. "_aSortData": null,
  8126. /**
  8127. * Per cell filtering data cache. As per the sort data cache, used to
  8128. * increase the performance of the filtering in DataTables
  8129. * @type array
  8130. * @default null
  8131. * @private
  8132. */
  8133. "_aFilterData": null,
  8134. /**
  8135. * Filtering data cache. This is the same as the cell filtering cache, but
  8136. * in this case a string rather than an array. This is easily computed with
  8137. * a join on `_aFilterData`, but is provided as a cache so the join isn't
  8138. * needed on every search (memory traded for performance)
  8139. * @type array
  8140. * @default null
  8141. * @private
  8142. */
  8143. "_sFilterRow": null,
  8144. /**
  8145. * Cache of the class name that DataTables has applied to the row, so we
  8146. * can quickly look at this variable rather than needing to do a DOM check
  8147. * on className for the nTr property.
  8148. * @type string
  8149. * @default <i>Empty string</i>
  8150. * @private
  8151. */
  8152. "_sRowStripe": "",
  8153. /**
  8154. * Denote if the original data source was from the DOM, or the data source
  8155. * object. This is used for invalidating data, so DataTables can
  8156. * automatically read data from the original source, unless uninstructed
  8157. * otherwise.
  8158. * @type string
  8159. * @default null
  8160. * @private
  8161. */
  8162. "src": null,
  8163. /**
  8164. * Index in the aoData array. This saves an indexOf lookup when we have the
  8165. * object, but want to know the index
  8166. * @type integer
  8167. * @default -1
  8168. * @private
  8169. */
  8170. "idx": -1
  8171. };
  8172. /**
  8173. * Template object for the column information object in DataTables. This object
  8174. * is held in the settings aoColumns array and contains all the information that
  8175. * DataTables needs about each individual column.
  8176. *
  8177. * Note that this object is related to {@link DataTable.defaults.column}
  8178. * but this one is the internal data store for DataTables's cache of columns.
  8179. * It should NOT be manipulated outside of DataTables. Any configuration should
  8180. * be done through the initialisation options.
  8181. * @namespace
  8182. */
  8183. DataTable.models.oColumn = {
  8184. /**
  8185. * Column index. This could be worked out on-the-fly with $.inArray, but it
  8186. * is faster to just hold it as a variable
  8187. * @type integer
  8188. * @default null
  8189. */
  8190. "idx": null,
  8191. /**
  8192. * A list of the columns that sorting should occur on when this column
  8193. * is sorted. That this property is an array allows multi-column sorting
  8194. * to be defined for a column (for example first name / last name columns
  8195. * would benefit from this). The values are integers pointing to the
  8196. * columns to be sorted on (typically it will be a single integer pointing
  8197. * at itself, but that doesn't need to be the case).
  8198. * @type array
  8199. */
  8200. "aDataSort": null,
  8201. /**
  8202. * Define the sorting directions that are applied to the column, in sequence
  8203. * as the column is repeatedly sorted upon - i.e. the first value is used
  8204. * as the sorting direction when the column if first sorted (clicked on).
  8205. * Sort it again (click again) and it will move on to the next index.
  8206. * Repeat until loop.
  8207. * @type array
  8208. */
  8209. "asSorting": null,
  8210. /**
  8211. * Flag to indicate if the column is searchable, and thus should be included
  8212. * in the filtering or not.
  8213. * @type boolean
  8214. */
  8215. "bSearchable": null,
  8216. /**
  8217. * Flag to indicate if the column is sortable or not.
  8218. * @type boolean
  8219. */
  8220. "bSortable": null,
  8221. /**
  8222. * Flag to indicate if the column is currently visible in the table or not
  8223. * @type boolean
  8224. */
  8225. "bVisible": null,
  8226. /**
  8227. * Store for manual type assignment using the `column.type` option. This
  8228. * is held in store so we can manipulate the column's `sType` property.
  8229. * @type string
  8230. * @default null
  8231. * @private
  8232. */
  8233. "_sManualType": null,
  8234. /**
  8235. * Flag to indicate if HTML5 data attributes should be used as the data
  8236. * source for filtering or sorting. True is either are.
  8237. * @type boolean
  8238. * @default false
  8239. * @private
  8240. */
  8241. "_bAttrSrc": false,
  8242. /**
  8243. * Developer definable function that is called whenever a cell is created (Ajax source,
  8244. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  8245. * allowing you to modify the DOM element (add background colour for example) when the
  8246. * element is available.
  8247. * @type function
  8248. * @param {element} nTd The TD node that has been created
  8249. * @param {*} sData The Data for the cell
  8250. * @param {array|object} oData The data for the whole row
  8251. * @param {int} iRow The row index for the aoData data store
  8252. * @default null
  8253. */
  8254. "fnCreatedCell": null,
  8255. /**
  8256. * Function to get data from a cell in a column. You should <b>never</b>
  8257. * access data directly through _aData internally in DataTables - always use
  8258. * the method attached to this property. It allows mData to function as
  8259. * required. This function is automatically assigned by the column
  8260. * initialisation method
  8261. * @type function
  8262. * @param {array|object} oData The data array/object for the array
  8263. * (i.e. aoData[]._aData)
  8264. * @param {string} sSpecific The specific data type you want to get -
  8265. * 'display', 'type' 'filter' 'sort'
  8266. * @returns {*} The data for the cell from the given row's data
  8267. * @default null
  8268. */
  8269. "fnGetData": null,
  8270. /**
  8271. * Function to set data for a cell in the column. You should <b>never</b>
  8272. * set the data directly to _aData internally in DataTables - always use
  8273. * this method. It allows mData to function as required. This function
  8274. * is automatically assigned by the column initialisation method
  8275. * @type function
  8276. * @param {array|object} oData The data array/object for the array
  8277. * (i.e. aoData[]._aData)
  8278. * @param {*} sValue Value to set
  8279. * @default null
  8280. */
  8281. "fnSetData": null,
  8282. /**
  8283. * Property to read the value for the cells in the column from the data
  8284. * source array / object. If null, then the default content is used, if a
  8285. * function is given then the return from the function is used.
  8286. * @type function|int|string|null
  8287. * @default null
  8288. */
  8289. "mData": null,
  8290. /**
  8291. * Partner property to mData which is used (only when defined) to get
  8292. * the data - i.e. it is basically the same as mData, but without the
  8293. * 'set' option, and also the data fed to it is the result from mData.
  8294. * This is the rendering method to match the data method of mData.
  8295. * @type function|int|string|null
  8296. * @default null
  8297. */
  8298. "mRender": null,
  8299. /**
  8300. * Unique header TH/TD element for this column - this is what the sorting
  8301. * listener is attached to (if sorting is enabled.)
  8302. * @type node
  8303. * @default null
  8304. */
  8305. "nTh": null,
  8306. /**
  8307. * Unique footer TH/TD element for this column (if there is one). Not used
  8308. * in DataTables as such, but can be used for plug-ins to reference the
  8309. * footer for each column.
  8310. * @type node
  8311. * @default null
  8312. */
  8313. "nTf": null,
  8314. /**
  8315. * The class to apply to all TD elements in the table's TBODY for the column
  8316. * @type string
  8317. * @default null
  8318. */
  8319. "sClass": null,
  8320. /**
  8321. * When DataTables calculates the column widths to assign to each column,
  8322. * it finds the longest string in each column and then constructs a
  8323. * temporary table and reads the widths from that. The problem with this
  8324. * is that "mmm" is much wider then "iiii", but the latter is a longer
  8325. * string - thus the calculation can go wrong (doing it properly and putting
  8326. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  8327. * a "work around" we provide this option. It will append its value to the
  8328. * text that is found to be the longest string for the column - i.e. padding.
  8329. * @type string
  8330. */
  8331. "sContentPadding": null,
  8332. /**
  8333. * Allows a default value to be given for a column's data, and will be used
  8334. * whenever a null data source is encountered (this can be because mData
  8335. * is set to null, or because the data source itself is null).
  8336. * @type string
  8337. * @default null
  8338. */
  8339. "sDefaultContent": null,
  8340. /**
  8341. * Name for the column, allowing reference to the column by name as well as
  8342. * by index (needs a lookup to work by name).
  8343. * @type string
  8344. */
  8345. "sName": null,
  8346. /**
  8347. * Custom sorting data type - defines which of the available plug-ins in
  8348. * afnSortData the custom sorting will use - if any is defined.
  8349. * @type string
  8350. * @default std
  8351. */
  8352. "sSortDataType": 'std',
  8353. /**
  8354. * Class to be applied to the header element when sorting on this column
  8355. * @type string
  8356. * @default null
  8357. */
  8358. "sSortingClass": null,
  8359. /**
  8360. * Class to be applied to the header element when sorting on this column -
  8361. * when jQuery UI theming is used.
  8362. * @type string
  8363. * @default null
  8364. */
  8365. "sSortingClassJUI": null,
  8366. /**
  8367. * Title of the column - what is seen in the TH element (nTh).
  8368. * @type string
  8369. */
  8370. "sTitle": null,
  8371. /**
  8372. * Column sorting and filtering type
  8373. * @type string
  8374. * @default null
  8375. */
  8376. "sType": null,
  8377. /**
  8378. * Width of the column
  8379. * @type string
  8380. * @default null
  8381. */
  8382. "sWidth": null,
  8383. /**
  8384. * Width of the column when it was first "encountered"
  8385. * @type string
  8386. * @default null
  8387. */
  8388. "sWidthOrig": null
  8389. };
  8390. /*
  8391. * Developer note: The properties of the object below are given in Hungarian
  8392. * notation, that was used as the interface for DataTables prior to v1.10, however
  8393. * from v1.10 onwards the primary interface is camel case. In order to avoid
  8394. * breaking backwards compatibility utterly with this change, the Hungarian
  8395. * version is still, internally the primary interface, but is is not documented
  8396. * - hence the @name tags in each doc comment. This allows a Javascript function
  8397. * to create a map from Hungarian notation to camel case (going the other direction
  8398. * would require each property to be listed, which would at around 3K to the size
  8399. * of DataTables, while this method is about a 0.5K hit.
  8400. *
  8401. * Ultimately this does pave the way for Hungarian notation to be dropped
  8402. * completely, but that is a massive amount of work and will break current
  8403. * installs (therefore is on-hold until v2).
  8404. */
  8405. /**
  8406. * Initialisation options that can be given to DataTables at initialisation
  8407. * time.
  8408. * @namespace
  8409. */
  8410. DataTable.defaults = {
  8411. /**
  8412. * An array of data to use for the table, passed in at initialisation which
  8413. * will be used in preference to any data which is already in the DOM. This is
  8414. * particularly useful for constructing tables purely in Javascript, for
  8415. * example with a custom Ajax call.
  8416. * @type array
  8417. * @default null
  8418. *
  8419. * @dtopt Option
  8420. * @name DataTable.defaults.data
  8421. *
  8422. * @example
  8423. * // Using a 2D array data source
  8424. * $(document).ready( function () {
  8425. * $('#example').dataTable( {
  8426. * "data": [
  8427. * ['Trident', 'Internet Explorer 4.0', 'Win 95+', 4, 'X'],
  8428. * ['Trident', 'Internet Explorer 5.0', 'Win 95+', 5, 'C'],
  8429. * ],
  8430. * "columns": [
  8431. * { "title": "Engine" },
  8432. * { "title": "Browser" },
  8433. * { "title": "Platform" },
  8434. * { "title": "Version" },
  8435. * { "title": "Grade" }
  8436. * ]
  8437. * } );
  8438. * } );
  8439. *
  8440. * @example
  8441. * // Using an array of objects as a data source (`data`)
  8442. * $(document).ready( function () {
  8443. * $('#example').dataTable( {
  8444. * "data": [
  8445. * {
  8446. * "engine": "Trident",
  8447. * "browser": "Internet Explorer 4.0",
  8448. * "platform": "Win 95+",
  8449. * "version": 4,
  8450. * "grade": "X"
  8451. * },
  8452. * {
  8453. * "engine": "Trident",
  8454. * "browser": "Internet Explorer 5.0",
  8455. * "platform": "Win 95+",
  8456. * "version": 5,
  8457. * "grade": "C"
  8458. * }
  8459. * ],
  8460. * "columns": [
  8461. * { "title": "Engine", "data": "engine" },
  8462. * { "title": "Browser", "data": "browser" },
  8463. * { "title": "Platform", "data": "platform" },
  8464. * { "title": "Version", "data": "version" },
  8465. * { "title": "Grade", "data": "grade" }
  8466. * ]
  8467. * } );
  8468. * } );
  8469. */
  8470. "aaData": null,
  8471. /**
  8472. * If ordering is enabled, then DataTables will perform a first pass sort on
  8473. * initialisation. You can define which column(s) the sort is performed
  8474. * upon, and the sorting direction, with this variable. The `sorting` array
  8475. * should contain an array for each column to be sorted initially containing
  8476. * the column's index and a direction string ('asc' or 'desc').
  8477. * @type array
  8478. * @default [[0,'asc']]
  8479. *
  8480. * @dtopt Option
  8481. * @name DataTable.defaults.order
  8482. *
  8483. * @example
  8484. * // Sort by 3rd column first, and then 4th column
  8485. * $(document).ready( function() {
  8486. * $('#example').dataTable( {
  8487. * "order": [[2,'asc'], [3,'desc']]
  8488. * } );
  8489. * } );
  8490. *
  8491. * // No initial sorting
  8492. * $(document).ready( function() {
  8493. * $('#example').dataTable( {
  8494. * "order": []
  8495. * } );
  8496. * } );
  8497. */
  8498. "aaSorting": [[0,'asc']],
  8499. /**
  8500. * This parameter is basically identical to the `sorting` parameter, but
  8501. * cannot be overridden by user interaction with the table. What this means
  8502. * is that you could have a column (visible or hidden) which the sorting
  8503. * will always be forced on first - any sorting after that (from the user)
  8504. * will then be performed as required. This can be useful for grouping rows
  8505. * together.
  8506. * @type array
  8507. * @default null
  8508. *
  8509. * @dtopt Option
  8510. * @name DataTable.defaults.orderFixed
  8511. *
  8512. * @example
  8513. * $(document).ready( function() {
  8514. * $('#example').dataTable( {
  8515. * "orderFixed": [[0,'asc']]
  8516. * } );
  8517. * } )
  8518. */
  8519. "aaSortingFixed": [],
  8520. /**
  8521. * DataTables can be instructed to load data to display in the table from a
  8522. * Ajax source. This option defines how that Ajax call is made and where to.
  8523. *
  8524. * The `ajax` property has three different modes of operation, depending on
  8525. * how it is defined. These are:
  8526. *
  8527. * * `string` - Set the URL from where the data should be loaded from.
  8528. * * `object` - Define properties for `jQuery.ajax`.
  8529. * * `function` - Custom data get function
  8530. *
  8531. * `string`
  8532. * --------
  8533. *
  8534. * As a string, the `ajax` property simply defines the URL from which
  8535. * DataTables will load data.
  8536. *
  8537. * `object`
  8538. * --------
  8539. *
  8540. * As an object, the parameters in the object are passed to
  8541. * [jQuery.ajax](http://api.jquery.com/jQuery.ajax/) allowing fine control
  8542. * of the Ajax request. DataTables has a number of default parameters which
  8543. * you can override using this option. Please refer to the jQuery
  8544. * documentation for a full description of the options available, although
  8545. * the following parameters provide additional options in DataTables or
  8546. * require special consideration:
  8547. *
  8548. * * `data` - As with jQuery, `data` can be provided as an object, but it
  8549. * can also be used as a function to manipulate the data DataTables sends
  8550. * to the server. The function takes a single parameter, an object of
  8551. * parameters with the values that DataTables has readied for sending. An
  8552. * object may be returned which will be merged into the DataTables
  8553. * defaults, or you can add the items to the object that was passed in and
  8554. * not return anything from the function. This supersedes `fnServerParams`
  8555. * from DataTables 1.9-.
  8556. *
  8557. * * `dataSrc` - By default DataTables will look for the property `data` (or
  8558. * `aaData` for compatibility with DataTables 1.9-) when obtaining data
  8559. * from an Ajax source or for server-side processing - this parameter
  8560. * allows that property to be changed. You can use Javascript dotted
  8561. * object notation to get a data source for multiple levels of nesting, or
  8562. * it my be used as a function. As a function it takes a single parameter,
  8563. * the JSON returned from the server, which can be manipulated as
  8564. * required, with the returned value being that used by DataTables as the
  8565. * data source for the table. This supersedes `sAjaxDataProp` from
  8566. * DataTables 1.9-.
  8567. *
  8568. * * `success` - Should not be overridden it is used internally in
  8569. * DataTables. To manipulate / transform the data returned by the server
  8570. * use `ajax.dataSrc`, or use `ajax` as a function (see below).
  8571. *
  8572. * `function`
  8573. * ----------
  8574. *
  8575. * As a function, making the Ajax call is left up to yourself allowing
  8576. * complete control of the Ajax request. Indeed, if desired, a method other
  8577. * than Ajax could be used to obtain the required data, such as Web storage
  8578. * or an AIR database.
  8579. *
  8580. * The function is given four parameters and no return is required. The
  8581. * parameters are:
  8582. *
  8583. * 1. _object_ - Data to send to the server
  8584. * 2. _function_ - Callback function that must be executed when the required
  8585. * data has been obtained. That data should be passed into the callback
  8586. * as the only parameter
  8587. * 3. _object_ - DataTables settings object for the table
  8588. *
  8589. * Note that this supersedes `fnServerData` from DataTables 1.9-.
  8590. *
  8591. * @type string|object|function
  8592. * @default null
  8593. *
  8594. * @dtopt Option
  8595. * @name DataTable.defaults.ajax
  8596. * @since 1.10.0
  8597. *
  8598. * @example
  8599. * // Get JSON data from a file via Ajax.
  8600. * // Note DataTables expects data in the form `{ data: [ ...data... ] }` by default).
  8601. * $('#example').dataTable( {
  8602. * "ajax": "data.json"
  8603. * } );
  8604. *
  8605. * @example
  8606. * // Get JSON data from a file via Ajax, using `dataSrc` to change
  8607. * // `data` to `tableData` (i.e. `{ tableData: [ ...data... ] }`)
  8608. * $('#example').dataTable( {
  8609. * "ajax": {
  8610. * "url": "data.json",
  8611. * "dataSrc": "tableData"
  8612. * }
  8613. * } );
  8614. *
  8615. * @example
  8616. * // Get JSON data from a file via Ajax, using `dataSrc` to read data
  8617. * // from a plain array rather than an array in an object
  8618. * $('#example').dataTable( {
  8619. * "ajax": {
  8620. * "url": "data.json",
  8621. * "dataSrc": ""
  8622. * }
  8623. * } );
  8624. *
  8625. * @example
  8626. * // Manipulate the data returned from the server - add a link to data
  8627. * // (note this can, should, be done using `render` for the column - this
  8628. * // is just a simple example of how the data can be manipulated).
  8629. * $('#example').dataTable( {
  8630. * "ajax": {
  8631. * "url": "data.json",
  8632. * "dataSrc": function ( json ) {
  8633. * for ( var i=0, ien=json.length ; i<ien ; i++ ) {
  8634. * json[i][0] = '<a href="/message/'+json[i][0]+'>View message</a>';
  8635. * }
  8636. * return json;
  8637. * }
  8638. * }
  8639. * } );
  8640. *
  8641. * @example
  8642. * // Add data to the request
  8643. * $('#example').dataTable( {
  8644. * "ajax": {
  8645. * "url": "data.json",
  8646. * "data": function ( d ) {
  8647. * return {
  8648. * "extra_search": $('#extra').val()
  8649. * };
  8650. * }
  8651. * }
  8652. * } );
  8653. *
  8654. * @example
  8655. * // Send request as POST
  8656. * $('#example').dataTable( {
  8657. * "ajax": {
  8658. * "url": "data.json",
  8659. * "type": "POST"
  8660. * }
  8661. * } );
  8662. *
  8663. * @example
  8664. * // Get the data from localStorage (could interface with a form for
  8665. * // adding, editing and removing rows).
  8666. * $('#example').dataTable( {
  8667. * "ajax": function (data, callback, settings) {
  8668. * callback(
  8669. * JSON.parse( localStorage.getItem('dataTablesData') )
  8670. * );
  8671. * }
  8672. * } );
  8673. */
  8674. "ajax": null,
  8675. /**
  8676. * This parameter allows you to readily specify the entries in the length drop
  8677. * down menu that DataTables shows when pagination is enabled. It can be
  8678. * either a 1D array of options which will be used for both the displayed
  8679. * option and the value, or a 2D array which will use the array in the first
  8680. * position as the value, and the array in the second position as the
  8681. * displayed options (useful for language strings such as 'All').
  8682. *
  8683. * Note that the `pageLength` property will be automatically set to the
  8684. * first value given in this array, unless `pageLength` is also provided.
  8685. * @type array
  8686. * @default [ 10, 25, 50, 100 ]
  8687. *
  8688. * @dtopt Option
  8689. * @name DataTable.defaults.lengthMenu
  8690. *
  8691. * @example
  8692. * $(document).ready( function() {
  8693. * $('#example').dataTable( {
  8694. * "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
  8695. * } );
  8696. * } );
  8697. */
  8698. "aLengthMenu": [ 10, 25, 50, 100 ],
  8699. /**
  8700. * The `columns` option in the initialisation parameter allows you to define
  8701. * details about the way individual columns behave. For a full list of
  8702. * column options that can be set, please see
  8703. * {@link DataTable.defaults.column}. Note that if you use `columns` to
  8704. * define your columns, you must have an entry in the array for every single
  8705. * column that you have in your table (these can be null if you don't which
  8706. * to specify any options).
  8707. * @member
  8708. *
  8709. * @name DataTable.defaults.column
  8710. */
  8711. "aoColumns": null,
  8712. /**
  8713. * Very similar to `columns`, `columnDefs` allows you to target a specific
  8714. * column, multiple columns, or all columns, using the `targets` property of
  8715. * each object in the array. This allows great flexibility when creating
  8716. * tables, as the `columnDefs` arrays can be of any length, targeting the
  8717. * columns you specifically want. `columnDefs` may use any of the column
  8718. * options available: {@link DataTable.defaults.column}, but it _must_
  8719. * have `targets` defined in each object in the array. Values in the `targets`
  8720. * array may be:
  8721. * <ul>
  8722. * <li>a string - class name will be matched on the TH for the column</li>
  8723. * <li>0 or a positive integer - column index counting from the left</li>
  8724. * <li>a negative integer - column index counting from the right</li>
  8725. * <li>the string "_all" - all columns (i.e. assign a default)</li>
  8726. * </ul>
  8727. * @member
  8728. *
  8729. * @name DataTable.defaults.columnDefs
  8730. */
  8731. "aoColumnDefs": null,
  8732. /**
  8733. * Basically the same as `search`, this parameter defines the individual column
  8734. * filtering state at initialisation time. The array must be of the same size
  8735. * as the number of columns, and each element be an object with the parameters
  8736. * `search` and `escapeRegex` (the latter is optional). 'null' is also
  8737. * accepted and the default will be used.
  8738. * @type array
  8739. * @default []
  8740. *
  8741. * @dtopt Option
  8742. * @name DataTable.defaults.searchCols
  8743. *
  8744. * @example
  8745. * $(document).ready( function() {
  8746. * $('#example').dataTable( {
  8747. * "searchCols": [
  8748. * null,
  8749. * { "search": "My filter" },
  8750. * null,
  8751. * { "search": "^[0-9]", "escapeRegex": false }
  8752. * ]
  8753. * } );
  8754. * } )
  8755. */
  8756. "aoSearchCols": [],
  8757. /**
  8758. * An array of CSS classes that should be applied to displayed rows. This
  8759. * array may be of any length, and DataTables will apply each class
  8760. * sequentially, looping when required.
  8761. * @type array
  8762. * @default null <i>Will take the values determined by the `oClasses.stripe*`
  8763. * options</i>
  8764. *
  8765. * @dtopt Option
  8766. * @name DataTable.defaults.stripeClasses
  8767. *
  8768. * @example
  8769. * $(document).ready( function() {
  8770. * $('#example').dataTable( {
  8771. * "stripeClasses": [ 'strip1', 'strip2', 'strip3' ]
  8772. * } );
  8773. * } )
  8774. */
  8775. "asStripeClasses": null,
  8776. /**
  8777. * Enable or disable automatic column width calculation. This can be disabled
  8778. * as an optimisation (it takes some time to calculate the widths) if the
  8779. * tables widths are passed in using `columns`.
  8780. * @type boolean
  8781. * @default true
  8782. *
  8783. * @dtopt Features
  8784. * @name DataTable.defaults.autoWidth
  8785. *
  8786. * @example
  8787. * $(document).ready( function () {
  8788. * $('#example').dataTable( {
  8789. * "autoWidth": false
  8790. * } );
  8791. * } );
  8792. */
  8793. "bAutoWidth": true,
  8794. /**
  8795. * Deferred rendering can provide DataTables with a huge speed boost when you
  8796. * are using an Ajax or JS data source for the table. This option, when set to
  8797. * true, will cause DataTables to defer the creation of the table elements for
  8798. * each row until they are needed for a draw - saving a significant amount of
  8799. * time.
  8800. * @type boolean
  8801. * @default false
  8802. *
  8803. * @dtopt Features
  8804. * @name DataTable.defaults.deferRender
  8805. *
  8806. * @example
  8807. * $(document).ready( function() {
  8808. * $('#example').dataTable( {
  8809. * "ajax": "sources/arrays.txt",
  8810. * "deferRender": true
  8811. * } );
  8812. * } );
  8813. */
  8814. "bDeferRender": false,
  8815. /**
  8816. * Replace a DataTable which matches the given selector and replace it with
  8817. * one which has the properties of the new initialisation object passed. If no
  8818. * table matches the selector, then the new DataTable will be constructed as
  8819. * per normal.
  8820. * @type boolean
  8821. * @default false
  8822. *
  8823. * @dtopt Options
  8824. * @name DataTable.defaults.destroy
  8825. *
  8826. * @example
  8827. * $(document).ready( function() {
  8828. * $('#example').dataTable( {
  8829. * "srollY": "200px",
  8830. * "paginate": false
  8831. * } );
  8832. *
  8833. * // Some time later....
  8834. * $('#example').dataTable( {
  8835. * "filter": false,
  8836. * "destroy": true
  8837. * } );
  8838. * } );
  8839. */
  8840. "bDestroy": false,
  8841. /**
  8842. * Enable or disable filtering of data. Filtering in DataTables is "smart" in
  8843. * that it allows the end user to input multiple words (space separated) and
  8844. * will match a row containing those words, even if not in the order that was
  8845. * specified (this allow matching across multiple columns). Note that if you
  8846. * wish to use filtering in DataTables this must remain 'true' - to remove the
  8847. * default filtering input box and retain filtering abilities, please use
  8848. * {@link DataTable.defaults.dom}.
  8849. * @type boolean
  8850. * @default true
  8851. *
  8852. * @dtopt Features
  8853. * @name DataTable.defaults.searching
  8854. *
  8855. * @example
  8856. * $(document).ready( function () {
  8857. * $('#example').dataTable( {
  8858. * "searching": false
  8859. * } );
  8860. * } );
  8861. */
  8862. "bFilter": true,
  8863. /**
  8864. * Enable or disable the table information display. This shows information
  8865. * about the data that is currently visible on the page, including information
  8866. * about filtered data if that action is being performed.
  8867. * @type boolean
  8868. * @default true
  8869. *
  8870. * @dtopt Features
  8871. * @name DataTable.defaults.info
  8872. *
  8873. * @example
  8874. * $(document).ready( function () {
  8875. * $('#example').dataTable( {
  8876. * "info": false
  8877. * } );
  8878. * } );
  8879. */
  8880. "bInfo": true,
  8881. /**
  8882. * Allows the end user to select the size of a formatted page from a select
  8883. * menu (sizes are 10, 25, 50 and 100). Requires pagination (`paginate`).
  8884. * @type boolean
  8885. * @default true
  8886. *
  8887. * @dtopt Features
  8888. * @name DataTable.defaults.lengthChange
  8889. *
  8890. * @example
  8891. * $(document).ready( function () {
  8892. * $('#example').dataTable( {
  8893. * "lengthChange": false
  8894. * } );
  8895. * } );
  8896. */
  8897. "bLengthChange": true,
  8898. /**
  8899. * Enable or disable pagination.
  8900. * @type boolean
  8901. * @default true
  8902. *
  8903. * @dtopt Features
  8904. * @name DataTable.defaults.paging
  8905. *
  8906. * @example
  8907. * $(document).ready( function () {
  8908. * $('#example').dataTable( {
  8909. * "paging": false
  8910. * } );
  8911. * } );
  8912. */
  8913. "bPaginate": true,
  8914. /**
  8915. * Enable or disable the display of a 'processing' indicator when the table is
  8916. * being processed (e.g. a sort). This is particularly useful for tables with
  8917. * large amounts of data where it can take a noticeable amount of time to sort
  8918. * the entries.
  8919. * @type boolean
  8920. * @default false
  8921. *
  8922. * @dtopt Features
  8923. * @name DataTable.defaults.processing
  8924. *
  8925. * @example
  8926. * $(document).ready( function () {
  8927. * $('#example').dataTable( {
  8928. * "processing": true
  8929. * } );
  8930. * } );
  8931. */
  8932. "bProcessing": false,
  8933. /**
  8934. * Retrieve the DataTables object for the given selector. Note that if the
  8935. * table has already been initialised, this parameter will cause DataTables
  8936. * to simply return the object that has already been set up - it will not take
  8937. * account of any changes you might have made to the initialisation object
  8938. * passed to DataTables (setting this parameter to true is an acknowledgement
  8939. * that you understand this). `destroy` can be used to reinitialise a table if
  8940. * you need.
  8941. * @type boolean
  8942. * @default false
  8943. *
  8944. * @dtopt Options
  8945. * @name DataTable.defaults.retrieve
  8946. *
  8947. * @example
  8948. * $(document).ready( function() {
  8949. * initTable();
  8950. * tableActions();
  8951. * } );
  8952. *
  8953. * function initTable ()
  8954. * {
  8955. * return $('#example').dataTable( {
  8956. * "scrollY": "200px",
  8957. * "paginate": false,
  8958. * "retrieve": true
  8959. * } );
  8960. * }
  8961. *
  8962. * function tableActions ()
  8963. * {
  8964. * var table = initTable();
  8965. * // perform API operations with oTable
  8966. * }
  8967. */
  8968. "bRetrieve": false,
  8969. /**
  8970. * When vertical (y) scrolling is enabled, DataTables will force the height of
  8971. * the table's viewport to the given height at all times (useful for layout).
  8972. * However, this can look odd when filtering data down to a small data set,
  8973. * and the footer is left "floating" further down. This parameter (when
  8974. * enabled) will cause DataTables to collapse the table's viewport down when
  8975. * the result set will fit within the given Y height.
  8976. * @type boolean
  8977. * @default false
  8978. *
  8979. * @dtopt Options
  8980. * @name DataTable.defaults.scrollCollapse
  8981. *
  8982. * @example
  8983. * $(document).ready( function() {
  8984. * $('#example').dataTable( {
  8985. * "scrollY": "200",
  8986. * "scrollCollapse": true
  8987. * } );
  8988. * } );
  8989. */
  8990. "bScrollCollapse": false,
  8991. /**
  8992. * Configure DataTables to use server-side processing. Note that the
  8993. * `ajax` parameter must also be given in order to give DataTables a
  8994. * source to obtain the required data for each draw.
  8995. * @type boolean
  8996. * @default false
  8997. *
  8998. * @dtopt Features
  8999. * @dtopt Server-side
  9000. * @name DataTable.defaults.serverSide
  9001. *
  9002. * @example
  9003. * $(document).ready( function () {
  9004. * $('#example').dataTable( {
  9005. * "serverSide": true,
  9006. * "ajax": "xhr.php"
  9007. * } );
  9008. * } );
  9009. */
  9010. "bServerSide": false,
  9011. /**
  9012. * Enable or disable sorting of columns. Sorting of individual columns can be
  9013. * disabled by the `sortable` option for each column.
  9014. * @type boolean
  9015. * @default true
  9016. *
  9017. * @dtopt Features
  9018. * @name DataTable.defaults.ordering
  9019. *
  9020. * @example
  9021. * $(document).ready( function () {
  9022. * $('#example').dataTable( {
  9023. * "ordering": false
  9024. * } );
  9025. * } );
  9026. */
  9027. "bSort": true,
  9028. /**
  9029. * Enable or display DataTables' ability to sort multiple columns at the
  9030. * same time (activated by shift-click by the user).
  9031. * @type boolean
  9032. * @default true
  9033. *
  9034. * @dtopt Options
  9035. * @name DataTable.defaults.orderMulti
  9036. *
  9037. * @example
  9038. * // Disable multiple column sorting ability
  9039. * $(document).ready( function () {
  9040. * $('#example').dataTable( {
  9041. * "orderMulti": false
  9042. * } );
  9043. * } );
  9044. */
  9045. "bSortMulti": true,
  9046. /**
  9047. * Allows control over whether DataTables should use the top (true) unique
  9048. * cell that is found for a single column, or the bottom (false - default).
  9049. * This is useful when using complex headers.
  9050. * @type boolean
  9051. * @default false
  9052. *
  9053. * @dtopt Options
  9054. * @name DataTable.defaults.orderCellsTop
  9055. *
  9056. * @example
  9057. * $(document).ready( function() {
  9058. * $('#example').dataTable( {
  9059. * "orderCellsTop": true
  9060. * } );
  9061. * } );
  9062. */
  9063. "bSortCellsTop": false,
  9064. /**
  9065. * Enable or disable the addition of the classes `sorting\_1`, `sorting\_2` and
  9066. * `sorting\_3` to the columns which are currently being sorted on. This is
  9067. * presented as a feature switch as it can increase processing time (while
  9068. * classes are removed and added) so for large data sets you might want to
  9069. * turn this off.
  9070. * @type boolean
  9071. * @default true
  9072. *
  9073. * @dtopt Features
  9074. * @name DataTable.defaults.orderClasses
  9075. *
  9076. * @example
  9077. * $(document).ready( function () {
  9078. * $('#example').dataTable( {
  9079. * "orderClasses": false
  9080. * } );
  9081. * } );
  9082. */
  9083. "bSortClasses": true,
  9084. /**
  9085. * Enable or disable state saving. When enabled HTML5 `localStorage` will be
  9086. * used to save table display information such as pagination information,
  9087. * display length, filtering and sorting. As such when the end user reloads
  9088. * the page the display display will match what thy had previously set up.
  9089. *
  9090. * Due to the use of `localStorage` the default state saving is not supported
  9091. * in IE6 or 7. If state saving is required in those browsers, use
  9092. * `stateSaveCallback` to provide a storage solution such as cookies.
  9093. * @type boolean
  9094. * @default false
  9095. *
  9096. * @dtopt Features
  9097. * @name DataTable.defaults.stateSave
  9098. *
  9099. * @example
  9100. * $(document).ready( function () {
  9101. * $('#example').dataTable( {
  9102. * "stateSave": true
  9103. * } );
  9104. * } );
  9105. */
  9106. "bStateSave": false,
  9107. /**
  9108. * This function is called when a TR element is created (and all TD child
  9109. * elements have been inserted), or registered if using a DOM source, allowing
  9110. * manipulation of the TR element (adding classes etc).
  9111. * @type function
  9112. * @param {node} row "TR" element for the current row
  9113. * @param {array} data Raw data array for this row
  9114. * @param {int} dataIndex The index of this row in the internal aoData array
  9115. *
  9116. * @dtopt Callbacks
  9117. * @name DataTable.defaults.createdRow
  9118. *
  9119. * @example
  9120. * $(document).ready( function() {
  9121. * $('#example').dataTable( {
  9122. * "createdRow": function( row, data, dataIndex ) {
  9123. * // Bold the grade for all 'A' grade browsers
  9124. * if ( data[4] == "A" )
  9125. * {
  9126. * $('td:eq(4)', row).html( '<b>A</b>' );
  9127. * }
  9128. * }
  9129. * } );
  9130. * } );
  9131. */
  9132. "fnCreatedRow": null,
  9133. /**
  9134. * This function is called on every 'draw' event, and allows you to
  9135. * dynamically modify any aspect you want about the created DOM.
  9136. * @type function
  9137. * @param {object} settings DataTables settings object
  9138. *
  9139. * @dtopt Callbacks
  9140. * @name DataTable.defaults.drawCallback
  9141. *
  9142. * @example
  9143. * $(document).ready( function() {
  9144. * $('#example').dataTable( {
  9145. * "drawCallback": function( settings ) {
  9146. * alert( 'DataTables has redrawn the table' );
  9147. * }
  9148. * } );
  9149. * } );
  9150. */
  9151. "fnDrawCallback": null,
  9152. /**
  9153. * Identical to fnHeaderCallback() but for the table footer this function
  9154. * allows you to modify the table footer on every 'draw' event.
  9155. * @type function
  9156. * @param {node} foot "TR" element for the footer
  9157. * @param {array} data Full table data (as derived from the original HTML)
  9158. * @param {int} start Index for the current display starting point in the
  9159. * display array
  9160. * @param {int} end Index for the current display ending point in the
  9161. * display array
  9162. * @param {array int} display Index array to translate the visual position
  9163. * to the full data array
  9164. *
  9165. * @dtopt Callbacks
  9166. * @name DataTable.defaults.footerCallback
  9167. *
  9168. * @example
  9169. * $(document).ready( function() {
  9170. * $('#example').dataTable( {
  9171. * "footerCallback": function( tfoot, data, start, end, display ) {
  9172. * tfoot.getElementsByTagName('th')[0].innerHTML = "Starting index is "+start;
  9173. * }
  9174. * } );
  9175. * } )
  9176. */
  9177. "fnFooterCallback": null,
  9178. /**
  9179. * When rendering large numbers in the information element for the table
  9180. * (i.e. "Showing 1 to 10 of 57 entries") DataTables will render large numbers
  9181. * to have a comma separator for the 'thousands' units (e.g. 1 million is
  9182. * rendered as "1,000,000") to help readability for the end user. This
  9183. * function will override the default method DataTables uses.
  9184. * @type function
  9185. * @member
  9186. * @param {int} toFormat number to be formatted
  9187. * @returns {string} formatted string for DataTables to show the number
  9188. *
  9189. * @dtopt Callbacks
  9190. * @name DataTable.defaults.formatNumber
  9191. *
  9192. * @example
  9193. * // Format a number using a single quote for the separator (note that
  9194. * // this can also be done with the language.thousands option)
  9195. * $(document).ready( function() {
  9196. * $('#example').dataTable( {
  9197. * "formatNumber": function ( toFormat ) {
  9198. * return toFormat.toString().replace(
  9199. * /\B(?=(\d{3})+(?!\d))/g, "'"
  9200. * );
  9201. * };
  9202. * } );
  9203. * } );
  9204. */
  9205. "fnFormatNumber": function ( toFormat ) {
  9206. return toFormat.toString().replace(
  9207. /\B(?=(\d{3})+(?!\d))/g,
  9208. this.oLanguage.sThousands
  9209. );
  9210. },
  9211. /**
  9212. * This function is called on every 'draw' event, and allows you to
  9213. * dynamically modify the header row. This can be used to calculate and
  9214. * display useful information about the table.
  9215. * @type function
  9216. * @param {node} head "TR" element for the header
  9217. * @param {array} data Full table data (as derived from the original HTML)
  9218. * @param {int} start Index for the current display starting point in the
  9219. * display array
  9220. * @param {int} end Index for the current display ending point in the
  9221. * display array
  9222. * @param {array int} display Index array to translate the visual position
  9223. * to the full data array
  9224. *
  9225. * @dtopt Callbacks
  9226. * @name DataTable.defaults.headerCallback
  9227. *
  9228. * @example
  9229. * $(document).ready( function() {
  9230. * $('#example').dataTable( {
  9231. * "fheaderCallback": function( head, data, start, end, display ) {
  9232. * head.getElementsByTagName('th')[0].innerHTML = "Displaying "+(end-start)+" records";
  9233. * }
  9234. * } );
  9235. * } )
  9236. */
  9237. "fnHeaderCallback": null,
  9238. /**
  9239. * The information element can be used to convey information about the current
  9240. * state of the table. Although the internationalisation options presented by
  9241. * DataTables are quite capable of dealing with most customisations, there may
  9242. * be times where you wish to customise the string further. This callback
  9243. * allows you to do exactly that.
  9244. * @type function
  9245. * @param {object} oSettings DataTables settings object
  9246. * @param {int} start Starting position in data for the draw
  9247. * @param {int} end End position in data for the draw
  9248. * @param {int} max Total number of rows in the table (regardless of
  9249. * filtering)
  9250. * @param {int} total Total number of rows in the data set, after filtering
  9251. * @param {string} pre The string that DataTables has formatted using it's
  9252. * own rules
  9253. * @returns {string} The string to be displayed in the information element.
  9254. *
  9255. * @dtopt Callbacks
  9256. * @name DataTable.defaults.infoCallback
  9257. *
  9258. * @example
  9259. * $('#example').dataTable( {
  9260. * "infoCallback": function( settings, start, end, max, total, pre ) {
  9261. * return start +" to "+ end;
  9262. * }
  9263. * } );
  9264. */
  9265. "fnInfoCallback": null,
  9266. /**
  9267. * Called when the table has been initialised. Normally DataTables will
  9268. * initialise sequentially and there will be no need for this function,
  9269. * however, this does not hold true when using external language information
  9270. * since that is obtained using an async XHR call.
  9271. * @type function
  9272. * @param {object} settings DataTables settings object
  9273. * @param {object} json The JSON object request from the server - only
  9274. * present if client-side Ajax sourced data is used
  9275. *
  9276. * @dtopt Callbacks
  9277. * @name DataTable.defaults.initComplete
  9278. *
  9279. * @example
  9280. * $(document).ready( function() {
  9281. * $('#example').dataTable( {
  9282. * "initComplete": function(settings, json) {
  9283. * alert( 'DataTables has finished its initialisation.' );
  9284. * }
  9285. * } );
  9286. * } )
  9287. */
  9288. "fnInitComplete": null,
  9289. /**
  9290. * Called at the very start of each table draw and can be used to cancel the
  9291. * draw by returning false, any other return (including undefined) results in
  9292. * the full draw occurring).
  9293. * @type function
  9294. * @param {object} settings DataTables settings object
  9295. * @returns {boolean} False will cancel the draw, anything else (including no
  9296. * return) will allow it to complete.
  9297. *
  9298. * @dtopt Callbacks
  9299. * @name DataTable.defaults.preDrawCallback
  9300. *
  9301. * @example
  9302. * $(document).ready( function() {
  9303. * $('#example').dataTable( {
  9304. * "preDrawCallback": function( settings ) {
  9305. * if ( $('#test').val() == 1 ) {
  9306. * return false;
  9307. * }
  9308. * }
  9309. * } );
  9310. * } );
  9311. */
  9312. "fnPreDrawCallback": null,
  9313. /**
  9314. * This function allows you to 'post process' each row after it have been
  9315. * generated for each table draw, but before it is rendered on screen. This
  9316. * function might be used for setting the row class name etc.
  9317. * @type function
  9318. * @param {node} row "TR" element for the current row
  9319. * @param {array} data Raw data array for this row
  9320. * @param {int} displayIndex The display index for the current table draw
  9321. * @param {int} displayIndexFull The index of the data in the full list of
  9322. * rows (after filtering)
  9323. *
  9324. * @dtopt Callbacks
  9325. * @name DataTable.defaults.rowCallback
  9326. *
  9327. * @example
  9328. * $(document).ready( function() {
  9329. * $('#example').dataTable( {
  9330. * "rowCallback": function( row, data, displayIndex, displayIndexFull ) {
  9331. * // Bold the grade for all 'A' grade browsers
  9332. * if ( data[4] == "A" ) {
  9333. * $('td:eq(4)', row).html( '<b>A</b>' );
  9334. * }
  9335. * }
  9336. * } );
  9337. * } );
  9338. */
  9339. "fnRowCallback": null,
  9340. /**
  9341. * __Deprecated__ The functionality provided by this parameter has now been
  9342. * superseded by that provided through `ajax`, which should be used instead.
  9343. *
  9344. * This parameter allows you to override the default function which obtains
  9345. * the data from the server so something more suitable for your application.
  9346. * For example you could use POST data, or pull information from a Gears or
  9347. * AIR database.
  9348. * @type function
  9349. * @member
  9350. * @param {string} source HTTP source to obtain the data from (`ajax`)
  9351. * @param {array} data A key/value pair object containing the data to send
  9352. * to the server
  9353. * @param {function} callback to be called on completion of the data get
  9354. * process that will draw the data on the page.
  9355. * @param {object} settings DataTables settings object
  9356. *
  9357. * @dtopt Callbacks
  9358. * @dtopt Server-side
  9359. * @name DataTable.defaults.serverData
  9360. *
  9361. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9362. */
  9363. "fnServerData": null,
  9364. /**
  9365. * __Deprecated__ The functionality provided by this parameter has now been
  9366. * superseded by that provided through `ajax`, which should be used instead.
  9367. *
  9368. * It is often useful to send extra data to the server when making an Ajax
  9369. * request - for example custom filtering information, and this callback
  9370. * function makes it trivial to send extra information to the server. The
  9371. * passed in parameter is the data set that has been constructed by
  9372. * DataTables, and you can add to this or modify it as you require.
  9373. * @type function
  9374. * @param {array} data Data array (array of objects which are name/value
  9375. * pairs) that has been constructed by DataTables and will be sent to the
  9376. * server. In the case of Ajax sourced data with server-side processing
  9377. * this will be an empty array, for server-side processing there will be a
  9378. * significant number of parameters!
  9379. * @returns {undefined} Ensure that you modify the data array passed in,
  9380. * as this is passed by reference.
  9381. *
  9382. * @dtopt Callbacks
  9383. * @dtopt Server-side
  9384. * @name DataTable.defaults.serverParams
  9385. *
  9386. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9387. */
  9388. "fnServerParams": null,
  9389. /**
  9390. * Load the table state. With this function you can define from where, and how, the
  9391. * state of a table is loaded. By default DataTables will load from `localStorage`
  9392. * but you might wish to use a server-side database or cookies.
  9393. * @type function
  9394. * @member
  9395. * @param {object} settings DataTables settings object
  9396. * @param {object} callback Callback that can be executed when done. It
  9397. * should be passed the loaded state object.
  9398. * @return {object} The DataTables state object to be loaded
  9399. *
  9400. * @dtopt Callbacks
  9401. * @name DataTable.defaults.stateLoadCallback
  9402. *
  9403. * @example
  9404. * $(document).ready( function() {
  9405. * $('#example').dataTable( {
  9406. * "stateSave": true,
  9407. * "stateLoadCallback": function (settings, callback) {
  9408. * $.ajax( {
  9409. * "url": "/state_load",
  9410. * "dataType": "json",
  9411. * "success": function (json) {
  9412. * callback( json );
  9413. * }
  9414. * } );
  9415. * }
  9416. * } );
  9417. * } );
  9418. */
  9419. "fnStateLoadCallback": function ( settings ) {
  9420. try {
  9421. return JSON.parse(
  9422. (settings.iStateDuration === -1 ? sessionStorage : localStorage).getItem(
  9423. 'DataTables_'+settings.sInstance+'_'+location.pathname
  9424. )
  9425. );
  9426. } catch (e) {}
  9427. },
  9428. /**
  9429. * Callback which allows modification of the saved state prior to loading that state.
  9430. * This callback is called when the table is loading state from the stored data, but
  9431. * prior to the settings object being modified by the saved state. Note that for
  9432. * plug-in authors, you should use the `stateLoadParams` event to load parameters for
  9433. * a plug-in.
  9434. * @type function
  9435. * @param {object} settings DataTables settings object
  9436. * @param {object} data The state object that is to be loaded
  9437. *
  9438. * @dtopt Callbacks
  9439. * @name DataTable.defaults.stateLoadParams
  9440. *
  9441. * @example
  9442. * // Remove a saved filter, so filtering is never loaded
  9443. * $(document).ready( function() {
  9444. * $('#example').dataTable( {
  9445. * "stateSave": true,
  9446. * "stateLoadParams": function (settings, data) {
  9447. * data.oSearch.sSearch = "";
  9448. * }
  9449. * } );
  9450. * } );
  9451. *
  9452. * @example
  9453. * // Disallow state loading by returning false
  9454. * $(document).ready( function() {
  9455. * $('#example').dataTable( {
  9456. * "stateSave": true,
  9457. * "stateLoadParams": function (settings, data) {
  9458. * return false;
  9459. * }
  9460. * } );
  9461. * } );
  9462. */
  9463. "fnStateLoadParams": null,
  9464. /**
  9465. * Callback that is called when the state has been loaded from the state saving method
  9466. * and the DataTables settings object has been modified as a result of the loaded state.
  9467. * @type function
  9468. * @param {object} settings DataTables settings object
  9469. * @param {object} data The state object that was loaded
  9470. *
  9471. * @dtopt Callbacks
  9472. * @name DataTable.defaults.stateLoaded
  9473. *
  9474. * @example
  9475. * // Show an alert with the filtering value that was saved
  9476. * $(document).ready( function() {
  9477. * $('#example').dataTable( {
  9478. * "stateSave": true,
  9479. * "stateLoaded": function (settings, data) {
  9480. * alert( 'Saved filter was: '+data.oSearch.sSearch );
  9481. * }
  9482. * } );
  9483. * } );
  9484. */
  9485. "fnStateLoaded": null,
  9486. /**
  9487. * Save the table state. This function allows you to define where and how the state
  9488. * information for the table is stored By default DataTables will use `localStorage`
  9489. * but you might wish to use a server-side database or cookies.
  9490. * @type function
  9491. * @member
  9492. * @param {object} settings DataTables settings object
  9493. * @param {object} data The state object to be saved
  9494. *
  9495. * @dtopt Callbacks
  9496. * @name DataTable.defaults.stateSaveCallback
  9497. *
  9498. * @example
  9499. * $(document).ready( function() {
  9500. * $('#example').dataTable( {
  9501. * "stateSave": true,
  9502. * "stateSaveCallback": function (settings, data) {
  9503. * // Send an Ajax request to the server with the state object
  9504. * $.ajax( {
  9505. * "url": "/state_save",
  9506. * "data": data,
  9507. * "dataType": "json",
  9508. * "method": "POST"
  9509. * "success": function () {}
  9510. * } );
  9511. * }
  9512. * } );
  9513. * } );
  9514. */
  9515. "fnStateSaveCallback": function ( settings, data ) {
  9516. try {
  9517. (settings.iStateDuration === -1 ? sessionStorage : localStorage).setItem(
  9518. 'DataTables_'+settings.sInstance+'_'+location.pathname,
  9519. JSON.stringify( data )
  9520. );
  9521. } catch (e) {}
  9522. },
  9523. /**
  9524. * Callback which allows modification of the state to be saved. Called when the table
  9525. * has changed state a new state save is required. This method allows modification of
  9526. * the state saving object prior to actually doing the save, including addition or
  9527. * other state properties or modification. Note that for plug-in authors, you should
  9528. * use the `stateSaveParams` event to save parameters for a plug-in.
  9529. * @type function
  9530. * @param {object} settings DataTables settings object
  9531. * @param {object} data The state object to be saved
  9532. *
  9533. * @dtopt Callbacks
  9534. * @name DataTable.defaults.stateSaveParams
  9535. *
  9536. * @example
  9537. * // Remove a saved filter, so filtering is never saved
  9538. * $(document).ready( function() {
  9539. * $('#example').dataTable( {
  9540. * "stateSave": true,
  9541. * "stateSaveParams": function (settings, data) {
  9542. * data.oSearch.sSearch = "";
  9543. * }
  9544. * } );
  9545. * } );
  9546. */
  9547. "fnStateSaveParams": null,
  9548. /**
  9549. * Duration for which the saved state information is considered valid. After this period
  9550. * has elapsed the state will be returned to the default.
  9551. * Value is given in seconds.
  9552. * @type int
  9553. * @default 7200 <i>(2 hours)</i>
  9554. *
  9555. * @dtopt Options
  9556. * @name DataTable.defaults.stateDuration
  9557. *
  9558. * @example
  9559. * $(document).ready( function() {
  9560. * $('#example').dataTable( {
  9561. * "stateDuration": 60*60*24; // 1 day
  9562. * } );
  9563. * } )
  9564. */
  9565. "iStateDuration": 7200,
  9566. /**
  9567. * When enabled DataTables will not make a request to the server for the first
  9568. * page draw - rather it will use the data already on the page (no sorting etc
  9569. * will be applied to it), thus saving on an XHR at load time. `deferLoading`
  9570. * is used to indicate that deferred loading is required, but it is also used
  9571. * to tell DataTables how many records there are in the full table (allowing
  9572. * the information element and pagination to be displayed correctly). In the case
  9573. * where a filtering is applied to the table on initial load, this can be
  9574. * indicated by giving the parameter as an array, where the first element is
  9575. * the number of records available after filtering and the second element is the
  9576. * number of records without filtering (allowing the table information element
  9577. * to be shown correctly).
  9578. * @type int | array
  9579. * @default null
  9580. *
  9581. * @dtopt Options
  9582. * @name DataTable.defaults.deferLoading
  9583. *
  9584. * @example
  9585. * // 57 records available in the table, no filtering applied
  9586. * $(document).ready( function() {
  9587. * $('#example').dataTable( {
  9588. * "serverSide": true,
  9589. * "ajax": "scripts/server_processing.php",
  9590. * "deferLoading": 57
  9591. * } );
  9592. * } );
  9593. *
  9594. * @example
  9595. * // 57 records after filtering, 100 without filtering (an initial filter applied)
  9596. * $(document).ready( function() {
  9597. * $('#example').dataTable( {
  9598. * "serverSide": true,
  9599. * "ajax": "scripts/server_processing.php",
  9600. * "deferLoading": [ 57, 100 ],
  9601. * "search": {
  9602. * "search": "my_filter"
  9603. * }
  9604. * } );
  9605. * } );
  9606. */
  9607. "iDeferLoading": null,
  9608. /**
  9609. * Number of rows to display on a single page when using pagination. If
  9610. * feature enabled (`lengthChange`) then the end user will be able to override
  9611. * this to a custom setting using a pop-up menu.
  9612. * @type int
  9613. * @default 10
  9614. *
  9615. * @dtopt Options
  9616. * @name DataTable.defaults.pageLength
  9617. *
  9618. * @example
  9619. * $(document).ready( function() {
  9620. * $('#example').dataTable( {
  9621. * "pageLength": 50
  9622. * } );
  9623. * } )
  9624. */
  9625. "iDisplayLength": 10,
  9626. /**
  9627. * Define the starting point for data display when using DataTables with
  9628. * pagination. Note that this parameter is the number of records, rather than
  9629. * the page number, so if you have 10 records per page and want to start on
  9630. * the third page, it should be "20".
  9631. * @type int
  9632. * @default 0
  9633. *
  9634. * @dtopt Options
  9635. * @name DataTable.defaults.displayStart
  9636. *
  9637. * @example
  9638. * $(document).ready( function() {
  9639. * $('#example').dataTable( {
  9640. * "displayStart": 20
  9641. * } );
  9642. * } )
  9643. */
  9644. "iDisplayStart": 0,
  9645. /**
  9646. * By default DataTables allows keyboard navigation of the table (sorting, paging,
  9647. * and filtering) by adding a `tabindex` attribute to the required elements. This
  9648. * allows you to tab through the controls and press the enter key to activate them.
  9649. * The tabindex is default 0, meaning that the tab follows the flow of the document.
  9650. * You can overrule this using this parameter if you wish. Use a value of -1 to
  9651. * disable built-in keyboard navigation.
  9652. * @type int
  9653. * @default 0
  9654. *
  9655. * @dtopt Options
  9656. * @name DataTable.defaults.tabIndex
  9657. *
  9658. * @example
  9659. * $(document).ready( function() {
  9660. * $('#example').dataTable( {
  9661. * "tabIndex": 1
  9662. * } );
  9663. * } );
  9664. */
  9665. "iTabIndex": 0,
  9666. /**
  9667. * Classes that DataTables assigns to the various components and features
  9668. * that it adds to the HTML table. This allows classes to be configured
  9669. * during initialisation in addition to through the static
  9670. * {@link DataTable.ext.oStdClasses} object).
  9671. * @namespace
  9672. * @name DataTable.defaults.classes
  9673. */
  9674. "oClasses": {},
  9675. /**
  9676. * All strings that DataTables uses in the user interface that it creates
  9677. * are defined in this object, allowing you to modified them individually or
  9678. * completely replace them all as required.
  9679. * @namespace
  9680. * @name DataTable.defaults.language
  9681. */
  9682. "oLanguage": {
  9683. /**
  9684. * Strings that are used for WAI-ARIA labels and controls only (these are not
  9685. * actually visible on the page, but will be read by screenreaders, and thus
  9686. * must be internationalised as well).
  9687. * @namespace
  9688. * @name DataTable.defaults.language.aria
  9689. */
  9690. "oAria": {
  9691. /**
  9692. * ARIA label that is added to the table headers when the column may be
  9693. * sorted ascending by activing the column (click or return when focused).
  9694. * Note that the column header is prefixed to this string.
  9695. * @type string
  9696. * @default : activate to sort column ascending
  9697. *
  9698. * @dtopt Language
  9699. * @name DataTable.defaults.language.aria.sortAscending
  9700. *
  9701. * @example
  9702. * $(document).ready( function() {
  9703. * $('#example').dataTable( {
  9704. * "language": {
  9705. * "aria": {
  9706. * "sortAscending": " - click/return to sort ascending"
  9707. * }
  9708. * }
  9709. * } );
  9710. * } );
  9711. */
  9712. "sSortAscending": ": activate to sort column ascending",
  9713. /**
  9714. * ARIA label that is added to the table headers when the column may be
  9715. * sorted descending by activing the column (click or return when focused).
  9716. * Note that the column header is prefixed to this string.
  9717. * @type string
  9718. * @default : activate to sort column ascending
  9719. *
  9720. * @dtopt Language
  9721. * @name DataTable.defaults.language.aria.sortDescending
  9722. *
  9723. * @example
  9724. * $(document).ready( function() {
  9725. * $('#example').dataTable( {
  9726. * "language": {
  9727. * "aria": {
  9728. * "sortDescending": " - click/return to sort descending"
  9729. * }
  9730. * }
  9731. * } );
  9732. * } );
  9733. */
  9734. "sSortDescending": ": activate to sort column descending"
  9735. },
  9736. /**
  9737. * Pagination string used by DataTables for the built-in pagination
  9738. * control types.
  9739. * @namespace
  9740. * @name DataTable.defaults.language.paginate
  9741. */
  9742. "oPaginate": {
  9743. /**
  9744. * Text to use when using the 'full_numbers' type of pagination for the
  9745. * button to take the user to the first page.
  9746. * @type string
  9747. * @default First
  9748. *
  9749. * @dtopt Language
  9750. * @name DataTable.defaults.language.paginate.first
  9751. *
  9752. * @example
  9753. * $(document).ready( function() {
  9754. * $('#example').dataTable( {
  9755. * "language": {
  9756. * "paginate": {
  9757. * "first": "First page"
  9758. * }
  9759. * }
  9760. * } );
  9761. * } );
  9762. */
  9763. "sFirst": "First",
  9764. /**
  9765. * Text to use when using the 'full_numbers' type of pagination for the
  9766. * button to take the user to the last page.
  9767. * @type string
  9768. * @default Last
  9769. *
  9770. * @dtopt Language
  9771. * @name DataTable.defaults.language.paginate.last
  9772. *
  9773. * @example
  9774. * $(document).ready( function() {
  9775. * $('#example').dataTable( {
  9776. * "language": {
  9777. * "paginate": {
  9778. * "last": "Last page"
  9779. * }
  9780. * }
  9781. * } );
  9782. * } );
  9783. */
  9784. "sLast": "Last",
  9785. /**
  9786. * Text to use for the 'next' pagination button (to take the user to the
  9787. * next page).
  9788. * @type string
  9789. * @default Next
  9790. *
  9791. * @dtopt Language
  9792. * @name DataTable.defaults.language.paginate.next
  9793. *
  9794. * @example
  9795. * $(document).ready( function() {
  9796. * $('#example').dataTable( {
  9797. * "language": {
  9798. * "paginate": {
  9799. * "next": "Next page"
  9800. * }
  9801. * }
  9802. * } );
  9803. * } );
  9804. */
  9805. "sNext": "Next",
  9806. /**
  9807. * Text to use for the 'previous' pagination button (to take the user to
  9808. * the previous page).
  9809. * @type string
  9810. * @default Previous
  9811. *
  9812. * @dtopt Language
  9813. * @name DataTable.defaults.language.paginate.previous
  9814. *
  9815. * @example
  9816. * $(document).ready( function() {
  9817. * $('#example').dataTable( {
  9818. * "language": {
  9819. * "paginate": {
  9820. * "previous": "Previous page"
  9821. * }
  9822. * }
  9823. * } );
  9824. * } );
  9825. */
  9826. "sPrevious": "Previous"
  9827. },
  9828. /**
  9829. * This string is shown in preference to `zeroRecords` when the table is
  9830. * empty of data (regardless of filtering). Note that this is an optional
  9831. * parameter - if it is not given, the value of `zeroRecords` will be used
  9832. * instead (either the default or given value).
  9833. * @type string
  9834. * @default No data available in table
  9835. *
  9836. * @dtopt Language
  9837. * @name DataTable.defaults.language.emptyTable
  9838. *
  9839. * @example
  9840. * $(document).ready( function() {
  9841. * $('#example').dataTable( {
  9842. * "language": {
  9843. * "emptyTable": "No data available in table"
  9844. * }
  9845. * } );
  9846. * } );
  9847. */
  9848. "sEmptyTable": "No data available in table",
  9849. /**
  9850. * This string gives information to the end user about the information
  9851. * that is current on display on the page. The following tokens can be
  9852. * used in the string and will be dynamically replaced as the table
  9853. * display updates. This tokens can be placed anywhere in the string, or
  9854. * removed as needed by the language requires:
  9855. *
  9856. * * `\_START\_` - Display index of the first record on the current page
  9857. * * `\_END\_` - Display index of the last record on the current page
  9858. * * `\_TOTAL\_` - Number of records in the table after filtering
  9859. * * `\_MAX\_` - Number of records in the table without filtering
  9860. * * `\_PAGE\_` - Current page number
  9861. * * `\_PAGES\_` - Total number of pages of data in the table
  9862. *
  9863. * @type string
  9864. * @default Showing _START_ to _END_ of _TOTAL_ entries
  9865. *
  9866. * @dtopt Language
  9867. * @name DataTable.defaults.language.info
  9868. *
  9869. * @example
  9870. * $(document).ready( function() {
  9871. * $('#example').dataTable( {
  9872. * "language": {
  9873. * "info": "Showing page _PAGE_ of _PAGES_"
  9874. * }
  9875. * } );
  9876. * } );
  9877. */
  9878. "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
  9879. /**
  9880. * Display information string for when the table is empty. Typically the
  9881. * format of this string should match `info`.
  9882. * @type string
  9883. * @default Showing 0 to 0 of 0 entries
  9884. *
  9885. * @dtopt Language
  9886. * @name DataTable.defaults.language.infoEmpty
  9887. *
  9888. * @example
  9889. * $(document).ready( function() {
  9890. * $('#example').dataTable( {
  9891. * "language": {
  9892. * "infoEmpty": "No entries to show"
  9893. * }
  9894. * } );
  9895. * } );
  9896. */
  9897. "sInfoEmpty": "Showing 0 to 0 of 0 entries",
  9898. /**
  9899. * When a user filters the information in a table, this string is appended
  9900. * to the information (`info`) to give an idea of how strong the filtering
  9901. * is. The variable _MAX_ is dynamically updated.
  9902. * @type string
  9903. * @default (filtered from _MAX_ total entries)
  9904. *
  9905. * @dtopt Language
  9906. * @name DataTable.defaults.language.infoFiltered
  9907. *
  9908. * @example
  9909. * $(document).ready( function() {
  9910. * $('#example').dataTable( {
  9911. * "language": {
  9912. * "infoFiltered": " - filtering from _MAX_ records"
  9913. * }
  9914. * } );
  9915. * } );
  9916. */
  9917. "sInfoFiltered": "(filtered from _MAX_ total entries)",
  9918. /**
  9919. * If can be useful to append extra information to the info string at times,
  9920. * and this variable does exactly that. This information will be appended to
  9921. * the `info` (`infoEmpty` and `infoFiltered` in whatever combination they are
  9922. * being used) at all times.
  9923. * @type string
  9924. * @default <i>Empty string</i>
  9925. *
  9926. * @dtopt Language
  9927. * @name DataTable.defaults.language.infoPostFix
  9928. *
  9929. * @example
  9930. * $(document).ready( function() {
  9931. * $('#example').dataTable( {
  9932. * "language": {
  9933. * "infoPostFix": "All records shown are derived from real information."
  9934. * }
  9935. * } );
  9936. * } );
  9937. */
  9938. "sInfoPostFix": "",
  9939. /**
  9940. * This decimal place operator is a little different from the other
  9941. * language options since DataTables doesn't output floating point
  9942. * numbers, so it won't ever use this for display of a number. Rather,
  9943. * what this parameter does is modify the sort methods of the table so
  9944. * that numbers which are in a format which has a character other than
  9945. * a period (`.`) as a decimal place will be sorted numerically.
  9946. *
  9947. * Note that numbers with different decimal places cannot be shown in
  9948. * the same table and still be sortable, the table must be consistent.
  9949. * However, multiple different tables on the page can use different
  9950. * decimal place characters.
  9951. * @type string
  9952. * @default
  9953. *
  9954. * @dtopt Language
  9955. * @name DataTable.defaults.language.decimal
  9956. *
  9957. * @example
  9958. * $(document).ready( function() {
  9959. * $('#example').dataTable( {
  9960. * "language": {
  9961. * "decimal": ","
  9962. * "thousands": "."
  9963. * }
  9964. * } );
  9965. * } );
  9966. */
  9967. "sDecimal": "",
  9968. /**
  9969. * DataTables has a build in number formatter (`formatNumber`) which is
  9970. * used to format large numbers that are used in the table information.
  9971. * By default a comma is used, but this can be trivially changed to any
  9972. * character you wish with this parameter.
  9973. * @type string
  9974. * @default ,
  9975. *
  9976. * @dtopt Language
  9977. * @name DataTable.defaults.language.thousands
  9978. *
  9979. * @example
  9980. * $(document).ready( function() {
  9981. * $('#example').dataTable( {
  9982. * "language": {
  9983. * "thousands": "'"
  9984. * }
  9985. * } );
  9986. * } );
  9987. */
  9988. "sThousands": ",",
  9989. /**
  9990. * Detail the action that will be taken when the drop down menu for the
  9991. * pagination length option is changed. The '_MENU_' variable is replaced
  9992. * with a default select list of 10, 25, 50 and 100, and can be replaced
  9993. * with a custom select box if required.
  9994. * @type string
  9995. * @default Show _MENU_ entries
  9996. *
  9997. * @dtopt Language
  9998. * @name DataTable.defaults.language.lengthMenu
  9999. *
  10000. * @example
  10001. * // Language change only
  10002. * $(document).ready( function() {
  10003. * $('#example').dataTable( {
  10004. * "language": {
  10005. * "lengthMenu": "Display _MENU_ records"
  10006. * }
  10007. * } );
  10008. * } );
  10009. *
  10010. * @example
  10011. * // Language and options change
  10012. * $(document).ready( function() {
  10013. * $('#example').dataTable( {
  10014. * "language": {
  10015. * "lengthMenu": 'Display <select>'+
  10016. * '<option value="10">10</option>'+
  10017. * '<option value="20">20</option>'+
  10018. * '<option value="30">30</option>'+
  10019. * '<option value="40">40</option>'+
  10020. * '<option value="50">50</option>'+
  10021. * '<option value="-1">All</option>'+
  10022. * '</select> records'
  10023. * }
  10024. * } );
  10025. * } );
  10026. */
  10027. "sLengthMenu": "Show _MENU_ entries",
  10028. /**
  10029. * When using Ajax sourced data and during the first draw when DataTables is
  10030. * gathering the data, this message is shown in an empty row in the table to
  10031. * indicate to the end user the the data is being loaded. Note that this
  10032. * parameter is not used when loading data by server-side processing, just
  10033. * Ajax sourced data with client-side processing.
  10034. * @type string
  10035. * @default Loading...
  10036. *
  10037. * @dtopt Language
  10038. * @name DataTable.defaults.language.loadingRecords
  10039. *
  10040. * @example
  10041. * $(document).ready( function() {
  10042. * $('#example').dataTable( {
  10043. * "language": {
  10044. * "loadingRecords": "Please wait - loading..."
  10045. * }
  10046. * } );
  10047. * } );
  10048. */
  10049. "sLoadingRecords": "Loading...",
  10050. /**
  10051. * Text which is displayed when the table is processing a user action
  10052. * (usually a sort command or similar).
  10053. * @type string
  10054. * @default Processing...
  10055. *
  10056. * @dtopt Language
  10057. * @name DataTable.defaults.language.processing
  10058. *
  10059. * @example
  10060. * $(document).ready( function() {
  10061. * $('#example').dataTable( {
  10062. * "language": {
  10063. * "processing": "DataTables is currently busy"
  10064. * }
  10065. * } );
  10066. * } );
  10067. */
  10068. "sProcessing": "Processing...",
  10069. /**
  10070. * Details the actions that will be taken when the user types into the
  10071. * filtering input text box. The variable "_INPUT_", if used in the string,
  10072. * is replaced with the HTML text box for the filtering input allowing
  10073. * control over where it appears in the string. If "_INPUT_" is not given
  10074. * then the input box is appended to the string automatically.
  10075. * @type string
  10076. * @default Search:
  10077. *
  10078. * @dtopt Language
  10079. * @name DataTable.defaults.language.search
  10080. *
  10081. * @example
  10082. * // Input text box will be appended at the end automatically
  10083. * $(document).ready( function() {
  10084. * $('#example').dataTable( {
  10085. * "language": {
  10086. * "search": "Filter records:"
  10087. * }
  10088. * } );
  10089. * } );
  10090. *
  10091. * @example
  10092. * // Specify where the filter should appear
  10093. * $(document).ready( function() {
  10094. * $('#example').dataTable( {
  10095. * "language": {
  10096. * "search": "Apply filter _INPUT_ to table"
  10097. * }
  10098. * } );
  10099. * } );
  10100. */
  10101. "sSearch": "Search:",
  10102. /**
  10103. * Assign a `placeholder` attribute to the search `input` element
  10104. * @type string
  10105. * @default
  10106. *
  10107. * @dtopt Language
  10108. * @name DataTable.defaults.language.searchPlaceholder
  10109. */
  10110. "sSearchPlaceholder": "",
  10111. /**
  10112. * All of the language information can be stored in a file on the
  10113. * server-side, which DataTables will look up if this parameter is passed.
  10114. * It must store the URL of the language file, which is in a JSON format,
  10115. * and the object has the same properties as the oLanguage object in the
  10116. * initialiser object (i.e. the above parameters). Please refer to one of
  10117. * the example language files to see how this works in action.
  10118. * @type string
  10119. * @default <i>Empty string - i.e. disabled</i>
  10120. *
  10121. * @dtopt Language
  10122. * @name DataTable.defaults.language.url
  10123. *
  10124. * @example
  10125. * $(document).ready( function() {
  10126. * $('#example').dataTable( {
  10127. * "language": {
  10128. * "url": "http://www.sprymedia.co.uk/dataTables/lang.txt"
  10129. * }
  10130. * } );
  10131. * } );
  10132. */
  10133. "sUrl": "",
  10134. /**
  10135. * Text shown inside the table records when the is no information to be
  10136. * displayed after filtering. `emptyTable` is shown when there is simply no
  10137. * information in the table at all (regardless of filtering).
  10138. * @type string
  10139. * @default No matching records found
  10140. *
  10141. * @dtopt Language
  10142. * @name DataTable.defaults.language.zeroRecords
  10143. *
  10144. * @example
  10145. * $(document).ready( function() {
  10146. * $('#example').dataTable( {
  10147. * "language": {
  10148. * "zeroRecords": "No records to display"
  10149. * }
  10150. * } );
  10151. * } );
  10152. */
  10153. "sZeroRecords": "No matching records found"
  10154. },
  10155. /**
  10156. * This parameter allows you to have define the global filtering state at
  10157. * initialisation time. As an object the `search` parameter must be
  10158. * defined, but all other parameters are optional. When `regex` is true,
  10159. * the search string will be treated as a regular expression, when false
  10160. * (default) it will be treated as a straight string. When `smart`
  10161. * DataTables will use it's smart filtering methods (to word match at
  10162. * any point in the data), when false this will not be done.
  10163. * @namespace
  10164. * @extends DataTable.models.oSearch
  10165. *
  10166. * @dtopt Options
  10167. * @name DataTable.defaults.search
  10168. *
  10169. * @example
  10170. * $(document).ready( function() {
  10171. * $('#example').dataTable( {
  10172. * "search": {"search": "Initial search"}
  10173. * } );
  10174. * } )
  10175. */
  10176. "oSearch": $.extend( {}, DataTable.models.oSearch ),
  10177. /**
  10178. * __Deprecated__ The functionality provided by this parameter has now been
  10179. * superseded by that provided through `ajax`, which should be used instead.
  10180. *
  10181. * By default DataTables will look for the property `data` (or `aaData` for
  10182. * compatibility with DataTables 1.9-) when obtaining data from an Ajax
  10183. * source or for server-side processing - this parameter allows that
  10184. * property to be changed. You can use Javascript dotted object notation to
  10185. * get a data source for multiple levels of nesting.
  10186. * @type string
  10187. * @default data
  10188. *
  10189. * @dtopt Options
  10190. * @dtopt Server-side
  10191. * @name DataTable.defaults.ajaxDataProp
  10192. *
  10193. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10194. */
  10195. "sAjaxDataProp": "data",
  10196. /**
  10197. * __Deprecated__ The functionality provided by this parameter has now been
  10198. * superseded by that provided through `ajax`, which should be used instead.
  10199. *
  10200. * You can instruct DataTables to load data from an external
  10201. * source using this parameter (use aData if you want to pass data in you
  10202. * already have). Simply provide a url a JSON object can be obtained from.
  10203. * @type string
  10204. * @default null
  10205. *
  10206. * @dtopt Options
  10207. * @dtopt Server-side
  10208. * @name DataTable.defaults.ajaxSource
  10209. *
  10210. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10211. */
  10212. "sAjaxSource": null,
  10213. /**
  10214. * This initialisation variable allows you to specify exactly where in the
  10215. * DOM you want DataTables to inject the various controls it adds to the page
  10216. * (for example you might want the pagination controls at the top of the
  10217. * table). DIV elements (with or without a custom class) can also be added to
  10218. * aid styling. The follow syntax is used:
  10219. * <ul>
  10220. * <li>The following options are allowed:
  10221. * <ul>
  10222. * <li>'l' - Length changing</li>
  10223. * <li>'f' - Filtering input</li>
  10224. * <li>'t' - The table!</li>
  10225. * <li>'i' - Information</li>
  10226. * <li>'p' - Pagination</li>
  10227. * <li>'r' - pRocessing</li>
  10228. * </ul>
  10229. * </li>
  10230. * <li>The following constants are allowed:
  10231. * <ul>
  10232. * <li>'H' - jQueryUI theme "header" classes ('fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix')</li>
  10233. * <li>'F' - jQueryUI theme "footer" classes ('fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix')</li>
  10234. * </ul>
  10235. * </li>
  10236. * <li>The following syntax is expected:
  10237. * <ul>
  10238. * <li>'&lt;' and '&gt;' - div elements</li>
  10239. * <li>'&lt;"class" and '&gt;' - div with a class</li>
  10240. * <li>'&lt;"#id" and '&gt;' - div with an ID</li>
  10241. * </ul>
  10242. * </li>
  10243. * <li>Examples:
  10244. * <ul>
  10245. * <li>'&lt;"wrapper"flipt&gt;'</li>
  10246. * <li>'&lt;lf&lt;t&gt;ip&gt;'</li>
  10247. * </ul>
  10248. * </li>
  10249. * </ul>
  10250. * @type string
  10251. * @default lfrtip <i>(when `jQueryUI` is false)</i> <b>or</b>
  10252. * <"H"lfr>t<"F"ip> <i>(when `jQueryUI` is true)</i>
  10253. *
  10254. * @dtopt Options
  10255. * @name DataTable.defaults.dom
  10256. *
  10257. * @example
  10258. * $(document).ready( function() {
  10259. * $('#example').dataTable( {
  10260. * "dom": '&lt;"top"i&gt;rt&lt;"bottom"flp&gt;&lt;"clear"&gt;'
  10261. * } );
  10262. * } );
  10263. */
  10264. "sDom": "lfrtip",
  10265. /**
  10266. * Search delay option. This will throttle full table searches that use the
  10267. * DataTables provided search input element (it does not effect calls to
  10268. * `dt-api search()`, providing a delay before the search is made.
  10269. * @type integer
  10270. * @default 0
  10271. *
  10272. * @dtopt Options
  10273. * @name DataTable.defaults.searchDelay
  10274. *
  10275. * @example
  10276. * $(document).ready( function() {
  10277. * $('#example').dataTable( {
  10278. * "searchDelay": 200
  10279. * } );
  10280. * } )
  10281. */
  10282. "searchDelay": null,
  10283. /**
  10284. * DataTables features six different built-in options for the buttons to
  10285. * display for pagination control:
  10286. *
  10287. * * `numbers` - Page number buttons only
  10288. * * `simple` - 'Previous' and 'Next' buttons only
  10289. * * 'simple_numbers` - 'Previous' and 'Next' buttons, plus page numbers
  10290. * * `full` - 'First', 'Previous', 'Next' and 'Last' buttons
  10291. * * `full_numbers` - 'First', 'Previous', 'Next' and 'Last' buttons, plus page numbers
  10292. * * `first_last_numbers` - 'First' and 'Last' buttons, plus page numbers
  10293. *
  10294. * Further methods can be added using {@link DataTable.ext.oPagination}.
  10295. * @type string
  10296. * @default simple_numbers
  10297. *
  10298. * @dtopt Options
  10299. * @name DataTable.defaults.pagingType
  10300. *
  10301. * @example
  10302. * $(document).ready( function() {
  10303. * $('#example').dataTable( {
  10304. * "pagingType": "full_numbers"
  10305. * } );
  10306. * } )
  10307. */
  10308. "sPaginationType": "simple_numbers",
  10309. /**
  10310. * Enable horizontal scrolling. When a table is too wide to fit into a
  10311. * certain layout, or you have a large number of columns in the table, you
  10312. * can enable x-scrolling to show the table in a viewport, which can be
  10313. * scrolled. This property can be `true` which will allow the table to
  10314. * scroll horizontally when needed, or any CSS unit, or a number (in which
  10315. * case it will be treated as a pixel measurement). Setting as simply `true`
  10316. * is recommended.
  10317. * @type boolean|string
  10318. * @default <i>blank string - i.e. disabled</i>
  10319. *
  10320. * @dtopt Features
  10321. * @name DataTable.defaults.scrollX
  10322. *
  10323. * @example
  10324. * $(document).ready( function() {
  10325. * $('#example').dataTable( {
  10326. * "scrollX": true,
  10327. * "scrollCollapse": true
  10328. * } );
  10329. * } );
  10330. */
  10331. "sScrollX": "",
  10332. /**
  10333. * This property can be used to force a DataTable to use more width than it
  10334. * might otherwise do when x-scrolling is enabled. For example if you have a
  10335. * table which requires to be well spaced, this parameter is useful for
  10336. * "over-sizing" the table, and thus forcing scrolling. This property can by
  10337. * any CSS unit, or a number (in which case it will be treated as a pixel
  10338. * measurement).
  10339. * @type string
  10340. * @default <i>blank string - i.e. disabled</i>
  10341. *
  10342. * @dtopt Options
  10343. * @name DataTable.defaults.scrollXInner
  10344. *
  10345. * @example
  10346. * $(document).ready( function() {
  10347. * $('#example').dataTable( {
  10348. * "scrollX": "100%",
  10349. * "scrollXInner": "110%"
  10350. * } );
  10351. * } );
  10352. */
  10353. "sScrollXInner": "",
  10354. /**
  10355. * Enable vertical scrolling. Vertical scrolling will constrain the DataTable
  10356. * to the given height, and enable scrolling for any data which overflows the
  10357. * current viewport. This can be used as an alternative to paging to display
  10358. * a lot of data in a small area (although paging and scrolling can both be
  10359. * enabled at the same time). This property can be any CSS unit, or a number
  10360. * (in which case it will be treated as a pixel measurement).
  10361. * @type string
  10362. * @default <i>blank string - i.e. disabled</i>
  10363. *
  10364. * @dtopt Features
  10365. * @name DataTable.defaults.scrollY
  10366. *
  10367. * @example
  10368. * $(document).ready( function() {
  10369. * $('#example').dataTable( {
  10370. * "scrollY": "200px",
  10371. * "paginate": false
  10372. * } );
  10373. * } );
  10374. */
  10375. "sScrollY": "",
  10376. /**
  10377. * __Deprecated__ The functionality provided by this parameter has now been
  10378. * superseded by that provided through `ajax`, which should be used instead.
  10379. *
  10380. * Set the HTTP method that is used to make the Ajax call for server-side
  10381. * processing or Ajax sourced data.
  10382. * @type string
  10383. * @default GET
  10384. *
  10385. * @dtopt Options
  10386. * @dtopt Server-side
  10387. * @name DataTable.defaults.serverMethod
  10388. *
  10389. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10390. */
  10391. "sServerMethod": "GET",
  10392. /**
  10393. * DataTables makes use of renderers when displaying HTML elements for
  10394. * a table. These renderers can be added or modified by plug-ins to
  10395. * generate suitable mark-up for a site. For example the Bootstrap
  10396. * integration plug-in for DataTables uses a paging button renderer to
  10397. * display pagination buttons in the mark-up required by Bootstrap.
  10398. *
  10399. * For further information about the renderers available see
  10400. * DataTable.ext.renderer
  10401. * @type string|object
  10402. * @default null
  10403. *
  10404. * @name DataTable.defaults.renderer
  10405. *
  10406. */
  10407. "renderer": null,
  10408. /**
  10409. * Set the data property name that DataTables should use to get a row's id
  10410. * to set as the `id` property in the node.
  10411. * @type string
  10412. * @default DT_RowId
  10413. *
  10414. * @name DataTable.defaults.rowId
  10415. */
  10416. "rowId": "DT_RowId"
  10417. };
  10418. _fnHungarianMap( DataTable.defaults );
  10419. /*
  10420. * Developer note - See note in model.defaults.js about the use of Hungarian
  10421. * notation and camel case.
  10422. */
  10423. /**
  10424. * Column options that can be given to DataTables at initialisation time.
  10425. * @namespace
  10426. */
  10427. DataTable.defaults.column = {
  10428. /**
  10429. * Define which column(s) an order will occur on for this column. This
  10430. * allows a column's ordering to take multiple columns into account when
  10431. * doing a sort or use the data from a different column. For example first
  10432. * name / last name columns make sense to do a multi-column sort over the
  10433. * two columns.
  10434. * @type array|int
  10435. * @default null <i>Takes the value of the column index automatically</i>
  10436. *
  10437. * @name DataTable.defaults.column.orderData
  10438. * @dtopt Columns
  10439. *
  10440. * @example
  10441. * // Using `columnDefs`
  10442. * $(document).ready( function() {
  10443. * $('#example').dataTable( {
  10444. * "columnDefs": [
  10445. * { "orderData": [ 0, 1 ], "targets": [ 0 ] },
  10446. * { "orderData": [ 1, 0 ], "targets": [ 1 ] },
  10447. * { "orderData": 2, "targets": [ 2 ] }
  10448. * ]
  10449. * } );
  10450. * } );
  10451. *
  10452. * @example
  10453. * // Using `columns`
  10454. * $(document).ready( function() {
  10455. * $('#example').dataTable( {
  10456. * "columns": [
  10457. * { "orderData": [ 0, 1 ] },
  10458. * { "orderData": [ 1, 0 ] },
  10459. * { "orderData": 2 },
  10460. * null,
  10461. * null
  10462. * ]
  10463. * } );
  10464. * } );
  10465. */
  10466. "aDataSort": null,
  10467. "iDataSort": -1,
  10468. /**
  10469. * You can control the default ordering direction, and even alter the
  10470. * behaviour of the sort handler (i.e. only allow ascending ordering etc)
  10471. * using this parameter.
  10472. * @type array
  10473. * @default [ 'asc', 'desc' ]
  10474. *
  10475. * @name DataTable.defaults.column.orderSequence
  10476. * @dtopt Columns
  10477. *
  10478. * @example
  10479. * // Using `columnDefs`
  10480. * $(document).ready( function() {
  10481. * $('#example').dataTable( {
  10482. * "columnDefs": [
  10483. * { "orderSequence": [ "asc" ], "targets": [ 1 ] },
  10484. * { "orderSequence": [ "desc", "asc", "asc" ], "targets": [ 2 ] },
  10485. * { "orderSequence": [ "desc" ], "targets": [ 3 ] }
  10486. * ]
  10487. * } );
  10488. * } );
  10489. *
  10490. * @example
  10491. * // Using `columns`
  10492. * $(document).ready( function() {
  10493. * $('#example').dataTable( {
  10494. * "columns": [
  10495. * null,
  10496. * { "orderSequence": [ "asc" ] },
  10497. * { "orderSequence": [ "desc", "asc", "asc" ] },
  10498. * { "orderSequence": [ "desc" ] },
  10499. * null
  10500. * ]
  10501. * } );
  10502. * } );
  10503. */
  10504. "asSorting": [ 'asc', 'desc' ],
  10505. /**
  10506. * Enable or disable filtering on the data in this column.
  10507. * @type boolean
  10508. * @default true
  10509. *
  10510. * @name DataTable.defaults.column.searchable
  10511. * @dtopt Columns
  10512. *
  10513. * @example
  10514. * // Using `columnDefs`
  10515. * $(document).ready( function() {
  10516. * $('#example').dataTable( {
  10517. * "columnDefs": [
  10518. * { "searchable": false, "targets": [ 0 ] }
  10519. * ] } );
  10520. * } );
  10521. *
  10522. * @example
  10523. * // Using `columns`
  10524. * $(document).ready( function() {
  10525. * $('#example').dataTable( {
  10526. * "columns": [
  10527. * { "searchable": false },
  10528. * null,
  10529. * null,
  10530. * null,
  10531. * null
  10532. * ] } );
  10533. * } );
  10534. */
  10535. "bSearchable": true,
  10536. /**
  10537. * Enable or disable ordering on this column.
  10538. * @type boolean
  10539. * @default true
  10540. *
  10541. * @name DataTable.defaults.column.orderable
  10542. * @dtopt Columns
  10543. *
  10544. * @example
  10545. * // Using `columnDefs`
  10546. * $(document).ready( function() {
  10547. * $('#example').dataTable( {
  10548. * "columnDefs": [
  10549. * { "orderable": false, "targets": [ 0 ] }
  10550. * ] } );
  10551. * } );
  10552. *
  10553. * @example
  10554. * // Using `columns`
  10555. * $(document).ready( function() {
  10556. * $('#example').dataTable( {
  10557. * "columns": [
  10558. * { "orderable": false },
  10559. * null,
  10560. * null,
  10561. * null,
  10562. * null
  10563. * ] } );
  10564. * } );
  10565. */
  10566. "bSortable": true,
  10567. /**
  10568. * Enable or disable the display of this column.
  10569. * @type boolean
  10570. * @default true
  10571. *
  10572. * @name DataTable.defaults.column.visible
  10573. * @dtopt Columns
  10574. *
  10575. * @example
  10576. * // Using `columnDefs`
  10577. * $(document).ready( function() {
  10578. * $('#example').dataTable( {
  10579. * "columnDefs": [
  10580. * { "visible": false, "targets": [ 0 ] }
  10581. * ] } );
  10582. * } );
  10583. *
  10584. * @example
  10585. * // Using `columns`
  10586. * $(document).ready( function() {
  10587. * $('#example').dataTable( {
  10588. * "columns": [
  10589. * { "visible": false },
  10590. * null,
  10591. * null,
  10592. * null,
  10593. * null
  10594. * ] } );
  10595. * } );
  10596. */
  10597. "bVisible": true,
  10598. /**
  10599. * Developer definable function that is called whenever a cell is created (Ajax source,
  10600. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  10601. * allowing you to modify the DOM element (add background colour for example) when the
  10602. * element is available.
  10603. * @type function
  10604. * @param {element} td The TD node that has been created
  10605. * @param {*} cellData The Data for the cell
  10606. * @param {array|object} rowData The data for the whole row
  10607. * @param {int} row The row index for the aoData data store
  10608. * @param {int} col The column index for aoColumns
  10609. *
  10610. * @name DataTable.defaults.column.createdCell
  10611. * @dtopt Columns
  10612. *
  10613. * @example
  10614. * $(document).ready( function() {
  10615. * $('#example').dataTable( {
  10616. * "columnDefs": [ {
  10617. * "targets": [3],
  10618. * "createdCell": function (td, cellData, rowData, row, col) {
  10619. * if ( cellData == "1.7" ) {
  10620. * $(td).css('color', 'blue')
  10621. * }
  10622. * }
  10623. * } ]
  10624. * });
  10625. * } );
  10626. */
  10627. "fnCreatedCell": null,
  10628. /**
  10629. * This parameter has been replaced by `data` in DataTables to ensure naming
  10630. * consistency. `dataProp` can still be used, as there is backwards
  10631. * compatibility in DataTables for this option, but it is strongly
  10632. * recommended that you use `data` in preference to `dataProp`.
  10633. * @name DataTable.defaults.column.dataProp
  10634. */
  10635. /**
  10636. * This property can be used to read data from any data source property,
  10637. * including deeply nested objects / properties. `data` can be given in a
  10638. * number of different ways which effect its behaviour:
  10639. *
  10640. * * `integer` - treated as an array index for the data source. This is the
  10641. * default that DataTables uses (incrementally increased for each column).
  10642. * * `string` - read an object property from the data source. There are
  10643. * three 'special' options that can be used in the string to alter how
  10644. * DataTables reads the data from the source object:
  10645. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10646. * Javascript to read from nested objects, so to can the options
  10647. * specified in `data`. For example: `browser.version` or
  10648. * `browser.name`. If your object parameter name contains a period, use
  10649. * `\\` to escape it - i.e. `first\\.name`.
  10650. * * `[]` - Array notation. DataTables can automatically combine data
  10651. * from and array source, joining the data with the characters provided
  10652. * between the two brackets. For example: `name[, ]` would provide a
  10653. * comma-space separated list from the source array. If no characters
  10654. * are provided between the brackets, the original array source is
  10655. * returned.
  10656. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10657. * execute a function of the name given. For example: `browser()` for a
  10658. * simple function on the data source, `browser.version()` for a
  10659. * function in a nested property or even `browser().version` to get an
  10660. * object property if the function called returns an object. Note that
  10661. * function notation is recommended for use in `render` rather than
  10662. * `data` as it is much simpler to use as a renderer.
  10663. * * `null` - use the original data source for the row rather than plucking
  10664. * data directly from it. This action has effects on two other
  10665. * initialisation options:
  10666. * * `defaultContent` - When null is given as the `data` option and
  10667. * `defaultContent` is specified for the column, the value defined by
  10668. * `defaultContent` will be used for the cell.
  10669. * * `render` - When null is used for the `data` option and the `render`
  10670. * option is specified for the column, the whole data source for the
  10671. * row is used for the renderer.
  10672. * * `function` - the function given will be executed whenever DataTables
  10673. * needs to set or get the data for a cell in the column. The function
  10674. * takes three parameters:
  10675. * * Parameters:
  10676. * * `{array|object}` The data source for the row
  10677. * * `{string}` The type call data requested - this will be 'set' when
  10678. * setting data or 'filter', 'display', 'type', 'sort' or undefined
  10679. * when gathering data. Note that when `undefined` is given for the
  10680. * type DataTables expects to get the raw data for the object back<
  10681. * * `{*}` Data to set when the second parameter is 'set'.
  10682. * * Return:
  10683. * * The return value from the function is not required when 'set' is
  10684. * the type of call, but otherwise the return is what will be used
  10685. * for the data requested.
  10686. *
  10687. * Note that `data` is a getter and setter option. If you just require
  10688. * formatting of data for output, you will likely want to use `render` which
  10689. * is simply a getter and thus simpler to use.
  10690. *
  10691. * Note that prior to DataTables 1.9.2 `data` was called `mDataProp`. The
  10692. * name change reflects the flexibility of this property and is consistent
  10693. * with the naming of mRender. If 'mDataProp' is given, then it will still
  10694. * be used by DataTables, as it automatically maps the old name to the new
  10695. * if required.
  10696. *
  10697. * @type string|int|function|null
  10698. * @default null <i>Use automatically calculated column index</i>
  10699. *
  10700. * @name DataTable.defaults.column.data
  10701. * @dtopt Columns
  10702. *
  10703. * @example
  10704. * // Read table data from objects
  10705. * // JSON structure for each row:
  10706. * // {
  10707. * // "engine": {value},
  10708. * // "browser": {value},
  10709. * // "platform": {value},
  10710. * // "version": {value},
  10711. * // "grade": {value}
  10712. * // }
  10713. * $(document).ready( function() {
  10714. * $('#example').dataTable( {
  10715. * "ajaxSource": "sources/objects.txt",
  10716. * "columns": [
  10717. * { "data": "engine" },
  10718. * { "data": "browser" },
  10719. * { "data": "platform" },
  10720. * { "data": "version" },
  10721. * { "data": "grade" }
  10722. * ]
  10723. * } );
  10724. * } );
  10725. *
  10726. * @example
  10727. * // Read information from deeply nested objects
  10728. * // JSON structure for each row:
  10729. * // {
  10730. * // "engine": {value},
  10731. * // "browser": {value},
  10732. * // "platform": {
  10733. * // "inner": {value}
  10734. * // },
  10735. * // "details": [
  10736. * // {value}, {value}
  10737. * // ]
  10738. * // }
  10739. * $(document).ready( function() {
  10740. * $('#example').dataTable( {
  10741. * "ajaxSource": "sources/deep.txt",
  10742. * "columns": [
  10743. * { "data": "engine" },
  10744. * { "data": "browser" },
  10745. * { "data": "platform.inner" },
  10746. * { "data": "details.0" },
  10747. * { "data": "details.1" }
  10748. * ]
  10749. * } );
  10750. * } );
  10751. *
  10752. * @example
  10753. * // Using `data` as a function to provide different information for
  10754. * // sorting, filtering and display. In this case, currency (price)
  10755. * $(document).ready( function() {
  10756. * $('#example').dataTable( {
  10757. * "columnDefs": [ {
  10758. * "targets": [ 0 ],
  10759. * "data": function ( source, type, val ) {
  10760. * if (type === 'set') {
  10761. * source.price = val;
  10762. * // Store the computed dislay and filter values for efficiency
  10763. * source.price_display = val=="" ? "" : "$"+numberFormat(val);
  10764. * source.price_filter = val=="" ? "" : "$"+numberFormat(val)+" "+val;
  10765. * return;
  10766. * }
  10767. * else if (type === 'display') {
  10768. * return source.price_display;
  10769. * }
  10770. * else if (type === 'filter') {
  10771. * return source.price_filter;
  10772. * }
  10773. * // 'sort', 'type' and undefined all just use the integer
  10774. * return source.price;
  10775. * }
  10776. * } ]
  10777. * } );
  10778. * } );
  10779. *
  10780. * @example
  10781. * // Using default content
  10782. * $(document).ready( function() {
  10783. * $('#example').dataTable( {
  10784. * "columnDefs": [ {
  10785. * "targets": [ 0 ],
  10786. * "data": null,
  10787. * "defaultContent": "Click to edit"
  10788. * } ]
  10789. * } );
  10790. * } );
  10791. *
  10792. * @example
  10793. * // Using array notation - outputting a list from an array
  10794. * $(document).ready( function() {
  10795. * $('#example').dataTable( {
  10796. * "columnDefs": [ {
  10797. * "targets": [ 0 ],
  10798. * "data": "name[, ]"
  10799. * } ]
  10800. * } );
  10801. * } );
  10802. *
  10803. */
  10804. "mData": null,
  10805. /**
  10806. * This property is the rendering partner to `data` and it is suggested that
  10807. * when you want to manipulate data for display (including filtering,
  10808. * sorting etc) without altering the underlying data for the table, use this
  10809. * property. `render` can be considered to be the the read only companion to
  10810. * `data` which is read / write (then as such more complex). Like `data`
  10811. * this option can be given in a number of different ways to effect its
  10812. * behaviour:
  10813. *
  10814. * * `integer` - treated as an array index for the data source. This is the
  10815. * default that DataTables uses (incrementally increased for each column).
  10816. * * `string` - read an object property from the data source. There are
  10817. * three 'special' options that can be used in the string to alter how
  10818. * DataTables reads the data from the source object:
  10819. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10820. * Javascript to read from nested objects, so to can the options
  10821. * specified in `data`. For example: `browser.version` or
  10822. * `browser.name`. If your object parameter name contains a period, use
  10823. * `\\` to escape it - i.e. `first\\.name`.
  10824. * * `[]` - Array notation. DataTables can automatically combine data
  10825. * from and array source, joining the data with the characters provided
  10826. * between the two brackets. For example: `name[, ]` would provide a
  10827. * comma-space separated list from the source array. If no characters
  10828. * are provided between the brackets, the original array source is
  10829. * returned.
  10830. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10831. * execute a function of the name given. For example: `browser()` for a
  10832. * simple function on the data source, `browser.version()` for a
  10833. * function in a nested property or even `browser().version` to get an
  10834. * object property if the function called returns an object.
  10835. * * `object` - use different data for the different data types requested by
  10836. * DataTables ('filter', 'display', 'type' or 'sort'). The property names
  10837. * of the object is the data type the property refers to and the value can
  10838. * defined using an integer, string or function using the same rules as
  10839. * `render` normally does. Note that an `_` option _must_ be specified.
  10840. * This is the default value to use if you haven't specified a value for
  10841. * the data type requested by DataTables.
  10842. * * `function` - the function given will be executed whenever DataTables
  10843. * needs to set or get the data for a cell in the column. The function
  10844. * takes three parameters:
  10845. * * Parameters:
  10846. * * {array|object} The data source for the row (based on `data`)
  10847. * * {string} The type call data requested - this will be 'filter',
  10848. * 'display', 'type' or 'sort'.
  10849. * * {array|object} The full data source for the row (not based on
  10850. * `data`)
  10851. * * Return:
  10852. * * The return value from the function is what will be used for the
  10853. * data requested.
  10854. *
  10855. * @type string|int|function|object|null
  10856. * @default null Use the data source value.
  10857. *
  10858. * @name DataTable.defaults.column.render
  10859. * @dtopt Columns
  10860. *
  10861. * @example
  10862. * // Create a comma separated list from an array of objects
  10863. * $(document).ready( function() {
  10864. * $('#example').dataTable( {
  10865. * "ajaxSource": "sources/deep.txt",
  10866. * "columns": [
  10867. * { "data": "engine" },
  10868. * { "data": "browser" },
  10869. * {
  10870. * "data": "platform",
  10871. * "render": "[, ].name"
  10872. * }
  10873. * ]
  10874. * } );
  10875. * } );
  10876. *
  10877. * @example
  10878. * // Execute a function to obtain data
  10879. * $(document).ready( function() {
  10880. * $('#example').dataTable( {
  10881. * "columnDefs": [ {
  10882. * "targets": [ 0 ],
  10883. * "data": null, // Use the full data source object for the renderer's source
  10884. * "render": "browserName()"
  10885. * } ]
  10886. * } );
  10887. * } );
  10888. *
  10889. * @example
  10890. * // As an object, extracting different data for the different types
  10891. * // This would be used with a data source such as:
  10892. * // { "phone": 5552368, "phone_filter": "5552368 555-2368", "phone_display": "555-2368" }
  10893. * // Here the `phone` integer is used for sorting and type detection, while `phone_filter`
  10894. * // (which has both forms) is used for filtering for if a user inputs either format, while
  10895. * // the formatted phone number is the one that is shown in the table.
  10896. * $(document).ready( function() {
  10897. * $('#example').dataTable( {
  10898. * "columnDefs": [ {
  10899. * "targets": [ 0 ],
  10900. * "data": null, // Use the full data source object for the renderer's source
  10901. * "render": {
  10902. * "_": "phone",
  10903. * "filter": "phone_filter",
  10904. * "display": "phone_display"
  10905. * }
  10906. * } ]
  10907. * } );
  10908. * } );
  10909. *
  10910. * @example
  10911. * // Use as a function to create a link from the data source
  10912. * $(document).ready( function() {
  10913. * $('#example').dataTable( {
  10914. * "columnDefs": [ {
  10915. * "targets": [ 0 ],
  10916. * "data": "download_link",
  10917. * "render": function ( data, type, full ) {
  10918. * return '<a href="'+data+'">Download</a>';
  10919. * }
  10920. * } ]
  10921. * } );
  10922. * } );
  10923. */
  10924. "mRender": null,
  10925. /**
  10926. * Change the cell type created for the column - either TD cells or TH cells. This
  10927. * can be useful as TH cells have semantic meaning in the table body, allowing them
  10928. * to act as a header for a row (you may wish to add scope='row' to the TH elements).
  10929. * @type string
  10930. * @default td
  10931. *
  10932. * @name DataTable.defaults.column.cellType
  10933. * @dtopt Columns
  10934. *
  10935. * @example
  10936. * // Make the first column use TH cells
  10937. * $(document).ready( function() {
  10938. * $('#example').dataTable( {
  10939. * "columnDefs": [ {
  10940. * "targets": [ 0 ],
  10941. * "cellType": "th"
  10942. * } ]
  10943. * } );
  10944. * } );
  10945. */
  10946. "sCellType": "td",
  10947. /**
  10948. * Class to give to each cell in this column.
  10949. * @type string
  10950. * @default <i>Empty string</i>
  10951. *
  10952. * @name DataTable.defaults.column.class
  10953. * @dtopt Columns
  10954. *
  10955. * @example
  10956. * // Using `columnDefs`
  10957. * $(document).ready( function() {
  10958. * $('#example').dataTable( {
  10959. * "columnDefs": [
  10960. * { "class": "my_class", "targets": [ 0 ] }
  10961. * ]
  10962. * } );
  10963. * } );
  10964. *
  10965. * @example
  10966. * // Using `columns`
  10967. * $(document).ready( function() {
  10968. * $('#example').dataTable( {
  10969. * "columns": [
  10970. * { "class": "my_class" },
  10971. * null,
  10972. * null,
  10973. * null,
  10974. * null
  10975. * ]
  10976. * } );
  10977. * } );
  10978. */
  10979. "sClass": "",
  10980. /**
  10981. * When DataTables calculates the column widths to assign to each column,
  10982. * it finds the longest string in each column and then constructs a
  10983. * temporary table and reads the widths from that. The problem with this
  10984. * is that "mmm" is much wider then "iiii", but the latter is a longer
  10985. * string - thus the calculation can go wrong (doing it properly and putting
  10986. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  10987. * a "work around" we provide this option. It will append its value to the
  10988. * text that is found to be the longest string for the column - i.e. padding.
  10989. * Generally you shouldn't need this!
  10990. * @type string
  10991. * @default <i>Empty string<i>
  10992. *
  10993. * @name DataTable.defaults.column.contentPadding
  10994. * @dtopt Columns
  10995. *
  10996. * @example
  10997. * // Using `columns`
  10998. * $(document).ready( function() {
  10999. * $('#example').dataTable( {
  11000. * "columns": [
  11001. * null,
  11002. * null,
  11003. * null,
  11004. * {
  11005. * "contentPadding": "mmm"
  11006. * }
  11007. * ]
  11008. * } );
  11009. * } );
  11010. */
  11011. "sContentPadding": "",
  11012. /**
  11013. * Allows a default value to be given for a column's data, and will be used
  11014. * whenever a null data source is encountered (this can be because `data`
  11015. * is set to null, or because the data source itself is null).
  11016. * @type string
  11017. * @default null
  11018. *
  11019. * @name DataTable.defaults.column.defaultContent
  11020. * @dtopt Columns
  11021. *
  11022. * @example
  11023. * // Using `columnDefs`
  11024. * $(document).ready( function() {
  11025. * $('#example').dataTable( {
  11026. * "columnDefs": [
  11027. * {
  11028. * "data": null,
  11029. * "defaultContent": "Edit",
  11030. * "targets": [ -1 ]
  11031. * }
  11032. * ]
  11033. * } );
  11034. * } );
  11035. *
  11036. * @example
  11037. * // Using `columns`
  11038. * $(document).ready( function() {
  11039. * $('#example').dataTable( {
  11040. * "columns": [
  11041. * null,
  11042. * null,
  11043. * null,
  11044. * {
  11045. * "data": null,
  11046. * "defaultContent": "Edit"
  11047. * }
  11048. * ]
  11049. * } );
  11050. * } );
  11051. */
  11052. "sDefaultContent": null,
  11053. /**
  11054. * This parameter is only used in DataTables' server-side processing. It can
  11055. * be exceptionally useful to know what columns are being displayed on the
  11056. * client side, and to map these to database fields. When defined, the names
  11057. * also allow DataTables to reorder information from the server if it comes
  11058. * back in an unexpected order (i.e. if you switch your columns around on the
  11059. * client-side, your server-side code does not also need updating).
  11060. * @type string
  11061. * @default <i>Empty string</i>
  11062. *
  11063. * @name DataTable.defaults.column.name
  11064. * @dtopt Columns
  11065. *
  11066. * @example
  11067. * // Using `columnDefs`
  11068. * $(document).ready( function() {
  11069. * $('#example').dataTable( {
  11070. * "columnDefs": [
  11071. * { "name": "engine", "targets": [ 0 ] },
  11072. * { "name": "browser", "targets": [ 1 ] },
  11073. * { "name": "platform", "targets": [ 2 ] },
  11074. * { "name": "version", "targets": [ 3 ] },
  11075. * { "name": "grade", "targets": [ 4 ] }
  11076. * ]
  11077. * } );
  11078. * } );
  11079. *
  11080. * @example
  11081. * // Using `columns`
  11082. * $(document).ready( function() {
  11083. * $('#example').dataTable( {
  11084. * "columns": [
  11085. * { "name": "engine" },
  11086. * { "name": "browser" },
  11087. * { "name": "platform" },
  11088. * { "name": "version" },
  11089. * { "name": "grade" }
  11090. * ]
  11091. * } );
  11092. * } );
  11093. */
  11094. "sName": "",
  11095. /**
  11096. * Defines a data source type for the ordering which can be used to read
  11097. * real-time information from the table (updating the internally cached
  11098. * version) prior to ordering. This allows ordering to occur on user
  11099. * editable elements such as form inputs.
  11100. * @type string
  11101. * @default std
  11102. *
  11103. * @name DataTable.defaults.column.orderDataType
  11104. * @dtopt Columns
  11105. *
  11106. * @example
  11107. * // Using `columnDefs`
  11108. * $(document).ready( function() {
  11109. * $('#example').dataTable( {
  11110. * "columnDefs": [
  11111. * { "orderDataType": "dom-text", "targets": [ 2, 3 ] },
  11112. * { "type": "numeric", "targets": [ 3 ] },
  11113. * { "orderDataType": "dom-select", "targets": [ 4 ] },
  11114. * { "orderDataType": "dom-checkbox", "targets": [ 5 ] }
  11115. * ]
  11116. * } );
  11117. * } );
  11118. *
  11119. * @example
  11120. * // Using `columns`
  11121. * $(document).ready( function() {
  11122. * $('#example').dataTable( {
  11123. * "columns": [
  11124. * null,
  11125. * null,
  11126. * { "orderDataType": "dom-text" },
  11127. * { "orderDataType": "dom-text", "type": "numeric" },
  11128. * { "orderDataType": "dom-select" },
  11129. * { "orderDataType": "dom-checkbox" }
  11130. * ]
  11131. * } );
  11132. * } );
  11133. */
  11134. "sSortDataType": "std",
  11135. /**
  11136. * The title of this column.
  11137. * @type string
  11138. * @default null <i>Derived from the 'TH' value for this column in the
  11139. * original HTML table.</i>
  11140. *
  11141. * @name DataTable.defaults.column.title
  11142. * @dtopt Columns
  11143. *
  11144. * @example
  11145. * // Using `columnDefs`
  11146. * $(document).ready( function() {
  11147. * $('#example').dataTable( {
  11148. * "columnDefs": [
  11149. * { "title": "My column title", "targets": [ 0 ] }
  11150. * ]
  11151. * } );
  11152. * } );
  11153. *
  11154. * @example
  11155. * // Using `columns`
  11156. * $(document).ready( function() {
  11157. * $('#example').dataTable( {
  11158. * "columns": [
  11159. * { "title": "My column title" },
  11160. * null,
  11161. * null,
  11162. * null,
  11163. * null
  11164. * ]
  11165. * } );
  11166. * } );
  11167. */
  11168. "sTitle": null,
  11169. /**
  11170. * The type allows you to specify how the data for this column will be
  11171. * ordered. Four types (string, numeric, date and html (which will strip
  11172. * HTML tags before ordering)) are currently available. Note that only date
  11173. * formats understood by Javascript's Date() object will be accepted as type
  11174. * date. For example: "Mar 26, 2008 5:03 PM". May take the values: 'string',
  11175. * 'numeric', 'date' or 'html' (by default). Further types can be adding
  11176. * through plug-ins.
  11177. * @type string
  11178. * @default null <i>Auto-detected from raw data</i>
  11179. *
  11180. * @name DataTable.defaults.column.type
  11181. * @dtopt Columns
  11182. *
  11183. * @example
  11184. * // Using `columnDefs`
  11185. * $(document).ready( function() {
  11186. * $('#example').dataTable( {
  11187. * "columnDefs": [
  11188. * { "type": "html", "targets": [ 0 ] }
  11189. * ]
  11190. * } );
  11191. * } );
  11192. *
  11193. * @example
  11194. * // Using `columns`
  11195. * $(document).ready( function() {
  11196. * $('#example').dataTable( {
  11197. * "columns": [
  11198. * { "type": "html" },
  11199. * null,
  11200. * null,
  11201. * null,
  11202. * null
  11203. * ]
  11204. * } );
  11205. * } );
  11206. */
  11207. "sType": null,
  11208. /**
  11209. * Defining the width of the column, this parameter may take any CSS value
  11210. * (3em, 20px etc). DataTables applies 'smart' widths to columns which have not
  11211. * been given a specific width through this interface ensuring that the table
  11212. * remains readable.
  11213. * @type string
  11214. * @default null <i>Automatic</i>
  11215. *
  11216. * @name DataTable.defaults.column.width
  11217. * @dtopt Columns
  11218. *
  11219. * @example
  11220. * // Using `columnDefs`
  11221. * $(document).ready( function() {
  11222. * $('#example').dataTable( {
  11223. * "columnDefs": [
  11224. * { "width": "20%", "targets": [ 0 ] }
  11225. * ]
  11226. * } );
  11227. * } );
  11228. *
  11229. * @example
  11230. * // Using `columns`
  11231. * $(document).ready( function() {
  11232. * $('#example').dataTable( {
  11233. * "columns": [
  11234. * { "width": "20%" },
  11235. * null,
  11236. * null,
  11237. * null,
  11238. * null
  11239. * ]
  11240. * } );
  11241. * } );
  11242. */
  11243. "sWidth": null
  11244. };
  11245. _fnHungarianMap( DataTable.defaults.column );
  11246. /**
  11247. * DataTables settings object - this holds all the information needed for a
  11248. * given table, including configuration, data and current application of the
  11249. * table options. DataTables does not have a single instance for each DataTable
  11250. * with the settings attached to that instance, but rather instances of the
  11251. * DataTable "class" are created on-the-fly as needed (typically by a
  11252. * $().dataTable() call) and the settings object is then applied to that
  11253. * instance.
  11254. *
  11255. * Note that this object is related to {@link DataTable.defaults} but this
  11256. * one is the internal data store for DataTables's cache of columns. It should
  11257. * NOT be manipulated outside of DataTables. Any configuration should be done
  11258. * through the initialisation options.
  11259. * @namespace
  11260. * @todo Really should attach the settings object to individual instances so we
  11261. * don't need to create new instances on each $().dataTable() call (if the
  11262. * table already exists). It would also save passing oSettings around and
  11263. * into every single function. However, this is a very significant
  11264. * architecture change for DataTables and will almost certainly break
  11265. * backwards compatibility with older installations. This is something that
  11266. * will be done in 2.0.
  11267. */
  11268. DataTable.models.oSettings = {
  11269. /**
  11270. * Primary features of DataTables and their enablement state.
  11271. * @namespace
  11272. */
  11273. "oFeatures": {
  11274. /**
  11275. * Flag to say if DataTables should automatically try to calculate the
  11276. * optimum table and columns widths (true) or not (false).
  11277. * Note that this parameter will be set by the initialisation routine. To
  11278. * set a default use {@link DataTable.defaults}.
  11279. * @type boolean
  11280. */
  11281. "bAutoWidth": null,
  11282. /**
  11283. * Delay the creation of TR and TD elements until they are actually
  11284. * needed by a driven page draw. This can give a significant speed
  11285. * increase for Ajax source and Javascript source data, but makes no
  11286. * difference at all fro DOM and server-side processing tables.
  11287. * Note that this parameter will be set by the initialisation routine. To
  11288. * set a default use {@link DataTable.defaults}.
  11289. * @type boolean
  11290. */
  11291. "bDeferRender": null,
  11292. /**
  11293. * Enable filtering on the table or not. Note that if this is disabled
  11294. * then there is no filtering at all on the table, including fnFilter.
  11295. * To just remove the filtering input use sDom and remove the 'f' option.
  11296. * Note that this parameter will be set by the initialisation routine. To
  11297. * set a default use {@link DataTable.defaults}.
  11298. * @type boolean
  11299. */
  11300. "bFilter": null,
  11301. /**
  11302. * Table information element (the 'Showing x of y records' div) enable
  11303. * flag.
  11304. * Note that this parameter will be set by the initialisation routine. To
  11305. * set a default use {@link DataTable.defaults}.
  11306. * @type boolean
  11307. */
  11308. "bInfo": null,
  11309. /**
  11310. * Present a user control allowing the end user to change the page size
  11311. * when pagination is enabled.
  11312. * Note that this parameter will be set by the initialisation routine. To
  11313. * set a default use {@link DataTable.defaults}.
  11314. * @type boolean
  11315. */
  11316. "bLengthChange": null,
  11317. /**
  11318. * Pagination enabled or not. Note that if this is disabled then length
  11319. * changing must also be disabled.
  11320. * Note that this parameter will be set by the initialisation routine. To
  11321. * set a default use {@link DataTable.defaults}.
  11322. * @type boolean
  11323. */
  11324. "bPaginate": null,
  11325. /**
  11326. * Processing indicator enable flag whenever DataTables is enacting a
  11327. * user request - typically an Ajax request for server-side processing.
  11328. * Note that this parameter will be set by the initialisation routine. To
  11329. * set a default use {@link DataTable.defaults}.
  11330. * @type boolean
  11331. */
  11332. "bProcessing": null,
  11333. /**
  11334. * Server-side processing enabled flag - when enabled DataTables will
  11335. * get all data from the server for every draw - there is no filtering,
  11336. * sorting or paging done on the client-side.
  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. "bServerSide": null,
  11342. /**
  11343. * Sorting enablement flag.
  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. "bSort": null,
  11349. /**
  11350. * Multi-column sorting
  11351. * Note that this parameter will be set by the initialisation routine. To
  11352. * set a default use {@link DataTable.defaults}.
  11353. * @type boolean
  11354. */
  11355. "bSortMulti": null,
  11356. /**
  11357. * Apply a class to the columns which are being sorted to provide a
  11358. * visual highlight or not. This can slow things down when enabled since
  11359. * there is a lot of DOM interaction.
  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. "bSortClasses": null,
  11365. /**
  11366. * State saving enablement flag.
  11367. * Note that this parameter will be set by the initialisation routine. To
  11368. * set a default use {@link DataTable.defaults}.
  11369. * @type boolean
  11370. */
  11371. "bStateSave": null
  11372. },
  11373. /**
  11374. * Scrolling settings for a table.
  11375. * @namespace
  11376. */
  11377. "oScroll": {
  11378. /**
  11379. * When the table is shorter in height than sScrollY, collapse the
  11380. * table container down to the height of the table (when true).
  11381. * Note that this parameter will be set by the initialisation routine. To
  11382. * set a default use {@link DataTable.defaults}.
  11383. * @type boolean
  11384. */
  11385. "bCollapse": null,
  11386. /**
  11387. * Width of the scrollbar for the web-browser's platform. Calculated
  11388. * during table initialisation.
  11389. * @type int
  11390. * @default 0
  11391. */
  11392. "iBarWidth": 0,
  11393. /**
  11394. * Viewport width for horizontal scrolling. Horizontal scrolling is
  11395. * disabled if an empty string.
  11396. * Note that this parameter will be set by the initialisation routine. To
  11397. * set a default use {@link DataTable.defaults}.
  11398. * @type string
  11399. */
  11400. "sX": null,
  11401. /**
  11402. * Width to expand the table to when using x-scrolling. Typically you
  11403. * should not need to use this.
  11404. * Note that this parameter will be set by the initialisation routine. To
  11405. * set a default use {@link DataTable.defaults}.
  11406. * @type string
  11407. * @deprecated
  11408. */
  11409. "sXInner": null,
  11410. /**
  11411. * Viewport height for vertical scrolling. Vertical scrolling is disabled
  11412. * if an empty string.
  11413. * Note that this parameter will be set by the initialisation routine. To
  11414. * set a default use {@link DataTable.defaults}.
  11415. * @type string
  11416. */
  11417. "sY": null
  11418. },
  11419. /**
  11420. * Language information for the table.
  11421. * @namespace
  11422. * @extends DataTable.defaults.oLanguage
  11423. */
  11424. "oLanguage": {
  11425. /**
  11426. * Information callback function. See
  11427. * {@link DataTable.defaults.fnInfoCallback}
  11428. * @type function
  11429. * @default null
  11430. */
  11431. "fnInfoCallback": null
  11432. },
  11433. /**
  11434. * Browser support parameters
  11435. * @namespace
  11436. */
  11437. "oBrowser": {
  11438. /**
  11439. * Indicate if the browser incorrectly calculates width:100% inside a
  11440. * scrolling element (IE6/7)
  11441. * @type boolean
  11442. * @default false
  11443. */
  11444. "bScrollOversize": false,
  11445. /**
  11446. * Determine if the vertical scrollbar is on the right or left of the
  11447. * scrolling container - needed for rtl language layout, although not
  11448. * all browsers move the scrollbar (Safari).
  11449. * @type boolean
  11450. * @default false
  11451. */
  11452. "bScrollbarLeft": false,
  11453. /**
  11454. * Flag for if `getBoundingClientRect` is fully supported or not
  11455. * @type boolean
  11456. * @default false
  11457. */
  11458. "bBounding": false,
  11459. /**
  11460. * Browser scrollbar width
  11461. * @type integer
  11462. * @default 0
  11463. */
  11464. "barWidth": 0
  11465. },
  11466. "ajax": null,
  11467. /**
  11468. * Array referencing the nodes which are used for the features. The
  11469. * parameters of this object match what is allowed by sDom - i.e.
  11470. * <ul>
  11471. * <li>'l' - Length changing</li>
  11472. * <li>'f' - Filtering input</li>
  11473. * <li>'t' - The table!</li>
  11474. * <li>'i' - Information</li>
  11475. * <li>'p' - Pagination</li>
  11476. * <li>'r' - pRocessing</li>
  11477. * </ul>
  11478. * @type array
  11479. * @default []
  11480. */
  11481. "aanFeatures": [],
  11482. /**
  11483. * Store data information - see {@link DataTable.models.oRow} for detailed
  11484. * information.
  11485. * @type array
  11486. * @default []
  11487. */
  11488. "aoData": [],
  11489. /**
  11490. * Array of indexes which are in the current display (after filtering etc)
  11491. * @type array
  11492. * @default []
  11493. */
  11494. "aiDisplay": [],
  11495. /**
  11496. * Array of indexes for display - no filtering
  11497. * @type array
  11498. * @default []
  11499. */
  11500. "aiDisplayMaster": [],
  11501. /**
  11502. * Map of row ids to data indexes
  11503. * @type object
  11504. * @default {}
  11505. */
  11506. "aIds": {},
  11507. /**
  11508. * Store information about each column that is in use
  11509. * @type array
  11510. * @default []
  11511. */
  11512. "aoColumns": [],
  11513. /**
  11514. * Store information about the table's header
  11515. * @type array
  11516. * @default []
  11517. */
  11518. "aoHeader": [],
  11519. /**
  11520. * Store information about the table's footer
  11521. * @type array
  11522. * @default []
  11523. */
  11524. "aoFooter": [],
  11525. /**
  11526. * Store the applied global search information in case we want to force a
  11527. * research or compare the old search to a new one.
  11528. * Note that this parameter will be set by the initialisation routine. To
  11529. * set a default use {@link DataTable.defaults}.
  11530. * @namespace
  11531. * @extends DataTable.models.oSearch
  11532. */
  11533. "oPreviousSearch": {},
  11534. /**
  11535. * Store the applied search for each column - see
  11536. * {@link DataTable.models.oSearch} for the format that is used for the
  11537. * filtering information for each column.
  11538. * @type array
  11539. * @default []
  11540. */
  11541. "aoPreSearchCols": [],
  11542. /**
  11543. * Sorting that is applied to the table. Note that the inner arrays are
  11544. * used in the following manner:
  11545. * <ul>
  11546. * <li>Index 0 - column number</li>
  11547. * <li>Index 1 - current sorting direction</li>
  11548. * </ul>
  11549. * Note that this parameter will be set by the initialisation routine. To
  11550. * set a default use {@link DataTable.defaults}.
  11551. * @type array
  11552. * @todo These inner arrays should really be objects
  11553. */
  11554. "aaSorting": null,
  11555. /**
  11556. * Sorting that is always applied to the table (i.e. prefixed in front of
  11557. * aaSorting).
  11558. * Note that this parameter will be set by the initialisation routine. To
  11559. * set a default use {@link DataTable.defaults}.
  11560. * @type array
  11561. * @default []
  11562. */
  11563. "aaSortingFixed": [],
  11564. /**
  11565. * Classes to use for the striping of a table.
  11566. * Note that this parameter will be set by the initialisation routine. To
  11567. * set a default use {@link DataTable.defaults}.
  11568. * @type array
  11569. * @default []
  11570. */
  11571. "asStripeClasses": null,
  11572. /**
  11573. * If restoring a table - we should restore its striping classes as well
  11574. * @type array
  11575. * @default []
  11576. */
  11577. "asDestroyStripes": [],
  11578. /**
  11579. * If restoring a table - we should restore its width
  11580. * @type int
  11581. * @default 0
  11582. */
  11583. "sDestroyWidth": 0,
  11584. /**
  11585. * Callback functions array for every time a row is inserted (i.e. on a draw).
  11586. * @type array
  11587. * @default []
  11588. */
  11589. "aoRowCallback": [],
  11590. /**
  11591. * Callback functions for the header on each draw.
  11592. * @type array
  11593. * @default []
  11594. */
  11595. "aoHeaderCallback": [],
  11596. /**
  11597. * Callback function for the footer on each draw.
  11598. * @type array
  11599. * @default []
  11600. */
  11601. "aoFooterCallback": [],
  11602. /**
  11603. * Array of callback functions for draw callback functions
  11604. * @type array
  11605. * @default []
  11606. */
  11607. "aoDrawCallback": [],
  11608. /**
  11609. * Array of callback functions for row created function
  11610. * @type array
  11611. * @default []
  11612. */
  11613. "aoRowCreatedCallback": [],
  11614. /**
  11615. * Callback functions for just before the table is redrawn. A return of
  11616. * false will be used to cancel the draw.
  11617. * @type array
  11618. * @default []
  11619. */
  11620. "aoPreDrawCallback": [],
  11621. /**
  11622. * Callback functions for when the table has been initialised.
  11623. * @type array
  11624. * @default []
  11625. */
  11626. "aoInitComplete": [],
  11627. /**
  11628. * Callbacks for modifying the settings to be stored for state saving, prior to
  11629. * saving state.
  11630. * @type array
  11631. * @default []
  11632. */
  11633. "aoStateSaveParams": [],
  11634. /**
  11635. * Callbacks for modifying the settings that have been stored for state saving
  11636. * prior to using the stored values to restore the state.
  11637. * @type array
  11638. * @default []
  11639. */
  11640. "aoStateLoadParams": [],
  11641. /**
  11642. * Callbacks for operating on the settings object once the saved state has been
  11643. * loaded
  11644. * @type array
  11645. * @default []
  11646. */
  11647. "aoStateLoaded": [],
  11648. /**
  11649. * Cache the table ID for quick access
  11650. * @type string
  11651. * @default <i>Empty string</i>
  11652. */
  11653. "sTableId": "",
  11654. /**
  11655. * The TABLE node for the main table
  11656. * @type node
  11657. * @default null
  11658. */
  11659. "nTable": null,
  11660. /**
  11661. * Permanent ref to the thead element
  11662. * @type node
  11663. * @default null
  11664. */
  11665. "nTHead": null,
  11666. /**
  11667. * Permanent ref to the tfoot element - if it exists
  11668. * @type node
  11669. * @default null
  11670. */
  11671. "nTFoot": null,
  11672. /**
  11673. * Permanent ref to the tbody element
  11674. * @type node
  11675. * @default null
  11676. */
  11677. "nTBody": null,
  11678. /**
  11679. * Cache the wrapper node (contains all DataTables controlled elements)
  11680. * @type node
  11681. * @default null
  11682. */
  11683. "nTableWrapper": null,
  11684. /**
  11685. * Indicate if when using server-side processing the loading of data
  11686. * should be deferred until the second draw.
  11687. * Note that this parameter will be set by the initialisation routine. To
  11688. * set a default use {@link DataTable.defaults}.
  11689. * @type boolean
  11690. * @default false
  11691. */
  11692. "bDeferLoading": false,
  11693. /**
  11694. * Indicate if all required information has been read in
  11695. * @type boolean
  11696. * @default false
  11697. */
  11698. "bInitialised": false,
  11699. /**
  11700. * Information about open rows. Each object in the array has the parameters
  11701. * 'nTr' and 'nParent'
  11702. * @type array
  11703. * @default []
  11704. */
  11705. "aoOpenRows": [],
  11706. /**
  11707. * Dictate the positioning of DataTables' control elements - see
  11708. * {@link DataTable.model.oInit.sDom}.
  11709. * Note that this parameter will be set by the initialisation routine. To
  11710. * set a default use {@link DataTable.defaults}.
  11711. * @type string
  11712. * @default null
  11713. */
  11714. "sDom": null,
  11715. /**
  11716. * Search delay (in mS)
  11717. * @type integer
  11718. * @default null
  11719. */
  11720. "searchDelay": null,
  11721. /**
  11722. * Which type of pagination should be used.
  11723. * Note that this parameter will be set by the initialisation routine. To
  11724. * set a default use {@link DataTable.defaults}.
  11725. * @type string
  11726. * @default two_button
  11727. */
  11728. "sPaginationType": "two_button",
  11729. /**
  11730. * The state duration (for `stateSave`) in seconds.
  11731. * Note that this parameter will be set by the initialisation routine. To
  11732. * set a default use {@link DataTable.defaults}.
  11733. * @type int
  11734. * @default 0
  11735. */
  11736. "iStateDuration": 0,
  11737. /**
  11738. * Array of callback functions for state saving. Each array element is an
  11739. * object with the following parameters:
  11740. * <ul>
  11741. * <li>function:fn - function to call. Takes two parameters, oSettings
  11742. * and the JSON string to save that has been thus far created. Returns
  11743. * a JSON string to be inserted into a json object
  11744. * (i.e. '"param": [ 0, 1, 2]')</li>
  11745. * <li>string:sName - name of callback</li>
  11746. * </ul>
  11747. * @type array
  11748. * @default []
  11749. */
  11750. "aoStateSave": [],
  11751. /**
  11752. * Array of callback functions for state loading. Each array element is an
  11753. * object with the following parameters:
  11754. * <ul>
  11755. * <li>function:fn - function to call. Takes two parameters, oSettings
  11756. * and the object stored. May return false to cancel state loading</li>
  11757. * <li>string:sName - name of callback</li>
  11758. * </ul>
  11759. * @type array
  11760. * @default []
  11761. */
  11762. "aoStateLoad": [],
  11763. /**
  11764. * State that was saved. Useful for back reference
  11765. * @type object
  11766. * @default null
  11767. */
  11768. "oSavedState": null,
  11769. /**
  11770. * State that was loaded. Useful for back reference
  11771. * @type object
  11772. * @default null
  11773. */
  11774. "oLoadedState": null,
  11775. /**
  11776. * Source url for AJAX data for the table.
  11777. * Note that this parameter will be set by the initialisation routine. To
  11778. * set a default use {@link DataTable.defaults}.
  11779. * @type string
  11780. * @default null
  11781. */
  11782. "sAjaxSource": null,
  11783. /**
  11784. * Property from a given object from which to read the table data from. This
  11785. * can be an empty string (when not server-side processing), in which case
  11786. * it is assumed an an array is given directly.
  11787. * Note that this parameter will be set by the initialisation routine. To
  11788. * set a default use {@link DataTable.defaults}.
  11789. * @type string
  11790. */
  11791. "sAjaxDataProp": null,
  11792. /**
  11793. * Note if draw should be blocked while getting data
  11794. * @type boolean
  11795. * @default true
  11796. */
  11797. "bAjaxDataGet": true,
  11798. /**
  11799. * The last jQuery XHR object that was used for server-side data gathering.
  11800. * This can be used for working with the XHR information in one of the
  11801. * callbacks
  11802. * @type object
  11803. * @default null
  11804. */
  11805. "jqXHR": null,
  11806. /**
  11807. * JSON returned from the server in the last Ajax request
  11808. * @type object
  11809. * @default undefined
  11810. */
  11811. "json": undefined,
  11812. /**
  11813. * Data submitted as part of the last Ajax request
  11814. * @type object
  11815. * @default undefined
  11816. */
  11817. "oAjaxData": undefined,
  11818. /**
  11819. * Function to get the server-side data.
  11820. * Note that this parameter will be set by the initialisation routine. To
  11821. * set a default use {@link DataTable.defaults}.
  11822. * @type function
  11823. */
  11824. "fnServerData": null,
  11825. /**
  11826. * Functions which are called prior to sending an Ajax request so extra
  11827. * parameters can easily be sent to the server
  11828. * @type array
  11829. * @default []
  11830. */
  11831. "aoServerParams": [],
  11832. /**
  11833. * Send the XHR HTTP method - GET or POST (could be PUT or DELETE if
  11834. * required).
  11835. * Note that this parameter will be set by the initialisation routine. To
  11836. * set a default use {@link DataTable.defaults}.
  11837. * @type string
  11838. */
  11839. "sServerMethod": null,
  11840. /**
  11841. * Format numbers for display.
  11842. * Note that this parameter will be set by the initialisation routine. To
  11843. * set a default use {@link DataTable.defaults}.
  11844. * @type function
  11845. */
  11846. "fnFormatNumber": null,
  11847. /**
  11848. * List of options that can be used for the user selectable length menu.
  11849. * Note that this parameter will be set by the initialisation routine. To
  11850. * set a default use {@link DataTable.defaults}.
  11851. * @type array
  11852. * @default []
  11853. */
  11854. "aLengthMenu": null,
  11855. /**
  11856. * Counter for the draws that the table does. Also used as a tracker for
  11857. * server-side processing
  11858. * @type int
  11859. * @default 0
  11860. */
  11861. "iDraw": 0,
  11862. /**
  11863. * Indicate if a redraw is being done - useful for Ajax
  11864. * @type boolean
  11865. * @default false
  11866. */
  11867. "bDrawing": false,
  11868. /**
  11869. * Draw index (iDraw) of the last error when parsing the returned data
  11870. * @type int
  11871. * @default -1
  11872. */
  11873. "iDrawError": -1,
  11874. /**
  11875. * Paging display length
  11876. * @type int
  11877. * @default 10
  11878. */
  11879. "_iDisplayLength": 10,
  11880. /**
  11881. * Paging start point - aiDisplay index
  11882. * @type int
  11883. * @default 0
  11884. */
  11885. "_iDisplayStart": 0,
  11886. /**
  11887. * Server-side processing - number of records in the result set
  11888. * (i.e. before filtering), Use fnRecordsTotal rather than
  11889. * this property to get the value of the number of records, regardless of
  11890. * the server-side processing setting.
  11891. * @type int
  11892. * @default 0
  11893. * @private
  11894. */
  11895. "_iRecordsTotal": 0,
  11896. /**
  11897. * Server-side processing - number of records in the current display set
  11898. * (i.e. after filtering). Use fnRecordsDisplay rather than
  11899. * this property to get the value of the number of records, regardless of
  11900. * the server-side processing setting.
  11901. * @type boolean
  11902. * @default 0
  11903. * @private
  11904. */
  11905. "_iRecordsDisplay": 0,
  11906. /**
  11907. * The classes to use for the table
  11908. * @type object
  11909. * @default {}
  11910. */
  11911. "oClasses": {},
  11912. /**
  11913. * Flag attached to the settings object so you can check in the draw
  11914. * callback if filtering has been done in the draw. Deprecated in favour of
  11915. * events.
  11916. * @type boolean
  11917. * @default false
  11918. * @deprecated
  11919. */
  11920. "bFiltered": false,
  11921. /**
  11922. * Flag attached to the settings object so you can check in the draw
  11923. * callback if sorting has been done in the draw. Deprecated in favour of
  11924. * events.
  11925. * @type boolean
  11926. * @default false
  11927. * @deprecated
  11928. */
  11929. "bSorted": false,
  11930. /**
  11931. * Indicate that if multiple rows are in the header and there is more than
  11932. * one unique cell per column, if the top one (true) or bottom one (false)
  11933. * should be used for sorting / title by DataTables.
  11934. * Note that this parameter will be set by the initialisation routine. To
  11935. * set a default use {@link DataTable.defaults}.
  11936. * @type boolean
  11937. */
  11938. "bSortCellsTop": null,
  11939. /**
  11940. * Initialisation object that is used for the table
  11941. * @type object
  11942. * @default null
  11943. */
  11944. "oInit": null,
  11945. /**
  11946. * Destroy callback functions - for plug-ins to attach themselves to the
  11947. * destroy so they can clean up markup and events.
  11948. * @type array
  11949. * @default []
  11950. */
  11951. "aoDestroyCallback": [],
  11952. /**
  11953. * Get the number of records in the current record set, before filtering
  11954. * @type function
  11955. */
  11956. "fnRecordsTotal": function ()
  11957. {
  11958. return _fnDataSource( this ) == 'ssp' ?
  11959. this._iRecordsTotal * 1 :
  11960. this.aiDisplayMaster.length;
  11961. },
  11962. /**
  11963. * Get the number of records in the current record set, after filtering
  11964. * @type function
  11965. */
  11966. "fnRecordsDisplay": function ()
  11967. {
  11968. return _fnDataSource( this ) == 'ssp' ?
  11969. this._iRecordsDisplay * 1 :
  11970. this.aiDisplay.length;
  11971. },
  11972. /**
  11973. * Get the display end point - aiDisplay index
  11974. * @type function
  11975. */
  11976. "fnDisplayEnd": function ()
  11977. {
  11978. var
  11979. len = this._iDisplayLength,
  11980. start = this._iDisplayStart,
  11981. calc = start + len,
  11982. records = this.aiDisplay.length,
  11983. features = this.oFeatures,
  11984. paginate = features.bPaginate;
  11985. if ( features.bServerSide ) {
  11986. return paginate === false || len === -1 ?
  11987. start + records :
  11988. Math.min( start+len, this._iRecordsDisplay );
  11989. }
  11990. else {
  11991. return ! paginate || calc>records || len===-1 ?
  11992. records :
  11993. calc;
  11994. }
  11995. },
  11996. /**
  11997. * The DataTables object for this table
  11998. * @type object
  11999. * @default null
  12000. */
  12001. "oInstance": null,
  12002. /**
  12003. * Unique identifier for each instance of the DataTables object. If there
  12004. * is an ID on the table node, then it takes that value, otherwise an
  12005. * incrementing internal counter is used.
  12006. * @type string
  12007. * @default null
  12008. */
  12009. "sInstance": null,
  12010. /**
  12011. * tabindex attribute value that is added to DataTables control elements, allowing
  12012. * keyboard navigation of the table and its controls.
  12013. */
  12014. "iTabIndex": 0,
  12015. /**
  12016. * DIV container for the footer scrolling table if scrolling
  12017. */
  12018. "nScrollHead": null,
  12019. /**
  12020. * DIV container for the footer scrolling table if scrolling
  12021. */
  12022. "nScrollFoot": null,
  12023. /**
  12024. * Last applied sort
  12025. * @type array
  12026. * @default []
  12027. */
  12028. "aLastSort": [],
  12029. /**
  12030. * Stored plug-in instances
  12031. * @type object
  12032. * @default {}
  12033. */
  12034. "oPlugins": {},
  12035. /**
  12036. * Function used to get a row's id from the row's data
  12037. * @type function
  12038. * @default null
  12039. */
  12040. "rowIdFn": null,
  12041. /**
  12042. * Data location where to store a row's id
  12043. * @type string
  12044. * @default null
  12045. */
  12046. "rowId": null
  12047. };
  12048. /**
  12049. * Extension object for DataTables that is used to provide all extension
  12050. * options.
  12051. *
  12052. * Note that the `DataTable.ext` object is available through
  12053. * `jQuery.fn.dataTable.ext` where it may be accessed and manipulated. It is
  12054. * also aliased to `jQuery.fn.dataTableExt` for historic reasons.
  12055. * @namespace
  12056. * @extends DataTable.models.ext
  12057. */
  12058. /**
  12059. * DataTables extensions
  12060. *
  12061. * This namespace acts as a collection area for plug-ins that can be used to
  12062. * extend DataTables capabilities. Indeed many of the build in methods
  12063. * use this method to provide their own capabilities (sorting methods for
  12064. * example).
  12065. *
  12066. * Note that this namespace is aliased to `jQuery.fn.dataTableExt` for legacy
  12067. * reasons
  12068. *
  12069. * @namespace
  12070. */
  12071. DataTable.ext = _ext = {
  12072. /**
  12073. * Buttons. For use with the Buttons extension for DataTables. This is
  12074. * defined here so other extensions can define buttons regardless of load
  12075. * order. It is _not_ used by DataTables core.
  12076. *
  12077. * @type object
  12078. * @default {}
  12079. */
  12080. buttons: {},
  12081. /**
  12082. * Element class names
  12083. *
  12084. * @type object
  12085. * @default {}
  12086. */
  12087. classes: {},
  12088. /**
  12089. * DataTables build type (expanded by the download builder)
  12090. *
  12091. * @type string
  12092. */
  12093. builder: "-source-",
  12094. /**
  12095. * Error reporting.
  12096. *
  12097. * How should DataTables report an error. Can take the value 'alert',
  12098. * 'throw', 'none' or a function.
  12099. *
  12100. * @type string|function
  12101. * @default alert
  12102. */
  12103. errMode: "alert",
  12104. /**
  12105. * Feature plug-ins.
  12106. *
  12107. * This is an array of objects which describe the feature plug-ins that are
  12108. * available to DataTables. These feature plug-ins are then available for
  12109. * use through the `dom` initialisation option.
  12110. *
  12111. * Each feature plug-in is described by an object which must have the
  12112. * following properties:
  12113. *
  12114. * * `fnInit` - function that is used to initialise the plug-in,
  12115. * * `cFeature` - a character so the feature can be enabled by the `dom`
  12116. * instillation option. This is case sensitive.
  12117. *
  12118. * The `fnInit` function has the following input parameters:
  12119. *
  12120. * 1. `{object}` DataTables settings object: see
  12121. * {@link DataTable.models.oSettings}
  12122. *
  12123. * And the following return is expected:
  12124. *
  12125. * * {node|null} The element which contains your feature. Note that the
  12126. * return may also be void if your plug-in does not require to inject any
  12127. * DOM elements into DataTables control (`dom`) - for example this might
  12128. * be useful when developing a plug-in which allows table control via
  12129. * keyboard entry
  12130. *
  12131. * @type array
  12132. *
  12133. * @example
  12134. * $.fn.dataTable.ext.features.push( {
  12135. * "fnInit": function( oSettings ) {
  12136. * return new TableTools( { "oDTSettings": oSettings } );
  12137. * },
  12138. * "cFeature": "T"
  12139. * } );
  12140. */
  12141. feature: [],
  12142. /**
  12143. * Row searching.
  12144. *
  12145. * This method of searching is complimentary to the default type based
  12146. * searching, and a lot more comprehensive as it allows you complete control
  12147. * over the searching logic. Each element in this array is a function
  12148. * (parameters described below) that is called for every row in the table,
  12149. * and your logic decides if it should be included in the searching data set
  12150. * or not.
  12151. *
  12152. * Searching functions have the following input parameters:
  12153. *
  12154. * 1. `{object}` DataTables settings object: see
  12155. * {@link DataTable.models.oSettings}
  12156. * 2. `{array|object}` Data for the row to be processed (same as the
  12157. * original format that was passed in as the data source, or an array
  12158. * from a DOM data source
  12159. * 3. `{int}` Row index ({@link DataTable.models.oSettings.aoData}), which
  12160. * can be useful to retrieve the `TR` element if you need DOM interaction.
  12161. *
  12162. * And the following return is expected:
  12163. *
  12164. * * {boolean} Include the row in the searched result set (true) or not
  12165. * (false)
  12166. *
  12167. * Note that as with the main search ability in DataTables, technically this
  12168. * is "filtering", since it is subtractive. However, for consistency in
  12169. * naming we call it searching here.
  12170. *
  12171. * @type array
  12172. * @default []
  12173. *
  12174. * @example
  12175. * // The following example shows custom search being applied to the
  12176. * // fourth column (i.e. the data[3] index) based on two input values
  12177. * // from the end-user, matching the data in a certain range.
  12178. * $.fn.dataTable.ext.search.push(
  12179. * function( settings, data, dataIndex ) {
  12180. * var min = document.getElementById('min').value * 1;
  12181. * var max = document.getElementById('max').value * 1;
  12182. * var version = data[3] == "-" ? 0 : data[3]*1;
  12183. *
  12184. * if ( min == "" && max == "" ) {
  12185. * return true;
  12186. * }
  12187. * else if ( min == "" && version < max ) {
  12188. * return true;
  12189. * }
  12190. * else if ( min < version && "" == max ) {
  12191. * return true;
  12192. * }
  12193. * else if ( min < version && version < max ) {
  12194. * return true;
  12195. * }
  12196. * return false;
  12197. * }
  12198. * );
  12199. */
  12200. search: [],
  12201. /**
  12202. * Selector extensions
  12203. *
  12204. * The `selector` option can be used to extend the options available for the
  12205. * selector modifier options (`selector-modifier` object data type) that
  12206. * each of the three built in selector types offer (row, column and cell +
  12207. * their plural counterparts). For example the Select extension uses this
  12208. * mechanism to provide an option to select only rows, columns and cells
  12209. * that have been marked as selected by the end user (`{selected: true}`),
  12210. * which can be used in conjunction with the existing built in selector
  12211. * options.
  12212. *
  12213. * Each property is an array to which functions can be pushed. The functions
  12214. * take three attributes:
  12215. *
  12216. * * Settings object for the host table
  12217. * * Options object (`selector-modifier` object type)
  12218. * * Array of selected item indexes
  12219. *
  12220. * The return is an array of the resulting item indexes after the custom
  12221. * selector has been applied.
  12222. *
  12223. * @type object
  12224. */
  12225. selector: {
  12226. cell: [],
  12227. column: [],
  12228. row: []
  12229. },
  12230. /**
  12231. * Internal functions, exposed for used in plug-ins.
  12232. *
  12233. * Please note that you should not need to use the internal methods for
  12234. * anything other than a plug-in (and even then, try to avoid if possible).
  12235. * The internal function may change between releases.
  12236. *
  12237. * @type object
  12238. * @default {}
  12239. */
  12240. internal: {},
  12241. /**
  12242. * Legacy configuration options. Enable and disable legacy options that
  12243. * are available in DataTables.
  12244. *
  12245. * @type object
  12246. */
  12247. legacy: {
  12248. /**
  12249. * Enable / disable DataTables 1.9 compatible server-side processing
  12250. * requests
  12251. *
  12252. * @type boolean
  12253. * @default null
  12254. */
  12255. ajax: null
  12256. },
  12257. /**
  12258. * Pagination plug-in methods.
  12259. *
  12260. * Each entry in this object is a function and defines which buttons should
  12261. * be shown by the pagination rendering method that is used for the table:
  12262. * {@link DataTable.ext.renderer.pageButton}. The renderer addresses how the
  12263. * buttons are displayed in the document, while the functions here tell it
  12264. * what buttons to display. This is done by returning an array of button
  12265. * descriptions (what each button will do).
  12266. *
  12267. * Pagination types (the four built in options and any additional plug-in
  12268. * options defined here) can be used through the `paginationType`
  12269. * initialisation parameter.
  12270. *
  12271. * The functions defined take two parameters:
  12272. *
  12273. * 1. `{int} page` The current page index
  12274. * 2. `{int} pages` The number of pages in the table
  12275. *
  12276. * Each function is expected to return an array where each element of the
  12277. * array can be one of:
  12278. *
  12279. * * `first` - Jump to first page when activated
  12280. * * `last` - Jump to last page when activated
  12281. * * `previous` - Show previous page when activated
  12282. * * `next` - Show next page when activated
  12283. * * `{int}` - Show page of the index given
  12284. * * `{array}` - A nested array containing the above elements to add a
  12285. * containing 'DIV' element (might be useful for styling).
  12286. *
  12287. * Note that DataTables v1.9- used this object slightly differently whereby
  12288. * an object with two functions would be defined for each plug-in. That
  12289. * ability is still supported by DataTables 1.10+ to provide backwards
  12290. * compatibility, but this option of use is now decremented and no longer
  12291. * documented in DataTables 1.10+.
  12292. *
  12293. * @type object
  12294. * @default {}
  12295. *
  12296. * @example
  12297. * // Show previous, next and current page buttons only
  12298. * $.fn.dataTableExt.oPagination.current = function ( page, pages ) {
  12299. * return [ 'previous', page, 'next' ];
  12300. * };
  12301. */
  12302. pager: {},
  12303. renderer: {
  12304. pageButton: {},
  12305. header: {}
  12306. },
  12307. /**
  12308. * Ordering plug-ins - custom data source
  12309. *
  12310. * The extension options for ordering of data available here is complimentary
  12311. * to the default type based ordering that DataTables typically uses. It
  12312. * allows much greater control over the the data that is being used to
  12313. * order a column, but is necessarily therefore more complex.
  12314. *
  12315. * This type of ordering is useful if you want to do ordering based on data
  12316. * live from the DOM (for example the contents of an 'input' element) rather
  12317. * than just the static string that DataTables knows of.
  12318. *
  12319. * The way these plug-ins work is that you create an array of the values you
  12320. * wish to be ordering for the column in question and then return that
  12321. * array. The data in the array much be in the index order of the rows in
  12322. * the table (not the currently ordering order!). Which order data gathering
  12323. * function is run here depends on the `dt-init columns.orderDataType`
  12324. * parameter that is used for the column (if any).
  12325. *
  12326. * The functions defined take two parameters:
  12327. *
  12328. * 1. `{object}` DataTables settings object: see
  12329. * {@link DataTable.models.oSettings}
  12330. * 2. `{int}` Target column index
  12331. *
  12332. * Each function is expected to return an array:
  12333. *
  12334. * * `{array}` Data for the column to be ordering upon
  12335. *
  12336. * @type array
  12337. *
  12338. * @example
  12339. * // Ordering using `input` node values
  12340. * $.fn.dataTable.ext.order['dom-text'] = function ( settings, col )
  12341. * {
  12342. * return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
  12343. * return $('input', td).val();
  12344. * } );
  12345. * }
  12346. */
  12347. order: {},
  12348. /**
  12349. * Type based plug-ins.
  12350. *
  12351. * Each column in DataTables has a type assigned to it, either by automatic
  12352. * detection or by direct assignment using the `type` option for the column.
  12353. * The type of a column will effect how it is ordering and search (plug-ins
  12354. * can also make use of the column type if required).
  12355. *
  12356. * @namespace
  12357. */
  12358. type: {
  12359. /**
  12360. * Type detection functions.
  12361. *
  12362. * The functions defined in this object are used to automatically detect
  12363. * a column's type, making initialisation of DataTables super easy, even
  12364. * when complex data is in the table.
  12365. *
  12366. * The functions defined take two parameters:
  12367. *
  12368. * 1. `{*}` Data from the column cell to be analysed
  12369. * 2. `{settings}` DataTables settings object. This can be used to
  12370. * perform context specific type detection - for example detection
  12371. * based on language settings such as using a comma for a decimal
  12372. * place. Generally speaking the options from the settings will not
  12373. * be required
  12374. *
  12375. * Each function is expected to return:
  12376. *
  12377. * * `{string|null}` Data type detected, or null if unknown (and thus
  12378. * pass it on to the other type detection functions.
  12379. *
  12380. * @type array
  12381. *
  12382. * @example
  12383. * // Currency type detection plug-in:
  12384. * $.fn.dataTable.ext.type.detect.push(
  12385. * function ( data, settings ) {
  12386. * // Check the numeric part
  12387. * if ( ! data.substring(1).match(/[0-9]/) ) {
  12388. * return null;
  12389. * }
  12390. *
  12391. * // Check prefixed by currency
  12392. * if ( data.charAt(0) == '$' || data.charAt(0) == '&pound;' ) {
  12393. * return 'currency';
  12394. * }
  12395. * return null;
  12396. * }
  12397. * );
  12398. */
  12399. detect: [],
  12400. /**
  12401. * Type based search formatting.
  12402. *
  12403. * The type based searching functions can be used to pre-format the
  12404. * data to be search on. For example, it can be used to strip HTML
  12405. * tags or to de-format telephone numbers for numeric only searching.
  12406. *
  12407. * Note that is a search is not defined for a column of a given type,
  12408. * no search formatting will be performed.
  12409. *
  12410. * Pre-processing of searching data plug-ins - When you assign the sType
  12411. * for a column (or have it automatically detected for you by DataTables
  12412. * or a type detection plug-in), you will typically be using this for
  12413. * custom sorting, but it can also be used to provide custom searching
  12414. * by allowing you to pre-processing the data and returning the data in
  12415. * the format that should be searched upon. This is done by adding
  12416. * functions this object with a parameter name which matches the sType
  12417. * for that target column. This is the corollary of <i>afnSortData</i>
  12418. * for searching data.
  12419. *
  12420. * The functions defined take a single parameter:
  12421. *
  12422. * 1. `{*}` Data from the column cell to be prepared for searching
  12423. *
  12424. * Each function is expected to return:
  12425. *
  12426. * * `{string|null}` Formatted string that will be used for the searching.
  12427. *
  12428. * @type object
  12429. * @default {}
  12430. *
  12431. * @example
  12432. * $.fn.dataTable.ext.type.search['title-numeric'] = function ( d ) {
  12433. * return d.replace(/\n/g," ").replace( /<.*?>/g, "" );
  12434. * }
  12435. */
  12436. search: {},
  12437. /**
  12438. * Type based ordering.
  12439. *
  12440. * The column type tells DataTables what ordering to apply to the table
  12441. * when a column is sorted upon. The order for each type that is defined,
  12442. * is defined by the functions available in this object.
  12443. *
  12444. * Each ordering option can be described by three properties added to
  12445. * this object:
  12446. *
  12447. * * `{type}-pre` - Pre-formatting function
  12448. * * `{type}-asc` - Ascending order function
  12449. * * `{type}-desc` - Descending order function
  12450. *
  12451. * All three can be used together, only `{type}-pre` or only
  12452. * `{type}-asc` and `{type}-desc` together. It is generally recommended
  12453. * that only `{type}-pre` is used, as this provides the optimal
  12454. * implementation in terms of speed, although the others are provided
  12455. * for compatibility with existing Javascript sort functions.
  12456. *
  12457. * `{type}-pre`: Functions defined take a single parameter:
  12458. *
  12459. * 1. `{*}` Data from the column cell to be prepared for ordering
  12460. *
  12461. * And return:
  12462. *
  12463. * * `{*}` Data to be sorted upon
  12464. *
  12465. * `{type}-asc` and `{type}-desc`: Functions are typical Javascript sort
  12466. * functions, taking two parameters:
  12467. *
  12468. * 1. `{*}` Data to compare to the second parameter
  12469. * 2. `{*}` Data to compare to the first parameter
  12470. *
  12471. * And returning:
  12472. *
  12473. * * `{*}` Ordering match: <0 if first parameter should be sorted lower
  12474. * than the second parameter, ===0 if the two parameters are equal and
  12475. * >0 if the first parameter should be sorted height than the second
  12476. * parameter.
  12477. *
  12478. * @type object
  12479. * @default {}
  12480. *
  12481. * @example
  12482. * // Numeric ordering of formatted numbers with a pre-formatter
  12483. * $.extend( $.fn.dataTable.ext.type.order, {
  12484. * "string-pre": function(x) {
  12485. * a = (a === "-" || a === "") ? 0 : a.replace( /[^\d\-\.]/g, "" );
  12486. * return parseFloat( a );
  12487. * }
  12488. * } );
  12489. *
  12490. * @example
  12491. * // Case-sensitive string ordering, with no pre-formatting method
  12492. * $.extend( $.fn.dataTable.ext.order, {
  12493. * "string-case-asc": function(x,y) {
  12494. * return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12495. * },
  12496. * "string-case-desc": function(x,y) {
  12497. * return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12498. * }
  12499. * } );
  12500. */
  12501. order: {}
  12502. },
  12503. /**
  12504. * Unique DataTables instance counter
  12505. *
  12506. * @type int
  12507. * @private
  12508. */
  12509. _unique: 0,
  12510. //
  12511. // Depreciated
  12512. // The following properties are retained for backwards compatiblity only.
  12513. // The should not be used in new projects and will be removed in a future
  12514. // version
  12515. //
  12516. /**
  12517. * Version check function.
  12518. * @type function
  12519. * @depreciated Since 1.10
  12520. */
  12521. fnVersionCheck: DataTable.fnVersionCheck,
  12522. /**
  12523. * Index for what 'this' index API functions should use
  12524. * @type int
  12525. * @deprecated Since v1.10
  12526. */
  12527. iApiIndex: 0,
  12528. /**
  12529. * jQuery UI class container
  12530. * @type object
  12531. * @deprecated Since v1.10
  12532. */
  12533. oJUIClasses: {},
  12534. /**
  12535. * Software version
  12536. * @type string
  12537. * @deprecated Since v1.10
  12538. */
  12539. sVersion: DataTable.version
  12540. };
  12541. //
  12542. // Backwards compatibility. Alias to pre 1.10 Hungarian notation counter parts
  12543. //
  12544. $.extend( _ext, {
  12545. afnFiltering: _ext.search,
  12546. aTypes: _ext.type.detect,
  12547. ofnSearch: _ext.type.search,
  12548. oSort: _ext.type.order,
  12549. afnSortData: _ext.order,
  12550. aoFeatures: _ext.feature,
  12551. oApi: _ext.internal,
  12552. oStdClasses: _ext.classes,
  12553. oPagination: _ext.pager
  12554. } );
  12555. $.extend( DataTable.ext.classes, {
  12556. "sTable": "dataTable",
  12557. "sNoFooter": "no-footer",
  12558. /* Paging buttons */
  12559. "sPageButton": "paginate_button",
  12560. "sPageButtonActive": "current",
  12561. "sPageButtonDisabled": "disabled",
  12562. /* Striping classes */
  12563. "sStripeOdd": "odd",
  12564. "sStripeEven": "even",
  12565. /* Empty row */
  12566. "sRowEmpty": "dataTables_empty",
  12567. /* Features */
  12568. "sWrapper": "dataTables_wrapper",
  12569. "sFilter": "dataTables_filter",
  12570. "sInfo": "dataTables_info",
  12571. "sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */
  12572. "sLength": "dataTables_length",
  12573. "sProcessing": "dataTables_processing",
  12574. /* Sorting */
  12575. "sSortAsc": "sorting_asc",
  12576. "sSortDesc": "sorting_desc",
  12577. "sSortable": "sorting", /* Sortable in both directions */
  12578. "sSortableAsc": "sorting_asc_disabled",
  12579. "sSortableDesc": "sorting_desc_disabled",
  12580. "sSortableNone": "sorting_disabled",
  12581. "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
  12582. /* Filtering */
  12583. "sFilterInput": "",
  12584. /* Page length */
  12585. "sLengthSelect": "",
  12586. /* Scrolling */
  12587. "sScrollWrapper": "dataTables_scroll",
  12588. "sScrollHead": "dataTables_scrollHead",
  12589. "sScrollHeadInner": "dataTables_scrollHeadInner",
  12590. "sScrollBody": "dataTables_scrollBody",
  12591. "sScrollFoot": "dataTables_scrollFoot",
  12592. "sScrollFootInner": "dataTables_scrollFootInner",
  12593. /* Misc */
  12594. "sHeaderTH": "",
  12595. "sFooterTH": "",
  12596. // Deprecated
  12597. "sSortJUIAsc": "",
  12598. "sSortJUIDesc": "",
  12599. "sSortJUI": "",
  12600. "sSortJUIAscAllowed": "",
  12601. "sSortJUIDescAllowed": "",
  12602. "sSortJUIWrapper": "",
  12603. "sSortIcon": "",
  12604. "sJUIHeader": "",
  12605. "sJUIFooter": ""
  12606. } );
  12607. var extPagination = DataTable.ext.pager;
  12608. function _numbers ( page, pages ) {
  12609. var
  12610. numbers = [],
  12611. buttons = extPagination.numbers_length,
  12612. half = Math.floor( buttons / 2 ),
  12613. i = 1;
  12614. if ( pages <= buttons ) {
  12615. numbers = _range( 0, pages );
  12616. }
  12617. else if ( page <= half ) {
  12618. numbers = _range( 0, buttons-2 );
  12619. numbers.push( 'ellipsis' );
  12620. numbers.push( pages-1 );
  12621. }
  12622. else if ( page >= pages - 1 - half ) {
  12623. numbers = _range( pages-(buttons-2), pages );
  12624. numbers.splice( 0, 0, 'ellipsis' ); // no unshift in ie6
  12625. numbers.splice( 0, 0, 0 );
  12626. }
  12627. else {
  12628. numbers = _range( page-half+2, page+half-1 );
  12629. numbers.push( 'ellipsis' );
  12630. numbers.push( pages-1 );
  12631. numbers.splice( 0, 0, 'ellipsis' );
  12632. numbers.splice( 0, 0, 0 );
  12633. }
  12634. numbers.DT_el = 'span';
  12635. return numbers;
  12636. }
  12637. $.extend( extPagination, {
  12638. simple: function ( page, pages ) {
  12639. return [ 'previous', 'next' ];
  12640. },
  12641. full: function ( page, pages ) {
  12642. return [ 'first', 'previous', 'next', 'last' ];
  12643. },
  12644. numbers: function ( page, pages ) {
  12645. return [ _numbers(page, pages) ];
  12646. },
  12647. simple_numbers: function ( page, pages ) {
  12648. return [ 'previous', _numbers(page, pages), 'next' ];
  12649. },
  12650. full_numbers: function ( page, pages ) {
  12651. return [ 'first', 'previous', _numbers(page, pages), 'next', 'last' ];
  12652. },
  12653. first_last_numbers: function (page, pages) {
  12654. return ['first', _numbers(page, pages), 'last'];
  12655. },
  12656. // For testing and plug-ins to use
  12657. _numbers: _numbers,
  12658. // Number of number buttons (including ellipsis) to show. _Must be odd!_
  12659. numbers_length: 7
  12660. } );
  12661. $.extend( true, DataTable.ext.renderer, {
  12662. pageButton: {
  12663. _: function ( settings, host, idx, buttons, page, pages ) {
  12664. var classes = settings.oClasses;
  12665. var lang = settings.oLanguage.oPaginate;
  12666. var aria = settings.oLanguage.oAria.paginate || {};
  12667. var btnDisplay, btnClass, counter=0;
  12668. var attach = function( container, buttons ) {
  12669. var i, ien, node, button, tabIndex;
  12670. var disabledClass = classes.sPageButtonDisabled;
  12671. var clickHandler = function ( e ) {
  12672. _fnPageChange( settings, e.data.action, true );
  12673. };
  12674. for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
  12675. button = buttons[i];
  12676. if ( $.isArray( button ) ) {
  12677. var inner = $( '<'+(button.DT_el || 'div')+'/>' )
  12678. .appendTo( container );
  12679. attach( inner, button );
  12680. }
  12681. else {
  12682. btnDisplay = null;
  12683. btnClass = button;
  12684. tabIndex = settings.iTabIndex;
  12685. switch ( button ) {
  12686. case 'ellipsis':
  12687. container.append('<span class="ellipsis">&#x2026;</span>');
  12688. break;
  12689. case 'first':
  12690. btnDisplay = lang.sFirst;
  12691. if ( page === 0 ) {
  12692. tabIndex = -1;
  12693. btnClass += ' ' + disabledClass;
  12694. }
  12695. break;
  12696. case 'previous':
  12697. btnDisplay = lang.sPrevious;
  12698. if ( page === 0 ) {
  12699. tabIndex = -1;
  12700. btnClass += ' ' + disabledClass;
  12701. }
  12702. break;
  12703. case 'next':
  12704. btnDisplay = lang.sNext;
  12705. if ( page === pages-1 ) {
  12706. tabIndex = -1;
  12707. btnClass += ' ' + disabledClass;
  12708. }
  12709. break;
  12710. case 'last':
  12711. btnDisplay = lang.sLast;
  12712. if ( page === pages-1 ) {
  12713. tabIndex = -1;
  12714. btnClass += ' ' + disabledClass;
  12715. }
  12716. break;
  12717. default:
  12718. btnDisplay = button + 1;
  12719. btnClass = page === button ?
  12720. classes.sPageButtonActive : '';
  12721. break;
  12722. }
  12723. if ( btnDisplay !== null ) {
  12724. node = $('<a>', {
  12725. 'class': classes.sPageButton+' '+btnClass,
  12726. 'aria-controls': settings.sTableId,
  12727. 'aria-label': aria[ button ],
  12728. 'data-dt-idx': counter,
  12729. 'tabindex': tabIndex,
  12730. 'id': idx === 0 && typeof button === 'string' ?
  12731. settings.sTableId +'_'+ button :
  12732. null
  12733. } )
  12734. .html( btnDisplay )
  12735. .appendTo( container );
  12736. _fnBindAction(
  12737. node, {action: button}, clickHandler
  12738. );
  12739. counter++;
  12740. }
  12741. }
  12742. }
  12743. };
  12744. // IE9 throws an 'unknown error' if document.activeElement is used
  12745. // inside an iframe or frame. Try / catch the error. Not good for
  12746. // accessibility, but neither are frames.
  12747. var activeEl;
  12748. try {
  12749. // Because this approach is destroying and recreating the paging
  12750. // elements, focus is lost on the select button which is bad for
  12751. // accessibility. So we want to restore focus once the draw has
  12752. // completed
  12753. activeEl = $(host).find(document.activeElement).data('dt-idx');
  12754. }
  12755. catch (e) {}
  12756. attach( $(host).empty(), buttons );
  12757. if ( activeEl !== undefined ) {
  12758. $(host).find( '[data-dt-idx='+activeEl+']' ).focus();
  12759. }
  12760. }
  12761. }
  12762. } );
  12763. // Built in type detection. See model.ext.aTypes for information about
  12764. // what is required from this methods.
  12765. $.extend( DataTable.ext.type.detect, [
  12766. // Plain numbers - first since V8 detects some plain numbers as dates
  12767. // e.g. Date.parse('55') (but not all, e.g. Date.parse('22')...).
  12768. function ( d, settings )
  12769. {
  12770. var decimal = settings.oLanguage.sDecimal;
  12771. return _isNumber( d, decimal ) ? 'num'+decimal : null;
  12772. },
  12773. // Dates (only those recognised by the browser's Date.parse)
  12774. function ( d, settings )
  12775. {
  12776. // V8 tries _very_ hard to make a string passed into `Date.parse()`
  12777. // valid, so we need to use a regex to restrict date formats. Use a
  12778. // plug-in for anything other than ISO8601 style strings
  12779. if ( d && !(d instanceof Date) && ! _re_date.test(d) ) {
  12780. return null;
  12781. }
  12782. var parsed = Date.parse(d);
  12783. return (parsed !== null && !isNaN(parsed)) || _empty(d) ? 'date' : null;
  12784. },
  12785. // Formatted numbers
  12786. function ( d, settings )
  12787. {
  12788. var decimal = settings.oLanguage.sDecimal;
  12789. return _isNumber( d, decimal, true ) ? 'num-fmt'+decimal : null;
  12790. },
  12791. // HTML numeric
  12792. function ( d, settings )
  12793. {
  12794. var decimal = settings.oLanguage.sDecimal;
  12795. return _htmlNumeric( d, decimal ) ? 'html-num'+decimal : null;
  12796. },
  12797. // HTML numeric, formatted
  12798. function ( d, settings )
  12799. {
  12800. var decimal = settings.oLanguage.sDecimal;
  12801. return _htmlNumeric( d, decimal, true ) ? 'html-num-fmt'+decimal : null;
  12802. },
  12803. // HTML (this is strict checking - there must be html)
  12804. function ( d, settings )
  12805. {
  12806. return _empty( d ) || (typeof d === 'string' && d.indexOf('<') !== -1) ?
  12807. 'html' : null;
  12808. }
  12809. ] );
  12810. // Filter formatting functions. See model.ext.ofnSearch for information about
  12811. // what is required from these methods.
  12812. //
  12813. // Note that additional search methods are added for the html numbers and
  12814. // html formatted numbers by `_addNumericSort()` when we know what the decimal
  12815. // place is
  12816. $.extend( DataTable.ext.type.search, {
  12817. html: function ( data ) {
  12818. return _empty(data) ?
  12819. data :
  12820. typeof data === 'string' ?
  12821. data
  12822. .replace( _re_new_lines, " " )
  12823. .replace( _re_html, "" ) :
  12824. '';
  12825. },
  12826. string: function ( data ) {
  12827. return _empty(data) ?
  12828. data :
  12829. typeof data === 'string' ?
  12830. data.replace( _re_new_lines, " " ) :
  12831. data;
  12832. }
  12833. } );
  12834. var __numericReplace = function ( d, decimalPlace, re1, re2 ) {
  12835. if ( d !== 0 && (!d || d === '-') ) {
  12836. return -Infinity;
  12837. }
  12838. // If a decimal place other than `.` is used, it needs to be given to the
  12839. // function so we can detect it and replace with a `.` which is the only
  12840. // decimal place Javascript recognises - it is not locale aware.
  12841. if ( decimalPlace ) {
  12842. d = _numToDecimal( d, decimalPlace );
  12843. }
  12844. if ( d.replace ) {
  12845. if ( re1 ) {
  12846. d = d.replace( re1, '' );
  12847. }
  12848. if ( re2 ) {
  12849. d = d.replace( re2, '' );
  12850. }
  12851. }
  12852. return d * 1;
  12853. };
  12854. // Add the numeric 'deformatting' functions for sorting and search. This is done
  12855. // in a function to provide an easy ability for the language options to add
  12856. // additional methods if a non-period decimal place is used.
  12857. function _addNumericSort ( decimalPlace ) {
  12858. $.each(
  12859. {
  12860. // Plain numbers
  12861. "num": function ( d ) {
  12862. return __numericReplace( d, decimalPlace );
  12863. },
  12864. // Formatted numbers
  12865. "num-fmt": function ( d ) {
  12866. return __numericReplace( d, decimalPlace, _re_formatted_numeric );
  12867. },
  12868. // HTML numeric
  12869. "html-num": function ( d ) {
  12870. return __numericReplace( d, decimalPlace, _re_html );
  12871. },
  12872. // HTML numeric, formatted
  12873. "html-num-fmt": function ( d ) {
  12874. return __numericReplace( d, decimalPlace, _re_html, _re_formatted_numeric );
  12875. }
  12876. },
  12877. function ( key, fn ) {
  12878. // Add the ordering method
  12879. _ext.type.order[ key+decimalPlace+'-pre' ] = fn;
  12880. // For HTML types add a search formatter that will strip the HTML
  12881. if ( key.match(/^html\-/) ) {
  12882. _ext.type.search[ key+decimalPlace ] = _ext.type.search.html;
  12883. }
  12884. }
  12885. );
  12886. }
  12887. // Default sort methods
  12888. $.extend( _ext.type.order, {
  12889. // Dates
  12890. "date-pre": function ( d ) {
  12891. var ts = Date.parse( d );
  12892. return isNaN(ts) ? -Infinity : ts;
  12893. },
  12894. // html
  12895. "html-pre": function ( a ) {
  12896. return _empty(a) ?
  12897. '' :
  12898. a.replace ?
  12899. a.replace( /<.*?>/g, "" ).toLowerCase() :
  12900. a+'';
  12901. },
  12902. // string
  12903. "string-pre": function ( a ) {
  12904. // This is a little complex, but faster than always calling toString,
  12905. // http://jsperf.com/tostring-v-check
  12906. return _empty(a) ?
  12907. '' :
  12908. typeof a === 'string' ?
  12909. a.toLowerCase() :
  12910. ! a.toString ?
  12911. '' :
  12912. a.toString();
  12913. },
  12914. // string-asc and -desc are retained only for compatibility with the old
  12915. // sort methods
  12916. "string-asc": function ( x, y ) {
  12917. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12918. },
  12919. "string-desc": function ( x, y ) {
  12920. return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12921. }
  12922. } );
  12923. // Numeric sorting types - order doesn't matter here
  12924. _addNumericSort( '' );
  12925. $.extend( true, DataTable.ext.renderer, {
  12926. header: {
  12927. _: function ( settings, cell, column, classes ) {
  12928. // No additional mark-up required
  12929. // Attach a sort listener to update on sort - note that using the
  12930. // `DT` namespace will allow the event to be removed automatically
  12931. // on destroy, while the `dt` namespaced event is the one we are
  12932. // listening for
  12933. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  12934. if ( settings !== ctx ) { // need to check this this is the host
  12935. return; // table, not a nested one
  12936. }
  12937. var colIdx = column.idx;
  12938. cell
  12939. .removeClass(
  12940. column.sSortingClass +' '+
  12941. classes.sSortAsc +' '+
  12942. classes.sSortDesc
  12943. )
  12944. .addClass( columns[ colIdx ] == 'asc' ?
  12945. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  12946. classes.sSortDesc :
  12947. column.sSortingClass
  12948. );
  12949. } );
  12950. },
  12951. jqueryui: function ( settings, cell, column, classes ) {
  12952. $('<div/>')
  12953. .addClass( classes.sSortJUIWrapper )
  12954. .append( cell.contents() )
  12955. .append( $('<span/>')
  12956. .addClass( classes.sSortIcon+' '+column.sSortingClassJUI )
  12957. )
  12958. .appendTo( cell );
  12959. // Attach a sort listener to update on sort
  12960. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  12961. if ( settings !== ctx ) {
  12962. return;
  12963. }
  12964. var colIdx = column.idx;
  12965. cell
  12966. .removeClass( classes.sSortAsc +" "+classes.sSortDesc )
  12967. .addClass( columns[ colIdx ] == 'asc' ?
  12968. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  12969. classes.sSortDesc :
  12970. column.sSortingClass
  12971. );
  12972. cell
  12973. .find( 'span.'+classes.sSortIcon )
  12974. .removeClass(
  12975. classes.sSortJUIAsc +" "+
  12976. classes.sSortJUIDesc +" "+
  12977. classes.sSortJUI +" "+
  12978. classes.sSortJUIAscAllowed +" "+
  12979. classes.sSortJUIDescAllowed
  12980. )
  12981. .addClass( columns[ colIdx ] == 'asc' ?
  12982. classes.sSortJUIAsc : columns[ colIdx ] == 'desc' ?
  12983. classes.sSortJUIDesc :
  12984. column.sSortingClassJUI
  12985. );
  12986. } );
  12987. }
  12988. }
  12989. } );
  12990. /*
  12991. * Public helper functions. These aren't used internally by DataTables, or
  12992. * called by any of the options passed into DataTables, but they can be used
  12993. * externally by developers working with DataTables. They are helper functions
  12994. * to make working with DataTables a little bit easier.
  12995. */
  12996. var __htmlEscapeEntities = function ( d ) {
  12997. return typeof d === 'string' ?
  12998. d.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;') :
  12999. d;
  13000. };
  13001. /**
  13002. * Helpers for `columns.render`.
  13003. *
  13004. * The options defined here can be used with the `columns.render` initialisation
  13005. * option to provide a display renderer. The following functions are defined:
  13006. *
  13007. * * `number` - Will format numeric data (defined by `columns.data`) for
  13008. * display, retaining the original unformatted data for sorting and filtering.
  13009. * It takes 5 parameters:
  13010. * * `string` - Thousands grouping separator
  13011. * * `string` - Decimal point indicator
  13012. * * `integer` - Number of decimal points to show
  13013. * * `string` (optional) - Prefix.
  13014. * * `string` (optional) - Postfix (/suffix).
  13015. * * `text` - Escape HTML to help prevent XSS attacks. It has no optional
  13016. * parameters.
  13017. *
  13018. * @example
  13019. * // Column definition using the number renderer
  13020. * {
  13021. * data: "salary",
  13022. * render: $.fn.dataTable.render.number( '\'', '.', 0, '$' )
  13023. * }
  13024. *
  13025. * @namespace
  13026. */
  13027. DataTable.render = {
  13028. number: function ( thousands, decimal, precision, prefix, postfix ) {
  13029. return {
  13030. display: function ( d ) {
  13031. if ( typeof d !== 'number' && typeof d !== 'string' ) {
  13032. return d;
  13033. }
  13034. var negative = d < 0 ? '-' : '';
  13035. var flo = parseFloat( d );
  13036. // If NaN then there isn't much formatting that we can do - just
  13037. // return immediately, escaping any HTML (this was supposed to
  13038. // be a number after all)
  13039. if ( isNaN( flo ) ) {
  13040. return __htmlEscapeEntities( d );
  13041. }
  13042. flo = flo.toFixed( precision );
  13043. d = Math.abs( flo );
  13044. var intPart = parseInt( d, 10 );
  13045. var floatPart = precision ?
  13046. decimal+(d - intPart).toFixed( precision ).substring( 2 ):
  13047. '';
  13048. return negative + (prefix||'') +
  13049. intPart.toString().replace(
  13050. /\B(?=(\d{3})+(?!\d))/g, thousands
  13051. ) +
  13052. floatPart +
  13053. (postfix||'');
  13054. }
  13055. };
  13056. },
  13057. text: function () {
  13058. return {
  13059. display: __htmlEscapeEntities,
  13060. filter: __htmlEscapeEntities
  13061. };
  13062. }
  13063. };
  13064. /*
  13065. * This is really a good bit rubbish this method of exposing the internal methods
  13066. * publicly... - To be fixed in 2.0 using methods on the prototype
  13067. */
  13068. /**
  13069. * Create a wrapper function for exporting an internal functions to an external API.
  13070. * @param {string} fn API function name
  13071. * @returns {function} wrapped function
  13072. * @memberof DataTable#internal
  13073. */
  13074. function _fnExternApiFunc (fn)
  13075. {
  13076. return function() {
  13077. var args = [_fnSettingsFromNode( this[DataTable.ext.iApiIndex] )].concat(
  13078. Array.prototype.slice.call(arguments)
  13079. );
  13080. return DataTable.ext.internal[fn].apply( this, args );
  13081. };
  13082. }
  13083. /**
  13084. * Reference to internal functions for use by plug-in developers. Note that
  13085. * these methods are references to internal functions and are considered to be
  13086. * private. If you use these methods, be aware that they are liable to change
  13087. * between versions.
  13088. * @namespace
  13089. */
  13090. $.extend( DataTable.ext.internal, {
  13091. _fnExternApiFunc: _fnExternApiFunc,
  13092. _fnBuildAjax: _fnBuildAjax,
  13093. _fnAjaxUpdate: _fnAjaxUpdate,
  13094. _fnAjaxParameters: _fnAjaxParameters,
  13095. _fnAjaxUpdateDraw: _fnAjaxUpdateDraw,
  13096. _fnAjaxDataSrc: _fnAjaxDataSrc,
  13097. _fnAddColumn: _fnAddColumn,
  13098. _fnColumnOptions: _fnColumnOptions,
  13099. _fnAdjustColumnSizing: _fnAdjustColumnSizing,
  13100. _fnVisibleToColumnIndex: _fnVisibleToColumnIndex,
  13101. _fnColumnIndexToVisible: _fnColumnIndexToVisible,
  13102. _fnVisbleColumns: _fnVisbleColumns,
  13103. _fnGetColumns: _fnGetColumns,
  13104. _fnColumnTypes: _fnColumnTypes,
  13105. _fnApplyColumnDefs: _fnApplyColumnDefs,
  13106. _fnHungarianMap: _fnHungarianMap,
  13107. _fnCamelToHungarian: _fnCamelToHungarian,
  13108. _fnLanguageCompat: _fnLanguageCompat,
  13109. _fnBrowserDetect: _fnBrowserDetect,
  13110. _fnAddData: _fnAddData,
  13111. _fnAddTr: _fnAddTr,
  13112. _fnNodeToDataIndex: _fnNodeToDataIndex,
  13113. _fnNodeToColumnIndex: _fnNodeToColumnIndex,
  13114. _fnGetCellData: _fnGetCellData,
  13115. _fnSetCellData: _fnSetCellData,
  13116. _fnSplitObjNotation: _fnSplitObjNotation,
  13117. _fnGetObjectDataFn: _fnGetObjectDataFn,
  13118. _fnSetObjectDataFn: _fnSetObjectDataFn,
  13119. _fnGetDataMaster: _fnGetDataMaster,
  13120. _fnClearTable: _fnClearTable,
  13121. _fnDeleteIndex: _fnDeleteIndex,
  13122. _fnInvalidate: _fnInvalidate,
  13123. _fnGetRowElements: _fnGetRowElements,
  13124. _fnCreateTr: _fnCreateTr,
  13125. _fnBuildHead: _fnBuildHead,
  13126. _fnDrawHead: _fnDrawHead,
  13127. _fnDraw: _fnDraw,
  13128. _fnReDraw: _fnReDraw,
  13129. _fnAddOptionsHtml: _fnAddOptionsHtml,
  13130. _fnDetectHeader: _fnDetectHeader,
  13131. _fnGetUniqueThs: _fnGetUniqueThs,
  13132. _fnFeatureHtmlFilter: _fnFeatureHtmlFilter,
  13133. _fnFilterComplete: _fnFilterComplete,
  13134. _fnFilterCustom: _fnFilterCustom,
  13135. _fnFilterColumn: _fnFilterColumn,
  13136. _fnFilter: _fnFilter,
  13137. _fnFilterCreateSearch: _fnFilterCreateSearch,
  13138. _fnEscapeRegex: _fnEscapeRegex,
  13139. _fnFilterData: _fnFilterData,
  13140. _fnFeatureHtmlInfo: _fnFeatureHtmlInfo,
  13141. _fnUpdateInfo: _fnUpdateInfo,
  13142. _fnInfoMacros: _fnInfoMacros,
  13143. _fnInitialise: _fnInitialise,
  13144. _fnInitComplete: _fnInitComplete,
  13145. _fnLengthChange: _fnLengthChange,
  13146. _fnFeatureHtmlLength: _fnFeatureHtmlLength,
  13147. _fnFeatureHtmlPaginate: _fnFeatureHtmlPaginate,
  13148. _fnPageChange: _fnPageChange,
  13149. _fnFeatureHtmlProcessing: _fnFeatureHtmlProcessing,
  13150. _fnProcessingDisplay: _fnProcessingDisplay,
  13151. _fnFeatureHtmlTable: _fnFeatureHtmlTable,
  13152. _fnScrollDraw: _fnScrollDraw,
  13153. _fnApplyToChildren: _fnApplyToChildren,
  13154. _fnCalculateColumnWidths: _fnCalculateColumnWidths,
  13155. _fnThrottle: _fnThrottle,
  13156. _fnConvertToWidth: _fnConvertToWidth,
  13157. _fnGetWidestNode: _fnGetWidestNode,
  13158. _fnGetMaxLenString: _fnGetMaxLenString,
  13159. _fnStringToCss: _fnStringToCss,
  13160. _fnSortFlatten: _fnSortFlatten,
  13161. _fnSort: _fnSort,
  13162. _fnSortAria: _fnSortAria,
  13163. _fnSortListener: _fnSortListener,
  13164. _fnSortAttachListener: _fnSortAttachListener,
  13165. _fnSortingClasses: _fnSortingClasses,
  13166. _fnSortData: _fnSortData,
  13167. _fnSaveState: _fnSaveState,
  13168. _fnLoadState: _fnLoadState,
  13169. _fnSettingsFromNode: _fnSettingsFromNode,
  13170. _fnLog: _fnLog,
  13171. _fnMap: _fnMap,
  13172. _fnBindAction: _fnBindAction,
  13173. _fnCallbackReg: _fnCallbackReg,
  13174. _fnCallbackFire: _fnCallbackFire,
  13175. _fnLengthOverflow: _fnLengthOverflow,
  13176. _fnRenderer: _fnRenderer,
  13177. _fnDataSource: _fnDataSource,
  13178. _fnRowAttributes: _fnRowAttributes,
  13179. _fnExtend: _fnExtend,
  13180. _fnCalculateEnd: function () {} // Used by a lot of plug-ins, but redundant
  13181. // in 1.10, so this dead-end function is
  13182. // added to prevent errors
  13183. } );
  13184. // jQuery access
  13185. $.fn.dataTable = DataTable;
  13186. // Provide access to the host jQuery object (circular reference)
  13187. DataTable.$ = $;
  13188. // Legacy aliases
  13189. $.fn.dataTableSettings = DataTable.settings;
  13190. $.fn.dataTableExt = DataTable.ext;
  13191. // With a capital `D` we return a DataTables API instance rather than a
  13192. // jQuery object
  13193. $.fn.DataTable = function ( opts ) {
  13194. return $(this).dataTable( opts ).api();
  13195. };
  13196. // All properties that are available to $.fn.dataTable should also be
  13197. // available on $.fn.DataTable
  13198. $.each( DataTable, function ( prop, val ) {
  13199. $.fn.DataTable[ prop ] = val;
  13200. } );
  13201. // Information about events fired by DataTables - for documentation.
  13202. /**
  13203. * Draw event, fired whenever the table is redrawn on the page, at the same
  13204. * point as fnDrawCallback. This may be useful for binding events or
  13205. * performing calculations when the table is altered at all.
  13206. * @name DataTable#draw.dt
  13207. * @event
  13208. * @param {event} e jQuery event object
  13209. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13210. */
  13211. /**
  13212. * Search event, fired when the searching applied to the table (using the
  13213. * built-in global search, or column filters) is altered.
  13214. * @name DataTable#search.dt
  13215. * @event
  13216. * @param {event} e jQuery event object
  13217. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13218. */
  13219. /**
  13220. * Page change event, fired when the paging of the table is altered.
  13221. * @name DataTable#page.dt
  13222. * @event
  13223. * @param {event} e jQuery event object
  13224. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13225. */
  13226. /**
  13227. * Order event, fired when the ordering applied to the table is altered.
  13228. * @name DataTable#order.dt
  13229. * @event
  13230. * @param {event} e jQuery event object
  13231. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13232. */
  13233. /**
  13234. * DataTables initialisation complete event, fired when the table is fully
  13235. * drawn, including Ajax data loaded, if Ajax data is required.
  13236. * @name DataTable#init.dt
  13237. * @event
  13238. * @param {event} e jQuery event object
  13239. * @param {object} oSettings DataTables settings object
  13240. * @param {object} json The JSON object request from the server - only
  13241. * present if client-side Ajax sourced data is used</li></ol>
  13242. */
  13243. /**
  13244. * State save event, fired when the table has changed state a new state save
  13245. * is required. This event allows modification of the state saving object
  13246. * prior to actually doing the save, including addition or other state
  13247. * properties (for plug-ins) or modification of a DataTables core property.
  13248. * @name DataTable#stateSaveParams.dt
  13249. * @event
  13250. * @param {event} e jQuery event object
  13251. * @param {object} oSettings DataTables settings object
  13252. * @param {object} json The state information to be saved
  13253. */
  13254. /**
  13255. * State load event, fired when the table is loading state from the stored
  13256. * data, but prior to the settings object being modified by the saved state
  13257. * - allowing modification of the saved state is required or loading of
  13258. * state for a plug-in.
  13259. * @name DataTable#stateLoadParams.dt
  13260. * @event
  13261. * @param {event} e jQuery event object
  13262. * @param {object} oSettings DataTables settings object
  13263. * @param {object} json The saved state information
  13264. */
  13265. /**
  13266. * State loaded event, fired when state has been loaded from stored data and
  13267. * the settings object has been modified by the loaded data.
  13268. * @name DataTable#stateLoaded.dt
  13269. * @event
  13270. * @param {event} e jQuery event object
  13271. * @param {object} oSettings DataTables settings object
  13272. * @param {object} json The saved state information
  13273. */
  13274. /**
  13275. * Processing event, fired when DataTables is doing some kind of processing
  13276. * (be it, order, search or anything else). It can be used to indicate to
  13277. * the end user that there is something happening, or that something has
  13278. * finished.
  13279. * @name DataTable#processing.dt
  13280. * @event
  13281. * @param {event} e jQuery event object
  13282. * @param {object} oSettings DataTables settings object
  13283. * @param {boolean} bShow Flag for if DataTables is doing processing or not
  13284. */
  13285. /**
  13286. * Ajax (XHR) event, fired whenever an Ajax request is completed from a
  13287. * request to made to the server for new data. This event is called before
  13288. * DataTables processed the returned data, so it can also be used to pre-
  13289. * process the data returned from the server, if needed.
  13290. *
  13291. * Note that this trigger is called in `fnServerData`, if you override
  13292. * `fnServerData` and which to use this event, you need to trigger it in you
  13293. * success function.
  13294. * @name DataTable#xhr.dt
  13295. * @event
  13296. * @param {event} e jQuery event object
  13297. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13298. * @param {object} json JSON returned from the server
  13299. *
  13300. * @example
  13301. * // Use a custom property returned from the server in another DOM element
  13302. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  13303. * $('#status').html( json.status );
  13304. * } );
  13305. *
  13306. * @example
  13307. * // Pre-process the data returned from the server
  13308. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  13309. * for ( var i=0, ien=json.aaData.length ; i<ien ; i++ ) {
  13310. * json.aaData[i].sum = json.aaData[i].one + json.aaData[i].two;
  13311. * }
  13312. * // Note no return - manipulate the data directly in the JSON object.
  13313. * } );
  13314. */
  13315. /**
  13316. * Destroy event, fired when the DataTable is destroyed by calling fnDestroy
  13317. * or passing the bDestroy:true parameter in the initialisation object. This
  13318. * can be used to remove bound events, added DOM nodes, etc.
  13319. * @name DataTable#destroy.dt
  13320. * @event
  13321. * @param {event} e jQuery event object
  13322. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13323. */
  13324. /**
  13325. * Page length change event, fired when number of records to show on each
  13326. * page (the length) is changed.
  13327. * @name DataTable#length.dt
  13328. * @event
  13329. * @param {event} e jQuery event object
  13330. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13331. * @param {integer} len New length
  13332. */
  13333. /**
  13334. * Column sizing has changed.
  13335. * @name DataTable#column-sizing.dt
  13336. * @event
  13337. * @param {event} e jQuery event object
  13338. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13339. */
  13340. /**
  13341. * Column visibility has changed.
  13342. * @name DataTable#column-visibility.dt
  13343. * @event
  13344. * @param {event} e jQuery event object
  13345. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13346. * @param {int} column Column index
  13347. * @param {bool} vis `false` if column now hidden, or `true` if visible
  13348. */
  13349. return $.fn.dataTable;
  13350. }));