jquery.dataTables.js 398 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013
  1. /*! DataTables 1.10.0-dev
  2. * ©2008-2013 SpryMedia Ltd - datatables.net/license
  3. */
  4. /**
  5. * @summary DataTables
  6. * @description Paginate, search and order HTML tables
  7. * @version 1.10.0-dev
  8. * @file jquery.dataTables.js
  9. * @author SpryMedia Ltd (www.sprymedia.co.uk)
  10. * @contact www.sprymedia.co.uk/contact
  11. * @copyright Copyright 2008-2013 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,_empty,_intVal,_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,_fnGetRowData,_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. // Define as an AMD module if possible
  28. if ( typeof define === 'function' && define.amd )
  29. {
  30. define( 'datatables', ['jquery'], factory );
  31. }
  32. /* Define using browser globals otherwise
  33. * Prevent multiple instantiations if the script is loaded twice
  34. */
  35. else if ( jQuery && !jQuery.fn.dataTable )
  36. {
  37. factory( jQuery );
  38. }
  39. }
  40. (/** @lends <global> */function( $ ) {
  41. "use strict";
  42. /**
  43. * DataTables is a plug-in for the jQuery Javascript library. It is a highly
  44. * flexible tool, based upon the foundations of progressive enhancement,
  45. * which will add advanced interaction controls to any HTML table. For a
  46. * full list of features please refer to
  47. * [DataTables.net](href="http://datatables.net).
  48. *
  49. * Note that the `DataTable` object is not a global variable but is aliased
  50. * to `jQuery.fn.DataTable` and `jQuery.fn.dataTable` through which it may
  51. * be accessed.
  52. *
  53. * @class
  54. * @param {object} [init={}] Configuration object for DataTables. Options
  55. * are defined by {@link DataTable.defaults}
  56. * @requires jQuery 1.3+
  57. *
  58. * @example
  59. * // Basic initialisation
  60. * $(document).ready( function {
  61. * $('#example').dataTable();
  62. * } );
  63. *
  64. * @example
  65. * // Initialisation with configuration options - in this case, disable
  66. * // pagination and sorting.
  67. * $(document).ready( function {
  68. * $('#example').dataTable( {
  69. * "paginate": false,
  70. * "sort": false
  71. * } );
  72. * } );
  73. */
  74. var DataTable;
  75. /*
  76. * It is useful to have variables which are scoped locally so only the
  77. * DataTables functions can access them and they don't leak into global space.
  78. * At the same time these functions are often useful over multiple files in the
  79. * core and API, so we list, or at least document, all variables which are used
  80. * by DataTables as private variables here. This also ensures that there is no
  81. * clashing of variable names and that they can easily referenced for reuse.
  82. */
  83. // Defined else where
  84. // _selector_run
  85. // _selector_opts
  86. // _selector_first
  87. // _selector_row_indexes
  88. var _ext; // DataTable.ext
  89. var _Api; // DataTable.Api
  90. var _api_register; // DataTable.Api.register
  91. var _api_registerPlural; // DataTable.Api.registerPlural
  92. var _re_new_lines = /[\r\n]/g;
  93. var _re_html = /<.*?>/g;
  94. var _re_formatted_numeric = /[',$£€¥%]/g;
  95. var _re_date_start = /^[\d\+\-a-zA-Z]/;
  96. var _empty = function ( d ) {
  97. return !d || d === '-' ? true : false;
  98. };
  99. var _intVal = function ( s ) {
  100. var integer = parseInt( s, 10 );
  101. return !isNaN(integer) && isFinite(s) ? integer : null;
  102. };
  103. var _isNumber = function ( d, formatted ) {
  104. if ( formatted && typeof d === 'string' ) {
  105. d = d.replace( _re_formatted_numeric, '' );
  106. }
  107. return !d || d==='-' || (!isNaN( parseFloat(d) ) && isFinite( d ));
  108. };
  109. // A string without HTML in it can be considered to be HTML still
  110. var _isHtml = function ( d ) {
  111. return !d || typeof d === 'string';
  112. };
  113. var _htmlNumeric = function ( d, formatted ) {
  114. if ( _empty( d ) ) {
  115. return true;
  116. }
  117. var html = _isHtml( d );
  118. return ! html ?
  119. null :
  120. _isNumber( _stripHtml( d ), formatted ) ?
  121. true :
  122. null;
  123. };
  124. var _pluck = function ( a, prop, prop2 ) {
  125. var out = [];
  126. var i=0, ien=a.length;
  127. // Could have the test in the loop for slightly smaller code, but speed
  128. // is essential here
  129. if ( prop2 !== undefined ) {
  130. for ( ; i<ien ; i++ ) {
  131. if ( a[i] && a[i][ prop ] ) {
  132. out.push( a[i][ prop ][ prop2 ] );
  133. }
  134. }
  135. }
  136. else {
  137. for ( ; i<ien ; i++ ) {
  138. if ( a[i] ) {
  139. out.push( a[i][ prop ] );
  140. }
  141. }
  142. }
  143. return out;
  144. };
  145. // Basically the same as _pluck, but rather than looping over `a` we use `order`
  146. // as the indexes to pick from `a`
  147. var _pluck_order = function ( a, order, prop, prop2 )
  148. {
  149. var out = [];
  150. var i=0, ien=order.length;
  151. // Could have the test in the loop for slightly smaller code, but speed
  152. // is essential here
  153. if ( prop2 !== undefined ) {
  154. for ( ; i<ien ; i++ ) {
  155. out.push( a[ order[i] ][ prop ][ prop2 ] );
  156. }
  157. }
  158. else {
  159. for ( ; i<ien ; i++ ) {
  160. out.push( a[ order[i] ][ prop ] );
  161. }
  162. }
  163. return out;
  164. };
  165. var _range = function ( len, start )
  166. {
  167. var out = [];
  168. var end;
  169. if ( start === undefined ) {
  170. start = 0;
  171. end = len;
  172. }
  173. else {
  174. end = start;
  175. start = len;
  176. }
  177. for ( var i=start ; i<end ; i++ ) {
  178. out.push( i );
  179. }
  180. return out;
  181. };
  182. var _stripHtml = function ( d ) {
  183. return d.replace( _re_html, '' );
  184. };
  185. /**
  186. * Find the unique elements in a source array.
  187. *
  188. * @param {array} src Source array
  189. * @return {array} Array of unique items
  190. * @ignore
  191. */
  192. var _unique = function ( src )
  193. {
  194. // A faster unique method is to use object keys to identify used values,
  195. // but this doesn't work with arrays or objects, which we must also
  196. // consider. See jsperf.com/compare-array-unique-versions/4 for more
  197. // information.
  198. var
  199. out = [],
  200. val,
  201. i, ien=src.length,
  202. j, k=0;
  203. again: for ( i=0 ; i<ien ; i++ ) {
  204. val = src[i];
  205. for ( j=0 ; j<k ; j++ ) {
  206. if ( out[j] === val ) {
  207. continue again;
  208. }
  209. }
  210. out.push( val );
  211. k++;
  212. }
  213. return out;
  214. };
  215. /**
  216. * Create a mapping object that allows camel case parameters to be looked up
  217. * for their Hungarian counterparts. The mapping is stored in a private
  218. * parameter called `_hungarianMap` which can be accessed on the source object.
  219. * @param {object} o
  220. * @memberof DataTable#oApi
  221. */
  222. function _fnHungarianMap ( o )
  223. {
  224. var
  225. hungarian = 'a aa ao as b fn i m o s ',
  226. match,
  227. newKey,
  228. map = {};
  229. $.each( o, function (key, val) {
  230. match = key.match(/^([^A-Z]+?)([A-Z])/);
  231. if ( match && hungarian.indexOf(match[1]+' ') !== -1 )
  232. {
  233. newKey = key.replace( match[0], match[2].toLowerCase() );
  234. map[ newKey ] = key;
  235. if ( match[1] === 'o' )
  236. {
  237. _fnHungarianMap( o[key] );
  238. }
  239. }
  240. } );
  241. o._hungarianMap = map;
  242. }
  243. /**
  244. * Convert from camel case parameters to Hungarian, based on a Hungarian map
  245. * created by _fnHungarianMap.
  246. * @param {object} src The model object which holds all parameters that can be
  247. * mapped.
  248. * @param {object} user The object to convert from camel case to Hungarian.
  249. * @param {boolean} force When set to `true`, properties which already have a
  250. * Hungarian value in the `user` object will be overwritten. Otherwise they
  251. * won't be.
  252. * @memberof DataTable#oApi
  253. */
  254. function _fnCamelToHungarian ( src, user, force )
  255. {
  256. if ( ! src._hungarianMap )
  257. {
  258. _fnHungarianMap( src );
  259. }
  260. var hungarianKey;
  261. $.each( user, function (key, val) {
  262. hungarianKey = src._hungarianMap[ key ];
  263. if ( hungarianKey !== undefined && (force || user[hungarianKey] === undefined) )
  264. {
  265. user[hungarianKey] = user[ key ];
  266. if ( hungarianKey.charAt(0) === 'o' )
  267. {
  268. _fnCamelToHungarian( src[hungarianKey], user[key] );
  269. }
  270. }
  271. } );
  272. }
  273. /**
  274. * Language compatibility - when certain options are given, and others aren't, we
  275. * need to duplicate the values over, in order to provide backwards compatibility
  276. * with older language files.
  277. * @param {object} oSettings dataTables settings object
  278. * @memberof DataTable#oApi
  279. */
  280. function _fnLanguageCompat( oLanguage )
  281. {
  282. var oDefaults = DataTable.defaults.oLanguage;
  283. var zeroRecords = oLanguage.sZeroRecords;
  284. /* Backwards compatibility - if there is no sEmptyTable given, then use the same as
  285. * sZeroRecords - assuming that is given.
  286. */
  287. if ( !oLanguage.sEmptyTable && zeroRecords &&
  288. oDefaults.sEmptyTable === "没有数据" )
  289. {
  290. _fnMap( oLanguage, oLanguage, 'sZeroRecords', 'sEmptyTable' );
  291. }
  292. /* Likewise with loading records */
  293. if ( !oLanguage.sLoadingRecords && zeroRecords &&
  294. oDefaults.sLoadingRecords === "加载中…" )
  295. {
  296. _fnMap( oLanguage, oLanguage, 'sZeroRecords', 'sLoadingRecords' );
  297. }
  298. }
  299. /**
  300. * Map one parameter onto another
  301. * @param {object} o Object to map
  302. * @param {*} knew The new parameter name
  303. * @param {*} old The old parameter name
  304. */
  305. var _fnCompatMap = function ( o, knew, old ) {
  306. if ( o[ knew ] !== undefined ) {
  307. o[ old ] = o[ knew ];
  308. }
  309. };
  310. /**
  311. * Provide backwards compatibility for the main DT options. Note that the new
  312. * options are mapped onto the old parameters, so this is an external interface
  313. * change only.
  314. * @param {object} init Object to map
  315. */
  316. function _fnCompatOpts ( init )
  317. {
  318. _fnCompatMap( init, 'ordering', 'bSort' );
  319. _fnCompatMap( init, 'orderMulti', 'bSortMulti' );
  320. _fnCompatMap( init, 'orderClasses', 'bSortClasses' );
  321. _fnCompatMap( init, 'orderCellsTop', 'bSortCellsTop' );
  322. _fnCompatMap( init, 'order', 'aaSorting' );
  323. _fnCompatMap( init, 'orderFixed', 'aaSortingFixed' );
  324. _fnCompatMap( init, 'paging', 'bPaginate' );
  325. _fnCompatMap( init, 'pagingType', 'sPaginationType' );
  326. _fnCompatMap( init, 'pageLength', 'iDisplayLength' );
  327. _fnCompatMap( init, 'searching', 'bFilter' );
  328. }
  329. /**
  330. * Provide backwards compatibility for column options. Note that the new options
  331. * are mapped onto the old parameters, so this is an external interface change
  332. * only.
  333. * @param {object} init Object to map
  334. */
  335. function _fnCompatCols ( init )
  336. {
  337. _fnCompatMap( init, 'orderable', 'bSortable' );
  338. _fnCompatMap( init, 'orderData', 'aDataSort' );
  339. _fnCompatMap( init, 'orderSequence', 'asSorting' );
  340. _fnCompatMap( init, 'orderDataType', 'sortDataType' );
  341. }
  342. /**
  343. * Browser feature detection for capabilities, quirks
  344. * @param {object} settings dataTables settings object
  345. * @memberof DataTable#oApi
  346. */
  347. function _fnBrowserDetect( settings )
  348. {
  349. var browser = settings.oBrowser;
  350. // Scrolling feature / quirks detection
  351. var n = $('<div/>')
  352. .css( {
  353. position: 'absolute',
  354. top: 0,
  355. left: 0,
  356. height: 1,
  357. width: 1,
  358. overflow: 'hidden'
  359. } )
  360. .append(
  361. $('<div/>')
  362. .css( {
  363. position: 'absolute',
  364. top: 1,
  365. left: 1,
  366. width: 100,
  367. overflow: 'scroll'
  368. } )
  369. .append(
  370. $('<div class="test"/>')
  371. .css( {
  372. width: '100%',
  373. height: 10
  374. } )
  375. )
  376. )
  377. .appendTo( 'body' );
  378. var test = n.find('.test');
  379. // IE6/7 will oversize a width 100% element inside a scrolling element, to
  380. // include the width of the scrollbar, while other browsers ensure the inner
  381. // element is contained without forcing scrolling
  382. browser.bScrollOversize = test[0].offsetWidth === 100;
  383. // In rtl text layout, some browsers (most, but not all) will place the
  384. // scrollbar on the left, rather than the right.
  385. browser.bScrollbarLeft = test.offset().left !== 1;
  386. n.remove();
  387. }
  388. /**
  389. * Add a column to the list used for the table with default values
  390. * @param {object} oSettings dataTables settings object
  391. * @param {node} nTh The th element for this column
  392. * @memberof DataTable#oApi
  393. */
  394. function _fnAddColumn( oSettings, nTh )
  395. {
  396. var oDefaults = DataTable.defaults.column;
  397. var iCol = oSettings.aoColumns.length;
  398. var oCol = $.extend( {}, DataTable.models.oColumn, oDefaults, {
  399. "sSortingClass": oSettings.oClasses.sSortable,
  400. "sSortingClassJUI": oSettings.oClasses.sSortJUI,
  401. "nTh": nTh ? nTh : document.createElement('th'),
  402. "sTitle": oDefaults.sTitle ? oDefaults.sTitle : nTh ? nTh.innerHTML : '',
  403. "aDataSort": oDefaults.aDataSort ? oDefaults.aDataSort : [iCol],
  404. "mData": oDefaults.mData ? oDefaults.mData : iCol
  405. } );
  406. oSettings.aoColumns.push( oCol );
  407. /* Add a column specific filter */
  408. if ( oSettings.aoPreSearchCols[ iCol ] === undefined || oSettings.aoPreSearchCols[ iCol ] === null )
  409. {
  410. oSettings.aoPreSearchCols[ iCol ] = $.extend( true, {}, DataTable.models.oSearch );
  411. }
  412. else
  413. {
  414. var oPre = oSettings.aoPreSearchCols[ iCol ];
  415. /* Don't require that the user must specify bRegex, bSmart or bCaseInsensitive */
  416. if ( oPre.bRegex === undefined )
  417. {
  418. oPre.bRegex = true;
  419. }
  420. if ( oPre.bSmart === undefined )
  421. {
  422. oPre.bSmart = true;
  423. }
  424. if ( oPre.bCaseInsensitive === undefined )
  425. {
  426. oPre.bCaseInsensitive = true;
  427. }
  428. }
  429. /* Use the column options function to initialise classes etc */
  430. _fnColumnOptions( oSettings, iCol, null );
  431. }
  432. /**
  433. * Apply options for a column
  434. * @param {object} oSettings dataTables settings object
  435. * @param {int} iCol column index to consider
  436. * @param {object} oOptions object with sType, bVisible and bSearchable etc
  437. * @memberof DataTable#oApi
  438. */
  439. function _fnColumnOptions( oSettings, iCol, oOptions )
  440. {
  441. var oCol = oSettings.aoColumns[ iCol ];
  442. var oClasses = oSettings.oClasses;
  443. /* User specified column options */
  444. if ( oOptions !== undefined && oOptions !== null )
  445. {
  446. // Backwards compatibility
  447. _fnCompatCols( oOptions );
  448. // Map camel case parameters to their Hungarian counterparts
  449. _fnCamelToHungarian( DataTable.defaults.column, oOptions );
  450. /* Backwards compatibility for mDataProp */
  451. if ( oOptions.mDataProp !== undefined && !oOptions.mData )
  452. {
  453. oOptions.mData = oOptions.mDataProp;
  454. }
  455. oCol._sManualType = oOptions.sType;
  456. // `class` is a reserved word in Javascript, so we need to provide
  457. // the ability to use a valid name for the camel case input
  458. if ( oOptions.className && ! oOptions.sClass )
  459. {
  460. oOptions.sClass = oOptions.className;
  461. }
  462. $.extend( oCol, oOptions );
  463. _fnMap( oCol, oOptions, "sWidth", "sWidthOrig" );
  464. /* iDataSort to be applied (backwards compatibility), but aDataSort will take
  465. * priority if defined
  466. */
  467. if ( typeof oOptions.iDataSort === 'number' )
  468. {
  469. oCol.aDataSort = [ oOptions.iDataSort ];
  470. }
  471. _fnMap( oCol, oOptions, "aDataSort" );
  472. }
  473. /* Cache the data get and set functions for speed */
  474. var mDataSrc = oCol.mData;
  475. var mData = _fnGetObjectDataFn( mDataSrc );
  476. var mRender = oCol.mRender ? _fnGetObjectDataFn( oCol.mRender ) : null;
  477. var attrTest = function( src ) {
  478. return typeof src === 'string' && src.indexOf('@') !== -1;
  479. };
  480. oCol._bAttrSrc = $.isPlainObject( mDataSrc ) && (
  481. attrTest(mDataSrc.sort) || attrTest(mDataSrc.type) || attrTest(mDataSrc.filter)
  482. );
  483. oCol.fnGetData = function (oData, sSpecific) {
  484. var innerData = mData( oData, sSpecific );
  485. if ( oCol.mRender && (sSpecific && sSpecific !== '') )
  486. {
  487. return mRender( innerData, sSpecific, oData );
  488. }
  489. return innerData;
  490. };
  491. oCol.fnSetData = _fnSetObjectDataFn( mDataSrc );
  492. /* Feature sorting overrides column specific when off */
  493. if ( !oSettings.oFeatures.bSort )
  494. {
  495. oCol.bSortable = false;
  496. }
  497. /* Check that the class assignment is correct for sorting */
  498. var bAsc = $.inArray('asc', oCol.asSorting) !== -1;
  499. var bDesc = $.inArray('desc', oCol.asSorting) !== -1;
  500. if ( !oCol.bSortable || (!bAsc && !bDesc) )
  501. {
  502. oCol.sSortingClass = oClasses.sSortableNone;
  503. oCol.sSortingClassJUI = "";
  504. }
  505. else if ( bAsc && !bDesc )
  506. {
  507. oCol.sSortingClass = oClasses.sSortableAsc;
  508. oCol.sSortingClassJUI = oClasses.sSortJUIAscAllowed;
  509. }
  510. else if ( !bAsc && bDesc )
  511. {
  512. oCol.sSortingClass = oClasses.sSortableDesc;
  513. oCol.sSortingClassJUI = oClasses.sSortJUIDescAllowed;
  514. }
  515. }
  516. /**
  517. * Adjust the table column widths for new data. Note: you would probably want to
  518. * do a redraw after calling this function!
  519. * @param {object} settings dataTables settings object
  520. * @memberof DataTable#oApi
  521. */
  522. function _fnAdjustColumnSizing ( settings )
  523. {
  524. /* Not interested in doing column width calculation if auto-width is disabled */
  525. if ( settings.oFeatures.bAutoWidth !== false )
  526. {
  527. var columns = settings.aoColumns;
  528. _fnCalculateColumnWidths( settings );
  529. for ( var i=0 , iLen=columns.length ; i<iLen ; i++ )
  530. {
  531. columns[i].nTh.style.width = columns[i].sWidth;
  532. }
  533. }
  534. var scroll = settings.oScroll;
  535. if ( scroll.sY !== '' || scroll.sX !== '')
  536. {
  537. _fnScrollDraw( settings );
  538. }
  539. _fnCallbackFire( settings, null, 'column-sizing', [settings] );
  540. }
  541. /**
  542. * Covert the index of a visible column to the index in the data array (take account
  543. * of hidden columns)
  544. * @param {object} oSettings dataTables settings object
  545. * @param {int} iMatch Visible column index to lookup
  546. * @returns {int} i the data index
  547. * @memberof DataTable#oApi
  548. */
  549. function _fnVisibleToColumnIndex( oSettings, iMatch )
  550. {
  551. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  552. return typeof aiVis[iMatch] === 'number' ?
  553. aiVis[iMatch] :
  554. null;
  555. }
  556. /**
  557. * Covert the index of an index in the data array and convert it to the visible
  558. * column index (take account of hidden columns)
  559. * @param {int} iMatch Column index to lookup
  560. * @param {object} oSettings dataTables settings object
  561. * @returns {int} i the data index
  562. * @memberof DataTable#oApi
  563. */
  564. function _fnColumnIndexToVisible( oSettings, iMatch )
  565. {
  566. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  567. var iPos = $.inArray( iMatch, aiVis );
  568. return iPos !== -1 ? iPos : null;
  569. }
  570. /**
  571. * Get the number of visible columns
  572. * @param {object} oSettings dataTables settings object
  573. * @returns {int} i the number of visible columns
  574. * @memberof DataTable#oApi
  575. */
  576. function _fnVisbleColumns( oSettings )
  577. {
  578. return _fnGetColumns( oSettings, 'bVisible' ).length;
  579. }
  580. /**
  581. * Get an array of column indexes that match a given property
  582. * @param {object} oSettings dataTables settings object
  583. * @param {string} sParam Parameter in aoColumns to look for - typically
  584. * bVisible or bSearchable
  585. * @returns {array} Array of indexes with matched properties
  586. * @memberof DataTable#oApi
  587. */
  588. function _fnGetColumns( oSettings, sParam )
  589. {
  590. var a = [];
  591. $.map( oSettings.aoColumns, function(val, i) {
  592. if ( val[sParam] ) {
  593. a.push( i );
  594. }
  595. } );
  596. return a;
  597. }
  598. function _fnColumnTypes ( settings )
  599. {
  600. var columns = settings.aoColumns;
  601. var data = settings.aoData;
  602. var types = DataTable.ext.type.detect;
  603. var i, ien, j, jen, k, ken;
  604. var col, cell, detectedType, cache;
  605. // For each column, spin over the
  606. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  607. col = columns[i];
  608. cache = [];
  609. if ( ! col.sType && col._sManualType ) {
  610. col.sType = col._sManualType;
  611. }
  612. else if ( ! col.sType ) {
  613. for ( j=0, jen=types.length ; j<jen ; j++ ) {
  614. for ( k=0, ken=data.length ; k<ken ; k++ ) {
  615. // Use a cache array so we only need to get the type data
  616. // from the formatter once (when using multiple detectors)
  617. if ( cache[k] === undefined ) {
  618. cache[k] = _fnGetCellData( settings, k, i, 'type' );
  619. }
  620. detectedType = types[j]( cache[k] );
  621. // Doesn't match, so break early, since this type can't
  622. // apply to this column. Also, HTML is a special case since
  623. // it is so similar to `string`. Just a single match is
  624. // needed for a column to be html type
  625. if ( ! detectedType || detectedType === 'html' ) {
  626. break;
  627. }
  628. }
  629. // Type is valid for all data points in the column - use this
  630. // type
  631. if ( detectedType ) {
  632. col.sType = detectedType;
  633. break;
  634. }
  635. }
  636. // Fall back - if no type was detected, always use string
  637. if ( ! col.sType ) {
  638. col.sType = 'string';
  639. }
  640. }
  641. }
  642. }
  643. /**
  644. * Take the column definitions and static columns arrays and calculate how
  645. * they relate to column indexes. The callback function will then apply the
  646. * definition found for a column to a suitable configuration object.
  647. * @param {object} oSettings dataTables settings object
  648. * @param {array} aoColDefs The aoColumnDefs array that is to be applied
  649. * @param {array} aoCols The aoColumns array that defines columns individually
  650. * @param {function} fn Callback function - takes two parameters, the calculated
  651. * column index and the definition for that column.
  652. * @memberof DataTable#oApi
  653. */
  654. function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, fn )
  655. {
  656. var i, iLen, j, jLen, k, kLen, def;
  657. // Column definitions with aTargets
  658. if ( aoColDefs )
  659. {
  660. /* Loop over the definitions array - loop in reverse so first instance has priority */
  661. for ( i=aoColDefs.length-1 ; i>=0 ; i-- )
  662. {
  663. def = aoColDefs[i];
  664. /* Each definition can target multiple columns, as it is an array */
  665. var aTargets = def.targets !== undefined ?
  666. def.targets :
  667. def.aTargets;
  668. if ( ! $.isArray( aTargets ) )
  669. {
  670. aTargets = [ aTargets ];
  671. }
  672. for ( j=0, jLen=aTargets.length ; j<jLen ; j++ )
  673. {
  674. if ( typeof aTargets[j] === 'number' && aTargets[j] >= 0 )
  675. {
  676. /* Add columns that we don't yet know about */
  677. while( oSettings.aoColumns.length <= aTargets[j] )
  678. {
  679. _fnAddColumn( oSettings );
  680. }
  681. /* Integer, basic index */
  682. fn( aTargets[j], def );
  683. }
  684. else if ( typeof aTargets[j] === 'number' && aTargets[j] < 0 )
  685. {
  686. /* Negative integer, right to left column counting */
  687. fn( oSettings.aoColumns.length+aTargets[j], def );
  688. }
  689. else if ( typeof aTargets[j] === 'string' )
  690. {
  691. /* Class name matching on TH element */
  692. for ( k=0, kLen=oSettings.aoColumns.length ; k<kLen ; k++ )
  693. {
  694. if ( aTargets[j] == "_all" ||
  695. $(oSettings.aoColumns[k].nTh).hasClass( aTargets[j] ) )
  696. {
  697. fn( k, def );
  698. }
  699. }
  700. }
  701. }
  702. }
  703. }
  704. // Statically defined columns array
  705. if ( aoCols )
  706. {
  707. for ( i=0, iLen=aoCols.length ; i<iLen ; i++ )
  708. {
  709. fn( i, aoCols[i] );
  710. }
  711. }
  712. }
  713. /**
  714. * Add a data array to the table, creating DOM node etc. This is the parallel to
  715. * _fnGatherData, but for adding rows from a Javascript source, rather than a
  716. * DOM source.
  717. * @param {object} oSettings dataTables settings object
  718. * @param {array} aData data array to be added
  719. * @param {node} [nTr] TR element to add to the table - optional. If not given,
  720. * DataTables will create a row automatically
  721. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  722. * if nTr is.
  723. * @returns {int} >=0 if successful (index of new aoData entry), -1 if failed
  724. * @memberof DataTable#oApi
  725. */
  726. function _fnAddData ( oSettings, aDataIn, nTr, anTds )
  727. {
  728. /* Create the object for storing information about this new row */
  729. var iRow = oSettings.aoData.length;
  730. var oData = $.extend( true, {}, DataTable.models.oRow, {
  731. src: nTr ? 'dom' : 'data'
  732. } );
  733. oData._aData = aDataIn;
  734. oSettings.aoData.push( oData );
  735. /* Create the cells */
  736. var nTd, sThisType;
  737. var columns = oSettings.aoColumns;
  738. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  739. {
  740. // When working with a row, the data source object must be populated. In
  741. // all other cases, the data source object is already populated, so we
  742. // don't overwrite it, which might break bindings etc
  743. if ( nTr ) {
  744. _fnSetCellData( oSettings, iRow, i, _fnGetCellData( oSettings, iRow, i ) );
  745. }
  746. columns[i].sType = null;
  747. }
  748. /* Add to the display array */
  749. oSettings.aiDisplayMaster.push( iRow );
  750. /* Create the DOM information */
  751. if ( !oSettings.oFeatures.bDeferRender )
  752. {
  753. _fnCreateTr( oSettings, iRow, nTr, anTds );
  754. }
  755. return iRow;
  756. }
  757. /**
  758. * Add one or more TR elements to the table. Generally we'd expect to
  759. * use this for reading data from a DOM sourced table, but it could be
  760. * used for an TR element. Note that if a TR is given, it is used (i.e.
  761. * it is not cloned).
  762. * @param {object} settings dataTables settings object
  763. * @param {array|node|jQuery} trs The TR element(s) to add to the table
  764. * @returns {array} Array of indexes for the added rows
  765. * @memberof DataTable#oApi
  766. */
  767. function _fnAddTr( settings, trs )
  768. {
  769. var row;
  770. // Allow an individual node to be passed in
  771. if ( ! (trs instanceof $) ) {
  772. trs = $(trs);
  773. }
  774. return trs.map( function (i, el) {
  775. row = _fnGetRowElements( settings, el );
  776. return _fnAddData( settings, row.data, el, row.cells );
  777. } );
  778. }
  779. /**
  780. * Take a TR element and convert it to an index in aoData
  781. * @param {object} oSettings dataTables settings object
  782. * @param {node} n the TR element to find
  783. * @returns {int} index if the node is found, null if not
  784. * @memberof DataTable#oApi
  785. */
  786. function _fnNodeToDataIndex( oSettings, n )
  787. {
  788. return (n._DT_RowIndex!==undefined) ? n._DT_RowIndex : null;
  789. }
  790. /**
  791. * Take a TD element and convert it into a column data index (not the visible index)
  792. * @param {object} oSettings dataTables settings object
  793. * @param {int} iRow The row number the TD/TH can be found in
  794. * @param {node} n The TD/TH element to find
  795. * @returns {int} index if the node is found, -1 if not
  796. * @memberof DataTable#oApi
  797. */
  798. function _fnNodeToColumnIndex( oSettings, iRow, n )
  799. {
  800. return $.inArray( n, oSettings.aoData[ iRow ].anCells );
  801. }
  802. /**
  803. * Get an array of data for a given row from the internal data cache
  804. * @param {object} oSettings dataTables settings object
  805. * @param {int} iRow aoData row id
  806. * @param {string} sSpecific data get type ('type' 'filter' 'sort')
  807. * @param {array} aiColumns Array of column indexes to get data from
  808. * @returns {array} Data array
  809. * @memberof DataTable#oApi
  810. */
  811. function _fnGetRowData( oSettings, iRow, sSpecific, aiColumns )
  812. {
  813. var out = [];
  814. for ( var i=0, iLen=aiColumns.length ; i<iLen ; i++ )
  815. {
  816. out.push( _fnGetCellData( oSettings, iRow, aiColumns[i], sSpecific ) );
  817. }
  818. return out;
  819. }
  820. /**
  821. * Get the data for a given cell from the internal cache, taking into account data mapping
  822. * @param {object} oSettings dataTables settings object
  823. * @param {int} iRow aoData row id
  824. * @param {int} iCol Column index
  825. * @param {string} sSpecific data get type ('display', 'type' 'filter' 'sort')
  826. * @returns {*} Cell data
  827. * @memberof DataTable#oApi
  828. */
  829. function _fnGetCellData( oSettings, iRow, iCol, sSpecific )
  830. {
  831. var oCol = oSettings.aoColumns[iCol];
  832. var oData = oSettings.aoData[iRow]._aData;
  833. var sData = oCol.fnGetData( oData, sSpecific );
  834. if ( sData === undefined )
  835. {
  836. if ( oSettings.iDrawError != oSettings.iDraw && oCol.sDefaultContent === null )
  837. {
  838. _fnLog( oSettings, 0, "Requested unknown parameter "+
  839. (typeof oCol.mData=='function' ? '{function}' : "'"+oCol.mData+"'")+
  840. " for row "+iRow, 4 );
  841. oSettings.iDrawError = oSettings.iDraw;
  842. }
  843. return oCol.sDefaultContent;
  844. }
  845. /* When the data source is null, we can use default column data */
  846. if ( (sData === oData || sData === null) && oCol.sDefaultContent !== null )
  847. {
  848. sData = oCol.sDefaultContent;
  849. }
  850. else if ( typeof sData === 'function' )
  851. {
  852. // If the data source is a function, then we run it and use the return
  853. return sData();
  854. }
  855. if ( sData === null && sSpecific == 'display' )
  856. {
  857. return '';
  858. }
  859. return sData;
  860. }
  861. /**
  862. * Set the value for a specific cell, into the internal data cache
  863. * @param {object} oSettings dataTables settings object
  864. * @param {int} iRow aoData row id
  865. * @param {int} iCol Column index
  866. * @param {*} val Value to set
  867. * @memberof DataTable#oApi
  868. */
  869. function _fnSetCellData( oSettings, iRow, iCol, val )
  870. {
  871. var oCol = oSettings.aoColumns[iCol];
  872. var oData = oSettings.aoData[iRow]._aData;
  873. oCol.fnSetData( oData, val );
  874. }
  875. // Private variable that is used to match action syntax in the data property object
  876. var __reArray = /\[.*?\]$/;
  877. var __reFn = /\(\)$/;
  878. /**
  879. * Split string on periods, taking into account escaped periods
  880. * @param {string} str String to split
  881. * @return {array} Split string
  882. */
  883. function _fnSplitObjNotation( str )
  884. {
  885. return $.map( str.match(/(\\.|[^\.])+/g), function ( s ) {
  886. return s.replace('\\.', '.');
  887. } );
  888. }
  889. /**
  890. * Return a function that can be used to get data from a source object, taking
  891. * into account the ability to use nested objects as a source
  892. * @param {string|int|function} mSource The data source for the object
  893. * @returns {function} Data get function
  894. * @memberof DataTable#oApi
  895. */
  896. function _fnGetObjectDataFn( mSource )
  897. {
  898. if ( $.isPlainObject( mSource ) )
  899. {
  900. /* Build an object of get functions, and wrap them in a single call */
  901. var o = {};
  902. $.each( mSource, function (key, val) {
  903. if ( val ) {
  904. o[key] = _fnGetObjectDataFn( val );
  905. }
  906. } );
  907. return function (data, type, extra) {
  908. return o[ o[type] !== undefined ? type : '_' ](data, type, extra);
  909. };
  910. }
  911. else if ( mSource === null )
  912. {
  913. /* Give an empty string for rendering / sorting etc */
  914. return function (data, type) {
  915. return data;
  916. };
  917. }
  918. else if ( typeof mSource === 'function' )
  919. {
  920. return function (data, type, extra) {
  921. return mSource( data, type, extra );
  922. };
  923. }
  924. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  925. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  926. {
  927. /* If there is a . in the source string then the data source is in a
  928. * nested object so we loop over the data for each level to get the next
  929. * level down. On each loop we test for undefined, and if found immediately
  930. * return. This allows entire objects to be missing and sDefaultContent to
  931. * be used if defined, rather than throwing an error
  932. */
  933. var fetchData = function (data, type, src) {
  934. var arrayNotation, funcNotation, out, innerSrc;
  935. if ( src !== "" )
  936. {
  937. var a = _fnSplitObjNotation( src );
  938. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  939. {
  940. // Check if we are dealing with special notation
  941. arrayNotation = a[i].match(__reArray);
  942. funcNotation = a[i].match(__reFn);
  943. if ( arrayNotation )
  944. {
  945. // Array notation
  946. a[i] = a[i].replace(__reArray, '');
  947. // Condition allows simply [] to be passed in
  948. if ( a[i] !== "" ) {
  949. data = data[ a[i] ];
  950. }
  951. out = [];
  952. // Get the remainder of the nested object to get
  953. a.splice( 0, i+1 );
  954. innerSrc = a.join('.');
  955. // Traverse each entry in the array getting the properties requested
  956. for ( var j=0, jLen=data.length ; j<jLen ; j++ ) {
  957. out.push( fetchData( data[j], type, innerSrc ) );
  958. }
  959. // If a string is given in between the array notation indicators, that
  960. // is used to join the strings together, otherwise an array is returned
  961. var join = arrayNotation[0].substring(1, arrayNotation[0].length-1);
  962. data = (join==="") ? out : out.join(join);
  963. // The inner call to fetchData has already traversed through the remainder
  964. // of the source requested, so we exit from the loop
  965. break;
  966. }
  967. else if ( funcNotation )
  968. {
  969. // Function call
  970. a[i] = a[i].replace(__reFn, '');
  971. data = data[ a[i] ]();
  972. continue;
  973. }
  974. if ( data === null || data[ a[i] ] === undefined )
  975. {
  976. return undefined;
  977. }
  978. data = data[ a[i] ];
  979. }
  980. }
  981. return data;
  982. };
  983. return function (data, type) {
  984. return fetchData( data, type, mSource );
  985. };
  986. }
  987. else
  988. {
  989. /* Array or flat object mapping */
  990. return function (data, type) {
  991. return data[mSource];
  992. };
  993. }
  994. }
  995. /**
  996. * Return a function that can be used to set data from a source object, taking
  997. * into account the ability to use nested objects as a source
  998. * @param {string|int|function} mSource The data source for the object
  999. * @returns {function} Data set function
  1000. * @memberof DataTable#oApi
  1001. */
  1002. function _fnSetObjectDataFn( mSource )
  1003. {
  1004. if ( $.isPlainObject( mSource ) )
  1005. {
  1006. /* Unlike get, only the underscore (global) option is used for for
  1007. * setting data since we don't know the type here. This is why an object
  1008. * option is not documented for `mData` (which is read/write), but it is
  1009. * for `mRender` which is read only.
  1010. */
  1011. return _fnSetObjectDataFn( mSource._ );
  1012. }
  1013. else if ( mSource === null )
  1014. {
  1015. /* Nothing to do when the data source is null */
  1016. return function (data, val) {};
  1017. }
  1018. else if ( typeof mSource === 'function' )
  1019. {
  1020. return function (data, val) {
  1021. mSource( data, 'set', val );
  1022. };
  1023. }
  1024. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  1025. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  1026. {
  1027. /* Like the get, we need to get data from a nested object */
  1028. var setData = function (data, val, src) {
  1029. var a = _fnSplitObjNotation( src ), b;
  1030. var aLast = a[a.length-1];
  1031. var arrayNotation, funcNotation, o, innerSrc;
  1032. for ( var i=0, iLen=a.length-1 ; i<iLen ; i++ )
  1033. {
  1034. // Check if we are dealing with an array notation request
  1035. arrayNotation = a[i].match(__reArray);
  1036. funcNotation = a[i].match(__reFn);
  1037. if ( arrayNotation )
  1038. {
  1039. a[i] = a[i].replace(__reArray, '');
  1040. data[ a[i] ] = [];
  1041. // Get the remainder of the nested object to set so we can recurse
  1042. b = a.slice();
  1043. b.splice( 0, i+1 );
  1044. innerSrc = b.join('.');
  1045. // Traverse each entry in the array setting the properties requested
  1046. for ( var j=0, jLen=val.length ; j<jLen ; j++ )
  1047. {
  1048. o = {};
  1049. setData( o, val[j], innerSrc );
  1050. data[ a[i] ].push( o );
  1051. }
  1052. // The inner call to setData has already traversed through the remainder
  1053. // of the source and has set the data, thus we can exit here
  1054. return;
  1055. }
  1056. else if ( funcNotation )
  1057. {
  1058. // Function call
  1059. a[i] = a[i].replace(__reFn, '');
  1060. data = data[ a[i] ]( val );
  1061. }
  1062. // If the nested object doesn't currently exist - since we are
  1063. // trying to set the value - create it
  1064. if ( data[ a[i] ] === null || data[ a[i] ] === undefined )
  1065. {
  1066. data[ a[i] ] = {};
  1067. }
  1068. data = data[ a[i] ];
  1069. }
  1070. // Last item in the input - i.e, the actual set
  1071. if ( aLast.match(__reFn ) )
  1072. {
  1073. // Function call
  1074. data = data[ aLast.replace(__reFn, '') ]( val );
  1075. }
  1076. else
  1077. {
  1078. // If array notation is used, we just want to strip it and use the property name
  1079. // and assign the value. If it isn't used, then we get the result we want anyway
  1080. data[ aLast.replace(__reArray, '') ] = val;
  1081. }
  1082. };
  1083. return function (data, val) {
  1084. return setData( data, val, mSource );
  1085. };
  1086. }
  1087. else
  1088. {
  1089. /* Array or flat object mapping */
  1090. return function (data, val) {
  1091. data[mSource] = val;
  1092. };
  1093. }
  1094. }
  1095. /**
  1096. * Return an array with the full table data
  1097. * @param {object} oSettings dataTables settings object
  1098. * @returns array {array} aData Master data array
  1099. * @memberof DataTable#oApi
  1100. */
  1101. function _fnGetDataMaster ( settings )
  1102. {
  1103. return _pluck( settings.aoData, '_aData' );
  1104. }
  1105. /**
  1106. * Nuke the table
  1107. * @param {object} oSettings dataTables settings object
  1108. * @memberof DataTable#oApi
  1109. */
  1110. function _fnClearTable( settings )
  1111. {
  1112. settings.aoData.length = 0;
  1113. settings.aiDisplayMaster.length = 0;
  1114. settings.aiDisplay.length = 0;
  1115. }
  1116. /**
  1117. * Take an array of integers (index array) and remove a target integer (value - not
  1118. * the key!)
  1119. * @param {array} a Index array to target
  1120. * @param {int} iTarget value to find
  1121. * @memberof DataTable#oApi
  1122. */
  1123. function _fnDeleteIndex( a, iTarget, splice )
  1124. {
  1125. var iTargetIndex = -1;
  1126. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  1127. {
  1128. if ( a[i] == iTarget )
  1129. {
  1130. iTargetIndex = i;
  1131. }
  1132. else if ( a[i] > iTarget )
  1133. {
  1134. a[i]--;
  1135. }
  1136. }
  1137. if ( iTargetIndex != -1 && splice === undefined )
  1138. {
  1139. a.splice( iTargetIndex, 1 );
  1140. }
  1141. }
  1142. /**
  1143. * Mark cached data as invalid such that a re-read of the data will occur when
  1144. * the cached data is next requested. Also update from the data source object.
  1145. *
  1146. * @param {object} settings DataTables settings object
  1147. * @param {int} rowIdx Row index to invalidate
  1148. * @memberof DataTable#oApi
  1149. *
  1150. * @todo For the modularisation of v1.11 this will need to become a callback, so
  1151. * the sort and filter methods can subscribe to it. That will required
  1152. * initialisation options for sorting, which is why it is not already baked in
  1153. */
  1154. function _fnInvalidateRow( settings, rowIdx, src, column )
  1155. {
  1156. var row = settings.aoData[ rowIdx ];
  1157. var i, ien;
  1158. // Are we reading last data from DOM or the data object?
  1159. if ( src === 'dom' || ((! src || src === 'auto') && row.src === 'dom') ) {
  1160. // Read the data from the DOM
  1161. row._aData = _fnGetRowElements( settings, row.nTr ).data;
  1162. }
  1163. else {
  1164. // Reading from data object, update the DOM
  1165. var cells = row.anCells;
  1166. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  1167. cells[i].innerHTML = _fnGetCellData( settings, rowIdx, i, 'display' );
  1168. }
  1169. }
  1170. row._aSortData = null;
  1171. row._aFilterData = null;
  1172. // Invalidate the type for a specific column (if given) or all columns since
  1173. // the data might have changed
  1174. var cols = settings.aoColumns;
  1175. if ( column !== undefined ) {
  1176. cols[ column ].sType = null;
  1177. }
  1178. else {
  1179. for ( i=0, ien=cols.length ; i<ien ; i++ ) {
  1180. cols[i].sType = null;
  1181. }
  1182. }
  1183. // Update DataTables special `DT_*` attributes for the row
  1184. _fnRowAttributes( row );
  1185. }
  1186. /**
  1187. * Build a data source object from an HTML row, reading the contents of the
  1188. * cells that are in the row.
  1189. *
  1190. * @param {object} settings DataTables settings object
  1191. * @param {node} TR element from which to read data
  1192. * @returns {object} Object with two parameters: `data` the data read, in
  1193. * document order, and `cells` and array of nodes (they can be useful to the
  1194. * caller, so rather than needing a second traversal to get them, just return
  1195. * them from here).
  1196. * @memberof DataTable#oApi
  1197. */
  1198. function _fnGetRowElements( settings, row )
  1199. {
  1200. var
  1201. d = [],
  1202. tds = [],
  1203. td = row.firstChild,
  1204. name, col, o, i=0, contents,
  1205. columns = settings.aoColumns;
  1206. var attr = function ( str, data, td ) {
  1207. if ( typeof str === 'string' ) {
  1208. var idx = str.indexOf('@');
  1209. if ( idx !== -1 ) {
  1210. var src = str.substring( idx+1 );
  1211. o[ '@'+src ] = td.getAttribute( src );
  1212. }
  1213. }
  1214. };
  1215. while ( td ) {
  1216. name = td.nodeName.toUpperCase();
  1217. if ( name == "TD" || name == "TH" ) {
  1218. col = columns[i];
  1219. contents = $.trim(td.innerHTML);
  1220. if ( col && col._bAttrSrc ) {
  1221. o = {
  1222. display: contents
  1223. };
  1224. attr( col.mData.sort, o, td );
  1225. attr( col.mData.type, o, td );
  1226. attr( col.mData.filter, o, td );
  1227. d.push( o );
  1228. }
  1229. else {
  1230. d.push( contents );
  1231. }
  1232. tds.push( td );
  1233. i++;
  1234. }
  1235. td = td.nextSibling;
  1236. }
  1237. return {
  1238. data: d,
  1239. cells: tds
  1240. };
  1241. }
  1242. /**
  1243. * Create a new TR element (and it's TD children) for a row
  1244. * @param {object} oSettings dataTables settings object
  1245. * @param {int} iRow Row to consider
  1246. * @param {node} [nTrIn] TR element to add to the table - optional. If not given,
  1247. * DataTables will create a row automatically
  1248. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  1249. * if nTr is.
  1250. * @memberof DataTable#oApi
  1251. */
  1252. function _fnCreateTr ( oSettings, iRow, nTrIn, anTds )
  1253. {
  1254. var
  1255. row = oSettings.aoData[iRow],
  1256. rowData = row._aData,
  1257. cells = [],
  1258. nTr, nTd, oCol,
  1259. i, iLen;
  1260. if ( row.nTr === null )
  1261. {
  1262. nTr = nTrIn || document.createElement('tr');
  1263. row.nTr = nTr;
  1264. row.anCells = cells;
  1265. /* Use a private property on the node to allow reserve mapping from the node
  1266. * to the aoData array for fast look up
  1267. */
  1268. nTr._DT_RowIndex = iRow;
  1269. /* Special parameters can be given by the data source to be used on the row */
  1270. _fnRowAttributes( row );
  1271. /* Process each column */
  1272. for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
  1273. {
  1274. oCol = oSettings.aoColumns[i];
  1275. nTd = nTrIn ? anTds[i] : document.createElement( oCol.sCellType );
  1276. cells.push( nTd );
  1277. // Need to create the HTML if new, or if a rendering function is defined
  1278. if ( !nTrIn || oCol.mRender || oCol.mData !== i )
  1279. {
  1280. nTd.innerHTML = _fnGetCellData( oSettings, iRow, i, 'display' );
  1281. }
  1282. /* Add user defined class */
  1283. if ( oCol.sClass !== null )
  1284. {
  1285. nTd.className += ' '+oCol.sClass;
  1286. }
  1287. // Visibility - add or remove as required
  1288. if ( oCol.bVisible && ! nTrIn )
  1289. {
  1290. nTr.appendChild( nTd );
  1291. }
  1292. else if ( ! oCol.bVisible && nTrIn )
  1293. {
  1294. nTd.parentNode.removeChild( nTd );
  1295. }
  1296. if ( oCol.fnCreatedCell )
  1297. {
  1298. oCol.fnCreatedCell.call( oSettings.oInstance,
  1299. nTd, _fnGetCellData( oSettings, iRow, i, 'display' ), rowData, iRow, i
  1300. );
  1301. }
  1302. }
  1303. _fnCallbackFire( oSettings, 'aoRowCreatedCallback', null, [nTr, rowData, iRow] );
  1304. }
  1305. }
  1306. /**
  1307. * Add attributes to a row based on the special `DT_*` parameters in a data
  1308. * source object.
  1309. * @param {object} DataTables row object for the row to be modified
  1310. * @memberof DataTable#oApi
  1311. */
  1312. function _fnRowAttributes( row )
  1313. {
  1314. var tr = row.nTr;
  1315. var data = row._aData;
  1316. if ( tr ) {
  1317. if ( data.DT_RowId ) {
  1318. tr.id = data.DT_RowId;
  1319. }
  1320. if ( data.DT_RowClass ) {
  1321. // Remove any classes added by DT_RowClass before
  1322. var a = data.DT_RowClass.split(' ');
  1323. row.__rowc = row.__rowc ?
  1324. _unique( row.__rowc.concat( a ) ) :
  1325. a;
  1326. $(tr)
  1327. .removeClass( row.__rowc.join(' ') )
  1328. .addClass( data.DT_RowClass );
  1329. }
  1330. if ( data.DT_RowData ) {
  1331. $(tr).data( data.DT_RowData );
  1332. }
  1333. }
  1334. }
  1335. /**
  1336. * Create the HTML header for the table
  1337. * @param {object} oSettings dataTables settings object
  1338. * @memberof DataTable#oApi
  1339. */
  1340. function _fnBuildHead( oSettings )
  1341. {
  1342. var i, ien, cell, row, column;
  1343. var thead = oSettings.nTHead;
  1344. var tfoot = oSettings.nTFoot;
  1345. var createHeader = $('th, td', thead).length === 0;
  1346. var classes = oSettings.oClasses;
  1347. var columns = oSettings.aoColumns;
  1348. if ( createHeader ) {
  1349. row = $('<tr/>').appendTo( thead );
  1350. }
  1351. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  1352. column = columns[i];
  1353. cell = $( column.nTh ).addClass( column.sClass );
  1354. if ( createHeader ) {
  1355. cell.appendTo( row );
  1356. }
  1357. // 1.11 move into sorting
  1358. if ( oSettings.oFeatures.bSort ) {
  1359. cell.addClass( column.sSortingClass );
  1360. if ( column.bSortable !== false ) {
  1361. cell
  1362. .attr( 'tabindex', oSettings.iTabIndex )
  1363. .attr( 'aria-controls', oSettings.sTableId );
  1364. _fnSortAttachListener( oSettings, column.nTh, i );
  1365. }
  1366. }
  1367. if ( column.sTitle != cell.html() ) {
  1368. cell.html( column.sTitle );
  1369. }
  1370. _fnRenderer( oSettings, 'header' )(
  1371. oSettings, cell, column, i, classes
  1372. );
  1373. }
  1374. if ( createHeader ) {
  1375. _fnDetectHeader( oSettings.aoHeader, thead );
  1376. }
  1377. /* ARIA role for the rows */
  1378. $(thead).find('>tr').attr('role', 'row');
  1379. /* Deal with the footer - add classes if required */
  1380. $(thead).find('>tr>th, >tr>td').addClass( classes.sHeaderTH );
  1381. $(tfoot).find('>tr>th, >tr>td').addClass( classes.sFooterTH );
  1382. // Cache the footer cells. Note that we only take the cells from the first
  1383. // row in the footer. If there is more than one row the user wants to
  1384. // interact with, they need to use the table().foot() method. Note also this
  1385. // allows cells to be used for multiple columns using colspan
  1386. if ( tfoot !== null ) {
  1387. var cells = oSettings.aoFooter[0];
  1388. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  1389. column = columns[i];
  1390. column.nTf = cells[i].cell;
  1391. if ( column.sClass ) {
  1392. $(column.nTf).addClass( column.sClass );
  1393. }
  1394. }
  1395. }
  1396. }
  1397. /**
  1398. * Draw the header (or footer) element based on the column visibility states. The
  1399. * methodology here is to use the layout array from _fnDetectHeader, modified for
  1400. * the instantaneous column visibility, to construct the new layout. The grid is
  1401. * traversed over cell at a time in a rows x columns grid fashion, although each
  1402. * cell insert can cover multiple elements in the grid - which is tracks using the
  1403. * aApplied array. Cell inserts in the grid will only occur where there isn't
  1404. * already a cell in that position.
  1405. * @param {object} oSettings dataTables settings object
  1406. * @param array {objects} aoSource Layout array from _fnDetectHeader
  1407. * @param {boolean} [bIncludeHidden=false] If true then include the hidden columns in the calc,
  1408. * @memberof DataTable#oApi
  1409. */
  1410. function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
  1411. {
  1412. var i, iLen, j, jLen, k, kLen, n, nLocalTr;
  1413. var aoLocal = [];
  1414. var aApplied = [];
  1415. var iColumns = oSettings.aoColumns.length;
  1416. var iRowspan, iColspan;
  1417. if ( ! aoSource )
  1418. {
  1419. return;
  1420. }
  1421. if ( bIncludeHidden === undefined )
  1422. {
  1423. bIncludeHidden = false;
  1424. }
  1425. /* Make a copy of the master layout array, but without the visible columns in it */
  1426. for ( i=0, iLen=aoSource.length ; i<iLen ; i++ )
  1427. {
  1428. aoLocal[i] = aoSource[i].slice();
  1429. aoLocal[i].nTr = aoSource[i].nTr;
  1430. /* Remove any columns which are currently hidden */
  1431. for ( j=iColumns-1 ; j>=0 ; j-- )
  1432. {
  1433. if ( !oSettings.aoColumns[j].bVisible && !bIncludeHidden )
  1434. {
  1435. aoLocal[i].splice( j, 1 );
  1436. }
  1437. }
  1438. /* Prep the applied array - it needs an element for each row */
  1439. aApplied.push( [] );
  1440. }
  1441. for ( i=0, iLen=aoLocal.length ; i<iLen ; i++ )
  1442. {
  1443. nLocalTr = aoLocal[i].nTr;
  1444. /* All cells are going to be replaced, so empty out the row */
  1445. if ( nLocalTr )
  1446. {
  1447. while( (n = nLocalTr.firstChild) )
  1448. {
  1449. nLocalTr.removeChild( n );
  1450. }
  1451. }
  1452. for ( j=0, jLen=aoLocal[i].length ; j<jLen ; j++ )
  1453. {
  1454. iRowspan = 1;
  1455. iColspan = 1;
  1456. /* Check to see if there is already a cell (row/colspan) covering our target
  1457. * insert point. If there is, then there is nothing to do.
  1458. */
  1459. if ( aApplied[i][j] === undefined )
  1460. {
  1461. nLocalTr.appendChild( aoLocal[i][j].cell );
  1462. aApplied[i][j] = 1;
  1463. /* Expand the cell to cover as many rows as needed */
  1464. while ( aoLocal[i+iRowspan] !== undefined &&
  1465. aoLocal[i][j].cell == aoLocal[i+iRowspan][j].cell )
  1466. {
  1467. aApplied[i+iRowspan][j] = 1;
  1468. iRowspan++;
  1469. }
  1470. /* Expand the cell to cover as many columns as needed */
  1471. while ( aoLocal[i][j+iColspan] !== undefined &&
  1472. aoLocal[i][j].cell == aoLocal[i][j+iColspan].cell )
  1473. {
  1474. /* Must update the applied array over the rows for the columns */
  1475. for ( k=0 ; k<iRowspan ; k++ )
  1476. {
  1477. aApplied[i+k][j+iColspan] = 1;
  1478. }
  1479. iColspan++;
  1480. }
  1481. /* Do the actual expansion in the DOM */
  1482. aoLocal[i][j].cell.rowSpan = iRowspan;
  1483. aoLocal[i][j].cell.colSpan = iColspan;
  1484. }
  1485. }
  1486. }
  1487. }
  1488. /**
  1489. * Insert the required TR nodes into the table for display
  1490. * @param {object} oSettings dataTables settings object
  1491. * @memberof DataTable#oApi
  1492. */
  1493. function _fnDraw( oSettings )
  1494. {
  1495. /* Provide a pre-callback function which can be used to cancel the draw is false is returned */
  1496. var aPreDraw = _fnCallbackFire( oSettings, 'aoPreDrawCallback', 'preDraw', [oSettings] );
  1497. if ( $.inArray( false, aPreDraw ) !== -1 )
  1498. {
  1499. _fnProcessingDisplay( oSettings, false );
  1500. return;
  1501. }
  1502. var i, iLen, n;
  1503. var anRows = [];
  1504. var iRowCount = 0;
  1505. var asStripeClasses = oSettings.asStripeClasses;
  1506. var iStripes = asStripeClasses.length;
  1507. var iOpenRows = oSettings.aoOpenRows.length;
  1508. var oLang = oSettings.oLanguage;
  1509. var iInitDisplayStart = oSettings.iInitDisplayStart;
  1510. var bServerSide = _fnDataSource( oSettings ) == 'ssp';
  1511. var aiDisplay = oSettings.aiDisplay;
  1512. oSettings.bDrawing = true;
  1513. /* Check and see if we have an initial draw position from state saving */
  1514. if ( iInitDisplayStart !== undefined && iInitDisplayStart !== -1 )
  1515. {
  1516. oSettings._iDisplayStart = bServerSide ?
  1517. iInitDisplayStart :
  1518. iInitDisplayStart >= oSettings.fnRecordsDisplay() ?
  1519. 0 :
  1520. iInitDisplayStart;
  1521. oSettings.iInitDisplayStart = -1;
  1522. }
  1523. var iDisplayStart = oSettings._iDisplayStart;
  1524. var iDisplayEnd = oSettings.fnDisplayEnd();
  1525. /* Server-side processing draw intercept */
  1526. if ( oSettings.bDeferLoading )
  1527. {
  1528. oSettings.bDeferLoading = false;
  1529. oSettings.iDraw++;
  1530. _fnProcessingDisplay( oSettings, false );
  1531. }
  1532. else if ( !bServerSide )
  1533. {
  1534. oSettings.iDraw++;
  1535. }
  1536. else if ( !oSettings.bDestroying && !_fnAjaxUpdate( oSettings ) )
  1537. {
  1538. return;
  1539. }
  1540. if ( aiDisplay.length !== 0 )
  1541. {
  1542. var iStart = bServerSide ? 0 : iDisplayStart;
  1543. var iEnd = bServerSide ? oSettings.aoData.length : iDisplayEnd;
  1544. for ( var j=iStart ; j<iEnd ; j++ )
  1545. {
  1546. var iDataIndex = aiDisplay[j];
  1547. var aoData = oSettings.aoData[ iDataIndex ];
  1548. if ( aoData.nTr === null )
  1549. {
  1550. _fnCreateTr( oSettings, iDataIndex );
  1551. }
  1552. var nRow = aoData.nTr;
  1553. /* Remove the old striping classes and then add the new one */
  1554. if ( iStripes !== 0 )
  1555. {
  1556. var sStripe = asStripeClasses[ iRowCount % iStripes ];
  1557. if ( aoData._sRowStripe != sStripe )
  1558. {
  1559. $(nRow).removeClass( aoData._sRowStripe ).addClass( sStripe );
  1560. aoData._sRowStripe = sStripe;
  1561. }
  1562. }
  1563. /* Row callback functions - might want to manipulate the row */
  1564. _fnCallbackFire( oSettings, 'aoRowCallback', null,
  1565. [nRow, aoData._aData, iRowCount, j] );
  1566. anRows.push( nRow );
  1567. iRowCount++;
  1568. }
  1569. }
  1570. else
  1571. {
  1572. /* Table is empty - create a row with an empty message in it */
  1573. var sZero = oLang.sZeroRecords;
  1574. if ( oSettings.iDraw == 1 && _fnDataSource( oSettings ) == 'ajax' )
  1575. {
  1576. sZero = oLang.sLoadingRecords;
  1577. }
  1578. else if ( oLang.sEmptyTable && oSettings.fnRecordsTotal() === 0 )
  1579. {
  1580. sZero = oLang.sEmptyTable;
  1581. }
  1582. anRows[ 0 ] = $( '<tr/>', { 'class': iStripes ? asStripeClasses[0] : '' } )
  1583. .append( $('<td />', {
  1584. 'valign': 'top',
  1585. 'colSpan': _fnVisbleColumns( oSettings ),
  1586. 'class': oSettings.oClasses.sRowEmpty
  1587. } ).html( sZero ) )[0];
  1588. }
  1589. /* Header and footer callbacks */
  1590. _fnCallbackFire( oSettings, 'aoHeaderCallback', 'header', [ $(oSettings.nTHead).children('tr')[0],
  1591. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  1592. _fnCallbackFire( oSettings, 'aoFooterCallback', 'footer', [ $(oSettings.nTFoot).children('tr')[0],
  1593. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  1594. var body = $(oSettings.nTBody);
  1595. body.children().detach();
  1596. body.append( $(anRows) );
  1597. /* Call all required callback functions for the end of a draw */
  1598. _fnCallbackFire( oSettings, 'aoDrawCallback', 'draw', [oSettings] );
  1599. /* Draw is complete, sorting and filtering must be as well */
  1600. oSettings.bSorted = false;
  1601. oSettings.bFiltered = false;
  1602. oSettings.bDrawing = false;
  1603. }
  1604. /**
  1605. * Redraw the table - taking account of the various features which are enabled
  1606. * @param {object} oSettings dataTables settings object
  1607. * @param {boolean} [holdPosition] Keep the current paging position. By default
  1608. * the paging is reset to the first page
  1609. * @memberof DataTable#oApi
  1610. */
  1611. function _fnReDraw( settings, holdPosition )
  1612. {
  1613. var
  1614. features = settings.oFeatures,
  1615. sort = features.bSort,
  1616. filter = features.bFilter;
  1617. if ( sort ) {
  1618. _fnSort( settings );
  1619. }
  1620. if ( filter ) {
  1621. _fnFilterComplete( settings, settings.oPreviousSearch );
  1622. }
  1623. else {
  1624. // No filtering, so we want to just use the display master
  1625. settings.aiDisplay = settings.aiDisplayMaster.slice();
  1626. }
  1627. if ( holdPosition !== true ) {
  1628. settings._iDisplayStart = 0;
  1629. }
  1630. _fnDraw( settings );
  1631. }
  1632. /**
  1633. * Add the options to the page HTML for the table
  1634. * @param {object} oSettings dataTables settings object
  1635. * @memberof DataTable#oApi
  1636. */
  1637. function _fnAddOptionsHtml ( oSettings )
  1638. {
  1639. /*
  1640. * Create a temporary, empty, div which we can later on replace with what we have generated
  1641. * we do it this way to rendering the 'options' html offline - speed :-)
  1642. */
  1643. var nHolding = $('<div></div>')[0];
  1644. oSettings.nTable.parentNode.insertBefore( nHolding, oSettings.nTable );
  1645. /*
  1646. * All DataTables are wrapped in a div
  1647. */
  1648. oSettings.nTableWrapper = $('<div id="'+oSettings.sTableId+'_wrapper" class="'+oSettings.oClasses.sWrapper+'" role="grid"></div>')[0];
  1649. oSettings.nTableReinsertBefore = oSettings.nTable.nextSibling;
  1650. /* Track where we want to insert the option */
  1651. var nInsertNode = oSettings.nTableWrapper;
  1652. /* Loop over the user set positioning and place the elements as needed */
  1653. var aDom = oSettings.sDom.split('');
  1654. var nTmp, iPushFeature, cOption, nNewNode, cNext, sAttr, j;
  1655. for ( var i=0 ; i<aDom.length ; i++ )
  1656. {
  1657. iPushFeature = 0;
  1658. cOption = aDom[i];
  1659. if ( cOption == '<' )
  1660. {
  1661. /* New container div */
  1662. nNewNode = $('<div></div>')[0];
  1663. /* Check to see if we should append an id and/or a class name to the container */
  1664. cNext = aDom[i+1];
  1665. if ( cNext == "'" || cNext == '"' )
  1666. {
  1667. sAttr = "";
  1668. j = 2;
  1669. while ( aDom[i+j] != cNext )
  1670. {
  1671. sAttr += aDom[i+j];
  1672. j++;
  1673. }
  1674. /* Replace jQuery UI constants @todo depreciated */
  1675. if ( sAttr == "H" )
  1676. {
  1677. sAttr = oSettings.oClasses.sJUIHeader;
  1678. }
  1679. else if ( sAttr == "F" )
  1680. {
  1681. sAttr = oSettings.oClasses.sJUIFooter;
  1682. }
  1683. /* The attribute can be in the format of "#id.class", "#id" or "class" This logic
  1684. * breaks the string into parts and applies them as needed
  1685. */
  1686. if ( sAttr.indexOf('.') != -1 )
  1687. {
  1688. var aSplit = sAttr.split('.');
  1689. nNewNode.id = aSplit[0].substr(1, aSplit[0].length-1);
  1690. nNewNode.className = aSplit[1];
  1691. }
  1692. else if ( sAttr.charAt(0) == "#" )
  1693. {
  1694. nNewNode.id = sAttr.substr(1, sAttr.length-1);
  1695. }
  1696. else
  1697. {
  1698. nNewNode.className = sAttr;
  1699. }
  1700. i += j; /* Move along the position array */
  1701. }
  1702. nInsertNode.appendChild( nNewNode );
  1703. nInsertNode = nNewNode;
  1704. }
  1705. else if ( cOption == '>' )
  1706. {
  1707. /* End container div */
  1708. nInsertNode = nInsertNode.parentNode;
  1709. }
  1710. // @todo Move options into their own plugins?
  1711. else if ( cOption == 'l' && oSettings.oFeatures.bPaginate && oSettings.oFeatures.bLengthChange )
  1712. {
  1713. /* Length */
  1714. nTmp = _fnFeatureHtmlLength( oSettings );
  1715. iPushFeature = 1;
  1716. }
  1717. else if ( cOption == 'f' && oSettings.oFeatures.bFilter )
  1718. {
  1719. /* Filter */
  1720. nTmp = _fnFeatureHtmlFilter( oSettings );
  1721. iPushFeature = 1;
  1722. }
  1723. else if ( cOption == 'r' && oSettings.oFeatures.bProcessing )
  1724. {
  1725. /* pRocessing */
  1726. nTmp = _fnFeatureHtmlProcessing( oSettings );
  1727. iPushFeature = 1;
  1728. }
  1729. else if ( cOption == 't' )
  1730. {
  1731. /* Table */
  1732. nTmp = _fnFeatureHtmlTable( oSettings );
  1733. iPushFeature = 1;
  1734. }
  1735. else if ( cOption == 'i' && oSettings.oFeatures.bInfo )
  1736. {
  1737. /* Info */
  1738. nTmp = _fnFeatureHtmlInfo( oSettings );
  1739. iPushFeature = 1;
  1740. }
  1741. else if ( cOption == 'p' && oSettings.oFeatures.bPaginate )
  1742. {
  1743. /* Pagination */
  1744. nTmp = _fnFeatureHtmlPaginate( oSettings );
  1745. iPushFeature = 1;
  1746. }
  1747. else if ( DataTable.ext.feature.length !== 0 )
  1748. {
  1749. /* Plug-in features */
  1750. var aoFeatures = DataTable.ext.feature;
  1751. for ( var k=0, kLen=aoFeatures.length ; k<kLen ; k++ )
  1752. {
  1753. if ( cOption == aoFeatures[k].cFeature )
  1754. {
  1755. nTmp = aoFeatures[k].fnInit( oSettings );
  1756. if ( nTmp )
  1757. {
  1758. iPushFeature = 1;
  1759. }
  1760. break;
  1761. }
  1762. }
  1763. }
  1764. /* Add to the 2D features array */
  1765. if ( iPushFeature == 1 && nTmp !== null )
  1766. {
  1767. if ( typeof oSettings.aanFeatures[cOption] !== 'object' )
  1768. {
  1769. oSettings.aanFeatures[cOption] = [];
  1770. }
  1771. oSettings.aanFeatures[cOption].push( nTmp );
  1772. nInsertNode.appendChild( nTmp );
  1773. }
  1774. }
  1775. /* Built our DOM structure - replace the holding div with what we want */
  1776. nHolding.parentNode.replaceChild( oSettings.nTableWrapper, nHolding );
  1777. }
  1778. /**
  1779. * Use the DOM source to create up an array of header cells. The idea here is to
  1780. * create a layout grid (array) of rows x columns, which contains a reference
  1781. * to the cell that that point in the grid (regardless of col/rowspan), such that
  1782. * any column / row could be removed and the new grid constructed
  1783. * @param array {object} aLayout Array to store the calculated layout in
  1784. * @param {node} nThead The header/footer element for the table
  1785. * @memberof DataTable#oApi
  1786. */
  1787. function _fnDetectHeader ( aLayout, nThead )
  1788. {
  1789. var nTrs = $(nThead).children('tr');
  1790. var nTr, nCell;
  1791. var i, k, l, iLen, jLen, iColShifted, iColumn, iColspan, iRowspan;
  1792. var bUnique;
  1793. var fnShiftCol = function ( a, i, j ) {
  1794. var k = a[i];
  1795. while ( k[j] ) {
  1796. j++;
  1797. }
  1798. return j;
  1799. };
  1800. aLayout.splice( 0, aLayout.length );
  1801. /* We know how many rows there are in the layout - so prep it */
  1802. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  1803. {
  1804. aLayout.push( [] );
  1805. }
  1806. /* Calculate a layout array */
  1807. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  1808. {
  1809. nTr = nTrs[i];
  1810. iColumn = 0;
  1811. /* For every cell in the row... */
  1812. nCell = nTr.firstChild;
  1813. while ( nCell ) {
  1814. if ( nCell.nodeName.toUpperCase() == "TD" ||
  1815. nCell.nodeName.toUpperCase() == "TH" )
  1816. {
  1817. /* Get the col and rowspan attributes from the DOM and sanitise them */
  1818. iColspan = nCell.getAttribute('colspan') * 1;
  1819. iRowspan = nCell.getAttribute('rowspan') * 1;
  1820. iColspan = (!iColspan || iColspan===0 || iColspan===1) ? 1 : iColspan;
  1821. iRowspan = (!iRowspan || iRowspan===0 || iRowspan===1) ? 1 : iRowspan;
  1822. /* There might be colspan cells already in this row, so shift our target
  1823. * accordingly
  1824. */
  1825. iColShifted = fnShiftCol( aLayout, i, iColumn );
  1826. /* Cache calculation for unique columns */
  1827. bUnique = iColspan === 1 ? true : false;
  1828. /* If there is col / rowspan, copy the information into the layout grid */
  1829. for ( l=0 ; l<iColspan ; l++ )
  1830. {
  1831. for ( k=0 ; k<iRowspan ; k++ )
  1832. {
  1833. aLayout[i+k][iColShifted+l] = {
  1834. "cell": nCell,
  1835. "unique": bUnique
  1836. };
  1837. aLayout[i+k].nTr = nTr;
  1838. }
  1839. }
  1840. }
  1841. nCell = nCell.nextSibling;
  1842. }
  1843. }
  1844. }
  1845. /**
  1846. * Get an array of unique th elements, one for each column
  1847. * @param {object} oSettings dataTables settings object
  1848. * @param {node} nHeader automatically detect the layout from this node - optional
  1849. * @param {array} aLayout thead/tfoot layout from _fnDetectHeader - optional
  1850. * @returns array {node} aReturn list of unique th's
  1851. * @memberof DataTable#oApi
  1852. */
  1853. function _fnGetUniqueThs ( oSettings, nHeader, aLayout )
  1854. {
  1855. var aReturn = [];
  1856. if ( !aLayout )
  1857. {
  1858. aLayout = oSettings.aoHeader;
  1859. if ( nHeader )
  1860. {
  1861. aLayout = [];
  1862. _fnDetectHeader( aLayout, nHeader );
  1863. }
  1864. }
  1865. for ( var i=0, iLen=aLayout.length ; i<iLen ; i++ )
  1866. {
  1867. for ( var j=0, jLen=aLayout[i].length ; j<jLen ; j++ )
  1868. {
  1869. if ( aLayout[i][j].unique &&
  1870. (!aReturn[j] || !oSettings.bSortCellsTop) )
  1871. {
  1872. aReturn[j] = aLayout[i][j].cell;
  1873. }
  1874. }
  1875. }
  1876. return aReturn;
  1877. }
  1878. /**
  1879. * Create an Ajax call based on the table's settings, taking into account that
  1880. * parameters can have multiple forms, and backwards compatibility.
  1881. *
  1882. * @param {object} oSettings dataTables settings object
  1883. * @param {array} data Data to send to the server, required by
  1884. * DataTables - may be augmented by developer callbacks
  1885. * @param {function} fn Callback function to run when data is obtained
  1886. */
  1887. function _fnBuildAjax( oSettings, data, fn )
  1888. {
  1889. // Compatibility with 1.9-, allow fnServerData and event to manipulate
  1890. _fnCallbackFire( oSettings, 'aoServerParams', 'serverParams', [data] );
  1891. // Convert to object based for 1.10+ if using the old scheme
  1892. if ( data && data.__legacy ) {
  1893. var tmp = {};
  1894. var rbracket = /(.*?)\[\]$/;
  1895. $.each( data, function (key, val) {
  1896. var match = val.name.match(rbracket);
  1897. if ( match ) {
  1898. // Support for arrays
  1899. var name = match[0];
  1900. if ( ! tmp[ name ] ) {
  1901. tmp[ name ] = [];
  1902. }
  1903. tmp[ name ].push( val.value );
  1904. }
  1905. else {
  1906. tmp[val.name] = val.value;
  1907. }
  1908. } );
  1909. data = tmp;
  1910. }
  1911. var ajaxData;
  1912. var ajax = oSettings.ajax;
  1913. var instance = oSettings.oInstance;
  1914. if ( $.isPlainObject( ajax ) && ajax.data )
  1915. {
  1916. ajaxData = ajax.data;
  1917. var newData = $.isFunction( ajaxData ) ?
  1918. ajaxData( data ) : // fn can manipulate data or return an object
  1919. ajaxData; // object or array to merge
  1920. // If the function returned an object, use that alone
  1921. data = $.isFunction( ajaxData ) && newData ?
  1922. newData :
  1923. $.extend( true, data, newData );
  1924. // Remove the data property as we've resolved it already and don't want
  1925. // jQuery to do it again (it is restored at the end of the function)
  1926. delete ajax.data;
  1927. }
  1928. var baseAjax = {
  1929. "data": data,
  1930. "success": function (json) {
  1931. var error = json.error || json.sError;
  1932. if ( error ) {
  1933. oSettings.oApi._fnLog( oSettings, 0, error );
  1934. }
  1935. oSettings.json = json;
  1936. _fnCallbackFire( oSettings, null, 'xhr', [oSettings, json] );
  1937. fn( json );
  1938. },
  1939. "dataType": "json",
  1940. "cache": false,
  1941. "type": oSettings.sServerMethod,
  1942. "error": function (xhr, error, thrown) {
  1943. var log = oSettings.oApi._fnLog;
  1944. if ( error == "parsererror" ) {
  1945. log( oSettings, 0, 'Invalid JSON response', 1 );
  1946. }
  1947. else {
  1948. log( oSettings, 0, 'Ajax error', 7 );
  1949. }
  1950. }
  1951. };
  1952. if ( oSettings.fnServerData )
  1953. {
  1954. // DataTables 1.9- compatibility
  1955. oSettings.fnServerData.call( instance,
  1956. oSettings.sAjaxSource, data, fn, oSettings
  1957. );
  1958. }
  1959. else if ( oSettings.sAjaxSource || typeof ajax === 'string' )
  1960. {
  1961. // DataTables 1.9- compatibility
  1962. oSettings.jqXHR = $.ajax( $.extend( baseAjax, {
  1963. url: ajax || oSettings.sAjaxSource
  1964. } ) );
  1965. }
  1966. else if ( $.isFunction( ajax ) )
  1967. {
  1968. // Is a function - let the caller define what needs to be done
  1969. oSettings.jqXHR = ajax.call( instance, data, fn, oSettings );
  1970. }
  1971. else
  1972. {
  1973. // Object to extend the base settings
  1974. oSettings.jqXHR = $.ajax( $.extend( baseAjax, ajax ) );
  1975. // Restore for next time around
  1976. ajax.data = ajaxData;
  1977. }
  1978. }
  1979. /**
  1980. * Update the table using an Ajax call
  1981. * @param {object} oSettings dataTables settings object
  1982. * @returns {boolean} Block the table drawing or not
  1983. * @memberof DataTable#oApi
  1984. */
  1985. function _fnAjaxUpdate( oSettings )
  1986. {
  1987. if ( oSettings.bAjaxDataGet )
  1988. {
  1989. oSettings.iDraw++;
  1990. _fnProcessingDisplay( oSettings, true );
  1991. var iColumns = oSettings.aoColumns.length;
  1992. var aoData = _fnAjaxParameters( oSettings );
  1993. _fnBuildAjax( oSettings, aoData, function(json) {
  1994. _fnAjaxUpdateDraw( oSettings, json );
  1995. }, oSettings );
  1996. return false;
  1997. }
  1998. return true;
  1999. }
  2000. /**
  2001. * Build up the parameters in an object needed for a server-side processing
  2002. * request. Note that this is basically done twice, is different ways - a modern
  2003. * method which is used by default in DataTables 1.10 which uses objects and
  2004. * arrays, or the 1.9- method with is name / value pairs. 1.9 method is used if
  2005. * the sAjaxSource option is used in the initialisation, or the legacyAjax
  2006. * option is set.
  2007. * @param {object} oSettings dataTables settings object
  2008. * @returns {bool} block the table drawing or not
  2009. * @memberof DataTable#oApi
  2010. */
  2011. function _fnAjaxParameters( settings )
  2012. {
  2013. var
  2014. columns = settings.aoColumns,
  2015. columnCount = columns.length,
  2016. features = settings.oFeatures,
  2017. preSearch = settings.oPreviousSearch,
  2018. preColSearch = settings.aoPreSearchCols,
  2019. i, data = [], dataProp, column, columnSearch,
  2020. sort = _fnSortFlatten( settings ),
  2021. displayStart = settings._iDisplayStart,
  2022. displayLength = features.bPaginate !== false ?
  2023. settings._iDisplayLength :
  2024. -1;
  2025. var param = function ( name, value ) {
  2026. data.push( { 'name': name, 'value': value } );
  2027. };
  2028. // DataTables 1.9- compatible method
  2029. param( 'sEcho', settings.iDraw );
  2030. param( 'iColumns', columnCount );
  2031. param( 'sColumns', _pluck( columns, 'sName' ).join(',') );
  2032. param( 'iDisplayStart', displayStart );
  2033. param( 'iDisplayLength', displayLength );
  2034. // DataTables 1.10+ method
  2035. var d = {
  2036. draw: settings.iDraw,
  2037. columns: [],
  2038. order: [],
  2039. start: displayStart,
  2040. length: displayLength,
  2041. search: {
  2042. value: preSearch.sSearch,
  2043. regex: preSearch.bRegex
  2044. }
  2045. };
  2046. for ( i=0 ; i<columnCount ; i++ ) {
  2047. column = columns[i];
  2048. columnSearch = preColSearch[i];
  2049. dataProp = typeof column.mData=="function" ? 'function' : column.mData ;
  2050. d.columns.push( {
  2051. data: dataProp,
  2052. name: column.sName,
  2053. searchable: column.bSearchable,
  2054. orderable: column.bSortable,
  2055. search: {
  2056. value: columnSearch.sSearch,
  2057. regex: columnSearch.bRegex
  2058. }
  2059. } );
  2060. param( "mDataProp_"+i, dataProp );
  2061. if ( features.bFilter ) {
  2062. param( 'sSearch_'+i, columnSearch.sSearch );
  2063. param( 'bRegex_'+i, columnSearch.bRegex );
  2064. param( 'bSearchable_'+i, column.bSearchable );
  2065. }
  2066. if ( features.bSort ) {
  2067. param( 'bSortable_'+i, column.bSortable );
  2068. }
  2069. }
  2070. $.each( sort, function ( i, val ) {
  2071. d.order.push( { column: val.col, dir: val.dir } );
  2072. param( 'iSortCol_'+i, val.col );
  2073. param( 'sSortDir_'+i, val.dir );
  2074. } );
  2075. if ( features.bFilter ) {
  2076. param( 'sSearch', preSearch.sSearch );
  2077. param( 'bRegex', preSearch.bRegex );
  2078. }
  2079. if ( features.bSort ) {
  2080. param( 'iSortingCols', sort.length );
  2081. }
  2082. data.__legacy = true;
  2083. return settings.sAjaxSource || DataTable.ext.legacy.ajax ?
  2084. data : d;
  2085. }
  2086. /**
  2087. * Data the data from the server (nuking the old) and redraw the table
  2088. * @param {object} oSettings dataTables settings object
  2089. * @param {object} json json data return from the server.
  2090. * @param {string} json.sEcho Tracking flag for DataTables to match requests
  2091. * @param {int} json.iTotalRecords Number of records in the data set, not accounting for filtering
  2092. * @param {int} json.iTotalDisplayRecords Number of records in the data set, accounting for filtering
  2093. * @param {array} json.aaData The data to display on this page
  2094. * @param {string} [json.sColumns] Column ordering (sName, comma separated)
  2095. * @memberof DataTable#oApi
  2096. */
  2097. function _fnAjaxUpdateDraw ( settings, json )
  2098. {
  2099. // v1.10 uses camelCase variables, while 1.9 uses Hungarian notation.
  2100. // Support both
  2101. var compat = function ( old, modern ) {
  2102. return json[old] !== undefined ? json[old] : json[modern];
  2103. };
  2104. var draw = compat( 'sEcho', 'draw' );
  2105. var recordsTotal = compat( 'iTotalRecords', 'recordsTotal' );
  2106. var rocordsFiltered = compat( 'iTotalDisplayRecords', 'recordsFiltered' );
  2107. if ( draw ) {
  2108. // Protect against out of sequence returns
  2109. if ( draw*1 < settings.iDraw ) {
  2110. return;
  2111. }
  2112. settings.iDraw = draw * 1;
  2113. }
  2114. _fnClearTable( settings );
  2115. settings._iRecordsTotal = parseInt(recordsTotal, 10);
  2116. settings._iRecordsDisplay = parseInt(rocordsFiltered, 10);
  2117. var data = _fnAjaxDataSrc( settings, json );
  2118. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  2119. _fnAddData( settings, data[i] );
  2120. }
  2121. settings.aiDisplay = settings.aiDisplayMaster.slice();
  2122. settings.bAjaxDataGet = false;
  2123. _fnDraw( settings );
  2124. if ( ! settings._bInitComplete ) {
  2125. _fnInitComplete( settings, json );
  2126. }
  2127. settings.bAjaxDataGet = true;
  2128. _fnProcessingDisplay( settings, false );
  2129. }
  2130. /**
  2131. * Get the data from the JSON data source to use for drawing a table. Using
  2132. * `_fnGetObjectDataFn` allows the data to be sourced from a property of the
  2133. * source object, or from a processing function.
  2134. * @param {object} oSettings dataTables settings object
  2135. * @param {object} json Data source object / array from the server
  2136. * @return {array} Array of data to use
  2137. */
  2138. function _fnAjaxDataSrc ( oSettings, json )
  2139. {
  2140. var dataSrc = $.isPlainObject( oSettings.ajax ) && oSettings.ajax.dataSrc !== undefined ?
  2141. oSettings.ajax.dataSrc :
  2142. oSettings.sAjaxDataProp; // Compatibility with 1.9-.
  2143. // Compatibility with 1.9-. In order to read from aaData, check if the
  2144. // default has been changed, if not, check for aaData
  2145. if ( dataSrc === 'data' ) {
  2146. return json.aaData || json[dataSrc];
  2147. }
  2148. return dataSrc !== "" ?
  2149. _fnGetObjectDataFn( dataSrc )( json ) :
  2150. json;
  2151. }
  2152. /**
  2153. * Generate the node required for filtering text
  2154. * @returns {node} Filter control element
  2155. * @param {object} oSettings dataTables settings object
  2156. * @memberof DataTable#oApi
  2157. */
  2158. function _fnFeatureHtmlFilter ( settings )
  2159. {
  2160. var classes = settings.oClasses;
  2161. var tableId = settings.sTableId;
  2162. var previousSearch = settings.oPreviousSearch;
  2163. var features = settings.aanFeatures;
  2164. var input = '<input type="search" class="'+classes.sFilterInput+'"/>';
  2165. var str = settings.oLanguage.sSearch;
  2166. str = str.match(/_INPUT_/) ?
  2167. str.replace('_INPUT_', input) :
  2168. str+input;
  2169. var filter = $('<div/>', {
  2170. 'id': ! features.f ? tableId+'_filter' : null,
  2171. 'class': classes.sFilter
  2172. } )
  2173. .append( $('<label/>' ).append( str ) );
  2174. var jqFilter = $('input[type="search"]', filter)
  2175. .val( previousSearch.sSearch.replace('"','&quot;') )
  2176. .bind( 'keyup.DT search.DT input.DT paste.DT cut.DT', function(e) {
  2177. /* Update all other filter input elements for the new display */
  2178. var n = features.f;
  2179. var val = !this.value ? "" : this.value; // mental IE8 fix :-(
  2180. /* Now do the filter */
  2181. if ( val != previousSearch.sSearch ) {
  2182. _fnFilterComplete( settings, {
  2183. "sSearch": val,
  2184. "bRegex": previousSearch.bRegex,
  2185. "bSmart": previousSearch.bSmart ,
  2186. "bCaseInsensitive": previousSearch.bCaseInsensitive
  2187. } );
  2188. // Need to redraw, without resorting
  2189. settings._iDisplayStart = 0;
  2190. _fnDraw( settings );
  2191. }
  2192. } )
  2193. .bind( 'keypress.DT', function(e) {
  2194. /* Prevent form submission */
  2195. if ( e.keyCode == 13 ) {
  2196. return false;
  2197. }
  2198. } )
  2199. .attr('aria-controls', tableId);
  2200. // Update the input elements whenever the table is filtered
  2201. $(settings.nTable).on( 'filter.DT', function () {
  2202. // IE9 throws an 'unknown error' if document.activeElement is used
  2203. // inside an iframe or frame...
  2204. try {
  2205. if ( jqFilter[0] !== document.activeElement ) {
  2206. jqFilter.val( previousSearch.sSearch );
  2207. }
  2208. }
  2209. catch ( e ) {}
  2210. } );
  2211. return filter[0];
  2212. }
  2213. /**
  2214. * Filter the table using both the global filter and column based filtering
  2215. * @param {object} oSettings dataTables settings object
  2216. * @param {object} oSearch search information
  2217. * @param {int} [iForce] force a research of the master array (1) or not (undefined or 0)
  2218. * @memberof DataTable#oApi
  2219. */
  2220. function _fnFilterComplete ( oSettings, oInput, iForce )
  2221. {
  2222. var oPrevSearch = oSettings.oPreviousSearch;
  2223. var aoPrevSearch = oSettings.aoPreSearchCols;
  2224. var fnSaveFilter = function ( oFilter ) {
  2225. /* Save the filtering values */
  2226. oPrevSearch.sSearch = oFilter.sSearch;
  2227. oPrevSearch.bRegex = oFilter.bRegex;
  2228. oPrevSearch.bSmart = oFilter.bSmart;
  2229. oPrevSearch.bCaseInsensitive = oFilter.bCaseInsensitive;
  2230. };
  2231. // Resolve any column types that are unknown due to addition or invalidation
  2232. // @todo As per sort - can this be moved into an event handler?
  2233. _fnColumnTypes( oSettings );
  2234. /* In server-side processing all filtering is done by the server, so no point hanging around here */
  2235. if ( _fnDataSource( oSettings ) != 'ssp' )
  2236. {
  2237. /* Global filter */
  2238. _fnFilter( oSettings, oInput.sSearch, iForce, oInput.bRegex, oInput.bSmart, oInput.bCaseInsensitive );
  2239. fnSaveFilter( oInput );
  2240. /* Now do the individual column filter */
  2241. for ( var i=0 ; i<aoPrevSearch.length ; i++ )
  2242. {
  2243. _fnFilterColumn( oSettings, aoPrevSearch[i].sSearch, i, aoPrevSearch[i].bRegex,
  2244. aoPrevSearch[i].bSmart, aoPrevSearch[i].bCaseInsensitive );
  2245. }
  2246. /* Custom filtering */
  2247. _fnFilterCustom( oSettings );
  2248. }
  2249. else
  2250. {
  2251. fnSaveFilter( oInput );
  2252. }
  2253. /* Tell the draw function we have been filtering */
  2254. oSettings.bFiltered = true;
  2255. _fnCallbackFire( oSettings, null, 'search', [oSettings] );
  2256. }
  2257. /**
  2258. * Apply custom filtering functions
  2259. * @param {object} oSettings dataTables settings object
  2260. * @memberof DataTable#oApi
  2261. */
  2262. function _fnFilterCustom( oSettings )
  2263. {
  2264. var afnFilters = DataTable.ext.search;
  2265. var aiFilterColumns = _fnGetColumns( oSettings, 'bSearchable' );
  2266. for ( var i=0, iLen=afnFilters.length ; i<iLen ; i++ )
  2267. {
  2268. var iCorrector = 0;
  2269. for ( var j=0, jLen=oSettings.aiDisplay.length ; j<jLen ; j++ )
  2270. {
  2271. var iDisIndex = oSettings.aiDisplay[j-iCorrector];
  2272. var bTest = afnFilters[i](
  2273. oSettings,
  2274. _fnGetRowData( oSettings, iDisIndex, 'filter', aiFilterColumns ),
  2275. iDisIndex
  2276. );
  2277. /* Check if we should use this row based on the filtering function */
  2278. if ( !bTest )
  2279. {
  2280. oSettings.aiDisplay.splice( j-iCorrector, 1 );
  2281. iCorrector++;
  2282. }
  2283. }
  2284. }
  2285. }
  2286. /**
  2287. * Filter the table on a per-column basis
  2288. * @param {object} oSettings dataTables settings object
  2289. * @param {string} sInput string to filter on
  2290. * @param {int} iColumn column to filter
  2291. * @param {bool} bRegex treat search string as a regular expression or not
  2292. * @param {bool} bSmart use smart filtering or not
  2293. * @param {bool} bCaseInsensitive Do case insenstive matching or not
  2294. * @memberof DataTable#oApi
  2295. */
  2296. function _fnFilterColumn ( settings, searchStr, colIdx, regex, smart, caseInsensitive )
  2297. {
  2298. if ( searchStr === '' ) {
  2299. return;
  2300. }
  2301. var data;
  2302. var display = settings.aiDisplay;
  2303. var rpSearch = _fnFilterCreateSearch( searchStr, regex, smart, caseInsensitive );
  2304. for ( var i=display.length-1 ; i>=0 ; i-- ) {
  2305. data = settings.aoData[ display[i] ]._aFilterData[ colIdx ];
  2306. if ( ! rpSearch.test( data ) ) {
  2307. display.splice( i, 1 );
  2308. }
  2309. }
  2310. }
  2311. /**
  2312. * Filter the data table based on user input and draw the table
  2313. * @param {object} settings dataTables settings object
  2314. * @param {string} input string to filter on
  2315. * @param {int} force optional - force a research of the master array (1) or not (undefined or 0)
  2316. * @param {bool} regex treat as a regular expression or not
  2317. * @param {bool} smart perform smart filtering or not
  2318. * @param {bool} caseInsensitive Do case insenstive matching or not
  2319. * @memberof DataTable#oApi
  2320. */
  2321. function _fnFilter( settings, input, force, regex, smart, caseInsensitive )
  2322. {
  2323. var rpSearch = _fnFilterCreateSearch( input, regex, smart, caseInsensitive );
  2324. var prevSearch = settings.oPreviousSearch.sSearch;
  2325. var displayMaster = settings.aiDisplayMaster;
  2326. var display, invalidated, i;
  2327. // Need to take account of custom filtering functions - always filter
  2328. if ( DataTable.ext.search.length !== 0 ) {
  2329. force = true;
  2330. }
  2331. // Check if any of the rows were invalidated
  2332. invalidated = _fnFilterData( settings );
  2333. // If the input is blank - we just want the full data set
  2334. if ( input.length <= 0 ) {
  2335. settings.aiDisplay = displayMaster.slice();
  2336. }
  2337. else {
  2338. // New search - start from the master array
  2339. if ( invalidated ||
  2340. force ||
  2341. prevSearch.length > input.length ||
  2342. input.indexOf(prevSearch) !== 0 ||
  2343. settings.bSorted // On resort, the display master needs to be
  2344. // re-filtered since indexes will have changed
  2345. ) {
  2346. settings.aiDisplay = displayMaster.slice();
  2347. }
  2348. // Search the display array
  2349. display = settings.aiDisplay;
  2350. for ( i=display.length-1 ; i>=0 ; i-- ) {
  2351. if ( ! rpSearch.test( settings.aoData[ display[i] ]._sFilterRow ) ) {
  2352. display.splice( i, 1 );
  2353. }
  2354. }
  2355. }
  2356. }
  2357. /**
  2358. * Build a regular expression object suitable for searching a table
  2359. * @param {string} sSearch string to search for
  2360. * @param {bool} bRegex treat as a regular expression or not
  2361. * @param {bool} bSmart perform smart filtering or not
  2362. * @param {bool} bCaseInsensitive Do case insensitive matching or not
  2363. * @returns {RegExp} constructed object
  2364. * @memberof DataTable#oApi
  2365. */
  2366. function _fnFilterCreateSearch( sSearch, bRegex, bSmart, bCaseInsensitive )
  2367. {
  2368. var asSearch,
  2369. sRegExpString = bRegex ? sSearch : _fnEscapeRegex( sSearch );
  2370. if ( bSmart )
  2371. {
  2372. /* Generate the regular expression to use. Something along the lines of:
  2373. * ^(?=.*?\bone\b)(?=.*?\btwo\b)(?=.*?\bthree\b).*$
  2374. */
  2375. asSearch = sRegExpString.split( ' ' );
  2376. sRegExpString = '^(?=.*?'+asSearch.join( ')(?=.*?' )+').*$';
  2377. }
  2378. return new RegExp( sRegExpString, bCaseInsensitive ? "i" : "" );
  2379. }
  2380. /**
  2381. * scape a string such that it can be used in a regular expression
  2382. * @param {string} sVal string to escape
  2383. * @returns {string} escaped string
  2384. * @memberof DataTable#oApi
  2385. */
  2386. function _fnEscapeRegex ( sVal )
  2387. {
  2388. var acEscape = [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^', '-' ];
  2389. var reReplace = new RegExp( '(\\' + acEscape.join('|\\') + ')', 'g' );
  2390. return sVal.replace(reReplace, '\\$1');
  2391. }
  2392. var __filter_div = $('<div>')[0];
  2393. var __filter_div_textContent = __filter_div.textContent !== undefined;
  2394. // Update the filtering data for each row if needed (by invalidation or first run)
  2395. function _fnFilterData ( settings )
  2396. {
  2397. var columns = settings.aoColumns;
  2398. var column;
  2399. var i, j, ien, jen, filterData, cellData, row;
  2400. var fomatters = DataTable.ext.type.search;
  2401. var wasInvalidated = false;
  2402. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  2403. row = settings.aoData[i];
  2404. if ( ! row._aFilterData ) {
  2405. filterData = [];
  2406. for ( j=0, jen=columns.length ; j<jen ; j++ ) {
  2407. column = columns[j];
  2408. if ( column.bSearchable ) {
  2409. cellData = _fnGetCellData( settings, i, j, 'filter' );
  2410. cellData = fomatters[ column.sType ] ?
  2411. fomatters[ column.sType ]( cellData ) :
  2412. cellData !== null ?
  2413. cellData :
  2414. '';
  2415. }
  2416. else {
  2417. cellData = '';
  2418. }
  2419. // If it looks like there is an HTML entity in the string,
  2420. // attempt to decode it so sorting works as expected. Note that
  2421. // we could use a single line of jQuery to do this, but the DOM
  2422. // method used here is much faster http://jsperf.com/html-decode
  2423. if ( cellData.indexOf && cellData.indexOf('&') !== -1 ) {
  2424. __filter_div.innerHTML = cellData;
  2425. cellData = __filter_div_textContent ?
  2426. __filter_div.textContent :
  2427. __filter_div.innerText;
  2428. cellData = cellData.replace(/[\r\n]/g, '');
  2429. }
  2430. filterData.push( cellData );
  2431. }
  2432. row._aFilterData = filterData;
  2433. row._sFilterRow = filterData.join(' ');
  2434. wasInvalidated = true;
  2435. }
  2436. }
  2437. return wasInvalidated;
  2438. }
  2439. /**
  2440. * Generate the node required for the info display
  2441. * @param {object} oSettings dataTables settings object
  2442. * @returns {node} Information element
  2443. * @memberof DataTable#oApi
  2444. */
  2445. function _fnFeatureHtmlInfo ( settings )
  2446. {
  2447. var
  2448. tid = settings.sTableId,
  2449. nodes = settings.aanFeatures.i,
  2450. n = $('<div/>', {
  2451. 'class': settings.oClasses.sInfo,
  2452. 'id': ! nodes ? tid+'_info' : null
  2453. } );
  2454. if ( ! nodes ) {
  2455. // Update display on each draw
  2456. settings.aoDrawCallback.push( {
  2457. "fn": _fnUpdateInfo,
  2458. "sName": "information"
  2459. } );
  2460. n
  2461. .attr( 'role', 'alert' )
  2462. .attr( 'aria-live', 'polite' )
  2463. .attr( 'aria-relevant', 'all' );
  2464. // Table is described by our info div
  2465. $(settings.nTable).attr( 'aria-describedby', tid+'_info' );
  2466. }
  2467. return n[0];
  2468. }
  2469. /**
  2470. * Update the information elements in the display
  2471. * @param {object} settings dataTables settings object
  2472. * @memberof DataTable#oApi
  2473. */
  2474. function _fnUpdateInfo ( settings )
  2475. {
  2476. /* Show information about the table */
  2477. var nodes = settings.aanFeatures.i;
  2478. if ( nodes.length === 0 ) {
  2479. return;
  2480. }
  2481. var
  2482. lang = settings.oLanguage,
  2483. start = settings._iDisplayStart+1,
  2484. end = settings.fnDisplayEnd(),
  2485. max = settings.fnRecordsTotal(),
  2486. total = settings.fnRecordsDisplay(),
  2487. out = total ?
  2488. lang.sInfo :
  2489. lang.sInfoEmpty;
  2490. if ( total !== max ) {
  2491. /* Record set after filtering */
  2492. out += ' ' + lang.sInfoFiltered;
  2493. }
  2494. // Convert the macros
  2495. out += lang.sInfoPostFix;
  2496. out = _fnInfoMacros( settings, out );
  2497. var callback = lang.fnInfoCallback;
  2498. if ( callback !== null ) {
  2499. out = callback.call( settings.oInstance,
  2500. settings, start, end, max, total, out
  2501. );
  2502. }
  2503. $(nodes).html( out );
  2504. }
  2505. function _fnInfoMacros ( settings, str )
  2506. {
  2507. // When infinite scrolling, we are always starting at 1. _iDisplayStart is used only
  2508. // internally
  2509. var
  2510. formatter = settings.fnFormatNumber,
  2511. start = settings._iDisplayStart+1,
  2512. len = settings._iDisplayLength,
  2513. vis = settings.fnRecordsDisplay(),
  2514. all = len === -1;
  2515. return str.
  2516. replace(/_START_/g, formatter.call( settings, start ) ).
  2517. replace(/_END_/g, formatter.call( settings, settings.fnDisplayEnd() ) ).
  2518. replace(/_MAX_/g, formatter.call( settings, settings.fnRecordsTotal() ) ).
  2519. replace(/_TOTAL_/g, formatter.call( settings, vis ) ).
  2520. replace(/_PAGE_/g, formatter.call( settings, all ? 1 : Math.ceil( start / len ) ) ).
  2521. replace(/_PAGES_/g, formatter.call( settings, all ? 1 : Math.ceil( vis / len ) ) );
  2522. }
  2523. /**
  2524. * Draw the table for the first time, adding all required features
  2525. * @param {object} settings dataTables settings object
  2526. * @memberof DataTable#oApi
  2527. */
  2528. function _fnInitialise ( settings )
  2529. {
  2530. var i, iLen, iAjaxStart=settings.iInitDisplayStart;
  2531. var columns = settings.aoColumns, column;
  2532. var features = settings.oFeatures;
  2533. /* Ensure that the table data is fully initialised */
  2534. if ( ! settings.bInitialised ) {
  2535. setTimeout( function(){ _fnInitialise( settings ); }, 200 );
  2536. return;
  2537. }
  2538. /* Show the display HTML options */
  2539. _fnAddOptionsHtml( settings );
  2540. /* Build and draw the header / footer for the table */
  2541. _fnBuildHead( settings );
  2542. _fnDrawHead( settings, settings.aoHeader );
  2543. _fnDrawHead( settings, settings.aoFooter );
  2544. /* Okay to show that something is going on now */
  2545. _fnProcessingDisplay( settings, true );
  2546. /* Calculate sizes for columns */
  2547. if ( features.bAutoWidth ) {
  2548. _fnCalculateColumnWidths( settings );
  2549. }
  2550. for ( i=0, iLen=columns.length ; i<iLen ; i++ ) {
  2551. column = columns[i];
  2552. if ( column.sWidth ) {
  2553. column.nTh.style.width = _fnStringToCss( column.sWidth );
  2554. }
  2555. }
  2556. // If there is default sorting required - let's do it. The sort function
  2557. // will do the drawing for us. Otherwise we draw the table regardless of the
  2558. // Ajax source - this allows the table to look initialised for Ajax sourcing
  2559. // data (show 'loading' message possibly)
  2560. _fnReDraw( settings );
  2561. // Server-side processing init complete is done by _fnAjaxUpdateDraw
  2562. var dataSrc = _fnDataSource( settings );
  2563. if ( dataSrc != 'ssp' ) {
  2564. // if there is an ajax source load the data
  2565. if ( dataSrc == 'ajax' ) {
  2566. _fnBuildAjax( settings, [], function(json) {
  2567. var aData = _fnAjaxDataSrc( settings, json );
  2568. // Got the data - add it to the table
  2569. for ( i=0 ; i<aData.length ; i++ ) {
  2570. _fnAddData( settings, aData[i] );
  2571. }
  2572. // Reset the init display for cookie saving. We've already done
  2573. // a filter, and therefore cleared it before. So we need to make
  2574. // it appear 'fresh'
  2575. settings.iInitDisplayStart = iAjaxStart;
  2576. _fnReDraw( settings );
  2577. _fnProcessingDisplay( settings, false );
  2578. _fnInitComplete( settings, json );
  2579. }, settings );
  2580. }
  2581. else {
  2582. _fnProcessingDisplay( settings, false );
  2583. _fnInitComplete( settings );
  2584. }
  2585. }
  2586. }
  2587. /**
  2588. * Draw the table for the first time, adding all required features
  2589. * @param {object} oSettings dataTables settings object
  2590. * @param {object} [json] JSON from the server that completed the table, if using Ajax source
  2591. * with client-side processing (optional)
  2592. * @memberof DataTable#oApi
  2593. */
  2594. function _fnInitComplete ( settings, json )
  2595. {
  2596. settings._bInitComplete = true;
  2597. // On an Ajax load we now have data and therefore want to apply the column
  2598. // sizing
  2599. if ( json ) {
  2600. _fnAdjustColumnSizing( settings );
  2601. }
  2602. _fnCallbackFire( settings, 'aoInitComplete', 'init', [settings, json] );
  2603. }
  2604. function _fnLengthChange ( settings, val )
  2605. {
  2606. var len = parseInt( val, 10 );
  2607. settings._iDisplayLength = len;
  2608. _fnLengthOverflow( settings );
  2609. // Fire length change event
  2610. _fnCallbackFire( settings, null, 'length', [settings, len] );
  2611. }
  2612. /**
  2613. * Generate the node required for user display length changing
  2614. * @param {object} settings dataTables settings object
  2615. * @returns {node} Display length feature node
  2616. * @memberof DataTable#oApi
  2617. */
  2618. function _fnFeatureHtmlLength ( settings )
  2619. {
  2620. var
  2621. classes = settings.oClasses,
  2622. tableId = settings.sTableId,
  2623. menu = settings.aLengthMenu,
  2624. d2 = $.isArray( menu[0] ),
  2625. lengths = d2 ? menu[0] : menu,
  2626. language = d2 ? menu[1] : menu;
  2627. var select = $('<select/>', {
  2628. 'name': tableId+'_length',
  2629. 'aria-controls': tableId,
  2630. 'class': classes.sLengthSelect
  2631. } );
  2632. for ( var i=0, ien=lengths.length ; i<ien ; i++ ) {
  2633. select[0][ i ] = new Option( language[i], lengths[i] );
  2634. }
  2635. var div = $('<div><label/></div>').addClass( classes.sLength );
  2636. if ( ! settings.aanFeatures.l ) {
  2637. div[0].id = tableId+'_length';
  2638. }
  2639. // This split doesn't matter where _MENU_ is, we get three items back from it
  2640. var a = settings.oLanguage.sLengthMenu.split(/(_MENU_)/);
  2641. div.children()
  2642. .append( a[0] )
  2643. .append( select )
  2644. .append( a[2] );
  2645. select
  2646. .val( settings._iDisplayLength )
  2647. .bind( 'change.DT', function(e) {
  2648. _fnLengthChange( settings, $(this).val() );
  2649. _fnDraw( settings );
  2650. } );
  2651. // Update node value whenever anything changes the table's length
  2652. $(settings.nTable).bind( 'length', function (e, s, len) {
  2653. select.val( len );
  2654. } );
  2655. return div[0];
  2656. }
  2657. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  2658. * Note that most of the paging logic is done in
  2659. * DataTable.ext.pager
  2660. */
  2661. /**
  2662. * Generate the node required for default pagination
  2663. * @param {object} oSettings dataTables settings object
  2664. * @returns {node} Pagination feature node
  2665. * @memberof DataTable#oApi
  2666. */
  2667. function _fnFeatureHtmlPaginate ( settings )
  2668. {
  2669. var
  2670. type = settings.sPaginationType,
  2671. plugin = DataTable.ext.pager[ type ],
  2672. modern = typeof plugin === 'function',
  2673. redraw = function( settings ) {
  2674. _fnDraw( settings );
  2675. },
  2676. node = $('<div/>').addClass( settings.oClasses.sPaging + type )[0],
  2677. features = settings.aanFeatures;
  2678. if ( ! modern ) {
  2679. plugin.fnInit( settings, node, redraw );
  2680. }
  2681. /* Add a draw callback for the pagination on first instance, to update the paging display */
  2682. if ( ! features.p )
  2683. {
  2684. node.id = settings.sTableId+'_paginate';
  2685. settings.aoDrawCallback.push( {
  2686. "fn": function( settings ) {
  2687. if ( modern ) {
  2688. var
  2689. start = settings._iDisplayStart,
  2690. len = settings._iDisplayLength,
  2691. visRecords = settings.fnRecordsDisplay(),
  2692. all = len === -1,
  2693. page = all ? 0 : Math.ceil( start / len ),
  2694. pages = all ? 1 : Math.ceil( visRecords / len ),
  2695. buttons = plugin(page, pages),
  2696. i, ien;
  2697. for ( i=0, ien=features.p.length ; i<ien ; i++ ) {
  2698. _fnRenderer( settings, 'pageButton' )(
  2699. settings, features.p[i], i, buttons, page, pages
  2700. );
  2701. }
  2702. }
  2703. else {
  2704. plugin.fnUpdate( settings, redraw );
  2705. }
  2706. },
  2707. "sName": "pagination"
  2708. } );
  2709. }
  2710. return node;
  2711. }
  2712. /**
  2713. * Alter the display settings to change the page
  2714. * @param {object} settings DataTables settings object
  2715. * @param {string|int} action Paging action to take: "first", "previous",
  2716. * "next" or "last" or page number to jump to (integer)
  2717. * @param [bool] redraw Automatically draw the update or not
  2718. * @returns {bool} true page has changed, false - no change
  2719. * @memberof DataTable#oApi
  2720. */
  2721. function _fnPageChange ( settings, action, redraw )
  2722. {
  2723. var
  2724. start = settings._iDisplayStart,
  2725. len = settings._iDisplayLength,
  2726. records = settings.fnRecordsDisplay();
  2727. if ( records === 0 || len === -1 )
  2728. {
  2729. start = 0;
  2730. }
  2731. else if ( typeof action === "number" )
  2732. {
  2733. start = action * len;
  2734. if ( start > records )
  2735. {
  2736. start = 0;
  2737. }
  2738. }
  2739. else if ( action == "first" )
  2740. {
  2741. start = 0;
  2742. }
  2743. else if ( action == "previous" )
  2744. {
  2745. start = len >= 0 ?
  2746. start - len :
  2747. 0;
  2748. if ( start < 0 )
  2749. {
  2750. start = 0;
  2751. }
  2752. }
  2753. else if ( action == "next" )
  2754. {
  2755. if ( start + len < records )
  2756. {
  2757. start += len;
  2758. }
  2759. }
  2760. else if ( action == "last" )
  2761. {
  2762. start = Math.floor( (records-1) / len) * len;
  2763. }
  2764. else
  2765. {
  2766. _fnLog( settings, 0, "Unknown paging action: "+action, 5 );
  2767. }
  2768. var changed = settings._iDisplayStart !== start;
  2769. settings._iDisplayStart = start;
  2770. _fnCallbackFire( settings, null, 'page', [settings] );
  2771. if ( redraw ) {
  2772. _fnDraw( settings );
  2773. }
  2774. return changed;
  2775. }
  2776. /**
  2777. * Generate the node required for the processing node
  2778. * @param {object} settings dataTables settings object
  2779. * @returns {node} Processing element
  2780. * @memberof DataTable#oApi
  2781. */
  2782. function _fnFeatureHtmlProcessing ( settings )
  2783. {
  2784. return $('<div/>', {
  2785. 'id': ! settings.aanFeatures.r ? settings.sTableId+'_processing' : null,
  2786. 'class': settings.oClasses.sProcessing
  2787. } )
  2788. .html( settings.oLanguage.sProcessing )
  2789. .insertBefore( settings.nTable )[0];
  2790. }
  2791. /**
  2792. * Display or hide the processing indicator
  2793. * @param {object} settings dataTables settings object
  2794. * @param {bool} show Show the processing indicator (true) or not (false)
  2795. * @memberof DataTable#oApi
  2796. */
  2797. function _fnProcessingDisplay ( settings, show )
  2798. {
  2799. if ( settings.oFeatures.bProcessing ) {
  2800. $(settings.aanFeatures.r).css( 'visibility', show ? 'visible' : 'hidden' );
  2801. }
  2802. _fnCallbackFire( settings, null, 'processing', [settings, show] );
  2803. }
  2804. /**
  2805. * Add any control elements for the table - specifically scrolling
  2806. * @param {object} settings dataTables settings object
  2807. * @returns {node} Node to add to the DOM
  2808. * @memberof DataTable#oApi
  2809. */
  2810. function _fnFeatureHtmlTable ( settings )
  2811. {
  2812. var scroll = settings.oScroll;
  2813. if ( scroll.sX === '' && scroll.sY === '' ) {
  2814. return settings.nTable;
  2815. }
  2816. var scrollX = scroll.sX;
  2817. var scrollY = scroll.sY;
  2818. var classes = settings.oClasses;
  2819. var table = $(settings.nTable);
  2820. var caption = table.children('caption');
  2821. var captionSide = caption.length ? caption[0]._captionSide : null;
  2822. var headerClone = $( table[0].cloneNode(false) );
  2823. var footerClone = $( table[0].cloneNode(false) );
  2824. var footer = table.children('tfoot');
  2825. var _div = '<div/>';
  2826. var size = function ( s ) {
  2827. return !s ? null : _fnStringToCss( s );
  2828. };
  2829. if ( ! footer.length ) {
  2830. footer = null;
  2831. }
  2832. /*
  2833. * The HTML structure that we want to generate in this function is:
  2834. * div - scroller
  2835. * div - scroll head
  2836. * div - scroll head inner
  2837. * table - scroll head table
  2838. * thead - thead
  2839. * div - scroll body
  2840. * table - table (master table)
  2841. * thead - thead clone for sizing
  2842. * tbody - tbody
  2843. * div - scroll foot
  2844. * div - scroll foot inner
  2845. * table - scroll foot table
  2846. * tfoot - tfoot
  2847. */
  2848. var scroller = $( _div, { 'class': classes.sScrollWrapper } )
  2849. .append(
  2850. $(_div, { 'class': classes.sScrollHead } )
  2851. .css( {
  2852. overflow: 'hidden',
  2853. position: 'relative',
  2854. border: 0,
  2855. width: scrollX ? size(scrollX) : '100%'
  2856. } )
  2857. .append(
  2858. $(_div, { 'class': classes.sScrollHeadInner } )
  2859. .css( {
  2860. 'box-sizing': 'content-box',
  2861. width: scroll.sXInner || '100%'
  2862. } )
  2863. .append(
  2864. headerClone
  2865. .removeAttr('id')
  2866. .css( 'margin-left', 0 )
  2867. .append(
  2868. table.children('thead')
  2869. )
  2870. )
  2871. )
  2872. .append( captionSide === 'top' ? caption : null )
  2873. )
  2874. .append(
  2875. $(_div, { 'class': classes.sScrollBody } )
  2876. .css( {
  2877. overflow: 'auto',
  2878. height: size( scrollY ),
  2879. width: size( scrollX )
  2880. } )
  2881. .append( table )
  2882. );
  2883. if ( footer ) {
  2884. scroller.append(
  2885. $(_div, { 'class': classes.sScrollFoot } )
  2886. .css( {
  2887. overflow: 'hidden',
  2888. border: 0,
  2889. width: scrollX ? size(scrollX) : '100%'
  2890. } )
  2891. .append(
  2892. $(_div, { 'class': classes.sScrollFootInner } )
  2893. .append(
  2894. footerClone
  2895. .removeAttr('id')
  2896. .css( 'margin-left', 0 )
  2897. .append(
  2898. table.children('tfoot')
  2899. )
  2900. )
  2901. )
  2902. .append( captionSide === 'bottom' ? caption : null )
  2903. );
  2904. }
  2905. var children = scroller.children();
  2906. var scrollHead = children[0];
  2907. var scrollBody = children[1];
  2908. var scrollFoot = footer ? children[2] : null;
  2909. // When the body is scrolled, then we also want to scroll the headers
  2910. if ( scrollX ) {
  2911. $(scrollBody).scroll( function (e) {
  2912. var scrollLeft = this.scrollLeft;
  2913. scrollHead.scrollLeft = scrollLeft;
  2914. if ( footer ) {
  2915. scrollFoot.scrollLeft = scrollLeft;
  2916. }
  2917. } );
  2918. }
  2919. settings.nScrollHead = scrollHead;
  2920. settings.nScrollBody = scrollBody;
  2921. settings.nScrollFoot = scrollFoot;
  2922. // On redraw - align columns
  2923. settings.aoDrawCallback.push( {
  2924. "fn": _fnScrollDraw,
  2925. "sName": "scrolling"
  2926. } );
  2927. return scroller[0];
  2928. }
  2929. /**
  2930. * Update the header, footer and body tables for resizing - i.e. column
  2931. * alignment.
  2932. *
  2933. * Welcome to the most horrible function DataTables. The process that this
  2934. * function follows is basically:
  2935. * 1. Re-create the table inside the scrolling div
  2936. * 2. Take live measurements from the DOM
  2937. * 3. Apply the measurements to align the columns
  2938. * 4. Clean up
  2939. *
  2940. * @param {object} settings dataTables settings object
  2941. * @memberof DataTable#oApi
  2942. */
  2943. function _fnScrollDraw ( settings )
  2944. {
  2945. // Given that this is such a monster function, a lot of variables are use
  2946. // to try and keep the minimised size as small as possible
  2947. var
  2948. scroll = settings.oScroll,
  2949. scrollX = scroll.sX,
  2950. scrollXInner = scroll.sXInner,
  2951. scrollY = scroll.sY,
  2952. barWidth = scroll.iBarWidth,
  2953. divHeader = $(settings.nScrollHead),
  2954. divHeaderStyle = divHeader[0].style,
  2955. divHeaderInner = divHeader.children('div'),
  2956. divHeaderInnerStyle = divHeaderInner[0].style,
  2957. divHeaderTable = divHeaderInner.children('table'),
  2958. divBodyEl = settings.nScrollBody,
  2959. divBody = $(divBodyEl),
  2960. divBodyStyle = divBodyEl.style,
  2961. divFooter = $(settings.nScrollFoot),
  2962. divFooterInner = divFooter.children('div'),
  2963. divFooterTable = divFooterInner.children('table'),
  2964. header = $(settings.nTHead),
  2965. table = $(settings.nTable),
  2966. tableEl = table[0],
  2967. tableStyle = tableEl.style,
  2968. footer = settings.nTFoot ? $(settings.nTFoot) : null,
  2969. browser = settings.oBrowser,
  2970. ie67 = browser.bScrollOversize,
  2971. headerTrgEls, footerTrgEls,
  2972. headerSrcEls, footerSrcEls,
  2973. headerCopy, footerCopy,
  2974. headerWidths=[], footerWidths=[],
  2975. idx, correction, sanityWidth,
  2976. zeroOut = function(nSizer) {
  2977. var style = nSizer.style;
  2978. style.paddingTop = "0";
  2979. style.paddingBottom = "0";
  2980. style.borderTopWidth = "0";
  2981. style.borderBottomWidth = "0";
  2982. style.height = 0;
  2983. };
  2984. /*
  2985. * 1. Re-create the table inside the scrolling div
  2986. */
  2987. // Remove the old minimised thead and tfoot elements in the inner table
  2988. table.children('thead, tfoot').remove();
  2989. // Clone the current header and footer elements and then place it into the inner table
  2990. headerCopy = header.clone().prependTo( table );
  2991. headerTrgEls = header.find('tr'); // original header is in its own table
  2992. headerSrcEls = headerCopy.find('tr');
  2993. headerCopy.find('th, td').removeAttr('tabindex');
  2994. if ( footer ) {
  2995. footerCopy = footer.clone().prependTo( table );
  2996. footerTrgEls = footer.find('tr'); // the original tfoot is in its own table and must be sized
  2997. footerSrcEls = footerCopy.find('tr');
  2998. }
  2999. /*
  3000. * 2. Take live measurements from the DOM - do not alter the DOM itself!
  3001. */
  3002. // Remove old sizing and apply the calculated column widths
  3003. // Get the unique column headers in the newly created (cloned) header. We want to apply the
  3004. // calculated sizes to this header
  3005. if ( ! scrollX )
  3006. {
  3007. divBodyStyle.width = '100%';
  3008. divHeader[0].style.width = '100%';
  3009. }
  3010. $.each( _fnGetUniqueThs( settings, headerCopy ), function ( i, el ) {
  3011. idx = _fnVisibleToColumnIndex( settings, i );
  3012. el.style.width = settings.aoColumns[idx].sWidth;
  3013. } );
  3014. if ( footer ) {
  3015. _fnApplyToChildren( function(n) {
  3016. n.style.width = "";
  3017. }, footerSrcEls );
  3018. }
  3019. // If scroll collapse is enabled, when we put the headers back into the body for sizing, we
  3020. // will end up forcing the scrollbar to appear, making our measurements wrong for when we
  3021. // then hide it (end of this function), so add the header height to the body scroller.
  3022. if ( scroll.bCollapse && scrollY !== "" ) {
  3023. divBodyStyle.height = (divBody.offsetHeight + header[0].offsetHeight)+"px";
  3024. }
  3025. // Size the table as a whole
  3026. sanityWidth = table.outerWidth();
  3027. if ( scrollX === "" ) {
  3028. // No x scrolling
  3029. tableStyle.width = "100%";
  3030. // IE7 will make the width of the table when 100% include the scrollbar
  3031. // - which is shouldn't. When there is a scrollbar we need to take this
  3032. // into account.
  3033. if ( ie67 && (table.find('tbody').height() > divBodyEl.offsetHeight ||
  3034. divBody.css('overflow-y') == "scroll")
  3035. ) {
  3036. tableStyle.width = _fnStringToCss( table.outerWidth() - barWidth);
  3037. }
  3038. }
  3039. else
  3040. {
  3041. // x scrolling
  3042. if ( scrollXInner !== "" ) {
  3043. // x scroll inner has been given - use it
  3044. tableStyle.width = _fnStringToCss(scrollXInner);
  3045. }
  3046. else if ( sanityWidth == divBody.width() && divBody.height() < table.height() ) {
  3047. // There is y-scrolling - try to take account of the y scroll bar
  3048. tableStyle.width = _fnStringToCss( sanityWidth-barWidth );
  3049. if ( table.outerWidth() > sanityWidth-barWidth ) {
  3050. // Not possible to take account of it
  3051. tableStyle.width = _fnStringToCss( sanityWidth );
  3052. }
  3053. }
  3054. else {
  3055. // When all else fails
  3056. tableStyle.width = _fnStringToCss( sanityWidth );
  3057. }
  3058. }
  3059. // Recalculate the sanity width - now that we've applied the required width,
  3060. // before it was a temporary variable. This is required because the column
  3061. // width calculation is done before this table DOM is created.
  3062. sanityWidth = table.outerWidth();
  3063. // Hidden header should have zero height, so remove padding and borders. Then
  3064. // set the width based on the real headers
  3065. // Apply all styles in one pass
  3066. _fnApplyToChildren( zeroOut, headerSrcEls );
  3067. // Read all widths in next pass
  3068. _fnApplyToChildren( function(nSizer) {
  3069. headerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  3070. }, headerSrcEls );
  3071. // Apply all widths in final pass
  3072. _fnApplyToChildren( function(nToSize, i) {
  3073. nToSize.style.width = headerWidths[i];
  3074. }, headerTrgEls );
  3075. $(headerSrcEls).height(0);
  3076. /* Same again with the footer if we have one */
  3077. if ( footer )
  3078. {
  3079. _fnApplyToChildren( zeroOut, footerSrcEls );
  3080. _fnApplyToChildren( function(nSizer) {
  3081. footerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  3082. }, footerSrcEls );
  3083. _fnApplyToChildren( function(nToSize, i) {
  3084. nToSize.style.width = footerWidths[i];
  3085. }, footerTrgEls );
  3086. $(footerSrcEls).height(0);
  3087. }
  3088. /*
  3089. * 3. Apply the measurements
  3090. */
  3091. // "Hide" the header and footer that we used for the sizing. We want to also fix their width
  3092. // to what they currently are
  3093. _fnApplyToChildren( function(nSizer, i) {
  3094. nSizer.innerHTML = "";
  3095. nSizer.style.width = headerWidths[i];
  3096. }, headerSrcEls );
  3097. if ( footer )
  3098. {
  3099. _fnApplyToChildren( function(nSizer, i) {
  3100. nSizer.innerHTML = "";
  3101. nSizer.style.width = footerWidths[i];
  3102. }, footerSrcEls );
  3103. }
  3104. // Sanity check that the table is of a sensible width. If not then we are going to get
  3105. // misalignment - try to prevent this by not allowing the table to shrink below its min width
  3106. if ( table.outerWidth() < sanityWidth )
  3107. {
  3108. // The min width depends upon if we have a vertical scrollbar visible or not */
  3109. correction = ((divBodyEl.scrollHeight > divBodyEl.offsetHeight ||
  3110. divBody.css('overflow-y') == "scroll")) ?
  3111. sanityWidth+barWidth :
  3112. sanityWidth;
  3113. // IE6/7 are a law unto themselves...
  3114. if ( ie67 && (divBodyEl.scrollHeight >
  3115. divBodyEl.offsetHeight || divBody.css('overflow-y') == "scroll")
  3116. ) {
  3117. tableStyle.width = _fnStringToCss( correction-barWidth );
  3118. }
  3119. // And give the user a warning that we've stopped the table getting too small
  3120. if ( scrollX === "" || scrollXInner !== "" ) {
  3121. _fnLog( settings, 1, 'Possible column misalignment', 6 );
  3122. }
  3123. }
  3124. else
  3125. {
  3126. correction = '100%';
  3127. }
  3128. // Apply to the container elements
  3129. divBodyStyle.width = _fnStringToCss( correction );
  3130. divHeaderStyle.width = _fnStringToCss( correction );
  3131. if ( footer ) {
  3132. settings.nScrollFoot.style.width = _fnStringToCss( correction );
  3133. }
  3134. /*
  3135. * 4. Clean up
  3136. */
  3137. if ( ! scrollY ) {
  3138. /* IE7< puts a vertical scrollbar in place (when it shouldn't be) due to subtracting
  3139. * the scrollbar height from the visible display, rather than adding it on. We need to
  3140. * set the height in order to sort this. Don't want to do it in any other browsers.
  3141. */
  3142. if ( ie67 ) {
  3143. divBodyStyle.height = _fnStringToCss( tableEl.offsetHeight+barWidth );
  3144. }
  3145. }
  3146. if ( scrollY && scroll.bCollapse ) {
  3147. divBodyStyle.height = _fnStringToCss( scrollY );
  3148. var iExtra = (scrollX && tableEl.offsetWidth > divBodyEl.offsetWidth) ?
  3149. barWidth :
  3150. 0;
  3151. if ( tableEl.offsetHeight < divBodyEl.offsetHeight ) {
  3152. divBodyStyle.height = _fnStringToCss( tableEl.offsetHeight+iExtra );
  3153. }
  3154. }
  3155. /* Finally set the width's of the header and footer tables */
  3156. var iOuterWidth = table.outerWidth();
  3157. divHeaderTable[0].style.width = _fnStringToCss( iOuterWidth );
  3158. divHeaderInnerStyle.width = _fnStringToCss( iOuterWidth );
  3159. // Figure out if there are scrollbar present - if so then we need a the header and footer to
  3160. // provide a bit more space to allow "overflow" scrolling (i.e. past the scrollbar)
  3161. var bScrolling = table.height() > divBodyEl.clientHeight || divBody.css('overflow-y') == "scroll";
  3162. var padding = 'padding' + (browser.bScrollbarLeft ? 'Left' : 'Right' );
  3163. divHeaderInnerStyle[ padding ] = bScrolling ? barWidth+"px" : "0px";
  3164. if ( footer ) {
  3165. divFooterTable[0].style.width = _fnStringToCss( iOuterWidth );
  3166. divFooterInner[0].style.width = _fnStringToCss( iOuterWidth );
  3167. divFooterInner[0].style[padding] = bScrolling ? barWidth+"px" : "0px";
  3168. }
  3169. /* Adjust the position of the header in case we loose the y-scrollbar */
  3170. divBody.scroll();
  3171. /* If sorting or filtering has occurred, jump the scrolling back to the top */
  3172. if ( settings.bSorted || settings.bFiltered ) {
  3173. divBodyEl.scrollTop = 0;
  3174. }
  3175. }
  3176. /**
  3177. * Apply a given function to the display child nodes of an element array (typically
  3178. * TD children of TR rows
  3179. * @param {function} fn Method to apply to the objects
  3180. * @param array {nodes} an1 List of elements to look through for display children
  3181. * @param array {nodes} an2 Another list (identical structure to the first) - optional
  3182. * @memberof DataTable#oApi
  3183. */
  3184. function _fnApplyToChildren( fn, an1, an2 )
  3185. {
  3186. var index=0, i=0, iLen=an1.length;
  3187. var nNode1, nNode2;
  3188. while ( i < iLen ) {
  3189. nNode1 = an1[i].firstChild;
  3190. nNode2 = an2 ? an2[i].firstChild : null;
  3191. while ( nNode1 ) {
  3192. if ( nNode1.nodeType === 1 ) {
  3193. if ( an2 ) {
  3194. fn( nNode1, nNode2, index );
  3195. }
  3196. else {
  3197. fn( nNode1, index );
  3198. }
  3199. index++;
  3200. }
  3201. nNode1 = nNode1.nextSibling;
  3202. nNode2 = an2 ? nNode2.nextSibling : null;
  3203. }
  3204. i++;
  3205. }
  3206. }
  3207. var __re_html_remove = /<.*?>/g;
  3208. /**
  3209. * Calculate the width of columns for the table
  3210. * @param {object} oSettings dataTables settings object
  3211. * @memberof DataTable#oApi
  3212. */
  3213. function _fnCalculateColumnWidths ( oSettings )
  3214. {
  3215. var
  3216. table = oSettings.nTable,
  3217. columns = oSettings.aoColumns,
  3218. scroll = oSettings.oScroll,
  3219. scrollY = scroll.sY,
  3220. scrollX = scroll.sX,
  3221. scrollXInner = scroll.sXInner,
  3222. columnCount = columns.length,
  3223. visibleColumns = _fnGetColumns( oSettings, 'bVisible' ),
  3224. headerCells = $('th', oSettings.nTHead),
  3225. tableWidthAttr = table.getAttribute('width'),
  3226. tableContainer = table.parentNode,
  3227. userInputs = false,
  3228. i, column, columnIdx, width, outerWidth;
  3229. /* Convert any user input sizes into pixel sizes */
  3230. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3231. column = columns[ visibleColumns[i] ];
  3232. if ( column.sWidth !== null ) {
  3233. column.sWidth = _fnConvertToWidth( column.sWidthOrig, tableContainer );
  3234. userInputs = true;
  3235. }
  3236. }
  3237. /* If the number of columns in the DOM equals the number that we have to
  3238. * process in DataTables, then we can use the offsets that are created by
  3239. * the web- browser. No custom sizes can be set in order for this to happen,
  3240. * nor scrolling used
  3241. */
  3242. if ( ! userInputs && ! scrollX && ! scrollY &&
  3243. columnCount == _fnVisbleColumns( oSettings ) &&
  3244. columnCount == headerCells.length
  3245. ) {
  3246. for ( i=0 ; i<columnCount ; i++ ) {
  3247. columns[i].sWidth = _fnStringToCss( headerCells.eq(i).width() );
  3248. }
  3249. }
  3250. else
  3251. {
  3252. // Otherwise construct a single row table with the widest node in the
  3253. // data, assign any user defined widths, then insert it into the DOM and
  3254. // allow the browser to do all the hard work of calculating table widths
  3255. var tmpTable = $( table.cloneNode( false ) )
  3256. .css( 'visibility', 'hidden' )
  3257. .removeAttr( 'id' )
  3258. .append( $(oSettings.nTHead).clone( false ) )
  3259. .append( $(oSettings.nTFoot).clone( false ) )
  3260. .append( $('<tbody><tr/></tbody>') );
  3261. // Remove any assigned widths from the footer (from scrolling)
  3262. tmpTable.find('tfoot th, tfoot td').css('width', '');
  3263. var tr = tmpTable.find( 'tbody tr' );
  3264. // Apply custom sizing to the cloned header
  3265. headerCells = _fnGetUniqueThs( oSettings, tmpTable.find('thead')[0] );
  3266. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3267. column = columns[ visibleColumns[i] ];
  3268. headerCells[i].style.width = column.sWidthOrig !== null && column.sWidthOrig !== '' ?
  3269. _fnStringToCss( column.sWidthOrig ) :
  3270. '';
  3271. }
  3272. // Find the widest cell for each column and put it into the table
  3273. if ( oSettings.aoData.length ) {
  3274. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3275. columnIdx = visibleColumns[i];
  3276. column = columns[ columnIdx ];
  3277. $( _fnGetWidestNode( oSettings, columnIdx ) )
  3278. .clone( false )
  3279. .append( column.sContentPadding )
  3280. .appendTo( tr );
  3281. }
  3282. }
  3283. // Table has been built, attach to the document so we can work with it
  3284. tmpTable.appendTo( tableContainer );
  3285. // When scrolling (X or Y) we want to set the width of the table as
  3286. // appropriate. However, when not scrolling leave the table width as it
  3287. // is. This results in slightly different, but I think correct behaviour
  3288. if ( scrollX && scrollXInner ) {
  3289. tmpTable.width( scrollXInner );
  3290. }
  3291. else if ( scrollX ) {
  3292. tmpTable.css( 'width', 'auto' );
  3293. if ( tmpTable.width() < tableContainer.offsetWidth ) {
  3294. tmpTable.width( tableContainer.offsetWidth );
  3295. }
  3296. }
  3297. else if ( scrollY ) {
  3298. tmpTable.width( tableContainer.offsetWidth );
  3299. }
  3300. else if ( tableWidthAttr ) {
  3301. tmpTable.width( tableWidthAttr );
  3302. }
  3303. // Take into account the y scrollbar
  3304. _fnScrollingWidthAdjust( oSettings, tmpTable[0] );
  3305. // Browsers need a bit of a hand when a width is assigned to any columns
  3306. // when x-scrolling as they tend to collapse the table to the min-width,
  3307. // even if we sent the column widths. So we need to keep track of what
  3308. // the table width should be by summing the user given values, and the
  3309. // automatic values
  3310. if ( scrollX )
  3311. {
  3312. var total = 0;
  3313. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3314. column = columns[ visibleColumns[i] ];
  3315. outerWidth = $(headerCells[i]).outerWidth();
  3316. total += column.sWidthOrig === null ?
  3317. outerWidth :
  3318. parseInt( column.sWidth, 10 ) + outerWidth - $(headerCells[i]).width();
  3319. }
  3320. tmpTable.width( _fnStringToCss( total ) );
  3321. table.style.width = _fnStringToCss( total );
  3322. }
  3323. // Get the width of each column in the constructed table
  3324. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3325. column = columns[ visibleColumns[i] ];
  3326. width = $(headerCells[i]).width();
  3327. if ( width ) {
  3328. column.sWidth = _fnStringToCss( width );
  3329. }
  3330. }
  3331. table.style.width = _fnStringToCss( tmpTable.css('width') );
  3332. // Finished with the table - ditch it
  3333. tmpTable.remove();
  3334. }
  3335. // If there is a width attr, we want to attach an event listener which
  3336. // allows the table sizing to automatically adjust when the window is
  3337. // resized. Use the width attr rather than CSS, since we can't know if the
  3338. // CSS is a relative value or absolute - DOM read is always px.
  3339. if ( tableWidthAttr ) {
  3340. table.style.width = _fnStringToCss( tableWidthAttr );
  3341. if ( ! oSettings._reszEvt ) {
  3342. $(window).bind('resize.DT-'+oSettings.sInstance, _fnThrottle( function () {
  3343. _fnAdjustColumnSizing( oSettings );
  3344. } ) );
  3345. oSettings._reszEvt = true;
  3346. }
  3347. }
  3348. }
  3349. function _fnThrottle( fn ) {
  3350. var
  3351. frequency = 200,
  3352. last,
  3353. timer;
  3354. return function () {
  3355. var
  3356. now = +new Date(),
  3357. args = arguments;
  3358. if ( last && now < last + frequency ) {
  3359. clearTimeout( timer );
  3360. timer = setTimeout( function () {
  3361. last = now;
  3362. fn();
  3363. }, frequency );
  3364. }
  3365. else {
  3366. last = now;
  3367. fn();
  3368. }
  3369. };
  3370. }
  3371. /**
  3372. * Convert a CSS unit width to pixels (e.g. 2em)
  3373. * @param {string} width width to be converted
  3374. * @param {node} parent parent to get the with for (required for relative widths) - optional
  3375. * @returns {int} width in pixels
  3376. * @memberof DataTable#oApi
  3377. */
  3378. function _fnConvertToWidth ( width, parent )
  3379. {
  3380. if ( ! width ) {
  3381. return 0;
  3382. }
  3383. var n = $('<div/>')
  3384. .css( 'width', _fnStringToCss( width ) )
  3385. .appendTo( parent || document.body );
  3386. var val = n[0].offsetWidth;
  3387. n.remove();
  3388. return val;
  3389. }
  3390. /**
  3391. * Adjust a table's width to take account of vertical scroll bar
  3392. * @param {object} oSettings dataTables settings object
  3393. * @param {node} n table node
  3394. * @memberof DataTable#oApi
  3395. */
  3396. function _fnScrollingWidthAdjust ( settings, n )
  3397. {
  3398. var scroll = settings.oScroll;
  3399. if ( scroll.sX || scroll.sY ) {
  3400. // When y-scrolling only, we want to remove the width of the scroll bar
  3401. // so the table + scroll bar will fit into the area available, otherwise
  3402. // we fix the table at its current size with no adjustment
  3403. var correction = ! scroll.sX ? scroll.iBarWidth : 0;
  3404. n.style.width = _fnStringToCss( $(n).outerWidth() - correction );
  3405. }
  3406. }
  3407. /**
  3408. * Get the widest node
  3409. * @param {object} settings dataTables settings object
  3410. * @param {int} colIdx column of interest
  3411. * @returns {node} widest table node
  3412. * @memberof DataTable#oApi
  3413. */
  3414. function _fnGetWidestNode( settings, colIdx )
  3415. {
  3416. var idx = _fnGetMaxLenString( settings, colIdx );
  3417. if ( idx < 0 ) {
  3418. return null;
  3419. }
  3420. var data = settings.aoData[ idx ];
  3421. return ! data.nTr ? // Might not have been created when deferred rendering
  3422. $('<td/>').html( _fnGetCellData( settings, idx, colIdx, 'display' ) )[0] :
  3423. data.anCells[ colIdx ];
  3424. }
  3425. /**
  3426. * Get the maximum strlen for each data column
  3427. * @param {object} settings dataTables settings object
  3428. * @param {int} colIdx column of interest
  3429. * @returns {string} max string length for each column
  3430. * @memberof DataTable#oApi
  3431. */
  3432. function _fnGetMaxLenString( settings, colIdx )
  3433. {
  3434. var s, max=-1, maxIdx = -1;
  3435. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  3436. s = _fnGetCellData( settings, i, colIdx, 'display' )+'';
  3437. s = s.replace( __re_html_remove, '' );
  3438. if ( s.length > max ) {
  3439. max = s.length;
  3440. maxIdx = i;
  3441. }
  3442. }
  3443. return maxIdx;
  3444. }
  3445. /**
  3446. * Append a CSS unit (only if required) to a string
  3447. * @param {string} value to css-ify
  3448. * @returns {string} value with css unit
  3449. * @memberof DataTable#oApi
  3450. */
  3451. function _fnStringToCss( s )
  3452. {
  3453. if ( s === null ) {
  3454. return '0px';
  3455. }
  3456. if ( typeof s == 'number' ) {
  3457. return s < 0 ?
  3458. '0px' :
  3459. s+'px';
  3460. }
  3461. // Check it has a unit character already
  3462. return s.match(/\d$/) ?
  3463. s+'px' :
  3464. s;
  3465. }
  3466. /**
  3467. * Get the width of a scroll bar in this browser being used
  3468. * @returns {int} width in pixels
  3469. * @memberof DataTable#oApi
  3470. */
  3471. function _fnScrollBarWidth ()
  3472. {
  3473. // On first run a static variable is set, since this is only needed once.
  3474. // Subsequent runs will just use the previously calculated value
  3475. if ( ! DataTable.__scrollbarWidth ) {
  3476. var inner = $('<p/>').css( {
  3477. width: '100%',
  3478. height: 200,
  3479. padding: 0
  3480. } )[0];
  3481. var outer = $('<div/>')
  3482. .css( {
  3483. position: 'absolute',
  3484. top: 0,
  3485. left: 0,
  3486. width: 200,
  3487. height: 150,
  3488. padding: 0,
  3489. overflow: 'hidden',
  3490. visibility: 'hidden'
  3491. } )
  3492. .append( inner )
  3493. .appendTo( 'body' );
  3494. var w1 = inner.offsetWidth;
  3495. outer.css( 'overflow', 'scroll' );
  3496. var w2 = inner.offsetWidth;
  3497. if ( w1 === w2 ) {
  3498. w2 = outer[0].clientWidth;
  3499. }
  3500. outer.remove();
  3501. DataTable.__scrollbarWidth = w1 - w2;
  3502. }
  3503. return DataTable.__scrollbarWidth;
  3504. }
  3505. function _fnSortFlatten ( settings )
  3506. {
  3507. var
  3508. i, iLen, k, kLen,
  3509. aSort = [],
  3510. aiOrig = [],
  3511. aoColumns = settings.aoColumns,
  3512. aDataSort, iCol, sType, srcCol,
  3513. fixed = settings.aaSortingFixed,
  3514. fixedObj = $.isPlainObject( fixed ),
  3515. nestedSort = [],
  3516. add = function ( a ) {
  3517. if ( a.length && ! $.isArray( a[0] ) ) {
  3518. // 1D array
  3519. nestedSort.push( a );
  3520. }
  3521. else {
  3522. // 2D array
  3523. nestedSort.push.apply( nestedSort, a );
  3524. }
  3525. };
  3526. // Build the sort array, with pre-fix and post-fix options if they have been
  3527. // specified
  3528. if ( $.isArray( fixed ) ) {
  3529. add( fixed );
  3530. }
  3531. if ( fixedObj && fixed.pre ) {
  3532. add( fixed.pre );
  3533. }
  3534. add( settings.aaSorting );
  3535. if (fixedObj && fixed.post ) {
  3536. add( fixed.post );
  3537. }
  3538. for ( i=0 ; i<nestedSort.length ; i++ )
  3539. {
  3540. srcCol = nestedSort[i][0];
  3541. aDataSort = aoColumns[ srcCol ].aDataSort;
  3542. for ( k=0, kLen=aDataSort.length ; k<kLen ; k++ )
  3543. {
  3544. iCol = aDataSort[k];
  3545. sType = aoColumns[ iCol ].sType || 'string';
  3546. aSort.push( {
  3547. src: srcCol,
  3548. col: iCol,
  3549. dir: nestedSort[i][1],
  3550. index: nestedSort[i][2],
  3551. type: sType,
  3552. formatter: DataTable.ext.type.order[ sType+"-pre" ]
  3553. } );
  3554. }
  3555. }
  3556. return aSort;
  3557. }
  3558. /**
  3559. * Change the order of the table
  3560. * @param {object} oSettings dataTables settings object
  3561. * @memberof DataTable#oApi
  3562. * @todo This really needs split up!
  3563. */
  3564. function _fnSort ( oSettings )
  3565. {
  3566. var
  3567. i, ien, iLen, j, jLen, k, kLen,
  3568. sDataType, nTh,
  3569. aiOrig = [],
  3570. oExtSort = DataTable.ext.type.order,
  3571. aoData = oSettings.aoData,
  3572. aoColumns = oSettings.aoColumns,
  3573. aDataSort, data, iCol, sType, oSort,
  3574. formatters = 0,
  3575. sortCol,
  3576. displayMaster = oSettings.aiDisplayMaster,
  3577. aSort = _fnSortFlatten( oSettings );
  3578. // Resolve any column types that are unknown due to addition or invalidation
  3579. // @todo Can this be moved into a 'data-ready' handler which is called when
  3580. // data is going to be used in the table?
  3581. _fnColumnTypes( oSettings );
  3582. for ( i=0, ien=aSort.length ; i<ien ; i++ ) {
  3583. sortCol = aSort[i];
  3584. // Track if we can use the fast sort algorithm
  3585. if ( sortCol.formatter ) {
  3586. formatters++;
  3587. }
  3588. // Load the data needed for the sort, for each cell
  3589. _fnSortData( oSettings, sortCol.col );
  3590. }
  3591. /* No sorting required if server-side or no sorting array */
  3592. if ( _fnDataSource( oSettings ) != 'ssp' && aSort.length !== 0 )
  3593. {
  3594. // Create a value - key array of the current row positions such that we can use their
  3595. // current position during the sort, if values match, in order to perform stable sorting
  3596. for ( i=0, iLen=displayMaster.length ; i<iLen ; i++ ) {
  3597. aiOrig[ displayMaster[i] ] = i;
  3598. }
  3599. /* Do the sort - here we want multi-column sorting based on a given data source (column)
  3600. * and sorting function (from oSort) in a certain direction. It's reasonably complex to
  3601. * follow on it's own, but this is what we want (example two column sorting):
  3602. * fnLocalSorting = function(a,b){
  3603. * var iTest;
  3604. * iTest = oSort['string-asc']('data11', 'data12');
  3605. * if (iTest !== 0)
  3606. * return iTest;
  3607. * iTest = oSort['numeric-desc']('data21', 'data22');
  3608. * if (iTest !== 0)
  3609. * return iTest;
  3610. * return oSort['numeric-asc']( aiOrig[a], aiOrig[b] );
  3611. * }
  3612. * Basically we have a test for each sorting column, if the data in that column is equal,
  3613. * test the next column. If all columns match, then we use a numeric sort on the row
  3614. * positions in the original data array to provide a stable sort.
  3615. *
  3616. * Note - I know it seems excessive to have two sorting methods, but the first is around
  3617. * 15% faster, so the second is only maintained for backwards compatibility with sorting
  3618. * methods which do not have a pre-sort formatting function.
  3619. */
  3620. if ( formatters === aSort.length ) {
  3621. // All sort types have formatting functions
  3622. displayMaster.sort( function ( a, b ) {
  3623. var
  3624. x, y, k, test, sort,
  3625. len=aSort.length,
  3626. dataA = aoData[a]._aSortData,
  3627. dataB = aoData[b]._aSortData;
  3628. for ( k=0 ; k<len ; k++ ) {
  3629. sort = aSort[k];
  3630. x = dataA[ sort.col ];
  3631. y = dataB[ sort.col ];
  3632. test = x<y ? -1 : x>y ? 1 : 0;
  3633. if ( test !== 0 ) {
  3634. return sort.dir === 'asc' ? test : -test;
  3635. }
  3636. }
  3637. x = aiOrig[a];
  3638. y = aiOrig[b];
  3639. return x<y ? -1 : x>y ? 1 : 0;
  3640. } );
  3641. }
  3642. else {
  3643. // Depreciated - remove in 1.11 (providing a plug-in option)
  3644. // Not all sort types have formatting methods, so we have to call their sorting
  3645. // methods.
  3646. displayMaster.sort( function ( a, b ) {
  3647. var
  3648. x, y, k, l, test, sort, fn,
  3649. len=aSort.length,
  3650. dataA = aoData[a]._aSortData,
  3651. dataB = aoData[b]._aSortData;
  3652. for ( k=0 ; k<len ; k++ ) {
  3653. sort = aSort[k];
  3654. x = dataA[ sort.col ];
  3655. y = dataB[ sort.col ];
  3656. fn = oExtSort[ sort.type+"-"+sort.dir ] || oExtSort[ "string-"+sort.dir ];
  3657. test = fn( x, y );
  3658. if ( test !== 0 ) {
  3659. return test;
  3660. }
  3661. }
  3662. x = aiOrig[a];
  3663. y = aiOrig[b];
  3664. return x<y ? -1 : x>y ? 1 : 0;
  3665. } );
  3666. }
  3667. }
  3668. /* Tell the draw function that we have sorted the data */
  3669. oSettings.bSorted = true;
  3670. }
  3671. function _fnSortAria ( settings )
  3672. {
  3673. var label;
  3674. var nextSort;
  3675. var columns = settings.aoColumns;
  3676. var aSort = _fnSortFlatten( settings );
  3677. var oAria = settings.oLanguage.oAria;
  3678. // ARIA attributes - need to loop all columns, to update all (removing old
  3679. // attributes as needed)
  3680. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  3681. {
  3682. var col = columns[i];
  3683. var asSorting = col.asSorting;
  3684. var sTitle = col.sTitle.replace( /<.*?>/g, "" );
  3685. var jqTh = $(col.nTh).removeAttr('aria-sort');
  3686. /* In ARIA only the first sorting column can be marked as sorting - no multi-sort option */
  3687. if ( col.bSortable ) {
  3688. if ( aSort.length > 0 && aSort[0].col == i ) {
  3689. jqTh.attr('aria-sort', aSort[0].dir=="asc" ? "ascending" : "descending" );
  3690. nextSort = asSorting[ aSort[0].index+1 ] || asSorting[0];
  3691. }
  3692. else {
  3693. nextSort = asSorting[0];
  3694. }
  3695. label = sTitle + ( nextSort === "asc" ?
  3696. oAria.sSortAscending :
  3697. oAria.sSortDescending
  3698. );
  3699. }
  3700. else {
  3701. label = sTitle;
  3702. }
  3703. jqTh.attr('aria-label', label);
  3704. }
  3705. }
  3706. /**
  3707. * Function to run on user sort request
  3708. * @param {object} settings dataTables settings object
  3709. * @param {node} attachTo node to attach the handler to
  3710. * @param {int} colIdx column sorting index
  3711. * @param {boolean} [append=false] Append the requested sort to the existing
  3712. * sort if true (i.e. multi-column sort)
  3713. * @param {function} [callback] callback function
  3714. * @memberof DataTable#oApi
  3715. */
  3716. function _fnSortListener ( settings, colIdx, append, callback )
  3717. {
  3718. var col = settings.aoColumns[ colIdx ];
  3719. var sorting = settings.aaSorting;
  3720. var asSorting = col.asSorting;
  3721. var nextSortIdx;
  3722. var next = function ( a ) {
  3723. var idx = a._idx;
  3724. if ( idx === undefined ) {
  3725. idx = $.inArray( a[1], asSorting );
  3726. }
  3727. return idx+1 >= asSorting.length ? 0 : idx+1;
  3728. };
  3729. // If appending the sort then we are multi-column sorting
  3730. if ( append && settings.oFeatures.bSortMulti ) {
  3731. // Are we already doing some kind of sort on this column?
  3732. var sortIdx = $.inArray( colIdx, _pluck(sorting, '0') );
  3733. if ( sortIdx !== -1 ) {
  3734. // Yes, modify the sort
  3735. nextSortIdx = next( sorting[sortIdx] );
  3736. sorting[sortIdx][1] = asSorting[ nextSortIdx ];
  3737. sorting[sortIdx]._idx = nextSortIdx;
  3738. }
  3739. else {
  3740. // No sort on this column yet
  3741. sorting.push( [ colIdx, asSorting[0], 0 ] );
  3742. sorting[sorting.length-1]._idx = 0;
  3743. }
  3744. }
  3745. else if ( sorting.length && sorting[0][0] == colIdx ) {
  3746. // Single column - already sorting on this column, modify the sort
  3747. nextSortIdx = next( sorting[0] );
  3748. sorting.length = 1;
  3749. sorting[0][1] = asSorting[ nextSortIdx ];
  3750. sorting[0]._idx = nextSortIdx;
  3751. }
  3752. else {
  3753. // Single column - sort only on this column
  3754. sorting.length = 0;
  3755. sorting.push( [ colIdx, asSorting[0] ] );
  3756. sorting[0]._idx = 0;
  3757. }
  3758. // Run the sort by calling a full redraw
  3759. _fnReDraw( settings );
  3760. // callback used for async user interaction
  3761. if ( typeof callback == 'function' ) {
  3762. callback( settings );
  3763. }
  3764. }
  3765. /**
  3766. * Attach a sort handler (click) to a node
  3767. * @param {object} settings dataTables settings object
  3768. * @param {node} attachTo node to attach the handler to
  3769. * @param {int} colIdx column sorting index
  3770. * @param {function} [callback] callback function
  3771. * @memberof DataTable#oApi
  3772. */
  3773. function _fnSortAttachListener ( settings, attachTo, colIdx, callback )
  3774. {
  3775. var col = settings.aoColumns[ colIdx ];
  3776. _fnBindAction( attachTo, {}, function (e) {
  3777. /* If the column is not sortable - don't to anything */
  3778. if ( col.bSortable === false ) {
  3779. return;
  3780. }
  3781. _fnProcessingDisplay( settings, true );
  3782. // Use a timeout to allow the processing display to be shown.
  3783. setTimeout( function() {
  3784. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  3785. // In server-side processing, the draw callback will remove the
  3786. // processing display
  3787. if ( _fnDataSource( settings ) !== 'ssp' ) {
  3788. _fnProcessingDisplay( settings, false );
  3789. }
  3790. }, 0 );
  3791. } );
  3792. }
  3793. /**
  3794. * Set the sorting classes on table's body, Note: it is safe to call this function
  3795. * when bSort and bSortClasses are false
  3796. * @param {object} oSettings dataTables settings object
  3797. * @memberof DataTable#oApi
  3798. */
  3799. function _fnSortingClasses( settings )
  3800. {
  3801. var oldSort = settings.aLastSort;
  3802. var sortClass = settings.oClasses.sSortColumn;
  3803. var sort = _fnSortFlatten( settings );
  3804. var features = settings.oFeatures;
  3805. var i, ien, colIdx;
  3806. if ( features.bSort && features.bSortClasses ) {
  3807. // Remove old sorting classes
  3808. for ( i=0, ien=oldSort.length ; i<ien ; i++ ) {
  3809. colIdx = oldSort[i].src;
  3810. // Remove column sorting
  3811. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  3812. .removeClass( sortClass + (i<2 ? i+1 : 3) );
  3813. }
  3814. // Add new column sorting
  3815. for ( i=0, ien=sort.length ; i<ien ; i++ ) {
  3816. colIdx = sort[i].src;
  3817. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  3818. .addClass( sortClass + (i<2 ? i+1 : 3) );
  3819. }
  3820. }
  3821. settings.aLastSort = sort;
  3822. }
  3823. // Get the data to sort a column, be it from cache, fresh (populating the
  3824. // cache), or from a sort formatter
  3825. function _fnSortData( settings, idx )
  3826. {
  3827. // Custom sorting function - provided by the sort data type
  3828. var column = settings.aoColumns[ idx ];
  3829. var customSort = DataTable.ext.order[ column.sSortDataType ];
  3830. var customData;
  3831. if ( customSort ) {
  3832. customData = customSort.call( settings.oInstance, settings, idx,
  3833. _fnColumnIndexToVisible( settings, idx )
  3834. );
  3835. }
  3836. // Use / populate cache
  3837. var row, cellData;
  3838. var formatter = DataTable.ext.type.order[ column.sType+"-pre" ];
  3839. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  3840. row = settings.aoData[i];
  3841. if ( ! row._aSortData ) {
  3842. row._aSortData = [];
  3843. }
  3844. if ( ! row._aSortData[idx] || customSort ) {
  3845. cellData = customSort ?
  3846. customData[i] : // If there was a custom sort function, use data from there
  3847. _fnGetCellData( settings, i, idx, 'sort' );
  3848. row._aSortData[ idx ] = formatter ?
  3849. formatter( cellData ) :
  3850. cellData;
  3851. }
  3852. }
  3853. }
  3854. /**
  3855. * Save the state of a table
  3856. * @param {object} oSettings dataTables settings object
  3857. * @memberof DataTable#oApi
  3858. */
  3859. function _fnSaveState ( oSettings )
  3860. {
  3861. if ( !oSettings.oFeatures.bStateSave || oSettings.bDestroying )
  3862. {
  3863. return;
  3864. }
  3865. /* Store the interesting variables */
  3866. var i, iLen;
  3867. var oState = {
  3868. "iCreate": new Date().getTime(),
  3869. "iStart": oSettings._iDisplayStart,
  3870. "iLength": oSettings._iDisplayLength,
  3871. "aaSorting": $.extend( true, [], oSettings.aaSorting ),
  3872. "oSearch": $.extend( true, {}, oSettings.oPreviousSearch ),
  3873. "aoSearchCols": $.extend( true, [], oSettings.aoPreSearchCols ),
  3874. "abVisCols": []
  3875. };
  3876. for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
  3877. {
  3878. oState.abVisCols.push( oSettings.aoColumns[i].bVisible );
  3879. }
  3880. _fnCallbackFire( oSettings, "aoStateSaveParams", 'stateSaveParams', [oSettings, oState] );
  3881. oSettings.fnStateSaveCallback.call( oSettings.oInstance, oSettings, oState );
  3882. }
  3883. /**
  3884. * Attempt to load a saved table state
  3885. * @param {object} oSettings dataTables settings object
  3886. * @param {object} oInit DataTables init object so we can override settings
  3887. * @memberof DataTable#oApi
  3888. */
  3889. function _fnLoadState ( oSettings, oInit )
  3890. {
  3891. var i, ien;
  3892. var columns = oSettings.aoColumns;
  3893. if ( !oSettings.oFeatures.bStateSave )
  3894. {
  3895. return;
  3896. }
  3897. var oData = oSettings.fnStateLoadCallback.call( oSettings.oInstance, oSettings );
  3898. if ( !oData )
  3899. {
  3900. return;
  3901. }
  3902. /* Allow custom and plug-in manipulation functions to alter the saved data set and
  3903. * cancelling of loading by returning false
  3904. */
  3905. var abStateLoad = _fnCallbackFire( oSettings, 'aoStateLoadParams', 'stateLoadParams', [oSettings, oData] );
  3906. if ( $.inArray( false, abStateLoad ) !== -1 )
  3907. {
  3908. return;
  3909. }
  3910. /* Reject old data */
  3911. if ( oData.iCreate < new Date().getTime() - (oSettings.iStateDuration*1000) ) {
  3912. return;
  3913. }
  3914. // Number of columns have changed - all bets are off, no restore of settings
  3915. if ( columns.length !== oData.aoSearchCols.length ) {
  3916. return;
  3917. }
  3918. /* Store the saved state so it might be accessed at any time */
  3919. oSettings.oLoadedState = $.extend( true, {}, oData );
  3920. /* Restore key features */
  3921. oSettings._iDisplayStart = oData.iStart;
  3922. oSettings.iInitDisplayStart = oData.iStart;
  3923. oSettings._iDisplayLength = oData.iLength;
  3924. oSettings.aaSorting = [];
  3925. var savedSort = oData.aaSorting;
  3926. for ( i=0, ien=savedSort.length ; i<ien ; i++ ) {
  3927. oSettings.aaSorting.push( savedSort[i][0] >= columns.length ?
  3928. [ 0, savedSort[i][1] ] :
  3929. savedSort[i]
  3930. );
  3931. }
  3932. /* Search filtering */
  3933. $.extend( oSettings.oPreviousSearch, oData.oSearch );
  3934. $.extend( true, oSettings.aoPreSearchCols, oData.aoSearchCols );
  3935. /* Column visibility state */
  3936. for ( i=0, ien=oData.abVisCols.length ; i<ien ; i++ ) {
  3937. columns[i].bVisible = oData.abVisCols[i];
  3938. }
  3939. _fnCallbackFire( oSettings, 'aoStateLoaded', 'stateLoaded', [oSettings, oData] );
  3940. }
  3941. /**
  3942. * Return the settings object for a particular table
  3943. * @param {node} table table we are using as a dataTable
  3944. * @returns {object} Settings object - or null if not found
  3945. * @memberof DataTable#oApi
  3946. */
  3947. function _fnSettingsFromNode ( table )
  3948. {
  3949. var settings = DataTable.settings;
  3950. var idx = $.inArray( table, _pluck( settings, 'nTable' ) );
  3951. return idx !== -1 ?
  3952. settings[ idx ] :
  3953. null;
  3954. }
  3955. /**
  3956. * Log an error message
  3957. * @param {object} settings dataTables settings object
  3958. * @param {int} level log error messages, or display them to the user
  3959. * @param {string} msg error message
  3960. * @param {int} tn Technical note id to get more information about the error.
  3961. * @memberof DataTable#oApi
  3962. */
  3963. function _fnLog( settings, level, msg, tn )
  3964. {
  3965. msg = 'DataTables warning: '+
  3966. (settings!==null ? 'table id='+settings.sTableId+' - ' : '')+msg;
  3967. if ( tn ) {
  3968. msg += '. For more information about this error, please see '+
  3969. 'http://datatables.net/tn/'+tn;
  3970. }
  3971. if ( ! level ) {
  3972. // Backwards compatibility pre 1.10
  3973. var ext = DataTable.ext;
  3974. var type = ext.sErrMode || ext.errMode;
  3975. if ( type == 'alert' ) {
  3976. alert( msg );
  3977. }
  3978. else {
  3979. throw new Error(msg);
  3980. }
  3981. }
  3982. else if ( window.console && console.log ) {
  3983. console.log( msg );
  3984. }
  3985. }
  3986. /**
  3987. * See if a property is defined on one object, if so assign it to the other object
  3988. * @param {object} ret target object
  3989. * @param {object} src source object
  3990. * @param {string} name property
  3991. * @param {string} [mappedName] name to map too - optional, name used if not given
  3992. * @memberof DataTable#oApi
  3993. */
  3994. function _fnMap( ret, src, name, mappedName )
  3995. {
  3996. if ( $.isArray( name ) ) {
  3997. $.each( name, function (i, val) {
  3998. if ( $.isArray( val ) ) {
  3999. _fnMap( ret, src, val[0], val[1] );
  4000. }
  4001. else {
  4002. _fnMap( ret, src, val );
  4003. }
  4004. } );
  4005. return;
  4006. }
  4007. if ( mappedName === undefined ) {
  4008. mappedName = name;
  4009. }
  4010. if ( src[name] !== undefined ) {
  4011. ret[mappedName] = src[name];
  4012. }
  4013. }
  4014. /**
  4015. * Extend objects - very similar to jQuery.extend, but deep copy objects, and
  4016. * shallow copy arrays. The reason we need to do this, is that we don't want to
  4017. * deep copy array init values (such as aaSorting) since the dev wouldn't be
  4018. * able to override them, but we do want to deep copy arrays.
  4019. * @param {object} out Object to extend
  4020. * @param {object} extender Object from which the properties will be applied to
  4021. * out
  4022. * @param {boolean} breakRefs If true, then arrays will be sliced to take an
  4023. * independent copy with the exception of the `data` or `aaData` parameters
  4024. * if they are present. This is so you can pass in a collection to
  4025. * DataTables and have that used as your data source without breaking the
  4026. * references
  4027. * @returns {object} out Reference, just for convenience - out === the return.
  4028. * @memberof DataTable#oApi
  4029. * @todo This doesn't take account of arrays inside the deep copied objects.
  4030. */
  4031. function _fnExtend( out, extender, breakRefs )
  4032. {
  4033. var val;
  4034. for ( var prop in extender ) {
  4035. if ( extender.hasOwnProperty(prop) ) {
  4036. val = extender[prop];
  4037. if ( $.isPlainObject( val ) ) {
  4038. if ( ! $.isPlainObject( out[prop] ) ) {
  4039. out[prop] = {};
  4040. }
  4041. $.extend( true, out[prop], val );
  4042. }
  4043. else if ( breakRefs && prop !== 'data' && prop !== 'aaData' && $.isArray(val) ) {
  4044. out[prop] = val.slice();
  4045. }
  4046. else {
  4047. out[prop] = val;
  4048. }
  4049. }
  4050. }
  4051. return out;
  4052. }
  4053. /**
  4054. * Bind an event handers to allow a click or return key to activate the callback.
  4055. * This is good for accessibility since a return on the keyboard will have the
  4056. * same effect as a click, if the element has focus.
  4057. * @param {element} n Element to bind the action to
  4058. * @param {object} oData Data object to pass to the triggered function
  4059. * @param {function} fn Callback function for when the event is triggered
  4060. * @memberof DataTable#oApi
  4061. */
  4062. function _fnBindAction( n, oData, fn )
  4063. {
  4064. $(n)
  4065. .bind( 'click.DT', oData, function (e) {
  4066. n.blur(); // Remove focus outline for mouse users
  4067. fn(e);
  4068. } )
  4069. .bind( 'keypress.DT', oData, function (e){
  4070. if ( e.which === 13 ) {
  4071. fn(e);
  4072. } } )
  4073. .bind( 'selectstart.DT', function () {
  4074. /* Take the brutal approach to cancelling text selection */
  4075. return false;
  4076. } );
  4077. }
  4078. /**
  4079. * Register a callback function. Easily allows a callback function to be added to
  4080. * an array store of callback functions that can then all be called together.
  4081. * @param {object} oSettings dataTables settings object
  4082. * @param {string} sStore Name of the array storage for the callbacks in oSettings
  4083. * @param {function} fn Function to be called back
  4084. * @param {string} sName Identifying name for the callback (i.e. a label)
  4085. * @memberof DataTable#oApi
  4086. */
  4087. function _fnCallbackReg( oSettings, sStore, fn, sName )
  4088. {
  4089. if ( fn )
  4090. {
  4091. oSettings[sStore].push( {
  4092. "fn": fn,
  4093. "sName": sName
  4094. } );
  4095. }
  4096. }
  4097. /**
  4098. * Fire callback functions and trigger events. Note that the loop over the
  4099. * callback array store is done backwards! Further note that you do not want to
  4100. * fire off triggers in time sensitive applications (for example cell creation)
  4101. * as its slow.
  4102. * @param {object} settings dataTables settings object
  4103. * @param {string} callbackArr Name of the array storage for the callbacks in
  4104. * oSettings
  4105. * @param {string} event Name of the jQuery custom event to trigger. If null no
  4106. * trigger is fired
  4107. * @param {array} args Array of arguments to pass to the callback function /
  4108. * trigger
  4109. * @memberof DataTable#oApi
  4110. */
  4111. function _fnCallbackFire( settings, callbackArr, event, args )
  4112. {
  4113. var ret = [];
  4114. if ( callbackArr ) {
  4115. ret = $.map( settings[callbackArr].slice().reverse(), function (val, i) {
  4116. return val.fn.apply( settings.oInstance, args );
  4117. } );
  4118. }
  4119. if ( event !== null ) {
  4120. $(settings.nTable).trigger( event+'.dt', args );
  4121. }
  4122. return ret;
  4123. }
  4124. function _fnLengthOverflow ( settings )
  4125. {
  4126. var
  4127. start = settings._iDisplayStart,
  4128. end = settings.fnDisplayEnd(),
  4129. len = settings._iDisplayLength;
  4130. /* If we have space to show extra rows (backing up from the end point - then do so */
  4131. if ( end === settings.fnRecordsDisplay() )
  4132. {
  4133. start = end - len;
  4134. }
  4135. if ( len === -1 || start < 0 )
  4136. {
  4137. start = 0;
  4138. }
  4139. settings._iDisplayStart = start;
  4140. }
  4141. function _fnRenderer( settings, type )
  4142. {
  4143. var renderer = settings.renderer;
  4144. var host = DataTable.ext.renderer[type];
  4145. if ( $.isPlainObject( renderer ) && renderer[type] ) {
  4146. // Specific renderer for this type. If available use it, otherwise use
  4147. // the default.
  4148. return host[renderer[type]] || host._;
  4149. }
  4150. else if ( typeof renderer === 'string' ) {
  4151. // Common renderer - if there is one available for this type use it,
  4152. // otherwise use the default
  4153. return host[renderer] || host._;
  4154. }
  4155. // Use the default
  4156. return host._;
  4157. }
  4158. /**
  4159. * Detect the data source being used for the table. Used to simplify the code
  4160. * a little (ajax) and to make it compress a little smaller.
  4161. *
  4162. * @param {object} settings dataTables settings object
  4163. * @returns {string} Data source
  4164. * @memberof DataTable#oApi
  4165. */
  4166. function _fnDataSource ( settings )
  4167. {
  4168. if ( settings.oFeatures.bServerSide ) {
  4169. return 'ssp';
  4170. }
  4171. else if ( settings.ajax || settings.sAjaxSource ) {
  4172. return 'ajax';
  4173. }
  4174. return 'dom';
  4175. }
  4176. DataTable = function( options )
  4177. {
  4178. /**
  4179. * Perform a jQuery selector action on the table's TR elements (from the tbody) and
  4180. * return the resulting jQuery object.
  4181. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  4182. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  4183. * @param {string} [oOpts.filter=none] Select TR elements that meet the current filter
  4184. * criterion ("applied") or all TR elements (i.e. no filter).
  4185. * @param {string} [oOpts.order=current] Order of the TR elements in the processed array.
  4186. * Can be either 'current', whereby the current sorting of the table is used, or
  4187. * 'original' whereby the original order the data was read into the table is used.
  4188. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  4189. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  4190. * 'current' and filter is 'applied', regardless of what they might be given as.
  4191. * @returns {object} jQuery object, filtered by the given selector.
  4192. * @dtopt API
  4193. * @deprecated Since v1.10
  4194. *
  4195. * @example
  4196. * $(document).ready(function() {
  4197. * var oTable = $('#example').dataTable();
  4198. *
  4199. * // Highlight every second row
  4200. * oTable.$('tr:odd').css('backgroundColor', 'blue');
  4201. * } );
  4202. *
  4203. * @example
  4204. * $(document).ready(function() {
  4205. * var oTable = $('#example').dataTable();
  4206. *
  4207. * // Filter to rows with 'Webkit' in them, add a background colour and then
  4208. * // remove the filter, thus highlighting the 'Webkit' rows only.
  4209. * oTable.fnFilter('Webkit');
  4210. * oTable.$('tr', {"search": "applied"}).css('backgroundColor', 'blue');
  4211. * oTable.fnFilter('');
  4212. * } );
  4213. */
  4214. this.$ = function ( sSelector, oOpts )
  4215. {
  4216. return this.api(true).$( sSelector, oOpts );
  4217. };
  4218. /**
  4219. * Almost identical to $ in operation, but in this case returns the data for the matched
  4220. * rows - as such, the jQuery selector used should match TR row nodes or TD/TH cell nodes
  4221. * rather than any descendants, so the data can be obtained for the row/cell. If matching
  4222. * rows are found, the data returned is the original data array/object that was used to
  4223. * create the row (or a generated array if from a DOM source).
  4224. *
  4225. * This method is often useful in-combination with $ where both functions are given the
  4226. * same parameters and the array indexes will match identically.
  4227. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  4228. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  4229. * @param {string} [oOpts.filter=none] Select elements that meet the current filter
  4230. * criterion ("applied") or all elements (i.e. no filter).
  4231. * @param {string} [oOpts.order=current] Order of the data in the processed array.
  4232. * Can be either 'current', whereby the current sorting of the table is used, or
  4233. * 'original' whereby the original order the data was read into the table is used.
  4234. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  4235. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  4236. * 'current' and filter is 'applied', regardless of what they might be given as.
  4237. * @returns {array} Data for the matched elements. If any elements, as a result of the
  4238. * selector, were not TR, TD or TH elements in the DataTable, they will have a null
  4239. * entry in the array.
  4240. * @dtopt API
  4241. * @deprecated Since v1.10
  4242. *
  4243. * @example
  4244. * $(document).ready(function() {
  4245. * var oTable = $('#example').dataTable();
  4246. *
  4247. * // Get the data from the first row in the table
  4248. * var data = oTable._('tr:first');
  4249. *
  4250. * // Do something useful with the data
  4251. * alert( "First cell is: "+data[0] );
  4252. * } );
  4253. *
  4254. * @example
  4255. * $(document).ready(function() {
  4256. * var oTable = $('#example').dataTable();
  4257. *
  4258. * // Filter to 'Webkit' and get all data for
  4259. * oTable.fnFilter('Webkit');
  4260. * var data = oTable._('tr', {"search": "applied"});
  4261. *
  4262. * // Do something with the data
  4263. * alert( data.length+" rows matched the search" );
  4264. * } );
  4265. */
  4266. this._ = function ( sSelector, oOpts )
  4267. {
  4268. return this.api(true).rows( sSelector, oOpts ).data();
  4269. };
  4270. /**
  4271. * Create a DataTables Api instance, with the currently selected tables for
  4272. * the Api's context.
  4273. * @param {boolean} [traditional=false] Set the API instance's context to be
  4274. * only the table referred to by the `DataTable.ext.iApiIndex` option, as was
  4275. * used in the API presented by DataTables 1.9- (i.e. the traditional mode),
  4276. * or if all tables captured in the jQuery object should be used.
  4277. * @return {DataTables.Api}
  4278. */
  4279. this.api = function ( traditional )
  4280. {
  4281. return traditional ?
  4282. new _Api(
  4283. _fnSettingsFromNode( this[ _ext.iApiIndex ] )
  4284. ) :
  4285. new _Api( this );
  4286. };
  4287. /**
  4288. * Add a single new row or multiple rows of data to the table. Please note
  4289. * that this is suitable for client-side processing only - if you are using
  4290. * server-side processing (i.e. "bServerSide": true), then to add data, you
  4291. * must add it to the data source, i.e. the server-side, through an Ajax call.
  4292. * @param {array|object} data The data to be added to the table. This can be:
  4293. * <ul>
  4294. * <li>1D array of data - add a single row with the data provided</li>
  4295. * <li>2D array of arrays - add multiple rows in a single call</li>
  4296. * <li>object - data object when using <i>mData</i></li>
  4297. * <li>array of objects - multiple data objects when using <i>mData</i></li>
  4298. * </ul>
  4299. * @param {bool} [redraw=true] redraw the table or not
  4300. * @returns {array} An array of integers, representing the list of indexes in
  4301. * <i>aoData</i> ({@link DataTable.models.oSettings}) that have been added to
  4302. * the table.
  4303. * @dtopt API
  4304. * @deprecated Since v1.10
  4305. *
  4306. * @example
  4307. * // Global var for counter
  4308. * var giCount = 2;
  4309. *
  4310. * $(document).ready(function() {
  4311. * $('#example').dataTable();
  4312. * } );
  4313. *
  4314. * function fnClickAddRow() {
  4315. * $('#example').dataTable().fnAddData( [
  4316. * giCount+".1",
  4317. * giCount+".2",
  4318. * giCount+".3",
  4319. * giCount+".4" ]
  4320. * );
  4321. *
  4322. * giCount++;
  4323. * }
  4324. */
  4325. this.fnAddData = function( data, redraw )
  4326. {
  4327. var api = this.api( true );
  4328. /* Check if we want to add multiple rows or not */
  4329. var rows = $.isArray(data) && ( $.isArray(data[0]) || $.isPlainObject(data[0]) ) ?
  4330. api.rows.add( data ) :
  4331. api.row.add( data );
  4332. if ( redraw === undefined || redraw ) {
  4333. api.draw();
  4334. }
  4335. return rows.flatten().toArray();
  4336. };
  4337. /**
  4338. * This function will make DataTables recalculate the column sizes, based on the data
  4339. * contained in the table and the sizes applied to the columns (in the DOM, CSS or
  4340. * through the sWidth parameter). This can be useful when the width of the table's
  4341. * parent element changes (for example a window resize).
  4342. * @param {boolean} [bRedraw=true] Redraw the table or not, you will typically want to
  4343. * @dtopt API
  4344. * @deprecated Since v1.10
  4345. *
  4346. * @example
  4347. * $(document).ready(function() {
  4348. * var oTable = $('#example').dataTable( {
  4349. * "sScrollY": "200px",
  4350. * "bPaginate": false
  4351. * } );
  4352. *
  4353. * $(window).bind('resize', function () {
  4354. * oTable.fnAdjustColumnSizing();
  4355. * } );
  4356. * } );
  4357. */
  4358. this.fnAdjustColumnSizing = function ( bRedraw )
  4359. {
  4360. var api = this.api( true ).columns.adjust();
  4361. var settings = api.settings()[0];
  4362. var scroll = settings.oScroll;
  4363. if ( bRedraw === undefined || bRedraw ) {
  4364. api.draw( false );
  4365. }
  4366. else if ( scroll.sX !== "" || scroll.sY !== "" ) {
  4367. /* If not redrawing, but scrolling, we want to apply the new column sizes anyway */
  4368. _fnScrollDraw( settings );
  4369. }
  4370. };
  4371. /**
  4372. * Quickly and simply clear a table
  4373. * @param {bool} [bRedraw=true] redraw the table or not
  4374. * @dtopt API
  4375. * @deprecated Since v1.10
  4376. *
  4377. * @example
  4378. * $(document).ready(function() {
  4379. * var oTable = $('#example').dataTable();
  4380. *
  4381. * // Immediately 'nuke' the current rows (perhaps waiting for an Ajax callback...)
  4382. * oTable.fnClearTable();
  4383. * } );
  4384. */
  4385. this.fnClearTable = function( bRedraw )
  4386. {
  4387. var api = this.api( true ).clear();
  4388. if ( bRedraw === undefined || bRedraw ) {
  4389. api.draw();
  4390. }
  4391. };
  4392. /**
  4393. * The exact opposite of 'opening' a row, this function will close any rows which
  4394. * are currently 'open'.
  4395. * @param {node} nTr the table row to 'close'
  4396. * @returns {int} 0 on success, or 1 if failed (can't find the row)
  4397. * @dtopt API
  4398. * @deprecated Since v1.10
  4399. *
  4400. * @example
  4401. * $(document).ready(function() {
  4402. * var oTable;
  4403. *
  4404. * // 'open' an information row when a row is clicked on
  4405. * $('#example tbody tr').click( function () {
  4406. * if ( oTable.fnIsOpen(this) ) {
  4407. * oTable.fnClose( this );
  4408. * } else {
  4409. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  4410. * }
  4411. * } );
  4412. *
  4413. * oTable = $('#example').dataTable();
  4414. * } );
  4415. */
  4416. this.fnClose = function( nTr )
  4417. {
  4418. this.api( true ).row( nTr ).child.hide();
  4419. };
  4420. /**
  4421. * Remove a row for the table
  4422. * @param {mixed} target The index of the row from aoData to be deleted, or
  4423. * the TR element you want to delete
  4424. * @param {function|null} [callBack] Callback function
  4425. * @param {bool} [redraw=true] Redraw the table or not
  4426. * @returns {array} The row that was deleted
  4427. * @dtopt API
  4428. * @deprecated Since v1.10
  4429. *
  4430. * @example
  4431. * $(document).ready(function() {
  4432. * var oTable = $('#example').dataTable();
  4433. *
  4434. * // Immediately remove the first row
  4435. * oTable.fnDeleteRow( 0 );
  4436. * } );
  4437. */
  4438. this.fnDeleteRow = function( target, callback, redraw )
  4439. {
  4440. var api = this.api( true );
  4441. var rows = api.rows( target );
  4442. var settings = rows.settings()[0];
  4443. var data = settings.aoData[ rows[0][0] ];
  4444. rows.remove();
  4445. if ( callback ) {
  4446. callback.call( this, settings, data );
  4447. }
  4448. if ( redraw === undefined || redraw ) {
  4449. api.draw();
  4450. }
  4451. return data;
  4452. };
  4453. /**
  4454. * Restore the table to it's original state in the DOM by removing all of DataTables
  4455. * enhancements, alterations to the DOM structure of the table and event listeners.
  4456. * @param {boolean} [remove=false] Completely remove the table from the DOM
  4457. * @dtopt API
  4458. * @deprecated Since v1.10
  4459. *
  4460. * @example
  4461. * $(document).ready(function() {
  4462. * // This example is fairly pointless in reality, but shows how fnDestroy can be used
  4463. * var oTable = $('#example').dataTable();
  4464. * oTable.fnDestroy();
  4465. * } );
  4466. */
  4467. this.fnDestroy = function ( remove )
  4468. {
  4469. this.api( true ).destroy( remove );
  4470. };
  4471. /**
  4472. * Redraw the table
  4473. * @param {bool} [complete=true] Re-filter and resort (if enabled) the table before the draw.
  4474. * @dtopt API
  4475. * @deprecated Since v1.10
  4476. *
  4477. * @example
  4478. * $(document).ready(function() {
  4479. * var oTable = $('#example').dataTable();
  4480. *
  4481. * // Re-draw the table - you wouldn't want to do it here, but it's an example :-)
  4482. * oTable.fnDraw();
  4483. * } );
  4484. */
  4485. this.fnDraw = function( complete )
  4486. {
  4487. // Note that this isn't an exact match to the old call to _fnDraw - it takes
  4488. // into account the new data, but can old position.
  4489. this.api( true ).draw( ! complete );
  4490. };
  4491. /**
  4492. * Filter the input based on data
  4493. * @param {string} sInput String to filter the table on
  4494. * @param {int|null} [iColumn] Column to limit filtering to
  4495. * @param {bool} [bRegex=false] Treat as regular expression or not
  4496. * @param {bool} [bSmart=true] Perform smart filtering or not
  4497. * @param {bool} [bShowGlobal=true] Show the input global filter in it's input box(es)
  4498. * @param {bool} [bCaseInsensitive=true] Do case-insensitive matching (true) or not (false)
  4499. * @dtopt API
  4500. * @deprecated Since v1.10
  4501. *
  4502. * @example
  4503. * $(document).ready(function() {
  4504. * var oTable = $('#example').dataTable();
  4505. *
  4506. * // Sometime later - filter...
  4507. * oTable.fnFilter( 'test string' );
  4508. * } );
  4509. */
  4510. this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal, bCaseInsensitive )
  4511. {
  4512. var api = this.api( true );
  4513. if ( iColumn === null || iColumn === undefined ) {
  4514. api.search( sInput, bRegex, bSmart, bCaseInsensitive );
  4515. }
  4516. else {
  4517. api.column( iColumn ).search( sInput, bRegex, bSmart, bCaseInsensitive );
  4518. }
  4519. api.draw();
  4520. };
  4521. /**
  4522. * Get the data for the whole table, an individual row or an individual cell based on the
  4523. * provided parameters.
  4524. * @param {int|node} [src] A TR row node, TD/TH cell node or an integer. If given as
  4525. * a TR node then the data source for the whole row will be returned. If given as a
  4526. * TD/TH cell node then iCol will be automatically calculated and the data for the
  4527. * cell returned. If given as an integer, then this is treated as the aoData internal
  4528. * data index for the row (see fnGetPosition) and the data for that row used.
  4529. * @param {int} [col] Optional column index that you want the data of.
  4530. * @returns {array|object|string} If mRow is undefined, then the data for all rows is
  4531. * returned. If mRow is defined, just data for that row, and is iCol is
  4532. * defined, only data for the designated cell is returned.
  4533. * @dtopt API
  4534. * @deprecated Since v1.10
  4535. *
  4536. * @example
  4537. * // Row data
  4538. * $(document).ready(function() {
  4539. * oTable = $('#example').dataTable();
  4540. *
  4541. * oTable.$('tr').click( function () {
  4542. * var data = oTable.fnGetData( this );
  4543. * // ... do something with the array / object of data for the row
  4544. * } );
  4545. * } );
  4546. *
  4547. * @example
  4548. * // Individual cell data
  4549. * $(document).ready(function() {
  4550. * oTable = $('#example').dataTable();
  4551. *
  4552. * oTable.$('td').click( function () {
  4553. * var sData = oTable.fnGetData( this );
  4554. * alert( 'The cell clicked on had the value of '+sData );
  4555. * } );
  4556. * } );
  4557. */
  4558. this.fnGetData = function( src, col )
  4559. {
  4560. var api = this.api( true );
  4561. if ( src !== undefined ) {
  4562. var type = src.nodeName ? src.nodeName.toLowerCase() : '';
  4563. return col !== undefined || type == 'td' || type == 'th' ?
  4564. api.cell( src, col ).data() :
  4565. api.row( src ).data();
  4566. }
  4567. return api.data().toArray();
  4568. };
  4569. /**
  4570. * Get an array of the TR nodes that are used in the table's body. Note that you will
  4571. * typically want to use the '$' API method in preference to this as it is more
  4572. * flexible.
  4573. * @param {int} [iRow] Optional row index for the TR element you want
  4574. * @returns {array|node} If iRow is undefined, returns an array of all TR elements
  4575. * in the table's body, or iRow is defined, just the TR element requested.
  4576. * @dtopt API
  4577. * @deprecated Since v1.10
  4578. *
  4579. * @example
  4580. * $(document).ready(function() {
  4581. * var oTable = $('#example').dataTable();
  4582. *
  4583. * // Get the nodes from the table
  4584. * var nNodes = oTable.fnGetNodes( );
  4585. * } );
  4586. */
  4587. this.fnGetNodes = function( iRow )
  4588. {
  4589. var api = this.api( true );
  4590. return iRow !== undefined ?
  4591. api.row( iRow ).node() :
  4592. api.rows().nodes().toArray();
  4593. };
  4594. /**
  4595. * Get the array indexes of a particular cell from it's DOM element
  4596. * and column index including hidden columns
  4597. * @param {node} node this can either be a TR, TD or TH in the table's body
  4598. * @returns {int} If nNode is given as a TR, then a single index is returned, or
  4599. * if given as a cell, an array of [row index, column index (visible),
  4600. * column index (all)] is given.
  4601. * @dtopt API
  4602. * @deprecated Since v1.10
  4603. *
  4604. * @example
  4605. * $(document).ready(function() {
  4606. * $('#example tbody td').click( function () {
  4607. * // Get the position of the current data from the node
  4608. * var aPos = oTable.fnGetPosition( this );
  4609. *
  4610. * // Get the data array for this row
  4611. * var aData = oTable.fnGetData( aPos[0] );
  4612. *
  4613. * // Update the data array and return the value
  4614. * aData[ aPos[1] ] = 'clicked';
  4615. * this.innerHTML = 'clicked';
  4616. * } );
  4617. *
  4618. * // Init DataTables
  4619. * oTable = $('#example').dataTable();
  4620. * } );
  4621. */
  4622. this.fnGetPosition = function( node )
  4623. {
  4624. var api = this.api( true );
  4625. var nodeName = node.nodeName.toUpperCase();
  4626. if ( nodeName == 'TR' ) {
  4627. return api.row( node ).index();
  4628. }
  4629. else if ( nodeName == 'TD' || nodeName == 'TH' ) {
  4630. var cell = api.cell( node ).index();
  4631. return [
  4632. cell.row,
  4633. cell.columnVisible,
  4634. cell.column
  4635. ];
  4636. }
  4637. return null;
  4638. };
  4639. /**
  4640. * Check to see if a row is 'open' or not.
  4641. * @param {node} nTr the table row to check
  4642. * @returns {boolean} true if the row is currently open, false otherwise
  4643. * @dtopt API
  4644. * @deprecated Since v1.10
  4645. *
  4646. * @example
  4647. * $(document).ready(function() {
  4648. * var oTable;
  4649. *
  4650. * // 'open' an information row when a row is clicked on
  4651. * $('#example tbody tr').click( function () {
  4652. * if ( oTable.fnIsOpen(this) ) {
  4653. * oTable.fnClose( this );
  4654. * } else {
  4655. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  4656. * }
  4657. * } );
  4658. *
  4659. * oTable = $('#example').dataTable();
  4660. * } );
  4661. */
  4662. this.fnIsOpen = function( nTr )
  4663. {
  4664. return this.api( true ).row( nTr ).child.isShown();
  4665. };
  4666. /**
  4667. * This function will place a new row directly after a row which is currently
  4668. * on display on the page, with the HTML contents that is passed into the
  4669. * function. This can be used, for example, to ask for confirmation that a
  4670. * particular record should be deleted.
  4671. * @param {node} nTr The table row to 'open'
  4672. * @param {string|node|jQuery} mHtml The HTML to put into the row
  4673. * @param {string} sClass Class to give the new TD cell
  4674. * @returns {node} The row opened. Note that if the table row passed in as the
  4675. * first parameter, is not found in the table, this method will silently
  4676. * return.
  4677. * @dtopt API
  4678. * @deprecated Since v1.10
  4679. *
  4680. * @example
  4681. * $(document).ready(function() {
  4682. * var oTable;
  4683. *
  4684. * // 'open' an information row when a row is clicked on
  4685. * $('#example tbody tr').click( function () {
  4686. * if ( oTable.fnIsOpen(this) ) {
  4687. * oTable.fnClose( this );
  4688. * } else {
  4689. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  4690. * }
  4691. * } );
  4692. *
  4693. * oTable = $('#example').dataTable();
  4694. * } );
  4695. */
  4696. this.fnOpen = function( nTr, mHtml, sClass )
  4697. {
  4698. return this.api( true ).row( nTr ).child( mHtml, sClass ).show();
  4699. };
  4700. /**
  4701. * Change the pagination - provides the internal logic for pagination in a simple API
  4702. * function. With this function you can have a DataTables table go to the next,
  4703. * previous, first or last pages.
  4704. * @param {string|int} mAction Paging action to take: "first", "previous", "next" or "last"
  4705. * or page number to jump to (integer), note that page 0 is the first page.
  4706. * @param {bool} [bRedraw=true] Redraw the table or not
  4707. * @dtopt API
  4708. * @deprecated Since v1.10
  4709. *
  4710. * @example
  4711. * $(document).ready(function() {
  4712. * var oTable = $('#example').dataTable();
  4713. * oTable.fnPageChange( 'next' );
  4714. * } );
  4715. */
  4716. this.fnPageChange = function ( mAction, bRedraw )
  4717. {
  4718. var api = this.api( true ).page( mAction );
  4719. if ( bRedraw === undefined || bRedraw ) {
  4720. api.draw(false);
  4721. }
  4722. };
  4723. /**
  4724. * Show a particular column
  4725. * @param {int} iCol The column whose display should be changed
  4726. * @param {bool} bShow Show (true) or hide (false) the column
  4727. * @param {bool} [bRedraw=true] Redraw the table or not
  4728. * @dtopt API
  4729. * @deprecated Since v1.10
  4730. *
  4731. * @example
  4732. * $(document).ready(function() {
  4733. * var oTable = $('#example').dataTable();
  4734. *
  4735. * // Hide the second column after initialisation
  4736. * oTable.fnSetColumnVis( 1, false );
  4737. * } );
  4738. */
  4739. this.fnSetColumnVis = function ( iCol, bShow, bRedraw )
  4740. {
  4741. var api = this.api( true ).column( iCol ).visible( bShow );
  4742. if ( bRedraw === undefined || bRedraw ) {
  4743. api.columns.adjust().draw();
  4744. }
  4745. };
  4746. /**
  4747. * Get the settings for a particular table for external manipulation
  4748. * @returns {object} DataTables settings object. See
  4749. * {@link DataTable.models.oSettings}
  4750. * @dtopt API
  4751. * @deprecated Since v1.10
  4752. *
  4753. * @example
  4754. * $(document).ready(function() {
  4755. * var oTable = $('#example').dataTable();
  4756. * var oSettings = oTable.fnSettings();
  4757. *
  4758. * // Show an example parameter from the settings
  4759. * alert( oSettings._iDisplayStart );
  4760. * } );
  4761. */
  4762. this.fnSettings = function()
  4763. {
  4764. return _fnSettingsFromNode( this[_ext.iApiIndex] );
  4765. };
  4766. /**
  4767. * Sort the table by a particular column
  4768. * @param {int} iCol the data index to sort on. Note that this will not match the
  4769. * 'display index' if you have hidden data entries
  4770. * @dtopt API
  4771. * @deprecated Since v1.10
  4772. *
  4773. * @example
  4774. * $(document).ready(function() {
  4775. * var oTable = $('#example').dataTable();
  4776. *
  4777. * // Sort immediately with columns 0 and 1
  4778. * oTable.fnSort( [ [0,'asc'], [1,'asc'] ] );
  4779. * } );
  4780. */
  4781. this.fnSort = function( aaSort )
  4782. {
  4783. this.api( true ).order( aaSort ).draw();
  4784. };
  4785. /**
  4786. * Attach a sort listener to an element for a given column
  4787. * @param {node} nNode the element to attach the sort listener to
  4788. * @param {int} iColumn the column that a click on this node will sort on
  4789. * @param {function} [fnCallback] callback function when sort is run
  4790. * @dtopt API
  4791. * @deprecated Since v1.10
  4792. *
  4793. * @example
  4794. * $(document).ready(function() {
  4795. * var oTable = $('#example').dataTable();
  4796. *
  4797. * // Sort on column 1, when 'sorter' is clicked on
  4798. * oTable.fnSortListener( document.getElementById('sorter'), 1 );
  4799. * } );
  4800. */
  4801. this.fnSortListener = function( nNode, iColumn, fnCallback )
  4802. {
  4803. this.api( true ).order.listener( nNode, iColumn, fnCallback );
  4804. };
  4805. /**
  4806. * Update a table cell or row - this method will accept either a single value to
  4807. * update the cell with, an array of values with one element for each column or
  4808. * an object in the same format as the original data source. The function is
  4809. * self-referencing in order to make the multi column updates easier.
  4810. * @param {object|array|string} mData Data to update the cell/row with
  4811. * @param {node|int} mRow TR element you want to update or the aoData index
  4812. * @param {int} [iColumn] The column to update, give as null or undefined to
  4813. * update a whole row.
  4814. * @param {bool} [bRedraw=true] Redraw the table or not
  4815. * @param {bool} [bAction=true] Perform pre-draw actions or not
  4816. * @returns {int} 0 on success, 1 on error
  4817. * @dtopt API
  4818. * @deprecated Since v1.10
  4819. *
  4820. * @example
  4821. * $(document).ready(function() {
  4822. * var oTable = $('#example').dataTable();
  4823. * oTable.fnUpdate( 'Example update', 0, 0 ); // Single cell
  4824. * oTable.fnUpdate( ['a', 'b', 'c', 'd', 'e'], $('tbody tr')[0] ); // Row
  4825. * } );
  4826. */
  4827. this.fnUpdate = function( mData, mRow, iColumn, bRedraw, bAction )
  4828. {
  4829. var api = this.api( true );
  4830. if ( iColumn === undefined || iColumn === null ) {
  4831. api.row( mRow ).data( mData );
  4832. }
  4833. else {
  4834. api.cell( mRow, iColumn ).data( mData );
  4835. }
  4836. if ( bAction === undefined || bAction ) {
  4837. api.columns.adjust();
  4838. }
  4839. if ( bRedraw === undefined || bRedraw ) {
  4840. api.draw();
  4841. }
  4842. return 0;
  4843. };
  4844. /**
  4845. * Provide a common method for plug-ins to check the version of DataTables being used, in order
  4846. * to ensure compatibility.
  4847. * @param {string} sVersion Version string to check for, in the format "X.Y.Z". Note that the
  4848. * formats "X" and "X.Y" are also acceptable.
  4849. * @returns {boolean} true if this version of DataTables is greater or equal to the required
  4850. * version, or false if this version of DataTales is not suitable
  4851. * @method
  4852. * @dtopt API
  4853. * @deprecated Since v1.10
  4854. *
  4855. * @example
  4856. * $(document).ready(function() {
  4857. * var oTable = $('#example').dataTable();
  4858. * alert( oTable.fnVersionCheck( '1.9.0' ) );
  4859. * } );
  4860. */
  4861. this.fnVersionCheck = _ext.fnVersionCheck;
  4862. /*
  4863. * This is really a good bit rubbish this method of exposing the internal methods
  4864. * publicly... - To be fixed in 2.0 using methods on the prototype
  4865. */
  4866. /**
  4867. * Create a wrapper function for exporting an internal functions to an external API.
  4868. * @param {string} fn API function name
  4869. * @returns {function} wrapped function
  4870. * @memberof DataTable#internal
  4871. */
  4872. function _fnExternApiFunc (fn)
  4873. {
  4874. return function() {
  4875. var args = [_fnSettingsFromNode( this[DataTable.ext.iApiIndex] )].concat(
  4876. Array.prototype.slice.call(arguments)
  4877. );
  4878. return DataTable.ext.internal[fn].apply( this, args );
  4879. };
  4880. }
  4881. /**
  4882. * Reference to internal functions for use by plug-in developers. Note that
  4883. * these methods are references to internal functions and are considered to be
  4884. * private. If you use these methods, be aware that they are liable to change
  4885. * between versions.
  4886. * @namespace
  4887. */
  4888. this.oApi = this.internal = {
  4889. _fnExternApiFunc: _fnExternApiFunc,
  4890. _fnBuildAjax: _fnBuildAjax,
  4891. _fnAjaxUpdate: _fnAjaxUpdate,
  4892. _fnAjaxParameters: _fnAjaxParameters,
  4893. _fnAjaxUpdateDraw: _fnAjaxUpdateDraw,
  4894. _fnAjaxDataSrc: _fnAjaxDataSrc,
  4895. _fnAddColumn: _fnAddColumn,
  4896. _fnColumnOptions: _fnColumnOptions,
  4897. _fnAdjustColumnSizing: _fnAdjustColumnSizing,
  4898. _fnVisibleToColumnIndex: _fnVisibleToColumnIndex,
  4899. _fnColumnIndexToVisible: _fnColumnIndexToVisible,
  4900. _fnVisbleColumns: _fnVisbleColumns,
  4901. _fnGetColumns: _fnGetColumns,
  4902. _fnColumnTypes: _fnColumnTypes,
  4903. _fnApplyColumnDefs: _fnApplyColumnDefs,
  4904. _fnHungarianMap: _fnHungarianMap,
  4905. _fnCamelToHungarian: _fnCamelToHungarian,
  4906. _fnLanguageCompat: _fnLanguageCompat,
  4907. _fnBrowserDetect: _fnBrowserDetect,
  4908. _fnAddData: _fnAddData,
  4909. _fnAddTr: _fnAddTr,
  4910. _fnNodeToDataIndex: _fnNodeToDataIndex,
  4911. _fnNodeToColumnIndex: _fnNodeToColumnIndex,
  4912. _fnGetRowData: _fnGetRowData,
  4913. _fnGetCellData: _fnGetCellData,
  4914. _fnSetCellData: _fnSetCellData,
  4915. _fnSplitObjNotation: _fnSplitObjNotation,
  4916. _fnGetObjectDataFn: _fnGetObjectDataFn,
  4917. _fnSetObjectDataFn: _fnSetObjectDataFn,
  4918. _fnGetDataMaster: _fnGetDataMaster,
  4919. _fnClearTable: _fnClearTable,
  4920. _fnDeleteIndex: _fnDeleteIndex,
  4921. _fnInvalidateRow: _fnInvalidateRow,
  4922. _fnGetRowElements: _fnGetRowElements,
  4923. _fnCreateTr: _fnCreateTr,
  4924. _fnBuildHead: _fnBuildHead,
  4925. _fnDrawHead: _fnDrawHead,
  4926. _fnDraw: _fnDraw,
  4927. _fnReDraw: _fnReDraw,
  4928. _fnAddOptionsHtml: _fnAddOptionsHtml,
  4929. _fnDetectHeader: _fnDetectHeader,
  4930. _fnGetUniqueThs: _fnGetUniqueThs,
  4931. _fnFeatureHtmlFilter: _fnFeatureHtmlFilter,
  4932. _fnFilterComplete: _fnFilterComplete,
  4933. _fnFilterCustom: _fnFilterCustom,
  4934. _fnFilterColumn: _fnFilterColumn,
  4935. _fnFilter: _fnFilter,
  4936. _fnFilterCreateSearch: _fnFilterCreateSearch,
  4937. _fnEscapeRegex: _fnEscapeRegex,
  4938. _fnFilterData: _fnFilterData,
  4939. _fnFeatureHtmlInfo: _fnFeatureHtmlInfo,
  4940. _fnUpdateInfo: _fnUpdateInfo,
  4941. _fnInfoMacros: _fnInfoMacros,
  4942. _fnInitialise: _fnInitialise,
  4943. _fnInitComplete: _fnInitComplete,
  4944. _fnLengthChange: _fnLengthChange,
  4945. _fnFeatureHtmlLength: _fnFeatureHtmlLength,
  4946. _fnFeatureHtmlPaginate: _fnFeatureHtmlPaginate,
  4947. _fnPageChange: _fnPageChange,
  4948. _fnFeatureHtmlProcessing: _fnFeatureHtmlProcessing,
  4949. _fnProcessingDisplay: _fnProcessingDisplay,
  4950. _fnFeatureHtmlTable: _fnFeatureHtmlTable,
  4951. _fnScrollDraw: _fnScrollDraw,
  4952. _fnApplyToChildren: _fnApplyToChildren,
  4953. _fnCalculateColumnWidths: _fnCalculateColumnWidths,
  4954. _fnThrottle: _fnThrottle,
  4955. _fnConvertToWidth: _fnConvertToWidth,
  4956. _fnScrollingWidthAdjust: _fnScrollingWidthAdjust,
  4957. _fnGetWidestNode: _fnGetWidestNode,
  4958. _fnGetMaxLenString: _fnGetMaxLenString,
  4959. _fnStringToCss: _fnStringToCss,
  4960. _fnScrollBarWidth: _fnScrollBarWidth,
  4961. _fnSortFlatten: _fnSortFlatten,
  4962. _fnSort: _fnSort,
  4963. _fnSortAria: _fnSortAria,
  4964. _fnSortListener: _fnSortListener,
  4965. _fnSortAttachListener: _fnSortAttachListener,
  4966. _fnSortingClasses: _fnSortingClasses,
  4967. _fnSortData: _fnSortData,
  4968. _fnSaveState: _fnSaveState,
  4969. _fnLoadState: _fnLoadState,
  4970. _fnSettingsFromNode: _fnSettingsFromNode,
  4971. _fnLog: _fnLog,
  4972. _fnMap: _fnMap,
  4973. _fnBindAction: _fnBindAction,
  4974. _fnCallbackReg: _fnCallbackReg,
  4975. _fnCallbackFire: _fnCallbackFire,
  4976. _fnLengthOverflow: _fnLengthOverflow,
  4977. _fnRenderer: _fnRenderer,
  4978. _fnDataSource: _fnDataSource,
  4979. _fnRowAttributes: _fnRowAttributes
  4980. };
  4981. $.extend( DataTable.ext.internal, this.internal );
  4982. for ( var fn in DataTable.ext.internal ) {
  4983. if ( fn ) {
  4984. this[fn] = _fnExternApiFunc(fn);
  4985. }
  4986. }
  4987. var _that = this;
  4988. var emptyInit = options === undefined;
  4989. var len = this.length;
  4990. if ( emptyInit ) {
  4991. options = {};
  4992. }
  4993. this.each(function() {
  4994. // For each initialisation we want to give it a clean initialisation
  4995. // object that can be bashed around
  4996. var o = {};
  4997. var oInit = len > 1 ? // optimisation for single table case
  4998. _fnExtend( o, options, true ) :
  4999. options;
  5000. /*global oInit,_that,emptyInit*/
  5001. var i=0, iLen, j, jLen, k, kLen;
  5002. var sId = this.getAttribute( 'id' );
  5003. var bInitHandedOff = false;
  5004. var defaults = DataTable.defaults;
  5005. /* Sanity check */
  5006. if ( this.nodeName.toLowerCase() != 'table' )
  5007. {
  5008. _fnLog( null, 0, 'Non-table node initialisation ('+this.nodeName+')', 2 );
  5009. return;
  5010. }
  5011. /* Backwards compatibility for the defaults */
  5012. _fnCompatOpts( defaults );
  5013. _fnCompatCols( defaults.column );
  5014. /* Convert the camel-case defaults to Hungarian */
  5015. _fnCamelToHungarian( defaults, defaults, true );
  5016. _fnCamelToHungarian( defaults.column, defaults.column, true );
  5017. /* Setting up the initialisation object */
  5018. _fnCamelToHungarian( defaults, oInit );
  5019. /* Check to see if we are re-initialising a table */
  5020. var allSettings = DataTable.settings;
  5021. for ( i=0, iLen=allSettings.length ; i<iLen ; i++ )
  5022. {
  5023. /* Base check on table node */
  5024. if ( allSettings[i].nTable == this )
  5025. {
  5026. var bRetrieve = oInit.bRetrieve !== undefined ? oInit.bRetrieve : defaults.bRetrieve;
  5027. var bDestroy = oInit.bDestroy !== undefined ? oInit.bDestroy : defaults.bDestroy;
  5028. if ( emptyInit || bRetrieve )
  5029. {
  5030. return allSettings[i].oInstance;
  5031. }
  5032. else if ( bDestroy )
  5033. {
  5034. allSettings[i].oInstance.fnDestroy();
  5035. break;
  5036. }
  5037. else
  5038. {
  5039. _fnLog( allSettings[i], 0, 'Cannot reinitialise DataTable', 3 );
  5040. return;
  5041. }
  5042. }
  5043. /* If the element we are initialising has the same ID as a table which was previously
  5044. * initialised, but the table nodes don't match (from before) then we destroy the old
  5045. * instance by simply deleting it. This is under the assumption that the table has been
  5046. * destroyed by other methods. Anyone using non-id selectors will need to do this manually
  5047. */
  5048. if ( allSettings[i].sTableId == this.id )
  5049. {
  5050. allSettings.splice( i, 1 );
  5051. break;
  5052. }
  5053. }
  5054. /* Ensure the table has an ID - required for accessibility */
  5055. if ( sId === null || sId === "" )
  5056. {
  5057. sId = "DataTables_Table_"+(DataTable.ext._unique++);
  5058. this.id = sId;
  5059. }
  5060. /* Create the settings object for this table and set some of the default parameters */
  5061. var oSettings = $.extend( true, {}, DataTable.models.oSettings, {
  5062. "nTable": this,
  5063. "oApi": _that.internal,
  5064. "oInit": oInit,
  5065. "sDestroyWidth": $(this)[0].style.width,
  5066. "sInstance": sId,
  5067. "sTableId": sId
  5068. } );
  5069. allSettings.push( oSettings );
  5070. // Need to add the instance after the instance after the settings object has been added
  5071. // to the settings array, so we can self reference the table instance if more than one
  5072. oSettings.oInstance = (_that.length===1) ? _that : $(this).dataTable();
  5073. // Backwards compatibility, before we apply all the defaults
  5074. _fnCompatOpts( oInit );
  5075. if ( oInit.oLanguage )
  5076. {
  5077. _fnLanguageCompat( oInit.oLanguage );
  5078. }
  5079. // If the length menu is given, but the init display length is not, use the length menu
  5080. if ( oInit.aLengthMenu && ! oInit.iDisplayLength )
  5081. {
  5082. oInit.iDisplayLength = $.isArray( oInit.aLengthMenu[0] ) ?
  5083. oInit.aLengthMenu[0][0] : oInit.aLengthMenu[0];
  5084. }
  5085. // Apply the defaults and init options to make a single init object will all
  5086. // options defined from defaults and instance options.
  5087. oInit = _fnExtend( $.extend( true, {}, defaults ), oInit );
  5088. // Map the initialisation options onto the settings object
  5089. _fnMap( oSettings.oFeatures, oInit, [
  5090. "bPaginate",
  5091. "bLengthChange",
  5092. "bFilter",
  5093. "bSort",
  5094. "bSortMulti",
  5095. "bInfo",
  5096. "bProcessing",
  5097. "bAutoWidth",
  5098. "bSortClasses",
  5099. "bServerSide",
  5100. "bDeferRender"
  5101. ] );
  5102. _fnMap( oSettings, oInit, [
  5103. "asStripeClasses",
  5104. "ajax",
  5105. "fnServerData",
  5106. "fnFormatNumber",
  5107. "sServerMethod",
  5108. "aaSorting",
  5109. "aaSortingFixed",
  5110. "aLengthMenu",
  5111. "sPaginationType",
  5112. "sAjaxSource",
  5113. "sAjaxDataProp",
  5114. "iStateDuration",
  5115. "sDom",
  5116. "bSortCellsTop",
  5117. "iTabIndex",
  5118. "fnStateLoadCallback",
  5119. "fnStateSaveCallback",
  5120. "renderer",
  5121. [ "iCookieDuration", "iStateDuration" ], // backwards compat
  5122. [ "oSearch", "oPreviousSearch" ],
  5123. [ "aoSearchCols", "aoPreSearchCols" ],
  5124. [ "iDisplayLength", "_iDisplayLength" ],
  5125. [ "bJQueryUI", "bJUI" ]
  5126. ] );
  5127. _fnMap( oSettings.oScroll, oInit, [
  5128. [ "sScrollX", "sX" ],
  5129. [ "sScrollXInner", "sXInner" ],
  5130. [ "sScrollY", "sY" ],
  5131. [ "bScrollCollapse", "bCollapse" ]
  5132. ] );
  5133. _fnMap( oSettings.oLanguage, oInit, "fnInfoCallback" );
  5134. /* Callback functions which are array driven */
  5135. _fnCallbackReg( oSettings, 'aoDrawCallback', oInit.fnDrawCallback, 'user' );
  5136. _fnCallbackReg( oSettings, 'aoServerParams', oInit.fnServerParams, 'user' );
  5137. _fnCallbackReg( oSettings, 'aoStateSaveParams', oInit.fnStateSaveParams, 'user' );
  5138. _fnCallbackReg( oSettings, 'aoStateLoadParams', oInit.fnStateLoadParams, 'user' );
  5139. _fnCallbackReg( oSettings, 'aoStateLoaded', oInit.fnStateLoaded, 'user' );
  5140. _fnCallbackReg( oSettings, 'aoRowCallback', oInit.fnRowCallback, 'user' );
  5141. _fnCallbackReg( oSettings, 'aoRowCreatedCallback', oInit.fnCreatedRow, 'user' );
  5142. _fnCallbackReg( oSettings, 'aoHeaderCallback', oInit.fnHeaderCallback, 'user' );
  5143. _fnCallbackReg( oSettings, 'aoFooterCallback', oInit.fnFooterCallback, 'user' );
  5144. _fnCallbackReg( oSettings, 'aoInitComplete', oInit.fnInitComplete, 'user' );
  5145. _fnCallbackReg( oSettings, 'aoPreDrawCallback', oInit.fnPreDrawCallback, 'user' );
  5146. // @todo Remove in 1.11
  5147. if ( oInit.bJQueryUI )
  5148. {
  5149. /* Use the JUI classes object for display. You could clone the oStdClasses object if
  5150. * you want to have multiple tables with multiple independent classes
  5151. */
  5152. $.extend( oSettings.oClasses, DataTable.ext.oJUIClasses, oInit.oClasses );
  5153. if ( oInit.sDom === defaults.sDom && defaults.sDom === "lfrtip" )
  5154. {
  5155. /* Set the DOM to use a layout suitable for jQuery UI's theming */
  5156. oSettings.sDom = '<"H"lfr>t<"F"ip>';
  5157. }
  5158. if ( ! oSettings.renderer ) {
  5159. oSettings.renderer = 'jqueryui';
  5160. }
  5161. else if ( $.isPlainObject( oSettings.renderer ) && ! oSettings.renderer.header ) {
  5162. oSettings.renderer.header = 'jqueryui';
  5163. }
  5164. }
  5165. else
  5166. {
  5167. $.extend( oSettings.oClasses, DataTable.ext.classes, oInit.oClasses );
  5168. }
  5169. $(this).addClass( oSettings.oClasses.sTable );
  5170. /* Calculate the scroll bar width and cache it for use later on */
  5171. if ( oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "" )
  5172. {
  5173. oSettings.oScroll.iBarWidth = _fnScrollBarWidth();
  5174. }
  5175. if ( oSettings.oScroll.sX === true ) { // Easy initialisation of x-scrolling
  5176. oSettings.oScroll.sX = '100%';
  5177. }
  5178. if ( oSettings.iInitDisplayStart === undefined )
  5179. {
  5180. /* Display start point, taking into account the save saving */
  5181. oSettings.iInitDisplayStart = oInit.iDisplayStart;
  5182. oSettings._iDisplayStart = oInit.iDisplayStart;
  5183. }
  5184. if ( oInit.iDeferLoading !== null )
  5185. {
  5186. oSettings.bDeferLoading = true;
  5187. var tmp = $.isArray( oInit.iDeferLoading );
  5188. oSettings._iRecordsDisplay = tmp ? oInit.iDeferLoading[0] : oInit.iDeferLoading;
  5189. oSettings._iRecordsTotal = tmp ? oInit.iDeferLoading[1] : oInit.iDeferLoading;
  5190. }
  5191. /* Language definitions */
  5192. if ( oInit.oLanguage.sUrl !== "" )
  5193. {
  5194. /* Get the language definitions from a file - because this Ajax call makes the language
  5195. * get async to the remainder of this function we use bInitHandedOff to indicate that
  5196. * _fnInitialise will be fired by the returned Ajax handler, rather than the constructor
  5197. */
  5198. oSettings.oLanguage.sUrl = oInit.oLanguage.sUrl;
  5199. $.getJSON( oSettings.oLanguage.sUrl, null, function( json ) {
  5200. _fnLanguageCompat( json );
  5201. _fnCamelToHungarian( defaults.oLanguage, json );
  5202. $.extend( true, oSettings.oLanguage, oInit.oLanguage, json );
  5203. _fnInitialise( oSettings );
  5204. } );
  5205. bInitHandedOff = true;
  5206. }
  5207. else
  5208. {
  5209. $.extend( true, oSettings.oLanguage, oInit.oLanguage );
  5210. }
  5211. /*
  5212. * Stripes
  5213. */
  5214. if ( oInit.asStripeClasses === null )
  5215. {
  5216. oSettings.asStripeClasses =[
  5217. oSettings.oClasses.sStripeOdd,
  5218. oSettings.oClasses.sStripeEven
  5219. ];
  5220. }
  5221. /* Remove row stripe classes if they are already on the table row */
  5222. var stripeClasses = oSettings.asStripeClasses;
  5223. var rowOne = $('tbody tr:eq(0)', this);
  5224. if ( $.inArray( true, $.map( stripeClasses, function(el, i) {
  5225. return rowOne.hasClass(el);
  5226. } ) ) !== -1 ) {
  5227. $('tbody tr', this).removeClass( stripeClasses.join(' ') );
  5228. oSettings.asDestroyStripes = stripeClasses.slice();
  5229. }
  5230. /*
  5231. * Columns
  5232. * See if we should load columns automatically or use defined ones
  5233. */
  5234. var anThs = [];
  5235. var aoColumnsInit;
  5236. var nThead = this.getElementsByTagName('thead');
  5237. if ( nThead.length !== 0 )
  5238. {
  5239. _fnDetectHeader( oSettings.aoHeader, nThead[0] );
  5240. anThs = _fnGetUniqueThs( oSettings );
  5241. }
  5242. /* If not given a column array, generate one with nulls */
  5243. if ( oInit.aoColumns === null )
  5244. {
  5245. aoColumnsInit = [];
  5246. for ( i=0, iLen=anThs.length ; i<iLen ; i++ )
  5247. {
  5248. aoColumnsInit.push( null );
  5249. }
  5250. }
  5251. else
  5252. {
  5253. aoColumnsInit = oInit.aoColumns;
  5254. }
  5255. /* Add the columns */
  5256. for ( i=0, iLen=aoColumnsInit.length ; i<iLen ; i++ )
  5257. {
  5258. _fnAddColumn( oSettings, anThs ? anThs[i] : null );
  5259. }
  5260. /* Apply the column definitions */
  5261. _fnApplyColumnDefs( oSettings, oInit.aoColumnDefs, aoColumnsInit, function (iCol, oDef) {
  5262. _fnColumnOptions( oSettings, iCol, oDef );
  5263. } );
  5264. /* HTML5 attribute detection - build an mData object automatically if the
  5265. * attributes are found
  5266. */
  5267. if ( rowOne.length ) {
  5268. var a = function ( cell, name ) {
  5269. return cell.getAttribute( 'data-'+name ) ? name : null;
  5270. };
  5271. $.each( _fnGetRowElements( oSettings, rowOne[0] ).cells, function (i, cell) {
  5272. var col = oSettings.aoColumns[i];
  5273. if ( col.mData === i ) {
  5274. var sort = a( cell, 'sort' ) || a( cell, 'order' );
  5275. var filter = a( cell, 'filter' ) || a( cell, 'search' );
  5276. if ( sort !== null || filter !== null ) {
  5277. col.mData = {
  5278. _: i+'.display',
  5279. sort: sort !== null ? i+'.@data-'+sort : undefined,
  5280. type: sort !== null ? i+'.@data-'+sort : undefined,
  5281. filter: filter !== null ? i+'.@data-'+filter : undefined
  5282. };
  5283. _fnColumnOptions( oSettings, i );
  5284. }
  5285. }
  5286. } );
  5287. }
  5288. /* Must be done after everything which can be overridden by the state saving! */
  5289. if ( oInit.bStateSave )
  5290. {
  5291. oSettings.oFeatures.bStateSave = true;
  5292. _fnLoadState( oSettings, oInit );
  5293. _fnCallbackReg( oSettings, 'aoDrawCallback', _fnSaveState, 'state_save' );
  5294. }
  5295. /*
  5296. * Sorting
  5297. * @todo For modularisation (1.11) this needs to do into a sort start up handler
  5298. */
  5299. // If aaSorting is not defined, then we use the first indicator in asSorting
  5300. // in case that has been altered, so the default sort reflects that option
  5301. if ( oInit.aaSorting === undefined )
  5302. {
  5303. for ( i=0, iLen=oSettings.aaSorting.length ; i<iLen ; i++ )
  5304. {
  5305. oSettings.aaSorting[i][1] = oSettings.aoColumns[ i ].asSorting[0];
  5306. }
  5307. }
  5308. /* Do a first pass on the sorting classes (allows any size changes to be taken into
  5309. * account, and also will apply sorting disabled classes if disabled
  5310. */
  5311. _fnSortingClasses( oSettings );
  5312. if ( oSettings.oFeatures.bSort )
  5313. {
  5314. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  5315. if ( oSettings.bSorted ) {
  5316. var aSort = _fnSortFlatten( oSettings );
  5317. var sortedColumns = {};
  5318. $.each( aSort, function (i, val) {
  5319. sortedColumns[ val.src ] = val.dir;
  5320. } );
  5321. _fnCallbackFire( oSettings, null, 'order', [oSettings, aSort, sortedColumns] );
  5322. _fnSortingClasses( oSettings );
  5323. _fnSortAria( oSettings );
  5324. }
  5325. } );
  5326. }
  5327. /*
  5328. * Final init
  5329. * Cache the header, body and footer as required, creating them if needed
  5330. */
  5331. /* Browser support detection */
  5332. _fnBrowserDetect( oSettings );
  5333. // Work around for Webkit bug 83867 - store the caption-side before removing from doc
  5334. var captions = $(this).children('caption').each( function () {
  5335. this._captionSide = $(this).css('caption-side');
  5336. } );
  5337. var thead = $(this).children('thead');
  5338. if ( thead.length === 0 )
  5339. {
  5340. thead = $('<thead/>').appendTo(this);
  5341. }
  5342. oSettings.nTHead = thead[0];
  5343. var tbody = $(this).children('tbody');
  5344. if ( tbody.length === 0 )
  5345. {
  5346. tbody = $('<tbody/>').appendTo(this);
  5347. }
  5348. oSettings.nTBody = tbody[0];
  5349. var tfoot = $(this).children('tfoot');
  5350. if ( tfoot.length === 0 && captions.length > 0 && (oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "") )
  5351. {
  5352. // If we are a scrolling table, and no footer has been given, then we need to create
  5353. // a tfoot element for the caption element to be appended to
  5354. tfoot = $('<tfoot/>').appendTo(this);
  5355. }
  5356. if ( tfoot.length === 0 || tfoot.children().length === 0 ) {
  5357. $(this).addClass( oSettings.oClasses.sNoFooter );
  5358. }
  5359. else if ( tfoot.length > 0 ) {
  5360. oSettings.nTFoot = tfoot[0];
  5361. _fnDetectHeader( oSettings.aoFooter, oSettings.nTFoot );
  5362. }
  5363. /* Check if there is data passing into the constructor */
  5364. if ( oInit.aaData )
  5365. {
  5366. for ( i=0 ; i<oInit.aaData.length ; i++ )
  5367. {
  5368. _fnAddData( oSettings, oInit.aaData[ i ] );
  5369. }
  5370. }
  5371. else if ( oSettings.bDeferLoading || _fnDataSource( oSettings ) == 'dom' )
  5372. {
  5373. /* Grab the data from the page - only do this when deferred loading or no Ajax
  5374. * source since there is no point in reading the DOM data if we are then going
  5375. * to replace it with Ajax data
  5376. */
  5377. _fnAddTr( oSettings, $(oSettings.nTBody).children('tr') );
  5378. }
  5379. /* Copy the data index array */
  5380. oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
  5381. /* Initialisation complete - table can be drawn */
  5382. oSettings.bInitialised = true;
  5383. /* Check if we need to initialise the table (it might not have been handed off to the
  5384. * language processor)
  5385. */
  5386. if ( bInitHandedOff === false )
  5387. {
  5388. _fnInitialise( oSettings );
  5389. }
  5390. } );
  5391. _that = null;
  5392. return this;
  5393. };
  5394. /**
  5395. * Computed structure of the DataTables API, defined by the options passed to
  5396. * `DataTable.Api.register()` when building the API.
  5397. *
  5398. * The structure is built in order to speed creation and extension of the Api
  5399. * objects since the extensions are effectively pre-parsed.
  5400. *
  5401. * The array is an array of objects with the following structure, where this
  5402. * base array represents the Api prototype base:
  5403. *
  5404. * [
  5405. * {
  5406. * name: 'data' -- string - Property name
  5407. * val: function () {}, -- function - Api method (or undefined if just an object
  5408. * methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  5409. * propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  5410. * },
  5411. * {
  5412. * name: 'row'
  5413. * val: {},
  5414. * methodExt: [ ... ],
  5415. * propExt: [
  5416. * {
  5417. * name: 'data'
  5418. * val: function () {},
  5419. * methodExt: [ ... ],
  5420. * propExt: [ ... ]
  5421. * },
  5422. * ...
  5423. * ]
  5424. * }
  5425. * ]
  5426. *
  5427. * @type {Array}
  5428. * @ignore
  5429. */
  5430. var __apiStruct = [];
  5431. /**
  5432. * `Array.prototype` reference.
  5433. *
  5434. * @type object
  5435. * @ignore
  5436. */
  5437. var __arrayProto = Array.prototype;
  5438. /**
  5439. * Abstraction for `context` parameter of the `Api` constructor to allow it to
  5440. * take several different forms for ease of use.
  5441. *
  5442. * Each of the input parameter types will be converted to a DataTables settings
  5443. * object where possible.
  5444. *
  5445. * @param {string|node|jQuery|object} mixed DataTable identifier. Can be one
  5446. * of:
  5447. *
  5448. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5449. * with be found and used.
  5450. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5451. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5452. * * `object` - DataTables settings object
  5453. * @return {array|null} Matching DataTables settings objects. `null` or
  5454. * `undefined` is returned if no matching DataTable is found.
  5455. * @ignore
  5456. */
  5457. var _toSettings = function ( mixed )
  5458. {
  5459. var idx, jq;
  5460. var settings = DataTable.settings;
  5461. var tables = $.map( settings, function (el, i) {
  5462. return el.nTable;
  5463. } );
  5464. if ( mixed.nTable && mixed.oApi ) {
  5465. // DataTables settings object
  5466. return [ mixed ];
  5467. }
  5468. else if ( mixed.nodeName && mixed.nodeName.toLowerCase() === 'table' ) {
  5469. // Table node
  5470. idx = $.inArray( mixed, tables );
  5471. return idx !== -1 ? [ settings[idx] ] : null;
  5472. }
  5473. else if ( typeof mixed === 'string' ) {
  5474. // jQuery selector
  5475. jq = $(mixed);
  5476. }
  5477. else if ( mixed instanceof $ ) {
  5478. // jQuery object (also DataTables instance)
  5479. jq = mixed;
  5480. }
  5481. if ( jq ) {
  5482. return jq.map( function(i) {
  5483. idx = $.inArray( this, tables );
  5484. return idx !== -1 ? settings[idx] : null;
  5485. } );
  5486. }
  5487. };
  5488. /**
  5489. * DataTables API class - used to control and interface with one or more
  5490. * DataTables enhanced tables.
  5491. *
  5492. * The API class is heavily based on jQuery, presenting a chainable interface
  5493. * that you can use to interact with tables. Each instance of the API class has
  5494. * a "context" - i.e. the tables that it will operate on. This could be a single
  5495. * table, all tables on a page or a sub-set thereof.
  5496. *
  5497. * Additionally the API is designed to allow you to easily work with the data in
  5498. * the tables, retrieving and manipulating it as required. This is done by
  5499. * presenting the API class as an array like interface. The contents of the
  5500. * array depend upon the actions requested by each method (for example
  5501. * `rows().nodes()` will return an array of nodes, while `rows().data()` will
  5502. * return an array of objects or arrays depending upon your table's
  5503. * configuration). The API object has a number of array like methods (`push`,
  5504. * `pop`, `reverse` etc) as well as additional helper methods (`each`, `pluck`,
  5505. * `unique` etc) to assist your working with the data held in a table.
  5506. *
  5507. * Most methods (those which return an Api instance) are chainable, which means
  5508. * the return from a method call also has all of the methods available that the
  5509. * top level object had. For example, these two calls are equivalent:
  5510. *
  5511. * // Not chained
  5512. * api.row.add( {...} );
  5513. * api.draw();
  5514. *
  5515. * // Chained
  5516. * api.row.add( {...} ).draw();
  5517. *
  5518. * @class DataTable.Api
  5519. * @param {array|object|string|jQuery} context DataTable identifier. This is
  5520. * used to define which DataTables enhanced tables this API will operate on.
  5521. * Can be one of:
  5522. *
  5523. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5524. * with be found and used.
  5525. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5526. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5527. * * `object` - DataTables settings object
  5528. * @param {array} [data] Data to initialise the Api instance with.
  5529. *
  5530. * @example
  5531. * // Direct initialisation during DataTables construction
  5532. * var api = $('#example').DataTable();
  5533. *
  5534. * @example
  5535. * // Initialisation using a DataTables jQuery object
  5536. * var api = $('#example').dataTable().api();
  5537. *
  5538. * @example
  5539. * // Initialisation as a constructor
  5540. * var api = new $.fn.DataTable.Api( 'table.dataTable' );
  5541. */
  5542. DataTable.Api = _Api = function ( context, data )
  5543. {
  5544. if ( ! this instanceof _Api ) {
  5545. throw 'DT API must be constructed as a new object';
  5546. // or should it do the 'new' for the caller?
  5547. // return new _Api.apply( this, arguments );
  5548. }
  5549. var settings = [];
  5550. var ctxSettings = function ( o ) {
  5551. var a = _toSettings( o );
  5552. if ( a ) {
  5553. settings.push.apply( settings, a );
  5554. }
  5555. };
  5556. if ( $.isArray( context ) ) {
  5557. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  5558. ctxSettings( context[i] );
  5559. }
  5560. }
  5561. else {
  5562. ctxSettings( context );
  5563. }
  5564. // Remove duplicates
  5565. this.context = _unique( settings );
  5566. // Initial data
  5567. if ( data ) {
  5568. this.push.apply( this, data );
  5569. }
  5570. // selector
  5571. this.selector = {
  5572. rows: null,
  5573. cols: null,
  5574. opts: null
  5575. };
  5576. _Api.extend( this, this, __apiStruct );
  5577. };
  5578. _Api.prototype = /** @lends DataTables.Api */{
  5579. /**
  5580. * Return a new Api instance, comprised of the data held in the current
  5581. * instance, join with the other array(s) and/or value(s).
  5582. *
  5583. * An alias for `Array.prototype.concat`.
  5584. *
  5585. * @type method
  5586. * @param {*} value1 Arrays and/or values to concatenate.
  5587. * @param {*} [...] Additional arrays and/or values to concatenate.
  5588. * @returns {DataTables.Api} New API instance, comprising of the combined
  5589. * array.
  5590. */
  5591. concat: __arrayProto.concat,
  5592. context: [], // array of table settings objects
  5593. each: function ( fn )
  5594. {
  5595. if ( __arrayProto.forEach ) {
  5596. // Where possible, use the built-in forEach
  5597. __arrayProto.forEach.call( this, fn, this );
  5598. }
  5599. else {
  5600. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  5601. for ( var i=0, ien=this.length ; i<ien; i++ ) {
  5602. // In strict mode the execution scope is the passed value
  5603. fn.call( this, this[i], i, this );
  5604. }
  5605. }
  5606. return this;
  5607. },
  5608. filter: function ( fn )
  5609. {
  5610. var a = [];
  5611. if ( __arrayProto.filter ) {
  5612. a = __arrayProto.filter.call( this, fn, this );
  5613. }
  5614. else {
  5615. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  5616. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  5617. if ( fn.call( this, this[i], i, this ) ) {
  5618. a.push( this[i] );
  5619. }
  5620. }
  5621. }
  5622. return new _Api( this.context, a );
  5623. },
  5624. flatten: function ()
  5625. {
  5626. var a = [];
  5627. return new _Api( this.context, a.concat.apply( a, this ) );
  5628. },
  5629. join: __arrayProto.join,
  5630. indexOf: __arrayProto.indexOf || function (obj, start)
  5631. {
  5632. for ( var i=(start || 0), ien=this.length ; i<ien ; i++ ) {
  5633. if ( this[i] === obj ) {
  5634. return i;
  5635. }
  5636. }
  5637. return -1;
  5638. },
  5639. // Internal only at the moment - relax?
  5640. iterator: function ( flatten, type, fn ) {
  5641. var
  5642. a = [], ret,
  5643. i, ien, j, jen,
  5644. context = this.context,
  5645. rows, items, item,
  5646. selector = this.selector;
  5647. // Argument shifting
  5648. if ( typeof flatten === 'string' ) {
  5649. fn = type;
  5650. type = flatten;
  5651. flatten = false;
  5652. }
  5653. for ( i=0, ien=context.length ; i<ien ; i++ ) {
  5654. if ( type === 'table' ) {
  5655. ret = fn( context[i], i );
  5656. if ( ret !== undefined ) {
  5657. a.push( ret );
  5658. }
  5659. }
  5660. else if ( type === 'columns' || type === 'rows' ) {
  5661. // this has same length as context - one entry for each table
  5662. ret = fn( context[i], this[i], i );
  5663. if ( ret !== undefined ) {
  5664. a.push( ret );
  5665. }
  5666. }
  5667. else if ( type === 'column' || type === 'column-rows' || type === 'row' || type === 'cell' ) {
  5668. // columns and rows share the same structure.
  5669. // 'this' is an array of column indexes for each context
  5670. items = this[i];
  5671. if ( type === 'column-rows' ) {
  5672. rows = _selector_row_indexes( context[i], selector.opts );
  5673. }
  5674. for ( j=0, jen=items.length ; j<jen ; j++ ) {
  5675. item = items[j];
  5676. if ( type === 'cell' ) {
  5677. ret = fn( context[i], item.row, item.column, i, j );
  5678. }
  5679. else {
  5680. ret = fn( context[i], item, i, j, rows );
  5681. }
  5682. if ( ret !== undefined ) {
  5683. a.push( ret );
  5684. }
  5685. }
  5686. }
  5687. }
  5688. if ( a.length ) {
  5689. var api = new _Api( context, flatten ? a.concat.apply( [], a ) : a );
  5690. var apiSelector = api.selector;
  5691. apiSelector.rows = selector.rows;
  5692. apiSelector.cols = selector.cols;
  5693. apiSelector.opts = selector.opts;
  5694. return api;
  5695. }
  5696. return this;
  5697. },
  5698. lastIndexOf: __arrayProto.lastIndexOf || function (obj, start)
  5699. {
  5700. // Bit cheeky...
  5701. return this.indexOf.apply( this.toArray.reverse(), arguments );
  5702. },
  5703. length: 0,
  5704. map: function ( fn )
  5705. {
  5706. var a = [];
  5707. if ( __arrayProto.map ) {
  5708. a = __arrayProto.map.call( this, fn, this );
  5709. }
  5710. else {
  5711. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  5712. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  5713. a.push( fn.call( this, this[i], i ) );
  5714. }
  5715. }
  5716. return new _Api( this.context, a );
  5717. },
  5718. pluck: function ( prop )
  5719. {
  5720. return this.map( function ( el ) {
  5721. return el[ prop ];
  5722. } );
  5723. },
  5724. pop: __arrayProto.pop,
  5725. push: __arrayProto.push,
  5726. // Does not return an API instance
  5727. reduce: __arrayProto.reduce || function ( fn, init )
  5728. {
  5729. var
  5730. value,
  5731. isSet = false;
  5732. if ( arguments.length > 1 ) {
  5733. value = init;
  5734. isSet = true;
  5735. }
  5736. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  5737. if ( ! this.hasOwnProperty(i) ) {
  5738. continue;
  5739. }
  5740. value = isSet ?
  5741. fn( value, this[i], i, this ) :
  5742. this[i];
  5743. isSet = true;
  5744. }
  5745. return value;
  5746. },
  5747. reduceRight: __arrayProto.reduceRight || function ( fn, init )
  5748. {
  5749. var
  5750. value,
  5751. isSet = false;
  5752. if ( arguments.length > 1 ) {
  5753. value = init;
  5754. isSet = true;
  5755. }
  5756. for ( var i=this.length-1 ; i>=0 ; i-- ) {
  5757. if ( ! this.hasOwnProperty(i) ) {
  5758. continue;
  5759. }
  5760. value = isSet ?
  5761. fn( value, this[i], i, this ) :
  5762. this[i];
  5763. isSet = true;
  5764. }
  5765. return value;
  5766. },
  5767. reverse: __arrayProto.reverse,
  5768. // Object with rows, columns and opts
  5769. selector: null,
  5770. shift: __arrayProto.shift,
  5771. sort: __arrayProto.sort, // ? name - order?
  5772. splice: __arrayProto.splice,
  5773. toArray: function ()
  5774. {
  5775. return __arrayProto.slice.call( this );
  5776. },
  5777. to$: function ()
  5778. {
  5779. return $( this );
  5780. },
  5781. toJQuery: function ()
  5782. {
  5783. return $( this );
  5784. },
  5785. unique: function ()
  5786. {
  5787. return new _Api( this.context, _unique(this) );
  5788. },
  5789. unshift: __arrayProto.unshift
  5790. };
  5791. _Api.extend = function ( scope, obj, ext )
  5792. {
  5793. // Only extend API instances and static properties of the API
  5794. if ( ! obj || ( ! (obj instanceof _Api) && ! obj.__dt_wrapper ) ) {
  5795. return;
  5796. }
  5797. var
  5798. i, ien,
  5799. j, jen,
  5800. struct, inner,
  5801. methodScoping = function ( fn, struc ) {
  5802. return function () {
  5803. var ret = fn.apply( scope, arguments );
  5804. // Method extension
  5805. _Api.extend( ret, ret, struc.methodExt );
  5806. return ret;
  5807. };
  5808. };
  5809. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  5810. struct = ext[i];
  5811. // Value
  5812. obj[ struct.name ] = typeof struct.val === 'function' ?
  5813. methodScoping( struct.val, struct ) :
  5814. struct.val;
  5815. obj[ struct.name ].__dt_wrapper = true;
  5816. // Property extension
  5817. _Api.extend( scope, obj[ struct.name ], struct.propExt );
  5818. }
  5819. };
  5820. // @todo - Is there need for an augment function?
  5821. // _Api.augment = function ( inst, name )
  5822. // {
  5823. // // Find src object in the structure from the name
  5824. // var parts = name.split('.');
  5825. // _Api.extend( inst, obj );
  5826. // };
  5827. // [
  5828. // {
  5829. // name: 'data' -- string - Property name
  5830. // val: function () {}, -- function - Api method (or undefined if just an object
  5831. // methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  5832. // propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  5833. // },
  5834. // {
  5835. // name: 'row'
  5836. // val: {},
  5837. // methodExt: [ ... ],
  5838. // propExt: [
  5839. // {
  5840. // name: 'data'
  5841. // val: function () {},
  5842. // methodExt: [ ... ],
  5843. // propExt: [ ... ]
  5844. // },
  5845. // ...
  5846. // ]
  5847. // }
  5848. // ]
  5849. _Api.register = _api_register = function ( name, val )
  5850. {
  5851. if ( $.isArray( name ) ) {
  5852. for ( var j=0, jen=name.length ; j<jen ; j++ ) {
  5853. _Api.register( name[j], val );
  5854. }
  5855. return;
  5856. }
  5857. var
  5858. i, ien,
  5859. heir = name.split('.'),
  5860. struct = __apiStruct,
  5861. key, method;
  5862. var find = function ( src, name ) {
  5863. for ( var i=0, ien=src.length ; i<ien ; i++ ) {
  5864. if ( src[i].name === name ) {
  5865. return src[i];
  5866. }
  5867. }
  5868. return null;
  5869. };
  5870. for ( i=0, ien=heir.length ; i<ien ; i++ ) {
  5871. method = heir[i].indexOf('()') !== -1;
  5872. key = method ?
  5873. heir[i].replace('()', '') :
  5874. heir[i];
  5875. var src = find( struct, key );
  5876. if ( ! src ) {
  5877. src = {
  5878. name: key,
  5879. val: {},
  5880. methodExt: [],
  5881. propExt: []
  5882. };
  5883. struct.push( src );
  5884. }
  5885. if ( i === ien-1 ) {
  5886. src.val = val;
  5887. }
  5888. else {
  5889. struct = method ?
  5890. src.methodExt :
  5891. src.propExt;
  5892. }
  5893. }
  5894. // Rebuild the API with the new construct
  5895. if ( _Api.ready ) {
  5896. DataTable.api.build();
  5897. }
  5898. };
  5899. _Api.registerPlural = _api_registerPlural = function ( pluralName, singularName, val ) {
  5900. _Api.register( pluralName, val );
  5901. _Api.register( singularName, function () {
  5902. var ret = val.apply( this, arguments );
  5903. if ( ret === this ) {
  5904. // Returned item is the API instance that was passed in, return it
  5905. return this;
  5906. }
  5907. else if ( ret instanceof _Api ) {
  5908. // New API instance returned, want the value from the first item
  5909. // in the returned array for the singular result.
  5910. return ret.length ?
  5911. $.isArray( ret[0] ) ?
  5912. new _Api( ret.context, ret[0] ) : // Array results are 'enhanced'
  5913. ret[0] :
  5914. undefined;
  5915. }
  5916. // Non-API return - just fire it back
  5917. return ret;
  5918. } );
  5919. };
  5920. /**
  5921. * Selector for HTML tables. Apply the given selector to the give array of
  5922. * DataTables settings objects.
  5923. *
  5924. * @param {string|integer} [selector] jQuery selector string or integer
  5925. * @param {array} Array of DataTables settings objects to be filtered
  5926. * @return {array}
  5927. * @ignore
  5928. */
  5929. var __table_selector = function ( selector, a )
  5930. {
  5931. // Integer is used to pick out a table by index
  5932. if ( typeof selector === 'number' ) {
  5933. return [ a[ selector ] ];
  5934. }
  5935. // Perform a jQuery selector on the table nodes
  5936. var nodes = $.map( a, function (el, i) {
  5937. return el.nTable;
  5938. } );
  5939. return $(nodes)
  5940. .filter( selector )
  5941. .map( function (i) {
  5942. // Need to translate back from the table node to the settings
  5943. var idx = $.inArray( this, nodes );
  5944. return a[ idx ];
  5945. } )
  5946. .toArray();
  5947. };
  5948. /**
  5949. * Context selector for the API's context (i.e. the tables the API instance
  5950. * refers to.
  5951. *
  5952. * @name DataTable.Api#tables
  5953. * @param {string|integer} [selector] Selector to pick which tables the iterator
  5954. * should operate on. If not given, all tables in the current context are
  5955. * used. This can be given as a jQuery selector (for example `':gt(0)'`) to
  5956. * select multiple tables or as an integer to select a single table.
  5957. * @returns {DataTable.Api} Returns a new API instance if a selector is given.
  5958. */
  5959. _api_register( 'tables()', function ( selector ) {
  5960. // A new instance is created if there was a selector specified
  5961. return selector ?
  5962. new _Api( __table_selector( selector, this.context ) ) :
  5963. this;
  5964. } );
  5965. _api_register( 'table()', function ( selector ) {
  5966. var tables = this.tables( selector );
  5967. var ctx = tables.context;
  5968. // Truncate to the first matched table
  5969. if ( ctx.length ) {
  5970. ctx.length = 1;
  5971. }
  5972. return tables;
  5973. } );
  5974. _api_registerPlural( 'tables().nodes()', 'table().node()' , function () {
  5975. return this.iterator( 'table', function ( ctx ) {
  5976. return ctx.nTable;
  5977. } );
  5978. } );
  5979. _api_registerPlural( 'tables().body()', 'table().body()' , function () {
  5980. return this.iterator( 'table', function ( ctx ) {
  5981. return ctx.nTBody;
  5982. } );
  5983. } );
  5984. _api_registerPlural( 'tables().header()', 'table().header()' , function () {
  5985. return this.iterator( 'table', function ( ctx ) {
  5986. return ctx.nTHead;
  5987. } );
  5988. } );
  5989. _api_registerPlural( 'tables().footer()', 'table().footer()' , function () {
  5990. return this.iterator( 'table', function ( ctx ) {
  5991. return ctx.nTFoot;
  5992. } );
  5993. } );
  5994. /**
  5995. * Redraw the tables in the current context.
  5996. *
  5997. * @param {boolean} [reset=true] Reset (default) or hold the current paging
  5998. * position. A full re-sort and re-filter is performed when this method is
  5999. * called, which is why the pagination reset is the default action.
  6000. * @returns {DataTables.Api} this
  6001. */
  6002. _api_register( 'draw()', function ( resetPaging ) {
  6003. return this.iterator( 'table', function ( settings ) {
  6004. _fnReDraw( settings, resetPaging===false );
  6005. } );
  6006. } );
  6007. /**
  6008. * Get the current page index.
  6009. *
  6010. * @return {integer} Current page index (zero based)
  6011. *//**
  6012. * Set the current page.
  6013. *
  6014. * Note that if you attempt to show a page which does not exist, DataTables will
  6015. * not throw an error, but rather reset the paging.
  6016. *
  6017. * @param {integer|string} action The paging action to take. This can be one of:
  6018. * * `integer` - The page index to jump to
  6019. * * `string` - An action to take:
  6020. * * `first` - Jump to first page.
  6021. * * `next` - Jump to the next page
  6022. * * `previous` - Jump to previous page
  6023. * * `last` - Jump to the last page.
  6024. * @returns {DataTables.Api} this
  6025. */
  6026. _api_register( 'page()', function ( action ) {
  6027. if ( action === undefined ) {
  6028. return this.page.info().page; // not an expensive call
  6029. }
  6030. // else, have an action to take on all tables
  6031. return this.iterator( 'table', function ( settings ) {
  6032. _fnPageChange( settings, action );
  6033. } );
  6034. } );
  6035. /**
  6036. * Paging information for the first table in the current context.
  6037. *
  6038. * If you require paging information for another table, use the `table()` method
  6039. * with a suitable selector.
  6040. *
  6041. * @return {object} Object with the following properties set:
  6042. * * `page` - Current page index (zero based - i.e. the first page is `0`)
  6043. * * `pages` - Total number of pages
  6044. * * `start` - Display index for the first record shown on the current page
  6045. * * `end` - Display index for the last record shown on the current page
  6046. * * `length` - Display length (number of records). Note that generally `start
  6047. * + length = end`, but this is not always true, for example if there are
  6048. * only 2 records to show on the final page, with a length of 10.
  6049. * * `recordsTotal` - Full data set length
  6050. * * `recordsDisplay` - Data set length once the current filtering criterion
  6051. * are applied.
  6052. */
  6053. _api_register( 'page.info()', function ( action ) {
  6054. if ( this.context.length === 0 ) {
  6055. return undefined;
  6056. }
  6057. var
  6058. settings = this.context[0],
  6059. start = settings._iDisplayStart,
  6060. len = settings._iDisplayLength,
  6061. visRecords = settings.fnRecordsDisplay(),
  6062. all = len === -1;
  6063. return {
  6064. "page": all ? 0 : Math.floor( start / len ),
  6065. "pages": all ? 1 : Math.ceil( visRecords / len ),
  6066. "start": start,
  6067. "end": settings.fnDisplayEnd(),
  6068. "length": len,
  6069. "recordsTotal": settings.fnRecordsTotal(),
  6070. "recordsDisplay": visRecords
  6071. };
  6072. } );
  6073. /**
  6074. * Get the current page length.
  6075. *
  6076. * @return {integer} Current page length. Note `-1` indicates that all records
  6077. * are to be shown.
  6078. *//**
  6079. * Set the current page length.
  6080. *
  6081. * @param {integer} Page length to set. Use `-1` to show all records.
  6082. * @returns {DataTables.Api} this
  6083. */
  6084. _api_register( 'page.len()', function ( len ) {
  6085. // Note that we can't call this function 'length()' because `length`
  6086. // is a Javascript property of functions which defines how many arguments
  6087. // the function expects.
  6088. if ( len === undefined ) {
  6089. return this.context.length !== 0 ?
  6090. this.context[0]._iDisplayLength :
  6091. undefined;
  6092. }
  6093. // else, set the page length
  6094. return this.iterator( 'table', function ( settings ) {
  6095. _fnLengthChange( settings, len );
  6096. } );
  6097. } );
  6098. var __reload = function ( settings, holdPosition, callback ) {
  6099. if ( _fnDataSource( settings ) == 'ssp' ) {
  6100. _fnReDraw( settings, holdPosition );
  6101. }
  6102. else {
  6103. // Trigger xhr
  6104. _fnBuildAjax( settings, [], function( json ) {
  6105. // xxx can this be reduced?
  6106. _fnClearTable( settings );
  6107. var data = _fnAjaxDataSrc( settings, json );
  6108. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6109. _fnAddData( settings, data[i] );
  6110. }
  6111. _fnReDraw( settings, holdPosition );
  6112. if ( callback ) {
  6113. callback( json );
  6114. }
  6115. } );
  6116. }
  6117. };
  6118. /**
  6119. * Get the JSON response from the last Ajax request that DataTables made to the
  6120. * server. Note that this returns the JSON from the first table in the current
  6121. * context.
  6122. *
  6123. * @return {object} JSON received from the server.
  6124. */
  6125. _api_register( 'ajax.json()', function () {
  6126. var ctx = this.context;
  6127. if ( ctx.length > 0 ) {
  6128. return ctx[0].json;
  6129. }
  6130. // else return undefined;
  6131. } );
  6132. /**
  6133. * Reload tables from the Ajax data source. Note that this function will
  6134. * automatically re-draw the table when the remote data has been loaded.
  6135. *
  6136. * @param {boolean} [reset=true] Reset (default) or hold the current paging
  6137. * position. A full re-sort and re-filter is performed when this method is
  6138. * called, which is why the pagination reset is the default action.
  6139. * @returns {DataTables.Api} this
  6140. */
  6141. _api_register( 'ajax.reload()', function ( callback, resetPaging ) {
  6142. return this.iterator( 'table', function (settings) {
  6143. __reload( settings, resetPaging===false, callback );
  6144. } );
  6145. } );
  6146. /**
  6147. * Get the current Ajax URL. Note that this returns the URL from the first
  6148. * table in the current context.
  6149. *
  6150. * @return {string} Current Ajax source URL
  6151. *//**
  6152. * Set the Ajax URL. Note that this will set the URL for all tables in the
  6153. * current context.
  6154. *
  6155. * @param {string} url URL to set.
  6156. * @returns {DataTables.Api} this
  6157. */
  6158. _api_register( 'ajax.url()', function ( url ) {
  6159. var ctx = this.context;
  6160. if ( url === undefined ) {
  6161. // get
  6162. if ( ctx.length === 0 ) {
  6163. return undefined;
  6164. }
  6165. ctx = ctx[0];
  6166. return ctx.ajax ?
  6167. $.isPlainObject( ctx.ajax ) ?
  6168. ctx.ajax.url :
  6169. ctx.ajax :
  6170. ctx.sAjaxSource;
  6171. }
  6172. // set
  6173. return this.iterator( 'table', function ( settings ) {
  6174. if ( $.isPlainObject( settings.ajax ) ) {
  6175. settings.ajax.url = url;
  6176. }
  6177. else {
  6178. settings.ajax = url;
  6179. }
  6180. // No need to consider sAjaxSource here since DataTables gives priority
  6181. // to `ajax` over `sAjaxSource`. So setting `ajax` here, renders any
  6182. // value of `sAjaxSource` redundant.
  6183. } );
  6184. } );
  6185. /**
  6186. * Load data from the newly set Ajax URL. Note that this method is only
  6187. * available when `ajax.url()` is used to set a URL. Additionally, this method
  6188. * has the same effect as calling `ajax.reload()` but is provided for
  6189. * convenience when setting a new URL. Like `ajax.reload()` it will
  6190. * automatically redraw the table once the remote data has been loaded.
  6191. *
  6192. * @returns {DataTables.Api} this
  6193. */
  6194. _api_register( 'ajax.url().load()', function ( callback, resetPaging ) {
  6195. // Same as a reload, but makes sense to present it for easy access after a
  6196. // url change
  6197. return this.iterator( 'table', function ( ctx ) {
  6198. __reload( ctx, resetPaging===false, callback );
  6199. } );
  6200. } );
  6201. var _selector_run = function ( selector, select )
  6202. {
  6203. var
  6204. out = [], res,
  6205. a, i, ien, j, jen;
  6206. if ( ! $.isArray( selector ) ) {
  6207. selector = [ selector ];
  6208. }
  6209. for ( i=0, ien=selector.length ; i<ien ; i++ ) {
  6210. a = selector[i] && selector[i].split ?
  6211. selector[i].split(',') :
  6212. [ selector[i] ];
  6213. for ( j=0, jen=a.length ; j<jen ; j++ ) {
  6214. res = select( typeof a[j] === 'string' ? $.trim(a[j]) : a[j] );
  6215. if ( res && res.length ) {
  6216. out.push.apply( out, res );
  6217. }
  6218. }
  6219. }
  6220. return out;
  6221. };
  6222. var _selector_opts = function ( opts )
  6223. {
  6224. if ( ! opts ) {
  6225. opts = {};
  6226. }
  6227. // Backwards compatibility for 1.9- which used the terminology filter rather
  6228. // than search
  6229. if ( opts.filter && ! opts.search ) {
  6230. opts.search = opts.filter;
  6231. }
  6232. return {
  6233. search: opts.search || 'none',
  6234. order: opts.order || 'current',
  6235. page: opts.page || 'all'
  6236. };
  6237. };
  6238. var _selector_first = function ( inst )
  6239. {
  6240. // Reduce the API instance to the first item found
  6241. for ( var i=0, ien=inst.length ; i<ien ; i++ ) {
  6242. if ( inst[i].length > 0 ) {
  6243. // Assign the first element to the first item in the instance
  6244. // and truncate the instance and context
  6245. inst[0] = inst[i];
  6246. inst.length = 1;
  6247. inst.context = [ inst.context[i] ];
  6248. return inst;
  6249. }
  6250. }
  6251. // Not found - return an empty instance
  6252. inst.length = 0;
  6253. return inst;
  6254. };
  6255. var _selector_row_indexes = function ( settings, opts )
  6256. {
  6257. var
  6258. i, ien, tmp, a=[],
  6259. displayFiltered = settings.aiDisplay,
  6260. displayMaster = settings.aiDisplayMaster;
  6261. var
  6262. search = opts.search, // none, applied, removed
  6263. order = opts.order, // applied, current, index (original - compatibility with 1.9)
  6264. page = opts.page; // all, current
  6265. // Current page implies that order=current and fitler=applied, since it is
  6266. // fairly senseless otherwise, regardless of what order and search actually
  6267. // are
  6268. if ( page == 'current' )
  6269. {
  6270. for ( i=settings._iDisplayStart, ien=settings.fnDisplayEnd() ; i<ien ; i++ ) {
  6271. a.push( displayFiltered[i] );
  6272. }
  6273. }
  6274. else if ( order == 'current' || order == 'applied' ) {
  6275. a = search == 'none' ?
  6276. displayMaster.slice() : // no search
  6277. search == 'applied' ?
  6278. displayFiltered.slice() : // applied search
  6279. $.map( displayMaster, function (el, i) { // removed search
  6280. return $.inArray( el, displayFiltered ) === -1 ? el : null;
  6281. } );
  6282. }
  6283. else if ( order == 'index' || order == 'original' ) {
  6284. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  6285. if ( search == 'none' ) {
  6286. a.push( i );
  6287. }
  6288. else { // applied | removed
  6289. tmp = $.inArray( i, displayFiltered );
  6290. if ((tmp === -1 && search == 'removed') ||
  6291. (tmp === 1 && search == 'applied') )
  6292. {
  6293. a.push( i );
  6294. }
  6295. }
  6296. }
  6297. }
  6298. return a;
  6299. };
  6300. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6301. * Rows
  6302. *
  6303. * {} - no selector - use all available rows
  6304. * {integer} - row aoData index
  6305. * {node} - TR node
  6306. * {string} - jQuery selector to apply to the TR elements
  6307. * {array} - jQuery array of nodes, or simply an array of TR nodes
  6308. *
  6309. */
  6310. var __row_selector = function ( settings, selector, opts )
  6311. {
  6312. return _selector_run( selector, function ( sel ) {
  6313. var selInt = _intVal( sel );
  6314. // Short cut - selector is a number and no options provided (default is
  6315. // all records, so no need to check if the index is in there, since it
  6316. // must be - dev error if the index doesn't exist).
  6317. if ( selInt !== null && ! opts ) {
  6318. return [ selInt ];
  6319. }
  6320. var rows = _selector_row_indexes( settings, opts );
  6321. if ( selInt !== null && $.inArray( selInt, rows ) !== -1 ) {
  6322. // Selector - integer
  6323. return [ selInt ];
  6324. }
  6325. else if ( ! sel ) {
  6326. // Selector - none
  6327. return rows;
  6328. }
  6329. // Get nodes in the order from the `rows` array (can't use `pluck`) @todo - use pluck_order
  6330. var nodes = [];
  6331. for ( var i=0, ien=rows.length ; i<ien ; i++ ) {
  6332. nodes.push( settings.aoData[ rows[i] ].nTr );
  6333. }
  6334. if ( sel.nodeName ) {
  6335. // Selector - node
  6336. if ( $.inArray( sel, nodes ) !== -1 ) {
  6337. return [ sel._DT_RowIndex ];// sel is a TR node that is in the table
  6338. // and DataTables adds a prop for fast lookup
  6339. }
  6340. }
  6341. // Selector - jQuery selector string, array of nodes or jQuery object/
  6342. // As jQuery's .filter() allows jQuery objects to be passed in filter,
  6343. // it also allows arrays, so this will cope with all three options
  6344. return $(nodes)
  6345. .filter( sel )
  6346. .map( function () {
  6347. return this._DT_RowIndex;
  6348. } )
  6349. .toArray();
  6350. } );
  6351. };
  6352. /**
  6353. *
  6354. */
  6355. _api_register( 'rows()', function ( selector, opts ) {
  6356. // argument shifting
  6357. if ( selector === undefined ) {
  6358. selector = '';
  6359. }
  6360. else if ( $.isPlainObject( selector ) ) {
  6361. opts = selector;
  6362. selector = '';
  6363. }
  6364. opts = _selector_opts( opts );
  6365. var inst = this.iterator( 'table', function ( settings ) {
  6366. return __row_selector( settings, selector, opts );
  6367. } );
  6368. // Want argument shifting here and in __row_selector?
  6369. inst.selector.rows = selector;
  6370. inst.selector.opts = opts;
  6371. return inst;
  6372. } );
  6373. _api_registerPlural( 'rows().nodes()', 'row().node()' , function () {
  6374. return this.iterator( 'row', function ( settings, row ) {
  6375. // use pluck order on an array rather - rows gives an array, row gives it individually
  6376. return settings.aoData[ row ].nTr || undefined;
  6377. } );
  6378. } );
  6379. _api_register( 'rows().data()', function () {
  6380. return this.iterator( true, 'rows', function ( settings, rows ) {
  6381. return _pluck_order( settings.aoData, rows, '_aData' );
  6382. } );
  6383. } );
  6384. _api_registerPlural( 'rows().cache()', 'row().cache()', function ( type ) {
  6385. return this.iterator( 'row', function ( settings, row ) {
  6386. var r = settings.aoData[ row ];
  6387. return type === 'search' ? r._aFilterData : r._aSortData;
  6388. } );
  6389. } );
  6390. _api_registerPlural( 'rows().invalidate()', 'row().invalidate()', function ( src ) {
  6391. return this.iterator( 'row', function ( settings, row ) {
  6392. _fnInvalidateRow( settings, row, src );
  6393. } );
  6394. } );
  6395. _api_registerPlural( 'rows().indexes()', 'row().index()', function () {
  6396. return this.iterator( 'row', function ( settings, row ) {
  6397. return row;
  6398. } );
  6399. } );
  6400. _api_registerPlural( 'rows().remove()', 'row().remove()', function () {
  6401. var that = this;
  6402. return this.iterator( 'row', function ( settings, row, thatIdx ) {
  6403. var data = settings.aoData;
  6404. data.splice( row, 1 );
  6405. // Update the _DT_RowIndex parameter on all rows in the table
  6406. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6407. if ( data[i].nTr !== null ) {
  6408. data[i].nTr._DT_RowIndex = i;
  6409. }
  6410. }
  6411. // Remove the target row from the search array
  6412. var displayIndex = $.inArray( row, settings.aiDisplay );
  6413. // Delete from the display arrays
  6414. _fnDeleteIndex( settings.aiDisplayMaster, row );
  6415. _fnDeleteIndex( settings.aiDisplay, row );
  6416. _fnDeleteIndex( that[ thatIdx ], row, false ); // maintain local indexes
  6417. // Check for an 'overflow' they case for displaying the table
  6418. _fnLengthOverflow( settings );
  6419. } );
  6420. } );
  6421. _api_register( 'rows.add()', function ( rows ) {
  6422. var newRows = this.iterator( 'table', function ( settings ) {
  6423. var row, i, ien;
  6424. var out = [];
  6425. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  6426. row = rows[i];
  6427. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  6428. out.push( _fnAddTr( settings, row )[0] );
  6429. }
  6430. else {
  6431. out.push( _fnAddData( settings, row ) );
  6432. }
  6433. }
  6434. return out;
  6435. } );
  6436. // Return an Api.rows() extended instance, so rows().nodes() etc can be used
  6437. var modRows = this.rows( -1 );
  6438. modRows.pop();
  6439. modRows.push.apply( modRows, newRows );
  6440. return modRows;
  6441. } );
  6442. /**
  6443. *
  6444. */
  6445. _api_register( 'row()', function ( selector, opts ) {
  6446. return _selector_first( this.rows( selector, opts ) );
  6447. } );
  6448. _api_register( 'row().data()', function ( data ) {
  6449. var ctx = this.context;
  6450. if ( data === undefined ) {
  6451. // Get
  6452. return ctx.length && this.length ?
  6453. ctx[0].aoData[ this[0] ]._aData :
  6454. undefined;
  6455. }
  6456. // Set
  6457. ctx[0].aoData[ this[0] ]._aData = data;
  6458. // Automatically invalidate
  6459. _fnInvalidateRow( ctx[0], this[0], 'data' );
  6460. return this;
  6461. } );
  6462. _api_register( 'row.add()', function ( row ) {
  6463. // Allow a jQuery object to be passed in - only a single row is added from
  6464. // it though - the first element in the set
  6465. if ( row instanceof $ && row.length ) {
  6466. row = row[0];
  6467. }
  6468. var rows = this.iterator( 'table', function ( settings ) {
  6469. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  6470. return _fnAddTr( settings, row )[0];
  6471. }
  6472. return _fnAddData( settings, row );
  6473. } );
  6474. // Return an Api.rows() extended instance, with the newly added row selected
  6475. return this.row( rows[0] );
  6476. } );
  6477. var __details_add = function ( ctx, row, data, klass )
  6478. {
  6479. // Convert to array of TR elements
  6480. var rows = [];
  6481. var addRow = function ( r, k ) {
  6482. if ( ! r.nodeName || r.nodeName.toUpperCase() !== 'tr' ) {
  6483. r = $('<tr><td></td></tr>').find('td').html( r ).parent();
  6484. }
  6485. $('td', r).addClass( k )[0].colSpan = _fnVisbleColumns( ctx );
  6486. rows.push( r[0] );
  6487. };
  6488. if ( $.isArray( data ) || data instanceof $ ) {
  6489. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6490. addRow( data[i], klass );
  6491. }
  6492. }
  6493. else {
  6494. addRow( data, klass );
  6495. }
  6496. if ( row._details ) {
  6497. row._details.remove();
  6498. }
  6499. row._details = $(rows);
  6500. // If the children were already shown, that state should be retained
  6501. if ( row._detailsShow ) {
  6502. row._details.insertAfter( row.nTr );
  6503. }
  6504. };
  6505. var __details_display = function ( show ) {
  6506. var ctx = this.context;
  6507. if ( ctx.length && this.length ) {
  6508. var row = ctx[0].aoData[ this[0] ];
  6509. if ( row._details ) {
  6510. row._detailsShow = show;
  6511. if ( show ) {
  6512. row._details.insertAfter( row.nTr );
  6513. }
  6514. else {
  6515. row._details.remove();
  6516. }
  6517. __details_events( ctx[0] );
  6518. }
  6519. }
  6520. return this;
  6521. };
  6522. var __details_events = function ( settings )
  6523. {
  6524. var table = $(settings.nTable);
  6525. table.off('draw.DT_details');
  6526. table.off('column-visibility.DT_details');
  6527. if ( _pluck( settings.aoData, '_details' ).length > 0 ) {
  6528. // On each draw, insert the required elements into the document
  6529. table.on('draw.DT_details', function () {
  6530. table.find('tbody tr').each( function () {
  6531. // Look up the row index for each row and append open row
  6532. var rowIdx = _fnNodeToDataIndex( settings, this );
  6533. var row = settings.aoData[ rowIdx ];
  6534. if ( row._detailsShow ) {
  6535. row._details.insertAfter( this );
  6536. }
  6537. } );
  6538. } );
  6539. // Column visibility change - update the colspan
  6540. table.on( 'column-visibility.DT_details', function ( e, settings, idx, vis ) {
  6541. // Update the colspan for the details rows (note, only if it already has
  6542. // a colspan)
  6543. var row, visible = _fnVisbleColumns( settings );
  6544. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  6545. row = settings.aoData[i];
  6546. if ( row._details ) {
  6547. row._details.children('td[colspan]').attr('colspan', visible );
  6548. }
  6549. }
  6550. } );
  6551. }
  6552. };
  6553. // data can be:
  6554. // tr
  6555. // string
  6556. // jQuery or array of any of the above
  6557. _api_register( 'row().child()', function ( data, klass ) {
  6558. var ctx = this.context;
  6559. if ( data === undefined ) {
  6560. // get
  6561. return ctx.length && this.length ?
  6562. ctx[0].aoData[ this[0] ]._details :
  6563. undefined;
  6564. }
  6565. else if ( ctx.length && this.length ) {
  6566. // set
  6567. __details_add( ctx[0], ctx[0].aoData[ this[0] ], data, klass );
  6568. }
  6569. return this;
  6570. } );
  6571. _api_register( [
  6572. 'row().child.show()',
  6573. 'row().child().show()'
  6574. ], function () {
  6575. __details_display.call( this, true );
  6576. } );
  6577. _api_register( [
  6578. 'row().child.hide()',
  6579. 'row().child().hide()'
  6580. ], function () {
  6581. __details_display.call( this, false );
  6582. } );
  6583. _api_register( 'row().child.isShown()', function () {
  6584. var ctx = this.context;
  6585. if ( ctx.length && this.length ) {
  6586. // _detailsShown as false or undefined will fall through to return false
  6587. return ctx[0].aoData[ this[0] ]._detailsShow || false;
  6588. }
  6589. return false;
  6590. } );
  6591. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6592. * Columns
  6593. *
  6594. * {integer} - column index (>=0 count from left, <0 count from right)
  6595. * "{integer}:visIdx" - visible column index (i.e. translate to column index) (>=0 count from left, <0 count from right)
  6596. * "{integer}:visible" - alias for {integer}:visIdx (>=0 count from left, <0 count from right)
  6597. * "{string}:name" - column name
  6598. * "{string}" - jQuery selector on column header nodes
  6599. *
  6600. */
  6601. // can be an array of these items, comma separated list, or an array of comma
  6602. // separated lists
  6603. var __re_column_selector = /^(.*):(name|visIdx|visible)$/;
  6604. var __column_selector = function ( settings, selector, opts )
  6605. {
  6606. var
  6607. columns = settings.aoColumns,
  6608. names = _pluck( columns, 'sName' ),
  6609. nodes = _pluck( columns, 'nTh' );
  6610. return _selector_run( selector, function ( s ) {
  6611. var selInt = _intVal( s );
  6612. if ( s === '' ) {
  6613. // All columns
  6614. return _range( settings.aoColumns.length );
  6615. }
  6616. else if ( selInt !== null ) {
  6617. // Integer selector
  6618. return [ selInt >= 0 ?
  6619. selInt : // Count from left
  6620. columns.length + selInt // Count from right (+ because its a negative value)
  6621. ];
  6622. }
  6623. else {
  6624. var match = s.match( __re_column_selector );
  6625. if ( match ) {
  6626. switch( match[2] ) {
  6627. case 'visIdx':
  6628. case 'visible':
  6629. var idx = parseInt( match[1], 10 );
  6630. // Visible index given, convert to column index
  6631. if ( idx < 0 ) {
  6632. // Counting from the right
  6633. var visColumns = $.map( columns, function (col,i) {
  6634. return col.bVisible ? i : null;
  6635. } );
  6636. return [ visColumns[ visColumns.length + idx ] ];
  6637. }
  6638. // Counting from the left
  6639. return [ _fnVisibleToColumnIndex( settings, idx ) ];
  6640. case 'name':
  6641. // match by name. `names` is column index complete and in order
  6642. return $.map( names, function (name, i) {
  6643. return name === match[1] ? i : null;
  6644. } );
  6645. }
  6646. }
  6647. else {
  6648. // jQuery selector on the TH elements for the columns
  6649. return $( nodes )
  6650. .filter( s )
  6651. .map( function () {
  6652. return $.inArray( this, nodes ); // `nodes` is column index complete and in order
  6653. } )
  6654. .toArray();
  6655. }
  6656. }
  6657. } );
  6658. };
  6659. var __setColumnVis = function ( settings, column, vis ) {
  6660. var
  6661. cols = settings.aoColumns,
  6662. col = cols[ column ],
  6663. data = settings.aoData,
  6664. row, cells, i, ien, tr;
  6665. // Get
  6666. if ( vis === undefined ) {
  6667. return col.bVisible;
  6668. }
  6669. // Set
  6670. // No change
  6671. if ( col.bVisible === vis ) {
  6672. return;
  6673. }
  6674. if ( vis ) {
  6675. // Insert column
  6676. // Need to decide if we should use appendChild or insertBefore
  6677. var insertBefore = $.inArray( true, _pluck(cols, 'bVisible'), column+1 );
  6678. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  6679. tr = data[i].nTr;
  6680. cells = data[i].anCells;
  6681. if ( tr ) {
  6682. // insertBefore can act like appendChild if 2nd arg is null
  6683. tr.insertBefore( cells[ column ], cells[ insertBefore ] || null );
  6684. }
  6685. }
  6686. }
  6687. else {
  6688. // Remove column
  6689. $( _pluck( settings.aoData, 'anCells', column ) ).remove();
  6690. col.bVisible = false;
  6691. _fnDrawHead( settings, settings.aoHeader );
  6692. _fnDrawHead( settings, settings.aoFooter );
  6693. _fnSaveState( settings );
  6694. }
  6695. // Common actions
  6696. col.bVisible = vis;
  6697. _fnDrawHead( settings, settings.aoHeader );
  6698. _fnDrawHead( settings, settings.aoFooter );
  6699. // Automatically adjust column sizing
  6700. _fnAdjustColumnSizing( settings );
  6701. // Realign columns for scrolling
  6702. if ( settings.oScroll.sX || settings.oScroll.sY ) {
  6703. _fnScrollDraw( settings );
  6704. }
  6705. _fnCallbackFire( settings, null, 'column-visibility', [settings, column, vis] );
  6706. _fnSaveState( settings );
  6707. };
  6708. /**
  6709. *
  6710. */
  6711. _api_register( 'columns()', function ( selector, opts ) {
  6712. // argument shifting
  6713. if ( selector === undefined ) {
  6714. selector = '';
  6715. }
  6716. else if ( $.isPlainObject( selector ) ) {
  6717. opts = selector;
  6718. selector = '';
  6719. }
  6720. opts = _selector_opts( opts );
  6721. var inst = this.iterator( 'table', function ( settings ) {
  6722. return __column_selector( settings, selector, opts );
  6723. } );
  6724. // Want argument shifting here and in _row_selector?
  6725. inst.selector.cols = selector;
  6726. inst.selector.opts = opts;
  6727. return inst;
  6728. } );
  6729. /**
  6730. *
  6731. */
  6732. _api_registerPlural( 'columns().header()', 'column().header()', function ( selector, opts ) {
  6733. return this.iterator( 'column', function ( settings, column ) {
  6734. return settings.aoColumns[column].nTh;
  6735. } );
  6736. } );
  6737. /**
  6738. *
  6739. */
  6740. _api_registerPlural( 'columns().footer()', 'column().footer()', function ( selector, opts ) {
  6741. return this.iterator( 'column', function ( settings, column ) {
  6742. return settings.aoColumns[column].nTf;
  6743. } );
  6744. } );
  6745. /**
  6746. *
  6747. */
  6748. _api_registerPlural( 'columns().data()', 'column().data()', function () {
  6749. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  6750. var a = [];
  6751. for ( var row=0, ien=rows.length ; row<ien ; row++ ) {
  6752. a.push( _fnGetCellData( settings, rows[row], column, '' ) );
  6753. }
  6754. return a;
  6755. } );
  6756. } );
  6757. _api_registerPlural( 'columns().cache()', 'column().cache()', function ( type ) {
  6758. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  6759. return _pluck_order( settings.aoData, rows,
  6760. type === 'search' ? '_aFilterData' : '_aSortData', column
  6761. );
  6762. } );
  6763. } );
  6764. _api_registerPlural( 'columns().nodes()', 'column().nodes()', function () {
  6765. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  6766. return _pluck_order( settings.aoData, rows, 'anCells', column ) ;
  6767. } );
  6768. } );
  6769. _api_registerPlural( 'columns().visible()', 'column().visible()', function ( vis ) {
  6770. return this.iterator( 'column', function ( settings, column ) {
  6771. return __setColumnVis( settings, column, vis );
  6772. } );
  6773. } );
  6774. _api_registerPlural( 'columns().indexes()', 'column().index()', function ( type ) {
  6775. return this.iterator( 'column', function ( settings, column ) {
  6776. return type === 'visible' ?
  6777. _fnColumnIndexToVisible( settings, column ) :
  6778. column;
  6779. } );
  6780. } );
  6781. // _api_register( 'columns().show()', function () {
  6782. // var selector = this.selector;
  6783. // return this.columns( selector.cols, selector.opts ).visible( true );
  6784. // } );
  6785. // _api_register( 'columns().hide()', function () {
  6786. // var selector = this.selector;
  6787. // return this.columns( selector.cols, selector.opts ).visible( false );
  6788. // } );
  6789. _api_register( 'columns.adjust()', function () {
  6790. return this.iterator( 'table', function ( settings ) {
  6791. _fnAdjustColumnSizing( settings );
  6792. } );
  6793. } );
  6794. // Convert from one column index type, to another type
  6795. _api_register( 'column.index()', function ( type, idx ) {
  6796. if ( this.context.length !== 0 ) {
  6797. var ctx = this.context[0];
  6798. if ( type === 'fromVisible' || type === 'toData' ) {
  6799. return _fnColumnIndexToVisible( ctx, idx );
  6800. }
  6801. else if ( type === 'fromData' || type === 'toVisible' ) {
  6802. return _fnVisibleToColumnIndex( ctx, idx );
  6803. }
  6804. }
  6805. } );
  6806. _api_register( 'column()', function ( selector, opts ) {
  6807. return _selector_first( this.columns( selector, opts ) );
  6808. } );
  6809. var __cell_selector = function ( settings, selector, opts )
  6810. {
  6811. var data = settings.aoData;
  6812. var rows = _selector_row_indexes( settings, opts );
  6813. var cells = _pluck_order( data, rows, 'anCells' );
  6814. var allCells = $( [].concat.apply([], cells) );
  6815. var row;
  6816. var columns = settings.aoColumns.length;
  6817. var a, i, ien, j;
  6818. return _selector_run( selector, function ( s ) {
  6819. if ( ! s ) {
  6820. // All cells
  6821. a = [];
  6822. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  6823. row = rows[i];
  6824. for ( j=0 ; j<columns ; j++ ) {
  6825. a.push( {
  6826. row: row,
  6827. column: j
  6828. } );
  6829. }
  6830. }
  6831. return a;
  6832. }
  6833. // jQuery filtered cells
  6834. return allCells.filter( s ).map( function (i, el) {
  6835. row = el.parentNode._DT_RowIndex;
  6836. return {
  6837. row: row,
  6838. column: $.inArray( el, data[ row ].anCells )
  6839. };
  6840. } );
  6841. } );
  6842. };
  6843. _api_register( 'cells()', function ( rowSelector, columnSelector, opts ) {
  6844. // Argument shifting
  6845. if ( $.isPlainObject( rowSelector ) ) {
  6846. opts = rowSelector;
  6847. rowSelector = null;
  6848. }
  6849. if ( $.isPlainObject( columnSelector ) ) {
  6850. opts = columnSelector;
  6851. columnSelector = null;
  6852. }
  6853. // Cell selector
  6854. if ( columnSelector === null || columnSelector === undefined ) {
  6855. return this.iterator( 'table', function ( settings ) {
  6856. return __cell_selector( settings, rowSelector, _selector_opts( opts ) );
  6857. } );
  6858. }
  6859. // Row + column selector
  6860. var columns = this.columns( columnSelector, opts );
  6861. var rows = this.rows( rowSelector, opts );
  6862. var a, i, ien, j, jen;
  6863. var cells = this.iterator( 'table', function ( settings, idx ) {
  6864. a = [];
  6865. for ( i=0, ien=rows[idx].length ; i<ien ; i++ ) {
  6866. for ( j=0, jen=columns[idx].length ; j<jen ; j++ ) {
  6867. a.push( {
  6868. row: rows[idx][i],
  6869. column: columns[idx][j]
  6870. } );
  6871. }
  6872. }
  6873. return a;
  6874. } );
  6875. $.extend( cells.selector, {
  6876. cols: columnSelector,
  6877. rows: rowSelector,
  6878. opts: opts
  6879. } );
  6880. return cells;
  6881. } );
  6882. _api_registerPlural( 'cells().nodes()', 'cell().node()', function () {
  6883. return this.iterator( 'cell', function ( settings, row, column ) {
  6884. return settings.aoData[ row ].anCells[ column ];
  6885. } );
  6886. } );
  6887. _api_register( 'cells().data()', function () {
  6888. return this.iterator( 'cell', function ( settings, row, column ) {
  6889. return _fnGetCellData( settings, row, column );
  6890. } );
  6891. } );
  6892. _api_registerPlural( 'cells().cache()', 'cell().cache()', function ( type ) {
  6893. type = type === 'search' ? '_aFilterData' : '_aSortData';
  6894. return this.iterator( 'cell', function ( settings, row, column ) {
  6895. return settings.aoData[ row ][ type ][ column ];
  6896. } );
  6897. } );
  6898. _api_registerPlural( 'cells().indexes()', 'cell().index()', function () {
  6899. return this.iterator( 'cell', function ( settings, row, column ) {
  6900. return {
  6901. row: row,
  6902. column: column,
  6903. columnVisible: _fnColumnIndexToVisible( settings, column )
  6904. };
  6905. } );
  6906. } );
  6907. _api_register( [
  6908. 'cells().invalidate()',
  6909. 'cell().invalidate()'
  6910. ], function ( src ) {
  6911. var selector = this.selector;
  6912. // Use the rows method of the instance to perform the invalidation, rather
  6913. // than doing it here. This avoids needing to handle duplicate rows from
  6914. // the cells.
  6915. this.rows( selector.rows, selector.opts ).invalidate( src );
  6916. return this;
  6917. } );
  6918. _api_register( 'cell()', function ( rowSelector, columnSelector, opts ) {
  6919. return _selector_first( this.cells( rowSelector, columnSelector, opts ) );
  6920. } );
  6921. _api_register( 'cell().data()', function ( data ) {
  6922. var ctx = this.context;
  6923. var cell = this[0];
  6924. if ( data === undefined ) {
  6925. // Get
  6926. return ctx.length && cell.length ?
  6927. _fnGetCellData( ctx[0], cell[0].row, cell[0].column ) :
  6928. undefined;
  6929. }
  6930. // Set
  6931. _fnSetCellData( ctx[0], cell[0].row, cell[0].column, data );
  6932. _fnInvalidateRow( ctx[0], cell[0].row, 'data', cell[0].column );
  6933. return this;
  6934. } );
  6935. /**
  6936. * Get current ordering (sorting) that has been applied to the table.
  6937. *
  6938. * @returns {array} 2D array containing the sorting information for the first
  6939. * table in the current context. Each element in the parent array represents
  6940. * a column being sorted upon (i.e. multi-sorting with two columns would have
  6941. * 2 inner arrays). The inner arrays may have 2 or 3 elements. The first is
  6942. * the column index that the sorting condition applies to, the second is the
  6943. * direction of the sort (`desc` or `asc`) and, optionally, the third is the
  6944. * index of the sorting order from the `column.sorting` initialisation array.
  6945. *//**
  6946. * Set the ordering for the table.
  6947. *
  6948. * @param {integer} order Column index to sort upon.
  6949. * @param {string} direction Direction of the sort to be applied (`asc` or `desc`)
  6950. * @returns {DataTables.Api} this
  6951. *//**
  6952. * Set the ordering for the table.
  6953. *
  6954. * @param {array} order 1D array of sorting information to be applied.
  6955. * @param {array} [...] Optional additional sorting conditions
  6956. * @returns {DataTables.Api} this
  6957. *//**
  6958. * Set the ordering for the table.
  6959. *
  6960. * @param {array} order 2D array of sorting information to be applied.
  6961. * @returns {DataTables.Api} this
  6962. */
  6963. _api_register( 'order()', function ( order, dir ) {
  6964. var ctx = this.context;
  6965. if ( order === undefined ) {
  6966. // get
  6967. return ctx.length !== 0 ?
  6968. ctx[0].aaSorting :
  6969. undefined;
  6970. }
  6971. // set
  6972. if ( typeof order === 'number' ) {
  6973. // Simple column / direction passed in
  6974. order = [ [ order, dir ] ];
  6975. }
  6976. else if ( ! $.isArray( order[0] ) ) {
  6977. // Arguments passed in (list of 1D arrays)
  6978. order = Array.prototype.slice.call( arguments );
  6979. }
  6980. // otherwise a 2D array was passed in
  6981. return this.iterator( 'table', function ( settings ) {
  6982. settings.aaSorting = order.slice();
  6983. } );
  6984. } );
  6985. /**
  6986. * Attach a sort listener to an element for a given column
  6987. *
  6988. * @param {node|jQuery|string} node Identifier for the element(s) to attach the
  6989. * listener to. This can take the form of a single DOM node, a jQuery
  6990. * collection of nodes or a jQuery selector which will identify the node(s).
  6991. * @param {integer} column the column that a click on this node will sort on
  6992. * @param {function} [callback] callback function when sort is run
  6993. * @returns {DataTables.Api} this
  6994. */
  6995. _api_register( 'order.listener()', function ( node, column, callback ) {
  6996. return this.iterator( 'table', function ( settings ) {
  6997. _fnSortAttachListener( settings, node, column, callback );
  6998. } );
  6999. } );
  7000. // Order by the selected column(s)
  7001. _api_register( [
  7002. 'columns().order()',
  7003. 'column().order()'
  7004. ], function ( dir ) {
  7005. var that = this;
  7006. return this.iterator( 'table', function ( settings, i ) {
  7007. var sort = [];
  7008. $.each( that[i], function (j, col) {
  7009. sort.push( [ col, dir ] );
  7010. } );
  7011. settings.aaSorting = sort;
  7012. } );
  7013. } );
  7014. _api_register( 'search()', function ( input, regex, smart, caseInsen ) {
  7015. var ctx = this.context;
  7016. if ( input === undefined ) {
  7017. // get
  7018. return ctx.length !== 0 ?
  7019. ctx[0].oPreviousSearch.sSearch :
  7020. undefined;
  7021. }
  7022. // set
  7023. return this.iterator( 'table', function ( settings ) {
  7024. if ( ! settings.oFeatures.bFilter ) {
  7025. return;
  7026. }
  7027. _fnFilterComplete( settings, $.extend( {}, settings.oPreviousSearch, {
  7028. "sSearch": input+"",
  7029. "bRegex": regex === null ? false : regex,
  7030. "bSmart": smart === null ? true : smart,
  7031. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7032. } ), 1 );
  7033. } );
  7034. } );
  7035. _api_register( [
  7036. 'columns().search()',
  7037. 'column().search()'
  7038. ], function ( input, regex, smart, caseInsen ) {
  7039. return this.iterator( 'column', function ( settings, column ) {
  7040. var preSearch = settings.aoPreSearchCols;
  7041. if ( input === undefined ) {
  7042. // get
  7043. return preSearch[ column ].sSearch;
  7044. }
  7045. // set
  7046. if ( ! settings.oFeatures.bFilter ) {
  7047. return;
  7048. }
  7049. $.extend( preSearch[ column ], {
  7050. "sSearch": input+"",
  7051. "bRegex": regex === null ? false : regex,
  7052. "bSmart": smart === null ? true : smart,
  7053. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7054. } );
  7055. _fnFilterComplete( settings, settings.oPreviousSearch, 1 );
  7056. } );
  7057. } );
  7058. /**
  7059. * Provide a common method for plug-ins to check the version of DataTables being
  7060. * used, in order to ensure compatibility.
  7061. *
  7062. * @param {string} version Version string to check for, in the format "X.Y.Z".
  7063. * Note that the formats "X" and "X.Y" are also acceptable.
  7064. * @returns {boolean} true if this version of DataTables is greater or equal to
  7065. * the required version, or false if this version of DataTales is not
  7066. * suitable
  7067. * @static
  7068. * @dtopt API-Static
  7069. *
  7070. * @example
  7071. * alert( $.fn.dataTable.versionCheck( '1.9.0' ) );
  7072. */
  7073. DataTable.versionCheck = DataTable.fnVersionCheck = function( version )
  7074. {
  7075. var aThis = DataTable.version.split('.');
  7076. var aThat = version.split('.');
  7077. var iThis, iThat;
  7078. for ( var i=0, iLen=aThat.length ; i<iLen ; i++ ) {
  7079. iThis = parseInt( aThis[i], 10 ) || 0;
  7080. iThat = parseInt( aThat[i], 10 ) || 0;
  7081. // Parts are the same, keep comparing
  7082. if (iThis === iThat) {
  7083. continue;
  7084. }
  7085. // Parts are different, return immediately
  7086. return iThis > iThat;
  7087. }
  7088. return true;
  7089. };
  7090. /**
  7091. * Check if a `<table>` node is a DataTable table already or not.
  7092. *
  7093. * @param {node|jquery|string} table Table node, jQuery object or jQuery
  7094. * selector for the table to test. Note that if more than more than one
  7095. * table is passed on, only the first will be checked
  7096. * @returns {boolean} true the table given is a DataTable, or false otherwise
  7097. * @static
  7098. * @dtopt API-Static
  7099. *
  7100. * @example
  7101. * if ( ! $.fn.DataTable.isDataTable( '#example' ) ) {
  7102. * $('#example').dataTable();
  7103. * }
  7104. */
  7105. DataTable.isDataTable = DataTable.fnIsDataTable = function ( table )
  7106. {
  7107. var t = $(table).get(0);
  7108. var is = false;
  7109. $.each( DataTable.settings, function (i, o) {
  7110. if ( o.nTable === t || o.nScrollHead === t || o.nScrollFoot === t ) {
  7111. is = true;
  7112. }
  7113. } );
  7114. return is;
  7115. };
  7116. /**
  7117. * Get all DataTable tables that have been initialised - optionally you can
  7118. * select to get only currently visible tables.
  7119. *
  7120. * @param {boolean} [visible=false] Flag to indicate if you want all (default)
  7121. * or visible tables only.
  7122. * @returns {array} Array of `table` nodes (not DataTable instances) which are
  7123. * DataTables
  7124. * @static
  7125. * @dtopt API-Static
  7126. *
  7127. * @example
  7128. * $.each( $.fn.dataTable.tables(true), function () {
  7129. * $(table).DataTable().columns.adjust();
  7130. * } );
  7131. */
  7132. DataTable.tables = DataTable.fnTables = function ( visible )
  7133. {
  7134. return jQuery.map( DataTable.settings, function (o) {
  7135. if ( !visible || (visible && $(o.nTable).is(':visible')) ) {
  7136. return o.nTable;
  7137. }
  7138. } );
  7139. };
  7140. /**
  7141. *
  7142. */
  7143. _api_register( '$()', function ( selector, opts ) {
  7144. var
  7145. rows = this.rows( opts ).nodes(), // Get all rows
  7146. jqRows = $(rows);
  7147. return $( [].concat(
  7148. jqRows.filter( selector ).toArray(),
  7149. jqRows.find( selector ).toArray()
  7150. ) );
  7151. } );
  7152. // jQuery functions to operate on the tables
  7153. $.each( [ 'on', 'one', 'off' ], function (i, key) {
  7154. _api_register( key+'()', function ( /* event, handler */ ) {
  7155. var args = Array.prototype.slice.call(arguments);
  7156. // Add the `dt` namespace automatically if it isn't already present
  7157. if ( args[0].indexOf( '.dt' ) === -1 ) {
  7158. args[0] += '.dt';
  7159. }
  7160. var inst = $( this.tables().nodes() );
  7161. inst[key].apply( inst, args );
  7162. return this;
  7163. } );
  7164. } );
  7165. _api_register( 'clear()', function () {
  7166. return this.iterator( 'table', function ( settings ) {
  7167. _fnClearTable( settings );
  7168. } );
  7169. } );
  7170. _api_register( 'settings()', function () {
  7171. return new _Api( this.context, this.context );
  7172. } );
  7173. _api_register( 'data()', function () {
  7174. return this.iterator( 'table', function ( settings ) {
  7175. return _pluck( settings.aoData, '_aData' );
  7176. } ).flatten();
  7177. } );
  7178. _api_register( 'destroy()', function ( remove ) {
  7179. remove = remove || false;
  7180. return this.iterator( 'table', function ( settings ) {
  7181. var orig = settings.nTableWrapper.parentNode;
  7182. var classes = settings.oClasses;
  7183. var table = settings.nTable;
  7184. var tbody = settings.nTBody;
  7185. var thead = settings.nTHead;
  7186. var tfoot = settings.nTFoot;
  7187. var jqTable = $(table);
  7188. var jqTbody = $(tbody);
  7189. var jqWrapper = $(settings.nTableWrapper);
  7190. var rows = $.map( settings.aoData, function (r) { return r.nTr; } );
  7191. var i, ien;
  7192. // Flag to note that the table is currently being destroyed - no action
  7193. // should be taken
  7194. settings.bDestroying = true;
  7195. // Fire off the destroy callbacks for plug-ins etc
  7196. _fnCallbackFire( settings, "aoDestroyCallback", "destroy", [settings] );
  7197. // If not being removed from the document, make all columns visible
  7198. if ( ! remove ) {
  7199. new _Api( settings ).columns().visible( true );
  7200. }
  7201. // Blitz all DT events
  7202. jqWrapper.unbind('.DT').find(':not(tbody *)').unbind('.DT');
  7203. $(window).unbind('.DT-'+settings.sInstance);
  7204. // When scrolling we had to break the table up - restore it
  7205. if ( table != thead.parentNode ) {
  7206. jqTable.children('thead').remove();
  7207. jqTable.append( thead );
  7208. }
  7209. if ( tfoot && table != tfoot.parentNode ) {
  7210. jqTable.children('tfoot').remove();
  7211. jqTable.append( tfoot );
  7212. }
  7213. // Remove the DataTables generated nodes, events and classes
  7214. jqTable.remove();
  7215. jqWrapper.remove();
  7216. settings.aaSorting = [];
  7217. settings.aaSortingFixed = [];
  7218. _fnSortingClasses( settings );
  7219. $( rows ).removeClass( settings.asStripeClasses.join(' ') );
  7220. $('th, td', thead).removeClass( classes.sSortable+' '+
  7221. classes.sSortableAsc+' '+classes.sSortableDesc+' '+classes.sSortableNone
  7222. );
  7223. if ( settings.bJUI ) {
  7224. $('th span.'+classes.sSortIcon+ ', td span.'+classes.sSortIcon, thead).remove();
  7225. $('th, td', thead).each( function () {
  7226. var wrapper = $('div.'+classes.sSortJUIWrapper, this);
  7227. $(this).append( wrapper.contents() );
  7228. wrapper.remove();
  7229. } );
  7230. }
  7231. if ( ! remove ) {
  7232. // insertBefore acts like appendChild if !arg[1]
  7233. orig.insertBefore( table, settings.nTableReinsertBefore );
  7234. }
  7235. // Add the TR elements back into the table in their original order
  7236. jqTbody.children().detach();
  7237. jqTbody.append( rows );
  7238. // Restore the width of the original table - was read from the style property,
  7239. // so we can restore directly to that
  7240. jqTable
  7241. .css( 'width', settings.sDestroyWidth )
  7242. .removeClass( classes.sTable );
  7243. // If the were originally stripe classes - then we add them back here.
  7244. // Note this is not fool proof (for example if not all rows had stripe
  7245. // classes - but it's a good effort without getting carried away
  7246. ien = settings.asDestroyStripes.length;
  7247. if ( ien ) {
  7248. jqTbody.children().each( function (i) {
  7249. $(this).addClass( settings.asDestroyStripes[i % ien] );
  7250. } );
  7251. }
  7252. /* Remove the settings object from the settings array */
  7253. var idx = $.inArray( settings, DataTable.settings );
  7254. if ( idx !== -1 ) {
  7255. DataTable.settings.splice( idx, 1 );
  7256. }
  7257. } );
  7258. } );
  7259. /**
  7260. * Version string for plug-ins to check compatibility. Allowed format is
  7261. * `a.b.c-d` where: a:int, b:int, c:int, d:string(dev|beta|alpha). `d` is used
  7262. * only for non-release builds. See http://semver.org/ for more information.
  7263. * @member
  7264. * @type string
  7265. * @default Version number
  7266. */
  7267. DataTable.version = "1.10.0-dev";
  7268. /**
  7269. * Private data store, containing all of the settings objects that are
  7270. * created for the tables on a given page.
  7271. *
  7272. * Note that the `DataTable.settings` object is aliased to
  7273. * `jQuery.fn.dataTableExt` through which it may be accessed and
  7274. * manipulated, or `jQuery.fn.dataTable.settings`.
  7275. * @member
  7276. * @type array
  7277. * @default []
  7278. * @private
  7279. */
  7280. DataTable.settings = [];
  7281. /**
  7282. * Object models container, for the various models that DataTables has
  7283. * available to it. These models define the objects that are used to hold
  7284. * the active state and configuration of the table.
  7285. * @namespace
  7286. */
  7287. DataTable.models = {};
  7288. /**
  7289. * Template object for the way in which DataTables holds information about
  7290. * search information for the global filter and individual column filters.
  7291. * @namespace
  7292. */
  7293. DataTable.models.oSearch = {
  7294. /**
  7295. * Flag to indicate if the filtering should be case insensitive or not
  7296. * @type boolean
  7297. * @default true
  7298. */
  7299. "bCaseInsensitive": true,
  7300. /**
  7301. * Applied search term
  7302. * @type string
  7303. * @default <i>Empty string</i>
  7304. */
  7305. "sSearch": "",
  7306. /**
  7307. * Flag to indicate if the search term should be interpreted as a
  7308. * regular expression (true) or not (false) and therefore and special
  7309. * regex characters escaped.
  7310. * @type boolean
  7311. * @default false
  7312. */
  7313. "bRegex": false,
  7314. /**
  7315. * Flag to indicate if DataTables is to use its smart filtering or not.
  7316. * @type boolean
  7317. * @default true
  7318. */
  7319. "bSmart": true
  7320. };
  7321. /**
  7322. * Template object for the way in which DataTables holds information about
  7323. * each individual row. This is the object format used for the settings
  7324. * aoData array.
  7325. * @namespace
  7326. */
  7327. DataTable.models.oRow = {
  7328. /**
  7329. * TR element for the row
  7330. * @type node
  7331. * @default null
  7332. */
  7333. "nTr": null,
  7334. /**
  7335. * Array of TD elements for each row. This is null until the row has been
  7336. * created.
  7337. * @type array nodes
  7338. * @default []
  7339. */
  7340. "anCells": null,
  7341. /**
  7342. * Data object from the original data source for the row. This is either
  7343. * an array if using the traditional form of DataTables, or an object if
  7344. * using mData options. The exact type will depend on the passed in
  7345. * data from the data source, or will be an array if using DOM a data
  7346. * source.
  7347. * @type array|object
  7348. * @default []
  7349. */
  7350. "_aData": [],
  7351. /**
  7352. * Sorting data cache - this array is ostensibly the same length as the
  7353. * number of columns (although each index is generated only as it is
  7354. * needed), and holds the data that is used for sorting each column in the
  7355. * row. We do this cache generation at the start of the sort in order that
  7356. * the formatting of the sort data need be done only once for each cell
  7357. * per sort. This array should not be read from or written to by anything
  7358. * other than the master sorting methods.
  7359. * @type array
  7360. * @default null
  7361. * @private
  7362. */
  7363. "_aSortData": null,
  7364. /**
  7365. * Per cell filtering data cache. As per the sort data cache, used to
  7366. * increase the performance of the filtering in DataTables
  7367. * @type array
  7368. * @default null
  7369. * @private
  7370. */
  7371. "_aFilterData": null,
  7372. /**
  7373. * Filtering data cache. This is the same as the cell filtering cache, but
  7374. * in this case a string rather than an array. This is easily computed with
  7375. * a join on `_aFilterData`, but is provided as a cache so the join isn't
  7376. * needed on every search (memory traded for performance)
  7377. * @type array
  7378. * @default null
  7379. * @private
  7380. */
  7381. "_sFilterRow": null,
  7382. /**
  7383. * Cache of the class name that DataTables has applied to the row, so we
  7384. * can quickly look at this variable rather than needing to do a DOM check
  7385. * on className for the nTr property.
  7386. * @type string
  7387. * @default <i>Empty string</i>
  7388. * @private
  7389. */
  7390. "_sRowStripe": "",
  7391. /**
  7392. * Denote if the original data source was from the DOM, or the data source
  7393. * object. This is used for invalidating data, so DataTables can
  7394. * automatically read data from the original source, unless uninstructed
  7395. * otherwise.
  7396. * @type string
  7397. * @default null
  7398. * @private
  7399. */
  7400. "src": null
  7401. };
  7402. /**
  7403. * Template object for the column information object in DataTables. This object
  7404. * is held in the settings aoColumns array and contains all the information that
  7405. * DataTables needs about each individual column.
  7406. *
  7407. * Note that this object is related to {@link DataTable.defaults.column}
  7408. * but this one is the internal data store for DataTables's cache of columns.
  7409. * It should NOT be manipulated outside of DataTables. Any configuration should
  7410. * be done through the initialisation options.
  7411. * @namespace
  7412. */
  7413. DataTable.models.oColumn = {
  7414. /**
  7415. * A list of the columns that sorting should occur on when this column
  7416. * is sorted. That this property is an array allows multi-column sorting
  7417. * to be defined for a column (for example first name / last name columns
  7418. * would benefit from this). The values are integers pointing to the
  7419. * columns to be sorted on (typically it will be a single integer pointing
  7420. * at itself, but that doesn't need to be the case).
  7421. * @type array
  7422. */
  7423. "aDataSort": null,
  7424. /**
  7425. * Define the sorting directions that are applied to the column, in sequence
  7426. * as the column is repeatedly sorted upon - i.e. the first value is used
  7427. * as the sorting direction when the column if first sorted (clicked on).
  7428. * Sort it again (click again) and it will move on to the next index.
  7429. * Repeat until loop.
  7430. * @type array
  7431. */
  7432. "asSorting": null,
  7433. /**
  7434. * Flag to indicate if the column is searchable, and thus should be included
  7435. * in the filtering or not.
  7436. * @type boolean
  7437. */
  7438. "bSearchable": null,
  7439. /**
  7440. * Flag to indicate if the column is sortable or not.
  7441. * @type boolean
  7442. */
  7443. "bSortable": null,
  7444. /**
  7445. * Flag to indicate if the column is currently visible in the table or not
  7446. * @type boolean
  7447. */
  7448. "bVisible": null,
  7449. /**
  7450. * Store for manual type assignment using the `column.type` option. This
  7451. * is held in store so we can manipulate the column's `sType` property.
  7452. * @type string
  7453. * @default null
  7454. * @private
  7455. */
  7456. "_sManualType": null,
  7457. /**
  7458. * Flag to indicate if HTML5 data attributes should be used as the data
  7459. * source for filtering or sorting. True is either are.
  7460. * @type boolean
  7461. * @default false
  7462. * @private
  7463. */
  7464. "_bAttrSrc": false,
  7465. /**
  7466. * Developer definable function that is called whenever a cell is created (Ajax source,
  7467. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  7468. * allowing you to modify the DOM element (add background colour for example) when the
  7469. * element is available.
  7470. * @type function
  7471. * @param {element} nTd The TD node that has been created
  7472. * @param {*} sData The Data for the cell
  7473. * @param {array|object} oData The data for the whole row
  7474. * @param {int} iRow The row index for the aoData data store
  7475. * @default null
  7476. */
  7477. "fnCreatedCell": null,
  7478. /**
  7479. * Function to get data from a cell in a column. You should <b>never</b>
  7480. * access data directly through _aData internally in DataTables - always use
  7481. * the method attached to this property. It allows mData to function as
  7482. * required. This function is automatically assigned by the column
  7483. * initialisation method
  7484. * @type function
  7485. * @param {array|object} oData The data array/object for the array
  7486. * (i.e. aoData[]._aData)
  7487. * @param {string} sSpecific The specific data type you want to get -
  7488. * 'display', 'type' 'filter' 'sort'
  7489. * @returns {*} The data for the cell from the given row's data
  7490. * @default null
  7491. */
  7492. "fnGetData": null,
  7493. /**
  7494. * Function to set data for a cell in the column. You should <b>never</b>
  7495. * set the data directly to _aData internally in DataTables - always use
  7496. * this method. It allows mData to function as required. This function
  7497. * is automatically assigned by the column initialisation method
  7498. * @type function
  7499. * @param {array|object} oData The data array/object for the array
  7500. * (i.e. aoData[]._aData)
  7501. * @param {*} sValue Value to set
  7502. * @default null
  7503. */
  7504. "fnSetData": null,
  7505. /**
  7506. * Property to read the value for the cells in the column from the data
  7507. * source array / object. If null, then the default content is used, if a
  7508. * function is given then the return from the function is used.
  7509. * @type function|int|string|null
  7510. * @default null
  7511. */
  7512. "mData": null,
  7513. /**
  7514. * Partner property to mData which is used (only when defined) to get
  7515. * the data - i.e. it is basically the same as mData, but without the
  7516. * 'set' option, and also the data fed to it is the result from mData.
  7517. * This is the rendering method to match the data method of mData.
  7518. * @type function|int|string|null
  7519. * @default null
  7520. */
  7521. "mRender": null,
  7522. /**
  7523. * Unique header TH/TD element for this column - this is what the sorting
  7524. * listener is attached to (if sorting is enabled.)
  7525. * @type node
  7526. * @default null
  7527. */
  7528. "nTh": null,
  7529. /**
  7530. * Unique footer TH/TD element for this column (if there is one). Not used
  7531. * in DataTables as such, but can be used for plug-ins to reference the
  7532. * footer for each column.
  7533. * @type node
  7534. * @default null
  7535. */
  7536. "nTf": null,
  7537. /**
  7538. * The class to apply to all TD elements in the table's TBODY for the column
  7539. * @type string
  7540. * @default null
  7541. */
  7542. "sClass": null,
  7543. /**
  7544. * When DataTables calculates the column widths to assign to each column,
  7545. * it finds the longest string in each column and then constructs a
  7546. * temporary table and reads the widths from that. The problem with this
  7547. * is that "mmm" is much wider then "iiii", but the latter is a longer
  7548. * string - thus the calculation can go wrong (doing it properly and putting
  7549. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  7550. * a "work around" we provide this option. It will append its value to the
  7551. * text that is found to be the longest string for the column - i.e. padding.
  7552. * @type string
  7553. */
  7554. "sContentPadding": null,
  7555. /**
  7556. * Allows a default value to be given for a column's data, and will be used
  7557. * whenever a null data source is encountered (this can be because mData
  7558. * is set to null, or because the data source itself is null).
  7559. * @type string
  7560. * @default null
  7561. */
  7562. "sDefaultContent": null,
  7563. /**
  7564. * Name for the column, allowing reference to the column by name as well as
  7565. * by index (needs a lookup to work by name).
  7566. * @type string
  7567. */
  7568. "sName": null,
  7569. /**
  7570. * Custom sorting data type - defines which of the available plug-ins in
  7571. * afnSortData the custom sorting will use - if any is defined.
  7572. * @type string
  7573. * @default std
  7574. */
  7575. "sSortDataType": 'std',
  7576. /**
  7577. * Class to be applied to the header element when sorting on this column
  7578. * @type string
  7579. * @default null
  7580. */
  7581. "sSortingClass": null,
  7582. /**
  7583. * Class to be applied to the header element when sorting on this column -
  7584. * when jQuery UI theming is used.
  7585. * @type string
  7586. * @default null
  7587. */
  7588. "sSortingClassJUI": null,
  7589. /**
  7590. * Title of the column - what is seen in the TH element (nTh).
  7591. * @type string
  7592. */
  7593. "sTitle": null,
  7594. /**
  7595. * Column sorting and filtering type
  7596. * @type string
  7597. * @default null
  7598. */
  7599. "sType": null,
  7600. /**
  7601. * Width of the column
  7602. * @type string
  7603. * @default null
  7604. */
  7605. "sWidth": null,
  7606. /**
  7607. * Width of the column when it was first "encountered"
  7608. * @type string
  7609. * @default null
  7610. */
  7611. "sWidthOrig": null
  7612. };
  7613. /*
  7614. * Developer note: The properties of the object below are given in Hungarian
  7615. * notation, that was used as the interface for DataTables prior to v1.10, however
  7616. * from v1.10 onwards the primary interface is camel case. In order to avoid
  7617. * breaking backwards compatibility utterly with this change, the Hungarian
  7618. * version is still, internally the primary interface, but is is not documented
  7619. * - hence the @name tags in each doc comment. This allows a Javascript function
  7620. * to create a map from Hungarian notation to camel case (going the other direction
  7621. * would require each property to be listed, which would at around 3K to the size
  7622. * of DataTables, while this method is about a 0.5K hit.
  7623. *
  7624. * Ultimately this does pave the way for Hungarian notation to be dropped
  7625. * completely, but that is a massive amount of work and will break current
  7626. * installs (therefore is on-hold until v2).
  7627. */
  7628. /**
  7629. * Initialisation options that can be given to DataTables at initialisation
  7630. * time.
  7631. * @namespace
  7632. */
  7633. DataTable.defaults = {
  7634. /**
  7635. * An array of data to use for the table, passed in at initialisation which
  7636. * will be used in preference to any data which is already in the DOM. This is
  7637. * particularly useful for constructing tables purely in Javascript, for
  7638. * example with a custom Ajax call.
  7639. * @type array
  7640. * @default null
  7641. *
  7642. * @dtopt Option
  7643. * @name DataTable.defaults.data
  7644. *
  7645. * @example
  7646. * // Using a 2D array data source
  7647. * $(document).ready( function () {
  7648. * $('#example').dataTable( {
  7649. * "data": [
  7650. * ['Trident', 'Internet Explorer 4.0', 'Win 95+', 4, 'X'],
  7651. * ['Trident', 'Internet Explorer 5.0', 'Win 95+', 5, 'C'],
  7652. * ],
  7653. * "columns": [
  7654. * { "title": "Engine" },
  7655. * { "title": "Browser" },
  7656. * { "title": "Platform" },
  7657. * { "title": "Version" },
  7658. * { "title": "Grade" }
  7659. * ]
  7660. * } );
  7661. * } );
  7662. *
  7663. * @example
  7664. * // Using an array of objects as a data source (`data`)
  7665. * $(document).ready( function () {
  7666. * $('#example').dataTable( {
  7667. * "data": [
  7668. * {
  7669. * "engine": "Trident",
  7670. * "browser": "Internet Explorer 4.0",
  7671. * "platform": "Win 95+",
  7672. * "version": 4,
  7673. * "grade": "X"
  7674. * },
  7675. * {
  7676. * "engine": "Trident",
  7677. * "browser": "Internet Explorer 5.0",
  7678. * "platform": "Win 95+",
  7679. * "version": 5,
  7680. * "grade": "C"
  7681. * }
  7682. * ],
  7683. * "columns": [
  7684. * { "title": "Engine", "data": "engine" },
  7685. * { "title": "Browser", "data": "browser" },
  7686. * { "title": "Platform", "data": "platform" },
  7687. * { "title": "Version", "data": "version" },
  7688. * { "title": "Grade", "data": "grade" }
  7689. * ]
  7690. * } );
  7691. * } );
  7692. */
  7693. "aaData": null,
  7694. /**
  7695. * If ordering is enabled, then DataTables will perform a first pass sort on
  7696. * initialisation. You can define which column(s) the sort is performed
  7697. * upon, and the sorting direction, with this variable. The `sorting` array
  7698. * should contain an array for each column to be sorted initially containing
  7699. * the column's index and a direction string ('asc' or 'desc').
  7700. * @type array
  7701. * @default [[0,'asc']]
  7702. *
  7703. * @dtopt Option
  7704. * @name DataTable.defaults.order
  7705. *
  7706. * @example
  7707. * // Sort by 3rd column first, and then 4th column
  7708. * $(document).ready( function() {
  7709. * $('#example').dataTable( {
  7710. * "order": [[2,'asc'], [3,'desc']]
  7711. * } );
  7712. * } );
  7713. *
  7714. * // No initial sorting
  7715. * $(document).ready( function() {
  7716. * $('#example').dataTable( {
  7717. * "order": []
  7718. * } );
  7719. * } );
  7720. */
  7721. "aaSorting": [[0,'asc']],
  7722. /**
  7723. * This parameter is basically identical to the `sorting` parameter, but
  7724. * cannot be overridden by user interaction with the table. What this means
  7725. * is that you could have a column (visible or hidden) which the sorting
  7726. * will always be forced on first - any sorting after that (from the user)
  7727. * will then be performed as required. This can be useful for grouping rows
  7728. * together.
  7729. * @type array
  7730. * @default null
  7731. *
  7732. * @dtopt Option
  7733. * @name DataTable.defaults.orderFixed
  7734. *
  7735. * @example
  7736. * $(document).ready( function() {
  7737. * $('#example').dataTable( {
  7738. * "orderFixed": [[0,'asc']]
  7739. * } );
  7740. * } )
  7741. */
  7742. "aaSortingFixed": [],
  7743. /**
  7744. * DataTables can be instructed to load data to display in the table from a
  7745. * Ajax source. This option defines how that Ajax call is made and where to.
  7746. *
  7747. * The `ajax` property has three different modes of operation, depending on
  7748. * how it is defined. These are:
  7749. *
  7750. * * `string` - Set the URL from where the data should be loaded from.
  7751. * * `object` - Define properties for `jQuery.ajax`.
  7752. * * `function` - Custom data get function
  7753. *
  7754. * `string`
  7755. * --------
  7756. *
  7757. * As a string, the `ajax` property simply defines the URL from which
  7758. * DataTables will load data.
  7759. *
  7760. * `object`
  7761. * --------
  7762. *
  7763. * As an object, the parameters in the object are passed to
  7764. * [jQuery.ajax](http://api.jquery.com/jQuery.ajax/) allowing fine control
  7765. * of the Ajax request. DataTables has a number of default parameters which
  7766. * you can override using this option. Please refer to the jQuery
  7767. * documentation for a full description of the options available, although
  7768. * the following parameters provide additional options in DataTables or
  7769. * require special consideration:
  7770. *
  7771. * * `data` - As with jQuery, `data` can be provided as an object, but it
  7772. * can also be used as a function to manipulate the data DataTables sends
  7773. * to the server. The function takes a single parameter, an object of
  7774. * parameters with the values that DataTables has readied for sending. An
  7775. * object may be returned which will be merged into the DataTables
  7776. * defaults, or you can add the items to the object that was passed in and
  7777. * not return anything from the function. This supersedes `fnServerParams`
  7778. * from DataTables 1.9-.
  7779. *
  7780. * * `dataSrc` - By default DataTables will look for the property `data` (or
  7781. * `aaData` for compatibility with DataTables 1.9-) when obtaining data
  7782. * from an Ajax source or for server-side processing - this parameter
  7783. * allows that property to be changed. You can use Javascript dotted
  7784. * object notation to get a data source for multiple levels of nesting, or
  7785. * it my be used as a function. As a function it takes a single parameter,
  7786. * the JSON returned from the server, which can be manipulated as
  7787. * required, with the returned value being that used by DataTables as the
  7788. * data source for the table. This supersedes `sAjaxDataProp` from
  7789. * DataTables 1.9-.
  7790. *
  7791. * * `success` - Should not be overridden it is used internally in
  7792. * DataTables. To manipulate / transform the data returned by the server
  7793. * use `ajax.dataSrc`, or use `ajax` as a function (see below).
  7794. *
  7795. * `function`
  7796. * ----------
  7797. *
  7798. * As a function, making the Ajax call is left up to yourself allowing
  7799. * complete control of the Ajax request. Indeed, if desired, a method other
  7800. * than Ajax could be used to obtain the required data, such as Web storage
  7801. * or an AIR database.
  7802. *
  7803. * The function is given four parameters and no return is required. The
  7804. * parameters are:
  7805. *
  7806. * 1. _object_ - Data to send to the server
  7807. * 2. _function_ - Callback function that must be executed when the required
  7808. * data has been obtained. That data should be passed into the callback
  7809. * as the only parameter
  7810. * 3. _object_ - DataTables settings object for the table
  7811. *
  7812. * Note that this supersedes `fnServerData` from DataTables 1.9-.
  7813. *
  7814. * @type string|object|function
  7815. * @default null
  7816. *
  7817. * @dtopt Option
  7818. * @name DataTable.defaults.ajax
  7819. * @since 1.10.0
  7820. *
  7821. * @example
  7822. * // Get JSON data from a file via Ajax.
  7823. * // Note DataTables expects data in the form `{ data: [ ...data... ] }` by default).
  7824. * $('#example').dataTable( {
  7825. * "ajax": "data.json"
  7826. * } );
  7827. *
  7828. * @example
  7829. * // Get JSON data from a file via Ajax, using `dataSrc` to change
  7830. * // `data` to `tableData` (i.e. `{ tableData: [ ...data... ] }`)
  7831. * $('#example').dataTable( {
  7832. * "ajax": {
  7833. * "url": "data.json",
  7834. * "dataSrc": "tableData"
  7835. * }
  7836. * } );
  7837. *
  7838. * @example
  7839. * // Get JSON data from a file via Ajax, using `dataSrc` to read data
  7840. * // from a plain array rather than an array in an object
  7841. * $('#example').dataTable( {
  7842. * "ajax": {
  7843. * "url": "data.json",
  7844. * "dataSrc": ""
  7845. * }
  7846. * } );
  7847. *
  7848. * @example
  7849. * // Manipulate the data returned from the server - add a link to data
  7850. * // (note this can, should, be done using `render` for the column - this
  7851. * // is just a simple example of how the data can be manipulated).
  7852. * $('#example').dataTable( {
  7853. * "ajax": {
  7854. * "url": "data.json",
  7855. * "dataSrc": function ( json ) {
  7856. * for ( var i=0, ien=json.length ; i<ien ; i++ ) {
  7857. * json[i][0] = '<a href="/message/'+json[i][0]+'>View message</a>';
  7858. * }
  7859. * return json;
  7860. * }
  7861. * }
  7862. * } );
  7863. *
  7864. * @example
  7865. * // Add data to the request
  7866. * $('#example').dataTable( {
  7867. * "ajax": {
  7868. * "url": "data.json",
  7869. * "data": function ( d ) {
  7870. * return {
  7871. * "extra_search": $('#extra').val()
  7872. * };
  7873. * }
  7874. * }
  7875. * } );
  7876. *
  7877. * @example
  7878. * // Send request as POST
  7879. * $('#example').dataTable( {
  7880. * "ajax": {
  7881. * "url": "data.json",
  7882. * "type": "POST"
  7883. * }
  7884. * } );
  7885. *
  7886. * @example
  7887. * // Get the data from localStorage (could interface with a form for
  7888. * // adding, editing and removing rows).
  7889. * $('#example').dataTable( {
  7890. * "ajax": function (data, callback, settings) {
  7891. * callback(
  7892. * JSON.parse( localStorage.getItem('dataTablesData') )
  7893. * );
  7894. * }
  7895. * } );
  7896. */
  7897. "ajax": null,
  7898. /**
  7899. * This parameter allows you to readily specify the entries in the length drop
  7900. * down menu that DataTables shows when pagination is enabled. It can be
  7901. * either a 1D array of options which will be used for both the displayed
  7902. * option and the value, or a 2D array which will use the array in the first
  7903. * position as the value, and the array in the second position as the
  7904. * displayed options (useful for language strings such as 'All').
  7905. *
  7906. * Note that the `pageLength` property will be automatically set to the
  7907. * first value given in this array, unless `pageLength` is also provided.
  7908. * @type array
  7909. * @default [ 10, 25, 50, 100 ]
  7910. *
  7911. * @dtopt Option
  7912. * @name DataTable.defaults.lengthMenu
  7913. *
  7914. * @example
  7915. * $(document).ready( function() {
  7916. * $('#example').dataTable( {
  7917. * "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
  7918. * } );
  7919. * } );
  7920. */
  7921. "aLengthMenu": [ 10, 25, 50, 100 ],
  7922. /**
  7923. * The `columns` option in the initialisation parameter allows you to define
  7924. * details about the way individual columns behave. For a full list of
  7925. * column options that can be set, please see
  7926. * {@link DataTable.defaults.column}. Note that if you use `columns` to
  7927. * define your columns, you must have an entry in the array for every single
  7928. * column that you have in your table (these can be null if you don't which
  7929. * to specify any options).
  7930. * @member
  7931. *
  7932. * @name DataTable.defaults.column
  7933. */
  7934. "aoColumns": null,
  7935. /**
  7936. * Very similar to `columns`, `columnDefs` allows you to target a specific
  7937. * column, multiple columns, or all columns, using the `targets` property of
  7938. * each object in the array. This allows great flexibility when creating
  7939. * tables, as the `columnDefs` arrays can be of any length, targeting the
  7940. * columns you specifically want. `columnDefs` may use any of the column
  7941. * options available: {@link DataTable.defaults.column}, but it _must_
  7942. * have `targets` defined in each object in the array. Values in the `targets`
  7943. * array may be:
  7944. * <ul>
  7945. * <li>a string - class name will be matched on the TH for the column</li>
  7946. * <li>0 or a positive integer - column index counting from the left</li>
  7947. * <li>a negative integer - column index counting from the right</li>
  7948. * <li>the string "_all" - all columns (i.e. assign a default)</li>
  7949. * </ul>
  7950. * @member
  7951. *
  7952. * @name DataTable.defaults.columnDefs
  7953. */
  7954. "aoColumnDefs": null,
  7955. /**
  7956. * Basically the same as `search`, this parameter defines the individual column
  7957. * filtering state at initialisation time. The array must be of the same size
  7958. * as the number of columns, and each element be an object with the parameters
  7959. * `search` and `escapeRegex` (the latter is optional). 'null' is also
  7960. * accepted and the default will be used.
  7961. * @type array
  7962. * @default []
  7963. *
  7964. * @dtopt Option
  7965. * @name DataTable.defaults.searchCols
  7966. *
  7967. * @example
  7968. * $(document).ready( function() {
  7969. * $('#example').dataTable( {
  7970. * "searchCols": [
  7971. * null,
  7972. * { "search": "My filter" },
  7973. * null,
  7974. * { "search": "^[0-9]", "escapeRegex": false }
  7975. * ]
  7976. * } );
  7977. * } )
  7978. */
  7979. "aoSearchCols": [],
  7980. /**
  7981. * An array of CSS classes that should be applied to displayed rows. This
  7982. * array may be of any length, and DataTables will apply each class
  7983. * sequentially, looping when required.
  7984. * @type array
  7985. * @default null <i>Will take the values determined by the `oClasses.stripe*`
  7986. * options</i>
  7987. *
  7988. * @dtopt Option
  7989. * @name DataTable.defaults.stripeClasses
  7990. *
  7991. * @example
  7992. * $(document).ready( function() {
  7993. * $('#example').dataTable( {
  7994. * "stripeClasses": [ 'strip1', 'strip2', 'strip3' ]
  7995. * } );
  7996. * } )
  7997. */
  7998. "asStripeClasses": null,
  7999. /**
  8000. * Enable or disable automatic column width calculation. This can be disabled
  8001. * as an optimisation (it takes some time to calculate the widths) if the
  8002. * tables widths are passed in using `columns`.
  8003. * @type boolean
  8004. * @default true
  8005. *
  8006. * @dtopt Features
  8007. * @name DataTable.defaults.autoWidth
  8008. *
  8009. * @example
  8010. * $(document).ready( function () {
  8011. * $('#example').dataTable( {
  8012. * "autoWidth": false
  8013. * } );
  8014. * } );
  8015. */
  8016. "bAutoWidth": true,
  8017. /**
  8018. * Deferred rendering can provide DataTables with a huge speed boost when you
  8019. * are using an Ajax or JS data source for the table. This option, when set to
  8020. * true, will cause DataTables to defer the creation of the table elements for
  8021. * each row until they are needed for a draw - saving a significant amount of
  8022. * time.
  8023. * @type boolean
  8024. * @default false
  8025. *
  8026. * @dtopt Features
  8027. * @name DataTable.defaults.deferRender
  8028. *
  8029. * @example
  8030. * $(document).ready( function() {
  8031. * $('#example').dataTable( {
  8032. * "ajax": "sources/arrays.txt",
  8033. * "deferRender": true
  8034. * } );
  8035. * } );
  8036. */
  8037. "bDeferRender": false,
  8038. /**
  8039. * Replace a DataTable which matches the given selector and replace it with
  8040. * one which has the properties of the new initialisation object passed. If no
  8041. * table matches the selector, then the new DataTable will be constructed as
  8042. * per normal.
  8043. * @type boolean
  8044. * @default false
  8045. *
  8046. * @dtopt Options
  8047. * @name DataTable.defaults.destroy
  8048. *
  8049. * @example
  8050. * $(document).ready( function() {
  8051. * $('#example').dataTable( {
  8052. * "srollY": "200px",
  8053. * "paginate": false
  8054. * } );
  8055. *
  8056. * // Some time later....
  8057. * $('#example').dataTable( {
  8058. * "filter": false,
  8059. * "destroy": true
  8060. * } );
  8061. * } );
  8062. */
  8063. "bDestroy": false,
  8064. /**
  8065. * Enable or disable filtering of data. Filtering in DataTables is "smart" in
  8066. * that it allows the end user to input multiple words (space separated) and
  8067. * will match a row containing those words, even if not in the order that was
  8068. * specified (this allow matching across multiple columns). Note that if you
  8069. * wish to use filtering in DataTables this must remain 'true' - to remove the
  8070. * default filtering input box and retain filtering abilities, please use
  8071. * {@link DataTable.defaults.dom}.
  8072. * @type boolean
  8073. * @default true
  8074. *
  8075. * @dtopt Features
  8076. * @name DataTable.defaults.searching
  8077. *
  8078. * @example
  8079. * $(document).ready( function () {
  8080. * $('#example').dataTable( {
  8081. * "searching": false
  8082. * } );
  8083. * } );
  8084. */
  8085. "bFilter": true,
  8086. /**
  8087. * Enable or disable the table information display. This shows information
  8088. * about the data that is currently visible on the page, including information
  8089. * about filtered data if that action is being performed.
  8090. * @type boolean
  8091. * @default true
  8092. *
  8093. * @dtopt Features
  8094. * @name DataTable.defaults.info
  8095. *
  8096. * @example
  8097. * $(document).ready( function () {
  8098. * $('#example').dataTable( {
  8099. * "info": false
  8100. * } );
  8101. * } );
  8102. */
  8103. "bInfo": true,
  8104. /**
  8105. * Enable jQuery UI ThemeRoller support (required as ThemeRoller requires some
  8106. * slightly different and additional mark-up from what DataTables has
  8107. * traditionally used).
  8108. * @type boolean
  8109. * @default false
  8110. *
  8111. * @dtopt Features
  8112. * @name DataTable.defaults.jQueryUI
  8113. *
  8114. * @example
  8115. * $(document).ready( function() {
  8116. * $('#example').dataTable( {
  8117. * "jQueryUI": true
  8118. * } );
  8119. * } );
  8120. */
  8121. "bJQueryUI": false,
  8122. /**
  8123. * Allows the end user to select the size of a formatted page from a select
  8124. * menu (sizes are 10, 25, 50 and 100). Requires pagination (`paginate`).
  8125. * @type boolean
  8126. * @default true
  8127. *
  8128. * @dtopt Features
  8129. * @name DataTable.defaults.lengthChange
  8130. *
  8131. * @example
  8132. * $(document).ready( function () {
  8133. * $('#example').dataTable( {
  8134. * "lengthChange": false
  8135. * } );
  8136. * } );
  8137. */
  8138. "bLengthChange": true,
  8139. /**
  8140. * Enable or disable pagination.
  8141. * @type boolean
  8142. * @default true
  8143. *
  8144. * @dtopt Features
  8145. * @name DataTable.defaults.paging
  8146. *
  8147. * @example
  8148. * $(document).ready( function () {
  8149. * $('#example').dataTable( {
  8150. * "paging": false
  8151. * } );
  8152. * } );
  8153. */
  8154. "bPaginate": true,
  8155. /**
  8156. * Enable or disable the display of a 'processing' indicator when the table is
  8157. * being processed (e.g. a sort). This is particularly useful for tables with
  8158. * large amounts of data where it can take a noticeable amount of time to sort
  8159. * the entries.
  8160. * @type boolean
  8161. * @default false
  8162. *
  8163. * @dtopt Features
  8164. * @name DataTable.defaults.processing
  8165. *
  8166. * @example
  8167. * $(document).ready( function () {
  8168. * $('#example').dataTable( {
  8169. * "processing": true
  8170. * } );
  8171. * } );
  8172. */
  8173. "bProcessing": false,
  8174. /**
  8175. * Retrieve the DataTables object for the given selector. Note that if the
  8176. * table has already been initialised, this parameter will cause DataTables
  8177. * to simply return the object that has already been set up - it will not take
  8178. * account of any changes you might have made to the initialisation object
  8179. * passed to DataTables (setting this parameter to true is an acknowledgement
  8180. * that you understand this). `destroy` can be used to reinitialise a table if
  8181. * you need.
  8182. * @type boolean
  8183. * @default false
  8184. *
  8185. * @dtopt Options
  8186. * @name DataTable.defaults.retrieve
  8187. *
  8188. * @example
  8189. * $(document).ready( function() {
  8190. * initTable();
  8191. * tableActions();
  8192. * } );
  8193. *
  8194. * function initTable ()
  8195. * {
  8196. * return $('#example').dataTable( {
  8197. * "scrollY": "200px",
  8198. * "paginate": false,
  8199. * "retrieve": true
  8200. * } );
  8201. * }
  8202. *
  8203. * function tableActions ()
  8204. * {
  8205. * var table = initTable();
  8206. * // perform API operations with oTable
  8207. * }
  8208. */
  8209. "bRetrieve": false,
  8210. /**
  8211. * When vertical (y) scrolling is enabled, DataTables will force the height of
  8212. * the table's viewport to the given height at all times (useful for layout).
  8213. * However, this can look odd when filtering data down to a small data set,
  8214. * and the footer is left "floating" further down. This parameter (when
  8215. * enabled) will cause DataTables to collapse the table's viewport down when
  8216. * the result set will fit within the given Y height.
  8217. * @type boolean
  8218. * @default false
  8219. *
  8220. * @dtopt Options
  8221. * @name DataTable.defaults.scrollCollapse
  8222. *
  8223. * @example
  8224. * $(document).ready( function() {
  8225. * $('#example').dataTable( {
  8226. * "scrollY": "200",
  8227. * "scrollCollapse": true
  8228. * } );
  8229. * } );
  8230. */
  8231. "bScrollCollapse": false,
  8232. /**
  8233. * Configure DataTables to use server-side processing. Note that the
  8234. * `ajax` parameter must also be given in order to give DataTables a
  8235. * source to obtain the required data for each draw.
  8236. * @type boolean
  8237. * @default false
  8238. *
  8239. * @dtopt Features
  8240. * @dtopt Server-side
  8241. * @name DataTable.defaults.serverSide
  8242. *
  8243. * @example
  8244. * $(document).ready( function () {
  8245. * $('#example').dataTable( {
  8246. * "serverSide": true,
  8247. * "ajax": "xhr.php"
  8248. * } );
  8249. * } );
  8250. */
  8251. "bServerSide": false,
  8252. /**
  8253. * Enable or disable sorting of columns. Sorting of individual columns can be
  8254. * disabled by the `sortable` option for each column.
  8255. * @type boolean
  8256. * @default true
  8257. *
  8258. * @dtopt Features
  8259. * @name DataTable.defaults.ordering
  8260. *
  8261. * @example
  8262. * $(document).ready( function () {
  8263. * $('#example').dataTable( {
  8264. * "ordering": false
  8265. * } );
  8266. * } );
  8267. */
  8268. "bSort": true,
  8269. /**
  8270. * Enable or display DataTables' ability to sort multiple columns at the
  8271. * same time (activated by shift-click by the user).
  8272. * @type boolean
  8273. * @default true
  8274. *
  8275. * @dtopt Options
  8276. * @name DataTable.defaults.orderMulti
  8277. *
  8278. * @example
  8279. * // Disable multiple column sorting ability
  8280. * $(document).ready( function () {
  8281. * $('#example').dataTable( {
  8282. * "orderMulti": false
  8283. * } );
  8284. * } );
  8285. */
  8286. "bSortMulti": true,
  8287. /**
  8288. * Allows control over whether DataTables should use the top (true) unique
  8289. * cell that is found for a single column, or the bottom (false - default).
  8290. * This is useful when using complex headers.
  8291. * @type boolean
  8292. * @default false
  8293. *
  8294. * @dtopt Options
  8295. * @name DataTable.defaults.orderCellsTop
  8296. *
  8297. * @example
  8298. * $(document).ready( function() {
  8299. * $('#example').dataTable( {
  8300. * "orderCellsTop": true
  8301. * } );
  8302. * } );
  8303. */
  8304. "bSortCellsTop": false,
  8305. /**
  8306. * Enable or disable the addition of the classes `sorting\_1`, `sorting\_2` and
  8307. * `sorting\_3` to the columns which are currently being sorted on. This is
  8308. * presented as a feature switch as it can increase processing time (while
  8309. * classes are removed and added) so for large data sets you might want to
  8310. * turn this off.
  8311. * @type boolean
  8312. * @default true
  8313. *
  8314. * @dtopt Features
  8315. * @name DataTable.defaults.orderClasses
  8316. *
  8317. * @example
  8318. * $(document).ready( function () {
  8319. * $('#example').dataTable( {
  8320. * "orderClasses": false
  8321. * } );
  8322. * } );
  8323. */
  8324. "bSortClasses": true,
  8325. /**
  8326. * Enable or disable state saving. When enabled HTML5 `localStorage` will be
  8327. * used to save table display information such as pagination information,
  8328. * display length, filtering and sorting. As such when the end user reloads
  8329. * the page the display display will match what thy had previously set up.
  8330. *
  8331. * Due to the use of `localStorage` the default state saving is not supported
  8332. * in IE6 or 7. If state saving is required in those browsers, use
  8333. * `stateSaveCallback` to provide a storage solution such as cookies.
  8334. * @type boolean
  8335. * @default false
  8336. *
  8337. * @dtopt Features
  8338. * @name DataTable.defaults.stateSave
  8339. *
  8340. * @example
  8341. * $(document).ready( function () {
  8342. * $('#example').dataTable( {
  8343. * "stateSave": true
  8344. * } );
  8345. * } );
  8346. */
  8347. "bStateSave": false,
  8348. /**
  8349. * This function is called when a TR element is created (and all TD child
  8350. * elements have been inserted), or registered if using a DOM source, allowing
  8351. * manipulation of the TR element (adding classes etc).
  8352. * @type function
  8353. * @param {node} row "TR" element for the current row
  8354. * @param {array} data Raw data array for this row
  8355. * @param {int} dataIndex The index of this row in the internal aoData array
  8356. *
  8357. * @dtopt Callbacks
  8358. * @name DataTable.defaults.createdRow
  8359. *
  8360. * @example
  8361. * $(document).ready( function() {
  8362. * $('#example').dataTable( {
  8363. * "createdRow": function( row, data, dataIndex ) {
  8364. * // Bold the grade for all 'A' grade browsers
  8365. * if ( data[4] == "A" )
  8366. * {
  8367. * $('td:eq(4)', row).html( '<b>A</b>' );
  8368. * }
  8369. * }
  8370. * } );
  8371. * } );
  8372. */
  8373. "fnCreatedRow": null,
  8374. /**
  8375. * This function is called on every 'draw' event, and allows you to
  8376. * dynamically modify any aspect you want about the created DOM.
  8377. * @type function
  8378. * @param {object} settings DataTables settings object
  8379. *
  8380. * @dtopt Callbacks
  8381. * @name DataTable.defaults.drawCallback
  8382. *
  8383. * @example
  8384. * $(document).ready( function() {
  8385. * $('#example').dataTable( {
  8386. * "drawCallback": function( settings ) {
  8387. * alert( 'DataTables has redrawn the table' );
  8388. * }
  8389. * } );
  8390. * } );
  8391. */
  8392. "fnDrawCallback": null,
  8393. /**
  8394. * Identical to fnHeaderCallback() but for the table footer this function
  8395. * allows you to modify the table footer on every 'draw' event.
  8396. * @type function
  8397. * @param {node} foot "TR" element for the footer
  8398. * @param {array} data Full table data (as derived from the original HTML)
  8399. * @param {int} start Index for the current display starting point in the
  8400. * display array
  8401. * @param {int} end Index for the current display ending point in the
  8402. * display array
  8403. * @param {array int} display Index array to translate the visual position
  8404. * to the full data array
  8405. *
  8406. * @dtopt Callbacks
  8407. * @name DataTable.defaults.footerCallback
  8408. *
  8409. * @example
  8410. * $(document).ready( function() {
  8411. * $('#example').dataTable( {
  8412. * "footerCallback": function( tfoot, data, start, end, display ) {
  8413. * tfoot.getElementsByTagName('th')[0].innerHTML = "Starting index is "+start;
  8414. * }
  8415. * } );
  8416. * } )
  8417. */
  8418. "fnFooterCallback": null,
  8419. /**
  8420. * When rendering large numbers in the information element for the table
  8421. * (i.e. "Showing 1 to 10 of 57 entries") DataTables will render large numbers
  8422. * to have a comma separator for the 'thousands' units (e.g. 1 million is
  8423. * rendered as "1,000,000") to help readability for the end user. This
  8424. * function will override the default method DataTables uses.
  8425. * @type function
  8426. * @member
  8427. * @param {int} toFormat number to be formatted
  8428. * @returns {string} formatted string for DataTables to show the number
  8429. *
  8430. * @dtopt Callbacks
  8431. * @name DataTable.defaults.formatNumber
  8432. *
  8433. * @example
  8434. * // Format a number using a single quote for the separator (note that
  8435. * // this can also be done with the language.infoThousands option)
  8436. * $(document).ready( function() {
  8437. * $('#example').dataTable( {
  8438. * "formatNumber": function ( toFormat ) {
  8439. * return toFormat.toString().replace(
  8440. * /\B(?=(\d{3})+(?!\d))/g, "'"
  8441. * );
  8442. * };
  8443. * } );
  8444. * } );
  8445. */
  8446. "fnFormatNumber": function ( toFormat ) {
  8447. return toFormat.toString().replace(
  8448. /\B(?=(\d{3})+(?!\d))/g,
  8449. this.oLanguage.sInfoThousands
  8450. );
  8451. },
  8452. /**
  8453. * This function is called on every 'draw' event, and allows you to
  8454. * dynamically modify the header row. This can be used to calculate and
  8455. * display useful information about the table.
  8456. * @type function
  8457. * @param {node} head "TR" element for the header
  8458. * @param {array} data Full table data (as derived from the original HTML)
  8459. * @param {int} start Index for the current display starting point in the
  8460. * display array
  8461. * @param {int} end Index for the current display ending point in the
  8462. * display array
  8463. * @param {array int} display Index array to translate the visual position
  8464. * to the full data array
  8465. *
  8466. * @dtopt Callbacks
  8467. * @name DataTable.defaults.headerCallback
  8468. *
  8469. * @example
  8470. * $(document).ready( function() {
  8471. * $('#example').dataTable( {
  8472. * "fheaderCallback": function( head, data, start, end, display ) {
  8473. * head.getElementsByTagName('th')[0].innerHTML = "Displaying "+(end-start)+" records";
  8474. * }
  8475. * } );
  8476. * } )
  8477. */
  8478. "fnHeaderCallback": null,
  8479. /**
  8480. * The information element can be used to convey information about the current
  8481. * state of the table. Although the internationalisation options presented by
  8482. * DataTables are quite capable of dealing with most customisations, there may
  8483. * be times where you wish to customise the string further. This callback
  8484. * allows you to do exactly that.
  8485. * @type function
  8486. * @param {object} oSettings DataTables settings object
  8487. * @param {int} start Starting position in data for the draw
  8488. * @param {int} end End position in data for the draw
  8489. * @param {int} max Total number of rows in the table (regardless of
  8490. * filtering)
  8491. * @param {int} total Total number of rows in the data set, after filtering
  8492. * @param {string} pre The string that DataTables has formatted using it's
  8493. * own rules
  8494. * @returns {string} The string to be displayed in the information element.
  8495. *
  8496. * @dtopt Callbacks
  8497. * @name DataTable.defaults.infoCallback
  8498. *
  8499. * @example
  8500. * $('#example').dataTable( {
  8501. * "infoCallback": function( settings, start, end, max, total, pre ) {
  8502. * return start +" to "+ end;
  8503. * }
  8504. * } );
  8505. */
  8506. "fnInfoCallback": null,
  8507. /**
  8508. * Called when the table has been initialised. Normally DataTables will
  8509. * initialise sequentially and there will be no need for this function,
  8510. * however, this does not hold true when using external language information
  8511. * since that is obtained using an async XHR call.
  8512. * @type function
  8513. * @param {object} settings DataTables settings object
  8514. * @param {object} json The JSON object request from the server - only
  8515. * present if client-side Ajax sourced data is used
  8516. *
  8517. * @dtopt Callbacks
  8518. * @name DataTable.defaults.initComplete
  8519. *
  8520. * @example
  8521. * $(document).ready( function() {
  8522. * $('#example').dataTable( {
  8523. * "initComplete": function(settings, json) {
  8524. * alert( 'DataTables has finished its initialisation.' );
  8525. * }
  8526. * } );
  8527. * } )
  8528. */
  8529. "fnInitComplete": null,
  8530. /**
  8531. * Called at the very start of each table draw and can be used to cancel the
  8532. * draw by returning false, any other return (including undefined) results in
  8533. * the full draw occurring).
  8534. * @type function
  8535. * @param {object} settings DataTables settings object
  8536. * @returns {boolean} False will cancel the draw, anything else (including no
  8537. * return) will allow it to complete.
  8538. *
  8539. * @dtopt Callbacks
  8540. * @name DataTable.defaults.preDrawCallback
  8541. *
  8542. * @example
  8543. * $(document).ready( function() {
  8544. * $('#example').dataTable( {
  8545. * "preDrawCallback": function( settings ) {
  8546. * if ( $('#test').val() == 1 ) {
  8547. * return false;
  8548. * }
  8549. * }
  8550. * } );
  8551. * } );
  8552. */
  8553. "fnPreDrawCallback": null,
  8554. /**
  8555. * This function allows you to 'post process' each row after it have been
  8556. * generated for each table draw, but before it is rendered on screen. This
  8557. * function might be used for setting the row class name etc.
  8558. * @type function
  8559. * @param {node} row "TR" element for the current row
  8560. * @param {array} data Raw data array for this row
  8561. * @param {int} displayIndex The display index for the current table draw
  8562. * @param {int} displayIndexFull The index of the data in the full list of
  8563. * rows (after filtering)
  8564. *
  8565. * @dtopt Callbacks
  8566. * @name DataTable.defaults.rowCallback
  8567. *
  8568. * @example
  8569. * $(document).ready( function() {
  8570. * $('#example').dataTable( {
  8571. * "rowCallback": function( row, data, displayIndex, displayIndexFull ) {
  8572. * // Bold the grade for all 'A' grade browsers
  8573. * if ( data[4] == "A" ) {
  8574. * $('td:eq(4)', row).html( '<b>A</b>' );
  8575. * }
  8576. * }
  8577. * } );
  8578. * } );
  8579. */
  8580. "fnRowCallback": null,
  8581. /**
  8582. * __Deprecated__ The functionality provided by this parameter has now been
  8583. * superseded by that provided through `ajax`, which should be used instead.
  8584. *
  8585. * This parameter allows you to override the default function which obtains
  8586. * the data from the server so something more suitable for your application.
  8587. * For example you could use POST data, or pull information from a Gears or
  8588. * AIR database.
  8589. * @type function
  8590. * @member
  8591. * @param {string} source HTTP source to obtain the data from (`ajax`)
  8592. * @param {array} data A key/value pair object containing the data to send
  8593. * to the server
  8594. * @param {function} callback to be called on completion of the data get
  8595. * process that will draw the data on the page.
  8596. * @param {object} settings DataTables settings object
  8597. *
  8598. * @dtopt Callbacks
  8599. * @dtopt Server-side
  8600. * @name DataTable.defaults.serverData
  8601. *
  8602. * @deprecated 1.10. Please use `ajax` for this functionality now.
  8603. */
  8604. "fnServerData": null,
  8605. /**
  8606. * __Deprecated__ The functionality provided by this parameter has now been
  8607. * superseded by that provided through `ajax`, which should be used instead.
  8608. *
  8609. * It is often useful to send extra data to the server when making an Ajax
  8610. * request - for example custom filtering information, and this callback
  8611. * function makes it trivial to send extra information to the server. The
  8612. * passed in parameter is the data set that has been constructed by
  8613. * DataTables, and you can add to this or modify it as you require.
  8614. * @type function
  8615. * @param {array} data Data array (array of objects which are name/value
  8616. * pairs) that has been constructed by DataTables and will be sent to the
  8617. * server. In the case of Ajax sourced data with server-side processing
  8618. * this will be an empty array, for server-side processing there will be a
  8619. * significant number of parameters!
  8620. * @returns {undefined} Ensure that you modify the data array passed in,
  8621. * as this is passed by reference.
  8622. *
  8623. * @dtopt Callbacks
  8624. * @dtopt Server-side
  8625. * @name DataTable.defaults.serverParams
  8626. *
  8627. * @deprecated 1.10. Please use `ajax` for this functionality now.
  8628. */
  8629. "fnServerParams": null,
  8630. /**
  8631. * Load the table state. With this function you can define from where, and how, the
  8632. * state of a table is loaded. By default DataTables will load from `localStorage`
  8633. * but you might wish to use a server-side database or cookies.
  8634. * @type function
  8635. * @member
  8636. * @param {object} settings DataTables settings object
  8637. * @return {object} The DataTables state object to be loaded
  8638. *
  8639. * @dtopt Callbacks
  8640. * @name DataTable.defaults.stateLoadCallback
  8641. *
  8642. * @example
  8643. * $(document).ready( function() {
  8644. * $('#example').dataTable( {
  8645. * "stateSave": true,
  8646. * "stateLoadCallback": function (settings) {
  8647. * var o;
  8648. *
  8649. * // Send an Ajax request to the server to get the data. Note that
  8650. * // this is a synchronous request.
  8651. * $.ajax( {
  8652. * "url": "/state_load",
  8653. * "async": false,
  8654. * "dataType": "json",
  8655. * "success": function (json) {
  8656. * o = json;
  8657. * }
  8658. * } );
  8659. *
  8660. * return o;
  8661. * }
  8662. * } );
  8663. * } );
  8664. */
  8665. "fnStateLoadCallback": function ( settings ) {
  8666. try {
  8667. return JSON.parse(
  8668. localStorage.getItem('DataTables_'+settings.sInstance+'_'+window.location.pathname)
  8669. );
  8670. } catch (e) {}
  8671. },
  8672. /**
  8673. * Callback which allows modification of the saved state prior to loading that state.
  8674. * This callback is called when the table is loading state from the stored data, but
  8675. * prior to the settings object being modified by the saved state. Note that for
  8676. * plug-in authors, you should use the `stateLoadParams` event to load parameters for
  8677. * a plug-in.
  8678. * @type function
  8679. * @param {object} settings DataTables settings object
  8680. * @param {object} data The state object that is to be loaded
  8681. *
  8682. * @dtopt Callbacks
  8683. * @name DataTable.defaults.stateLoadParams
  8684. *
  8685. * @example
  8686. * // Remove a saved filter, so filtering is never loaded
  8687. * $(document).ready( function() {
  8688. * $('#example').dataTable( {
  8689. * "stateSave": true,
  8690. * "stateLoadParams": function (settings, data) {
  8691. * data.oSearch.sSearch = "";
  8692. * }
  8693. * } );
  8694. * } );
  8695. *
  8696. * @example
  8697. * // Disallow state loading by returning false
  8698. * $(document).ready( function() {
  8699. * $('#example').dataTable( {
  8700. * "stateSave": true,
  8701. * "stateLoadParams": function (settings, data) {
  8702. * return false;
  8703. * }
  8704. * } );
  8705. * } );
  8706. */
  8707. "fnStateLoadParams": null,
  8708. /**
  8709. * Callback that is called when the state has been loaded from the state saving method
  8710. * and the DataTables settings object has been modified as a result of the loaded state.
  8711. * @type function
  8712. * @param {object} settings DataTables settings object
  8713. * @param {object} data The state object that was loaded
  8714. *
  8715. * @dtopt Callbacks
  8716. * @name DataTable.defaults.stateLoaded
  8717. *
  8718. * @example
  8719. * // Show an alert with the filtering value that was saved
  8720. * $(document).ready( function() {
  8721. * $('#example').dataTable( {
  8722. * "stateSave": true,
  8723. * "stateLoaded": function (settings, data) {
  8724. * alert( 'Saved filter was: '+data.oSearch.sSearch );
  8725. * }
  8726. * } );
  8727. * } );
  8728. */
  8729. "fnStateLoaded": null,
  8730. /**
  8731. * Save the table state. This function allows you to define where and how the state
  8732. * information for the table is stored By default DataTables will use `localStorage`
  8733. * but you might wish to use a server-side database or cookies.
  8734. * @type function
  8735. * @member
  8736. * @param {object} settings DataTables settings object
  8737. * @param {object} data The state object to be saved
  8738. *
  8739. * @dtopt Callbacks
  8740. * @name DataTable.defaults.stateSaveCallback
  8741. *
  8742. * @example
  8743. * $(document).ready( function() {
  8744. * $('#example').dataTable( {
  8745. * "stateSave": true,
  8746. * "stateSaveCallback": function (settings, data) {
  8747. * // Send an Ajax request to the server with the state object
  8748. * $.ajax( {
  8749. * "url": "/state_save",
  8750. * "data": data,
  8751. * "dataType": "json",
  8752. * "method": "POST"
  8753. * "success": function () {}
  8754. * } );
  8755. * }
  8756. * } );
  8757. * } );
  8758. */
  8759. "fnStateSaveCallback": function ( settings, data ) {
  8760. try {
  8761. localStorage.setItem(
  8762. 'DataTables_'+settings.sInstance+'_'+window.location.pathname,
  8763. JSON.stringify(data)
  8764. );
  8765. } catch (e) {}
  8766. },
  8767. /**
  8768. * Callback which allows modification of the state to be saved. Called when the table
  8769. * has changed state a new state save is required. This method allows modification of
  8770. * the state saving object prior to actually doing the save, including addition or
  8771. * other state properties or modification. Note that for plug-in authors, you should
  8772. * use the `stateSaveParams` event to save parameters for a plug-in.
  8773. * @type function
  8774. * @param {object} settings DataTables settings object
  8775. * @param {object} data The state object to be saved
  8776. *
  8777. * @dtopt Callbacks
  8778. * @name DataTable.defaults.stateSaveParams
  8779. *
  8780. * @example
  8781. * // Remove a saved filter, so filtering is never saved
  8782. * $(document).ready( function() {
  8783. * $('#example').dataTable( {
  8784. * "stateSave": true,
  8785. * "stateSaveParams": function (settings, data) {
  8786. * data.oSearch.sSearch = "";
  8787. * }
  8788. * } );
  8789. * } );
  8790. */
  8791. "fnStateSaveParams": null,
  8792. /**
  8793. * Duration for which the saved state information is considered valid. After this period
  8794. * has elapsed the state will be returned to the default.
  8795. * Value is given in seconds.
  8796. * @type int
  8797. * @default 7200 <i>(2 hours)</i>
  8798. *
  8799. * @dtopt Options
  8800. * @name DataTable.defaults.stateDuration
  8801. *
  8802. * @example
  8803. * $(document).ready( function() {
  8804. * $('#example').dataTable( {
  8805. * "stateDuration": 60*60*24; // 1 day
  8806. * } );
  8807. * } )
  8808. */
  8809. "iStateDuration": 7200,
  8810. /**
  8811. * When enabled DataTables will not make a request to the server for the first
  8812. * page draw - rather it will use the data already on the page (no sorting etc
  8813. * will be applied to it), thus saving on an XHR at load time. `deferLoading`
  8814. * is used to indicate that deferred loading is required, but it is also used
  8815. * to tell DataTables how many records there are in the full table (allowing
  8816. * the information element and pagination to be displayed correctly). In the case
  8817. * where a filtering is applied to the table on initial load, this can be
  8818. * indicated by giving the parameter as an array, where the first element is
  8819. * the number of records available after filtering and the second element is the
  8820. * number of records without filtering (allowing the table information element
  8821. * to be shown correctly).
  8822. * @type int | array
  8823. * @default null
  8824. *
  8825. * @dtopt Options
  8826. * @name DataTable.defaults.deferLoading
  8827. *
  8828. * @example
  8829. * // 57 records available in the table, no filtering applied
  8830. * $(document).ready( function() {
  8831. * $('#example').dataTable( {
  8832. * "serverSide": true,
  8833. * "ajax": "scripts/server_processing.php",
  8834. * "deferLoading": 57
  8835. * } );
  8836. * } );
  8837. *
  8838. * @example
  8839. * // 57 records after filtering, 100 without filtering (an initial filter applied)
  8840. * $(document).ready( function() {
  8841. * $('#example').dataTable( {
  8842. * "serverSide": true,
  8843. * "ajax": "scripts/server_processing.php",
  8844. * "deferLoading": [ 57, 100 ],
  8845. * "search": {
  8846. * "search": "my_filter"
  8847. * }
  8848. * } );
  8849. * } );
  8850. */
  8851. "iDeferLoading": null,
  8852. /**
  8853. * Number of rows to display on a single page when using pagination. If
  8854. * feature enabled (`lengthChange`) then the end user will be able to override
  8855. * this to a custom setting using a pop-up menu.
  8856. * @type int
  8857. * @default 10
  8858. *
  8859. * @dtopt Options
  8860. * @name DataTable.defaults.pageLength
  8861. *
  8862. * @example
  8863. * $(document).ready( function() {
  8864. * $('#example').dataTable( {
  8865. * "pageLength": 50
  8866. * } );
  8867. * } )
  8868. */
  8869. "iDisplayLength": 10,
  8870. /**
  8871. * Define the starting point for data display when using DataTables with
  8872. * pagination. Note that this parameter is the number of records, rather than
  8873. * the page number, so if you have 10 records per page and want to start on
  8874. * the third page, it should be "20".
  8875. * @type int
  8876. * @default 0
  8877. *
  8878. * @dtopt Options
  8879. * @name DataTable.defaults.displayStart
  8880. *
  8881. * @example
  8882. * $(document).ready( function() {
  8883. * $('#example').dataTable( {
  8884. * "displayStart": 20
  8885. * } );
  8886. * } )
  8887. */
  8888. "iDisplayStart": 0,
  8889. /**
  8890. * By default DataTables allows keyboard navigation of the table (sorting, paging,
  8891. * and filtering) by adding a `tabindex` attribute to the required elements. This
  8892. * allows you to tab through the controls and press the enter key to activate them.
  8893. * The tabindex is default 0, meaning that the tab follows the flow of the document.
  8894. * You can overrule this using this parameter if you wish. Use a value of -1 to
  8895. * disable built-in keyboard navigation.
  8896. * @type int
  8897. * @default 0
  8898. *
  8899. * @dtopt Options
  8900. * @name DataTable.defaults.tabIndex
  8901. *
  8902. * @example
  8903. * $(document).ready( function() {
  8904. * $('#example').dataTable( {
  8905. * "tabIndex": 1
  8906. * } );
  8907. * } );
  8908. */
  8909. "iTabIndex": 0,
  8910. /**
  8911. * Classes that DataTables assigns to the various components and features
  8912. * that it adds to the HTML table. This allows classes to be configured
  8913. * during initialisation in addition to through the static
  8914. * {@link DataTable.ext.oStdClasses} object).
  8915. * @namespace
  8916. * @name DataTable.defaults.classes
  8917. */
  8918. "oClasses": {},
  8919. /**
  8920. * All strings that DataTables uses in the user interface that it creates
  8921. * are defined in this object, allowing you to modified them individually or
  8922. * completely replace them all as required.
  8923. * @namespace
  8924. * @name DataTable.defaults.language
  8925. */
  8926. "oLanguage": {
  8927. /**
  8928. * Strings that are used for WAI-ARIA labels and controls only (these are not
  8929. * actually visible on the page, but will be read by screenreaders, and thus
  8930. * must be internationalised as well).
  8931. * @namespace
  8932. * @name DataTable.defaults.language.aria
  8933. */
  8934. "oAria": {
  8935. /**
  8936. * ARIA label that is added to the table headers when the column may be
  8937. * sorted ascending by activing the column (click or return when focused).
  8938. * Note that the column header is prefixed to this string.
  8939. * @type string
  8940. * @default : activate to sort column ascending
  8941. *
  8942. * @dtopt Language
  8943. * @name DataTable.defaults.language.aria.sortAscending
  8944. *
  8945. * @example
  8946. * $(document).ready( function() {
  8947. * $('#example').dataTable( {
  8948. * "language": {
  8949. * "aria": {
  8950. * "sortAscending": " - click/return to sort ascending"
  8951. * }
  8952. * }
  8953. * } );
  8954. * } );
  8955. */
  8956. "sSortAscending": ":激活排序列升序",
  8957. /**
  8958. * ARIA label that is added to the table headers when the column may be
  8959. * sorted descending by activing the column (click or return when focused).
  8960. * Note that the column header is prefixed to this string.
  8961. * @type string
  8962. * @default : activate to sort column ascending
  8963. *
  8964. * @dtopt Language
  8965. * @name DataTable.defaults.language.aria.sortDescending
  8966. *
  8967. * @example
  8968. * $(document).ready( function() {
  8969. * $('#example').dataTable( {
  8970. * "language": {
  8971. * "aria": {
  8972. * "sortDescending": " - click/return to sort descending"
  8973. * }
  8974. * }
  8975. * } );
  8976. * } );
  8977. */
  8978. "sSortDescending": ":激活排序列降序"
  8979. },
  8980. /**
  8981. * Pagination string used by DataTables for the built-in pagination
  8982. * control types.
  8983. * @namespace
  8984. * @name DataTable.defaults.language.paginate
  8985. */
  8986. "oPaginate": {
  8987. /**
  8988. * Text to use when using the 'full_numbers' type of pagination for the
  8989. * button to take the user to the first page.
  8990. * @type string
  8991. * @default First
  8992. *
  8993. * @dtopt Language
  8994. * @name DataTable.defaults.language.paginate.first
  8995. *
  8996. * @example
  8997. * $(document).ready( function() {
  8998. * $('#example').dataTable( {
  8999. * "language": {
  9000. * "paginate": {
  9001. * "first": "First page"
  9002. * }
  9003. * }
  9004. * } );
  9005. * } );
  9006. */
  9007. "sFirst": "第一页",
  9008. /**
  9009. * Text to use when using the 'full_numbers' type of pagination for the
  9010. * button to take the user to the last page.
  9011. * @type string
  9012. * @default Last
  9013. *
  9014. * @dtopt Language
  9015. * @name DataTable.defaults.language.paginate.last
  9016. *
  9017. * @example
  9018. * $(document).ready( function() {
  9019. * $('#example').dataTable( {
  9020. * "language": {
  9021. * "paginate": {
  9022. * "last": "Last page"
  9023. * }
  9024. * }
  9025. * } );
  9026. * } );
  9027. */
  9028. "sLast": "最后一页",
  9029. /**
  9030. * Text to use for the 'next' pagination button (to take the user to the
  9031. * next page).
  9032. * @type string
  9033. * @default Next
  9034. *
  9035. * @dtopt Language
  9036. * @name DataTable.defaults.language.paginate.next
  9037. *
  9038. * @example
  9039. * $(document).ready( function() {
  9040. * $('#example').dataTable( {
  9041. * "language": {
  9042. * "paginate": {
  9043. * "next": "Next page"
  9044. * }
  9045. * }
  9046. * } );
  9047. * } );
  9048. */
  9049. "sNext": "下一页",
  9050. /**
  9051. * Text to use for the 'previous' pagination button (to take the user to
  9052. * the previous page).
  9053. * @type string
  9054. * @default Previous
  9055. *
  9056. * @dtopt Language
  9057. * @name DataTable.defaults.language.paginate.previous
  9058. *
  9059. * @example
  9060. * $(document).ready( function() {
  9061. * $('#example').dataTable( {
  9062. * "language": {
  9063. * "paginate": {
  9064. * "previous": "Previous page"
  9065. * }
  9066. * }
  9067. * } );
  9068. * } );
  9069. */
  9070. "sPrevious": "上一页"
  9071. },
  9072. /**
  9073. * This string is shown in preference to `zeroRecords` when the table is
  9074. * empty of data (regardless of filtering). Note that this is an optional
  9075. * parameter - if it is not given, the value of `zeroRecords` will be used
  9076. * instead (either the default or given value).
  9077. * @type string
  9078. * @default No data available in table
  9079. *
  9080. * @dtopt Language
  9081. * @name DataTable.defaults.language.emptyTable
  9082. *
  9083. * @example
  9084. * $(document).ready( function() {
  9085. * $('#example').dataTable( {
  9086. * "language": {
  9087. * "emptyTable": "No data available in table"
  9088. * }
  9089. * } );
  9090. * } );
  9091. */
  9092. "sEmptyTable": "没有数据",
  9093. /**
  9094. * This string gives information to the end user about the information
  9095. * that is current on display on the page. The following tokens can be
  9096. * used in the string and will be dynamically replaced as the table
  9097. * display updates. This tokens can be placed anywhere in the string, or
  9098. * removed as needed by the language requires:
  9099. *
  9100. * * `\_START\_` - Display index of the first record on the current page
  9101. * * `\_END\_` - Display index of the last record on the current page
  9102. * * `\_TOTAL\_` - Number of records in the table after filtering
  9103. * * `\_MAX\_` - Number of records in the table without filtering
  9104. * * `\_PAGE\_` - Current page number
  9105. * * `\_PAGES\_` - Total number of pages of data in the table
  9106. *
  9107. * @type string
  9108. * @default Showing _START_ to _END_ of _TOTAL_ entries
  9109. *
  9110. * @dtopt Language
  9111. * @name DataTable.defaults.language.info
  9112. *
  9113. * @example
  9114. * $(document).ready( function() {
  9115. * $('#example').dataTable( {
  9116. * "language": {
  9117. * "info": "Showing page _PAGE_ of _PAGES_"
  9118. * }
  9119. * } );
  9120. * } );
  9121. */
  9122. "sInfo": "显示 _START_ 到 _END_ 项,共 _TOTAL_ 项",
  9123. /**
  9124. * Display information string for when the table is empty. Typically the
  9125. * format of this string should match `info`.
  9126. * @type string
  9127. * @default Showing 0 to 0 of 0 entries
  9128. *
  9129. * @dtopt Language
  9130. * @name DataTable.defaults.language.infoEmpty
  9131. *
  9132. * @example
  9133. * $(document).ready( function() {
  9134. * $('#example').dataTable( {
  9135. * "language": {
  9136. * "infoEmpty": "No entries to show"
  9137. * }
  9138. * } );
  9139. * } );
  9140. */
  9141. "sInfoEmpty": "显示0项",
  9142. /**
  9143. * When a user filters the information in a table, this string is appended
  9144. * to the information (`info`) to give an idea of how strong the filtering
  9145. * is. The variable _MAX_ is dynamically updated.
  9146. * @type string
  9147. * @default (filtered from _MAX_ total entries)
  9148. *
  9149. * @dtopt Language
  9150. * @name DataTable.defaults.language.infoFiltered
  9151. *
  9152. * @example
  9153. * $(document).ready( function() {
  9154. * $('#example').dataTable( {
  9155. * "language": {
  9156. * "infoFiltered": " - filtering from _MAX_ records"
  9157. * }
  9158. * } );
  9159. * } );
  9160. */
  9161. "sInfoFiltered": "(从 _MAX_ 中筛选)",
  9162. /**
  9163. * If can be useful to append extra information to the info string at times,
  9164. * and this variable does exactly that. This information will be appended to
  9165. * the `info` (`infoEmpty` and `infoFiltered` in whatever combination they are
  9166. * being used) at all times.
  9167. * @type string
  9168. * @default <i>Empty string</i>
  9169. *
  9170. * @dtopt Language
  9171. * @name DataTable.defaults.language.infoPostFix
  9172. *
  9173. * @example
  9174. * $(document).ready( function() {
  9175. * $('#example').dataTable( {
  9176. * "language": {
  9177. * "infoPostFix": "All records shown are derived from real information."
  9178. * }
  9179. * } );
  9180. * } );
  9181. */
  9182. "sInfoPostFix": "",
  9183. /**
  9184. * DataTables has a build in number formatter (`formatNumber`) which is used
  9185. * to format large numbers that are used in the table information. By
  9186. * default a comma is used, but this can be trivially changed to any
  9187. * character you wish with this parameter.
  9188. * @type string
  9189. * @default ,
  9190. *
  9191. * @dtopt Language
  9192. * @name DataTable.defaults.language.infoThousands
  9193. *
  9194. * @example
  9195. * $(document).ready( function() {
  9196. * $('#example').dataTable( {
  9197. * "language": {
  9198. * "infoThousands": "'"
  9199. * }
  9200. * } );
  9201. * } );
  9202. */
  9203. "sInfoThousands": ",",
  9204. /**
  9205. * Detail the action that will be taken when the drop down menu for the
  9206. * pagination length option is changed. The '_MENU_' variable is replaced
  9207. * with a default select list of 10, 25, 50 and 100, and can be replaced
  9208. * with a custom select box if required.
  9209. * @type string
  9210. * @default Show _MENU_ entries
  9211. *
  9212. * @dtopt Language
  9213. * @name DataTable.defaults.language.lengthMenu
  9214. *
  9215. * @example
  9216. * // Language change only
  9217. * $(document).ready( function() {
  9218. * $('#example').dataTable( {
  9219. * "language": {
  9220. * "lengthMenu": "Display _MENU_ records"
  9221. * }
  9222. * } );
  9223. * } );
  9224. *
  9225. * @example
  9226. * // Language and options change
  9227. * $(document).ready( function() {
  9228. * $('#example').dataTable( {
  9229. * "language": {
  9230. * "lengthMenu": 'Display <select>'+
  9231. * '<option value="10">10</option>'+
  9232. * '<option value="20">20</option>'+
  9233. * '<option value="30">30</option>'+
  9234. * '<option value="40">40</option>'+
  9235. * '<option value="50">50</option>'+
  9236. * '<option value="-1">All</option>'+
  9237. * '</select> records'
  9238. * }
  9239. * } );
  9240. * } );
  9241. */
  9242. "sLengthMenu": "显示 _MENU_ entries",
  9243. /**
  9244. * When using Ajax sourced data and during the first draw when DataTables is
  9245. * gathering the data, this message is shown in an empty row in the table to
  9246. * indicate to the end user the the data is being loaded. Note that this
  9247. * parameter is not used when loading data by server-side processing, just
  9248. * Ajax sourced data with client-side processing.
  9249. * @type string
  9250. * @default Loading...
  9251. *
  9252. * @dtopt Language
  9253. * @name DataTable.defaults.language.loadingRecords
  9254. *
  9255. * @example
  9256. * $(document).ready( function() {
  9257. * $('#example').dataTable( {
  9258. * "language": {
  9259. * "loadingRecords": "Please wait - loading..."
  9260. * }
  9261. * } );
  9262. * } );
  9263. */
  9264. "sLoadingRecords": "加载中…",
  9265. /**
  9266. * Text which is displayed when the table is processing a user action
  9267. * (usually a sort command or similar).
  9268. * @type string
  9269. * @default Processing...
  9270. *
  9271. * @dtopt Language
  9272. * @name DataTable.defaults.language.processing
  9273. *
  9274. * @example
  9275. * $(document).ready( function() {
  9276. * $('#example').dataTable( {
  9277. * "language": {
  9278. * "processing": "DataTables is currently busy"
  9279. * }
  9280. * } );
  9281. * } );
  9282. */
  9283. "sProcessing": "处理中…",
  9284. /**
  9285. * Details the actions that will be taken when the user types into the
  9286. * filtering input text box. The variable "_INPUT_", if used in the string,
  9287. * is replaced with the HTML text box for the filtering input allowing
  9288. * control over where it appears in the string. If "_INPUT_" is not given
  9289. * then the input box is appended to the string automatically.
  9290. * @type string
  9291. * @default Search:
  9292. *
  9293. * @dtopt Language
  9294. * @name DataTable.defaults.language.search
  9295. *
  9296. * @example
  9297. * // Input text box will be appended at the end automatically
  9298. * $(document).ready( function() {
  9299. * $('#example').dataTable( {
  9300. * "language": {
  9301. * "search": "Filter records:"
  9302. * }
  9303. * } );
  9304. * } );
  9305. *
  9306. * @example
  9307. * // Specify where the filter should appear
  9308. * $(document).ready( function() {
  9309. * $('#example').dataTable( {
  9310. * "language": {
  9311. * "search": "Apply filter _INPUT_ to table"
  9312. * }
  9313. * } );
  9314. * } );
  9315. */
  9316. "sSearch": "查找:",
  9317. /**
  9318. * All of the language information can be stored in a file on the
  9319. * server-side, which DataTables will look up if this parameter is passed.
  9320. * It must store the URL of the language file, which is in a JSON format,
  9321. * and the object has the same properties as the oLanguage object in the
  9322. * initialiser object (i.e. the above parameters). Please refer to one of
  9323. * the example language files to see how this works in action.
  9324. * @type string
  9325. * @default <i>Empty string - i.e. disabled</i>
  9326. *
  9327. * @dtopt Language
  9328. * @name DataTable.defaults.language.url
  9329. *
  9330. * @example
  9331. * $(document).ready( function() {
  9332. * $('#example').dataTable( {
  9333. * "language": {
  9334. * "url": "http://www.sprymedia.co.uk/dataTables/lang.txt"
  9335. * }
  9336. * } );
  9337. * } );
  9338. */
  9339. "sUrl": "",
  9340. /**
  9341. * Text shown inside the table records when the is no information to be
  9342. * displayed after filtering. `emptyTable` is shown when there is simply no
  9343. * information in the table at all (regardless of filtering).
  9344. * @type string
  9345. * @default No matching records found
  9346. *
  9347. * @dtopt Language
  9348. * @name DataTable.defaults.language.zeroRecords
  9349. *
  9350. * @example
  9351. * $(document).ready( function() {
  9352. * $('#example').dataTable( {
  9353. * "language": {
  9354. * "zeroRecords": "No records to display"
  9355. * }
  9356. * } );
  9357. * } );
  9358. */
  9359. "sZeroRecords": "没有找到符合条件的记录"
  9360. },
  9361. /**
  9362. * This parameter allows you to have define the global filtering state at
  9363. * initialisation time. As an object the `search` parameter must be
  9364. * defined, but all other parameters are optional. When `regex` is true,
  9365. * the search string will be treated as a regular expression, when false
  9366. * (default) it will be treated as a straight string. When `smart`
  9367. * DataTables will use it's smart filtering methods (to word match at
  9368. * any point in the data), when false this will not be done.
  9369. * @namespace
  9370. * @extends DataTable.models.oSearch
  9371. *
  9372. * @dtopt Options
  9373. * @name DataTable.defaults.search
  9374. *
  9375. * @example
  9376. * $(document).ready( function() {
  9377. * $('#example').dataTable( {
  9378. * "search": {"search": "Initial search"}
  9379. * } );
  9380. * } )
  9381. */
  9382. "oSearch": $.extend( {}, DataTable.models.oSearch ),
  9383. /**
  9384. * __Deprecated__ The functionality provided by this parameter has now been
  9385. * superseded by that provided through `ajax`, which should be used instead.
  9386. *
  9387. * By default DataTables will look for the property `data` (or `aaData` for
  9388. * compatibility with DataTables 1.9-) when obtaining data from an Ajax
  9389. * source or for server-side processing - this parameter allows that
  9390. * property to be changed. You can use Javascript dotted object notation to
  9391. * get a data source for multiple levels of nesting.
  9392. * @type string
  9393. * @default data
  9394. *
  9395. * @dtopt Options
  9396. * @dtopt Server-side
  9397. * @name DataTable.defaults.ajaxDataProp
  9398. *
  9399. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9400. */
  9401. "sAjaxDataProp": "data",
  9402. /**
  9403. * __Deprecated__ The functionality provided by this parameter has now been
  9404. * superseded by that provided through `ajax`, which should be used instead.
  9405. *
  9406. * You can instruct DataTables to load data from an external
  9407. * source using this parameter (use aData if you want to pass data in you
  9408. * already have). Simply provide a url a JSON object can be obtained from.
  9409. * @type string
  9410. * @default null
  9411. *
  9412. * @dtopt Options
  9413. * @dtopt Server-side
  9414. * @name DataTable.defaults.ajaxSource
  9415. *
  9416. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9417. */
  9418. "sAjaxSource": null,
  9419. /**
  9420. * This initialisation variable allows you to specify exactly where in the
  9421. * DOM you want DataTables to inject the various controls it adds to the page
  9422. * (for example you might want the pagination controls at the top of the
  9423. * table). DIV elements (with or without a custom class) can also be added to
  9424. * aid styling. The follow syntax is used:
  9425. * <ul>
  9426. * <li>The following options are allowed:
  9427. * <ul>
  9428. * <li>'l' - Length changing</li>
  9429. * <li>'f' - Filtering input</li>
  9430. * <li>'t' - The table!</li>
  9431. * <li>'i' - Information</li>
  9432. * <li>'p' - Pagination</li>
  9433. * <li>'r' - pRocessing</li>
  9434. * </ul>
  9435. * </li>
  9436. * <li>The following constants are allowed:
  9437. * <ul>
  9438. * <li>'H' - jQueryUI theme "header" classes ('fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix')</li>
  9439. * <li>'F' - jQueryUI theme "footer" classes ('fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix')</li>
  9440. * </ul>
  9441. * </li>
  9442. * <li>The following syntax is expected:
  9443. * <ul>
  9444. * <li>'&lt;' and '&gt;' - div elements</li>
  9445. * <li>'&lt;"class" and '&gt;' - div with a class</li>
  9446. * <li>'&lt;"#id" and '&gt;' - div with an ID</li>
  9447. * </ul>
  9448. * </li>
  9449. * <li>Examples:
  9450. * <ul>
  9451. * <li>'&lt;"wrapper"flipt&gt;'</li>
  9452. * <li>'&lt;lf&lt;t&gt;ip&gt;'</li>
  9453. * </ul>
  9454. * </li>
  9455. * </ul>
  9456. * @type string
  9457. * @default lfrtip <i>(when `jQueryUI` is false)</i> <b>or</b>
  9458. * <"H"lfr>t<"F"ip> <i>(when `jQueryUI` is true)</i>
  9459. *
  9460. * @dtopt Options
  9461. * @name DataTable.defaults.dom
  9462. *
  9463. * @example
  9464. * $(document).ready( function() {
  9465. * $('#example').dataTable( {
  9466. * "dom": '&lt;"top"i&gt;rt&lt;"bottom"flp&gt;&lt;"clear"&gt;'
  9467. * } );
  9468. * } );
  9469. */
  9470. "sDom": "lfrtip",
  9471. /**
  9472. * DataTables features four different built-in options for the buttons to
  9473. * display for pagination control:
  9474. *
  9475. * * `simple` - 'Previous' and 'Next' buttons only
  9476. * * 'simple_numbers` - 'Previous' and 'Next' buttons, plus page numbers
  9477. * * `full` - 'First', 'Previous', 'Next' and 'Last' buttons
  9478. * * `full_numbers` - 'First', 'Previous', 'Next' and 'Last' buttons, plus
  9479. * page numbers
  9480. *
  9481. * Further methods can be added using {@link DataTable.ext.oPagination}.
  9482. * @type string
  9483. * @default simple_numbers
  9484. *
  9485. * @dtopt Options
  9486. * @name DataTable.defaults.pagingType
  9487. *
  9488. * @example
  9489. * $(document).ready( function() {
  9490. * $('#example').dataTable( {
  9491. * "pagingType": "full_numbers"
  9492. * } );
  9493. * } )
  9494. */
  9495. "sPaginationType": "simple_numbers",
  9496. /**
  9497. * Enable horizontal scrolling. When a table is too wide to fit into a
  9498. * certain layout, or you have a large number of columns in the table, you
  9499. * can enable x-scrolling to show the table in a viewport, which can be
  9500. * scrolled. This property can be `true` which will allow the table to
  9501. * scroll horizontally when needed, or any CSS unit, or a number (in which
  9502. * case it will be treated as a pixel measurement). Setting as simply `true`
  9503. * is recommended.
  9504. * @type boolean|string
  9505. * @default <i>blank string - i.e. disabled</i>
  9506. *
  9507. * @dtopt Features
  9508. * @name DataTable.defaults.scrollX
  9509. *
  9510. * @example
  9511. * $(document).ready( function() {
  9512. * $('#example').dataTable( {
  9513. * "scrollX": true,
  9514. * "scrollCollapse": true
  9515. * } );
  9516. * } );
  9517. */
  9518. "sScrollX": "",
  9519. /**
  9520. * This property can be used to force a DataTable to use more width than it
  9521. * might otherwise do when x-scrolling is enabled. For example if you have a
  9522. * table which requires to be well spaced, this parameter is useful for
  9523. * "over-sizing" the table, and thus forcing scrolling. This property can by
  9524. * any CSS unit, or a number (in which case it will be treated as a pixel
  9525. * measurement).
  9526. * @type string
  9527. * @default <i>blank string - i.e. disabled</i>
  9528. *
  9529. * @dtopt Options
  9530. * @name DataTable.defaults.scrollXInner
  9531. *
  9532. * @example
  9533. * $(document).ready( function() {
  9534. * $('#example').dataTable( {
  9535. * "scrollX": "100%",
  9536. * "scrollXInner": "110%"
  9537. * } );
  9538. * } );
  9539. */
  9540. "sScrollXInner": "",
  9541. /**
  9542. * Enable vertical scrolling. Vertical scrolling will constrain the DataTable
  9543. * to the given height, and enable scrolling for any data which overflows the
  9544. * current viewport. This can be used as an alternative to paging to display
  9545. * a lot of data in a small area (although paging and scrolling can both be
  9546. * enabled at the same time). This property can be any CSS unit, or a number
  9547. * (in which case it will be treated as a pixel measurement).
  9548. * @type string
  9549. * @default <i>blank string - i.e. disabled</i>
  9550. *
  9551. * @dtopt Features
  9552. * @name DataTable.defaults.scrollY
  9553. *
  9554. * @example
  9555. * $(document).ready( function() {
  9556. * $('#example').dataTable( {
  9557. * "scrollY": "200px",
  9558. * "paginate": false
  9559. * } );
  9560. * } );
  9561. */
  9562. "sScrollY": "",
  9563. /**
  9564. * __Deprecated__ The functionality provided by this parameter has now been
  9565. * superseded by that provided through `ajax`, which should be used instead.
  9566. *
  9567. * Set the HTTP method that is used to make the Ajax call for server-side
  9568. * processing or Ajax sourced data.
  9569. * @type string
  9570. * @default GET
  9571. *
  9572. * @dtopt Options
  9573. * @dtopt Server-side
  9574. * @name DataTable.defaults.serverMethod
  9575. *
  9576. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9577. */
  9578. "sServerMethod": "GET",
  9579. /**
  9580. * DataTables makes use of renderers when displaying HTML elements for
  9581. * a table. These renderers can be added or modified by plug-ins to
  9582. * generate suitable mark-up for a site. For example the Bootstrap
  9583. * integration plug-in for DataTables uses a paging button renderer to
  9584. * display pagination buttons in the mark-up required by Bootstrap.
  9585. *
  9586. * For further information about the renderers available see
  9587. * DataTable.ext.renderer
  9588. * @type string|object
  9589. * @default null
  9590. *
  9591. * @name DataTable.defaults.renderer
  9592. *
  9593. */
  9594. "renderer": null
  9595. };
  9596. _fnHungarianMap( DataTable.defaults );
  9597. /*
  9598. * Developer note - See note in model.defaults.js about the use of Hungarian
  9599. * notation and camel case.
  9600. */
  9601. /**
  9602. * Column options that can be given to DataTables at initialisation time.
  9603. * @namespace
  9604. */
  9605. DataTable.defaults.column = {
  9606. /**
  9607. * Define which column(s) an order will occur on for this column. This
  9608. * allows a column's ordering to take multiple columns into account when
  9609. * doing a sort or use the data from a different column. For example first
  9610. * name / last name columns make sense to do a multi-column sort over the
  9611. * two columns.
  9612. * @type array|int
  9613. * @default null <i>Takes the value of the column index automatically</i>
  9614. *
  9615. * @name DataTable.defaults.column.orderData
  9616. * @dtopt Columns
  9617. *
  9618. * @example
  9619. * // Using `columnDefs`
  9620. * $(document).ready( function() {
  9621. * $('#example').dataTable( {
  9622. * "columnDefs": [
  9623. * { "orderData": [ 0, 1 ], "targets": [ 0 ] },
  9624. * { "orderData": [ 1, 0 ], "targets": [ 1 ] },
  9625. * { "orderData": 2, "targets": [ 2 ] }
  9626. * ]
  9627. * } );
  9628. * } );
  9629. *
  9630. * @example
  9631. * // Using `columns`
  9632. * $(document).ready( function() {
  9633. * $('#example').dataTable( {
  9634. * "columns": [
  9635. * { "orderData": [ 0, 1 ] },
  9636. * { "orderData": [ 1, 0 ] },
  9637. * { "orderData": 2 },
  9638. * null,
  9639. * null
  9640. * ]
  9641. * } );
  9642. * } );
  9643. */
  9644. "aDataSort": null,
  9645. "iDataSort": -1,
  9646. /**
  9647. * You can control the default ordering direction, and even alter the
  9648. * behaviour of the sort handler (i.e. only allow ascending ordering etc)
  9649. * using this parameter.
  9650. * @type array
  9651. * @default [ 'asc', 'desc' ]
  9652. *
  9653. * @name DataTable.defaults.column.orderSequence
  9654. * @dtopt Columns
  9655. *
  9656. * @example
  9657. * // Using `columnDefs`
  9658. * $(document).ready( function() {
  9659. * $('#example').dataTable( {
  9660. * "columnDefs": [
  9661. * { "orderSequence": [ "asc" ], "targets": [ 1 ] },
  9662. * { "orderSequence": [ "desc", "asc", "asc" ], "targets": [ 2 ] },
  9663. * { "orderSequence": [ "desc" ], "targets": [ 3 ] }
  9664. * ]
  9665. * } );
  9666. * } );
  9667. *
  9668. * @example
  9669. * // Using `columns`
  9670. * $(document).ready( function() {
  9671. * $('#example').dataTable( {
  9672. * "columns": [
  9673. * null,
  9674. * { "orderSequence": [ "asc" ] },
  9675. * { "orderSequence": [ "desc", "asc", "asc" ] },
  9676. * { "orderSequence": [ "desc" ] },
  9677. * null
  9678. * ]
  9679. * } );
  9680. * } );
  9681. */
  9682. "asSorting": [ 'asc', 'desc' ],
  9683. /**
  9684. * Enable or disable filtering on the data in this column.
  9685. * @type boolean
  9686. * @default true
  9687. *
  9688. * @name DataTable.defaults.column.searchable
  9689. * @dtopt Columns
  9690. *
  9691. * @example
  9692. * // Using `columnDefs`
  9693. * $(document).ready( function() {
  9694. * $('#example').dataTable( {
  9695. * "columnDefs": [
  9696. * { "searchable": false, "targets": [ 0 ] }
  9697. * ] } );
  9698. * } );
  9699. *
  9700. * @example
  9701. * // Using `columns`
  9702. * $(document).ready( function() {
  9703. * $('#example').dataTable( {
  9704. * "columns": [
  9705. * { "searchable": false },
  9706. * null,
  9707. * null,
  9708. * null,
  9709. * null
  9710. * ] } );
  9711. * } );
  9712. */
  9713. "bSearchable": true,
  9714. /**
  9715. * Enable or disable ordering on this column.
  9716. * @type boolean
  9717. * @default true
  9718. *
  9719. * @name DataTable.defaults.column.orderable
  9720. * @dtopt Columns
  9721. *
  9722. * @example
  9723. * // Using `columnDefs`
  9724. * $(document).ready( function() {
  9725. * $('#example').dataTable( {
  9726. * "columnDefs": [
  9727. * { "orderable": false, "targets": [ 0 ] }
  9728. * ] } );
  9729. * } );
  9730. *
  9731. * @example
  9732. * // Using `columns`
  9733. * $(document).ready( function() {
  9734. * $('#example').dataTable( {
  9735. * "columns": [
  9736. * { "orderable": false },
  9737. * null,
  9738. * null,
  9739. * null,
  9740. * null
  9741. * ] } );
  9742. * } );
  9743. */
  9744. "bSortable": true,
  9745. /**
  9746. * Enable or disable the display of this column.
  9747. * @type boolean
  9748. * @default true
  9749. *
  9750. * @name DataTable.defaults.column.visible
  9751. * @dtopt Columns
  9752. *
  9753. * @example
  9754. * // Using `columnDefs`
  9755. * $(document).ready( function() {
  9756. * $('#example').dataTable( {
  9757. * "columnDefs": [
  9758. * { "visible": false, "targets": [ 0 ] }
  9759. * ] } );
  9760. * } );
  9761. *
  9762. * @example
  9763. * // Using `columns`
  9764. * $(document).ready( function() {
  9765. * $('#example').dataTable( {
  9766. * "columns": [
  9767. * { "visible": false },
  9768. * null,
  9769. * null,
  9770. * null,
  9771. * null
  9772. * ] } );
  9773. * } );
  9774. */
  9775. "bVisible": true,
  9776. /**
  9777. * Developer definable function that is called whenever a cell is created (Ajax source,
  9778. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  9779. * allowing you to modify the DOM element (add background colour for example) when the
  9780. * element is available.
  9781. * @type function
  9782. * @param {element} td The TD node that has been created
  9783. * @param {*} cellData The Data for the cell
  9784. * @param {array|object} rowData The data for the whole row
  9785. * @param {int} row The row index for the aoData data store
  9786. * @param {int} col The column index for aoColumns
  9787. *
  9788. * @name DataTable.defaults.column.createdCell
  9789. * @dtopt Columns
  9790. *
  9791. * @example
  9792. * $(document).ready( function() {
  9793. * $('#example').dataTable( {
  9794. * "columnDefs": [ {
  9795. * "targets": [3],
  9796. * "createdCell": function (td, cellData, rowData, row, col) {
  9797. * if ( cellData == "1.7" ) {
  9798. * $(td).css('color', 'blue')
  9799. * }
  9800. * }
  9801. * } ]
  9802. * });
  9803. * } );
  9804. */
  9805. "fnCreatedCell": null,
  9806. /**
  9807. * This parameter has been replaced by `data` in DataTables to ensure naming
  9808. * consistency. `dataProp` can still be used, as there is backwards
  9809. * compatibility in DataTables for this option, but it is strongly
  9810. * recommended that you use `data` in preference to `dataProp`.
  9811. * @name DataTable.defaults.column.dataProp
  9812. */
  9813. /**
  9814. * This property can be used to read data from any data source property,
  9815. * including deeply nested objects / properties. `data` can be given in a
  9816. * number of different ways which effect its behaviour:
  9817. *
  9818. * * `integer` - treated as an array index for the data source. This is the
  9819. * default that DataTables uses (incrementally increased for each column).
  9820. * * `string` - read an object property from the data source. There are
  9821. * three 'special' options that can be used in the string to alter how
  9822. * DataTables reads the data from the source object:
  9823. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  9824. * Javascript to read from nested objects, so to can the options
  9825. * specified in `data`. For example: `browser.version` or
  9826. * `browser.name`. If your object parameter name contains a period, use
  9827. * `\\` to escape it - i.e. `first\\.name`.
  9828. * * `[]` - Array notation. DataTables can automatically combine data
  9829. * from and array source, joining the data with the characters provided
  9830. * between the two brackets. For example: `name[, ]` would provide a
  9831. * comma-space separated list from the source array. If no characters
  9832. * are provided between the brackets, the original array source is
  9833. * returned.
  9834. * * `()` - Function notation. Adding `()` to the end of a parameter will
  9835. * execute a function of the name given. For example: `browser()` for a
  9836. * simple function on the data source, `browser.version()` for a
  9837. * function in a nested property or even `browser().version` to get an
  9838. * object property if the function called returns an object. Note that
  9839. * function notation is recommended for use in `render` rather than
  9840. * `data` as it is much simpler to use as a renderer.
  9841. * * `null` - use the original data source for the row rather than plucking
  9842. * data directly from it. This action has effects on two other
  9843. * initialisation options:
  9844. * * `defaultContent` - When null is given as the `data` option and
  9845. * `defaultContent` is specified for the column, the value defined by
  9846. * `defaultContent` will be used for the cell.
  9847. * * `render` - When null is used for the `data` option and the `render`
  9848. * option is specified for the column, the whole data source for the
  9849. * row is used for the renderer.
  9850. * * `function` - the function given will be executed whenever DataTables
  9851. * needs to set or get the data for a cell in the column. The function
  9852. * takes three parameters:
  9853. * * Parameters:
  9854. * * `{array|object}` The data source for the row
  9855. * * `{string}` The type call data requested - this will be 'set' when
  9856. * setting data or 'filter', 'display', 'type', 'sort' or undefined
  9857. * when gathering data. Note that when `undefined` is given for the
  9858. * type DataTables expects to get the raw data for the object back<
  9859. * * `{*}` Data to set when the second parameter is 'set'.
  9860. * * Return:
  9861. * * The return value from the function is not required when 'set' is
  9862. * the type of call, but otherwise the return is what will be used
  9863. * for the data requested.
  9864. *
  9865. * Note that `data` is a getter and setter option. If you just require
  9866. * formatting of data for output, you will likely want to use `render` which
  9867. * is simply a getter and thus simpler to use.
  9868. *
  9869. * Note that prior to DataTables 1.9.2 `data` was called `mDataProp`. The
  9870. * name change reflects the flexibility of this property and is consistent
  9871. * with the naming of mRender. If 'mDataProp' is given, then it will still
  9872. * be used by DataTables, as it automatically maps the old name to the new
  9873. * if required.
  9874. *
  9875. * @type string|int|function|null
  9876. * @default null <i>Use automatically calculated column index</i>
  9877. *
  9878. * @name DataTable.defaults.column.data
  9879. * @dtopt Columns
  9880. *
  9881. * @example
  9882. * // Read table data from objects
  9883. * // JSON structure for each row:
  9884. * // {
  9885. * // "engine": {value},
  9886. * // "browser": {value},
  9887. * // "platform": {value},
  9888. * // "version": {value},
  9889. * // "grade": {value}
  9890. * // }
  9891. * $(document).ready( function() {
  9892. * $('#example').dataTable( {
  9893. * "ajaxSource": "sources/objects.txt",
  9894. * "columns": [
  9895. * { "data": "engine" },
  9896. * { "data": "browser" },
  9897. * { "data": "platform" },
  9898. * { "data": "version" },
  9899. * { "data": "grade" }
  9900. * ]
  9901. * } );
  9902. * } );
  9903. *
  9904. * @example
  9905. * // Read information from deeply nested objects
  9906. * // JSON structure for each row:
  9907. * // {
  9908. * // "engine": {value},
  9909. * // "browser": {value},
  9910. * // "platform": {
  9911. * // "inner": {value}
  9912. * // },
  9913. * // "details": [
  9914. * // {value}, {value}
  9915. * // ]
  9916. * // }
  9917. * $(document).ready( function() {
  9918. * $('#example').dataTable( {
  9919. * "ajaxSource": "sources/deep.txt",
  9920. * "columns": [
  9921. * { "data": "engine" },
  9922. * { "data": "browser" },
  9923. * { "data": "platform.inner" },
  9924. * { "data": "platform.details.0" },
  9925. * { "data": "platform.details.1" }
  9926. * ]
  9927. * } );
  9928. * } );
  9929. *
  9930. * @example
  9931. * // Using `data` as a function to provide different information for
  9932. * // sorting, filtering and display. In this case, currency (price)
  9933. * $(document).ready( function() {
  9934. * $('#example').dataTable( {
  9935. * "columnDefs": [ {
  9936. * "targets": [ 0 ],
  9937. * "data": function ( source, type, val ) {
  9938. * if (type === 'set') {
  9939. * source.price = val;
  9940. * // Store the computed dislay and filter values for efficiency
  9941. * source.price_display = val=="" ? "" : "$"+numberFormat(val);
  9942. * source.price_filter = val=="" ? "" : "$"+numberFormat(val)+" "+val;
  9943. * return;
  9944. * }
  9945. * else if (type === 'display') {
  9946. * return source.price_display;
  9947. * }
  9948. * else if (type === 'filter') {
  9949. * return source.price_filter;
  9950. * }
  9951. * // 'sort', 'type' and undefined all just use the integer
  9952. * return source.price;
  9953. * }
  9954. * } ]
  9955. * } );
  9956. * } );
  9957. *
  9958. * @example
  9959. * // Using default content
  9960. * $(document).ready( function() {
  9961. * $('#example').dataTable( {
  9962. * "columnDefs": [ {
  9963. * "targets": [ 0 ],
  9964. * "data": null,
  9965. * "defaultContent": "Click to edit"
  9966. * } ]
  9967. * } );
  9968. * } );
  9969. *
  9970. * @example
  9971. * // Using array notation - outputting a list from an array
  9972. * $(document).ready( function() {
  9973. * $('#example').dataTable( {
  9974. * "columnDefs": [ {
  9975. * "targets": [ 0 ],
  9976. * "data": "name[, ]"
  9977. * } ]
  9978. * } );
  9979. * } );
  9980. *
  9981. */
  9982. "mData": null,
  9983. /**
  9984. * This property is the rendering partner to `data` and it is suggested that
  9985. * when you want to manipulate data for display (including filtering,
  9986. * sorting etc) without altering the underlying data for the table, use this
  9987. * property. `render` can be considered to be the the read only companion to
  9988. * `data` which is read / write (then as such more complex). Like `data`
  9989. * this option can be given in a number of different ways to effect its
  9990. * behaviour:
  9991. *
  9992. * * `integer` - treated as an array index for the data source. This is the
  9993. * default that DataTables uses (incrementally increased for each column).
  9994. * * `string` - read an object property from the data source. There are
  9995. * three 'special' options that can be used in the string to alter how
  9996. * DataTables reads the data from the source object:
  9997. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  9998. * Javascript to read from nested objects, so to can the options
  9999. * specified in `data`. For example: `browser.version` or
  10000. * `browser.name`. If your object parameter name contains a period, use
  10001. * `\\` to escape it - i.e. `first\\.name`.
  10002. * * `[]` - Array notation. DataTables can automatically combine data
  10003. * from and array source, joining the data with the characters provided
  10004. * between the two brackets. For example: `name[, ]` would provide a
  10005. * comma-space separated list from the source array. If no characters
  10006. * are provided between the brackets, the original array source is
  10007. * returned.
  10008. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10009. * execute a function of the name given. For example: `browser()` for a
  10010. * simple function on the data source, `browser.version()` for a
  10011. * function in a nested property or even `browser().version` to get an
  10012. * object property if the function called returns an object.
  10013. * * `object` - use different data for the different data types requested by
  10014. * DataTables ('filter', 'display', 'type' or 'sort'). The property names
  10015. * of the object is the data type the property refers to and the value can
  10016. * defined using an integer, string or function using the same rules as
  10017. * `render` normally does. Note that an `_` option _must_ be specified.
  10018. * This is the default value to use if you haven't specified a value for
  10019. * the data type requested by DataTables.
  10020. * * `function` - the function given will be executed whenever DataTables
  10021. * needs to set or get the data for a cell in the column. The function
  10022. * takes three parameters:
  10023. * * Parameters:
  10024. * * {array|object} The data source for the row (based on `data`)
  10025. * * {string} The type call data requested - this will be 'filter',
  10026. * 'display', 'type' or 'sort'.
  10027. * * {array|object} The full data source for the row (not based on
  10028. * `data`)
  10029. * * Return:
  10030. * * The return value from the function is what will be used for the
  10031. * data requested.
  10032. *
  10033. * @type string|int|function|object|null
  10034. * @default null Use the data source value.
  10035. *
  10036. * @name DataTable.defaults.column.render
  10037. * @dtopt Columns
  10038. *
  10039. * @example
  10040. * // Create a comma separated list from an array of objects
  10041. * $(document).ready( function() {
  10042. * $('#example').dataTable( {
  10043. * "ajaxSource": "sources/deep.txt",
  10044. * "columns": [
  10045. * { "data": "engine" },
  10046. * { "data": "browser" },
  10047. * {
  10048. * "data": "platform",
  10049. * "render": "[, ].name"
  10050. * }
  10051. * ]
  10052. * } );
  10053. * } );
  10054. *
  10055. * @example
  10056. * // Execute a function to obtain data
  10057. * $(document).ready( function() {
  10058. * $('#example').dataTable( {
  10059. * "columnDefs": [ {
  10060. * "targets": [ 0 ],
  10061. * "data": null, // Use the full data source object for the renderer's source
  10062. * "render": "browserName()"
  10063. * } ]
  10064. * } );
  10065. * } );
  10066. *
  10067. * @example
  10068. * // As an object, extracting different data for the different types
  10069. * // This would be used with a data source such as:
  10070. * // { "phone": 5552368, "phone_filter": "5552368 555-2368", "phone_display": "555-2368" }
  10071. * // Here the `phone` integer is used for sorting and type detection, while `phone_filter`
  10072. * // (which has both forms) is used for filtering for if a user inputs either format, while
  10073. * // the formatted phone number is the one that is shown in the table.
  10074. * $(document).ready( function() {
  10075. * $('#example').dataTable( {
  10076. * "columnDefs": [ {
  10077. * "targets": [ 0 ],
  10078. * "data": null, // Use the full data source object for the renderer's source
  10079. * "render": {
  10080. * "_": "phone",
  10081. * "filter": "phone_filter",
  10082. * "display": "phone_display"
  10083. * }
  10084. * } ]
  10085. * } );
  10086. * } );
  10087. *
  10088. * @example
  10089. * // Use as a function to create a link from the data source
  10090. * $(document).ready( function() {
  10091. * $('#example').dataTable( {
  10092. * "columnDefs": [ {
  10093. * "targets": [ 0 ],
  10094. * "data": "download_link",
  10095. * "render": function ( data, type, full ) {
  10096. * return '<a href="'+data+'">Download</a>';
  10097. * }
  10098. * } ]
  10099. * } );
  10100. * } );
  10101. */
  10102. "mRender": null,
  10103. /**
  10104. * Change the cell type created for the column - either TD cells or TH cells. This
  10105. * can be useful as TH cells have semantic meaning in the table body, allowing them
  10106. * to act as a header for a row (you may wish to add scope='row' to the TH elements).
  10107. * @type string
  10108. * @default td
  10109. *
  10110. * @name DataTable.defaults.column.cellType
  10111. * @dtopt Columns
  10112. *
  10113. * @example
  10114. * // Make the first column use TH cells
  10115. * $(document).ready( function() {
  10116. * $('#example').dataTable( {
  10117. * "columnDefs": [ {
  10118. * "targets": [ 0 ],
  10119. * "cellType": "th"
  10120. * } ]
  10121. * } );
  10122. * } );
  10123. */
  10124. "sCellType": "td",
  10125. /**
  10126. * Class to give to each cell in this column.
  10127. * @type string
  10128. * @default <i>Empty string</i>
  10129. *
  10130. * @name DataTable.defaults.column.class
  10131. * @dtopt Columns
  10132. *
  10133. * @example
  10134. * // Using `columnDefs`
  10135. * $(document).ready( function() {
  10136. * $('#example').dataTable( {
  10137. * "columnDefs": [
  10138. * { "class": "my_class", "targets": [ 0 ] }
  10139. * ]
  10140. * } );
  10141. * } );
  10142. *
  10143. * @example
  10144. * // Using `columns`
  10145. * $(document).ready( function() {
  10146. * $('#example').dataTable( {
  10147. * "columns": [
  10148. * { "class": "my_class" },
  10149. * null,
  10150. * null,
  10151. * null,
  10152. * null
  10153. * ]
  10154. * } );
  10155. * } );
  10156. */
  10157. "sClass": "",
  10158. /**
  10159. * When DataTables calculates the column widths to assign to each column,
  10160. * it finds the longest string in each column and then constructs a
  10161. * temporary table and reads the widths from that. The problem with this
  10162. * is that "mmm" is much wider then "iiii", but the latter is a longer
  10163. * string - thus the calculation can go wrong (doing it properly and putting
  10164. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  10165. * a "work around" we provide this option. It will append its value to the
  10166. * text that is found to be the longest string for the column - i.e. padding.
  10167. * Generally you shouldn't need this!
  10168. * @type string
  10169. * @default <i>Empty string<i>
  10170. *
  10171. * @name DataTable.defaults.column.contentPadding
  10172. * @dtopt Columns
  10173. *
  10174. * @example
  10175. * // Using `columns`
  10176. * $(document).ready( function() {
  10177. * $('#example').dataTable( {
  10178. * "columns": [
  10179. * null,
  10180. * null,
  10181. * null,
  10182. * {
  10183. * "contentPadding": "mmm"
  10184. * }
  10185. * ]
  10186. * } );
  10187. * } );
  10188. */
  10189. "sContentPadding": "",
  10190. /**
  10191. * Allows a default value to be given for a column's data, and will be used
  10192. * whenever a null data source is encountered (this can be because `data`
  10193. * is set to null, or because the data source itself is null).
  10194. * @type string
  10195. * @default null
  10196. *
  10197. * @name DataTable.defaults.column.defaultContent
  10198. * @dtopt Columns
  10199. *
  10200. * @example
  10201. * // Using `columnDefs`
  10202. * $(document).ready( function() {
  10203. * $('#example').dataTable( {
  10204. * "columnDefs": [
  10205. * {
  10206. * "data": null,
  10207. * "defaultContent": "Edit",
  10208. * "targets": [ -1 ]
  10209. * }
  10210. * ]
  10211. * } );
  10212. * } );
  10213. *
  10214. * @example
  10215. * // Using `columns`
  10216. * $(document).ready( function() {
  10217. * $('#example').dataTable( {
  10218. * "columns": [
  10219. * null,
  10220. * null,
  10221. * null,
  10222. * {
  10223. * "data": null,
  10224. * "defaultContent": "Edit"
  10225. * }
  10226. * ]
  10227. * } );
  10228. * } );
  10229. */
  10230. "sDefaultContent": null,
  10231. /**
  10232. * This parameter is only used in DataTables' server-side processing. It can
  10233. * be exceptionally useful to know what columns are being displayed on the
  10234. * client side, and to map these to database fields. When defined, the names
  10235. * also allow DataTables to reorder information from the server if it comes
  10236. * back in an unexpected order (i.e. if you switch your columns around on the
  10237. * client-side, your server-side code does not also need updating).
  10238. * @type string
  10239. * @default <i>Empty string</i>
  10240. *
  10241. * @name DataTable.defaults.column.name
  10242. * @dtopt Columns
  10243. *
  10244. * @example
  10245. * // Using `columnDefs`
  10246. * $(document).ready( function() {
  10247. * $('#example').dataTable( {
  10248. * "columnDefs": [
  10249. * { "name": "engine", "targets": [ 0 ] },
  10250. * { "name": "browser", "targets": [ 1 ] },
  10251. * { "name": "platform", "targets": [ 2 ] },
  10252. * { "name": "version", "targets": [ 3 ] },
  10253. * { "name": "grade", "targets": [ 4 ] }
  10254. * ]
  10255. * } );
  10256. * } );
  10257. *
  10258. * @example
  10259. * // Using `columns`
  10260. * $(document).ready( function() {
  10261. * $('#example').dataTable( {
  10262. * "columns": [
  10263. * { "name": "engine" },
  10264. * { "name": "browser" },
  10265. * { "name": "platform" },
  10266. * { "name": "version" },
  10267. * { "name": "grade" }
  10268. * ]
  10269. * } );
  10270. * } );
  10271. */
  10272. "sName": "",
  10273. /**
  10274. * Defines a data source type for the ordering which can be used to read
  10275. * real-time information from the table (updating the internally cached
  10276. * version) prior to ordering. This allows ordering to occur on user
  10277. * editable elements such as form inputs.
  10278. * @type string
  10279. * @default std
  10280. *
  10281. * @name DataTable.defaults.column.orderDataType
  10282. * @dtopt Columns
  10283. *
  10284. * @example
  10285. * // Using `columnDefs`
  10286. * $(document).ready( function() {
  10287. * $('#example').dataTable( {
  10288. * "columnDefs": [
  10289. * { "orderDataType": "dom-text", "targets": [ 2, 3 ] },
  10290. * { "type": "numeric", "targets": [ 3 ] },
  10291. * { "orderDataType": "dom-select", "targets": [ 4 ] },
  10292. * { "orderDataType": "dom-checkbox", "targets": [ 5 ] }
  10293. * ]
  10294. * } );
  10295. * } );
  10296. *
  10297. * @example
  10298. * // Using `columns`
  10299. * $(document).ready( function() {
  10300. * $('#example').dataTable( {
  10301. * "columns": [
  10302. * null,
  10303. * null,
  10304. * { "orderDataType": "dom-text" },
  10305. * { "orderDataType": "dom-text", "type": "numeric" },
  10306. * { "orderDataType": "dom-select" },
  10307. * { "orderDataType": "dom-checkbox" }
  10308. * ]
  10309. * } );
  10310. * } );
  10311. */
  10312. "sSortDataType": "std",
  10313. /**
  10314. * The title of this column.
  10315. * @type string
  10316. * @default null <i>Derived from the 'TH' value for this column in the
  10317. * original HTML table.</i>
  10318. *
  10319. * @name DataTable.defaults.column.title
  10320. * @dtopt Columns
  10321. *
  10322. * @example
  10323. * // Using `columnDefs`
  10324. * $(document).ready( function() {
  10325. * $('#example').dataTable( {
  10326. * "columnDefs": [
  10327. * { "title": "My column title", "targets": [ 0 ] }
  10328. * ]
  10329. * } );
  10330. * } );
  10331. *
  10332. * @example
  10333. * // Using `columns`
  10334. * $(document).ready( function() {
  10335. * $('#example').dataTable( {
  10336. * "columns": [
  10337. * { "title": "My column title" },
  10338. * null,
  10339. * null,
  10340. * null,
  10341. * null
  10342. * ]
  10343. * } );
  10344. * } );
  10345. */
  10346. "sTitle": null,
  10347. /**
  10348. * The type allows you to specify how the data for this column will be
  10349. * ordered. Four types (string, numeric, date and html (which will strip
  10350. * HTML tags before ordering)) are currently available. Note that only date
  10351. * formats understood by Javascript's Date() object will be accepted as type
  10352. * date. For example: "Mar 26, 2008 5:03 PM". May take the values: 'string',
  10353. * 'numeric', 'date' or 'html' (by default). Further types can be adding
  10354. * through plug-ins.
  10355. * @type string
  10356. * @default null <i>Auto-detected from raw data</i>
  10357. *
  10358. * @name DataTable.defaults.column.type
  10359. * @dtopt Columns
  10360. *
  10361. * @example
  10362. * // Using `columnDefs`
  10363. * $(document).ready( function() {
  10364. * $('#example').dataTable( {
  10365. * "columnDefs": [
  10366. * { "type": "html", "targets": [ 0 ] }
  10367. * ]
  10368. * } );
  10369. * } );
  10370. *
  10371. * @example
  10372. * // Using `columns`
  10373. * $(document).ready( function() {
  10374. * $('#example').dataTable( {
  10375. * "columns": [
  10376. * { "type": "html" },
  10377. * null,
  10378. * null,
  10379. * null,
  10380. * null
  10381. * ]
  10382. * } );
  10383. * } );
  10384. */
  10385. "sType": null,
  10386. /**
  10387. * Defining the width of the column, this parameter may take any CSS value
  10388. * (3em, 20px etc). DataTables applies 'smart' widths to columns which have not
  10389. * been given a specific width through this interface ensuring that the table
  10390. * remains readable.
  10391. * @type string
  10392. * @default null <i>Automatic</i>
  10393. *
  10394. * @name DataTable.defaults.column.width
  10395. * @dtopt Columns
  10396. *
  10397. * @example
  10398. * // Using `columnDefs`
  10399. * $(document).ready( function() {
  10400. * $('#example').dataTable( {
  10401. * "columnDefs": [
  10402. * { "width": "20%", "targets": [ 0 ] }
  10403. * ]
  10404. * } );
  10405. * } );
  10406. *
  10407. * @example
  10408. * // Using `columns`
  10409. * $(document).ready( function() {
  10410. * $('#example').dataTable( {
  10411. * "columns": [
  10412. * { "width": "20%" },
  10413. * null,
  10414. * null,
  10415. * null,
  10416. * null
  10417. * ]
  10418. * } );
  10419. * } );
  10420. */
  10421. "sWidth": null
  10422. };
  10423. _fnHungarianMap( DataTable.defaults.column );
  10424. /**
  10425. * DataTables settings object - this holds all the information needed for a
  10426. * given table, including configuration, data and current application of the
  10427. * table options. DataTables does not have a single instance for each DataTable
  10428. * with the settings attached to that instance, but rather instances of the
  10429. * DataTable "class" are created on-the-fly as needed (typically by a
  10430. * $().dataTable() call) and the settings object is then applied to that
  10431. * instance.
  10432. *
  10433. * Note that this object is related to {@link DataTable.defaults} but this
  10434. * one is the internal data store for DataTables's cache of columns. It should
  10435. * NOT be manipulated outside of DataTables. Any configuration should be done
  10436. * through the initialisation options.
  10437. * @namespace
  10438. * @todo Really should attach the settings object to individual instances so we
  10439. * don't need to create new instances on each $().dataTable() call (if the
  10440. * table already exists). It would also save passing oSettings around and
  10441. * into every single function. However, this is a very significant
  10442. * architecture change for DataTables and will almost certainly break
  10443. * backwards compatibility with older installations. This is something that
  10444. * will be done in 2.0.
  10445. */
  10446. DataTable.models.oSettings = {
  10447. /**
  10448. * Primary features of DataTables and their enablement state.
  10449. * @namespace
  10450. */
  10451. "oFeatures": {
  10452. /**
  10453. * Flag to say if DataTables should automatically try to calculate the
  10454. * optimum table and columns widths (true) or not (false).
  10455. * Note that this parameter will be set by the initialisation routine. To
  10456. * set a default use {@link DataTable.defaults}.
  10457. * @type boolean
  10458. */
  10459. "bAutoWidth": null,
  10460. /**
  10461. * Delay the creation of TR and TD elements until they are actually
  10462. * needed by a driven page draw. This can give a significant speed
  10463. * increase for Ajax source and Javascript source data, but makes no
  10464. * difference at all fro DOM and server-side processing tables.
  10465. * Note that this parameter will be set by the initialisation routine. To
  10466. * set a default use {@link DataTable.defaults}.
  10467. * @type boolean
  10468. */
  10469. "bDeferRender": null,
  10470. /**
  10471. * Enable filtering on the table or not. Note that if this is disabled
  10472. * then there is no filtering at all on the table, including fnFilter.
  10473. * To just remove the filtering input use sDom and remove the 'f' option.
  10474. * Note that this parameter will be set by the initialisation routine. To
  10475. * set a default use {@link DataTable.defaults}.
  10476. * @type boolean
  10477. */
  10478. "bFilter": null,
  10479. /**
  10480. * Table information element (the 'Showing x of y records' div) enable
  10481. * flag.
  10482. * Note that this parameter will be set by the initialisation routine. To
  10483. * set a default use {@link DataTable.defaults}.
  10484. * @type boolean
  10485. */
  10486. "bInfo": null,
  10487. /**
  10488. * Present a user control allowing the end user to change the page size
  10489. * when pagination is enabled.
  10490. * Note that this parameter will be set by the initialisation routine. To
  10491. * set a default use {@link DataTable.defaults}.
  10492. * @type boolean
  10493. */
  10494. "bLengthChange": null,
  10495. /**
  10496. * Pagination enabled or not. Note that if this is disabled then length
  10497. * changing must also be disabled.
  10498. * Note that this parameter will be set by the initialisation routine. To
  10499. * set a default use {@link DataTable.defaults}.
  10500. * @type boolean
  10501. */
  10502. "bPaginate": null,
  10503. /**
  10504. * Processing indicator enable flag whenever DataTables is enacting a
  10505. * user request - typically an Ajax request for server-side processing.
  10506. * Note that this parameter will be set by the initialisation routine. To
  10507. * set a default use {@link DataTable.defaults}.
  10508. * @type boolean
  10509. */
  10510. "bProcessing": null,
  10511. /**
  10512. * Server-side processing enabled flag - when enabled DataTables will
  10513. * get all data from the server for every draw - there is no filtering,
  10514. * sorting or paging done on the client-side.
  10515. * Note that this parameter will be set by the initialisation routine. To
  10516. * set a default use {@link DataTable.defaults}.
  10517. * @type boolean
  10518. */
  10519. "bServerSide": null,
  10520. /**
  10521. * Sorting enablement flag.
  10522. * Note that this parameter will be set by the initialisation routine. To
  10523. * set a default use {@link DataTable.defaults}.
  10524. * @type boolean
  10525. */
  10526. "bSort": null,
  10527. /**
  10528. * Multi-column sorting
  10529. * Note that this parameter will be set by the initialisation routine. To
  10530. * set a default use {@link DataTable.defaults}.
  10531. * @type boolean
  10532. */
  10533. "bSortMulti": null,
  10534. /**
  10535. * Apply a class to the columns which are being sorted to provide a
  10536. * visual highlight or not. This can slow things down when enabled since
  10537. * there is a lot of DOM interaction.
  10538. * Note that this parameter will be set by the initialisation routine. To
  10539. * set a default use {@link DataTable.defaults}.
  10540. * @type boolean
  10541. */
  10542. "bSortClasses": null,
  10543. /**
  10544. * State saving enablement flag.
  10545. * Note that this parameter will be set by the initialisation routine. To
  10546. * set a default use {@link DataTable.defaults}.
  10547. * @type boolean
  10548. */
  10549. "bStateSave": null
  10550. },
  10551. /**
  10552. * Scrolling settings for a table.
  10553. * @namespace
  10554. */
  10555. "oScroll": {
  10556. /**
  10557. * When the table is shorter in height than sScrollY, collapse the
  10558. * table container down to the height of the table (when true).
  10559. * Note that this parameter will be set by the initialisation routine. To
  10560. * set a default use {@link DataTable.defaults}.
  10561. * @type boolean
  10562. */
  10563. "bCollapse": null,
  10564. /**
  10565. * Width of the scrollbar for the web-browser's platform. Calculated
  10566. * during table initialisation.
  10567. * @type int
  10568. * @default 0
  10569. */
  10570. "iBarWidth": 0,
  10571. /**
  10572. * Viewport width for horizontal scrolling. Horizontal scrolling is
  10573. * disabled if an empty string.
  10574. * Note that this parameter will be set by the initialisation routine. To
  10575. * set a default use {@link DataTable.defaults}.
  10576. * @type string
  10577. */
  10578. "sX": null,
  10579. /**
  10580. * Width to expand the table to when using x-scrolling. Typically you
  10581. * should not need to use this.
  10582. * Note that this parameter will be set by the initialisation routine. To
  10583. * set a default use {@link DataTable.defaults}.
  10584. * @type string
  10585. * @deprecated
  10586. */
  10587. "sXInner": null,
  10588. /**
  10589. * Viewport height for vertical scrolling. Vertical scrolling is disabled
  10590. * if an empty string.
  10591. * Note that this parameter will be set by the initialisation routine. To
  10592. * set a default use {@link DataTable.defaults}.
  10593. * @type string
  10594. */
  10595. "sY": null
  10596. },
  10597. /**
  10598. * Language information for the table.
  10599. * @namespace
  10600. * @extends DataTable.defaults.oLanguage
  10601. */
  10602. "oLanguage": {
  10603. /**
  10604. * Information callback function. See
  10605. * {@link DataTable.defaults.fnInfoCallback}
  10606. * @type function
  10607. * @default null
  10608. */
  10609. "fnInfoCallback": null
  10610. },
  10611. /**
  10612. * Browser support parameters
  10613. * @namespace
  10614. */
  10615. "oBrowser": {
  10616. /**
  10617. * Indicate if the browser incorrectly calculates width:100% inside a
  10618. * scrolling element (IE6/7)
  10619. * @type boolean
  10620. * @default false
  10621. */
  10622. "bScrollOversize": false,
  10623. /**
  10624. * Determine if the vertical scrollbar is on the right or left of the
  10625. * scrolling container - needed for rtl language layout, although not
  10626. * all browsers move the scrollbar (Safari).
  10627. * @type boolean
  10628. * @default false
  10629. */
  10630. "bScrollbarLeft": false
  10631. },
  10632. "ajax": null,
  10633. /**
  10634. * Array referencing the nodes which are used for the features. The
  10635. * parameters of this object match what is allowed by sDom - i.e.
  10636. * <ul>
  10637. * <li>'l' - Length changing</li>
  10638. * <li>'f' - Filtering input</li>
  10639. * <li>'t' - The table!</li>
  10640. * <li>'i' - Information</li>
  10641. * <li>'p' - Pagination</li>
  10642. * <li>'r' - pRocessing</li>
  10643. * </ul>
  10644. * @type array
  10645. * @default []
  10646. */
  10647. "aanFeatures": [],
  10648. /**
  10649. * Store data information - see {@link DataTable.models.oRow} for detailed
  10650. * information.
  10651. * @type array
  10652. * @default []
  10653. */
  10654. "aoData": [],
  10655. /**
  10656. * Array of indexes which are in the current display (after filtering etc)
  10657. * @type array
  10658. * @default []
  10659. */
  10660. "aiDisplay": [],
  10661. /**
  10662. * Array of indexes for display - no filtering
  10663. * @type array
  10664. * @default []
  10665. */
  10666. "aiDisplayMaster": [],
  10667. /**
  10668. * Store information about each column that is in use
  10669. * @type array
  10670. * @default []
  10671. */
  10672. "aoColumns": [],
  10673. /**
  10674. * Store information about the table's header
  10675. * @type array
  10676. * @default []
  10677. */
  10678. "aoHeader": [],
  10679. /**
  10680. * Store information about the table's footer
  10681. * @type array
  10682. * @default []
  10683. */
  10684. "aoFooter": [],
  10685. /**
  10686. * Store the applied global search information in case we want to force a
  10687. * research or compare the old search to a new one.
  10688. * Note that this parameter will be set by the initialisation routine. To
  10689. * set a default use {@link DataTable.defaults}.
  10690. * @namespace
  10691. * @extends DataTable.models.oSearch
  10692. */
  10693. "oPreviousSearch": {},
  10694. /**
  10695. * Store the applied search for each column - see
  10696. * {@link DataTable.models.oSearch} for the format that is used for the
  10697. * filtering information for each column.
  10698. * @type array
  10699. * @default []
  10700. */
  10701. "aoPreSearchCols": [],
  10702. /**
  10703. * Sorting that is applied to the table. Note that the inner arrays are
  10704. * used in the following manner:
  10705. * <ul>
  10706. * <li>Index 0 - column number</li>
  10707. * <li>Index 1 - current sorting direction</li>
  10708. * </ul>
  10709. * Note that this parameter will be set by the initialisation routine. To
  10710. * set a default use {@link DataTable.defaults}.
  10711. * @type array
  10712. * @todo These inner arrays should really be objects
  10713. */
  10714. "aaSorting": null,
  10715. /**
  10716. * Sorting that is always applied to the table (i.e. prefixed in front of
  10717. * aaSorting).
  10718. * Note that this parameter will be set by the initialisation routine. To
  10719. * set a default use {@link DataTable.defaults}.
  10720. * @type array
  10721. * @default []
  10722. */
  10723. "aaSortingFixed": [],
  10724. /**
  10725. * Classes to use for the striping of a table.
  10726. * Note that this parameter will be set by the initialisation routine. To
  10727. * set a default use {@link DataTable.defaults}.
  10728. * @type array
  10729. * @default []
  10730. */
  10731. "asStripeClasses": null,
  10732. /**
  10733. * If restoring a table - we should restore its striping classes as well
  10734. * @type array
  10735. * @default []
  10736. */
  10737. "asDestroyStripes": [],
  10738. /**
  10739. * If restoring a table - we should restore its width
  10740. * @type int
  10741. * @default 0
  10742. */
  10743. "sDestroyWidth": 0,
  10744. /**
  10745. * Callback functions array for every time a row is inserted (i.e. on a draw).
  10746. * @type array
  10747. * @default []
  10748. */
  10749. "aoRowCallback": [],
  10750. /**
  10751. * Callback functions for the header on each draw.
  10752. * @type array
  10753. * @default []
  10754. */
  10755. "aoHeaderCallback": [],
  10756. /**
  10757. * Callback function for the footer on each draw.
  10758. * @type array
  10759. * @default []
  10760. */
  10761. "aoFooterCallback": [],
  10762. /**
  10763. * Array of callback functions for draw callback functions
  10764. * @type array
  10765. * @default []
  10766. */
  10767. "aoDrawCallback": [],
  10768. /**
  10769. * Array of callback functions for row created function
  10770. * @type array
  10771. * @default []
  10772. */
  10773. "aoRowCreatedCallback": [],
  10774. /**
  10775. * Callback functions for just before the table is redrawn. A return of
  10776. * false will be used to cancel the draw.
  10777. * @type array
  10778. * @default []
  10779. */
  10780. "aoPreDrawCallback": [],
  10781. /**
  10782. * Callback functions for when the table has been initialised.
  10783. * @type array
  10784. * @default []
  10785. */
  10786. "aoInitComplete": [],
  10787. /**
  10788. * Callbacks for modifying the settings to be stored for state saving, prior to
  10789. * saving state.
  10790. * @type array
  10791. * @default []
  10792. */
  10793. "aoStateSaveParams": [],
  10794. /**
  10795. * Callbacks for modifying the settings that have been stored for state saving
  10796. * prior to using the stored values to restore the state.
  10797. * @type array
  10798. * @default []
  10799. */
  10800. "aoStateLoadParams": [],
  10801. /**
  10802. * Callbacks for operating on the settings object once the saved state has been
  10803. * loaded
  10804. * @type array
  10805. * @default []
  10806. */
  10807. "aoStateLoaded": [],
  10808. /**
  10809. * Cache the table ID for quick access
  10810. * @type string
  10811. * @default <i>Empty string</i>
  10812. */
  10813. "sTableId": "",
  10814. /**
  10815. * The TABLE node for the main table
  10816. * @type node
  10817. * @default null
  10818. */
  10819. "nTable": null,
  10820. /**
  10821. * Permanent ref to the thead element
  10822. * @type node
  10823. * @default null
  10824. */
  10825. "nTHead": null,
  10826. /**
  10827. * Permanent ref to the tfoot element - if it exists
  10828. * @type node
  10829. * @default null
  10830. */
  10831. "nTFoot": null,
  10832. /**
  10833. * Permanent ref to the tbody element
  10834. * @type node
  10835. * @default null
  10836. */
  10837. "nTBody": null,
  10838. /**
  10839. * Cache the wrapper node (contains all DataTables controlled elements)
  10840. * @type node
  10841. * @default null
  10842. */
  10843. "nTableWrapper": null,
  10844. /**
  10845. * Indicate if when using server-side processing the loading of data
  10846. * should be deferred until the second draw.
  10847. * Note that this parameter will be set by the initialisation routine. To
  10848. * set a default use {@link DataTable.defaults}.
  10849. * @type boolean
  10850. * @default false
  10851. */
  10852. "bDeferLoading": false,
  10853. /**
  10854. * Indicate if all required information has been read in
  10855. * @type boolean
  10856. * @default false
  10857. */
  10858. "bInitialised": false,
  10859. /**
  10860. * Information about open rows. Each object in the array has the parameters
  10861. * 'nTr' and 'nParent'
  10862. * @type array
  10863. * @default []
  10864. */
  10865. "aoOpenRows": [],
  10866. /**
  10867. * Dictate the positioning of DataTables' control elements - see
  10868. * {@link DataTable.model.oInit.sDom}.
  10869. * Note that this parameter will be set by the initialisation routine. To
  10870. * set a default use {@link DataTable.defaults}.
  10871. * @type string
  10872. * @default null
  10873. */
  10874. "sDom": null,
  10875. /**
  10876. * Which type of pagination should be used.
  10877. * Note that this parameter will be set by the initialisation routine. To
  10878. * set a default use {@link DataTable.defaults}.
  10879. * @type string
  10880. * @default two_button
  10881. */
  10882. "sPaginationType": "two_button",
  10883. /**
  10884. * The state duration (for `stateSave`) in seconds.
  10885. * Note that this parameter will be set by the initialisation routine. To
  10886. * set a default use {@link DataTable.defaults}.
  10887. * @type int
  10888. * @default 0
  10889. */
  10890. "iStateDuration": 0,
  10891. /**
  10892. * Array of callback functions for state saving. Each array element is an
  10893. * object with the following parameters:
  10894. * <ul>
  10895. * <li>function:fn - function to call. Takes two parameters, oSettings
  10896. * and the JSON string to save that has been thus far created. Returns
  10897. * a JSON string to be inserted into a json object
  10898. * (i.e. '"param": [ 0, 1, 2]')</li>
  10899. * <li>string:sName - name of callback</li>
  10900. * </ul>
  10901. * @type array
  10902. * @default []
  10903. */
  10904. "aoStateSave": [],
  10905. /**
  10906. * Array of callback functions for state loading. Each array element is an
  10907. * object with the following parameters:
  10908. * <ul>
  10909. * <li>function:fn - function to call. Takes two parameters, oSettings
  10910. * and the object stored. May return false to cancel state loading</li>
  10911. * <li>string:sName - name of callback</li>
  10912. * </ul>
  10913. * @type array
  10914. * @default []
  10915. */
  10916. "aoStateLoad": [],
  10917. /**
  10918. * State that was loaded. Useful for back reference
  10919. * @type object
  10920. * @default null
  10921. */
  10922. "oLoadedState": null,
  10923. /**
  10924. * Source url for AJAX data for the table.
  10925. * Note that this parameter will be set by the initialisation routine. To
  10926. * set a default use {@link DataTable.defaults}.
  10927. * @type string
  10928. * @default null
  10929. */
  10930. "sAjaxSource": null,
  10931. /**
  10932. * Property from a given object from which to read the table data from. This
  10933. * can be an empty string (when not server-side processing), in which case
  10934. * it is assumed an an array is given directly.
  10935. * Note that this parameter will be set by the initialisation routine. To
  10936. * set a default use {@link DataTable.defaults}.
  10937. * @type string
  10938. */
  10939. "sAjaxDataProp": null,
  10940. /**
  10941. * Note if draw should be blocked while getting data
  10942. * @type boolean
  10943. * @default true
  10944. */
  10945. "bAjaxDataGet": true,
  10946. /**
  10947. * The last jQuery XHR object that was used for server-side data gathering.
  10948. * This can be used for working with the XHR information in one of the
  10949. * callbacks
  10950. * @type object
  10951. * @default null
  10952. */
  10953. "jqXHR": null,
  10954. /**
  10955. * JSON returned from the server in the last Ajax request
  10956. * @type object
  10957. * @default undefined
  10958. */
  10959. "json": undefined,
  10960. /**
  10961. * Function to get the server-side data.
  10962. * Note that this parameter will be set by the initialisation routine. To
  10963. * set a default use {@link DataTable.defaults}.
  10964. * @type function
  10965. */
  10966. "fnServerData": null,
  10967. /**
  10968. * Functions which are called prior to sending an Ajax request so extra
  10969. * parameters can easily be sent to the server
  10970. * @type array
  10971. * @default []
  10972. */
  10973. "aoServerParams": [],
  10974. /**
  10975. * Send the XHR HTTP method - GET or POST (could be PUT or DELETE if
  10976. * required).
  10977. * Note that this parameter will be set by the initialisation routine. To
  10978. * set a default use {@link DataTable.defaults}.
  10979. * @type string
  10980. */
  10981. "sServerMethod": null,
  10982. /**
  10983. * Format numbers for display.
  10984. * Note that this parameter will be set by the initialisation routine. To
  10985. * set a default use {@link DataTable.defaults}.
  10986. * @type function
  10987. */
  10988. "fnFormatNumber": null,
  10989. /**
  10990. * List of options that can be used for the user selectable length menu.
  10991. * Note that this parameter will be set by the initialisation routine. To
  10992. * set a default use {@link DataTable.defaults}.
  10993. * @type array
  10994. * @default []
  10995. */
  10996. "aLengthMenu": null,
  10997. /**
  10998. * Counter for the draws that the table does. Also used as a tracker for
  10999. * server-side processing
  11000. * @type int
  11001. * @default 0
  11002. */
  11003. "iDraw": 0,
  11004. /**
  11005. * Indicate if a redraw is being done - useful for Ajax
  11006. * @type boolean
  11007. * @default false
  11008. */
  11009. "bDrawing": false,
  11010. /**
  11011. * Draw index (iDraw) of the last error when parsing the returned data
  11012. * @type int
  11013. * @default -1
  11014. */
  11015. "iDrawError": -1,
  11016. /**
  11017. * Paging display length
  11018. * @type int
  11019. * @default 10
  11020. */
  11021. "_iDisplayLength": 10,
  11022. /**
  11023. * Paging start point - aiDisplay index
  11024. * @type int
  11025. * @default 0
  11026. */
  11027. "_iDisplayStart": 0,
  11028. /**
  11029. * Server-side processing - number of records in the result set
  11030. * (i.e. before filtering), Use fnRecordsTotal rather than
  11031. * this property to get the value of the number of records, regardless of
  11032. * the server-side processing setting.
  11033. * @type int
  11034. * @default 0
  11035. * @private
  11036. */
  11037. "_iRecordsTotal": 0,
  11038. /**
  11039. * Server-side processing - number of records in the current display set
  11040. * (i.e. after filtering). Use fnRecordsDisplay rather than
  11041. * this property to get the value of the number of records, regardless of
  11042. * the server-side processing setting.
  11043. * @type boolean
  11044. * @default 0
  11045. * @private
  11046. */
  11047. "_iRecordsDisplay": 0,
  11048. /**
  11049. * Flag to indicate if jQuery UI marking and classes should be used.
  11050. * Note that this parameter will be set by the initialisation routine. To
  11051. * set a default use {@link DataTable.defaults}.
  11052. * @type boolean
  11053. */
  11054. "bJUI": null,
  11055. /**
  11056. * The classes to use for the table
  11057. * @type object
  11058. * @default {}
  11059. */
  11060. "oClasses": {},
  11061. /**
  11062. * Flag attached to the settings object so you can check in the draw
  11063. * callback if filtering has been done in the draw. Deprecated in favour of
  11064. * events.
  11065. * @type boolean
  11066. * @default false
  11067. * @deprecated
  11068. */
  11069. "bFiltered": false,
  11070. /**
  11071. * Flag attached to the settings object so you can check in the draw
  11072. * callback if sorting has been done in the draw. Deprecated in favour of
  11073. * events.
  11074. * @type boolean
  11075. * @default false
  11076. * @deprecated
  11077. */
  11078. "bSorted": false,
  11079. /**
  11080. * Indicate that if multiple rows are in the header and there is more than
  11081. * one unique cell per column, if the top one (true) or bottom one (false)
  11082. * should be used for sorting / title by DataTables.
  11083. * Note that this parameter will be set by the initialisation routine. To
  11084. * set a default use {@link DataTable.defaults}.
  11085. * @type boolean
  11086. */
  11087. "bSortCellsTop": null,
  11088. /**
  11089. * Initialisation object that is used for the table
  11090. * @type object
  11091. * @default null
  11092. */
  11093. "oInit": null,
  11094. /**
  11095. * Destroy callback functions - for plug-ins to attach themselves to the
  11096. * destroy so they can clean up markup and events.
  11097. * @type array
  11098. * @default []
  11099. */
  11100. "aoDestroyCallback": [],
  11101. /**
  11102. * Get the number of records in the current record set, before filtering
  11103. * @type function
  11104. */
  11105. "fnRecordsTotal": function ()
  11106. {
  11107. return _fnDataSource( this ) == 'ssp' ?
  11108. this._iRecordsTotal * 1 :
  11109. this.aiDisplayMaster.length;
  11110. },
  11111. /**
  11112. * Get the number of records in the current record set, after filtering
  11113. * @type function
  11114. */
  11115. "fnRecordsDisplay": function ()
  11116. {
  11117. return _fnDataSource( this ) == 'ssp' ?
  11118. this._iRecordsDisplay * 1 :
  11119. this.aiDisplay.length;
  11120. },
  11121. /**
  11122. * Get the display end point - aiDisplay index
  11123. * @type function
  11124. */
  11125. "fnDisplayEnd": function ()
  11126. {
  11127. var
  11128. len = this._iDisplayLength,
  11129. start = this._iDisplayStart,
  11130. calc = start + len,
  11131. records = this.aiDisplay.length,
  11132. features = this.oFeatures,
  11133. paginate = features.bPaginate;
  11134. if ( features.bServerSide ) {
  11135. return paginate === false || len === -1 ?
  11136. start + records :
  11137. Math.min( start+len, this._iRecordsDisplay );
  11138. }
  11139. else {
  11140. return ! paginate || calc>records || len===-1 ?
  11141. records :
  11142. calc;
  11143. }
  11144. },
  11145. /**
  11146. * The DataTables object for this table
  11147. * @type object
  11148. * @default null
  11149. */
  11150. "oInstance": null,
  11151. /**
  11152. * Unique identifier for each instance of the DataTables object. If there
  11153. * is an ID on the table node, then it takes that value, otherwise an
  11154. * incrementing internal counter is used.
  11155. * @type string
  11156. * @default null
  11157. */
  11158. "sInstance": null,
  11159. /**
  11160. * tabindex attribute value that is added to DataTables control elements, allowing
  11161. * keyboard navigation of the table and its controls.
  11162. */
  11163. "iTabIndex": 0,
  11164. /**
  11165. * DIV container for the footer scrolling table if scrolling
  11166. */
  11167. "nScrollHead": null,
  11168. /**
  11169. * DIV container for the footer scrolling table if scrolling
  11170. */
  11171. "nScrollFoot": null,
  11172. /**
  11173. * Last applied sort
  11174. * @type array
  11175. * @default []
  11176. */
  11177. "aLastSort": [],
  11178. /**
  11179. * Stored plug-in instances
  11180. * @type object
  11181. * @default {}
  11182. */
  11183. "oPlugins": {}
  11184. };
  11185. /**
  11186. * Extension object for DataTables that is used to provide all extension
  11187. * options.
  11188. *
  11189. * Note that the `DataTable.ext` object is available through
  11190. * `jQuery.fn.dataTable.ext` where it may be accessed and manipulated. It is
  11191. * also aliased to `jQuery.fn.dataTableExt` for historic reasons.
  11192. * @namespace
  11193. * @extends DataTable.models.ext
  11194. */
  11195. /**
  11196. * DataTables extensions
  11197. *
  11198. * This namespace acts as a collection area for plug-ins that can be used to
  11199. * extend DataTables capabilities. Indeed many of the build in methods
  11200. * use this method to provide their own capabilities (sorting methods for
  11201. * example).
  11202. *
  11203. * Note that this namespace is aliased to `jQuery.fn.dataTableExt` for legacy
  11204. * reasons
  11205. *
  11206. * @namespace
  11207. */
  11208. DataTable.ext = _ext = {
  11209. /**
  11210. * Element class names
  11211. *
  11212. * @type object
  11213. * @default {}
  11214. */
  11215. classes: {},
  11216. /**
  11217. * Error reporting.
  11218. *
  11219. * How should DataTables report an error. Can take the value 'alert' or
  11220. * 'throw'
  11221. *
  11222. * @type string
  11223. * @default alert
  11224. */
  11225. errMode: "alert",
  11226. /**
  11227. * Feature plug-ins.
  11228. *
  11229. * This is an array of objects which describe the feature plug-ins that are
  11230. * available to DataTables. These feature plug-ins are then available for
  11231. * use through the `dom` initialisation option.
  11232. *
  11233. * Each feature plug-in is described by an object which must have the
  11234. * following properties:
  11235. *
  11236. * * `fnInit` - function that is used to initialise the plug-in,
  11237. * * `cFeature` - a character so the feature can be enabled by the `dom`
  11238. * instillation option. This is case sensitive.
  11239. *
  11240. * The `fnInit` function has the following input parameters:
  11241. *
  11242. * 1. `{object}` DataTables settings object: see
  11243. * {@link DataTable.models.oSettings}
  11244. *
  11245. * And the following return is expected:
  11246. *
  11247. * * {node|null} The element which contains your feature. Note that the
  11248. * return may also be void if your plug-in does not require to inject any
  11249. * DOM elements into DataTables control (`dom`) - for example this might
  11250. * be useful when developing a plug-in which allows table control via
  11251. * keyboard entry
  11252. *
  11253. * @type array
  11254. *
  11255. * @example
  11256. * $.fn.dataTable.ext.features.push( {
  11257. * "fnInit": function( oSettings ) {
  11258. * return new TableTools( { "oDTSettings": oSettings } );
  11259. * },
  11260. * "cFeature": "T"
  11261. * } );
  11262. */
  11263. feature: [],
  11264. /**
  11265. * Row searching.
  11266. *
  11267. * This method of searching is complimentary to the default type based
  11268. * searching, and a lot more comprehensive as it allows you complete control
  11269. * over the searching logic. Each element in this array is a function
  11270. * (parameters described below) that is called for every row in the table,
  11271. * and your logic decides if it should be included in the searching data set
  11272. * or not.
  11273. *
  11274. * Searching functions have the following input parameters:
  11275. *
  11276. * 1. `{object}` DataTables settings object: see
  11277. * {@link DataTable.models.oSettings}
  11278. * 2. `{array|object}` Data for the row to be processed (same as the
  11279. * original format that was passed in as the data source, or an array
  11280. * from a DOM data source
  11281. * 3. `{int}` Row index ({@link DataTable.models.oSettings.aoData}), which
  11282. * can be useful to retrieve the `TR` element if you need DOM interaction.
  11283. *
  11284. * And the following return is expected:
  11285. *
  11286. * * {boolean} Include the row in the searched result set (true) or not
  11287. * (false)
  11288. *
  11289. * Note that as with the main search ability in DataTables, technically this
  11290. * is "filtering", since it is subtractive. However, for consistency in
  11291. * naming we call it searching here.
  11292. *
  11293. * @type array
  11294. * @default []
  11295. *
  11296. * @example
  11297. * // The following example shows custom search being applied to the
  11298. * // fourth column (i.e. the data[3] index) based on two input values
  11299. * // from the end-user, matching the data in a certain range.
  11300. * $.fn.dataTable.ext.search.push(
  11301. * function( settings, data, dataIndex ) {
  11302. * var min = document.getElementById('min').value * 1;
  11303. * var max = document.getElementById('max').value * 1;
  11304. * var version = data[3] == "-" ? 0 : data[3]*1;
  11305. *
  11306. * if ( min == "" && max == "" ) {
  11307. * return true;
  11308. * }
  11309. * else if ( min == "" && version < max ) {
  11310. * return true;
  11311. * }
  11312. * else if ( min < version && "" == max ) {
  11313. * return true;
  11314. * }
  11315. * else if ( min < version && version < max ) {
  11316. * return true;
  11317. * }
  11318. * return false;
  11319. * }
  11320. * );
  11321. */
  11322. search: [],
  11323. /**
  11324. * Internal functions, exposed for used in plug-ins.
  11325. *
  11326. * Please note that you should not need to use the internal methods for
  11327. * anything other than a plug-in (and even then, try to avoid if possible).
  11328. * The internal function may change between releases.
  11329. *
  11330. * @type object
  11331. * @default {}
  11332. */
  11333. internal: {},
  11334. /**
  11335. * Legacy configuration options. Enable and disable legacy options that
  11336. * are available in DataTables.
  11337. *
  11338. * @type object
  11339. */
  11340. legacy: {
  11341. /**
  11342. * Enable / disable DataTables 1.9 compatible server-side processing
  11343. * requests
  11344. *
  11345. * @type boolean
  11346. * @default false
  11347. */
  11348. ajax: false
  11349. },
  11350. /**
  11351. * Pagination plug-in methods.
  11352. *
  11353. * Each entry in this object is a function and defines which buttons should
  11354. * be shown by the pagination rendering method that is used for the table:
  11355. * {@link DataTable.ext.renderer.pageButton}. The renderer addresses how the
  11356. * buttons are displayed in the document, while the functions here tell it
  11357. * what buttons to display. This is done by returning an array of button
  11358. * descriptions (what each button will do).
  11359. *
  11360. * Pagination types (the four built in options and any additional plug-in
  11361. * options defined here) can be used through the `paginationType`
  11362. * initialisation parameter.
  11363. *
  11364. * The functions defined take two parameters:
  11365. *
  11366. * 1. `{int} page` The current page index
  11367. * 2. `{int} pages` The number of pages in the table
  11368. *
  11369. * Each function is expected to return an array where each element of the
  11370. * array can be one of:
  11371. *
  11372. * * `first` - Jump to first page when activated
  11373. * * `last` - Jump to last page when activated
  11374. * * `previous` - Show previous page when activated
  11375. * * `next` - Show next page when activated
  11376. * * `{int}` - Show page of the index given
  11377. * * `{array}` - A nested array containing the above elements to add a
  11378. * containing 'DIV' element (might be useful for styling).
  11379. *
  11380. * Note that DataTables v1.9- used this object slightly differently whereby
  11381. * an object with two functions would be defined for each plug-in. That
  11382. * ability is still supported by DataTables 1.10+ to provide backwards
  11383. * compatibility, but this option of use is now decremented and no longer
  11384. * documented in DataTables 1.10+.
  11385. *
  11386. * @type object
  11387. * @default {}
  11388. *
  11389. * @example
  11390. * // Show previous, next and current page buttons only
  11391. * $.fn.dataTableExt.oPagination.current = function ( page, pages ) {
  11392. * return [ 'previous', page, 'next' ];
  11393. * };
  11394. */
  11395. pager: {},
  11396. renderer: {
  11397. pageButton: {},
  11398. header: {}
  11399. },
  11400. /**
  11401. * Ordering plug-ins - custom data source
  11402. *
  11403. * The extension options for ordering of data available here is complimentary
  11404. * to the default type based ordering that DataTables typically uses. It
  11405. * allows much greater control over the the data that is being used to
  11406. * order a column, but is necessarily therefore more complex.
  11407. *
  11408. * This type of ordering is useful if you want to do ordering based on data
  11409. * live from the DOM (for example the contents of an 'input' element) rather
  11410. * than just the static string that DataTables knows of.
  11411. *
  11412. * The way these plug-ins work is that you create an array of the values you
  11413. * wish to be ordering for the column in question and then return that
  11414. * array. The data in the array much be in the index order of the rows in
  11415. * the table (not the currently ordering order!). Which order data gathering
  11416. * function is run here depends on the `dt-init columns.orderDataType`
  11417. * parameter that is used for the column (if any).
  11418. *
  11419. * The functions defined take two parameters:
  11420. *
  11421. * 1. `{object}` DataTables settings object: see
  11422. * {@link DataTable.models.oSettings}
  11423. * 2. `{int}` Target column index
  11424. *
  11425. * Each function is expected to return an array:
  11426. *
  11427. * * `{array}` Data for the column to be ordering upon
  11428. *
  11429. * @type array
  11430. *
  11431. * @example
  11432. * // Ordering using `input` node values
  11433. * $.fn.dataTable.ext.order['dom-text'] = function ( settings, col )
  11434. * {
  11435. * return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
  11436. * return $('input', td).val();
  11437. * } );
  11438. * }
  11439. */
  11440. order: {},
  11441. /**
  11442. * Type based plug-ins.
  11443. *
  11444. * Each column in DataTables has a type assigned to it, either by automatic
  11445. * detection or by direct assignment using the `type` option for the column.
  11446. * The type of a column will effect how it is ordering and search (plug-ins
  11447. * can also make use of the column type if required).
  11448. *
  11449. * @namespace
  11450. */
  11451. type: {
  11452. /**
  11453. * Type detection functions.
  11454. *
  11455. * The functions defined in this object are used to automatically detect
  11456. * a column's type, making initialisation of DataTables super easy, even
  11457. * when complex data is in the table.
  11458. *
  11459. * The functions defined take a single parameter:
  11460. *
  11461. * 1. `{*}` Data from the column cell to be analysed
  11462. *
  11463. * Each function is expected to return:
  11464. *
  11465. * * `{string|null}` Data type detected, or null if unknown (and thus
  11466. * pass it on to the other type detection functions.
  11467. *
  11468. * @type array
  11469. *
  11470. * @example
  11471. * // Currency type detection plug-in:
  11472. * $.fn.dataTable.ext.type.detect.push(
  11473. * function ( data ) {
  11474. * // Check the numeric part
  11475. * if ( ! $.isNumeric( data.substring(1) ) ) {
  11476. * return null;
  11477. * }
  11478. *
  11479. * // Check prefixed by currency
  11480. * if ( data.charAt(0) == '$' || data.charAt(0) == '&pound;' ) {
  11481. * return 'currency';
  11482. * }
  11483. * return null;
  11484. * }
  11485. * );
  11486. */
  11487. detect: [],
  11488. /**
  11489. * Type based search formatting.
  11490. *
  11491. * The type based searching functions can be used to pre-format the
  11492. * data to be search on. For example, it can be used to strip HTML
  11493. * tags or to de-format telephone numbers for numeric only searching.
  11494. *
  11495. * Note that is a search is not defined for a column of a given type,
  11496. * no search formatting will be performed.
  11497. *
  11498. * Pre-processing of searching data plug-ins - When you assign the sType
  11499. * for a column (or have it automatically detected for you by DataTables
  11500. * or a type detection plug-in), you will typically be using this for
  11501. * custom sorting, but it can also be used to provide custom searching
  11502. * by allowing you to pre-processing the data and returning the data in
  11503. * the format that should be searched upon. This is done by adding
  11504. * functions this object with a parameter name which matches the sType
  11505. * for that target column. This is the corollary of <i>afnSortData</i>
  11506. * for searching data.
  11507. *
  11508. * The functions defined take a single parameter:
  11509. *
  11510. * 1. `{*}` Data from the column cell to be prepared for searching
  11511. *
  11512. * Each function is expected to return:
  11513. *
  11514. * * `{string|null}` Formatted string that will be used for the searching.
  11515. *
  11516. * @type object
  11517. * @default {}
  11518. *
  11519. * @example
  11520. * $.fn.dataTable.ext.type.search['title-numeric'] = function ( d ) {
  11521. * return d.replace(/\n/g," ").replace( /<.*?>/g, "" );
  11522. * }
  11523. */
  11524. search: {},
  11525. /**
  11526. * Type based ordering.
  11527. *
  11528. * The column type tells DataTables what ordering to apply to the table
  11529. * when a column is sorted upon. The order for each type that is defined,
  11530. * is defined by the functions available in this object.
  11531. *
  11532. * Each ordering option can be described by three properties added to
  11533. * this object:
  11534. *
  11535. * * `{type}-pre` - Pre-formatting function
  11536. * * `{type}-asc` - Ascending order function
  11537. * * `{type}-desc` - Descending order function
  11538. *
  11539. * All three can be used together, only `{type}-pre` or only
  11540. * `{type}-asc` and `{type}-desc` together. It is generally recommended
  11541. * that only `{type}-pre` is used, as this provides the optimal
  11542. * implementation in terms of speed, although the others are provided
  11543. * for compatibility with existing Javascript sort functions.
  11544. *
  11545. * `{type}-pre`: Functions defined take a single parameter:
  11546. *
  11547. * 1. `{*}` Data from the column cell to be prepared for ordering
  11548. *
  11549. * And return:
  11550. *
  11551. * * `{*}` Data to be sorted upon
  11552. *
  11553. * `{type}-asc` and `{type}-desc`: Functions are typical Javascript sort
  11554. * functions, taking two parameters:
  11555. *
  11556. * 1. `{*}` Data to compare to the second parameter
  11557. * 2. `{*}` Data to compare to the first parameter
  11558. *
  11559. * And returning:
  11560. *
  11561. * * `{*}` Ordering match: <0 if first parameter should be sorted lower
  11562. * than the second parameter, ===0 if the two parameters are equal and
  11563. * >0 if the first parameter should be sorted height than the second
  11564. * parameter.
  11565. *
  11566. * @type object
  11567. * @default {}
  11568. *
  11569. * @example
  11570. * // Numeric ordering of formatted numbers with a pre-formatter
  11571. * $.extend( $.fn.dataTable.ext.type.order, {
  11572. * "string-pre": function(x) {
  11573. * a = (a === "-" || a === "") ? 0 : a.replace( /[^\d\-\.]/g, "" );
  11574. * return parseFloat( a );
  11575. * }
  11576. * } );
  11577. *
  11578. * @example
  11579. * // Case-sensitive string ordering, with no pre-formatting method
  11580. * $.extend( $.fn.dataTable.ext.order, {
  11581. * "string-case-asc": function(x,y) {
  11582. * return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  11583. * },
  11584. * "string-case-desc": function(x,y) {
  11585. * return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  11586. * }
  11587. * } );
  11588. */
  11589. order: {}
  11590. },
  11591. /**
  11592. * Unique DataTables instance counter
  11593. *
  11594. * @type int
  11595. * @private
  11596. */
  11597. _unique: 0,
  11598. //
  11599. // Depreciated
  11600. // The following properties are retained for backwards compatiblity only.
  11601. // The should not be used in new projects and will be removed in a future
  11602. // version
  11603. //
  11604. /**
  11605. * Version check function.
  11606. * @type function
  11607. * @depreciated Since 1.10
  11608. */
  11609. fnVersionCheck: DataTable.fnVersionCheck,
  11610. /**
  11611. * Index for what 'this' index API functions should use
  11612. * @type int
  11613. * @deprecated Since v1.10
  11614. */
  11615. iApiIndex: 0,
  11616. /**
  11617. * jQuery UI class container
  11618. * @type object
  11619. * @deprecated Since v1.10
  11620. */
  11621. oJUIClasses: {},
  11622. /**
  11623. * Software version
  11624. * @type string
  11625. * @deprecated Since v1.10
  11626. */
  11627. sVersion: DataTable.version
  11628. };
  11629. //
  11630. // Backwards compatibility. Alias to pre 1.10 Hungarian notation counter parts
  11631. //
  11632. $.extend( _ext, {
  11633. afnFiltering: _ext.filter,
  11634. aTypes: _ext.type.detect,
  11635. ofnSearch: _ext.type.search,
  11636. oSort: _ext.type.order,
  11637. afnSortData: _ext.order,
  11638. aoFeatures: _ext.feature,
  11639. oApi: _ext.internal,
  11640. oStdClasses: _ext.classes,
  11641. oPagination: _ext.pager
  11642. } );
  11643. $.extend( DataTable.ext.classes, {
  11644. "sTable": "dataTable",
  11645. "sNoFooter": "no-footer",
  11646. /* Paging buttons */
  11647. "sPageButton": "paginate_button",
  11648. "sPageButtonActive": "current",
  11649. "sPageButtonDisabled": "disabled",
  11650. /* Striping classes */
  11651. "sStripeOdd": "odd",
  11652. "sStripeEven": "even",
  11653. /* Empty row */
  11654. "sRowEmpty": "dataTables_empty",
  11655. /* Features */
  11656. "sWrapper": "dataTables_wrapper",
  11657. "sFilter": "dataTables_filter",
  11658. "sInfo": "dataTables_info",
  11659. "sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */
  11660. "sLength": "dataTables_length",
  11661. "sProcessing": "dataTables_processing",
  11662. /* Sorting */
  11663. "sSortAsc": "sorting_asc",
  11664. "sSortDesc": "sorting_desc",
  11665. "sSortable": "sorting", /* Sortable in both directions */
  11666. "sSortableAsc": "sorting_asc_disabled",
  11667. "sSortableDesc": "sorting_desc_disabled",
  11668. "sSortableNone": "sorting_disabled",
  11669. "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
  11670. /* Filtering */
  11671. "sFilterInput": "",
  11672. /* Page length */
  11673. "sLengthSelect": "",
  11674. /* Scrolling */
  11675. "sScrollWrapper": "dataTables_scroll",
  11676. "sScrollHead": "dataTables_scrollHead",
  11677. "sScrollHeadInner": "dataTables_scrollHeadInner",
  11678. "sScrollBody": "dataTables_scrollBody",
  11679. "sScrollFoot": "dataTables_scrollFoot",
  11680. "sScrollFootInner": "dataTables_scrollFootInner",
  11681. /* Misc */
  11682. "sHeaderTH": "",
  11683. "sFooterTH": "",
  11684. // Deprecated
  11685. "sSortJUIAsc": "",
  11686. "sSortJUIDesc": "",
  11687. "sSortJUI": "",
  11688. "sSortJUIAscAllowed": "",
  11689. "sSortJUIDescAllowed": "",
  11690. "sSortJUIWrapper": "",
  11691. "sSortIcon": "",
  11692. "sJUIHeader": "",
  11693. "sJUIFooter": ""
  11694. } );
  11695. (function() {
  11696. // Reused strings for better compression. Closure compiler appears to have a
  11697. // weird edge case where it is trying to expand strings rather than use the
  11698. // variable version. This results in about 200 bytes being added, for very
  11699. // little preference benefit since it this run on script load only.
  11700. var _empty = '';
  11701. _empty = '';
  11702. var _stateDefault = _empty + 'ui-state-default';
  11703. var _sortIcon = _empty + 'css_right ui-icon ui-icon-';
  11704. var _headerFooter = _empty + 'fg-toolbar ui-toolbar ui-widget-header ui-helper-clearfix';
  11705. $.extend( DataTable.ext.oJUIClasses, DataTable.ext.classes, {
  11706. /* Full numbers paging buttons */
  11707. "sPageButton": "fg-button ui-button "+_stateDefault,
  11708. "sPageButtonActive": "ui-state-disabled",
  11709. "sPageButtonDisabled": "ui-state-disabled",
  11710. /* Features */
  11711. "sPaging": "dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi "+
  11712. "ui-buttonset-multi paging_", /* Note that the type is postfixed */
  11713. /* Sorting */
  11714. "sSortAsc": _stateDefault+" sorting_asc",
  11715. "sSortDesc": _stateDefault+" sorting_desc",
  11716. "sSortable": _stateDefault+" sorting",
  11717. "sSortableAsc": _stateDefault+" sorting_asc_disabled",
  11718. "sSortableDesc": _stateDefault+" sorting_desc_disabled",
  11719. "sSortableNone": _stateDefault+" sorting_disabled",
  11720. "sSortJUIAsc": _sortIcon+"triangle-1-n",
  11721. "sSortJUIDesc": _sortIcon+"triangle-1-s",
  11722. "sSortJUI": _sortIcon+"carat-2-n-s",
  11723. "sSortJUIAscAllowed": _sortIcon+"carat-1-n",
  11724. "sSortJUIDescAllowed": _sortIcon+"carat-1-s",
  11725. "sSortJUIWrapper": "DataTables_sort_wrapper",
  11726. "sSortIcon": "DataTables_sort_icon",
  11727. /* Scrolling */
  11728. "sScrollHead": "dataTables_scrollHead "+_stateDefault,
  11729. "sScrollFoot": "dataTables_scrollFoot "+_stateDefault,
  11730. /* Misc */
  11731. "sHeaderTH": _stateDefault,
  11732. "sFooterTH": _stateDefault,
  11733. "sJUIHeader": _headerFooter+" ui-corner-tl ui-corner-tr",
  11734. "sJUIFooter": _headerFooter+" ui-corner-bl ui-corner-br"
  11735. } );
  11736. }());
  11737. var extPagination = DataTable.ext.pager;
  11738. function _numbers ( page, pages ) {
  11739. var
  11740. numbers = [],
  11741. buttons = extPagination.numbers_length,
  11742. half = Math.floor( buttons / 2 ),
  11743. i = 1;
  11744. if ( pages <= buttons ) {
  11745. numbers = _range( 0, pages );
  11746. }
  11747. else if ( page <= half ) {
  11748. numbers = _range( 0, buttons-2 );
  11749. numbers.push( 'ellipsis' );
  11750. numbers.push( pages-1 );
  11751. }
  11752. else if ( page >= pages - 1 - half ) {
  11753. numbers = _range( pages-(buttons-2), pages );
  11754. numbers.splice( 0, 0, 'ellipsis' ); // no unshift in ie6
  11755. numbers.splice( 0, 0, 0 );
  11756. }
  11757. else {
  11758. numbers = _range( page-1, page+2 );
  11759. numbers.push( 'ellipsis' );
  11760. numbers.push( pages-1 );
  11761. numbers.splice( 0, 0, 'ellipsis' );
  11762. numbers.splice( 0, 0, 0 );
  11763. }
  11764. numbers.DT_el = 'span';
  11765. return numbers;
  11766. }
  11767. $.extend( extPagination, {
  11768. simple: function ( page, pages ) {
  11769. return [ 'previous', 'next' ];
  11770. },
  11771. full: function ( page, pages ) {
  11772. return [ 'first', 'previous', 'next', 'last' ];
  11773. },
  11774. simple_numbers: function ( page, pages ) {
  11775. return [ 'previous', _numbers(page, pages), 'next' ];
  11776. },
  11777. full_numbers: function ( page, pages ) {
  11778. return [ 'first', 'previous', _numbers(page, pages), 'next', 'last' ];
  11779. },
  11780. // For testing and plug-ins to use
  11781. _numbers: _numbers,
  11782. numbers_length: 7
  11783. } );
  11784. $.extend( true, DataTable.ext.renderer, {
  11785. pageButton: {
  11786. _: function ( settings, host, idx, buttons, page, pages ) {
  11787. var classes = settings.oClasses;
  11788. var lang = settings.oLanguage.oPaginate;
  11789. var btnDisplay, btnClass;
  11790. var attach = function( container, buttons ) {
  11791. var i, ien, node, button;
  11792. var clickHandler = function ( e ) {
  11793. _fnPageChange( settings, e.data.action, true );
  11794. };
  11795. for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
  11796. button = buttons[i];
  11797. if ( $.isArray( button ) ) {
  11798. var inner = $( '<'+(button.DT_el || 'div')+'/>' )
  11799. .appendTo( container );
  11800. attach( inner, button );
  11801. }
  11802. else {
  11803. btnDisplay = '';
  11804. btnClass = '';
  11805. switch ( button ) {
  11806. case 'ellipsis':
  11807. container.append('<span>&hellip;</span>');
  11808. break;
  11809. case 'first':
  11810. btnDisplay = lang.sFirst;
  11811. btnClass = button + (page > 0 ?
  11812. '' : ' '+classes.sPageButtonDisabled);
  11813. break;
  11814. case 'previous':
  11815. btnDisplay = lang.sPrevious;
  11816. btnClass = button + (page > 0 ?
  11817. '' : ' '+classes.sPageButtonDisabled);
  11818. break;
  11819. case 'next':
  11820. btnDisplay = lang.sNext;
  11821. btnClass = button + (page < pages-1 ?
  11822. '' : ' '+classes.sPageButtonDisabled);
  11823. break;
  11824. case 'last':
  11825. btnDisplay = lang.sLast;
  11826. btnClass = button + (page < pages-1 ?
  11827. '' : ' '+classes.sPageButtonDisabled);
  11828. break;
  11829. default:
  11830. btnDisplay = button + 1;
  11831. btnClass = page === button ?
  11832. classes.sPageButtonActive : '';
  11833. break;
  11834. }
  11835. if ( btnDisplay ) {
  11836. node = $('<a>', {
  11837. 'class': classes.sPageButton+' '+btnClass,
  11838. 'aria-controls': settings.sTableId,
  11839. 'tabindex': settings.iTabIndex,
  11840. 'id': idx === 0 && typeof button === 'string' ?
  11841. settings.sTableId +'_'+ button :
  11842. null
  11843. } )
  11844. .html( btnDisplay )
  11845. .appendTo( container );
  11846. _fnBindAction(
  11847. node, {action: button}, clickHandler
  11848. );
  11849. }
  11850. }
  11851. }
  11852. };
  11853. attach( $(host).empty(), buttons );
  11854. }
  11855. }
  11856. } );
  11857. var __numericReplace = function ( d, re1, re2 ) {
  11858. if ( !d || d === '-' ) {
  11859. return -Infinity;
  11860. }
  11861. if ( d.replace ) {
  11862. if ( re1 ) {
  11863. d = d.replace( re1, '' );
  11864. }
  11865. if ( re2 ) {
  11866. d = d.replace( re2, '' );
  11867. }
  11868. }
  11869. return d * 1;
  11870. };
  11871. $.extend( DataTable.ext.type.order, {
  11872. // Dates
  11873. "date-pre": function ( d )
  11874. {
  11875. return Date.parse( d ) || 0;
  11876. },
  11877. // Plain numbers
  11878. "numeric-pre": function ( d )
  11879. {
  11880. return __numericReplace( d );
  11881. },
  11882. // Formatted numbers
  11883. "numeric-fmt-pre": function ( d )
  11884. {
  11885. return __numericReplace( d, _re_formatted_numeric );
  11886. },
  11887. // HTML numeric
  11888. "html-numeric-pre": function ( d )
  11889. {
  11890. return __numericReplace( d, _re_html );
  11891. },
  11892. // HTML numeric, formatted
  11893. "html-numeric-fmt-pre": function ( d )
  11894. {
  11895. return __numericReplace( d, _re_html, _re_formatted_numeric );
  11896. },
  11897. // html
  11898. "html-pre": function ( a )
  11899. {
  11900. return a.replace ?
  11901. a.replace( /<.*?>/g, "" ).toLowerCase() :
  11902. a+'';
  11903. },
  11904. // string
  11905. "string-pre": function ( a )
  11906. {
  11907. return typeof a === 'string' ?
  11908. a.toLowerCase() :
  11909. ! a || ! a.toString ?
  11910. '' :
  11911. a.toString();
  11912. },
  11913. // string-asc and -desc are retained only for compatibility with the old
  11914. // sort methods
  11915. "string-asc": function ( x, y )
  11916. {
  11917. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  11918. },
  11919. "string-desc": function ( x, y )
  11920. {
  11921. return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  11922. }
  11923. } );
  11924. // Built in type detection. See model.ext.aTypes for information about
  11925. // what is required from this methods.
  11926. $.extend( DataTable.ext.type.detect, [
  11927. // Plain numbers - first since V8 detects some plain numbers as dates
  11928. // e.g. Date.parse('55') (but not all, e.g. Date.parse('22')...).
  11929. function ( d )
  11930. {
  11931. return _isNumber( d ) ? 'numeric' : null;
  11932. },
  11933. // Dates (only those recognised by the browser's Date.parse)
  11934. function ( d )
  11935. {
  11936. // V8 will remove any unknown characters at the start of the expression,
  11937. // leading to false matches such as `$245.12` being a valid date. See
  11938. // forum thread 18941 for detail.
  11939. if ( d && ! _re_date_start.test(d) ) {
  11940. return null;
  11941. }
  11942. var parsed = Date.parse(d);
  11943. return (parsed !== null && !isNaN(parsed)) || _empty(d) ? 'date' : null;
  11944. },
  11945. // Formatted numbers
  11946. function ( d )
  11947. {
  11948. return _isNumber( d, true ) ? 'numeric-fmt' : null;
  11949. },
  11950. // HTML numeric
  11951. function ( d )
  11952. {
  11953. return _htmlNumeric( d ) ? 'html-numeric' : null;
  11954. },
  11955. // HTML numeric, formatted
  11956. function ( d )
  11957. {
  11958. return _htmlNumeric( d, true ) ? 'html-numeric-fmt' : null;
  11959. },
  11960. // HTML (this is strict checking - there much be html)
  11961. function ( d )
  11962. {
  11963. return _empty( d ) || (typeof d === 'string' && d.indexOf('<') !== -1) ?
  11964. 'html' : null;
  11965. }
  11966. ] );
  11967. // Filter formatting functions. See model.ext.ofnSearch for information about
  11968. // what is required from these methods.
  11969. $.extend( DataTable.ext.type.search, {
  11970. html: function ( data ) {
  11971. return _empty(data) ?
  11972. '' :
  11973. typeof data === 'string' ?
  11974. data
  11975. .replace( _re_new_lines, " " )
  11976. .replace( _re_html, "" ) :
  11977. '';
  11978. },
  11979. string: function ( data ) {
  11980. return _empty(data) ?
  11981. '' :
  11982. typeof data === 'string' ?
  11983. data.replace( _re_new_lines, " " ) :
  11984. data;
  11985. }
  11986. } );
  11987. $.extend( true, DataTable.ext.renderer, {
  11988. header: {
  11989. _: function ( settings, cell, column, idx, classes ) {
  11990. // No additional mark-up required
  11991. // Attach a sort listener to update on sort
  11992. $(settings.nTable).on( 'order.dt', function ( e, settings, sorting, columns ) {
  11993. cell
  11994. .removeClass(
  11995. column.sSortingClass +' '+
  11996. classes.sSortAsc +' '+
  11997. classes.sSortDesc
  11998. )
  11999. .addClass( columns[ idx ] == 'asc' ?
  12000. classes.sSortAsc : columns[ idx ] == 'desc' ?
  12001. classes.sSortDesc :
  12002. column.sSortingClass
  12003. );
  12004. } );
  12005. },
  12006. jqueryui: function ( settings, cell, column, idx, classes ) {
  12007. $('<div/>')
  12008. .addClass( classes.sSortJUIWrapper )
  12009. .append( cell.contents() )
  12010. .append( $('<span/>')
  12011. .addClass( classes.sSortIcon+' '+column.sSortingClassJUI )
  12012. )
  12013. .appendTo( cell );
  12014. // Attach a sort listener to update on sort
  12015. $(settings.nTable).on( 'order.dt', function ( e, settings, sorting, columns ) {
  12016. cell
  12017. .removeClass( classes.sSortAsc +" "+classes.sSortDesc )
  12018. .addClass( columns[ idx ] == 'asc' ?
  12019. classes.sSortAsc : columns[ idx ] == 'desc' ?
  12020. classes.sSortDesc :
  12021. column.sSortingClass
  12022. );
  12023. cell
  12024. .find( 'span' )
  12025. .removeClass(
  12026. classes.sSortJUIAsc +" "+
  12027. classes.sSortJUIDesc +" "+
  12028. classes.sSortJUI +" "+
  12029. classes.sSortJUIAscAllowed +" "+
  12030. classes.sSortJUIDescAllowed
  12031. )
  12032. .addClass( columns[ idx ] == 'asc' ?
  12033. classes.sSortJUIAsc : columns[ idx ] == 'desc' ?
  12034. classes.sSortJUIDesc :
  12035. column.sSortingClassJUI
  12036. );
  12037. } );
  12038. }
  12039. }
  12040. } );
  12041. // jQuery access
  12042. $.fn.dataTable = DataTable;
  12043. // Legacy aliases
  12044. $.fn.dataTableSettings = DataTable.settings;
  12045. $.fn.dataTableExt = DataTable.ext;
  12046. // With a capital `D` we return a DataTables API instance rather than a
  12047. // jQuery object
  12048. $.fn.DataTable = function ( opts ) {
  12049. return $(this).dataTable( opts ).api();
  12050. };
  12051. // All properties that are available to $.fn.dataTable should also be
  12052. // available on $.fn.DataTable
  12053. $.each( DataTable, function ( prop, val ) {
  12054. $.fn.DataTable[ prop ] = val;
  12055. } );
  12056. // Information about events fired by DataTables - for documentation.
  12057. /**
  12058. * Draw event, fired whenever the table is redrawn on the page, at the same
  12059. * point as fnDrawCallback. This may be useful for binding events or
  12060. * performing calculations when the table is altered at all.
  12061. * @name DataTable#draw.dt
  12062. * @event
  12063. * @param {event} e jQuery event object
  12064. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12065. */
  12066. /**
  12067. * Search event, fired when the searching applied to the table (using the
  12068. * built-in global search, or column filters) is altered.
  12069. * @name DataTable#search.dt
  12070. * @event
  12071. * @param {event} e jQuery event object
  12072. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12073. */
  12074. /**
  12075. * Page change event, fired when the paging of the table is altered.
  12076. * @name DataTable#page.dt
  12077. * @event
  12078. * @param {event} e jQuery event object
  12079. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12080. */
  12081. /**
  12082. * Order event, fired when the ordering applied to the table is altered.
  12083. * @name DataTable#order.dt
  12084. * @event
  12085. * @param {event} e jQuery event object
  12086. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12087. */
  12088. /**
  12089. * DataTables initialisation complete event, fired when the table is fully
  12090. * drawn, including Ajax data loaded, if Ajax data is required.
  12091. * @name DataTable#init.dt
  12092. * @event
  12093. * @param {event} e jQuery event object
  12094. * @param {object} oSettings DataTables settings object
  12095. * @param {object} json The JSON object request from the server - only
  12096. * present if client-side Ajax sourced data is used</li></ol>
  12097. */
  12098. /**
  12099. * State save event, fired when the table has changed state a new state save
  12100. * is required. This event allows modification of the state saving object
  12101. * prior to actually doing the save, including addition or other state
  12102. * properties (for plug-ins) or modification of a DataTables core property.
  12103. * @name DataTable#stateSaveParams.dt
  12104. * @event
  12105. * @param {event} e jQuery event object
  12106. * @param {object} oSettings DataTables settings object
  12107. * @param {object} json The state information to be saved
  12108. */
  12109. /**
  12110. * State load event, fired when the table is loading state from the stored
  12111. * data, but prior to the settings object being modified by the saved state
  12112. * - allowing modification of the saved state is required or loading of
  12113. * state for a plug-in.
  12114. * @name DataTable#stateLoadParams.dt
  12115. * @event
  12116. * @param {event} e jQuery event object
  12117. * @param {object} oSettings DataTables settings object
  12118. * @param {object} json The saved state information
  12119. */
  12120. /**
  12121. * State loaded event, fired when state has been loaded from stored data and
  12122. * the settings object has been modified by the loaded data.
  12123. * @name DataTable#stateLoaded.dt
  12124. * @event
  12125. * @param {event} e jQuery event object
  12126. * @param {object} oSettings DataTables settings object
  12127. * @param {object} json The saved state information
  12128. */
  12129. /**
  12130. * Processing event, fired when DataTables is doing some kind of processing
  12131. * (be it, order, searcg or anything else). It can be used to indicate to
  12132. * the end user that there is something happening, or that something has
  12133. * finished.
  12134. * @name DataTable#processing.dt
  12135. * @event
  12136. * @param {event} e jQuery event object
  12137. * @param {object} oSettings DataTables settings object
  12138. * @param {boolean} bShow Flag for if DataTables is doing processing or not
  12139. */
  12140. /**
  12141. * Ajax (XHR) event, fired whenever an Ajax request is completed from a
  12142. * request to made to the server for new data. This event is called before
  12143. * DataTables processed the returned data, so it can also be used to pre-
  12144. * process the data returned from the server, if needed.
  12145. *
  12146. * Note that this trigger is called in `fnServerData`, if you override
  12147. * `fnServerData` and which to use this event, you need to trigger it in you
  12148. * success function.
  12149. * @name DataTable#xhr.dt
  12150. * @event
  12151. * @param {event} e jQuery event object
  12152. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12153. * @param {object} json JSON returned from the server
  12154. *
  12155. * @example
  12156. * // Use a custom property returned from the server in another DOM element
  12157. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  12158. * $('#status').html( json.status );
  12159. * } );
  12160. *
  12161. * @example
  12162. * // Pre-process the data returned from the server
  12163. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  12164. * for ( var i=0, ien=json.aaData.length ; i<ien ; i++ ) {
  12165. * json.aaData[i].sum = json.aaData[i].one + json.aaData[i].two;
  12166. * }
  12167. * // Note no return - manipulate the data directly in the JSON object.
  12168. * } );
  12169. */
  12170. /**
  12171. * Destroy event, fired when the DataTable is destroyed by calling fnDestroy
  12172. * or passing the bDestroy:true parameter in the initialisation object. This
  12173. * can be used to remove bound events, added DOM nodes, etc.
  12174. * @name DataTable#destroy.dt
  12175. * @event
  12176. * @param {event} e jQuery event object
  12177. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12178. */
  12179. /**
  12180. * Page length change event, fired when number of records to show on each
  12181. * page (the length) is changed.
  12182. * @name DataTable#length.dt
  12183. * @event
  12184. * @param {event} e jQuery event object
  12185. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12186. * @param {integer} len New length
  12187. */
  12188. /**
  12189. * Column sizing has changed.
  12190. * @name DataTable#column-sizing.dt
  12191. * @event
  12192. * @param {event} e jQuery event object
  12193. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12194. */
  12195. /**
  12196. * Column visibility has changed.
  12197. * @name DataTable#column-visibility.dt
  12198. * @event
  12199. * @param {event} e jQuery event object
  12200. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12201. * @param {int} column Column index
  12202. * @param {bool} vis `false` if column now hidden, or `true` if visible
  12203. */
  12204. }));
  12205. }(window, document, jQuery));