jquery.dataTables.js 419 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622
  1. /*! DataTables 1.10.2
  2. * ©2008-2014 SpryMedia Ltd - datatables.net/license
  3. */
  4. /**
  5. * @summary DataTables
  6. * @description Paginate, search and order HTML tables
  7. * @version 1.10.2
  8. * @file jquery.dataTables.js
  9. * @author SpryMedia Ltd (www.sprymedia.co.uk)
  10. * @contact www.sprymedia.co.uk/contact
  11. * @copyright Copyright 2008-2014 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,_fnInvalidateRow,_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,_fnScrollingWidthAdjust,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnScrollBarWidth,_fnSortFlatten,_fnSort,_fnSortAria,_fnSortListener,_fnSortAttachListener,_fnSortingClasses,_fnSortData,_fnSaveState,_fnLoadState,_fnSettingsFromNode,_fnLog,_fnMap,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnLengthOverflow,_fnRenderer,_fnDataSource,_fnRowAttributes*/
  24. (/** @lends <global> */function( window, document, undefined ) {
  25. (function( factory ) {
  26. "use strict";
  27. if ( typeof define === 'function' && define.amd ) {
  28. // Define as an AMD module if possible
  29. define( 'datatables', ['jquery'], factory );
  30. }
  31. else if ( typeof exports === 'object' ) {
  32. // Node/CommonJS
  33. factory( require( 'jquery' ) );
  34. }
  35. else if ( jQuery && !jQuery.fn.dataTable ) {
  36. // Define using browser globals otherwise
  37. // Prevent multiple instantiations if the script is loaded twice
  38. factory( jQuery );
  39. }
  40. }
  41. (/** @lends <global> */function( $ ) {
  42. "use strict";
  43. /**
  44. * DataTables is a plug-in for the jQuery Javascript library. It is a highly
  45. * flexible tool, based upon the foundations of progressive enhancement,
  46. * which will add advanced interaction controls to any HTML table. For a
  47. * full list of features please refer to
  48. * [DataTables.net](href="http://datatables.net).
  49. *
  50. * Note that the `DataTable` object is not a global variable but is aliased
  51. * to `jQuery.fn.DataTable` and `jQuery.fn.dataTable` through which it may
  52. * be accessed.
  53. *
  54. * @class
  55. * @param {object} [init={}] Configuration object for DataTables. Options
  56. * are defined by {@link DataTable.defaults}
  57. * @requires jQuery 1.7+
  58. *
  59. * @example
  60. * // Basic initialisation
  61. * $(document).ready( function {
  62. * $('#example').dataTable();
  63. * } );
  64. *
  65. * @example
  66. * // Initialisation with configuration options - in this case, disable
  67. * // pagination and sorting.
  68. * $(document).ready( function {
  69. * $('#example').dataTable( {
  70. * "paginate": false,
  71. * "sort": false
  72. * } );
  73. * } );
  74. */
  75. var DataTable;
  76. /*
  77. * It is useful to have variables which are scoped locally so only the
  78. * DataTables functions can access them and they don't leak into global space.
  79. * At the same time these functions are often useful over multiple files in the
  80. * core and API, so we list, or at least document, all variables which are used
  81. * by DataTables as private variables here. This also ensures that there is no
  82. * clashing of variable names and that they can easily referenced for reuse.
  83. */
  84. // Defined else where
  85. // _selector_run
  86. // _selector_opts
  87. // _selector_first
  88. // _selector_row_indexes
  89. var _ext; // DataTable.ext
  90. var _Api; // DataTable.Api
  91. var _api_register; // DataTable.Api.register
  92. var _api_registerPlural; // DataTable.Api.registerPlural
  93. var _re_dic = {};
  94. var _re_new_lines = /[\r\n]/g;
  95. var _re_html = /<.*?>/g;
  96. var _re_date_start = /^[\w\+\-]/;
  97. var _re_date_end = /[\w\+\-]$/;
  98. // Escape regular expression special characters
  99. var _re_escape_regex = new RegExp( '(\\' + [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^', '-' ].join('|\\') + ')', 'g' );
  100. // U+2009 is thin space and U+202F is narrow no-break space, both used in many
  101. // standards as thousands separators
  102. var _re_formatted_numeric = /[',$£€¥%\u2009\u202F]/g;
  103. var _empty = function ( d ) {
  104. return !d || d === true || d === '-' ? true : false;
  105. };
  106. var _intVal = function ( s ) {
  107. var integer = parseInt( s, 10 );
  108. return !isNaN(integer) && isFinite(s) ? integer : null;
  109. };
  110. // Convert from a formatted number with characters other than `.` as the
  111. // decimal place, to a Javascript number
  112. var _numToDecimal = function ( num, decimalPoint ) {
  113. // Cache created regular expressions for speed as this function is called often
  114. if ( ! _re_dic[ decimalPoint ] ) {
  115. _re_dic[ decimalPoint ] = new RegExp( _fnEscapeRegex( decimalPoint ), 'g' );
  116. }
  117. return typeof num === 'string' ?
  118. num.replace( /\./g, '' ).replace( _re_dic[ decimalPoint ], '.' ) :
  119. num;
  120. };
  121. var _isNumber = function ( d, decimalPoint, formatted ) {
  122. var strType = typeof d === 'string';
  123. if ( decimalPoint && strType ) {
  124. d = _numToDecimal( d, decimalPoint );
  125. }
  126. if ( formatted && strType ) {
  127. d = d.replace( _re_formatted_numeric, '' );
  128. }
  129. return _empty( d ) || (!isNaN( parseFloat(d) ) && isFinite( d ));
  130. };
  131. // A string without HTML in it can be considered to be HTML still
  132. var _isHtml = function ( d ) {
  133. return _empty( d ) || typeof d === 'string';
  134. };
  135. var _htmlNumeric = function ( d, decimalPoint, formatted ) {
  136. if ( _empty( d ) ) {
  137. return true;
  138. }
  139. var html = _isHtml( d );
  140. return ! html ?
  141. null :
  142. _isNumber( _stripHtml( d ), decimalPoint, formatted ) ?
  143. true :
  144. null;
  145. };
  146. var _pluck = function ( a, prop, prop2 ) {
  147. var out = [];
  148. var i=0, ien=a.length;
  149. // Could have the test in the loop for slightly smaller code, but speed
  150. // is essential here
  151. if ( prop2 !== undefined ) {
  152. for ( ; i<ien ; i++ ) {
  153. if ( a[i] && a[i][ prop ] ) {
  154. out.push( a[i][ prop ][ prop2 ] );
  155. }
  156. }
  157. }
  158. else {
  159. for ( ; i<ien ; i++ ) {
  160. if ( a[i] ) {
  161. out.push( a[i][ prop ] );
  162. }
  163. }
  164. }
  165. return out;
  166. };
  167. // Basically the same as _pluck, but rather than looping over `a` we use `order`
  168. // as the indexes to pick from `a`
  169. var _pluck_order = function ( a, order, prop, prop2 )
  170. {
  171. var out = [];
  172. var i=0, ien=order.length;
  173. // Could have the test in the loop for slightly smaller code, but speed
  174. // is essential here
  175. if ( prop2 !== undefined ) {
  176. for ( ; i<ien ; i++ ) {
  177. out.push( a[ order[i] ][ prop ][ prop2 ] );
  178. }
  179. }
  180. else {
  181. for ( ; i<ien ; i++ ) {
  182. out.push( a[ order[i] ][ prop ] );
  183. }
  184. }
  185. return out;
  186. };
  187. var _range = function ( len, start )
  188. {
  189. var out = [];
  190. var end;
  191. if ( start === undefined ) {
  192. start = 0;
  193. end = len;
  194. }
  195. else {
  196. end = start;
  197. start = len;
  198. }
  199. for ( var i=start ; i<end ; i++ ) {
  200. out.push( i );
  201. }
  202. return out;
  203. };
  204. var _stripHtml = function ( d ) {
  205. return d.replace( _re_html, '' );
  206. };
  207. /**
  208. * Find the unique elements in a source array.
  209. *
  210. * @param {array} src Source array
  211. * @return {array} Array of unique items
  212. * @ignore
  213. */
  214. var _unique = function ( src )
  215. {
  216. // A faster unique method is to use object keys to identify used values,
  217. // but this doesn't work with arrays or objects, which we must also
  218. // consider. See jsperf.com/compare-array-unique-versions/4 for more
  219. // information.
  220. var
  221. out = [],
  222. val,
  223. i, ien=src.length,
  224. j, k=0;
  225. again: for ( i=0 ; i<ien ; i++ ) {
  226. val = src[i];
  227. for ( j=0 ; j<k ; j++ ) {
  228. if ( out[j] === val ) {
  229. continue again;
  230. }
  231. }
  232. out.push( val );
  233. k++;
  234. }
  235. return out;
  236. };
  237. /**
  238. * Create a mapping object that allows camel case parameters to be looked up
  239. * for their Hungarian counterparts. The mapping is stored in a private
  240. * parameter called `_hungarianMap` which can be accessed on the source object.
  241. * @param {object} o
  242. * @memberof DataTable#oApi
  243. */
  244. function _fnHungarianMap ( o )
  245. {
  246. var
  247. hungarian = 'a aa ai ao as b fn i m o s ',
  248. match,
  249. newKey,
  250. map = {};
  251. $.each( o, function (key, val) {
  252. match = key.match(/^([^A-Z]+?)([A-Z])/);
  253. if ( match && hungarian.indexOf(match[1]+' ') !== -1 )
  254. {
  255. newKey = key.replace( match[0], match[2].toLowerCase() );
  256. map[ newKey ] = key;
  257. //console.log( key, match );
  258. if ( match[1] === 'o' )
  259. {
  260. _fnHungarianMap( o[key] );
  261. }
  262. }
  263. } );
  264. o._hungarianMap = map;
  265. }
  266. /**
  267. * Convert from camel case parameters to Hungarian, based on a Hungarian map
  268. * created by _fnHungarianMap.
  269. * @param {object} src The model object which holds all parameters that can be
  270. * mapped.
  271. * @param {object} user The object to convert from camel case to Hungarian.
  272. * @param {boolean} force When set to `true`, properties which already have a
  273. * Hungarian value in the `user` object will be overwritten. Otherwise they
  274. * won't be.
  275. * @memberof DataTable#oApi
  276. */
  277. function _fnCamelToHungarian ( src, user, force )
  278. {
  279. if ( ! src._hungarianMap ) {
  280. _fnHungarianMap( src );
  281. }
  282. var hungarianKey;
  283. $.each( user, function (key, val) {
  284. hungarianKey = src._hungarianMap[ key ];
  285. if ( hungarianKey !== undefined && (force || user[hungarianKey] === undefined) )
  286. {
  287. // For objects, we need to buzz down into the object to copy parameters
  288. if ( hungarianKey.charAt(0) === 'o' )
  289. {
  290. // Copy the camelCase options over to the hungarian
  291. if ( ! user[ hungarianKey ] ) {
  292. user[ hungarianKey ] = {};
  293. }
  294. $.extend( true, user[hungarianKey], user[key] );
  295. _fnCamelToHungarian( src[hungarianKey], user[hungarianKey], force );
  296. }
  297. else {
  298. user[hungarianKey] = user[ key ];
  299. }
  300. }
  301. } );
  302. }
  303. /**
  304. * Language compatibility - when certain options are given, and others aren't, we
  305. * need to duplicate the values over, in order to provide backwards compatibility
  306. * with older language files.
  307. * @param {object} oSettings dataTables settings object
  308. * @memberof DataTable#oApi
  309. */
  310. function _fnLanguageCompat( lang )
  311. {
  312. var defaults = DataTable.defaults.oLanguage;
  313. var zeroRecords = lang.sZeroRecords;
  314. /* Backwards compatibility - if there is no sEmptyTable given, then use the same as
  315. * sZeroRecords - assuming that is given.
  316. */
  317. if ( ! lang.sEmptyTable && zeroRecords &&
  318. defaults.sEmptyTable === "No data available in table" )
  319. {
  320. _fnMap( lang, lang, 'sZeroRecords', 'sEmptyTable' );
  321. }
  322. /* Likewise with loading records */
  323. if ( ! lang.sLoadingRecords && zeroRecords &&
  324. defaults.sLoadingRecords === "Loading..." )
  325. {
  326. _fnMap( lang, lang, 'sZeroRecords', 'sLoadingRecords' );
  327. }
  328. // Old parameter name of the thousands separator mapped onto the new
  329. if ( lang.sInfoThousands ) {
  330. lang.sThousands = lang.sInfoThousands;
  331. }
  332. var decimal = lang.sDecimal;
  333. if ( decimal ) {
  334. _addNumericSort( decimal );
  335. }
  336. }
  337. /**
  338. * Map one parameter onto another
  339. * @param {object} o Object to map
  340. * @param {*} knew The new parameter name
  341. * @param {*} old The old parameter name
  342. */
  343. var _fnCompatMap = function ( o, knew, old ) {
  344. if ( o[ knew ] !== undefined ) {
  345. o[ old ] = o[ knew ];
  346. }
  347. };
  348. /**
  349. * Provide backwards compatibility for the main DT options. Note that the new
  350. * options are mapped onto the old parameters, so this is an external interface
  351. * change only.
  352. * @param {object} init Object to map
  353. */
  354. function _fnCompatOpts ( init )
  355. {
  356. _fnCompatMap( init, 'ordering', 'bSort' );
  357. _fnCompatMap( init, 'orderMulti', 'bSortMulti' );
  358. _fnCompatMap( init, 'orderClasses', 'bSortClasses' );
  359. _fnCompatMap( init, 'orderCellsTop', 'bSortCellsTop' );
  360. _fnCompatMap( init, 'order', 'aaSorting' );
  361. _fnCompatMap( init, 'orderFixed', 'aaSortingFixed' );
  362. _fnCompatMap( init, 'paging', 'bPaginate' );
  363. _fnCompatMap( init, 'pagingType', 'sPaginationType' );
  364. _fnCompatMap( init, 'pageLength', 'iDisplayLength' );
  365. _fnCompatMap( init, 'searching', 'bFilter' );
  366. // Column search objects are in an array, so it needs to be converted
  367. // element by element
  368. var searchCols = init.aoSearchCols;
  369. if ( searchCols ) {
  370. for ( var i=0, ien=searchCols.length ; i<ien ; i++ ) {
  371. if ( searchCols[i] ) {
  372. _fnCamelToHungarian( DataTable.models.oSearch, searchCols[i] );
  373. }
  374. }
  375. }
  376. }
  377. /**
  378. * Provide backwards compatibility for column options. Note that the new options
  379. * are mapped onto the old parameters, so this is an external interface change
  380. * only.
  381. * @param {object} init Object to map
  382. */
  383. function _fnCompatCols ( init )
  384. {
  385. _fnCompatMap( init, 'orderable', 'bSortable' );
  386. _fnCompatMap( init, 'orderData', 'aDataSort' );
  387. _fnCompatMap( init, 'orderSequence', 'asSorting' );
  388. _fnCompatMap( init, 'orderDataType', 'sortDataType' );
  389. }
  390. /**
  391. * Browser feature detection for capabilities, quirks
  392. * @param {object} settings dataTables settings object
  393. * @memberof DataTable#oApi
  394. */
  395. function _fnBrowserDetect( settings )
  396. {
  397. var browser = settings.oBrowser;
  398. // Scrolling feature / quirks detection
  399. var n = $('<div/>')
  400. .css( {
  401. position: 'absolute',
  402. top: 0,
  403. left: 0,
  404. height: 1,
  405. width: 1,
  406. overflow: 'hidden'
  407. } )
  408. .append(
  409. $('<div/>')
  410. .css( {
  411. position: 'absolute',
  412. top: 1,
  413. left: 1,
  414. width: 100,
  415. overflow: 'scroll'
  416. } )
  417. .append(
  418. $('<div class="test"/>')
  419. .css( {
  420. width: '100%',
  421. height: 10
  422. } )
  423. )
  424. )
  425. .appendTo( 'body' );
  426. var test = n.find('.test');
  427. // IE6/7 will oversize a width 100% element inside a scrolling element, to
  428. // include the width of the scrollbar, while other browsers ensure the inner
  429. // element is contained without forcing scrolling
  430. browser.bScrollOversize = test[0].offsetWidth === 100;
  431. // In rtl text layout, some browsers (most, but not all) will place the
  432. // scrollbar on the left, rather than the right.
  433. browser.bScrollbarLeft = test.offset().left !== 1;
  434. n.remove();
  435. }
  436. /**
  437. * Array.prototype reduce[Right] method, used for browsers which don't support
  438. * JS 1.6. Done this way to reduce code size, since we iterate either way
  439. * @param {object} settings dataTables settings object
  440. * @memberof DataTable#oApi
  441. */
  442. function _fnReduce ( that, fn, init, start, end, inc )
  443. {
  444. var
  445. i = start,
  446. value,
  447. isSet = false;
  448. if ( init !== undefined ) {
  449. value = init;
  450. isSet = true;
  451. }
  452. while ( i !== end ) {
  453. if ( ! that.hasOwnProperty(i) ) {
  454. continue;
  455. }
  456. value = isSet ?
  457. fn( value, that[i], i, that ) :
  458. that[i];
  459. isSet = true;
  460. i += inc;
  461. }
  462. return value;
  463. }
  464. /**
  465. * Add a column to the list used for the table with default values
  466. * @param {object} oSettings dataTables settings object
  467. * @param {node} nTh The th element for this column
  468. * @memberof DataTable#oApi
  469. */
  470. function _fnAddColumn( oSettings, nTh )
  471. {
  472. // Add column to aoColumns array
  473. var oDefaults = DataTable.defaults.column;
  474. var iCol = oSettings.aoColumns.length;
  475. var oCol = $.extend( {}, DataTable.models.oColumn, oDefaults, {
  476. "nTh": nTh ? nTh : document.createElement('th'),
  477. "sTitle": oDefaults.sTitle ? oDefaults.sTitle : nTh ? nTh.innerHTML : '',
  478. "aDataSort": oDefaults.aDataSort ? oDefaults.aDataSort : [iCol],
  479. "mData": oDefaults.mData ? oDefaults.mData : iCol,
  480. idx: iCol
  481. } );
  482. oSettings.aoColumns.push( oCol );
  483. // Add search object for column specific search. Note that the `searchCols[ iCol ]`
  484. // passed into extend can be undefined. This allows the user to give a default
  485. // with only some of the parameters defined, and also not give a default
  486. var searchCols = oSettings.aoPreSearchCols;
  487. searchCols[ iCol ] = $.extend( {}, DataTable.models.oSearch, searchCols[ iCol ] );
  488. // Use the default column options function to initialise classes etc
  489. _fnColumnOptions( oSettings, iCol, null );
  490. }
  491. /**
  492. * Apply options for a column
  493. * @param {object} oSettings dataTables settings object
  494. * @param {int} iCol column index to consider
  495. * @param {object} oOptions object with sType, bVisible and bSearchable etc
  496. * @memberof DataTable#oApi
  497. */
  498. function _fnColumnOptions( oSettings, iCol, oOptions )
  499. {
  500. var oCol = oSettings.aoColumns[ iCol ];
  501. var oClasses = oSettings.oClasses;
  502. var th = $(oCol.nTh);
  503. // Try to get width information from the DOM. We can't get it from CSS
  504. // as we'd need to parse the CSS stylesheet. `width` option can override
  505. if ( ! oCol.sWidthOrig ) {
  506. // Width attribute
  507. oCol.sWidthOrig = th.attr('width') || null;
  508. // Style attribute
  509. var t = (th.attr('style') || '').match(/width:\s*(\d+[pxem%]+)/);
  510. if ( t ) {
  511. oCol.sWidthOrig = t[1];
  512. }
  513. }
  514. /* User specified column options */
  515. if ( oOptions !== undefined && oOptions !== null )
  516. {
  517. // Backwards compatibility
  518. _fnCompatCols( oOptions );
  519. // Map camel case parameters to their Hungarian counterparts
  520. _fnCamelToHungarian( DataTable.defaults.column, oOptions );
  521. /* Backwards compatibility for mDataProp */
  522. if ( oOptions.mDataProp !== undefined && !oOptions.mData )
  523. {
  524. oOptions.mData = oOptions.mDataProp;
  525. }
  526. if ( oOptions.sType )
  527. {
  528. oCol._sManualType = oOptions.sType;
  529. }
  530. // `class` is a reserved word in Javascript, so we need to provide
  531. // the ability to use a valid name for the camel case input
  532. if ( oOptions.className && ! oOptions.sClass )
  533. {
  534. oOptions.sClass = oOptions.className;
  535. }
  536. $.extend( oCol, oOptions );
  537. _fnMap( oCol, oOptions, "sWidth", "sWidthOrig" );
  538. /* iDataSort to be applied (backwards compatibility), but aDataSort will take
  539. * priority if defined
  540. */
  541. if ( typeof oOptions.iDataSort === 'number' )
  542. {
  543. oCol.aDataSort = [ oOptions.iDataSort ];
  544. }
  545. _fnMap( oCol, oOptions, "aDataSort" );
  546. }
  547. /* Cache the data get and set functions for speed */
  548. var mDataSrc = oCol.mData;
  549. var mData = _fnGetObjectDataFn( mDataSrc );
  550. var mRender = oCol.mRender ? _fnGetObjectDataFn( oCol.mRender ) : null;
  551. var attrTest = function( src ) {
  552. return typeof src === 'string' && src.indexOf('@') !== -1;
  553. };
  554. oCol._bAttrSrc = $.isPlainObject( mDataSrc ) && (
  555. attrTest(mDataSrc.sort) || attrTest(mDataSrc.type) || attrTest(mDataSrc.filter)
  556. );
  557. oCol.fnGetData = function (rowData, type, meta) {
  558. var innerData = mData( rowData, type, undefined, meta );
  559. return mRender && type ?
  560. mRender( innerData, type, rowData, meta ) :
  561. innerData;
  562. };
  563. oCol.fnSetData = function ( rowData, val, meta ) {
  564. return _fnSetObjectDataFn( mDataSrc )( rowData, val, meta );
  565. };
  566. /* Feature sorting overrides column specific when off */
  567. if ( !oSettings.oFeatures.bSort )
  568. {
  569. oCol.bSortable = false;
  570. th.addClass( oClasses.sSortableNone ); // Have to add class here as order event isn't called
  571. }
  572. /* Check that the class assignment is correct for sorting */
  573. var bAsc = $.inArray('asc', oCol.asSorting) !== -1;
  574. var bDesc = $.inArray('desc', oCol.asSorting) !== -1;
  575. if ( !oCol.bSortable || (!bAsc && !bDesc) )
  576. {
  577. oCol.sSortingClass = oClasses.sSortableNone;
  578. oCol.sSortingClassJUI = "";
  579. }
  580. else if ( bAsc && !bDesc )
  581. {
  582. oCol.sSortingClass = oClasses.sSortableAsc;
  583. oCol.sSortingClassJUI = oClasses.sSortJUIAscAllowed;
  584. }
  585. else if ( !bAsc && bDesc )
  586. {
  587. oCol.sSortingClass = oClasses.sSortableDesc;
  588. oCol.sSortingClassJUI = oClasses.sSortJUIDescAllowed;
  589. }
  590. else
  591. {
  592. oCol.sSortingClass = oClasses.sSortable;
  593. oCol.sSortingClassJUI = oClasses.sSortJUI;
  594. }
  595. }
  596. /**
  597. * Adjust the table column widths for new data. Note: you would probably want to
  598. * do a redraw after calling this function!
  599. * @param {object} settings dataTables settings object
  600. * @memberof DataTable#oApi
  601. */
  602. function _fnAdjustColumnSizing ( settings )
  603. {
  604. /* Not interested in doing column width calculation if auto-width is disabled */
  605. if ( settings.oFeatures.bAutoWidth !== false )
  606. {
  607. var columns = settings.aoColumns;
  608. _fnCalculateColumnWidths( settings );
  609. for ( var i=0 , iLen=columns.length ; i<iLen ; i++ )
  610. {
  611. columns[i].nTh.style.width = columns[i].sWidth;
  612. }
  613. }
  614. var scroll = settings.oScroll;
  615. if ( scroll.sY !== '' || scroll.sX !== '')
  616. {
  617. _fnScrollDraw( settings );
  618. }
  619. _fnCallbackFire( settings, null, 'column-sizing', [settings] );
  620. }
  621. /**
  622. * Covert the index of a visible column to the index in the data array (take account
  623. * of hidden columns)
  624. * @param {object} oSettings dataTables settings object
  625. * @param {int} iMatch Visible column index to lookup
  626. * @returns {int} i the data index
  627. * @memberof DataTable#oApi
  628. */
  629. function _fnVisibleToColumnIndex( oSettings, iMatch )
  630. {
  631. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  632. return typeof aiVis[iMatch] === 'number' ?
  633. aiVis[iMatch] :
  634. null;
  635. }
  636. /**
  637. * Covert the index of an index in the data array and convert it to the visible
  638. * column index (take account of hidden columns)
  639. * @param {int} iMatch Column index to lookup
  640. * @param {object} oSettings dataTables settings object
  641. * @returns {int} i the data index
  642. * @memberof DataTable#oApi
  643. */
  644. function _fnColumnIndexToVisible( oSettings, iMatch )
  645. {
  646. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  647. var iPos = $.inArray( iMatch, aiVis );
  648. return iPos !== -1 ? iPos : null;
  649. }
  650. /**
  651. * Get the number of visible columns
  652. * @param {object} oSettings dataTables settings object
  653. * @returns {int} i the number of visible columns
  654. * @memberof DataTable#oApi
  655. */
  656. function _fnVisbleColumns( oSettings )
  657. {
  658. return _fnGetColumns( oSettings, 'bVisible' ).length;
  659. }
  660. /**
  661. * Get an array of column indexes that match a given property
  662. * @param {object} oSettings dataTables settings object
  663. * @param {string} sParam Parameter in aoColumns to look for - typically
  664. * bVisible or bSearchable
  665. * @returns {array} Array of indexes with matched properties
  666. * @memberof DataTable#oApi
  667. */
  668. function _fnGetColumns( oSettings, sParam )
  669. {
  670. var a = [];
  671. $.map( oSettings.aoColumns, function(val, i) {
  672. if ( val[sParam] ) {
  673. a.push( i );
  674. }
  675. } );
  676. return a;
  677. }
  678. /**
  679. * Calculate the 'type' of a column
  680. * @param {object} settings dataTables settings object
  681. * @memberof DataTable#oApi
  682. */
  683. function _fnColumnTypes ( settings )
  684. {
  685. var columns = settings.aoColumns;
  686. var data = settings.aoData;
  687. var types = DataTable.ext.type.detect;
  688. var i, ien, j, jen, k, ken;
  689. var col, cell, detectedType, cache;
  690. // For each column, spin over the
  691. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  692. col = columns[i];
  693. cache = [];
  694. if ( ! col.sType && col._sManualType ) {
  695. col.sType = col._sManualType;
  696. }
  697. else if ( ! col.sType ) {
  698. for ( j=0, jen=types.length ; j<jen ; j++ ) {
  699. for ( k=0, ken=data.length ; k<ken ; k++ ) {
  700. // Use a cache array so we only need to get the type data
  701. // from the formatter once (when using multiple detectors)
  702. if ( cache[k] === undefined ) {
  703. cache[k] = _fnGetCellData( settings, k, i, 'type' );
  704. }
  705. detectedType = types[j]( cache[k], settings );
  706. // Doesn't match, so break early, since this type can't
  707. // apply to this column. Also, HTML is a special case since
  708. // it is so similar to `string`. Just a single match is
  709. // needed for a column to be html type
  710. if ( ! detectedType || detectedType === 'html' ) {
  711. break;
  712. }
  713. }
  714. // Type is valid for all data points in the column - use this
  715. // type
  716. if ( detectedType ) {
  717. col.sType = detectedType;
  718. break;
  719. }
  720. }
  721. // Fall back - if no type was detected, always use string
  722. if ( ! col.sType ) {
  723. col.sType = 'string';
  724. }
  725. }
  726. }
  727. }
  728. /**
  729. * Take the column definitions and static columns arrays and calculate how
  730. * they relate to column indexes. The callback function will then apply the
  731. * definition found for a column to a suitable configuration object.
  732. * @param {object} oSettings dataTables settings object
  733. * @param {array} aoColDefs The aoColumnDefs array that is to be applied
  734. * @param {array} aoCols The aoColumns array that defines columns individually
  735. * @param {function} fn Callback function - takes two parameters, the calculated
  736. * column index and the definition for that column.
  737. * @memberof DataTable#oApi
  738. */
  739. function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, fn )
  740. {
  741. var i, iLen, j, jLen, k, kLen, def;
  742. var columns = oSettings.aoColumns;
  743. // Column definitions with aTargets
  744. if ( aoColDefs )
  745. {
  746. /* Loop over the definitions array - loop in reverse so first instance has priority */
  747. for ( i=aoColDefs.length-1 ; i>=0 ; i-- )
  748. {
  749. def = aoColDefs[i];
  750. /* Each definition can target multiple columns, as it is an array */
  751. var aTargets = def.targets !== undefined ?
  752. def.targets :
  753. def.aTargets;
  754. if ( ! $.isArray( aTargets ) )
  755. {
  756. aTargets = [ aTargets ];
  757. }
  758. for ( j=0, jLen=aTargets.length ; j<jLen ; j++ )
  759. {
  760. if ( typeof aTargets[j] === 'number' && aTargets[j] >= 0 )
  761. {
  762. /* Add columns that we don't yet know about */
  763. while( columns.length <= aTargets[j] )
  764. {
  765. _fnAddColumn( oSettings );
  766. }
  767. /* Integer, basic index */
  768. fn( aTargets[j], def );
  769. }
  770. else if ( typeof aTargets[j] === 'number' && aTargets[j] < 0 )
  771. {
  772. /* Negative integer, right to left column counting */
  773. fn( columns.length+aTargets[j], def );
  774. }
  775. else if ( typeof aTargets[j] === 'string' )
  776. {
  777. /* Class name matching on TH element */
  778. for ( k=0, kLen=columns.length ; k<kLen ; k++ )
  779. {
  780. if ( aTargets[j] == "_all" ||
  781. $(columns[k].nTh).hasClass( aTargets[j] ) )
  782. {
  783. fn( k, def );
  784. }
  785. }
  786. }
  787. }
  788. }
  789. }
  790. // Statically defined columns array
  791. if ( aoCols )
  792. {
  793. for ( i=0, iLen=aoCols.length ; i<iLen ; i++ )
  794. {
  795. fn( i, aoCols[i] );
  796. }
  797. }
  798. }
  799. /**
  800. * Add a data array to the table, creating DOM node etc. This is the parallel to
  801. * _fnGatherData, but for adding rows from a Javascript source, rather than a
  802. * DOM source.
  803. * @param {object} oSettings dataTables settings object
  804. * @param {array} aData data array to be added
  805. * @param {node} [nTr] TR element to add to the table - optional. If not given,
  806. * DataTables will create a row automatically
  807. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  808. * if nTr is.
  809. * @returns {int} >=0 if successful (index of new aoData entry), -1 if failed
  810. * @memberof DataTable#oApi
  811. */
  812. function _fnAddData ( oSettings, aDataIn, nTr, anTds )
  813. {
  814. /* Create the object for storing information about this new row */
  815. var iRow = oSettings.aoData.length;
  816. var oData = $.extend( true, {}, DataTable.models.oRow, {
  817. src: nTr ? 'dom' : 'data'
  818. } );
  819. oData._aData = aDataIn;
  820. oSettings.aoData.push( oData );
  821. /* Create the cells */
  822. var nTd, sThisType;
  823. var columns = oSettings.aoColumns;
  824. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  825. {
  826. // When working with a row, the data source object must be populated. In
  827. // all other cases, the data source object is already populated, so we
  828. // don't overwrite it, which might break bindings etc
  829. if ( nTr ) {
  830. _fnSetCellData( oSettings, iRow, i, _fnGetCellData( oSettings, iRow, i ) );
  831. }
  832. columns[i].sType = null;
  833. }
  834. /* Add to the display array */
  835. oSettings.aiDisplayMaster.push( iRow );
  836. /* Create the DOM information, or register it if already present */
  837. if ( nTr || ! oSettings.oFeatures.bDeferRender )
  838. {
  839. _fnCreateTr( oSettings, iRow, nTr, anTds );
  840. }
  841. return iRow;
  842. }
  843. /**
  844. * Add one or more TR elements to the table. Generally we'd expect to
  845. * use this for reading data from a DOM sourced table, but it could be
  846. * used for an TR element. Note that if a TR is given, it is used (i.e.
  847. * it is not cloned).
  848. * @param {object} settings dataTables settings object
  849. * @param {array|node|jQuery} trs The TR element(s) to add to the table
  850. * @returns {array} Array of indexes for the added rows
  851. * @memberof DataTable#oApi
  852. */
  853. function _fnAddTr( settings, trs )
  854. {
  855. var row;
  856. // Allow an individual node to be passed in
  857. if ( ! (trs instanceof $) ) {
  858. trs = $(trs);
  859. }
  860. return trs.map( function (i, el) {
  861. row = _fnGetRowElements( settings, el );
  862. return _fnAddData( settings, row.data, el, row.cells );
  863. } );
  864. }
  865. /**
  866. * Take a TR element and convert it to an index in aoData
  867. * @param {object} oSettings dataTables settings object
  868. * @param {node} n the TR element to find
  869. * @returns {int} index if the node is found, null if not
  870. * @memberof DataTable#oApi
  871. */
  872. function _fnNodeToDataIndex( oSettings, n )
  873. {
  874. return (n._DT_RowIndex!==undefined) ? n._DT_RowIndex : null;
  875. }
  876. /**
  877. * Take a TD element and convert it into a column data index (not the visible index)
  878. * @param {object} oSettings dataTables settings object
  879. * @param {int} iRow The row number the TD/TH can be found in
  880. * @param {node} n The TD/TH element to find
  881. * @returns {int} index if the node is found, -1 if not
  882. * @memberof DataTable#oApi
  883. */
  884. function _fnNodeToColumnIndex( oSettings, iRow, n )
  885. {
  886. return $.inArray( n, oSettings.aoData[ iRow ].anCells );
  887. }
  888. /**
  889. * Get the data for a given cell from the internal cache, taking into account data mapping
  890. * @param {object} settings dataTables settings object
  891. * @param {int} rowIdx aoData row id
  892. * @param {int} colIdx Column index
  893. * @param {string} type data get type ('display', 'type' 'filter' 'sort')
  894. * @returns {*} Cell data
  895. * @memberof DataTable#oApi
  896. */
  897. function _fnGetCellData( settings, rowIdx, colIdx, type )
  898. {
  899. var draw = settings.iDraw;
  900. var col = settings.aoColumns[colIdx];
  901. var rowData = settings.aoData[rowIdx]._aData;
  902. var defaultContent = col.sDefaultContent;
  903. var cellData = col.fnGetData( rowData, type, {
  904. settings: settings,
  905. row: rowIdx,
  906. col: colIdx
  907. } );
  908. if ( cellData === undefined ) {
  909. if ( settings.iDrawError != draw && defaultContent === null ) {
  910. _fnLog( settings, 0, "Requested unknown parameter "+
  911. (typeof col.mData=='function' ? '{function}' : "'"+col.mData+"'")+
  912. " for row "+rowIdx, 4 );
  913. settings.iDrawError = draw;
  914. }
  915. return defaultContent;
  916. }
  917. /* When the data source is null, we can use default column data */
  918. if ( (cellData === rowData || cellData === null) && defaultContent !== null ) {
  919. cellData = defaultContent;
  920. }
  921. else if ( typeof cellData === 'function' ) {
  922. // If the data source is a function, then we run it and use the return,
  923. // executing in the scope of the data object (for instances)
  924. return cellData.call( rowData );
  925. }
  926. if ( cellData === null && type == 'display' ) {
  927. return '';
  928. }
  929. return cellData;
  930. }
  931. /**
  932. * Set the value for a specific cell, into the internal data cache
  933. * @param {object} settings dataTables settings object
  934. * @param {int} rowIdx aoData row id
  935. * @param {int} colIdx Column index
  936. * @param {*} val Value to set
  937. * @memberof DataTable#oApi
  938. */
  939. function _fnSetCellData( settings, rowIdx, colIdx, val )
  940. {
  941. var col = settings.aoColumns[colIdx];
  942. var rowData = settings.aoData[rowIdx]._aData;
  943. col.fnSetData( rowData, val, {
  944. settings: settings,
  945. row: rowIdx,
  946. col: colIdx
  947. } );
  948. }
  949. // Private variable that is used to match action syntax in the data property object
  950. var __reArray = /\[.*?\]$/;
  951. var __reFn = /\(\)$/;
  952. /**
  953. * Split string on periods, taking into account escaped periods
  954. * @param {string} str String to split
  955. * @return {array} Split string
  956. */
  957. function _fnSplitObjNotation( str )
  958. {
  959. return $.map( str.match(/(\\.|[^\.])+/g), function ( s ) {
  960. return s.replace(/\\./g, '.');
  961. } );
  962. }
  963. /**
  964. * Return a function that can be used to get data from a source object, taking
  965. * into account the ability to use nested objects as a source
  966. * @param {string|int|function} mSource The data source for the object
  967. * @returns {function} Data get function
  968. * @memberof DataTable#oApi
  969. */
  970. function _fnGetObjectDataFn( mSource )
  971. {
  972. if ( $.isPlainObject( mSource ) )
  973. {
  974. /* Build an object of get functions, and wrap them in a single call */
  975. var o = {};
  976. $.each( mSource, function (key, val) {
  977. if ( val ) {
  978. o[key] = _fnGetObjectDataFn( val );
  979. }
  980. } );
  981. return function (data, type, row, meta) {
  982. var t = o[type] || o._;
  983. return t !== undefined ?
  984. t(data, type, row, meta) :
  985. data;
  986. };
  987. }
  988. else if ( mSource === null )
  989. {
  990. /* Give an empty string for rendering / sorting etc */
  991. return function (data) { // type, row and meta also passed, but not used
  992. return data;
  993. };
  994. }
  995. else if ( typeof mSource === 'function' )
  996. {
  997. return function (data, type, row, meta) {
  998. return mSource( data, type, row, meta );
  999. };
  1000. }
  1001. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  1002. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  1003. {
  1004. /* If there is a . in the source string then the data source is in a
  1005. * nested object so we loop over the data for each level to get the next
  1006. * level down. On each loop we test for undefined, and if found immediately
  1007. * return. This allows entire objects to be missing and sDefaultContent to
  1008. * be used if defined, rather than throwing an error
  1009. */
  1010. var fetchData = function (data, type, src) {
  1011. var arrayNotation, funcNotation, out, innerSrc;
  1012. if ( src !== "" )
  1013. {
  1014. var a = _fnSplitObjNotation( src );
  1015. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  1016. {
  1017. // Check if we are dealing with special notation
  1018. arrayNotation = a[i].match(__reArray);
  1019. funcNotation = a[i].match(__reFn);
  1020. if ( arrayNotation )
  1021. {
  1022. // Array notation
  1023. a[i] = a[i].replace(__reArray, '');
  1024. // Condition allows simply [] to be passed in
  1025. if ( a[i] !== "" ) {
  1026. data = data[ a[i] ];
  1027. }
  1028. out = [];
  1029. // Get the remainder of the nested object to get
  1030. a.splice( 0, i+1 );
  1031. innerSrc = a.join('.');
  1032. // Traverse each entry in the array getting the properties requested
  1033. for ( var j=0, jLen=data.length ; j<jLen ; j++ ) {
  1034. out.push( fetchData( data[j], type, innerSrc ) );
  1035. }
  1036. // If a string is given in between the array notation indicators, that
  1037. // is used to join the strings together, otherwise an array is returned
  1038. var join = arrayNotation[0].substring(1, arrayNotation[0].length-1);
  1039. data = (join==="") ? out : out.join(join);
  1040. // The inner call to fetchData has already traversed through the remainder
  1041. // of the source requested, so we exit from the loop
  1042. break;
  1043. }
  1044. else if ( funcNotation )
  1045. {
  1046. // Function call
  1047. a[i] = a[i].replace(__reFn, '');
  1048. data = data[ a[i] ]();
  1049. continue;
  1050. }
  1051. if ( data === null || data[ a[i] ] === undefined )
  1052. {
  1053. return undefined;
  1054. }
  1055. data = data[ a[i] ];
  1056. }
  1057. }
  1058. return data;
  1059. };
  1060. return function (data, type) { // row and meta also passed, but not used
  1061. return fetchData( data, type, mSource );
  1062. };
  1063. }
  1064. else
  1065. {
  1066. /* Array or flat object mapping */
  1067. return function (data, type) { // row and meta also passed, but not used
  1068. return data[mSource];
  1069. };
  1070. }
  1071. }
  1072. /**
  1073. * Return a function that can be used to set data from a source object, taking
  1074. * into account the ability to use nested objects as a source
  1075. * @param {string|int|function} mSource The data source for the object
  1076. * @returns {function} Data set function
  1077. * @memberof DataTable#oApi
  1078. */
  1079. function _fnSetObjectDataFn( mSource )
  1080. {
  1081. if ( $.isPlainObject( mSource ) )
  1082. {
  1083. /* Unlike get, only the underscore (global) option is used for for
  1084. * setting data since we don't know the type here. This is why an object
  1085. * option is not documented for `mData` (which is read/write), but it is
  1086. * for `mRender` which is read only.
  1087. */
  1088. return _fnSetObjectDataFn( mSource._ );
  1089. }
  1090. else if ( mSource === null )
  1091. {
  1092. /* Nothing to do when the data source is null */
  1093. return function () {};
  1094. }
  1095. else if ( typeof mSource === 'function' )
  1096. {
  1097. return function (data, val, meta) {
  1098. mSource( data, 'set', val, meta );
  1099. };
  1100. }
  1101. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  1102. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  1103. {
  1104. /* Like the get, we need to get data from a nested object */
  1105. var setData = function (data, val, src) {
  1106. var a = _fnSplitObjNotation( src ), b;
  1107. var aLast = a[a.length-1];
  1108. var arrayNotation, funcNotation, o, innerSrc;
  1109. for ( var i=0, iLen=a.length-1 ; i<iLen ; i++ )
  1110. {
  1111. // Check if we are dealing with an array notation request
  1112. arrayNotation = a[i].match(__reArray);
  1113. funcNotation = a[i].match(__reFn);
  1114. if ( arrayNotation )
  1115. {
  1116. a[i] = a[i].replace(__reArray, '');
  1117. data[ a[i] ] = [];
  1118. // Get the remainder of the nested object to set so we can recurse
  1119. b = a.slice();
  1120. b.splice( 0, i+1 );
  1121. innerSrc = b.join('.');
  1122. // Traverse each entry in the array setting the properties requested
  1123. for ( var j=0, jLen=val.length ; j<jLen ; j++ )
  1124. {
  1125. o = {};
  1126. setData( o, val[j], innerSrc );
  1127. data[ a[i] ].push( o );
  1128. }
  1129. // The inner call to setData has already traversed through the remainder
  1130. // of the source and has set the data, thus we can exit here
  1131. return;
  1132. }
  1133. else if ( funcNotation )
  1134. {
  1135. // Function call
  1136. a[i] = a[i].replace(__reFn, '');
  1137. data = data[ a[i] ]( val );
  1138. }
  1139. // If the nested object doesn't currently exist - since we are
  1140. // trying to set the value - create it
  1141. if ( data[ a[i] ] === null || data[ a[i] ] === undefined )
  1142. {
  1143. data[ a[i] ] = {};
  1144. }
  1145. data = data[ a[i] ];
  1146. }
  1147. // Last item in the input - i.e, the actual set
  1148. if ( aLast.match(__reFn ) )
  1149. {
  1150. // Function call
  1151. data = data[ aLast.replace(__reFn, '') ]( val );
  1152. }
  1153. else
  1154. {
  1155. // If array notation is used, we just want to strip it and use the property name
  1156. // and assign the value. If it isn't used, then we get the result we want anyway
  1157. data[ aLast.replace(__reArray, '') ] = val;
  1158. }
  1159. };
  1160. return function (data, val) { // meta is also passed in, but not used
  1161. return setData( data, val, mSource );
  1162. };
  1163. }
  1164. else
  1165. {
  1166. /* Array or flat object mapping */
  1167. return function (data, val) { // meta is also passed in, but not used
  1168. data[mSource] = val;
  1169. };
  1170. }
  1171. }
  1172. /**
  1173. * Return an array with the full table data
  1174. * @param {object} oSettings dataTables settings object
  1175. * @returns array {array} aData Master data array
  1176. * @memberof DataTable#oApi
  1177. */
  1178. function _fnGetDataMaster ( settings )
  1179. {
  1180. return _pluck( settings.aoData, '_aData' );
  1181. }
  1182. /**
  1183. * Nuke the table
  1184. * @param {object} oSettings dataTables settings object
  1185. * @memberof DataTable#oApi
  1186. */
  1187. function _fnClearTable( settings )
  1188. {
  1189. settings.aoData.length = 0;
  1190. settings.aiDisplayMaster.length = 0;
  1191. settings.aiDisplay.length = 0;
  1192. }
  1193. /**
  1194. * Take an array of integers (index array) and remove a target integer (value - not
  1195. * the key!)
  1196. * @param {array} a Index array to target
  1197. * @param {int} iTarget value to find
  1198. * @memberof DataTable#oApi
  1199. */
  1200. function _fnDeleteIndex( a, iTarget, splice )
  1201. {
  1202. var iTargetIndex = -1;
  1203. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  1204. {
  1205. if ( a[i] == iTarget )
  1206. {
  1207. iTargetIndex = i;
  1208. }
  1209. else if ( a[i] > iTarget )
  1210. {
  1211. a[i]--;
  1212. }
  1213. }
  1214. if ( iTargetIndex != -1 && splice === undefined )
  1215. {
  1216. a.splice( iTargetIndex, 1 );
  1217. }
  1218. }
  1219. /**
  1220. * Mark cached data as invalid such that a re-read of the data will occur when
  1221. * the cached data is next requested. Also update from the data source object.
  1222. *
  1223. * @param {object} settings DataTables settings object
  1224. * @param {int} rowIdx Row index to invalidate
  1225. * @memberof DataTable#oApi
  1226. *
  1227. * @todo For the modularisation of v1.11 this will need to become a callback, so
  1228. * the sort and filter methods can subscribe to it. That will required
  1229. * initialisation options for sorting, which is why it is not already baked in
  1230. */
  1231. function _fnInvalidateRow( settings, rowIdx, src, column )
  1232. {
  1233. var row = settings.aoData[ rowIdx ];
  1234. var i, ien;
  1235. // Are we reading last data from DOM or the data object?
  1236. if ( src === 'dom' || ((! src || src === 'auto') && row.src === 'dom') ) {
  1237. // Read the data from the DOM
  1238. row._aData = _fnGetRowElements( settings, row ).data;
  1239. }
  1240. else {
  1241. // Reading from data object, update the DOM
  1242. var cells = row.anCells;
  1243. var cell;
  1244. if ( cells ) {
  1245. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  1246. cell = cells[i];
  1247. // This is very frustrating, but in IE if you just write directly
  1248. // to innerHTML, and elements that are overwritten are GC'ed,
  1249. // even if there is a reference to them elsewhere
  1250. while ( cell.childNodes.length ) {
  1251. cell.removeChild( cell.firstChild );
  1252. }
  1253. cells[i].innerHTML = _fnGetCellData( settings, rowIdx, i, 'display' );
  1254. }
  1255. }
  1256. }
  1257. row._aSortData = null;
  1258. row._aFilterData = null;
  1259. // Invalidate the type for a specific column (if given) or all columns since
  1260. // the data might have changed
  1261. var cols = settings.aoColumns;
  1262. if ( column !== undefined ) {
  1263. cols[ column ].sType = null;
  1264. }
  1265. else {
  1266. for ( i=0, ien=cols.length ; i<ien ; i++ ) {
  1267. cols[i].sType = null;
  1268. }
  1269. }
  1270. // Update DataTables special `DT_*` attributes for the row
  1271. _fnRowAttributes( row );
  1272. }
  1273. /**
  1274. * Build a data source object from an HTML row, reading the contents of the
  1275. * cells that are in the row.
  1276. *
  1277. * @param {object} settings DataTables settings object
  1278. * @param {node|object} TR element from which to read data or existing row
  1279. * object from which to re-read the data from the cells
  1280. * @returns {object} Object with two parameters: `data` the data read, in
  1281. * document order, and `cells` and array of nodes (they can be useful to the
  1282. * caller, so rather than needing a second traversal to get them, just return
  1283. * them from here).
  1284. * @memberof DataTable#oApi
  1285. */
  1286. function _fnGetRowElements( settings, row )
  1287. {
  1288. var
  1289. d = [],
  1290. tds = [],
  1291. td = row.firstChild,
  1292. name, col, o, i=0, contents,
  1293. columns = settings.aoColumns;
  1294. var attr = function ( str, data, td ) {
  1295. if ( typeof str === 'string' ) {
  1296. var idx = str.indexOf('@');
  1297. if ( idx !== -1 ) {
  1298. var src = str.substring( idx+1 );
  1299. o[ '@'+src ] = td.getAttribute( src );
  1300. }
  1301. }
  1302. };
  1303. var cellProcess = function ( cell ) {
  1304. col = columns[i];
  1305. contents = $.trim(cell.innerHTML);
  1306. if ( col && col._bAttrSrc ) {
  1307. o = {
  1308. display: contents
  1309. };
  1310. attr( col.mData.sort, o, cell );
  1311. attr( col.mData.type, o, cell );
  1312. attr( col.mData.filter, o, cell );
  1313. d.push( o );
  1314. }
  1315. else {
  1316. d.push( contents );
  1317. }
  1318. i++;
  1319. };
  1320. if ( td ) {
  1321. // `tr` element passed in
  1322. while ( td ) {
  1323. name = td.nodeName.toUpperCase();
  1324. if ( name == "TD" || name == "TH" ) {
  1325. cellProcess( td );
  1326. tds.push( td );
  1327. }
  1328. td = td.nextSibling;
  1329. }
  1330. }
  1331. else {
  1332. // Existing row object passed in
  1333. tds = row.anCells;
  1334. for ( var j=0, jen=tds.length ; j<jen ; j++ ) {
  1335. cellProcess( tds[j] );
  1336. }
  1337. }
  1338. return {
  1339. data: d,
  1340. cells: tds
  1341. };
  1342. }
  1343. /**
  1344. * Create a new TR element (and it's TD children) for a row
  1345. * @param {object} oSettings dataTables settings object
  1346. * @param {int} iRow Row to consider
  1347. * @param {node} [nTrIn] TR element to add to the table - optional. If not given,
  1348. * DataTables will create a row automatically
  1349. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  1350. * if nTr is.
  1351. * @memberof DataTable#oApi
  1352. */
  1353. function _fnCreateTr ( oSettings, iRow, nTrIn, anTds )
  1354. {
  1355. var
  1356. row = oSettings.aoData[iRow],
  1357. rowData = row._aData,
  1358. cells = [],
  1359. nTr, nTd, oCol,
  1360. i, iLen;
  1361. if ( row.nTr === null )
  1362. {
  1363. nTr = nTrIn || document.createElement('tr');
  1364. row.nTr = nTr;
  1365. row.anCells = cells;
  1366. /* Use a private property on the node to allow reserve mapping from the node
  1367. * to the aoData array for fast look up
  1368. */
  1369. nTr._DT_RowIndex = iRow;
  1370. /* Special parameters can be given by the data source to be used on the row */
  1371. _fnRowAttributes( row );
  1372. /* Process each column */
  1373. for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
  1374. {
  1375. oCol = oSettings.aoColumns[i];
  1376. nTd = nTrIn ? anTds[i] : document.createElement( oCol.sCellType );
  1377. cells.push( nTd );
  1378. // Need to create the HTML if new, or if a rendering function is defined
  1379. if ( !nTrIn || oCol.mRender || oCol.mData !== i )
  1380. {
  1381. nTd.innerHTML = _fnGetCellData( oSettings, iRow, i, 'display' );
  1382. }
  1383. /* Add user defined class */
  1384. if ( oCol.sClass )
  1385. {
  1386. nTd.className += ' '+oCol.sClass;
  1387. }
  1388. // Visibility - add or remove as required
  1389. if ( oCol.bVisible && ! nTrIn )
  1390. {
  1391. nTr.appendChild( nTd );
  1392. }
  1393. else if ( ! oCol.bVisible && nTrIn )
  1394. {
  1395. nTd.parentNode.removeChild( nTd );
  1396. }
  1397. if ( oCol.fnCreatedCell )
  1398. {
  1399. oCol.fnCreatedCell.call( oSettings.oInstance,
  1400. nTd, _fnGetCellData( oSettings, iRow, i ), rowData, iRow, i
  1401. );
  1402. }
  1403. }
  1404. _fnCallbackFire( oSettings, 'aoRowCreatedCallback', null, [nTr, rowData, iRow] );
  1405. }
  1406. // Remove once webkit bug 131819 and Chromium bug 365619 have been resolved
  1407. // and deployed
  1408. row.nTr.setAttribute( 'role', 'row' );
  1409. }
  1410. /**
  1411. * Add attributes to a row based on the special `DT_*` parameters in a data
  1412. * source object.
  1413. * @param {object} DataTables row object for the row to be modified
  1414. * @memberof DataTable#oApi
  1415. */
  1416. function _fnRowAttributes( row )
  1417. {
  1418. var tr = row.nTr;
  1419. var data = row._aData;
  1420. if ( tr ) {
  1421. if ( data.DT_RowId ) {
  1422. tr.id = data.DT_RowId;
  1423. }
  1424. if ( data.DT_RowClass ) {
  1425. // Remove any classes added by DT_RowClass before
  1426. var a = data.DT_RowClass.split(' ');
  1427. row.__rowc = row.__rowc ?
  1428. _unique( row.__rowc.concat( a ) ) :
  1429. a;
  1430. $(tr)
  1431. .removeClass( row.__rowc.join(' ') )
  1432. .addClass( data.DT_RowClass );
  1433. }
  1434. if ( data.DT_RowData ) {
  1435. $(tr).data( data.DT_RowData );
  1436. }
  1437. }
  1438. }
  1439. /**
  1440. * Create the HTML header for the table
  1441. * @param {object} oSettings dataTables settings object
  1442. * @memberof DataTable#oApi
  1443. */
  1444. function _fnBuildHead( oSettings )
  1445. {
  1446. var i, ien, cell, row, column;
  1447. var thead = oSettings.nTHead;
  1448. var tfoot = oSettings.nTFoot;
  1449. var createHeader = $('th, td', thead).length === 0;
  1450. var classes = oSettings.oClasses;
  1451. var columns = oSettings.aoColumns;
  1452. if ( createHeader ) {
  1453. row = $('<tr/>').appendTo( thead );
  1454. }
  1455. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  1456. column = columns[i];
  1457. cell = $( column.nTh ).addClass( column.sClass );
  1458. if ( createHeader ) {
  1459. cell.appendTo( row );
  1460. }
  1461. // 1.11 move into sorting
  1462. if ( oSettings.oFeatures.bSort ) {
  1463. cell.addClass( column.sSortingClass );
  1464. if ( column.bSortable !== false ) {
  1465. cell
  1466. .attr( 'tabindex', oSettings.iTabIndex )
  1467. .attr( 'aria-controls', oSettings.sTableId );
  1468. _fnSortAttachListener( oSettings, column.nTh, i );
  1469. }
  1470. }
  1471. if ( column.sTitle != cell.html() ) {
  1472. cell.html( column.sTitle );
  1473. }
  1474. _fnRenderer( oSettings, 'header' )(
  1475. oSettings, cell, column, classes
  1476. );
  1477. }
  1478. if ( createHeader ) {
  1479. _fnDetectHeader( oSettings.aoHeader, thead );
  1480. }
  1481. /* ARIA role for the rows */
  1482. $(thead).find('>tr').attr('role', 'row');
  1483. /* Deal with the footer - add classes if required */
  1484. $(thead).find('>tr>th, >tr>td').addClass( classes.sHeaderTH );
  1485. $(tfoot).find('>tr>th, >tr>td').addClass( classes.sFooterTH );
  1486. // Cache the footer cells. Note that we only take the cells from the first
  1487. // row in the footer. If there is more than one row the user wants to
  1488. // interact with, they need to use the table().foot() method. Note also this
  1489. // allows cells to be used for multiple columns using colspan
  1490. if ( tfoot !== null ) {
  1491. var cells = oSettings.aoFooter[0];
  1492. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  1493. column = columns[i];
  1494. column.nTf = cells[i].cell;
  1495. if ( column.sClass ) {
  1496. $(column.nTf).addClass( column.sClass );
  1497. }
  1498. }
  1499. }
  1500. }
  1501. /**
  1502. * Draw the header (or footer) element based on the column visibility states. The
  1503. * methodology here is to use the layout array from _fnDetectHeader, modified for
  1504. * the instantaneous column visibility, to construct the new layout. The grid is
  1505. * traversed over cell at a time in a rows x columns grid fashion, although each
  1506. * cell insert can cover multiple elements in the grid - which is tracks using the
  1507. * aApplied array. Cell inserts in the grid will only occur where there isn't
  1508. * already a cell in that position.
  1509. * @param {object} oSettings dataTables settings object
  1510. * @param array {objects} aoSource Layout array from _fnDetectHeader
  1511. * @param {boolean} [bIncludeHidden=false] If true then include the hidden columns in the calc,
  1512. * @memberof DataTable#oApi
  1513. */
  1514. function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
  1515. {
  1516. var i, iLen, j, jLen, k, kLen, n, nLocalTr;
  1517. var aoLocal = [];
  1518. var aApplied = [];
  1519. var iColumns = oSettings.aoColumns.length;
  1520. var iRowspan, iColspan;
  1521. if ( ! aoSource )
  1522. {
  1523. return;
  1524. }
  1525. if ( bIncludeHidden === undefined )
  1526. {
  1527. bIncludeHidden = false;
  1528. }
  1529. /* Make a copy of the master layout array, but without the visible columns in it */
  1530. for ( i=0, iLen=aoSource.length ; i<iLen ; i++ )
  1531. {
  1532. aoLocal[i] = aoSource[i].slice();
  1533. aoLocal[i].nTr = aoSource[i].nTr;
  1534. /* Remove any columns which are currently hidden */
  1535. for ( j=iColumns-1 ; j>=0 ; j-- )
  1536. {
  1537. if ( !oSettings.aoColumns[j].bVisible && !bIncludeHidden )
  1538. {
  1539. aoLocal[i].splice( j, 1 );
  1540. }
  1541. }
  1542. /* Prep the applied array - it needs an element for each row */
  1543. aApplied.push( [] );
  1544. }
  1545. for ( i=0, iLen=aoLocal.length ; i<iLen ; i++ )
  1546. {
  1547. nLocalTr = aoLocal[i].nTr;
  1548. /* All cells are going to be replaced, so empty out the row */
  1549. if ( nLocalTr )
  1550. {
  1551. while( (n = nLocalTr.firstChild) )
  1552. {
  1553. nLocalTr.removeChild( n );
  1554. }
  1555. }
  1556. for ( j=0, jLen=aoLocal[i].length ; j<jLen ; j++ )
  1557. {
  1558. iRowspan = 1;
  1559. iColspan = 1;
  1560. /* Check to see if there is already a cell (row/colspan) covering our target
  1561. * insert point. If there is, then there is nothing to do.
  1562. */
  1563. if ( aApplied[i][j] === undefined )
  1564. {
  1565. nLocalTr.appendChild( aoLocal[i][j].cell );
  1566. aApplied[i][j] = 1;
  1567. /* Expand the cell to cover as many rows as needed */
  1568. while ( aoLocal[i+iRowspan] !== undefined &&
  1569. aoLocal[i][j].cell == aoLocal[i+iRowspan][j].cell )
  1570. {
  1571. aApplied[i+iRowspan][j] = 1;
  1572. iRowspan++;
  1573. }
  1574. /* Expand the cell to cover as many columns as needed */
  1575. while ( aoLocal[i][j+iColspan] !== undefined &&
  1576. aoLocal[i][j].cell == aoLocal[i][j+iColspan].cell )
  1577. {
  1578. /* Must update the applied array over the rows for the columns */
  1579. for ( k=0 ; k<iRowspan ; k++ )
  1580. {
  1581. aApplied[i+k][j+iColspan] = 1;
  1582. }
  1583. iColspan++;
  1584. }
  1585. /* Do the actual expansion in the DOM */
  1586. $(aoLocal[i][j].cell)
  1587. .attr('rowspan', iRowspan)
  1588. .attr('colspan', iColspan);
  1589. }
  1590. }
  1591. }
  1592. }
  1593. /**
  1594. * Insert the required TR nodes into the table for display
  1595. * @param {object} oSettings dataTables settings object
  1596. * @memberof DataTable#oApi
  1597. */
  1598. function _fnDraw( oSettings )
  1599. {
  1600. /* Provide a pre-callback function which can be used to cancel the draw is false is returned */
  1601. var aPreDraw = _fnCallbackFire( oSettings, 'aoPreDrawCallback', 'preDraw', [oSettings] );
  1602. if ( $.inArray( false, aPreDraw ) !== -1 )
  1603. {
  1604. _fnProcessingDisplay( oSettings, false );
  1605. return;
  1606. }
  1607. var i, iLen, n;
  1608. var anRows = [];
  1609. var iRowCount = 0;
  1610. var asStripeClasses = oSettings.asStripeClasses;
  1611. var iStripes = asStripeClasses.length;
  1612. var iOpenRows = oSettings.aoOpenRows.length;
  1613. var oLang = oSettings.oLanguage;
  1614. var iInitDisplayStart = oSettings.iInitDisplayStart;
  1615. var bServerSide = _fnDataSource( oSettings ) == 'ssp';
  1616. var aiDisplay = oSettings.aiDisplay;
  1617. oSettings.bDrawing = true;
  1618. /* Check and see if we have an initial draw position from state saving */
  1619. if ( iInitDisplayStart !== undefined && iInitDisplayStart !== -1 )
  1620. {
  1621. oSettings._iDisplayStart = bServerSide ?
  1622. iInitDisplayStart :
  1623. iInitDisplayStart >= oSettings.fnRecordsDisplay() ?
  1624. 0 :
  1625. iInitDisplayStart;
  1626. oSettings.iInitDisplayStart = -1;
  1627. }
  1628. var iDisplayStart = oSettings._iDisplayStart;
  1629. var iDisplayEnd = oSettings.fnDisplayEnd();
  1630. /* Server-side processing draw intercept */
  1631. if ( oSettings.bDeferLoading )
  1632. {
  1633. oSettings.bDeferLoading = false;
  1634. oSettings.iDraw++;
  1635. _fnProcessingDisplay( oSettings, false );
  1636. }
  1637. else if ( !bServerSide )
  1638. {
  1639. oSettings.iDraw++;
  1640. }
  1641. else if ( !oSettings.bDestroying && !_fnAjaxUpdate( oSettings ) )
  1642. {
  1643. return;
  1644. }
  1645. if ( aiDisplay.length !== 0 )
  1646. {
  1647. var iStart = bServerSide ? 0 : iDisplayStart;
  1648. var iEnd = bServerSide ? oSettings.aoData.length : iDisplayEnd;
  1649. for ( var j=iStart ; j<iEnd ; j++ )
  1650. {
  1651. var iDataIndex = aiDisplay[j];
  1652. var aoData = oSettings.aoData[ iDataIndex ];
  1653. if ( aoData.nTr === null )
  1654. {
  1655. _fnCreateTr( oSettings, iDataIndex );
  1656. }
  1657. var nRow = aoData.nTr;
  1658. /* Remove the old striping classes and then add the new one */
  1659. if ( iStripes !== 0 )
  1660. {
  1661. var sStripe = asStripeClasses[ iRowCount % iStripes ];
  1662. if ( aoData._sRowStripe != sStripe )
  1663. {
  1664. $(nRow).removeClass( aoData._sRowStripe ).addClass( sStripe );
  1665. aoData._sRowStripe = sStripe;
  1666. }
  1667. }
  1668. /* Row callback functions - might want to manipulate the row */
  1669. _fnCallbackFire( oSettings, 'aoRowCallback', null,
  1670. [nRow, aoData._aData, iRowCount, j] );
  1671. anRows.push( nRow );
  1672. iRowCount++;
  1673. }
  1674. }
  1675. else
  1676. {
  1677. /* Table is empty - create a row with an empty message in it */
  1678. var sZero = oLang.sZeroRecords;
  1679. if ( oSettings.iDraw == 1 && _fnDataSource( oSettings ) == 'ajax' )
  1680. {
  1681. sZero = oLang.sLoadingRecords;
  1682. }
  1683. else if ( oLang.sEmptyTable && oSettings.fnRecordsTotal() === 0 )
  1684. {
  1685. sZero = oLang.sEmptyTable;
  1686. }
  1687. anRows[ 0 ] = $( '<tr/>', { 'class': iStripes ? asStripeClasses[0] : '' } )
  1688. .append( $('<td />', {
  1689. 'valign': 'top',
  1690. 'colSpan': _fnVisbleColumns( oSettings ),
  1691. 'class': oSettings.oClasses.sRowEmpty
  1692. } ).html( sZero ) )[0];
  1693. }
  1694. /* Header and footer callbacks */
  1695. _fnCallbackFire( oSettings, 'aoHeaderCallback', 'header', [ $(oSettings.nTHead).children('tr')[0],
  1696. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  1697. _fnCallbackFire( oSettings, 'aoFooterCallback', 'footer', [ $(oSettings.nTFoot).children('tr')[0],
  1698. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  1699. var body = $(oSettings.nTBody);
  1700. body.children().detach();
  1701. body.append( $(anRows) );
  1702. /* Call all required callback functions for the end of a draw */
  1703. _fnCallbackFire( oSettings, 'aoDrawCallback', 'draw', [oSettings] );
  1704. /* Draw is complete, sorting and filtering must be as well */
  1705. oSettings.bSorted = false;
  1706. oSettings.bFiltered = false;
  1707. oSettings.bDrawing = false;
  1708. }
  1709. /**
  1710. * Redraw the table - taking account of the various features which are enabled
  1711. * @param {object} oSettings dataTables settings object
  1712. * @param {boolean} [holdPosition] Keep the current paging position. By default
  1713. * the paging is reset to the first page
  1714. * @memberof DataTable#oApi
  1715. */
  1716. function _fnReDraw( settings, holdPosition )
  1717. {
  1718. var
  1719. features = settings.oFeatures,
  1720. sort = features.bSort,
  1721. filter = features.bFilter;
  1722. if ( sort ) {
  1723. _fnSort( settings );
  1724. }
  1725. if ( filter ) {
  1726. _fnFilterComplete( settings, settings.oPreviousSearch );
  1727. }
  1728. else {
  1729. // No filtering, so we want to just use the display master
  1730. settings.aiDisplay = settings.aiDisplayMaster.slice();
  1731. }
  1732. if ( holdPosition !== true ) {
  1733. settings._iDisplayStart = 0;
  1734. }
  1735. // Let any modules know about the draw hold position state (used by
  1736. // scrolling internally)
  1737. settings._drawHold = holdPosition;
  1738. _fnDraw( settings );
  1739. settings._drawHold = false;
  1740. }
  1741. /**
  1742. * Add the options to the page HTML for the table
  1743. * @param {object} oSettings dataTables settings object
  1744. * @memberof DataTable#oApi
  1745. */
  1746. function _fnAddOptionsHtml ( oSettings )
  1747. {
  1748. var classes = oSettings.oClasses;
  1749. var table = $(oSettings.nTable);
  1750. var holding = $('<div/>').insertBefore( table ); // Holding element for speed
  1751. var features = oSettings.oFeatures;
  1752. // All DataTables are wrapped in a div
  1753. var insert = $('<div/>', {
  1754. id: oSettings.sTableId+'_wrapper',
  1755. 'class': classes.sWrapper + (oSettings.nTFoot ? '' : ' '+classes.sNoFooter)
  1756. } );
  1757. oSettings.nHolding = holding[0];
  1758. oSettings.nTableWrapper = insert[0];
  1759. oSettings.nTableReinsertBefore = oSettings.nTable.nextSibling;
  1760. /* Loop over the user set positioning and place the elements as needed */
  1761. var aDom = oSettings.sDom.split('');
  1762. var featureNode, cOption, nNewNode, cNext, sAttr, j;
  1763. for ( var i=0 ; i<aDom.length ; i++ )
  1764. {
  1765. featureNode = null;
  1766. cOption = aDom[i];
  1767. if ( cOption == '<' )
  1768. {
  1769. /* New container div */
  1770. nNewNode = $('<div/>')[0];
  1771. /* Check to see if we should append an id and/or a class name to the container */
  1772. cNext = aDom[i+1];
  1773. if ( cNext == "'" || cNext == '"' )
  1774. {
  1775. sAttr = "";
  1776. j = 2;
  1777. while ( aDom[i+j] != cNext )
  1778. {
  1779. sAttr += aDom[i+j];
  1780. j++;
  1781. }
  1782. /* Replace jQuery UI constants @todo depreciated */
  1783. if ( sAttr == "H" )
  1784. {
  1785. sAttr = classes.sJUIHeader;
  1786. }
  1787. else if ( sAttr == "F" )
  1788. {
  1789. sAttr = classes.sJUIFooter;
  1790. }
  1791. /* The attribute can be in the format of "#id.class", "#id" or "class" This logic
  1792. * breaks the string into parts and applies them as needed
  1793. */
  1794. if ( sAttr.indexOf('.') != -1 )
  1795. {
  1796. var aSplit = sAttr.split('.');
  1797. nNewNode.id = aSplit[0].substr(1, aSplit[0].length-1);
  1798. nNewNode.className = aSplit[1];
  1799. }
  1800. else if ( sAttr.charAt(0) == "#" )
  1801. {
  1802. nNewNode.id = sAttr.substr(1, sAttr.length-1);
  1803. }
  1804. else
  1805. {
  1806. nNewNode.className = sAttr;
  1807. }
  1808. i += j; /* Move along the position array */
  1809. }
  1810. insert.append( nNewNode );
  1811. insert = $(nNewNode);
  1812. }
  1813. else if ( cOption == '>' )
  1814. {
  1815. /* End container div */
  1816. insert = insert.parent();
  1817. }
  1818. // @todo Move options into their own plugins?
  1819. else if ( cOption == 'l' && features.bPaginate && features.bLengthChange )
  1820. {
  1821. /* Length */
  1822. featureNode = _fnFeatureHtmlLength( oSettings );
  1823. }
  1824. else if ( cOption == 'f' && features.bFilter )
  1825. {
  1826. /* Filter */
  1827. featureNode = _fnFeatureHtmlFilter( oSettings );
  1828. }
  1829. else if ( cOption == 'r' && features.bProcessing )
  1830. {
  1831. /* pRocessing */
  1832. featureNode = _fnFeatureHtmlProcessing( oSettings );
  1833. }
  1834. else if ( cOption == 't' )
  1835. {
  1836. /* Table */
  1837. featureNode = _fnFeatureHtmlTable( oSettings );
  1838. }
  1839. else if ( cOption == 'i' && features.bInfo )
  1840. {
  1841. /* Info */
  1842. featureNode = _fnFeatureHtmlInfo( oSettings );
  1843. }
  1844. else if ( cOption == 'p' && features.bPaginate )
  1845. {
  1846. /* Pagination */
  1847. featureNode = _fnFeatureHtmlPaginate( oSettings );
  1848. }
  1849. else if ( DataTable.ext.feature.length !== 0 )
  1850. {
  1851. /* Plug-in features */
  1852. var aoFeatures = DataTable.ext.feature;
  1853. for ( var k=0, kLen=aoFeatures.length ; k<kLen ; k++ )
  1854. {
  1855. if ( cOption == aoFeatures[k].cFeature )
  1856. {
  1857. featureNode = aoFeatures[k].fnInit( oSettings );
  1858. break;
  1859. }
  1860. }
  1861. }
  1862. /* Add to the 2D features array */
  1863. if ( featureNode )
  1864. {
  1865. var aanFeatures = oSettings.aanFeatures;
  1866. if ( ! aanFeatures[cOption] )
  1867. {
  1868. aanFeatures[cOption] = [];
  1869. }
  1870. aanFeatures[cOption].push( featureNode );
  1871. insert.append( featureNode );
  1872. }
  1873. }
  1874. /* Built our DOM structure - replace the holding div with what we want */
  1875. holding.replaceWith( insert );
  1876. }
  1877. /**
  1878. * Use the DOM source to create up an array of header cells. The idea here is to
  1879. * create a layout grid (array) of rows x columns, which contains a reference
  1880. * to the cell that that point in the grid (regardless of col/rowspan), such that
  1881. * any column / row could be removed and the new grid constructed
  1882. * @param array {object} aLayout Array to store the calculated layout in
  1883. * @param {node} nThead The header/footer element for the table
  1884. * @memberof DataTable#oApi
  1885. */
  1886. function _fnDetectHeader ( aLayout, nThead )
  1887. {
  1888. var nTrs = $(nThead).children('tr');
  1889. var nTr, nCell;
  1890. var i, k, l, iLen, jLen, iColShifted, iColumn, iColspan, iRowspan;
  1891. var bUnique;
  1892. var fnShiftCol = function ( a, i, j ) {
  1893. var k = a[i];
  1894. while ( k[j] ) {
  1895. j++;
  1896. }
  1897. return j;
  1898. };
  1899. aLayout.splice( 0, aLayout.length );
  1900. /* We know how many rows there are in the layout - so prep it */
  1901. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  1902. {
  1903. aLayout.push( [] );
  1904. }
  1905. /* Calculate a layout array */
  1906. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  1907. {
  1908. nTr = nTrs[i];
  1909. iColumn = 0;
  1910. /* For every cell in the row... */
  1911. nCell = nTr.firstChild;
  1912. while ( nCell ) {
  1913. if ( nCell.nodeName.toUpperCase() == "TD" ||
  1914. nCell.nodeName.toUpperCase() == "TH" )
  1915. {
  1916. /* Get the col and rowspan attributes from the DOM and sanitise them */
  1917. iColspan = nCell.getAttribute('colspan') * 1;
  1918. iRowspan = nCell.getAttribute('rowspan') * 1;
  1919. iColspan = (!iColspan || iColspan===0 || iColspan===1) ? 1 : iColspan;
  1920. iRowspan = (!iRowspan || iRowspan===0 || iRowspan===1) ? 1 : iRowspan;
  1921. /* There might be colspan cells already in this row, so shift our target
  1922. * accordingly
  1923. */
  1924. iColShifted = fnShiftCol( aLayout, i, iColumn );
  1925. /* Cache calculation for unique columns */
  1926. bUnique = iColspan === 1 ? true : false;
  1927. /* If there is col / rowspan, copy the information into the layout grid */
  1928. for ( l=0 ; l<iColspan ; l++ )
  1929. {
  1930. for ( k=0 ; k<iRowspan ; k++ )
  1931. {
  1932. aLayout[i+k][iColShifted+l] = {
  1933. "cell": nCell,
  1934. "unique": bUnique
  1935. };
  1936. aLayout[i+k].nTr = nTr;
  1937. }
  1938. }
  1939. }
  1940. nCell = nCell.nextSibling;
  1941. }
  1942. }
  1943. }
  1944. /**
  1945. * Get an array of unique th elements, one for each column
  1946. * @param {object} oSettings dataTables settings object
  1947. * @param {node} nHeader automatically detect the layout from this node - optional
  1948. * @param {array} aLayout thead/tfoot layout from _fnDetectHeader - optional
  1949. * @returns array {node} aReturn list of unique th's
  1950. * @memberof DataTable#oApi
  1951. */
  1952. function _fnGetUniqueThs ( oSettings, nHeader, aLayout )
  1953. {
  1954. var aReturn = [];
  1955. if ( !aLayout )
  1956. {
  1957. aLayout = oSettings.aoHeader;
  1958. if ( nHeader )
  1959. {
  1960. aLayout = [];
  1961. _fnDetectHeader( aLayout, nHeader );
  1962. }
  1963. }
  1964. for ( var i=0, iLen=aLayout.length ; i<iLen ; i++ )
  1965. {
  1966. for ( var j=0, jLen=aLayout[i].length ; j<jLen ; j++ )
  1967. {
  1968. if ( aLayout[i][j].unique &&
  1969. (!aReturn[j] || !oSettings.bSortCellsTop) )
  1970. {
  1971. aReturn[j] = aLayout[i][j].cell;
  1972. }
  1973. }
  1974. }
  1975. return aReturn;
  1976. }
  1977. /**
  1978. * Create an Ajax call based on the table's settings, taking into account that
  1979. * parameters can have multiple forms, and backwards compatibility.
  1980. *
  1981. * @param {object} oSettings dataTables settings object
  1982. * @param {array} data Data to send to the server, required by
  1983. * DataTables - may be augmented by developer callbacks
  1984. * @param {function} fn Callback function to run when data is obtained
  1985. */
  1986. function _fnBuildAjax( oSettings, data, fn )
  1987. {
  1988. // Compatibility with 1.9-, allow fnServerData and event to manipulate
  1989. _fnCallbackFire( oSettings, 'aoServerParams', 'serverParams', [data] );
  1990. // Convert to object based for 1.10+ if using the old array scheme which can
  1991. // come from server-side processing or serverParams
  1992. if ( data && $.isArray(data) ) {
  1993. var tmp = {};
  1994. var rbracket = /(.*?)\[\]$/;
  1995. $.each( data, function (key, val) {
  1996. var match = val.name.match(rbracket);
  1997. if ( match ) {
  1998. // Support for arrays
  1999. var name = match[0];
  2000. if ( ! tmp[ name ] ) {
  2001. tmp[ name ] = [];
  2002. }
  2003. tmp[ name ].push( val.value );
  2004. }
  2005. else {
  2006. tmp[val.name] = val.value;
  2007. }
  2008. } );
  2009. data = tmp;
  2010. }
  2011. var ajaxData;
  2012. var ajax = oSettings.ajax;
  2013. var instance = oSettings.oInstance;
  2014. if ( $.isPlainObject( ajax ) && ajax.data )
  2015. {
  2016. ajaxData = ajax.data;
  2017. var newData = $.isFunction( ajaxData ) ?
  2018. ajaxData( data ) : // fn can manipulate data or return an object
  2019. ajaxData; // object or array to merge
  2020. // If the function returned an object, use that alone
  2021. data = $.isFunction( ajaxData ) && newData ?
  2022. newData :
  2023. $.extend( true, data, newData );
  2024. // Remove the data property as we've resolved it already and don't want
  2025. // jQuery to do it again (it is restored at the end of the function)
  2026. delete ajax.data;
  2027. }
  2028. var baseAjax = {
  2029. "data": data,
  2030. "success": function (json) {
  2031. var error = json.error || json.sError;
  2032. if ( error ) {
  2033. oSettings.oApi._fnLog( oSettings, 0, error );
  2034. }
  2035. oSettings.json = json;
  2036. _fnCallbackFire( oSettings, null, 'xhr', [oSettings, json] );
  2037. fn( json );
  2038. },
  2039. "dataType": "json",
  2040. "cache": false,
  2041. "type": oSettings.sServerMethod,
  2042. "error": function (xhr, error, thrown) {
  2043. var log = oSettings.oApi._fnLog;
  2044. if ( error == "parsererror" ) {
  2045. log( oSettings, 0, 'Invalid JSON response', 1 );
  2046. }
  2047. else if ( xhr.readyState === 4 ) {
  2048. log( oSettings, 0, 'Ajax error', 7 );
  2049. }
  2050. _fnProcessingDisplay( oSettings, false );
  2051. }
  2052. };
  2053. // Store the data submitted for the API
  2054. oSettings.oAjaxData = data;
  2055. // Allow plug-ins and external processes to modify the data
  2056. _fnCallbackFire( oSettings, null, 'preXhr', [oSettings, data] );
  2057. if ( oSettings.fnServerData )
  2058. {
  2059. // DataTables 1.9- compatibility
  2060. oSettings.fnServerData.call( instance,
  2061. oSettings.sAjaxSource,
  2062. $.map( data, function (val, key) { // Need to convert back to 1.9 trad format
  2063. return { name: key, value: val };
  2064. } ),
  2065. fn,
  2066. oSettings
  2067. );
  2068. }
  2069. else if ( oSettings.sAjaxSource || typeof ajax === 'string' )
  2070. {
  2071. // DataTables 1.9- compatibility
  2072. oSettings.jqXHR = $.ajax( $.extend( baseAjax, {
  2073. url: ajax || oSettings.sAjaxSource
  2074. } ) );
  2075. }
  2076. else if ( $.isFunction( ajax ) )
  2077. {
  2078. // Is a function - let the caller define what needs to be done
  2079. oSettings.jqXHR = ajax.call( instance, data, fn, oSettings );
  2080. }
  2081. else
  2082. {
  2083. // Object to extend the base settings
  2084. oSettings.jqXHR = $.ajax( $.extend( baseAjax, ajax ) );
  2085. // Restore for next time around
  2086. ajax.data = ajaxData;
  2087. }
  2088. }
  2089. /**
  2090. * Update the table using an Ajax call
  2091. * @param {object} settings dataTables settings object
  2092. * @returns {boolean} Block the table drawing or not
  2093. * @memberof DataTable#oApi
  2094. */
  2095. function _fnAjaxUpdate( settings )
  2096. {
  2097. if ( settings.bAjaxDataGet ) {
  2098. settings.iDraw++;
  2099. _fnProcessingDisplay( settings, true );
  2100. _fnBuildAjax(
  2101. settings,
  2102. _fnAjaxParameters( settings ),
  2103. function(json) {
  2104. _fnAjaxUpdateDraw( settings, json );
  2105. }
  2106. );
  2107. return false;
  2108. }
  2109. return true;
  2110. }
  2111. /**
  2112. * Build up the parameters in an object needed for a server-side processing
  2113. * request. Note that this is basically done twice, is different ways - a modern
  2114. * method which is used by default in DataTables 1.10 which uses objects and
  2115. * arrays, or the 1.9- method with is name / value pairs. 1.9 method is used if
  2116. * the sAjaxSource option is used in the initialisation, or the legacyAjax
  2117. * option is set.
  2118. * @param {object} oSettings dataTables settings object
  2119. * @returns {bool} block the table drawing or not
  2120. * @memberof DataTable#oApi
  2121. */
  2122. function _fnAjaxParameters( settings )
  2123. {
  2124. var
  2125. columns = settings.aoColumns,
  2126. columnCount = columns.length,
  2127. features = settings.oFeatures,
  2128. preSearch = settings.oPreviousSearch,
  2129. preColSearch = settings.aoPreSearchCols,
  2130. i, data = [], dataProp, column, columnSearch,
  2131. sort = _fnSortFlatten( settings ),
  2132. displayStart = settings._iDisplayStart,
  2133. displayLength = features.bPaginate !== false ?
  2134. settings._iDisplayLength :
  2135. -1;
  2136. var param = function ( name, value ) {
  2137. data.push( { 'name': name, 'value': value } );
  2138. };
  2139. // DataTables 1.9- compatible method
  2140. param( 'sEcho', settings.iDraw );
  2141. param( 'iColumns', columnCount );
  2142. param( 'sColumns', _pluck( columns, 'sName' ).join(',') );
  2143. param( 'iDisplayStart', displayStart );
  2144. param( 'iDisplayLength', displayLength );
  2145. // DataTables 1.10+ method
  2146. var d = {
  2147. draw: settings.iDraw,
  2148. columns: [],
  2149. order: [],
  2150. start: displayStart,
  2151. length: displayLength,
  2152. search: {
  2153. value: preSearch.sSearch,
  2154. regex: preSearch.bRegex
  2155. }
  2156. };
  2157. for ( i=0 ; i<columnCount ; i++ ) {
  2158. column = columns[i];
  2159. columnSearch = preColSearch[i];
  2160. dataProp = typeof column.mData=="function" ? 'function' : column.mData ;
  2161. d.columns.push( {
  2162. data: dataProp,
  2163. name: column.sName,
  2164. searchable: column.bSearchable,
  2165. orderable: column.bSortable,
  2166. search: {
  2167. value: columnSearch.sSearch,
  2168. regex: columnSearch.bRegex
  2169. }
  2170. } );
  2171. param( "mDataProp_"+i, dataProp );
  2172. if ( features.bFilter ) {
  2173. param( 'sSearch_'+i, columnSearch.sSearch );
  2174. param( 'bRegex_'+i, columnSearch.bRegex );
  2175. param( 'bSearchable_'+i, column.bSearchable );
  2176. }
  2177. if ( features.bSort ) {
  2178. param( 'bSortable_'+i, column.bSortable );
  2179. }
  2180. }
  2181. if ( features.bFilter ) {
  2182. param( 'sSearch', preSearch.sSearch );
  2183. param( 'bRegex', preSearch.bRegex );
  2184. }
  2185. if ( features.bSort ) {
  2186. $.each( sort, function ( i, val ) {
  2187. d.order.push( { column: val.col, dir: val.dir } );
  2188. param( 'iSortCol_'+i, val.col );
  2189. param( 'sSortDir_'+i, val.dir );
  2190. } );
  2191. param( 'iSortingCols', sort.length );
  2192. }
  2193. // If the legacy.ajax parameter is null, then we automatically decide which
  2194. // form to use, based on sAjaxSource
  2195. var legacy = DataTable.ext.legacy.ajax;
  2196. if ( legacy === null ) {
  2197. return settings.sAjaxSource ? data : d;
  2198. }
  2199. // Otherwise, if legacy has been specified then we use that to decide on the
  2200. // form
  2201. return legacy ? data : d;
  2202. }
  2203. /**
  2204. * Data the data from the server (nuking the old) and redraw the table
  2205. * @param {object} oSettings dataTables settings object
  2206. * @param {object} json json data return from the server.
  2207. * @param {string} json.sEcho Tracking flag for DataTables to match requests
  2208. * @param {int} json.iTotalRecords Number of records in the data set, not accounting for filtering
  2209. * @param {int} json.iTotalDisplayRecords Number of records in the data set, accounting for filtering
  2210. * @param {array} json.aaData The data to display on this page
  2211. * @param {string} [json.sColumns] Column ordering (sName, comma separated)
  2212. * @memberof DataTable#oApi
  2213. */
  2214. function _fnAjaxUpdateDraw ( settings, json )
  2215. {
  2216. // v1.10 uses camelCase variables, while 1.9 uses Hungarian notation.
  2217. // Support both
  2218. var compat = function ( old, modern ) {
  2219. return json[old] !== undefined ? json[old] : json[modern];
  2220. };
  2221. var draw = compat( 'sEcho', 'draw' );
  2222. var recordsTotal = compat( 'iTotalRecords', 'recordsTotal' );
  2223. var rocordsFiltered = compat( 'iTotalDisplayRecords', 'recordsFiltered' );
  2224. if ( draw ) {
  2225. // Protect against out of sequence returns
  2226. if ( draw*1 < settings.iDraw ) {
  2227. return;
  2228. }
  2229. settings.iDraw = draw * 1;
  2230. }
  2231. _fnClearTable( settings );
  2232. settings._iRecordsTotal = parseInt(recordsTotal, 10);
  2233. settings._iRecordsDisplay = parseInt(rocordsFiltered, 10);
  2234. var data = _fnAjaxDataSrc( settings, json );
  2235. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  2236. _fnAddData( settings, data[i] );
  2237. }
  2238. settings.aiDisplay = settings.aiDisplayMaster.slice();
  2239. settings.bAjaxDataGet = false;
  2240. _fnDraw( settings );
  2241. if ( ! settings._bInitComplete ) {
  2242. _fnInitComplete( settings, json );
  2243. }
  2244. settings.bAjaxDataGet = true;
  2245. _fnProcessingDisplay( settings, false );
  2246. }
  2247. /**
  2248. * Get the data from the JSON data source to use for drawing a table. Using
  2249. * `_fnGetObjectDataFn` allows the data to be sourced from a property of the
  2250. * source object, or from a processing function.
  2251. * @param {object} oSettings dataTables settings object
  2252. * @param {object} json Data source object / array from the server
  2253. * @return {array} Array of data to use
  2254. */
  2255. function _fnAjaxDataSrc ( oSettings, json )
  2256. {
  2257. var dataSrc = $.isPlainObject( oSettings.ajax ) && oSettings.ajax.dataSrc !== undefined ?
  2258. oSettings.ajax.dataSrc :
  2259. oSettings.sAjaxDataProp; // Compatibility with 1.9-.
  2260. // Compatibility with 1.9-. In order to read from aaData, check if the
  2261. // default has been changed, if not, check for aaData
  2262. if ( dataSrc === 'data' ) {
  2263. return json.aaData || json[dataSrc];
  2264. }
  2265. return dataSrc !== "" ?
  2266. _fnGetObjectDataFn( dataSrc )( json ) :
  2267. json;
  2268. }
  2269. /**
  2270. * Generate the node required for filtering text
  2271. * @returns {node} Filter control element
  2272. * @param {object} oSettings dataTables settings object
  2273. * @memberof DataTable#oApi
  2274. */
  2275. function _fnFeatureHtmlFilter ( settings )
  2276. {
  2277. var classes = settings.oClasses;
  2278. var tableId = settings.sTableId;
  2279. var language = settings.oLanguage;
  2280. var previousSearch = settings.oPreviousSearch;
  2281. var features = settings.aanFeatures;
  2282. var input = '<input type="search" class="'+classes.sFilterInput+'"/>';
  2283. var str = language.sSearch;
  2284. str = str.match(/_INPUT_/) ?
  2285. str.replace('_INPUT_', input) :
  2286. str+input;
  2287. var filter = $('<div/>', {
  2288. 'id': ! features.f ? tableId+'_filter' : null,
  2289. 'class': classes.sFilter
  2290. } )
  2291. .append( $('<label/>' ).append( str ) );
  2292. var searchFn = function() {
  2293. /* Update all other filter input elements for the new display */
  2294. var n = features.f;
  2295. var val = !this.value ? "" : this.value; // mental IE8 fix :-(
  2296. /* Now do the filter */
  2297. if ( val != previousSearch.sSearch ) {
  2298. _fnFilterComplete( settings, {
  2299. "sSearch": val,
  2300. "bRegex": previousSearch.bRegex,
  2301. "bSmart": previousSearch.bSmart ,
  2302. "bCaseInsensitive": previousSearch.bCaseInsensitive
  2303. } );
  2304. // Need to redraw, without resorting
  2305. settings._iDisplayStart = 0;
  2306. _fnDraw( settings );
  2307. }
  2308. };
  2309. var jqFilter = $('input', filter)
  2310. .val( previousSearch.sSearch )
  2311. .attr( 'placeholder', language.sSearchPlaceholder )
  2312. .bind(
  2313. 'keyup.DT search.DT input.DT paste.DT cut.DT',
  2314. _fnDataSource( settings ) === 'ssp' ?
  2315. _fnThrottle( searchFn, 400 ):
  2316. searchFn
  2317. )
  2318. .bind( 'keypress.DT', function(e) {
  2319. /* Prevent form submission */
  2320. if ( e.keyCode == 13 ) {
  2321. return false;
  2322. }
  2323. } )
  2324. .attr('aria-controls', tableId);
  2325. // Update the input elements whenever the table is filtered
  2326. $(settings.nTable).on( 'search.dt.DT', function ( ev, s ) {
  2327. if ( settings === s ) {
  2328. // IE9 throws an 'unknown error' if document.activeElement is used
  2329. // inside an iframe or frame...
  2330. try {
  2331. if ( jqFilter[0] !== document.activeElement ) {
  2332. jqFilter.val( previousSearch.sSearch );
  2333. }
  2334. }
  2335. catch ( e ) {}
  2336. }
  2337. } );
  2338. return filter[0];
  2339. }
  2340. /**
  2341. * Filter the table using both the global filter and column based filtering
  2342. * @param {object} oSettings dataTables settings object
  2343. * @param {object} oSearch search information
  2344. * @param {int} [iForce] force a research of the master array (1) or not (undefined or 0)
  2345. * @memberof DataTable#oApi
  2346. */
  2347. function _fnFilterComplete ( oSettings, oInput, iForce )
  2348. {
  2349. var oPrevSearch = oSettings.oPreviousSearch;
  2350. var aoPrevSearch = oSettings.aoPreSearchCols;
  2351. var fnSaveFilter = function ( oFilter ) {
  2352. /* Save the filtering values */
  2353. oPrevSearch.sSearch = oFilter.sSearch;
  2354. oPrevSearch.bRegex = oFilter.bRegex;
  2355. oPrevSearch.bSmart = oFilter.bSmart;
  2356. oPrevSearch.bCaseInsensitive = oFilter.bCaseInsensitive;
  2357. };
  2358. var fnRegex = function ( o ) {
  2359. // Backwards compatibility with the bEscapeRegex option
  2360. return o.bEscapeRegex !== undefined ? !o.bEscapeRegex : o.bRegex;
  2361. };
  2362. // Resolve any column types that are unknown due to addition or invalidation
  2363. // @todo As per sort - can this be moved into an event handler?
  2364. _fnColumnTypes( oSettings );
  2365. /* In server-side processing all filtering is done by the server, so no point hanging around here */
  2366. if ( _fnDataSource( oSettings ) != 'ssp' )
  2367. {
  2368. /* Global filter */
  2369. _fnFilter( oSettings, oInput.sSearch, iForce, fnRegex(oInput), oInput.bSmart, oInput.bCaseInsensitive );
  2370. fnSaveFilter( oInput );
  2371. /* Now do the individual column filter */
  2372. for ( var i=0 ; i<aoPrevSearch.length ; i++ )
  2373. {
  2374. _fnFilterColumn( oSettings, aoPrevSearch[i].sSearch, i, fnRegex(aoPrevSearch[i]),
  2375. aoPrevSearch[i].bSmart, aoPrevSearch[i].bCaseInsensitive );
  2376. }
  2377. /* Custom filtering */
  2378. _fnFilterCustom( oSettings );
  2379. }
  2380. else
  2381. {
  2382. fnSaveFilter( oInput );
  2383. }
  2384. /* Tell the draw function we have been filtering */
  2385. oSettings.bFiltered = true;
  2386. _fnCallbackFire( oSettings, null, 'search', [oSettings] );
  2387. }
  2388. /**
  2389. * Apply custom filtering functions
  2390. * @param {object} oSettings dataTables settings object
  2391. * @memberof DataTable#oApi
  2392. */
  2393. function _fnFilterCustom( settings )
  2394. {
  2395. var filters = DataTable.ext.search;
  2396. var displayRows = settings.aiDisplay;
  2397. var row, rowIdx;
  2398. for ( var i=0, ien=filters.length ; i<ien ; i++ ) {
  2399. var rows = [];
  2400. // Loop over each row and see if it should be included
  2401. for ( var j=0, jen=displayRows.length ; j<jen ; j++ ) {
  2402. rowIdx = displayRows[ j ];
  2403. row = settings.aoData[ rowIdx ];
  2404. if ( filters[i]( settings, row._aFilterData, rowIdx, row._aData, j ) ) {
  2405. rows.push( rowIdx );
  2406. }
  2407. }
  2408. // So the array reference doesn't break set the results into the
  2409. // existing array
  2410. displayRows.length = 0;
  2411. displayRows.push.apply( displayRows, rows );
  2412. }
  2413. }
  2414. /**
  2415. * Filter the table on a per-column basis
  2416. * @param {object} oSettings dataTables settings object
  2417. * @param {string} sInput string to filter on
  2418. * @param {int} iColumn column to filter
  2419. * @param {bool} bRegex treat search string as a regular expression or not
  2420. * @param {bool} bSmart use smart filtering or not
  2421. * @param {bool} bCaseInsensitive Do case insenstive matching or not
  2422. * @memberof DataTable#oApi
  2423. */
  2424. function _fnFilterColumn ( settings, searchStr, colIdx, regex, smart, caseInsensitive )
  2425. {
  2426. if ( searchStr === '' ) {
  2427. return;
  2428. }
  2429. var data;
  2430. var display = settings.aiDisplay;
  2431. var rpSearch = _fnFilterCreateSearch( searchStr, regex, smart, caseInsensitive );
  2432. for ( var i=display.length-1 ; i>=0 ; i-- ) {
  2433. data = settings.aoData[ display[i] ]._aFilterData[ colIdx ];
  2434. if ( ! rpSearch.test( data ) ) {
  2435. display.splice( i, 1 );
  2436. }
  2437. }
  2438. }
  2439. /**
  2440. * Filter the data table based on user input and draw the table
  2441. * @param {object} settings dataTables settings object
  2442. * @param {string} input string to filter on
  2443. * @param {int} force optional - force a research of the master array (1) or not (undefined or 0)
  2444. * @param {bool} regex treat as a regular expression or not
  2445. * @param {bool} smart perform smart filtering or not
  2446. * @param {bool} caseInsensitive Do case insenstive matching or not
  2447. * @memberof DataTable#oApi
  2448. */
  2449. function _fnFilter( settings, input, force, regex, smart, caseInsensitive )
  2450. {
  2451. var rpSearch = _fnFilterCreateSearch( input, regex, smart, caseInsensitive );
  2452. var prevSearch = settings.oPreviousSearch.sSearch;
  2453. var displayMaster = settings.aiDisplayMaster;
  2454. var display, invalidated, i;
  2455. // Need to take account of custom filtering functions - always filter
  2456. if ( DataTable.ext.search.length !== 0 ) {
  2457. force = true;
  2458. }
  2459. // Check if any of the rows were invalidated
  2460. invalidated = _fnFilterData( settings );
  2461. // If the input is blank - we just want the full data set
  2462. if ( input.length <= 0 ) {
  2463. settings.aiDisplay = displayMaster.slice();
  2464. }
  2465. else {
  2466. // New search - start from the master array
  2467. if ( invalidated ||
  2468. force ||
  2469. prevSearch.length > input.length ||
  2470. input.indexOf(prevSearch) !== 0 ||
  2471. settings.bSorted // On resort, the display master needs to be
  2472. // re-filtered since indexes will have changed
  2473. ) {
  2474. settings.aiDisplay = displayMaster.slice();
  2475. }
  2476. // Search the display array
  2477. display = settings.aiDisplay;
  2478. for ( i=display.length-1 ; i>=0 ; i-- ) {
  2479. if ( ! rpSearch.test( settings.aoData[ display[i] ]._sFilterRow ) ) {
  2480. display.splice( i, 1 );
  2481. }
  2482. }
  2483. }
  2484. }
  2485. /**
  2486. * Build a regular expression object suitable for searching a table
  2487. * @param {string} sSearch string to search for
  2488. * @param {bool} bRegex treat as a regular expression or not
  2489. * @param {bool} bSmart perform smart filtering or not
  2490. * @param {bool} bCaseInsensitive Do case insensitive matching or not
  2491. * @returns {RegExp} constructed object
  2492. * @memberof DataTable#oApi
  2493. */
  2494. function _fnFilterCreateSearch( search, regex, smart, caseInsensitive )
  2495. {
  2496. search = regex ?
  2497. search :
  2498. _fnEscapeRegex( search );
  2499. if ( smart ) {
  2500. /* For smart filtering we want to allow the search to work regardless of
  2501. * word order. We also want double quoted text to be preserved, so word
  2502. * order is important - a la google. So this is what we want to
  2503. * generate:
  2504. *
  2505. * ^(?=.*?\bone\b)(?=.*?\btwo three\b)(?=.*?\bfour\b).*$
  2506. */
  2507. var a = $.map( search.match( /"[^"]+"|[^ ]+/g ) || '', function ( word ) {
  2508. return word.charAt(0) === '"' ?
  2509. word.match( /^"(.*)"$/ )[1] :
  2510. word;
  2511. } );
  2512. search = '^(?=.*?'+a.join( ')(?=.*?' )+').*$';
  2513. }
  2514. return new RegExp( search, caseInsensitive ? 'i' : '' );
  2515. }
  2516. /**
  2517. * scape a string such that it can be used in a regular expression
  2518. * @param {string} sVal string to escape
  2519. * @returns {string} escaped string
  2520. * @memberof DataTable#oApi
  2521. */
  2522. function _fnEscapeRegex ( sVal )
  2523. {
  2524. return sVal.replace( _re_escape_regex, '\\$1' );
  2525. }
  2526. var __filter_div = $('<div>')[0];
  2527. var __filter_div_textContent = __filter_div.textContent !== undefined;
  2528. // Update the filtering data for each row if needed (by invalidation or first run)
  2529. function _fnFilterData ( settings )
  2530. {
  2531. var columns = settings.aoColumns;
  2532. var column;
  2533. var i, j, ien, jen, filterData, cellData, row;
  2534. var fomatters = DataTable.ext.type.search;
  2535. var wasInvalidated = false;
  2536. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  2537. row = settings.aoData[i];
  2538. if ( ! row._aFilterData ) {
  2539. filterData = [];
  2540. for ( j=0, jen=columns.length ; j<jen ; j++ ) {
  2541. column = columns[j];
  2542. if ( column.bSearchable ) {
  2543. cellData = _fnGetCellData( settings, i, j, 'filter' );
  2544. if ( fomatters[ column.sType ] ) {
  2545. cellData = fomatters[ column.sType ]( cellData );
  2546. }
  2547. // Search in DataTables 1.10 is string based. In 1.11 this
  2548. // should be altered to also allow strict type checking.
  2549. if ( cellData === null ) {
  2550. cellData = '';
  2551. }
  2552. if ( typeof cellData !== 'string' && cellData.toString ) {
  2553. cellData = cellData.toString();
  2554. }
  2555. }
  2556. else {
  2557. cellData = '';
  2558. }
  2559. // If it looks like there is an HTML entity in the string,
  2560. // attempt to decode it so sorting works as expected. Note that
  2561. // we could use a single line of jQuery to do this, but the DOM
  2562. // method used here is much faster http://jsperf.com/html-decode
  2563. if ( cellData.indexOf && cellData.indexOf('&') !== -1 ) {
  2564. __filter_div.innerHTML = cellData;
  2565. cellData = __filter_div_textContent ?
  2566. __filter_div.textContent :
  2567. __filter_div.innerText;
  2568. }
  2569. if ( cellData.replace ) {
  2570. cellData = cellData.replace(/[\r\n]/g, '');
  2571. }
  2572. filterData.push( cellData );
  2573. }
  2574. row._aFilterData = filterData;
  2575. row._sFilterRow = filterData.join(' ');
  2576. wasInvalidated = true;
  2577. }
  2578. }
  2579. return wasInvalidated;
  2580. }
  2581. /**
  2582. * Convert from the internal Hungarian notation to camelCase for external
  2583. * interaction
  2584. * @param {object} obj Object to convert
  2585. * @returns {object} Inverted object
  2586. * @memberof DataTable#oApi
  2587. */
  2588. function _fnSearchToCamel ( obj )
  2589. {
  2590. return {
  2591. search: obj.sSearch,
  2592. smart: obj.bSmart,
  2593. regex: obj.bRegex,
  2594. caseInsensitive: obj.bCaseInsensitive
  2595. };
  2596. }
  2597. /**
  2598. * Convert from camelCase notation to the internal Hungarian. We could use the
  2599. * Hungarian convert function here, but this is cleaner
  2600. * @param {object} obj Object to convert
  2601. * @returns {object} Inverted object
  2602. * @memberof DataTable#oApi
  2603. */
  2604. function _fnSearchToHung ( obj )
  2605. {
  2606. return {
  2607. sSearch: obj.search,
  2608. bSmart: obj.smart,
  2609. bRegex: obj.regex,
  2610. bCaseInsensitive: obj.caseInsensitive
  2611. };
  2612. }
  2613. /**
  2614. * Generate the node required for the info display
  2615. * @param {object} oSettings dataTables settings object
  2616. * @returns {node} Information element
  2617. * @memberof DataTable#oApi
  2618. */
  2619. function _fnFeatureHtmlInfo ( settings )
  2620. {
  2621. var
  2622. tid = settings.sTableId,
  2623. nodes = settings.aanFeatures.i,
  2624. n = $('<div/>', {
  2625. 'class': settings.oClasses.sInfo,
  2626. 'id': ! nodes ? tid+'_info' : null
  2627. } );
  2628. if ( ! nodes ) {
  2629. // Update display on each draw
  2630. settings.aoDrawCallback.push( {
  2631. "fn": _fnUpdateInfo,
  2632. "sName": "information"
  2633. } );
  2634. n
  2635. .attr( 'role', 'status' )
  2636. .attr( 'aria-live', 'polite' );
  2637. // Table is described by our info div
  2638. $(settings.nTable).attr( 'aria-describedby', tid+'_info' );
  2639. }
  2640. return n[0];
  2641. }
  2642. /**
  2643. * Update the information elements in the display
  2644. * @param {object} settings dataTables settings object
  2645. * @memberof DataTable#oApi
  2646. */
  2647. function _fnUpdateInfo ( settings )
  2648. {
  2649. /* Show information about the table */
  2650. var nodes = settings.aanFeatures.i;
  2651. if ( nodes.length === 0 ) {
  2652. return;
  2653. }
  2654. var
  2655. lang = settings.oLanguage,
  2656. start = settings._iDisplayStart+1,
  2657. end = settings.fnDisplayEnd(),
  2658. max = settings.fnRecordsTotal(),
  2659. total = settings.fnRecordsDisplay(),
  2660. out = total ?
  2661. lang.sInfo :
  2662. lang.sInfoEmpty;
  2663. if ( total !== max ) {
  2664. /* Record set after filtering */
  2665. out += ' ' + lang.sInfoFiltered;
  2666. }
  2667. // Convert the macros
  2668. out += lang.sInfoPostFix;
  2669. out = _fnInfoMacros( settings, out );
  2670. var callback = lang.fnInfoCallback;
  2671. if ( callback !== null ) {
  2672. out = callback.call( settings.oInstance,
  2673. settings, start, end, max, total, out
  2674. );
  2675. }
  2676. $(nodes).html( out );
  2677. }
  2678. function _fnInfoMacros ( settings, str )
  2679. {
  2680. // When infinite scrolling, we are always starting at 1. _iDisplayStart is used only
  2681. // internally
  2682. var
  2683. formatter = settings.fnFormatNumber,
  2684. start = settings._iDisplayStart+1,
  2685. len = settings._iDisplayLength,
  2686. vis = settings.fnRecordsDisplay(),
  2687. all = len === -1;
  2688. return str.
  2689. replace(/_START_/g, formatter.call( settings, start ) ).
  2690. replace(/_END_/g, formatter.call( settings, settings.fnDisplayEnd() ) ).
  2691. replace(/_MAX_/g, formatter.call( settings, settings.fnRecordsTotal() ) ).
  2692. replace(/_TOTAL_/g, formatter.call( settings, vis ) ).
  2693. replace(/_PAGE_/g, formatter.call( settings, all ? 1 : Math.ceil( start / len ) ) ).
  2694. replace(/_PAGES_/g, formatter.call( settings, all ? 1 : Math.ceil( vis / len ) ) );
  2695. }
  2696. /**
  2697. * Draw the table for the first time, adding all required features
  2698. * @param {object} settings dataTables settings object
  2699. * @memberof DataTable#oApi
  2700. */
  2701. function _fnInitialise ( settings )
  2702. {
  2703. var i, iLen, iAjaxStart=settings.iInitDisplayStart;
  2704. var columns = settings.aoColumns, column;
  2705. var features = settings.oFeatures;
  2706. /* Ensure that the table data is fully initialised */
  2707. if ( ! settings.bInitialised ) {
  2708. setTimeout( function(){ _fnInitialise( settings ); }, 200 );
  2709. return;
  2710. }
  2711. /* Show the display HTML options */
  2712. _fnAddOptionsHtml( settings );
  2713. /* Build and draw the header / footer for the table */
  2714. _fnBuildHead( settings );
  2715. _fnDrawHead( settings, settings.aoHeader );
  2716. _fnDrawHead( settings, settings.aoFooter );
  2717. /* Okay to show that something is going on now */
  2718. _fnProcessingDisplay( settings, true );
  2719. /* Calculate sizes for columns */
  2720. if ( features.bAutoWidth ) {
  2721. _fnCalculateColumnWidths( settings );
  2722. }
  2723. for ( i=0, iLen=columns.length ; i<iLen ; i++ ) {
  2724. column = columns[i];
  2725. if ( column.sWidth ) {
  2726. column.nTh.style.width = _fnStringToCss( column.sWidth );
  2727. }
  2728. }
  2729. // If there is default sorting required - let's do it. The sort function
  2730. // will do the drawing for us. Otherwise we draw the table regardless of the
  2731. // Ajax source - this allows the table to look initialised for Ajax sourcing
  2732. // data (show 'loading' message possibly)
  2733. _fnReDraw( settings );
  2734. // Server-side processing init complete is done by _fnAjaxUpdateDraw
  2735. var dataSrc = _fnDataSource( settings );
  2736. if ( dataSrc != 'ssp' ) {
  2737. // if there is an ajax source load the data
  2738. if ( dataSrc == 'ajax' ) {
  2739. _fnBuildAjax( settings, [], function(json) {
  2740. var aData = _fnAjaxDataSrc( settings, json );
  2741. // Got the data - add it to the table
  2742. for ( i=0 ; i<aData.length ; i++ ) {
  2743. _fnAddData( settings, aData[i] );
  2744. }
  2745. // Reset the init display for cookie saving. We've already done
  2746. // a filter, and therefore cleared it before. So we need to make
  2747. // it appear 'fresh'
  2748. settings.iInitDisplayStart = iAjaxStart;
  2749. _fnReDraw( settings );
  2750. _fnProcessingDisplay( settings, false );
  2751. _fnInitComplete( settings, json );
  2752. }, settings );
  2753. }
  2754. else {
  2755. _fnProcessingDisplay( settings, false );
  2756. _fnInitComplete( settings );
  2757. }
  2758. }
  2759. }
  2760. /**
  2761. * Draw the table for the first time, adding all required features
  2762. * @param {object} oSettings dataTables settings object
  2763. * @param {object} [json] JSON from the server that completed the table, if using Ajax source
  2764. * with client-side processing (optional)
  2765. * @memberof DataTable#oApi
  2766. */
  2767. function _fnInitComplete ( settings, json )
  2768. {
  2769. settings._bInitComplete = true;
  2770. // On an Ajax load we now have data and therefore want to apply the column
  2771. // sizing
  2772. if ( json ) {
  2773. _fnAdjustColumnSizing( settings );
  2774. }
  2775. _fnCallbackFire( settings, 'aoInitComplete', 'init', [settings, json] );
  2776. }
  2777. function _fnLengthChange ( settings, val )
  2778. {
  2779. var len = parseInt( val, 10 );
  2780. settings._iDisplayLength = len;
  2781. _fnLengthOverflow( settings );
  2782. // Fire length change event
  2783. _fnCallbackFire( settings, null, 'length', [settings, len] );
  2784. }
  2785. /**
  2786. * Generate the node required for user display length changing
  2787. * @param {object} settings dataTables settings object
  2788. * @returns {node} Display length feature node
  2789. * @memberof DataTable#oApi
  2790. */
  2791. function _fnFeatureHtmlLength ( settings )
  2792. {
  2793. var
  2794. classes = settings.oClasses,
  2795. tableId = settings.sTableId,
  2796. menu = settings.aLengthMenu,
  2797. d2 = $.isArray( menu[0] ),
  2798. lengths = d2 ? menu[0] : menu,
  2799. language = d2 ? menu[1] : menu;
  2800. var select = $('<select/>', {
  2801. 'name': tableId+'_length',
  2802. 'aria-controls': tableId,
  2803. 'class': classes.sLengthSelect
  2804. } );
  2805. for ( var i=0, ien=lengths.length ; i<ien ; i++ ) {
  2806. select[0][ i ] = new Option( language[i], lengths[i] );
  2807. }
  2808. var div = $('<div><label/></div>').addClass( classes.sLength );
  2809. if ( ! settings.aanFeatures.l ) {
  2810. div[0].id = tableId+'_length';
  2811. }
  2812. div.children().append(
  2813. settings.oLanguage.sLengthMenu.replace( '_MENU_', select[0].outerHTML )
  2814. );
  2815. // Can't use `select` variable as user might provide their own and the
  2816. // reference is broken by the use of outerHTML
  2817. $('select', div)
  2818. .val( settings._iDisplayLength )
  2819. .bind( 'change.DT', function(e) {
  2820. _fnLengthChange( settings, $(this).val() );
  2821. _fnDraw( settings );
  2822. } );
  2823. // Update node value whenever anything changes the table's length
  2824. $(settings.nTable).bind( 'length.dt.DT', function (e, s, len) {
  2825. if ( settings === s ) {
  2826. $('select', div).val( len );
  2827. }
  2828. } );
  2829. return div[0];
  2830. }
  2831. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  2832. * Note that most of the paging logic is done in
  2833. * DataTable.ext.pager
  2834. */
  2835. /**
  2836. * Generate the node required for default pagination
  2837. * @param {object} oSettings dataTables settings object
  2838. * @returns {node} Pagination feature node
  2839. * @memberof DataTable#oApi
  2840. */
  2841. function _fnFeatureHtmlPaginate ( settings )
  2842. {
  2843. var
  2844. type = settings.sPaginationType,
  2845. plugin = DataTable.ext.pager[ type ],
  2846. modern = typeof plugin === 'function',
  2847. redraw = function( settings ) {
  2848. _fnDraw( settings );
  2849. },
  2850. node = $('<div/>').addClass( settings.oClasses.sPaging + type )[0],
  2851. features = settings.aanFeatures;
  2852. if ( ! modern ) {
  2853. plugin.fnInit( settings, node, redraw );
  2854. }
  2855. /* Add a draw callback for the pagination on first instance, to update the paging display */
  2856. if ( ! features.p )
  2857. {
  2858. node.id = settings.sTableId+'_paginate';
  2859. settings.aoDrawCallback.push( {
  2860. "fn": function( settings ) {
  2861. if ( modern ) {
  2862. var
  2863. start = settings._iDisplayStart,
  2864. len = settings._iDisplayLength,
  2865. visRecords = settings.fnRecordsDisplay(),
  2866. all = len === -1,
  2867. page = all ? 0 : Math.ceil( start / len ),
  2868. pages = all ? 1 : Math.ceil( visRecords / len ),
  2869. buttons = plugin(page, pages),
  2870. i, ien;
  2871. for ( i=0, ien=features.p.length ; i<ien ; i++ ) {
  2872. _fnRenderer( settings, 'pageButton' )(
  2873. settings, features.p[i], i, buttons, page, pages
  2874. );
  2875. }
  2876. }
  2877. else {
  2878. plugin.fnUpdate( settings, redraw );
  2879. }
  2880. },
  2881. "sName": "pagination"
  2882. } );
  2883. }
  2884. return node;
  2885. }
  2886. /**
  2887. * Alter the display settings to change the page
  2888. * @param {object} settings DataTables settings object
  2889. * @param {string|int} action Paging action to take: "first", "previous",
  2890. * "next" or "last" or page number to jump to (integer)
  2891. * @param [bool] redraw Automatically draw the update or not
  2892. * @returns {bool} true page has changed, false - no change
  2893. * @memberof DataTable#oApi
  2894. */
  2895. function _fnPageChange ( settings, action, redraw )
  2896. {
  2897. var
  2898. start = settings._iDisplayStart,
  2899. len = settings._iDisplayLength,
  2900. records = settings.fnRecordsDisplay();
  2901. if ( records === 0 || len === -1 )
  2902. {
  2903. start = 0;
  2904. }
  2905. else if ( typeof action === "number" )
  2906. {
  2907. start = action * len;
  2908. if ( start > records )
  2909. {
  2910. start = 0;
  2911. }
  2912. }
  2913. else if ( action == "first" )
  2914. {
  2915. start = 0;
  2916. }
  2917. else if ( action == "previous" )
  2918. {
  2919. start = len >= 0 ?
  2920. start - len :
  2921. 0;
  2922. if ( start < 0 )
  2923. {
  2924. start = 0;
  2925. }
  2926. }
  2927. else if ( action == "next" )
  2928. {
  2929. if ( start + len < records )
  2930. {
  2931. start += len;
  2932. }
  2933. }
  2934. else if ( action == "last" )
  2935. {
  2936. start = Math.floor( (records-1) / len) * len;
  2937. }
  2938. else
  2939. {
  2940. _fnLog( settings, 0, "Unknown paging action: "+action, 5 );
  2941. }
  2942. var changed = settings._iDisplayStart !== start;
  2943. settings._iDisplayStart = start;
  2944. if ( changed ) {
  2945. _fnCallbackFire( settings, null, 'page', [settings] );
  2946. if ( redraw ) {
  2947. _fnDraw( settings );
  2948. }
  2949. }
  2950. return changed;
  2951. }
  2952. /**
  2953. * Generate the node required for the processing node
  2954. * @param {object} settings dataTables settings object
  2955. * @returns {node} Processing element
  2956. * @memberof DataTable#oApi
  2957. */
  2958. function _fnFeatureHtmlProcessing ( settings )
  2959. {
  2960. return $('<div/>', {
  2961. 'id': ! settings.aanFeatures.r ? settings.sTableId+'_processing' : null,
  2962. 'class': settings.oClasses.sProcessing
  2963. } )
  2964. .html( settings.oLanguage.sProcessing )
  2965. .insertBefore( settings.nTable )[0];
  2966. }
  2967. /**
  2968. * Display or hide the processing indicator
  2969. * @param {object} settings dataTables settings object
  2970. * @param {bool} show Show the processing indicator (true) or not (false)
  2971. * @memberof DataTable#oApi
  2972. */
  2973. function _fnProcessingDisplay ( settings, show )
  2974. {
  2975. if ( settings.oFeatures.bProcessing ) {
  2976. $(settings.aanFeatures.r).css( 'display', show ? 'block' : 'none' );
  2977. }
  2978. _fnCallbackFire( settings, null, 'processing', [settings, show] );
  2979. }
  2980. /**
  2981. * Add any control elements for the table - specifically scrolling
  2982. * @param {object} settings dataTables settings object
  2983. * @returns {node} Node to add to the DOM
  2984. * @memberof DataTable#oApi
  2985. */
  2986. function _fnFeatureHtmlTable ( settings )
  2987. {
  2988. var table = $(settings.nTable);
  2989. // Add the ARIA grid role to the table
  2990. table.attr( 'role', 'grid' );
  2991. // Scrolling from here on in
  2992. var scroll = settings.oScroll;
  2993. if ( scroll.sX === '' && scroll.sY === '' ) {
  2994. return settings.nTable;
  2995. }
  2996. var scrollX = scroll.sX;
  2997. var scrollY = scroll.sY;
  2998. var classes = settings.oClasses;
  2999. var caption = table.children('caption');
  3000. var captionSide = caption.length ? caption[0]._captionSide : null;
  3001. var headerClone = $( table[0].cloneNode(false) );
  3002. var footerClone = $( table[0].cloneNode(false) );
  3003. var footer = table.children('tfoot');
  3004. var _div = '<div/>';
  3005. var size = function ( s ) {
  3006. return !s ? null : _fnStringToCss( s );
  3007. };
  3008. // This is fairly messy, but with x scrolling enabled, if the table has a
  3009. // width attribute, regardless of any width applied using the column width
  3010. // options, the browser will shrink or grow the table as needed to fit into
  3011. // that 100%. That would make the width options useless. So we remove it.
  3012. // This is okay, under the assumption that width:100% is applied to the
  3013. // table in CSS (it is in the default stylesheet) which will set the table
  3014. // width as appropriate (the attribute and css behave differently...)
  3015. if ( scroll.sX && table.attr('width') === '100%' ) {
  3016. table.removeAttr('width');
  3017. }
  3018. if ( ! footer.length ) {
  3019. footer = null;
  3020. }
  3021. /*
  3022. * The HTML structure that we want to generate in this function is:
  3023. * div - scroller
  3024. * div - scroll head
  3025. * div - scroll head inner
  3026. * table - scroll head table
  3027. * thead - thead
  3028. * div - scroll body
  3029. * table - table (master table)
  3030. * thead - thead clone for sizing
  3031. * tbody - tbody
  3032. * div - scroll foot
  3033. * div - scroll foot inner
  3034. * table - scroll foot table
  3035. * tfoot - tfoot
  3036. */
  3037. var scroller = $( _div, { 'class': classes.sScrollWrapper } )
  3038. .append(
  3039. $(_div, { 'class': classes.sScrollHead } )
  3040. .css( {
  3041. overflow: 'hidden',
  3042. position: 'relative',
  3043. border: 0,
  3044. width: scrollX ? size(scrollX) : '100%'
  3045. } )
  3046. .append(
  3047. $(_div, { 'class': classes.sScrollHeadInner } )
  3048. .css( {
  3049. 'box-sizing': 'content-box',
  3050. width: scroll.sXInner || '100%'
  3051. } )
  3052. .append(
  3053. headerClone
  3054. .removeAttr('id')
  3055. .css( 'margin-left', 0 )
  3056. .append(
  3057. table.children('thead')
  3058. )
  3059. )
  3060. )
  3061. .append( captionSide === 'top' ? caption : null )
  3062. )
  3063. .append(
  3064. $(_div, { 'class': classes.sScrollBody } )
  3065. .css( {
  3066. overflow: 'auto',
  3067. height: size( scrollY ),
  3068. width: size( scrollX )
  3069. } )
  3070. .append( table )
  3071. );
  3072. if ( footer ) {
  3073. scroller.append(
  3074. $(_div, { 'class': classes.sScrollFoot } )
  3075. .css( {
  3076. overflow: 'hidden',
  3077. border: 0,
  3078. width: scrollX ? size(scrollX) : '100%'
  3079. } )
  3080. .append(
  3081. $(_div, { 'class': classes.sScrollFootInner } )
  3082. .append(
  3083. footerClone
  3084. .removeAttr('id')
  3085. .css( 'margin-left', 0 )
  3086. .append(
  3087. table.children('tfoot')
  3088. )
  3089. )
  3090. )
  3091. .append( captionSide === 'bottom' ? caption : null )
  3092. );
  3093. }
  3094. var children = scroller.children();
  3095. var scrollHead = children[0];
  3096. var scrollBody = children[1];
  3097. var scrollFoot = footer ? children[2] : null;
  3098. // When the body is scrolled, then we also want to scroll the headers
  3099. if ( scrollX ) {
  3100. $(scrollBody).scroll( function (e) {
  3101. var scrollLeft = this.scrollLeft;
  3102. scrollHead.scrollLeft = scrollLeft;
  3103. if ( footer ) {
  3104. scrollFoot.scrollLeft = scrollLeft;
  3105. }
  3106. } );
  3107. }
  3108. settings.nScrollHead = scrollHead;
  3109. settings.nScrollBody = scrollBody;
  3110. settings.nScrollFoot = scrollFoot;
  3111. // On redraw - align columns
  3112. settings.aoDrawCallback.push( {
  3113. "fn": _fnScrollDraw,
  3114. "sName": "scrolling"
  3115. } );
  3116. return scroller[0];
  3117. }
  3118. /**
  3119. * Update the header, footer and body tables for resizing - i.e. column
  3120. * alignment.
  3121. *
  3122. * Welcome to the most horrible function DataTables. The process that this
  3123. * function follows is basically:
  3124. * 1. Re-create the table inside the scrolling div
  3125. * 2. Take live measurements from the DOM
  3126. * 3. Apply the measurements to align the columns
  3127. * 4. Clean up
  3128. *
  3129. * @param {object} settings dataTables settings object
  3130. * @memberof DataTable#oApi
  3131. */
  3132. function _fnScrollDraw ( settings )
  3133. {
  3134. // Given that this is such a monster function, a lot of variables are use
  3135. // to try and keep the minimised size as small as possible
  3136. var
  3137. scroll = settings.oScroll,
  3138. scrollX = scroll.sX,
  3139. scrollXInner = scroll.sXInner,
  3140. scrollY = scroll.sY,
  3141. barWidth = scroll.iBarWidth,
  3142. divHeader = $(settings.nScrollHead),
  3143. divHeaderStyle = divHeader[0].style,
  3144. divHeaderInner = divHeader.children('div'),
  3145. divHeaderInnerStyle = divHeaderInner[0].style,
  3146. divHeaderTable = divHeaderInner.children('table'),
  3147. divBodyEl = settings.nScrollBody,
  3148. divBody = $(divBodyEl),
  3149. divBodyStyle = divBodyEl.style,
  3150. divFooter = $(settings.nScrollFoot),
  3151. divFooterInner = divFooter.children('div'),
  3152. divFooterTable = divFooterInner.children('table'),
  3153. header = $(settings.nTHead),
  3154. table = $(settings.nTable),
  3155. tableEl = table[0],
  3156. tableStyle = tableEl.style,
  3157. footer = settings.nTFoot ? $(settings.nTFoot) : null,
  3158. browser = settings.oBrowser,
  3159. ie67 = browser.bScrollOversize,
  3160. headerTrgEls, footerTrgEls,
  3161. headerSrcEls, footerSrcEls,
  3162. headerCopy, footerCopy,
  3163. headerWidths=[], footerWidths=[],
  3164. headerContent=[],
  3165. idx, correction, sanityWidth,
  3166. zeroOut = function(nSizer) {
  3167. var style = nSizer.style;
  3168. style.paddingTop = "0";
  3169. style.paddingBottom = "0";
  3170. style.borderTopWidth = "0";
  3171. style.borderBottomWidth = "0";
  3172. style.height = 0;
  3173. };
  3174. /*
  3175. * 1. Re-create the table inside the scrolling div
  3176. */
  3177. // Remove the old minimised thead and tfoot elements in the inner table
  3178. table.children('thead, tfoot').remove();
  3179. // Clone the current header and footer elements and then place it into the inner table
  3180. headerCopy = header.clone().prependTo( table );
  3181. headerTrgEls = header.find('tr'); // original header is in its own table
  3182. headerSrcEls = headerCopy.find('tr');
  3183. headerCopy.find('th, td').removeAttr('tabindex');
  3184. if ( footer ) {
  3185. footerCopy = footer.clone().prependTo( table );
  3186. footerTrgEls = footer.find('tr'); // the original tfoot is in its own table and must be sized
  3187. footerSrcEls = footerCopy.find('tr');
  3188. }
  3189. /*
  3190. * 2. Take live measurements from the DOM - do not alter the DOM itself!
  3191. */
  3192. // Remove old sizing and apply the calculated column widths
  3193. // Get the unique column headers in the newly created (cloned) header. We want to apply the
  3194. // calculated sizes to this header
  3195. if ( ! scrollX )
  3196. {
  3197. divBodyStyle.width = '100%';
  3198. divHeader[0].style.width = '100%';
  3199. }
  3200. $.each( _fnGetUniqueThs( settings, headerCopy ), function ( i, el ) {
  3201. idx = _fnVisibleToColumnIndex( settings, i );
  3202. el.style.width = settings.aoColumns[idx].sWidth;
  3203. } );
  3204. if ( footer ) {
  3205. _fnApplyToChildren( function(n) {
  3206. n.style.width = "";
  3207. }, footerSrcEls );
  3208. }
  3209. // If scroll collapse is enabled, when we put the headers back into the body for sizing, we
  3210. // will end up forcing the scrollbar to appear, making our measurements wrong for when we
  3211. // then hide it (end of this function), so add the header height to the body scroller.
  3212. if ( scroll.bCollapse && scrollY !== "" ) {
  3213. divBodyStyle.height = (divBody[0].offsetHeight + header[0].offsetHeight)+"px";
  3214. }
  3215. // Size the table as a whole
  3216. sanityWidth = table.outerWidth();
  3217. if ( scrollX === "" ) {
  3218. // No x scrolling
  3219. tableStyle.width = "100%";
  3220. // IE7 will make the width of the table when 100% include the scrollbar
  3221. // - which is shouldn't. When there is a scrollbar we need to take this
  3222. // into account.
  3223. if ( ie67 && (table.find('tbody').height() > divBodyEl.offsetHeight ||
  3224. divBody.css('overflow-y') == "scroll")
  3225. ) {
  3226. tableStyle.width = _fnStringToCss( table.outerWidth() - barWidth);
  3227. }
  3228. }
  3229. else
  3230. {
  3231. // x scrolling
  3232. if ( scrollXInner !== "" ) {
  3233. // x scroll inner has been given - use it
  3234. tableStyle.width = _fnStringToCss(scrollXInner);
  3235. }
  3236. else if ( sanityWidth == divBody.width() && divBody.height() < table.height() ) {
  3237. // There is y-scrolling - try to take account of the y scroll bar
  3238. tableStyle.width = _fnStringToCss( sanityWidth-barWidth );
  3239. if ( table.outerWidth() > sanityWidth-barWidth ) {
  3240. // Not possible to take account of it
  3241. tableStyle.width = _fnStringToCss( sanityWidth );
  3242. }
  3243. }
  3244. else {
  3245. // When all else fails
  3246. tableStyle.width = _fnStringToCss( sanityWidth );
  3247. }
  3248. }
  3249. // Recalculate the sanity width - now that we've applied the required width,
  3250. // before it was a temporary variable. This is required because the column
  3251. // width calculation is done before this table DOM is created.
  3252. sanityWidth = table.outerWidth();
  3253. // Hidden header should have zero height, so remove padding and borders. Then
  3254. // set the width based on the real headers
  3255. // Apply all styles in one pass
  3256. _fnApplyToChildren( zeroOut, headerSrcEls );
  3257. // Read all widths in next pass
  3258. _fnApplyToChildren( function(nSizer) {
  3259. headerContent.push( nSizer.innerHTML );
  3260. headerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  3261. }, headerSrcEls );
  3262. // Apply all widths in final pass
  3263. _fnApplyToChildren( function(nToSize, i) {
  3264. nToSize.style.width = headerWidths[i];
  3265. }, headerTrgEls );
  3266. $(headerSrcEls).height(0);
  3267. /* Same again with the footer if we have one */
  3268. if ( footer )
  3269. {
  3270. _fnApplyToChildren( zeroOut, footerSrcEls );
  3271. _fnApplyToChildren( function(nSizer) {
  3272. footerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  3273. }, footerSrcEls );
  3274. _fnApplyToChildren( function(nToSize, i) {
  3275. nToSize.style.width = footerWidths[i];
  3276. }, footerTrgEls );
  3277. $(footerSrcEls).height(0);
  3278. }
  3279. /*
  3280. * 3. Apply the measurements
  3281. */
  3282. // "Hide" the header and footer that we used for the sizing. We need to keep
  3283. // the content of the cell so that the width applied to the header and body
  3284. // both match, but we want to hide it completely. We want to also fix their
  3285. // width to what they currently are
  3286. _fnApplyToChildren( function(nSizer, i) {
  3287. nSizer.innerHTML = '<div class="dataTables_sizing" style="height:0;overflow:hidden;">'+headerContent[i]+'</div>';
  3288. nSizer.style.width = headerWidths[i];
  3289. }, headerSrcEls );
  3290. if ( footer )
  3291. {
  3292. _fnApplyToChildren( function(nSizer, i) {
  3293. nSizer.innerHTML = "";
  3294. nSizer.style.width = footerWidths[i];
  3295. }, footerSrcEls );
  3296. }
  3297. // Sanity check that the table is of a sensible width. If not then we are going to get
  3298. // misalignment - try to prevent this by not allowing the table to shrink below its min width
  3299. if ( table.outerWidth() < sanityWidth )
  3300. {
  3301. // The min width depends upon if we have a vertical scrollbar visible or not */
  3302. correction = ((divBodyEl.scrollHeight > divBodyEl.offsetHeight ||
  3303. divBody.css('overflow-y') == "scroll")) ?
  3304. sanityWidth+barWidth :
  3305. sanityWidth;
  3306. // IE6/7 are a law unto themselves...
  3307. if ( ie67 && (divBodyEl.scrollHeight >
  3308. divBodyEl.offsetHeight || divBody.css('overflow-y') == "scroll")
  3309. ) {
  3310. tableStyle.width = _fnStringToCss( correction-barWidth );
  3311. }
  3312. // And give the user a warning that we've stopped the table getting too small
  3313. if ( scrollX === "" || scrollXInner !== "" ) {
  3314. _fnLog( settings, 1, 'Possible column misalignment', 6 );
  3315. }
  3316. }
  3317. else
  3318. {
  3319. correction = '100%';
  3320. }
  3321. // Apply to the container elements
  3322. divBodyStyle.width = _fnStringToCss( correction );
  3323. divHeaderStyle.width = _fnStringToCss( correction );
  3324. if ( footer ) {
  3325. settings.nScrollFoot.style.width = _fnStringToCss( correction );
  3326. }
  3327. /*
  3328. * 4. Clean up
  3329. */
  3330. if ( ! scrollY ) {
  3331. /* IE7< puts a vertical scrollbar in place (when it shouldn't be) due to subtracting
  3332. * the scrollbar height from the visible display, rather than adding it on. We need to
  3333. * set the height in order to sort this. Don't want to do it in any other browsers.
  3334. */
  3335. if ( ie67 ) {
  3336. divBodyStyle.height = _fnStringToCss( tableEl.offsetHeight+barWidth );
  3337. }
  3338. }
  3339. if ( scrollY && scroll.bCollapse ) {
  3340. divBodyStyle.height = _fnStringToCss( scrollY );
  3341. var iExtra = (scrollX && tableEl.offsetWidth > divBodyEl.offsetWidth) ?
  3342. barWidth :
  3343. 0;
  3344. if ( tableEl.offsetHeight < divBodyEl.offsetHeight ) {
  3345. divBodyStyle.height = _fnStringToCss( tableEl.offsetHeight+iExtra );
  3346. }
  3347. }
  3348. /* Finally set the width's of the header and footer tables */
  3349. var iOuterWidth = table.outerWidth();
  3350. divHeaderTable[0].style.width = _fnStringToCss( iOuterWidth );
  3351. divHeaderInnerStyle.width = _fnStringToCss( iOuterWidth );
  3352. // Figure out if there are scrollbar present - if so then we need a the header and footer to
  3353. // provide a bit more space to allow "overflow" scrolling (i.e. past the scrollbar)
  3354. var bScrolling = table.height() > divBodyEl.clientHeight || divBody.css('overflow-y') == "scroll";
  3355. var padding = 'padding' + (browser.bScrollbarLeft ? 'Left' : 'Right' );
  3356. divHeaderInnerStyle[ padding ] = bScrolling ? barWidth+"px" : "0px";
  3357. if ( footer ) {
  3358. divFooterTable[0].style.width = _fnStringToCss( iOuterWidth );
  3359. divFooterInner[0].style.width = _fnStringToCss( iOuterWidth );
  3360. divFooterInner[0].style[padding] = bScrolling ? barWidth+"px" : "0px";
  3361. }
  3362. /* Adjust the position of the header in case we loose the y-scrollbar */
  3363. divBody.scroll();
  3364. // If sorting or filtering has occurred, jump the scrolling back to the top
  3365. // only if we aren't holding the position
  3366. if ( (settings.bSorted || settings.bFiltered) && ! settings._drawHold ) {
  3367. divBodyEl.scrollTop = 0;
  3368. }
  3369. }
  3370. /**
  3371. * Apply a given function to the display child nodes of an element array (typically
  3372. * TD children of TR rows
  3373. * @param {function} fn Method to apply to the objects
  3374. * @param array {nodes} an1 List of elements to look through for display children
  3375. * @param array {nodes} an2 Another list (identical structure to the first) - optional
  3376. * @memberof DataTable#oApi
  3377. */
  3378. function _fnApplyToChildren( fn, an1, an2 )
  3379. {
  3380. var index=0, i=0, iLen=an1.length;
  3381. var nNode1, nNode2;
  3382. while ( i < iLen ) {
  3383. nNode1 = an1[i].firstChild;
  3384. nNode2 = an2 ? an2[i].firstChild : null;
  3385. while ( nNode1 ) {
  3386. if ( nNode1.nodeType === 1 ) {
  3387. if ( an2 ) {
  3388. fn( nNode1, nNode2, index );
  3389. }
  3390. else {
  3391. fn( nNode1, index );
  3392. }
  3393. index++;
  3394. }
  3395. nNode1 = nNode1.nextSibling;
  3396. nNode2 = an2 ? nNode2.nextSibling : null;
  3397. }
  3398. i++;
  3399. }
  3400. }
  3401. var __re_html_remove = /<.*?>/g;
  3402. /**
  3403. * Calculate the width of columns for the table
  3404. * @param {object} oSettings dataTables settings object
  3405. * @memberof DataTable#oApi
  3406. */
  3407. function _fnCalculateColumnWidths ( oSettings )
  3408. {
  3409. var
  3410. table = oSettings.nTable,
  3411. columns = oSettings.aoColumns,
  3412. scroll = oSettings.oScroll,
  3413. scrollY = scroll.sY,
  3414. scrollX = scroll.sX,
  3415. scrollXInner = scroll.sXInner,
  3416. columnCount = columns.length,
  3417. visibleColumns = _fnGetColumns( oSettings, 'bVisible' ),
  3418. headerCells = $('th', oSettings.nTHead),
  3419. tableWidthAttr = table.getAttribute('width'),
  3420. tableContainer = table.parentNode,
  3421. userInputs = false,
  3422. i, column, columnIdx, width, outerWidth;
  3423. /* Convert any user input sizes into pixel sizes */
  3424. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3425. column = columns[ visibleColumns[i] ];
  3426. if ( column.sWidth !== null ) {
  3427. column.sWidth = _fnConvertToWidth( column.sWidthOrig, tableContainer );
  3428. userInputs = true;
  3429. }
  3430. }
  3431. /* If the number of columns in the DOM equals the number that we have to
  3432. * process in DataTables, then we can use the offsets that are created by
  3433. * the web- browser. No custom sizes can be set in order for this to happen,
  3434. * nor scrolling used
  3435. */
  3436. if ( ! userInputs && ! scrollX && ! scrollY &&
  3437. columnCount == _fnVisbleColumns( oSettings ) &&
  3438. columnCount == headerCells.length
  3439. ) {
  3440. for ( i=0 ; i<columnCount ; i++ ) {
  3441. columns[i].sWidth = _fnStringToCss( headerCells.eq(i).width() );
  3442. }
  3443. }
  3444. else
  3445. {
  3446. // Otherwise construct a single row table with the widest node in the
  3447. // data, assign any user defined widths, then insert it into the DOM and
  3448. // allow the browser to do all the hard work of calculating table widths
  3449. var tmpTable = $(table).clone() // don't use cloneNode - IE8 will remove events on the main table
  3450. .empty()
  3451. .css( 'visibility', 'hidden' )
  3452. .removeAttr( 'id' )
  3453. .append( $(oSettings.nTHead).clone( false ) )
  3454. .append( $(oSettings.nTFoot).clone( false ) )
  3455. .append( $('<tbody><tr/></tbody>') );
  3456. // Remove any assigned widths from the footer (from scrolling)
  3457. tmpTable.find('tfoot th, tfoot td').css('width', '');
  3458. var tr = tmpTable.find( 'tbody tr' );
  3459. // Apply custom sizing to the cloned header
  3460. headerCells = _fnGetUniqueThs( oSettings, tmpTable.find('thead')[0] );
  3461. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3462. column = columns[ visibleColumns[i] ];
  3463. headerCells[i].style.width = column.sWidthOrig !== null && column.sWidthOrig !== '' ?
  3464. _fnStringToCss( column.sWidthOrig ) :
  3465. '';
  3466. }
  3467. // Find the widest cell for each column and put it into the table
  3468. if ( oSettings.aoData.length ) {
  3469. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3470. columnIdx = visibleColumns[i];
  3471. column = columns[ columnIdx ];
  3472. $( _fnGetWidestNode( oSettings, columnIdx ) )
  3473. .clone( false )
  3474. .append( column.sContentPadding )
  3475. .appendTo( tr );
  3476. }
  3477. }
  3478. // Table has been built, attach to the document so we can work with it
  3479. tmpTable.appendTo( tableContainer );
  3480. // When scrolling (X or Y) we want to set the width of the table as
  3481. // appropriate. However, when not scrolling leave the table width as it
  3482. // is. This results in slightly different, but I think correct behaviour
  3483. if ( scrollX && scrollXInner ) {
  3484. tmpTable.width( scrollXInner );
  3485. }
  3486. else if ( scrollX ) {
  3487. tmpTable.css( 'width', 'auto' );
  3488. if ( tmpTable.width() < tableContainer.offsetWidth ) {
  3489. tmpTable.width( tableContainer.offsetWidth );
  3490. }
  3491. }
  3492. else if ( scrollY ) {
  3493. tmpTable.width( tableContainer.offsetWidth );
  3494. }
  3495. else if ( tableWidthAttr ) {
  3496. tmpTable.width( tableWidthAttr );
  3497. }
  3498. // Take into account the y scrollbar
  3499. _fnScrollingWidthAdjust( oSettings, tmpTable[0] );
  3500. // Browsers need a bit of a hand when a width is assigned to any columns
  3501. // when x-scrolling as they tend to collapse the table to the min-width,
  3502. // even if we sent the column widths. So we need to keep track of what
  3503. // the table width should be by summing the user given values, and the
  3504. // automatic values
  3505. if ( scrollX )
  3506. {
  3507. var total = 0;
  3508. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3509. column = columns[ visibleColumns[i] ];
  3510. outerWidth = $(headerCells[i]).outerWidth();
  3511. total += column.sWidthOrig === null ?
  3512. outerWidth :
  3513. parseInt( column.sWidth, 10 ) + outerWidth - $(headerCells[i]).width();
  3514. }
  3515. tmpTable.width( _fnStringToCss( total ) );
  3516. table.style.width = _fnStringToCss( total );
  3517. }
  3518. // Get the width of each column in the constructed table
  3519. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3520. column = columns[ visibleColumns[i] ];
  3521. width = $(headerCells[i]).width();
  3522. if ( width ) {
  3523. column.sWidth = _fnStringToCss( width );
  3524. }
  3525. }
  3526. table.style.width = _fnStringToCss( tmpTable.css('width') );
  3527. // Finished with the table - ditch it
  3528. tmpTable.remove();
  3529. }
  3530. // If there is a width attr, we want to attach an event listener which
  3531. // allows the table sizing to automatically adjust when the window is
  3532. // resized. Use the width attr rather than CSS, since we can't know if the
  3533. // CSS is a relative value or absolute - DOM read is always px.
  3534. if ( tableWidthAttr ) {
  3535. table.style.width = _fnStringToCss( tableWidthAttr );
  3536. }
  3537. if ( (tableWidthAttr || scrollX) && ! oSettings._reszEvt ) {
  3538. $(window).bind('resize.DT-'+oSettings.sInstance, _fnThrottle( function () {
  3539. _fnAdjustColumnSizing( oSettings );
  3540. } ) );
  3541. oSettings._reszEvt = true;
  3542. }
  3543. }
  3544. /**
  3545. * Throttle the calls to a function. Arguments and context are maintained for
  3546. * the throttled function
  3547. * @param {function} fn Function to be called
  3548. * @param {int} [freq=200] call frequency in mS
  3549. * @returns {function} wrapped function
  3550. * @memberof DataTable#oApi
  3551. */
  3552. function _fnThrottle( fn, freq ) {
  3553. var
  3554. frequency = freq || 200,
  3555. last,
  3556. timer;
  3557. return function () {
  3558. var
  3559. that = this,
  3560. now = +new Date(),
  3561. args = arguments;
  3562. if ( last && now < last + frequency ) {
  3563. clearTimeout( timer );
  3564. timer = setTimeout( function () {
  3565. last = undefined;
  3566. fn.apply( that, args );
  3567. }, frequency );
  3568. }
  3569. else if ( last ) {
  3570. last = now;
  3571. fn.apply( that, args );
  3572. }
  3573. else {
  3574. last = now;
  3575. }
  3576. };
  3577. }
  3578. /**
  3579. * Convert a CSS unit width to pixels (e.g. 2em)
  3580. * @param {string} width width to be converted
  3581. * @param {node} parent parent to get the with for (required for relative widths) - optional
  3582. * @returns {int} width in pixels
  3583. * @memberof DataTable#oApi
  3584. */
  3585. function _fnConvertToWidth ( width, parent )
  3586. {
  3587. if ( ! width ) {
  3588. return 0;
  3589. }
  3590. var n = $('<div/>')
  3591. .css( 'width', _fnStringToCss( width ) )
  3592. .appendTo( parent || document.body );
  3593. var val = n[0].offsetWidth;
  3594. n.remove();
  3595. return val;
  3596. }
  3597. /**
  3598. * Adjust a table's width to take account of vertical scroll bar
  3599. * @param {object} oSettings dataTables settings object
  3600. * @param {node} n table node
  3601. * @memberof DataTable#oApi
  3602. */
  3603. function _fnScrollingWidthAdjust ( settings, n )
  3604. {
  3605. var scroll = settings.oScroll;
  3606. if ( scroll.sX || scroll.sY ) {
  3607. // When y-scrolling only, we want to remove the width of the scroll bar
  3608. // so the table + scroll bar will fit into the area available, otherwise
  3609. // we fix the table at its current size with no adjustment
  3610. var correction = ! scroll.sX ? scroll.iBarWidth : 0;
  3611. n.style.width = _fnStringToCss( $(n).outerWidth() - correction );
  3612. }
  3613. }
  3614. /**
  3615. * Get the widest node
  3616. * @param {object} settings dataTables settings object
  3617. * @param {int} colIdx column of interest
  3618. * @returns {node} widest table node
  3619. * @memberof DataTable#oApi
  3620. */
  3621. function _fnGetWidestNode( settings, colIdx )
  3622. {
  3623. var idx = _fnGetMaxLenString( settings, colIdx );
  3624. if ( idx < 0 ) {
  3625. return null;
  3626. }
  3627. var data = settings.aoData[ idx ];
  3628. return ! data.nTr ? // Might not have been created when deferred rendering
  3629. $('<td/>').html( _fnGetCellData( settings, idx, colIdx, 'display' ) )[0] :
  3630. data.anCells[ colIdx ];
  3631. }
  3632. /**
  3633. * Get the maximum strlen for each data column
  3634. * @param {object} settings dataTables settings object
  3635. * @param {int} colIdx column of interest
  3636. * @returns {string} max string length for each column
  3637. * @memberof DataTable#oApi
  3638. */
  3639. function _fnGetMaxLenString( settings, colIdx )
  3640. {
  3641. var s, max=-1, maxIdx = -1;
  3642. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  3643. s = _fnGetCellData( settings, i, colIdx, 'display' )+'';
  3644. s = s.replace( __re_html_remove, '' );
  3645. if ( s.length > max ) {
  3646. max = s.length;
  3647. maxIdx = i;
  3648. }
  3649. }
  3650. return maxIdx;
  3651. }
  3652. /**
  3653. * Append a CSS unit (only if required) to a string
  3654. * @param {string} value to css-ify
  3655. * @returns {string} value with css unit
  3656. * @memberof DataTable#oApi
  3657. */
  3658. function _fnStringToCss( s )
  3659. {
  3660. if ( s === null ) {
  3661. return '0px';
  3662. }
  3663. if ( typeof s == 'number' ) {
  3664. return s < 0 ?
  3665. '0px' :
  3666. s+'px';
  3667. }
  3668. // Check it has a unit character already
  3669. return s.match(/\d$/) ?
  3670. s+'px' :
  3671. s;
  3672. }
  3673. /**
  3674. * Get the width of a scroll bar in this browser being used
  3675. * @returns {int} width in pixels
  3676. * @memberof DataTable#oApi
  3677. */
  3678. function _fnScrollBarWidth ()
  3679. {
  3680. // On first run a static variable is set, since this is only needed once.
  3681. // Subsequent runs will just use the previously calculated value
  3682. if ( ! DataTable.__scrollbarWidth ) {
  3683. var inner = $('<p/>').css( {
  3684. width: '100%',
  3685. height: 200,
  3686. padding: 0
  3687. } )[0];
  3688. var outer = $('<div/>')
  3689. .css( {
  3690. position: 'absolute',
  3691. top: 0,
  3692. left: 0,
  3693. width: 200,
  3694. height: 150,
  3695. padding: 0,
  3696. overflow: 'hidden',
  3697. visibility: 'hidden'
  3698. } )
  3699. .append( inner )
  3700. .appendTo( 'body' );
  3701. var w1 = inner.offsetWidth;
  3702. outer.css( 'overflow', 'scroll' );
  3703. var w2 = inner.offsetWidth;
  3704. if ( w1 === w2 ) {
  3705. w2 = outer[0].clientWidth;
  3706. }
  3707. outer.remove();
  3708. DataTable.__scrollbarWidth = w1 - w2;
  3709. }
  3710. return DataTable.__scrollbarWidth;
  3711. }
  3712. function _fnSortFlatten ( settings )
  3713. {
  3714. var
  3715. i, iLen, k, kLen,
  3716. aSort = [],
  3717. aiOrig = [],
  3718. aoColumns = settings.aoColumns,
  3719. aDataSort, iCol, sType, srcCol,
  3720. fixed = settings.aaSortingFixed,
  3721. fixedObj = $.isPlainObject( fixed ),
  3722. nestedSort = [],
  3723. add = function ( a ) {
  3724. if ( a.length && ! $.isArray( a[0] ) ) {
  3725. // 1D array
  3726. nestedSort.push( a );
  3727. }
  3728. else {
  3729. // 2D array
  3730. nestedSort.push.apply( nestedSort, a );
  3731. }
  3732. };
  3733. // Build the sort array, with pre-fix and post-fix options if they have been
  3734. // specified
  3735. if ( $.isArray( fixed ) ) {
  3736. add( fixed );
  3737. }
  3738. if ( fixedObj && fixed.pre ) {
  3739. add( fixed.pre );
  3740. }
  3741. add( settings.aaSorting );
  3742. if (fixedObj && fixed.post ) {
  3743. add( fixed.post );
  3744. }
  3745. for ( i=0 ; i<nestedSort.length ; i++ )
  3746. {
  3747. srcCol = nestedSort[i][0];
  3748. aDataSort = aoColumns[ srcCol ].aDataSort;
  3749. for ( k=0, kLen=aDataSort.length ; k<kLen ; k++ )
  3750. {
  3751. iCol = aDataSort[k];
  3752. sType = aoColumns[ iCol ].sType || 'string';
  3753. aSort.push( {
  3754. src: srcCol,
  3755. col: iCol,
  3756. dir: nestedSort[i][1],
  3757. index: nestedSort[i][2],
  3758. type: sType,
  3759. formatter: DataTable.ext.type.order[ sType+"-pre" ]
  3760. } );
  3761. }
  3762. }
  3763. return aSort;
  3764. }
  3765. /**
  3766. * Change the order of the table
  3767. * @param {object} oSettings dataTables settings object
  3768. * @memberof DataTable#oApi
  3769. * @todo This really needs split up!
  3770. */
  3771. function _fnSort ( oSettings )
  3772. {
  3773. var
  3774. i, ien, iLen, j, jLen, k, kLen,
  3775. sDataType, nTh,
  3776. aiOrig = [],
  3777. oExtSort = DataTable.ext.type.order,
  3778. aoData = oSettings.aoData,
  3779. aoColumns = oSettings.aoColumns,
  3780. aDataSort, data, iCol, sType, oSort,
  3781. formatters = 0,
  3782. sortCol,
  3783. displayMaster = oSettings.aiDisplayMaster,
  3784. aSort;
  3785. // Resolve any column types that are unknown due to addition or invalidation
  3786. // @todo Can this be moved into a 'data-ready' handler which is called when
  3787. // data is going to be used in the table?
  3788. _fnColumnTypes( oSettings );
  3789. aSort = _fnSortFlatten( oSettings );
  3790. for ( i=0, ien=aSort.length ; i<ien ; i++ ) {
  3791. sortCol = aSort[i];
  3792. // Track if we can use the fast sort algorithm
  3793. if ( sortCol.formatter ) {
  3794. formatters++;
  3795. }
  3796. // Load the data needed for the sort, for each cell
  3797. _fnSortData( oSettings, sortCol.col );
  3798. }
  3799. /* No sorting required if server-side or no sorting array */
  3800. if ( _fnDataSource( oSettings ) != 'ssp' && aSort.length !== 0 )
  3801. {
  3802. // Create a value - key array of the current row positions such that we can use their
  3803. // current position during the sort, if values match, in order to perform stable sorting
  3804. for ( i=0, iLen=displayMaster.length ; i<iLen ; i++ ) {
  3805. aiOrig[ displayMaster[i] ] = i;
  3806. }
  3807. /* Do the sort - here we want multi-column sorting based on a given data source (column)
  3808. * and sorting function (from oSort) in a certain direction. It's reasonably complex to
  3809. * follow on it's own, but this is what we want (example two column sorting):
  3810. * fnLocalSorting = function(a,b){
  3811. * var iTest;
  3812. * iTest = oSort['string-asc']('data11', 'data12');
  3813. * if (iTest !== 0)
  3814. * return iTest;
  3815. * iTest = oSort['numeric-desc']('data21', 'data22');
  3816. * if (iTest !== 0)
  3817. * return iTest;
  3818. * return oSort['numeric-asc']( aiOrig[a], aiOrig[b] );
  3819. * }
  3820. * Basically we have a test for each sorting column, if the data in that column is equal,
  3821. * test the next column. If all columns match, then we use a numeric sort on the row
  3822. * positions in the original data array to provide a stable sort.
  3823. *
  3824. * Note - I know it seems excessive to have two sorting methods, but the first is around
  3825. * 15% faster, so the second is only maintained for backwards compatibility with sorting
  3826. * methods which do not have a pre-sort formatting function.
  3827. */
  3828. if ( formatters === aSort.length ) {
  3829. // All sort types have formatting functions
  3830. displayMaster.sort( function ( a, b ) {
  3831. var
  3832. x, y, k, test, sort,
  3833. len=aSort.length,
  3834. dataA = aoData[a]._aSortData,
  3835. dataB = aoData[b]._aSortData;
  3836. for ( k=0 ; k<len ; k++ ) {
  3837. sort = aSort[k];
  3838. x = dataA[ sort.col ];
  3839. y = dataB[ sort.col ];
  3840. test = x<y ? -1 : x>y ? 1 : 0;
  3841. if ( test !== 0 ) {
  3842. return sort.dir === 'asc' ? test : -test;
  3843. }
  3844. }
  3845. x = aiOrig[a];
  3846. y = aiOrig[b];
  3847. return x<y ? -1 : x>y ? 1 : 0;
  3848. } );
  3849. }
  3850. else {
  3851. // Depreciated - remove in 1.11 (providing a plug-in option)
  3852. // Not all sort types have formatting methods, so we have to call their sorting
  3853. // methods.
  3854. displayMaster.sort( function ( a, b ) {
  3855. var
  3856. x, y, k, l, test, sort, fn,
  3857. len=aSort.length,
  3858. dataA = aoData[a]._aSortData,
  3859. dataB = aoData[b]._aSortData;
  3860. for ( k=0 ; k<len ; k++ ) {
  3861. sort = aSort[k];
  3862. x = dataA[ sort.col ];
  3863. y = dataB[ sort.col ];
  3864. fn = oExtSort[ sort.type+"-"+sort.dir ] || oExtSort[ "string-"+sort.dir ];
  3865. test = fn( x, y );
  3866. if ( test !== 0 ) {
  3867. return test;
  3868. }
  3869. }
  3870. x = aiOrig[a];
  3871. y = aiOrig[b];
  3872. return x<y ? -1 : x>y ? 1 : 0;
  3873. } );
  3874. }
  3875. }
  3876. /* Tell the draw function that we have sorted the data */
  3877. oSettings.bSorted = true;
  3878. }
  3879. function _fnSortAria ( settings )
  3880. {
  3881. var label;
  3882. var nextSort;
  3883. var columns = settings.aoColumns;
  3884. var aSort = _fnSortFlatten( settings );
  3885. var oAria = settings.oLanguage.oAria;
  3886. // ARIA attributes - need to loop all columns, to update all (removing old
  3887. // attributes as needed)
  3888. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  3889. {
  3890. var col = columns[i];
  3891. var asSorting = col.asSorting;
  3892. var sTitle = col.sTitle.replace( /<.*?>/g, "" );
  3893. var th = col.nTh;
  3894. // IE7 is throwing an error when setting these properties with jQuery's
  3895. // attr() and removeAttr() methods...
  3896. th.removeAttribute('aria-sort');
  3897. /* In ARIA only the first sorting column can be marked as sorting - no multi-sort option */
  3898. if ( col.bSortable ) {
  3899. if ( aSort.length > 0 && aSort[0].col == i ) {
  3900. th.setAttribute('aria-sort', aSort[0].dir=="asc" ? "ascending" : "descending" );
  3901. nextSort = asSorting[ aSort[0].index+1 ] || asSorting[0];
  3902. }
  3903. else {
  3904. nextSort = asSorting[0];
  3905. }
  3906. label = sTitle + ( nextSort === "asc" ?
  3907. oAria.sSortAscending :
  3908. oAria.sSortDescending
  3909. );
  3910. }
  3911. else {
  3912. label = sTitle;
  3913. }
  3914. th.setAttribute('aria-label', label);
  3915. }
  3916. }
  3917. /**
  3918. * Function to run on user sort request
  3919. * @param {object} settings dataTables settings object
  3920. * @param {node} attachTo node to attach the handler to
  3921. * @param {int} colIdx column sorting index
  3922. * @param {boolean} [append=false] Append the requested sort to the existing
  3923. * sort if true (i.e. multi-column sort)
  3924. * @param {function} [callback] callback function
  3925. * @memberof DataTable#oApi
  3926. */
  3927. function _fnSortListener ( settings, colIdx, append, callback )
  3928. {
  3929. var col = settings.aoColumns[ colIdx ];
  3930. var sorting = settings.aaSorting;
  3931. var asSorting = col.asSorting;
  3932. var nextSortIdx;
  3933. var next = function ( a ) {
  3934. var idx = a._idx;
  3935. if ( idx === undefined ) {
  3936. idx = $.inArray( a[1], asSorting );
  3937. }
  3938. return idx+1 >= asSorting.length ? 0 : idx+1;
  3939. };
  3940. // Convert to 2D array if needed
  3941. if ( typeof sorting[0] === 'number' ) {
  3942. sorting = settings.aaSorting = [ sorting ];
  3943. }
  3944. // If appending the sort then we are multi-column sorting
  3945. if ( append && settings.oFeatures.bSortMulti ) {
  3946. // Are we already doing some kind of sort on this column?
  3947. var sortIdx = $.inArray( colIdx, _pluck(sorting, '0') );
  3948. if ( sortIdx !== -1 ) {
  3949. // Yes, modify the sort
  3950. nextSortIdx = next( sorting[sortIdx] );
  3951. sorting[sortIdx][1] = asSorting[ nextSortIdx ];
  3952. sorting[sortIdx]._idx = nextSortIdx;
  3953. }
  3954. else {
  3955. // No sort on this column yet
  3956. sorting.push( [ colIdx, asSorting[0], 0 ] );
  3957. sorting[sorting.length-1]._idx = 0;
  3958. }
  3959. }
  3960. else if ( sorting.length && sorting[0][0] == colIdx ) {
  3961. // Single column - already sorting on this column, modify the sort
  3962. nextSortIdx = next( sorting[0] );
  3963. sorting.length = 1;
  3964. sorting[0][1] = asSorting[ nextSortIdx ];
  3965. sorting[0]._idx = nextSortIdx;
  3966. }
  3967. else {
  3968. // Single column - sort only on this column
  3969. sorting.length = 0;
  3970. sorting.push( [ colIdx, asSorting[0] ] );
  3971. sorting[0]._idx = 0;
  3972. }
  3973. // Run the sort by calling a full redraw
  3974. _fnReDraw( settings );
  3975. // callback used for async user interaction
  3976. if ( typeof callback == 'function' ) {
  3977. callback( settings );
  3978. }
  3979. }
  3980. /**
  3981. * Attach a sort handler (click) to a node
  3982. * @param {object} settings dataTables settings object
  3983. * @param {node} attachTo node to attach the handler to
  3984. * @param {int} colIdx column sorting index
  3985. * @param {function} [callback] callback function
  3986. * @memberof DataTable#oApi
  3987. */
  3988. function _fnSortAttachListener ( settings, attachTo, colIdx, callback )
  3989. {
  3990. var col = settings.aoColumns[ colIdx ];
  3991. _fnBindAction( attachTo, {}, function (e) {
  3992. /* If the column is not sortable - don't to anything */
  3993. if ( col.bSortable === false ) {
  3994. return;
  3995. }
  3996. // If processing is enabled use a timeout to allow the processing
  3997. // display to be shown - otherwise to it synchronously
  3998. if ( settings.oFeatures.bProcessing ) {
  3999. _fnProcessingDisplay( settings, true );
  4000. setTimeout( function() {
  4001. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  4002. // In server-side processing, the draw callback will remove the
  4003. // processing display
  4004. if ( _fnDataSource( settings ) !== 'ssp' ) {
  4005. _fnProcessingDisplay( settings, false );
  4006. }
  4007. }, 0 );
  4008. }
  4009. else {
  4010. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  4011. }
  4012. } );
  4013. }
  4014. /**
  4015. * Set the sorting classes on table's body, Note: it is safe to call this function
  4016. * when bSort and bSortClasses are false
  4017. * @param {object} oSettings dataTables settings object
  4018. * @memberof DataTable#oApi
  4019. */
  4020. function _fnSortingClasses( settings )
  4021. {
  4022. var oldSort = settings.aLastSort;
  4023. var sortClass = settings.oClasses.sSortColumn;
  4024. var sort = _fnSortFlatten( settings );
  4025. var features = settings.oFeatures;
  4026. var i, ien, colIdx;
  4027. if ( features.bSort && features.bSortClasses ) {
  4028. // Remove old sorting classes
  4029. for ( i=0, ien=oldSort.length ; i<ien ; i++ ) {
  4030. colIdx = oldSort[i].src;
  4031. // Remove column sorting
  4032. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  4033. .removeClass( sortClass + (i<2 ? i+1 : 3) );
  4034. }
  4035. // Add new column sorting
  4036. for ( i=0, ien=sort.length ; i<ien ; i++ ) {
  4037. colIdx = sort[i].src;
  4038. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  4039. .addClass( sortClass + (i<2 ? i+1 : 3) );
  4040. }
  4041. }
  4042. settings.aLastSort = sort;
  4043. }
  4044. // Get the data to sort a column, be it from cache, fresh (populating the
  4045. // cache), or from a sort formatter
  4046. function _fnSortData( settings, idx )
  4047. {
  4048. // Custom sorting function - provided by the sort data type
  4049. var column = settings.aoColumns[ idx ];
  4050. var customSort = DataTable.ext.order[ column.sSortDataType ];
  4051. var customData;
  4052. if ( customSort ) {
  4053. customData = customSort.call( settings.oInstance, settings, idx,
  4054. _fnColumnIndexToVisible( settings, idx )
  4055. );
  4056. }
  4057. // Use / populate cache
  4058. var row, cellData;
  4059. var formatter = DataTable.ext.type.order[ column.sType+"-pre" ];
  4060. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  4061. row = settings.aoData[i];
  4062. if ( ! row._aSortData ) {
  4063. row._aSortData = [];
  4064. }
  4065. if ( ! row._aSortData[idx] || customSort ) {
  4066. cellData = customSort ?
  4067. customData[i] : // If there was a custom sort function, use data from there
  4068. _fnGetCellData( settings, i, idx, 'sort' );
  4069. row._aSortData[ idx ] = formatter ?
  4070. formatter( cellData ) :
  4071. cellData;
  4072. }
  4073. }
  4074. }
  4075. /**
  4076. * Save the state of a table
  4077. * @param {object} oSettings dataTables settings object
  4078. * @memberof DataTable#oApi
  4079. */
  4080. function _fnSaveState ( settings )
  4081. {
  4082. if ( !settings.oFeatures.bStateSave || settings.bDestroying )
  4083. {
  4084. return;
  4085. }
  4086. /* Store the interesting variables */
  4087. var state = {
  4088. time: +new Date(),
  4089. start: settings._iDisplayStart,
  4090. length: settings._iDisplayLength,
  4091. order: $.extend( true, [], settings.aaSorting ),
  4092. search: _fnSearchToCamel( settings.oPreviousSearch ),
  4093. columns: $.map( settings.aoColumns, function ( col, i ) {
  4094. return {
  4095. visible: col.bVisible,
  4096. search: _fnSearchToCamel( settings.aoPreSearchCols[i] )
  4097. };
  4098. } )
  4099. };
  4100. _fnCallbackFire( settings, "aoStateSaveParams", 'stateSaveParams', [settings, state] );
  4101. settings.oSavedState = state;
  4102. settings.fnStateSaveCallback.call( settings.oInstance, settings, state );
  4103. }
  4104. /**
  4105. * Attempt to load a saved table state
  4106. * @param {object} oSettings dataTables settings object
  4107. * @param {object} oInit DataTables init object so we can override settings
  4108. * @memberof DataTable#oApi
  4109. */
  4110. function _fnLoadState ( settings, oInit )
  4111. {
  4112. var i, ien;
  4113. var columns = settings.aoColumns;
  4114. if ( ! settings.oFeatures.bStateSave ) {
  4115. return;
  4116. }
  4117. var state = settings.fnStateLoadCallback.call( settings.oInstance, settings );
  4118. if ( ! state || ! state.time ) {
  4119. return;
  4120. }
  4121. /* Allow custom and plug-in manipulation functions to alter the saved data set and
  4122. * cancelling of loading by returning false
  4123. */
  4124. var abStateLoad = _fnCallbackFire( settings, 'aoStateLoadParams', 'stateLoadParams', [settings, state] );
  4125. if ( $.inArray( false, abStateLoad ) !== -1 ) {
  4126. return;
  4127. }
  4128. /* Reject old data */
  4129. var duration = settings.iStateDuration;
  4130. if ( duration > 0 && state.time < +new Date() - (duration*1000) ) {
  4131. return;
  4132. }
  4133. // Number of columns have changed - all bets are off, no restore of settings
  4134. if ( columns.length !== state.columns.length ) {
  4135. return;
  4136. }
  4137. // Store the saved state so it might be accessed at any time
  4138. settings.oLoadedState = $.extend( true, {}, state );
  4139. // Restore key features - todo - for 1.11 this needs to be done by
  4140. // subscribed events
  4141. settings._iDisplayStart = state.start;
  4142. settings.iInitDisplayStart = state.start;
  4143. settings._iDisplayLength = state.length;
  4144. settings.aaSorting = [];
  4145. // Order
  4146. $.each( state.order, function ( i, col ) {
  4147. settings.aaSorting.push( col[0] >= columns.length ?
  4148. [ 0, col[1] ] :
  4149. col
  4150. );
  4151. } );
  4152. // Search
  4153. $.extend( settings.oPreviousSearch, _fnSearchToHung( state.search ) );
  4154. // Columns
  4155. for ( i=0, ien=state.columns.length ; i<ien ; i++ ) {
  4156. var col = state.columns[i];
  4157. // Visibility
  4158. columns[i].bVisible = col.visible;
  4159. // Search
  4160. $.extend( settings.aoPreSearchCols[i], _fnSearchToHung( col.search ) );
  4161. }
  4162. _fnCallbackFire( settings, 'aoStateLoaded', 'stateLoaded', [settings, state] );
  4163. }
  4164. /**
  4165. * Return the settings object for a particular table
  4166. * @param {node} table table we are using as a dataTable
  4167. * @returns {object} Settings object - or null if not found
  4168. * @memberof DataTable#oApi
  4169. */
  4170. function _fnSettingsFromNode ( table )
  4171. {
  4172. var settings = DataTable.settings;
  4173. var idx = $.inArray( table, _pluck( settings, 'nTable' ) );
  4174. return idx !== -1 ?
  4175. settings[ idx ] :
  4176. null;
  4177. }
  4178. /**
  4179. * Log an error message
  4180. * @param {object} settings dataTables settings object
  4181. * @param {int} level log error messages, or display them to the user
  4182. * @param {string} msg error message
  4183. * @param {int} tn Technical note id to get more information about the error.
  4184. * @memberof DataTable#oApi
  4185. */
  4186. function _fnLog( settings, level, msg, tn )
  4187. {
  4188. msg = 'DataTables warning: '+
  4189. (settings!==null ? 'table id='+settings.sTableId+' - ' : '')+msg;
  4190. if ( tn ) {
  4191. msg += '. For more information about this error, please see '+
  4192. 'http://datatables.net/tn/'+tn;
  4193. }
  4194. if ( ! level ) {
  4195. // Backwards compatibility pre 1.10
  4196. var ext = DataTable.ext;
  4197. var type = ext.sErrMode || ext.errMode;
  4198. if ( type == 'alert' ) {
  4199. alert( msg );
  4200. }
  4201. else {
  4202. throw new Error(msg);
  4203. }
  4204. }
  4205. else if ( window.console && console.log ) {
  4206. console.log( msg );
  4207. }
  4208. }
  4209. /**
  4210. * See if a property is defined on one object, if so assign it to the other object
  4211. * @param {object} ret target object
  4212. * @param {object} src source object
  4213. * @param {string} name property
  4214. * @param {string} [mappedName] name to map too - optional, name used if not given
  4215. * @memberof DataTable#oApi
  4216. */
  4217. function _fnMap( ret, src, name, mappedName )
  4218. {
  4219. if ( $.isArray( name ) ) {
  4220. $.each( name, function (i, val) {
  4221. if ( $.isArray( val ) ) {
  4222. _fnMap( ret, src, val[0], val[1] );
  4223. }
  4224. else {
  4225. _fnMap( ret, src, val );
  4226. }
  4227. } );
  4228. return;
  4229. }
  4230. if ( mappedName === undefined ) {
  4231. mappedName = name;
  4232. }
  4233. if ( src[name] !== undefined ) {
  4234. ret[mappedName] = src[name];
  4235. }
  4236. }
  4237. /**
  4238. * Extend objects - very similar to jQuery.extend, but deep copy objects, and
  4239. * shallow copy arrays. The reason we need to do this, is that we don't want to
  4240. * deep copy array init values (such as aaSorting) since the dev wouldn't be
  4241. * able to override them, but we do want to deep copy arrays.
  4242. * @param {object} out Object to extend
  4243. * @param {object} extender Object from which the properties will be applied to
  4244. * out
  4245. * @param {boolean} breakRefs If true, then arrays will be sliced to take an
  4246. * independent copy with the exception of the `data` or `aaData` parameters
  4247. * if they are present. This is so you can pass in a collection to
  4248. * DataTables and have that used as your data source without breaking the
  4249. * references
  4250. * @returns {object} out Reference, just for convenience - out === the return.
  4251. * @memberof DataTable#oApi
  4252. * @todo This doesn't take account of arrays inside the deep copied objects.
  4253. */
  4254. function _fnExtend( out, extender, breakRefs )
  4255. {
  4256. var val;
  4257. for ( var prop in extender ) {
  4258. if ( extender.hasOwnProperty(prop) ) {
  4259. val = extender[prop];
  4260. if ( $.isPlainObject( val ) ) {
  4261. if ( ! $.isPlainObject( out[prop] ) ) {
  4262. out[prop] = {};
  4263. }
  4264. $.extend( true, out[prop], val );
  4265. }
  4266. else if ( breakRefs && prop !== 'data' && prop !== 'aaData' && $.isArray(val) ) {
  4267. out[prop] = val.slice();
  4268. }
  4269. else {
  4270. out[prop] = val;
  4271. }
  4272. }
  4273. }
  4274. return out;
  4275. }
  4276. /**
  4277. * Bind an event handers to allow a click or return key to activate the callback.
  4278. * This is good for accessibility since a return on the keyboard will have the
  4279. * same effect as a click, if the element has focus.
  4280. * @param {element} n Element to bind the action to
  4281. * @param {object} oData Data object to pass to the triggered function
  4282. * @param {function} fn Callback function for when the event is triggered
  4283. * @memberof DataTable#oApi
  4284. */
  4285. function _fnBindAction( n, oData, fn )
  4286. {
  4287. $(n)
  4288. .bind( 'click.DT', oData, function (e) {
  4289. n.blur(); // Remove focus outline for mouse users
  4290. fn(e);
  4291. } )
  4292. .bind( 'keypress.DT', oData, function (e){
  4293. if ( e.which === 13 ) {
  4294. e.preventDefault();
  4295. fn(e);
  4296. }
  4297. } )
  4298. .bind( 'selectstart.DT', function () {
  4299. /* Take the brutal approach to cancelling text selection */
  4300. return false;
  4301. } );
  4302. }
  4303. /**
  4304. * Register a callback function. Easily allows a callback function to be added to
  4305. * an array store of callback functions that can then all be called together.
  4306. * @param {object} oSettings dataTables settings object
  4307. * @param {string} sStore Name of the array storage for the callbacks in oSettings
  4308. * @param {function} fn Function to be called back
  4309. * @param {string} sName Identifying name for the callback (i.e. a label)
  4310. * @memberof DataTable#oApi
  4311. */
  4312. function _fnCallbackReg( oSettings, sStore, fn, sName )
  4313. {
  4314. if ( fn )
  4315. {
  4316. oSettings[sStore].push( {
  4317. "fn": fn,
  4318. "sName": sName
  4319. } );
  4320. }
  4321. }
  4322. /**
  4323. * Fire callback functions and trigger events. Note that the loop over the
  4324. * callback array store is done backwards! Further note that you do not want to
  4325. * fire off triggers in time sensitive applications (for example cell creation)
  4326. * as its slow.
  4327. * @param {object} settings dataTables settings object
  4328. * @param {string} callbackArr Name of the array storage for the callbacks in
  4329. * oSettings
  4330. * @param {string} event Name of the jQuery custom event to trigger. If null no
  4331. * trigger is fired
  4332. * @param {array} args Array of arguments to pass to the callback function /
  4333. * trigger
  4334. * @memberof DataTable#oApi
  4335. */
  4336. function _fnCallbackFire( settings, callbackArr, e, args )
  4337. {
  4338. var ret = [];
  4339. if ( callbackArr ) {
  4340. ret = $.map( settings[callbackArr].slice().reverse(), function (val, i) {
  4341. return val.fn.apply( settings.oInstance, args );
  4342. } );
  4343. }
  4344. if ( e !== null ) {
  4345. $(settings.nTable).trigger( e+'.dt', args );
  4346. }
  4347. return ret;
  4348. }
  4349. function _fnLengthOverflow ( settings )
  4350. {
  4351. var
  4352. start = settings._iDisplayStart,
  4353. end = settings.fnDisplayEnd(),
  4354. len = settings._iDisplayLength;
  4355. /* If we have space to show extra rows (backing up from the end point - then do so */
  4356. if ( end === settings.fnRecordsDisplay() )
  4357. {
  4358. start = end - len;
  4359. }
  4360. if ( len === -1 || start < 0 )
  4361. {
  4362. start = 0;
  4363. }
  4364. settings._iDisplayStart = start;
  4365. }
  4366. function _fnRenderer( settings, type )
  4367. {
  4368. var renderer = settings.renderer;
  4369. var host = DataTable.ext.renderer[type];
  4370. if ( $.isPlainObject( renderer ) && renderer[type] ) {
  4371. // Specific renderer for this type. If available use it, otherwise use
  4372. // the default.
  4373. return host[renderer[type]] || host._;
  4374. }
  4375. else if ( typeof renderer === 'string' ) {
  4376. // Common renderer - if there is one available for this type use it,
  4377. // otherwise use the default
  4378. return host[renderer] || host._;
  4379. }
  4380. // Use the default
  4381. return host._;
  4382. }
  4383. /**
  4384. * Detect the data source being used for the table. Used to simplify the code
  4385. * a little (ajax) and to make it compress a little smaller.
  4386. *
  4387. * @param {object} settings dataTables settings object
  4388. * @returns {string} Data source
  4389. * @memberof DataTable#oApi
  4390. */
  4391. function _fnDataSource ( settings )
  4392. {
  4393. if ( settings.oFeatures.bServerSide ) {
  4394. return 'ssp';
  4395. }
  4396. else if ( settings.ajax || settings.sAjaxSource ) {
  4397. return 'ajax';
  4398. }
  4399. return 'dom';
  4400. }
  4401. DataTable = function( options )
  4402. {
  4403. /**
  4404. * Perform a jQuery selector action on the table's TR elements (from the tbody) and
  4405. * return the resulting jQuery object.
  4406. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  4407. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  4408. * @param {string} [oOpts.filter=none] Select TR elements that meet the current filter
  4409. * criterion ("applied") or all TR elements (i.e. no filter).
  4410. * @param {string} [oOpts.order=current] Order of the TR elements in the processed array.
  4411. * Can be either 'current', whereby the current sorting of the table is used, or
  4412. * 'original' whereby the original order the data was read into the table is used.
  4413. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  4414. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  4415. * 'current' and filter is 'applied', regardless of what they might be given as.
  4416. * @returns {object} jQuery object, filtered by the given selector.
  4417. * @dtopt API
  4418. * @deprecated Since v1.10
  4419. *
  4420. * @example
  4421. * $(document).ready(function() {
  4422. * var oTable = $('#example').dataTable();
  4423. *
  4424. * // Highlight every second row
  4425. * oTable.$('tr:odd').css('backgroundColor', 'blue');
  4426. * } );
  4427. *
  4428. * @example
  4429. * $(document).ready(function() {
  4430. * var oTable = $('#example').dataTable();
  4431. *
  4432. * // Filter to rows with 'Webkit' in them, add a background colour and then
  4433. * // remove the filter, thus highlighting the 'Webkit' rows only.
  4434. * oTable.fnFilter('Webkit');
  4435. * oTable.$('tr', {"search": "applied"}).css('backgroundColor', 'blue');
  4436. * oTable.fnFilter('');
  4437. * } );
  4438. */
  4439. this.$ = function ( sSelector, oOpts )
  4440. {
  4441. return this.api(true).$( sSelector, oOpts );
  4442. };
  4443. /**
  4444. * Almost identical to $ in operation, but in this case returns the data for the matched
  4445. * rows - as such, the jQuery selector used should match TR row nodes or TD/TH cell nodes
  4446. * rather than any descendants, so the data can be obtained for the row/cell. If matching
  4447. * rows are found, the data returned is the original data array/object that was used to
  4448. * create the row (or a generated array if from a DOM source).
  4449. *
  4450. * This method is often useful in-combination with $ where both functions are given the
  4451. * same parameters and the array indexes will match identically.
  4452. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  4453. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  4454. * @param {string} [oOpts.filter=none] Select elements that meet the current filter
  4455. * criterion ("applied") or all elements (i.e. no filter).
  4456. * @param {string} [oOpts.order=current] Order of the data in the processed array.
  4457. * Can be either 'current', whereby the current sorting of the table is used, or
  4458. * 'original' whereby the original order the data was read into the table is used.
  4459. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  4460. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  4461. * 'current' and filter is 'applied', regardless of what they might be given as.
  4462. * @returns {array} Data for the matched elements. If any elements, as a result of the
  4463. * selector, were not TR, TD or TH elements in the DataTable, they will have a null
  4464. * entry in the array.
  4465. * @dtopt API
  4466. * @deprecated Since v1.10
  4467. *
  4468. * @example
  4469. * $(document).ready(function() {
  4470. * var oTable = $('#example').dataTable();
  4471. *
  4472. * // Get the data from the first row in the table
  4473. * var data = oTable._('tr:first');
  4474. *
  4475. * // Do something useful with the data
  4476. * alert( "First cell is: "+data[0] );
  4477. * } );
  4478. *
  4479. * @example
  4480. * $(document).ready(function() {
  4481. * var oTable = $('#example').dataTable();
  4482. *
  4483. * // Filter to 'Webkit' and get all data for
  4484. * oTable.fnFilter('Webkit');
  4485. * var data = oTable._('tr', {"search": "applied"});
  4486. *
  4487. * // Do something with the data
  4488. * alert( data.length+" rows matched the search" );
  4489. * } );
  4490. */
  4491. this._ = function ( sSelector, oOpts )
  4492. {
  4493. return this.api(true).rows( sSelector, oOpts ).data();
  4494. };
  4495. /**
  4496. * Create a DataTables Api instance, with the currently selected tables for
  4497. * the Api's context.
  4498. * @param {boolean} [traditional=false] Set the API instance's context to be
  4499. * only the table referred to by the `DataTable.ext.iApiIndex` option, as was
  4500. * used in the API presented by DataTables 1.9- (i.e. the traditional mode),
  4501. * or if all tables captured in the jQuery object should be used.
  4502. * @return {DataTables.Api}
  4503. */
  4504. this.api = function ( traditional )
  4505. {
  4506. return traditional ?
  4507. new _Api(
  4508. _fnSettingsFromNode( this[ _ext.iApiIndex ] )
  4509. ) :
  4510. new _Api( this );
  4511. };
  4512. /**
  4513. * Add a single new row or multiple rows of data to the table. Please note
  4514. * that this is suitable for client-side processing only - if you are using
  4515. * server-side processing (i.e. "bServerSide": true), then to add data, you
  4516. * must add it to the data source, i.e. the server-side, through an Ajax call.
  4517. * @param {array|object} data The data to be added to the table. This can be:
  4518. * <ul>
  4519. * <li>1D array of data - add a single row with the data provided</li>
  4520. * <li>2D array of arrays - add multiple rows in a single call</li>
  4521. * <li>object - data object when using <i>mData</i></li>
  4522. * <li>array of objects - multiple data objects when using <i>mData</i></li>
  4523. * </ul>
  4524. * @param {bool} [redraw=true] redraw the table or not
  4525. * @returns {array} An array of integers, representing the list of indexes in
  4526. * <i>aoData</i> ({@link DataTable.models.oSettings}) that have been added to
  4527. * the table.
  4528. * @dtopt API
  4529. * @deprecated Since v1.10
  4530. *
  4531. * @example
  4532. * // Global var for counter
  4533. * var giCount = 2;
  4534. *
  4535. * $(document).ready(function() {
  4536. * $('#example').dataTable();
  4537. * } );
  4538. *
  4539. * function fnClickAddRow() {
  4540. * $('#example').dataTable().fnAddData( [
  4541. * giCount+".1",
  4542. * giCount+".2",
  4543. * giCount+".3",
  4544. * giCount+".4" ]
  4545. * );
  4546. *
  4547. * giCount++;
  4548. * }
  4549. */
  4550. this.fnAddData = function( data, redraw )
  4551. {
  4552. var api = this.api( true );
  4553. /* Check if we want to add multiple rows or not */
  4554. var rows = $.isArray(data) && ( $.isArray(data[0]) || $.isPlainObject(data[0]) ) ?
  4555. api.rows.add( data ) :
  4556. api.row.add( data );
  4557. if ( redraw === undefined || redraw ) {
  4558. api.draw();
  4559. }
  4560. return rows.flatten().toArray();
  4561. };
  4562. /**
  4563. * This function will make DataTables recalculate the column sizes, based on the data
  4564. * contained in the table and the sizes applied to the columns (in the DOM, CSS or
  4565. * through the sWidth parameter). This can be useful when the width of the table's
  4566. * parent element changes (for example a window resize).
  4567. * @param {boolean} [bRedraw=true] Redraw the table or not, you will typically want to
  4568. * @dtopt API
  4569. * @deprecated Since v1.10
  4570. *
  4571. * @example
  4572. * $(document).ready(function() {
  4573. * var oTable = $('#example').dataTable( {
  4574. * "sScrollY": "200px",
  4575. * "bPaginate": false
  4576. * } );
  4577. *
  4578. * $(window).bind('resize', function () {
  4579. * oTable.fnAdjustColumnSizing();
  4580. * } );
  4581. * } );
  4582. */
  4583. this.fnAdjustColumnSizing = function ( bRedraw )
  4584. {
  4585. var api = this.api( true ).columns.adjust();
  4586. var settings = api.settings()[0];
  4587. var scroll = settings.oScroll;
  4588. if ( bRedraw === undefined || bRedraw ) {
  4589. api.draw( false );
  4590. }
  4591. else if ( scroll.sX !== "" || scroll.sY !== "" ) {
  4592. /* If not redrawing, but scrolling, we want to apply the new column sizes anyway */
  4593. _fnScrollDraw( settings );
  4594. }
  4595. };
  4596. /**
  4597. * Quickly and simply clear a table
  4598. * @param {bool} [bRedraw=true] redraw the table or not
  4599. * @dtopt API
  4600. * @deprecated Since v1.10
  4601. *
  4602. * @example
  4603. * $(document).ready(function() {
  4604. * var oTable = $('#example').dataTable();
  4605. *
  4606. * // Immediately 'nuke' the current rows (perhaps waiting for an Ajax callback...)
  4607. * oTable.fnClearTable();
  4608. * } );
  4609. */
  4610. this.fnClearTable = function( bRedraw )
  4611. {
  4612. var api = this.api( true ).clear();
  4613. if ( bRedraw === undefined || bRedraw ) {
  4614. api.draw();
  4615. }
  4616. };
  4617. /**
  4618. * The exact opposite of 'opening' a row, this function will close any rows which
  4619. * are currently 'open'.
  4620. * @param {node} nTr the table row to 'close'
  4621. * @returns {int} 0 on success, or 1 if failed (can't find the row)
  4622. * @dtopt API
  4623. * @deprecated Since v1.10
  4624. *
  4625. * @example
  4626. * $(document).ready(function() {
  4627. * var oTable;
  4628. *
  4629. * // 'open' an information row when a row is clicked on
  4630. * $('#example tbody tr').click( function () {
  4631. * if ( oTable.fnIsOpen(this) ) {
  4632. * oTable.fnClose( this );
  4633. * } else {
  4634. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  4635. * }
  4636. * } );
  4637. *
  4638. * oTable = $('#example').dataTable();
  4639. * } );
  4640. */
  4641. this.fnClose = function( nTr )
  4642. {
  4643. this.api( true ).row( nTr ).child.hide();
  4644. };
  4645. /**
  4646. * Remove a row for the table
  4647. * @param {mixed} target The index of the row from aoData to be deleted, or
  4648. * the TR element you want to delete
  4649. * @param {function|null} [callBack] Callback function
  4650. * @param {bool} [redraw=true] Redraw the table or not
  4651. * @returns {array} The row that was deleted
  4652. * @dtopt API
  4653. * @deprecated Since v1.10
  4654. *
  4655. * @example
  4656. * $(document).ready(function() {
  4657. * var oTable = $('#example').dataTable();
  4658. *
  4659. * // Immediately remove the first row
  4660. * oTable.fnDeleteRow( 0 );
  4661. * } );
  4662. */
  4663. this.fnDeleteRow = function( target, callback, redraw )
  4664. {
  4665. var api = this.api( true );
  4666. var rows = api.rows( target );
  4667. var settings = rows.settings()[0];
  4668. var data = settings.aoData[ rows[0][0] ];
  4669. rows.remove();
  4670. if ( callback ) {
  4671. callback.call( this, settings, data );
  4672. }
  4673. if ( redraw === undefined || redraw ) {
  4674. api.draw();
  4675. }
  4676. return data;
  4677. };
  4678. /**
  4679. * Restore the table to it's original state in the DOM by removing all of DataTables
  4680. * enhancements, alterations to the DOM structure of the table and event listeners.
  4681. * @param {boolean} [remove=false] Completely remove the table from the DOM
  4682. * @dtopt API
  4683. * @deprecated Since v1.10
  4684. *
  4685. * @example
  4686. * $(document).ready(function() {
  4687. * // This example is fairly pointless in reality, but shows how fnDestroy can be used
  4688. * var oTable = $('#example').dataTable();
  4689. * oTable.fnDestroy();
  4690. * } );
  4691. */
  4692. this.fnDestroy = function ( remove )
  4693. {
  4694. this.api( true ).destroy( remove );
  4695. };
  4696. /**
  4697. * Redraw the table
  4698. * @param {bool} [complete=true] Re-filter and resort (if enabled) the table before the draw.
  4699. * @dtopt API
  4700. * @deprecated Since v1.10
  4701. *
  4702. * @example
  4703. * $(document).ready(function() {
  4704. * var oTable = $('#example').dataTable();
  4705. *
  4706. * // Re-draw the table - you wouldn't want to do it here, but it's an example :-)
  4707. * oTable.fnDraw();
  4708. * } );
  4709. */
  4710. this.fnDraw = function( complete )
  4711. {
  4712. // Note that this isn't an exact match to the old call to _fnDraw - it takes
  4713. // into account the new data, but can old position.
  4714. this.api( true ).draw( ! complete );
  4715. };
  4716. /**
  4717. * Filter the input based on data
  4718. * @param {string} sInput String to filter the table on
  4719. * @param {int|null} [iColumn] Column to limit filtering to
  4720. * @param {bool} [bRegex=false] Treat as regular expression or not
  4721. * @param {bool} [bSmart=true] Perform smart filtering or not
  4722. * @param {bool} [bShowGlobal=true] Show the input global filter in it's input box(es)
  4723. * @param {bool} [bCaseInsensitive=true] Do case-insensitive matching (true) or not (false)
  4724. * @dtopt API
  4725. * @deprecated Since v1.10
  4726. *
  4727. * @example
  4728. * $(document).ready(function() {
  4729. * var oTable = $('#example').dataTable();
  4730. *
  4731. * // Sometime later - filter...
  4732. * oTable.fnFilter( 'test string' );
  4733. * } );
  4734. */
  4735. this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal, bCaseInsensitive )
  4736. {
  4737. var api = this.api( true );
  4738. if ( iColumn === null || iColumn === undefined ) {
  4739. api.search( sInput, bRegex, bSmart, bCaseInsensitive );
  4740. }
  4741. else {
  4742. api.column( iColumn ).search( sInput, bRegex, bSmart, bCaseInsensitive );
  4743. }
  4744. api.draw();
  4745. };
  4746. /**
  4747. * Get the data for the whole table, an individual row or an individual cell based on the
  4748. * provided parameters.
  4749. * @param {int|node} [src] A TR row node, TD/TH cell node or an integer. If given as
  4750. * a TR node then the data source for the whole row will be returned. If given as a
  4751. * TD/TH cell node then iCol will be automatically calculated and the data for the
  4752. * cell returned. If given as an integer, then this is treated as the aoData internal
  4753. * data index for the row (see fnGetPosition) and the data for that row used.
  4754. * @param {int} [col] Optional column index that you want the data of.
  4755. * @returns {array|object|string} If mRow is undefined, then the data for all rows is
  4756. * returned. If mRow is defined, just data for that row, and is iCol is
  4757. * defined, only data for the designated cell is returned.
  4758. * @dtopt API
  4759. * @deprecated Since v1.10
  4760. *
  4761. * @example
  4762. * // Row data
  4763. * $(document).ready(function() {
  4764. * oTable = $('#example').dataTable();
  4765. *
  4766. * oTable.$('tr').click( function () {
  4767. * var data = oTable.fnGetData( this );
  4768. * // ... do something with the array / object of data for the row
  4769. * } );
  4770. * } );
  4771. *
  4772. * @example
  4773. * // Individual cell data
  4774. * $(document).ready(function() {
  4775. * oTable = $('#example').dataTable();
  4776. *
  4777. * oTable.$('td').click( function () {
  4778. * var sData = oTable.fnGetData( this );
  4779. * alert( 'The cell clicked on had the value of '+sData );
  4780. * } );
  4781. * } );
  4782. */
  4783. this.fnGetData = function( src, col )
  4784. {
  4785. var api = this.api( true );
  4786. if ( src !== undefined ) {
  4787. var type = src.nodeName ? src.nodeName.toLowerCase() : '';
  4788. return col !== undefined || type == 'td' || type == 'th' ?
  4789. api.cell( src, col ).data() :
  4790. api.row( src ).data() || null;
  4791. }
  4792. return api.data().toArray();
  4793. };
  4794. /**
  4795. * Get an array of the TR nodes that are used in the table's body. Note that you will
  4796. * typically want to use the '$' API method in preference to this as it is more
  4797. * flexible.
  4798. * @param {int} [iRow] Optional row index for the TR element you want
  4799. * @returns {array|node} If iRow is undefined, returns an array of all TR elements
  4800. * in the table's body, or iRow is defined, just the TR element requested.
  4801. * @dtopt API
  4802. * @deprecated Since v1.10
  4803. *
  4804. * @example
  4805. * $(document).ready(function() {
  4806. * var oTable = $('#example').dataTable();
  4807. *
  4808. * // Get the nodes from the table
  4809. * var nNodes = oTable.fnGetNodes( );
  4810. * } );
  4811. */
  4812. this.fnGetNodes = function( iRow )
  4813. {
  4814. var api = this.api( true );
  4815. return iRow !== undefined ?
  4816. api.row( iRow ).node() :
  4817. api.rows().nodes().flatten().toArray();
  4818. };
  4819. /**
  4820. * Get the array indexes of a particular cell from it's DOM element
  4821. * and column index including hidden columns
  4822. * @param {node} node this can either be a TR, TD or TH in the table's body
  4823. * @returns {int} If nNode is given as a TR, then a single index is returned, or
  4824. * if given as a cell, an array of [row index, column index (visible),
  4825. * column index (all)] is given.
  4826. * @dtopt API
  4827. * @deprecated Since v1.10
  4828. *
  4829. * @example
  4830. * $(document).ready(function() {
  4831. * $('#example tbody td').click( function () {
  4832. * // Get the position of the current data from the node
  4833. * var aPos = oTable.fnGetPosition( this );
  4834. *
  4835. * // Get the data array for this row
  4836. * var aData = oTable.fnGetData( aPos[0] );
  4837. *
  4838. * // Update the data array and return the value
  4839. * aData[ aPos[1] ] = 'clicked';
  4840. * this.innerHTML = 'clicked';
  4841. * } );
  4842. *
  4843. * // Init DataTables
  4844. * oTable = $('#example').dataTable();
  4845. * } );
  4846. */
  4847. this.fnGetPosition = function( node )
  4848. {
  4849. var api = this.api( true );
  4850. var nodeName = node.nodeName.toUpperCase();
  4851. if ( nodeName == 'TR' ) {
  4852. return api.row( node ).index();
  4853. }
  4854. else if ( nodeName == 'TD' || nodeName == 'TH' ) {
  4855. var cell = api.cell( node ).index();
  4856. return [
  4857. cell.row,
  4858. cell.columnVisible,
  4859. cell.column
  4860. ];
  4861. }
  4862. return null;
  4863. };
  4864. /**
  4865. * Check to see if a row is 'open' or not.
  4866. * @param {node} nTr the table row to check
  4867. * @returns {boolean} true if the row is currently open, false otherwise
  4868. * @dtopt API
  4869. * @deprecated Since v1.10
  4870. *
  4871. * @example
  4872. * $(document).ready(function() {
  4873. * var oTable;
  4874. *
  4875. * // 'open' an information row when a row is clicked on
  4876. * $('#example tbody tr').click( function () {
  4877. * if ( oTable.fnIsOpen(this) ) {
  4878. * oTable.fnClose( this );
  4879. * } else {
  4880. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  4881. * }
  4882. * } );
  4883. *
  4884. * oTable = $('#example').dataTable();
  4885. * } );
  4886. */
  4887. this.fnIsOpen = function( nTr )
  4888. {
  4889. return this.api( true ).row( nTr ).child.isShown();
  4890. };
  4891. /**
  4892. * This function will place a new row directly after a row which is currently
  4893. * on display on the page, with the HTML contents that is passed into the
  4894. * function. This can be used, for example, to ask for confirmation that a
  4895. * particular record should be deleted.
  4896. * @param {node} nTr The table row to 'open'
  4897. * @param {string|node|jQuery} mHtml The HTML to put into the row
  4898. * @param {string} sClass Class to give the new TD cell
  4899. * @returns {node} The row opened. Note that if the table row passed in as the
  4900. * first parameter, is not found in the table, this method will silently
  4901. * return.
  4902. * @dtopt API
  4903. * @deprecated Since v1.10
  4904. *
  4905. * @example
  4906. * $(document).ready(function() {
  4907. * var oTable;
  4908. *
  4909. * // 'open' an information row when a row is clicked on
  4910. * $('#example tbody tr').click( function () {
  4911. * if ( oTable.fnIsOpen(this) ) {
  4912. * oTable.fnClose( this );
  4913. * } else {
  4914. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  4915. * }
  4916. * } );
  4917. *
  4918. * oTable = $('#example').dataTable();
  4919. * } );
  4920. */
  4921. this.fnOpen = function( nTr, mHtml, sClass )
  4922. {
  4923. return this.api( true )
  4924. .row( nTr )
  4925. .child( mHtml, sClass )
  4926. .show()
  4927. .child()[0];
  4928. };
  4929. /**
  4930. * Change the pagination - provides the internal logic for pagination in a simple API
  4931. * function. With this function you can have a DataTables table go to the next,
  4932. * previous, first or last pages.
  4933. * @param {string|int} mAction Paging action to take: "first", "previous", "next" or "last"
  4934. * or page number to jump to (integer), note that page 0 is the first page.
  4935. * @param {bool} [bRedraw=true] Redraw the table or not
  4936. * @dtopt API
  4937. * @deprecated Since v1.10
  4938. *
  4939. * @example
  4940. * $(document).ready(function() {
  4941. * var oTable = $('#example').dataTable();
  4942. * oTable.fnPageChange( 'next' );
  4943. * } );
  4944. */
  4945. this.fnPageChange = function ( mAction, bRedraw )
  4946. {
  4947. var api = this.api( true ).page( mAction );
  4948. if ( bRedraw === undefined || bRedraw ) {
  4949. api.draw(false);
  4950. }
  4951. };
  4952. /**
  4953. * Show a particular column
  4954. * @param {int} iCol The column whose display should be changed
  4955. * @param {bool} bShow Show (true) or hide (false) the column
  4956. * @param {bool} [bRedraw=true] Redraw the table or not
  4957. * @dtopt API
  4958. * @deprecated Since v1.10
  4959. *
  4960. * @example
  4961. * $(document).ready(function() {
  4962. * var oTable = $('#example').dataTable();
  4963. *
  4964. * // Hide the second column after initialisation
  4965. * oTable.fnSetColumnVis( 1, false );
  4966. * } );
  4967. */
  4968. this.fnSetColumnVis = function ( iCol, bShow, bRedraw )
  4969. {
  4970. var api = this.api( true ).column( iCol ).visible( bShow );
  4971. if ( bRedraw === undefined || bRedraw ) {
  4972. api.columns.adjust().draw();
  4973. }
  4974. };
  4975. /**
  4976. * Get the settings for a particular table for external manipulation
  4977. * @returns {object} DataTables settings object. See
  4978. * {@link DataTable.models.oSettings}
  4979. * @dtopt API
  4980. * @deprecated Since v1.10
  4981. *
  4982. * @example
  4983. * $(document).ready(function() {
  4984. * var oTable = $('#example').dataTable();
  4985. * var oSettings = oTable.fnSettings();
  4986. *
  4987. * // Show an example parameter from the settings
  4988. * alert( oSettings._iDisplayStart );
  4989. * } );
  4990. */
  4991. this.fnSettings = function()
  4992. {
  4993. return _fnSettingsFromNode( this[_ext.iApiIndex] );
  4994. };
  4995. /**
  4996. * Sort the table by a particular column
  4997. * @param {int} iCol the data index to sort on. Note that this will not match the
  4998. * 'display index' if you have hidden data entries
  4999. * @dtopt API
  5000. * @deprecated Since v1.10
  5001. *
  5002. * @example
  5003. * $(document).ready(function() {
  5004. * var oTable = $('#example').dataTable();
  5005. *
  5006. * // Sort immediately with columns 0 and 1
  5007. * oTable.fnSort( [ [0,'asc'], [1,'asc'] ] );
  5008. * } );
  5009. */
  5010. this.fnSort = function( aaSort )
  5011. {
  5012. this.api( true ).order( aaSort ).draw();
  5013. };
  5014. /**
  5015. * Attach a sort listener to an element for a given column
  5016. * @param {node} nNode the element to attach the sort listener to
  5017. * @param {int} iColumn the column that a click on this node will sort on
  5018. * @param {function} [fnCallback] callback function when sort is run
  5019. * @dtopt API
  5020. * @deprecated Since v1.10
  5021. *
  5022. * @example
  5023. * $(document).ready(function() {
  5024. * var oTable = $('#example').dataTable();
  5025. *
  5026. * // Sort on column 1, when 'sorter' is clicked on
  5027. * oTable.fnSortListener( document.getElementById('sorter'), 1 );
  5028. * } );
  5029. */
  5030. this.fnSortListener = function( nNode, iColumn, fnCallback )
  5031. {
  5032. this.api( true ).order.listener( nNode, iColumn, fnCallback );
  5033. };
  5034. /**
  5035. * Update a table cell or row - this method will accept either a single value to
  5036. * update the cell with, an array of values with one element for each column or
  5037. * an object in the same format as the original data source. The function is
  5038. * self-referencing in order to make the multi column updates easier.
  5039. * @param {object|array|string} mData Data to update the cell/row with
  5040. * @param {node|int} mRow TR element you want to update or the aoData index
  5041. * @param {int} [iColumn] The column to update, give as null or undefined to
  5042. * update a whole row.
  5043. * @param {bool} [bRedraw=true] Redraw the table or not
  5044. * @param {bool} [bAction=true] Perform pre-draw actions or not
  5045. * @returns {int} 0 on success, 1 on error
  5046. * @dtopt API
  5047. * @deprecated Since v1.10
  5048. *
  5049. * @example
  5050. * $(document).ready(function() {
  5051. * var oTable = $('#example').dataTable();
  5052. * oTable.fnUpdate( 'Example update', 0, 0 ); // Single cell
  5053. * oTable.fnUpdate( ['a', 'b', 'c', 'd', 'e'], $('tbody tr')[0] ); // Row
  5054. * } );
  5055. */
  5056. this.fnUpdate = function( mData, mRow, iColumn, bRedraw, bAction )
  5057. {
  5058. var api = this.api( true );
  5059. if ( iColumn === undefined || iColumn === null ) {
  5060. api.row( mRow ).data( mData );
  5061. }
  5062. else {
  5063. api.cell( mRow, iColumn ).data( mData );
  5064. }
  5065. if ( bAction === undefined || bAction ) {
  5066. api.columns.adjust();
  5067. }
  5068. if ( bRedraw === undefined || bRedraw ) {
  5069. api.draw();
  5070. }
  5071. return 0;
  5072. };
  5073. /**
  5074. * Provide a common method for plug-ins to check the version of DataTables being used, in order
  5075. * to ensure compatibility.
  5076. * @param {string} sVersion Version string to check for, in the format "X.Y.Z". Note that the
  5077. * formats "X" and "X.Y" are also acceptable.
  5078. * @returns {boolean} true if this version of DataTables is greater or equal to the required
  5079. * version, or false if this version of DataTales is not suitable
  5080. * @method
  5081. * @dtopt API
  5082. * @deprecated Since v1.10
  5083. *
  5084. * @example
  5085. * $(document).ready(function() {
  5086. * var oTable = $('#example').dataTable();
  5087. * alert( oTable.fnVersionCheck( '1.9.0' ) );
  5088. * } );
  5089. */
  5090. this.fnVersionCheck = _ext.fnVersionCheck;
  5091. var _that = this;
  5092. var emptyInit = options === undefined;
  5093. var len = this.length;
  5094. if ( emptyInit ) {
  5095. options = {};
  5096. }
  5097. this.oApi = this.internal = _ext.internal;
  5098. // Extend with old style plug-in API methods
  5099. for ( var fn in DataTable.ext.internal ) {
  5100. if ( fn ) {
  5101. this[fn] = _fnExternApiFunc(fn);
  5102. }
  5103. }
  5104. this.each(function() {
  5105. // For each initialisation we want to give it a clean initialisation
  5106. // object that can be bashed around
  5107. var o = {};
  5108. var oInit = len > 1 ? // optimisation for single table case
  5109. _fnExtend( o, options, true ) :
  5110. options;
  5111. /*global oInit,_that,emptyInit*/
  5112. var i=0, iLen, j, jLen, k, kLen;
  5113. var sId = this.getAttribute( 'id' );
  5114. var bInitHandedOff = false;
  5115. var defaults = DataTable.defaults;
  5116. /* Sanity check */
  5117. if ( this.nodeName.toLowerCase() != 'table' )
  5118. {
  5119. _fnLog( null, 0, 'Non-table node initialisation ('+this.nodeName+')', 2 );
  5120. return;
  5121. }
  5122. /* Backwards compatibility for the defaults */
  5123. _fnCompatOpts( defaults );
  5124. _fnCompatCols( defaults.column );
  5125. /* Convert the camel-case defaults to Hungarian */
  5126. _fnCamelToHungarian( defaults, defaults, true );
  5127. _fnCamelToHungarian( defaults.column, defaults.column, true );
  5128. /* Setting up the initialisation object */
  5129. _fnCamelToHungarian( defaults, oInit );
  5130. /* Check to see if we are re-initialising a table */
  5131. var allSettings = DataTable.settings;
  5132. for ( i=0, iLen=allSettings.length ; i<iLen ; i++ )
  5133. {
  5134. /* Base check on table node */
  5135. if ( allSettings[i].nTable == this )
  5136. {
  5137. var bRetrieve = oInit.bRetrieve !== undefined ? oInit.bRetrieve : defaults.bRetrieve;
  5138. var bDestroy = oInit.bDestroy !== undefined ? oInit.bDestroy : defaults.bDestroy;
  5139. if ( emptyInit || bRetrieve )
  5140. {
  5141. return allSettings[i].oInstance;
  5142. }
  5143. else if ( bDestroy )
  5144. {
  5145. allSettings[i].oInstance.fnDestroy();
  5146. break;
  5147. }
  5148. else
  5149. {
  5150. _fnLog( allSettings[i], 0, 'Cannot reinitialise DataTable', 3 );
  5151. return;
  5152. }
  5153. }
  5154. /* If the element we are initialising has the same ID as a table which was previously
  5155. * initialised, but the table nodes don't match (from before) then we destroy the old
  5156. * instance by simply deleting it. This is under the assumption that the table has been
  5157. * destroyed by other methods. Anyone using non-id selectors will need to do this manually
  5158. */
  5159. if ( allSettings[i].sTableId == this.id )
  5160. {
  5161. allSettings.splice( i, 1 );
  5162. break;
  5163. }
  5164. }
  5165. /* Ensure the table has an ID - required for accessibility */
  5166. if ( sId === null || sId === "" )
  5167. {
  5168. sId = "DataTables_Table_"+(DataTable.ext._unique++);
  5169. this.id = sId;
  5170. }
  5171. /* Create the settings object for this table and set some of the default parameters */
  5172. var oSettings = $.extend( true, {}, DataTable.models.oSettings, {
  5173. "nTable": this,
  5174. "oApi": _that.internal,
  5175. "oInit": oInit,
  5176. "sDestroyWidth": $(this)[0].style.width,
  5177. "sInstance": sId,
  5178. "sTableId": sId
  5179. } );
  5180. allSettings.push( oSettings );
  5181. // Need to add the instance after the instance after the settings object has been added
  5182. // to the settings array, so we can self reference the table instance if more than one
  5183. oSettings.oInstance = (_that.length===1) ? _that : $(this).dataTable();
  5184. // Backwards compatibility, before we apply all the defaults
  5185. _fnCompatOpts( oInit );
  5186. if ( oInit.oLanguage )
  5187. {
  5188. _fnLanguageCompat( oInit.oLanguage );
  5189. }
  5190. // If the length menu is given, but the init display length is not, use the length menu
  5191. if ( oInit.aLengthMenu && ! oInit.iDisplayLength )
  5192. {
  5193. oInit.iDisplayLength = $.isArray( oInit.aLengthMenu[0] ) ?
  5194. oInit.aLengthMenu[0][0] : oInit.aLengthMenu[0];
  5195. }
  5196. // Apply the defaults and init options to make a single init object will all
  5197. // options defined from defaults and instance options.
  5198. oInit = _fnExtend( $.extend( true, {}, defaults ), oInit );
  5199. // Map the initialisation options onto the settings object
  5200. _fnMap( oSettings.oFeatures, oInit, [
  5201. "bPaginate",
  5202. "bLengthChange",
  5203. "bFilter",
  5204. "bSort",
  5205. "bSortMulti",
  5206. "bInfo",
  5207. "bProcessing",
  5208. "bAutoWidth",
  5209. "bSortClasses",
  5210. "bServerSide",
  5211. "bDeferRender"
  5212. ] );
  5213. _fnMap( oSettings, oInit, [
  5214. "asStripeClasses",
  5215. "ajax",
  5216. "fnServerData",
  5217. "fnFormatNumber",
  5218. "sServerMethod",
  5219. "aaSorting",
  5220. "aaSortingFixed",
  5221. "aLengthMenu",
  5222. "sPaginationType",
  5223. "sAjaxSource",
  5224. "sAjaxDataProp",
  5225. "iStateDuration",
  5226. "sDom",
  5227. "bSortCellsTop",
  5228. "iTabIndex",
  5229. "fnStateLoadCallback",
  5230. "fnStateSaveCallback",
  5231. "renderer",
  5232. [ "iCookieDuration", "iStateDuration" ], // backwards compat
  5233. [ "oSearch", "oPreviousSearch" ],
  5234. [ "aoSearchCols", "aoPreSearchCols" ],
  5235. [ "iDisplayLength", "_iDisplayLength" ],
  5236. [ "bJQueryUI", "bJUI" ]
  5237. ] );
  5238. _fnMap( oSettings.oScroll, oInit, [
  5239. [ "sScrollX", "sX" ],
  5240. [ "sScrollXInner", "sXInner" ],
  5241. [ "sScrollY", "sY" ],
  5242. [ "bScrollCollapse", "bCollapse" ]
  5243. ] );
  5244. _fnMap( oSettings.oLanguage, oInit, "fnInfoCallback" );
  5245. /* Callback functions which are array driven */
  5246. _fnCallbackReg( oSettings, 'aoDrawCallback', oInit.fnDrawCallback, 'user' );
  5247. _fnCallbackReg( oSettings, 'aoServerParams', oInit.fnServerParams, 'user' );
  5248. _fnCallbackReg( oSettings, 'aoStateSaveParams', oInit.fnStateSaveParams, 'user' );
  5249. _fnCallbackReg( oSettings, 'aoStateLoadParams', oInit.fnStateLoadParams, 'user' );
  5250. _fnCallbackReg( oSettings, 'aoStateLoaded', oInit.fnStateLoaded, 'user' );
  5251. _fnCallbackReg( oSettings, 'aoRowCallback', oInit.fnRowCallback, 'user' );
  5252. _fnCallbackReg( oSettings, 'aoRowCreatedCallback', oInit.fnCreatedRow, 'user' );
  5253. _fnCallbackReg( oSettings, 'aoHeaderCallback', oInit.fnHeaderCallback, 'user' );
  5254. _fnCallbackReg( oSettings, 'aoFooterCallback', oInit.fnFooterCallback, 'user' );
  5255. _fnCallbackReg( oSettings, 'aoInitComplete', oInit.fnInitComplete, 'user' );
  5256. _fnCallbackReg( oSettings, 'aoPreDrawCallback', oInit.fnPreDrawCallback, 'user' );
  5257. var oClasses = oSettings.oClasses;
  5258. // @todo Remove in 1.11
  5259. if ( oInit.bJQueryUI )
  5260. {
  5261. /* Use the JUI classes object for display. You could clone the oStdClasses object if
  5262. * you want to have multiple tables with multiple independent classes
  5263. */
  5264. $.extend( oClasses, DataTable.ext.oJUIClasses, oInit.oClasses );
  5265. if ( oInit.sDom === defaults.sDom && defaults.sDom === "lfrtip" )
  5266. {
  5267. /* Set the DOM to use a layout suitable for jQuery UI's theming */
  5268. oSettings.sDom = '<"H"lfr>t<"F"ip>';
  5269. }
  5270. if ( ! oSettings.renderer ) {
  5271. oSettings.renderer = 'jqueryui';
  5272. }
  5273. else if ( $.isPlainObject( oSettings.renderer ) && ! oSettings.renderer.header ) {
  5274. oSettings.renderer.header = 'jqueryui';
  5275. }
  5276. }
  5277. else
  5278. {
  5279. $.extend( oClasses, DataTable.ext.classes, oInit.oClasses );
  5280. }
  5281. $(this).addClass( oClasses.sTable );
  5282. /* Calculate the scroll bar width and cache it for use later on */
  5283. if ( oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "" )
  5284. {
  5285. oSettings.oScroll.iBarWidth = _fnScrollBarWidth();
  5286. }
  5287. if ( oSettings.oScroll.sX === true ) { // Easy initialisation of x-scrolling
  5288. oSettings.oScroll.sX = '100%';
  5289. }
  5290. if ( oSettings.iInitDisplayStart === undefined )
  5291. {
  5292. /* Display start point, taking into account the save saving */
  5293. oSettings.iInitDisplayStart = oInit.iDisplayStart;
  5294. oSettings._iDisplayStart = oInit.iDisplayStart;
  5295. }
  5296. if ( oInit.iDeferLoading !== null )
  5297. {
  5298. oSettings.bDeferLoading = true;
  5299. var tmp = $.isArray( oInit.iDeferLoading );
  5300. oSettings._iRecordsDisplay = tmp ? oInit.iDeferLoading[0] : oInit.iDeferLoading;
  5301. oSettings._iRecordsTotal = tmp ? oInit.iDeferLoading[1] : oInit.iDeferLoading;
  5302. }
  5303. /* Language definitions */
  5304. if ( oInit.oLanguage.sUrl !== "" )
  5305. {
  5306. /* Get the language definitions from a file - because this Ajax call makes the language
  5307. * get async to the remainder of this function we use bInitHandedOff to indicate that
  5308. * _fnInitialise will be fired by the returned Ajax handler, rather than the constructor
  5309. */
  5310. oSettings.oLanguage.sUrl = oInit.oLanguage.sUrl;
  5311. $.getJSON( oSettings.oLanguage.sUrl, null, function( json ) {
  5312. _fnLanguageCompat( json );
  5313. _fnCamelToHungarian( defaults.oLanguage, json );
  5314. $.extend( true, oSettings.oLanguage, oInit.oLanguage, json );
  5315. _fnInitialise( oSettings );
  5316. } );
  5317. bInitHandedOff = true;
  5318. }
  5319. else
  5320. {
  5321. $.extend( true, oSettings.oLanguage, oInit.oLanguage );
  5322. }
  5323. /*
  5324. * Stripes
  5325. */
  5326. if ( oInit.asStripeClasses === null )
  5327. {
  5328. oSettings.asStripeClasses =[
  5329. oClasses.sStripeOdd,
  5330. oClasses.sStripeEven
  5331. ];
  5332. }
  5333. /* Remove row stripe classes if they are already on the table row */
  5334. var stripeClasses = oSettings.asStripeClasses;
  5335. var rowOne = $('tbody tr:eq(0)', this);
  5336. if ( $.inArray( true, $.map( stripeClasses, function(el, i) {
  5337. return rowOne.hasClass(el);
  5338. } ) ) !== -1 ) {
  5339. $('tbody tr', this).removeClass( stripeClasses.join(' ') );
  5340. oSettings.asDestroyStripes = stripeClasses.slice();
  5341. }
  5342. /*
  5343. * Columns
  5344. * See if we should load columns automatically or use defined ones
  5345. */
  5346. var anThs = [];
  5347. var aoColumnsInit;
  5348. var nThead = this.getElementsByTagName('thead');
  5349. if ( nThead.length !== 0 )
  5350. {
  5351. _fnDetectHeader( oSettings.aoHeader, nThead[0] );
  5352. anThs = _fnGetUniqueThs( oSettings );
  5353. }
  5354. /* If not given a column array, generate one with nulls */
  5355. if ( oInit.aoColumns === null )
  5356. {
  5357. aoColumnsInit = [];
  5358. for ( i=0, iLen=anThs.length ; i<iLen ; i++ )
  5359. {
  5360. aoColumnsInit.push( null );
  5361. }
  5362. }
  5363. else
  5364. {
  5365. aoColumnsInit = oInit.aoColumns;
  5366. }
  5367. /* Add the columns */
  5368. for ( i=0, iLen=aoColumnsInit.length ; i<iLen ; i++ )
  5369. {
  5370. _fnAddColumn( oSettings, anThs ? anThs[i] : null );
  5371. }
  5372. /* Apply the column definitions */
  5373. _fnApplyColumnDefs( oSettings, oInit.aoColumnDefs, aoColumnsInit, function (iCol, oDef) {
  5374. _fnColumnOptions( oSettings, iCol, oDef );
  5375. } );
  5376. /* HTML5 attribute detection - build an mData object automatically if the
  5377. * attributes are found
  5378. */
  5379. if ( rowOne.length ) {
  5380. var a = function ( cell, name ) {
  5381. return cell.getAttribute( 'data-'+name ) ? name : null;
  5382. };
  5383. $.each( _fnGetRowElements( oSettings, rowOne[0] ).cells, function (i, cell) {
  5384. var col = oSettings.aoColumns[i];
  5385. if ( col.mData === i ) {
  5386. var sort = a( cell, 'sort' ) || a( cell, 'order' );
  5387. var filter = a( cell, 'filter' ) || a( cell, 'search' );
  5388. if ( sort !== null || filter !== null ) {
  5389. col.mData = {
  5390. _: i+'.display',
  5391. sort: sort !== null ? i+'.@data-'+sort : undefined,
  5392. type: sort !== null ? i+'.@data-'+sort : undefined,
  5393. filter: filter !== null ? i+'.@data-'+filter : undefined
  5394. };
  5395. _fnColumnOptions( oSettings, i );
  5396. }
  5397. }
  5398. } );
  5399. }
  5400. var features = oSettings.oFeatures;
  5401. /* Must be done after everything which can be overridden by the state saving! */
  5402. if ( oInit.bStateSave )
  5403. {
  5404. features.bStateSave = true;
  5405. _fnLoadState( oSettings, oInit );
  5406. _fnCallbackReg( oSettings, 'aoDrawCallback', _fnSaveState, 'state_save' );
  5407. }
  5408. /*
  5409. * Sorting
  5410. * @todo For modularisation (1.11) this needs to do into a sort start up handler
  5411. */
  5412. // If aaSorting is not defined, then we use the first indicator in asSorting
  5413. // in case that has been altered, so the default sort reflects that option
  5414. if ( oInit.aaSorting === undefined )
  5415. {
  5416. var sorting = oSettings.aaSorting;
  5417. for ( i=0, iLen=sorting.length ; i<iLen ; i++ )
  5418. {
  5419. sorting[i][1] = oSettings.aoColumns[ i ].asSorting[0];
  5420. }
  5421. }
  5422. /* Do a first pass on the sorting classes (allows any size changes to be taken into
  5423. * account, and also will apply sorting disabled classes if disabled
  5424. */
  5425. _fnSortingClasses( oSettings );
  5426. if ( features.bSort )
  5427. {
  5428. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  5429. if ( oSettings.bSorted ) {
  5430. var aSort = _fnSortFlatten( oSettings );
  5431. var sortedColumns = {};
  5432. $.each( aSort, function (i, val) {
  5433. sortedColumns[ val.src ] = val.dir;
  5434. } );
  5435. _fnCallbackFire( oSettings, null, 'order', [oSettings, aSort, sortedColumns] );
  5436. _fnSortAria( oSettings );
  5437. }
  5438. } );
  5439. }
  5440. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  5441. if ( oSettings.bSorted || _fnDataSource( oSettings ) === 'ssp' || features.bDeferRender ) {
  5442. _fnSortingClasses( oSettings );
  5443. }
  5444. }, 'sc' );
  5445. /*
  5446. * Final init
  5447. * Cache the header, body and footer as required, creating them if needed
  5448. */
  5449. /* Browser support detection */
  5450. _fnBrowserDetect( oSettings );
  5451. // Work around for Webkit bug 83867 - store the caption-side before removing from doc
  5452. var captions = $(this).children('caption').each( function () {
  5453. this._captionSide = $(this).css('caption-side');
  5454. } );
  5455. var thead = $(this).children('thead');
  5456. if ( thead.length === 0 )
  5457. {
  5458. thead = $('<thead/>').appendTo(this);
  5459. }
  5460. oSettings.nTHead = thead[0];
  5461. var tbody = $(this).children('tbody');
  5462. if ( tbody.length === 0 )
  5463. {
  5464. tbody = $('<tbody/>').appendTo(this);
  5465. }
  5466. oSettings.nTBody = tbody[0];
  5467. var tfoot = $(this).children('tfoot');
  5468. if ( tfoot.length === 0 && captions.length > 0 && (oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "") )
  5469. {
  5470. // If we are a scrolling table, and no footer has been given, then we need to create
  5471. // a tfoot element for the caption element to be appended to
  5472. tfoot = $('<tfoot/>').appendTo(this);
  5473. }
  5474. if ( tfoot.length === 0 || tfoot.children().length === 0 ) {
  5475. $(this).addClass( oClasses.sNoFooter );
  5476. }
  5477. else if ( tfoot.length > 0 ) {
  5478. oSettings.nTFoot = tfoot[0];
  5479. _fnDetectHeader( oSettings.aoFooter, oSettings.nTFoot );
  5480. }
  5481. /* Check if there is data passing into the constructor */
  5482. if ( oInit.aaData )
  5483. {
  5484. for ( i=0 ; i<oInit.aaData.length ; i++ )
  5485. {
  5486. _fnAddData( oSettings, oInit.aaData[ i ] );
  5487. }
  5488. }
  5489. else if ( oSettings.bDeferLoading || _fnDataSource( oSettings ) == 'dom' )
  5490. {
  5491. /* Grab the data from the page - only do this when deferred loading or no Ajax
  5492. * source since there is no point in reading the DOM data if we are then going
  5493. * to replace it with Ajax data
  5494. */
  5495. _fnAddTr( oSettings, $(oSettings.nTBody).children('tr') );
  5496. }
  5497. /* Copy the data index array */
  5498. oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
  5499. /* Initialisation complete - table can be drawn */
  5500. oSettings.bInitialised = true;
  5501. /* Check if we need to initialise the table (it might not have been handed off to the
  5502. * language processor)
  5503. */
  5504. if ( bInitHandedOff === false )
  5505. {
  5506. _fnInitialise( oSettings );
  5507. }
  5508. } );
  5509. _that = null;
  5510. return this;
  5511. };
  5512. /**
  5513. * Computed structure of the DataTables API, defined by the options passed to
  5514. * `DataTable.Api.register()` when building the API.
  5515. *
  5516. * The structure is built in order to speed creation and extension of the Api
  5517. * objects since the extensions are effectively pre-parsed.
  5518. *
  5519. * The array is an array of objects with the following structure, where this
  5520. * base array represents the Api prototype base:
  5521. *
  5522. * [
  5523. * {
  5524. * name: 'data' -- string - Property name
  5525. * val: function () {}, -- function - Api method (or undefined if just an object
  5526. * methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  5527. * propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  5528. * },
  5529. * {
  5530. * name: 'row'
  5531. * val: {},
  5532. * methodExt: [ ... ],
  5533. * propExt: [
  5534. * {
  5535. * name: 'data'
  5536. * val: function () {},
  5537. * methodExt: [ ... ],
  5538. * propExt: [ ... ]
  5539. * },
  5540. * ...
  5541. * ]
  5542. * }
  5543. * ]
  5544. *
  5545. * @type {Array}
  5546. * @ignore
  5547. */
  5548. var __apiStruct = [];
  5549. /**
  5550. * `Array.prototype` reference.
  5551. *
  5552. * @type object
  5553. * @ignore
  5554. */
  5555. var __arrayProto = Array.prototype;
  5556. /**
  5557. * Abstraction for `context` parameter of the `Api` constructor to allow it to
  5558. * take several different forms for ease of use.
  5559. *
  5560. * Each of the input parameter types will be converted to a DataTables settings
  5561. * object where possible.
  5562. *
  5563. * @param {string|node|jQuery|object} mixed DataTable identifier. Can be one
  5564. * of:
  5565. *
  5566. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5567. * with be found and used.
  5568. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5569. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5570. * * `object` - DataTables settings object
  5571. * * `DataTables.Api` - API instance
  5572. * @return {array|null} Matching DataTables settings objects. `null` or
  5573. * `undefined` is returned if no matching DataTable is found.
  5574. * @ignore
  5575. */
  5576. var _toSettings = function ( mixed )
  5577. {
  5578. var idx, jq;
  5579. var settings = DataTable.settings;
  5580. var tables = $.map( settings, function (el, i) {
  5581. return el.nTable;
  5582. } );
  5583. if ( ! mixed ) {
  5584. return [];
  5585. }
  5586. else if ( mixed.nTable && mixed.oApi ) {
  5587. // DataTables settings object
  5588. return [ mixed ];
  5589. }
  5590. else if ( mixed.nodeName && mixed.nodeName.toLowerCase() === 'table' ) {
  5591. // Table node
  5592. idx = $.inArray( mixed, tables );
  5593. return idx !== -1 ? [ settings[idx] ] : null;
  5594. }
  5595. else if ( mixed && typeof mixed.settings === 'function' ) {
  5596. return mixed.settings().toArray();
  5597. }
  5598. else if ( typeof mixed === 'string' ) {
  5599. // jQuery selector
  5600. jq = $(mixed);
  5601. }
  5602. else if ( mixed instanceof $ ) {
  5603. // jQuery object (also DataTables instance)
  5604. jq = mixed;
  5605. }
  5606. if ( jq ) {
  5607. return jq.map( function(i) {
  5608. idx = $.inArray( this, tables );
  5609. return idx !== -1 ? settings[idx] : null;
  5610. } ).toArray();
  5611. }
  5612. };
  5613. /**
  5614. * DataTables API class - used to control and interface with one or more
  5615. * DataTables enhanced tables.
  5616. *
  5617. * The API class is heavily based on jQuery, presenting a chainable interface
  5618. * that you can use to interact with tables. Each instance of the API class has
  5619. * a "context" - i.e. the tables that it will operate on. This could be a single
  5620. * table, all tables on a page or a sub-set thereof.
  5621. *
  5622. * Additionally the API is designed to allow you to easily work with the data in
  5623. * the tables, retrieving and manipulating it as required. This is done by
  5624. * presenting the API class as an array like interface. The contents of the
  5625. * array depend upon the actions requested by each method (for example
  5626. * `rows().nodes()` will return an array of nodes, while `rows().data()` will
  5627. * return an array of objects or arrays depending upon your table's
  5628. * configuration). The API object has a number of array like methods (`push`,
  5629. * `pop`, `reverse` etc) as well as additional helper methods (`each`, `pluck`,
  5630. * `unique` etc) to assist your working with the data held in a table.
  5631. *
  5632. * Most methods (those which return an Api instance) are chainable, which means
  5633. * the return from a method call also has all of the methods available that the
  5634. * top level object had. For example, these two calls are equivalent:
  5635. *
  5636. * // Not chained
  5637. * api.row.add( {...} );
  5638. * api.draw();
  5639. *
  5640. * // Chained
  5641. * api.row.add( {...} ).draw();
  5642. *
  5643. * @class DataTable.Api
  5644. * @param {array|object|string|jQuery} context DataTable identifier. This is
  5645. * used to define which DataTables enhanced tables this API will operate on.
  5646. * Can be one of:
  5647. *
  5648. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5649. * with be found and used.
  5650. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5651. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5652. * * `object` - DataTables settings object
  5653. * @param {array} [data] Data to initialise the Api instance with.
  5654. *
  5655. * @example
  5656. * // Direct initialisation during DataTables construction
  5657. * var api = $('#example').DataTable();
  5658. *
  5659. * @example
  5660. * // Initialisation using a DataTables jQuery object
  5661. * var api = $('#example').dataTable().api();
  5662. *
  5663. * @example
  5664. * // Initialisation as a constructor
  5665. * var api = new $.fn.DataTable.Api( 'table.dataTable' );
  5666. */
  5667. _Api = function ( context, data )
  5668. {
  5669. if ( ! this instanceof _Api ) {
  5670. throw 'DT API must be constructed as a new object';
  5671. // or should it do the 'new' for the caller?
  5672. // return new _Api.apply( this, arguments );
  5673. }
  5674. var settings = [];
  5675. var ctxSettings = function ( o ) {
  5676. var a = _toSettings( o );
  5677. if ( a ) {
  5678. settings.push.apply( settings, a );
  5679. }
  5680. };
  5681. if ( $.isArray( context ) ) {
  5682. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  5683. ctxSettings( context[i] );
  5684. }
  5685. }
  5686. else {
  5687. ctxSettings( context );
  5688. }
  5689. // Remove duplicates
  5690. this.context = _unique( settings );
  5691. // Initial data
  5692. if ( data ) {
  5693. this.push.apply( this, data.toArray ? data.toArray() : data );
  5694. }
  5695. // selector
  5696. this.selector = {
  5697. rows: null,
  5698. cols: null,
  5699. opts: null
  5700. };
  5701. _Api.extend( this, this, __apiStruct );
  5702. };
  5703. DataTable.Api = _Api;
  5704. _Api.prototype = /** @lends DataTables.Api */{
  5705. /**
  5706. * Return a new Api instance, comprised of the data held in the current
  5707. * instance, join with the other array(s) and/or value(s).
  5708. *
  5709. * An alias for `Array.prototype.concat`.
  5710. *
  5711. * @type method
  5712. * @param {*} value1 Arrays and/or values to concatenate.
  5713. * @param {*} [...] Additional arrays and/or values to concatenate.
  5714. * @returns {DataTables.Api} New API instance, comprising of the combined
  5715. * array.
  5716. */
  5717. concat: __arrayProto.concat,
  5718. context: [], // array of table settings objects
  5719. each: function ( fn )
  5720. {
  5721. for ( var i=0, ien=this.length ; i<ien; i++ ) {
  5722. fn.call( this, this[i], i, this );
  5723. }
  5724. return this;
  5725. },
  5726. eq: function ( idx )
  5727. {
  5728. var ctx = this.context;
  5729. return ctx.length > idx ?
  5730. new _Api( ctx[idx], this[idx] ) :
  5731. null;
  5732. },
  5733. filter: function ( fn )
  5734. {
  5735. var a = [];
  5736. if ( __arrayProto.filter ) {
  5737. a = __arrayProto.filter.call( this, fn, this );
  5738. }
  5739. else {
  5740. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  5741. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  5742. if ( fn.call( this, this[i], i, this ) ) {
  5743. a.push( this[i] );
  5744. }
  5745. }
  5746. }
  5747. return new _Api( this.context, a );
  5748. },
  5749. flatten: function ()
  5750. {
  5751. var a = [];
  5752. return new _Api( this.context, a.concat.apply( a, this.toArray() ) );
  5753. },
  5754. join: __arrayProto.join,
  5755. indexOf: __arrayProto.indexOf || function (obj, start)
  5756. {
  5757. for ( var i=(start || 0), ien=this.length ; i<ien ; i++ ) {
  5758. if ( this[i] === obj ) {
  5759. return i;
  5760. }
  5761. }
  5762. return -1;
  5763. },
  5764. // Internal only at the moment - relax?
  5765. iterator: function ( flatten, type, fn ) {
  5766. var
  5767. a = [], ret,
  5768. i, ien, j, jen,
  5769. context = this.context,
  5770. rows, items, item,
  5771. selector = this.selector;
  5772. // Argument shifting
  5773. if ( typeof flatten === 'string' ) {
  5774. fn = type;
  5775. type = flatten;
  5776. flatten = false;
  5777. }
  5778. for ( i=0, ien=context.length ; i<ien ; i++ ) {
  5779. if ( type === 'table' ) {
  5780. ret = fn( context[i], i );
  5781. if ( ret !== undefined ) {
  5782. a.push( ret );
  5783. }
  5784. }
  5785. else if ( type === 'columns' || type === 'rows' ) {
  5786. // this has same length as context - one entry for each table
  5787. ret = fn( context[i], this[i], i );
  5788. if ( ret !== undefined ) {
  5789. a.push( ret );
  5790. }
  5791. }
  5792. else if ( type === 'column' || type === 'column-rows' || type === 'row' || type === 'cell' ) {
  5793. // columns and rows share the same structure.
  5794. // 'this' is an array of column indexes for each context
  5795. items = this[i];
  5796. if ( type === 'column-rows' ) {
  5797. rows = _selector_row_indexes( context[i], selector.opts );
  5798. }
  5799. for ( j=0, jen=items.length ; j<jen ; j++ ) {
  5800. item = items[j];
  5801. if ( type === 'cell' ) {
  5802. ret = fn( context[i], item.row, item.column, i, j );
  5803. }
  5804. else {
  5805. ret = fn( context[i], item, i, j, rows );
  5806. }
  5807. if ( ret !== undefined ) {
  5808. a.push( ret );
  5809. }
  5810. }
  5811. }
  5812. }
  5813. if ( a.length ) {
  5814. var api = new _Api( context, flatten ? a.concat.apply( [], a ) : a );
  5815. var apiSelector = api.selector;
  5816. apiSelector.rows = selector.rows;
  5817. apiSelector.cols = selector.cols;
  5818. apiSelector.opts = selector.opts;
  5819. return api;
  5820. }
  5821. return this;
  5822. },
  5823. lastIndexOf: __arrayProto.lastIndexOf || function (obj, start)
  5824. {
  5825. // Bit cheeky...
  5826. return this.indexOf.apply( this.toArray.reverse(), arguments );
  5827. },
  5828. length: 0,
  5829. map: function ( fn )
  5830. {
  5831. var a = [];
  5832. if ( __arrayProto.map ) {
  5833. a = __arrayProto.map.call( this, fn, this );
  5834. }
  5835. else {
  5836. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  5837. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  5838. a.push( fn.call( this, this[i], i ) );
  5839. }
  5840. }
  5841. return new _Api( this.context, a );
  5842. },
  5843. pluck: function ( prop )
  5844. {
  5845. return this.map( function ( el ) {
  5846. return el[ prop ];
  5847. } );
  5848. },
  5849. pop: __arrayProto.pop,
  5850. push: __arrayProto.push,
  5851. // Does not return an API instance
  5852. reduce: __arrayProto.reduce || function ( fn, init )
  5853. {
  5854. return _fnReduce( this, fn, init, 0, this.length, 1 );
  5855. },
  5856. reduceRight: __arrayProto.reduceRight || function ( fn, init )
  5857. {
  5858. return _fnReduce( this, fn, init, this.length-1, -1, -1 );
  5859. },
  5860. reverse: __arrayProto.reverse,
  5861. // Object with rows, columns and opts
  5862. selector: null,
  5863. shift: __arrayProto.shift,
  5864. sort: __arrayProto.sort, // ? name - order?
  5865. splice: __arrayProto.splice,
  5866. toArray: function ()
  5867. {
  5868. return __arrayProto.slice.call( this );
  5869. },
  5870. to$: function ()
  5871. {
  5872. return $( this );
  5873. },
  5874. toJQuery: function ()
  5875. {
  5876. return $( this );
  5877. },
  5878. unique: function ()
  5879. {
  5880. return new _Api( this.context, _unique(this) );
  5881. },
  5882. unshift: __arrayProto.unshift
  5883. };
  5884. _Api.extend = function ( scope, obj, ext )
  5885. {
  5886. // Only extend API instances and static properties of the API
  5887. if ( ! obj || ( ! (obj instanceof _Api) && ! obj.__dt_wrapper ) ) {
  5888. return;
  5889. }
  5890. var
  5891. i, ien,
  5892. j, jen,
  5893. struct, inner,
  5894. methodScoping = function ( scope, fn, struc ) {
  5895. return function () {
  5896. var ret = fn.apply( scope, arguments );
  5897. // Method extension
  5898. _Api.extend( ret, ret, struc.methodExt );
  5899. return ret;
  5900. };
  5901. };
  5902. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  5903. struct = ext[i];
  5904. // Value
  5905. obj[ struct.name ] = typeof struct.val === 'function' ?
  5906. methodScoping( scope, struct.val, struct ) :
  5907. $.isPlainObject( struct.val ) ?
  5908. {} :
  5909. struct.val;
  5910. obj[ struct.name ].__dt_wrapper = true;
  5911. // Property extension
  5912. _Api.extend( scope, obj[ struct.name ], struct.propExt );
  5913. }
  5914. };
  5915. // @todo - Is there need for an augment function?
  5916. // _Api.augment = function ( inst, name )
  5917. // {
  5918. // // Find src object in the structure from the name
  5919. // var parts = name.split('.');
  5920. // _Api.extend( inst, obj );
  5921. // };
  5922. // [
  5923. // {
  5924. // name: 'data' -- string - Property name
  5925. // val: function () {}, -- function - Api method (or undefined if just an object
  5926. // methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  5927. // propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  5928. // },
  5929. // {
  5930. // name: 'row'
  5931. // val: {},
  5932. // methodExt: [ ... ],
  5933. // propExt: [
  5934. // {
  5935. // name: 'data'
  5936. // val: function () {},
  5937. // methodExt: [ ... ],
  5938. // propExt: [ ... ]
  5939. // },
  5940. // ...
  5941. // ]
  5942. // }
  5943. // ]
  5944. _Api.register = _api_register = function ( name, val )
  5945. {
  5946. if ( $.isArray( name ) ) {
  5947. for ( var j=0, jen=name.length ; j<jen ; j++ ) {
  5948. _Api.register( name[j], val );
  5949. }
  5950. return;
  5951. }
  5952. var
  5953. i, ien,
  5954. heir = name.split('.'),
  5955. struct = __apiStruct,
  5956. key, method;
  5957. var find = function ( src, name ) {
  5958. for ( var i=0, ien=src.length ; i<ien ; i++ ) {
  5959. if ( src[i].name === name ) {
  5960. return src[i];
  5961. }
  5962. }
  5963. return null;
  5964. };
  5965. for ( i=0, ien=heir.length ; i<ien ; i++ ) {
  5966. method = heir[i].indexOf('()') !== -1;
  5967. key = method ?
  5968. heir[i].replace('()', '') :
  5969. heir[i];
  5970. var src = find( struct, key );
  5971. if ( ! src ) {
  5972. src = {
  5973. name: key,
  5974. val: {},
  5975. methodExt: [],
  5976. propExt: []
  5977. };
  5978. struct.push( src );
  5979. }
  5980. if ( i === ien-1 ) {
  5981. src.val = val;
  5982. }
  5983. else {
  5984. struct = method ?
  5985. src.methodExt :
  5986. src.propExt;
  5987. }
  5988. }
  5989. };
  5990. _Api.registerPlural = _api_registerPlural = function ( pluralName, singularName, val ) {
  5991. _Api.register( pluralName, val );
  5992. _Api.register( singularName, function () {
  5993. var ret = val.apply( this, arguments );
  5994. if ( ret === this ) {
  5995. // Returned item is the API instance that was passed in, return it
  5996. return this;
  5997. }
  5998. else if ( ret instanceof _Api ) {
  5999. // New API instance returned, want the value from the first item
  6000. // in the returned array for the singular result.
  6001. return ret.length ?
  6002. $.isArray( ret[0] ) ?
  6003. new _Api( ret.context, ret[0] ) : // Array results are 'enhanced'
  6004. ret[0] :
  6005. undefined;
  6006. }
  6007. // Non-API return - just fire it back
  6008. return ret;
  6009. } );
  6010. };
  6011. /**
  6012. * Selector for HTML tables. Apply the given selector to the give array of
  6013. * DataTables settings objects.
  6014. *
  6015. * @param {string|integer} [selector] jQuery selector string or integer
  6016. * @param {array} Array of DataTables settings objects to be filtered
  6017. * @return {array}
  6018. * @ignore
  6019. */
  6020. var __table_selector = function ( selector, a )
  6021. {
  6022. // Integer is used to pick out a table by index
  6023. if ( typeof selector === 'number' ) {
  6024. return [ a[ selector ] ];
  6025. }
  6026. // Perform a jQuery selector on the table nodes
  6027. var nodes = $.map( a, function (el, i) {
  6028. return el.nTable;
  6029. } );
  6030. return $(nodes)
  6031. .filter( selector )
  6032. .map( function (i) {
  6033. // Need to translate back from the table node to the settings
  6034. var idx = $.inArray( this, nodes );
  6035. return a[ idx ];
  6036. } )
  6037. .toArray();
  6038. };
  6039. /**
  6040. * Context selector for the API's context (i.e. the tables the API instance
  6041. * refers to.
  6042. *
  6043. * @name DataTable.Api#tables
  6044. * @param {string|integer} [selector] Selector to pick which tables the iterator
  6045. * should operate on. If not given, all tables in the current context are
  6046. * used. This can be given as a jQuery selector (for example `':gt(0)'`) to
  6047. * select multiple tables or as an integer to select a single table.
  6048. * @returns {DataTable.Api} Returns a new API instance if a selector is given.
  6049. */
  6050. _api_register( 'tables()', function ( selector ) {
  6051. // A new instance is created if there was a selector specified
  6052. return selector ?
  6053. new _Api( __table_selector( selector, this.context ) ) :
  6054. this;
  6055. } );
  6056. _api_register( 'table()', function ( selector ) {
  6057. var tables = this.tables( selector );
  6058. var ctx = tables.context;
  6059. // Truncate to the first matched table
  6060. return ctx.length ?
  6061. new _Api( ctx[0] ) :
  6062. tables;
  6063. } );
  6064. _api_registerPlural( 'tables().nodes()', 'table().node()' , function () {
  6065. return this.iterator( 'table', function ( ctx ) {
  6066. return ctx.nTable;
  6067. } );
  6068. } );
  6069. _api_registerPlural( 'tables().body()', 'table().body()' , function () {
  6070. return this.iterator( 'table', function ( ctx ) {
  6071. return ctx.nTBody;
  6072. } );
  6073. } );
  6074. _api_registerPlural( 'tables().header()', 'table().header()' , function () {
  6075. return this.iterator( 'table', function ( ctx ) {
  6076. return ctx.nTHead;
  6077. } );
  6078. } );
  6079. _api_registerPlural( 'tables().footer()', 'table().footer()' , function () {
  6080. return this.iterator( 'table', function ( ctx ) {
  6081. return ctx.nTFoot;
  6082. } );
  6083. } );
  6084. _api_registerPlural( 'tables().containers()', 'table().container()' , function () {
  6085. return this.iterator( 'table', function ( ctx ) {
  6086. return ctx.nTableWrapper;
  6087. } );
  6088. } );
  6089. /**
  6090. * Redraw the tables in the current context.
  6091. *
  6092. * @param {boolean} [reset=true] Reset (default) or hold the current paging
  6093. * position. A full re-sort and re-filter is performed when this method is
  6094. * called, which is why the pagination reset is the default action.
  6095. * @returns {DataTables.Api} this
  6096. */
  6097. _api_register( 'draw()', function ( resetPaging ) {
  6098. return this.iterator( 'table', function ( settings ) {
  6099. _fnReDraw( settings, resetPaging===false );
  6100. } );
  6101. } );
  6102. /**
  6103. * Get the current page index.
  6104. *
  6105. * @return {integer} Current page index (zero based)
  6106. *//**
  6107. * Set the current page.
  6108. *
  6109. * Note that if you attempt to show a page which does not exist, DataTables will
  6110. * not throw an error, but rather reset the paging.
  6111. *
  6112. * @param {integer|string} action The paging action to take. This can be one of:
  6113. * * `integer` - The page index to jump to
  6114. * * `string` - An action to take:
  6115. * * `first` - Jump to first page.
  6116. * * `next` - Jump to the next page
  6117. * * `previous` - Jump to previous page
  6118. * * `last` - Jump to the last page.
  6119. * @returns {DataTables.Api} this
  6120. */
  6121. _api_register( 'page()', function ( action ) {
  6122. if ( action === undefined ) {
  6123. return this.page.info().page; // not an expensive call
  6124. }
  6125. // else, have an action to take on all tables
  6126. return this.iterator( 'table', function ( settings ) {
  6127. _fnPageChange( settings, action );
  6128. } );
  6129. } );
  6130. /**
  6131. * Paging information for the first table in the current context.
  6132. *
  6133. * If you require paging information for another table, use the `table()` method
  6134. * with a suitable selector.
  6135. *
  6136. * @return {object} Object with the following properties set:
  6137. * * `page` - Current page index (zero based - i.e. the first page is `0`)
  6138. * * `pages` - Total number of pages
  6139. * * `start` - Display index for the first record shown on the current page
  6140. * * `end` - Display index for the last record shown on the current page
  6141. * * `length` - Display length (number of records). Note that generally `start
  6142. * + length = end`, but this is not always true, for example if there are
  6143. * only 2 records to show on the final page, with a length of 10.
  6144. * * `recordsTotal` - Full data set length
  6145. * * `recordsDisplay` - Data set length once the current filtering criterion
  6146. * are applied.
  6147. */
  6148. _api_register( 'page.info()', function ( action ) {
  6149. if ( this.context.length === 0 ) {
  6150. return undefined;
  6151. }
  6152. var
  6153. settings = this.context[0],
  6154. start = settings._iDisplayStart,
  6155. len = settings._iDisplayLength,
  6156. visRecords = settings.fnRecordsDisplay(),
  6157. all = len === -1;
  6158. return {
  6159. "page": all ? 0 : Math.floor( start / len ),
  6160. "pages": all ? 1 : Math.ceil( visRecords / len ),
  6161. "start": start,
  6162. "end": settings.fnDisplayEnd(),
  6163. "length": len,
  6164. "recordsTotal": settings.fnRecordsTotal(),
  6165. "recordsDisplay": visRecords
  6166. };
  6167. } );
  6168. /**
  6169. * Get the current page length.
  6170. *
  6171. * @return {integer} Current page length. Note `-1` indicates that all records
  6172. * are to be shown.
  6173. *//**
  6174. * Set the current page length.
  6175. *
  6176. * @param {integer} Page length to set. Use `-1` to show all records.
  6177. * @returns {DataTables.Api} this
  6178. */
  6179. _api_register( 'page.len()', function ( len ) {
  6180. // Note that we can't call this function 'length()' because `length`
  6181. // is a Javascript property of functions which defines how many arguments
  6182. // the function expects.
  6183. if ( len === undefined ) {
  6184. return this.context.length !== 0 ?
  6185. this.context[0]._iDisplayLength :
  6186. undefined;
  6187. }
  6188. // else, set the page length
  6189. return this.iterator( 'table', function ( settings ) {
  6190. _fnLengthChange( settings, len );
  6191. } );
  6192. } );
  6193. var __reload = function ( settings, holdPosition, callback ) {
  6194. if ( _fnDataSource( settings ) == 'ssp' ) {
  6195. _fnReDraw( settings, holdPosition );
  6196. }
  6197. else {
  6198. // Trigger xhr
  6199. _fnProcessingDisplay( settings, true );
  6200. _fnBuildAjax( settings, [], function( json ) {
  6201. _fnClearTable( settings );
  6202. var data = _fnAjaxDataSrc( settings, json );
  6203. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6204. _fnAddData( settings, data[i] );
  6205. }
  6206. _fnReDraw( settings, holdPosition );
  6207. _fnProcessingDisplay( settings, false );
  6208. } );
  6209. }
  6210. // Use the draw event to trigger a callback, regardless of if it is an async
  6211. // or sync draw
  6212. if ( callback ) {
  6213. var api = new _Api( settings );
  6214. api.one( 'draw', function () {
  6215. callback( api.ajax.json() );
  6216. } );
  6217. }
  6218. };
  6219. /**
  6220. * Get the JSON response from the last Ajax request that DataTables made to the
  6221. * server. Note that this returns the JSON from the first table in the current
  6222. * context.
  6223. *
  6224. * @return {object} JSON received from the server.
  6225. */
  6226. _api_register( 'ajax.json()', function () {
  6227. var ctx = this.context;
  6228. if ( ctx.length > 0 ) {
  6229. return ctx[0].json;
  6230. }
  6231. // else return undefined;
  6232. } );
  6233. /**
  6234. * Get the data submitted in the last Ajax request
  6235. */
  6236. _api_register( 'ajax.params()', function () {
  6237. var ctx = this.context;
  6238. if ( ctx.length > 0 ) {
  6239. return ctx[0].oAjaxData;
  6240. }
  6241. // else return undefined;
  6242. } );
  6243. /**
  6244. * Reload tables from the Ajax data source. Note that this function will
  6245. * automatically re-draw the table when the remote data has been loaded.
  6246. *
  6247. * @param {boolean} [reset=true] Reset (default) or hold the current paging
  6248. * position. A full re-sort and re-filter is performed when this method is
  6249. * called, which is why the pagination reset is the default action.
  6250. * @returns {DataTables.Api} this
  6251. */
  6252. _api_register( 'ajax.reload()', function ( callback, resetPaging ) {
  6253. return this.iterator( 'table', function (settings) {
  6254. __reload( settings, resetPaging===false, callback );
  6255. } );
  6256. } );
  6257. /**
  6258. * Get the current Ajax URL. Note that this returns the URL from the first
  6259. * table in the current context.
  6260. *
  6261. * @return {string} Current Ajax source URL
  6262. *//**
  6263. * Set the Ajax URL. Note that this will set the URL for all tables in the
  6264. * current context.
  6265. *
  6266. * @param {string} url URL to set.
  6267. * @returns {DataTables.Api} this
  6268. */
  6269. _api_register( 'ajax.url()', function ( url ) {
  6270. var ctx = this.context;
  6271. if ( url === undefined ) {
  6272. // get
  6273. if ( ctx.length === 0 ) {
  6274. return undefined;
  6275. }
  6276. ctx = ctx[0];
  6277. return ctx.ajax ?
  6278. $.isPlainObject( ctx.ajax ) ?
  6279. ctx.ajax.url :
  6280. ctx.ajax :
  6281. ctx.sAjaxSource;
  6282. }
  6283. // set
  6284. return this.iterator( 'table', function ( settings ) {
  6285. if ( $.isPlainObject( settings.ajax ) ) {
  6286. settings.ajax.url = url;
  6287. }
  6288. else {
  6289. settings.ajax = url;
  6290. }
  6291. // No need to consider sAjaxSource here since DataTables gives priority
  6292. // to `ajax` over `sAjaxSource`. So setting `ajax` here, renders any
  6293. // value of `sAjaxSource` redundant.
  6294. } );
  6295. } );
  6296. /**
  6297. * Load data from the newly set Ajax URL. Note that this method is only
  6298. * available when `ajax.url()` is used to set a URL. Additionally, this method
  6299. * has the same effect as calling `ajax.reload()` but is provided for
  6300. * convenience when setting a new URL. Like `ajax.reload()` it will
  6301. * automatically redraw the table once the remote data has been loaded.
  6302. *
  6303. * @returns {DataTables.Api} this
  6304. */
  6305. _api_register( 'ajax.url().load()', function ( callback, resetPaging ) {
  6306. // Same as a reload, but makes sense to present it for easy access after a
  6307. // url change
  6308. return this.iterator( 'table', function ( ctx ) {
  6309. __reload( ctx, resetPaging===false, callback );
  6310. } );
  6311. } );
  6312. var _selector_run = function ( selector, select )
  6313. {
  6314. var
  6315. out = [], res,
  6316. a, i, ien, j, jen;
  6317. // Can't just check for isArray here, as an API or jQuery instance might be
  6318. // given with their array like look
  6319. if ( ! selector || typeof selector === 'string' || selector.length === undefined ) {
  6320. selector = [ selector ];
  6321. }
  6322. for ( i=0, ien=selector.length ; i<ien ; i++ ) {
  6323. a = selector[i] && selector[i].split ?
  6324. selector[i].split(',') :
  6325. [ selector[i] ];
  6326. for ( j=0, jen=a.length ; j<jen ; j++ ) {
  6327. res = select( typeof a[j] === 'string' ? $.trim(a[j]) : a[j] );
  6328. if ( res && res.length ) {
  6329. out.push.apply( out, res );
  6330. }
  6331. }
  6332. }
  6333. return out;
  6334. };
  6335. var _selector_opts = function ( opts )
  6336. {
  6337. if ( ! opts ) {
  6338. opts = {};
  6339. }
  6340. // Backwards compatibility for 1.9- which used the terminology filter rather
  6341. // than search
  6342. if ( opts.filter && ! opts.search ) {
  6343. opts.search = opts.filter;
  6344. }
  6345. return {
  6346. search: opts.search || 'none',
  6347. order: opts.order || 'current',
  6348. page: opts.page || 'all'
  6349. };
  6350. };
  6351. var _selector_first = function ( inst )
  6352. {
  6353. // Reduce the API instance to the first item found
  6354. for ( var i=0, ien=inst.length ; i<ien ; i++ ) {
  6355. if ( inst[i].length > 0 ) {
  6356. // Assign the first element to the first item in the instance
  6357. // and truncate the instance and context
  6358. inst[0] = inst[i];
  6359. inst.length = 1;
  6360. inst.context = [ inst.context[i] ];
  6361. return inst;
  6362. }
  6363. }
  6364. // Not found - return an empty instance
  6365. inst.length = 0;
  6366. return inst;
  6367. };
  6368. var _selector_row_indexes = function ( settings, opts )
  6369. {
  6370. var
  6371. i, ien, tmp, a=[],
  6372. displayFiltered = settings.aiDisplay,
  6373. displayMaster = settings.aiDisplayMaster;
  6374. var
  6375. search = opts.search, // none, applied, removed
  6376. order = opts.order, // applied, current, index (original - compatibility with 1.9)
  6377. page = opts.page; // all, current
  6378. if ( _fnDataSource( settings ) == 'ssp' ) {
  6379. // In server-side processing mode, most options are irrelevant since
  6380. // rows not shown don't exist and the index order is the applied order
  6381. // Removed is a special case - for consistency just return an empty
  6382. // array
  6383. return search === 'removed' ?
  6384. [] :
  6385. _range( 0, displayMaster.length );
  6386. }
  6387. else if ( page == 'current' ) {
  6388. // Current page implies that order=current and fitler=applied, since it is
  6389. // fairly senseless otherwise, regardless of what order and search actually
  6390. // are
  6391. for ( i=settings._iDisplayStart, ien=settings.fnDisplayEnd() ; i<ien ; i++ ) {
  6392. a.push( displayFiltered[i] );
  6393. }
  6394. }
  6395. else if ( order == 'current' || order == 'applied' ) {
  6396. a = search == 'none' ?
  6397. displayMaster.slice() : // no search
  6398. search == 'applied' ?
  6399. displayFiltered.slice() : // applied search
  6400. $.map( displayMaster, function (el, i) { // removed search
  6401. return $.inArray( el, displayFiltered ) === -1 ? el : null;
  6402. } );
  6403. }
  6404. else if ( order == 'index' || order == 'original' ) {
  6405. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  6406. if ( search == 'none' ) {
  6407. a.push( i );
  6408. }
  6409. else { // applied | removed
  6410. tmp = $.inArray( i, displayFiltered );
  6411. if ((tmp === -1 && search == 'removed') ||
  6412. (tmp >= 0 && search == 'applied') )
  6413. {
  6414. a.push( i );
  6415. }
  6416. }
  6417. }
  6418. }
  6419. return a;
  6420. };
  6421. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6422. * Rows
  6423. *
  6424. * {} - no selector - use all available rows
  6425. * {integer} - row aoData index
  6426. * {node} - TR node
  6427. * {string} - jQuery selector to apply to the TR elements
  6428. * {array} - jQuery array of nodes, or simply an array of TR nodes
  6429. *
  6430. */
  6431. var __row_selector = function ( settings, selector, opts )
  6432. {
  6433. return _selector_run( selector, function ( sel ) {
  6434. var selInt = _intVal( sel );
  6435. // Short cut - selector is a number and no options provided (default is
  6436. // all records, so no need to check if the index is in there, since it
  6437. // must be - dev error if the index doesn't exist).
  6438. if ( selInt !== null && ! opts ) {
  6439. return [ selInt ];
  6440. }
  6441. var rows = _selector_row_indexes( settings, opts );
  6442. if ( selInt !== null && $.inArray( selInt, rows ) !== -1 ) {
  6443. // Selector - integer
  6444. return [ selInt ];
  6445. }
  6446. else if ( ! sel ) {
  6447. // Selector - none
  6448. return rows;
  6449. }
  6450. // Get nodes in the order from the `rows` array (can't use `pluck`) @todo - use pluck_order
  6451. var nodes = [];
  6452. for ( var i=0, ien=rows.length ; i<ien ; i++ ) {
  6453. nodes.push( settings.aoData[ rows[i] ].nTr );
  6454. }
  6455. if ( sel.nodeName ) {
  6456. // Selector - node
  6457. if ( $.inArray( sel, nodes ) !== -1 ) {
  6458. return [ sel._DT_RowIndex ];// sel is a TR node that is in the table
  6459. // and DataTables adds a prop for fast lookup
  6460. }
  6461. }
  6462. // Selector - jQuery selector string, array of nodes or jQuery object/
  6463. // As jQuery's .filter() allows jQuery objects to be passed in filter,
  6464. // it also allows arrays, so this will cope with all three options
  6465. return $(nodes)
  6466. .filter( sel )
  6467. .map( function () {
  6468. return this._DT_RowIndex;
  6469. } )
  6470. .toArray();
  6471. } );
  6472. };
  6473. /**
  6474. *
  6475. */
  6476. _api_register( 'rows()', function ( selector, opts ) {
  6477. // argument shifting
  6478. if ( selector === undefined ) {
  6479. selector = '';
  6480. }
  6481. else if ( $.isPlainObject( selector ) ) {
  6482. opts = selector;
  6483. selector = '';
  6484. }
  6485. opts = _selector_opts( opts );
  6486. var inst = this.iterator( 'table', function ( settings ) {
  6487. return __row_selector( settings, selector, opts );
  6488. } );
  6489. // Want argument shifting here and in __row_selector?
  6490. inst.selector.rows = selector;
  6491. inst.selector.opts = opts;
  6492. return inst;
  6493. } );
  6494. _api_register( 'rows().nodes()', function () {
  6495. return this.iterator( 'row', function ( settings, row ) {
  6496. return settings.aoData[ row ].nTr || undefined;
  6497. } );
  6498. } );
  6499. _api_register( 'rows().data()', function () {
  6500. return this.iterator( true, 'rows', function ( settings, rows ) {
  6501. return _pluck_order( settings.aoData, rows, '_aData' );
  6502. } );
  6503. } );
  6504. _api_registerPlural( 'rows().cache()', 'row().cache()', function ( type ) {
  6505. return this.iterator( 'row', function ( settings, row ) {
  6506. var r = settings.aoData[ row ];
  6507. return type === 'search' ? r._aFilterData : r._aSortData;
  6508. } );
  6509. } );
  6510. _api_registerPlural( 'rows().invalidate()', 'row().invalidate()', function ( src ) {
  6511. return this.iterator( 'row', function ( settings, row ) {
  6512. _fnInvalidateRow( settings, row, src );
  6513. } );
  6514. } );
  6515. _api_registerPlural( 'rows().indexes()', 'row().index()', function () {
  6516. return this.iterator( 'row', function ( settings, row ) {
  6517. return row;
  6518. } );
  6519. } );
  6520. _api_registerPlural( 'rows().remove()', 'row().remove()', function () {
  6521. var that = this;
  6522. return this.iterator( 'row', function ( settings, row, thatIdx ) {
  6523. var data = settings.aoData;
  6524. data.splice( row, 1 );
  6525. // Update the _DT_RowIndex parameter on all rows in the table
  6526. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6527. if ( data[i].nTr !== null ) {
  6528. data[i].nTr._DT_RowIndex = i;
  6529. }
  6530. }
  6531. // Remove the target row from the search array
  6532. var displayIndex = $.inArray( row, settings.aiDisplay );
  6533. // Delete from the display arrays
  6534. _fnDeleteIndex( settings.aiDisplayMaster, row );
  6535. _fnDeleteIndex( settings.aiDisplay, row );
  6536. _fnDeleteIndex( that[ thatIdx ], row, false ); // maintain local indexes
  6537. // Check for an 'overflow' they case for displaying the table
  6538. _fnLengthOverflow( settings );
  6539. } );
  6540. } );
  6541. _api_register( 'rows.add()', function ( rows ) {
  6542. var newRows = this.iterator( 'table', function ( settings ) {
  6543. var row, i, ien;
  6544. var out = [];
  6545. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  6546. row = rows[i];
  6547. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  6548. out.push( _fnAddTr( settings, row )[0] );
  6549. }
  6550. else {
  6551. out.push( _fnAddData( settings, row ) );
  6552. }
  6553. }
  6554. return out;
  6555. } );
  6556. // Return an Api.rows() extended instance, so rows().nodes() etc can be used
  6557. var modRows = this.rows( -1 );
  6558. modRows.pop();
  6559. modRows.push.apply( modRows, newRows.toArray() );
  6560. return modRows;
  6561. } );
  6562. /**
  6563. *
  6564. */
  6565. _api_register( 'row()', function ( selector, opts ) {
  6566. return _selector_first( this.rows( selector, opts ) );
  6567. } );
  6568. _api_register( 'row().data()', function ( data ) {
  6569. var ctx = this.context;
  6570. if ( data === undefined ) {
  6571. // Get
  6572. return ctx.length && this.length ?
  6573. ctx[0].aoData[ this[0] ]._aData :
  6574. undefined;
  6575. }
  6576. // Set
  6577. ctx[0].aoData[ this[0] ]._aData = data;
  6578. // Automatically invalidate
  6579. _fnInvalidateRow( ctx[0], this[0], 'data' );
  6580. return this;
  6581. } );
  6582. _api_register( 'row().node()', function () {
  6583. var ctx = this.context;
  6584. return ctx.length && this.length ?
  6585. ctx[0].aoData[ this[0] ].nTr || null :
  6586. null;
  6587. } );
  6588. _api_register( 'row.add()', function ( row ) {
  6589. // Allow a jQuery object to be passed in - only a single row is added from
  6590. // it though - the first element in the set
  6591. if ( row instanceof $ && row.length ) {
  6592. row = row[0];
  6593. }
  6594. var rows = this.iterator( 'table', function ( settings ) {
  6595. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  6596. return _fnAddTr( settings, row )[0];
  6597. }
  6598. return _fnAddData( settings, row );
  6599. } );
  6600. // Return an Api.rows() extended instance, with the newly added row selected
  6601. return this.row( rows[0] );
  6602. } );
  6603. var __details_add = function ( ctx, row, data, klass )
  6604. {
  6605. // Convert to array of TR elements
  6606. var rows = [];
  6607. var addRow = function ( r, k ) {
  6608. // If we get a TR element, then just add it directly - up to the dev
  6609. // to add the correct number of columns etc
  6610. if ( r.nodeName && r.nodeName.toLowerCase() === 'tr' ) {
  6611. rows.push( r );
  6612. }
  6613. else {
  6614. // Otherwise create a row with a wrapper
  6615. var created = $('<tr><td/></tr>').addClass( k );
  6616. $('td', created)
  6617. .addClass( k )
  6618. .html( r )
  6619. [0].colSpan = _fnVisbleColumns( ctx );
  6620. rows.push( created[0] );
  6621. }
  6622. };
  6623. if ( $.isArray( data ) || data instanceof $ ) {
  6624. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6625. addRow( data[i], klass );
  6626. }
  6627. }
  6628. else {
  6629. addRow( data, klass );
  6630. }
  6631. if ( row._details ) {
  6632. row._details.remove();
  6633. }
  6634. row._details = $(rows);
  6635. // If the children were already shown, that state should be retained
  6636. if ( row._detailsShow ) {
  6637. row._details.insertAfter( row.nTr );
  6638. }
  6639. };
  6640. var __details_remove = function ( api )
  6641. {
  6642. var ctx = api.context;
  6643. if ( ctx.length && api.length ) {
  6644. var row = ctx[0].aoData[ api[0] ];
  6645. if ( row._details ) {
  6646. row._details.remove();
  6647. row._detailsShow = undefined;
  6648. row._details = undefined;
  6649. }
  6650. }
  6651. };
  6652. var __details_display = function ( api, show ) {
  6653. var ctx = api.context;
  6654. if ( ctx.length && api.length ) {
  6655. var row = ctx[0].aoData[ api[0] ];
  6656. if ( row._details ) {
  6657. row._detailsShow = show;
  6658. if ( show ) {
  6659. row._details.insertAfter( row.nTr );
  6660. }
  6661. else {
  6662. row._details.detach();
  6663. }
  6664. __details_events( ctx[0] );
  6665. }
  6666. }
  6667. };
  6668. var __details_events = function ( settings )
  6669. {
  6670. var api = new _Api( settings );
  6671. var namespace = '.dt.DT_details';
  6672. var drawEvent = 'draw'+namespace;
  6673. var colvisEvent = 'column-visibility'+namespace;
  6674. var destroyEvent = 'destroy'+namespace;
  6675. var data = settings.aoData;
  6676. api.off( drawEvent +' '+ colvisEvent +' '+ destroyEvent );
  6677. if ( _pluck( data, '_details' ).length > 0 ) {
  6678. // On each draw, insert the required elements into the document
  6679. api.on( drawEvent, function ( e, ctx ) {
  6680. if ( settings !== ctx ) {
  6681. return;
  6682. }
  6683. api.rows( {page:'current'} ).eq(0).each( function (idx) {
  6684. // Internal data grab
  6685. var row = data[ idx ];
  6686. if ( row._detailsShow ) {
  6687. row._details.insertAfter( row.nTr );
  6688. }
  6689. } );
  6690. } );
  6691. // Column visibility change - update the colspan
  6692. api.on( colvisEvent, function ( e, ctx, idx, vis ) {
  6693. if ( settings !== ctx ) {
  6694. return;
  6695. }
  6696. // Update the colspan for the details rows (note, only if it already has
  6697. // a colspan)
  6698. var row, visible = _fnVisbleColumns( ctx );
  6699. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6700. row = data[i];
  6701. if ( row._details ) {
  6702. row._details.children('td[colspan]').attr('colspan', visible );
  6703. }
  6704. }
  6705. } );
  6706. // Table destroyed - nuke any child rows
  6707. api.on( destroyEvent, function ( e, ctx ) {
  6708. if ( settings !== ctx ) {
  6709. return;
  6710. }
  6711. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6712. if ( data[i]._details ) {
  6713. __details_remove( data[i] );
  6714. }
  6715. }
  6716. } );
  6717. }
  6718. };
  6719. // Strings for the method names to help minification
  6720. var _emp = '';
  6721. var _child_obj = _emp+'row().child';
  6722. var _child_mth = _child_obj+'()';
  6723. // data can be:
  6724. // tr
  6725. // string
  6726. // jQuery or array of any of the above
  6727. _api_register( _child_mth, function ( data, klass ) {
  6728. var ctx = this.context;
  6729. if ( data === undefined ) {
  6730. // get
  6731. return ctx.length && this.length ?
  6732. ctx[0].aoData[ this[0] ]._details :
  6733. undefined;
  6734. }
  6735. else if ( data === true ) {
  6736. // show
  6737. this.child.show();
  6738. }
  6739. else if ( data === false ) {
  6740. // remove
  6741. __details_remove( this );
  6742. }
  6743. else if ( ctx.length && this.length ) {
  6744. // set
  6745. __details_add( ctx[0], ctx[0].aoData[ this[0] ], data, klass );
  6746. }
  6747. return this;
  6748. } );
  6749. _api_register( [
  6750. _child_obj+'.show()',
  6751. _child_mth+'.show()' // only when `child()` was called with parameters (without
  6752. ], function ( show ) { // it returns an object and this method is not executed)
  6753. __details_display( this, true );
  6754. return this;
  6755. } );
  6756. _api_register( [
  6757. _child_obj+'.hide()',
  6758. _child_mth+'.hide()' // only when `child()` was called with parameters (without
  6759. ], function () { // it returns an object and this method is not executed)
  6760. __details_display( this, false );
  6761. return this;
  6762. } );
  6763. _api_register( [
  6764. _child_obj+'.remove()',
  6765. _child_mth+'.remove()' // only when `child()` was called with parameters (without
  6766. ], function () { // it returns an object and this method is not executed)
  6767. __details_remove( this );
  6768. return this;
  6769. } );
  6770. _api_register( _child_obj+'.isShown()', function () {
  6771. var ctx = this.context;
  6772. if ( ctx.length && this.length ) {
  6773. // _detailsShown as false or undefined will fall through to return false
  6774. return ctx[0].aoData[ this[0] ]._detailsShow || false;
  6775. }
  6776. return false;
  6777. } );
  6778. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6779. * Columns
  6780. *
  6781. * {integer} - column index (>=0 count from left, <0 count from right)
  6782. * "{integer}:visIdx" - visible column index (i.e. translate to column index) (>=0 count from left, <0 count from right)
  6783. * "{integer}:visible" - alias for {integer}:visIdx (>=0 count from left, <0 count from right)
  6784. * "{string}:name" - column name
  6785. * "{string}" - jQuery selector on column header nodes
  6786. *
  6787. */
  6788. // can be an array of these items, comma separated list, or an array of comma
  6789. // separated lists
  6790. var __re_column_selector = /^(.+):(name|visIdx|visible)$/;
  6791. var __column_selector = function ( settings, selector, opts )
  6792. {
  6793. var
  6794. columns = settings.aoColumns,
  6795. names = _pluck( columns, 'sName' ),
  6796. nodes = _pluck( columns, 'nTh' );
  6797. return _selector_run( selector, function ( s ) {
  6798. var selInt = _intVal( s );
  6799. if ( s === '' ) {
  6800. // All columns
  6801. return _range( columns.length );
  6802. }
  6803. else if ( selInt !== null ) {
  6804. // Integer selector
  6805. return [ selInt >= 0 ?
  6806. selInt : // Count from left
  6807. columns.length + selInt // Count from right (+ because its a negative value)
  6808. ];
  6809. }
  6810. else {
  6811. var match = typeof s === 'string' ?
  6812. s.match( __re_column_selector ) :
  6813. '';
  6814. if ( match ) {
  6815. switch( match[2] ) {
  6816. case 'visIdx':
  6817. case 'visible':
  6818. var idx = parseInt( match[1], 10 );
  6819. // Visible index given, convert to column index
  6820. if ( idx < 0 ) {
  6821. // Counting from the right
  6822. var visColumns = $.map( columns, function (col,i) {
  6823. return col.bVisible ? i : null;
  6824. } );
  6825. return [ visColumns[ visColumns.length + idx ] ];
  6826. }
  6827. // Counting from the left
  6828. return [ _fnVisibleToColumnIndex( settings, idx ) ];
  6829. case 'name':
  6830. // match by name. `names` is column index complete and in order
  6831. return $.map( names, function (name, i) {
  6832. return name === match[1] ? i : null;
  6833. } );
  6834. }
  6835. }
  6836. else {
  6837. // jQuery selector on the TH elements for the columns
  6838. return $( nodes )
  6839. .filter( s )
  6840. .map( function () {
  6841. return $.inArray( this, nodes ); // `nodes` is column index complete and in order
  6842. } )
  6843. .toArray();
  6844. }
  6845. }
  6846. } );
  6847. };
  6848. var __setColumnVis = function ( settings, column, vis, recalc ) {
  6849. var
  6850. cols = settings.aoColumns,
  6851. col = cols[ column ],
  6852. data = settings.aoData,
  6853. row, cells, i, ien, tr;
  6854. // Get
  6855. if ( vis === undefined ) {
  6856. return col.bVisible;
  6857. }
  6858. // Set
  6859. // No change
  6860. if ( col.bVisible === vis ) {
  6861. return;
  6862. }
  6863. if ( vis ) {
  6864. // Insert column
  6865. // Need to decide if we should use appendChild or insertBefore
  6866. var insertBefore = $.inArray( true, _pluck(cols, 'bVisible'), column+1 );
  6867. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  6868. tr = data[i].nTr;
  6869. cells = data[i].anCells;
  6870. if ( tr ) {
  6871. // insertBefore can act like appendChild if 2nd arg is null
  6872. tr.insertBefore( cells[ column ], cells[ insertBefore ] || null );
  6873. }
  6874. }
  6875. }
  6876. else {
  6877. // Remove column
  6878. $( _pluck( settings.aoData, 'anCells', column ) ).detach();
  6879. }
  6880. // Common actions
  6881. col.bVisible = vis;
  6882. _fnDrawHead( settings, settings.aoHeader );
  6883. _fnDrawHead( settings, settings.aoFooter );
  6884. if ( recalc === undefined || recalc ) {
  6885. // Automatically adjust column sizing
  6886. _fnAdjustColumnSizing( settings );
  6887. // Realign columns for scrolling
  6888. if ( settings.oScroll.sX || settings.oScroll.sY ) {
  6889. _fnScrollDraw( settings );
  6890. }
  6891. }
  6892. _fnCallbackFire( settings, null, 'column-visibility', [settings, column, vis] );
  6893. _fnSaveState( settings );
  6894. };
  6895. /**
  6896. *
  6897. */
  6898. _api_register( 'columns()', function ( selector, opts ) {
  6899. // argument shifting
  6900. if ( selector === undefined ) {
  6901. selector = '';
  6902. }
  6903. else if ( $.isPlainObject( selector ) ) {
  6904. opts = selector;
  6905. selector = '';
  6906. }
  6907. opts = _selector_opts( opts );
  6908. var inst = this.iterator( 'table', function ( settings ) {
  6909. return __column_selector( settings, selector, opts );
  6910. } );
  6911. // Want argument shifting here and in _row_selector?
  6912. inst.selector.cols = selector;
  6913. inst.selector.opts = opts;
  6914. return inst;
  6915. } );
  6916. /**
  6917. *
  6918. */
  6919. _api_registerPlural( 'columns().header()', 'column().header()', function ( selector, opts ) {
  6920. return this.iterator( 'column', function ( settings, column ) {
  6921. return settings.aoColumns[column].nTh;
  6922. } );
  6923. } );
  6924. /**
  6925. *
  6926. */
  6927. _api_registerPlural( 'columns().footer()', 'column().footer()', function ( selector, opts ) {
  6928. return this.iterator( 'column', function ( settings, column ) {
  6929. return settings.aoColumns[column].nTf;
  6930. } );
  6931. } );
  6932. /**
  6933. *
  6934. */
  6935. _api_registerPlural( 'columns().data()', 'column().data()', function () {
  6936. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  6937. var a = [];
  6938. for ( var row=0, ien=rows.length ; row<ien ; row++ ) {
  6939. a.push( _fnGetCellData( settings, rows[row], column, '' ) );
  6940. }
  6941. return a;
  6942. } );
  6943. } );
  6944. _api_registerPlural( 'columns().cache()', 'column().cache()', function ( type ) {
  6945. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  6946. return _pluck_order( settings.aoData, rows,
  6947. type === 'search' ? '_aFilterData' : '_aSortData', column
  6948. );
  6949. } );
  6950. } );
  6951. _api_registerPlural( 'columns().nodes()', 'column().nodes()', function () {
  6952. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  6953. return _pluck_order( settings.aoData, rows, 'anCells', column ) ;
  6954. } );
  6955. } );
  6956. _api_registerPlural( 'columns().visible()', 'column().visible()', function ( vis, calc ) {
  6957. return this.iterator( 'column', function ( settings, column ) {
  6958. return vis === undefined ?
  6959. settings.aoColumns[ column ].bVisible :
  6960. __setColumnVis( settings, column, vis, calc );
  6961. } );
  6962. } );
  6963. _api_registerPlural( 'columns().indexes()', 'column().index()', function ( type ) {
  6964. return this.iterator( 'column', function ( settings, column ) {
  6965. return type === 'visible' ?
  6966. _fnColumnIndexToVisible( settings, column ) :
  6967. column;
  6968. } );
  6969. } );
  6970. // _api_register( 'columns().show()', function () {
  6971. // var selector = this.selector;
  6972. // return this.columns( selector.cols, selector.opts ).visible( true );
  6973. // } );
  6974. // _api_register( 'columns().hide()', function () {
  6975. // var selector = this.selector;
  6976. // return this.columns( selector.cols, selector.opts ).visible( false );
  6977. // } );
  6978. _api_register( 'columns.adjust()', function () {
  6979. return this.iterator( 'table', function ( settings ) {
  6980. _fnAdjustColumnSizing( settings );
  6981. } );
  6982. } );
  6983. // Convert from one column index type, to another type
  6984. _api_register( 'column.index()', function ( type, idx ) {
  6985. if ( this.context.length !== 0 ) {
  6986. var ctx = this.context[0];
  6987. if ( type === 'fromVisible' || type === 'toData' ) {
  6988. return _fnVisibleToColumnIndex( ctx, idx );
  6989. }
  6990. else if ( type === 'fromData' || type === 'toVisible' ) {
  6991. return _fnColumnIndexToVisible( ctx, idx );
  6992. }
  6993. }
  6994. } );
  6995. _api_register( 'column()', function ( selector, opts ) {
  6996. return _selector_first( this.columns( selector, opts ) );
  6997. } );
  6998. var __cell_selector = function ( settings, selector, opts )
  6999. {
  7000. var data = settings.aoData;
  7001. var rows = _selector_row_indexes( settings, opts );
  7002. var cells = _pluck_order( data, rows, 'anCells' );
  7003. var allCells = $( [].concat.apply([], cells) );
  7004. var row;
  7005. var columns = settings.aoColumns.length;
  7006. var a, i, ien, j;
  7007. return _selector_run( selector, function ( s ) {
  7008. if ( s === null || s === undefined ) {
  7009. // All cells
  7010. a = [];
  7011. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  7012. row = rows[i];
  7013. for ( j=0 ; j<columns ; j++ ) {
  7014. a.push( {
  7015. row: row,
  7016. column: j
  7017. } );
  7018. }
  7019. }
  7020. return a;
  7021. }
  7022. else if ( $.isPlainObject( s ) ) {
  7023. return [s];
  7024. }
  7025. // jQuery filtered cells
  7026. return allCells
  7027. .filter( s )
  7028. .map( function (i, el) {
  7029. row = el.parentNode._DT_RowIndex;
  7030. return {
  7031. row: row,
  7032. column: $.inArray( el, data[ row ].anCells )
  7033. };
  7034. } )
  7035. .toArray();
  7036. } );
  7037. };
  7038. _api_register( 'cells()', function ( rowSelector, columnSelector, opts ) {
  7039. // Argument shifting
  7040. if ( $.isPlainObject( rowSelector ) ) {
  7041. // Indexes
  7042. if ( typeof rowSelector.row !== undefined ) {
  7043. opts = columnSelector;
  7044. columnSelector = null;
  7045. }
  7046. else {
  7047. opts = rowSelector;
  7048. rowSelector = null;
  7049. }
  7050. }
  7051. if ( $.isPlainObject( columnSelector ) ) {
  7052. opts = columnSelector;
  7053. columnSelector = null;
  7054. }
  7055. // Cell selector
  7056. if ( columnSelector === null || columnSelector === undefined ) {
  7057. return this.iterator( 'table', function ( settings ) {
  7058. return __cell_selector( settings, rowSelector, _selector_opts( opts ) );
  7059. } );
  7060. }
  7061. // Row + column selector
  7062. var columns = this.columns( columnSelector, opts );
  7063. var rows = this.rows( rowSelector, opts );
  7064. var a, i, ien, j, jen;
  7065. var cells = this.iterator( 'table', function ( settings, idx ) {
  7066. a = [];
  7067. for ( i=0, ien=rows[idx].length ; i<ien ; i++ ) {
  7068. for ( j=0, jen=columns[idx].length ; j<jen ; j++ ) {
  7069. a.push( {
  7070. row: rows[idx][i],
  7071. column: columns[idx][j]
  7072. } );
  7073. }
  7074. }
  7075. return a;
  7076. } );
  7077. $.extend( cells.selector, {
  7078. cols: columnSelector,
  7079. rows: rowSelector,
  7080. opts: opts
  7081. } );
  7082. return cells;
  7083. } );
  7084. _api_registerPlural( 'cells().nodes()', 'cell().node()', function () {
  7085. return this.iterator( 'cell', function ( settings, row, column ) {
  7086. return settings.aoData[ row ].anCells[ column ];
  7087. } );
  7088. } );
  7089. _api_register( 'cells().data()', function () {
  7090. return this.iterator( 'cell', function ( settings, row, column ) {
  7091. return _fnGetCellData( settings, row, column );
  7092. } );
  7093. } );
  7094. _api_registerPlural( 'cells().cache()', 'cell().cache()', function ( type ) {
  7095. type = type === 'search' ? '_aFilterData' : '_aSortData';
  7096. return this.iterator( 'cell', function ( settings, row, column ) {
  7097. return settings.aoData[ row ][ type ][ column ];
  7098. } );
  7099. } );
  7100. _api_registerPlural( 'cells().indexes()', 'cell().index()', function () {
  7101. return this.iterator( 'cell', function ( settings, row, column ) {
  7102. return {
  7103. row: row,
  7104. column: column,
  7105. columnVisible: _fnColumnIndexToVisible( settings, column )
  7106. };
  7107. } );
  7108. } );
  7109. _api_register( [
  7110. 'cells().invalidate()',
  7111. 'cell().invalidate()'
  7112. ], function ( src ) {
  7113. var selector = this.selector;
  7114. // Use the rows method of the instance to perform the invalidation, rather
  7115. // than doing it here. This avoids needing to handle duplicate rows from
  7116. // the cells.
  7117. this.rows( selector.rows, selector.opts ).invalidate( src );
  7118. return this;
  7119. } );
  7120. _api_register( 'cell()', function ( rowSelector, columnSelector, opts ) {
  7121. return _selector_first( this.cells( rowSelector, columnSelector, opts ) );
  7122. } );
  7123. _api_register( 'cell().data()', function ( data ) {
  7124. var ctx = this.context;
  7125. var cell = this[0];
  7126. if ( data === undefined ) {
  7127. // Get
  7128. return ctx.length && cell.length ?
  7129. _fnGetCellData( ctx[0], cell[0].row, cell[0].column ) :
  7130. undefined;
  7131. }
  7132. // Set
  7133. _fnSetCellData( ctx[0], cell[0].row, cell[0].column, data );
  7134. _fnInvalidateRow( ctx[0], cell[0].row, 'data', cell[0].column );
  7135. return this;
  7136. } );
  7137. /**
  7138. * Get current ordering (sorting) that has been applied to the table.
  7139. *
  7140. * @returns {array} 2D array containing the sorting information for the first
  7141. * table in the current context. Each element in the parent array represents
  7142. * a column being sorted upon (i.e. multi-sorting with two columns would have
  7143. * 2 inner arrays). The inner arrays may have 2 or 3 elements. The first is
  7144. * the column index that the sorting condition applies to, the second is the
  7145. * direction of the sort (`desc` or `asc`) and, optionally, the third is the
  7146. * index of the sorting order from the `column.sorting` initialisation array.
  7147. *//**
  7148. * Set the ordering for the table.
  7149. *
  7150. * @param {integer} order Column index to sort upon.
  7151. * @param {string} direction Direction of the sort to be applied (`asc` or `desc`)
  7152. * @returns {DataTables.Api} this
  7153. *//**
  7154. * Set the ordering for the table.
  7155. *
  7156. * @param {array} order 1D array of sorting information to be applied.
  7157. * @param {array} [...] Optional additional sorting conditions
  7158. * @returns {DataTables.Api} this
  7159. *//**
  7160. * Set the ordering for the table.
  7161. *
  7162. * @param {array} order 2D array of sorting information to be applied.
  7163. * @returns {DataTables.Api} this
  7164. */
  7165. _api_register( 'order()', function ( order, dir ) {
  7166. var ctx = this.context;
  7167. if ( order === undefined ) {
  7168. // get
  7169. return ctx.length !== 0 ?
  7170. ctx[0].aaSorting :
  7171. undefined;
  7172. }
  7173. // set
  7174. if ( typeof order === 'number' ) {
  7175. // Simple column / direction passed in
  7176. order = [ [ order, dir ] ];
  7177. }
  7178. else if ( ! $.isArray( order[0] ) ) {
  7179. // Arguments passed in (list of 1D arrays)
  7180. order = Array.prototype.slice.call( arguments );
  7181. }
  7182. // otherwise a 2D array was passed in
  7183. return this.iterator( 'table', function ( settings ) {
  7184. settings.aaSorting = order.slice();
  7185. } );
  7186. } );
  7187. /**
  7188. * Attach a sort listener to an element for a given column
  7189. *
  7190. * @param {node|jQuery|string} node Identifier for the element(s) to attach the
  7191. * listener to. This can take the form of a single DOM node, a jQuery
  7192. * collection of nodes or a jQuery selector which will identify the node(s).
  7193. * @param {integer} column the column that a click on this node will sort on
  7194. * @param {function} [callback] callback function when sort is run
  7195. * @returns {DataTables.Api} this
  7196. */
  7197. _api_register( 'order.listener()', function ( node, column, callback ) {
  7198. return this.iterator( 'table', function ( settings ) {
  7199. _fnSortAttachListener( settings, node, column, callback );
  7200. } );
  7201. } );
  7202. // Order by the selected column(s)
  7203. _api_register( [
  7204. 'columns().order()',
  7205. 'column().order()'
  7206. ], function ( dir ) {
  7207. var that = this;
  7208. return this.iterator( 'table', function ( settings, i ) {
  7209. var sort = [];
  7210. $.each( that[i], function (j, col) {
  7211. sort.push( [ col, dir ] );
  7212. } );
  7213. settings.aaSorting = sort;
  7214. } );
  7215. } );
  7216. _api_register( 'search()', function ( input, regex, smart, caseInsen ) {
  7217. var ctx = this.context;
  7218. if ( input === undefined ) {
  7219. // get
  7220. return ctx.length !== 0 ?
  7221. ctx[0].oPreviousSearch.sSearch :
  7222. undefined;
  7223. }
  7224. // set
  7225. return this.iterator( 'table', function ( settings ) {
  7226. if ( ! settings.oFeatures.bFilter ) {
  7227. return;
  7228. }
  7229. _fnFilterComplete( settings, $.extend( {}, settings.oPreviousSearch, {
  7230. "sSearch": input+"",
  7231. "bRegex": regex === null ? false : regex,
  7232. "bSmart": smart === null ? true : smart,
  7233. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7234. } ), 1 );
  7235. } );
  7236. } );
  7237. _api_registerPlural(
  7238. 'columns().search()',
  7239. 'column().search()',
  7240. function ( input, regex, smart, caseInsen ) {
  7241. return this.iterator( 'column', function ( settings, column ) {
  7242. var preSearch = settings.aoPreSearchCols;
  7243. if ( input === undefined ) {
  7244. // get
  7245. return preSearch[ column ].sSearch;
  7246. }
  7247. // set
  7248. if ( ! settings.oFeatures.bFilter ) {
  7249. return;
  7250. }
  7251. $.extend( preSearch[ column ], {
  7252. "sSearch": input+"",
  7253. "bRegex": regex === null ? false : regex,
  7254. "bSmart": smart === null ? true : smart,
  7255. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7256. } );
  7257. _fnFilterComplete( settings, settings.oPreviousSearch, 1 );
  7258. } );
  7259. }
  7260. );
  7261. /*
  7262. * State API methods
  7263. */
  7264. _api_register( 'state()', function () {
  7265. return this.context.length ?
  7266. this.context[0].oSavedState :
  7267. null;
  7268. } );
  7269. _api_register( 'state.clear()', function () {
  7270. return this.iterator( 'table', function ( settings ) {
  7271. // Save an empty object
  7272. settings.fnStateSaveCallback.call( settings.oInstance, settings, {} );
  7273. } );
  7274. } );
  7275. _api_register( 'state.loaded()', function () {
  7276. return this.context.length ?
  7277. this.context[0].oLoadedState :
  7278. null;
  7279. } );
  7280. _api_register( 'state.save()', function () {
  7281. return this.iterator( 'table', function ( settings ) {
  7282. _fnSaveState( settings );
  7283. } );
  7284. } );
  7285. /**
  7286. * Provide a common method for plug-ins to check the version of DataTables being
  7287. * used, in order to ensure compatibility.
  7288. *
  7289. * @param {string} version Version string to check for, in the format "X.Y.Z".
  7290. * Note that the formats "X" and "X.Y" are also acceptable.
  7291. * @returns {boolean} true if this version of DataTables is greater or equal to
  7292. * the required version, or false if this version of DataTales is not
  7293. * suitable
  7294. * @static
  7295. * @dtopt API-Static
  7296. *
  7297. * @example
  7298. * alert( $.fn.dataTable.versionCheck( '1.9.0' ) );
  7299. */
  7300. DataTable.versionCheck = DataTable.fnVersionCheck = function( version )
  7301. {
  7302. var aThis = DataTable.version.split('.');
  7303. var aThat = version.split('.');
  7304. var iThis, iThat;
  7305. for ( var i=0, iLen=aThat.length ; i<iLen ; i++ ) {
  7306. iThis = parseInt( aThis[i], 10 ) || 0;
  7307. iThat = parseInt( aThat[i], 10 ) || 0;
  7308. // Parts are the same, keep comparing
  7309. if (iThis === iThat) {
  7310. continue;
  7311. }
  7312. // Parts are different, return immediately
  7313. return iThis > iThat;
  7314. }
  7315. return true;
  7316. };
  7317. /**
  7318. * Check if a `<table>` node is a DataTable table already or not.
  7319. *
  7320. * @param {node|jquery|string} table Table node, jQuery object or jQuery
  7321. * selector for the table to test. Note that if more than more than one
  7322. * table is passed on, only the first will be checked
  7323. * @returns {boolean} true the table given is a DataTable, or false otherwise
  7324. * @static
  7325. * @dtopt API-Static
  7326. *
  7327. * @example
  7328. * if ( ! $.fn.DataTable.isDataTable( '#example' ) ) {
  7329. * $('#example').dataTable();
  7330. * }
  7331. */
  7332. DataTable.isDataTable = DataTable.fnIsDataTable = function ( table )
  7333. {
  7334. var t = $(table).get(0);
  7335. var is = false;
  7336. $.each( DataTable.settings, function (i, o) {
  7337. if ( o.nTable === t || o.nScrollHead === t || o.nScrollFoot === t ) {
  7338. is = true;
  7339. }
  7340. } );
  7341. return is;
  7342. };
  7343. /**
  7344. * Get all DataTable tables that have been initialised - optionally you can
  7345. * select to get only currently visible tables.
  7346. *
  7347. * @param {boolean} [visible=false] Flag to indicate if you want all (default)
  7348. * or visible tables only.
  7349. * @returns {array} Array of `table` nodes (not DataTable instances) which are
  7350. * DataTables
  7351. * @static
  7352. * @dtopt API-Static
  7353. *
  7354. * @example
  7355. * $.each( $.fn.dataTable.tables(true), function () {
  7356. * $(table).DataTable().columns.adjust();
  7357. * } );
  7358. */
  7359. DataTable.tables = DataTable.fnTables = function ( visible )
  7360. {
  7361. return jQuery.map( DataTable.settings, function (o) {
  7362. if ( !visible || (visible && $(o.nTable).is(':visible')) ) {
  7363. return o.nTable;
  7364. }
  7365. } );
  7366. };
  7367. /**
  7368. * Convert from camel case parameters to Hungarian notation. This is made public
  7369. * for the extensions to provide the same ability as DataTables core to accept
  7370. * either the 1.9 style Hungarian notation, or the 1.10+ style camelCase
  7371. * parameters.
  7372. *
  7373. * @param {object} src The model object which holds all parameters that can be
  7374. * mapped.
  7375. * @param {object} user The object to convert from camel case to Hungarian.
  7376. * @param {boolean} force When set to `true`, properties which already have a
  7377. * Hungarian value in the `user` object will be overwritten. Otherwise they
  7378. * won't be.
  7379. */
  7380. DataTable.camelToHungarian = _fnCamelToHungarian;
  7381. /**
  7382. *
  7383. */
  7384. _api_register( '$()', function ( selector, opts ) {
  7385. var
  7386. rows = this.rows( opts ).nodes(), // Get all rows
  7387. jqRows = $(rows);
  7388. return $( [].concat(
  7389. jqRows.filter( selector ).toArray(),
  7390. jqRows.find( selector ).toArray()
  7391. ) );
  7392. } );
  7393. // jQuery functions to operate on the tables
  7394. $.each( [ 'on', 'one', 'off' ], function (i, key) {
  7395. _api_register( key+'()', function ( /* event, handler */ ) {
  7396. var args = Array.prototype.slice.call(arguments);
  7397. // Add the `dt` namespace automatically if it isn't already present
  7398. if ( ! args[0].match(/\.dt\b/) ) {
  7399. args[0] += '.dt';
  7400. }
  7401. var inst = $( this.tables().nodes() );
  7402. inst[key].apply( inst, args );
  7403. return this;
  7404. } );
  7405. } );
  7406. _api_register( 'clear()', function () {
  7407. return this.iterator( 'table', function ( settings ) {
  7408. _fnClearTable( settings );
  7409. } );
  7410. } );
  7411. _api_register( 'settings()', function () {
  7412. return new _Api( this.context, this.context );
  7413. } );
  7414. _api_register( 'data()', function () {
  7415. return this.iterator( 'table', function ( settings ) {
  7416. return _pluck( settings.aoData, '_aData' );
  7417. } ).flatten();
  7418. } );
  7419. _api_register( 'destroy()', function ( remove ) {
  7420. remove = remove || false;
  7421. return this.iterator( 'table', function ( settings ) {
  7422. var orig = settings.nTableWrapper.parentNode;
  7423. var classes = settings.oClasses;
  7424. var table = settings.nTable;
  7425. var tbody = settings.nTBody;
  7426. var thead = settings.nTHead;
  7427. var tfoot = settings.nTFoot;
  7428. var jqTable = $(table);
  7429. var jqTbody = $(tbody);
  7430. var jqWrapper = $(settings.nTableWrapper);
  7431. var rows = $.map( settings.aoData, function (r) { return r.nTr; } );
  7432. var i, ien;
  7433. // Flag to note that the table is currently being destroyed - no action
  7434. // should be taken
  7435. settings.bDestroying = true;
  7436. // Fire off the destroy callbacks for plug-ins etc
  7437. _fnCallbackFire( settings, "aoDestroyCallback", "destroy", [settings] );
  7438. // If not being removed from the document, make all columns visible
  7439. if ( ! remove ) {
  7440. new _Api( settings ).columns().visible( true );
  7441. }
  7442. // Blitz all `DT` namespaced events (these are internal events, the
  7443. // lowercase, `dt` events are user subscribed and they are responsible
  7444. // for removing them
  7445. jqWrapper.unbind('.DT').find(':not(tbody *)').unbind('.DT');
  7446. $(window).unbind('.DT-'+settings.sInstance);
  7447. // When scrolling we had to break the table up - restore it
  7448. if ( table != thead.parentNode ) {
  7449. jqTable.children('thead').detach();
  7450. jqTable.append( thead );
  7451. }
  7452. if ( tfoot && table != tfoot.parentNode ) {
  7453. jqTable.children('tfoot').detach();
  7454. jqTable.append( tfoot );
  7455. }
  7456. // Remove the DataTables generated nodes, events and classes
  7457. jqTable.detach();
  7458. jqWrapper.detach();
  7459. settings.aaSorting = [];
  7460. settings.aaSortingFixed = [];
  7461. _fnSortingClasses( settings );
  7462. $( rows ).removeClass( settings.asStripeClasses.join(' ') );
  7463. $('th, td', thead).removeClass( classes.sSortable+' '+
  7464. classes.sSortableAsc+' '+classes.sSortableDesc+' '+classes.sSortableNone
  7465. );
  7466. if ( settings.bJUI ) {
  7467. $('th span.'+classes.sSortIcon+ ', td span.'+classes.sSortIcon, thead).detach();
  7468. $('th, td', thead).each( function () {
  7469. var wrapper = $('div.'+classes.sSortJUIWrapper, this);
  7470. $(this).append( wrapper.contents() );
  7471. wrapper.detach();
  7472. } );
  7473. }
  7474. if ( ! remove && orig ) {
  7475. // insertBefore acts like appendChild if !arg[1]
  7476. orig.insertBefore( table, settings.nTableReinsertBefore );
  7477. }
  7478. // Add the TR elements back into the table in their original order
  7479. jqTbody.children().detach();
  7480. jqTbody.append( rows );
  7481. // Restore the width of the original table - was read from the style property,
  7482. // so we can restore directly to that
  7483. jqTable
  7484. .css( 'width', settings.sDestroyWidth )
  7485. .removeClass( classes.sTable );
  7486. // If the were originally stripe classes - then we add them back here.
  7487. // Note this is not fool proof (for example if not all rows had stripe
  7488. // classes - but it's a good effort without getting carried away
  7489. ien = settings.asDestroyStripes.length;
  7490. if ( ien ) {
  7491. jqTbody.children().each( function (i) {
  7492. $(this).addClass( settings.asDestroyStripes[i % ien] );
  7493. } );
  7494. }
  7495. /* Remove the settings object from the settings array */
  7496. var idx = $.inArray( settings, DataTable.settings );
  7497. if ( idx !== -1 ) {
  7498. DataTable.settings.splice( idx, 1 );
  7499. }
  7500. } );
  7501. } );
  7502. /**
  7503. * Version string for plug-ins to check compatibility. Allowed format is
  7504. * `a.b.c-d` where: a:int, b:int, c:int, d:string(dev|beta|alpha). `d` is used
  7505. * only for non-release builds. See http://semver.org/ for more information.
  7506. * @member
  7507. * @type string
  7508. * @default Version number
  7509. */
  7510. DataTable.version = "1.10.2";
  7511. /**
  7512. * Private data store, containing all of the settings objects that are
  7513. * created for the tables on a given page.
  7514. *
  7515. * Note that the `DataTable.settings` object is aliased to
  7516. * `jQuery.fn.dataTableExt` through which it may be accessed and
  7517. * manipulated, or `jQuery.fn.dataTable.settings`.
  7518. * @member
  7519. * @type array
  7520. * @default []
  7521. * @private
  7522. */
  7523. DataTable.settings = [];
  7524. /**
  7525. * Object models container, for the various models that DataTables has
  7526. * available to it. These models define the objects that are used to hold
  7527. * the active state and configuration of the table.
  7528. * @namespace
  7529. */
  7530. DataTable.models = {};
  7531. /**
  7532. * Template object for the way in which DataTables holds information about
  7533. * search information for the global filter and individual column filters.
  7534. * @namespace
  7535. */
  7536. DataTable.models.oSearch = {
  7537. /**
  7538. * Flag to indicate if the filtering should be case insensitive or not
  7539. * @type boolean
  7540. * @default true
  7541. */
  7542. "bCaseInsensitive": true,
  7543. /**
  7544. * Applied search term
  7545. * @type string
  7546. * @default <i>Empty string</i>
  7547. */
  7548. "sSearch": "",
  7549. /**
  7550. * Flag to indicate if the search term should be interpreted as a
  7551. * regular expression (true) or not (false) and therefore and special
  7552. * regex characters escaped.
  7553. * @type boolean
  7554. * @default false
  7555. */
  7556. "bRegex": false,
  7557. /**
  7558. * Flag to indicate if DataTables is to use its smart filtering or not.
  7559. * @type boolean
  7560. * @default true
  7561. */
  7562. "bSmart": true
  7563. };
  7564. /**
  7565. * Template object for the way in which DataTables holds information about
  7566. * each individual row. This is the object format used for the settings
  7567. * aoData array.
  7568. * @namespace
  7569. */
  7570. DataTable.models.oRow = {
  7571. /**
  7572. * TR element for the row
  7573. * @type node
  7574. * @default null
  7575. */
  7576. "nTr": null,
  7577. /**
  7578. * Array of TD elements for each row. This is null until the row has been
  7579. * created.
  7580. * @type array nodes
  7581. * @default []
  7582. */
  7583. "anCells": null,
  7584. /**
  7585. * Data object from the original data source for the row. This is either
  7586. * an array if using the traditional form of DataTables, or an object if
  7587. * using mData options. The exact type will depend on the passed in
  7588. * data from the data source, or will be an array if using DOM a data
  7589. * source.
  7590. * @type array|object
  7591. * @default []
  7592. */
  7593. "_aData": [],
  7594. /**
  7595. * Sorting data cache - this array is ostensibly the same length as the
  7596. * number of columns (although each index is generated only as it is
  7597. * needed), and holds the data that is used for sorting each column in the
  7598. * row. We do this cache generation at the start of the sort in order that
  7599. * the formatting of the sort data need be done only once for each cell
  7600. * per sort. This array should not be read from or written to by anything
  7601. * other than the master sorting methods.
  7602. * @type array
  7603. * @default null
  7604. * @private
  7605. */
  7606. "_aSortData": null,
  7607. /**
  7608. * Per cell filtering data cache. As per the sort data cache, used to
  7609. * increase the performance of the filtering in DataTables
  7610. * @type array
  7611. * @default null
  7612. * @private
  7613. */
  7614. "_aFilterData": null,
  7615. /**
  7616. * Filtering data cache. This is the same as the cell filtering cache, but
  7617. * in this case a string rather than an array. This is easily computed with
  7618. * a join on `_aFilterData`, but is provided as a cache so the join isn't
  7619. * needed on every search (memory traded for performance)
  7620. * @type array
  7621. * @default null
  7622. * @private
  7623. */
  7624. "_sFilterRow": null,
  7625. /**
  7626. * Cache of the class name that DataTables has applied to the row, so we
  7627. * can quickly look at this variable rather than needing to do a DOM check
  7628. * on className for the nTr property.
  7629. * @type string
  7630. * @default <i>Empty string</i>
  7631. * @private
  7632. */
  7633. "_sRowStripe": "",
  7634. /**
  7635. * Denote if the original data source was from the DOM, or the data source
  7636. * object. This is used for invalidating data, so DataTables can
  7637. * automatically read data from the original source, unless uninstructed
  7638. * otherwise.
  7639. * @type string
  7640. * @default null
  7641. * @private
  7642. */
  7643. "src": null
  7644. };
  7645. /**
  7646. * Template object for the column information object in DataTables. This object
  7647. * is held in the settings aoColumns array and contains all the information that
  7648. * DataTables needs about each individual column.
  7649. *
  7650. * Note that this object is related to {@link DataTable.defaults.column}
  7651. * but this one is the internal data store for DataTables's cache of columns.
  7652. * It should NOT be manipulated outside of DataTables. Any configuration should
  7653. * be done through the initialisation options.
  7654. * @namespace
  7655. */
  7656. DataTable.models.oColumn = {
  7657. /**
  7658. * Column index. This could be worked out on-the-fly with $.inArray, but it
  7659. * is faster to just hold it as a variable
  7660. * @type integer
  7661. * @default null
  7662. */
  7663. "idx": null,
  7664. /**
  7665. * A list of the columns that sorting should occur on when this column
  7666. * is sorted. That this property is an array allows multi-column sorting
  7667. * to be defined for a column (for example first name / last name columns
  7668. * would benefit from this). The values are integers pointing to the
  7669. * columns to be sorted on (typically it will be a single integer pointing
  7670. * at itself, but that doesn't need to be the case).
  7671. * @type array
  7672. */
  7673. "aDataSort": null,
  7674. /**
  7675. * Define the sorting directions that are applied to the column, in sequence
  7676. * as the column is repeatedly sorted upon - i.e. the first value is used
  7677. * as the sorting direction when the column if first sorted (clicked on).
  7678. * Sort it again (click again) and it will move on to the next index.
  7679. * Repeat until loop.
  7680. * @type array
  7681. */
  7682. "asSorting": null,
  7683. /**
  7684. * Flag to indicate if the column is searchable, and thus should be included
  7685. * in the filtering or not.
  7686. * @type boolean
  7687. */
  7688. "bSearchable": null,
  7689. /**
  7690. * Flag to indicate if the column is sortable or not.
  7691. * @type boolean
  7692. */
  7693. "bSortable": null,
  7694. /**
  7695. * Flag to indicate if the column is currently visible in the table or not
  7696. * @type boolean
  7697. */
  7698. "bVisible": null,
  7699. /**
  7700. * Store for manual type assignment using the `column.type` option. This
  7701. * is held in store so we can manipulate the column's `sType` property.
  7702. * @type string
  7703. * @default null
  7704. * @private
  7705. */
  7706. "_sManualType": null,
  7707. /**
  7708. * Flag to indicate if HTML5 data attributes should be used as the data
  7709. * source for filtering or sorting. True is either are.
  7710. * @type boolean
  7711. * @default false
  7712. * @private
  7713. */
  7714. "_bAttrSrc": false,
  7715. /**
  7716. * Developer definable function that is called whenever a cell is created (Ajax source,
  7717. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  7718. * allowing you to modify the DOM element (add background colour for example) when the
  7719. * element is available.
  7720. * @type function
  7721. * @param {element} nTd The TD node that has been created
  7722. * @param {*} sData The Data for the cell
  7723. * @param {array|object} oData The data for the whole row
  7724. * @param {int} iRow The row index for the aoData data store
  7725. * @default null
  7726. */
  7727. "fnCreatedCell": null,
  7728. /**
  7729. * Function to get data from a cell in a column. You should <b>never</b>
  7730. * access data directly through _aData internally in DataTables - always use
  7731. * the method attached to this property. It allows mData to function as
  7732. * required. This function is automatically assigned by the column
  7733. * initialisation method
  7734. * @type function
  7735. * @param {array|object} oData The data array/object for the array
  7736. * (i.e. aoData[]._aData)
  7737. * @param {string} sSpecific The specific data type you want to get -
  7738. * 'display', 'type' 'filter' 'sort'
  7739. * @returns {*} The data for the cell from the given row's data
  7740. * @default null
  7741. */
  7742. "fnGetData": null,
  7743. /**
  7744. * Function to set data for a cell in the column. You should <b>never</b>
  7745. * set the data directly to _aData internally in DataTables - always use
  7746. * this method. It allows mData to function as required. This function
  7747. * is automatically assigned by the column initialisation method
  7748. * @type function
  7749. * @param {array|object} oData The data array/object for the array
  7750. * (i.e. aoData[]._aData)
  7751. * @param {*} sValue Value to set
  7752. * @default null
  7753. */
  7754. "fnSetData": null,
  7755. /**
  7756. * Property to read the value for the cells in the column from the data
  7757. * source array / object. If null, then the default content is used, if a
  7758. * function is given then the return from the function is used.
  7759. * @type function|int|string|null
  7760. * @default null
  7761. */
  7762. "mData": null,
  7763. /**
  7764. * Partner property to mData which is used (only when defined) to get
  7765. * the data - i.e. it is basically the same as mData, but without the
  7766. * 'set' option, and also the data fed to it is the result from mData.
  7767. * This is the rendering method to match the data method of mData.
  7768. * @type function|int|string|null
  7769. * @default null
  7770. */
  7771. "mRender": null,
  7772. /**
  7773. * Unique header TH/TD element for this column - this is what the sorting
  7774. * listener is attached to (if sorting is enabled.)
  7775. * @type node
  7776. * @default null
  7777. */
  7778. "nTh": null,
  7779. /**
  7780. * Unique footer TH/TD element for this column (if there is one). Not used
  7781. * in DataTables as such, but can be used for plug-ins to reference the
  7782. * footer for each column.
  7783. * @type node
  7784. * @default null
  7785. */
  7786. "nTf": null,
  7787. /**
  7788. * The class to apply to all TD elements in the table's TBODY for the column
  7789. * @type string
  7790. * @default null
  7791. */
  7792. "sClass": null,
  7793. /**
  7794. * When DataTables calculates the column widths to assign to each column,
  7795. * it finds the longest string in each column and then constructs a
  7796. * temporary table and reads the widths from that. The problem with this
  7797. * is that "mmm" is much wider then "iiii", but the latter is a longer
  7798. * string - thus the calculation can go wrong (doing it properly and putting
  7799. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  7800. * a "work around" we provide this option. It will append its value to the
  7801. * text that is found to be the longest string for the column - i.e. padding.
  7802. * @type string
  7803. */
  7804. "sContentPadding": null,
  7805. /**
  7806. * Allows a default value to be given for a column's data, and will be used
  7807. * whenever a null data source is encountered (this can be because mData
  7808. * is set to null, or because the data source itself is null).
  7809. * @type string
  7810. * @default null
  7811. */
  7812. "sDefaultContent": null,
  7813. /**
  7814. * Name for the column, allowing reference to the column by name as well as
  7815. * by index (needs a lookup to work by name).
  7816. * @type string
  7817. */
  7818. "sName": null,
  7819. /**
  7820. * Custom sorting data type - defines which of the available plug-ins in
  7821. * afnSortData the custom sorting will use - if any is defined.
  7822. * @type string
  7823. * @default std
  7824. */
  7825. "sSortDataType": 'std',
  7826. /**
  7827. * Class to be applied to the header element when sorting on this column
  7828. * @type string
  7829. * @default null
  7830. */
  7831. "sSortingClass": null,
  7832. /**
  7833. * Class to be applied to the header element when sorting on this column -
  7834. * when jQuery UI theming is used.
  7835. * @type string
  7836. * @default null
  7837. */
  7838. "sSortingClassJUI": null,
  7839. /**
  7840. * Title of the column - what is seen in the TH element (nTh).
  7841. * @type string
  7842. */
  7843. "sTitle": null,
  7844. /**
  7845. * Column sorting and filtering type
  7846. * @type string
  7847. * @default null
  7848. */
  7849. "sType": null,
  7850. /**
  7851. * Width of the column
  7852. * @type string
  7853. * @default null
  7854. */
  7855. "sWidth": null,
  7856. /**
  7857. * Width of the column when it was first "encountered"
  7858. * @type string
  7859. * @default null
  7860. */
  7861. "sWidthOrig": null
  7862. };
  7863. /*
  7864. * Developer note: The properties of the object below are given in Hungarian
  7865. * notation, that was used as the interface for DataTables prior to v1.10, however
  7866. * from v1.10 onwards the primary interface is camel case. In order to avoid
  7867. * breaking backwards compatibility utterly with this change, the Hungarian
  7868. * version is still, internally the primary interface, but is is not documented
  7869. * - hence the @name tags in each doc comment. This allows a Javascript function
  7870. * to create a map from Hungarian notation to camel case (going the other direction
  7871. * would require each property to be listed, which would at around 3K to the size
  7872. * of DataTables, while this method is about a 0.5K hit.
  7873. *
  7874. * Ultimately this does pave the way for Hungarian notation to be dropped
  7875. * completely, but that is a massive amount of work and will break current
  7876. * installs (therefore is on-hold until v2).
  7877. */
  7878. /**
  7879. * Initialisation options that can be given to DataTables at initialisation
  7880. * time.
  7881. * @namespace
  7882. */
  7883. DataTable.defaults = {
  7884. /**
  7885. * An array of data to use for the table, passed in at initialisation which
  7886. * will be used in preference to any data which is already in the DOM. This is
  7887. * particularly useful for constructing tables purely in Javascript, for
  7888. * example with a custom Ajax call.
  7889. * @type array
  7890. * @default null
  7891. *
  7892. * @dtopt Option
  7893. * @name DataTable.defaults.data
  7894. *
  7895. * @example
  7896. * // Using a 2D array data source
  7897. * $(document).ready( function () {
  7898. * $('#example').dataTable( {
  7899. * "data": [
  7900. * ['Trident', 'Internet Explorer 4.0', 'Win 95+', 4, 'X'],
  7901. * ['Trident', 'Internet Explorer 5.0', 'Win 95+', 5, 'C'],
  7902. * ],
  7903. * "columns": [
  7904. * { "title": "Engine" },
  7905. * { "title": "Browser" },
  7906. * { "title": "Platform" },
  7907. * { "title": "Version" },
  7908. * { "title": "Grade" }
  7909. * ]
  7910. * } );
  7911. * } );
  7912. *
  7913. * @example
  7914. * // Using an array of objects as a data source (`data`)
  7915. * $(document).ready( function () {
  7916. * $('#example').dataTable( {
  7917. * "data": [
  7918. * {
  7919. * "engine": "Trident",
  7920. * "browser": "Internet Explorer 4.0",
  7921. * "platform": "Win 95+",
  7922. * "version": 4,
  7923. * "grade": "X"
  7924. * },
  7925. * {
  7926. * "engine": "Trident",
  7927. * "browser": "Internet Explorer 5.0",
  7928. * "platform": "Win 95+",
  7929. * "version": 5,
  7930. * "grade": "C"
  7931. * }
  7932. * ],
  7933. * "columns": [
  7934. * { "title": "Engine", "data": "engine" },
  7935. * { "title": "Browser", "data": "browser" },
  7936. * { "title": "Platform", "data": "platform" },
  7937. * { "title": "Version", "data": "version" },
  7938. * { "title": "Grade", "data": "grade" }
  7939. * ]
  7940. * } );
  7941. * } );
  7942. */
  7943. "aaData": null,
  7944. /**
  7945. * If ordering is enabled, then DataTables will perform a first pass sort on
  7946. * initialisation. You can define which column(s) the sort is performed
  7947. * upon, and the sorting direction, with this variable. The `sorting` array
  7948. * should contain an array for each column to be sorted initially containing
  7949. * the column's index and a direction string ('asc' or 'desc').
  7950. * @type array
  7951. * @default [[0,'asc']]
  7952. *
  7953. * @dtopt Option
  7954. * @name DataTable.defaults.order
  7955. *
  7956. * @example
  7957. * // Sort by 3rd column first, and then 4th column
  7958. * $(document).ready( function() {
  7959. * $('#example').dataTable( {
  7960. * "order": [[2,'asc'], [3,'desc']]
  7961. * } );
  7962. * } );
  7963. *
  7964. * // No initial sorting
  7965. * $(document).ready( function() {
  7966. * $('#example').dataTable( {
  7967. * "order": []
  7968. * } );
  7969. * } );
  7970. */
  7971. "aaSorting": [[0,'asc']],
  7972. /**
  7973. * This parameter is basically identical to the `sorting` parameter, but
  7974. * cannot be overridden by user interaction with the table. What this means
  7975. * is that you could have a column (visible or hidden) which the sorting
  7976. * will always be forced on first - any sorting after that (from the user)
  7977. * will then be performed as required. This can be useful for grouping rows
  7978. * together.
  7979. * @type array
  7980. * @default null
  7981. *
  7982. * @dtopt Option
  7983. * @name DataTable.defaults.orderFixed
  7984. *
  7985. * @example
  7986. * $(document).ready( function() {
  7987. * $('#example').dataTable( {
  7988. * "orderFixed": [[0,'asc']]
  7989. * } );
  7990. * } )
  7991. */
  7992. "aaSortingFixed": [],
  7993. /**
  7994. * DataTables can be instructed to load data to display in the table from a
  7995. * Ajax source. This option defines how that Ajax call is made and where to.
  7996. *
  7997. * The `ajax` property has three different modes of operation, depending on
  7998. * how it is defined. These are:
  7999. *
  8000. * * `string` - Set the URL from where the data should be loaded from.
  8001. * * `object` - Define properties for `jQuery.ajax`.
  8002. * * `function` - Custom data get function
  8003. *
  8004. * `string`
  8005. * --------
  8006. *
  8007. * As a string, the `ajax` property simply defines the URL from which
  8008. * DataTables will load data.
  8009. *
  8010. * `object`
  8011. * --------
  8012. *
  8013. * As an object, the parameters in the object are passed to
  8014. * [jQuery.ajax](http://api.jquery.com/jQuery.ajax/) allowing fine control
  8015. * of the Ajax request. DataTables has a number of default parameters which
  8016. * you can override using this option. Please refer to the jQuery
  8017. * documentation for a full description of the options available, although
  8018. * the following parameters provide additional options in DataTables or
  8019. * require special consideration:
  8020. *
  8021. * * `data` - As with jQuery, `data` can be provided as an object, but it
  8022. * can also be used as a function to manipulate the data DataTables sends
  8023. * to the server. The function takes a single parameter, an object of
  8024. * parameters with the values that DataTables has readied for sending. An
  8025. * object may be returned which will be merged into the DataTables
  8026. * defaults, or you can add the items to the object that was passed in and
  8027. * not return anything from the function. This supersedes `fnServerParams`
  8028. * from DataTables 1.9-.
  8029. *
  8030. * * `dataSrc` - By default DataTables will look for the property `data` (or
  8031. * `aaData` for compatibility with DataTables 1.9-) when obtaining data
  8032. * from an Ajax source or for server-side processing - this parameter
  8033. * allows that property to be changed. You can use Javascript dotted
  8034. * object notation to get a data source for multiple levels of nesting, or
  8035. * it my be used as a function. As a function it takes a single parameter,
  8036. * the JSON returned from the server, which can be manipulated as
  8037. * required, with the returned value being that used by DataTables as the
  8038. * data source for the table. This supersedes `sAjaxDataProp` from
  8039. * DataTables 1.9-.
  8040. *
  8041. * * `success` - Should not be overridden it is used internally in
  8042. * DataTables. To manipulate / transform the data returned by the server
  8043. * use `ajax.dataSrc`, or use `ajax` as a function (see below).
  8044. *
  8045. * `function`
  8046. * ----------
  8047. *
  8048. * As a function, making the Ajax call is left up to yourself allowing
  8049. * complete control of the Ajax request. Indeed, if desired, a method other
  8050. * than Ajax could be used to obtain the required data, such as Web storage
  8051. * or an AIR database.
  8052. *
  8053. * The function is given four parameters and no return is required. The
  8054. * parameters are:
  8055. *
  8056. * 1. _object_ - Data to send to the server
  8057. * 2. _function_ - Callback function that must be executed when the required
  8058. * data has been obtained. That data should be passed into the callback
  8059. * as the only parameter
  8060. * 3. _object_ - DataTables settings object for the table
  8061. *
  8062. * Note that this supersedes `fnServerData` from DataTables 1.9-.
  8063. *
  8064. * @type string|object|function
  8065. * @default null
  8066. *
  8067. * @dtopt Option
  8068. * @name DataTable.defaults.ajax
  8069. * @since 1.10.0
  8070. *
  8071. * @example
  8072. * // Get JSON data from a file via Ajax.
  8073. * // Note DataTables expects data in the form `{ data: [ ...data... ] }` by default).
  8074. * $('#example').dataTable( {
  8075. * "ajax": "data.json"
  8076. * } );
  8077. *
  8078. * @example
  8079. * // Get JSON data from a file via Ajax, using `dataSrc` to change
  8080. * // `data` to `tableData` (i.e. `{ tableData: [ ...data... ] }`)
  8081. * $('#example').dataTable( {
  8082. * "ajax": {
  8083. * "url": "data.json",
  8084. * "dataSrc": "tableData"
  8085. * }
  8086. * } );
  8087. *
  8088. * @example
  8089. * // Get JSON data from a file via Ajax, using `dataSrc` to read data
  8090. * // from a plain array rather than an array in an object
  8091. * $('#example').dataTable( {
  8092. * "ajax": {
  8093. * "url": "data.json",
  8094. * "dataSrc": ""
  8095. * }
  8096. * } );
  8097. *
  8098. * @example
  8099. * // Manipulate the data returned from the server - add a link to data
  8100. * // (note this can, should, be done using `render` for the column - this
  8101. * // is just a simple example of how the data can be manipulated).
  8102. * $('#example').dataTable( {
  8103. * "ajax": {
  8104. * "url": "data.json",
  8105. * "dataSrc": function ( json ) {
  8106. * for ( var i=0, ien=json.length ; i<ien ; i++ ) {
  8107. * json[i][0] = '<a href="/message/'+json[i][0]+'>View message</a>';
  8108. * }
  8109. * return json;
  8110. * }
  8111. * }
  8112. * } );
  8113. *
  8114. * @example
  8115. * // Add data to the request
  8116. * $('#example').dataTable( {
  8117. * "ajax": {
  8118. * "url": "data.json",
  8119. * "data": function ( d ) {
  8120. * return {
  8121. * "extra_search": $('#extra').val()
  8122. * };
  8123. * }
  8124. * }
  8125. * } );
  8126. *
  8127. * @example
  8128. * // Send request as POST
  8129. * $('#example').dataTable( {
  8130. * "ajax": {
  8131. * "url": "data.json",
  8132. * "type": "POST"
  8133. * }
  8134. * } );
  8135. *
  8136. * @example
  8137. * // Get the data from localStorage (could interface with a form for
  8138. * // adding, editing and removing rows).
  8139. * $('#example').dataTable( {
  8140. * "ajax": function (data, callback, settings) {
  8141. * callback(
  8142. * JSON.parse( localStorage.getItem('dataTablesData') )
  8143. * );
  8144. * }
  8145. * } );
  8146. */
  8147. "ajax": null,
  8148. /**
  8149. * This parameter allows you to readily specify the entries in the length drop
  8150. * down menu that DataTables shows when pagination is enabled. It can be
  8151. * either a 1D array of options which will be used for both the displayed
  8152. * option and the value, or a 2D array which will use the array in the first
  8153. * position as the value, and the array in the second position as the
  8154. * displayed options (useful for language strings such as 'All').
  8155. *
  8156. * Note that the `pageLength` property will be automatically set to the
  8157. * first value given in this array, unless `pageLength` is also provided.
  8158. * @type array
  8159. * @default [ 10, 25, 50, 100 ]
  8160. *
  8161. * @dtopt Option
  8162. * @name DataTable.defaults.lengthMenu
  8163. *
  8164. * @example
  8165. * $(document).ready( function() {
  8166. * $('#example').dataTable( {
  8167. * "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
  8168. * } );
  8169. * } );
  8170. */
  8171. "aLengthMenu": [ 10, 25, 50, 100 ],
  8172. /**
  8173. * The `columns` option in the initialisation parameter allows you to define
  8174. * details about the way individual columns behave. For a full list of
  8175. * column options that can be set, please see
  8176. * {@link DataTable.defaults.column}. Note that if you use `columns` to
  8177. * define your columns, you must have an entry in the array for every single
  8178. * column that you have in your table (these can be null if you don't which
  8179. * to specify any options).
  8180. * @member
  8181. *
  8182. * @name DataTable.defaults.column
  8183. */
  8184. "aoColumns": null,
  8185. /**
  8186. * Very similar to `columns`, `columnDefs` allows you to target a specific
  8187. * column, multiple columns, or all columns, using the `targets` property of
  8188. * each object in the array. This allows great flexibility when creating
  8189. * tables, as the `columnDefs` arrays can be of any length, targeting the
  8190. * columns you specifically want. `columnDefs` may use any of the column
  8191. * options available: {@link DataTable.defaults.column}, but it _must_
  8192. * have `targets` defined in each object in the array. Values in the `targets`
  8193. * array may be:
  8194. * <ul>
  8195. * <li>a string - class name will be matched on the TH for the column</li>
  8196. * <li>0 or a positive integer - column index counting from the left</li>
  8197. * <li>a negative integer - column index counting from the right</li>
  8198. * <li>the string "_all" - all columns (i.e. assign a default)</li>
  8199. * </ul>
  8200. * @member
  8201. *
  8202. * @name DataTable.defaults.columnDefs
  8203. */
  8204. "aoColumnDefs": null,
  8205. /**
  8206. * Basically the same as `search`, this parameter defines the individual column
  8207. * filtering state at initialisation time. The array must be of the same size
  8208. * as the number of columns, and each element be an object with the parameters
  8209. * `search` and `escapeRegex` (the latter is optional). 'null' is also
  8210. * accepted and the default will be used.
  8211. * @type array
  8212. * @default []
  8213. *
  8214. * @dtopt Option
  8215. * @name DataTable.defaults.searchCols
  8216. *
  8217. * @example
  8218. * $(document).ready( function() {
  8219. * $('#example').dataTable( {
  8220. * "searchCols": [
  8221. * null,
  8222. * { "search": "My filter" },
  8223. * null,
  8224. * { "search": "^[0-9]", "escapeRegex": false }
  8225. * ]
  8226. * } );
  8227. * } )
  8228. */
  8229. "aoSearchCols": [],
  8230. /**
  8231. * An array of CSS classes that should be applied to displayed rows. This
  8232. * array may be of any length, and DataTables will apply each class
  8233. * sequentially, looping when required.
  8234. * @type array
  8235. * @default null <i>Will take the values determined by the `oClasses.stripe*`
  8236. * options</i>
  8237. *
  8238. * @dtopt Option
  8239. * @name DataTable.defaults.stripeClasses
  8240. *
  8241. * @example
  8242. * $(document).ready( function() {
  8243. * $('#example').dataTable( {
  8244. * "stripeClasses": [ 'strip1', 'strip2', 'strip3' ]
  8245. * } );
  8246. * } )
  8247. */
  8248. "asStripeClasses": null,
  8249. /**
  8250. * Enable or disable automatic column width calculation. This can be disabled
  8251. * as an optimisation (it takes some time to calculate the widths) if the
  8252. * tables widths are passed in using `columns`.
  8253. * @type boolean
  8254. * @default true
  8255. *
  8256. * @dtopt Features
  8257. * @name DataTable.defaults.autoWidth
  8258. *
  8259. * @example
  8260. * $(document).ready( function () {
  8261. * $('#example').dataTable( {
  8262. * "autoWidth": false
  8263. * } );
  8264. * } );
  8265. */
  8266. "bAutoWidth": true,
  8267. /**
  8268. * Deferred rendering can provide DataTables with a huge speed boost when you
  8269. * are using an Ajax or JS data source for the table. This option, when set to
  8270. * true, will cause DataTables to defer the creation of the table elements for
  8271. * each row until they are needed for a draw - saving a significant amount of
  8272. * time.
  8273. * @type boolean
  8274. * @default false
  8275. *
  8276. * @dtopt Features
  8277. * @name DataTable.defaults.deferRender
  8278. *
  8279. * @example
  8280. * $(document).ready( function() {
  8281. * $('#example').dataTable( {
  8282. * "ajax": "sources/arrays.txt",
  8283. * "deferRender": true
  8284. * } );
  8285. * } );
  8286. */
  8287. "bDeferRender": false,
  8288. /**
  8289. * Replace a DataTable which matches the given selector and replace it with
  8290. * one which has the properties of the new initialisation object passed. If no
  8291. * table matches the selector, then the new DataTable will be constructed as
  8292. * per normal.
  8293. * @type boolean
  8294. * @default false
  8295. *
  8296. * @dtopt Options
  8297. * @name DataTable.defaults.destroy
  8298. *
  8299. * @example
  8300. * $(document).ready( function() {
  8301. * $('#example').dataTable( {
  8302. * "srollY": "200px",
  8303. * "paginate": false
  8304. * } );
  8305. *
  8306. * // Some time later....
  8307. * $('#example').dataTable( {
  8308. * "filter": false,
  8309. * "destroy": true
  8310. * } );
  8311. * } );
  8312. */
  8313. "bDestroy": false,
  8314. /**
  8315. * Enable or disable filtering of data. Filtering in DataTables is "smart" in
  8316. * that it allows the end user to input multiple words (space separated) and
  8317. * will match a row containing those words, even if not in the order that was
  8318. * specified (this allow matching across multiple columns). Note that if you
  8319. * wish to use filtering in DataTables this must remain 'true' - to remove the
  8320. * default filtering input box and retain filtering abilities, please use
  8321. * {@link DataTable.defaults.dom}.
  8322. * @type boolean
  8323. * @default true
  8324. *
  8325. * @dtopt Features
  8326. * @name DataTable.defaults.searching
  8327. *
  8328. * @example
  8329. * $(document).ready( function () {
  8330. * $('#example').dataTable( {
  8331. * "searching": false
  8332. * } );
  8333. * } );
  8334. */
  8335. "bFilter": true,
  8336. /**
  8337. * Enable or disable the table information display. This shows information
  8338. * about the data that is currently visible on the page, including information
  8339. * about filtered data if that action is being performed.
  8340. * @type boolean
  8341. * @default true
  8342. *
  8343. * @dtopt Features
  8344. * @name DataTable.defaults.info
  8345. *
  8346. * @example
  8347. * $(document).ready( function () {
  8348. * $('#example').dataTable( {
  8349. * "info": false
  8350. * } );
  8351. * } );
  8352. */
  8353. "bInfo": true,
  8354. /**
  8355. * Enable jQuery UI ThemeRoller support (required as ThemeRoller requires some
  8356. * slightly different and additional mark-up from what DataTables has
  8357. * traditionally used).
  8358. * @type boolean
  8359. * @default false
  8360. *
  8361. * @dtopt Features
  8362. * @name DataTable.defaults.jQueryUI
  8363. *
  8364. * @example
  8365. * $(document).ready( function() {
  8366. * $('#example').dataTable( {
  8367. * "jQueryUI": true
  8368. * } );
  8369. * } );
  8370. */
  8371. "bJQueryUI": false,
  8372. /**
  8373. * Allows the end user to select the size of a formatted page from a select
  8374. * menu (sizes are 10, 25, 50 and 100). Requires pagination (`paginate`).
  8375. * @type boolean
  8376. * @default true
  8377. *
  8378. * @dtopt Features
  8379. * @name DataTable.defaults.lengthChange
  8380. *
  8381. * @example
  8382. * $(document).ready( function () {
  8383. * $('#example').dataTable( {
  8384. * "lengthChange": false
  8385. * } );
  8386. * } );
  8387. */
  8388. "bLengthChange": true,
  8389. /**
  8390. * Enable or disable pagination.
  8391. * @type boolean
  8392. * @default true
  8393. *
  8394. * @dtopt Features
  8395. * @name DataTable.defaults.paging
  8396. *
  8397. * @example
  8398. * $(document).ready( function () {
  8399. * $('#example').dataTable( {
  8400. * "paging": false
  8401. * } );
  8402. * } );
  8403. */
  8404. "bPaginate": true,
  8405. /**
  8406. * Enable or disable the display of a 'processing' indicator when the table is
  8407. * being processed (e.g. a sort). This is particularly useful for tables with
  8408. * large amounts of data where it can take a noticeable amount of time to sort
  8409. * the entries.
  8410. * @type boolean
  8411. * @default false
  8412. *
  8413. * @dtopt Features
  8414. * @name DataTable.defaults.processing
  8415. *
  8416. * @example
  8417. * $(document).ready( function () {
  8418. * $('#example').dataTable( {
  8419. * "processing": true
  8420. * } );
  8421. * } );
  8422. */
  8423. "bProcessing": false,
  8424. /**
  8425. * Retrieve the DataTables object for the given selector. Note that if the
  8426. * table has already been initialised, this parameter will cause DataTables
  8427. * to simply return the object that has already been set up - it will not take
  8428. * account of any changes you might have made to the initialisation object
  8429. * passed to DataTables (setting this parameter to true is an acknowledgement
  8430. * that you understand this). `destroy` can be used to reinitialise a table if
  8431. * you need.
  8432. * @type boolean
  8433. * @default false
  8434. *
  8435. * @dtopt Options
  8436. * @name DataTable.defaults.retrieve
  8437. *
  8438. * @example
  8439. * $(document).ready( function() {
  8440. * initTable();
  8441. * tableActions();
  8442. * } );
  8443. *
  8444. * function initTable ()
  8445. * {
  8446. * return $('#example').dataTable( {
  8447. * "scrollY": "200px",
  8448. * "paginate": false,
  8449. * "retrieve": true
  8450. * } );
  8451. * }
  8452. *
  8453. * function tableActions ()
  8454. * {
  8455. * var table = initTable();
  8456. * // perform API operations with oTable
  8457. * }
  8458. */
  8459. "bRetrieve": false,
  8460. /**
  8461. * When vertical (y) scrolling is enabled, DataTables will force the height of
  8462. * the table's viewport to the given height at all times (useful for layout).
  8463. * However, this can look odd when filtering data down to a small data set,
  8464. * and the footer is left "floating" further down. This parameter (when
  8465. * enabled) will cause DataTables to collapse the table's viewport down when
  8466. * the result set will fit within the given Y height.
  8467. * @type boolean
  8468. * @default false
  8469. *
  8470. * @dtopt Options
  8471. * @name DataTable.defaults.scrollCollapse
  8472. *
  8473. * @example
  8474. * $(document).ready( function() {
  8475. * $('#example').dataTable( {
  8476. * "scrollY": "200",
  8477. * "scrollCollapse": true
  8478. * } );
  8479. * } );
  8480. */
  8481. "bScrollCollapse": false,
  8482. /**
  8483. * Configure DataTables to use server-side processing. Note that the
  8484. * `ajax` parameter must also be given in order to give DataTables a
  8485. * source to obtain the required data for each draw.
  8486. * @type boolean
  8487. * @default false
  8488. *
  8489. * @dtopt Features
  8490. * @dtopt Server-side
  8491. * @name DataTable.defaults.serverSide
  8492. *
  8493. * @example
  8494. * $(document).ready( function () {
  8495. * $('#example').dataTable( {
  8496. * "serverSide": true,
  8497. * "ajax": "xhr.php"
  8498. * } );
  8499. * } );
  8500. */
  8501. "bServerSide": false,
  8502. /**
  8503. * Enable or disable sorting of columns. Sorting of individual columns can be
  8504. * disabled by the `sortable` option for each column.
  8505. * @type boolean
  8506. * @default true
  8507. *
  8508. * @dtopt Features
  8509. * @name DataTable.defaults.ordering
  8510. *
  8511. * @example
  8512. * $(document).ready( function () {
  8513. * $('#example').dataTable( {
  8514. * "ordering": false
  8515. * } );
  8516. * } );
  8517. */
  8518. "bSort": true,
  8519. /**
  8520. * Enable or display DataTables' ability to sort multiple columns at the
  8521. * same time (activated by shift-click by the user).
  8522. * @type boolean
  8523. * @default true
  8524. *
  8525. * @dtopt Options
  8526. * @name DataTable.defaults.orderMulti
  8527. *
  8528. * @example
  8529. * // Disable multiple column sorting ability
  8530. * $(document).ready( function () {
  8531. * $('#example').dataTable( {
  8532. * "orderMulti": false
  8533. * } );
  8534. * } );
  8535. */
  8536. "bSortMulti": true,
  8537. /**
  8538. * Allows control over whether DataTables should use the top (true) unique
  8539. * cell that is found for a single column, or the bottom (false - default).
  8540. * This is useful when using complex headers.
  8541. * @type boolean
  8542. * @default false
  8543. *
  8544. * @dtopt Options
  8545. * @name DataTable.defaults.orderCellsTop
  8546. *
  8547. * @example
  8548. * $(document).ready( function() {
  8549. * $('#example').dataTable( {
  8550. * "orderCellsTop": true
  8551. * } );
  8552. * } );
  8553. */
  8554. "bSortCellsTop": false,
  8555. /**
  8556. * Enable or disable the addition of the classes `sorting\_1`, `sorting\_2` and
  8557. * `sorting\_3` to the columns which are currently being sorted on. This is
  8558. * presented as a feature switch as it can increase processing time (while
  8559. * classes are removed and added) so for large data sets you might want to
  8560. * turn this off.
  8561. * @type boolean
  8562. * @default true
  8563. *
  8564. * @dtopt Features
  8565. * @name DataTable.defaults.orderClasses
  8566. *
  8567. * @example
  8568. * $(document).ready( function () {
  8569. * $('#example').dataTable( {
  8570. * "orderClasses": false
  8571. * } );
  8572. * } );
  8573. */
  8574. "bSortClasses": true,
  8575. /**
  8576. * Enable or disable state saving. When enabled HTML5 `localStorage` will be
  8577. * used to save table display information such as pagination information,
  8578. * display length, filtering and sorting. As such when the end user reloads
  8579. * the page the display display will match what thy had previously set up.
  8580. *
  8581. * Due to the use of `localStorage` the default state saving is not supported
  8582. * in IE6 or 7. If state saving is required in those browsers, use
  8583. * `stateSaveCallback` to provide a storage solution such as cookies.
  8584. * @type boolean
  8585. * @default false
  8586. *
  8587. * @dtopt Features
  8588. * @name DataTable.defaults.stateSave
  8589. *
  8590. * @example
  8591. * $(document).ready( function () {
  8592. * $('#example').dataTable( {
  8593. * "stateSave": true
  8594. * } );
  8595. * } );
  8596. */
  8597. "bStateSave": false,
  8598. /**
  8599. * This function is called when a TR element is created (and all TD child
  8600. * elements have been inserted), or registered if using a DOM source, allowing
  8601. * manipulation of the TR element (adding classes etc).
  8602. * @type function
  8603. * @param {node} row "TR" element for the current row
  8604. * @param {array} data Raw data array for this row
  8605. * @param {int} dataIndex The index of this row in the internal aoData array
  8606. *
  8607. * @dtopt Callbacks
  8608. * @name DataTable.defaults.createdRow
  8609. *
  8610. * @example
  8611. * $(document).ready( function() {
  8612. * $('#example').dataTable( {
  8613. * "createdRow": function( row, data, dataIndex ) {
  8614. * // Bold the grade for all 'A' grade browsers
  8615. * if ( data[4] == "A" )
  8616. * {
  8617. * $('td:eq(4)', row).html( '<b>A</b>' );
  8618. * }
  8619. * }
  8620. * } );
  8621. * } );
  8622. */
  8623. "fnCreatedRow": null,
  8624. /**
  8625. * This function is called on every 'draw' event, and allows you to
  8626. * dynamically modify any aspect you want about the created DOM.
  8627. * @type function
  8628. * @param {object} settings DataTables settings object
  8629. *
  8630. * @dtopt Callbacks
  8631. * @name DataTable.defaults.drawCallback
  8632. *
  8633. * @example
  8634. * $(document).ready( function() {
  8635. * $('#example').dataTable( {
  8636. * "drawCallback": function( settings ) {
  8637. * alert( 'DataTables has redrawn the table' );
  8638. * }
  8639. * } );
  8640. * } );
  8641. */
  8642. "fnDrawCallback": null,
  8643. /**
  8644. * Identical to fnHeaderCallback() but for the table footer this function
  8645. * allows you to modify the table footer on every 'draw' event.
  8646. * @type function
  8647. * @param {node} foot "TR" element for the footer
  8648. * @param {array} data Full table data (as derived from the original HTML)
  8649. * @param {int} start Index for the current display starting point in the
  8650. * display array
  8651. * @param {int} end Index for the current display ending point in the
  8652. * display array
  8653. * @param {array int} display Index array to translate the visual position
  8654. * to the full data array
  8655. *
  8656. * @dtopt Callbacks
  8657. * @name DataTable.defaults.footerCallback
  8658. *
  8659. * @example
  8660. * $(document).ready( function() {
  8661. * $('#example').dataTable( {
  8662. * "footerCallback": function( tfoot, data, start, end, display ) {
  8663. * tfoot.getElementsByTagName('th')[0].innerHTML = "Starting index is "+start;
  8664. * }
  8665. * } );
  8666. * } )
  8667. */
  8668. "fnFooterCallback": null,
  8669. /**
  8670. * When rendering large numbers in the information element for the table
  8671. * (i.e. "Showing 1 to 10 of 57 entries") DataTables will render large numbers
  8672. * to have a comma separator for the 'thousands' units (e.g. 1 million is
  8673. * rendered as "1,000,000") to help readability for the end user. This
  8674. * function will override the default method DataTables uses.
  8675. * @type function
  8676. * @member
  8677. * @param {int} toFormat number to be formatted
  8678. * @returns {string} formatted string for DataTables to show the number
  8679. *
  8680. * @dtopt Callbacks
  8681. * @name DataTable.defaults.formatNumber
  8682. *
  8683. * @example
  8684. * // Format a number using a single quote for the separator (note that
  8685. * // this can also be done with the language.thousands option)
  8686. * $(document).ready( function() {
  8687. * $('#example').dataTable( {
  8688. * "formatNumber": function ( toFormat ) {
  8689. * return toFormat.toString().replace(
  8690. * /\B(?=(\d{3})+(?!\d))/g, "'"
  8691. * );
  8692. * };
  8693. * } );
  8694. * } );
  8695. */
  8696. "fnFormatNumber": function ( toFormat ) {
  8697. return toFormat.toString().replace(
  8698. /\B(?=(\d{3})+(?!\d))/g,
  8699. this.oLanguage.sThousands
  8700. );
  8701. },
  8702. /**
  8703. * This function is called on every 'draw' event, and allows you to
  8704. * dynamically modify the header row. This can be used to calculate and
  8705. * display useful information about the table.
  8706. * @type function
  8707. * @param {node} head "TR" element for the header
  8708. * @param {array} data Full table data (as derived from the original HTML)
  8709. * @param {int} start Index for the current display starting point in the
  8710. * display array
  8711. * @param {int} end Index for the current display ending point in the
  8712. * display array
  8713. * @param {array int} display Index array to translate the visual position
  8714. * to the full data array
  8715. *
  8716. * @dtopt Callbacks
  8717. * @name DataTable.defaults.headerCallback
  8718. *
  8719. * @example
  8720. * $(document).ready( function() {
  8721. * $('#example').dataTable( {
  8722. * "fheaderCallback": function( head, data, start, end, display ) {
  8723. * head.getElementsByTagName('th')[0].innerHTML = "Displaying "+(end-start)+" records";
  8724. * }
  8725. * } );
  8726. * } )
  8727. */
  8728. "fnHeaderCallback": null,
  8729. /**
  8730. * The information element can be used to convey information about the current
  8731. * state of the table. Although the internationalisation options presented by
  8732. * DataTables are quite capable of dealing with most customisations, there may
  8733. * be times where you wish to customise the string further. This callback
  8734. * allows you to do exactly that.
  8735. * @type function
  8736. * @param {object} oSettings DataTables settings object
  8737. * @param {int} start Starting position in data for the draw
  8738. * @param {int} end End position in data for the draw
  8739. * @param {int} max Total number of rows in the table (regardless of
  8740. * filtering)
  8741. * @param {int} total Total number of rows in the data set, after filtering
  8742. * @param {string} pre The string that DataTables has formatted using it's
  8743. * own rules
  8744. * @returns {string} The string to be displayed in the information element.
  8745. *
  8746. * @dtopt Callbacks
  8747. * @name DataTable.defaults.infoCallback
  8748. *
  8749. * @example
  8750. * $('#example').dataTable( {
  8751. * "infoCallback": function( settings, start, end, max, total, pre ) {
  8752. * return start +" to "+ end;
  8753. * }
  8754. * } );
  8755. */
  8756. "fnInfoCallback": null,
  8757. /**
  8758. * Called when the table has been initialised. Normally DataTables will
  8759. * initialise sequentially and there will be no need for this function,
  8760. * however, this does not hold true when using external language information
  8761. * since that is obtained using an async XHR call.
  8762. * @type function
  8763. * @param {object} settings DataTables settings object
  8764. * @param {object} json The JSON object request from the server - only
  8765. * present if client-side Ajax sourced data is used
  8766. *
  8767. * @dtopt Callbacks
  8768. * @name DataTable.defaults.initComplete
  8769. *
  8770. * @example
  8771. * $(document).ready( function() {
  8772. * $('#example').dataTable( {
  8773. * "initComplete": function(settings, json) {
  8774. * alert( 'DataTables has finished its initialisation.' );
  8775. * }
  8776. * } );
  8777. * } )
  8778. */
  8779. "fnInitComplete": null,
  8780. /**
  8781. * Called at the very start of each table draw and can be used to cancel the
  8782. * draw by returning false, any other return (including undefined) results in
  8783. * the full draw occurring).
  8784. * @type function
  8785. * @param {object} settings DataTables settings object
  8786. * @returns {boolean} False will cancel the draw, anything else (including no
  8787. * return) will allow it to complete.
  8788. *
  8789. * @dtopt Callbacks
  8790. * @name DataTable.defaults.preDrawCallback
  8791. *
  8792. * @example
  8793. * $(document).ready( function() {
  8794. * $('#example').dataTable( {
  8795. * "preDrawCallback": function( settings ) {
  8796. * if ( $('#test').val() == 1 ) {
  8797. * return false;
  8798. * }
  8799. * }
  8800. * } );
  8801. * } );
  8802. */
  8803. "fnPreDrawCallback": null,
  8804. /**
  8805. * This function allows you to 'post process' each row after it have been
  8806. * generated for each table draw, but before it is rendered on screen. This
  8807. * function might be used for setting the row class name etc.
  8808. * @type function
  8809. * @param {node} row "TR" element for the current row
  8810. * @param {array} data Raw data array for this row
  8811. * @param {int} displayIndex The display index for the current table draw
  8812. * @param {int} displayIndexFull The index of the data in the full list of
  8813. * rows (after filtering)
  8814. *
  8815. * @dtopt Callbacks
  8816. * @name DataTable.defaults.rowCallback
  8817. *
  8818. * @example
  8819. * $(document).ready( function() {
  8820. * $('#example').dataTable( {
  8821. * "rowCallback": function( row, data, displayIndex, displayIndexFull ) {
  8822. * // Bold the grade for all 'A' grade browsers
  8823. * if ( data[4] == "A" ) {
  8824. * $('td:eq(4)', row).html( '<b>A</b>' );
  8825. * }
  8826. * }
  8827. * } );
  8828. * } );
  8829. */
  8830. "fnRowCallback": null,
  8831. /**
  8832. * __Deprecated__ The functionality provided by this parameter has now been
  8833. * superseded by that provided through `ajax`, which should be used instead.
  8834. *
  8835. * This parameter allows you to override the default function which obtains
  8836. * the data from the server so something more suitable for your application.
  8837. * For example you could use POST data, or pull information from a Gears or
  8838. * AIR database.
  8839. * @type function
  8840. * @member
  8841. * @param {string} source HTTP source to obtain the data from (`ajax`)
  8842. * @param {array} data A key/value pair object containing the data to send
  8843. * to the server
  8844. * @param {function} callback to be called on completion of the data get
  8845. * process that will draw the data on the page.
  8846. * @param {object} settings DataTables settings object
  8847. *
  8848. * @dtopt Callbacks
  8849. * @dtopt Server-side
  8850. * @name DataTable.defaults.serverData
  8851. *
  8852. * @deprecated 1.10. Please use `ajax` for this functionality now.
  8853. */
  8854. "fnServerData": null,
  8855. /**
  8856. * __Deprecated__ The functionality provided by this parameter has now been
  8857. * superseded by that provided through `ajax`, which should be used instead.
  8858. *
  8859. * It is often useful to send extra data to the server when making an Ajax
  8860. * request - for example custom filtering information, and this callback
  8861. * function makes it trivial to send extra information to the server. The
  8862. * passed in parameter is the data set that has been constructed by
  8863. * DataTables, and you can add to this or modify it as you require.
  8864. * @type function
  8865. * @param {array} data Data array (array of objects which are name/value
  8866. * pairs) that has been constructed by DataTables and will be sent to the
  8867. * server. In the case of Ajax sourced data with server-side processing
  8868. * this will be an empty array, for server-side processing there will be a
  8869. * significant number of parameters!
  8870. * @returns {undefined} Ensure that you modify the data array passed in,
  8871. * as this is passed by reference.
  8872. *
  8873. * @dtopt Callbacks
  8874. * @dtopt Server-side
  8875. * @name DataTable.defaults.serverParams
  8876. *
  8877. * @deprecated 1.10. Please use `ajax` for this functionality now.
  8878. */
  8879. "fnServerParams": null,
  8880. /**
  8881. * Load the table state. With this function you can define from where, and how, the
  8882. * state of a table is loaded. By default DataTables will load from `localStorage`
  8883. * but you might wish to use a server-side database or cookies.
  8884. * @type function
  8885. * @member
  8886. * @param {object} settings DataTables settings object
  8887. * @return {object} The DataTables state object to be loaded
  8888. *
  8889. * @dtopt Callbacks
  8890. * @name DataTable.defaults.stateLoadCallback
  8891. *
  8892. * @example
  8893. * $(document).ready( function() {
  8894. * $('#example').dataTable( {
  8895. * "stateSave": true,
  8896. * "stateLoadCallback": function (settings) {
  8897. * var o;
  8898. *
  8899. * // Send an Ajax request to the server to get the data. Note that
  8900. * // this is a synchronous request.
  8901. * $.ajax( {
  8902. * "url": "/state_load",
  8903. * "async": false,
  8904. * "dataType": "json",
  8905. * "success": function (json) {
  8906. * o = json;
  8907. * }
  8908. * } );
  8909. *
  8910. * return o;
  8911. * }
  8912. * } );
  8913. * } );
  8914. */
  8915. "fnStateLoadCallback": function ( settings ) {
  8916. try {
  8917. return JSON.parse(
  8918. (settings.iStateDuration === -1 ? sessionStorage : localStorage).getItem(
  8919. 'DataTables_'+settings.sInstance+'_'+location.pathname
  8920. )
  8921. );
  8922. } catch (e) {}
  8923. },
  8924. /**
  8925. * Callback which allows modification of the saved state prior to loading that state.
  8926. * This callback is called when the table is loading state from the stored data, but
  8927. * prior to the settings object being modified by the saved state. Note that for
  8928. * plug-in authors, you should use the `stateLoadParams` event to load parameters for
  8929. * a plug-in.
  8930. * @type function
  8931. * @param {object} settings DataTables settings object
  8932. * @param {object} data The state object that is to be loaded
  8933. *
  8934. * @dtopt Callbacks
  8935. * @name DataTable.defaults.stateLoadParams
  8936. *
  8937. * @example
  8938. * // Remove a saved filter, so filtering is never loaded
  8939. * $(document).ready( function() {
  8940. * $('#example').dataTable( {
  8941. * "stateSave": true,
  8942. * "stateLoadParams": function (settings, data) {
  8943. * data.oSearch.sSearch = "";
  8944. * }
  8945. * } );
  8946. * } );
  8947. *
  8948. * @example
  8949. * // Disallow state loading by returning false
  8950. * $(document).ready( function() {
  8951. * $('#example').dataTable( {
  8952. * "stateSave": true,
  8953. * "stateLoadParams": function (settings, data) {
  8954. * return false;
  8955. * }
  8956. * } );
  8957. * } );
  8958. */
  8959. "fnStateLoadParams": null,
  8960. /**
  8961. * Callback that is called when the state has been loaded from the state saving method
  8962. * and the DataTables settings object has been modified as a result of the loaded state.
  8963. * @type function
  8964. * @param {object} settings DataTables settings object
  8965. * @param {object} data The state object that was loaded
  8966. *
  8967. * @dtopt Callbacks
  8968. * @name DataTable.defaults.stateLoaded
  8969. *
  8970. * @example
  8971. * // Show an alert with the filtering value that was saved
  8972. * $(document).ready( function() {
  8973. * $('#example').dataTable( {
  8974. * "stateSave": true,
  8975. * "stateLoaded": function (settings, data) {
  8976. * alert( 'Saved filter was: '+data.oSearch.sSearch );
  8977. * }
  8978. * } );
  8979. * } );
  8980. */
  8981. "fnStateLoaded": null,
  8982. /**
  8983. * Save the table state. This function allows you to define where and how the state
  8984. * information for the table is stored By default DataTables will use `localStorage`
  8985. * but you might wish to use a server-side database or cookies.
  8986. * @type function
  8987. * @member
  8988. * @param {object} settings DataTables settings object
  8989. * @param {object} data The state object to be saved
  8990. *
  8991. * @dtopt Callbacks
  8992. * @name DataTable.defaults.stateSaveCallback
  8993. *
  8994. * @example
  8995. * $(document).ready( function() {
  8996. * $('#example').dataTable( {
  8997. * "stateSave": true,
  8998. * "stateSaveCallback": function (settings, data) {
  8999. * // Send an Ajax request to the server with the state object
  9000. * $.ajax( {
  9001. * "url": "/state_save",
  9002. * "data": data,
  9003. * "dataType": "json",
  9004. * "method": "POST"
  9005. * "success": function () {}
  9006. * } );
  9007. * }
  9008. * } );
  9009. * } );
  9010. */
  9011. "fnStateSaveCallback": function ( settings, data ) {
  9012. try {
  9013. (settings.iStateDuration === -1 ? sessionStorage : localStorage).setItem(
  9014. 'DataTables_'+settings.sInstance+'_'+location.pathname,
  9015. JSON.stringify( data )
  9016. );
  9017. } catch (e) {}
  9018. },
  9019. /**
  9020. * Callback which allows modification of the state to be saved. Called when the table
  9021. * has changed state a new state save is required. This method allows modification of
  9022. * the state saving object prior to actually doing the save, including addition or
  9023. * other state properties or modification. Note that for plug-in authors, you should
  9024. * use the `stateSaveParams` event to save parameters for a plug-in.
  9025. * @type function
  9026. * @param {object} settings DataTables settings object
  9027. * @param {object} data The state object to be saved
  9028. *
  9029. * @dtopt Callbacks
  9030. * @name DataTable.defaults.stateSaveParams
  9031. *
  9032. * @example
  9033. * // Remove a saved filter, so filtering is never saved
  9034. * $(document).ready( function() {
  9035. * $('#example').dataTable( {
  9036. * "stateSave": true,
  9037. * "stateSaveParams": function (settings, data) {
  9038. * data.oSearch.sSearch = "";
  9039. * }
  9040. * } );
  9041. * } );
  9042. */
  9043. "fnStateSaveParams": null,
  9044. /**
  9045. * Duration for which the saved state information is considered valid. After this period
  9046. * has elapsed the state will be returned to the default.
  9047. * Value is given in seconds.
  9048. * @type int
  9049. * @default 7200 <i>(2 hours)</i>
  9050. *
  9051. * @dtopt Options
  9052. * @name DataTable.defaults.stateDuration
  9053. *
  9054. * @example
  9055. * $(document).ready( function() {
  9056. * $('#example').dataTable( {
  9057. * "stateDuration": 60*60*24; // 1 day
  9058. * } );
  9059. * } )
  9060. */
  9061. "iStateDuration": 7200,
  9062. /**
  9063. * When enabled DataTables will not make a request to the server for the first
  9064. * page draw - rather it will use the data already on the page (no sorting etc
  9065. * will be applied to it), thus saving on an XHR at load time. `deferLoading`
  9066. * is used to indicate that deferred loading is required, but it is also used
  9067. * to tell DataTables how many records there are in the full table (allowing
  9068. * the information element and pagination to be displayed correctly). In the case
  9069. * where a filtering is applied to the table on initial load, this can be
  9070. * indicated by giving the parameter as an array, where the first element is
  9071. * the number of records available after filtering and the second element is the
  9072. * number of records without filtering (allowing the table information element
  9073. * to be shown correctly).
  9074. * @type int | array
  9075. * @default null
  9076. *
  9077. * @dtopt Options
  9078. * @name DataTable.defaults.deferLoading
  9079. *
  9080. * @example
  9081. * // 57 records available in the table, no filtering applied
  9082. * $(document).ready( function() {
  9083. * $('#example').dataTable( {
  9084. * "serverSide": true,
  9085. * "ajax": "scripts/server_processing.php",
  9086. * "deferLoading": 57
  9087. * } );
  9088. * } );
  9089. *
  9090. * @example
  9091. * // 57 records after filtering, 100 without filtering (an initial filter applied)
  9092. * $(document).ready( function() {
  9093. * $('#example').dataTable( {
  9094. * "serverSide": true,
  9095. * "ajax": "scripts/server_processing.php",
  9096. * "deferLoading": [ 57, 100 ],
  9097. * "search": {
  9098. * "search": "my_filter"
  9099. * }
  9100. * } );
  9101. * } );
  9102. */
  9103. "iDeferLoading": null,
  9104. /**
  9105. * Number of rows to display on a single page when using pagination. If
  9106. * feature enabled (`lengthChange`) then the end user will be able to override
  9107. * this to a custom setting using a pop-up menu.
  9108. * @type int
  9109. * @default 10
  9110. *
  9111. * @dtopt Options
  9112. * @name DataTable.defaults.pageLength
  9113. *
  9114. * @example
  9115. * $(document).ready( function() {
  9116. * $('#example').dataTable( {
  9117. * "pageLength": 50
  9118. * } );
  9119. * } )
  9120. */
  9121. "iDisplayLength": 10,
  9122. /**
  9123. * Define the starting point for data display when using DataTables with
  9124. * pagination. Note that this parameter is the number of records, rather than
  9125. * the page number, so if you have 10 records per page and want to start on
  9126. * the third page, it should be "20".
  9127. * @type int
  9128. * @default 0
  9129. *
  9130. * @dtopt Options
  9131. * @name DataTable.defaults.displayStart
  9132. *
  9133. * @example
  9134. * $(document).ready( function() {
  9135. * $('#example').dataTable( {
  9136. * "displayStart": 20
  9137. * } );
  9138. * } )
  9139. */
  9140. "iDisplayStart": 0,
  9141. /**
  9142. * By default DataTables allows keyboard navigation of the table (sorting, paging,
  9143. * and filtering) by adding a `tabindex` attribute to the required elements. This
  9144. * allows you to tab through the controls and press the enter key to activate them.
  9145. * The tabindex is default 0, meaning that the tab follows the flow of the document.
  9146. * You can overrule this using this parameter if you wish. Use a value of -1 to
  9147. * disable built-in keyboard navigation.
  9148. * @type int
  9149. * @default 0
  9150. *
  9151. * @dtopt Options
  9152. * @name DataTable.defaults.tabIndex
  9153. *
  9154. * @example
  9155. * $(document).ready( function() {
  9156. * $('#example').dataTable( {
  9157. * "tabIndex": 1
  9158. * } );
  9159. * } );
  9160. */
  9161. "iTabIndex": 0,
  9162. /**
  9163. * Classes that DataTables assigns to the various components and features
  9164. * that it adds to the HTML table. This allows classes to be configured
  9165. * during initialisation in addition to through the static
  9166. * {@link DataTable.ext.oStdClasses} object).
  9167. * @namespace
  9168. * @name DataTable.defaults.classes
  9169. */
  9170. "oClasses": {},
  9171. /**
  9172. * All strings that DataTables uses in the user interface that it creates
  9173. * are defined in this object, allowing you to modified them individually or
  9174. * completely replace them all as required.
  9175. * @namespace
  9176. * @name DataTable.defaults.language
  9177. */
  9178. "oLanguage": {
  9179. /**
  9180. * Strings that are used for WAI-ARIA labels and controls only (these are not
  9181. * actually visible on the page, but will be read by screenreaders, and thus
  9182. * must be internationalised as well).
  9183. * @namespace
  9184. * @name DataTable.defaults.language.aria
  9185. */
  9186. "oAria": {
  9187. /**
  9188. * ARIA label that is added to the table headers when the column may be
  9189. * sorted ascending by activing the column (click or return when focused).
  9190. * Note that the column header is prefixed to this string.
  9191. * @type string
  9192. * @default : activate to sort column ascending
  9193. *
  9194. * @dtopt Language
  9195. * @name DataTable.defaults.language.aria.sortAscending
  9196. *
  9197. * @example
  9198. * $(document).ready( function() {
  9199. * $('#example').dataTable( {
  9200. * "language": {
  9201. * "aria": {
  9202. * "sortAscending": " - click/return to sort ascending"
  9203. * }
  9204. * }
  9205. * } );
  9206. * } );
  9207. */
  9208. "sSortAscending": ": activate to sort column ascending",
  9209. /**
  9210. * ARIA label that is added to the table headers when the column may be
  9211. * sorted descending by activing the column (click or return when focused).
  9212. * Note that the column header is prefixed to this string.
  9213. * @type string
  9214. * @default : activate to sort column ascending
  9215. *
  9216. * @dtopt Language
  9217. * @name DataTable.defaults.language.aria.sortDescending
  9218. *
  9219. * @example
  9220. * $(document).ready( function() {
  9221. * $('#example').dataTable( {
  9222. * "language": {
  9223. * "aria": {
  9224. * "sortDescending": " - click/return to sort descending"
  9225. * }
  9226. * }
  9227. * } );
  9228. * } );
  9229. */
  9230. "sSortDescending": ": activate to sort column descending"
  9231. },
  9232. /**
  9233. * Pagination string used by DataTables for the built-in pagination
  9234. * control types.
  9235. * @namespace
  9236. * @name DataTable.defaults.language.paginate
  9237. */
  9238. "oPaginate": {
  9239. /**
  9240. * Text to use when using the 'full_numbers' type of pagination for the
  9241. * button to take the user to the first page.
  9242. * @type string
  9243. * @default First
  9244. *
  9245. * @dtopt Language
  9246. * @name DataTable.defaults.language.paginate.first
  9247. *
  9248. * @example
  9249. * $(document).ready( function() {
  9250. * $('#example').dataTable( {
  9251. * "language": {
  9252. * "paginate": {
  9253. * "first": "First page"
  9254. * }
  9255. * }
  9256. * } );
  9257. * } );
  9258. */
  9259. "sFirst": "First",
  9260. /**
  9261. * Text to use when using the 'full_numbers' type of pagination for the
  9262. * button to take the user to the last page.
  9263. * @type string
  9264. * @default Last
  9265. *
  9266. * @dtopt Language
  9267. * @name DataTable.defaults.language.paginate.last
  9268. *
  9269. * @example
  9270. * $(document).ready( function() {
  9271. * $('#example').dataTable( {
  9272. * "language": {
  9273. * "paginate": {
  9274. * "last": "Last page"
  9275. * }
  9276. * }
  9277. * } );
  9278. * } );
  9279. */
  9280. "sLast": "Last",
  9281. /**
  9282. * Text to use for the 'next' pagination button (to take the user to the
  9283. * next page).
  9284. * @type string
  9285. * @default Next
  9286. *
  9287. * @dtopt Language
  9288. * @name DataTable.defaults.language.paginate.next
  9289. *
  9290. * @example
  9291. * $(document).ready( function() {
  9292. * $('#example').dataTable( {
  9293. * "language": {
  9294. * "paginate": {
  9295. * "next": "Next page"
  9296. * }
  9297. * }
  9298. * } );
  9299. * } );
  9300. */
  9301. "sNext": "Next",
  9302. /**
  9303. * Text to use for the 'previous' pagination button (to take the user to
  9304. * the previous page).
  9305. * @type string
  9306. * @default Previous
  9307. *
  9308. * @dtopt Language
  9309. * @name DataTable.defaults.language.paginate.previous
  9310. *
  9311. * @example
  9312. * $(document).ready( function() {
  9313. * $('#example').dataTable( {
  9314. * "language": {
  9315. * "paginate": {
  9316. * "previous": "Previous page"
  9317. * }
  9318. * }
  9319. * } );
  9320. * } );
  9321. */
  9322. "sPrevious": "Previous"
  9323. },
  9324. /**
  9325. * This string is shown in preference to `zeroRecords` when the table is
  9326. * empty of data (regardless of filtering). Note that this is an optional
  9327. * parameter - if it is not given, the value of `zeroRecords` will be used
  9328. * instead (either the default or given value).
  9329. * @type string
  9330. * @default No data available in table
  9331. *
  9332. * @dtopt Language
  9333. * @name DataTable.defaults.language.emptyTable
  9334. *
  9335. * @example
  9336. * $(document).ready( function() {
  9337. * $('#example').dataTable( {
  9338. * "language": {
  9339. * "emptyTable": "No data available in table"
  9340. * }
  9341. * } );
  9342. * } );
  9343. */
  9344. "sEmptyTable": "No data available in table",
  9345. /**
  9346. * This string gives information to the end user about the information
  9347. * that is current on display on the page. The following tokens can be
  9348. * used in the string and will be dynamically replaced as the table
  9349. * display updates. This tokens can be placed anywhere in the string, or
  9350. * removed as needed by the language requires:
  9351. *
  9352. * * `\_START\_` - Display index of the first record on the current page
  9353. * * `\_END\_` - Display index of the last record on the current page
  9354. * * `\_TOTAL\_` - Number of records in the table after filtering
  9355. * * `\_MAX\_` - Number of records in the table without filtering
  9356. * * `\_PAGE\_` - Current page number
  9357. * * `\_PAGES\_` - Total number of pages of data in the table
  9358. *
  9359. * @type string
  9360. * @default Showing _START_ to _END_ of _TOTAL_ entries
  9361. *
  9362. * @dtopt Language
  9363. * @name DataTable.defaults.language.info
  9364. *
  9365. * @example
  9366. * $(document).ready( function() {
  9367. * $('#example').dataTable( {
  9368. * "language": {
  9369. * "info": "Showing page _PAGE_ of _PAGES_"
  9370. * }
  9371. * } );
  9372. * } );
  9373. */
  9374. "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
  9375. /**
  9376. * Display information string for when the table is empty. Typically the
  9377. * format of this string should match `info`.
  9378. * @type string
  9379. * @default Showing 0 to 0 of 0 entries
  9380. *
  9381. * @dtopt Language
  9382. * @name DataTable.defaults.language.infoEmpty
  9383. *
  9384. * @example
  9385. * $(document).ready( function() {
  9386. * $('#example').dataTable( {
  9387. * "language": {
  9388. * "infoEmpty": "No entries to show"
  9389. * }
  9390. * } );
  9391. * } );
  9392. */
  9393. "sInfoEmpty": "Showing 0 to 0 of 0 entries",
  9394. /**
  9395. * When a user filters the information in a table, this string is appended
  9396. * to the information (`info`) to give an idea of how strong the filtering
  9397. * is. The variable _MAX_ is dynamically updated.
  9398. * @type string
  9399. * @default (filtered from _MAX_ total entries)
  9400. *
  9401. * @dtopt Language
  9402. * @name DataTable.defaults.language.infoFiltered
  9403. *
  9404. * @example
  9405. * $(document).ready( function() {
  9406. * $('#example').dataTable( {
  9407. * "language": {
  9408. * "infoFiltered": " - filtering from _MAX_ records"
  9409. * }
  9410. * } );
  9411. * } );
  9412. */
  9413. "sInfoFiltered": "(filtered from _MAX_ total entries)",
  9414. /**
  9415. * If can be useful to append extra information to the info string at times,
  9416. * and this variable does exactly that. This information will be appended to
  9417. * the `info` (`infoEmpty` and `infoFiltered` in whatever combination they are
  9418. * being used) at all times.
  9419. * @type string
  9420. * @default <i>Empty string</i>
  9421. *
  9422. * @dtopt Language
  9423. * @name DataTable.defaults.language.infoPostFix
  9424. *
  9425. * @example
  9426. * $(document).ready( function() {
  9427. * $('#example').dataTable( {
  9428. * "language": {
  9429. * "infoPostFix": "All records shown are derived from real information."
  9430. * }
  9431. * } );
  9432. * } );
  9433. */
  9434. "sInfoPostFix": "",
  9435. /**
  9436. * This decimal place operator is a little different from the other
  9437. * language options since DataTables doesn't output floating point
  9438. * numbers, so it won't ever use this for display of a number. Rather,
  9439. * what this parameter does is modify the sort methods of the table so
  9440. * that numbers which are in a format which has a character other than
  9441. * a period (`.`) as a decimal place will be sorted numerically.
  9442. *
  9443. * Note that numbers with different decimal places cannot be shown in
  9444. * the same table and still be sortable, the table must be consistent.
  9445. * However, multiple different tables on the page can use different
  9446. * decimal place characters.
  9447. * @type string
  9448. * @default
  9449. *
  9450. * @dtopt Language
  9451. * @name DataTable.defaults.language.decimal
  9452. *
  9453. * @example
  9454. * $(document).ready( function() {
  9455. * $('#example').dataTable( {
  9456. * "language": {
  9457. * "decimal": ","
  9458. * "thousands": "."
  9459. * }
  9460. * } );
  9461. * } );
  9462. */
  9463. "sDecimal": "",
  9464. /**
  9465. * DataTables has a build in number formatter (`formatNumber`) which is
  9466. * used to format large numbers that are used in the table information.
  9467. * By default a comma is used, but this can be trivially changed to any
  9468. * character you wish with this parameter.
  9469. * @type string
  9470. * @default ,
  9471. *
  9472. * @dtopt Language
  9473. * @name DataTable.defaults.language.thousands
  9474. *
  9475. * @example
  9476. * $(document).ready( function() {
  9477. * $('#example').dataTable( {
  9478. * "language": {
  9479. * "thousands": "'"
  9480. * }
  9481. * } );
  9482. * } );
  9483. */
  9484. "sThousands": ",",
  9485. /**
  9486. * Detail the action that will be taken when the drop down menu for the
  9487. * pagination length option is changed. The '_MENU_' variable is replaced
  9488. * with a default select list of 10, 25, 50 and 100, and can be replaced
  9489. * with a custom select box if required.
  9490. * @type string
  9491. * @default Show _MENU_ entries
  9492. *
  9493. * @dtopt Language
  9494. * @name DataTable.defaults.language.lengthMenu
  9495. *
  9496. * @example
  9497. * // Language change only
  9498. * $(document).ready( function() {
  9499. * $('#example').dataTable( {
  9500. * "language": {
  9501. * "lengthMenu": "Display _MENU_ records"
  9502. * }
  9503. * } );
  9504. * } );
  9505. *
  9506. * @example
  9507. * // Language and options change
  9508. * $(document).ready( function() {
  9509. * $('#example').dataTable( {
  9510. * "language": {
  9511. * "lengthMenu": 'Display <select>'+
  9512. * '<option value="10">10</option>'+
  9513. * '<option value="20">20</option>'+
  9514. * '<option value="30">30</option>'+
  9515. * '<option value="40">40</option>'+
  9516. * '<option value="50">50</option>'+
  9517. * '<option value="-1">All</option>'+
  9518. * '</select> records'
  9519. * }
  9520. * } );
  9521. * } );
  9522. */
  9523. "sLengthMenu": "Show _MENU_ entries",
  9524. /**
  9525. * When using Ajax sourced data and during the first draw when DataTables is
  9526. * gathering the data, this message is shown in an empty row in the table to
  9527. * indicate to the end user the the data is being loaded. Note that this
  9528. * parameter is not used when loading data by server-side processing, just
  9529. * Ajax sourced data with client-side processing.
  9530. * @type string
  9531. * @default Loading...
  9532. *
  9533. * @dtopt Language
  9534. * @name DataTable.defaults.language.loadingRecords
  9535. *
  9536. * @example
  9537. * $(document).ready( function() {
  9538. * $('#example').dataTable( {
  9539. * "language": {
  9540. * "loadingRecords": "Please wait - loading..."
  9541. * }
  9542. * } );
  9543. * } );
  9544. */
  9545. "sLoadingRecords": "Loading...",
  9546. /**
  9547. * Text which is displayed when the table is processing a user action
  9548. * (usually a sort command or similar).
  9549. * @type string
  9550. * @default Processing...
  9551. *
  9552. * @dtopt Language
  9553. * @name DataTable.defaults.language.processing
  9554. *
  9555. * @example
  9556. * $(document).ready( function() {
  9557. * $('#example').dataTable( {
  9558. * "language": {
  9559. * "processing": "DataTables is currently busy"
  9560. * }
  9561. * } );
  9562. * } );
  9563. */
  9564. "sProcessing": "Processing...",
  9565. /**
  9566. * Details the actions that will be taken when the user types into the
  9567. * filtering input text box. The variable "_INPUT_", if used in the string,
  9568. * is replaced with the HTML text box for the filtering input allowing
  9569. * control over where it appears in the string. If "_INPUT_" is not given
  9570. * then the input box is appended to the string automatically.
  9571. * @type string
  9572. * @default Search:
  9573. *
  9574. * @dtopt Language
  9575. * @name DataTable.defaults.language.search
  9576. *
  9577. * @example
  9578. * // Input text box will be appended at the end automatically
  9579. * $(document).ready( function() {
  9580. * $('#example').dataTable( {
  9581. * "language": {
  9582. * "search": "Filter records:"
  9583. * }
  9584. * } );
  9585. * } );
  9586. *
  9587. * @example
  9588. * // Specify where the filter should appear
  9589. * $(document).ready( function() {
  9590. * $('#example').dataTable( {
  9591. * "language": {
  9592. * "search": "Apply filter _INPUT_ to table"
  9593. * }
  9594. * } );
  9595. * } );
  9596. */
  9597. "sSearch": "Search:",
  9598. /**
  9599. * Assign a `placeholder` attribute to the search `input` element
  9600. * @type string
  9601. * @default
  9602. *
  9603. * @dtopt Language
  9604. * @name DataTable.defaults.language.searchPlaceholder
  9605. */
  9606. "sSearchPlaceholder": "",
  9607. /**
  9608. * All of the language information can be stored in a file on the
  9609. * server-side, which DataTables will look up if this parameter is passed.
  9610. * It must store the URL of the language file, which is in a JSON format,
  9611. * and the object has the same properties as the oLanguage object in the
  9612. * initialiser object (i.e. the above parameters). Please refer to one of
  9613. * the example language files to see how this works in action.
  9614. * @type string
  9615. * @default <i>Empty string - i.e. disabled</i>
  9616. *
  9617. * @dtopt Language
  9618. * @name DataTable.defaults.language.url
  9619. *
  9620. * @example
  9621. * $(document).ready( function() {
  9622. * $('#example').dataTable( {
  9623. * "language": {
  9624. * "url": "http://www.sprymedia.co.uk/dataTables/lang.txt"
  9625. * }
  9626. * } );
  9627. * } );
  9628. */
  9629. "sUrl": "",
  9630. /**
  9631. * Text shown inside the table records when the is no information to be
  9632. * displayed after filtering. `emptyTable` is shown when there is simply no
  9633. * information in the table at all (regardless of filtering).
  9634. * @type string
  9635. * @default No matching records found
  9636. *
  9637. * @dtopt Language
  9638. * @name DataTable.defaults.language.zeroRecords
  9639. *
  9640. * @example
  9641. * $(document).ready( function() {
  9642. * $('#example').dataTable( {
  9643. * "language": {
  9644. * "zeroRecords": "No records to display"
  9645. * }
  9646. * } );
  9647. * } );
  9648. */
  9649. "sZeroRecords": "No matching records found"
  9650. },
  9651. /**
  9652. * This parameter allows you to have define the global filtering state at
  9653. * initialisation time. As an object the `search` parameter must be
  9654. * defined, but all other parameters are optional. When `regex` is true,
  9655. * the search string will be treated as a regular expression, when false
  9656. * (default) it will be treated as a straight string. When `smart`
  9657. * DataTables will use it's smart filtering methods (to word match at
  9658. * any point in the data), when false this will not be done.
  9659. * @namespace
  9660. * @extends DataTable.models.oSearch
  9661. *
  9662. * @dtopt Options
  9663. * @name DataTable.defaults.search
  9664. *
  9665. * @example
  9666. * $(document).ready( function() {
  9667. * $('#example').dataTable( {
  9668. * "search": {"search": "Initial search"}
  9669. * } );
  9670. * } )
  9671. */
  9672. "oSearch": $.extend( {}, DataTable.models.oSearch ),
  9673. /**
  9674. * __Deprecated__ The functionality provided by this parameter has now been
  9675. * superseded by that provided through `ajax`, which should be used instead.
  9676. *
  9677. * By default DataTables will look for the property `data` (or `aaData` for
  9678. * compatibility with DataTables 1.9-) when obtaining data from an Ajax
  9679. * source or for server-side processing - this parameter allows that
  9680. * property to be changed. You can use Javascript dotted object notation to
  9681. * get a data source for multiple levels of nesting.
  9682. * @type string
  9683. * @default data
  9684. *
  9685. * @dtopt Options
  9686. * @dtopt Server-side
  9687. * @name DataTable.defaults.ajaxDataProp
  9688. *
  9689. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9690. */
  9691. "sAjaxDataProp": "data",
  9692. /**
  9693. * __Deprecated__ The functionality provided by this parameter has now been
  9694. * superseded by that provided through `ajax`, which should be used instead.
  9695. *
  9696. * You can instruct DataTables to load data from an external
  9697. * source using this parameter (use aData if you want to pass data in you
  9698. * already have). Simply provide a url a JSON object can be obtained from.
  9699. * @type string
  9700. * @default null
  9701. *
  9702. * @dtopt Options
  9703. * @dtopt Server-side
  9704. * @name DataTable.defaults.ajaxSource
  9705. *
  9706. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9707. */
  9708. "sAjaxSource": null,
  9709. /**
  9710. * This initialisation variable allows you to specify exactly where in the
  9711. * DOM you want DataTables to inject the various controls it adds to the page
  9712. * (for example you might want the pagination controls at the top of the
  9713. * table). DIV elements (with or without a custom class) can also be added to
  9714. * aid styling. The follow syntax is used:
  9715. * <ul>
  9716. * <li>The following options are allowed:
  9717. * <ul>
  9718. * <li>'l' - Length changing</li>
  9719. * <li>'f' - Filtering input</li>
  9720. * <li>'t' - The table!</li>
  9721. * <li>'i' - Information</li>
  9722. * <li>'p' - Pagination</li>
  9723. * <li>'r' - pRocessing</li>
  9724. * </ul>
  9725. * </li>
  9726. * <li>The following constants are allowed:
  9727. * <ul>
  9728. * <li>'H' - jQueryUI theme "header" classes ('fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix')</li>
  9729. * <li>'F' - jQueryUI theme "footer" classes ('fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix')</li>
  9730. * </ul>
  9731. * </li>
  9732. * <li>The following syntax is expected:
  9733. * <ul>
  9734. * <li>'&lt;' and '&gt;' - div elements</li>
  9735. * <li>'&lt;"class" and '&gt;' - div with a class</li>
  9736. * <li>'&lt;"#id" and '&gt;' - div with an ID</li>
  9737. * </ul>
  9738. * </li>
  9739. * <li>Examples:
  9740. * <ul>
  9741. * <li>'&lt;"wrapper"flipt&gt;'</li>
  9742. * <li>'&lt;lf&lt;t&gt;ip&gt;'</li>
  9743. * </ul>
  9744. * </li>
  9745. * </ul>
  9746. * @type string
  9747. * @default lfrtip <i>(when `jQueryUI` is false)</i> <b>or</b>
  9748. * <"H"lfr>t<"F"ip> <i>(when `jQueryUI` is true)</i>
  9749. *
  9750. * @dtopt Options
  9751. * @name DataTable.defaults.dom
  9752. *
  9753. * @example
  9754. * $(document).ready( function() {
  9755. * $('#example').dataTable( {
  9756. * "dom": '&lt;"top"i&gt;rt&lt;"bottom"flp&gt;&lt;"clear"&gt;'
  9757. * } );
  9758. * } );
  9759. */
  9760. "sDom": "lfrtip",
  9761. /**
  9762. * DataTables features four different built-in options for the buttons to
  9763. * display for pagination control:
  9764. *
  9765. * * `simple` - 'Previous' and 'Next' buttons only
  9766. * * 'simple_numbers` - 'Previous' and 'Next' buttons, plus page numbers
  9767. * * `full` - 'First', 'Previous', 'Next' and 'Last' buttons
  9768. * * `full_numbers` - 'First', 'Previous', 'Next' and 'Last' buttons, plus
  9769. * page numbers
  9770. *
  9771. * Further methods can be added using {@link DataTable.ext.oPagination}.
  9772. * @type string
  9773. * @default simple_numbers
  9774. *
  9775. * @dtopt Options
  9776. * @name DataTable.defaults.pagingType
  9777. *
  9778. * @example
  9779. * $(document).ready( function() {
  9780. * $('#example').dataTable( {
  9781. * "pagingType": "full_numbers"
  9782. * } );
  9783. * } )
  9784. */
  9785. "sPaginationType": "simple_numbers",
  9786. /**
  9787. * Enable horizontal scrolling. When a table is too wide to fit into a
  9788. * certain layout, or you have a large number of columns in the table, you
  9789. * can enable x-scrolling to show the table in a viewport, which can be
  9790. * scrolled. This property can be `true` which will allow the table to
  9791. * scroll horizontally when needed, or any CSS unit, or a number (in which
  9792. * case it will be treated as a pixel measurement). Setting as simply `true`
  9793. * is recommended.
  9794. * @type boolean|string
  9795. * @default <i>blank string - i.e. disabled</i>
  9796. *
  9797. * @dtopt Features
  9798. * @name DataTable.defaults.scrollX
  9799. *
  9800. * @example
  9801. * $(document).ready( function() {
  9802. * $('#example').dataTable( {
  9803. * "scrollX": true,
  9804. * "scrollCollapse": true
  9805. * } );
  9806. * } );
  9807. */
  9808. "sScrollX": "",
  9809. /**
  9810. * This property can be used to force a DataTable to use more width than it
  9811. * might otherwise do when x-scrolling is enabled. For example if you have a
  9812. * table which requires to be well spaced, this parameter is useful for
  9813. * "over-sizing" the table, and thus forcing scrolling. This property can by
  9814. * any CSS unit, or a number (in which case it will be treated as a pixel
  9815. * measurement).
  9816. * @type string
  9817. * @default <i>blank string - i.e. disabled</i>
  9818. *
  9819. * @dtopt Options
  9820. * @name DataTable.defaults.scrollXInner
  9821. *
  9822. * @example
  9823. * $(document).ready( function() {
  9824. * $('#example').dataTable( {
  9825. * "scrollX": "100%",
  9826. * "scrollXInner": "110%"
  9827. * } );
  9828. * } );
  9829. */
  9830. "sScrollXInner": "",
  9831. /**
  9832. * Enable vertical scrolling. Vertical scrolling will constrain the DataTable
  9833. * to the given height, and enable scrolling for any data which overflows the
  9834. * current viewport. This can be used as an alternative to paging to display
  9835. * a lot of data in a small area (although paging and scrolling can both be
  9836. * enabled at the same time). This property can be any CSS unit, or a number
  9837. * (in which case it will be treated as a pixel measurement).
  9838. * @type string
  9839. * @default <i>blank string - i.e. disabled</i>
  9840. *
  9841. * @dtopt Features
  9842. * @name DataTable.defaults.scrollY
  9843. *
  9844. * @example
  9845. * $(document).ready( function() {
  9846. * $('#example').dataTable( {
  9847. * "scrollY": "200px",
  9848. * "paginate": false
  9849. * } );
  9850. * } );
  9851. */
  9852. "sScrollY": "",
  9853. /**
  9854. * __Deprecated__ The functionality provided by this parameter has now been
  9855. * superseded by that provided through `ajax`, which should be used instead.
  9856. *
  9857. * Set the HTTP method that is used to make the Ajax call for server-side
  9858. * processing or Ajax sourced data.
  9859. * @type string
  9860. * @default GET
  9861. *
  9862. * @dtopt Options
  9863. * @dtopt Server-side
  9864. * @name DataTable.defaults.serverMethod
  9865. *
  9866. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9867. */
  9868. "sServerMethod": "GET",
  9869. /**
  9870. * DataTables makes use of renderers when displaying HTML elements for
  9871. * a table. These renderers can be added or modified by plug-ins to
  9872. * generate suitable mark-up for a site. For example the Bootstrap
  9873. * integration plug-in for DataTables uses a paging button renderer to
  9874. * display pagination buttons in the mark-up required by Bootstrap.
  9875. *
  9876. * For further information about the renderers available see
  9877. * DataTable.ext.renderer
  9878. * @type string|object
  9879. * @default null
  9880. *
  9881. * @name DataTable.defaults.renderer
  9882. *
  9883. */
  9884. "renderer": null
  9885. };
  9886. _fnHungarianMap( DataTable.defaults );
  9887. /*
  9888. * Developer note - See note in model.defaults.js about the use of Hungarian
  9889. * notation and camel case.
  9890. */
  9891. /**
  9892. * Column options that can be given to DataTables at initialisation time.
  9893. * @namespace
  9894. */
  9895. DataTable.defaults.column = {
  9896. /**
  9897. * Define which column(s) an order will occur on for this column. This
  9898. * allows a column's ordering to take multiple columns into account when
  9899. * doing a sort or use the data from a different column. For example first
  9900. * name / last name columns make sense to do a multi-column sort over the
  9901. * two columns.
  9902. * @type array|int
  9903. * @default null <i>Takes the value of the column index automatically</i>
  9904. *
  9905. * @name DataTable.defaults.column.orderData
  9906. * @dtopt Columns
  9907. *
  9908. * @example
  9909. * // Using `columnDefs`
  9910. * $(document).ready( function() {
  9911. * $('#example').dataTable( {
  9912. * "columnDefs": [
  9913. * { "orderData": [ 0, 1 ], "targets": [ 0 ] },
  9914. * { "orderData": [ 1, 0 ], "targets": [ 1 ] },
  9915. * { "orderData": 2, "targets": [ 2 ] }
  9916. * ]
  9917. * } );
  9918. * } );
  9919. *
  9920. * @example
  9921. * // Using `columns`
  9922. * $(document).ready( function() {
  9923. * $('#example').dataTable( {
  9924. * "columns": [
  9925. * { "orderData": [ 0, 1 ] },
  9926. * { "orderData": [ 1, 0 ] },
  9927. * { "orderData": 2 },
  9928. * null,
  9929. * null
  9930. * ]
  9931. * } );
  9932. * } );
  9933. */
  9934. "aDataSort": null,
  9935. "iDataSort": -1,
  9936. /**
  9937. * You can control the default ordering direction, and even alter the
  9938. * behaviour of the sort handler (i.e. only allow ascending ordering etc)
  9939. * using this parameter.
  9940. * @type array
  9941. * @default [ 'asc', 'desc' ]
  9942. *
  9943. * @name DataTable.defaults.column.orderSequence
  9944. * @dtopt Columns
  9945. *
  9946. * @example
  9947. * // Using `columnDefs`
  9948. * $(document).ready( function() {
  9949. * $('#example').dataTable( {
  9950. * "columnDefs": [
  9951. * { "orderSequence": [ "asc" ], "targets": [ 1 ] },
  9952. * { "orderSequence": [ "desc", "asc", "asc" ], "targets": [ 2 ] },
  9953. * { "orderSequence": [ "desc" ], "targets": [ 3 ] }
  9954. * ]
  9955. * } );
  9956. * } );
  9957. *
  9958. * @example
  9959. * // Using `columns`
  9960. * $(document).ready( function() {
  9961. * $('#example').dataTable( {
  9962. * "columns": [
  9963. * null,
  9964. * { "orderSequence": [ "asc" ] },
  9965. * { "orderSequence": [ "desc", "asc", "asc" ] },
  9966. * { "orderSequence": [ "desc" ] },
  9967. * null
  9968. * ]
  9969. * } );
  9970. * } );
  9971. */
  9972. "asSorting": [ 'asc', 'desc' ],
  9973. /**
  9974. * Enable or disable filtering on the data in this column.
  9975. * @type boolean
  9976. * @default true
  9977. *
  9978. * @name DataTable.defaults.column.searchable
  9979. * @dtopt Columns
  9980. *
  9981. * @example
  9982. * // Using `columnDefs`
  9983. * $(document).ready( function() {
  9984. * $('#example').dataTable( {
  9985. * "columnDefs": [
  9986. * { "searchable": false, "targets": [ 0 ] }
  9987. * ] } );
  9988. * } );
  9989. *
  9990. * @example
  9991. * // Using `columns`
  9992. * $(document).ready( function() {
  9993. * $('#example').dataTable( {
  9994. * "columns": [
  9995. * { "searchable": false },
  9996. * null,
  9997. * null,
  9998. * null,
  9999. * null
  10000. * ] } );
  10001. * } );
  10002. */
  10003. "bSearchable": true,
  10004. /**
  10005. * Enable or disable ordering on this column.
  10006. * @type boolean
  10007. * @default true
  10008. *
  10009. * @name DataTable.defaults.column.orderable
  10010. * @dtopt Columns
  10011. *
  10012. * @example
  10013. * // Using `columnDefs`
  10014. * $(document).ready( function() {
  10015. * $('#example').dataTable( {
  10016. * "columnDefs": [
  10017. * { "orderable": false, "targets": [ 0 ] }
  10018. * ] } );
  10019. * } );
  10020. *
  10021. * @example
  10022. * // Using `columns`
  10023. * $(document).ready( function() {
  10024. * $('#example').dataTable( {
  10025. * "columns": [
  10026. * { "orderable": false },
  10027. * null,
  10028. * null,
  10029. * null,
  10030. * null
  10031. * ] } );
  10032. * } );
  10033. */
  10034. "bSortable": true,
  10035. /**
  10036. * Enable or disable the display of this column.
  10037. * @type boolean
  10038. * @default true
  10039. *
  10040. * @name DataTable.defaults.column.visible
  10041. * @dtopt Columns
  10042. *
  10043. * @example
  10044. * // Using `columnDefs`
  10045. * $(document).ready( function() {
  10046. * $('#example').dataTable( {
  10047. * "columnDefs": [
  10048. * { "visible": false, "targets": [ 0 ] }
  10049. * ] } );
  10050. * } );
  10051. *
  10052. * @example
  10053. * // Using `columns`
  10054. * $(document).ready( function() {
  10055. * $('#example').dataTable( {
  10056. * "columns": [
  10057. * { "visible": false },
  10058. * null,
  10059. * null,
  10060. * null,
  10061. * null
  10062. * ] } );
  10063. * } );
  10064. */
  10065. "bVisible": true,
  10066. /**
  10067. * Developer definable function that is called whenever a cell is created (Ajax source,
  10068. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  10069. * allowing you to modify the DOM element (add background colour for example) when the
  10070. * element is available.
  10071. * @type function
  10072. * @param {element} td The TD node that has been created
  10073. * @param {*} cellData The Data for the cell
  10074. * @param {array|object} rowData The data for the whole row
  10075. * @param {int} row The row index for the aoData data store
  10076. * @param {int} col The column index for aoColumns
  10077. *
  10078. * @name DataTable.defaults.column.createdCell
  10079. * @dtopt Columns
  10080. *
  10081. * @example
  10082. * $(document).ready( function() {
  10083. * $('#example').dataTable( {
  10084. * "columnDefs": [ {
  10085. * "targets": [3],
  10086. * "createdCell": function (td, cellData, rowData, row, col) {
  10087. * if ( cellData == "1.7" ) {
  10088. * $(td).css('color', 'blue')
  10089. * }
  10090. * }
  10091. * } ]
  10092. * });
  10093. * } );
  10094. */
  10095. "fnCreatedCell": null,
  10096. /**
  10097. * This parameter has been replaced by `data` in DataTables to ensure naming
  10098. * consistency. `dataProp` can still be used, as there is backwards
  10099. * compatibility in DataTables for this option, but it is strongly
  10100. * recommended that you use `data` in preference to `dataProp`.
  10101. * @name DataTable.defaults.column.dataProp
  10102. */
  10103. /**
  10104. * This property can be used to read data from any data source property,
  10105. * including deeply nested objects / properties. `data` can be given in a
  10106. * number of different ways which effect its behaviour:
  10107. *
  10108. * * `integer` - treated as an array index for the data source. This is the
  10109. * default that DataTables uses (incrementally increased for each column).
  10110. * * `string` - read an object property from the data source. There are
  10111. * three 'special' options that can be used in the string to alter how
  10112. * DataTables reads the data from the source object:
  10113. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10114. * Javascript to read from nested objects, so to can the options
  10115. * specified in `data`. For example: `browser.version` or
  10116. * `browser.name`. If your object parameter name contains a period, use
  10117. * `\\` to escape it - i.e. `first\\.name`.
  10118. * * `[]` - Array notation. DataTables can automatically combine data
  10119. * from and array source, joining the data with the characters provided
  10120. * between the two brackets. For example: `name[, ]` would provide a
  10121. * comma-space separated list from the source array. If no characters
  10122. * are provided between the brackets, the original array source is
  10123. * returned.
  10124. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10125. * execute a function of the name given. For example: `browser()` for a
  10126. * simple function on the data source, `browser.version()` for a
  10127. * function in a nested property or even `browser().version` to get an
  10128. * object property if the function called returns an object. Note that
  10129. * function notation is recommended for use in `render` rather than
  10130. * `data` as it is much simpler to use as a renderer.
  10131. * * `null` - use the original data source for the row rather than plucking
  10132. * data directly from it. This action has effects on two other
  10133. * initialisation options:
  10134. * * `defaultContent` - When null is given as the `data` option and
  10135. * `defaultContent` is specified for the column, the value defined by
  10136. * `defaultContent` will be used for the cell.
  10137. * * `render` - When null is used for the `data` option and the `render`
  10138. * option is specified for the column, the whole data source for the
  10139. * row is used for the renderer.
  10140. * * `function` - the function given will be executed whenever DataTables
  10141. * needs to set or get the data for a cell in the column. The function
  10142. * takes three parameters:
  10143. * * Parameters:
  10144. * * `{array|object}` The data source for the row
  10145. * * `{string}` The type call data requested - this will be 'set' when
  10146. * setting data or 'filter', 'display', 'type', 'sort' or undefined
  10147. * when gathering data. Note that when `undefined` is given for the
  10148. * type DataTables expects to get the raw data for the object back<
  10149. * * `{*}` Data to set when the second parameter is 'set'.
  10150. * * Return:
  10151. * * The return value from the function is not required when 'set' is
  10152. * the type of call, but otherwise the return is what will be used
  10153. * for the data requested.
  10154. *
  10155. * Note that `data` is a getter and setter option. If you just require
  10156. * formatting of data for output, you will likely want to use `render` which
  10157. * is simply a getter and thus simpler to use.
  10158. *
  10159. * Note that prior to DataTables 1.9.2 `data` was called `mDataProp`. The
  10160. * name change reflects the flexibility of this property and is consistent
  10161. * with the naming of mRender. If 'mDataProp' is given, then it will still
  10162. * be used by DataTables, as it automatically maps the old name to the new
  10163. * if required.
  10164. *
  10165. * @type string|int|function|null
  10166. * @default null <i>Use automatically calculated column index</i>
  10167. *
  10168. * @name DataTable.defaults.column.data
  10169. * @dtopt Columns
  10170. *
  10171. * @example
  10172. * // Read table data from objects
  10173. * // JSON structure for each row:
  10174. * // {
  10175. * // "engine": {value},
  10176. * // "browser": {value},
  10177. * // "platform": {value},
  10178. * // "version": {value},
  10179. * // "grade": {value}
  10180. * // }
  10181. * $(document).ready( function() {
  10182. * $('#example').dataTable( {
  10183. * "ajaxSource": "sources/objects.txt",
  10184. * "columns": [
  10185. * { "data": "engine" },
  10186. * { "data": "browser" },
  10187. * { "data": "platform" },
  10188. * { "data": "version" },
  10189. * { "data": "grade" }
  10190. * ]
  10191. * } );
  10192. * } );
  10193. *
  10194. * @example
  10195. * // Read information from deeply nested objects
  10196. * // JSON structure for each row:
  10197. * // {
  10198. * // "engine": {value},
  10199. * // "browser": {value},
  10200. * // "platform": {
  10201. * // "inner": {value}
  10202. * // },
  10203. * // "details": [
  10204. * // {value}, {value}
  10205. * // ]
  10206. * // }
  10207. * $(document).ready( function() {
  10208. * $('#example').dataTable( {
  10209. * "ajaxSource": "sources/deep.txt",
  10210. * "columns": [
  10211. * { "data": "engine" },
  10212. * { "data": "browser" },
  10213. * { "data": "platform.inner" },
  10214. * { "data": "platform.details.0" },
  10215. * { "data": "platform.details.1" }
  10216. * ]
  10217. * } );
  10218. * } );
  10219. *
  10220. * @example
  10221. * // Using `data` as a function to provide different information for
  10222. * // sorting, filtering and display. In this case, currency (price)
  10223. * $(document).ready( function() {
  10224. * $('#example').dataTable( {
  10225. * "columnDefs": [ {
  10226. * "targets": [ 0 ],
  10227. * "data": function ( source, type, val ) {
  10228. * if (type === 'set') {
  10229. * source.price = val;
  10230. * // Store the computed dislay and filter values for efficiency
  10231. * source.price_display = val=="" ? "" : "$"+numberFormat(val);
  10232. * source.price_filter = val=="" ? "" : "$"+numberFormat(val)+" "+val;
  10233. * return;
  10234. * }
  10235. * else if (type === 'display') {
  10236. * return source.price_display;
  10237. * }
  10238. * else if (type === 'filter') {
  10239. * return source.price_filter;
  10240. * }
  10241. * // 'sort', 'type' and undefined all just use the integer
  10242. * return source.price;
  10243. * }
  10244. * } ]
  10245. * } );
  10246. * } );
  10247. *
  10248. * @example
  10249. * // Using default content
  10250. * $(document).ready( function() {
  10251. * $('#example').dataTable( {
  10252. * "columnDefs": [ {
  10253. * "targets": [ 0 ],
  10254. * "data": null,
  10255. * "defaultContent": "Click to edit"
  10256. * } ]
  10257. * } );
  10258. * } );
  10259. *
  10260. * @example
  10261. * // Using array notation - outputting a list from an array
  10262. * $(document).ready( function() {
  10263. * $('#example').dataTable( {
  10264. * "columnDefs": [ {
  10265. * "targets": [ 0 ],
  10266. * "data": "name[, ]"
  10267. * } ]
  10268. * } );
  10269. * } );
  10270. *
  10271. */
  10272. "mData": null,
  10273. /**
  10274. * This property is the rendering partner to `data` and it is suggested that
  10275. * when you want to manipulate data for display (including filtering,
  10276. * sorting etc) without altering the underlying data for the table, use this
  10277. * property. `render` can be considered to be the the read only companion to
  10278. * `data` which is read / write (then as such more complex). Like `data`
  10279. * this option can be given in a number of different ways to effect its
  10280. * behaviour:
  10281. *
  10282. * * `integer` - treated as an array index for the data source. This is the
  10283. * default that DataTables uses (incrementally increased for each column).
  10284. * * `string` - read an object property from the data source. There are
  10285. * three 'special' options that can be used in the string to alter how
  10286. * DataTables reads the data from the source object:
  10287. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10288. * Javascript to read from nested objects, so to can the options
  10289. * specified in `data`. For example: `browser.version` or
  10290. * `browser.name`. If your object parameter name contains a period, use
  10291. * `\\` to escape it - i.e. `first\\.name`.
  10292. * * `[]` - Array notation. DataTables can automatically combine data
  10293. * from and array source, joining the data with the characters provided
  10294. * between the two brackets. For example: `name[, ]` would provide a
  10295. * comma-space separated list from the source array. If no characters
  10296. * are provided between the brackets, the original array source is
  10297. * returned.
  10298. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10299. * execute a function of the name given. For example: `browser()` for a
  10300. * simple function on the data source, `browser.version()` for a
  10301. * function in a nested property or even `browser().version` to get an
  10302. * object property if the function called returns an object.
  10303. * * `object` - use different data for the different data types requested by
  10304. * DataTables ('filter', 'display', 'type' or 'sort'). The property names
  10305. * of the object is the data type the property refers to and the value can
  10306. * defined using an integer, string or function using the same rules as
  10307. * `render` normally does. Note that an `_` option _must_ be specified.
  10308. * This is the default value to use if you haven't specified a value for
  10309. * the data type requested by DataTables.
  10310. * * `function` - the function given will be executed whenever DataTables
  10311. * needs to set or get the data for a cell in the column. The function
  10312. * takes three parameters:
  10313. * * Parameters:
  10314. * * {array|object} The data source for the row (based on `data`)
  10315. * * {string} The type call data requested - this will be 'filter',
  10316. * 'display', 'type' or 'sort'.
  10317. * * {array|object} The full data source for the row (not based on
  10318. * `data`)
  10319. * * Return:
  10320. * * The return value from the function is what will be used for the
  10321. * data requested.
  10322. *
  10323. * @type string|int|function|object|null
  10324. * @default null Use the data source value.
  10325. *
  10326. * @name DataTable.defaults.column.render
  10327. * @dtopt Columns
  10328. *
  10329. * @example
  10330. * // Create a comma separated list from an array of objects
  10331. * $(document).ready( function() {
  10332. * $('#example').dataTable( {
  10333. * "ajaxSource": "sources/deep.txt",
  10334. * "columns": [
  10335. * { "data": "engine" },
  10336. * { "data": "browser" },
  10337. * {
  10338. * "data": "platform",
  10339. * "render": "[, ].name"
  10340. * }
  10341. * ]
  10342. * } );
  10343. * } );
  10344. *
  10345. * @example
  10346. * // Execute a function to obtain data
  10347. * $(document).ready( function() {
  10348. * $('#example').dataTable( {
  10349. * "columnDefs": [ {
  10350. * "targets": [ 0 ],
  10351. * "data": null, // Use the full data source object for the renderer's source
  10352. * "render": "browserName()"
  10353. * } ]
  10354. * } );
  10355. * } );
  10356. *
  10357. * @example
  10358. * // As an object, extracting different data for the different types
  10359. * // This would be used with a data source such as:
  10360. * // { "phone": 5552368, "phone_filter": "5552368 555-2368", "phone_display": "555-2368" }
  10361. * // Here the `phone` integer is used for sorting and type detection, while `phone_filter`
  10362. * // (which has both forms) is used for filtering for if a user inputs either format, while
  10363. * // the formatted phone number is the one that is shown in the table.
  10364. * $(document).ready( function() {
  10365. * $('#example').dataTable( {
  10366. * "columnDefs": [ {
  10367. * "targets": [ 0 ],
  10368. * "data": null, // Use the full data source object for the renderer's source
  10369. * "render": {
  10370. * "_": "phone",
  10371. * "filter": "phone_filter",
  10372. * "display": "phone_display"
  10373. * }
  10374. * } ]
  10375. * } );
  10376. * } );
  10377. *
  10378. * @example
  10379. * // Use as a function to create a link from the data source
  10380. * $(document).ready( function() {
  10381. * $('#example').dataTable( {
  10382. * "columnDefs": [ {
  10383. * "targets": [ 0 ],
  10384. * "data": "download_link",
  10385. * "render": function ( data, type, full ) {
  10386. * return '<a href="'+data+'">Download</a>';
  10387. * }
  10388. * } ]
  10389. * } );
  10390. * } );
  10391. */
  10392. "mRender": null,
  10393. /**
  10394. * Change the cell type created for the column - either TD cells or TH cells. This
  10395. * can be useful as TH cells have semantic meaning in the table body, allowing them
  10396. * to act as a header for a row (you may wish to add scope='row' to the TH elements).
  10397. * @type string
  10398. * @default td
  10399. *
  10400. * @name DataTable.defaults.column.cellType
  10401. * @dtopt Columns
  10402. *
  10403. * @example
  10404. * // Make the first column use TH cells
  10405. * $(document).ready( function() {
  10406. * $('#example').dataTable( {
  10407. * "columnDefs": [ {
  10408. * "targets": [ 0 ],
  10409. * "cellType": "th"
  10410. * } ]
  10411. * } );
  10412. * } );
  10413. */
  10414. "sCellType": "td",
  10415. /**
  10416. * Class to give to each cell in this column.
  10417. * @type string
  10418. * @default <i>Empty string</i>
  10419. *
  10420. * @name DataTable.defaults.column.class
  10421. * @dtopt Columns
  10422. *
  10423. * @example
  10424. * // Using `columnDefs`
  10425. * $(document).ready( function() {
  10426. * $('#example').dataTable( {
  10427. * "columnDefs": [
  10428. * { "class": "my_class", "targets": [ 0 ] }
  10429. * ]
  10430. * } );
  10431. * } );
  10432. *
  10433. * @example
  10434. * // Using `columns`
  10435. * $(document).ready( function() {
  10436. * $('#example').dataTable( {
  10437. * "columns": [
  10438. * { "class": "my_class" },
  10439. * null,
  10440. * null,
  10441. * null,
  10442. * null
  10443. * ]
  10444. * } );
  10445. * } );
  10446. */
  10447. "sClass": "",
  10448. /**
  10449. * When DataTables calculates the column widths to assign to each column,
  10450. * it finds the longest string in each column and then constructs a
  10451. * temporary table and reads the widths from that. The problem with this
  10452. * is that "mmm" is much wider then "iiii", but the latter is a longer
  10453. * string - thus the calculation can go wrong (doing it properly and putting
  10454. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  10455. * a "work around" we provide this option. It will append its value to the
  10456. * text that is found to be the longest string for the column - i.e. padding.
  10457. * Generally you shouldn't need this!
  10458. * @type string
  10459. * @default <i>Empty string<i>
  10460. *
  10461. * @name DataTable.defaults.column.contentPadding
  10462. * @dtopt Columns
  10463. *
  10464. * @example
  10465. * // Using `columns`
  10466. * $(document).ready( function() {
  10467. * $('#example').dataTable( {
  10468. * "columns": [
  10469. * null,
  10470. * null,
  10471. * null,
  10472. * {
  10473. * "contentPadding": "mmm"
  10474. * }
  10475. * ]
  10476. * } );
  10477. * } );
  10478. */
  10479. "sContentPadding": "",
  10480. /**
  10481. * Allows a default value to be given for a column's data, and will be used
  10482. * whenever a null data source is encountered (this can be because `data`
  10483. * is set to null, or because the data source itself is null).
  10484. * @type string
  10485. * @default null
  10486. *
  10487. * @name DataTable.defaults.column.defaultContent
  10488. * @dtopt Columns
  10489. *
  10490. * @example
  10491. * // Using `columnDefs`
  10492. * $(document).ready( function() {
  10493. * $('#example').dataTable( {
  10494. * "columnDefs": [
  10495. * {
  10496. * "data": null,
  10497. * "defaultContent": "Edit",
  10498. * "targets": [ -1 ]
  10499. * }
  10500. * ]
  10501. * } );
  10502. * } );
  10503. *
  10504. * @example
  10505. * // Using `columns`
  10506. * $(document).ready( function() {
  10507. * $('#example').dataTable( {
  10508. * "columns": [
  10509. * null,
  10510. * null,
  10511. * null,
  10512. * {
  10513. * "data": null,
  10514. * "defaultContent": "Edit"
  10515. * }
  10516. * ]
  10517. * } );
  10518. * } );
  10519. */
  10520. "sDefaultContent": null,
  10521. /**
  10522. * This parameter is only used in DataTables' server-side processing. It can
  10523. * be exceptionally useful to know what columns are being displayed on the
  10524. * client side, and to map these to database fields. When defined, the names
  10525. * also allow DataTables to reorder information from the server if it comes
  10526. * back in an unexpected order (i.e. if you switch your columns around on the
  10527. * client-side, your server-side code does not also need updating).
  10528. * @type string
  10529. * @default <i>Empty string</i>
  10530. *
  10531. * @name DataTable.defaults.column.name
  10532. * @dtopt Columns
  10533. *
  10534. * @example
  10535. * // Using `columnDefs`
  10536. * $(document).ready( function() {
  10537. * $('#example').dataTable( {
  10538. * "columnDefs": [
  10539. * { "name": "engine", "targets": [ 0 ] },
  10540. * { "name": "browser", "targets": [ 1 ] },
  10541. * { "name": "platform", "targets": [ 2 ] },
  10542. * { "name": "version", "targets": [ 3 ] },
  10543. * { "name": "grade", "targets": [ 4 ] }
  10544. * ]
  10545. * } );
  10546. * } );
  10547. *
  10548. * @example
  10549. * // Using `columns`
  10550. * $(document).ready( function() {
  10551. * $('#example').dataTable( {
  10552. * "columns": [
  10553. * { "name": "engine" },
  10554. * { "name": "browser" },
  10555. * { "name": "platform" },
  10556. * { "name": "version" },
  10557. * { "name": "grade" }
  10558. * ]
  10559. * } );
  10560. * } );
  10561. */
  10562. "sName": "",
  10563. /**
  10564. * Defines a data source type for the ordering which can be used to read
  10565. * real-time information from the table (updating the internally cached
  10566. * version) prior to ordering. This allows ordering to occur on user
  10567. * editable elements such as form inputs.
  10568. * @type string
  10569. * @default std
  10570. *
  10571. * @name DataTable.defaults.column.orderDataType
  10572. * @dtopt Columns
  10573. *
  10574. * @example
  10575. * // Using `columnDefs`
  10576. * $(document).ready( function() {
  10577. * $('#example').dataTable( {
  10578. * "columnDefs": [
  10579. * { "orderDataType": "dom-text", "targets": [ 2, 3 ] },
  10580. * { "type": "numeric", "targets": [ 3 ] },
  10581. * { "orderDataType": "dom-select", "targets": [ 4 ] },
  10582. * { "orderDataType": "dom-checkbox", "targets": [ 5 ] }
  10583. * ]
  10584. * } );
  10585. * } );
  10586. *
  10587. * @example
  10588. * // Using `columns`
  10589. * $(document).ready( function() {
  10590. * $('#example').dataTable( {
  10591. * "columns": [
  10592. * null,
  10593. * null,
  10594. * { "orderDataType": "dom-text" },
  10595. * { "orderDataType": "dom-text", "type": "numeric" },
  10596. * { "orderDataType": "dom-select" },
  10597. * { "orderDataType": "dom-checkbox" }
  10598. * ]
  10599. * } );
  10600. * } );
  10601. */
  10602. "sSortDataType": "std",
  10603. /**
  10604. * The title of this column.
  10605. * @type string
  10606. * @default null <i>Derived from the 'TH' value for this column in the
  10607. * original HTML table.</i>
  10608. *
  10609. * @name DataTable.defaults.column.title
  10610. * @dtopt Columns
  10611. *
  10612. * @example
  10613. * // Using `columnDefs`
  10614. * $(document).ready( function() {
  10615. * $('#example').dataTable( {
  10616. * "columnDefs": [
  10617. * { "title": "My column title", "targets": [ 0 ] }
  10618. * ]
  10619. * } );
  10620. * } );
  10621. *
  10622. * @example
  10623. * // Using `columns`
  10624. * $(document).ready( function() {
  10625. * $('#example').dataTable( {
  10626. * "columns": [
  10627. * { "title": "My column title" },
  10628. * null,
  10629. * null,
  10630. * null,
  10631. * null
  10632. * ]
  10633. * } );
  10634. * } );
  10635. */
  10636. "sTitle": null,
  10637. /**
  10638. * The type allows you to specify how the data for this column will be
  10639. * ordered. Four types (string, numeric, date and html (which will strip
  10640. * HTML tags before ordering)) are currently available. Note that only date
  10641. * formats understood by Javascript's Date() object will be accepted as type
  10642. * date. For example: "Mar 26, 2008 5:03 PM". May take the values: 'string',
  10643. * 'numeric', 'date' or 'html' (by default). Further types can be adding
  10644. * through plug-ins.
  10645. * @type string
  10646. * @default null <i>Auto-detected from raw data</i>
  10647. *
  10648. * @name DataTable.defaults.column.type
  10649. * @dtopt Columns
  10650. *
  10651. * @example
  10652. * // Using `columnDefs`
  10653. * $(document).ready( function() {
  10654. * $('#example').dataTable( {
  10655. * "columnDefs": [
  10656. * { "type": "html", "targets": [ 0 ] }
  10657. * ]
  10658. * } );
  10659. * } );
  10660. *
  10661. * @example
  10662. * // Using `columns`
  10663. * $(document).ready( function() {
  10664. * $('#example').dataTable( {
  10665. * "columns": [
  10666. * { "type": "html" },
  10667. * null,
  10668. * null,
  10669. * null,
  10670. * null
  10671. * ]
  10672. * } );
  10673. * } );
  10674. */
  10675. "sType": null,
  10676. /**
  10677. * Defining the width of the column, this parameter may take any CSS value
  10678. * (3em, 20px etc). DataTables applies 'smart' widths to columns which have not
  10679. * been given a specific width through this interface ensuring that the table
  10680. * remains readable.
  10681. * @type string
  10682. * @default null <i>Automatic</i>
  10683. *
  10684. * @name DataTable.defaults.column.width
  10685. * @dtopt Columns
  10686. *
  10687. * @example
  10688. * // Using `columnDefs`
  10689. * $(document).ready( function() {
  10690. * $('#example').dataTable( {
  10691. * "columnDefs": [
  10692. * { "width": "20%", "targets": [ 0 ] }
  10693. * ]
  10694. * } );
  10695. * } );
  10696. *
  10697. * @example
  10698. * // Using `columns`
  10699. * $(document).ready( function() {
  10700. * $('#example').dataTable( {
  10701. * "columns": [
  10702. * { "width": "20%" },
  10703. * null,
  10704. * null,
  10705. * null,
  10706. * null
  10707. * ]
  10708. * } );
  10709. * } );
  10710. */
  10711. "sWidth": null
  10712. };
  10713. _fnHungarianMap( DataTable.defaults.column );
  10714. /**
  10715. * DataTables settings object - this holds all the information needed for a
  10716. * given table, including configuration, data and current application of the
  10717. * table options. DataTables does not have a single instance for each DataTable
  10718. * with the settings attached to that instance, but rather instances of the
  10719. * DataTable "class" are created on-the-fly as needed (typically by a
  10720. * $().dataTable() call) and the settings object is then applied to that
  10721. * instance.
  10722. *
  10723. * Note that this object is related to {@link DataTable.defaults} but this
  10724. * one is the internal data store for DataTables's cache of columns. It should
  10725. * NOT be manipulated outside of DataTables. Any configuration should be done
  10726. * through the initialisation options.
  10727. * @namespace
  10728. * @todo Really should attach the settings object to individual instances so we
  10729. * don't need to create new instances on each $().dataTable() call (if the
  10730. * table already exists). It would also save passing oSettings around and
  10731. * into every single function. However, this is a very significant
  10732. * architecture change for DataTables and will almost certainly break
  10733. * backwards compatibility with older installations. This is something that
  10734. * will be done in 2.0.
  10735. */
  10736. DataTable.models.oSettings = {
  10737. /**
  10738. * Primary features of DataTables and their enablement state.
  10739. * @namespace
  10740. */
  10741. "oFeatures": {
  10742. /**
  10743. * Flag to say if DataTables should automatically try to calculate the
  10744. * optimum table and columns widths (true) or not (false).
  10745. * Note that this parameter will be set by the initialisation routine. To
  10746. * set a default use {@link DataTable.defaults}.
  10747. * @type boolean
  10748. */
  10749. "bAutoWidth": null,
  10750. /**
  10751. * Delay the creation of TR and TD elements until they are actually
  10752. * needed by a driven page draw. This can give a significant speed
  10753. * increase for Ajax source and Javascript source data, but makes no
  10754. * difference at all fro DOM and server-side processing tables.
  10755. * Note that this parameter will be set by the initialisation routine. To
  10756. * set a default use {@link DataTable.defaults}.
  10757. * @type boolean
  10758. */
  10759. "bDeferRender": null,
  10760. /**
  10761. * Enable filtering on the table or not. Note that if this is disabled
  10762. * then there is no filtering at all on the table, including fnFilter.
  10763. * To just remove the filtering input use sDom and remove the 'f' option.
  10764. * Note that this parameter will be set by the initialisation routine. To
  10765. * set a default use {@link DataTable.defaults}.
  10766. * @type boolean
  10767. */
  10768. "bFilter": null,
  10769. /**
  10770. * Table information element (the 'Showing x of y records' div) enable
  10771. * flag.
  10772. * Note that this parameter will be set by the initialisation routine. To
  10773. * set a default use {@link DataTable.defaults}.
  10774. * @type boolean
  10775. */
  10776. "bInfo": null,
  10777. /**
  10778. * Present a user control allowing the end user to change the page size
  10779. * when pagination is enabled.
  10780. * Note that this parameter will be set by the initialisation routine. To
  10781. * set a default use {@link DataTable.defaults}.
  10782. * @type boolean
  10783. */
  10784. "bLengthChange": null,
  10785. /**
  10786. * Pagination enabled or not. Note that if this is disabled then length
  10787. * changing must also be disabled.
  10788. * Note that this parameter will be set by the initialisation routine. To
  10789. * set a default use {@link DataTable.defaults}.
  10790. * @type boolean
  10791. */
  10792. "bPaginate": null,
  10793. /**
  10794. * Processing indicator enable flag whenever DataTables is enacting a
  10795. * user request - typically an Ajax request for server-side processing.
  10796. * Note that this parameter will be set by the initialisation routine. To
  10797. * set a default use {@link DataTable.defaults}.
  10798. * @type boolean
  10799. */
  10800. "bProcessing": null,
  10801. /**
  10802. * Server-side processing enabled flag - when enabled DataTables will
  10803. * get all data from the server for every draw - there is no filtering,
  10804. * sorting or paging done on the client-side.
  10805. * Note that this parameter will be set by the initialisation routine. To
  10806. * set a default use {@link DataTable.defaults}.
  10807. * @type boolean
  10808. */
  10809. "bServerSide": null,
  10810. /**
  10811. * Sorting enablement flag.
  10812. * Note that this parameter will be set by the initialisation routine. To
  10813. * set a default use {@link DataTable.defaults}.
  10814. * @type boolean
  10815. */
  10816. "bSort": null,
  10817. /**
  10818. * Multi-column sorting
  10819. * Note that this parameter will be set by the initialisation routine. To
  10820. * set a default use {@link DataTable.defaults}.
  10821. * @type boolean
  10822. */
  10823. "bSortMulti": null,
  10824. /**
  10825. * Apply a class to the columns which are being sorted to provide a
  10826. * visual highlight or not. This can slow things down when enabled since
  10827. * there is a lot of DOM interaction.
  10828. * Note that this parameter will be set by the initialisation routine. To
  10829. * set a default use {@link DataTable.defaults}.
  10830. * @type boolean
  10831. */
  10832. "bSortClasses": null,
  10833. /**
  10834. * State saving enablement flag.
  10835. * Note that this parameter will be set by the initialisation routine. To
  10836. * set a default use {@link DataTable.defaults}.
  10837. * @type boolean
  10838. */
  10839. "bStateSave": null
  10840. },
  10841. /**
  10842. * Scrolling settings for a table.
  10843. * @namespace
  10844. */
  10845. "oScroll": {
  10846. /**
  10847. * When the table is shorter in height than sScrollY, collapse the
  10848. * table container down to the height of the table (when true).
  10849. * Note that this parameter will be set by the initialisation routine. To
  10850. * set a default use {@link DataTable.defaults}.
  10851. * @type boolean
  10852. */
  10853. "bCollapse": null,
  10854. /**
  10855. * Width of the scrollbar for the web-browser's platform. Calculated
  10856. * during table initialisation.
  10857. * @type int
  10858. * @default 0
  10859. */
  10860. "iBarWidth": 0,
  10861. /**
  10862. * Viewport width for horizontal scrolling. Horizontal scrolling is
  10863. * disabled if an empty string.
  10864. * Note that this parameter will be set by the initialisation routine. To
  10865. * set a default use {@link DataTable.defaults}.
  10866. * @type string
  10867. */
  10868. "sX": null,
  10869. /**
  10870. * Width to expand the table to when using x-scrolling. Typically you
  10871. * should not need to use this.
  10872. * Note that this parameter will be set by the initialisation routine. To
  10873. * set a default use {@link DataTable.defaults}.
  10874. * @type string
  10875. * @deprecated
  10876. */
  10877. "sXInner": null,
  10878. /**
  10879. * Viewport height for vertical scrolling. Vertical scrolling is disabled
  10880. * if an empty string.
  10881. * Note that this parameter will be set by the initialisation routine. To
  10882. * set a default use {@link DataTable.defaults}.
  10883. * @type string
  10884. */
  10885. "sY": null
  10886. },
  10887. /**
  10888. * Language information for the table.
  10889. * @namespace
  10890. * @extends DataTable.defaults.oLanguage
  10891. */
  10892. "oLanguage": {
  10893. /**
  10894. * Information callback function. See
  10895. * {@link DataTable.defaults.fnInfoCallback}
  10896. * @type function
  10897. * @default null
  10898. */
  10899. "fnInfoCallback": null
  10900. },
  10901. /**
  10902. * Browser support parameters
  10903. * @namespace
  10904. */
  10905. "oBrowser": {
  10906. /**
  10907. * Indicate if the browser incorrectly calculates width:100% inside a
  10908. * scrolling element (IE6/7)
  10909. * @type boolean
  10910. * @default false
  10911. */
  10912. "bScrollOversize": false,
  10913. /**
  10914. * Determine if the vertical scrollbar is on the right or left of the
  10915. * scrolling container - needed for rtl language layout, although not
  10916. * all browsers move the scrollbar (Safari).
  10917. * @type boolean
  10918. * @default false
  10919. */
  10920. "bScrollbarLeft": false
  10921. },
  10922. "ajax": null,
  10923. /**
  10924. * Array referencing the nodes which are used for the features. The
  10925. * parameters of this object match what is allowed by sDom - i.e.
  10926. * <ul>
  10927. * <li>'l' - Length changing</li>
  10928. * <li>'f' - Filtering input</li>
  10929. * <li>'t' - The table!</li>
  10930. * <li>'i' - Information</li>
  10931. * <li>'p' - Pagination</li>
  10932. * <li>'r' - pRocessing</li>
  10933. * </ul>
  10934. * @type array
  10935. * @default []
  10936. */
  10937. "aanFeatures": [],
  10938. /**
  10939. * Store data information - see {@link DataTable.models.oRow} for detailed
  10940. * information.
  10941. * @type array
  10942. * @default []
  10943. */
  10944. "aoData": [],
  10945. /**
  10946. * Array of indexes which are in the current display (after filtering etc)
  10947. * @type array
  10948. * @default []
  10949. */
  10950. "aiDisplay": [],
  10951. /**
  10952. * Array of indexes for display - no filtering
  10953. * @type array
  10954. * @default []
  10955. */
  10956. "aiDisplayMaster": [],
  10957. /**
  10958. * Store information about each column that is in use
  10959. * @type array
  10960. * @default []
  10961. */
  10962. "aoColumns": [],
  10963. /**
  10964. * Store information about the table's header
  10965. * @type array
  10966. * @default []
  10967. */
  10968. "aoHeader": [],
  10969. /**
  10970. * Store information about the table's footer
  10971. * @type array
  10972. * @default []
  10973. */
  10974. "aoFooter": [],
  10975. /**
  10976. * Store the applied global search information in case we want to force a
  10977. * research or compare the old search to a new one.
  10978. * Note that this parameter will be set by the initialisation routine. To
  10979. * set a default use {@link DataTable.defaults}.
  10980. * @namespace
  10981. * @extends DataTable.models.oSearch
  10982. */
  10983. "oPreviousSearch": {},
  10984. /**
  10985. * Store the applied search for each column - see
  10986. * {@link DataTable.models.oSearch} for the format that is used for the
  10987. * filtering information for each column.
  10988. * @type array
  10989. * @default []
  10990. */
  10991. "aoPreSearchCols": [],
  10992. /**
  10993. * Sorting that is applied to the table. Note that the inner arrays are
  10994. * used in the following manner:
  10995. * <ul>
  10996. * <li>Index 0 - column number</li>
  10997. * <li>Index 1 - current sorting direction</li>
  10998. * </ul>
  10999. * Note that this parameter will be set by the initialisation routine. To
  11000. * set a default use {@link DataTable.defaults}.
  11001. * @type array
  11002. * @todo These inner arrays should really be objects
  11003. */
  11004. "aaSorting": null,
  11005. /**
  11006. * Sorting that is always applied to the table (i.e. prefixed in front of
  11007. * aaSorting).
  11008. * Note that this parameter will be set by the initialisation routine. To
  11009. * set a default use {@link DataTable.defaults}.
  11010. * @type array
  11011. * @default []
  11012. */
  11013. "aaSortingFixed": [],
  11014. /**
  11015. * Classes to use for the striping of a table.
  11016. * Note that this parameter will be set by the initialisation routine. To
  11017. * set a default use {@link DataTable.defaults}.
  11018. * @type array
  11019. * @default []
  11020. */
  11021. "asStripeClasses": null,
  11022. /**
  11023. * If restoring a table - we should restore its striping classes as well
  11024. * @type array
  11025. * @default []
  11026. */
  11027. "asDestroyStripes": [],
  11028. /**
  11029. * If restoring a table - we should restore its width
  11030. * @type int
  11031. * @default 0
  11032. */
  11033. "sDestroyWidth": 0,
  11034. /**
  11035. * Callback functions array for every time a row is inserted (i.e. on a draw).
  11036. * @type array
  11037. * @default []
  11038. */
  11039. "aoRowCallback": [],
  11040. /**
  11041. * Callback functions for the header on each draw.
  11042. * @type array
  11043. * @default []
  11044. */
  11045. "aoHeaderCallback": [],
  11046. /**
  11047. * Callback function for the footer on each draw.
  11048. * @type array
  11049. * @default []
  11050. */
  11051. "aoFooterCallback": [],
  11052. /**
  11053. * Array of callback functions for draw callback functions
  11054. * @type array
  11055. * @default []
  11056. */
  11057. "aoDrawCallback": [],
  11058. /**
  11059. * Array of callback functions for row created function
  11060. * @type array
  11061. * @default []
  11062. */
  11063. "aoRowCreatedCallback": [],
  11064. /**
  11065. * Callback functions for just before the table is redrawn. A return of
  11066. * false will be used to cancel the draw.
  11067. * @type array
  11068. * @default []
  11069. */
  11070. "aoPreDrawCallback": [],
  11071. /**
  11072. * Callback functions for when the table has been initialised.
  11073. * @type array
  11074. * @default []
  11075. */
  11076. "aoInitComplete": [],
  11077. /**
  11078. * Callbacks for modifying the settings to be stored for state saving, prior to
  11079. * saving state.
  11080. * @type array
  11081. * @default []
  11082. */
  11083. "aoStateSaveParams": [],
  11084. /**
  11085. * Callbacks for modifying the settings that have been stored for state saving
  11086. * prior to using the stored values to restore the state.
  11087. * @type array
  11088. * @default []
  11089. */
  11090. "aoStateLoadParams": [],
  11091. /**
  11092. * Callbacks for operating on the settings object once the saved state has been
  11093. * loaded
  11094. * @type array
  11095. * @default []
  11096. */
  11097. "aoStateLoaded": [],
  11098. /**
  11099. * Cache the table ID for quick access
  11100. * @type string
  11101. * @default <i>Empty string</i>
  11102. */
  11103. "sTableId": "",
  11104. /**
  11105. * The TABLE node for the main table
  11106. * @type node
  11107. * @default null
  11108. */
  11109. "nTable": null,
  11110. /**
  11111. * Permanent ref to the thead element
  11112. * @type node
  11113. * @default null
  11114. */
  11115. "nTHead": null,
  11116. /**
  11117. * Permanent ref to the tfoot element - if it exists
  11118. * @type node
  11119. * @default null
  11120. */
  11121. "nTFoot": null,
  11122. /**
  11123. * Permanent ref to the tbody element
  11124. * @type node
  11125. * @default null
  11126. */
  11127. "nTBody": null,
  11128. /**
  11129. * Cache the wrapper node (contains all DataTables controlled elements)
  11130. * @type node
  11131. * @default null
  11132. */
  11133. "nTableWrapper": null,
  11134. /**
  11135. * Indicate if when using server-side processing the loading of data
  11136. * should be deferred until the second draw.
  11137. * Note that this parameter will be set by the initialisation routine. To
  11138. * set a default use {@link DataTable.defaults}.
  11139. * @type boolean
  11140. * @default false
  11141. */
  11142. "bDeferLoading": false,
  11143. /**
  11144. * Indicate if all required information has been read in
  11145. * @type boolean
  11146. * @default false
  11147. */
  11148. "bInitialised": false,
  11149. /**
  11150. * Information about open rows. Each object in the array has the parameters
  11151. * 'nTr' and 'nParent'
  11152. * @type array
  11153. * @default []
  11154. */
  11155. "aoOpenRows": [],
  11156. /**
  11157. * Dictate the positioning of DataTables' control elements - see
  11158. * {@link DataTable.model.oInit.sDom}.
  11159. * Note that this parameter will be set by the initialisation routine. To
  11160. * set a default use {@link DataTable.defaults}.
  11161. * @type string
  11162. * @default null
  11163. */
  11164. "sDom": null,
  11165. /**
  11166. * Which type of pagination should be used.
  11167. * Note that this parameter will be set by the initialisation routine. To
  11168. * set a default use {@link DataTable.defaults}.
  11169. * @type string
  11170. * @default two_button
  11171. */
  11172. "sPaginationType": "two_button",
  11173. /**
  11174. * The state duration (for `stateSave`) in seconds.
  11175. * Note that this parameter will be set by the initialisation routine. To
  11176. * set a default use {@link DataTable.defaults}.
  11177. * @type int
  11178. * @default 0
  11179. */
  11180. "iStateDuration": 0,
  11181. /**
  11182. * Array of callback functions for state saving. Each array element is an
  11183. * object with the following parameters:
  11184. * <ul>
  11185. * <li>function:fn - function to call. Takes two parameters, oSettings
  11186. * and the JSON string to save that has been thus far created. Returns
  11187. * a JSON string to be inserted into a json object
  11188. * (i.e. '"param": [ 0, 1, 2]')</li>
  11189. * <li>string:sName - name of callback</li>
  11190. * </ul>
  11191. * @type array
  11192. * @default []
  11193. */
  11194. "aoStateSave": [],
  11195. /**
  11196. * Array of callback functions for state loading. Each array element is an
  11197. * object with the following parameters:
  11198. * <ul>
  11199. * <li>function:fn - function to call. Takes two parameters, oSettings
  11200. * and the object stored. May return false to cancel state loading</li>
  11201. * <li>string:sName - name of callback</li>
  11202. * </ul>
  11203. * @type array
  11204. * @default []
  11205. */
  11206. "aoStateLoad": [],
  11207. /**
  11208. * State that was saved. Useful for back reference
  11209. * @type object
  11210. * @default null
  11211. */
  11212. "oSavedState": null,
  11213. /**
  11214. * State that was loaded. Useful for back reference
  11215. * @type object
  11216. * @default null
  11217. */
  11218. "oLoadedState": null,
  11219. /**
  11220. * Source url for AJAX data for the table.
  11221. * Note that this parameter will be set by the initialisation routine. To
  11222. * set a default use {@link DataTable.defaults}.
  11223. * @type string
  11224. * @default null
  11225. */
  11226. "sAjaxSource": null,
  11227. /**
  11228. * Property from a given object from which to read the table data from. This
  11229. * can be an empty string (when not server-side processing), in which case
  11230. * it is assumed an an array is given directly.
  11231. * Note that this parameter will be set by the initialisation routine. To
  11232. * set a default use {@link DataTable.defaults}.
  11233. * @type string
  11234. */
  11235. "sAjaxDataProp": null,
  11236. /**
  11237. * Note if draw should be blocked while getting data
  11238. * @type boolean
  11239. * @default true
  11240. */
  11241. "bAjaxDataGet": true,
  11242. /**
  11243. * The last jQuery XHR object that was used for server-side data gathering.
  11244. * This can be used for working with the XHR information in one of the
  11245. * callbacks
  11246. * @type object
  11247. * @default null
  11248. */
  11249. "jqXHR": null,
  11250. /**
  11251. * JSON returned from the server in the last Ajax request
  11252. * @type object
  11253. * @default undefined
  11254. */
  11255. "json": undefined,
  11256. /**
  11257. * Data submitted as part of the last Ajax request
  11258. * @type object
  11259. * @default undefined
  11260. */
  11261. "oAjaxData": undefined,
  11262. /**
  11263. * Function to get the server-side data.
  11264. * Note that this parameter will be set by the initialisation routine. To
  11265. * set a default use {@link DataTable.defaults}.
  11266. * @type function
  11267. */
  11268. "fnServerData": null,
  11269. /**
  11270. * Functions which are called prior to sending an Ajax request so extra
  11271. * parameters can easily be sent to the server
  11272. * @type array
  11273. * @default []
  11274. */
  11275. "aoServerParams": [],
  11276. /**
  11277. * Send the XHR HTTP method - GET or POST (could be PUT or DELETE if
  11278. * required).
  11279. * Note that this parameter will be set by the initialisation routine. To
  11280. * set a default use {@link DataTable.defaults}.
  11281. * @type string
  11282. */
  11283. "sServerMethod": null,
  11284. /**
  11285. * Format numbers for display.
  11286. * Note that this parameter will be set by the initialisation routine. To
  11287. * set a default use {@link DataTable.defaults}.
  11288. * @type function
  11289. */
  11290. "fnFormatNumber": null,
  11291. /**
  11292. * List of options that can be used for the user selectable length menu.
  11293. * Note that this parameter will be set by the initialisation routine. To
  11294. * set a default use {@link DataTable.defaults}.
  11295. * @type array
  11296. * @default []
  11297. */
  11298. "aLengthMenu": null,
  11299. /**
  11300. * Counter for the draws that the table does. Also used as a tracker for
  11301. * server-side processing
  11302. * @type int
  11303. * @default 0
  11304. */
  11305. "iDraw": 0,
  11306. /**
  11307. * Indicate if a redraw is being done - useful for Ajax
  11308. * @type boolean
  11309. * @default false
  11310. */
  11311. "bDrawing": false,
  11312. /**
  11313. * Draw index (iDraw) of the last error when parsing the returned data
  11314. * @type int
  11315. * @default -1
  11316. */
  11317. "iDrawError": -1,
  11318. /**
  11319. * Paging display length
  11320. * @type int
  11321. * @default 10
  11322. */
  11323. "_iDisplayLength": 10,
  11324. /**
  11325. * Paging start point - aiDisplay index
  11326. * @type int
  11327. * @default 0
  11328. */
  11329. "_iDisplayStart": 0,
  11330. /**
  11331. * Server-side processing - number of records in the result set
  11332. * (i.e. before filtering), Use fnRecordsTotal rather than
  11333. * this property to get the value of the number of records, regardless of
  11334. * the server-side processing setting.
  11335. * @type int
  11336. * @default 0
  11337. * @private
  11338. */
  11339. "_iRecordsTotal": 0,
  11340. /**
  11341. * Server-side processing - number of records in the current display set
  11342. * (i.e. after filtering). Use fnRecordsDisplay rather than
  11343. * this property to get the value of the number of records, regardless of
  11344. * the server-side processing setting.
  11345. * @type boolean
  11346. * @default 0
  11347. * @private
  11348. */
  11349. "_iRecordsDisplay": 0,
  11350. /**
  11351. * Flag to indicate if jQuery UI marking and classes should be used.
  11352. * Note that this parameter will be set by the initialisation routine. To
  11353. * set a default use {@link DataTable.defaults}.
  11354. * @type boolean
  11355. */
  11356. "bJUI": null,
  11357. /**
  11358. * The classes to use for the table
  11359. * @type object
  11360. * @default {}
  11361. */
  11362. "oClasses": {},
  11363. /**
  11364. * Flag attached to the settings object so you can check in the draw
  11365. * callback if filtering has been done in the draw. Deprecated in favour of
  11366. * events.
  11367. * @type boolean
  11368. * @default false
  11369. * @deprecated
  11370. */
  11371. "bFiltered": false,
  11372. /**
  11373. * Flag attached to the settings object so you can check in the draw
  11374. * callback if sorting has been done in the draw. Deprecated in favour of
  11375. * events.
  11376. * @type boolean
  11377. * @default false
  11378. * @deprecated
  11379. */
  11380. "bSorted": false,
  11381. /**
  11382. * Indicate that if multiple rows are in the header and there is more than
  11383. * one unique cell per column, if the top one (true) or bottom one (false)
  11384. * should be used for sorting / title by DataTables.
  11385. * Note that this parameter will be set by the initialisation routine. To
  11386. * set a default use {@link DataTable.defaults}.
  11387. * @type boolean
  11388. */
  11389. "bSortCellsTop": null,
  11390. /**
  11391. * Initialisation object that is used for the table
  11392. * @type object
  11393. * @default null
  11394. */
  11395. "oInit": null,
  11396. /**
  11397. * Destroy callback functions - for plug-ins to attach themselves to the
  11398. * destroy so they can clean up markup and events.
  11399. * @type array
  11400. * @default []
  11401. */
  11402. "aoDestroyCallback": [],
  11403. /**
  11404. * Get the number of records in the current record set, before filtering
  11405. * @type function
  11406. */
  11407. "fnRecordsTotal": function ()
  11408. {
  11409. return _fnDataSource( this ) == 'ssp' ?
  11410. this._iRecordsTotal * 1 :
  11411. this.aiDisplayMaster.length;
  11412. },
  11413. /**
  11414. * Get the number of records in the current record set, after filtering
  11415. * @type function
  11416. */
  11417. "fnRecordsDisplay": function ()
  11418. {
  11419. return _fnDataSource( this ) == 'ssp' ?
  11420. this._iRecordsDisplay * 1 :
  11421. this.aiDisplay.length;
  11422. },
  11423. /**
  11424. * Get the display end point - aiDisplay index
  11425. * @type function
  11426. */
  11427. "fnDisplayEnd": function ()
  11428. {
  11429. var
  11430. len = this._iDisplayLength,
  11431. start = this._iDisplayStart,
  11432. calc = start + len,
  11433. records = this.aiDisplay.length,
  11434. features = this.oFeatures,
  11435. paginate = features.bPaginate;
  11436. if ( features.bServerSide ) {
  11437. return paginate === false || len === -1 ?
  11438. start + records :
  11439. Math.min( start+len, this._iRecordsDisplay );
  11440. }
  11441. else {
  11442. return ! paginate || calc>records || len===-1 ?
  11443. records :
  11444. calc;
  11445. }
  11446. },
  11447. /**
  11448. * The DataTables object for this table
  11449. * @type object
  11450. * @default null
  11451. */
  11452. "oInstance": null,
  11453. /**
  11454. * Unique identifier for each instance of the DataTables object. If there
  11455. * is an ID on the table node, then it takes that value, otherwise an
  11456. * incrementing internal counter is used.
  11457. * @type string
  11458. * @default null
  11459. */
  11460. "sInstance": null,
  11461. /**
  11462. * tabindex attribute value that is added to DataTables control elements, allowing
  11463. * keyboard navigation of the table and its controls.
  11464. */
  11465. "iTabIndex": 0,
  11466. /**
  11467. * DIV container for the footer scrolling table if scrolling
  11468. */
  11469. "nScrollHead": null,
  11470. /**
  11471. * DIV container for the footer scrolling table if scrolling
  11472. */
  11473. "nScrollFoot": null,
  11474. /**
  11475. * Last applied sort
  11476. * @type array
  11477. * @default []
  11478. */
  11479. "aLastSort": [],
  11480. /**
  11481. * Stored plug-in instances
  11482. * @type object
  11483. * @default {}
  11484. */
  11485. "oPlugins": {}
  11486. };
  11487. /**
  11488. * Extension object for DataTables that is used to provide all extension
  11489. * options.
  11490. *
  11491. * Note that the `DataTable.ext` object is available through
  11492. * `jQuery.fn.dataTable.ext` where it may be accessed and manipulated. It is
  11493. * also aliased to `jQuery.fn.dataTableExt` for historic reasons.
  11494. * @namespace
  11495. * @extends DataTable.models.ext
  11496. */
  11497. /**
  11498. * DataTables extensions
  11499. *
  11500. * This namespace acts as a collection area for plug-ins that can be used to
  11501. * extend DataTables capabilities. Indeed many of the build in methods
  11502. * use this method to provide their own capabilities (sorting methods for
  11503. * example).
  11504. *
  11505. * Note that this namespace is aliased to `jQuery.fn.dataTableExt` for legacy
  11506. * reasons
  11507. *
  11508. * @namespace
  11509. */
  11510. DataTable.ext = _ext = {
  11511. /**
  11512. * Element class names
  11513. *
  11514. * @type object
  11515. * @default {}
  11516. */
  11517. classes: {},
  11518. /**
  11519. * Error reporting.
  11520. *
  11521. * How should DataTables report an error. Can take the value 'alert' or
  11522. * 'throw'
  11523. *
  11524. * @type string
  11525. * @default alert
  11526. */
  11527. errMode: "alert",
  11528. /**
  11529. * Feature plug-ins.
  11530. *
  11531. * This is an array of objects which describe the feature plug-ins that are
  11532. * available to DataTables. These feature plug-ins are then available for
  11533. * use through the `dom` initialisation option.
  11534. *
  11535. * Each feature plug-in is described by an object which must have the
  11536. * following properties:
  11537. *
  11538. * * `fnInit` - function that is used to initialise the plug-in,
  11539. * * `cFeature` - a character so the feature can be enabled by the `dom`
  11540. * instillation option. This is case sensitive.
  11541. *
  11542. * The `fnInit` function has the following input parameters:
  11543. *
  11544. * 1. `{object}` DataTables settings object: see
  11545. * {@link DataTable.models.oSettings}
  11546. *
  11547. * And the following return is expected:
  11548. *
  11549. * * {node|null} The element which contains your feature. Note that the
  11550. * return may also be void if your plug-in does not require to inject any
  11551. * DOM elements into DataTables control (`dom`) - for example this might
  11552. * be useful when developing a plug-in which allows table control via
  11553. * keyboard entry
  11554. *
  11555. * @type array
  11556. *
  11557. * @example
  11558. * $.fn.dataTable.ext.features.push( {
  11559. * "fnInit": function( oSettings ) {
  11560. * return new TableTools( { "oDTSettings": oSettings } );
  11561. * },
  11562. * "cFeature": "T"
  11563. * } );
  11564. */
  11565. feature: [],
  11566. /**
  11567. * Row searching.
  11568. *
  11569. * This method of searching is complimentary to the default type based
  11570. * searching, and a lot more comprehensive as it allows you complete control
  11571. * over the searching logic. Each element in this array is a function
  11572. * (parameters described below) that is called for every row in the table,
  11573. * and your logic decides if it should be included in the searching data set
  11574. * or not.
  11575. *
  11576. * Searching functions have the following input parameters:
  11577. *
  11578. * 1. `{object}` DataTables settings object: see
  11579. * {@link DataTable.models.oSettings}
  11580. * 2. `{array|object}` Data for the row to be processed (same as the
  11581. * original format that was passed in as the data source, or an array
  11582. * from a DOM data source
  11583. * 3. `{int}` Row index ({@link DataTable.models.oSettings.aoData}), which
  11584. * can be useful to retrieve the `TR` element if you need DOM interaction.
  11585. *
  11586. * And the following return is expected:
  11587. *
  11588. * * {boolean} Include the row in the searched result set (true) or not
  11589. * (false)
  11590. *
  11591. * Note that as with the main search ability in DataTables, technically this
  11592. * is "filtering", since it is subtractive. However, for consistency in
  11593. * naming we call it searching here.
  11594. *
  11595. * @type array
  11596. * @default []
  11597. *
  11598. * @example
  11599. * // The following example shows custom search being applied to the
  11600. * // fourth column (i.e. the data[3] index) based on two input values
  11601. * // from the end-user, matching the data in a certain range.
  11602. * $.fn.dataTable.ext.search.push(
  11603. * function( settings, data, dataIndex ) {
  11604. * var min = document.getElementById('min').value * 1;
  11605. * var max = document.getElementById('max').value * 1;
  11606. * var version = data[3] == "-" ? 0 : data[3]*1;
  11607. *
  11608. * if ( min == "" && max == "" ) {
  11609. * return true;
  11610. * }
  11611. * else if ( min == "" && version < max ) {
  11612. * return true;
  11613. * }
  11614. * else if ( min < version && "" == max ) {
  11615. * return true;
  11616. * }
  11617. * else if ( min < version && version < max ) {
  11618. * return true;
  11619. * }
  11620. * return false;
  11621. * }
  11622. * );
  11623. */
  11624. search: [],
  11625. /**
  11626. * Internal functions, exposed for used in plug-ins.
  11627. *
  11628. * Please note that you should not need to use the internal methods for
  11629. * anything other than a plug-in (and even then, try to avoid if possible).
  11630. * The internal function may change between releases.
  11631. *
  11632. * @type object
  11633. * @default {}
  11634. */
  11635. internal: {},
  11636. /**
  11637. * Legacy configuration options. Enable and disable legacy options that
  11638. * are available in DataTables.
  11639. *
  11640. * @type object
  11641. */
  11642. legacy: {
  11643. /**
  11644. * Enable / disable DataTables 1.9 compatible server-side processing
  11645. * requests
  11646. *
  11647. * @type boolean
  11648. * @default null
  11649. */
  11650. ajax: null
  11651. },
  11652. /**
  11653. * Pagination plug-in methods.
  11654. *
  11655. * Each entry in this object is a function and defines which buttons should
  11656. * be shown by the pagination rendering method that is used for the table:
  11657. * {@link DataTable.ext.renderer.pageButton}. The renderer addresses how the
  11658. * buttons are displayed in the document, while the functions here tell it
  11659. * what buttons to display. This is done by returning an array of button
  11660. * descriptions (what each button will do).
  11661. *
  11662. * Pagination types (the four built in options and any additional plug-in
  11663. * options defined here) can be used through the `paginationType`
  11664. * initialisation parameter.
  11665. *
  11666. * The functions defined take two parameters:
  11667. *
  11668. * 1. `{int} page` The current page index
  11669. * 2. `{int} pages` The number of pages in the table
  11670. *
  11671. * Each function is expected to return an array where each element of the
  11672. * array can be one of:
  11673. *
  11674. * * `first` - Jump to first page when activated
  11675. * * `last` - Jump to last page when activated
  11676. * * `previous` - Show previous page when activated
  11677. * * `next` - Show next page when activated
  11678. * * `{int}` - Show page of the index given
  11679. * * `{array}` - A nested array containing the above elements to add a
  11680. * containing 'DIV' element (might be useful for styling).
  11681. *
  11682. * Note that DataTables v1.9- used this object slightly differently whereby
  11683. * an object with two functions would be defined for each plug-in. That
  11684. * ability is still supported by DataTables 1.10+ to provide backwards
  11685. * compatibility, but this option of use is now decremented and no longer
  11686. * documented in DataTables 1.10+.
  11687. *
  11688. * @type object
  11689. * @default {}
  11690. *
  11691. * @example
  11692. * // Show previous, next and current page buttons only
  11693. * $.fn.dataTableExt.oPagination.current = function ( page, pages ) {
  11694. * return [ 'previous', page, 'next' ];
  11695. * };
  11696. */
  11697. pager: {},
  11698. renderer: {
  11699. pageButton: {},
  11700. header: {}
  11701. },
  11702. /**
  11703. * Ordering plug-ins - custom data source
  11704. *
  11705. * The extension options for ordering of data available here is complimentary
  11706. * to the default type based ordering that DataTables typically uses. It
  11707. * allows much greater control over the the data that is being used to
  11708. * order a column, but is necessarily therefore more complex.
  11709. *
  11710. * This type of ordering is useful if you want to do ordering based on data
  11711. * live from the DOM (for example the contents of an 'input' element) rather
  11712. * than just the static string that DataTables knows of.
  11713. *
  11714. * The way these plug-ins work is that you create an array of the values you
  11715. * wish to be ordering for the column in question and then return that
  11716. * array. The data in the array much be in the index order of the rows in
  11717. * the table (not the currently ordering order!). Which order data gathering
  11718. * function is run here depends on the `dt-init columns.orderDataType`
  11719. * parameter that is used for the column (if any).
  11720. *
  11721. * The functions defined take two parameters:
  11722. *
  11723. * 1. `{object}` DataTables settings object: see
  11724. * {@link DataTable.models.oSettings}
  11725. * 2. `{int}` Target column index
  11726. *
  11727. * Each function is expected to return an array:
  11728. *
  11729. * * `{array}` Data for the column to be ordering upon
  11730. *
  11731. * @type array
  11732. *
  11733. * @example
  11734. * // Ordering using `input` node values
  11735. * $.fn.dataTable.ext.order['dom-text'] = function ( settings, col )
  11736. * {
  11737. * return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
  11738. * return $('input', td).val();
  11739. * } );
  11740. * }
  11741. */
  11742. order: {},
  11743. /**
  11744. * Type based plug-ins.
  11745. *
  11746. * Each column in DataTables has a type assigned to it, either by automatic
  11747. * detection or by direct assignment using the `type` option for the column.
  11748. * The type of a column will effect how it is ordering and search (plug-ins
  11749. * can also make use of the column type if required).
  11750. *
  11751. * @namespace
  11752. */
  11753. type: {
  11754. /**
  11755. * Type detection functions.
  11756. *
  11757. * The functions defined in this object are used to automatically detect
  11758. * a column's type, making initialisation of DataTables super easy, even
  11759. * when complex data is in the table.
  11760. *
  11761. * The functions defined take two parameters:
  11762. *
  11763. * 1. `{*}` Data from the column cell to be analysed
  11764. * 2. `{settings}` DataTables settings object. This can be used to
  11765. * perform context specific type detection - for example detection
  11766. * based on language settings such as using a comma for a decimal
  11767. * place. Generally speaking the options from the settings will not
  11768. * be required
  11769. *
  11770. * Each function is expected to return:
  11771. *
  11772. * * `{string|null}` Data type detected, or null if unknown (and thus
  11773. * pass it on to the other type detection functions.
  11774. *
  11775. * @type array
  11776. *
  11777. * @example
  11778. * // Currency type detection plug-in:
  11779. * $.fn.dataTable.ext.type.detect.push(
  11780. * function ( data, settings ) {
  11781. * // Check the numeric part
  11782. * if ( ! $.isNumeric( data.substring(1) ) ) {
  11783. * return null;
  11784. * }
  11785. *
  11786. * // Check prefixed by currency
  11787. * if ( data.charAt(0) == '$' || data.charAt(0) == '&pound;' ) {
  11788. * return 'currency';
  11789. * }
  11790. * return null;
  11791. * }
  11792. * );
  11793. */
  11794. detect: [],
  11795. /**
  11796. * Type based search formatting.
  11797. *
  11798. * The type based searching functions can be used to pre-format the
  11799. * data to be search on. For example, it can be used to strip HTML
  11800. * tags or to de-format telephone numbers for numeric only searching.
  11801. *
  11802. * Note that is a search is not defined for a column of a given type,
  11803. * no search formatting will be performed.
  11804. *
  11805. * Pre-processing of searching data plug-ins - When you assign the sType
  11806. * for a column (or have it automatically detected for you by DataTables
  11807. * or a type detection plug-in), you will typically be using this for
  11808. * custom sorting, but it can also be used to provide custom searching
  11809. * by allowing you to pre-processing the data and returning the data in
  11810. * the format that should be searched upon. This is done by adding
  11811. * functions this object with a parameter name which matches the sType
  11812. * for that target column. This is the corollary of <i>afnSortData</i>
  11813. * for searching data.
  11814. *
  11815. * The functions defined take a single parameter:
  11816. *
  11817. * 1. `{*}` Data from the column cell to be prepared for searching
  11818. *
  11819. * Each function is expected to return:
  11820. *
  11821. * * `{string|null}` Formatted string that will be used for the searching.
  11822. *
  11823. * @type object
  11824. * @default {}
  11825. *
  11826. * @example
  11827. * $.fn.dataTable.ext.type.search['title-numeric'] = function ( d ) {
  11828. * return d.replace(/\n/g," ").replace( /<.*?>/g, "" );
  11829. * }
  11830. */
  11831. search: {},
  11832. /**
  11833. * Type based ordering.
  11834. *
  11835. * The column type tells DataTables what ordering to apply to the table
  11836. * when a column is sorted upon. The order for each type that is defined,
  11837. * is defined by the functions available in this object.
  11838. *
  11839. * Each ordering option can be described by three properties added to
  11840. * this object:
  11841. *
  11842. * * `{type}-pre` - Pre-formatting function
  11843. * * `{type}-asc` - Ascending order function
  11844. * * `{type}-desc` - Descending order function
  11845. *
  11846. * All three can be used together, only `{type}-pre` or only
  11847. * `{type}-asc` and `{type}-desc` together. It is generally recommended
  11848. * that only `{type}-pre` is used, as this provides the optimal
  11849. * implementation in terms of speed, although the others are provided
  11850. * for compatibility with existing Javascript sort functions.
  11851. *
  11852. * `{type}-pre`: Functions defined take a single parameter:
  11853. *
  11854. * 1. `{*}` Data from the column cell to be prepared for ordering
  11855. *
  11856. * And return:
  11857. *
  11858. * * `{*}` Data to be sorted upon
  11859. *
  11860. * `{type}-asc` and `{type}-desc`: Functions are typical Javascript sort
  11861. * functions, taking two parameters:
  11862. *
  11863. * 1. `{*}` Data to compare to the second parameter
  11864. * 2. `{*}` Data to compare to the first parameter
  11865. *
  11866. * And returning:
  11867. *
  11868. * * `{*}` Ordering match: <0 if first parameter should be sorted lower
  11869. * than the second parameter, ===0 if the two parameters are equal and
  11870. * >0 if the first parameter should be sorted height than the second
  11871. * parameter.
  11872. *
  11873. * @type object
  11874. * @default {}
  11875. *
  11876. * @example
  11877. * // Numeric ordering of formatted numbers with a pre-formatter
  11878. * $.extend( $.fn.dataTable.ext.type.order, {
  11879. * "string-pre": function(x) {
  11880. * a = (a === "-" || a === "") ? 0 : a.replace( /[^\d\-\.]/g, "" );
  11881. * return parseFloat( a );
  11882. * }
  11883. * } );
  11884. *
  11885. * @example
  11886. * // Case-sensitive string ordering, with no pre-formatting method
  11887. * $.extend( $.fn.dataTable.ext.order, {
  11888. * "string-case-asc": function(x,y) {
  11889. * return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  11890. * },
  11891. * "string-case-desc": function(x,y) {
  11892. * return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  11893. * }
  11894. * } );
  11895. */
  11896. order: {}
  11897. },
  11898. /**
  11899. * Unique DataTables instance counter
  11900. *
  11901. * @type int
  11902. * @private
  11903. */
  11904. _unique: 0,
  11905. //
  11906. // Depreciated
  11907. // The following properties are retained for backwards compatiblity only.
  11908. // The should not be used in new projects and will be removed in a future
  11909. // version
  11910. //
  11911. /**
  11912. * Version check function.
  11913. * @type function
  11914. * @depreciated Since 1.10
  11915. */
  11916. fnVersionCheck: DataTable.fnVersionCheck,
  11917. /**
  11918. * Index for what 'this' index API functions should use
  11919. * @type int
  11920. * @deprecated Since v1.10
  11921. */
  11922. iApiIndex: 0,
  11923. /**
  11924. * jQuery UI class container
  11925. * @type object
  11926. * @deprecated Since v1.10
  11927. */
  11928. oJUIClasses: {},
  11929. /**
  11930. * Software version
  11931. * @type string
  11932. * @deprecated Since v1.10
  11933. */
  11934. sVersion: DataTable.version
  11935. };
  11936. //
  11937. // Backwards compatibility. Alias to pre 1.10 Hungarian notation counter parts
  11938. //
  11939. $.extend( _ext, {
  11940. afnFiltering: _ext.search,
  11941. aTypes: _ext.type.detect,
  11942. ofnSearch: _ext.type.search,
  11943. oSort: _ext.type.order,
  11944. afnSortData: _ext.order,
  11945. aoFeatures: _ext.feature,
  11946. oApi: _ext.internal,
  11947. oStdClasses: _ext.classes,
  11948. oPagination: _ext.pager
  11949. } );
  11950. $.extend( DataTable.ext.classes, {
  11951. "sTable": "dataTable",
  11952. "sNoFooter": "no-footer",
  11953. /* Paging buttons */
  11954. "sPageButton": "paginate_button",
  11955. "sPageButtonActive": "current",
  11956. "sPageButtonDisabled": "disabled",
  11957. /* Striping classes */
  11958. "sStripeOdd": "odd",
  11959. "sStripeEven": "even",
  11960. /* Empty row */
  11961. "sRowEmpty": "dataTables_empty",
  11962. /* Features */
  11963. "sWrapper": "dataTables_wrapper",
  11964. "sFilter": "dataTables_filter",
  11965. "sInfo": "dataTables_info",
  11966. "sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */
  11967. "sLength": "dataTables_length",
  11968. "sProcessing": "dataTables_processing",
  11969. /* Sorting */
  11970. "sSortAsc": "sorting_asc",
  11971. "sSortDesc": "sorting_desc",
  11972. "sSortable": "sorting", /* Sortable in both directions */
  11973. "sSortableAsc": "sorting_asc_disabled",
  11974. "sSortableDesc": "sorting_desc_disabled",
  11975. "sSortableNone": "sorting_disabled",
  11976. "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
  11977. /* Filtering */
  11978. "sFilterInput": "",
  11979. /* Page length */
  11980. "sLengthSelect": "",
  11981. /* Scrolling */
  11982. "sScrollWrapper": "dataTables_scroll",
  11983. "sScrollHead": "dataTables_scrollHead",
  11984. "sScrollHeadInner": "dataTables_scrollHeadInner",
  11985. "sScrollBody": "dataTables_scrollBody",
  11986. "sScrollFoot": "dataTables_scrollFoot",
  11987. "sScrollFootInner": "dataTables_scrollFootInner",
  11988. /* Misc */
  11989. "sHeaderTH": "",
  11990. "sFooterTH": "",
  11991. // Deprecated
  11992. "sSortJUIAsc": "",
  11993. "sSortJUIDesc": "",
  11994. "sSortJUI": "",
  11995. "sSortJUIAscAllowed": "",
  11996. "sSortJUIDescAllowed": "",
  11997. "sSortJUIWrapper": "",
  11998. "sSortIcon": "",
  11999. "sJUIHeader": "",
  12000. "sJUIFooter": ""
  12001. } );
  12002. (function() {
  12003. // Reused strings for better compression. Closure compiler appears to have a
  12004. // weird edge case where it is trying to expand strings rather than use the
  12005. // variable version. This results in about 200 bytes being added, for very
  12006. // little preference benefit since it this run on script load only.
  12007. var _empty = '';
  12008. _empty = '';
  12009. var _stateDefault = _empty + 'ui-state-default';
  12010. var _sortIcon = _empty + 'css_right ui-icon ui-icon-';
  12011. var _headerFooter = _empty + 'fg-toolbar ui-toolbar ui-widget-header ui-helper-clearfix';
  12012. $.extend( DataTable.ext.oJUIClasses, DataTable.ext.classes, {
  12013. /* Full numbers paging buttons */
  12014. "sPageButton": "fg-button ui-button "+_stateDefault,
  12015. "sPageButtonActive": "ui-state-disabled",
  12016. "sPageButtonDisabled": "ui-state-disabled",
  12017. /* Features */
  12018. "sPaging": "dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi "+
  12019. "ui-buttonset-multi paging_", /* Note that the type is postfixed */
  12020. /* Sorting */
  12021. "sSortAsc": _stateDefault+" sorting_asc",
  12022. "sSortDesc": _stateDefault+" sorting_desc",
  12023. "sSortable": _stateDefault+" sorting",
  12024. "sSortableAsc": _stateDefault+" sorting_asc_disabled",
  12025. "sSortableDesc": _stateDefault+" sorting_desc_disabled",
  12026. "sSortableNone": _stateDefault+" sorting_disabled",
  12027. "sSortJUIAsc": _sortIcon+"triangle-1-n",
  12028. "sSortJUIDesc": _sortIcon+"triangle-1-s",
  12029. "sSortJUI": _sortIcon+"carat-2-n-s",
  12030. "sSortJUIAscAllowed": _sortIcon+"carat-1-n",
  12031. "sSortJUIDescAllowed": _sortIcon+"carat-1-s",
  12032. "sSortJUIWrapper": "DataTables_sort_wrapper",
  12033. "sSortIcon": "DataTables_sort_icon",
  12034. /* Scrolling */
  12035. "sScrollHead": "dataTables_scrollHead "+_stateDefault,
  12036. "sScrollFoot": "dataTables_scrollFoot "+_stateDefault,
  12037. /* Misc */
  12038. "sHeaderTH": _stateDefault,
  12039. "sFooterTH": _stateDefault,
  12040. "sJUIHeader": _headerFooter+" ui-corner-tl ui-corner-tr",
  12041. "sJUIFooter": _headerFooter+" ui-corner-bl ui-corner-br"
  12042. } );
  12043. }());
  12044. var extPagination = DataTable.ext.pager;
  12045. function _numbers ( page, pages ) {
  12046. var
  12047. numbers = [],
  12048. buttons = extPagination.numbers_length,
  12049. half = Math.floor( buttons / 2 ),
  12050. i = 1;
  12051. if ( pages <= buttons ) {
  12052. numbers = _range( 0, pages );
  12053. }
  12054. else if ( page <= half ) {
  12055. numbers = _range( 0, buttons-2 );
  12056. numbers.push( 'ellipsis' );
  12057. numbers.push( pages-1 );
  12058. }
  12059. else if ( page >= pages - 1 - half ) {
  12060. numbers = _range( pages-(buttons-2), pages );
  12061. numbers.splice( 0, 0, 'ellipsis' ); // no unshift in ie6
  12062. numbers.splice( 0, 0, 0 );
  12063. }
  12064. else {
  12065. numbers = _range( page-1, page+2 );
  12066. numbers.push( 'ellipsis' );
  12067. numbers.push( pages-1 );
  12068. numbers.splice( 0, 0, 'ellipsis' );
  12069. numbers.splice( 0, 0, 0 );
  12070. }
  12071. numbers.DT_el = 'span';
  12072. return numbers;
  12073. }
  12074. $.extend( extPagination, {
  12075. simple: function ( page, pages ) {
  12076. return [ 'previous', 'next' ];
  12077. },
  12078. full: function ( page, pages ) {
  12079. return [ 'first', 'previous', 'next', 'last' ];
  12080. },
  12081. simple_numbers: function ( page, pages ) {
  12082. return [ 'previous', _numbers(page, pages), 'next' ];
  12083. },
  12084. full_numbers: function ( page, pages ) {
  12085. return [ 'first', 'previous', _numbers(page, pages), 'next', 'last' ];
  12086. },
  12087. // For testing and plug-ins to use
  12088. _numbers: _numbers,
  12089. numbers_length: 7
  12090. } );
  12091. $.extend( true, DataTable.ext.renderer, {
  12092. pageButton: {
  12093. _: function ( settings, host, idx, buttons, page, pages ) {
  12094. var classes = settings.oClasses;
  12095. var lang = settings.oLanguage.oPaginate;
  12096. var btnDisplay, btnClass, counter=0;
  12097. var attach = function( container, buttons ) {
  12098. var i, ien, node, button;
  12099. var clickHandler = function ( e ) {
  12100. _fnPageChange( settings, e.data.action, true );
  12101. };
  12102. for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
  12103. button = buttons[i];
  12104. if ( $.isArray( button ) ) {
  12105. var inner = $( '<'+(button.DT_el || 'div')+'/>' )
  12106. .appendTo( container );
  12107. attach( inner, button );
  12108. }
  12109. else {
  12110. btnDisplay = '';
  12111. btnClass = '';
  12112. switch ( button ) {
  12113. case 'ellipsis':
  12114. container.append('<span>&hellip;</span>');
  12115. break;
  12116. case 'first':
  12117. btnDisplay = lang.sFirst;
  12118. btnClass = button + (page > 0 ?
  12119. '' : ' '+classes.sPageButtonDisabled);
  12120. break;
  12121. case 'previous':
  12122. btnDisplay = lang.sPrevious;
  12123. btnClass = button + (page > 0 ?
  12124. '' : ' '+classes.sPageButtonDisabled);
  12125. break;
  12126. case 'next':
  12127. btnDisplay = lang.sNext;
  12128. btnClass = button + (page < pages-1 ?
  12129. '' : ' '+classes.sPageButtonDisabled);
  12130. break;
  12131. case 'last':
  12132. btnDisplay = lang.sLast;
  12133. btnClass = button + (page < pages-1 ?
  12134. '' : ' '+classes.sPageButtonDisabled);
  12135. break;
  12136. default:
  12137. btnDisplay = button + 1;
  12138. btnClass = page === button ?
  12139. classes.sPageButtonActive : '';
  12140. break;
  12141. }
  12142. if ( btnDisplay ) {
  12143. node = $('<a>', {
  12144. 'class': classes.sPageButton+' '+btnClass,
  12145. 'aria-controls': settings.sTableId,
  12146. 'data-dt-idx': counter,
  12147. 'tabindex': settings.iTabIndex,
  12148. 'id': idx === 0 && typeof button === 'string' ?
  12149. settings.sTableId +'_'+ button :
  12150. null
  12151. } )
  12152. .html( btnDisplay )
  12153. .appendTo( container );
  12154. _fnBindAction(
  12155. node, {action: button}, clickHandler
  12156. );
  12157. counter++;
  12158. }
  12159. }
  12160. }
  12161. };
  12162. // IE9 throws an 'unknown error' if document.activeElement is used
  12163. // inside an iframe or frame. Try / catch the error. Not good for
  12164. // accessibility, but neither are frames.
  12165. try {
  12166. // Because this approach is destroying and recreating the paging
  12167. // elements, focus is lost on the select button which is bad for
  12168. // accessibility. So we want to restore focus once the draw has
  12169. // completed
  12170. var activeEl = $(document.activeElement).data('dt-idx');
  12171. attach( $(host).empty(), buttons );
  12172. if ( activeEl !== null ) {
  12173. $(host).find( '[data-dt-idx='+activeEl+']' ).focus();
  12174. }
  12175. }
  12176. catch (e) {}
  12177. }
  12178. }
  12179. } );
  12180. var __numericReplace = function ( d, decimalPlace, re1, re2 ) {
  12181. if ( !d || d === '-' ) {
  12182. return -Infinity;
  12183. }
  12184. // If a decimal place other than `.` is used, it needs to be given to the
  12185. // function so we can detect it and replace with a `.` which is the only
  12186. // decimal place Javascript recognises - it is not locale aware.
  12187. if ( decimalPlace ) {
  12188. d = _numToDecimal( d, decimalPlace );
  12189. }
  12190. if ( d.replace ) {
  12191. if ( re1 ) {
  12192. d = d.replace( re1, '' );
  12193. }
  12194. if ( re2 ) {
  12195. d = d.replace( re2, '' );
  12196. }
  12197. }
  12198. return d * 1;
  12199. };
  12200. // Add the numeric 'deformatting' functions for sorting. This is done in a
  12201. // function to provide an easy ability for the language options to add
  12202. // additional methods if a non-period decimal place is used.
  12203. function _addNumericSort ( decimalPlace ) {
  12204. $.each(
  12205. {
  12206. // Plain numbers
  12207. "num": function ( d ) {
  12208. return __numericReplace( d, decimalPlace );
  12209. },
  12210. // Formatted numbers
  12211. "num-fmt": function ( d ) {
  12212. return __numericReplace( d, decimalPlace, _re_formatted_numeric );
  12213. },
  12214. // HTML numeric
  12215. "html-num": function ( d ) {
  12216. return __numericReplace( d, decimalPlace, _re_html );
  12217. },
  12218. // HTML numeric, formatted
  12219. "html-num-fmt": function ( d ) {
  12220. return __numericReplace( d, decimalPlace, _re_html, _re_formatted_numeric );
  12221. }
  12222. },
  12223. function ( key, fn ) {
  12224. _ext.type.order[ key+decimalPlace+'-pre' ] = fn;
  12225. }
  12226. );
  12227. }
  12228. // Default sort methods
  12229. $.extend( _ext.type.order, {
  12230. // Dates
  12231. "date-pre": function ( d ) {
  12232. return Date.parse( d ) || 0;
  12233. },
  12234. // html
  12235. "html-pre": function ( a ) {
  12236. return _empty(a) ?
  12237. '' :
  12238. a.replace ?
  12239. a.replace( /<.*?>/g, "" ).toLowerCase() :
  12240. a+'';
  12241. },
  12242. // string
  12243. "string-pre": function ( a ) {
  12244. // This is a little complex, but faster than always calling toString,
  12245. // http://jsperf.com/tostring-v-check
  12246. return _empty(a) ?
  12247. '' :
  12248. typeof a === 'string' ?
  12249. a.toLowerCase() :
  12250. ! a.toString ?
  12251. '' :
  12252. a.toString();
  12253. },
  12254. // string-asc and -desc are retained only for compatibility with the old
  12255. // sort methods
  12256. "string-asc": function ( x, y ) {
  12257. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12258. },
  12259. "string-desc": function ( x, y ) {
  12260. return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12261. }
  12262. } );
  12263. // Numeric sorting types - order doesn't matter here
  12264. _addNumericSort( '' );
  12265. // Built in type detection. See model.ext.aTypes for information about
  12266. // what is required from this methods.
  12267. $.extend( DataTable.ext.type.detect, [
  12268. // Plain numbers - first since V8 detects some plain numbers as dates
  12269. // e.g. Date.parse('55') (but not all, e.g. Date.parse('22')...).
  12270. function ( d, settings )
  12271. {
  12272. var decimal = settings.oLanguage.sDecimal;
  12273. return _isNumber( d, decimal ) ? 'num'+decimal : null;
  12274. },
  12275. // Dates (only those recognised by the browser's Date.parse)
  12276. function ( d, settings )
  12277. {
  12278. // V8 will remove any unknown characters at the start and end of the
  12279. // expression, leading to false matches such as `$245.12` or `10%` being
  12280. // a valid date. See forum thread 18941 for detail.
  12281. if ( d && ( ! _re_date_start.test(d) || ! _re_date_end.test(d) ) ) {
  12282. return null;
  12283. }
  12284. var parsed = Date.parse(d);
  12285. return (parsed !== null && !isNaN(parsed)) || _empty(d) ? 'date' : null;
  12286. },
  12287. // Formatted numbers
  12288. function ( d, settings )
  12289. {
  12290. var decimal = settings.oLanguage.sDecimal;
  12291. return _isNumber( d, decimal, true ) ? 'num-fmt'+decimal : null;
  12292. },
  12293. // HTML numeric
  12294. function ( d, settings )
  12295. {
  12296. var decimal = settings.oLanguage.sDecimal;
  12297. return _htmlNumeric( d, decimal ) ? 'html-num'+decimal : null;
  12298. },
  12299. // HTML numeric, formatted
  12300. function ( d, settings )
  12301. {
  12302. var decimal = settings.oLanguage.sDecimal;
  12303. return _htmlNumeric( d, decimal, true ) ? 'html-num-fmt'+decimal : null;
  12304. },
  12305. // HTML (this is strict checking - there must be html)
  12306. function ( d, settings )
  12307. {
  12308. return _empty( d ) || (typeof d === 'string' && d.indexOf('<') !== -1) ?
  12309. 'html' : null;
  12310. }
  12311. ] );
  12312. // Filter formatting functions. See model.ext.ofnSearch for information about
  12313. // what is required from these methods.
  12314. $.extend( DataTable.ext.type.search, {
  12315. html: function ( data ) {
  12316. return _empty(data) ?
  12317. data :
  12318. typeof data === 'string' ?
  12319. data
  12320. .replace( _re_new_lines, " " )
  12321. .replace( _re_html, "" ) :
  12322. '';
  12323. },
  12324. string: function ( data ) {
  12325. return _empty(data) ?
  12326. data :
  12327. typeof data === 'string' ?
  12328. data.replace( _re_new_lines, " " ) :
  12329. data;
  12330. }
  12331. } );
  12332. $.extend( true, DataTable.ext.renderer, {
  12333. header: {
  12334. _: function ( settings, cell, column, classes ) {
  12335. // No additional mark-up required
  12336. // Attach a sort listener to update on sort - note that using the
  12337. // `DT` namespace will allow the event to be removed automatically
  12338. // on destroy, while the `dt` namespaced event is the one we are
  12339. // listening for
  12340. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  12341. if ( settings !== ctx ) { // need to check this this is the host
  12342. return; // table, not a nested one
  12343. }
  12344. var colIdx = column.idx;
  12345. cell
  12346. .removeClass(
  12347. column.sSortingClass +' '+
  12348. classes.sSortAsc +' '+
  12349. classes.sSortDesc
  12350. )
  12351. .addClass( columns[ colIdx ] == 'asc' ?
  12352. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  12353. classes.sSortDesc :
  12354. column.sSortingClass
  12355. );
  12356. } );
  12357. },
  12358. jqueryui: function ( settings, cell, column, classes ) {
  12359. var colIdx = column.idx;
  12360. $('<div/>')
  12361. .addClass( classes.sSortJUIWrapper )
  12362. .append( cell.contents() )
  12363. .append( $('<span/>')
  12364. .addClass( classes.sSortIcon+' '+column.sSortingClassJUI )
  12365. )
  12366. .appendTo( cell );
  12367. // Attach a sort listener to update on sort
  12368. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  12369. if ( settings !== ctx ) {
  12370. return;
  12371. }
  12372. cell
  12373. .removeClass( classes.sSortAsc +" "+classes.sSortDesc )
  12374. .addClass( columns[ colIdx ] == 'asc' ?
  12375. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  12376. classes.sSortDesc :
  12377. column.sSortingClass
  12378. );
  12379. cell
  12380. .find( 'span.'+classes.sSortIcon )
  12381. .removeClass(
  12382. classes.sSortJUIAsc +" "+
  12383. classes.sSortJUIDesc +" "+
  12384. classes.sSortJUI +" "+
  12385. classes.sSortJUIAscAllowed +" "+
  12386. classes.sSortJUIDescAllowed
  12387. )
  12388. .addClass( columns[ colIdx ] == 'asc' ?
  12389. classes.sSortJUIAsc : columns[ colIdx ] == 'desc' ?
  12390. classes.sSortJUIDesc :
  12391. column.sSortingClassJUI
  12392. );
  12393. } );
  12394. }
  12395. }
  12396. } );
  12397. /*
  12398. * Public helper functions. These aren't used internally by DataTables, or
  12399. * called by any of the options passed into DataTables, but they can be used
  12400. * externally by developers working with DataTables. They are helper functions
  12401. * to make working with DataTables a little bit easier.
  12402. */
  12403. /**
  12404. * Helpers for `columns.render`.
  12405. *
  12406. * The options defined here can be used with the `columns.render` initialisation
  12407. * option to provide a display renderer. The following functions are defined:
  12408. *
  12409. * * `number` - Will format numeric data (defined by `columns.data`) for
  12410. * display, retaining the original unformatted data for sorting and filtering.
  12411. * It takes 4 parameters:
  12412. * * `string` - Thousands grouping separator
  12413. * * `string` - Decimal point indicator
  12414. * * `integer` - Number of decimal points to show
  12415. * * `string` (optional) - Prefix.
  12416. *
  12417. * @example
  12418. * // Column definition using the number renderer
  12419. * {
  12420. * data: "salary",
  12421. * render: $.fn.dataTable.render.number( '\'', '.', 0, '$' )
  12422. * }
  12423. *
  12424. * @namespace
  12425. */
  12426. DataTable.render = {
  12427. number: function ( thousands, decimal, precision, prefix ) {
  12428. return {
  12429. display: function ( d ) {
  12430. var negative = d < 0 ? '-' : '';
  12431. d = Math.abs( parseFloat( d ) );
  12432. var intPart = parseInt( d, 10 );
  12433. var floatPart = precision ?
  12434. decimal+(d - intPart).toFixed( precision ).substring( 2 ):
  12435. '';
  12436. return negative + (prefix||'') +
  12437. intPart.toString().replace(
  12438. /\B(?=(\d{3})+(?!\d))/g, thousands
  12439. ) +
  12440. floatPart;
  12441. }
  12442. };
  12443. }
  12444. };
  12445. /*
  12446. * This is really a good bit rubbish this method of exposing the internal methods
  12447. * publicly... - To be fixed in 2.0 using methods on the prototype
  12448. */
  12449. /**
  12450. * Create a wrapper function for exporting an internal functions to an external API.
  12451. * @param {string} fn API function name
  12452. * @returns {function} wrapped function
  12453. * @memberof DataTable#internal
  12454. */
  12455. function _fnExternApiFunc (fn)
  12456. {
  12457. return function() {
  12458. var args = [_fnSettingsFromNode( this[DataTable.ext.iApiIndex] )].concat(
  12459. Array.prototype.slice.call(arguments)
  12460. );
  12461. return DataTable.ext.internal[fn].apply( this, args );
  12462. };
  12463. }
  12464. /**
  12465. * Reference to internal functions for use by plug-in developers. Note that
  12466. * these methods are references to internal functions and are considered to be
  12467. * private. If you use these methods, be aware that they are liable to change
  12468. * between versions.
  12469. * @namespace
  12470. */
  12471. $.extend( DataTable.ext.internal, {
  12472. _fnExternApiFunc: _fnExternApiFunc,
  12473. _fnBuildAjax: _fnBuildAjax,
  12474. _fnAjaxUpdate: _fnAjaxUpdate,
  12475. _fnAjaxParameters: _fnAjaxParameters,
  12476. _fnAjaxUpdateDraw: _fnAjaxUpdateDraw,
  12477. _fnAjaxDataSrc: _fnAjaxDataSrc,
  12478. _fnAddColumn: _fnAddColumn,
  12479. _fnColumnOptions: _fnColumnOptions,
  12480. _fnAdjustColumnSizing: _fnAdjustColumnSizing,
  12481. _fnVisibleToColumnIndex: _fnVisibleToColumnIndex,
  12482. _fnColumnIndexToVisible: _fnColumnIndexToVisible,
  12483. _fnVisbleColumns: _fnVisbleColumns,
  12484. _fnGetColumns: _fnGetColumns,
  12485. _fnColumnTypes: _fnColumnTypes,
  12486. _fnApplyColumnDefs: _fnApplyColumnDefs,
  12487. _fnHungarianMap: _fnHungarianMap,
  12488. _fnCamelToHungarian: _fnCamelToHungarian,
  12489. _fnLanguageCompat: _fnLanguageCompat,
  12490. _fnBrowserDetect: _fnBrowserDetect,
  12491. _fnAddData: _fnAddData,
  12492. _fnAddTr: _fnAddTr,
  12493. _fnNodeToDataIndex: _fnNodeToDataIndex,
  12494. _fnNodeToColumnIndex: _fnNodeToColumnIndex,
  12495. _fnGetCellData: _fnGetCellData,
  12496. _fnSetCellData: _fnSetCellData,
  12497. _fnSplitObjNotation: _fnSplitObjNotation,
  12498. _fnGetObjectDataFn: _fnGetObjectDataFn,
  12499. _fnSetObjectDataFn: _fnSetObjectDataFn,
  12500. _fnGetDataMaster: _fnGetDataMaster,
  12501. _fnClearTable: _fnClearTable,
  12502. _fnDeleteIndex: _fnDeleteIndex,
  12503. _fnInvalidateRow: _fnInvalidateRow,
  12504. _fnGetRowElements: _fnGetRowElements,
  12505. _fnCreateTr: _fnCreateTr,
  12506. _fnBuildHead: _fnBuildHead,
  12507. _fnDrawHead: _fnDrawHead,
  12508. _fnDraw: _fnDraw,
  12509. _fnReDraw: _fnReDraw,
  12510. _fnAddOptionsHtml: _fnAddOptionsHtml,
  12511. _fnDetectHeader: _fnDetectHeader,
  12512. _fnGetUniqueThs: _fnGetUniqueThs,
  12513. _fnFeatureHtmlFilter: _fnFeatureHtmlFilter,
  12514. _fnFilterComplete: _fnFilterComplete,
  12515. _fnFilterCustom: _fnFilterCustom,
  12516. _fnFilterColumn: _fnFilterColumn,
  12517. _fnFilter: _fnFilter,
  12518. _fnFilterCreateSearch: _fnFilterCreateSearch,
  12519. _fnEscapeRegex: _fnEscapeRegex,
  12520. _fnFilterData: _fnFilterData,
  12521. _fnFeatureHtmlInfo: _fnFeatureHtmlInfo,
  12522. _fnUpdateInfo: _fnUpdateInfo,
  12523. _fnInfoMacros: _fnInfoMacros,
  12524. _fnInitialise: _fnInitialise,
  12525. _fnInitComplete: _fnInitComplete,
  12526. _fnLengthChange: _fnLengthChange,
  12527. _fnFeatureHtmlLength: _fnFeatureHtmlLength,
  12528. _fnFeatureHtmlPaginate: _fnFeatureHtmlPaginate,
  12529. _fnPageChange: _fnPageChange,
  12530. _fnFeatureHtmlProcessing: _fnFeatureHtmlProcessing,
  12531. _fnProcessingDisplay: _fnProcessingDisplay,
  12532. _fnFeatureHtmlTable: _fnFeatureHtmlTable,
  12533. _fnScrollDraw: _fnScrollDraw,
  12534. _fnApplyToChildren: _fnApplyToChildren,
  12535. _fnCalculateColumnWidths: _fnCalculateColumnWidths,
  12536. _fnThrottle: _fnThrottle,
  12537. _fnConvertToWidth: _fnConvertToWidth,
  12538. _fnScrollingWidthAdjust: _fnScrollingWidthAdjust,
  12539. _fnGetWidestNode: _fnGetWidestNode,
  12540. _fnGetMaxLenString: _fnGetMaxLenString,
  12541. _fnStringToCss: _fnStringToCss,
  12542. _fnScrollBarWidth: _fnScrollBarWidth,
  12543. _fnSortFlatten: _fnSortFlatten,
  12544. _fnSort: _fnSort,
  12545. _fnSortAria: _fnSortAria,
  12546. _fnSortListener: _fnSortListener,
  12547. _fnSortAttachListener: _fnSortAttachListener,
  12548. _fnSortingClasses: _fnSortingClasses,
  12549. _fnSortData: _fnSortData,
  12550. _fnSaveState: _fnSaveState,
  12551. _fnLoadState: _fnLoadState,
  12552. _fnSettingsFromNode: _fnSettingsFromNode,
  12553. _fnLog: _fnLog,
  12554. _fnMap: _fnMap,
  12555. _fnBindAction: _fnBindAction,
  12556. _fnCallbackReg: _fnCallbackReg,
  12557. _fnCallbackFire: _fnCallbackFire,
  12558. _fnLengthOverflow: _fnLengthOverflow,
  12559. _fnRenderer: _fnRenderer,
  12560. _fnDataSource: _fnDataSource,
  12561. _fnRowAttributes: _fnRowAttributes,
  12562. _fnCalculateEnd: function () {} // Used by a lot of plug-ins, but redundant
  12563. // in 1.10, so this dead-end function is
  12564. // added to prevent errors
  12565. } );
  12566. // jQuery access
  12567. $.fn.dataTable = DataTable;
  12568. // Legacy aliases
  12569. $.fn.dataTableSettings = DataTable.settings;
  12570. $.fn.dataTableExt = DataTable.ext;
  12571. // With a capital `D` we return a DataTables API instance rather than a
  12572. // jQuery object
  12573. $.fn.DataTable = function ( opts ) {
  12574. return $(this).dataTable( opts ).api();
  12575. };
  12576. // All properties that are available to $.fn.dataTable should also be
  12577. // available on $.fn.DataTable
  12578. $.each( DataTable, function ( prop, val ) {
  12579. $.fn.DataTable[ prop ] = val;
  12580. } );
  12581. // Information about events fired by DataTables - for documentation.
  12582. /**
  12583. * Draw event, fired whenever the table is redrawn on the page, at the same
  12584. * point as fnDrawCallback. This may be useful for binding events or
  12585. * performing calculations when the table is altered at all.
  12586. * @name DataTable#draw.dt
  12587. * @event
  12588. * @param {event} e jQuery event object
  12589. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12590. */
  12591. /**
  12592. * Search event, fired when the searching applied to the table (using the
  12593. * built-in global search, or column filters) is altered.
  12594. * @name DataTable#search.dt
  12595. * @event
  12596. * @param {event} e jQuery event object
  12597. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12598. */
  12599. /**
  12600. * Page change event, fired when the paging of the table is altered.
  12601. * @name DataTable#page.dt
  12602. * @event
  12603. * @param {event} e jQuery event object
  12604. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12605. */
  12606. /**
  12607. * Order event, fired when the ordering applied to the table is altered.
  12608. * @name DataTable#order.dt
  12609. * @event
  12610. * @param {event} e jQuery event object
  12611. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12612. */
  12613. /**
  12614. * DataTables initialisation complete event, fired when the table is fully
  12615. * drawn, including Ajax data loaded, if Ajax data is required.
  12616. * @name DataTable#init.dt
  12617. * @event
  12618. * @param {event} e jQuery event object
  12619. * @param {object} oSettings DataTables settings object
  12620. * @param {object} json The JSON object request from the server - only
  12621. * present if client-side Ajax sourced data is used</li></ol>
  12622. */
  12623. /**
  12624. * State save event, fired when the table has changed state a new state save
  12625. * is required. This event allows modification of the state saving object
  12626. * prior to actually doing the save, including addition or other state
  12627. * properties (for plug-ins) or modification of a DataTables core property.
  12628. * @name DataTable#stateSaveParams.dt
  12629. * @event
  12630. * @param {event} e jQuery event object
  12631. * @param {object} oSettings DataTables settings object
  12632. * @param {object} json The state information to be saved
  12633. */
  12634. /**
  12635. * State load event, fired when the table is loading state from the stored
  12636. * data, but prior to the settings object being modified by the saved state
  12637. * - allowing modification of the saved state is required or loading of
  12638. * state for a plug-in.
  12639. * @name DataTable#stateLoadParams.dt
  12640. * @event
  12641. * @param {event} e jQuery event object
  12642. * @param {object} oSettings DataTables settings object
  12643. * @param {object} json The saved state information
  12644. */
  12645. /**
  12646. * State loaded event, fired when state has been loaded from stored data and
  12647. * the settings object has been modified by the loaded data.
  12648. * @name DataTable#stateLoaded.dt
  12649. * @event
  12650. * @param {event} e jQuery event object
  12651. * @param {object} oSettings DataTables settings object
  12652. * @param {object} json The saved state information
  12653. */
  12654. /**
  12655. * Processing event, fired when DataTables is doing some kind of processing
  12656. * (be it, order, searcg or anything else). It can be used to indicate to
  12657. * the end user that there is something happening, or that something has
  12658. * finished.
  12659. * @name DataTable#processing.dt
  12660. * @event
  12661. * @param {event} e jQuery event object
  12662. * @param {object} oSettings DataTables settings object
  12663. * @param {boolean} bShow Flag for if DataTables is doing processing or not
  12664. */
  12665. /**
  12666. * Ajax (XHR) event, fired whenever an Ajax request is completed from a
  12667. * request to made to the server for new data. This event is called before
  12668. * DataTables processed the returned data, so it can also be used to pre-
  12669. * process the data returned from the server, if needed.
  12670. *
  12671. * Note that this trigger is called in `fnServerData`, if you override
  12672. * `fnServerData` and which to use this event, you need to trigger it in you
  12673. * success function.
  12674. * @name DataTable#xhr.dt
  12675. * @event
  12676. * @param {event} e jQuery event object
  12677. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12678. * @param {object} json JSON returned from the server
  12679. *
  12680. * @example
  12681. * // Use a custom property returned from the server in another DOM element
  12682. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  12683. * $('#status').html( json.status );
  12684. * } );
  12685. *
  12686. * @example
  12687. * // Pre-process the data returned from the server
  12688. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  12689. * for ( var i=0, ien=json.aaData.length ; i<ien ; i++ ) {
  12690. * json.aaData[i].sum = json.aaData[i].one + json.aaData[i].two;
  12691. * }
  12692. * // Note no return - manipulate the data directly in the JSON object.
  12693. * } );
  12694. */
  12695. /**
  12696. * Destroy event, fired when the DataTable is destroyed by calling fnDestroy
  12697. * or passing the bDestroy:true parameter in the initialisation object. This
  12698. * can be used to remove bound events, added DOM nodes, etc.
  12699. * @name DataTable#destroy.dt
  12700. * @event
  12701. * @param {event} e jQuery event object
  12702. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12703. */
  12704. /**
  12705. * Page length change event, fired when number of records to show on each
  12706. * page (the length) is changed.
  12707. * @name DataTable#length.dt
  12708. * @event
  12709. * @param {event} e jQuery event object
  12710. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12711. * @param {integer} len New length
  12712. */
  12713. /**
  12714. * Column sizing has changed.
  12715. * @name DataTable#column-sizing.dt
  12716. * @event
  12717. * @param {event} e jQuery event object
  12718. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12719. */
  12720. /**
  12721. * Column visibility has changed.
  12722. * @name DataTable#column-visibility.dt
  12723. * @event
  12724. * @param {event} e jQuery event object
  12725. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12726. * @param {int} column Column index
  12727. * @param {bool} vis `false` if column now hidden, or `true` if visible
  12728. */
  12729. return $.fn.dataTable;
  12730. }));
  12731. }(window, document));