jquery.dataTables.js 398 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014
  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));