jquery.dataTables.js 437 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332
  1. /*! DataTables 1.11.3
  2. * ©2008-2021 SpryMedia Ltd - datatables.net/license
  3. */
  4. /**
  5. * @summary DataTables
  6. * @description Paginate, search and order HTML tables
  7. * @version 1.11.3
  8. * @file jquery.dataTables.js
  9. * @author SpryMedia Ltd
  10. * @contact www.datatables.net
  11. * @copyright Copyright 2008-2021 SpryMedia Ltd.
  12. *
  13. * This source file is free software, available under the following license:
  14. * MIT license - http://datatables.net/license
  15. *
  16. * This source file is distributed in the hope that it will be useful, but
  17. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  18. * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
  19. *
  20. * For details please refer to: http://www.datatables.net
  21. */
  22. /*jslint evil: true, undef: true, browser: true */
  23. /*globals $,require,jQuery,define,_selector_run,_selector_opts,_selector_first,_selector_row_indexes,_ext,_Api,_api_register,_api_registerPlural,_re_new_lines,_re_html,_re_formatted_numeric,_re_escape_regex,_empty,_intVal,_numToDecimal,_isNumber,_isHtml,_htmlNumeric,_pluck,_pluck_order,_range,_stripHtml,_unique,_fnBuildAjax,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnAjaxDataSrc,_fnAddColumn,_fnColumnOptions,_fnAdjustColumnSizing,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnVisbleColumns,_fnGetColumns,_fnColumnTypes,_fnApplyColumnDefs,_fnHungarianMap,_fnCamelToHungarian,_fnLanguageCompat,_fnBrowserDetect,_fnAddData,_fnAddTr,_fnNodeToDataIndex,_fnNodeToColumnIndex,_fnGetCellData,_fnSetCellData,_fnSplitObjNotation,_fnGetObjectDataFn,_fnSetObjectDataFn,_fnGetDataMaster,_fnClearTable,_fnDeleteIndex,_fnInvalidate,_fnGetRowElements,_fnCreateTr,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAddOptionsHtml,_fnDetectHeader,_fnGetUniqueThs,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnFilterCreateSearch,_fnEscapeRegex,_fnFilterData,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnInfoMacros,_fnInitialise,_fnInitComplete,_fnLengthChange,_fnFeatureHtmlLength,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnFeatureHtmlTable,_fnScrollDraw,_fnApplyToChildren,_fnCalculateColumnWidths,_fnThrottle,_fnConvertToWidth,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnSortFlatten,_fnSort,_fnSortAria,_fnSortListener,_fnSortAttachListener,_fnSortingClasses,_fnSortData,_fnSaveState,_fnLoadState,_fnSettingsFromNode,_fnLog,_fnMap,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnLengthOverflow,_fnRenderer,_fnDataSource,_fnRowAttributes*/
  24. (function( factory ) {
  25. "use strict";
  26. if ( typeof define === 'function' && define.amd ) {
  27. // AMD
  28. define( ['jquery'], function ( $ ) {
  29. return factory( $, window, document );
  30. } );
  31. }
  32. else if ( typeof exports === 'object' ) {
  33. // CommonJS
  34. module.exports = function (root, $) {
  35. if ( ! root ) {
  36. // CommonJS environments without a window global must pass a
  37. // root. This will give an error otherwise
  38. root = window;
  39. }
  40. if ( ! $ ) {
  41. $ = typeof window !== 'undefined' ? // jQuery's factory checks for a global window
  42. require('jquery') :
  43. require('jquery')( root );
  44. }
  45. return factory( $, root, root.document );
  46. };
  47. }
  48. else {
  49. // Browser
  50. window.DataTable = factory( jQuery, window, document );
  51. }
  52. }
  53. (function( $, window, document, undefined ) {
  54. "use strict";
  55. /**
  56. * DataTables is a plug-in for the jQuery Javascript library. It is a highly
  57. * flexible tool, based upon the foundations of progressive enhancement,
  58. * which will add advanced interaction controls to any HTML table. For a
  59. * full list of features please refer to
  60. * [DataTables.net](href="http://datatables.net).
  61. *
  62. * Note that the `DataTable` object is not a global variable but is aliased
  63. * to `jQuery.fn.DataTable` and `jQuery.fn.dataTable` through which it may
  64. * be accessed.
  65. *
  66. * @class
  67. * @param {object} [init={}] Configuration object for DataTables. Options
  68. * are defined by {@link DataTable.defaults}
  69. * @requires jQuery 1.7+
  70. *
  71. * @example
  72. * // Basic initialisation
  73. * $(document).ready( function {
  74. * $('#example').dataTable();
  75. * } );
  76. *
  77. * @example
  78. * // Initialisation with configuration options - in this case, disable
  79. * // pagination and sorting.
  80. * $(document).ready( function {
  81. * $('#example').dataTable( {
  82. * "paginate": false,
  83. * "sort": false
  84. * } );
  85. * } );
  86. */
  87. var DataTable = function ( selector, options )
  88. {
  89. // When creating with `new`, create a new DataTable, returning the API instance
  90. if (this instanceof DataTable) {
  91. return $(selector).DataTable(options);
  92. }
  93. else {
  94. // Argument switching
  95. options = selector;
  96. }
  97. /**
  98. * Perform a jQuery selector action on the table's TR elements (from the tbody) and
  99. * return the resulting jQuery object.
  100. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  101. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  102. * @param {string} [oOpts.filter=none] Select TR elements that meet the current filter
  103. * criterion ("applied") or all TR elements (i.e. no filter).
  104. * @param {string} [oOpts.order=current] Order of the TR elements in the processed array.
  105. * Can be either 'current', whereby the current sorting of the table is used, or
  106. * 'original' whereby the original order the data was read into the table is used.
  107. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  108. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  109. * 'current' and filter is 'applied', regardless of what they might be given as.
  110. * @returns {object} jQuery object, filtered by the given selector.
  111. * @dtopt API
  112. * @deprecated Since v1.10
  113. *
  114. * @example
  115. * $(document).ready(function() {
  116. * var oTable = $('#example').dataTable();
  117. *
  118. * // Highlight every second row
  119. * oTable.$('tr:odd').css('backgroundColor', 'blue');
  120. * } );
  121. *
  122. * @example
  123. * $(document).ready(function() {
  124. * var oTable = $('#example').dataTable();
  125. *
  126. * // Filter to rows with 'Webkit' in them, add a background colour and then
  127. * // remove the filter, thus highlighting the 'Webkit' rows only.
  128. * oTable.fnFilter('Webkit');
  129. * oTable.$('tr', {"search": "applied"}).css('backgroundColor', 'blue');
  130. * oTable.fnFilter('');
  131. * } );
  132. */
  133. this.$ = function ( sSelector, oOpts )
  134. {
  135. return this.api(true).$( sSelector, oOpts );
  136. };
  137. /**
  138. * Almost identical to $ in operation, but in this case returns the data for the matched
  139. * rows - as such, the jQuery selector used should match TR row nodes or TD/TH cell nodes
  140. * rather than any descendants, so the data can be obtained for the row/cell. If matching
  141. * rows are found, the data returned is the original data array/object that was used to
  142. * create the row (or a generated array if from a DOM source).
  143. *
  144. * This method is often useful in-combination with $ where both functions are given the
  145. * same parameters and the array indexes will match identically.
  146. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  147. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  148. * @param {string} [oOpts.filter=none] Select elements that meet the current filter
  149. * criterion ("applied") or all elements (i.e. no filter).
  150. * @param {string} [oOpts.order=current] Order of the data in the processed array.
  151. * Can be either 'current', whereby the current sorting of the table is used, or
  152. * 'original' whereby the original order the data was read into the table is used.
  153. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  154. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  155. * 'current' and filter is 'applied', regardless of what they might be given as.
  156. * @returns {array} Data for the matched elements. If any elements, as a result of the
  157. * selector, were not TR, TD or TH elements in the DataTable, they will have a null
  158. * entry in the array.
  159. * @dtopt API
  160. * @deprecated Since v1.10
  161. *
  162. * @example
  163. * $(document).ready(function() {
  164. * var oTable = $('#example').dataTable();
  165. *
  166. * // Get the data from the first row in the table
  167. * var data = oTable._('tr:first');
  168. *
  169. * // Do something useful with the data
  170. * alert( "First cell is: "+data[0] );
  171. * } );
  172. *
  173. * @example
  174. * $(document).ready(function() {
  175. * var oTable = $('#example').dataTable();
  176. *
  177. * // Filter to 'Webkit' and get all data for
  178. * oTable.fnFilter('Webkit');
  179. * var data = oTable._('tr', {"search": "applied"});
  180. *
  181. * // Do something with the data
  182. * alert( data.length+" rows matched the search" );
  183. * } );
  184. */
  185. this._ = function ( sSelector, oOpts )
  186. {
  187. return this.api(true).rows( sSelector, oOpts ).data();
  188. };
  189. /**
  190. * Create a DataTables Api instance, with the currently selected tables for
  191. * the Api's context.
  192. * @param {boolean} [traditional=false] Set the API instance's context to be
  193. * only the table referred to by the `DataTable.ext.iApiIndex` option, as was
  194. * used in the API presented by DataTables 1.9- (i.e. the traditional mode),
  195. * or if all tables captured in the jQuery object should be used.
  196. * @return {DataTables.Api}
  197. */
  198. this.api = function ( traditional )
  199. {
  200. return traditional ?
  201. new _Api(
  202. _fnSettingsFromNode( this[ _ext.iApiIndex ] )
  203. ) :
  204. new _Api( this );
  205. };
  206. /**
  207. * Add a single new row or multiple rows of data to the table. Please note
  208. * that this is suitable for client-side processing only - if you are using
  209. * server-side processing (i.e. "bServerSide": true), then to add data, you
  210. * must add it to the data source, i.e. the server-side, through an Ajax call.
  211. * @param {array|object} data The data to be added to the table. This can be:
  212. * <ul>
  213. * <li>1D array of data - add a single row with the data provided</li>
  214. * <li>2D array of arrays - add multiple rows in a single call</li>
  215. * <li>object - data object when using <i>mData</i></li>
  216. * <li>array of objects - multiple data objects when using <i>mData</i></li>
  217. * </ul>
  218. * @param {bool} [redraw=true] redraw the table or not
  219. * @returns {array} An array of integers, representing the list of indexes in
  220. * <i>aoData</i> ({@link DataTable.models.oSettings}) that have been added to
  221. * the table.
  222. * @dtopt API
  223. * @deprecated Since v1.10
  224. *
  225. * @example
  226. * // Global var for counter
  227. * var giCount = 2;
  228. *
  229. * $(document).ready(function() {
  230. * $('#example').dataTable();
  231. * } );
  232. *
  233. * function fnClickAddRow() {
  234. * $('#example').dataTable().fnAddData( [
  235. * giCount+".1",
  236. * giCount+".2",
  237. * giCount+".3",
  238. * giCount+".4" ]
  239. * );
  240. *
  241. * giCount++;
  242. * }
  243. */
  244. this.fnAddData = function( data, redraw )
  245. {
  246. var api = this.api( true );
  247. /* Check if we want to add multiple rows or not */
  248. var rows = Array.isArray(data) && ( Array.isArray(data[0]) || $.isPlainObject(data[0]) ) ?
  249. api.rows.add( data ) :
  250. api.row.add( data );
  251. if ( redraw === undefined || redraw ) {
  252. api.draw();
  253. }
  254. return rows.flatten().toArray();
  255. };
  256. /**
  257. * This function will make DataTables recalculate the column sizes, based on the data
  258. * contained in the table and the sizes applied to the columns (in the DOM, CSS or
  259. * through the sWidth parameter). This can be useful when the width of the table's
  260. * parent element changes (for example a window resize).
  261. * @param {boolean} [bRedraw=true] Redraw the table or not, you will typically want to
  262. * @dtopt API
  263. * @deprecated Since v1.10
  264. *
  265. * @example
  266. * $(document).ready(function() {
  267. * var oTable = $('#example').dataTable( {
  268. * "sScrollY": "200px",
  269. * "bPaginate": false
  270. * } );
  271. *
  272. * $(window).on('resize', function () {
  273. * oTable.fnAdjustColumnSizing();
  274. * } );
  275. * } );
  276. */
  277. this.fnAdjustColumnSizing = function ( bRedraw )
  278. {
  279. var api = this.api( true ).columns.adjust();
  280. var settings = api.settings()[0];
  281. var scroll = settings.oScroll;
  282. if ( bRedraw === undefined || bRedraw ) {
  283. api.draw( false );
  284. }
  285. else if ( scroll.sX !== "" || scroll.sY !== "" ) {
  286. /* If not redrawing, but scrolling, we want to apply the new column sizes anyway */
  287. _fnScrollDraw( settings );
  288. }
  289. };
  290. /**
  291. * Quickly and simply clear a table
  292. * @param {bool} [bRedraw=true] redraw the table or not
  293. * @dtopt API
  294. * @deprecated Since v1.10
  295. *
  296. * @example
  297. * $(document).ready(function() {
  298. * var oTable = $('#example').dataTable();
  299. *
  300. * // Immediately 'nuke' the current rows (perhaps waiting for an Ajax callback...)
  301. * oTable.fnClearTable();
  302. * } );
  303. */
  304. this.fnClearTable = function( bRedraw )
  305. {
  306. var api = this.api( true ).clear();
  307. if ( bRedraw === undefined || bRedraw ) {
  308. api.draw();
  309. }
  310. };
  311. /**
  312. * The exact opposite of 'opening' a row, this function will close any rows which
  313. * are currently 'open'.
  314. * @param {node} nTr the table row to 'close'
  315. * @returns {int} 0 on success, or 1 if failed (can't find the row)
  316. * @dtopt API
  317. * @deprecated Since v1.10
  318. *
  319. * @example
  320. * $(document).ready(function() {
  321. * var oTable;
  322. *
  323. * // 'open' an information row when a row is clicked on
  324. * $('#example tbody tr').click( function () {
  325. * if ( oTable.fnIsOpen(this) ) {
  326. * oTable.fnClose( this );
  327. * } else {
  328. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  329. * }
  330. * } );
  331. *
  332. * oTable = $('#example').dataTable();
  333. * } );
  334. */
  335. this.fnClose = function( nTr )
  336. {
  337. this.api( true ).row( nTr ).child.hide();
  338. };
  339. /**
  340. * Remove a row for the table
  341. * @param {mixed} target The index of the row from aoData to be deleted, or
  342. * the TR element you want to delete
  343. * @param {function|null} [callBack] Callback function
  344. * @param {bool} [redraw=true] Redraw the table or not
  345. * @returns {array} The row that was deleted
  346. * @dtopt API
  347. * @deprecated Since v1.10
  348. *
  349. * @example
  350. * $(document).ready(function() {
  351. * var oTable = $('#example').dataTable();
  352. *
  353. * // Immediately remove the first row
  354. * oTable.fnDeleteRow( 0 );
  355. * } );
  356. */
  357. this.fnDeleteRow = function( target, callback, redraw )
  358. {
  359. var api = this.api( true );
  360. var rows = api.rows( target );
  361. var settings = rows.settings()[0];
  362. var data = settings.aoData[ rows[0][0] ];
  363. rows.remove();
  364. if ( callback ) {
  365. callback.call( this, settings, data );
  366. }
  367. if ( redraw === undefined || redraw ) {
  368. api.draw();
  369. }
  370. return data;
  371. };
  372. /**
  373. * Restore the table to it's original state in the DOM by removing all of DataTables
  374. * enhancements, alterations to the DOM structure of the table and event listeners.
  375. * @param {boolean} [remove=false] Completely remove the table from the DOM
  376. * @dtopt API
  377. * @deprecated Since v1.10
  378. *
  379. * @example
  380. * $(document).ready(function() {
  381. * // This example is fairly pointless in reality, but shows how fnDestroy can be used
  382. * var oTable = $('#example').dataTable();
  383. * oTable.fnDestroy();
  384. * } );
  385. */
  386. this.fnDestroy = function ( remove )
  387. {
  388. this.api( true ).destroy( remove );
  389. };
  390. /**
  391. * Redraw the table
  392. * @param {bool} [complete=true] Re-filter and resort (if enabled) the table before the draw.
  393. * @dtopt API
  394. * @deprecated Since v1.10
  395. *
  396. * @example
  397. * $(document).ready(function() {
  398. * var oTable = $('#example').dataTable();
  399. *
  400. * // Re-draw the table - you wouldn't want to do it here, but it's an example :-)
  401. * oTable.fnDraw();
  402. * } );
  403. */
  404. this.fnDraw = function( complete )
  405. {
  406. // Note that this isn't an exact match to the old call to _fnDraw - it takes
  407. // into account the new data, but can hold position.
  408. this.api( true ).draw( complete );
  409. };
  410. /**
  411. * Filter the input based on data
  412. * @param {string} sInput String to filter the table on
  413. * @param {int|null} [iColumn] Column to limit filtering to
  414. * @param {bool} [bRegex=false] Treat as regular expression or not
  415. * @param {bool} [bSmart=true] Perform smart filtering or not
  416. * @param {bool} [bShowGlobal=true] Show the input global filter in it's input box(es)
  417. * @param {bool} [bCaseInsensitive=true] Do case-insensitive matching (true) or not (false)
  418. * @dtopt API
  419. * @deprecated Since v1.10
  420. *
  421. * @example
  422. * $(document).ready(function() {
  423. * var oTable = $('#example').dataTable();
  424. *
  425. * // Sometime later - filter...
  426. * oTable.fnFilter( 'test string' );
  427. * } );
  428. */
  429. this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal, bCaseInsensitive )
  430. {
  431. var api = this.api( true );
  432. if ( iColumn === null || iColumn === undefined ) {
  433. api.search( sInput, bRegex, bSmart, bCaseInsensitive );
  434. }
  435. else {
  436. api.column( iColumn ).search( sInput, bRegex, bSmart, bCaseInsensitive );
  437. }
  438. api.draw();
  439. };
  440. /**
  441. * Get the data for the whole table, an individual row or an individual cell based on the
  442. * provided parameters.
  443. * @param {int|node} [src] A TR row node, TD/TH cell node or an integer. If given as
  444. * a TR node then the data source for the whole row will be returned. If given as a
  445. * TD/TH cell node then iCol will be automatically calculated and the data for the
  446. * cell returned. If given as an integer, then this is treated as the aoData internal
  447. * data index for the row (see fnGetPosition) and the data for that row used.
  448. * @param {int} [col] Optional column index that you want the data of.
  449. * @returns {array|object|string} If mRow is undefined, then the data for all rows is
  450. * returned. If mRow is defined, just data for that row, and is iCol is
  451. * defined, only data for the designated cell is returned.
  452. * @dtopt API
  453. * @deprecated Since v1.10
  454. *
  455. * @example
  456. * // Row data
  457. * $(document).ready(function() {
  458. * oTable = $('#example').dataTable();
  459. *
  460. * oTable.$('tr').click( function () {
  461. * var data = oTable.fnGetData( this );
  462. * // ... do something with the array / object of data for the row
  463. * } );
  464. * } );
  465. *
  466. * @example
  467. * // Individual cell data
  468. * $(document).ready(function() {
  469. * oTable = $('#example').dataTable();
  470. *
  471. * oTable.$('td').click( function () {
  472. * var sData = oTable.fnGetData( this );
  473. * alert( 'The cell clicked on had the value of '+sData );
  474. * } );
  475. * } );
  476. */
  477. this.fnGetData = function( src, col )
  478. {
  479. var api = this.api( true );
  480. if ( src !== undefined ) {
  481. var type = src.nodeName ? src.nodeName.toLowerCase() : '';
  482. return col !== undefined || type == 'td' || type == 'th' ?
  483. api.cell( src, col ).data() :
  484. api.row( src ).data() || null;
  485. }
  486. return api.data().toArray();
  487. };
  488. /**
  489. * Get an array of the TR nodes that are used in the table's body. Note that you will
  490. * typically want to use the '$' API method in preference to this as it is more
  491. * flexible.
  492. * @param {int} [iRow] Optional row index for the TR element you want
  493. * @returns {array|node} If iRow is undefined, returns an array of all TR elements
  494. * in the table's body, or iRow is defined, just the TR element requested.
  495. * @dtopt API
  496. * @deprecated Since v1.10
  497. *
  498. * @example
  499. * $(document).ready(function() {
  500. * var oTable = $('#example').dataTable();
  501. *
  502. * // Get the nodes from the table
  503. * var nNodes = oTable.fnGetNodes( );
  504. * } );
  505. */
  506. this.fnGetNodes = function( iRow )
  507. {
  508. var api = this.api( true );
  509. return iRow !== undefined ?
  510. api.row( iRow ).node() :
  511. api.rows().nodes().flatten().toArray();
  512. };
  513. /**
  514. * Get the array indexes of a particular cell from it's DOM element
  515. * and column index including hidden columns
  516. * @param {node} node this can either be a TR, TD or TH in the table's body
  517. * @returns {int} If nNode is given as a TR, then a single index is returned, or
  518. * if given as a cell, an array of [row index, column index (visible),
  519. * column index (all)] is given.
  520. * @dtopt API
  521. * @deprecated Since v1.10
  522. *
  523. * @example
  524. * $(document).ready(function() {
  525. * $('#example tbody td').click( function () {
  526. * // Get the position of the current data from the node
  527. * var aPos = oTable.fnGetPosition( this );
  528. *
  529. * // Get the data array for this row
  530. * var aData = oTable.fnGetData( aPos[0] );
  531. *
  532. * // Update the data array and return the value
  533. * aData[ aPos[1] ] = 'clicked';
  534. * this.innerHTML = 'clicked';
  535. * } );
  536. *
  537. * // Init DataTables
  538. * oTable = $('#example').dataTable();
  539. * } );
  540. */
  541. this.fnGetPosition = function( node )
  542. {
  543. var api = this.api( true );
  544. var nodeName = node.nodeName.toUpperCase();
  545. if ( nodeName == 'TR' ) {
  546. return api.row( node ).index();
  547. }
  548. else if ( nodeName == 'TD' || nodeName == 'TH' ) {
  549. var cell = api.cell( node ).index();
  550. return [
  551. cell.row,
  552. cell.columnVisible,
  553. cell.column
  554. ];
  555. }
  556. return null;
  557. };
  558. /**
  559. * Check to see if a row is 'open' or not.
  560. * @param {node} nTr the table row to check
  561. * @returns {boolean} true if the row is currently open, false otherwise
  562. * @dtopt API
  563. * @deprecated Since v1.10
  564. *
  565. * @example
  566. * $(document).ready(function() {
  567. * var oTable;
  568. *
  569. * // 'open' an information row when a row is clicked on
  570. * $('#example tbody tr').click( function () {
  571. * if ( oTable.fnIsOpen(this) ) {
  572. * oTable.fnClose( this );
  573. * } else {
  574. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  575. * }
  576. * } );
  577. *
  578. * oTable = $('#example').dataTable();
  579. * } );
  580. */
  581. this.fnIsOpen = function( nTr )
  582. {
  583. return this.api( true ).row( nTr ).child.isShown();
  584. };
  585. /**
  586. * This function will place a new row directly after a row which is currently
  587. * on display on the page, with the HTML contents that is passed into the
  588. * function. This can be used, for example, to ask for confirmation that a
  589. * particular record should be deleted.
  590. * @param {node} nTr The table row to 'open'
  591. * @param {string|node|jQuery} mHtml The HTML to put into the row
  592. * @param {string} sClass Class to give the new TD cell
  593. * @returns {node} The row opened. Note that if the table row passed in as the
  594. * first parameter, is not found in the table, this method will silently
  595. * return.
  596. * @dtopt API
  597. * @deprecated Since v1.10
  598. *
  599. * @example
  600. * $(document).ready(function() {
  601. * var oTable;
  602. *
  603. * // 'open' an information row when a row is clicked on
  604. * $('#example tbody tr').click( function () {
  605. * if ( oTable.fnIsOpen(this) ) {
  606. * oTable.fnClose( this );
  607. * } else {
  608. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  609. * }
  610. * } );
  611. *
  612. * oTable = $('#example').dataTable();
  613. * } );
  614. */
  615. this.fnOpen = function( nTr, mHtml, sClass )
  616. {
  617. return this.api( true )
  618. .row( nTr )
  619. .child( mHtml, sClass )
  620. .show()
  621. .child()[0];
  622. };
  623. /**
  624. * Change the pagination - provides the internal logic for pagination in a simple API
  625. * function. With this function you can have a DataTables table go to the next,
  626. * previous, first or last pages.
  627. * @param {string|int} mAction Paging action to take: "first", "previous", "next" or "last"
  628. * or page number to jump to (integer), note that page 0 is the first page.
  629. * @param {bool} [bRedraw=true] Redraw the table or not
  630. * @dtopt API
  631. * @deprecated Since v1.10
  632. *
  633. * @example
  634. * $(document).ready(function() {
  635. * var oTable = $('#example').dataTable();
  636. * oTable.fnPageChange( 'next' );
  637. * } );
  638. */
  639. this.fnPageChange = function ( mAction, bRedraw )
  640. {
  641. var api = this.api( true ).page( mAction );
  642. if ( bRedraw === undefined || bRedraw ) {
  643. api.draw(false);
  644. }
  645. };
  646. /**
  647. * Show a particular column
  648. * @param {int} iCol The column whose display should be changed
  649. * @param {bool} bShow Show (true) or hide (false) the column
  650. * @param {bool} [bRedraw=true] Redraw the table or not
  651. * @dtopt API
  652. * @deprecated Since v1.10
  653. *
  654. * @example
  655. * $(document).ready(function() {
  656. * var oTable = $('#example').dataTable();
  657. *
  658. * // Hide the second column after initialisation
  659. * oTable.fnSetColumnVis( 1, false );
  660. * } );
  661. */
  662. this.fnSetColumnVis = function ( iCol, bShow, bRedraw )
  663. {
  664. var api = this.api( true ).column( iCol ).visible( bShow );
  665. if ( bRedraw === undefined || bRedraw ) {
  666. api.columns.adjust().draw();
  667. }
  668. };
  669. /**
  670. * Get the settings for a particular table for external manipulation
  671. * @returns {object} DataTables settings object. See
  672. * {@link DataTable.models.oSettings}
  673. * @dtopt API
  674. * @deprecated Since v1.10
  675. *
  676. * @example
  677. * $(document).ready(function() {
  678. * var oTable = $('#example').dataTable();
  679. * var oSettings = oTable.fnSettings();
  680. *
  681. * // Show an example parameter from the settings
  682. * alert( oSettings._iDisplayStart );
  683. * } );
  684. */
  685. this.fnSettings = function()
  686. {
  687. return _fnSettingsFromNode( this[_ext.iApiIndex] );
  688. };
  689. /**
  690. * Sort the table by a particular column
  691. * @param {int} iCol the data index to sort on. Note that this will not match the
  692. * 'display index' if you have hidden data entries
  693. * @dtopt API
  694. * @deprecated Since v1.10
  695. *
  696. * @example
  697. * $(document).ready(function() {
  698. * var oTable = $('#example').dataTable();
  699. *
  700. * // Sort immediately with columns 0 and 1
  701. * oTable.fnSort( [ [0,'asc'], [1,'asc'] ] );
  702. * } );
  703. */
  704. this.fnSort = function( aaSort )
  705. {
  706. this.api( true ).order( aaSort ).draw();
  707. };
  708. /**
  709. * Attach a sort listener to an element for a given column
  710. * @param {node} nNode the element to attach the sort listener to
  711. * @param {int} iColumn the column that a click on this node will sort on
  712. * @param {function} [fnCallback] callback function when sort is run
  713. * @dtopt API
  714. * @deprecated Since v1.10
  715. *
  716. * @example
  717. * $(document).ready(function() {
  718. * var oTable = $('#example').dataTable();
  719. *
  720. * // Sort on column 1, when 'sorter' is clicked on
  721. * oTable.fnSortListener( document.getElementById('sorter'), 1 );
  722. * } );
  723. */
  724. this.fnSortListener = function( nNode, iColumn, fnCallback )
  725. {
  726. this.api( true ).order.listener( nNode, iColumn, fnCallback );
  727. };
  728. /**
  729. * Update a table cell or row - this method will accept either a single value to
  730. * update the cell with, an array of values with one element for each column or
  731. * an object in the same format as the original data source. The function is
  732. * self-referencing in order to make the multi column updates easier.
  733. * @param {object|array|string} mData Data to update the cell/row with
  734. * @param {node|int} mRow TR element you want to update or the aoData index
  735. * @param {int} [iColumn] The column to update, give as null or undefined to
  736. * update a whole row.
  737. * @param {bool} [bRedraw=true] Redraw the table or not
  738. * @param {bool} [bAction=true] Perform pre-draw actions or not
  739. * @returns {int} 0 on success, 1 on error
  740. * @dtopt API
  741. * @deprecated Since v1.10
  742. *
  743. * @example
  744. * $(document).ready(function() {
  745. * var oTable = $('#example').dataTable();
  746. * oTable.fnUpdate( 'Example update', 0, 0 ); // Single cell
  747. * oTable.fnUpdate( ['a', 'b', 'c', 'd', 'e'], $('tbody tr')[0] ); // Row
  748. * } );
  749. */
  750. this.fnUpdate = function( mData, mRow, iColumn, bRedraw, bAction )
  751. {
  752. var api = this.api( true );
  753. if ( iColumn === undefined || iColumn === null ) {
  754. api.row( mRow ).data( mData );
  755. }
  756. else {
  757. api.cell( mRow, iColumn ).data( mData );
  758. }
  759. if ( bAction === undefined || bAction ) {
  760. api.columns.adjust();
  761. }
  762. if ( bRedraw === undefined || bRedraw ) {
  763. api.draw();
  764. }
  765. return 0;
  766. };
  767. /**
  768. * Provide a common method for plug-ins to check the version of DataTables being used, in order
  769. * to ensure compatibility.
  770. * @param {string} sVersion Version string to check for, in the format "X.Y.Z". Note that the
  771. * formats "X" and "X.Y" are also acceptable.
  772. * @returns {boolean} true if this version of DataTables is greater or equal to the required
  773. * version, or false if this version of DataTales is not suitable
  774. * @method
  775. * @dtopt API
  776. * @deprecated Since v1.10
  777. *
  778. * @example
  779. * $(document).ready(function() {
  780. * var oTable = $('#example').dataTable();
  781. * alert( oTable.fnVersionCheck( '1.9.0' ) );
  782. * } );
  783. */
  784. this.fnVersionCheck = _ext.fnVersionCheck;
  785. var _that = this;
  786. var emptyInit = options === undefined;
  787. var len = this.length;
  788. if ( emptyInit ) {
  789. options = {};
  790. }
  791. this.oApi = this.internal = _ext.internal;
  792. // Extend with old style plug-in API methods
  793. for ( var fn in DataTable.ext.internal ) {
  794. if ( fn ) {
  795. this[fn] = _fnExternApiFunc(fn);
  796. }
  797. }
  798. this.each(function() {
  799. // For each initialisation we want to give it a clean initialisation
  800. // object that can be bashed around
  801. var o = {};
  802. var oInit = len > 1 ? // optimisation for single table case
  803. _fnExtend( o, options, true ) :
  804. options;
  805. /*global oInit,_that,emptyInit*/
  806. var i=0, iLen, j, jLen, k, kLen;
  807. var sId = this.getAttribute( 'id' );
  808. var bInitHandedOff = false;
  809. var defaults = DataTable.defaults;
  810. var $this = $(this);
  811. /* Sanity check */
  812. if ( this.nodeName.toLowerCase() != 'table' )
  813. {
  814. _fnLog( null, 0, 'Non-table node initialisation ('+this.nodeName+')', 2 );
  815. return;
  816. }
  817. /* Backwards compatibility for the defaults */
  818. _fnCompatOpts( defaults );
  819. _fnCompatCols( defaults.column );
  820. /* Convert the camel-case defaults to Hungarian */
  821. _fnCamelToHungarian( defaults, defaults, true );
  822. _fnCamelToHungarian( defaults.column, defaults.column, true );
  823. /* Setting up the initialisation object */
  824. _fnCamelToHungarian( defaults, $.extend( oInit, $this.data() ), true );
  825. /* Check to see if we are re-initialising a table */
  826. var allSettings = DataTable.settings;
  827. for ( i=0, iLen=allSettings.length ; i<iLen ; i++ )
  828. {
  829. var s = allSettings[i];
  830. /* Base check on table node */
  831. if (
  832. s.nTable == this ||
  833. (s.nTHead && s.nTHead.parentNode == this) ||
  834. (s.nTFoot && s.nTFoot.parentNode == this)
  835. ) {
  836. var bRetrieve = oInit.bRetrieve !== undefined ? oInit.bRetrieve : defaults.bRetrieve;
  837. var bDestroy = oInit.bDestroy !== undefined ? oInit.bDestroy : defaults.bDestroy;
  838. if ( emptyInit || bRetrieve )
  839. {
  840. return s.oInstance;
  841. }
  842. else if ( bDestroy )
  843. {
  844. s.oInstance.fnDestroy();
  845. break;
  846. }
  847. else
  848. {
  849. _fnLog( s, 0, 'Cannot reinitialise DataTable', 3 );
  850. return;
  851. }
  852. }
  853. /* If the element we are initialising has the same ID as a table which was previously
  854. * initialised, but the table nodes don't match (from before) then we destroy the old
  855. * instance by simply deleting it. This is under the assumption that the table has been
  856. * destroyed by other methods. Anyone using non-id selectors will need to do this manually
  857. */
  858. if ( s.sTableId == this.id )
  859. {
  860. allSettings.splice( i, 1 );
  861. break;
  862. }
  863. }
  864. /* Ensure the table has an ID - required for accessibility */
  865. if ( sId === null || sId === "" )
  866. {
  867. sId = "DataTables_Table_"+(DataTable.ext._unique++);
  868. this.id = sId;
  869. }
  870. /* Create the settings object for this table and set some of the default parameters */
  871. var oSettings = $.extend( true, {}, DataTable.models.oSettings, {
  872. "sDestroyWidth": $this[0].style.width,
  873. "sInstance": sId,
  874. "sTableId": sId
  875. } );
  876. oSettings.nTable = this;
  877. oSettings.oApi = _that.internal;
  878. oSettings.oInit = oInit;
  879. allSettings.push( oSettings );
  880. // Need to add the instance after the instance after the settings object has been added
  881. // to the settings array, so we can self reference the table instance if more than one
  882. oSettings.oInstance = (_that.length===1) ? _that : $this.dataTable();
  883. // Backwards compatibility, before we apply all the defaults
  884. _fnCompatOpts( oInit );
  885. _fnLanguageCompat( oInit.oLanguage );
  886. // If the length menu is given, but the init display length is not, use the length menu
  887. if ( oInit.aLengthMenu && ! oInit.iDisplayLength )
  888. {
  889. oInit.iDisplayLength = Array.isArray( oInit.aLengthMenu[0] ) ?
  890. oInit.aLengthMenu[0][0] : oInit.aLengthMenu[0];
  891. }
  892. // Apply the defaults and init options to make a single init object will all
  893. // options defined from defaults and instance options.
  894. oInit = _fnExtend( $.extend( true, {}, defaults ), oInit );
  895. // Map the initialisation options onto the settings object
  896. _fnMap( oSettings.oFeatures, oInit, [
  897. "bPaginate",
  898. "bLengthChange",
  899. "bFilter",
  900. "bSort",
  901. "bSortMulti",
  902. "bInfo",
  903. "bProcessing",
  904. "bAutoWidth",
  905. "bSortClasses",
  906. "bServerSide",
  907. "bDeferRender"
  908. ] );
  909. _fnMap( oSettings, oInit, [
  910. "asStripeClasses",
  911. "ajax",
  912. "fnServerData",
  913. "fnFormatNumber",
  914. "sServerMethod",
  915. "aaSorting",
  916. "aaSortingFixed",
  917. "aLengthMenu",
  918. "sPaginationType",
  919. "sAjaxSource",
  920. "sAjaxDataProp",
  921. "iStateDuration",
  922. "sDom",
  923. "bSortCellsTop",
  924. "iTabIndex",
  925. "fnStateLoadCallback",
  926. "fnStateSaveCallback",
  927. "renderer",
  928. "searchDelay",
  929. "rowId",
  930. [ "iCookieDuration", "iStateDuration" ], // backwards compat
  931. [ "oSearch", "oPreviousSearch" ],
  932. [ "aoSearchCols", "aoPreSearchCols" ],
  933. [ "iDisplayLength", "_iDisplayLength" ]
  934. ] );
  935. _fnMap( oSettings.oScroll, oInit, [
  936. [ "sScrollX", "sX" ],
  937. [ "sScrollXInner", "sXInner" ],
  938. [ "sScrollY", "sY" ],
  939. [ "bScrollCollapse", "bCollapse" ]
  940. ] );
  941. _fnMap( oSettings.oLanguage, oInit, "fnInfoCallback" );
  942. /* Callback functions which are array driven */
  943. _fnCallbackReg( oSettings, 'aoDrawCallback', oInit.fnDrawCallback, 'user' );
  944. _fnCallbackReg( oSettings, 'aoServerParams', oInit.fnServerParams, 'user' );
  945. _fnCallbackReg( oSettings, 'aoStateSaveParams', oInit.fnStateSaveParams, 'user' );
  946. _fnCallbackReg( oSettings, 'aoStateLoadParams', oInit.fnStateLoadParams, 'user' );
  947. _fnCallbackReg( oSettings, 'aoStateLoaded', oInit.fnStateLoaded, 'user' );
  948. _fnCallbackReg( oSettings, 'aoRowCallback', oInit.fnRowCallback, 'user' );
  949. _fnCallbackReg( oSettings, 'aoRowCreatedCallback', oInit.fnCreatedRow, 'user' );
  950. _fnCallbackReg( oSettings, 'aoHeaderCallback', oInit.fnHeaderCallback, 'user' );
  951. _fnCallbackReg( oSettings, 'aoFooterCallback', oInit.fnFooterCallback, 'user' );
  952. _fnCallbackReg( oSettings, 'aoInitComplete', oInit.fnInitComplete, 'user' );
  953. _fnCallbackReg( oSettings, 'aoPreDrawCallback', oInit.fnPreDrawCallback, 'user' );
  954. oSettings.rowIdFn = _fnGetObjectDataFn( oInit.rowId );
  955. /* Browser support detection */
  956. _fnBrowserDetect( oSettings );
  957. var oClasses = oSettings.oClasses;
  958. $.extend( oClasses, DataTable.ext.classes, oInit.oClasses );
  959. $this.addClass( oClasses.sTable );
  960. if ( oSettings.iInitDisplayStart === undefined )
  961. {
  962. /* Display start point, taking into account the save saving */
  963. oSettings.iInitDisplayStart = oInit.iDisplayStart;
  964. oSettings._iDisplayStart = oInit.iDisplayStart;
  965. }
  966. if ( oInit.iDeferLoading !== null )
  967. {
  968. oSettings.bDeferLoading = true;
  969. var tmp = Array.isArray( oInit.iDeferLoading );
  970. oSettings._iRecordsDisplay = tmp ? oInit.iDeferLoading[0] : oInit.iDeferLoading;
  971. oSettings._iRecordsTotal = tmp ? oInit.iDeferLoading[1] : oInit.iDeferLoading;
  972. }
  973. /* Language definitions */
  974. var oLanguage = oSettings.oLanguage;
  975. $.extend( true, oLanguage, oInit.oLanguage );
  976. if ( oLanguage.sUrl )
  977. {
  978. /* Get the language definitions from a file - because this Ajax call makes the language
  979. * get async to the remainder of this function we use bInitHandedOff to indicate that
  980. * _fnInitialise will be fired by the returned Ajax handler, rather than the constructor
  981. */
  982. $.ajax( {
  983. dataType: 'json',
  984. url: oLanguage.sUrl,
  985. success: function ( json ) {
  986. _fnCamelToHungarian( defaults.oLanguage, json );
  987. _fnLanguageCompat( json );
  988. $.extend( true, oLanguage, json );
  989. _fnCallbackFire( oSettings, null, 'i18n', [oSettings]);
  990. _fnInitialise( oSettings );
  991. },
  992. error: function () {
  993. // Error occurred loading language file, continue on as best we can
  994. _fnInitialise( oSettings );
  995. }
  996. } );
  997. bInitHandedOff = true;
  998. }
  999. else {
  1000. _fnCallbackFire( oSettings, null, 'i18n', [oSettings]);
  1001. }
  1002. /*
  1003. * Stripes
  1004. */
  1005. if ( oInit.asStripeClasses === null )
  1006. {
  1007. oSettings.asStripeClasses =[
  1008. oClasses.sStripeOdd,
  1009. oClasses.sStripeEven
  1010. ];
  1011. }
  1012. /* Remove row stripe classes if they are already on the table row */
  1013. var stripeClasses = oSettings.asStripeClasses;
  1014. var rowOne = $this.children('tbody').find('tr').eq(0);
  1015. if ( $.inArray( true, $.map( stripeClasses, function(el, i) {
  1016. return rowOne.hasClass(el);
  1017. } ) ) !== -1 ) {
  1018. $('tbody tr', this).removeClass( stripeClasses.join(' ') );
  1019. oSettings.asDestroyStripes = stripeClasses.slice();
  1020. }
  1021. /*
  1022. * Columns
  1023. * See if we should load columns automatically or use defined ones
  1024. */
  1025. var anThs = [];
  1026. var aoColumnsInit;
  1027. var nThead = this.getElementsByTagName('thead');
  1028. if ( nThead.length !== 0 )
  1029. {
  1030. _fnDetectHeader( oSettings.aoHeader, nThead[0] );
  1031. anThs = _fnGetUniqueThs( oSettings );
  1032. }
  1033. /* If not given a column array, generate one with nulls */
  1034. if ( oInit.aoColumns === null )
  1035. {
  1036. aoColumnsInit = [];
  1037. for ( i=0, iLen=anThs.length ; i<iLen ; i++ )
  1038. {
  1039. aoColumnsInit.push( null );
  1040. }
  1041. }
  1042. else
  1043. {
  1044. aoColumnsInit = oInit.aoColumns;
  1045. }
  1046. /* Add the columns */
  1047. for ( i=0, iLen=aoColumnsInit.length ; i<iLen ; i++ )
  1048. {
  1049. _fnAddColumn( oSettings, anThs ? anThs[i] : null );
  1050. }
  1051. /* Apply the column definitions */
  1052. _fnApplyColumnDefs( oSettings, oInit.aoColumnDefs, aoColumnsInit, function (iCol, oDef) {
  1053. _fnColumnOptions( oSettings, iCol, oDef );
  1054. } );
  1055. /* HTML5 attribute detection - build an mData object automatically if the
  1056. * attributes are found
  1057. */
  1058. if ( rowOne.length ) {
  1059. var a = function ( cell, name ) {
  1060. return cell.getAttribute( 'data-'+name ) !== null ? name : null;
  1061. };
  1062. $( rowOne[0] ).children('th, td').each( function (i, cell) {
  1063. var col = oSettings.aoColumns[i];
  1064. if ( col.mData === i ) {
  1065. var sort = a( cell, 'sort' ) || a( cell, 'order' );
  1066. var filter = a( cell, 'filter' ) || a( cell, 'search' );
  1067. if ( sort !== null || filter !== null ) {
  1068. col.mData = {
  1069. _: i+'.display',
  1070. sort: sort !== null ? i+'.@data-'+sort : undefined,
  1071. type: sort !== null ? i+'.@data-'+sort : undefined,
  1072. filter: filter !== null ? i+'.@data-'+filter : undefined
  1073. };
  1074. _fnColumnOptions( oSettings, i );
  1075. }
  1076. }
  1077. } );
  1078. }
  1079. var features = oSettings.oFeatures;
  1080. var loadedInit = function () {
  1081. /*
  1082. * Sorting
  1083. * @todo For modularisation (1.11) this needs to do into a sort start up handler
  1084. */
  1085. // If aaSorting is not defined, then we use the first indicator in asSorting
  1086. // in case that has been altered, so the default sort reflects that option
  1087. if ( oInit.aaSorting === undefined ) {
  1088. var sorting = oSettings.aaSorting;
  1089. for ( i=0, iLen=sorting.length ; i<iLen ; i++ ) {
  1090. sorting[i][1] = oSettings.aoColumns[ i ].asSorting[0];
  1091. }
  1092. }
  1093. /* Do a first pass on the sorting classes (allows any size changes to be taken into
  1094. * account, and also will apply sorting disabled classes if disabled
  1095. */
  1096. _fnSortingClasses( oSettings );
  1097. if ( features.bSort ) {
  1098. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  1099. if ( oSettings.bSorted ) {
  1100. var aSort = _fnSortFlatten( oSettings );
  1101. var sortedColumns = {};
  1102. $.each( aSort, function (i, val) {
  1103. sortedColumns[ val.src ] = val.dir;
  1104. } );
  1105. _fnCallbackFire( oSettings, null, 'order', [oSettings, aSort, sortedColumns] );
  1106. _fnSortAria( oSettings );
  1107. }
  1108. } );
  1109. }
  1110. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  1111. if ( oSettings.bSorted || _fnDataSource( oSettings ) === 'ssp' || features.bDeferRender ) {
  1112. _fnSortingClasses( oSettings );
  1113. }
  1114. }, 'sc' );
  1115. /*
  1116. * Final init
  1117. * Cache the header, body and footer as required, creating them if needed
  1118. */
  1119. // Work around for Webkit bug 83867 - store the caption-side before removing from doc
  1120. var captions = $this.children('caption').each( function () {
  1121. this._captionSide = $(this).css('caption-side');
  1122. } );
  1123. var thead = $this.children('thead');
  1124. if ( thead.length === 0 ) {
  1125. thead = $('<thead/>').appendTo($this);
  1126. }
  1127. oSettings.nTHead = thead[0];
  1128. var tbody = $this.children('tbody');
  1129. if ( tbody.length === 0 ) {
  1130. tbody = $('<tbody/>').insertAfter(thead);
  1131. }
  1132. oSettings.nTBody = tbody[0];
  1133. var tfoot = $this.children('tfoot');
  1134. if ( tfoot.length === 0 && captions.length > 0 && (oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "") ) {
  1135. // If we are a scrolling table, and no footer has been given, then we need to create
  1136. // a tfoot element for the caption element to be appended to
  1137. tfoot = $('<tfoot/>').appendTo($this);
  1138. }
  1139. if ( tfoot.length === 0 || tfoot.children().length === 0 ) {
  1140. $this.addClass( oClasses.sNoFooter );
  1141. }
  1142. else if ( tfoot.length > 0 ) {
  1143. oSettings.nTFoot = tfoot[0];
  1144. _fnDetectHeader( oSettings.aoFooter, oSettings.nTFoot );
  1145. }
  1146. /* Check if there is data passing into the constructor */
  1147. if ( oInit.aaData ) {
  1148. for ( i=0 ; i<oInit.aaData.length ; i++ ) {
  1149. _fnAddData( oSettings, oInit.aaData[ i ] );
  1150. }
  1151. }
  1152. else if ( oSettings.bDeferLoading || _fnDataSource( oSettings ) == 'dom' ) {
  1153. /* Grab the data from the page - only do this when deferred loading or no Ajax
  1154. * source since there is no point in reading the DOM data if we are then going
  1155. * to replace it with Ajax data
  1156. */
  1157. _fnAddTr( oSettings, $(oSettings.nTBody).children('tr') );
  1158. }
  1159. /* Copy the data index array */
  1160. oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
  1161. /* Initialisation complete - table can be drawn */
  1162. oSettings.bInitialised = true;
  1163. /* Check if we need to initialise the table (it might not have been handed off to the
  1164. * language processor)
  1165. */
  1166. if ( bInitHandedOff === false ) {
  1167. _fnInitialise( oSettings );
  1168. }
  1169. };
  1170. /* Must be done after everything which can be overridden by the state saving! */
  1171. _fnCallbackReg( oSettings, 'aoDrawCallback', _fnSaveState, 'state_save' );
  1172. if ( oInit.bStateSave )
  1173. {
  1174. features.bStateSave = true;
  1175. _fnLoadState( oSettings, oInit, loadedInit );
  1176. }
  1177. else {
  1178. loadedInit();
  1179. }
  1180. } );
  1181. _that = null;
  1182. return this;
  1183. };
  1184. /*
  1185. * It is useful to have variables which are scoped locally so only the
  1186. * DataTables functions can access them and they don't leak into global space.
  1187. * At the same time these functions are often useful over multiple files in the
  1188. * core and API, so we list, or at least document, all variables which are used
  1189. * by DataTables as private variables here. This also ensures that there is no
  1190. * clashing of variable names and that they can easily referenced for reuse.
  1191. */
  1192. // Defined else where
  1193. // _selector_run
  1194. // _selector_opts
  1195. // _selector_first
  1196. // _selector_row_indexes
  1197. var _ext; // DataTable.ext
  1198. var _Api; // DataTable.Api
  1199. var _api_register; // DataTable.Api.register
  1200. var _api_registerPlural; // DataTable.Api.registerPlural
  1201. var _re_dic = {};
  1202. var _re_new_lines = /[\r\n\u2028]/g;
  1203. var _re_html = /<.*?>/g;
  1204. // This is not strict ISO8601 - Date.parse() is quite lax, although
  1205. // implementations differ between browsers.
  1206. var _re_date = /^\d{2,4}[\.\/\-]\d{1,2}[\.\/\-]\d{1,2}([T ]{1}\d{1,2}[:\.]\d{2}([\.:]\d{2})?)?$/;
  1207. // Escape regular expression special characters
  1208. var _re_escape_regex = new RegExp( '(\\' + [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^', '-' ].join('|\\') + ')', 'g' );
  1209. // http://en.wikipedia.org/wiki/Foreign_exchange_market
  1210. // - \u20BD - Russian ruble.
  1211. // - \u20a9 - South Korean Won
  1212. // - \u20BA - Turkish Lira
  1213. // - \u20B9 - Indian Rupee
  1214. // - R - Brazil (R$) and South Africa
  1215. // - fr - Swiss Franc
  1216. // - kr - Swedish krona, Norwegian krone and Danish krone
  1217. // - \u2009 is thin space and \u202F is narrow no-break space, both used in many
  1218. // - Ƀ - Bitcoin
  1219. // - Ξ - Ethereum
  1220. // standards as thousands separators.
  1221. var _re_formatted_numeric = /['\u00A0,$£€¥%\u2009\u202F\u20BD\u20a9\u20BArfkɃΞ]/gi;
  1222. var _empty = function ( d ) {
  1223. return !d || d === true || d === '-' ? true : false;
  1224. };
  1225. var _intVal = function ( s ) {
  1226. var integer = parseInt( s, 10 );
  1227. return !isNaN(integer) && isFinite(s) ? integer : null;
  1228. };
  1229. // Convert from a formatted number with characters other than `.` as the
  1230. // decimal place, to a Javascript number
  1231. var _numToDecimal = function ( num, decimalPoint ) {
  1232. // Cache created regular expressions for speed as this function is called often
  1233. if ( ! _re_dic[ decimalPoint ] ) {
  1234. _re_dic[ decimalPoint ] = new RegExp( _fnEscapeRegex( decimalPoint ), 'g' );
  1235. }
  1236. return typeof num === 'string' && decimalPoint !== '.' ?
  1237. num.replace( /\./g, '' ).replace( _re_dic[ decimalPoint ], '.' ) :
  1238. num;
  1239. };
  1240. var _isNumber = function ( d, decimalPoint, formatted ) {
  1241. var strType = typeof d === 'string';
  1242. // If empty return immediately so there must be a number if it is a
  1243. // formatted string (this stops the string "k", or "kr", etc being detected
  1244. // as a formatted number for currency
  1245. if ( _empty( d ) ) {
  1246. return true;
  1247. }
  1248. if ( decimalPoint && strType ) {
  1249. d = _numToDecimal( d, decimalPoint );
  1250. }
  1251. if ( formatted && strType ) {
  1252. d = d.replace( _re_formatted_numeric, '' );
  1253. }
  1254. return !isNaN( parseFloat(d) ) && isFinite( d );
  1255. };
  1256. // A string without HTML in it can be considered to be HTML still
  1257. var _isHtml = function ( d ) {
  1258. return _empty( d ) || typeof d === 'string';
  1259. };
  1260. var _htmlNumeric = function ( d, decimalPoint, formatted ) {
  1261. if ( _empty( d ) ) {
  1262. return true;
  1263. }
  1264. var html = _isHtml( d );
  1265. return ! html ?
  1266. null :
  1267. _isNumber( _stripHtml( d ), decimalPoint, formatted ) ?
  1268. true :
  1269. null;
  1270. };
  1271. var _pluck = function ( a, prop, prop2 ) {
  1272. var out = [];
  1273. var i=0, ien=a.length;
  1274. // Could have the test in the loop for slightly smaller code, but speed
  1275. // is essential here
  1276. if ( prop2 !== undefined ) {
  1277. for ( ; i<ien ; i++ ) {
  1278. if ( a[i] && a[i][ prop ] ) {
  1279. out.push( a[i][ prop ][ prop2 ] );
  1280. }
  1281. }
  1282. }
  1283. else {
  1284. for ( ; i<ien ; i++ ) {
  1285. if ( a[i] ) {
  1286. out.push( a[i][ prop ] );
  1287. }
  1288. }
  1289. }
  1290. return out;
  1291. };
  1292. // Basically the same as _pluck, but rather than looping over `a` we use `order`
  1293. // as the indexes to pick from `a`
  1294. var _pluck_order = function ( a, order, prop, prop2 )
  1295. {
  1296. var out = [];
  1297. var i=0, ien=order.length;
  1298. // Could have the test in the loop for slightly smaller code, but speed
  1299. // is essential here
  1300. if ( prop2 !== undefined ) {
  1301. for ( ; i<ien ; i++ ) {
  1302. if ( a[ order[i] ][ prop ] ) {
  1303. out.push( a[ order[i] ][ prop ][ prop2 ] );
  1304. }
  1305. }
  1306. }
  1307. else {
  1308. for ( ; i<ien ; i++ ) {
  1309. out.push( a[ order[i] ][ prop ] );
  1310. }
  1311. }
  1312. return out;
  1313. };
  1314. var _range = function ( len, start )
  1315. {
  1316. var out = [];
  1317. var end;
  1318. if ( start === undefined ) {
  1319. start = 0;
  1320. end = len;
  1321. }
  1322. else {
  1323. end = start;
  1324. start = len;
  1325. }
  1326. for ( var i=start ; i<end ; i++ ) {
  1327. out.push( i );
  1328. }
  1329. return out;
  1330. };
  1331. var _removeEmpty = function ( a )
  1332. {
  1333. var out = [];
  1334. for ( var i=0, ien=a.length ; i<ien ; i++ ) {
  1335. if ( a[i] ) { // careful - will remove all falsy values!
  1336. out.push( a[i] );
  1337. }
  1338. }
  1339. return out;
  1340. };
  1341. var _stripHtml = function ( d ) {
  1342. return d.replace( _re_html, '' );
  1343. };
  1344. /**
  1345. * Determine if all values in the array are unique. This means we can short
  1346. * cut the _unique method at the cost of a single loop. A sorted array is used
  1347. * to easily check the values.
  1348. *
  1349. * @param {array} src Source array
  1350. * @return {boolean} true if all unique, false otherwise
  1351. * @ignore
  1352. */
  1353. var _areAllUnique = function ( src ) {
  1354. if ( src.length < 2 ) {
  1355. return true;
  1356. }
  1357. var sorted = src.slice().sort();
  1358. var last = sorted[0];
  1359. for ( var i=1, ien=sorted.length ; i<ien ; i++ ) {
  1360. if ( sorted[i] === last ) {
  1361. return false;
  1362. }
  1363. last = sorted[i];
  1364. }
  1365. return true;
  1366. };
  1367. /**
  1368. * Find the unique elements in a source array.
  1369. *
  1370. * @param {array} src Source array
  1371. * @return {array} Array of unique items
  1372. * @ignore
  1373. */
  1374. var _unique = function ( src )
  1375. {
  1376. if ( _areAllUnique( src ) ) {
  1377. return src.slice();
  1378. }
  1379. // A faster unique method is to use object keys to identify used values,
  1380. // but this doesn't work with arrays or objects, which we must also
  1381. // consider. See jsperf.com/compare-array-unique-versions/4 for more
  1382. // information.
  1383. var
  1384. out = [],
  1385. val,
  1386. i, ien=src.length,
  1387. j, k=0;
  1388. again: for ( i=0 ; i<ien ; i++ ) {
  1389. val = src[i];
  1390. for ( j=0 ; j<k ; j++ ) {
  1391. if ( out[j] === val ) {
  1392. continue again;
  1393. }
  1394. }
  1395. out.push( val );
  1396. k++;
  1397. }
  1398. return out;
  1399. };
  1400. // Surprisingly this is faster than [].concat.apply
  1401. // https://jsperf.com/flatten-an-array-loop-vs-reduce/2
  1402. var _flatten = function (out, val) {
  1403. if (Array.isArray(val)) {
  1404. for (var i=0 ; i<val.length ; i++) {
  1405. _flatten(out, val[i]);
  1406. }
  1407. }
  1408. else {
  1409. out.push(val);
  1410. }
  1411. return out;
  1412. }
  1413. var _includes = function (search, start) {
  1414. if (start === undefined) {
  1415. start = 0;
  1416. }
  1417. return this.indexOf(search, start) !== -1;
  1418. };
  1419. // Array.isArray polyfill.
  1420. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
  1421. if (! Array.isArray) {
  1422. Array.isArray = function(arg) {
  1423. return Object.prototype.toString.call(arg) === '[object Array]';
  1424. };
  1425. }
  1426. if (! Array.prototype.includes) {
  1427. Array.prototype.includes = _includes;
  1428. }
  1429. // .trim() polyfill
  1430. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim
  1431. if (!String.prototype.trim) {
  1432. String.prototype.trim = function () {
  1433. return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
  1434. };
  1435. }
  1436. if (! String.prototype.includes) {
  1437. String.prototype.includes = _includes;
  1438. }
  1439. /**
  1440. * DataTables utility methods
  1441. *
  1442. * This namespace provides helper methods that DataTables uses internally to
  1443. * create a DataTable, but which are not exclusively used only for DataTables.
  1444. * These methods can be used by extension authors to save the duplication of
  1445. * code.
  1446. *
  1447. * @namespace
  1448. */
  1449. DataTable.util = {
  1450. /**
  1451. * Throttle the calls to a function. Arguments and context are maintained
  1452. * for the throttled function.
  1453. *
  1454. * @param {function} fn Function to be called
  1455. * @param {integer} freq Call frequency in mS
  1456. * @return {function} Wrapped function
  1457. */
  1458. throttle: function ( fn, freq ) {
  1459. var
  1460. frequency = freq !== undefined ? freq : 200,
  1461. last,
  1462. timer;
  1463. return function () {
  1464. var
  1465. that = this,
  1466. now = +new Date(),
  1467. args = arguments;
  1468. if ( last && now < last + frequency ) {
  1469. clearTimeout( timer );
  1470. timer = setTimeout( function () {
  1471. last = undefined;
  1472. fn.apply( that, args );
  1473. }, frequency );
  1474. }
  1475. else {
  1476. last = now;
  1477. fn.apply( that, args );
  1478. }
  1479. };
  1480. },
  1481. /**
  1482. * Escape a string such that it can be used in a regular expression
  1483. *
  1484. * @param {string} val string to escape
  1485. * @returns {string} escaped string
  1486. */
  1487. escapeRegex: function ( val ) {
  1488. return val.replace( _re_escape_regex, '\\$1' );
  1489. },
  1490. /**
  1491. * Create a function that will write to a nested object or array
  1492. * @param {*} source JSON notation string
  1493. * @returns Write function
  1494. */
  1495. set: function ( source ) {
  1496. if ( $.isPlainObject( source ) ) {
  1497. /* Unlike get, only the underscore (global) option is used for for
  1498. * setting data since we don't know the type here. This is why an object
  1499. * option is not documented for `mData` (which is read/write), but it is
  1500. * for `mRender` which is read only.
  1501. */
  1502. return DataTable.util.set( source._ );
  1503. }
  1504. else if ( source === null ) {
  1505. // Nothing to do when the data source is null
  1506. return function () {};
  1507. }
  1508. else if ( typeof source === 'function' ) {
  1509. return function (data, val, meta) {
  1510. source( data, 'set', val, meta );
  1511. };
  1512. }
  1513. else if ( typeof source === 'string' && (source.indexOf('.') !== -1 ||
  1514. source.indexOf('[') !== -1 || source.indexOf('(') !== -1) )
  1515. {
  1516. // Like the get, we need to get data from a nested object
  1517. var setData = function (data, val, src) {
  1518. var a = _fnSplitObjNotation( src ), b;
  1519. var aLast = a[a.length-1];
  1520. var arrayNotation, funcNotation, o, innerSrc;
  1521. for ( var i=0, iLen=a.length-1 ; i<iLen ; i++ ) {
  1522. // Protect against prototype pollution
  1523. if (a[i] === '__proto__' || a[i] === 'constructor') {
  1524. throw new Error('Cannot set prototype values');
  1525. }
  1526. // Check if we are dealing with an array notation request
  1527. arrayNotation = a[i].match(__reArray);
  1528. funcNotation = a[i].match(__reFn);
  1529. if ( arrayNotation ) {
  1530. a[i] = a[i].replace(__reArray, '');
  1531. data[ a[i] ] = [];
  1532. // Get the remainder of the nested object to set so we can recurse
  1533. b = a.slice();
  1534. b.splice( 0, i+1 );
  1535. innerSrc = b.join('.');
  1536. // Traverse each entry in the array setting the properties requested
  1537. if ( Array.isArray( val ) ) {
  1538. for ( var j=0, jLen=val.length ; j<jLen ; j++ ) {
  1539. o = {};
  1540. setData( o, val[j], innerSrc );
  1541. data[ a[i] ].push( o );
  1542. }
  1543. }
  1544. else {
  1545. // We've been asked to save data to an array, but it
  1546. // isn't array data to be saved. Best that can be done
  1547. // is to just save the value.
  1548. data[ a[i] ] = val;
  1549. }
  1550. // The inner call to setData has already traversed through the remainder
  1551. // of the source and has set the data, thus we can exit here
  1552. return;
  1553. }
  1554. else if ( funcNotation ) {
  1555. // Function call
  1556. a[i] = a[i].replace(__reFn, '');
  1557. data = data[ a[i] ]( val );
  1558. }
  1559. // If the nested object doesn't currently exist - since we are
  1560. // trying to set the value - create it
  1561. if ( data[ a[i] ] === null || data[ a[i] ] === undefined ) {
  1562. data[ a[i] ] = {};
  1563. }
  1564. data = data[ a[i] ];
  1565. }
  1566. // Last item in the input - i.e, the actual set
  1567. if ( aLast.match(__reFn ) ) {
  1568. // Function call
  1569. data = data[ aLast.replace(__reFn, '') ]( val );
  1570. }
  1571. else {
  1572. // If array notation is used, we just want to strip it and use the property name
  1573. // and assign the value. If it isn't used, then we get the result we want anyway
  1574. data[ aLast.replace(__reArray, '') ] = val;
  1575. }
  1576. };
  1577. return function (data, val) { // meta is also passed in, but not used
  1578. return setData( data, val, source );
  1579. };
  1580. }
  1581. else {
  1582. // Array or flat object mapping
  1583. return function (data, val) { // meta is also passed in, but not used
  1584. data[source] = val;
  1585. };
  1586. }
  1587. },
  1588. /**
  1589. * Create a function that will read nested objects from arrays, based on JSON notation
  1590. * @param {*} source JSON notation string
  1591. * @returns Value read
  1592. */
  1593. get: function ( source ) {
  1594. if ( $.isPlainObject( source ) ) {
  1595. // Build an object of get functions, and wrap them in a single call
  1596. var o = {};
  1597. $.each( source, function (key, val) {
  1598. if ( val ) {
  1599. o[key] = DataTable.util.get( val );
  1600. }
  1601. } );
  1602. return function (data, type, row, meta) {
  1603. var t = o[type] || o._;
  1604. return t !== undefined ?
  1605. t(data, type, row, meta) :
  1606. data;
  1607. };
  1608. }
  1609. else if ( source === null ) {
  1610. // Give an empty string for rendering / sorting etc
  1611. return function (data) { // type, row and meta also passed, but not used
  1612. return data;
  1613. };
  1614. }
  1615. else if ( typeof source === 'function' ) {
  1616. return function (data, type, row, meta) {
  1617. return source( data, type, row, meta );
  1618. };
  1619. }
  1620. else if ( typeof source === 'string' && (source.indexOf('.') !== -1 ||
  1621. source.indexOf('[') !== -1 || source.indexOf('(') !== -1) )
  1622. {
  1623. /* If there is a . in the source string then the data source is in a
  1624. * nested object so we loop over the data for each level to get the next
  1625. * level down. On each loop we test for undefined, and if found immediately
  1626. * return. This allows entire objects to be missing and sDefaultContent to
  1627. * be used if defined, rather than throwing an error
  1628. */
  1629. var fetchData = function (data, type, src) {
  1630. var arrayNotation, funcNotation, out, innerSrc;
  1631. if ( src !== "" ) {
  1632. var a = _fnSplitObjNotation( src );
  1633. for ( var i=0, iLen=a.length ; i<iLen ; i++ ) {
  1634. // Check if we are dealing with special notation
  1635. arrayNotation = a[i].match(__reArray);
  1636. funcNotation = a[i].match(__reFn);
  1637. if ( arrayNotation ) {
  1638. // Array notation
  1639. a[i] = a[i].replace(__reArray, '');
  1640. // Condition allows simply [] to be passed in
  1641. if ( a[i] !== "" ) {
  1642. data = data[ a[i] ];
  1643. }
  1644. out = [];
  1645. // Get the remainder of the nested object to get
  1646. a.splice( 0, i+1 );
  1647. innerSrc = a.join('.');
  1648. // Traverse each entry in the array getting the properties requested
  1649. if ( Array.isArray( data ) ) {
  1650. for ( var j=0, jLen=data.length ; j<jLen ; j++ ) {
  1651. out.push( fetchData( data[j], type, innerSrc ) );
  1652. }
  1653. }
  1654. // If a string is given in between the array notation indicators, that
  1655. // is used to join the strings together, otherwise an array is returned
  1656. var join = arrayNotation[0].substring(1, arrayNotation[0].length-1);
  1657. data = (join==="") ? out : out.join(join);
  1658. // The inner call to fetchData has already traversed through the remainder
  1659. // of the source requested, so we exit from the loop
  1660. break;
  1661. }
  1662. else if ( funcNotation ) {
  1663. // Function call
  1664. a[i] = a[i].replace(__reFn, '');
  1665. data = data[ a[i] ]();
  1666. continue;
  1667. }
  1668. if ( data === null || data[ a[i] ] === undefined ) {
  1669. return undefined;
  1670. }
  1671. data = data[ a[i] ];
  1672. }
  1673. }
  1674. return data;
  1675. };
  1676. return function (data, type) { // row and meta also passed, but not used
  1677. return fetchData( data, type, source );
  1678. };
  1679. }
  1680. else {
  1681. // Array or flat object mapping
  1682. return function (data, type) { // row and meta also passed, but not used
  1683. return data[source];
  1684. };
  1685. }
  1686. }
  1687. };
  1688. /**
  1689. * Create a mapping object that allows camel case parameters to be looked up
  1690. * for their Hungarian counterparts. The mapping is stored in a private
  1691. * parameter called `_hungarianMap` which can be accessed on the source object.
  1692. * @param {object} o
  1693. * @memberof DataTable#oApi
  1694. */
  1695. function _fnHungarianMap ( o )
  1696. {
  1697. var
  1698. hungarian = 'a aa ai ao as b fn i m o s ',
  1699. match,
  1700. newKey,
  1701. map = {};
  1702. $.each( o, function (key, val) {
  1703. match = key.match(/^([^A-Z]+?)([A-Z])/);
  1704. if ( match && hungarian.indexOf(match[1]+' ') !== -1 )
  1705. {
  1706. newKey = key.replace( match[0], match[2].toLowerCase() );
  1707. map[ newKey ] = key;
  1708. if ( match[1] === 'o' )
  1709. {
  1710. _fnHungarianMap( o[key] );
  1711. }
  1712. }
  1713. } );
  1714. o._hungarianMap = map;
  1715. }
  1716. /**
  1717. * Convert from camel case parameters to Hungarian, based on a Hungarian map
  1718. * created by _fnHungarianMap.
  1719. * @param {object} src The model object which holds all parameters that can be
  1720. * mapped.
  1721. * @param {object} user The object to convert from camel case to Hungarian.
  1722. * @param {boolean} force When set to `true`, properties which already have a
  1723. * Hungarian value in the `user` object will be overwritten. Otherwise they
  1724. * won't be.
  1725. * @memberof DataTable#oApi
  1726. */
  1727. function _fnCamelToHungarian ( src, user, force )
  1728. {
  1729. if ( ! src._hungarianMap ) {
  1730. _fnHungarianMap( src );
  1731. }
  1732. var hungarianKey;
  1733. $.each( user, function (key, val) {
  1734. hungarianKey = src._hungarianMap[ key ];
  1735. if ( hungarianKey !== undefined && (force || user[hungarianKey] === undefined) )
  1736. {
  1737. // For objects, we need to buzz down into the object to copy parameters
  1738. if ( hungarianKey.charAt(0) === 'o' )
  1739. {
  1740. // Copy the camelCase options over to the hungarian
  1741. if ( ! user[ hungarianKey ] ) {
  1742. user[ hungarianKey ] = {};
  1743. }
  1744. $.extend( true, user[hungarianKey], user[key] );
  1745. _fnCamelToHungarian( src[hungarianKey], user[hungarianKey], force );
  1746. }
  1747. else {
  1748. user[hungarianKey] = user[ key ];
  1749. }
  1750. }
  1751. } );
  1752. }
  1753. /**
  1754. * Language compatibility - when certain options are given, and others aren't, we
  1755. * need to duplicate the values over, in order to provide backwards compatibility
  1756. * with older language files.
  1757. * @param {object} oSettings dataTables settings object
  1758. * @memberof DataTable#oApi
  1759. */
  1760. function _fnLanguageCompat( lang )
  1761. {
  1762. // Note the use of the Hungarian notation for the parameters in this method as
  1763. // this is called after the mapping of camelCase to Hungarian
  1764. var defaults = DataTable.defaults.oLanguage;
  1765. // Default mapping
  1766. var defaultDecimal = defaults.sDecimal;
  1767. if ( defaultDecimal ) {
  1768. _addNumericSort( defaultDecimal );
  1769. }
  1770. if ( lang ) {
  1771. var zeroRecords = lang.sZeroRecords;
  1772. // Backwards compatibility - if there is no sEmptyTable given, then use the same as
  1773. // sZeroRecords - assuming that is given.
  1774. if ( ! lang.sEmptyTable && zeroRecords &&
  1775. defaults.sEmptyTable === "No data available in table" )
  1776. {
  1777. _fnMap( lang, lang, 'sZeroRecords', 'sEmptyTable' );
  1778. }
  1779. // Likewise with loading records
  1780. if ( ! lang.sLoadingRecords && zeroRecords &&
  1781. defaults.sLoadingRecords === "Loading..." )
  1782. {
  1783. _fnMap( lang, lang, 'sZeroRecords', 'sLoadingRecords' );
  1784. }
  1785. // Old parameter name of the thousands separator mapped onto the new
  1786. if ( lang.sInfoThousands ) {
  1787. lang.sThousands = lang.sInfoThousands;
  1788. }
  1789. var decimal = lang.sDecimal;
  1790. if ( decimal && defaultDecimal !== decimal ) {
  1791. _addNumericSort( decimal );
  1792. }
  1793. }
  1794. }
  1795. /**
  1796. * Map one parameter onto another
  1797. * @param {object} o Object to map
  1798. * @param {*} knew The new parameter name
  1799. * @param {*} old The old parameter name
  1800. */
  1801. var _fnCompatMap = function ( o, knew, old ) {
  1802. if ( o[ knew ] !== undefined ) {
  1803. o[ old ] = o[ knew ];
  1804. }
  1805. };
  1806. /**
  1807. * Provide backwards compatibility for the main DT options. Note that the new
  1808. * options are mapped onto the old parameters, so this is an external interface
  1809. * change only.
  1810. * @param {object} init Object to map
  1811. */
  1812. function _fnCompatOpts ( init )
  1813. {
  1814. _fnCompatMap( init, 'ordering', 'bSort' );
  1815. _fnCompatMap( init, 'orderMulti', 'bSortMulti' );
  1816. _fnCompatMap( init, 'orderClasses', 'bSortClasses' );
  1817. _fnCompatMap( init, 'orderCellsTop', 'bSortCellsTop' );
  1818. _fnCompatMap( init, 'order', 'aaSorting' );
  1819. _fnCompatMap( init, 'orderFixed', 'aaSortingFixed' );
  1820. _fnCompatMap( init, 'paging', 'bPaginate' );
  1821. _fnCompatMap( init, 'pagingType', 'sPaginationType' );
  1822. _fnCompatMap( init, 'pageLength', 'iDisplayLength' );
  1823. _fnCompatMap( init, 'searching', 'bFilter' );
  1824. // Boolean initialisation of x-scrolling
  1825. if ( typeof init.sScrollX === 'boolean' ) {
  1826. init.sScrollX = init.sScrollX ? '100%' : '';
  1827. }
  1828. if ( typeof init.scrollX === 'boolean' ) {
  1829. init.scrollX = init.scrollX ? '100%' : '';
  1830. }
  1831. // Column search objects are in an array, so it needs to be converted
  1832. // element by element
  1833. var searchCols = init.aoSearchCols;
  1834. if ( searchCols ) {
  1835. for ( var i=0, ien=searchCols.length ; i<ien ; i++ ) {
  1836. if ( searchCols[i] ) {
  1837. _fnCamelToHungarian( DataTable.models.oSearch, searchCols[i] );
  1838. }
  1839. }
  1840. }
  1841. }
  1842. /**
  1843. * Provide backwards compatibility for column options. Note that the new options
  1844. * are mapped onto the old parameters, so this is an external interface change
  1845. * only.
  1846. * @param {object} init Object to map
  1847. */
  1848. function _fnCompatCols ( init )
  1849. {
  1850. _fnCompatMap( init, 'orderable', 'bSortable' );
  1851. _fnCompatMap( init, 'orderData', 'aDataSort' );
  1852. _fnCompatMap( init, 'orderSequence', 'asSorting' );
  1853. _fnCompatMap( init, 'orderDataType', 'sortDataType' );
  1854. // orderData can be given as an integer
  1855. var dataSort = init.aDataSort;
  1856. if ( typeof dataSort === 'number' && ! Array.isArray( dataSort ) ) {
  1857. init.aDataSort = [ dataSort ];
  1858. }
  1859. }
  1860. /**
  1861. * Browser feature detection for capabilities, quirks
  1862. * @param {object} settings dataTables settings object
  1863. * @memberof DataTable#oApi
  1864. */
  1865. function _fnBrowserDetect( settings )
  1866. {
  1867. // We don't need to do this every time DataTables is constructed, the values
  1868. // calculated are specific to the browser and OS configuration which we
  1869. // don't expect to change between initialisations
  1870. if ( ! DataTable.__browser ) {
  1871. var browser = {};
  1872. DataTable.__browser = browser;
  1873. // Scrolling feature / quirks detection
  1874. var n = $('<div/>')
  1875. .css( {
  1876. position: 'fixed',
  1877. top: 0,
  1878. left: $(window).scrollLeft()*-1, // allow for scrolling
  1879. height: 1,
  1880. width: 1,
  1881. overflow: 'hidden'
  1882. } )
  1883. .append(
  1884. $('<div/>')
  1885. .css( {
  1886. position: 'absolute',
  1887. top: 1,
  1888. left: 1,
  1889. width: 100,
  1890. overflow: 'scroll'
  1891. } )
  1892. .append(
  1893. $('<div/>')
  1894. .css( {
  1895. width: '100%',
  1896. height: 10
  1897. } )
  1898. )
  1899. )
  1900. .appendTo( 'body' );
  1901. var outer = n.children();
  1902. var inner = outer.children();
  1903. // Numbers below, in order, are:
  1904. // inner.offsetWidth, inner.clientWidth, outer.offsetWidth, outer.clientWidth
  1905. //
  1906. // IE6 XP: 100 100 100 83
  1907. // IE7 Vista: 100 100 100 83
  1908. // IE 8+ Windows: 83 83 100 83
  1909. // Evergreen Windows: 83 83 100 83
  1910. // Evergreen Mac with scrollbars: 85 85 100 85
  1911. // Evergreen Mac without scrollbars: 100 100 100 100
  1912. // Get scrollbar width
  1913. browser.barWidth = outer[0].offsetWidth - outer[0].clientWidth;
  1914. // IE6/7 will oversize a width 100% element inside a scrolling element, to
  1915. // include the width of the scrollbar, while other browsers ensure the inner
  1916. // element is contained without forcing scrolling
  1917. browser.bScrollOversize = inner[0].offsetWidth === 100 && outer[0].clientWidth !== 100;
  1918. // In rtl text layout, some browsers (most, but not all) will place the
  1919. // scrollbar on the left, rather than the right.
  1920. browser.bScrollbarLeft = Math.round( inner.offset().left ) !== 1;
  1921. // IE8- don't provide height and width for getBoundingClientRect
  1922. browser.bBounding = n[0].getBoundingClientRect().width ? true : false;
  1923. n.remove();
  1924. }
  1925. $.extend( settings.oBrowser, DataTable.__browser );
  1926. settings.oScroll.iBarWidth = DataTable.__browser.barWidth;
  1927. }
  1928. /**
  1929. * Array.prototype reduce[Right] method, used for browsers which don't support
  1930. * JS 1.6. Done this way to reduce code size, since we iterate either way
  1931. * @param {object} settings dataTables settings object
  1932. * @memberof DataTable#oApi
  1933. */
  1934. function _fnReduce ( that, fn, init, start, end, inc )
  1935. {
  1936. var
  1937. i = start,
  1938. value,
  1939. isSet = false;
  1940. if ( init !== undefined ) {
  1941. value = init;
  1942. isSet = true;
  1943. }
  1944. while ( i !== end ) {
  1945. if ( ! that.hasOwnProperty(i) ) {
  1946. continue;
  1947. }
  1948. value = isSet ?
  1949. fn( value, that[i], i, that ) :
  1950. that[i];
  1951. isSet = true;
  1952. i += inc;
  1953. }
  1954. return value;
  1955. }
  1956. /**
  1957. * Add a column to the list used for the table with default values
  1958. * @param {object} oSettings dataTables settings object
  1959. * @param {node} nTh The th element for this column
  1960. * @memberof DataTable#oApi
  1961. */
  1962. function _fnAddColumn( oSettings, nTh )
  1963. {
  1964. // Add column to aoColumns array
  1965. var oDefaults = DataTable.defaults.column;
  1966. var iCol = oSettings.aoColumns.length;
  1967. var oCol = $.extend( {}, DataTable.models.oColumn, oDefaults, {
  1968. "nTh": nTh ? nTh : document.createElement('th'),
  1969. "sTitle": oDefaults.sTitle ? oDefaults.sTitle : nTh ? nTh.innerHTML : '',
  1970. "aDataSort": oDefaults.aDataSort ? oDefaults.aDataSort : [iCol],
  1971. "mData": oDefaults.mData ? oDefaults.mData : iCol,
  1972. idx: iCol
  1973. } );
  1974. oSettings.aoColumns.push( oCol );
  1975. // Add search object for column specific search. Note that the `searchCols[ iCol ]`
  1976. // passed into extend can be undefined. This allows the user to give a default
  1977. // with only some of the parameters defined, and also not give a default
  1978. var searchCols = oSettings.aoPreSearchCols;
  1979. searchCols[ iCol ] = $.extend( {}, DataTable.models.oSearch, searchCols[ iCol ] );
  1980. // Use the default column options function to initialise classes etc
  1981. _fnColumnOptions( oSettings, iCol, $(nTh).data() );
  1982. }
  1983. /**
  1984. * Apply options for a column
  1985. * @param {object} oSettings dataTables settings object
  1986. * @param {int} iCol column index to consider
  1987. * @param {object} oOptions object with sType, bVisible and bSearchable etc
  1988. * @memberof DataTable#oApi
  1989. */
  1990. function _fnColumnOptions( oSettings, iCol, oOptions )
  1991. {
  1992. var oCol = oSettings.aoColumns[ iCol ];
  1993. var oClasses = oSettings.oClasses;
  1994. var th = $(oCol.nTh);
  1995. // Try to get width information from the DOM. We can't get it from CSS
  1996. // as we'd need to parse the CSS stylesheet. `width` option can override
  1997. if ( ! oCol.sWidthOrig ) {
  1998. // Width attribute
  1999. oCol.sWidthOrig = th.attr('width') || null;
  2000. // Style attribute
  2001. var t = (th.attr('style') || '').match(/width:\s*(\d+[pxem%]+)/);
  2002. if ( t ) {
  2003. oCol.sWidthOrig = t[1];
  2004. }
  2005. }
  2006. /* User specified column options */
  2007. if ( oOptions !== undefined && oOptions !== null )
  2008. {
  2009. // Backwards compatibility
  2010. _fnCompatCols( oOptions );
  2011. // Map camel case parameters to their Hungarian counterparts
  2012. _fnCamelToHungarian( DataTable.defaults.column, oOptions, true );
  2013. /* Backwards compatibility for mDataProp */
  2014. if ( oOptions.mDataProp !== undefined && !oOptions.mData )
  2015. {
  2016. oOptions.mData = oOptions.mDataProp;
  2017. }
  2018. if ( oOptions.sType )
  2019. {
  2020. oCol._sManualType = oOptions.sType;
  2021. }
  2022. // `class` is a reserved word in Javascript, so we need to provide
  2023. // the ability to use a valid name for the camel case input
  2024. if ( oOptions.className && ! oOptions.sClass )
  2025. {
  2026. oOptions.sClass = oOptions.className;
  2027. }
  2028. if ( oOptions.sClass ) {
  2029. th.addClass( oOptions.sClass );
  2030. }
  2031. $.extend( oCol, oOptions );
  2032. _fnMap( oCol, oOptions, "sWidth", "sWidthOrig" );
  2033. /* iDataSort to be applied (backwards compatibility), but aDataSort will take
  2034. * priority if defined
  2035. */
  2036. if ( oOptions.iDataSort !== undefined )
  2037. {
  2038. oCol.aDataSort = [ oOptions.iDataSort ];
  2039. }
  2040. _fnMap( oCol, oOptions, "aDataSort" );
  2041. }
  2042. /* Cache the data get and set functions for speed */
  2043. var mDataSrc = oCol.mData;
  2044. var mData = _fnGetObjectDataFn( mDataSrc );
  2045. var mRender = oCol.mRender ? _fnGetObjectDataFn( oCol.mRender ) : null;
  2046. var attrTest = function( src ) {
  2047. return typeof src === 'string' && src.indexOf('@') !== -1;
  2048. };
  2049. oCol._bAttrSrc = $.isPlainObject( mDataSrc ) && (
  2050. attrTest(mDataSrc.sort) || attrTest(mDataSrc.type) || attrTest(mDataSrc.filter)
  2051. );
  2052. oCol._setter = null;
  2053. oCol.fnGetData = function (rowData, type, meta) {
  2054. var innerData = mData( rowData, type, undefined, meta );
  2055. return mRender && type ?
  2056. mRender( innerData, type, rowData, meta ) :
  2057. innerData;
  2058. };
  2059. oCol.fnSetData = function ( rowData, val, meta ) {
  2060. return _fnSetObjectDataFn( mDataSrc )( rowData, val, meta );
  2061. };
  2062. // Indicate if DataTables should read DOM data as an object or array
  2063. // Used in _fnGetRowElements
  2064. if ( typeof mDataSrc !== 'number' ) {
  2065. oSettings._rowReadObject = true;
  2066. }
  2067. /* Feature sorting overrides column specific when off */
  2068. if ( !oSettings.oFeatures.bSort )
  2069. {
  2070. oCol.bSortable = false;
  2071. th.addClass( oClasses.sSortableNone ); // Have to add class here as order event isn't called
  2072. }
  2073. /* Check that the class assignment is correct for sorting */
  2074. var bAsc = $.inArray('asc', oCol.asSorting) !== -1;
  2075. var bDesc = $.inArray('desc', oCol.asSorting) !== -1;
  2076. if ( !oCol.bSortable || (!bAsc && !bDesc) )
  2077. {
  2078. oCol.sSortingClass = oClasses.sSortableNone;
  2079. oCol.sSortingClassJUI = "";
  2080. }
  2081. else if ( bAsc && !bDesc )
  2082. {
  2083. oCol.sSortingClass = oClasses.sSortableAsc;
  2084. oCol.sSortingClassJUI = oClasses.sSortJUIAscAllowed;
  2085. }
  2086. else if ( !bAsc && bDesc )
  2087. {
  2088. oCol.sSortingClass = oClasses.sSortableDesc;
  2089. oCol.sSortingClassJUI = oClasses.sSortJUIDescAllowed;
  2090. }
  2091. else
  2092. {
  2093. oCol.sSortingClass = oClasses.sSortable;
  2094. oCol.sSortingClassJUI = oClasses.sSortJUI;
  2095. }
  2096. }
  2097. /**
  2098. * Adjust the table column widths for new data. Note: you would probably want to
  2099. * do a redraw after calling this function!
  2100. * @param {object} settings dataTables settings object
  2101. * @memberof DataTable#oApi
  2102. */
  2103. function _fnAdjustColumnSizing ( settings )
  2104. {
  2105. /* Not interested in doing column width calculation if auto-width is disabled */
  2106. if ( settings.oFeatures.bAutoWidth !== false )
  2107. {
  2108. var columns = settings.aoColumns;
  2109. _fnCalculateColumnWidths( settings );
  2110. for ( var i=0 , iLen=columns.length ; i<iLen ; i++ )
  2111. {
  2112. columns[i].nTh.style.width = columns[i].sWidth;
  2113. }
  2114. }
  2115. var scroll = settings.oScroll;
  2116. if ( scroll.sY !== '' || scroll.sX !== '')
  2117. {
  2118. _fnScrollDraw( settings );
  2119. }
  2120. _fnCallbackFire( settings, null, 'column-sizing', [settings] );
  2121. }
  2122. /**
  2123. * Convert the index of a visible column to the index in the data array (take account
  2124. * of hidden columns)
  2125. * @param {object} oSettings dataTables settings object
  2126. * @param {int} iMatch Visible column index to lookup
  2127. * @returns {int} i the data index
  2128. * @memberof DataTable#oApi
  2129. */
  2130. function _fnVisibleToColumnIndex( oSettings, iMatch )
  2131. {
  2132. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  2133. return typeof aiVis[iMatch] === 'number' ?
  2134. aiVis[iMatch] :
  2135. null;
  2136. }
  2137. /**
  2138. * Convert the index of an index in the data array and convert it to the visible
  2139. * column index (take account of hidden columns)
  2140. * @param {int} iMatch Column index to lookup
  2141. * @param {object} oSettings dataTables settings object
  2142. * @returns {int} i the data index
  2143. * @memberof DataTable#oApi
  2144. */
  2145. function _fnColumnIndexToVisible( oSettings, iMatch )
  2146. {
  2147. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  2148. var iPos = $.inArray( iMatch, aiVis );
  2149. return iPos !== -1 ? iPos : null;
  2150. }
  2151. /**
  2152. * Get the number of visible columns
  2153. * @param {object} oSettings dataTables settings object
  2154. * @returns {int} i the number of visible columns
  2155. * @memberof DataTable#oApi
  2156. */
  2157. function _fnVisbleColumns( oSettings )
  2158. {
  2159. var vis = 0;
  2160. // No reduce in IE8, use a loop for now
  2161. $.each( oSettings.aoColumns, function ( i, col ) {
  2162. if ( col.bVisible && $(col.nTh).css('display') !== 'none' ) {
  2163. vis++;
  2164. }
  2165. } );
  2166. return vis;
  2167. }
  2168. /**
  2169. * Get an array of column indexes that match a given property
  2170. * @param {object} oSettings dataTables settings object
  2171. * @param {string} sParam Parameter in aoColumns to look for - typically
  2172. * bVisible or bSearchable
  2173. * @returns {array} Array of indexes with matched properties
  2174. * @memberof DataTable#oApi
  2175. */
  2176. function _fnGetColumns( oSettings, sParam )
  2177. {
  2178. var a = [];
  2179. $.map( oSettings.aoColumns, function(val, i) {
  2180. if ( val[sParam] ) {
  2181. a.push( i );
  2182. }
  2183. } );
  2184. return a;
  2185. }
  2186. /**
  2187. * Calculate the 'type' of a column
  2188. * @param {object} settings dataTables settings object
  2189. * @memberof DataTable#oApi
  2190. */
  2191. function _fnColumnTypes ( settings )
  2192. {
  2193. var columns = settings.aoColumns;
  2194. var data = settings.aoData;
  2195. var types = DataTable.ext.type.detect;
  2196. var i, ien, j, jen, k, ken;
  2197. var col, cell, detectedType, cache;
  2198. // For each column, spin over the
  2199. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  2200. col = columns[i];
  2201. cache = [];
  2202. if ( ! col.sType && col._sManualType ) {
  2203. col.sType = col._sManualType;
  2204. }
  2205. else if ( ! col.sType ) {
  2206. for ( j=0, jen=types.length ; j<jen ; j++ ) {
  2207. for ( k=0, ken=data.length ; k<ken ; k++ ) {
  2208. // Use a cache array so we only need to get the type data
  2209. // from the formatter once (when using multiple detectors)
  2210. if ( cache[k] === undefined ) {
  2211. cache[k] = _fnGetCellData( settings, k, i, 'type' );
  2212. }
  2213. detectedType = types[j]( cache[k], settings );
  2214. // If null, then this type can't apply to this column, so
  2215. // rather than testing all cells, break out. There is an
  2216. // exception for the last type which is `html`. We need to
  2217. // scan all rows since it is possible to mix string and HTML
  2218. // types
  2219. if ( ! detectedType && j !== types.length-1 ) {
  2220. break;
  2221. }
  2222. // Only a single match is needed for html type since it is
  2223. // bottom of the pile and very similar to string - but it
  2224. // must not be empty
  2225. if ( detectedType === 'html' && ! _empty(cache[k]) ) {
  2226. break;
  2227. }
  2228. }
  2229. // Type is valid for all data points in the column - use this
  2230. // type
  2231. if ( detectedType ) {
  2232. col.sType = detectedType;
  2233. break;
  2234. }
  2235. }
  2236. // Fall back - if no type was detected, always use string
  2237. if ( ! col.sType ) {
  2238. col.sType = 'string';
  2239. }
  2240. }
  2241. }
  2242. }
  2243. /**
  2244. * Take the column definitions and static columns arrays and calculate how
  2245. * they relate to column indexes. The callback function will then apply the
  2246. * definition found for a column to a suitable configuration object.
  2247. * @param {object} oSettings dataTables settings object
  2248. * @param {array} aoColDefs The aoColumnDefs array that is to be applied
  2249. * @param {array} aoCols The aoColumns array that defines columns individually
  2250. * @param {function} fn Callback function - takes two parameters, the calculated
  2251. * column index and the definition for that column.
  2252. * @memberof DataTable#oApi
  2253. */
  2254. function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, fn )
  2255. {
  2256. var i, iLen, j, jLen, k, kLen, def;
  2257. var columns = oSettings.aoColumns;
  2258. // Column definitions with aTargets
  2259. if ( aoColDefs )
  2260. {
  2261. /* Loop over the definitions array - loop in reverse so first instance has priority */
  2262. for ( i=aoColDefs.length-1 ; i>=0 ; i-- )
  2263. {
  2264. def = aoColDefs[i];
  2265. /* Each definition can target multiple columns, as it is an array */
  2266. var aTargets = def.targets !== undefined ?
  2267. def.targets :
  2268. def.aTargets;
  2269. if ( ! Array.isArray( aTargets ) )
  2270. {
  2271. aTargets = [ aTargets ];
  2272. }
  2273. for ( j=0, jLen=aTargets.length ; j<jLen ; j++ )
  2274. {
  2275. if ( typeof aTargets[j] === 'number' && aTargets[j] >= 0 )
  2276. {
  2277. /* Add columns that we don't yet know about */
  2278. while( columns.length <= aTargets[j] )
  2279. {
  2280. _fnAddColumn( oSettings );
  2281. }
  2282. /* Integer, basic index */
  2283. fn( aTargets[j], def );
  2284. }
  2285. else if ( typeof aTargets[j] === 'number' && aTargets[j] < 0 )
  2286. {
  2287. /* Negative integer, right to left column counting */
  2288. fn( columns.length+aTargets[j], def );
  2289. }
  2290. else if ( typeof aTargets[j] === 'string' )
  2291. {
  2292. /* Class name matching on TH element */
  2293. for ( k=0, kLen=columns.length ; k<kLen ; k++ )
  2294. {
  2295. if ( aTargets[j] == "_all" ||
  2296. $(columns[k].nTh).hasClass( aTargets[j] ) )
  2297. {
  2298. fn( k, def );
  2299. }
  2300. }
  2301. }
  2302. }
  2303. }
  2304. }
  2305. // Statically defined columns array
  2306. if ( aoCols )
  2307. {
  2308. for ( i=0, iLen=aoCols.length ; i<iLen ; i++ )
  2309. {
  2310. fn( i, aoCols[i] );
  2311. }
  2312. }
  2313. }
  2314. /**
  2315. * Add a data array to the table, creating DOM node etc. This is the parallel to
  2316. * _fnGatherData, but for adding rows from a Javascript source, rather than a
  2317. * DOM source.
  2318. * @param {object} oSettings dataTables settings object
  2319. * @param {array} aData data array to be added
  2320. * @param {node} [nTr] TR element to add to the table - optional. If not given,
  2321. * DataTables will create a row automatically
  2322. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  2323. * if nTr is.
  2324. * @returns {int} >=0 if successful (index of new aoData entry), -1 if failed
  2325. * @memberof DataTable#oApi
  2326. */
  2327. function _fnAddData ( oSettings, aDataIn, nTr, anTds )
  2328. {
  2329. /* Create the object for storing information about this new row */
  2330. var iRow = oSettings.aoData.length;
  2331. var oData = $.extend( true, {}, DataTable.models.oRow, {
  2332. src: nTr ? 'dom' : 'data',
  2333. idx: iRow
  2334. } );
  2335. oData._aData = aDataIn;
  2336. oSettings.aoData.push( oData );
  2337. /* Create the cells */
  2338. var nTd, sThisType;
  2339. var columns = oSettings.aoColumns;
  2340. // Invalidate the column types as the new data needs to be revalidated
  2341. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  2342. {
  2343. columns[i].sType = null;
  2344. }
  2345. /* Add to the display array */
  2346. oSettings.aiDisplayMaster.push( iRow );
  2347. var id = oSettings.rowIdFn( aDataIn );
  2348. if ( id !== undefined ) {
  2349. oSettings.aIds[ id ] = oData;
  2350. }
  2351. /* Create the DOM information, or register it if already present */
  2352. if ( nTr || ! oSettings.oFeatures.bDeferRender )
  2353. {
  2354. _fnCreateTr( oSettings, iRow, nTr, anTds );
  2355. }
  2356. return iRow;
  2357. }
  2358. /**
  2359. * Add one or more TR elements to the table. Generally we'd expect to
  2360. * use this for reading data from a DOM sourced table, but it could be
  2361. * used for an TR element. Note that if a TR is given, it is used (i.e.
  2362. * it is not cloned).
  2363. * @param {object} settings dataTables settings object
  2364. * @param {array|node|jQuery} trs The TR element(s) to add to the table
  2365. * @returns {array} Array of indexes for the added rows
  2366. * @memberof DataTable#oApi
  2367. */
  2368. function _fnAddTr( settings, trs )
  2369. {
  2370. var row;
  2371. // Allow an individual node to be passed in
  2372. if ( ! (trs instanceof $) ) {
  2373. trs = $(trs);
  2374. }
  2375. return trs.map( function (i, el) {
  2376. row = _fnGetRowElements( settings, el );
  2377. return _fnAddData( settings, row.data, el, row.cells );
  2378. } );
  2379. }
  2380. /**
  2381. * Take a TR element and convert it to an index in aoData
  2382. * @param {object} oSettings dataTables settings object
  2383. * @param {node} n the TR element to find
  2384. * @returns {int} index if the node is found, null if not
  2385. * @memberof DataTable#oApi
  2386. */
  2387. function _fnNodeToDataIndex( oSettings, n )
  2388. {
  2389. return (n._DT_RowIndex!==undefined) ? n._DT_RowIndex : null;
  2390. }
  2391. /**
  2392. * Take a TD element and convert it into a column data index (not the visible index)
  2393. * @param {object} oSettings dataTables settings object
  2394. * @param {int} iRow The row number the TD/TH can be found in
  2395. * @param {node} n The TD/TH element to find
  2396. * @returns {int} index if the node is found, -1 if not
  2397. * @memberof DataTable#oApi
  2398. */
  2399. function _fnNodeToColumnIndex( oSettings, iRow, n )
  2400. {
  2401. return $.inArray( n, oSettings.aoData[ iRow ].anCells );
  2402. }
  2403. /**
  2404. * Get the data for a given cell from the internal cache, taking into account data mapping
  2405. * @param {object} settings dataTables settings object
  2406. * @param {int} rowIdx aoData row id
  2407. * @param {int} colIdx Column index
  2408. * @param {string} type data get type ('display', 'type' 'filter|search' 'sort|order')
  2409. * @returns {*} Cell data
  2410. * @memberof DataTable#oApi
  2411. */
  2412. function _fnGetCellData( settings, rowIdx, colIdx, type )
  2413. {
  2414. if (type === 'search') {
  2415. type = 'filter';
  2416. }
  2417. else if (type === 'order') {
  2418. type = 'sort';
  2419. }
  2420. var draw = settings.iDraw;
  2421. var col = settings.aoColumns[colIdx];
  2422. var rowData = settings.aoData[rowIdx]._aData;
  2423. var defaultContent = col.sDefaultContent;
  2424. var cellData = col.fnGetData( rowData, type, {
  2425. settings: settings,
  2426. row: rowIdx,
  2427. col: colIdx
  2428. } );
  2429. if ( cellData === undefined ) {
  2430. if ( settings.iDrawError != draw && defaultContent === null ) {
  2431. _fnLog( settings, 0, "Requested unknown parameter "+
  2432. (typeof col.mData=='function' ? '{function}' : "'"+col.mData+"'")+
  2433. " for row "+rowIdx+", column "+colIdx, 4 );
  2434. settings.iDrawError = draw;
  2435. }
  2436. return defaultContent;
  2437. }
  2438. // When the data source is null and a specific data type is requested (i.e.
  2439. // not the original data), we can use default column data
  2440. if ( (cellData === rowData || cellData === null) && defaultContent !== null && type !== undefined ) {
  2441. cellData = defaultContent;
  2442. }
  2443. else if ( typeof cellData === 'function' ) {
  2444. // If the data source is a function, then we run it and use the return,
  2445. // executing in the scope of the data object (for instances)
  2446. return cellData.call( rowData );
  2447. }
  2448. if ( cellData === null && type === 'display' ) {
  2449. return '';
  2450. }
  2451. if ( type === 'filter' ) {
  2452. var fomatters = DataTable.ext.type.search;
  2453. if ( fomatters[ col.sType ] ) {
  2454. cellData = fomatters[ col.sType ]( cellData );
  2455. }
  2456. }
  2457. return cellData;
  2458. }
  2459. /**
  2460. * Set the value for a specific cell, into the internal data cache
  2461. * @param {object} settings dataTables settings object
  2462. * @param {int} rowIdx aoData row id
  2463. * @param {int} colIdx Column index
  2464. * @param {*} val Value to set
  2465. * @memberof DataTable#oApi
  2466. */
  2467. function _fnSetCellData( settings, rowIdx, colIdx, val )
  2468. {
  2469. var col = settings.aoColumns[colIdx];
  2470. var rowData = settings.aoData[rowIdx]._aData;
  2471. col.fnSetData( rowData, val, {
  2472. settings: settings,
  2473. row: rowIdx,
  2474. col: colIdx
  2475. } );
  2476. }
  2477. // Private variable that is used to match action syntax in the data property object
  2478. var __reArray = /\[.*?\]$/;
  2479. var __reFn = /\(\)$/;
  2480. /**
  2481. * Split string on periods, taking into account escaped periods
  2482. * @param {string} str String to split
  2483. * @return {array} Split string
  2484. */
  2485. function _fnSplitObjNotation( str )
  2486. {
  2487. return $.map( str.match(/(\\.|[^\.])+/g) || [''], function ( s ) {
  2488. return s.replace(/\\\./g, '.');
  2489. } );
  2490. }
  2491. /**
  2492. * Return a function that can be used to get data from a source object, taking
  2493. * into account the ability to use nested objects as a source
  2494. * @param {string|int|function} mSource The data source for the object
  2495. * @returns {function} Data get function
  2496. * @memberof DataTable#oApi
  2497. */
  2498. var _fnGetObjectDataFn = DataTable.util.get;
  2499. /**
  2500. * Return a function that can be used to set data from a source object, taking
  2501. * into account the ability to use nested objects as a source
  2502. * @param {string|int|function} mSource The data source for the object
  2503. * @returns {function} Data set function
  2504. * @memberof DataTable#oApi
  2505. */
  2506. var _fnSetObjectDataFn = DataTable.util.set;
  2507. /**
  2508. * Return an array with the full table data
  2509. * @param {object} oSettings dataTables settings object
  2510. * @returns array {array} aData Master data array
  2511. * @memberof DataTable#oApi
  2512. */
  2513. function _fnGetDataMaster ( settings )
  2514. {
  2515. return _pluck( settings.aoData, '_aData' );
  2516. }
  2517. /**
  2518. * Nuke the table
  2519. * @param {object} oSettings dataTables settings object
  2520. * @memberof DataTable#oApi
  2521. */
  2522. function _fnClearTable( settings )
  2523. {
  2524. settings.aoData.length = 0;
  2525. settings.aiDisplayMaster.length = 0;
  2526. settings.aiDisplay.length = 0;
  2527. settings.aIds = {};
  2528. }
  2529. /**
  2530. * Take an array of integers (index array) and remove a target integer (value - not
  2531. * the key!)
  2532. * @param {array} a Index array to target
  2533. * @param {int} iTarget value to find
  2534. * @memberof DataTable#oApi
  2535. */
  2536. function _fnDeleteIndex( a, iTarget, splice )
  2537. {
  2538. var iTargetIndex = -1;
  2539. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  2540. {
  2541. if ( a[i] == iTarget )
  2542. {
  2543. iTargetIndex = i;
  2544. }
  2545. else if ( a[i] > iTarget )
  2546. {
  2547. a[i]--;
  2548. }
  2549. }
  2550. if ( iTargetIndex != -1 && splice === undefined )
  2551. {
  2552. a.splice( iTargetIndex, 1 );
  2553. }
  2554. }
  2555. /**
  2556. * Mark cached data as invalid such that a re-read of the data will occur when
  2557. * the cached data is next requested. Also update from the data source object.
  2558. *
  2559. * @param {object} settings DataTables settings object
  2560. * @param {int} rowIdx Row index to invalidate
  2561. * @param {string} [src] Source to invalidate from: undefined, 'auto', 'dom'
  2562. * or 'data'
  2563. * @param {int} [colIdx] Column index to invalidate. If undefined the whole
  2564. * row will be invalidated
  2565. * @memberof DataTable#oApi
  2566. *
  2567. * @todo For the modularisation of v1.11 this will need to become a callback, so
  2568. * the sort and filter methods can subscribe to it. That will required
  2569. * initialisation options for sorting, which is why it is not already baked in
  2570. */
  2571. function _fnInvalidate( settings, rowIdx, src, colIdx )
  2572. {
  2573. var row = settings.aoData[ rowIdx ];
  2574. var i, ien;
  2575. var cellWrite = function ( cell, col ) {
  2576. // This is very frustrating, but in IE if you just write directly
  2577. // to innerHTML, and elements that are overwritten are GC'ed,
  2578. // even if there is a reference to them elsewhere
  2579. while ( cell.childNodes.length ) {
  2580. cell.removeChild( cell.firstChild );
  2581. }
  2582. cell.innerHTML = _fnGetCellData( settings, rowIdx, col, 'display' );
  2583. };
  2584. // Are we reading last data from DOM or the data object?
  2585. if ( src === 'dom' || ((! src || src === 'auto') && row.src === 'dom') ) {
  2586. // Read the data from the DOM
  2587. row._aData = _fnGetRowElements(
  2588. settings, row, colIdx, colIdx === undefined ? undefined : row._aData
  2589. )
  2590. .data;
  2591. }
  2592. else {
  2593. // Reading from data object, update the DOM
  2594. var cells = row.anCells;
  2595. if ( cells ) {
  2596. if ( colIdx !== undefined ) {
  2597. cellWrite( cells[colIdx], colIdx );
  2598. }
  2599. else {
  2600. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  2601. cellWrite( cells[i], i );
  2602. }
  2603. }
  2604. }
  2605. }
  2606. // For both row and cell invalidation, the cached data for sorting and
  2607. // filtering is nulled out
  2608. row._aSortData = null;
  2609. row._aFilterData = null;
  2610. // Invalidate the type for a specific column (if given) or all columns since
  2611. // the data might have changed
  2612. var cols = settings.aoColumns;
  2613. if ( colIdx !== undefined ) {
  2614. cols[ colIdx ].sType = null;
  2615. }
  2616. else {
  2617. for ( i=0, ien=cols.length ; i<ien ; i++ ) {
  2618. cols[i].sType = null;
  2619. }
  2620. // Update DataTables special `DT_*` attributes for the row
  2621. _fnRowAttributes( settings, row );
  2622. }
  2623. }
  2624. /**
  2625. * Build a data source object from an HTML row, reading the contents of the
  2626. * cells that are in the row.
  2627. *
  2628. * @param {object} settings DataTables settings object
  2629. * @param {node|object} TR element from which to read data or existing row
  2630. * object from which to re-read the data from the cells
  2631. * @param {int} [colIdx] Optional column index
  2632. * @param {array|object} [d] Data source object. If `colIdx` is given then this
  2633. * parameter should also be given and will be used to write the data into.
  2634. * Only the column in question will be written
  2635. * @returns {object} Object with two parameters: `data` the data read, in
  2636. * document order, and `cells` and array of nodes (they can be useful to the
  2637. * caller, so rather than needing a second traversal to get them, just return
  2638. * them from here).
  2639. * @memberof DataTable#oApi
  2640. */
  2641. function _fnGetRowElements( settings, row, colIdx, d )
  2642. {
  2643. var
  2644. tds = [],
  2645. td = row.firstChild,
  2646. name, col, o, i=0, contents,
  2647. columns = settings.aoColumns,
  2648. objectRead = settings._rowReadObject;
  2649. // Allow the data object to be passed in, or construct
  2650. d = d !== undefined ?
  2651. d :
  2652. objectRead ?
  2653. {} :
  2654. [];
  2655. var attr = function ( str, td ) {
  2656. if ( typeof str === 'string' ) {
  2657. var idx = str.indexOf('@');
  2658. if ( idx !== -1 ) {
  2659. var attr = str.substring( idx+1 );
  2660. var setter = _fnSetObjectDataFn( str );
  2661. setter( d, td.getAttribute( attr ) );
  2662. }
  2663. }
  2664. };
  2665. // Read data from a cell and store into the data object
  2666. var cellProcess = function ( cell ) {
  2667. if ( colIdx === undefined || colIdx === i ) {
  2668. col = columns[i];
  2669. contents = (cell.innerHTML).trim();
  2670. if ( col && col._bAttrSrc ) {
  2671. var setter = _fnSetObjectDataFn( col.mData._ );
  2672. setter( d, contents );
  2673. attr( col.mData.sort, cell );
  2674. attr( col.mData.type, cell );
  2675. attr( col.mData.filter, cell );
  2676. }
  2677. else {
  2678. // Depending on the `data` option for the columns the data can
  2679. // be read to either an object or an array.
  2680. if ( objectRead ) {
  2681. if ( ! col._setter ) {
  2682. // Cache the setter function
  2683. col._setter = _fnSetObjectDataFn( col.mData );
  2684. }
  2685. col._setter( d, contents );
  2686. }
  2687. else {
  2688. d[i] = contents;
  2689. }
  2690. }
  2691. }
  2692. i++;
  2693. };
  2694. if ( td ) {
  2695. // `tr` element was passed in
  2696. while ( td ) {
  2697. name = td.nodeName.toUpperCase();
  2698. if ( name == "TD" || name == "TH" ) {
  2699. cellProcess( td );
  2700. tds.push( td );
  2701. }
  2702. td = td.nextSibling;
  2703. }
  2704. }
  2705. else {
  2706. // Existing row object passed in
  2707. tds = row.anCells;
  2708. for ( var j=0, jen=tds.length ; j<jen ; j++ ) {
  2709. cellProcess( tds[j] );
  2710. }
  2711. }
  2712. // Read the ID from the DOM if present
  2713. var rowNode = row.firstChild ? row : row.nTr;
  2714. if ( rowNode ) {
  2715. var id = rowNode.getAttribute( 'id' );
  2716. if ( id ) {
  2717. _fnSetObjectDataFn( settings.rowId )( d, id );
  2718. }
  2719. }
  2720. return {
  2721. data: d,
  2722. cells: tds
  2723. };
  2724. }
  2725. /**
  2726. * Create a new TR element (and it's TD children) for a row
  2727. * @param {object} oSettings dataTables settings object
  2728. * @param {int} iRow Row to consider
  2729. * @param {node} [nTrIn] TR element to add to the table - optional. If not given,
  2730. * DataTables will create a row automatically
  2731. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  2732. * if nTr is.
  2733. * @memberof DataTable#oApi
  2734. */
  2735. function _fnCreateTr ( oSettings, iRow, nTrIn, anTds )
  2736. {
  2737. var
  2738. row = oSettings.aoData[iRow],
  2739. rowData = row._aData,
  2740. cells = [],
  2741. nTr, nTd, oCol,
  2742. i, iLen, create;
  2743. if ( row.nTr === null )
  2744. {
  2745. nTr = nTrIn || document.createElement('tr');
  2746. row.nTr = nTr;
  2747. row.anCells = cells;
  2748. /* Use a private property on the node to allow reserve mapping from the node
  2749. * to the aoData array for fast look up
  2750. */
  2751. nTr._DT_RowIndex = iRow;
  2752. /* Special parameters can be given by the data source to be used on the row */
  2753. _fnRowAttributes( oSettings, row );
  2754. /* Process each column */
  2755. for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
  2756. {
  2757. oCol = oSettings.aoColumns[i];
  2758. create = nTrIn ? false : true;
  2759. nTd = create ? document.createElement( oCol.sCellType ) : anTds[i];
  2760. nTd._DT_CellIndex = {
  2761. row: iRow,
  2762. column: i
  2763. };
  2764. cells.push( nTd );
  2765. // Need to create the HTML if new, or if a rendering function is defined
  2766. if ( create || ((oCol.mRender || oCol.mData !== i) &&
  2767. (!$.isPlainObject(oCol.mData) || oCol.mData._ !== i+'.display')
  2768. )) {
  2769. nTd.innerHTML = _fnGetCellData( oSettings, iRow, i, 'display' );
  2770. }
  2771. /* Add user defined class */
  2772. if ( oCol.sClass )
  2773. {
  2774. nTd.className += ' '+oCol.sClass;
  2775. }
  2776. // Visibility - add or remove as required
  2777. if ( oCol.bVisible && ! nTrIn )
  2778. {
  2779. nTr.appendChild( nTd );
  2780. }
  2781. else if ( ! oCol.bVisible && nTrIn )
  2782. {
  2783. nTd.parentNode.removeChild( nTd );
  2784. }
  2785. if ( oCol.fnCreatedCell )
  2786. {
  2787. oCol.fnCreatedCell.call( oSettings.oInstance,
  2788. nTd, _fnGetCellData( oSettings, iRow, i ), rowData, iRow, i
  2789. );
  2790. }
  2791. }
  2792. _fnCallbackFire( oSettings, 'aoRowCreatedCallback', null, [nTr, rowData, iRow, cells] );
  2793. }
  2794. }
  2795. /**
  2796. * Add attributes to a row based on the special `DT_*` parameters in a data
  2797. * source object.
  2798. * @param {object} settings DataTables settings object
  2799. * @param {object} DataTables row object for the row to be modified
  2800. * @memberof DataTable#oApi
  2801. */
  2802. function _fnRowAttributes( settings, row )
  2803. {
  2804. var tr = row.nTr;
  2805. var data = row._aData;
  2806. if ( tr ) {
  2807. var id = settings.rowIdFn( data );
  2808. if ( id ) {
  2809. tr.id = id;
  2810. }
  2811. if ( data.DT_RowClass ) {
  2812. // Remove any classes added by DT_RowClass before
  2813. var a = data.DT_RowClass.split(' ');
  2814. row.__rowc = row.__rowc ?
  2815. _unique( row.__rowc.concat( a ) ) :
  2816. a;
  2817. $(tr)
  2818. .removeClass( row.__rowc.join(' ') )
  2819. .addClass( data.DT_RowClass );
  2820. }
  2821. if ( data.DT_RowAttr ) {
  2822. $(tr).attr( data.DT_RowAttr );
  2823. }
  2824. if ( data.DT_RowData ) {
  2825. $(tr).data( data.DT_RowData );
  2826. }
  2827. }
  2828. }
  2829. /**
  2830. * Create the HTML header for the table
  2831. * @param {object} oSettings dataTables settings object
  2832. * @memberof DataTable#oApi
  2833. */
  2834. function _fnBuildHead( oSettings )
  2835. {
  2836. var i, ien, cell, row, column;
  2837. var thead = oSettings.nTHead;
  2838. var tfoot = oSettings.nTFoot;
  2839. var createHeader = $('th, td', thead).length === 0;
  2840. var classes = oSettings.oClasses;
  2841. var columns = oSettings.aoColumns;
  2842. if ( createHeader ) {
  2843. row = $('<tr/>').appendTo( thead );
  2844. }
  2845. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  2846. column = columns[i];
  2847. cell = $( column.nTh ).addClass( column.sClass );
  2848. if ( createHeader ) {
  2849. cell.appendTo( row );
  2850. }
  2851. // 1.11 move into sorting
  2852. if ( oSettings.oFeatures.bSort ) {
  2853. cell.addClass( column.sSortingClass );
  2854. if ( column.bSortable !== false ) {
  2855. cell
  2856. .attr( 'tabindex', oSettings.iTabIndex )
  2857. .attr( 'aria-controls', oSettings.sTableId );
  2858. _fnSortAttachListener( oSettings, column.nTh, i );
  2859. }
  2860. }
  2861. if ( column.sTitle != cell[0].innerHTML ) {
  2862. cell.html( column.sTitle );
  2863. }
  2864. _fnRenderer( oSettings, 'header' )(
  2865. oSettings, cell, column, classes
  2866. );
  2867. }
  2868. if ( createHeader ) {
  2869. _fnDetectHeader( oSettings.aoHeader, thead );
  2870. }
  2871. /* Deal with the footer - add classes if required */
  2872. $(thead).children('tr').children('th, td').addClass( classes.sHeaderTH );
  2873. $(tfoot).children('tr').children('th, td').addClass( classes.sFooterTH );
  2874. // Cache the footer cells. Note that we only take the cells from the first
  2875. // row in the footer. If there is more than one row the user wants to
  2876. // interact with, they need to use the table().foot() method. Note also this
  2877. // allows cells to be used for multiple columns using colspan
  2878. if ( tfoot !== null ) {
  2879. var cells = oSettings.aoFooter[0];
  2880. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  2881. column = columns[i];
  2882. column.nTf = cells[i].cell;
  2883. if ( column.sClass ) {
  2884. $(column.nTf).addClass( column.sClass );
  2885. }
  2886. }
  2887. }
  2888. }
  2889. /**
  2890. * Draw the header (or footer) element based on the column visibility states. The
  2891. * methodology here is to use the layout array from _fnDetectHeader, modified for
  2892. * the instantaneous column visibility, to construct the new layout. The grid is
  2893. * traversed over cell at a time in a rows x columns grid fashion, although each
  2894. * cell insert can cover multiple elements in the grid - which is tracks using the
  2895. * aApplied array. Cell inserts in the grid will only occur where there isn't
  2896. * already a cell in that position.
  2897. * @param {object} oSettings dataTables settings object
  2898. * @param array {objects} aoSource Layout array from _fnDetectHeader
  2899. * @param {boolean} [bIncludeHidden=false] If true then include the hidden columns in the calc,
  2900. * @memberof DataTable#oApi
  2901. */
  2902. function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
  2903. {
  2904. var i, iLen, j, jLen, k, kLen, n, nLocalTr;
  2905. var aoLocal = [];
  2906. var aApplied = [];
  2907. var iColumns = oSettings.aoColumns.length;
  2908. var iRowspan, iColspan;
  2909. if ( ! aoSource )
  2910. {
  2911. return;
  2912. }
  2913. if ( bIncludeHidden === undefined )
  2914. {
  2915. bIncludeHidden = false;
  2916. }
  2917. /* Make a copy of the master layout array, but without the visible columns in it */
  2918. for ( i=0, iLen=aoSource.length ; i<iLen ; i++ )
  2919. {
  2920. aoLocal[i] = aoSource[i].slice();
  2921. aoLocal[i].nTr = aoSource[i].nTr;
  2922. /* Remove any columns which are currently hidden */
  2923. for ( j=iColumns-1 ; j>=0 ; j-- )
  2924. {
  2925. if ( !oSettings.aoColumns[j].bVisible && !bIncludeHidden )
  2926. {
  2927. aoLocal[i].splice( j, 1 );
  2928. }
  2929. }
  2930. /* Prep the applied array - it needs an element for each row */
  2931. aApplied.push( [] );
  2932. }
  2933. for ( i=0, iLen=aoLocal.length ; i<iLen ; i++ )
  2934. {
  2935. nLocalTr = aoLocal[i].nTr;
  2936. /* All cells are going to be replaced, so empty out the row */
  2937. if ( nLocalTr )
  2938. {
  2939. while( (n = nLocalTr.firstChild) )
  2940. {
  2941. nLocalTr.removeChild( n );
  2942. }
  2943. }
  2944. for ( j=0, jLen=aoLocal[i].length ; j<jLen ; j++ )
  2945. {
  2946. iRowspan = 1;
  2947. iColspan = 1;
  2948. /* Check to see if there is already a cell (row/colspan) covering our target
  2949. * insert point. If there is, then there is nothing to do.
  2950. */
  2951. if ( aApplied[i][j] === undefined )
  2952. {
  2953. nLocalTr.appendChild( aoLocal[i][j].cell );
  2954. aApplied[i][j] = 1;
  2955. /* Expand the cell to cover as many rows as needed */
  2956. while ( aoLocal[i+iRowspan] !== undefined &&
  2957. aoLocal[i][j].cell == aoLocal[i+iRowspan][j].cell )
  2958. {
  2959. aApplied[i+iRowspan][j] = 1;
  2960. iRowspan++;
  2961. }
  2962. /* Expand the cell to cover as many columns as needed */
  2963. while ( aoLocal[i][j+iColspan] !== undefined &&
  2964. aoLocal[i][j].cell == aoLocal[i][j+iColspan].cell )
  2965. {
  2966. /* Must update the applied array over the rows for the columns */
  2967. for ( k=0 ; k<iRowspan ; k++ )
  2968. {
  2969. aApplied[i+k][j+iColspan] = 1;
  2970. }
  2971. iColspan++;
  2972. }
  2973. /* Do the actual expansion in the DOM */
  2974. $(aoLocal[i][j].cell)
  2975. .attr('rowspan', iRowspan)
  2976. .attr('colspan', iColspan);
  2977. }
  2978. }
  2979. }
  2980. }
  2981. /**
  2982. * Insert the required TR nodes into the table for display
  2983. * @param {object} oSettings dataTables settings object
  2984. * @param ajaxComplete true after ajax call to complete rendering
  2985. * @memberof DataTable#oApi
  2986. */
  2987. function _fnDraw( oSettings, ajaxComplete )
  2988. {
  2989. /* Provide a pre-callback function which can be used to cancel the draw is false is returned */
  2990. var aPreDraw = _fnCallbackFire( oSettings, 'aoPreDrawCallback', 'preDraw', [oSettings] );
  2991. if ( $.inArray( false, aPreDraw ) !== -1 )
  2992. {
  2993. _fnProcessingDisplay( oSettings, false );
  2994. return;
  2995. }
  2996. var i, iLen, n;
  2997. var anRows = [];
  2998. var iRowCount = 0;
  2999. var asStripeClasses = oSettings.asStripeClasses;
  3000. var iStripes = asStripeClasses.length;
  3001. var iOpenRows = oSettings.aoOpenRows.length;
  3002. var oLang = oSettings.oLanguage;
  3003. var iInitDisplayStart = oSettings.iInitDisplayStart;
  3004. var bServerSide = _fnDataSource( oSettings ) == 'ssp';
  3005. var aiDisplay = oSettings.aiDisplay;
  3006. oSettings.bDrawing = true;
  3007. /* Check and see if we have an initial draw position from state saving */
  3008. if ( iInitDisplayStart !== undefined && iInitDisplayStart !== -1 )
  3009. {
  3010. oSettings._iDisplayStart = bServerSide ?
  3011. iInitDisplayStart :
  3012. iInitDisplayStart >= oSettings.fnRecordsDisplay() ?
  3013. 0 :
  3014. iInitDisplayStart;
  3015. oSettings.iInitDisplayStart = -1;
  3016. }
  3017. var iDisplayStart = oSettings._iDisplayStart;
  3018. var iDisplayEnd = oSettings.fnDisplayEnd();
  3019. /* Server-side processing draw intercept */
  3020. if ( oSettings.bDeferLoading )
  3021. {
  3022. oSettings.bDeferLoading = false;
  3023. oSettings.iDraw++;
  3024. _fnProcessingDisplay( oSettings, false );
  3025. }
  3026. else if ( !bServerSide )
  3027. {
  3028. oSettings.iDraw++;
  3029. }
  3030. else if ( !oSettings.bDestroying && !ajaxComplete)
  3031. {
  3032. _fnAjaxUpdate( oSettings );
  3033. return;
  3034. }
  3035. if ( aiDisplay.length !== 0 )
  3036. {
  3037. var iStart = bServerSide ? 0 : iDisplayStart;
  3038. var iEnd = bServerSide ? oSettings.aoData.length : iDisplayEnd;
  3039. for ( var j=iStart ; j<iEnd ; j++ )
  3040. {
  3041. var iDataIndex = aiDisplay[j];
  3042. var aoData = oSettings.aoData[ iDataIndex ];
  3043. if ( aoData.nTr === null )
  3044. {
  3045. _fnCreateTr( oSettings, iDataIndex );
  3046. }
  3047. var nRow = aoData.nTr;
  3048. /* Remove the old striping classes and then add the new one */
  3049. if ( iStripes !== 0 )
  3050. {
  3051. var sStripe = asStripeClasses[ iRowCount % iStripes ];
  3052. if ( aoData._sRowStripe != sStripe )
  3053. {
  3054. $(nRow).removeClass( aoData._sRowStripe ).addClass( sStripe );
  3055. aoData._sRowStripe = sStripe;
  3056. }
  3057. }
  3058. // Row callback functions - might want to manipulate the row
  3059. // iRowCount and j are not currently documented. Are they at all
  3060. // useful?
  3061. _fnCallbackFire( oSettings, 'aoRowCallback', null,
  3062. [nRow, aoData._aData, iRowCount, j, iDataIndex] );
  3063. anRows.push( nRow );
  3064. iRowCount++;
  3065. }
  3066. }
  3067. else
  3068. {
  3069. /* Table is empty - create a row with an empty message in it */
  3070. var sZero = oLang.sZeroRecords;
  3071. if ( oSettings.iDraw == 1 && _fnDataSource( oSettings ) == 'ajax' )
  3072. {
  3073. sZero = oLang.sLoadingRecords;
  3074. }
  3075. else if ( oLang.sEmptyTable && oSettings.fnRecordsTotal() === 0 )
  3076. {
  3077. sZero = oLang.sEmptyTable;
  3078. }
  3079. anRows[ 0 ] = $( '<tr/>', { 'class': iStripes ? asStripeClasses[0] : '' } )
  3080. .append( $('<td />', {
  3081. 'valign': 'top',
  3082. 'colSpan': _fnVisbleColumns( oSettings ),
  3083. 'class': oSettings.oClasses.sRowEmpty
  3084. } ).html( sZero ) )[0];
  3085. }
  3086. /* Header and footer callbacks */
  3087. _fnCallbackFire( oSettings, 'aoHeaderCallback', 'header', [ $(oSettings.nTHead).children('tr')[0],
  3088. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  3089. _fnCallbackFire( oSettings, 'aoFooterCallback', 'footer', [ $(oSettings.nTFoot).children('tr')[0],
  3090. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  3091. var body = $(oSettings.nTBody);
  3092. body.children().detach();
  3093. body.append( $(anRows) );
  3094. /* Call all required callback functions for the end of a draw */
  3095. _fnCallbackFire( oSettings, 'aoDrawCallback', 'draw', [oSettings] );
  3096. /* Draw is complete, sorting and filtering must be as well */
  3097. oSettings.bSorted = false;
  3098. oSettings.bFiltered = false;
  3099. oSettings.bDrawing = false;
  3100. }
  3101. /**
  3102. * Redraw the table - taking account of the various features which are enabled
  3103. * @param {object} oSettings dataTables settings object
  3104. * @param {boolean} [holdPosition] Keep the current paging position. By default
  3105. * the paging is reset to the first page
  3106. * @memberof DataTable#oApi
  3107. */
  3108. function _fnReDraw( settings, holdPosition )
  3109. {
  3110. var
  3111. features = settings.oFeatures,
  3112. sort = features.bSort,
  3113. filter = features.bFilter;
  3114. if ( sort ) {
  3115. _fnSort( settings );
  3116. }
  3117. if ( filter ) {
  3118. _fnFilterComplete( settings, settings.oPreviousSearch );
  3119. }
  3120. else {
  3121. // No filtering, so we want to just use the display master
  3122. settings.aiDisplay = settings.aiDisplayMaster.slice();
  3123. }
  3124. if ( holdPosition !== true ) {
  3125. settings._iDisplayStart = 0;
  3126. }
  3127. // Let any modules know about the draw hold position state (used by
  3128. // scrolling internally)
  3129. settings._drawHold = holdPosition;
  3130. _fnDraw( settings );
  3131. settings._drawHold = false;
  3132. }
  3133. /**
  3134. * Add the options to the page HTML for the table
  3135. * @param {object} oSettings dataTables settings object
  3136. * @memberof DataTable#oApi
  3137. */
  3138. function _fnAddOptionsHtml ( oSettings )
  3139. {
  3140. var classes = oSettings.oClasses;
  3141. var table = $(oSettings.nTable);
  3142. var holding = $('<div/>').insertBefore( table ); // Holding element for speed
  3143. var features = oSettings.oFeatures;
  3144. // All DataTables are wrapped in a div
  3145. var insert = $('<div/>', {
  3146. id: oSettings.sTableId+'_wrapper',
  3147. 'class': classes.sWrapper + (oSettings.nTFoot ? '' : ' '+classes.sNoFooter)
  3148. } );
  3149. oSettings.nHolding = holding[0];
  3150. oSettings.nTableWrapper = insert[0];
  3151. oSettings.nTableReinsertBefore = oSettings.nTable.nextSibling;
  3152. /* Loop over the user set positioning and place the elements as needed */
  3153. var aDom = oSettings.sDom.split('');
  3154. var featureNode, cOption, nNewNode, cNext, sAttr, j;
  3155. for ( var i=0 ; i<aDom.length ; i++ )
  3156. {
  3157. featureNode = null;
  3158. cOption = aDom[i];
  3159. if ( cOption == '<' )
  3160. {
  3161. /* New container div */
  3162. nNewNode = $('<div/>')[0];
  3163. /* Check to see if we should append an id and/or a class name to the container */
  3164. cNext = aDom[i+1];
  3165. if ( cNext == "'" || cNext == '"' )
  3166. {
  3167. sAttr = "";
  3168. j = 2;
  3169. while ( aDom[i+j] != cNext )
  3170. {
  3171. sAttr += aDom[i+j];
  3172. j++;
  3173. }
  3174. /* Replace jQuery UI constants @todo depreciated */
  3175. if ( sAttr == "H" )
  3176. {
  3177. sAttr = classes.sJUIHeader;
  3178. }
  3179. else if ( sAttr == "F" )
  3180. {
  3181. sAttr = classes.sJUIFooter;
  3182. }
  3183. /* The attribute can be in the format of "#id.class", "#id" or "class" This logic
  3184. * breaks the string into parts and applies them as needed
  3185. */
  3186. if ( sAttr.indexOf('.') != -1 )
  3187. {
  3188. var aSplit = sAttr.split('.');
  3189. nNewNode.id = aSplit[0].substr(1, aSplit[0].length-1);
  3190. nNewNode.className = aSplit[1];
  3191. }
  3192. else if ( sAttr.charAt(0) == "#" )
  3193. {
  3194. nNewNode.id = sAttr.substr(1, sAttr.length-1);
  3195. }
  3196. else
  3197. {
  3198. nNewNode.className = sAttr;
  3199. }
  3200. i += j; /* Move along the position array */
  3201. }
  3202. insert.append( nNewNode );
  3203. insert = $(nNewNode);
  3204. }
  3205. else if ( cOption == '>' )
  3206. {
  3207. /* End container div */
  3208. insert = insert.parent();
  3209. }
  3210. // @todo Move options into their own plugins?
  3211. else if ( cOption == 'l' && features.bPaginate && features.bLengthChange )
  3212. {
  3213. /* Length */
  3214. featureNode = _fnFeatureHtmlLength( oSettings );
  3215. }
  3216. else if ( cOption == 'f' && features.bFilter )
  3217. {
  3218. /* Filter */
  3219. featureNode = _fnFeatureHtmlFilter( oSettings );
  3220. }
  3221. else if ( cOption == 'r' && features.bProcessing )
  3222. {
  3223. /* pRocessing */
  3224. featureNode = _fnFeatureHtmlProcessing( oSettings );
  3225. }
  3226. else if ( cOption == 't' )
  3227. {
  3228. /* Table */
  3229. featureNode = _fnFeatureHtmlTable( oSettings );
  3230. }
  3231. else if ( cOption == 'i' && features.bInfo )
  3232. {
  3233. /* Info */
  3234. featureNode = _fnFeatureHtmlInfo( oSettings );
  3235. }
  3236. else if ( cOption == 'p' && features.bPaginate )
  3237. {
  3238. /* Pagination */
  3239. featureNode = _fnFeatureHtmlPaginate( oSettings );
  3240. }
  3241. else if ( DataTable.ext.feature.length !== 0 )
  3242. {
  3243. /* Plug-in features */
  3244. var aoFeatures = DataTable.ext.feature;
  3245. for ( var k=0, kLen=aoFeatures.length ; k<kLen ; k++ )
  3246. {
  3247. if ( cOption == aoFeatures[k].cFeature )
  3248. {
  3249. featureNode = aoFeatures[k].fnInit( oSettings );
  3250. break;
  3251. }
  3252. }
  3253. }
  3254. /* Add to the 2D features array */
  3255. if ( featureNode )
  3256. {
  3257. var aanFeatures = oSettings.aanFeatures;
  3258. if ( ! aanFeatures[cOption] )
  3259. {
  3260. aanFeatures[cOption] = [];
  3261. }
  3262. aanFeatures[cOption].push( featureNode );
  3263. insert.append( featureNode );
  3264. }
  3265. }
  3266. /* Built our DOM structure - replace the holding div with what we want */
  3267. holding.replaceWith( insert );
  3268. oSettings.nHolding = null;
  3269. }
  3270. /**
  3271. * Use the DOM source to create up an array of header cells. The idea here is to
  3272. * create a layout grid (array) of rows x columns, which contains a reference
  3273. * to the cell that that point in the grid (regardless of col/rowspan), such that
  3274. * any column / row could be removed and the new grid constructed
  3275. * @param array {object} aLayout Array to store the calculated layout in
  3276. * @param {node} nThead The header/footer element for the table
  3277. * @memberof DataTable#oApi
  3278. */
  3279. function _fnDetectHeader ( aLayout, nThead )
  3280. {
  3281. var nTrs = $(nThead).children('tr');
  3282. var nTr, nCell;
  3283. var i, k, l, iLen, jLen, iColShifted, iColumn, iColspan, iRowspan;
  3284. var bUnique;
  3285. var fnShiftCol = function ( a, i, j ) {
  3286. var k = a[i];
  3287. while ( k[j] ) {
  3288. j++;
  3289. }
  3290. return j;
  3291. };
  3292. aLayout.splice( 0, aLayout.length );
  3293. /* We know how many rows there are in the layout - so prep it */
  3294. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  3295. {
  3296. aLayout.push( [] );
  3297. }
  3298. /* Calculate a layout array */
  3299. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  3300. {
  3301. nTr = nTrs[i];
  3302. iColumn = 0;
  3303. /* For every cell in the row... */
  3304. nCell = nTr.firstChild;
  3305. while ( nCell ) {
  3306. if ( nCell.nodeName.toUpperCase() == "TD" ||
  3307. nCell.nodeName.toUpperCase() == "TH" )
  3308. {
  3309. /* Get the col and rowspan attributes from the DOM and sanitise them */
  3310. iColspan = nCell.getAttribute('colspan') * 1;
  3311. iRowspan = nCell.getAttribute('rowspan') * 1;
  3312. iColspan = (!iColspan || iColspan===0 || iColspan===1) ? 1 : iColspan;
  3313. iRowspan = (!iRowspan || iRowspan===0 || iRowspan===1) ? 1 : iRowspan;
  3314. /* There might be colspan cells already in this row, so shift our target
  3315. * accordingly
  3316. */
  3317. iColShifted = fnShiftCol( aLayout, i, iColumn );
  3318. /* Cache calculation for unique columns */
  3319. bUnique = iColspan === 1 ? true : false;
  3320. /* If there is col / rowspan, copy the information into the layout grid */
  3321. for ( l=0 ; l<iColspan ; l++ )
  3322. {
  3323. for ( k=0 ; k<iRowspan ; k++ )
  3324. {
  3325. aLayout[i+k][iColShifted+l] = {
  3326. "cell": nCell,
  3327. "unique": bUnique
  3328. };
  3329. aLayout[i+k].nTr = nTr;
  3330. }
  3331. }
  3332. }
  3333. nCell = nCell.nextSibling;
  3334. }
  3335. }
  3336. }
  3337. /**
  3338. * Get an array of unique th elements, one for each column
  3339. * @param {object} oSettings dataTables settings object
  3340. * @param {node} nHeader automatically detect the layout from this node - optional
  3341. * @param {array} aLayout thead/tfoot layout from _fnDetectHeader - optional
  3342. * @returns array {node} aReturn list of unique th's
  3343. * @memberof DataTable#oApi
  3344. */
  3345. function _fnGetUniqueThs ( oSettings, nHeader, aLayout )
  3346. {
  3347. var aReturn = [];
  3348. if ( !aLayout )
  3349. {
  3350. aLayout = oSettings.aoHeader;
  3351. if ( nHeader )
  3352. {
  3353. aLayout = [];
  3354. _fnDetectHeader( aLayout, nHeader );
  3355. }
  3356. }
  3357. for ( var i=0, iLen=aLayout.length ; i<iLen ; i++ )
  3358. {
  3359. for ( var j=0, jLen=aLayout[i].length ; j<jLen ; j++ )
  3360. {
  3361. if ( aLayout[i][j].unique &&
  3362. (!aReturn[j] || !oSettings.bSortCellsTop) )
  3363. {
  3364. aReturn[j] = aLayout[i][j].cell;
  3365. }
  3366. }
  3367. }
  3368. return aReturn;
  3369. }
  3370. /**
  3371. * Create an Ajax call based on the table's settings, taking into account that
  3372. * parameters can have multiple forms, and backwards compatibility.
  3373. *
  3374. * @param {object} oSettings dataTables settings object
  3375. * @param {array} data Data to send to the server, required by
  3376. * DataTables - may be augmented by developer callbacks
  3377. * @param {function} fn Callback function to run when data is obtained
  3378. */
  3379. function _fnBuildAjax( oSettings, data, fn )
  3380. {
  3381. // Compatibility with 1.9-, allow fnServerData and event to manipulate
  3382. _fnCallbackFire( oSettings, 'aoServerParams', 'serverParams', [data] );
  3383. // Convert to object based for 1.10+ if using the old array scheme which can
  3384. // come from server-side processing or serverParams
  3385. if ( data && Array.isArray(data) ) {
  3386. var tmp = {};
  3387. var rbracket = /(.*?)\[\]$/;
  3388. $.each( data, function (key, val) {
  3389. var match = val.name.match(rbracket);
  3390. if ( match ) {
  3391. // Support for arrays
  3392. var name = match[0];
  3393. if ( ! tmp[ name ] ) {
  3394. tmp[ name ] = [];
  3395. }
  3396. tmp[ name ].push( val.value );
  3397. }
  3398. else {
  3399. tmp[val.name] = val.value;
  3400. }
  3401. } );
  3402. data = tmp;
  3403. }
  3404. var ajaxData;
  3405. var ajax = oSettings.ajax;
  3406. var instance = oSettings.oInstance;
  3407. var callback = function ( json ) {
  3408. var status = oSettings.jqXhr
  3409. ? oSettings.jqXhr.status
  3410. : null;
  3411. if ( json === null || (typeof status === 'number' && status == 204 ) ) {
  3412. json = {};
  3413. _fnAjaxDataSrc( oSettings, json, [] );
  3414. }
  3415. var error = json.error || json.sError;
  3416. if ( error ) {
  3417. _fnLog( oSettings, 0, error );
  3418. }
  3419. oSettings.json = json;
  3420. _fnCallbackFire( oSettings, null, 'xhr', [oSettings, json, oSettings.jqXHR] );
  3421. fn( json );
  3422. };
  3423. if ( $.isPlainObject( ajax ) && ajax.data )
  3424. {
  3425. ajaxData = ajax.data;
  3426. var newData = typeof ajaxData === 'function' ?
  3427. ajaxData( data, oSettings ) : // fn can manipulate data or return
  3428. ajaxData; // an object object or array to merge
  3429. // If the function returned something, use that alone
  3430. data = typeof ajaxData === 'function' && newData ?
  3431. newData :
  3432. $.extend( true, data, newData );
  3433. // Remove the data property as we've resolved it already and don't want
  3434. // jQuery to do it again (it is restored at the end of the function)
  3435. delete ajax.data;
  3436. }
  3437. var baseAjax = {
  3438. "data": data,
  3439. "success": callback,
  3440. "dataType": "json",
  3441. "cache": false,
  3442. "type": oSettings.sServerMethod,
  3443. "error": function (xhr, error, thrown) {
  3444. var ret = _fnCallbackFire( oSettings, null, 'xhr', [oSettings, null, oSettings.jqXHR] );
  3445. if ( $.inArray( true, ret ) === -1 ) {
  3446. if ( error == "parsererror" ) {
  3447. _fnLog( oSettings, 0, 'Invalid JSON response', 1 );
  3448. }
  3449. else if ( xhr.readyState === 4 ) {
  3450. _fnLog( oSettings, 0, 'Ajax error', 7 );
  3451. }
  3452. }
  3453. _fnProcessingDisplay( oSettings, false );
  3454. }
  3455. };
  3456. // Store the data submitted for the API
  3457. oSettings.oAjaxData = data;
  3458. // Allow plug-ins and external processes to modify the data
  3459. _fnCallbackFire( oSettings, null, 'preXhr', [oSettings, data] );
  3460. if ( oSettings.fnServerData )
  3461. {
  3462. // DataTables 1.9- compatibility
  3463. oSettings.fnServerData.call( instance,
  3464. oSettings.sAjaxSource,
  3465. $.map( data, function (val, key) { // Need to convert back to 1.9 trad format
  3466. return { name: key, value: val };
  3467. } ),
  3468. callback,
  3469. oSettings
  3470. );
  3471. }
  3472. else if ( oSettings.sAjaxSource || typeof ajax === 'string' )
  3473. {
  3474. // DataTables 1.9- compatibility
  3475. oSettings.jqXHR = $.ajax( $.extend( baseAjax, {
  3476. url: ajax || oSettings.sAjaxSource
  3477. } ) );
  3478. }
  3479. else if ( typeof ajax === 'function' )
  3480. {
  3481. // Is a function - let the caller define what needs to be done
  3482. oSettings.jqXHR = ajax.call( instance, data, callback, oSettings );
  3483. }
  3484. else
  3485. {
  3486. // Object to extend the base settings
  3487. oSettings.jqXHR = $.ajax( $.extend( baseAjax, ajax ) );
  3488. // Restore for next time around
  3489. ajax.data = ajaxData;
  3490. }
  3491. }
  3492. /**
  3493. * Update the table using an Ajax call
  3494. * @param {object} settings dataTables settings object
  3495. * @returns {boolean} Block the table drawing or not
  3496. * @memberof DataTable#oApi
  3497. */
  3498. function _fnAjaxUpdate( settings )
  3499. {
  3500. settings.iDraw++;
  3501. _fnProcessingDisplay( settings, true );
  3502. _fnBuildAjax(
  3503. settings,
  3504. _fnAjaxParameters( settings ),
  3505. function(json) {
  3506. _fnAjaxUpdateDraw( settings, json );
  3507. }
  3508. );
  3509. }
  3510. /**
  3511. * Build up the parameters in an object needed for a server-side processing
  3512. * request. Note that this is basically done twice, is different ways - a modern
  3513. * method which is used by default in DataTables 1.10 which uses objects and
  3514. * arrays, or the 1.9- method with is name / value pairs. 1.9 method is used if
  3515. * the sAjaxSource option is used in the initialisation, or the legacyAjax
  3516. * option is set.
  3517. * @param {object} oSettings dataTables settings object
  3518. * @returns {bool} block the table drawing or not
  3519. * @memberof DataTable#oApi
  3520. */
  3521. function _fnAjaxParameters( settings )
  3522. {
  3523. var
  3524. columns = settings.aoColumns,
  3525. columnCount = columns.length,
  3526. features = settings.oFeatures,
  3527. preSearch = settings.oPreviousSearch,
  3528. preColSearch = settings.aoPreSearchCols,
  3529. i, data = [], dataProp, column, columnSearch,
  3530. sort = _fnSortFlatten( settings ),
  3531. displayStart = settings._iDisplayStart,
  3532. displayLength = features.bPaginate !== false ?
  3533. settings._iDisplayLength :
  3534. -1;
  3535. var param = function ( name, value ) {
  3536. data.push( { 'name': name, 'value': value } );
  3537. };
  3538. // DataTables 1.9- compatible method
  3539. param( 'sEcho', settings.iDraw );
  3540. param( 'iColumns', columnCount );
  3541. param( 'sColumns', _pluck( columns, 'sName' ).join(',') );
  3542. param( 'iDisplayStart', displayStart );
  3543. param( 'iDisplayLength', displayLength );
  3544. // DataTables 1.10+ method
  3545. var d = {
  3546. draw: settings.iDraw,
  3547. columns: [],
  3548. order: [],
  3549. start: displayStart,
  3550. length: displayLength,
  3551. search: {
  3552. value: preSearch.sSearch,
  3553. regex: preSearch.bRegex
  3554. }
  3555. };
  3556. for ( i=0 ; i<columnCount ; i++ ) {
  3557. column = columns[i];
  3558. columnSearch = preColSearch[i];
  3559. dataProp = typeof column.mData=="function" ? 'function' : column.mData ;
  3560. d.columns.push( {
  3561. data: dataProp,
  3562. name: column.sName,
  3563. searchable: column.bSearchable,
  3564. orderable: column.bSortable,
  3565. search: {
  3566. value: columnSearch.sSearch,
  3567. regex: columnSearch.bRegex
  3568. }
  3569. } );
  3570. param( "mDataProp_"+i, dataProp );
  3571. if ( features.bFilter ) {
  3572. param( 'sSearch_'+i, columnSearch.sSearch );
  3573. param( 'bRegex_'+i, columnSearch.bRegex );
  3574. param( 'bSearchable_'+i, column.bSearchable );
  3575. }
  3576. if ( features.bSort ) {
  3577. param( 'bSortable_'+i, column.bSortable );
  3578. }
  3579. }
  3580. if ( features.bFilter ) {
  3581. param( 'sSearch', preSearch.sSearch );
  3582. param( 'bRegex', preSearch.bRegex );
  3583. }
  3584. if ( features.bSort ) {
  3585. $.each( sort, function ( i, val ) {
  3586. d.order.push( { column: val.col, dir: val.dir } );
  3587. param( 'iSortCol_'+i, val.col );
  3588. param( 'sSortDir_'+i, val.dir );
  3589. } );
  3590. param( 'iSortingCols', sort.length );
  3591. }
  3592. // If the legacy.ajax parameter is null, then we automatically decide which
  3593. // form to use, based on sAjaxSource
  3594. var legacy = DataTable.ext.legacy.ajax;
  3595. if ( legacy === null ) {
  3596. return settings.sAjaxSource ? data : d;
  3597. }
  3598. // Otherwise, if legacy has been specified then we use that to decide on the
  3599. // form
  3600. return legacy ? data : d;
  3601. }
  3602. /**
  3603. * Data the data from the server (nuking the old) and redraw the table
  3604. * @param {object} oSettings dataTables settings object
  3605. * @param {object} json json data return from the server.
  3606. * @param {string} json.sEcho Tracking flag for DataTables to match requests
  3607. * @param {int} json.iTotalRecords Number of records in the data set, not accounting for filtering
  3608. * @param {int} json.iTotalDisplayRecords Number of records in the data set, accounting for filtering
  3609. * @param {array} json.aaData The data to display on this page
  3610. * @param {string} [json.sColumns] Column ordering (sName, comma separated)
  3611. * @memberof DataTable#oApi
  3612. */
  3613. function _fnAjaxUpdateDraw ( settings, json )
  3614. {
  3615. // v1.10 uses camelCase variables, while 1.9 uses Hungarian notation.
  3616. // Support both
  3617. var compat = function ( old, modern ) {
  3618. return json[old] !== undefined ? json[old] : json[modern];
  3619. };
  3620. var data = _fnAjaxDataSrc( settings, json );
  3621. var draw = compat( 'sEcho', 'draw' );
  3622. var recordsTotal = compat( 'iTotalRecords', 'recordsTotal' );
  3623. var recordsFiltered = compat( 'iTotalDisplayRecords', 'recordsFiltered' );
  3624. if ( draw !== undefined ) {
  3625. // Protect against out of sequence returns
  3626. if ( draw*1 < settings.iDraw ) {
  3627. return;
  3628. }
  3629. settings.iDraw = draw * 1;
  3630. }
  3631. // No data in returned object, so rather than an array, we show an empty table
  3632. if ( ! data ) {
  3633. data = [];
  3634. }
  3635. _fnClearTable( settings );
  3636. settings._iRecordsTotal = parseInt(recordsTotal, 10);
  3637. settings._iRecordsDisplay = parseInt(recordsFiltered, 10);
  3638. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  3639. _fnAddData( settings, data[i] );
  3640. }
  3641. settings.aiDisplay = settings.aiDisplayMaster.slice();
  3642. _fnDraw( settings, true );
  3643. if ( ! settings._bInitComplete ) {
  3644. _fnInitComplete( settings, json );
  3645. }
  3646. _fnProcessingDisplay( settings, false );
  3647. }
  3648. /**
  3649. * Get the data from the JSON data source to use for drawing a table. Using
  3650. * `_fnGetObjectDataFn` allows the data to be sourced from a property of the
  3651. * source object, or from a processing function.
  3652. * @param {object} oSettings dataTables settings object
  3653. * @param {object} json Data source object / array from the server
  3654. * @return {array} Array of data to use
  3655. */
  3656. function _fnAjaxDataSrc ( oSettings, json, write )
  3657. {
  3658. var dataSrc = $.isPlainObject( oSettings.ajax ) && oSettings.ajax.dataSrc !== undefined ?
  3659. oSettings.ajax.dataSrc :
  3660. oSettings.sAjaxDataProp; // Compatibility with 1.9-.
  3661. if ( ! write ) {
  3662. if ( dataSrc === 'data' ) {
  3663. // If the default, then we still want to support the old style, and safely ignore
  3664. // it if possible
  3665. return json.aaData || json[dataSrc];
  3666. }
  3667. return dataSrc !== "" ?
  3668. _fnGetObjectDataFn( dataSrc )( json ) :
  3669. json;
  3670. }
  3671. // set
  3672. _fnSetObjectDataFn( dataSrc )( json, write );
  3673. }
  3674. /**
  3675. * Generate the node required for filtering text
  3676. * @returns {node} Filter control element
  3677. * @param {object} oSettings dataTables settings object
  3678. * @memberof DataTable#oApi
  3679. */
  3680. function _fnFeatureHtmlFilter ( settings )
  3681. {
  3682. var classes = settings.oClasses;
  3683. var tableId = settings.sTableId;
  3684. var language = settings.oLanguage;
  3685. var previousSearch = settings.oPreviousSearch;
  3686. var features = settings.aanFeatures;
  3687. var input = '<input type="search" class="'+classes.sFilterInput+'"/>';
  3688. var str = language.sSearch;
  3689. str = str.match(/_INPUT_/) ?
  3690. str.replace('_INPUT_', input) :
  3691. str+input;
  3692. var filter = $('<div/>', {
  3693. 'id': ! features.f ? tableId+'_filter' : null,
  3694. 'class': classes.sFilter
  3695. } )
  3696. .append( $('<label/>' ).append( str ) );
  3697. var searchFn = function(event) {
  3698. /* Update all other filter input elements for the new display */
  3699. var n = features.f;
  3700. var val = !this.value ? "" : this.value; // mental IE8 fix :-(
  3701. if(previousSearch.return && event.key !== "Enter") {
  3702. return;
  3703. }
  3704. /* Now do the filter */
  3705. if ( val != previousSearch.sSearch ) {
  3706. _fnFilterComplete( settings, {
  3707. "sSearch": val,
  3708. "bRegex": previousSearch.bRegex,
  3709. "bSmart": previousSearch.bSmart ,
  3710. "bCaseInsensitive": previousSearch.bCaseInsensitive,
  3711. "return": previousSearch.return
  3712. } );
  3713. // Need to redraw, without resorting
  3714. settings._iDisplayStart = 0;
  3715. _fnDraw( settings );
  3716. }
  3717. };
  3718. var searchDelay = settings.searchDelay !== null ?
  3719. settings.searchDelay :
  3720. _fnDataSource( settings ) === 'ssp' ?
  3721. 400 :
  3722. 0;
  3723. var jqFilter = $('input', filter)
  3724. .val( previousSearch.sSearch )
  3725. .attr( 'placeholder', language.sSearchPlaceholder )
  3726. .on(
  3727. 'keyup.DT search.DT input.DT paste.DT cut.DT',
  3728. searchDelay ?
  3729. _fnThrottle( searchFn, searchDelay ) :
  3730. searchFn
  3731. )
  3732. .on( 'mouseup', function(e) {
  3733. // Edge fix! Edge 17 does not trigger anything other than mouse events when clicking
  3734. // on the clear icon (Edge bug 17584515). This is safe in other browsers as `searchFn`
  3735. // checks the value to see if it has changed. In other browsers it won't have.
  3736. setTimeout( function () {
  3737. searchFn.call(jqFilter[0], e);
  3738. }, 10);
  3739. } )
  3740. .on( 'keypress.DT', function(e) {
  3741. /* Prevent form submission */
  3742. if ( e.keyCode == 13 ) {
  3743. return false;
  3744. }
  3745. } )
  3746. .attr('aria-controls', tableId);
  3747. // Update the input elements whenever the table is filtered
  3748. $(settings.nTable).on( 'search.dt.DT', function ( ev, s ) {
  3749. if ( settings === s ) {
  3750. // IE9 throws an 'unknown error' if document.activeElement is used
  3751. // inside an iframe or frame...
  3752. try {
  3753. if ( jqFilter[0] !== document.activeElement ) {
  3754. jqFilter.val( previousSearch.sSearch );
  3755. }
  3756. }
  3757. catch ( e ) {}
  3758. }
  3759. } );
  3760. return filter[0];
  3761. }
  3762. /**
  3763. * Filter the table using both the global filter and column based filtering
  3764. * @param {object} oSettings dataTables settings object
  3765. * @param {object} oSearch search information
  3766. * @param {int} [iForce] force a research of the master array (1) or not (undefined or 0)
  3767. * @memberof DataTable#oApi
  3768. */
  3769. function _fnFilterComplete ( oSettings, oInput, iForce )
  3770. {
  3771. var oPrevSearch = oSettings.oPreviousSearch;
  3772. var aoPrevSearch = oSettings.aoPreSearchCols;
  3773. var fnSaveFilter = function ( oFilter ) {
  3774. /* Save the filtering values */
  3775. oPrevSearch.sSearch = oFilter.sSearch;
  3776. oPrevSearch.bRegex = oFilter.bRegex;
  3777. oPrevSearch.bSmart = oFilter.bSmart;
  3778. oPrevSearch.bCaseInsensitive = oFilter.bCaseInsensitive;
  3779. oPrevSearch.return = oFilter.return;
  3780. };
  3781. var fnRegex = function ( o ) {
  3782. // Backwards compatibility with the bEscapeRegex option
  3783. return o.bEscapeRegex !== undefined ? !o.bEscapeRegex : o.bRegex;
  3784. };
  3785. // Resolve any column types that are unknown due to addition or invalidation
  3786. // @todo As per sort - can this be moved into an event handler?
  3787. _fnColumnTypes( oSettings );
  3788. /* In server-side processing all filtering is done by the server, so no point hanging around here */
  3789. if ( _fnDataSource( oSettings ) != 'ssp' )
  3790. {
  3791. /* Global filter */
  3792. _fnFilter( oSettings, oInput.sSearch, iForce, fnRegex(oInput), oInput.bSmart, oInput.bCaseInsensitive, oInput.return );
  3793. fnSaveFilter( oInput );
  3794. /* Now do the individual column filter */
  3795. for ( var i=0 ; i<aoPrevSearch.length ; i++ )
  3796. {
  3797. _fnFilterColumn( oSettings, aoPrevSearch[i].sSearch, i, fnRegex(aoPrevSearch[i]),
  3798. aoPrevSearch[i].bSmart, aoPrevSearch[i].bCaseInsensitive );
  3799. }
  3800. /* Custom filtering */
  3801. _fnFilterCustom( oSettings );
  3802. }
  3803. else
  3804. {
  3805. fnSaveFilter( oInput );
  3806. }
  3807. /* Tell the draw function we have been filtering */
  3808. oSettings.bFiltered = true;
  3809. _fnCallbackFire( oSettings, null, 'search', [oSettings] );
  3810. }
  3811. /**
  3812. * Apply custom filtering functions
  3813. * @param {object} oSettings dataTables settings object
  3814. * @memberof DataTable#oApi
  3815. */
  3816. function _fnFilterCustom( settings )
  3817. {
  3818. var filters = DataTable.ext.search;
  3819. var displayRows = settings.aiDisplay;
  3820. var row, rowIdx;
  3821. for ( var i=0, ien=filters.length ; i<ien ; i++ ) {
  3822. var rows = [];
  3823. // Loop over each row and see if it should be included
  3824. for ( var j=0, jen=displayRows.length ; j<jen ; j++ ) {
  3825. rowIdx = displayRows[ j ];
  3826. row = settings.aoData[ rowIdx ];
  3827. if ( filters[i]( settings, row._aFilterData, rowIdx, row._aData, j ) ) {
  3828. rows.push( rowIdx );
  3829. }
  3830. }
  3831. // So the array reference doesn't break set the results into the
  3832. // existing array
  3833. displayRows.length = 0;
  3834. $.merge( displayRows, rows );
  3835. }
  3836. }
  3837. /**
  3838. * Filter the table on a per-column basis
  3839. * @param {object} oSettings dataTables settings object
  3840. * @param {string} sInput string to filter on
  3841. * @param {int} iColumn column to filter
  3842. * @param {bool} bRegex treat search string as a regular expression or not
  3843. * @param {bool} bSmart use smart filtering or not
  3844. * @param {bool} bCaseInsensitive Do case insensitive matching or not
  3845. * @memberof DataTable#oApi
  3846. */
  3847. function _fnFilterColumn ( settings, searchStr, colIdx, regex, smart, caseInsensitive )
  3848. {
  3849. if ( searchStr === '' ) {
  3850. return;
  3851. }
  3852. var data;
  3853. var out = [];
  3854. var display = settings.aiDisplay;
  3855. var rpSearch = _fnFilterCreateSearch( searchStr, regex, smart, caseInsensitive );
  3856. for ( var i=0 ; i<display.length ; i++ ) {
  3857. data = settings.aoData[ display[i] ]._aFilterData[ colIdx ];
  3858. if ( rpSearch.test( data ) ) {
  3859. out.push( display[i] );
  3860. }
  3861. }
  3862. settings.aiDisplay = out;
  3863. }
  3864. /**
  3865. * Filter the data table based on user input and draw the table
  3866. * @param {object} settings dataTables settings object
  3867. * @param {string} input string to filter on
  3868. * @param {int} force optional - force a research of the master array (1) or not (undefined or 0)
  3869. * @param {bool} regex treat as a regular expression or not
  3870. * @param {bool} smart perform smart filtering or not
  3871. * @param {bool} caseInsensitive Do case insensitive matching or not
  3872. * @memberof DataTable#oApi
  3873. */
  3874. function _fnFilter( settings, input, force, regex, smart, caseInsensitive )
  3875. {
  3876. var rpSearch = _fnFilterCreateSearch( input, regex, smart, caseInsensitive );
  3877. var prevSearch = settings.oPreviousSearch.sSearch;
  3878. var displayMaster = settings.aiDisplayMaster;
  3879. var display, invalidated, i;
  3880. var filtered = [];
  3881. // Need to take account of custom filtering functions - always filter
  3882. if ( DataTable.ext.search.length !== 0 ) {
  3883. force = true;
  3884. }
  3885. // Check if any of the rows were invalidated
  3886. invalidated = _fnFilterData( settings );
  3887. // If the input is blank - we just want the full data set
  3888. if ( input.length <= 0 ) {
  3889. settings.aiDisplay = displayMaster.slice();
  3890. }
  3891. else {
  3892. // New search - start from the master array
  3893. if ( invalidated ||
  3894. force ||
  3895. regex ||
  3896. prevSearch.length > input.length ||
  3897. input.indexOf(prevSearch) !== 0 ||
  3898. settings.bSorted // On resort, the display master needs to be
  3899. // re-filtered since indexes will have changed
  3900. ) {
  3901. settings.aiDisplay = displayMaster.slice();
  3902. }
  3903. // Search the display array
  3904. display = settings.aiDisplay;
  3905. for ( i=0 ; i<display.length ; i++ ) {
  3906. if ( rpSearch.test( settings.aoData[ display[i] ]._sFilterRow ) ) {
  3907. filtered.push( display[i] );
  3908. }
  3909. }
  3910. settings.aiDisplay = filtered;
  3911. }
  3912. }
  3913. /**
  3914. * Build a regular expression object suitable for searching a table
  3915. * @param {string} sSearch string to search for
  3916. * @param {bool} bRegex treat as a regular expression or not
  3917. * @param {bool} bSmart perform smart filtering or not
  3918. * @param {bool} bCaseInsensitive Do case insensitive matching or not
  3919. * @returns {RegExp} constructed object
  3920. * @memberof DataTable#oApi
  3921. */
  3922. function _fnFilterCreateSearch( search, regex, smart, caseInsensitive )
  3923. {
  3924. search = regex ?
  3925. search :
  3926. _fnEscapeRegex( search );
  3927. if ( smart ) {
  3928. /* For smart filtering we want to allow the search to work regardless of
  3929. * word order. We also want double quoted text to be preserved, so word
  3930. * order is important - a la google. So this is what we want to
  3931. * generate:
  3932. *
  3933. * ^(?=.*?\bone\b)(?=.*?\btwo three\b)(?=.*?\bfour\b).*$
  3934. */
  3935. var a = $.map( search.match( /"[^"]+"|[^ ]+/g ) || [''], function ( word ) {
  3936. if ( word.charAt(0) === '"' ) {
  3937. var m = word.match( /^"(.*)"$/ );
  3938. word = m ? m[1] : word;
  3939. }
  3940. return word.replace('"', '');
  3941. } );
  3942. search = '^(?=.*?'+a.join( ')(?=.*?' )+').*$';
  3943. }
  3944. return new RegExp( search, caseInsensitive ? 'i' : '' );
  3945. }
  3946. /**
  3947. * Escape a string such that it can be used in a regular expression
  3948. * @param {string} sVal string to escape
  3949. * @returns {string} escaped string
  3950. * @memberof DataTable#oApi
  3951. */
  3952. var _fnEscapeRegex = DataTable.util.escapeRegex;
  3953. var __filter_div = $('<div>')[0];
  3954. var __filter_div_textContent = __filter_div.textContent !== undefined;
  3955. // Update the filtering data for each row if needed (by invalidation or first run)
  3956. function _fnFilterData ( settings )
  3957. {
  3958. var columns = settings.aoColumns;
  3959. var column;
  3960. var i, j, ien, jen, filterData, cellData, row;
  3961. var wasInvalidated = false;
  3962. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  3963. row = settings.aoData[i];
  3964. if ( ! row._aFilterData ) {
  3965. filterData = [];
  3966. for ( j=0, jen=columns.length ; j<jen ; j++ ) {
  3967. column = columns[j];
  3968. if ( column.bSearchable ) {
  3969. cellData = _fnGetCellData( settings, i, j, 'filter' );
  3970. // Search in DataTables 1.10 is string based. In 1.11 this
  3971. // should be altered to also allow strict type checking.
  3972. if ( cellData === null ) {
  3973. cellData = '';
  3974. }
  3975. if ( typeof cellData !== 'string' && cellData.toString ) {
  3976. cellData = cellData.toString();
  3977. }
  3978. }
  3979. else {
  3980. cellData = '';
  3981. }
  3982. // If it looks like there is an HTML entity in the string,
  3983. // attempt to decode it so sorting works as expected. Note that
  3984. // we could use a single line of jQuery to do this, but the DOM
  3985. // method used here is much faster http://jsperf.com/html-decode
  3986. if ( cellData.indexOf && cellData.indexOf('&') !== -1 ) {
  3987. __filter_div.innerHTML = cellData;
  3988. cellData = __filter_div_textContent ?
  3989. __filter_div.textContent :
  3990. __filter_div.innerText;
  3991. }
  3992. if ( cellData.replace ) {
  3993. cellData = cellData.replace(/[\r\n\u2028]/g, '');
  3994. }
  3995. filterData.push( cellData );
  3996. }
  3997. row._aFilterData = filterData;
  3998. row._sFilterRow = filterData.join(' ');
  3999. wasInvalidated = true;
  4000. }
  4001. }
  4002. return wasInvalidated;
  4003. }
  4004. /**
  4005. * Convert from the internal Hungarian notation to camelCase for external
  4006. * interaction
  4007. * @param {object} obj Object to convert
  4008. * @returns {object} Inverted object
  4009. * @memberof DataTable#oApi
  4010. */
  4011. function _fnSearchToCamel ( obj )
  4012. {
  4013. return {
  4014. search: obj.sSearch,
  4015. smart: obj.bSmart,
  4016. regex: obj.bRegex,
  4017. caseInsensitive: obj.bCaseInsensitive
  4018. };
  4019. }
  4020. /**
  4021. * Convert from camelCase notation to the internal Hungarian. We could use the
  4022. * Hungarian convert function here, but this is cleaner
  4023. * @param {object} obj Object to convert
  4024. * @returns {object} Inverted object
  4025. * @memberof DataTable#oApi
  4026. */
  4027. function _fnSearchToHung ( obj )
  4028. {
  4029. return {
  4030. sSearch: obj.search,
  4031. bSmart: obj.smart,
  4032. bRegex: obj.regex,
  4033. bCaseInsensitive: obj.caseInsensitive
  4034. };
  4035. }
  4036. /**
  4037. * Generate the node required for the info display
  4038. * @param {object} oSettings dataTables settings object
  4039. * @returns {node} Information element
  4040. * @memberof DataTable#oApi
  4041. */
  4042. function _fnFeatureHtmlInfo ( settings )
  4043. {
  4044. var
  4045. tid = settings.sTableId,
  4046. nodes = settings.aanFeatures.i,
  4047. n = $('<div/>', {
  4048. 'class': settings.oClasses.sInfo,
  4049. 'id': ! nodes ? tid+'_info' : null
  4050. } );
  4051. if ( ! nodes ) {
  4052. // Update display on each draw
  4053. settings.aoDrawCallback.push( {
  4054. "fn": _fnUpdateInfo,
  4055. "sName": "information"
  4056. } );
  4057. n
  4058. .attr( 'role', 'status' )
  4059. .attr( 'aria-live', 'polite' );
  4060. // Table is described by our info div
  4061. $(settings.nTable).attr( 'aria-describedby', tid+'_info' );
  4062. }
  4063. return n[0];
  4064. }
  4065. /**
  4066. * Update the information elements in the display
  4067. * @param {object} settings dataTables settings object
  4068. * @memberof DataTable#oApi
  4069. */
  4070. function _fnUpdateInfo ( settings )
  4071. {
  4072. /* Show information about the table */
  4073. var nodes = settings.aanFeatures.i;
  4074. if ( nodes.length === 0 ) {
  4075. return;
  4076. }
  4077. var
  4078. lang = settings.oLanguage,
  4079. start = settings._iDisplayStart+1,
  4080. end = settings.fnDisplayEnd(),
  4081. max = settings.fnRecordsTotal(),
  4082. total = settings.fnRecordsDisplay(),
  4083. out = total ?
  4084. lang.sInfo :
  4085. lang.sInfoEmpty;
  4086. if ( total !== max ) {
  4087. /* Record set after filtering */
  4088. out += ' ' + lang.sInfoFiltered;
  4089. }
  4090. // Convert the macros
  4091. out += lang.sInfoPostFix;
  4092. out = _fnInfoMacros( settings, out );
  4093. var callback = lang.fnInfoCallback;
  4094. if ( callback !== null ) {
  4095. out = callback.call( settings.oInstance,
  4096. settings, start, end, max, total, out
  4097. );
  4098. }
  4099. $(nodes).html( out );
  4100. }
  4101. function _fnInfoMacros ( settings, str )
  4102. {
  4103. // When infinite scrolling, we are always starting at 1. _iDisplayStart is used only
  4104. // internally
  4105. var
  4106. formatter = settings.fnFormatNumber,
  4107. start = settings._iDisplayStart+1,
  4108. len = settings._iDisplayLength,
  4109. vis = settings.fnRecordsDisplay(),
  4110. all = len === -1;
  4111. return str.
  4112. replace(/_START_/g, formatter.call( settings, start ) ).
  4113. replace(/_END_/g, formatter.call( settings, settings.fnDisplayEnd() ) ).
  4114. replace(/_MAX_/g, formatter.call( settings, settings.fnRecordsTotal() ) ).
  4115. replace(/_TOTAL_/g, formatter.call( settings, vis ) ).
  4116. replace(/_PAGE_/g, formatter.call( settings, all ? 1 : Math.ceil( start / len ) ) ).
  4117. replace(/_PAGES_/g, formatter.call( settings, all ? 1 : Math.ceil( vis / len ) ) );
  4118. }
  4119. /**
  4120. * Draw the table for the first time, adding all required features
  4121. * @param {object} settings dataTables settings object
  4122. * @memberof DataTable#oApi
  4123. */
  4124. function _fnInitialise ( settings )
  4125. {
  4126. var i, iLen, iAjaxStart=settings.iInitDisplayStart;
  4127. var columns = settings.aoColumns, column;
  4128. var features = settings.oFeatures;
  4129. var deferLoading = settings.bDeferLoading; // value modified by the draw
  4130. /* Ensure that the table data is fully initialised */
  4131. if ( ! settings.bInitialised ) {
  4132. setTimeout( function(){ _fnInitialise( settings ); }, 200 );
  4133. return;
  4134. }
  4135. /* Show the display HTML options */
  4136. _fnAddOptionsHtml( settings );
  4137. /* Build and draw the header / footer for the table */
  4138. _fnBuildHead( settings );
  4139. _fnDrawHead( settings, settings.aoHeader );
  4140. _fnDrawHead( settings, settings.aoFooter );
  4141. /* Okay to show that something is going on now */
  4142. _fnProcessingDisplay( settings, true );
  4143. /* Calculate sizes for columns */
  4144. if ( features.bAutoWidth ) {
  4145. _fnCalculateColumnWidths( settings );
  4146. }
  4147. for ( i=0, iLen=columns.length ; i<iLen ; i++ ) {
  4148. column = columns[i];
  4149. if ( column.sWidth ) {
  4150. column.nTh.style.width = _fnStringToCss( column.sWidth );
  4151. }
  4152. }
  4153. _fnCallbackFire( settings, null, 'preInit', [settings] );
  4154. // If there is default sorting required - let's do it. The sort function
  4155. // will do the drawing for us. Otherwise we draw the table regardless of the
  4156. // Ajax source - this allows the table to look initialised for Ajax sourcing
  4157. // data (show 'loading' message possibly)
  4158. _fnReDraw( settings );
  4159. // Server-side processing init complete is done by _fnAjaxUpdateDraw
  4160. var dataSrc = _fnDataSource( settings );
  4161. if ( dataSrc != 'ssp' || deferLoading ) {
  4162. // if there is an ajax source load the data
  4163. if ( dataSrc == 'ajax' ) {
  4164. _fnBuildAjax( settings, [], function(json) {
  4165. var aData = _fnAjaxDataSrc( settings, json );
  4166. // Got the data - add it to the table
  4167. for ( i=0 ; i<aData.length ; i++ ) {
  4168. _fnAddData( settings, aData[i] );
  4169. }
  4170. // Reset the init display for cookie saving. We've already done
  4171. // a filter, and therefore cleared it before. So we need to make
  4172. // it appear 'fresh'
  4173. settings.iInitDisplayStart = iAjaxStart;
  4174. _fnReDraw( settings );
  4175. _fnProcessingDisplay( settings, false );
  4176. _fnInitComplete( settings, json );
  4177. }, settings );
  4178. }
  4179. else {
  4180. _fnProcessingDisplay( settings, false );
  4181. _fnInitComplete( settings );
  4182. }
  4183. }
  4184. }
  4185. /**
  4186. * Draw the table for the first time, adding all required features
  4187. * @param {object} oSettings dataTables settings object
  4188. * @param {object} [json] JSON from the server that completed the table, if using Ajax source
  4189. * with client-side processing (optional)
  4190. * @memberof DataTable#oApi
  4191. */
  4192. function _fnInitComplete ( settings, json )
  4193. {
  4194. settings._bInitComplete = true;
  4195. // When data was added after the initialisation (data or Ajax) we need to
  4196. // calculate the column sizing
  4197. if ( json || settings.oInit.aaData ) {
  4198. _fnAdjustColumnSizing( settings );
  4199. }
  4200. _fnCallbackFire( settings, null, 'plugin-init', [settings, json] );
  4201. _fnCallbackFire( settings, 'aoInitComplete', 'init', [settings, json] );
  4202. }
  4203. function _fnLengthChange ( settings, val )
  4204. {
  4205. var len = parseInt( val, 10 );
  4206. settings._iDisplayLength = len;
  4207. _fnLengthOverflow( settings );
  4208. // Fire length change event
  4209. _fnCallbackFire( settings, null, 'length', [settings, len] );
  4210. }
  4211. /**
  4212. * Generate the node required for user display length changing
  4213. * @param {object} settings dataTables settings object
  4214. * @returns {node} Display length feature node
  4215. * @memberof DataTable#oApi
  4216. */
  4217. function _fnFeatureHtmlLength ( settings )
  4218. {
  4219. var
  4220. classes = settings.oClasses,
  4221. tableId = settings.sTableId,
  4222. menu = settings.aLengthMenu,
  4223. d2 = Array.isArray( menu[0] ),
  4224. lengths = d2 ? menu[0] : menu,
  4225. language = d2 ? menu[1] : menu;
  4226. var select = $('<select/>', {
  4227. 'name': tableId+'_length',
  4228. 'aria-controls': tableId,
  4229. 'class': classes.sLengthSelect
  4230. } );
  4231. for ( var i=0, ien=lengths.length ; i<ien ; i++ ) {
  4232. select[0][ i ] = new Option(
  4233. typeof language[i] === 'number' ?
  4234. settings.fnFormatNumber( language[i] ) :
  4235. language[i],
  4236. lengths[i]
  4237. );
  4238. }
  4239. var div = $('<div><label/></div>').addClass( classes.sLength );
  4240. if ( ! settings.aanFeatures.l ) {
  4241. div[0].id = tableId+'_length';
  4242. }
  4243. div.children().append(
  4244. settings.oLanguage.sLengthMenu.replace( '_MENU_', select[0].outerHTML )
  4245. );
  4246. // Can't use `select` variable as user might provide their own and the
  4247. // reference is broken by the use of outerHTML
  4248. $('select', div)
  4249. .val( settings._iDisplayLength )
  4250. .on( 'change.DT', function(e) {
  4251. _fnLengthChange( settings, $(this).val() );
  4252. _fnDraw( settings );
  4253. } );
  4254. // Update node value whenever anything changes the table's length
  4255. $(settings.nTable).on( 'length.dt.DT', function (e, s, len) {
  4256. if ( settings === s ) {
  4257. $('select', div).val( len );
  4258. }
  4259. } );
  4260. return div[0];
  4261. }
  4262. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  4263. * Note that most of the paging logic is done in
  4264. * DataTable.ext.pager
  4265. */
  4266. /**
  4267. * Generate the node required for default pagination
  4268. * @param {object} oSettings dataTables settings object
  4269. * @returns {node} Pagination feature node
  4270. * @memberof DataTable#oApi
  4271. */
  4272. function _fnFeatureHtmlPaginate ( settings )
  4273. {
  4274. var
  4275. type = settings.sPaginationType,
  4276. plugin = DataTable.ext.pager[ type ],
  4277. modern = typeof plugin === 'function',
  4278. redraw = function( settings ) {
  4279. _fnDraw( settings );
  4280. },
  4281. node = $('<div/>').addClass( settings.oClasses.sPaging + type )[0],
  4282. features = settings.aanFeatures;
  4283. if ( ! modern ) {
  4284. plugin.fnInit( settings, node, redraw );
  4285. }
  4286. /* Add a draw callback for the pagination on first instance, to update the paging display */
  4287. if ( ! features.p )
  4288. {
  4289. node.id = settings.sTableId+'_paginate';
  4290. settings.aoDrawCallback.push( {
  4291. "fn": function( settings ) {
  4292. if ( modern ) {
  4293. var
  4294. start = settings._iDisplayStart,
  4295. len = settings._iDisplayLength,
  4296. visRecords = settings.fnRecordsDisplay(),
  4297. all = len === -1,
  4298. page = all ? 0 : Math.ceil( start / len ),
  4299. pages = all ? 1 : Math.ceil( visRecords / len ),
  4300. buttons = plugin(page, pages),
  4301. i, ien;
  4302. for ( i=0, ien=features.p.length ; i<ien ; i++ ) {
  4303. _fnRenderer( settings, 'pageButton' )(
  4304. settings, features.p[i], i, buttons, page, pages
  4305. );
  4306. }
  4307. }
  4308. else {
  4309. plugin.fnUpdate( settings, redraw );
  4310. }
  4311. },
  4312. "sName": "pagination"
  4313. } );
  4314. }
  4315. return node;
  4316. }
  4317. /**
  4318. * Alter the display settings to change the page
  4319. * @param {object} settings DataTables settings object
  4320. * @param {string|int} action Paging action to take: "first", "previous",
  4321. * "next" or "last" or page number to jump to (integer)
  4322. * @param [bool] redraw Automatically draw the update or not
  4323. * @returns {bool} true page has changed, false - no change
  4324. * @memberof DataTable#oApi
  4325. */
  4326. function _fnPageChange ( settings, action, redraw )
  4327. {
  4328. var
  4329. start = settings._iDisplayStart,
  4330. len = settings._iDisplayLength,
  4331. records = settings.fnRecordsDisplay();
  4332. if ( records === 0 || len === -1 )
  4333. {
  4334. start = 0;
  4335. }
  4336. else if ( typeof action === "number" )
  4337. {
  4338. start = action * len;
  4339. if ( start > records )
  4340. {
  4341. start = 0;
  4342. }
  4343. }
  4344. else if ( action == "first" )
  4345. {
  4346. start = 0;
  4347. }
  4348. else if ( action == "previous" )
  4349. {
  4350. start = len >= 0 ?
  4351. start - len :
  4352. 0;
  4353. if ( start < 0 )
  4354. {
  4355. start = 0;
  4356. }
  4357. }
  4358. else if ( action == "next" )
  4359. {
  4360. if ( start + len < records )
  4361. {
  4362. start += len;
  4363. }
  4364. }
  4365. else if ( action == "last" )
  4366. {
  4367. start = Math.floor( (records-1) / len) * len;
  4368. }
  4369. else
  4370. {
  4371. _fnLog( settings, 0, "Unknown paging action: "+action, 5 );
  4372. }
  4373. var changed = settings._iDisplayStart !== start;
  4374. settings._iDisplayStart = start;
  4375. if ( changed ) {
  4376. _fnCallbackFire( settings, null, 'page', [settings] );
  4377. if ( redraw ) {
  4378. _fnDraw( settings );
  4379. }
  4380. }
  4381. return changed;
  4382. }
  4383. /**
  4384. * Generate the node required for the processing node
  4385. * @param {object} settings dataTables settings object
  4386. * @returns {node} Processing element
  4387. * @memberof DataTable#oApi
  4388. */
  4389. function _fnFeatureHtmlProcessing ( settings )
  4390. {
  4391. return $('<div/>', {
  4392. 'id': ! settings.aanFeatures.r ? settings.sTableId+'_processing' : null,
  4393. 'class': settings.oClasses.sProcessing
  4394. } )
  4395. .html( settings.oLanguage.sProcessing )
  4396. .insertBefore( settings.nTable )[0];
  4397. }
  4398. /**
  4399. * Display or hide the processing indicator
  4400. * @param {object} settings dataTables settings object
  4401. * @param {bool} show Show the processing indicator (true) or not (false)
  4402. * @memberof DataTable#oApi
  4403. */
  4404. function _fnProcessingDisplay ( settings, show )
  4405. {
  4406. if ( settings.oFeatures.bProcessing ) {
  4407. $(settings.aanFeatures.r).css( 'display', show ? 'block' : 'none' );
  4408. }
  4409. _fnCallbackFire( settings, null, 'processing', [settings, show] );
  4410. }
  4411. /**
  4412. * Add any control elements for the table - specifically scrolling
  4413. * @param {object} settings dataTables settings object
  4414. * @returns {node} Node to add to the DOM
  4415. * @memberof DataTable#oApi
  4416. */
  4417. function _fnFeatureHtmlTable ( settings )
  4418. {
  4419. var table = $(settings.nTable);
  4420. // Scrolling from here on in
  4421. var scroll = settings.oScroll;
  4422. if ( scroll.sX === '' && scroll.sY === '' ) {
  4423. return settings.nTable;
  4424. }
  4425. var scrollX = scroll.sX;
  4426. var scrollY = scroll.sY;
  4427. var classes = settings.oClasses;
  4428. var caption = table.children('caption');
  4429. var captionSide = caption.length ? caption[0]._captionSide : null;
  4430. var headerClone = $( table[0].cloneNode(false) );
  4431. var footerClone = $( table[0].cloneNode(false) );
  4432. var footer = table.children('tfoot');
  4433. var _div = '<div/>';
  4434. var size = function ( s ) {
  4435. return !s ? null : _fnStringToCss( s );
  4436. };
  4437. if ( ! footer.length ) {
  4438. footer = null;
  4439. }
  4440. /*
  4441. * The HTML structure that we want to generate in this function is:
  4442. * div - scroller
  4443. * div - scroll head
  4444. * div - scroll head inner
  4445. * table - scroll head table
  4446. * thead - thead
  4447. * div - scroll body
  4448. * table - table (master table)
  4449. * thead - thead clone for sizing
  4450. * tbody - tbody
  4451. * div - scroll foot
  4452. * div - scroll foot inner
  4453. * table - scroll foot table
  4454. * tfoot - tfoot
  4455. */
  4456. var scroller = $( _div, { 'class': classes.sScrollWrapper } )
  4457. .append(
  4458. $(_div, { 'class': classes.sScrollHead } )
  4459. .css( {
  4460. overflow: 'hidden',
  4461. position: 'relative',
  4462. border: 0,
  4463. width: scrollX ? size(scrollX) : '100%'
  4464. } )
  4465. .append(
  4466. $(_div, { 'class': classes.sScrollHeadInner } )
  4467. .css( {
  4468. 'box-sizing': 'content-box',
  4469. width: scroll.sXInner || '100%'
  4470. } )
  4471. .append(
  4472. headerClone
  4473. .removeAttr('id')
  4474. .css( 'margin-left', 0 )
  4475. .append( captionSide === 'top' ? caption : null )
  4476. .append(
  4477. table.children('thead')
  4478. )
  4479. )
  4480. )
  4481. )
  4482. .append(
  4483. $(_div, { 'class': classes.sScrollBody } )
  4484. .css( {
  4485. position: 'relative',
  4486. overflow: 'auto',
  4487. width: size( scrollX )
  4488. } )
  4489. .append( table )
  4490. );
  4491. if ( footer ) {
  4492. scroller.append(
  4493. $(_div, { 'class': classes.sScrollFoot } )
  4494. .css( {
  4495. overflow: 'hidden',
  4496. border: 0,
  4497. width: scrollX ? size(scrollX) : '100%'
  4498. } )
  4499. .append(
  4500. $(_div, { 'class': classes.sScrollFootInner } )
  4501. .append(
  4502. footerClone
  4503. .removeAttr('id')
  4504. .css( 'margin-left', 0 )
  4505. .append( captionSide === 'bottom' ? caption : null )
  4506. .append(
  4507. table.children('tfoot')
  4508. )
  4509. )
  4510. )
  4511. );
  4512. }
  4513. var children = scroller.children();
  4514. var scrollHead = children[0];
  4515. var scrollBody = children[1];
  4516. var scrollFoot = footer ? children[2] : null;
  4517. // When the body is scrolled, then we also want to scroll the headers
  4518. if ( scrollX ) {
  4519. $(scrollBody).on( 'scroll.DT', function (e) {
  4520. var scrollLeft = this.scrollLeft;
  4521. scrollHead.scrollLeft = scrollLeft;
  4522. if ( footer ) {
  4523. scrollFoot.scrollLeft = scrollLeft;
  4524. }
  4525. } );
  4526. }
  4527. $(scrollBody).css('max-height', scrollY);
  4528. if (! scroll.bCollapse) {
  4529. $(scrollBody).css('height', scrollY);
  4530. }
  4531. settings.nScrollHead = scrollHead;
  4532. settings.nScrollBody = scrollBody;
  4533. settings.nScrollFoot = scrollFoot;
  4534. // On redraw - align columns
  4535. settings.aoDrawCallback.push( {
  4536. "fn": _fnScrollDraw,
  4537. "sName": "scrolling"
  4538. } );
  4539. return scroller[0];
  4540. }
  4541. /**
  4542. * Update the header, footer and body tables for resizing - i.e. column
  4543. * alignment.
  4544. *
  4545. * Welcome to the most horrible function DataTables. The process that this
  4546. * function follows is basically:
  4547. * 1. Re-create the table inside the scrolling div
  4548. * 2. Take live measurements from the DOM
  4549. * 3. Apply the measurements to align the columns
  4550. * 4. Clean up
  4551. *
  4552. * @param {object} settings dataTables settings object
  4553. * @memberof DataTable#oApi
  4554. */
  4555. function _fnScrollDraw ( settings )
  4556. {
  4557. // Given that this is such a monster function, a lot of variables are use
  4558. // to try and keep the minimised size as small as possible
  4559. var
  4560. scroll = settings.oScroll,
  4561. scrollX = scroll.sX,
  4562. scrollXInner = scroll.sXInner,
  4563. scrollY = scroll.sY,
  4564. barWidth = scroll.iBarWidth,
  4565. divHeader = $(settings.nScrollHead),
  4566. divHeaderStyle = divHeader[0].style,
  4567. divHeaderInner = divHeader.children('div'),
  4568. divHeaderInnerStyle = divHeaderInner[0].style,
  4569. divHeaderTable = divHeaderInner.children('table'),
  4570. divBodyEl = settings.nScrollBody,
  4571. divBody = $(divBodyEl),
  4572. divBodyStyle = divBodyEl.style,
  4573. divFooter = $(settings.nScrollFoot),
  4574. divFooterInner = divFooter.children('div'),
  4575. divFooterTable = divFooterInner.children('table'),
  4576. header = $(settings.nTHead),
  4577. table = $(settings.nTable),
  4578. tableEl = table[0],
  4579. tableStyle = tableEl.style,
  4580. footer = settings.nTFoot ? $(settings.nTFoot) : null,
  4581. browser = settings.oBrowser,
  4582. ie67 = browser.bScrollOversize,
  4583. dtHeaderCells = _pluck( settings.aoColumns, 'nTh' ),
  4584. headerTrgEls, footerTrgEls,
  4585. headerSrcEls, footerSrcEls,
  4586. headerCopy, footerCopy,
  4587. headerWidths=[], footerWidths=[],
  4588. headerContent=[], footerContent=[],
  4589. idx, correction, sanityWidth,
  4590. zeroOut = function(nSizer) {
  4591. var style = nSizer.style;
  4592. style.paddingTop = "0";
  4593. style.paddingBottom = "0";
  4594. style.borderTopWidth = "0";
  4595. style.borderBottomWidth = "0";
  4596. style.height = 0;
  4597. };
  4598. // If the scrollbar visibility has changed from the last draw, we need to
  4599. // adjust the column sizes as the table width will have changed to account
  4600. // for the scrollbar
  4601. var scrollBarVis = divBodyEl.scrollHeight > divBodyEl.clientHeight;
  4602. if ( settings.scrollBarVis !== scrollBarVis && settings.scrollBarVis !== undefined ) {
  4603. settings.scrollBarVis = scrollBarVis;
  4604. _fnAdjustColumnSizing( settings );
  4605. return; // adjust column sizing will call this function again
  4606. }
  4607. else {
  4608. settings.scrollBarVis = scrollBarVis;
  4609. }
  4610. /*
  4611. * 1. Re-create the table inside the scrolling div
  4612. */
  4613. // Remove the old minimised thead and tfoot elements in the inner table
  4614. table.children('thead, tfoot').remove();
  4615. if ( footer ) {
  4616. footerCopy = footer.clone().prependTo( table );
  4617. footerTrgEls = footer.find('tr'); // the original tfoot is in its own table and must be sized
  4618. footerSrcEls = footerCopy.find('tr');
  4619. }
  4620. // Clone the current header and footer elements and then place it into the inner table
  4621. headerCopy = header.clone().prependTo( table );
  4622. headerTrgEls = header.find('tr'); // original header is in its own table
  4623. headerSrcEls = headerCopy.find('tr');
  4624. headerCopy.find('th, td').removeAttr('tabindex');
  4625. /*
  4626. * 2. Take live measurements from the DOM - do not alter the DOM itself!
  4627. */
  4628. // Remove old sizing and apply the calculated column widths
  4629. // Get the unique column headers in the newly created (cloned) header. We want to apply the
  4630. // calculated sizes to this header
  4631. if ( ! scrollX )
  4632. {
  4633. divBodyStyle.width = '100%';
  4634. divHeader[0].style.width = '100%';
  4635. }
  4636. $.each( _fnGetUniqueThs( settings, headerCopy ), function ( i, el ) {
  4637. idx = _fnVisibleToColumnIndex( settings, i );
  4638. el.style.width = settings.aoColumns[idx].sWidth;
  4639. } );
  4640. if ( footer ) {
  4641. _fnApplyToChildren( function(n) {
  4642. n.style.width = "";
  4643. }, footerSrcEls );
  4644. }
  4645. // Size the table as a whole
  4646. sanityWidth = table.outerWidth();
  4647. if ( scrollX === "" ) {
  4648. // No x scrolling
  4649. tableStyle.width = "100%";
  4650. // IE7 will make the width of the table when 100% include the scrollbar
  4651. // - which is shouldn't. When there is a scrollbar we need to take this
  4652. // into account.
  4653. if ( ie67 && (table.find('tbody').height() > divBodyEl.offsetHeight ||
  4654. divBody.css('overflow-y') == "scroll")
  4655. ) {
  4656. tableStyle.width = _fnStringToCss( table.outerWidth() - barWidth);
  4657. }
  4658. // Recalculate the sanity width
  4659. sanityWidth = table.outerWidth();
  4660. }
  4661. else if ( scrollXInner !== "" ) {
  4662. // legacy x scroll inner has been given - use it
  4663. tableStyle.width = _fnStringToCss(scrollXInner);
  4664. // Recalculate the sanity width
  4665. sanityWidth = table.outerWidth();
  4666. }
  4667. // Hidden header should have zero height, so remove padding and borders. Then
  4668. // set the width based on the real headers
  4669. // Apply all styles in one pass
  4670. _fnApplyToChildren( zeroOut, headerSrcEls );
  4671. // Read all widths in next pass
  4672. _fnApplyToChildren( function(nSizer) {
  4673. var style = window.getComputedStyle ?
  4674. window.getComputedStyle(nSizer).width :
  4675. _fnStringToCss( $(nSizer).width() );
  4676. headerContent.push( nSizer.innerHTML );
  4677. headerWidths.push( style );
  4678. }, headerSrcEls );
  4679. // Apply all widths in final pass
  4680. _fnApplyToChildren( function(nToSize, i) {
  4681. nToSize.style.width = headerWidths[i];
  4682. }, headerTrgEls );
  4683. $(headerSrcEls).height(0);
  4684. /* Same again with the footer if we have one */
  4685. if ( footer )
  4686. {
  4687. _fnApplyToChildren( zeroOut, footerSrcEls );
  4688. _fnApplyToChildren( function(nSizer) {
  4689. footerContent.push( nSizer.innerHTML );
  4690. footerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  4691. }, footerSrcEls );
  4692. _fnApplyToChildren( function(nToSize, i) {
  4693. nToSize.style.width = footerWidths[i];
  4694. }, footerTrgEls );
  4695. $(footerSrcEls).height(0);
  4696. }
  4697. /*
  4698. * 3. Apply the measurements
  4699. */
  4700. // "Hide" the header and footer that we used for the sizing. We need to keep
  4701. // the content of the cell so that the width applied to the header and body
  4702. // both match, but we want to hide it completely. We want to also fix their
  4703. // width to what they currently are
  4704. _fnApplyToChildren( function(nSizer, i) {
  4705. nSizer.innerHTML = '<div class="dataTables_sizing">'+headerContent[i]+'</div>';
  4706. nSizer.childNodes[0].style.height = "0";
  4707. nSizer.childNodes[0].style.overflow = "hidden";
  4708. nSizer.style.width = headerWidths[i];
  4709. }, headerSrcEls );
  4710. if ( footer )
  4711. {
  4712. _fnApplyToChildren( function(nSizer, i) {
  4713. nSizer.innerHTML = '<div class="dataTables_sizing">'+footerContent[i]+'</div>';
  4714. nSizer.childNodes[0].style.height = "0";
  4715. nSizer.childNodes[0].style.overflow = "hidden";
  4716. nSizer.style.width = footerWidths[i];
  4717. }, footerSrcEls );
  4718. }
  4719. // Sanity check that the table is of a sensible width. If not then we are going to get
  4720. // misalignment - try to prevent this by not allowing the table to shrink below its min width
  4721. if ( table.outerWidth() < sanityWidth )
  4722. {
  4723. // The min width depends upon if we have a vertical scrollbar visible or not */
  4724. correction = ((divBodyEl.scrollHeight > divBodyEl.offsetHeight ||
  4725. divBody.css('overflow-y') == "scroll")) ?
  4726. sanityWidth+barWidth :
  4727. sanityWidth;
  4728. // IE6/7 are a law unto themselves...
  4729. if ( ie67 && (divBodyEl.scrollHeight >
  4730. divBodyEl.offsetHeight || divBody.css('overflow-y') == "scroll")
  4731. ) {
  4732. tableStyle.width = _fnStringToCss( correction-barWidth );
  4733. }
  4734. // And give the user a warning that we've stopped the table getting too small
  4735. if ( scrollX === "" || scrollXInner !== "" ) {
  4736. _fnLog( settings, 1, 'Possible column misalignment', 6 );
  4737. }
  4738. }
  4739. else
  4740. {
  4741. correction = '100%';
  4742. }
  4743. // Apply to the container elements
  4744. divBodyStyle.width = _fnStringToCss( correction );
  4745. divHeaderStyle.width = _fnStringToCss( correction );
  4746. if ( footer ) {
  4747. settings.nScrollFoot.style.width = _fnStringToCss( correction );
  4748. }
  4749. /*
  4750. * 4. Clean up
  4751. */
  4752. if ( ! scrollY ) {
  4753. /* IE7< puts a vertical scrollbar in place (when it shouldn't be) due to subtracting
  4754. * the scrollbar height from the visible display, rather than adding it on. We need to
  4755. * set the height in order to sort this. Don't want to do it in any other browsers.
  4756. */
  4757. if ( ie67 ) {
  4758. divBodyStyle.height = _fnStringToCss( tableEl.offsetHeight+barWidth );
  4759. }
  4760. }
  4761. /* Finally set the width's of the header and footer tables */
  4762. var iOuterWidth = table.outerWidth();
  4763. divHeaderTable[0].style.width = _fnStringToCss( iOuterWidth );
  4764. divHeaderInnerStyle.width = _fnStringToCss( iOuterWidth );
  4765. // Figure out if there are scrollbar present - if so then we need a the header and footer to
  4766. // provide a bit more space to allow "overflow" scrolling (i.e. past the scrollbar)
  4767. var bScrolling = table.height() > divBodyEl.clientHeight || divBody.css('overflow-y') == "scroll";
  4768. var padding = 'padding' + (browser.bScrollbarLeft ? 'Left' : 'Right' );
  4769. divHeaderInnerStyle[ padding ] = bScrolling ? barWidth+"px" : "0px";
  4770. if ( footer ) {
  4771. divFooterTable[0].style.width = _fnStringToCss( iOuterWidth );
  4772. divFooterInner[0].style.width = _fnStringToCss( iOuterWidth );
  4773. divFooterInner[0].style[padding] = bScrolling ? barWidth+"px" : "0px";
  4774. }
  4775. // Correct DOM ordering for colgroup - comes before the thead
  4776. table.children('colgroup').insertBefore( table.children('thead') );
  4777. /* Adjust the position of the header in case we loose the y-scrollbar */
  4778. divBody.trigger('scroll');
  4779. // If sorting or filtering has occurred, jump the scrolling back to the top
  4780. // only if we aren't holding the position
  4781. if ( (settings.bSorted || settings.bFiltered) && ! settings._drawHold ) {
  4782. divBodyEl.scrollTop = 0;
  4783. }
  4784. }
  4785. /**
  4786. * Apply a given function to the display child nodes of an element array (typically
  4787. * TD children of TR rows
  4788. * @param {function} fn Method to apply to the objects
  4789. * @param array {nodes} an1 List of elements to look through for display children
  4790. * @param array {nodes} an2 Another list (identical structure to the first) - optional
  4791. * @memberof DataTable#oApi
  4792. */
  4793. function _fnApplyToChildren( fn, an1, an2 )
  4794. {
  4795. var index=0, i=0, iLen=an1.length;
  4796. var nNode1, nNode2;
  4797. while ( i < iLen ) {
  4798. nNode1 = an1[i].firstChild;
  4799. nNode2 = an2 ? an2[i].firstChild : null;
  4800. while ( nNode1 ) {
  4801. if ( nNode1.nodeType === 1 ) {
  4802. if ( an2 ) {
  4803. fn( nNode1, nNode2, index );
  4804. }
  4805. else {
  4806. fn( nNode1, index );
  4807. }
  4808. index++;
  4809. }
  4810. nNode1 = nNode1.nextSibling;
  4811. nNode2 = an2 ? nNode2.nextSibling : null;
  4812. }
  4813. i++;
  4814. }
  4815. }
  4816. var __re_html_remove = /<.*?>/g;
  4817. /**
  4818. * Calculate the width of columns for the table
  4819. * @param {object} oSettings dataTables settings object
  4820. * @memberof DataTable#oApi
  4821. */
  4822. function _fnCalculateColumnWidths ( oSettings )
  4823. {
  4824. var
  4825. table = oSettings.nTable,
  4826. columns = oSettings.aoColumns,
  4827. scroll = oSettings.oScroll,
  4828. scrollY = scroll.sY,
  4829. scrollX = scroll.sX,
  4830. scrollXInner = scroll.sXInner,
  4831. columnCount = columns.length,
  4832. visibleColumns = _fnGetColumns( oSettings, 'bVisible' ),
  4833. headerCells = $('th', oSettings.nTHead),
  4834. tableWidthAttr = table.getAttribute('width'), // from DOM element
  4835. tableContainer = table.parentNode,
  4836. userInputs = false,
  4837. i, column, columnIdx, width, outerWidth,
  4838. browser = oSettings.oBrowser,
  4839. ie67 = browser.bScrollOversize;
  4840. var styleWidth = table.style.width;
  4841. if ( styleWidth && styleWidth.indexOf('%') !== -1 ) {
  4842. tableWidthAttr = styleWidth;
  4843. }
  4844. /* Convert any user input sizes into pixel sizes */
  4845. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4846. column = columns[ visibleColumns[i] ];
  4847. if ( column.sWidth !== null ) {
  4848. column.sWidth = _fnConvertToWidth( column.sWidthOrig, tableContainer );
  4849. userInputs = true;
  4850. }
  4851. }
  4852. /* If the number of columns in the DOM equals the number that we have to
  4853. * process in DataTables, then we can use the offsets that are created by
  4854. * the web- browser. No custom sizes can be set in order for this to happen,
  4855. * nor scrolling used
  4856. */
  4857. if ( ie67 || ! userInputs && ! scrollX && ! scrollY &&
  4858. columnCount == _fnVisbleColumns( oSettings ) &&
  4859. columnCount == headerCells.length
  4860. ) {
  4861. for ( i=0 ; i<columnCount ; i++ ) {
  4862. var colIdx = _fnVisibleToColumnIndex( oSettings, i );
  4863. if ( colIdx !== null ) {
  4864. columns[ colIdx ].sWidth = _fnStringToCss( headerCells.eq(i).width() );
  4865. }
  4866. }
  4867. }
  4868. else
  4869. {
  4870. // Otherwise construct a single row, worst case, table with the widest
  4871. // node in the data, assign any user defined widths, then insert it into
  4872. // the DOM and allow the browser to do all the hard work of calculating
  4873. // table widths
  4874. var tmpTable = $(table).clone() // don't use cloneNode - IE8 will remove events on the main table
  4875. .css( 'visibility', 'hidden' )
  4876. .removeAttr( 'id' );
  4877. // Clean up the table body
  4878. tmpTable.find('tbody tr').remove();
  4879. var tr = $('<tr/>').appendTo( tmpTable.find('tbody') );
  4880. // Clone the table header and footer - we can't use the header / footer
  4881. // from the cloned table, since if scrolling is active, the table's
  4882. // real header and footer are contained in different table tags
  4883. tmpTable.find('thead, tfoot').remove();
  4884. tmpTable
  4885. .append( $(oSettings.nTHead).clone() )
  4886. .append( $(oSettings.nTFoot).clone() );
  4887. // Remove any assigned widths from the footer (from scrolling)
  4888. tmpTable.find('tfoot th, tfoot td').css('width', '');
  4889. // Apply custom sizing to the cloned header
  4890. headerCells = _fnGetUniqueThs( oSettings, tmpTable.find('thead')[0] );
  4891. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4892. column = columns[ visibleColumns[i] ];
  4893. headerCells[i].style.width = column.sWidthOrig !== null && column.sWidthOrig !== '' ?
  4894. _fnStringToCss( column.sWidthOrig ) :
  4895. '';
  4896. // For scrollX we need to force the column width otherwise the
  4897. // browser will collapse it. If this width is smaller than the
  4898. // width the column requires, then it will have no effect
  4899. if ( column.sWidthOrig && scrollX ) {
  4900. $( headerCells[i] ).append( $('<div/>').css( {
  4901. width: column.sWidthOrig,
  4902. margin: 0,
  4903. padding: 0,
  4904. border: 0,
  4905. height: 1
  4906. } ) );
  4907. }
  4908. }
  4909. // Find the widest cell for each column and put it into the table
  4910. if ( oSettings.aoData.length ) {
  4911. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4912. columnIdx = visibleColumns[i];
  4913. column = columns[ columnIdx ];
  4914. $( _fnGetWidestNode( oSettings, columnIdx ) )
  4915. .clone( false )
  4916. .append( column.sContentPadding )
  4917. .appendTo( tr );
  4918. }
  4919. }
  4920. // Tidy the temporary table - remove name attributes so there aren't
  4921. // duplicated in the dom (radio elements for example)
  4922. $('[name]', tmpTable).removeAttr('name');
  4923. // Table has been built, attach to the document so we can work with it.
  4924. // A holding element is used, positioned at the top of the container
  4925. // with minimal height, so it has no effect on if the container scrolls
  4926. // or not. Otherwise it might trigger scrolling when it actually isn't
  4927. // needed
  4928. var holder = $('<div/>').css( scrollX || scrollY ?
  4929. {
  4930. position: 'absolute',
  4931. top: 0,
  4932. left: 0,
  4933. height: 1,
  4934. right: 0,
  4935. overflow: 'hidden'
  4936. } :
  4937. {}
  4938. )
  4939. .append( tmpTable )
  4940. .appendTo( tableContainer );
  4941. // When scrolling (X or Y) we want to set the width of the table as
  4942. // appropriate. However, when not scrolling leave the table width as it
  4943. // is. This results in slightly different, but I think correct behaviour
  4944. if ( scrollX && scrollXInner ) {
  4945. tmpTable.width( scrollXInner );
  4946. }
  4947. else if ( scrollX ) {
  4948. tmpTable.css( 'width', 'auto' );
  4949. tmpTable.removeAttr('width');
  4950. // If there is no width attribute or style, then allow the table to
  4951. // collapse
  4952. if ( tmpTable.width() < tableContainer.clientWidth && tableWidthAttr ) {
  4953. tmpTable.width( tableContainer.clientWidth );
  4954. }
  4955. }
  4956. else if ( scrollY ) {
  4957. tmpTable.width( tableContainer.clientWidth );
  4958. }
  4959. else if ( tableWidthAttr ) {
  4960. tmpTable.width( tableWidthAttr );
  4961. }
  4962. // Get the width of each column in the constructed table - we need to
  4963. // know the inner width (so it can be assigned to the other table's
  4964. // cells) and the outer width so we can calculate the full width of the
  4965. // table. This is safe since DataTables requires a unique cell for each
  4966. // column, but if ever a header can span multiple columns, this will
  4967. // need to be modified.
  4968. var total = 0;
  4969. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4970. var cell = $(headerCells[i]);
  4971. var border = cell.outerWidth() - cell.width();
  4972. // Use getBounding... where possible (not IE8-) because it can give
  4973. // sub-pixel accuracy, which we then want to round up!
  4974. var bounding = browser.bBounding ?
  4975. Math.ceil( headerCells[i].getBoundingClientRect().width ) :
  4976. cell.outerWidth();
  4977. // Total is tracked to remove any sub-pixel errors as the outerWidth
  4978. // of the table might not equal the total given here (IE!).
  4979. total += bounding;
  4980. // Width for each column to use
  4981. columns[ visibleColumns[i] ].sWidth = _fnStringToCss( bounding - border );
  4982. }
  4983. table.style.width = _fnStringToCss( total );
  4984. // Finished with the table - ditch it
  4985. holder.remove();
  4986. }
  4987. // If there is a width attr, we want to attach an event listener which
  4988. // allows the table sizing to automatically adjust when the window is
  4989. // resized. Use the width attr rather than CSS, since we can't know if the
  4990. // CSS is a relative value or absolute - DOM read is always px.
  4991. if ( tableWidthAttr ) {
  4992. table.style.width = _fnStringToCss( tableWidthAttr );
  4993. }
  4994. if ( (tableWidthAttr || scrollX) && ! oSettings._reszEvt ) {
  4995. var bindResize = function () {
  4996. $(window).on('resize.DT-'+oSettings.sInstance, _fnThrottle( function () {
  4997. _fnAdjustColumnSizing( oSettings );
  4998. } ) );
  4999. };
  5000. // IE6/7 will crash if we bind a resize event handler on page load.
  5001. // To be removed in 1.11 which drops IE6/7 support
  5002. if ( ie67 ) {
  5003. setTimeout( bindResize, 1000 );
  5004. }
  5005. else {
  5006. bindResize();
  5007. }
  5008. oSettings._reszEvt = true;
  5009. }
  5010. }
  5011. /**
  5012. * Throttle the calls to a function. Arguments and context are maintained for
  5013. * the throttled function
  5014. * @param {function} fn Function to be called
  5015. * @param {int} [freq=200] call frequency in mS
  5016. * @returns {function} wrapped function
  5017. * @memberof DataTable#oApi
  5018. */
  5019. var _fnThrottle = DataTable.util.throttle;
  5020. /**
  5021. * Convert a CSS unit width to pixels (e.g. 2em)
  5022. * @param {string} width width to be converted
  5023. * @param {node} parent parent to get the with for (required for relative widths) - optional
  5024. * @returns {int} width in pixels
  5025. * @memberof DataTable#oApi
  5026. */
  5027. function _fnConvertToWidth ( width, parent )
  5028. {
  5029. if ( ! width ) {
  5030. return 0;
  5031. }
  5032. var n = $('<div/>')
  5033. .css( 'width', _fnStringToCss( width ) )
  5034. .appendTo( parent || document.body );
  5035. var val = n[0].offsetWidth;
  5036. n.remove();
  5037. return val;
  5038. }
  5039. /**
  5040. * Get the widest node
  5041. * @param {object} settings dataTables settings object
  5042. * @param {int} colIdx column of interest
  5043. * @returns {node} widest table node
  5044. * @memberof DataTable#oApi
  5045. */
  5046. function _fnGetWidestNode( settings, colIdx )
  5047. {
  5048. var idx = _fnGetMaxLenString( settings, colIdx );
  5049. if ( idx < 0 ) {
  5050. return null;
  5051. }
  5052. var data = settings.aoData[ idx ];
  5053. return ! data.nTr ? // Might not have been created when deferred rendering
  5054. $('<td/>').html( _fnGetCellData( settings, idx, colIdx, 'display' ) )[0] :
  5055. data.anCells[ colIdx ];
  5056. }
  5057. /**
  5058. * Get the maximum strlen for each data column
  5059. * @param {object} settings dataTables settings object
  5060. * @param {int} colIdx column of interest
  5061. * @returns {string} max string length for each column
  5062. * @memberof DataTable#oApi
  5063. */
  5064. function _fnGetMaxLenString( settings, colIdx )
  5065. {
  5066. var s, max=-1, maxIdx = -1;
  5067. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  5068. s = _fnGetCellData( settings, i, colIdx, 'display' )+'';
  5069. s = s.replace( __re_html_remove, '' );
  5070. s = s.replace( /&nbsp;/g, ' ' );
  5071. if ( s.length > max ) {
  5072. max = s.length;
  5073. maxIdx = i;
  5074. }
  5075. }
  5076. return maxIdx;
  5077. }
  5078. /**
  5079. * Append a CSS unit (only if required) to a string
  5080. * @param {string} value to css-ify
  5081. * @returns {string} value with css unit
  5082. * @memberof DataTable#oApi
  5083. */
  5084. function _fnStringToCss( s )
  5085. {
  5086. if ( s === null ) {
  5087. return '0px';
  5088. }
  5089. if ( typeof s == 'number' ) {
  5090. return s < 0 ?
  5091. '0px' :
  5092. s+'px';
  5093. }
  5094. // Check it has a unit character already
  5095. return s.match(/\d$/) ?
  5096. s+'px' :
  5097. s;
  5098. }
  5099. function _fnSortFlatten ( settings )
  5100. {
  5101. var
  5102. i, iLen, k, kLen,
  5103. aSort = [],
  5104. aiOrig = [],
  5105. aoColumns = settings.aoColumns,
  5106. aDataSort, iCol, sType, srcCol,
  5107. fixed = settings.aaSortingFixed,
  5108. fixedObj = $.isPlainObject( fixed ),
  5109. nestedSort = [],
  5110. add = function ( a ) {
  5111. if ( a.length && ! Array.isArray( a[0] ) ) {
  5112. // 1D array
  5113. nestedSort.push( a );
  5114. }
  5115. else {
  5116. // 2D array
  5117. $.merge( nestedSort, a );
  5118. }
  5119. };
  5120. // Build the sort array, with pre-fix and post-fix options if they have been
  5121. // specified
  5122. if ( Array.isArray( fixed ) ) {
  5123. add( fixed );
  5124. }
  5125. if ( fixedObj && fixed.pre ) {
  5126. add( fixed.pre );
  5127. }
  5128. add( settings.aaSorting );
  5129. if (fixedObj && fixed.post ) {
  5130. add( fixed.post );
  5131. }
  5132. for ( i=0 ; i<nestedSort.length ; i++ )
  5133. {
  5134. srcCol = nestedSort[i][0];
  5135. aDataSort = aoColumns[ srcCol ].aDataSort;
  5136. for ( k=0, kLen=aDataSort.length ; k<kLen ; k++ )
  5137. {
  5138. iCol = aDataSort[k];
  5139. sType = aoColumns[ iCol ].sType || 'string';
  5140. if ( nestedSort[i]._idx === undefined ) {
  5141. nestedSort[i]._idx = $.inArray( nestedSort[i][1], aoColumns[iCol].asSorting );
  5142. }
  5143. aSort.push( {
  5144. src: srcCol,
  5145. col: iCol,
  5146. dir: nestedSort[i][1],
  5147. index: nestedSort[i]._idx,
  5148. type: sType,
  5149. formatter: DataTable.ext.type.order[ sType+"-pre" ]
  5150. } );
  5151. }
  5152. }
  5153. return aSort;
  5154. }
  5155. /**
  5156. * Change the order of the table
  5157. * @param {object} oSettings dataTables settings object
  5158. * @memberof DataTable#oApi
  5159. * @todo This really needs split up!
  5160. */
  5161. function _fnSort ( oSettings )
  5162. {
  5163. var
  5164. i, ien, iLen, j, jLen, k, kLen,
  5165. sDataType, nTh,
  5166. aiOrig = [],
  5167. oExtSort = DataTable.ext.type.order,
  5168. aoData = oSettings.aoData,
  5169. aoColumns = oSettings.aoColumns,
  5170. aDataSort, data, iCol, sType, oSort,
  5171. formatters = 0,
  5172. sortCol,
  5173. displayMaster = oSettings.aiDisplayMaster,
  5174. aSort;
  5175. // Resolve any column types that are unknown due to addition or invalidation
  5176. // @todo Can this be moved into a 'data-ready' handler which is called when
  5177. // data is going to be used in the table?
  5178. _fnColumnTypes( oSettings );
  5179. aSort = _fnSortFlatten( oSettings );
  5180. for ( i=0, ien=aSort.length ; i<ien ; i++ ) {
  5181. sortCol = aSort[i];
  5182. // Track if we can use the fast sort algorithm
  5183. if ( sortCol.formatter ) {
  5184. formatters++;
  5185. }
  5186. // Load the data needed for the sort, for each cell
  5187. _fnSortData( oSettings, sortCol.col );
  5188. }
  5189. /* No sorting required if server-side or no sorting array */
  5190. if ( _fnDataSource( oSettings ) != 'ssp' && aSort.length !== 0 )
  5191. {
  5192. // Create a value - key array of the current row positions such that we can use their
  5193. // current position during the sort, if values match, in order to perform stable sorting
  5194. for ( i=0, iLen=displayMaster.length ; i<iLen ; i++ ) {
  5195. aiOrig[ displayMaster[i] ] = i;
  5196. }
  5197. /* Do the sort - here we want multi-column sorting based on a given data source (column)
  5198. * and sorting function (from oSort) in a certain direction. It's reasonably complex to
  5199. * follow on it's own, but this is what we want (example two column sorting):
  5200. * fnLocalSorting = function(a,b){
  5201. * var iTest;
  5202. * iTest = oSort['string-asc']('data11', 'data12');
  5203. * if (iTest !== 0)
  5204. * return iTest;
  5205. * iTest = oSort['numeric-desc']('data21', 'data22');
  5206. * if (iTest !== 0)
  5207. * return iTest;
  5208. * return oSort['numeric-asc']( aiOrig[a], aiOrig[b] );
  5209. * }
  5210. * Basically we have a test for each sorting column, if the data in that column is equal,
  5211. * test the next column. If all columns match, then we use a numeric sort on the row
  5212. * positions in the original data array to provide a stable sort.
  5213. *
  5214. * Note - I know it seems excessive to have two sorting methods, but the first is around
  5215. * 15% faster, so the second is only maintained for backwards compatibility with sorting
  5216. * methods which do not have a pre-sort formatting function.
  5217. */
  5218. if ( formatters === aSort.length ) {
  5219. // All sort types have formatting functions
  5220. displayMaster.sort( function ( a, b ) {
  5221. var
  5222. x, y, k, test, sort,
  5223. len=aSort.length,
  5224. dataA = aoData[a]._aSortData,
  5225. dataB = aoData[b]._aSortData;
  5226. for ( k=0 ; k<len ; k++ ) {
  5227. sort = aSort[k];
  5228. x = dataA[ sort.col ];
  5229. y = dataB[ sort.col ];
  5230. test = x<y ? -1 : x>y ? 1 : 0;
  5231. if ( test !== 0 ) {
  5232. return sort.dir === 'asc' ? test : -test;
  5233. }
  5234. }
  5235. x = aiOrig[a];
  5236. y = aiOrig[b];
  5237. return x<y ? -1 : x>y ? 1 : 0;
  5238. } );
  5239. }
  5240. else {
  5241. // Depreciated - remove in 1.11 (providing a plug-in option)
  5242. // Not all sort types have formatting methods, so we have to call their sorting
  5243. // methods.
  5244. displayMaster.sort( function ( a, b ) {
  5245. var
  5246. x, y, k, l, test, sort, fn,
  5247. len=aSort.length,
  5248. dataA = aoData[a]._aSortData,
  5249. dataB = aoData[b]._aSortData;
  5250. for ( k=0 ; k<len ; k++ ) {
  5251. sort = aSort[k];
  5252. x = dataA[ sort.col ];
  5253. y = dataB[ sort.col ];
  5254. fn = oExtSort[ sort.type+"-"+sort.dir ] || oExtSort[ "string-"+sort.dir ];
  5255. test = fn( x, y );
  5256. if ( test !== 0 ) {
  5257. return test;
  5258. }
  5259. }
  5260. x = aiOrig[a];
  5261. y = aiOrig[b];
  5262. return x<y ? -1 : x>y ? 1 : 0;
  5263. } );
  5264. }
  5265. }
  5266. /* Tell the draw function that we have sorted the data */
  5267. oSettings.bSorted = true;
  5268. }
  5269. function _fnSortAria ( settings )
  5270. {
  5271. var label;
  5272. var nextSort;
  5273. var columns = settings.aoColumns;
  5274. var aSort = _fnSortFlatten( settings );
  5275. var oAria = settings.oLanguage.oAria;
  5276. // ARIA attributes - need to loop all columns, to update all (removing old
  5277. // attributes as needed)
  5278. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  5279. {
  5280. var col = columns[i];
  5281. var asSorting = col.asSorting;
  5282. var sTitle = col.ariaTitle || col.sTitle.replace( /<.*?>/g, "" );
  5283. var th = col.nTh;
  5284. // IE7 is throwing an error when setting these properties with jQuery's
  5285. // attr() and removeAttr() methods...
  5286. th.removeAttribute('aria-sort');
  5287. /* In ARIA only the first sorting column can be marked as sorting - no multi-sort option */
  5288. if ( col.bSortable ) {
  5289. if ( aSort.length > 0 && aSort[0].col == i ) {
  5290. th.setAttribute('aria-sort', aSort[0].dir=="asc" ? "ascending" : "descending" );
  5291. nextSort = asSorting[ aSort[0].index+1 ] || asSorting[0];
  5292. }
  5293. else {
  5294. nextSort = asSorting[0];
  5295. }
  5296. label = sTitle + ( nextSort === "asc" ?
  5297. oAria.sSortAscending :
  5298. oAria.sSortDescending
  5299. );
  5300. }
  5301. else {
  5302. label = sTitle;
  5303. }
  5304. th.setAttribute('aria-label', label);
  5305. }
  5306. }
  5307. /**
  5308. * Function to run on user sort request
  5309. * @param {object} settings dataTables settings object
  5310. * @param {node} attachTo node to attach the handler to
  5311. * @param {int} colIdx column sorting index
  5312. * @param {boolean} [append=false] Append the requested sort to the existing
  5313. * sort if true (i.e. multi-column sort)
  5314. * @param {function} [callback] callback function
  5315. * @memberof DataTable#oApi
  5316. */
  5317. function _fnSortListener ( settings, colIdx, append, callback )
  5318. {
  5319. var col = settings.aoColumns[ colIdx ];
  5320. var sorting = settings.aaSorting;
  5321. var asSorting = col.asSorting;
  5322. var nextSortIdx;
  5323. var next = function ( a, overflow ) {
  5324. var idx = a._idx;
  5325. if ( idx === undefined ) {
  5326. idx = $.inArray( a[1], asSorting );
  5327. }
  5328. return idx+1 < asSorting.length ?
  5329. idx+1 :
  5330. overflow ?
  5331. null :
  5332. 0;
  5333. };
  5334. // Convert to 2D array if needed
  5335. if ( typeof sorting[0] === 'number' ) {
  5336. sorting = settings.aaSorting = [ sorting ];
  5337. }
  5338. // If appending the sort then we are multi-column sorting
  5339. if ( append && settings.oFeatures.bSortMulti ) {
  5340. // Are we already doing some kind of sort on this column?
  5341. var sortIdx = $.inArray( colIdx, _pluck(sorting, '0') );
  5342. if ( sortIdx !== -1 ) {
  5343. // Yes, modify the sort
  5344. nextSortIdx = next( sorting[sortIdx], true );
  5345. if ( nextSortIdx === null && sorting.length === 1 ) {
  5346. nextSortIdx = 0; // can't remove sorting completely
  5347. }
  5348. if ( nextSortIdx === null ) {
  5349. sorting.splice( sortIdx, 1 );
  5350. }
  5351. else {
  5352. sorting[sortIdx][1] = asSorting[ nextSortIdx ];
  5353. sorting[sortIdx]._idx = nextSortIdx;
  5354. }
  5355. }
  5356. else {
  5357. // No sort on this column yet
  5358. sorting.push( [ colIdx, asSorting[0], 0 ] );
  5359. sorting[sorting.length-1]._idx = 0;
  5360. }
  5361. }
  5362. else if ( sorting.length && sorting[0][0] == colIdx ) {
  5363. // Single column - already sorting on this column, modify the sort
  5364. nextSortIdx = next( sorting[0] );
  5365. sorting.length = 1;
  5366. sorting[0][1] = asSorting[ nextSortIdx ];
  5367. sorting[0]._idx = nextSortIdx;
  5368. }
  5369. else {
  5370. // Single column - sort only on this column
  5371. sorting.length = 0;
  5372. sorting.push( [ colIdx, asSorting[0] ] );
  5373. sorting[0]._idx = 0;
  5374. }
  5375. // Run the sort by calling a full redraw
  5376. _fnReDraw( settings );
  5377. // callback used for async user interaction
  5378. if ( typeof callback == 'function' ) {
  5379. callback( settings );
  5380. }
  5381. }
  5382. /**
  5383. * Attach a sort handler (click) to a node
  5384. * @param {object} settings dataTables settings object
  5385. * @param {node} attachTo node to attach the handler to
  5386. * @param {int} colIdx column sorting index
  5387. * @param {function} [callback] callback function
  5388. * @memberof DataTable#oApi
  5389. */
  5390. function _fnSortAttachListener ( settings, attachTo, colIdx, callback )
  5391. {
  5392. var col = settings.aoColumns[ colIdx ];
  5393. _fnBindAction( attachTo, {}, function (e) {
  5394. /* If the column is not sortable - don't to anything */
  5395. if ( col.bSortable === false ) {
  5396. return;
  5397. }
  5398. // If processing is enabled use a timeout to allow the processing
  5399. // display to be shown - otherwise to it synchronously
  5400. if ( settings.oFeatures.bProcessing ) {
  5401. _fnProcessingDisplay( settings, true );
  5402. setTimeout( function() {
  5403. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  5404. // In server-side processing, the draw callback will remove the
  5405. // processing display
  5406. if ( _fnDataSource( settings ) !== 'ssp' ) {
  5407. _fnProcessingDisplay( settings, false );
  5408. }
  5409. }, 0 );
  5410. }
  5411. else {
  5412. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  5413. }
  5414. } );
  5415. }
  5416. /**
  5417. * Set the sorting classes on table's body, Note: it is safe to call this function
  5418. * when bSort and bSortClasses are false
  5419. * @param {object} oSettings dataTables settings object
  5420. * @memberof DataTable#oApi
  5421. */
  5422. function _fnSortingClasses( settings )
  5423. {
  5424. var oldSort = settings.aLastSort;
  5425. var sortClass = settings.oClasses.sSortColumn;
  5426. var sort = _fnSortFlatten( settings );
  5427. var features = settings.oFeatures;
  5428. var i, ien, colIdx;
  5429. if ( features.bSort && features.bSortClasses ) {
  5430. // Remove old sorting classes
  5431. for ( i=0, ien=oldSort.length ; i<ien ; i++ ) {
  5432. colIdx = oldSort[i].src;
  5433. // Remove column sorting
  5434. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  5435. .removeClass( sortClass + (i<2 ? i+1 : 3) );
  5436. }
  5437. // Add new column sorting
  5438. for ( i=0, ien=sort.length ; i<ien ; i++ ) {
  5439. colIdx = sort[i].src;
  5440. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  5441. .addClass( sortClass + (i<2 ? i+1 : 3) );
  5442. }
  5443. }
  5444. settings.aLastSort = sort;
  5445. }
  5446. // Get the data to sort a column, be it from cache, fresh (populating the
  5447. // cache), or from a sort formatter
  5448. function _fnSortData( settings, idx )
  5449. {
  5450. // Custom sorting function - provided by the sort data type
  5451. var column = settings.aoColumns[ idx ];
  5452. var customSort = DataTable.ext.order[ column.sSortDataType ];
  5453. var customData;
  5454. if ( customSort ) {
  5455. customData = customSort.call( settings.oInstance, settings, idx,
  5456. _fnColumnIndexToVisible( settings, idx )
  5457. );
  5458. }
  5459. // Use / populate cache
  5460. var row, cellData;
  5461. var formatter = DataTable.ext.type.order[ column.sType+"-pre" ];
  5462. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  5463. row = settings.aoData[i];
  5464. if ( ! row._aSortData ) {
  5465. row._aSortData = [];
  5466. }
  5467. if ( ! row._aSortData[idx] || customSort ) {
  5468. cellData = customSort ?
  5469. customData[i] : // If there was a custom sort function, use data from there
  5470. _fnGetCellData( settings, i, idx, 'sort' );
  5471. row._aSortData[ idx ] = formatter ?
  5472. formatter( cellData ) :
  5473. cellData;
  5474. }
  5475. }
  5476. }
  5477. /**
  5478. * Save the state of a table
  5479. * @param {object} oSettings dataTables settings object
  5480. * @memberof DataTable#oApi
  5481. */
  5482. function _fnSaveState ( settings )
  5483. {
  5484. if (settings._bLoadingState) {
  5485. return;
  5486. }
  5487. /* Store the interesting variables */
  5488. var state = {
  5489. time: +new Date(),
  5490. start: settings._iDisplayStart,
  5491. length: settings._iDisplayLength,
  5492. order: $.extend( true, [], settings.aaSorting ),
  5493. search: _fnSearchToCamel( settings.oPreviousSearch ),
  5494. columns: $.map( settings.aoColumns, function ( col, i ) {
  5495. return {
  5496. visible: col.bVisible,
  5497. search: _fnSearchToCamel( settings.aoPreSearchCols[i] )
  5498. };
  5499. } )
  5500. };
  5501. settings.oSavedState = state;
  5502. _fnCallbackFire( settings, "aoStateSaveParams", 'stateSaveParams', [settings, state] );
  5503. if ( settings.oFeatures.bStateSave && !settings.bDestroying )
  5504. {
  5505. settings.fnStateSaveCallback.call( settings.oInstance, settings, state );
  5506. }
  5507. }
  5508. /**
  5509. * Attempt to load a saved table state
  5510. * @param {object} oSettings dataTables settings object
  5511. * @param {object} oInit DataTables init object so we can override settings
  5512. * @param {function} callback Callback to execute when the state has been loaded
  5513. * @memberof DataTable#oApi
  5514. */
  5515. function _fnLoadState ( settings, oInit, callback )
  5516. {
  5517. if ( ! settings.oFeatures.bStateSave ) {
  5518. callback();
  5519. return;
  5520. }
  5521. var loaded = function(state) {
  5522. _fnImplementState(settings, state, callback);
  5523. }
  5524. var state = settings.fnStateLoadCallback.call( settings.oInstance, settings, loaded );
  5525. if ( state !== undefined ) {
  5526. _fnImplementState( settings, state, callback );
  5527. }
  5528. // otherwise, wait for the loaded callback to be executed
  5529. return true;
  5530. }
  5531. function _fnImplementState ( settings, s, callback) {
  5532. var i, ien;
  5533. var columns = settings.aoColumns;
  5534. settings._bLoadingState = true;
  5535. // When StateRestore was introduced the state could now be implemented at any time
  5536. // Not just initialisation. To do this an api instance is required in some places
  5537. var api = settings._bInitComplete ? new DataTable.Api(settings) : null;
  5538. if ( ! s || ! s.time ) {
  5539. settings._bLoadingState = false;
  5540. callback();
  5541. return;
  5542. }
  5543. // Allow custom and plug-in manipulation functions to alter the saved data set and
  5544. // cancelling of loading by returning false
  5545. var abStateLoad = _fnCallbackFire( settings, 'aoStateLoadParams', 'stateLoadParams', [settings, s] );
  5546. if ( $.inArray( false, abStateLoad ) !== -1 ) {
  5547. settings._bLoadingState = false;
  5548. callback();
  5549. return;
  5550. }
  5551. // Reject old data
  5552. var duration = settings.iStateDuration;
  5553. if ( duration > 0 && s.time < +new Date() - (duration*1000) ) {
  5554. settings._bLoadingState = false;
  5555. callback();
  5556. return;
  5557. }
  5558. // Number of columns have changed - all bets are off, no restore of settings
  5559. if ( s.columns && columns.length !== s.columns.length ) {
  5560. settings._bLoadingState = false;
  5561. callback();
  5562. return;
  5563. }
  5564. // Store the saved state so it might be accessed at any time
  5565. settings.oLoadedState = $.extend( true, {}, s );
  5566. // Restore key features - todo - for 1.11 this needs to be done by
  5567. // subscribed events
  5568. if ( s.start !== undefined ) {
  5569. settings._iDisplayStart = s.start;
  5570. if(api === null) {
  5571. settings.iInitDisplayStart = s.start;
  5572. }
  5573. }
  5574. if ( s.length !== undefined ) {
  5575. settings._iDisplayLength = s.length;
  5576. }
  5577. // Order
  5578. if ( s.order !== undefined ) {
  5579. settings.aaSorting = [];
  5580. $.each( s.order, function ( i, col ) {
  5581. settings.aaSorting.push( col[0] >= columns.length ?
  5582. [ 0, col[1] ] :
  5583. col
  5584. );
  5585. } );
  5586. }
  5587. // Search
  5588. if ( s.search !== undefined ) {
  5589. $.extend( settings.oPreviousSearch, _fnSearchToHung( s.search ) );
  5590. }
  5591. // Columns
  5592. if ( s.columns ) {
  5593. for ( i=0, ien=s.columns.length ; i<ien ; i++ ) {
  5594. var col = s.columns[i];
  5595. // Visibility
  5596. if ( col.visible !== undefined ) {
  5597. // If the api is defined, the table has been initialised so we need to use it rather than internal settings
  5598. if (api) {
  5599. // Don't redraw the columns on every iteration of this loop, we will do this at the end instead
  5600. api.column(i).visible(col.visible, false);
  5601. }
  5602. else {
  5603. columns[i].bVisible = col.visible;
  5604. }
  5605. }
  5606. // Search
  5607. if ( col.search !== undefined ) {
  5608. $.extend( settings.aoPreSearchCols[i], _fnSearchToHung( col.search ) );
  5609. }
  5610. }
  5611. // If the api is defined then we need to adjust the columns once the visibility has been changed
  5612. if (api) {
  5613. api.columns.adjust();
  5614. }
  5615. }
  5616. settings._bLoadingState = false;
  5617. _fnCallbackFire( settings, 'aoStateLoaded', 'stateLoaded', [settings, s] );
  5618. callback();
  5619. };
  5620. /**
  5621. * Return the settings object for a particular table
  5622. * @param {node} table table we are using as a dataTable
  5623. * @returns {object} Settings object - or null if not found
  5624. * @memberof DataTable#oApi
  5625. */
  5626. function _fnSettingsFromNode ( table )
  5627. {
  5628. var settings = DataTable.settings;
  5629. var idx = $.inArray( table, _pluck( settings, 'nTable' ) );
  5630. return idx !== -1 ?
  5631. settings[ idx ] :
  5632. null;
  5633. }
  5634. /**
  5635. * Log an error message
  5636. * @param {object} settings dataTables settings object
  5637. * @param {int} level log error messages, or display them to the user
  5638. * @param {string} msg error message
  5639. * @param {int} tn Technical note id to get more information about the error.
  5640. * @memberof DataTable#oApi
  5641. */
  5642. function _fnLog( settings, level, msg, tn )
  5643. {
  5644. msg = 'DataTables warning: '+
  5645. (settings ? 'table id='+settings.sTableId+' - ' : '')+msg;
  5646. if ( tn ) {
  5647. msg += '. For more information about this error, please see '+
  5648. 'http://datatables.net/tn/'+tn;
  5649. }
  5650. if ( ! level ) {
  5651. // Backwards compatibility pre 1.10
  5652. var ext = DataTable.ext;
  5653. var type = ext.sErrMode || ext.errMode;
  5654. if ( settings ) {
  5655. _fnCallbackFire( settings, null, 'error', [ settings, tn, msg ] );
  5656. }
  5657. if ( type == 'alert' ) {
  5658. alert( msg );
  5659. }
  5660. else if ( type == 'throw' ) {
  5661. throw new Error(msg);
  5662. }
  5663. else if ( typeof type == 'function' ) {
  5664. type( settings, tn, msg );
  5665. }
  5666. }
  5667. else if ( window.console && console.log ) {
  5668. console.log( msg );
  5669. }
  5670. }
  5671. /**
  5672. * See if a property is defined on one object, if so assign it to the other object
  5673. * @param {object} ret target object
  5674. * @param {object} src source object
  5675. * @param {string} name property
  5676. * @param {string} [mappedName] name to map too - optional, name used if not given
  5677. * @memberof DataTable#oApi
  5678. */
  5679. function _fnMap( ret, src, name, mappedName )
  5680. {
  5681. if ( Array.isArray( name ) ) {
  5682. $.each( name, function (i, val) {
  5683. if ( Array.isArray( val ) ) {
  5684. _fnMap( ret, src, val[0], val[1] );
  5685. }
  5686. else {
  5687. _fnMap( ret, src, val );
  5688. }
  5689. } );
  5690. return;
  5691. }
  5692. if ( mappedName === undefined ) {
  5693. mappedName = name;
  5694. }
  5695. if ( src[name] !== undefined ) {
  5696. ret[mappedName] = src[name];
  5697. }
  5698. }
  5699. /**
  5700. * Extend objects - very similar to jQuery.extend, but deep copy objects, and
  5701. * shallow copy arrays. The reason we need to do this, is that we don't want to
  5702. * deep copy array init values (such as aaSorting) since the dev wouldn't be
  5703. * able to override them, but we do want to deep copy arrays.
  5704. * @param {object} out Object to extend
  5705. * @param {object} extender Object from which the properties will be applied to
  5706. * out
  5707. * @param {boolean} breakRefs If true, then arrays will be sliced to take an
  5708. * independent copy with the exception of the `data` or `aaData` parameters
  5709. * if they are present. This is so you can pass in a collection to
  5710. * DataTables and have that used as your data source without breaking the
  5711. * references
  5712. * @returns {object} out Reference, just for convenience - out === the return.
  5713. * @memberof DataTable#oApi
  5714. * @todo This doesn't take account of arrays inside the deep copied objects.
  5715. */
  5716. function _fnExtend( out, extender, breakRefs )
  5717. {
  5718. var val;
  5719. for ( var prop in extender ) {
  5720. if ( extender.hasOwnProperty(prop) ) {
  5721. val = extender[prop];
  5722. if ( $.isPlainObject( val ) ) {
  5723. if ( ! $.isPlainObject( out[prop] ) ) {
  5724. out[prop] = {};
  5725. }
  5726. $.extend( true, out[prop], val );
  5727. }
  5728. else if ( breakRefs && prop !== 'data' && prop !== 'aaData' && Array.isArray(val) ) {
  5729. out[prop] = val.slice();
  5730. }
  5731. else {
  5732. out[prop] = val;
  5733. }
  5734. }
  5735. }
  5736. return out;
  5737. }
  5738. /**
  5739. * Bind an event handers to allow a click or return key to activate the callback.
  5740. * This is good for accessibility since a return on the keyboard will have the
  5741. * same effect as a click, if the element has focus.
  5742. * @param {element} n Element to bind the action to
  5743. * @param {object} oData Data object to pass to the triggered function
  5744. * @param {function} fn Callback function for when the event is triggered
  5745. * @memberof DataTable#oApi
  5746. */
  5747. function _fnBindAction( n, oData, fn )
  5748. {
  5749. $(n)
  5750. .on( 'click.DT', oData, function (e) {
  5751. $(n).trigger('blur'); // Remove focus outline for mouse users
  5752. fn(e);
  5753. } )
  5754. .on( 'keypress.DT', oData, function (e){
  5755. if ( e.which === 13 ) {
  5756. e.preventDefault();
  5757. fn(e);
  5758. }
  5759. } )
  5760. .on( 'selectstart.DT', function () {
  5761. /* Take the brutal approach to cancelling text selection */
  5762. return false;
  5763. } );
  5764. }
  5765. /**
  5766. * Register a callback function. Easily allows a callback function to be added to
  5767. * an array store of callback functions that can then all be called together.
  5768. * @param {object} oSettings dataTables settings object
  5769. * @param {string} sStore Name of the array storage for the callbacks in oSettings
  5770. * @param {function} fn Function to be called back
  5771. * @param {string} sName Identifying name for the callback (i.e. a label)
  5772. * @memberof DataTable#oApi
  5773. */
  5774. function _fnCallbackReg( oSettings, sStore, fn, sName )
  5775. {
  5776. if ( fn )
  5777. {
  5778. oSettings[sStore].push( {
  5779. "fn": fn,
  5780. "sName": sName
  5781. } );
  5782. }
  5783. }
  5784. /**
  5785. * Fire callback functions and trigger events. Note that the loop over the
  5786. * callback array store is done backwards! Further note that you do not want to
  5787. * fire off triggers in time sensitive applications (for example cell creation)
  5788. * as its slow.
  5789. * @param {object} settings dataTables settings object
  5790. * @param {string} callbackArr Name of the array storage for the callbacks in
  5791. * oSettings
  5792. * @param {string} eventName Name of the jQuery custom event to trigger. If
  5793. * null no trigger is fired
  5794. * @param {array} args Array of arguments to pass to the callback function /
  5795. * trigger
  5796. * @memberof DataTable#oApi
  5797. */
  5798. function _fnCallbackFire( settings, callbackArr, eventName, args )
  5799. {
  5800. var ret = [];
  5801. if ( callbackArr ) {
  5802. ret = $.map( settings[callbackArr].slice().reverse(), function (val, i) {
  5803. return val.fn.apply( settings.oInstance, args );
  5804. } );
  5805. }
  5806. if ( eventName !== null ) {
  5807. var e = $.Event( eventName+'.dt' );
  5808. $(settings.nTable).trigger( e, args );
  5809. ret.push( e.result );
  5810. }
  5811. return ret;
  5812. }
  5813. function _fnLengthOverflow ( settings )
  5814. {
  5815. var
  5816. start = settings._iDisplayStart,
  5817. end = settings.fnDisplayEnd(),
  5818. len = settings._iDisplayLength;
  5819. /* If we have space to show extra rows (backing up from the end point - then do so */
  5820. if ( start >= end )
  5821. {
  5822. start = end - len;
  5823. }
  5824. // Keep the start record on the current page
  5825. start -= (start % len);
  5826. if ( len === -1 || start < 0 )
  5827. {
  5828. start = 0;
  5829. }
  5830. settings._iDisplayStart = start;
  5831. }
  5832. function _fnRenderer( settings, type )
  5833. {
  5834. var renderer = settings.renderer;
  5835. var host = DataTable.ext.renderer[type];
  5836. if ( $.isPlainObject( renderer ) && renderer[type] ) {
  5837. // Specific renderer for this type. If available use it, otherwise use
  5838. // the default.
  5839. return host[renderer[type]] || host._;
  5840. }
  5841. else if ( typeof renderer === 'string' ) {
  5842. // Common renderer - if there is one available for this type use it,
  5843. // otherwise use the default
  5844. return host[renderer] || host._;
  5845. }
  5846. // Use the default
  5847. return host._;
  5848. }
  5849. /**
  5850. * Detect the data source being used for the table. Used to simplify the code
  5851. * a little (ajax) and to make it compress a little smaller.
  5852. *
  5853. * @param {object} settings dataTables settings object
  5854. * @returns {string} Data source
  5855. * @memberof DataTable#oApi
  5856. */
  5857. function _fnDataSource ( settings )
  5858. {
  5859. if ( settings.oFeatures.bServerSide ) {
  5860. return 'ssp';
  5861. }
  5862. else if ( settings.ajax || settings.sAjaxSource ) {
  5863. return 'ajax';
  5864. }
  5865. return 'dom';
  5866. }
  5867. /**
  5868. * Computed structure of the DataTables API, defined by the options passed to
  5869. * `DataTable.Api.register()` when building the API.
  5870. *
  5871. * The structure is built in order to speed creation and extension of the Api
  5872. * objects since the extensions are effectively pre-parsed.
  5873. *
  5874. * The array is an array of objects with the following structure, where this
  5875. * base array represents the Api prototype base:
  5876. *
  5877. * [
  5878. * {
  5879. * name: 'data' -- string - Property name
  5880. * val: function () {}, -- function - Api method (or undefined if just an object
  5881. * methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  5882. * propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  5883. * },
  5884. * {
  5885. * name: 'row'
  5886. * val: {},
  5887. * methodExt: [ ... ],
  5888. * propExt: [
  5889. * {
  5890. * name: 'data'
  5891. * val: function () {},
  5892. * methodExt: [ ... ],
  5893. * propExt: [ ... ]
  5894. * },
  5895. * ...
  5896. * ]
  5897. * }
  5898. * ]
  5899. *
  5900. * @type {Array}
  5901. * @ignore
  5902. */
  5903. var __apiStruct = [];
  5904. /**
  5905. * `Array.prototype` reference.
  5906. *
  5907. * @type object
  5908. * @ignore
  5909. */
  5910. var __arrayProto = Array.prototype;
  5911. /**
  5912. * Abstraction for `context` parameter of the `Api` constructor to allow it to
  5913. * take several different forms for ease of use.
  5914. *
  5915. * Each of the input parameter types will be converted to a DataTables settings
  5916. * object where possible.
  5917. *
  5918. * @param {string|node|jQuery|object} mixed DataTable identifier. Can be one
  5919. * of:
  5920. *
  5921. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5922. * with be found and used.
  5923. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5924. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5925. * * `object` - DataTables settings object
  5926. * * `DataTables.Api` - API instance
  5927. * @return {array|null} Matching DataTables settings objects. `null` or
  5928. * `undefined` is returned if no matching DataTable is found.
  5929. * @ignore
  5930. */
  5931. var _toSettings = function ( mixed )
  5932. {
  5933. var idx, jq;
  5934. var settings = DataTable.settings;
  5935. var tables = $.map( settings, function (el, i) {
  5936. return el.nTable;
  5937. } );
  5938. if ( ! mixed ) {
  5939. return [];
  5940. }
  5941. else if ( mixed.nTable && mixed.oApi ) {
  5942. // DataTables settings object
  5943. return [ mixed ];
  5944. }
  5945. else if ( mixed.nodeName && mixed.nodeName.toLowerCase() === 'table' ) {
  5946. // Table node
  5947. idx = $.inArray( mixed, tables );
  5948. return idx !== -1 ? [ settings[idx] ] : null;
  5949. }
  5950. else if ( mixed && typeof mixed.settings === 'function' ) {
  5951. return mixed.settings().toArray();
  5952. }
  5953. else if ( typeof mixed === 'string' ) {
  5954. // jQuery selector
  5955. jq = $(mixed);
  5956. }
  5957. else if ( mixed instanceof $ ) {
  5958. // jQuery object (also DataTables instance)
  5959. jq = mixed;
  5960. }
  5961. if ( jq ) {
  5962. return jq.map( function(i) {
  5963. idx = $.inArray( this, tables );
  5964. return idx !== -1 ? settings[idx] : null;
  5965. } ).toArray();
  5966. }
  5967. };
  5968. /**
  5969. * DataTables API class - used to control and interface with one or more
  5970. * DataTables enhanced tables.
  5971. *
  5972. * The API class is heavily based on jQuery, presenting a chainable interface
  5973. * that you can use to interact with tables. Each instance of the API class has
  5974. * a "context" - i.e. the tables that it will operate on. This could be a single
  5975. * table, all tables on a page or a sub-set thereof.
  5976. *
  5977. * Additionally the API is designed to allow you to easily work with the data in
  5978. * the tables, retrieving and manipulating it as required. This is done by
  5979. * presenting the API class as an array like interface. The contents of the
  5980. * array depend upon the actions requested by each method (for example
  5981. * `rows().nodes()` will return an array of nodes, while `rows().data()` will
  5982. * return an array of objects or arrays depending upon your table's
  5983. * configuration). The API object has a number of array like methods (`push`,
  5984. * `pop`, `reverse` etc) as well as additional helper methods (`each`, `pluck`,
  5985. * `unique` etc) to assist your working with the data held in a table.
  5986. *
  5987. * Most methods (those which return an Api instance) are chainable, which means
  5988. * the return from a method call also has all of the methods available that the
  5989. * top level object had. For example, these two calls are equivalent:
  5990. *
  5991. * // Not chained
  5992. * api.row.add( {...} );
  5993. * api.draw();
  5994. *
  5995. * // Chained
  5996. * api.row.add( {...} ).draw();
  5997. *
  5998. * @class DataTable.Api
  5999. * @param {array|object|string|jQuery} context DataTable identifier. This is
  6000. * used to define which DataTables enhanced tables this API will operate on.
  6001. * Can be one of:
  6002. *
  6003. * * `string` - jQuery selector. Any DataTables' matching the given selector
  6004. * with be found and used.
  6005. * * `node` - `TABLE` node which has already been formed into a DataTable.
  6006. * * `jQuery` - A jQuery object of `TABLE` nodes.
  6007. * * `object` - DataTables settings object
  6008. * @param {array} [data] Data to initialise the Api instance with.
  6009. *
  6010. * @example
  6011. * // Direct initialisation during DataTables construction
  6012. * var api = $('#example').DataTable();
  6013. *
  6014. * @example
  6015. * // Initialisation using a DataTables jQuery object
  6016. * var api = $('#example').dataTable().api();
  6017. *
  6018. * @example
  6019. * // Initialisation as a constructor
  6020. * var api = new $.fn.DataTable.Api( 'table.dataTable' );
  6021. */
  6022. _Api = function ( context, data )
  6023. {
  6024. if ( ! (this instanceof _Api) ) {
  6025. return new _Api( context, data );
  6026. }
  6027. var settings = [];
  6028. var ctxSettings = function ( o ) {
  6029. var a = _toSettings( o );
  6030. if ( a ) {
  6031. settings.push.apply( settings, a );
  6032. }
  6033. };
  6034. if ( Array.isArray( context ) ) {
  6035. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  6036. ctxSettings( context[i] );
  6037. }
  6038. }
  6039. else {
  6040. ctxSettings( context );
  6041. }
  6042. // Remove duplicates
  6043. this.context = _unique( settings );
  6044. // Initial data
  6045. if ( data ) {
  6046. $.merge( this, data );
  6047. }
  6048. // selector
  6049. this.selector = {
  6050. rows: null,
  6051. cols: null,
  6052. opts: null
  6053. };
  6054. _Api.extend( this, this, __apiStruct );
  6055. };
  6056. DataTable.Api = _Api;
  6057. // Don't destroy the existing prototype, just extend it. Required for jQuery 2's
  6058. // isPlainObject.
  6059. $.extend( _Api.prototype, {
  6060. any: function ()
  6061. {
  6062. return this.count() !== 0;
  6063. },
  6064. concat: __arrayProto.concat,
  6065. context: [], // array of table settings objects
  6066. count: function ()
  6067. {
  6068. return this.flatten().length;
  6069. },
  6070. each: function ( fn )
  6071. {
  6072. for ( var i=0, ien=this.length ; i<ien; i++ ) {
  6073. fn.call( this, this[i], i, this );
  6074. }
  6075. return this;
  6076. },
  6077. eq: function ( idx )
  6078. {
  6079. var ctx = this.context;
  6080. return ctx.length > idx ?
  6081. new _Api( ctx[idx], this[idx] ) :
  6082. null;
  6083. },
  6084. filter: function ( fn )
  6085. {
  6086. var a = [];
  6087. if ( __arrayProto.filter ) {
  6088. a = __arrayProto.filter.call( this, fn, this );
  6089. }
  6090. else {
  6091. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  6092. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  6093. if ( fn.call( this, this[i], i, this ) ) {
  6094. a.push( this[i] );
  6095. }
  6096. }
  6097. }
  6098. return new _Api( this.context, a );
  6099. },
  6100. flatten: function ()
  6101. {
  6102. var a = [];
  6103. return new _Api( this.context, a.concat.apply( a, this.toArray() ) );
  6104. },
  6105. join: __arrayProto.join,
  6106. indexOf: __arrayProto.indexOf || function (obj, start)
  6107. {
  6108. for ( var i=(start || 0), ien=this.length ; i<ien ; i++ ) {
  6109. if ( this[i] === obj ) {
  6110. return i;
  6111. }
  6112. }
  6113. return -1;
  6114. },
  6115. iterator: function ( flatten, type, fn, alwaysNew ) {
  6116. var
  6117. a = [], ret,
  6118. i, ien, j, jen,
  6119. context = this.context,
  6120. rows, items, item,
  6121. selector = this.selector;
  6122. // Argument shifting
  6123. if ( typeof flatten === 'string' ) {
  6124. alwaysNew = fn;
  6125. fn = type;
  6126. type = flatten;
  6127. flatten = false;
  6128. }
  6129. for ( i=0, ien=context.length ; i<ien ; i++ ) {
  6130. var apiInst = new _Api( context[i] );
  6131. if ( type === 'table' ) {
  6132. ret = fn.call( apiInst, context[i], i );
  6133. if ( ret !== undefined ) {
  6134. a.push( ret );
  6135. }
  6136. }
  6137. else if ( type === 'columns' || type === 'rows' ) {
  6138. // this has same length as context - one entry for each table
  6139. ret = fn.call( apiInst, context[i], this[i], i );
  6140. if ( ret !== undefined ) {
  6141. a.push( ret );
  6142. }
  6143. }
  6144. else if ( type === 'column' || type === 'column-rows' || type === 'row' || type === 'cell' ) {
  6145. // columns and rows share the same structure.
  6146. // 'this' is an array of column indexes for each context
  6147. items = this[i];
  6148. if ( type === 'column-rows' ) {
  6149. rows = _selector_row_indexes( context[i], selector.opts );
  6150. }
  6151. for ( j=0, jen=items.length ; j<jen ; j++ ) {
  6152. item = items[j];
  6153. if ( type === 'cell' ) {
  6154. ret = fn.call( apiInst, context[i], item.row, item.column, i, j );
  6155. }
  6156. else {
  6157. ret = fn.call( apiInst, context[i], item, i, j, rows );
  6158. }
  6159. if ( ret !== undefined ) {
  6160. a.push( ret );
  6161. }
  6162. }
  6163. }
  6164. }
  6165. if ( a.length || alwaysNew ) {
  6166. var api = new _Api( context, flatten ? a.concat.apply( [], a ) : a );
  6167. var apiSelector = api.selector;
  6168. apiSelector.rows = selector.rows;
  6169. apiSelector.cols = selector.cols;
  6170. apiSelector.opts = selector.opts;
  6171. return api;
  6172. }
  6173. return this;
  6174. },
  6175. lastIndexOf: __arrayProto.lastIndexOf || function (obj, start)
  6176. {
  6177. // Bit cheeky...
  6178. return this.indexOf.apply( this.toArray.reverse(), arguments );
  6179. },
  6180. length: 0,
  6181. map: function ( fn )
  6182. {
  6183. var a = [];
  6184. if ( __arrayProto.map ) {
  6185. a = __arrayProto.map.call( this, fn, this );
  6186. }
  6187. else {
  6188. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  6189. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  6190. a.push( fn.call( this, this[i], i ) );
  6191. }
  6192. }
  6193. return new _Api( this.context, a );
  6194. },
  6195. pluck: function ( prop )
  6196. {
  6197. return this.map( function ( el ) {
  6198. return el[ prop ];
  6199. } );
  6200. },
  6201. pop: __arrayProto.pop,
  6202. push: __arrayProto.push,
  6203. // Does not return an API instance
  6204. reduce: __arrayProto.reduce || function ( fn, init )
  6205. {
  6206. return _fnReduce( this, fn, init, 0, this.length, 1 );
  6207. },
  6208. reduceRight: __arrayProto.reduceRight || function ( fn, init )
  6209. {
  6210. return _fnReduce( this, fn, init, this.length-1, -1, -1 );
  6211. },
  6212. reverse: __arrayProto.reverse,
  6213. // Object with rows, columns and opts
  6214. selector: null,
  6215. shift: __arrayProto.shift,
  6216. slice: function () {
  6217. return new _Api( this.context, this );
  6218. },
  6219. sort: __arrayProto.sort, // ? name - order?
  6220. splice: __arrayProto.splice,
  6221. toArray: function ()
  6222. {
  6223. return __arrayProto.slice.call( this );
  6224. },
  6225. to$: function ()
  6226. {
  6227. return $( this );
  6228. },
  6229. toJQuery: function ()
  6230. {
  6231. return $( this );
  6232. },
  6233. unique: function ()
  6234. {
  6235. return new _Api( this.context, _unique(this) );
  6236. },
  6237. unshift: __arrayProto.unshift
  6238. } );
  6239. _Api.extend = function ( scope, obj, ext )
  6240. {
  6241. // Only extend API instances and static properties of the API
  6242. if ( ! ext.length || ! obj || ( ! (obj instanceof _Api) && ! obj.__dt_wrapper ) ) {
  6243. return;
  6244. }
  6245. var
  6246. i, ien,
  6247. struct,
  6248. methodScoping = function ( scope, fn, struc ) {
  6249. return function () {
  6250. var ret = fn.apply( scope, arguments );
  6251. // Method extension
  6252. _Api.extend( ret, ret, struc.methodExt );
  6253. return ret;
  6254. };
  6255. };
  6256. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  6257. struct = ext[i];
  6258. // Value
  6259. obj[ struct.name ] = struct.type === 'function' ?
  6260. methodScoping( scope, struct.val, struct ) :
  6261. struct.type === 'object' ?
  6262. {} :
  6263. struct.val;
  6264. obj[ struct.name ].__dt_wrapper = true;
  6265. // Property extension
  6266. _Api.extend( scope, obj[ struct.name ], struct.propExt );
  6267. }
  6268. };
  6269. // @todo - Is there need for an augment function?
  6270. // _Api.augment = function ( inst, name )
  6271. // {
  6272. // // Find src object in the structure from the name
  6273. // var parts = name.split('.');
  6274. // _Api.extend( inst, obj );
  6275. // };
  6276. // [
  6277. // {
  6278. // name: 'data' -- string - Property name
  6279. // val: function () {}, -- function - Api method (or undefined if just an object
  6280. // methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  6281. // propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  6282. // },
  6283. // {
  6284. // name: 'row'
  6285. // val: {},
  6286. // methodExt: [ ... ],
  6287. // propExt: [
  6288. // {
  6289. // name: 'data'
  6290. // val: function () {},
  6291. // methodExt: [ ... ],
  6292. // propExt: [ ... ]
  6293. // },
  6294. // ...
  6295. // ]
  6296. // }
  6297. // ]
  6298. _Api.register = _api_register = function ( name, val )
  6299. {
  6300. if ( Array.isArray( name ) ) {
  6301. for ( var j=0, jen=name.length ; j<jen ; j++ ) {
  6302. _Api.register( name[j], val );
  6303. }
  6304. return;
  6305. }
  6306. var
  6307. i, ien,
  6308. heir = name.split('.'),
  6309. struct = __apiStruct,
  6310. key, method;
  6311. var find = function ( src, name ) {
  6312. for ( var i=0, ien=src.length ; i<ien ; i++ ) {
  6313. if ( src[i].name === name ) {
  6314. return src[i];
  6315. }
  6316. }
  6317. return null;
  6318. };
  6319. for ( i=0, ien=heir.length ; i<ien ; i++ ) {
  6320. method = heir[i].indexOf('()') !== -1;
  6321. key = method ?
  6322. heir[i].replace('()', '') :
  6323. heir[i];
  6324. var src = find( struct, key );
  6325. if ( ! src ) {
  6326. src = {
  6327. name: key,
  6328. val: {},
  6329. methodExt: [],
  6330. propExt: [],
  6331. type: 'object'
  6332. };
  6333. struct.push( src );
  6334. }
  6335. if ( i === ien-1 ) {
  6336. src.val = val;
  6337. src.type = typeof val === 'function' ?
  6338. 'function' :
  6339. $.isPlainObject( val ) ?
  6340. 'object' :
  6341. 'other';
  6342. }
  6343. else {
  6344. struct = method ?
  6345. src.methodExt :
  6346. src.propExt;
  6347. }
  6348. }
  6349. };
  6350. _Api.registerPlural = _api_registerPlural = function ( pluralName, singularName, val ) {
  6351. _Api.register( pluralName, val );
  6352. _Api.register( singularName, function () {
  6353. var ret = val.apply( this, arguments );
  6354. if ( ret === this ) {
  6355. // Returned item is the API instance that was passed in, return it
  6356. return this;
  6357. }
  6358. else if ( ret instanceof _Api ) {
  6359. // New API instance returned, want the value from the first item
  6360. // in the returned array for the singular result.
  6361. return ret.length ?
  6362. Array.isArray( ret[0] ) ?
  6363. new _Api( ret.context, ret[0] ) : // Array results are 'enhanced'
  6364. ret[0] :
  6365. undefined;
  6366. }
  6367. // Non-API return - just fire it back
  6368. return ret;
  6369. } );
  6370. };
  6371. /**
  6372. * Selector for HTML tables. Apply the given selector to the give array of
  6373. * DataTables settings objects.
  6374. *
  6375. * @param {string|integer} [selector] jQuery selector string or integer
  6376. * @param {array} Array of DataTables settings objects to be filtered
  6377. * @return {array}
  6378. * @ignore
  6379. */
  6380. var __table_selector = function ( selector, a )
  6381. {
  6382. if ( Array.isArray(selector) ) {
  6383. return $.map( selector, function (item) {
  6384. return __table_selector(item, a);
  6385. } );
  6386. }
  6387. // Integer is used to pick out a table by index
  6388. if ( typeof selector === 'number' ) {
  6389. return [ a[ selector ] ];
  6390. }
  6391. // Perform a jQuery selector on the table nodes
  6392. var nodes = $.map( a, function (el, i) {
  6393. return el.nTable;
  6394. } );
  6395. return $(nodes)
  6396. .filter( selector )
  6397. .map( function (i) {
  6398. // Need to translate back from the table node to the settings
  6399. var idx = $.inArray( this, nodes );
  6400. return a[ idx ];
  6401. } )
  6402. .toArray();
  6403. };
  6404. /**
  6405. * Context selector for the API's context (i.e. the tables the API instance
  6406. * refers to.
  6407. *
  6408. * @name DataTable.Api#tables
  6409. * @param {string|integer} [selector] Selector to pick which tables the iterator
  6410. * should operate on. If not given, all tables in the current context are
  6411. * used. This can be given as a jQuery selector (for example `':gt(0)'`) to
  6412. * select multiple tables or as an integer to select a single table.
  6413. * @returns {DataTable.Api} Returns a new API instance if a selector is given.
  6414. */
  6415. _api_register( 'tables()', function ( selector ) {
  6416. // A new instance is created if there was a selector specified
  6417. return selector !== undefined && selector !== null ?
  6418. new _Api( __table_selector( selector, this.context ) ) :
  6419. this;
  6420. } );
  6421. _api_register( 'table()', function ( selector ) {
  6422. var tables = this.tables( selector );
  6423. var ctx = tables.context;
  6424. // Truncate to the first matched table
  6425. return ctx.length ?
  6426. new _Api( ctx[0] ) :
  6427. tables;
  6428. } );
  6429. _api_registerPlural( 'tables().nodes()', 'table().node()' , function () {
  6430. return this.iterator( 'table', function ( ctx ) {
  6431. return ctx.nTable;
  6432. }, 1 );
  6433. } );
  6434. _api_registerPlural( 'tables().body()', 'table().body()' , function () {
  6435. return this.iterator( 'table', function ( ctx ) {
  6436. return ctx.nTBody;
  6437. }, 1 );
  6438. } );
  6439. _api_registerPlural( 'tables().header()', 'table().header()' , function () {
  6440. return this.iterator( 'table', function ( ctx ) {
  6441. return ctx.nTHead;
  6442. }, 1 );
  6443. } );
  6444. _api_registerPlural( 'tables().footer()', 'table().footer()' , function () {
  6445. return this.iterator( 'table', function ( ctx ) {
  6446. return ctx.nTFoot;
  6447. }, 1 );
  6448. } );
  6449. _api_registerPlural( 'tables().containers()', 'table().container()' , function () {
  6450. return this.iterator( 'table', function ( ctx ) {
  6451. return ctx.nTableWrapper;
  6452. }, 1 );
  6453. } );
  6454. /**
  6455. * Redraw the tables in the current context.
  6456. */
  6457. _api_register( 'draw()', function ( paging ) {
  6458. return this.iterator( 'table', function ( settings ) {
  6459. if ( paging === 'page' ) {
  6460. _fnDraw( settings );
  6461. }
  6462. else {
  6463. if ( typeof paging === 'string' ) {
  6464. paging = paging === 'full-hold' ?
  6465. false :
  6466. true;
  6467. }
  6468. _fnReDraw( settings, paging===false );
  6469. }
  6470. } );
  6471. } );
  6472. /**
  6473. * Get the current page index.
  6474. *
  6475. * @return {integer} Current page index (zero based)
  6476. *//**
  6477. * Set the current page.
  6478. *
  6479. * Note that if you attempt to show a page which does not exist, DataTables will
  6480. * not throw an error, but rather reset the paging.
  6481. *
  6482. * @param {integer|string} action The paging action to take. This can be one of:
  6483. * * `integer` - The page index to jump to
  6484. * * `string` - An action to take:
  6485. * * `first` - Jump to first page.
  6486. * * `next` - Jump to the next page
  6487. * * `previous` - Jump to previous page
  6488. * * `last` - Jump to the last page.
  6489. * @returns {DataTables.Api} this
  6490. */
  6491. _api_register( 'page()', function ( action ) {
  6492. if ( action === undefined ) {
  6493. return this.page.info().page; // not an expensive call
  6494. }
  6495. // else, have an action to take on all tables
  6496. return this.iterator( 'table', function ( settings ) {
  6497. _fnPageChange( settings, action );
  6498. } );
  6499. } );
  6500. /**
  6501. * Paging information for the first table in the current context.
  6502. *
  6503. * If you require paging information for another table, use the `table()` method
  6504. * with a suitable selector.
  6505. *
  6506. * @return {object} Object with the following properties set:
  6507. * * `page` - Current page index (zero based - i.e. the first page is `0`)
  6508. * * `pages` - Total number of pages
  6509. * * `start` - Display index for the first record shown on the current page
  6510. * * `end` - Display index for the last record shown on the current page
  6511. * * `length` - Display length (number of records). Note that generally `start
  6512. * + length = end`, but this is not always true, for example if there are
  6513. * only 2 records to show on the final page, with a length of 10.
  6514. * * `recordsTotal` - Full data set length
  6515. * * `recordsDisplay` - Data set length once the current filtering criterion
  6516. * are applied.
  6517. */
  6518. _api_register( 'page.info()', function ( action ) {
  6519. if ( this.context.length === 0 ) {
  6520. return undefined;
  6521. }
  6522. var
  6523. settings = this.context[0],
  6524. start = settings._iDisplayStart,
  6525. len = settings.oFeatures.bPaginate ? settings._iDisplayLength : -1,
  6526. visRecords = settings.fnRecordsDisplay(),
  6527. all = len === -1;
  6528. return {
  6529. "page": all ? 0 : Math.floor( start / len ),
  6530. "pages": all ? 1 : Math.ceil( visRecords / len ),
  6531. "start": start,
  6532. "end": settings.fnDisplayEnd(),
  6533. "length": len,
  6534. "recordsTotal": settings.fnRecordsTotal(),
  6535. "recordsDisplay": visRecords,
  6536. "serverSide": _fnDataSource( settings ) === 'ssp'
  6537. };
  6538. } );
  6539. /**
  6540. * Get the current page length.
  6541. *
  6542. * @return {integer} Current page length. Note `-1` indicates that all records
  6543. * are to be shown.
  6544. *//**
  6545. * Set the current page length.
  6546. *
  6547. * @param {integer} Page length to set. Use `-1` to show all records.
  6548. * @returns {DataTables.Api} this
  6549. */
  6550. _api_register( 'page.len()', function ( len ) {
  6551. // Note that we can't call this function 'length()' because `length`
  6552. // is a Javascript property of functions which defines how many arguments
  6553. // the function expects.
  6554. if ( len === undefined ) {
  6555. return this.context.length !== 0 ?
  6556. this.context[0]._iDisplayLength :
  6557. undefined;
  6558. }
  6559. // else, set the page length
  6560. return this.iterator( 'table', function ( settings ) {
  6561. _fnLengthChange( settings, len );
  6562. } );
  6563. } );
  6564. var __reload = function ( settings, holdPosition, callback ) {
  6565. // Use the draw event to trigger a callback
  6566. if ( callback ) {
  6567. var api = new _Api( settings );
  6568. api.one( 'draw', function () {
  6569. callback( api.ajax.json() );
  6570. } );
  6571. }
  6572. if ( _fnDataSource( settings ) == 'ssp' ) {
  6573. _fnReDraw( settings, holdPosition );
  6574. }
  6575. else {
  6576. _fnProcessingDisplay( settings, true );
  6577. // Cancel an existing request
  6578. var xhr = settings.jqXHR;
  6579. if ( xhr && xhr.readyState !== 4 ) {
  6580. xhr.abort();
  6581. }
  6582. // Trigger xhr
  6583. _fnBuildAjax( settings, [], function( json ) {
  6584. _fnClearTable( settings );
  6585. var data = _fnAjaxDataSrc( settings, json );
  6586. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6587. _fnAddData( settings, data[i] );
  6588. }
  6589. _fnReDraw( settings, holdPosition );
  6590. _fnProcessingDisplay( settings, false );
  6591. } );
  6592. }
  6593. };
  6594. /**
  6595. * Get the JSON response from the last Ajax request that DataTables made to the
  6596. * server. Note that this returns the JSON from the first table in the current
  6597. * context.
  6598. *
  6599. * @return {object} JSON received from the server.
  6600. */
  6601. _api_register( 'ajax.json()', function () {
  6602. var ctx = this.context;
  6603. if ( ctx.length > 0 ) {
  6604. return ctx[0].json;
  6605. }
  6606. // else return undefined;
  6607. } );
  6608. /**
  6609. * Get the data submitted in the last Ajax request
  6610. */
  6611. _api_register( 'ajax.params()', function () {
  6612. var ctx = this.context;
  6613. if ( ctx.length > 0 ) {
  6614. return ctx[0].oAjaxData;
  6615. }
  6616. // else return undefined;
  6617. } );
  6618. /**
  6619. * Reload tables from the Ajax data source. Note that this function will
  6620. * automatically re-draw the table when the remote data has been loaded.
  6621. *
  6622. * @param {boolean} [reset=true] Reset (default) or hold the current paging
  6623. * position. A full re-sort and re-filter is performed when this method is
  6624. * called, which is why the pagination reset is the default action.
  6625. * @returns {DataTables.Api} this
  6626. */
  6627. _api_register( 'ajax.reload()', function ( callback, resetPaging ) {
  6628. return this.iterator( 'table', function (settings) {
  6629. __reload( settings, resetPaging===false, callback );
  6630. } );
  6631. } );
  6632. /**
  6633. * Get the current Ajax URL. Note that this returns the URL from the first
  6634. * table in the current context.
  6635. *
  6636. * @return {string} Current Ajax source URL
  6637. *//**
  6638. * Set the Ajax URL. Note that this will set the URL for all tables in the
  6639. * current context.
  6640. *
  6641. * @param {string} url URL to set.
  6642. * @returns {DataTables.Api} this
  6643. */
  6644. _api_register( 'ajax.url()', function ( url ) {
  6645. var ctx = this.context;
  6646. if ( url === undefined ) {
  6647. // get
  6648. if ( ctx.length === 0 ) {
  6649. return undefined;
  6650. }
  6651. ctx = ctx[0];
  6652. return ctx.ajax ?
  6653. $.isPlainObject( ctx.ajax ) ?
  6654. ctx.ajax.url :
  6655. ctx.ajax :
  6656. ctx.sAjaxSource;
  6657. }
  6658. // set
  6659. return this.iterator( 'table', function ( settings ) {
  6660. if ( $.isPlainObject( settings.ajax ) ) {
  6661. settings.ajax.url = url;
  6662. }
  6663. else {
  6664. settings.ajax = url;
  6665. }
  6666. // No need to consider sAjaxSource here since DataTables gives priority
  6667. // to `ajax` over `sAjaxSource`. So setting `ajax` here, renders any
  6668. // value of `sAjaxSource` redundant.
  6669. } );
  6670. } );
  6671. /**
  6672. * Load data from the newly set Ajax URL. Note that this method is only
  6673. * available when `ajax.url()` is used to set a URL. Additionally, this method
  6674. * has the same effect as calling `ajax.reload()` but is provided for
  6675. * convenience when setting a new URL. Like `ajax.reload()` it will
  6676. * automatically redraw the table once the remote data has been loaded.
  6677. *
  6678. * @returns {DataTables.Api} this
  6679. */
  6680. _api_register( 'ajax.url().load()', function ( callback, resetPaging ) {
  6681. // Same as a reload, but makes sense to present it for easy access after a
  6682. // url change
  6683. return this.iterator( 'table', function ( ctx ) {
  6684. __reload( ctx, resetPaging===false, callback );
  6685. } );
  6686. } );
  6687. var _selector_run = function ( type, selector, selectFn, settings, opts )
  6688. {
  6689. var
  6690. out = [], res,
  6691. a, i, ien, j, jen,
  6692. selectorType = typeof selector;
  6693. // Can't just check for isArray here, as an API or jQuery instance might be
  6694. // given with their array like look
  6695. if ( ! selector || selectorType === 'string' || selectorType === 'function' || selector.length === undefined ) {
  6696. selector = [ selector ];
  6697. }
  6698. for ( i=0, ien=selector.length ; i<ien ; i++ ) {
  6699. // Only split on simple strings - complex expressions will be jQuery selectors
  6700. a = selector[i] && selector[i].split && ! selector[i].match(/[\[\(:]/) ?
  6701. selector[i].split(',') :
  6702. [ selector[i] ];
  6703. for ( j=0, jen=a.length ; j<jen ; j++ ) {
  6704. res = selectFn( typeof a[j] === 'string' ? (a[j]).trim() : a[j] );
  6705. if ( res && res.length ) {
  6706. out = out.concat( res );
  6707. }
  6708. }
  6709. }
  6710. // selector extensions
  6711. var ext = _ext.selector[ type ];
  6712. if ( ext.length ) {
  6713. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  6714. out = ext[i]( settings, opts, out );
  6715. }
  6716. }
  6717. return _unique( out );
  6718. };
  6719. var _selector_opts = function ( opts )
  6720. {
  6721. if ( ! opts ) {
  6722. opts = {};
  6723. }
  6724. // Backwards compatibility for 1.9- which used the terminology filter rather
  6725. // than search
  6726. if ( opts.filter && opts.search === undefined ) {
  6727. opts.search = opts.filter;
  6728. }
  6729. return $.extend( {
  6730. search: 'none',
  6731. order: 'current',
  6732. page: 'all'
  6733. }, opts );
  6734. };
  6735. var _selector_first = function ( inst )
  6736. {
  6737. // Reduce the API instance to the first item found
  6738. for ( var i=0, ien=inst.length ; i<ien ; i++ ) {
  6739. if ( inst[i].length > 0 ) {
  6740. // Assign the first element to the first item in the instance
  6741. // and truncate the instance and context
  6742. inst[0] = inst[i];
  6743. inst[0].length = 1;
  6744. inst.length = 1;
  6745. inst.context = [ inst.context[i] ];
  6746. return inst;
  6747. }
  6748. }
  6749. // Not found - return an empty instance
  6750. inst.length = 0;
  6751. return inst;
  6752. };
  6753. var _selector_row_indexes = function ( settings, opts )
  6754. {
  6755. var
  6756. i, ien, tmp, a=[],
  6757. displayFiltered = settings.aiDisplay,
  6758. displayMaster = settings.aiDisplayMaster;
  6759. var
  6760. search = opts.search, // none, applied, removed
  6761. order = opts.order, // applied, current, index (original - compatibility with 1.9)
  6762. page = opts.page; // all, current
  6763. if ( _fnDataSource( settings ) == 'ssp' ) {
  6764. // In server-side processing mode, most options are irrelevant since
  6765. // rows not shown don't exist and the index order is the applied order
  6766. // Removed is a special case - for consistency just return an empty
  6767. // array
  6768. return search === 'removed' ?
  6769. [] :
  6770. _range( 0, displayMaster.length );
  6771. }
  6772. else if ( page == 'current' ) {
  6773. // Current page implies that order=current and filter=applied, since it is
  6774. // fairly senseless otherwise, regardless of what order and search actually
  6775. // are
  6776. for ( i=settings._iDisplayStart, ien=settings.fnDisplayEnd() ; i<ien ; i++ ) {
  6777. a.push( displayFiltered[i] );
  6778. }
  6779. }
  6780. else if ( order == 'current' || order == 'applied' ) {
  6781. if ( search == 'none') {
  6782. a = displayMaster.slice();
  6783. }
  6784. else if ( search == 'applied' ) {
  6785. a = displayFiltered.slice();
  6786. }
  6787. else if ( search == 'removed' ) {
  6788. // O(n+m) solution by creating a hash map
  6789. var displayFilteredMap = {};
  6790. for ( var i=0, ien=displayFiltered.length ; i<ien ; i++ ) {
  6791. displayFilteredMap[displayFiltered[i]] = null;
  6792. }
  6793. a = $.map( displayMaster, function (el) {
  6794. return ! displayFilteredMap.hasOwnProperty(el) ?
  6795. el :
  6796. null;
  6797. } );
  6798. }
  6799. }
  6800. else if ( order == 'index' || order == 'original' ) {
  6801. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  6802. if ( search == 'none' ) {
  6803. a.push( i );
  6804. }
  6805. else { // applied | removed
  6806. tmp = $.inArray( i, displayFiltered );
  6807. if ((tmp === -1 && search == 'removed') ||
  6808. (tmp >= 0 && search == 'applied') )
  6809. {
  6810. a.push( i );
  6811. }
  6812. }
  6813. }
  6814. }
  6815. return a;
  6816. };
  6817. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6818. * Rows
  6819. *
  6820. * {} - no selector - use all available rows
  6821. * {integer} - row aoData index
  6822. * {node} - TR node
  6823. * {string} - jQuery selector to apply to the TR elements
  6824. * {array} - jQuery array of nodes, or simply an array of TR nodes
  6825. *
  6826. */
  6827. var __row_selector = function ( settings, selector, opts )
  6828. {
  6829. var rows;
  6830. var run = function ( sel ) {
  6831. var selInt = _intVal( sel );
  6832. var i, ien;
  6833. var aoData = settings.aoData;
  6834. // Short cut - selector is a number and no options provided (default is
  6835. // all records, so no need to check if the index is in there, since it
  6836. // must be - dev error if the index doesn't exist).
  6837. if ( selInt !== null && ! opts ) {
  6838. return [ selInt ];
  6839. }
  6840. if ( ! rows ) {
  6841. rows = _selector_row_indexes( settings, opts );
  6842. }
  6843. if ( selInt !== null && $.inArray( selInt, rows ) !== -1 ) {
  6844. // Selector - integer
  6845. return [ selInt ];
  6846. }
  6847. else if ( sel === null || sel === undefined || sel === '' ) {
  6848. // Selector - none
  6849. return rows;
  6850. }
  6851. // Selector - function
  6852. if ( typeof sel === 'function' ) {
  6853. return $.map( rows, function (idx) {
  6854. var row = aoData[ idx ];
  6855. return sel( idx, row._aData, row.nTr ) ? idx : null;
  6856. } );
  6857. }
  6858. // Selector - node
  6859. if ( sel.nodeName ) {
  6860. var rowIdx = sel._DT_RowIndex; // Property added by DT for fast lookup
  6861. var cellIdx = sel._DT_CellIndex;
  6862. if ( rowIdx !== undefined ) {
  6863. // Make sure that the row is actually still present in the table
  6864. return aoData[ rowIdx ] && aoData[ rowIdx ].nTr === sel ?
  6865. [ rowIdx ] :
  6866. [];
  6867. }
  6868. else if ( cellIdx ) {
  6869. return aoData[ cellIdx.row ] && aoData[ cellIdx.row ].nTr === sel.parentNode ?
  6870. [ cellIdx.row ] :
  6871. [];
  6872. }
  6873. else {
  6874. var host = $(sel).closest('*[data-dt-row]');
  6875. return host.length ?
  6876. [ host.data('dt-row') ] :
  6877. [];
  6878. }
  6879. }
  6880. // ID selector. Want to always be able to select rows by id, regardless
  6881. // of if the tr element has been created or not, so can't rely upon
  6882. // jQuery here - hence a custom implementation. This does not match
  6883. // Sizzle's fast selector or HTML4 - in HTML5 the ID can be anything,
  6884. // but to select it using a CSS selector engine (like Sizzle or
  6885. // querySelect) it would need to need to be escaped for some characters.
  6886. // DataTables simplifies this for row selectors since you can select
  6887. // only a row. A # indicates an id any anything that follows is the id -
  6888. // unescaped.
  6889. if ( typeof sel === 'string' && sel.charAt(0) === '#' ) {
  6890. // get row index from id
  6891. var rowObj = settings.aIds[ sel.replace( /^#/, '' ) ];
  6892. if ( rowObj !== undefined ) {
  6893. return [ rowObj.idx ];
  6894. }
  6895. // need to fall through to jQuery in case there is DOM id that
  6896. // matches
  6897. }
  6898. // Get nodes in the order from the `rows` array with null values removed
  6899. var nodes = _removeEmpty(
  6900. _pluck_order( settings.aoData, rows, 'nTr' )
  6901. );
  6902. // Selector - jQuery selector string, array of nodes or jQuery object/
  6903. // As jQuery's .filter() allows jQuery objects to be passed in filter,
  6904. // it also allows arrays, so this will cope with all three options
  6905. return $(nodes)
  6906. .filter( sel )
  6907. .map( function () {
  6908. return this._DT_RowIndex;
  6909. } )
  6910. .toArray();
  6911. };
  6912. return _selector_run( 'row', selector, run, settings, opts );
  6913. };
  6914. _api_register( 'rows()', function ( selector, opts ) {
  6915. // argument shifting
  6916. if ( selector === undefined ) {
  6917. selector = '';
  6918. }
  6919. else if ( $.isPlainObject( selector ) ) {
  6920. opts = selector;
  6921. selector = '';
  6922. }
  6923. opts = _selector_opts( opts );
  6924. var inst = this.iterator( 'table', function ( settings ) {
  6925. return __row_selector( settings, selector, opts );
  6926. }, 1 );
  6927. // Want argument shifting here and in __row_selector?
  6928. inst.selector.rows = selector;
  6929. inst.selector.opts = opts;
  6930. return inst;
  6931. } );
  6932. _api_register( 'rows().nodes()', function () {
  6933. return this.iterator( 'row', function ( settings, row ) {
  6934. return settings.aoData[ row ].nTr || undefined;
  6935. }, 1 );
  6936. } );
  6937. _api_register( 'rows().data()', function () {
  6938. return this.iterator( true, 'rows', function ( settings, rows ) {
  6939. return _pluck_order( settings.aoData, rows, '_aData' );
  6940. }, 1 );
  6941. } );
  6942. _api_registerPlural( 'rows().cache()', 'row().cache()', function ( type ) {
  6943. return this.iterator( 'row', function ( settings, row ) {
  6944. var r = settings.aoData[ row ];
  6945. return type === 'search' ? r._aFilterData : r._aSortData;
  6946. }, 1 );
  6947. } );
  6948. _api_registerPlural( 'rows().invalidate()', 'row().invalidate()', function ( src ) {
  6949. return this.iterator( 'row', function ( settings, row ) {
  6950. _fnInvalidate( settings, row, src );
  6951. } );
  6952. } );
  6953. _api_registerPlural( 'rows().indexes()', 'row().index()', function () {
  6954. return this.iterator( 'row', function ( settings, row ) {
  6955. return row;
  6956. }, 1 );
  6957. } );
  6958. _api_registerPlural( 'rows().ids()', 'row().id()', function ( hash ) {
  6959. var a = [];
  6960. var context = this.context;
  6961. // `iterator` will drop undefined values, but in this case we want them
  6962. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  6963. for ( var j=0, jen=this[i].length ; j<jen ; j++ ) {
  6964. var id = context[i].rowIdFn( context[i].aoData[ this[i][j] ]._aData );
  6965. a.push( (hash === true ? '#' : '' )+ id );
  6966. }
  6967. }
  6968. return new _Api( context, a );
  6969. } );
  6970. _api_registerPlural( 'rows().remove()', 'row().remove()', function () {
  6971. var that = this;
  6972. this.iterator( 'row', function ( settings, row, thatIdx ) {
  6973. var data = settings.aoData;
  6974. var rowData = data[ row ];
  6975. var i, ien, j, jen;
  6976. var loopRow, loopCells;
  6977. data.splice( row, 1 );
  6978. // Update the cached indexes
  6979. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  6980. loopRow = data[i];
  6981. loopCells = loopRow.anCells;
  6982. // Rows
  6983. if ( loopRow.nTr !== null ) {
  6984. loopRow.nTr._DT_RowIndex = i;
  6985. }
  6986. // Cells
  6987. if ( loopCells !== null ) {
  6988. for ( j=0, jen=loopCells.length ; j<jen ; j++ ) {
  6989. loopCells[j]._DT_CellIndex.row = i;
  6990. }
  6991. }
  6992. }
  6993. // Delete from the display arrays
  6994. _fnDeleteIndex( settings.aiDisplayMaster, row );
  6995. _fnDeleteIndex( settings.aiDisplay, row );
  6996. _fnDeleteIndex( that[ thatIdx ], row, false ); // maintain local indexes
  6997. // For server-side processing tables - subtract the deleted row from the count
  6998. if ( settings._iRecordsDisplay > 0 ) {
  6999. settings._iRecordsDisplay--;
  7000. }
  7001. // Check for an 'overflow' they case for displaying the table
  7002. _fnLengthOverflow( settings );
  7003. // Remove the row's ID reference if there is one
  7004. var id = settings.rowIdFn( rowData._aData );
  7005. if ( id !== undefined ) {
  7006. delete settings.aIds[ id ];
  7007. }
  7008. } );
  7009. this.iterator( 'table', function ( settings ) {
  7010. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  7011. settings.aoData[i].idx = i;
  7012. }
  7013. } );
  7014. return this;
  7015. } );
  7016. _api_register( 'rows.add()', function ( rows ) {
  7017. var newRows = this.iterator( 'table', function ( settings ) {
  7018. var row, i, ien;
  7019. var out = [];
  7020. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  7021. row = rows[i];
  7022. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  7023. out.push( _fnAddTr( settings, row )[0] );
  7024. }
  7025. else {
  7026. out.push( _fnAddData( settings, row ) );
  7027. }
  7028. }
  7029. return out;
  7030. }, 1 );
  7031. // Return an Api.rows() extended instance, so rows().nodes() etc can be used
  7032. var modRows = this.rows( -1 );
  7033. modRows.pop();
  7034. $.merge( modRows, newRows );
  7035. return modRows;
  7036. } );
  7037. /**
  7038. *
  7039. */
  7040. _api_register( 'row()', function ( selector, opts ) {
  7041. return _selector_first( this.rows( selector, opts ) );
  7042. } );
  7043. _api_register( 'row().data()', function ( data ) {
  7044. var ctx = this.context;
  7045. if ( data === undefined ) {
  7046. // Get
  7047. return ctx.length && this.length ?
  7048. ctx[0].aoData[ this[0] ]._aData :
  7049. undefined;
  7050. }
  7051. // Set
  7052. var row = ctx[0].aoData[ this[0] ];
  7053. row._aData = data;
  7054. // If the DOM has an id, and the data source is an array
  7055. if ( Array.isArray( data ) && row.nTr && row.nTr.id ) {
  7056. _fnSetObjectDataFn( ctx[0].rowId )( data, row.nTr.id );
  7057. }
  7058. // Automatically invalidate
  7059. _fnInvalidate( ctx[0], this[0], 'data' );
  7060. return this;
  7061. } );
  7062. _api_register( 'row().node()', function () {
  7063. var ctx = this.context;
  7064. return ctx.length && this.length ?
  7065. ctx[0].aoData[ this[0] ].nTr || null :
  7066. null;
  7067. } );
  7068. _api_register( 'row.add()', function ( row ) {
  7069. // Allow a jQuery object to be passed in - only a single row is added from
  7070. // it though - the first element in the set
  7071. if ( row instanceof $ && row.length ) {
  7072. row = row[0];
  7073. }
  7074. var rows = this.iterator( 'table', function ( settings ) {
  7075. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  7076. return _fnAddTr( settings, row )[0];
  7077. }
  7078. return _fnAddData( settings, row );
  7079. } );
  7080. // Return an Api.rows() extended instance, with the newly added row selected
  7081. return this.row( rows[0] );
  7082. } );
  7083. $(document).on('plugin-init.dt', function (e, context) {
  7084. var api = new _Api( context );
  7085. api.on( 'stateSaveParams', function ( e, settings, data ) {
  7086. var indexes = api.rows().iterator( 'row', function ( settings, idx ) {
  7087. return settings.aoData[idx]._detailsShow ? idx : undefined;
  7088. });
  7089. data.childRows = api.rows( indexes ).ids( true ).toArray();
  7090. })
  7091. var loaded = api.state.loaded();
  7092. if ( loaded && loaded.childRows ) {
  7093. api.rows( loaded.childRows ).every( function () {
  7094. _fnCallbackFire( context, null, 'requestChild', [ this ] )
  7095. })
  7096. }
  7097. })
  7098. var __details_add = function ( ctx, row, data, klass )
  7099. {
  7100. // Convert to array of TR elements
  7101. var rows = [];
  7102. var addRow = function ( r, k ) {
  7103. // Recursion to allow for arrays of jQuery objects
  7104. if ( Array.isArray( r ) || r instanceof $ ) {
  7105. for ( var i=0, ien=r.length ; i<ien ; i++ ) {
  7106. addRow( r[i], k );
  7107. }
  7108. return;
  7109. }
  7110. // If we get a TR element, then just add it directly - up to the dev
  7111. // to add the correct number of columns etc
  7112. if ( r.nodeName && r.nodeName.toLowerCase() === 'tr' ) {
  7113. rows.push( r );
  7114. }
  7115. else {
  7116. // Otherwise create a row with a wrapper
  7117. var created = $('<tr><td></td></tr>').addClass( k );
  7118. $('td', created)
  7119. .addClass( k )
  7120. .html( r )
  7121. [0].colSpan = _fnVisbleColumns( ctx );
  7122. rows.push( created[0] );
  7123. }
  7124. };
  7125. addRow( data, klass );
  7126. if ( row._details ) {
  7127. row._details.detach();
  7128. }
  7129. row._details = $(rows);
  7130. // If the children were already shown, that state should be retained
  7131. if ( row._detailsShow ) {
  7132. row._details.insertAfter( row.nTr );
  7133. }
  7134. };
  7135. var __details_remove = function ( api, idx )
  7136. {
  7137. var ctx = api.context;
  7138. if ( ctx.length ) {
  7139. var row = ctx[0].aoData[ idx !== undefined ? idx : api[0] ];
  7140. if ( row && row._details ) {
  7141. row._details.remove();
  7142. row._detailsShow = undefined;
  7143. row._details = undefined;
  7144. $( row.nTr ).removeClass( 'dt-hasChild' );
  7145. _fnSaveState( ctx[0] );
  7146. }
  7147. }
  7148. };
  7149. var __details_display = function ( api, show ) {
  7150. var ctx = api.context;
  7151. if ( ctx.length && api.length ) {
  7152. var row = ctx[0].aoData[ api[0] ];
  7153. if ( row._details ) {
  7154. row._detailsShow = show;
  7155. if ( show ) {
  7156. row._details.insertAfter( row.nTr );
  7157. $( row.nTr ).addClass( 'dt-hasChild' );
  7158. }
  7159. else {
  7160. row._details.detach();
  7161. $( row.nTr ).removeClass( 'dt-hasChild' );
  7162. }
  7163. _fnCallbackFire( ctx[0], null, 'childRow', [ show, api.row( api[0] ) ] )
  7164. __details_events( ctx[0] );
  7165. _fnSaveState( ctx[0] );
  7166. }
  7167. }
  7168. };
  7169. var __details_events = function ( settings )
  7170. {
  7171. var api = new _Api( settings );
  7172. var namespace = '.dt.DT_details';
  7173. var drawEvent = 'draw'+namespace;
  7174. var colvisEvent = 'column-visibility'+namespace;
  7175. var destroyEvent = 'destroy'+namespace;
  7176. var data = settings.aoData;
  7177. api.off( drawEvent +' '+ colvisEvent +' '+ destroyEvent );
  7178. if ( _pluck( data, '_details' ).length > 0 ) {
  7179. // On each draw, insert the required elements into the document
  7180. api.on( drawEvent, function ( e, ctx ) {
  7181. if ( settings !== ctx ) {
  7182. return;
  7183. }
  7184. api.rows( {page:'current'} ).eq(0).each( function (idx) {
  7185. // Internal data grab
  7186. var row = data[ idx ];
  7187. if ( row._detailsShow ) {
  7188. row._details.insertAfter( row.nTr );
  7189. }
  7190. } );
  7191. } );
  7192. // Column visibility change - update the colspan
  7193. api.on( colvisEvent, function ( e, ctx, idx, vis ) {
  7194. if ( settings !== ctx ) {
  7195. return;
  7196. }
  7197. // Update the colspan for the details rows (note, only if it already has
  7198. // a colspan)
  7199. var row, visible = _fnVisbleColumns( ctx );
  7200. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  7201. row = data[i];
  7202. if ( row._details ) {
  7203. row._details.children('td[colspan]').attr('colspan', visible );
  7204. }
  7205. }
  7206. } );
  7207. // Table destroyed - nuke any child rows
  7208. api.on( destroyEvent, function ( e, ctx ) {
  7209. if ( settings !== ctx ) {
  7210. return;
  7211. }
  7212. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  7213. if ( data[i]._details ) {
  7214. __details_remove( api, i );
  7215. }
  7216. }
  7217. } );
  7218. }
  7219. };
  7220. // Strings for the method names to help minification
  7221. var _emp = '';
  7222. var _child_obj = _emp+'row().child';
  7223. var _child_mth = _child_obj+'()';
  7224. // data can be:
  7225. // tr
  7226. // string
  7227. // jQuery or array of any of the above
  7228. _api_register( _child_mth, function ( data, klass ) {
  7229. var ctx = this.context;
  7230. if ( data === undefined ) {
  7231. // get
  7232. return ctx.length && this.length ?
  7233. ctx[0].aoData[ this[0] ]._details :
  7234. undefined;
  7235. }
  7236. else if ( data === true ) {
  7237. // show
  7238. this.child.show();
  7239. }
  7240. else if ( data === false ) {
  7241. // remove
  7242. __details_remove( this );
  7243. }
  7244. else if ( ctx.length && this.length ) {
  7245. // set
  7246. __details_add( ctx[0], ctx[0].aoData[ this[0] ], data, klass );
  7247. }
  7248. return this;
  7249. } );
  7250. _api_register( [
  7251. _child_obj+'.show()',
  7252. _child_mth+'.show()' // only when `child()` was called with parameters (without
  7253. ], function ( show ) { // it returns an object and this method is not executed)
  7254. __details_display( this, true );
  7255. return this;
  7256. } );
  7257. _api_register( [
  7258. _child_obj+'.hide()',
  7259. _child_mth+'.hide()' // only when `child()` was called with parameters (without
  7260. ], function () { // it returns an object and this method is not executed)
  7261. __details_display( this, false );
  7262. return this;
  7263. } );
  7264. _api_register( [
  7265. _child_obj+'.remove()',
  7266. _child_mth+'.remove()' // only when `child()` was called with parameters (without
  7267. ], function () { // it returns an object and this method is not executed)
  7268. __details_remove( this );
  7269. return this;
  7270. } );
  7271. _api_register( _child_obj+'.isShown()', function () {
  7272. var ctx = this.context;
  7273. if ( ctx.length && this.length ) {
  7274. // _detailsShown as false or undefined will fall through to return false
  7275. return ctx[0].aoData[ this[0] ]._detailsShow || false;
  7276. }
  7277. return false;
  7278. } );
  7279. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  7280. * Columns
  7281. *
  7282. * {integer} - column index (>=0 count from left, <0 count from right)
  7283. * "{integer}:visIdx" - visible column index (i.e. translate to column index) (>=0 count from left, <0 count from right)
  7284. * "{integer}:visible" - alias for {integer}:visIdx (>=0 count from left, <0 count from right)
  7285. * "{string}:name" - column name
  7286. * "{string}" - jQuery selector on column header nodes
  7287. *
  7288. */
  7289. // can be an array of these items, comma separated list, or an array of comma
  7290. // separated lists
  7291. var __re_column_selector = /^([^:]+):(name|visIdx|visible)$/;
  7292. // r1 and r2 are redundant - but it means that the parameters match for the
  7293. // iterator callback in columns().data()
  7294. var __columnData = function ( settings, column, r1, r2, rows ) {
  7295. var a = [];
  7296. for ( var row=0, ien=rows.length ; row<ien ; row++ ) {
  7297. a.push( _fnGetCellData( settings, rows[row], column ) );
  7298. }
  7299. return a;
  7300. };
  7301. var __column_selector = function ( settings, selector, opts )
  7302. {
  7303. var
  7304. columns = settings.aoColumns,
  7305. names = _pluck( columns, 'sName' ),
  7306. nodes = _pluck( columns, 'nTh' );
  7307. var run = function ( s ) {
  7308. var selInt = _intVal( s );
  7309. // Selector - all
  7310. if ( s === '' ) {
  7311. return _range( columns.length );
  7312. }
  7313. // Selector - index
  7314. if ( selInt !== null ) {
  7315. return [ selInt >= 0 ?
  7316. selInt : // Count from left
  7317. columns.length + selInt // Count from right (+ because its a negative value)
  7318. ];
  7319. }
  7320. // Selector = function
  7321. if ( typeof s === 'function' ) {
  7322. var rows = _selector_row_indexes( settings, opts );
  7323. return $.map( columns, function (col, idx) {
  7324. return s(
  7325. idx,
  7326. __columnData( settings, idx, 0, 0, rows ),
  7327. nodes[ idx ]
  7328. ) ? idx : null;
  7329. } );
  7330. }
  7331. // jQuery or string selector
  7332. var match = typeof s === 'string' ?
  7333. s.match( __re_column_selector ) :
  7334. '';
  7335. if ( match ) {
  7336. switch( match[2] ) {
  7337. case 'visIdx':
  7338. case 'visible':
  7339. var idx = parseInt( match[1], 10 );
  7340. // Visible index given, convert to column index
  7341. if ( idx < 0 ) {
  7342. // Counting from the right
  7343. var visColumns = $.map( columns, function (col,i) {
  7344. return col.bVisible ? i : null;
  7345. } );
  7346. return [ visColumns[ visColumns.length + idx ] ];
  7347. }
  7348. // Counting from the left
  7349. return [ _fnVisibleToColumnIndex( settings, idx ) ];
  7350. case 'name':
  7351. // match by name. `names` is column index complete and in order
  7352. return $.map( names, function (name, i) {
  7353. return name === match[1] ? i : null;
  7354. } );
  7355. default:
  7356. return [];
  7357. }
  7358. }
  7359. // Cell in the table body
  7360. if ( s.nodeName && s._DT_CellIndex ) {
  7361. return [ s._DT_CellIndex.column ];
  7362. }
  7363. // jQuery selector on the TH elements for the columns
  7364. var jqResult = $( nodes )
  7365. .filter( s )
  7366. .map( function () {
  7367. return $.inArray( this, nodes ); // `nodes` is column index complete and in order
  7368. } )
  7369. .toArray();
  7370. if ( jqResult.length || ! s.nodeName ) {
  7371. return jqResult;
  7372. }
  7373. // Otherwise a node which might have a `dt-column` data attribute, or be
  7374. // a child or such an element
  7375. var host = $(s).closest('*[data-dt-column]');
  7376. return host.length ?
  7377. [ host.data('dt-column') ] :
  7378. [];
  7379. };
  7380. return _selector_run( 'column', selector, run, settings, opts );
  7381. };
  7382. var __setColumnVis = function ( settings, column, vis ) {
  7383. var
  7384. cols = settings.aoColumns,
  7385. col = cols[ column ],
  7386. data = settings.aoData,
  7387. row, cells, i, ien, tr;
  7388. // Get
  7389. if ( vis === undefined ) {
  7390. return col.bVisible;
  7391. }
  7392. // Set
  7393. // No change
  7394. if ( col.bVisible === vis ) {
  7395. return;
  7396. }
  7397. if ( vis ) {
  7398. // Insert column
  7399. // Need to decide if we should use appendChild or insertBefore
  7400. var insertBefore = $.inArray( true, _pluck(cols, 'bVisible'), column+1 );
  7401. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  7402. tr = data[i].nTr;
  7403. cells = data[i].anCells;
  7404. if ( tr ) {
  7405. // insertBefore can act like appendChild if 2nd arg is null
  7406. tr.insertBefore( cells[ column ], cells[ insertBefore ] || null );
  7407. }
  7408. }
  7409. }
  7410. else {
  7411. // Remove column
  7412. $( _pluck( settings.aoData, 'anCells', column ) ).detach();
  7413. }
  7414. // Common actions
  7415. col.bVisible = vis;
  7416. };
  7417. _api_register( 'columns()', function ( selector, opts ) {
  7418. // argument shifting
  7419. if ( selector === undefined ) {
  7420. selector = '';
  7421. }
  7422. else if ( $.isPlainObject( selector ) ) {
  7423. opts = selector;
  7424. selector = '';
  7425. }
  7426. opts = _selector_opts( opts );
  7427. var inst = this.iterator( 'table', function ( settings ) {
  7428. return __column_selector( settings, selector, opts );
  7429. }, 1 );
  7430. // Want argument shifting here and in _row_selector?
  7431. inst.selector.cols = selector;
  7432. inst.selector.opts = opts;
  7433. return inst;
  7434. } );
  7435. _api_registerPlural( 'columns().header()', 'column().header()', function ( selector, opts ) {
  7436. return this.iterator( 'column', function ( settings, column ) {
  7437. return settings.aoColumns[column].nTh;
  7438. }, 1 );
  7439. } );
  7440. _api_registerPlural( 'columns().footer()', 'column().footer()', function ( selector, opts ) {
  7441. return this.iterator( 'column', function ( settings, column ) {
  7442. return settings.aoColumns[column].nTf;
  7443. }, 1 );
  7444. } );
  7445. _api_registerPlural( 'columns().data()', 'column().data()', function () {
  7446. return this.iterator( 'column-rows', __columnData, 1 );
  7447. } );
  7448. _api_registerPlural( 'columns().dataSrc()', 'column().dataSrc()', function () {
  7449. return this.iterator( 'column', function ( settings, column ) {
  7450. return settings.aoColumns[column].mData;
  7451. }, 1 );
  7452. } );
  7453. _api_registerPlural( 'columns().cache()', 'column().cache()', function ( type ) {
  7454. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7455. return _pluck_order( settings.aoData, rows,
  7456. type === 'search' ? '_aFilterData' : '_aSortData', column
  7457. );
  7458. }, 1 );
  7459. } );
  7460. _api_registerPlural( 'columns().nodes()', 'column().nodes()', function () {
  7461. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7462. return _pluck_order( settings.aoData, rows, 'anCells', column ) ;
  7463. }, 1 );
  7464. } );
  7465. _api_registerPlural( 'columns().visible()', 'column().visible()', function ( vis, calc ) {
  7466. var that = this;
  7467. var ret = this.iterator( 'column', function ( settings, column ) {
  7468. if ( vis === undefined ) {
  7469. return settings.aoColumns[ column ].bVisible;
  7470. } // else
  7471. __setColumnVis( settings, column, vis );
  7472. } );
  7473. // Group the column visibility changes
  7474. if ( vis !== undefined ) {
  7475. this.iterator( 'table', function ( settings ) {
  7476. // Redraw the header after changes
  7477. _fnDrawHead( settings, settings.aoHeader );
  7478. _fnDrawHead( settings, settings.aoFooter );
  7479. // Update colspan for no records display. Child rows and extensions will use their own
  7480. // listeners to do this - only need to update the empty table item here
  7481. if ( ! settings.aiDisplay.length ) {
  7482. $(settings.nTBody).find('td[colspan]').attr('colspan', _fnVisbleColumns(settings));
  7483. }
  7484. _fnSaveState( settings );
  7485. // Second loop once the first is done for events
  7486. that.iterator( 'column', function ( settings, column ) {
  7487. _fnCallbackFire( settings, null, 'column-visibility', [settings, column, vis, calc] );
  7488. } );
  7489. if ( calc === undefined || calc ) {
  7490. that.columns.adjust();
  7491. }
  7492. });
  7493. }
  7494. return ret;
  7495. } );
  7496. _api_registerPlural( 'columns().indexes()', 'column().index()', function ( type ) {
  7497. return this.iterator( 'column', function ( settings, column ) {
  7498. return type === 'visible' ?
  7499. _fnColumnIndexToVisible( settings, column ) :
  7500. column;
  7501. }, 1 );
  7502. } );
  7503. _api_register( 'columns.adjust()', function () {
  7504. return this.iterator( 'table', function ( settings ) {
  7505. _fnAdjustColumnSizing( settings );
  7506. }, 1 );
  7507. } );
  7508. _api_register( 'column.index()', function ( type, idx ) {
  7509. if ( this.context.length !== 0 ) {
  7510. var ctx = this.context[0];
  7511. if ( type === 'fromVisible' || type === 'toData' ) {
  7512. return _fnVisibleToColumnIndex( ctx, idx );
  7513. }
  7514. else if ( type === 'fromData' || type === 'toVisible' ) {
  7515. return _fnColumnIndexToVisible( ctx, idx );
  7516. }
  7517. }
  7518. } );
  7519. _api_register( 'column()', function ( selector, opts ) {
  7520. return _selector_first( this.columns( selector, opts ) );
  7521. } );
  7522. var __cell_selector = function ( settings, selector, opts )
  7523. {
  7524. var data = settings.aoData;
  7525. var rows = _selector_row_indexes( settings, opts );
  7526. var cells = _removeEmpty( _pluck_order( data, rows, 'anCells' ) );
  7527. var allCells = $(_flatten( [], cells ));
  7528. var row;
  7529. var columns = settings.aoColumns.length;
  7530. var a, i, ien, j, o, host;
  7531. var run = function ( s ) {
  7532. var fnSelector = typeof s === 'function';
  7533. if ( s === null || s === undefined || fnSelector ) {
  7534. // All cells and function selectors
  7535. a = [];
  7536. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  7537. row = rows[i];
  7538. for ( j=0 ; j<columns ; j++ ) {
  7539. o = {
  7540. row: row,
  7541. column: j
  7542. };
  7543. if ( fnSelector ) {
  7544. // Selector - function
  7545. host = data[ row ];
  7546. if ( s( o, _fnGetCellData(settings, row, j), host.anCells ? host.anCells[j] : null ) ) {
  7547. a.push( o );
  7548. }
  7549. }
  7550. else {
  7551. // Selector - all
  7552. a.push( o );
  7553. }
  7554. }
  7555. }
  7556. return a;
  7557. }
  7558. // Selector - index
  7559. if ( $.isPlainObject( s ) ) {
  7560. // Valid cell index and its in the array of selectable rows
  7561. return s.column !== undefined && s.row !== undefined && $.inArray( s.row, rows ) !== -1 ?
  7562. [s] :
  7563. [];
  7564. }
  7565. // Selector - jQuery filtered cells
  7566. var jqResult = allCells
  7567. .filter( s )
  7568. .map( function (i, el) {
  7569. return { // use a new object, in case someone changes the values
  7570. row: el._DT_CellIndex.row,
  7571. column: el._DT_CellIndex.column
  7572. };
  7573. } )
  7574. .toArray();
  7575. if ( jqResult.length || ! s.nodeName ) {
  7576. return jqResult;
  7577. }
  7578. // Otherwise the selector is a node, and there is one last option - the
  7579. // element might be a child of an element which has dt-row and dt-column
  7580. // data attributes
  7581. host = $(s).closest('*[data-dt-row]');
  7582. return host.length ?
  7583. [ {
  7584. row: host.data('dt-row'),
  7585. column: host.data('dt-column')
  7586. } ] :
  7587. [];
  7588. };
  7589. return _selector_run( 'cell', selector, run, settings, opts );
  7590. };
  7591. _api_register( 'cells()', function ( rowSelector, columnSelector, opts ) {
  7592. // Argument shifting
  7593. if ( $.isPlainObject( rowSelector ) ) {
  7594. // Indexes
  7595. if ( rowSelector.row === undefined ) {
  7596. // Selector options in first parameter
  7597. opts = rowSelector;
  7598. rowSelector = null;
  7599. }
  7600. else {
  7601. // Cell index objects in first parameter
  7602. opts = columnSelector;
  7603. columnSelector = null;
  7604. }
  7605. }
  7606. if ( $.isPlainObject( columnSelector ) ) {
  7607. opts = columnSelector;
  7608. columnSelector = null;
  7609. }
  7610. // Cell selector
  7611. if ( columnSelector === null || columnSelector === undefined ) {
  7612. return this.iterator( 'table', function ( settings ) {
  7613. return __cell_selector( settings, rowSelector, _selector_opts( opts ) );
  7614. } );
  7615. }
  7616. // The default built in options need to apply to row and columns
  7617. var internalOpts = opts ? {
  7618. page: opts.page,
  7619. order: opts.order,
  7620. search: opts.search
  7621. } : {};
  7622. // Row + column selector
  7623. var columns = this.columns( columnSelector, internalOpts );
  7624. var rows = this.rows( rowSelector, internalOpts );
  7625. var i, ien, j, jen;
  7626. var cellsNoOpts = this.iterator( 'table', function ( settings, idx ) {
  7627. var a = [];
  7628. for ( i=0, ien=rows[idx].length ; i<ien ; i++ ) {
  7629. for ( j=0, jen=columns[idx].length ; j<jen ; j++ ) {
  7630. a.push( {
  7631. row: rows[idx][i],
  7632. column: columns[idx][j]
  7633. } );
  7634. }
  7635. }
  7636. return a;
  7637. }, 1 );
  7638. // There is currently only one extension which uses a cell selector extension
  7639. // It is a _major_ performance drag to run this if it isn't needed, so this is
  7640. // an extension specific check at the moment
  7641. var cells = opts && opts.selected ?
  7642. this.cells( cellsNoOpts, opts ) :
  7643. cellsNoOpts;
  7644. $.extend( cells.selector, {
  7645. cols: columnSelector,
  7646. rows: rowSelector,
  7647. opts: opts
  7648. } );
  7649. return cells;
  7650. } );
  7651. _api_registerPlural( 'cells().nodes()', 'cell().node()', function () {
  7652. return this.iterator( 'cell', function ( settings, row, column ) {
  7653. var data = settings.aoData[ row ];
  7654. return data && data.anCells ?
  7655. data.anCells[ column ] :
  7656. undefined;
  7657. }, 1 );
  7658. } );
  7659. _api_register( 'cells().data()', function () {
  7660. return this.iterator( 'cell', function ( settings, row, column ) {
  7661. return _fnGetCellData( settings, row, column );
  7662. }, 1 );
  7663. } );
  7664. _api_registerPlural( 'cells().cache()', 'cell().cache()', function ( type ) {
  7665. type = type === 'search' ? '_aFilterData' : '_aSortData';
  7666. return this.iterator( 'cell', function ( settings, row, column ) {
  7667. return settings.aoData[ row ][ type ][ column ];
  7668. }, 1 );
  7669. } );
  7670. _api_registerPlural( 'cells().render()', 'cell().render()', function ( type ) {
  7671. return this.iterator( 'cell', function ( settings, row, column ) {
  7672. return _fnGetCellData( settings, row, column, type );
  7673. }, 1 );
  7674. } );
  7675. _api_registerPlural( 'cells().indexes()', 'cell().index()', function () {
  7676. return this.iterator( 'cell', function ( settings, row, column ) {
  7677. return {
  7678. row: row,
  7679. column: column,
  7680. columnVisible: _fnColumnIndexToVisible( settings, column )
  7681. };
  7682. }, 1 );
  7683. } );
  7684. _api_registerPlural( 'cells().invalidate()', 'cell().invalidate()', function ( src ) {
  7685. return this.iterator( 'cell', function ( settings, row, column ) {
  7686. _fnInvalidate( settings, row, src, column );
  7687. } );
  7688. } );
  7689. _api_register( 'cell()', function ( rowSelector, columnSelector, opts ) {
  7690. return _selector_first( this.cells( rowSelector, columnSelector, opts ) );
  7691. } );
  7692. _api_register( 'cell().data()', function ( data ) {
  7693. var ctx = this.context;
  7694. var cell = this[0];
  7695. if ( data === undefined ) {
  7696. // Get
  7697. return ctx.length && cell.length ?
  7698. _fnGetCellData( ctx[0], cell[0].row, cell[0].column ) :
  7699. undefined;
  7700. }
  7701. // Set
  7702. _fnSetCellData( ctx[0], cell[0].row, cell[0].column, data );
  7703. _fnInvalidate( ctx[0], cell[0].row, 'data', cell[0].column );
  7704. return this;
  7705. } );
  7706. /**
  7707. * Get current ordering (sorting) that has been applied to the table.
  7708. *
  7709. * @returns {array} 2D array containing the sorting information for the first
  7710. * table in the current context. Each element in the parent array represents
  7711. * a column being sorted upon (i.e. multi-sorting with two columns would have
  7712. * 2 inner arrays). The inner arrays may have 2 or 3 elements. The first is
  7713. * the column index that the sorting condition applies to, the second is the
  7714. * direction of the sort (`desc` or `asc`) and, optionally, the third is the
  7715. * index of the sorting order from the `column.sorting` initialisation array.
  7716. *//**
  7717. * Set the ordering for the table.
  7718. *
  7719. * @param {integer} order Column index to sort upon.
  7720. * @param {string} direction Direction of the sort to be applied (`asc` or `desc`)
  7721. * @returns {DataTables.Api} this
  7722. *//**
  7723. * Set the ordering for the table.
  7724. *
  7725. * @param {array} order 1D array of sorting information to be applied.
  7726. * @param {array} [...] Optional additional sorting conditions
  7727. * @returns {DataTables.Api} this
  7728. *//**
  7729. * Set the ordering for the table.
  7730. *
  7731. * @param {array} order 2D array of sorting information to be applied.
  7732. * @returns {DataTables.Api} this
  7733. */
  7734. _api_register( 'order()', function ( order, dir ) {
  7735. var ctx = this.context;
  7736. if ( order === undefined ) {
  7737. // get
  7738. return ctx.length !== 0 ?
  7739. ctx[0].aaSorting :
  7740. undefined;
  7741. }
  7742. // set
  7743. if ( typeof order === 'number' ) {
  7744. // Simple column / direction passed in
  7745. order = [ [ order, dir ] ];
  7746. }
  7747. else if ( order.length && ! Array.isArray( order[0] ) ) {
  7748. // Arguments passed in (list of 1D arrays)
  7749. order = Array.prototype.slice.call( arguments );
  7750. }
  7751. // otherwise a 2D array was passed in
  7752. return this.iterator( 'table', function ( settings ) {
  7753. settings.aaSorting = order.slice();
  7754. } );
  7755. } );
  7756. /**
  7757. * Attach a sort listener to an element for a given column
  7758. *
  7759. * @param {node|jQuery|string} node Identifier for the element(s) to attach the
  7760. * listener to. This can take the form of a single DOM node, a jQuery
  7761. * collection of nodes or a jQuery selector which will identify the node(s).
  7762. * @param {integer} column the column that a click on this node will sort on
  7763. * @param {function} [callback] callback function when sort is run
  7764. * @returns {DataTables.Api} this
  7765. */
  7766. _api_register( 'order.listener()', function ( node, column, callback ) {
  7767. return this.iterator( 'table', function ( settings ) {
  7768. _fnSortAttachListener( settings, node, column, callback );
  7769. } );
  7770. } );
  7771. _api_register( 'order.fixed()', function ( set ) {
  7772. if ( ! set ) {
  7773. var ctx = this.context;
  7774. var fixed = ctx.length ?
  7775. ctx[0].aaSortingFixed :
  7776. undefined;
  7777. return Array.isArray( fixed ) ?
  7778. { pre: fixed } :
  7779. fixed;
  7780. }
  7781. return this.iterator( 'table', function ( settings ) {
  7782. settings.aaSortingFixed = $.extend( true, {}, set );
  7783. } );
  7784. } );
  7785. // Order by the selected column(s)
  7786. _api_register( [
  7787. 'columns().order()',
  7788. 'column().order()'
  7789. ], function ( dir ) {
  7790. var that = this;
  7791. return this.iterator( 'table', function ( settings, i ) {
  7792. var sort = [];
  7793. $.each( that[i], function (j, col) {
  7794. sort.push( [ col, dir ] );
  7795. } );
  7796. settings.aaSorting = sort;
  7797. } );
  7798. } );
  7799. _api_register( 'search()', function ( input, regex, smart, caseInsen ) {
  7800. var ctx = this.context;
  7801. if ( input === undefined ) {
  7802. // get
  7803. return ctx.length !== 0 ?
  7804. ctx[0].oPreviousSearch.sSearch :
  7805. undefined;
  7806. }
  7807. // set
  7808. return this.iterator( 'table', function ( settings ) {
  7809. if ( ! settings.oFeatures.bFilter ) {
  7810. return;
  7811. }
  7812. _fnFilterComplete( settings, $.extend( {}, settings.oPreviousSearch, {
  7813. "sSearch": input+"",
  7814. "bRegex": regex === null ? false : regex,
  7815. "bSmart": smart === null ? true : smart,
  7816. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7817. } ), 1 );
  7818. } );
  7819. } );
  7820. _api_registerPlural(
  7821. 'columns().search()',
  7822. 'column().search()',
  7823. function ( input, regex, smart, caseInsen ) {
  7824. return this.iterator( 'column', function ( settings, column ) {
  7825. var preSearch = settings.aoPreSearchCols;
  7826. if ( input === undefined ) {
  7827. // get
  7828. return preSearch[ column ].sSearch;
  7829. }
  7830. // set
  7831. if ( ! settings.oFeatures.bFilter ) {
  7832. return;
  7833. }
  7834. $.extend( preSearch[ column ], {
  7835. "sSearch": input+"",
  7836. "bRegex": regex === null ? false : regex,
  7837. "bSmart": smart === null ? true : smart,
  7838. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7839. } );
  7840. _fnFilterComplete( settings, settings.oPreviousSearch, 1 );
  7841. } );
  7842. }
  7843. );
  7844. /*
  7845. * State API methods
  7846. */
  7847. _api_register( 'state()', function () {
  7848. return this.context.length ?
  7849. this.context[0].oSavedState :
  7850. null;
  7851. } );
  7852. _api_register( 'state.clear()', function () {
  7853. return this.iterator( 'table', function ( settings ) {
  7854. // Save an empty object
  7855. settings.fnStateSaveCallback.call( settings.oInstance, settings, {} );
  7856. } );
  7857. } );
  7858. _api_register( 'state.loaded()', function () {
  7859. return this.context.length ?
  7860. this.context[0].oLoadedState :
  7861. null;
  7862. } );
  7863. _api_register( 'state.save()', function () {
  7864. return this.iterator( 'table', function ( settings ) {
  7865. _fnSaveState( settings );
  7866. } );
  7867. } );
  7868. /**
  7869. * Provide a common method for plug-ins to check the version of DataTables being
  7870. * used, in order to ensure compatibility.
  7871. *
  7872. * @param {string} version Version string to check for, in the format "X.Y.Z".
  7873. * Note that the formats "X" and "X.Y" are also acceptable.
  7874. * @returns {boolean} true if this version of DataTables is greater or equal to
  7875. * the required version, or false if this version of DataTales is not
  7876. * suitable
  7877. * @static
  7878. * @dtopt API-Static
  7879. *
  7880. * @example
  7881. * alert( $.fn.dataTable.versionCheck( '1.9.0' ) );
  7882. */
  7883. DataTable.versionCheck = DataTable.fnVersionCheck = function( version )
  7884. {
  7885. var aThis = DataTable.version.split('.');
  7886. var aThat = version.split('.');
  7887. var iThis, iThat;
  7888. for ( var i=0, iLen=aThat.length ; i<iLen ; i++ ) {
  7889. iThis = parseInt( aThis[i], 10 ) || 0;
  7890. iThat = parseInt( aThat[i], 10 ) || 0;
  7891. // Parts are the same, keep comparing
  7892. if (iThis === iThat) {
  7893. continue;
  7894. }
  7895. // Parts are different, return immediately
  7896. return iThis > iThat;
  7897. }
  7898. return true;
  7899. };
  7900. /**
  7901. * Check if a `<table>` node is a DataTable table already or not.
  7902. *
  7903. * @param {node|jquery|string} table Table node, jQuery object or jQuery
  7904. * selector for the table to test. Note that if more than more than one
  7905. * table is passed on, only the first will be checked
  7906. * @returns {boolean} true the table given is a DataTable, or false otherwise
  7907. * @static
  7908. * @dtopt API-Static
  7909. *
  7910. * @example
  7911. * if ( ! $.fn.DataTable.isDataTable( '#example' ) ) {
  7912. * $('#example').dataTable();
  7913. * }
  7914. */
  7915. DataTable.isDataTable = DataTable.fnIsDataTable = function ( table )
  7916. {
  7917. var t = $(table).get(0);
  7918. var is = false;
  7919. if ( table instanceof DataTable.Api ) {
  7920. return true;
  7921. }
  7922. $.each( DataTable.settings, function (i, o) {
  7923. var head = o.nScrollHead ? $('table', o.nScrollHead)[0] : null;
  7924. var foot = o.nScrollFoot ? $('table', o.nScrollFoot)[0] : null;
  7925. if ( o.nTable === t || head === t || foot === t ) {
  7926. is = true;
  7927. }
  7928. } );
  7929. return is;
  7930. };
  7931. /**
  7932. * Get all DataTable tables that have been initialised - optionally you can
  7933. * select to get only currently visible tables.
  7934. *
  7935. * @param {boolean} [visible=false] Flag to indicate if you want all (default)
  7936. * or visible tables only.
  7937. * @returns {array} Array of `table` nodes (not DataTable instances) which are
  7938. * DataTables
  7939. * @static
  7940. * @dtopt API-Static
  7941. *
  7942. * @example
  7943. * $.each( $.fn.dataTable.tables(true), function () {
  7944. * $(table).DataTable().columns.adjust();
  7945. * } );
  7946. */
  7947. DataTable.tables = DataTable.fnTables = function ( visible )
  7948. {
  7949. var api = false;
  7950. if ( $.isPlainObject( visible ) ) {
  7951. api = visible.api;
  7952. visible = visible.visible;
  7953. }
  7954. var a = $.map( DataTable.settings, function (o) {
  7955. if ( !visible || (visible && $(o.nTable).is(':visible')) ) {
  7956. return o.nTable;
  7957. }
  7958. } );
  7959. return api ?
  7960. new _Api( a ) :
  7961. a;
  7962. };
  7963. /**
  7964. * Convert from camel case parameters to Hungarian notation. This is made public
  7965. * for the extensions to provide the same ability as DataTables core to accept
  7966. * either the 1.9 style Hungarian notation, or the 1.10+ style camelCase
  7967. * parameters.
  7968. *
  7969. * @param {object} src The model object which holds all parameters that can be
  7970. * mapped.
  7971. * @param {object} user The object to convert from camel case to Hungarian.
  7972. * @param {boolean} force When set to `true`, properties which already have a
  7973. * Hungarian value in the `user` object will be overwritten. Otherwise they
  7974. * won't be.
  7975. */
  7976. DataTable.camelToHungarian = _fnCamelToHungarian;
  7977. /**
  7978. *
  7979. */
  7980. _api_register( '$()', function ( selector, opts ) {
  7981. var
  7982. rows = this.rows( opts ).nodes(), // Get all rows
  7983. jqRows = $(rows);
  7984. return $( [].concat(
  7985. jqRows.filter( selector ).toArray(),
  7986. jqRows.find( selector ).toArray()
  7987. ) );
  7988. } );
  7989. // jQuery functions to operate on the tables
  7990. $.each( [ 'on', 'one', 'off' ], function (i, key) {
  7991. _api_register( key+'()', function ( /* event, handler */ ) {
  7992. var args = Array.prototype.slice.call(arguments);
  7993. // Add the `dt` namespace automatically if it isn't already present
  7994. args[0] = $.map( args[0].split( /\s/ ), function ( e ) {
  7995. return ! e.match(/\.dt\b/) ?
  7996. e+'.dt' :
  7997. e;
  7998. } ).join( ' ' );
  7999. var inst = $( this.tables().nodes() );
  8000. inst[key].apply( inst, args );
  8001. return this;
  8002. } );
  8003. } );
  8004. _api_register( 'clear()', function () {
  8005. return this.iterator( 'table', function ( settings ) {
  8006. _fnClearTable( settings );
  8007. } );
  8008. } );
  8009. _api_register( 'settings()', function () {
  8010. return new _Api( this.context, this.context );
  8011. } );
  8012. _api_register( 'init()', function () {
  8013. var ctx = this.context;
  8014. return ctx.length ? ctx[0].oInit : null;
  8015. } );
  8016. _api_register( 'data()', function () {
  8017. return this.iterator( 'table', function ( settings ) {
  8018. return _pluck( settings.aoData, '_aData' );
  8019. } ).flatten();
  8020. } );
  8021. _api_register( 'destroy()', function ( remove ) {
  8022. remove = remove || false;
  8023. return this.iterator( 'table', function ( settings ) {
  8024. var orig = settings.nTableWrapper.parentNode;
  8025. var classes = settings.oClasses;
  8026. var table = settings.nTable;
  8027. var tbody = settings.nTBody;
  8028. var thead = settings.nTHead;
  8029. var tfoot = settings.nTFoot;
  8030. var jqTable = $(table);
  8031. var jqTbody = $(tbody);
  8032. var jqWrapper = $(settings.nTableWrapper);
  8033. var rows = $.map( settings.aoData, function (r) { return r.nTr; } );
  8034. var i, ien;
  8035. // Flag to note that the table is currently being destroyed - no action
  8036. // should be taken
  8037. settings.bDestroying = true;
  8038. // Fire off the destroy callbacks for plug-ins etc
  8039. _fnCallbackFire( settings, "aoDestroyCallback", "destroy", [settings] );
  8040. // If not being removed from the document, make all columns visible
  8041. if ( ! remove ) {
  8042. new _Api( settings ).columns().visible( true );
  8043. }
  8044. // Blitz all `DT` namespaced events (these are internal events, the
  8045. // lowercase, `dt` events are user subscribed and they are responsible
  8046. // for removing them
  8047. jqWrapper.off('.DT').find(':not(tbody *)').off('.DT');
  8048. $(window).off('.DT-'+settings.sInstance);
  8049. // When scrolling we had to break the table up - restore it
  8050. if ( table != thead.parentNode ) {
  8051. jqTable.children('thead').detach();
  8052. jqTable.append( thead );
  8053. }
  8054. if ( tfoot && table != tfoot.parentNode ) {
  8055. jqTable.children('tfoot').detach();
  8056. jqTable.append( tfoot );
  8057. }
  8058. settings.aaSorting = [];
  8059. settings.aaSortingFixed = [];
  8060. _fnSortingClasses( settings );
  8061. $( rows ).removeClass( settings.asStripeClasses.join(' ') );
  8062. $('th, td', thead).removeClass( classes.sSortable+' '+
  8063. classes.sSortableAsc+' '+classes.sSortableDesc+' '+classes.sSortableNone
  8064. );
  8065. // Add the TR elements back into the table in their original order
  8066. jqTbody.children().detach();
  8067. jqTbody.append( rows );
  8068. // Remove the DataTables generated nodes, events and classes
  8069. var removedMethod = remove ? 'remove' : 'detach';
  8070. jqTable[ removedMethod ]();
  8071. jqWrapper[ removedMethod ]();
  8072. // If we need to reattach the table to the document
  8073. if ( ! remove && orig ) {
  8074. // insertBefore acts like appendChild if !arg[1]
  8075. orig.insertBefore( table, settings.nTableReinsertBefore );
  8076. // Restore the width of the original table - was read from the style property,
  8077. // so we can restore directly to that
  8078. jqTable
  8079. .css( 'width', settings.sDestroyWidth )
  8080. .removeClass( classes.sTable );
  8081. // If the were originally stripe classes - then we add them back here.
  8082. // Note this is not fool proof (for example if not all rows had stripe
  8083. // classes - but it's a good effort without getting carried away
  8084. ien = settings.asDestroyStripes.length;
  8085. if ( ien ) {
  8086. jqTbody.children().each( function (i) {
  8087. $(this).addClass( settings.asDestroyStripes[i % ien] );
  8088. } );
  8089. }
  8090. }
  8091. /* Remove the settings object from the settings array */
  8092. var idx = $.inArray( settings, DataTable.settings );
  8093. if ( idx !== -1 ) {
  8094. DataTable.settings.splice( idx, 1 );
  8095. }
  8096. } );
  8097. } );
  8098. // Add the `every()` method for rows, columns and cells in a compact form
  8099. $.each( [ 'column', 'row', 'cell' ], function ( i, type ) {
  8100. _api_register( type+'s().every()', function ( fn ) {
  8101. var opts = this.selector.opts;
  8102. var api = this;
  8103. return this.iterator( type, function ( settings, arg1, arg2, arg3, arg4 ) {
  8104. // Rows and columns:
  8105. // arg1 - index
  8106. // arg2 - table counter
  8107. // arg3 - loop counter
  8108. // arg4 - undefined
  8109. // Cells:
  8110. // arg1 - row index
  8111. // arg2 - column index
  8112. // arg3 - table counter
  8113. // arg4 - loop counter
  8114. fn.call(
  8115. api[ type ](
  8116. arg1,
  8117. type==='cell' ? arg2 : opts,
  8118. type==='cell' ? opts : undefined
  8119. ),
  8120. arg1, arg2, arg3, arg4
  8121. );
  8122. } );
  8123. } );
  8124. } );
  8125. // i18n method for extensions to be able to use the language object from the
  8126. // DataTable
  8127. _api_register( 'i18n()', function ( token, def, plural ) {
  8128. var ctx = this.context[0];
  8129. var resolved = _fnGetObjectDataFn( token )( ctx.oLanguage );
  8130. if ( resolved === undefined ) {
  8131. resolved = def;
  8132. }
  8133. if ( plural !== undefined && $.isPlainObject( resolved ) ) {
  8134. resolved = resolved[ plural ] !== undefined ?
  8135. resolved[ plural ] :
  8136. resolved._;
  8137. }
  8138. return resolved.replace( '%d', plural ); // nb: plural might be undefined,
  8139. } );
  8140. /**
  8141. * Version string for plug-ins to check compatibility. Allowed format is
  8142. * `a.b.c-d` where: a:int, b:int, c:int, d:string(dev|beta|alpha). `d` is used
  8143. * only for non-release builds. See http://semver.org/ for more information.
  8144. * @member
  8145. * @type string
  8146. * @default Version number
  8147. */
  8148. DataTable.version = "1.11.3";
  8149. /**
  8150. * Private data store, containing all of the settings objects that are
  8151. * created for the tables on a given page.
  8152. *
  8153. * Note that the `DataTable.settings` object is aliased to
  8154. * `jQuery.fn.dataTableExt` through which it may be accessed and
  8155. * manipulated, or `jQuery.fn.dataTable.settings`.
  8156. * @member
  8157. * @type array
  8158. * @default []
  8159. * @private
  8160. */
  8161. DataTable.settings = [];
  8162. /**
  8163. * Object models container, for the various models that DataTables has
  8164. * available to it. These models define the objects that are used to hold
  8165. * the active state and configuration of the table.
  8166. * @namespace
  8167. */
  8168. DataTable.models = {};
  8169. /**
  8170. * Template object for the way in which DataTables holds information about
  8171. * search information for the global filter and individual column filters.
  8172. * @namespace
  8173. */
  8174. DataTable.models.oSearch = {
  8175. /**
  8176. * Flag to indicate if the filtering should be case insensitive or not
  8177. * @type boolean
  8178. * @default true
  8179. */
  8180. "bCaseInsensitive": true,
  8181. /**
  8182. * Applied search term
  8183. * @type string
  8184. * @default <i>Empty string</i>
  8185. */
  8186. "sSearch": "",
  8187. /**
  8188. * Flag to indicate if the search term should be interpreted as a
  8189. * regular expression (true) or not (false) and therefore and special
  8190. * regex characters escaped.
  8191. * @type boolean
  8192. * @default false
  8193. */
  8194. "bRegex": false,
  8195. /**
  8196. * Flag to indicate if DataTables is to use its smart filtering or not.
  8197. * @type boolean
  8198. * @default true
  8199. */
  8200. "bSmart": true,
  8201. /**
  8202. * Flag to indicate if DataTables should only trigger a search when
  8203. * the return key is pressed.
  8204. * @type boolean
  8205. * @default false
  8206. */
  8207. "return": false
  8208. };
  8209. /**
  8210. * Template object for the way in which DataTables holds information about
  8211. * each individual row. This is the object format used for the settings
  8212. * aoData array.
  8213. * @namespace
  8214. */
  8215. DataTable.models.oRow = {
  8216. /**
  8217. * TR element for the row
  8218. * @type node
  8219. * @default null
  8220. */
  8221. "nTr": null,
  8222. /**
  8223. * Array of TD elements for each row. This is null until the row has been
  8224. * created.
  8225. * @type array nodes
  8226. * @default []
  8227. */
  8228. "anCells": null,
  8229. /**
  8230. * Data object from the original data source for the row. This is either
  8231. * an array if using the traditional form of DataTables, or an object if
  8232. * using mData options. The exact type will depend on the passed in
  8233. * data from the data source, or will be an array if using DOM a data
  8234. * source.
  8235. * @type array|object
  8236. * @default []
  8237. */
  8238. "_aData": [],
  8239. /**
  8240. * Sorting data cache - this array is ostensibly the same length as the
  8241. * number of columns (although each index is generated only as it is
  8242. * needed), and holds the data that is used for sorting each column in the
  8243. * row. We do this cache generation at the start of the sort in order that
  8244. * the formatting of the sort data need be done only once for each cell
  8245. * per sort. This array should not be read from or written to by anything
  8246. * other than the master sorting methods.
  8247. * @type array
  8248. * @default null
  8249. * @private
  8250. */
  8251. "_aSortData": null,
  8252. /**
  8253. * Per cell filtering data cache. As per the sort data cache, used to
  8254. * increase the performance of the filtering in DataTables
  8255. * @type array
  8256. * @default null
  8257. * @private
  8258. */
  8259. "_aFilterData": null,
  8260. /**
  8261. * Filtering data cache. This is the same as the cell filtering cache, but
  8262. * in this case a string rather than an array. This is easily computed with
  8263. * a join on `_aFilterData`, but is provided as a cache so the join isn't
  8264. * needed on every search (memory traded for performance)
  8265. * @type array
  8266. * @default null
  8267. * @private
  8268. */
  8269. "_sFilterRow": null,
  8270. /**
  8271. * Cache of the class name that DataTables has applied to the row, so we
  8272. * can quickly look at this variable rather than needing to do a DOM check
  8273. * on className for the nTr property.
  8274. * @type string
  8275. * @default <i>Empty string</i>
  8276. * @private
  8277. */
  8278. "_sRowStripe": "",
  8279. /**
  8280. * Denote if the original data source was from the DOM, or the data source
  8281. * object. This is used for invalidating data, so DataTables can
  8282. * automatically read data from the original source, unless uninstructed
  8283. * otherwise.
  8284. * @type string
  8285. * @default null
  8286. * @private
  8287. */
  8288. "src": null,
  8289. /**
  8290. * Index in the aoData array. This saves an indexOf lookup when we have the
  8291. * object, but want to know the index
  8292. * @type integer
  8293. * @default -1
  8294. * @private
  8295. */
  8296. "idx": -1
  8297. };
  8298. /**
  8299. * Template object for the column information object in DataTables. This object
  8300. * is held in the settings aoColumns array and contains all the information that
  8301. * DataTables needs about each individual column.
  8302. *
  8303. * Note that this object is related to {@link DataTable.defaults.column}
  8304. * but this one is the internal data store for DataTables's cache of columns.
  8305. * It should NOT be manipulated outside of DataTables. Any configuration should
  8306. * be done through the initialisation options.
  8307. * @namespace
  8308. */
  8309. DataTable.models.oColumn = {
  8310. /**
  8311. * Column index. This could be worked out on-the-fly with $.inArray, but it
  8312. * is faster to just hold it as a variable
  8313. * @type integer
  8314. * @default null
  8315. */
  8316. "idx": null,
  8317. /**
  8318. * A list of the columns that sorting should occur on when this column
  8319. * is sorted. That this property is an array allows multi-column sorting
  8320. * to be defined for a column (for example first name / last name columns
  8321. * would benefit from this). The values are integers pointing to the
  8322. * columns to be sorted on (typically it will be a single integer pointing
  8323. * at itself, but that doesn't need to be the case).
  8324. * @type array
  8325. */
  8326. "aDataSort": null,
  8327. /**
  8328. * Define the sorting directions that are applied to the column, in sequence
  8329. * as the column is repeatedly sorted upon - i.e. the first value is used
  8330. * as the sorting direction when the column if first sorted (clicked on).
  8331. * Sort it again (click again) and it will move on to the next index.
  8332. * Repeat until loop.
  8333. * @type array
  8334. */
  8335. "asSorting": null,
  8336. /**
  8337. * Flag to indicate if the column is searchable, and thus should be included
  8338. * in the filtering or not.
  8339. * @type boolean
  8340. */
  8341. "bSearchable": null,
  8342. /**
  8343. * Flag to indicate if the column is sortable or not.
  8344. * @type boolean
  8345. */
  8346. "bSortable": null,
  8347. /**
  8348. * Flag to indicate if the column is currently visible in the table or not
  8349. * @type boolean
  8350. */
  8351. "bVisible": null,
  8352. /**
  8353. * Store for manual type assignment using the `column.type` option. This
  8354. * is held in store so we can manipulate the column's `sType` property.
  8355. * @type string
  8356. * @default null
  8357. * @private
  8358. */
  8359. "_sManualType": null,
  8360. /**
  8361. * Flag to indicate if HTML5 data attributes should be used as the data
  8362. * source for filtering or sorting. True is either are.
  8363. * @type boolean
  8364. * @default false
  8365. * @private
  8366. */
  8367. "_bAttrSrc": false,
  8368. /**
  8369. * Developer definable function that is called whenever a cell is created (Ajax source,
  8370. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  8371. * allowing you to modify the DOM element (add background colour for example) when the
  8372. * element is available.
  8373. * @type function
  8374. * @param {element} nTd The TD node that has been created
  8375. * @param {*} sData The Data for the cell
  8376. * @param {array|object} oData The data for the whole row
  8377. * @param {int} iRow The row index for the aoData data store
  8378. * @default null
  8379. */
  8380. "fnCreatedCell": null,
  8381. /**
  8382. * Function to get data from a cell in a column. You should <b>never</b>
  8383. * access data directly through _aData internally in DataTables - always use
  8384. * the method attached to this property. It allows mData to function as
  8385. * required. This function is automatically assigned by the column
  8386. * initialisation method
  8387. * @type function
  8388. * @param {array|object} oData The data array/object for the array
  8389. * (i.e. aoData[]._aData)
  8390. * @param {string} sSpecific The specific data type you want to get -
  8391. * 'display', 'type' 'filter' 'sort'
  8392. * @returns {*} The data for the cell from the given row's data
  8393. * @default null
  8394. */
  8395. "fnGetData": null,
  8396. /**
  8397. * Function to set data for a cell in the column. You should <b>never</b>
  8398. * set the data directly to _aData internally in DataTables - always use
  8399. * this method. It allows mData to function as required. This function
  8400. * is automatically assigned by the column initialisation method
  8401. * @type function
  8402. * @param {array|object} oData The data array/object for the array
  8403. * (i.e. aoData[]._aData)
  8404. * @param {*} sValue Value to set
  8405. * @default null
  8406. */
  8407. "fnSetData": null,
  8408. /**
  8409. * Property to read the value for the cells in the column from the data
  8410. * source array / object. If null, then the default content is used, if a
  8411. * function is given then the return from the function is used.
  8412. * @type function|int|string|null
  8413. * @default null
  8414. */
  8415. "mData": null,
  8416. /**
  8417. * Partner property to mData which is used (only when defined) to get
  8418. * the data - i.e. it is basically the same as mData, but without the
  8419. * 'set' option, and also the data fed to it is the result from mData.
  8420. * This is the rendering method to match the data method of mData.
  8421. * @type function|int|string|null
  8422. * @default null
  8423. */
  8424. "mRender": null,
  8425. /**
  8426. * Unique header TH/TD element for this column - this is what the sorting
  8427. * listener is attached to (if sorting is enabled.)
  8428. * @type node
  8429. * @default null
  8430. */
  8431. "nTh": null,
  8432. /**
  8433. * Unique footer TH/TD element for this column (if there is one). Not used
  8434. * in DataTables as such, but can be used for plug-ins to reference the
  8435. * footer for each column.
  8436. * @type node
  8437. * @default null
  8438. */
  8439. "nTf": null,
  8440. /**
  8441. * The class to apply to all TD elements in the table's TBODY for the column
  8442. * @type string
  8443. * @default null
  8444. */
  8445. "sClass": null,
  8446. /**
  8447. * When DataTables calculates the column widths to assign to each column,
  8448. * it finds the longest string in each column and then constructs a
  8449. * temporary table and reads the widths from that. The problem with this
  8450. * is that "mmm" is much wider then "iiii", but the latter is a longer
  8451. * string - thus the calculation can go wrong (doing it properly and putting
  8452. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  8453. * a "work around" we provide this option. It will append its value to the
  8454. * text that is found to be the longest string for the column - i.e. padding.
  8455. * @type string
  8456. */
  8457. "sContentPadding": null,
  8458. /**
  8459. * Allows a default value to be given for a column's data, and will be used
  8460. * whenever a null data source is encountered (this can be because mData
  8461. * is set to null, or because the data source itself is null).
  8462. * @type string
  8463. * @default null
  8464. */
  8465. "sDefaultContent": null,
  8466. /**
  8467. * Name for the column, allowing reference to the column by name as well as
  8468. * by index (needs a lookup to work by name).
  8469. * @type string
  8470. */
  8471. "sName": null,
  8472. /**
  8473. * Custom sorting data type - defines which of the available plug-ins in
  8474. * afnSortData the custom sorting will use - if any is defined.
  8475. * @type string
  8476. * @default std
  8477. */
  8478. "sSortDataType": 'std',
  8479. /**
  8480. * Class to be applied to the header element when sorting on this column
  8481. * @type string
  8482. * @default null
  8483. */
  8484. "sSortingClass": null,
  8485. /**
  8486. * Class to be applied to the header element when sorting on this column -
  8487. * when jQuery UI theming is used.
  8488. * @type string
  8489. * @default null
  8490. */
  8491. "sSortingClassJUI": null,
  8492. /**
  8493. * Title of the column - what is seen in the TH element (nTh).
  8494. * @type string
  8495. */
  8496. "sTitle": null,
  8497. /**
  8498. * Column sorting and filtering type
  8499. * @type string
  8500. * @default null
  8501. */
  8502. "sType": null,
  8503. /**
  8504. * Width of the column
  8505. * @type string
  8506. * @default null
  8507. */
  8508. "sWidth": null,
  8509. /**
  8510. * Width of the column when it was first "encountered"
  8511. * @type string
  8512. * @default null
  8513. */
  8514. "sWidthOrig": null
  8515. };
  8516. /*
  8517. * Developer note: The properties of the object below are given in Hungarian
  8518. * notation, that was used as the interface for DataTables prior to v1.10, however
  8519. * from v1.10 onwards the primary interface is camel case. In order to avoid
  8520. * breaking backwards compatibility utterly with this change, the Hungarian
  8521. * version is still, internally the primary interface, but is is not documented
  8522. * - hence the @name tags in each doc comment. This allows a Javascript function
  8523. * to create a map from Hungarian notation to camel case (going the other direction
  8524. * would require each property to be listed, which would add around 3K to the size
  8525. * of DataTables, while this method is about a 0.5K hit).
  8526. *
  8527. * Ultimately this does pave the way for Hungarian notation to be dropped
  8528. * completely, but that is a massive amount of work and will break current
  8529. * installs (therefore is on-hold until v2).
  8530. */
  8531. /**
  8532. * Initialisation options that can be given to DataTables at initialisation
  8533. * time.
  8534. * @namespace
  8535. */
  8536. DataTable.defaults = {
  8537. /**
  8538. * An array of data to use for the table, passed in at initialisation which
  8539. * will be used in preference to any data which is already in the DOM. This is
  8540. * particularly useful for constructing tables purely in Javascript, for
  8541. * example with a custom Ajax call.
  8542. * @type array
  8543. * @default null
  8544. *
  8545. * @dtopt Option
  8546. * @name DataTable.defaults.data
  8547. *
  8548. * @example
  8549. * // Using a 2D array data source
  8550. * $(document).ready( function () {
  8551. * $('#example').dataTable( {
  8552. * "data": [
  8553. * ['Trident', 'Internet Explorer 4.0', 'Win 95+', 4, 'X'],
  8554. * ['Trident', 'Internet Explorer 5.0', 'Win 95+', 5, 'C'],
  8555. * ],
  8556. * "columns": [
  8557. * { "title": "Engine" },
  8558. * { "title": "Browser" },
  8559. * { "title": "Platform" },
  8560. * { "title": "Version" },
  8561. * { "title": "Grade" }
  8562. * ]
  8563. * } );
  8564. * } );
  8565. *
  8566. * @example
  8567. * // Using an array of objects as a data source (`data`)
  8568. * $(document).ready( function () {
  8569. * $('#example').dataTable( {
  8570. * "data": [
  8571. * {
  8572. * "engine": "Trident",
  8573. * "browser": "Internet Explorer 4.0",
  8574. * "platform": "Win 95+",
  8575. * "version": 4,
  8576. * "grade": "X"
  8577. * },
  8578. * {
  8579. * "engine": "Trident",
  8580. * "browser": "Internet Explorer 5.0",
  8581. * "platform": "Win 95+",
  8582. * "version": 5,
  8583. * "grade": "C"
  8584. * }
  8585. * ],
  8586. * "columns": [
  8587. * { "title": "Engine", "data": "engine" },
  8588. * { "title": "Browser", "data": "browser" },
  8589. * { "title": "Platform", "data": "platform" },
  8590. * { "title": "Version", "data": "version" },
  8591. * { "title": "Grade", "data": "grade" }
  8592. * ]
  8593. * } );
  8594. * } );
  8595. */
  8596. "aaData": null,
  8597. /**
  8598. * If ordering is enabled, then DataTables will perform a first pass sort on
  8599. * initialisation. You can define which column(s) the sort is performed
  8600. * upon, and the sorting direction, with this variable. The `sorting` array
  8601. * should contain an array for each column to be sorted initially containing
  8602. * the column's index and a direction string ('asc' or 'desc').
  8603. * @type array
  8604. * @default [[0,'asc']]
  8605. *
  8606. * @dtopt Option
  8607. * @name DataTable.defaults.order
  8608. *
  8609. * @example
  8610. * // Sort by 3rd column first, and then 4th column
  8611. * $(document).ready( function() {
  8612. * $('#example').dataTable( {
  8613. * "order": [[2,'asc'], [3,'desc']]
  8614. * } );
  8615. * } );
  8616. *
  8617. * // No initial sorting
  8618. * $(document).ready( function() {
  8619. * $('#example').dataTable( {
  8620. * "order": []
  8621. * } );
  8622. * } );
  8623. */
  8624. "aaSorting": [[0,'asc']],
  8625. /**
  8626. * This parameter is basically identical to the `sorting` parameter, but
  8627. * cannot be overridden by user interaction with the table. What this means
  8628. * is that you could have a column (visible or hidden) which the sorting
  8629. * will always be forced on first - any sorting after that (from the user)
  8630. * will then be performed as required. This can be useful for grouping rows
  8631. * together.
  8632. * @type array
  8633. * @default null
  8634. *
  8635. * @dtopt Option
  8636. * @name DataTable.defaults.orderFixed
  8637. *
  8638. * @example
  8639. * $(document).ready( function() {
  8640. * $('#example').dataTable( {
  8641. * "orderFixed": [[0,'asc']]
  8642. * } );
  8643. * } )
  8644. */
  8645. "aaSortingFixed": [],
  8646. /**
  8647. * DataTables can be instructed to load data to display in the table from a
  8648. * Ajax source. This option defines how that Ajax call is made and where to.
  8649. *
  8650. * The `ajax` property has three different modes of operation, depending on
  8651. * how it is defined. These are:
  8652. *
  8653. * * `string` - Set the URL from where the data should be loaded from.
  8654. * * `object` - Define properties for `jQuery.ajax`.
  8655. * * `function` - Custom data get function
  8656. *
  8657. * `string`
  8658. * --------
  8659. *
  8660. * As a string, the `ajax` property simply defines the URL from which
  8661. * DataTables will load data.
  8662. *
  8663. * `object`
  8664. * --------
  8665. *
  8666. * As an object, the parameters in the object are passed to
  8667. * [jQuery.ajax](http://api.jquery.com/jQuery.ajax/) allowing fine control
  8668. * of the Ajax request. DataTables has a number of default parameters which
  8669. * you can override using this option. Please refer to the jQuery
  8670. * documentation for a full description of the options available, although
  8671. * the following parameters provide additional options in DataTables or
  8672. * require special consideration:
  8673. *
  8674. * * `data` - As with jQuery, `data` can be provided as an object, but it
  8675. * can also be used as a function to manipulate the data DataTables sends
  8676. * to the server. The function takes a single parameter, an object of
  8677. * parameters with the values that DataTables has readied for sending. An
  8678. * object may be returned which will be merged into the DataTables
  8679. * defaults, or you can add the items to the object that was passed in and
  8680. * not return anything from the function. This supersedes `fnServerParams`
  8681. * from DataTables 1.9-.
  8682. *
  8683. * * `dataSrc` - By default DataTables will look for the property `data` (or
  8684. * `aaData` for compatibility with DataTables 1.9-) when obtaining data
  8685. * from an Ajax source or for server-side processing - this parameter
  8686. * allows that property to be changed. You can use Javascript dotted
  8687. * object notation to get a data source for multiple levels of nesting, or
  8688. * it my be used as a function. As a function it takes a single parameter,
  8689. * the JSON returned from the server, which can be manipulated as
  8690. * required, with the returned value being that used by DataTables as the
  8691. * data source for the table. This supersedes `sAjaxDataProp` from
  8692. * DataTables 1.9-.
  8693. *
  8694. * * `success` - Should not be overridden it is used internally in
  8695. * DataTables. To manipulate / transform the data returned by the server
  8696. * use `ajax.dataSrc`, or use `ajax` as a function (see below).
  8697. *
  8698. * `function`
  8699. * ----------
  8700. *
  8701. * As a function, making the Ajax call is left up to yourself allowing
  8702. * complete control of the Ajax request. Indeed, if desired, a method other
  8703. * than Ajax could be used to obtain the required data, such as Web storage
  8704. * or an AIR database.
  8705. *
  8706. * The function is given four parameters and no return is required. The
  8707. * parameters are:
  8708. *
  8709. * 1. _object_ - Data to send to the server
  8710. * 2. _function_ - Callback function that must be executed when the required
  8711. * data has been obtained. That data should be passed into the callback
  8712. * as the only parameter
  8713. * 3. _object_ - DataTables settings object for the table
  8714. *
  8715. * Note that this supersedes `fnServerData` from DataTables 1.9-.
  8716. *
  8717. * @type string|object|function
  8718. * @default null
  8719. *
  8720. * @dtopt Option
  8721. * @name DataTable.defaults.ajax
  8722. * @since 1.10.0
  8723. *
  8724. * @example
  8725. * // Get JSON data from a file via Ajax.
  8726. * // Note DataTables expects data in the form `{ data: [ ...data... ] }` by default).
  8727. * $('#example').dataTable( {
  8728. * "ajax": "data.json"
  8729. * } );
  8730. *
  8731. * @example
  8732. * // Get JSON data from a file via Ajax, using `dataSrc` to change
  8733. * // `data` to `tableData` (i.e. `{ tableData: [ ...data... ] }`)
  8734. * $('#example').dataTable( {
  8735. * "ajax": {
  8736. * "url": "data.json",
  8737. * "dataSrc": "tableData"
  8738. * }
  8739. * } );
  8740. *
  8741. * @example
  8742. * // Get JSON data from a file via Ajax, using `dataSrc` to read data
  8743. * // from a plain array rather than an array in an object
  8744. * $('#example').dataTable( {
  8745. * "ajax": {
  8746. * "url": "data.json",
  8747. * "dataSrc": ""
  8748. * }
  8749. * } );
  8750. *
  8751. * @example
  8752. * // Manipulate the data returned from the server - add a link to data
  8753. * // (note this can, should, be done using `render` for the column - this
  8754. * // is just a simple example of how the data can be manipulated).
  8755. * $('#example').dataTable( {
  8756. * "ajax": {
  8757. * "url": "data.json",
  8758. * "dataSrc": function ( json ) {
  8759. * for ( var i=0, ien=json.length ; i<ien ; i++ ) {
  8760. * json[i][0] = '<a href="/message/'+json[i][0]+'>View message</a>';
  8761. * }
  8762. * return json;
  8763. * }
  8764. * }
  8765. * } );
  8766. *
  8767. * @example
  8768. * // Add data to the request
  8769. * $('#example').dataTable( {
  8770. * "ajax": {
  8771. * "url": "data.json",
  8772. * "data": function ( d ) {
  8773. * return {
  8774. * "extra_search": $('#extra').val()
  8775. * };
  8776. * }
  8777. * }
  8778. * } );
  8779. *
  8780. * @example
  8781. * // Send request as POST
  8782. * $('#example').dataTable( {
  8783. * "ajax": {
  8784. * "url": "data.json",
  8785. * "type": "POST"
  8786. * }
  8787. * } );
  8788. *
  8789. * @example
  8790. * // Get the data from localStorage (could interface with a form for
  8791. * // adding, editing and removing rows).
  8792. * $('#example').dataTable( {
  8793. * "ajax": function (data, callback, settings) {
  8794. * callback(
  8795. * JSON.parse( localStorage.getItem('dataTablesData') )
  8796. * );
  8797. * }
  8798. * } );
  8799. */
  8800. "ajax": null,
  8801. /**
  8802. * This parameter allows you to readily specify the entries in the length drop
  8803. * down menu that DataTables shows when pagination is enabled. It can be
  8804. * either a 1D array of options which will be used for both the displayed
  8805. * option and the value, or a 2D array which will use the array in the first
  8806. * position as the value, and the array in the second position as the
  8807. * displayed options (useful for language strings such as 'All').
  8808. *
  8809. * Note that the `pageLength` property will be automatically set to the
  8810. * first value given in this array, unless `pageLength` is also provided.
  8811. * @type array
  8812. * @default [ 10, 25, 50, 100 ]
  8813. *
  8814. * @dtopt Option
  8815. * @name DataTable.defaults.lengthMenu
  8816. *
  8817. * @example
  8818. * $(document).ready( function() {
  8819. * $('#example').dataTable( {
  8820. * "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
  8821. * } );
  8822. * } );
  8823. */
  8824. "aLengthMenu": [ 10, 25, 50, 100 ],
  8825. /**
  8826. * The `columns` option in the initialisation parameter allows you to define
  8827. * details about the way individual columns behave. For a full list of
  8828. * column options that can be set, please see
  8829. * {@link DataTable.defaults.column}. Note that if you use `columns` to
  8830. * define your columns, you must have an entry in the array for every single
  8831. * column that you have in your table (these can be null if you don't which
  8832. * to specify any options).
  8833. * @member
  8834. *
  8835. * @name DataTable.defaults.column
  8836. */
  8837. "aoColumns": null,
  8838. /**
  8839. * Very similar to `columns`, `columnDefs` allows you to target a specific
  8840. * column, multiple columns, or all columns, using the `targets` property of
  8841. * each object in the array. This allows great flexibility when creating
  8842. * tables, as the `columnDefs` arrays can be of any length, targeting the
  8843. * columns you specifically want. `columnDefs` may use any of the column
  8844. * options available: {@link DataTable.defaults.column}, but it _must_
  8845. * have `targets` defined in each object in the array. Values in the `targets`
  8846. * array may be:
  8847. * <ul>
  8848. * <li>a string - class name will be matched on the TH for the column</li>
  8849. * <li>0 or a positive integer - column index counting from the left</li>
  8850. * <li>a negative integer - column index counting from the right</li>
  8851. * <li>the string "_all" - all columns (i.e. assign a default)</li>
  8852. * </ul>
  8853. * @member
  8854. *
  8855. * @name DataTable.defaults.columnDefs
  8856. */
  8857. "aoColumnDefs": null,
  8858. /**
  8859. * Basically the same as `search`, this parameter defines the individual column
  8860. * filtering state at initialisation time. The array must be of the same size
  8861. * as the number of columns, and each element be an object with the parameters
  8862. * `search` and `escapeRegex` (the latter is optional). 'null' is also
  8863. * accepted and the default will be used.
  8864. * @type array
  8865. * @default []
  8866. *
  8867. * @dtopt Option
  8868. * @name DataTable.defaults.searchCols
  8869. *
  8870. * @example
  8871. * $(document).ready( function() {
  8872. * $('#example').dataTable( {
  8873. * "searchCols": [
  8874. * null,
  8875. * { "search": "My filter" },
  8876. * null,
  8877. * { "search": "^[0-9]", "escapeRegex": false }
  8878. * ]
  8879. * } );
  8880. * } )
  8881. */
  8882. "aoSearchCols": [],
  8883. /**
  8884. * An array of CSS classes that should be applied to displayed rows. This
  8885. * array may be of any length, and DataTables will apply each class
  8886. * sequentially, looping when required.
  8887. * @type array
  8888. * @default null <i>Will take the values determined by the `oClasses.stripe*`
  8889. * options</i>
  8890. *
  8891. * @dtopt Option
  8892. * @name DataTable.defaults.stripeClasses
  8893. *
  8894. * @example
  8895. * $(document).ready( function() {
  8896. * $('#example').dataTable( {
  8897. * "stripeClasses": [ 'strip1', 'strip2', 'strip3' ]
  8898. * } );
  8899. * } )
  8900. */
  8901. "asStripeClasses": null,
  8902. /**
  8903. * Enable or disable automatic column width calculation. This can be disabled
  8904. * as an optimisation (it takes some time to calculate the widths) if the
  8905. * tables widths are passed in using `columns`.
  8906. * @type boolean
  8907. * @default true
  8908. *
  8909. * @dtopt Features
  8910. * @name DataTable.defaults.autoWidth
  8911. *
  8912. * @example
  8913. * $(document).ready( function () {
  8914. * $('#example').dataTable( {
  8915. * "autoWidth": false
  8916. * } );
  8917. * } );
  8918. */
  8919. "bAutoWidth": true,
  8920. /**
  8921. * Deferred rendering can provide DataTables with a huge speed boost when you
  8922. * are using an Ajax or JS data source for the table. This option, when set to
  8923. * true, will cause DataTables to defer the creation of the table elements for
  8924. * each row until they are needed for a draw - saving a significant amount of
  8925. * time.
  8926. * @type boolean
  8927. * @default false
  8928. *
  8929. * @dtopt Features
  8930. * @name DataTable.defaults.deferRender
  8931. *
  8932. * @example
  8933. * $(document).ready( function() {
  8934. * $('#example').dataTable( {
  8935. * "ajax": "sources/arrays.txt",
  8936. * "deferRender": true
  8937. * } );
  8938. * } );
  8939. */
  8940. "bDeferRender": false,
  8941. /**
  8942. * Replace a DataTable which matches the given selector and replace it with
  8943. * one which has the properties of the new initialisation object passed. If no
  8944. * table matches the selector, then the new DataTable will be constructed as
  8945. * per normal.
  8946. * @type boolean
  8947. * @default false
  8948. *
  8949. * @dtopt Options
  8950. * @name DataTable.defaults.destroy
  8951. *
  8952. * @example
  8953. * $(document).ready( function() {
  8954. * $('#example').dataTable( {
  8955. * "srollY": "200px",
  8956. * "paginate": false
  8957. * } );
  8958. *
  8959. * // Some time later....
  8960. * $('#example').dataTable( {
  8961. * "filter": false,
  8962. * "destroy": true
  8963. * } );
  8964. * } );
  8965. */
  8966. "bDestroy": false,
  8967. /**
  8968. * Enable or disable filtering of data. Filtering in DataTables is "smart" in
  8969. * that it allows the end user to input multiple words (space separated) and
  8970. * will match a row containing those words, even if not in the order that was
  8971. * specified (this allow matching across multiple columns). Note that if you
  8972. * wish to use filtering in DataTables this must remain 'true' - to remove the
  8973. * default filtering input box and retain filtering abilities, please use
  8974. * {@link DataTable.defaults.dom}.
  8975. * @type boolean
  8976. * @default true
  8977. *
  8978. * @dtopt Features
  8979. * @name DataTable.defaults.searching
  8980. *
  8981. * @example
  8982. * $(document).ready( function () {
  8983. * $('#example').dataTable( {
  8984. * "searching": false
  8985. * } );
  8986. * } );
  8987. */
  8988. "bFilter": true,
  8989. /**
  8990. * Enable or disable the table information display. This shows information
  8991. * about the data that is currently visible on the page, including information
  8992. * about filtered data if that action is being performed.
  8993. * @type boolean
  8994. * @default true
  8995. *
  8996. * @dtopt Features
  8997. * @name DataTable.defaults.info
  8998. *
  8999. * @example
  9000. * $(document).ready( function () {
  9001. * $('#example').dataTable( {
  9002. * "info": false
  9003. * } );
  9004. * } );
  9005. */
  9006. "bInfo": true,
  9007. /**
  9008. * Allows the end user to select the size of a formatted page from a select
  9009. * menu (sizes are 10, 25, 50 and 100). Requires pagination (`paginate`).
  9010. * @type boolean
  9011. * @default true
  9012. *
  9013. * @dtopt Features
  9014. * @name DataTable.defaults.lengthChange
  9015. *
  9016. * @example
  9017. * $(document).ready( function () {
  9018. * $('#example').dataTable( {
  9019. * "lengthChange": false
  9020. * } );
  9021. * } );
  9022. */
  9023. "bLengthChange": true,
  9024. /**
  9025. * Enable or disable pagination.
  9026. * @type boolean
  9027. * @default true
  9028. *
  9029. * @dtopt Features
  9030. * @name DataTable.defaults.paging
  9031. *
  9032. * @example
  9033. * $(document).ready( function () {
  9034. * $('#example').dataTable( {
  9035. * "paging": false
  9036. * } );
  9037. * } );
  9038. */
  9039. "bPaginate": true,
  9040. /**
  9041. * Enable or disable the display of a 'processing' indicator when the table is
  9042. * being processed (e.g. a sort). This is particularly useful for tables with
  9043. * large amounts of data where it can take a noticeable amount of time to sort
  9044. * the entries.
  9045. * @type boolean
  9046. * @default false
  9047. *
  9048. * @dtopt Features
  9049. * @name DataTable.defaults.processing
  9050. *
  9051. * @example
  9052. * $(document).ready( function () {
  9053. * $('#example').dataTable( {
  9054. * "processing": true
  9055. * } );
  9056. * } );
  9057. */
  9058. "bProcessing": false,
  9059. /**
  9060. * Retrieve the DataTables object for the given selector. Note that if the
  9061. * table has already been initialised, this parameter will cause DataTables
  9062. * to simply return the object that has already been set up - it will not take
  9063. * account of any changes you might have made to the initialisation object
  9064. * passed to DataTables (setting this parameter to true is an acknowledgement
  9065. * that you understand this). `destroy` can be used to reinitialise a table if
  9066. * you need.
  9067. * @type boolean
  9068. * @default false
  9069. *
  9070. * @dtopt Options
  9071. * @name DataTable.defaults.retrieve
  9072. *
  9073. * @example
  9074. * $(document).ready( function() {
  9075. * initTable();
  9076. * tableActions();
  9077. * } );
  9078. *
  9079. * function initTable ()
  9080. * {
  9081. * return $('#example').dataTable( {
  9082. * "scrollY": "200px",
  9083. * "paginate": false,
  9084. * "retrieve": true
  9085. * } );
  9086. * }
  9087. *
  9088. * function tableActions ()
  9089. * {
  9090. * var table = initTable();
  9091. * // perform API operations with oTable
  9092. * }
  9093. */
  9094. "bRetrieve": false,
  9095. /**
  9096. * When vertical (y) scrolling is enabled, DataTables will force the height of
  9097. * the table's viewport to the given height at all times (useful for layout).
  9098. * However, this can look odd when filtering data down to a small data set,
  9099. * and the footer is left "floating" further down. This parameter (when
  9100. * enabled) will cause DataTables to collapse the table's viewport down when
  9101. * the result set will fit within the given Y height.
  9102. * @type boolean
  9103. * @default false
  9104. *
  9105. * @dtopt Options
  9106. * @name DataTable.defaults.scrollCollapse
  9107. *
  9108. * @example
  9109. * $(document).ready( function() {
  9110. * $('#example').dataTable( {
  9111. * "scrollY": "200",
  9112. * "scrollCollapse": true
  9113. * } );
  9114. * } );
  9115. */
  9116. "bScrollCollapse": false,
  9117. /**
  9118. * Configure DataTables to use server-side processing. Note that the
  9119. * `ajax` parameter must also be given in order to give DataTables a
  9120. * source to obtain the required data for each draw.
  9121. * @type boolean
  9122. * @default false
  9123. *
  9124. * @dtopt Features
  9125. * @dtopt Server-side
  9126. * @name DataTable.defaults.serverSide
  9127. *
  9128. * @example
  9129. * $(document).ready( function () {
  9130. * $('#example').dataTable( {
  9131. * "serverSide": true,
  9132. * "ajax": "xhr.php"
  9133. * } );
  9134. * } );
  9135. */
  9136. "bServerSide": false,
  9137. /**
  9138. * Enable or disable sorting of columns. Sorting of individual columns can be
  9139. * disabled by the `sortable` option for each column.
  9140. * @type boolean
  9141. * @default true
  9142. *
  9143. * @dtopt Features
  9144. * @name DataTable.defaults.ordering
  9145. *
  9146. * @example
  9147. * $(document).ready( function () {
  9148. * $('#example').dataTable( {
  9149. * "ordering": false
  9150. * } );
  9151. * } );
  9152. */
  9153. "bSort": true,
  9154. /**
  9155. * Enable or display DataTables' ability to sort multiple columns at the
  9156. * same time (activated by shift-click by the user).
  9157. * @type boolean
  9158. * @default true
  9159. *
  9160. * @dtopt Options
  9161. * @name DataTable.defaults.orderMulti
  9162. *
  9163. * @example
  9164. * // Disable multiple column sorting ability
  9165. * $(document).ready( function () {
  9166. * $('#example').dataTable( {
  9167. * "orderMulti": false
  9168. * } );
  9169. * } );
  9170. */
  9171. "bSortMulti": true,
  9172. /**
  9173. * Allows control over whether DataTables should use the top (true) unique
  9174. * cell that is found for a single column, or the bottom (false - default).
  9175. * This is useful when using complex headers.
  9176. * @type boolean
  9177. * @default false
  9178. *
  9179. * @dtopt Options
  9180. * @name DataTable.defaults.orderCellsTop
  9181. *
  9182. * @example
  9183. * $(document).ready( function() {
  9184. * $('#example').dataTable( {
  9185. * "orderCellsTop": true
  9186. * } );
  9187. * } );
  9188. */
  9189. "bSortCellsTop": false,
  9190. /**
  9191. * Enable or disable the addition of the classes `sorting\_1`, `sorting\_2` and
  9192. * `sorting\_3` to the columns which are currently being sorted on. This is
  9193. * presented as a feature switch as it can increase processing time (while
  9194. * classes are removed and added) so for large data sets you might want to
  9195. * turn this off.
  9196. * @type boolean
  9197. * @default true
  9198. *
  9199. * @dtopt Features
  9200. * @name DataTable.defaults.orderClasses
  9201. *
  9202. * @example
  9203. * $(document).ready( function () {
  9204. * $('#example').dataTable( {
  9205. * "orderClasses": false
  9206. * } );
  9207. * } );
  9208. */
  9209. "bSortClasses": true,
  9210. /**
  9211. * Enable or disable state saving. When enabled HTML5 `localStorage` will be
  9212. * used to save table display information such as pagination information,
  9213. * display length, filtering and sorting. As such when the end user reloads
  9214. * the page the display display will match what thy had previously set up.
  9215. *
  9216. * Due to the use of `localStorage` the default state saving is not supported
  9217. * in IE6 or 7. If state saving is required in those browsers, use
  9218. * `stateSaveCallback` to provide a storage solution such as cookies.
  9219. * @type boolean
  9220. * @default false
  9221. *
  9222. * @dtopt Features
  9223. * @name DataTable.defaults.stateSave
  9224. *
  9225. * @example
  9226. * $(document).ready( function () {
  9227. * $('#example').dataTable( {
  9228. * "stateSave": true
  9229. * } );
  9230. * } );
  9231. */
  9232. "bStateSave": false,
  9233. /**
  9234. * This function is called when a TR element is created (and all TD child
  9235. * elements have been inserted), or registered if using a DOM source, allowing
  9236. * manipulation of the TR element (adding classes etc).
  9237. * @type function
  9238. * @param {node} row "TR" element for the current row
  9239. * @param {array} data Raw data array for this row
  9240. * @param {int} dataIndex The index of this row in the internal aoData array
  9241. *
  9242. * @dtopt Callbacks
  9243. * @name DataTable.defaults.createdRow
  9244. *
  9245. * @example
  9246. * $(document).ready( function() {
  9247. * $('#example').dataTable( {
  9248. * "createdRow": function( row, data, dataIndex ) {
  9249. * // Bold the grade for all 'A' grade browsers
  9250. * if ( data[4] == "A" )
  9251. * {
  9252. * $('td:eq(4)', row).html( '<b>A</b>' );
  9253. * }
  9254. * }
  9255. * } );
  9256. * } );
  9257. */
  9258. "fnCreatedRow": null,
  9259. /**
  9260. * This function is called on every 'draw' event, and allows you to
  9261. * dynamically modify any aspect you want about the created DOM.
  9262. * @type function
  9263. * @param {object} settings DataTables settings object
  9264. *
  9265. * @dtopt Callbacks
  9266. * @name DataTable.defaults.drawCallback
  9267. *
  9268. * @example
  9269. * $(document).ready( function() {
  9270. * $('#example').dataTable( {
  9271. * "drawCallback": function( settings ) {
  9272. * alert( 'DataTables has redrawn the table' );
  9273. * }
  9274. * } );
  9275. * } );
  9276. */
  9277. "fnDrawCallback": null,
  9278. /**
  9279. * Identical to fnHeaderCallback() but for the table footer this function
  9280. * allows you to modify the table footer on every 'draw' event.
  9281. * @type function
  9282. * @param {node} foot "TR" element for the footer
  9283. * @param {array} data Full table data (as derived from the original HTML)
  9284. * @param {int} start Index for the current display starting point in the
  9285. * display array
  9286. * @param {int} end Index for the current display ending point in the
  9287. * display array
  9288. * @param {array int} display Index array to translate the visual position
  9289. * to the full data array
  9290. *
  9291. * @dtopt Callbacks
  9292. * @name DataTable.defaults.footerCallback
  9293. *
  9294. * @example
  9295. * $(document).ready( function() {
  9296. * $('#example').dataTable( {
  9297. * "footerCallback": function( tfoot, data, start, end, display ) {
  9298. * tfoot.getElementsByTagName('th')[0].innerHTML = "Starting index is "+start;
  9299. * }
  9300. * } );
  9301. * } )
  9302. */
  9303. "fnFooterCallback": null,
  9304. /**
  9305. * When rendering large numbers in the information element for the table
  9306. * (i.e. "Showing 1 to 10 of 57 entries") DataTables will render large numbers
  9307. * to have a comma separator for the 'thousands' units (e.g. 1 million is
  9308. * rendered as "1,000,000") to help readability for the end user. This
  9309. * function will override the default method DataTables uses.
  9310. * @type function
  9311. * @member
  9312. * @param {int} toFormat number to be formatted
  9313. * @returns {string} formatted string for DataTables to show the number
  9314. *
  9315. * @dtopt Callbacks
  9316. * @name DataTable.defaults.formatNumber
  9317. *
  9318. * @example
  9319. * // Format a number using a single quote for the separator (note that
  9320. * // this can also be done with the language.thousands option)
  9321. * $(document).ready( function() {
  9322. * $('#example').dataTable( {
  9323. * "formatNumber": function ( toFormat ) {
  9324. * return toFormat.toString().replace(
  9325. * /\B(?=(\d{3})+(?!\d))/g, "'"
  9326. * );
  9327. * };
  9328. * } );
  9329. * } );
  9330. */
  9331. "fnFormatNumber": function ( toFormat ) {
  9332. return toFormat.toString().replace(
  9333. /\B(?=(\d{3})+(?!\d))/g,
  9334. this.oLanguage.sThousands
  9335. );
  9336. },
  9337. /**
  9338. * This function is called on every 'draw' event, and allows you to
  9339. * dynamically modify the header row. This can be used to calculate and
  9340. * display useful information about the table.
  9341. * @type function
  9342. * @param {node} head "TR" element for the header
  9343. * @param {array} data Full table data (as derived from the original HTML)
  9344. * @param {int} start Index for the current display starting point in the
  9345. * display array
  9346. * @param {int} end Index for the current display ending point in the
  9347. * display array
  9348. * @param {array int} display Index array to translate the visual position
  9349. * to the full data array
  9350. *
  9351. * @dtopt Callbacks
  9352. * @name DataTable.defaults.headerCallback
  9353. *
  9354. * @example
  9355. * $(document).ready( function() {
  9356. * $('#example').dataTable( {
  9357. * "fheaderCallback": function( head, data, start, end, display ) {
  9358. * head.getElementsByTagName('th')[0].innerHTML = "Displaying "+(end-start)+" records";
  9359. * }
  9360. * } );
  9361. * } )
  9362. */
  9363. "fnHeaderCallback": null,
  9364. /**
  9365. * The information element can be used to convey information about the current
  9366. * state of the table. Although the internationalisation options presented by
  9367. * DataTables are quite capable of dealing with most customisations, there may
  9368. * be times where you wish to customise the string further. This callback
  9369. * allows you to do exactly that.
  9370. * @type function
  9371. * @param {object} oSettings DataTables settings object
  9372. * @param {int} start Starting position in data for the draw
  9373. * @param {int} end End position in data for the draw
  9374. * @param {int} max Total number of rows in the table (regardless of
  9375. * filtering)
  9376. * @param {int} total Total number of rows in the data set, after filtering
  9377. * @param {string} pre The string that DataTables has formatted using it's
  9378. * own rules
  9379. * @returns {string} The string to be displayed in the information element.
  9380. *
  9381. * @dtopt Callbacks
  9382. * @name DataTable.defaults.infoCallback
  9383. *
  9384. * @example
  9385. * $('#example').dataTable( {
  9386. * "infoCallback": function( settings, start, end, max, total, pre ) {
  9387. * return start +" to "+ end;
  9388. * }
  9389. * } );
  9390. */
  9391. "fnInfoCallback": null,
  9392. /**
  9393. * Called when the table has been initialised. Normally DataTables will
  9394. * initialise sequentially and there will be no need for this function,
  9395. * however, this does not hold true when using external language information
  9396. * since that is obtained using an async XHR call.
  9397. * @type function
  9398. * @param {object} settings DataTables settings object
  9399. * @param {object} json The JSON object request from the server - only
  9400. * present if client-side Ajax sourced data is used
  9401. *
  9402. * @dtopt Callbacks
  9403. * @name DataTable.defaults.initComplete
  9404. *
  9405. * @example
  9406. * $(document).ready( function() {
  9407. * $('#example').dataTable( {
  9408. * "initComplete": function(settings, json) {
  9409. * alert( 'DataTables has finished its initialisation.' );
  9410. * }
  9411. * } );
  9412. * } )
  9413. */
  9414. "fnInitComplete": null,
  9415. /**
  9416. * Called at the very start of each table draw and can be used to cancel the
  9417. * draw by returning false, any other return (including undefined) results in
  9418. * the full draw occurring).
  9419. * @type function
  9420. * @param {object} settings DataTables settings object
  9421. * @returns {boolean} False will cancel the draw, anything else (including no
  9422. * return) will allow it to complete.
  9423. *
  9424. * @dtopt Callbacks
  9425. * @name DataTable.defaults.preDrawCallback
  9426. *
  9427. * @example
  9428. * $(document).ready( function() {
  9429. * $('#example').dataTable( {
  9430. * "preDrawCallback": function( settings ) {
  9431. * if ( $('#test').val() == 1 ) {
  9432. * return false;
  9433. * }
  9434. * }
  9435. * } );
  9436. * } );
  9437. */
  9438. "fnPreDrawCallback": null,
  9439. /**
  9440. * This function allows you to 'post process' each row after it have been
  9441. * generated for each table draw, but before it is rendered on screen. This
  9442. * function might be used for setting the row class name etc.
  9443. * @type function
  9444. * @param {node} row "TR" element for the current row
  9445. * @param {array} data Raw data array for this row
  9446. * @param {int} displayIndex The display index for the current table draw
  9447. * @param {int} displayIndexFull The index of the data in the full list of
  9448. * rows (after filtering)
  9449. *
  9450. * @dtopt Callbacks
  9451. * @name DataTable.defaults.rowCallback
  9452. *
  9453. * @example
  9454. * $(document).ready( function() {
  9455. * $('#example').dataTable( {
  9456. * "rowCallback": function( row, data, displayIndex, displayIndexFull ) {
  9457. * // Bold the grade for all 'A' grade browsers
  9458. * if ( data[4] == "A" ) {
  9459. * $('td:eq(4)', row).html( '<b>A</b>' );
  9460. * }
  9461. * }
  9462. * } );
  9463. * } );
  9464. */
  9465. "fnRowCallback": null,
  9466. /**
  9467. * __Deprecated__ The functionality provided by this parameter has now been
  9468. * superseded by that provided through `ajax`, which should be used instead.
  9469. *
  9470. * This parameter allows you to override the default function which obtains
  9471. * the data from the server so something more suitable for your application.
  9472. * For example you could use POST data, or pull information from a Gears or
  9473. * AIR database.
  9474. * @type function
  9475. * @member
  9476. * @param {string} source HTTP source to obtain the data from (`ajax`)
  9477. * @param {array} data A key/value pair object containing the data to send
  9478. * to the server
  9479. * @param {function} callback to be called on completion of the data get
  9480. * process that will draw the data on the page.
  9481. * @param {object} settings DataTables settings object
  9482. *
  9483. * @dtopt Callbacks
  9484. * @dtopt Server-side
  9485. * @name DataTable.defaults.serverData
  9486. *
  9487. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9488. */
  9489. "fnServerData": null,
  9490. /**
  9491. * __Deprecated__ The functionality provided by this parameter has now been
  9492. * superseded by that provided through `ajax`, which should be used instead.
  9493. *
  9494. * It is often useful to send extra data to the server when making an Ajax
  9495. * request - for example custom filtering information, and this callback
  9496. * function makes it trivial to send extra information to the server. The
  9497. * passed in parameter is the data set that has been constructed by
  9498. * DataTables, and you can add to this or modify it as you require.
  9499. * @type function
  9500. * @param {array} data Data array (array of objects which are name/value
  9501. * pairs) that has been constructed by DataTables and will be sent to the
  9502. * server. In the case of Ajax sourced data with server-side processing
  9503. * this will be an empty array, for server-side processing there will be a
  9504. * significant number of parameters!
  9505. * @returns {undefined} Ensure that you modify the data array passed in,
  9506. * as this is passed by reference.
  9507. *
  9508. * @dtopt Callbacks
  9509. * @dtopt Server-side
  9510. * @name DataTable.defaults.serverParams
  9511. *
  9512. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9513. */
  9514. "fnServerParams": null,
  9515. /**
  9516. * Load the table state. With this function you can define from where, and how, the
  9517. * state of a table is loaded. By default DataTables will load from `localStorage`
  9518. * but you might wish to use a server-side database or cookies.
  9519. * @type function
  9520. * @member
  9521. * @param {object} settings DataTables settings object
  9522. * @param {object} callback Callback that can be executed when done. It
  9523. * should be passed the loaded state object.
  9524. * @return {object} The DataTables state object to be loaded
  9525. *
  9526. * @dtopt Callbacks
  9527. * @name DataTable.defaults.stateLoadCallback
  9528. *
  9529. * @example
  9530. * $(document).ready( function() {
  9531. * $('#example').dataTable( {
  9532. * "stateSave": true,
  9533. * "stateLoadCallback": function (settings, callback) {
  9534. * $.ajax( {
  9535. * "url": "/state_load",
  9536. * "dataType": "json",
  9537. * "success": function (json) {
  9538. * callback( json );
  9539. * }
  9540. * } );
  9541. * }
  9542. * } );
  9543. * } );
  9544. */
  9545. "fnStateLoadCallback": function ( settings ) {
  9546. try {
  9547. return JSON.parse(
  9548. (settings.iStateDuration === -1 ? sessionStorage : localStorage).getItem(
  9549. 'DataTables_'+settings.sInstance+'_'+location.pathname
  9550. )
  9551. );
  9552. } catch (e) {
  9553. return {};
  9554. }
  9555. },
  9556. /**
  9557. * Callback which allows modification of the saved state prior to loading that state.
  9558. * This callback is called when the table is loading state from the stored data, but
  9559. * prior to the settings object being modified by the saved state. Note that for
  9560. * plug-in authors, you should use the `stateLoadParams` event to load parameters for
  9561. * a plug-in.
  9562. * @type function
  9563. * @param {object} settings DataTables settings object
  9564. * @param {object} data The state object that is to be loaded
  9565. *
  9566. * @dtopt Callbacks
  9567. * @name DataTable.defaults.stateLoadParams
  9568. *
  9569. * @example
  9570. * // Remove a saved filter, so filtering is never loaded
  9571. * $(document).ready( function() {
  9572. * $('#example').dataTable( {
  9573. * "stateSave": true,
  9574. * "stateLoadParams": function (settings, data) {
  9575. * data.oSearch.sSearch = "";
  9576. * }
  9577. * } );
  9578. * } );
  9579. *
  9580. * @example
  9581. * // Disallow state loading by returning false
  9582. * $(document).ready( function() {
  9583. * $('#example').dataTable( {
  9584. * "stateSave": true,
  9585. * "stateLoadParams": function (settings, data) {
  9586. * return false;
  9587. * }
  9588. * } );
  9589. * } );
  9590. */
  9591. "fnStateLoadParams": null,
  9592. /**
  9593. * Callback that is called when the state has been loaded from the state saving method
  9594. * and the DataTables settings object has been modified as a result of the loaded state.
  9595. * @type function
  9596. * @param {object} settings DataTables settings object
  9597. * @param {object} data The state object that was loaded
  9598. *
  9599. * @dtopt Callbacks
  9600. * @name DataTable.defaults.stateLoaded
  9601. *
  9602. * @example
  9603. * // Show an alert with the filtering value that was saved
  9604. * $(document).ready( function() {
  9605. * $('#example').dataTable( {
  9606. * "stateSave": true,
  9607. * "stateLoaded": function (settings, data) {
  9608. * alert( 'Saved filter was: '+data.oSearch.sSearch );
  9609. * }
  9610. * } );
  9611. * } );
  9612. */
  9613. "fnStateLoaded": null,
  9614. /**
  9615. * Save the table state. This function allows you to define where and how the state
  9616. * information for the table is stored By default DataTables will use `localStorage`
  9617. * but you might wish to use a server-side database or cookies.
  9618. * @type function
  9619. * @member
  9620. * @param {object} settings DataTables settings object
  9621. * @param {object} data The state object to be saved
  9622. *
  9623. * @dtopt Callbacks
  9624. * @name DataTable.defaults.stateSaveCallback
  9625. *
  9626. * @example
  9627. * $(document).ready( function() {
  9628. * $('#example').dataTable( {
  9629. * "stateSave": true,
  9630. * "stateSaveCallback": function (settings, data) {
  9631. * // Send an Ajax request to the server with the state object
  9632. * $.ajax( {
  9633. * "url": "/state_save",
  9634. * "data": data,
  9635. * "dataType": "json",
  9636. * "method": "POST"
  9637. * "success": function () {}
  9638. * } );
  9639. * }
  9640. * } );
  9641. * } );
  9642. */
  9643. "fnStateSaveCallback": function ( settings, data ) {
  9644. try {
  9645. (settings.iStateDuration === -1 ? sessionStorage : localStorage).setItem(
  9646. 'DataTables_'+settings.sInstance+'_'+location.pathname,
  9647. JSON.stringify( data )
  9648. );
  9649. } catch (e) {}
  9650. },
  9651. /**
  9652. * Callback which allows modification of the state to be saved. Called when the table
  9653. * has changed state a new state save is required. This method allows modification of
  9654. * the state saving object prior to actually doing the save, including addition or
  9655. * other state properties or modification. Note that for plug-in authors, you should
  9656. * use the `stateSaveParams` event to save parameters for a plug-in.
  9657. * @type function
  9658. * @param {object} settings DataTables settings object
  9659. * @param {object} data The state object to be saved
  9660. *
  9661. * @dtopt Callbacks
  9662. * @name DataTable.defaults.stateSaveParams
  9663. *
  9664. * @example
  9665. * // Remove a saved filter, so filtering is never saved
  9666. * $(document).ready( function() {
  9667. * $('#example').dataTable( {
  9668. * "stateSave": true,
  9669. * "stateSaveParams": function (settings, data) {
  9670. * data.oSearch.sSearch = "";
  9671. * }
  9672. * } );
  9673. * } );
  9674. */
  9675. "fnStateSaveParams": null,
  9676. /**
  9677. * Duration for which the saved state information is considered valid. After this period
  9678. * has elapsed the state will be returned to the default.
  9679. * Value is given in seconds.
  9680. * @type int
  9681. * @default 7200 <i>(2 hours)</i>
  9682. *
  9683. * @dtopt Options
  9684. * @name DataTable.defaults.stateDuration
  9685. *
  9686. * @example
  9687. * $(document).ready( function() {
  9688. * $('#example').dataTable( {
  9689. * "stateDuration": 60*60*24; // 1 day
  9690. * } );
  9691. * } )
  9692. */
  9693. "iStateDuration": 7200,
  9694. /**
  9695. * When enabled DataTables will not make a request to the server for the first
  9696. * page draw - rather it will use the data already on the page (no sorting etc
  9697. * will be applied to it), thus saving on an XHR at load time. `deferLoading`
  9698. * is used to indicate that deferred loading is required, but it is also used
  9699. * to tell DataTables how many records there are in the full table (allowing
  9700. * the information element and pagination to be displayed correctly). In the case
  9701. * where a filtering is applied to the table on initial load, this can be
  9702. * indicated by giving the parameter as an array, where the first element is
  9703. * the number of records available after filtering and the second element is the
  9704. * number of records without filtering (allowing the table information element
  9705. * to be shown correctly).
  9706. * @type int | array
  9707. * @default null
  9708. *
  9709. * @dtopt Options
  9710. * @name DataTable.defaults.deferLoading
  9711. *
  9712. * @example
  9713. * // 57 records available in the table, no filtering applied
  9714. * $(document).ready( function() {
  9715. * $('#example').dataTable( {
  9716. * "serverSide": true,
  9717. * "ajax": "scripts/server_processing.php",
  9718. * "deferLoading": 57
  9719. * } );
  9720. * } );
  9721. *
  9722. * @example
  9723. * // 57 records after filtering, 100 without filtering (an initial filter applied)
  9724. * $(document).ready( function() {
  9725. * $('#example').dataTable( {
  9726. * "serverSide": true,
  9727. * "ajax": "scripts/server_processing.php",
  9728. * "deferLoading": [ 57, 100 ],
  9729. * "search": {
  9730. * "search": "my_filter"
  9731. * }
  9732. * } );
  9733. * } );
  9734. */
  9735. "iDeferLoading": null,
  9736. /**
  9737. * Number of rows to display on a single page when using pagination. If
  9738. * feature enabled (`lengthChange`) then the end user will be able to override
  9739. * this to a custom setting using a pop-up menu.
  9740. * @type int
  9741. * @default 10
  9742. *
  9743. * @dtopt Options
  9744. * @name DataTable.defaults.pageLength
  9745. *
  9746. * @example
  9747. * $(document).ready( function() {
  9748. * $('#example').dataTable( {
  9749. * "pageLength": 50
  9750. * } );
  9751. * } )
  9752. */
  9753. "iDisplayLength": 10,
  9754. /**
  9755. * Define the starting point for data display when using DataTables with
  9756. * pagination. Note that this parameter is the number of records, rather than
  9757. * the page number, so if you have 10 records per page and want to start on
  9758. * the third page, it should be "20".
  9759. * @type int
  9760. * @default 0
  9761. *
  9762. * @dtopt Options
  9763. * @name DataTable.defaults.displayStart
  9764. *
  9765. * @example
  9766. * $(document).ready( function() {
  9767. * $('#example').dataTable( {
  9768. * "displayStart": 20
  9769. * } );
  9770. * } )
  9771. */
  9772. "iDisplayStart": 0,
  9773. /**
  9774. * By default DataTables allows keyboard navigation of the table (sorting, paging,
  9775. * and filtering) by adding a `tabindex` attribute to the required elements. This
  9776. * allows you to tab through the controls and press the enter key to activate them.
  9777. * The tabindex is default 0, meaning that the tab follows the flow of the document.
  9778. * You can overrule this using this parameter if you wish. Use a value of -1 to
  9779. * disable built-in keyboard navigation.
  9780. * @type int
  9781. * @default 0
  9782. *
  9783. * @dtopt Options
  9784. * @name DataTable.defaults.tabIndex
  9785. *
  9786. * @example
  9787. * $(document).ready( function() {
  9788. * $('#example').dataTable( {
  9789. * "tabIndex": 1
  9790. * } );
  9791. * } );
  9792. */
  9793. "iTabIndex": 0,
  9794. /**
  9795. * Classes that DataTables assigns to the various components and features
  9796. * that it adds to the HTML table. This allows classes to be configured
  9797. * during initialisation in addition to through the static
  9798. * {@link DataTable.ext.oStdClasses} object).
  9799. * @namespace
  9800. * @name DataTable.defaults.classes
  9801. */
  9802. "oClasses": {},
  9803. /**
  9804. * All strings that DataTables uses in the user interface that it creates
  9805. * are defined in this object, allowing you to modified them individually or
  9806. * completely replace them all as required.
  9807. * @namespace
  9808. * @name DataTable.defaults.language
  9809. */
  9810. "oLanguage": {
  9811. /**
  9812. * Strings that are used for WAI-ARIA labels and controls only (these are not
  9813. * actually visible on the page, but will be read by screenreaders, and thus
  9814. * must be internationalised as well).
  9815. * @namespace
  9816. * @name DataTable.defaults.language.aria
  9817. */
  9818. "oAria": {
  9819. /**
  9820. * ARIA label that is added to the table headers when the column may be
  9821. * sorted ascending by activing the column (click or return when focused).
  9822. * Note that the column header is prefixed to this string.
  9823. * @type string
  9824. * @default : activate to sort column ascending
  9825. *
  9826. * @dtopt Language
  9827. * @name DataTable.defaults.language.aria.sortAscending
  9828. *
  9829. * @example
  9830. * $(document).ready( function() {
  9831. * $('#example').dataTable( {
  9832. * "language": {
  9833. * "aria": {
  9834. * "sortAscending": " - click/return to sort ascending"
  9835. * }
  9836. * }
  9837. * } );
  9838. * } );
  9839. */
  9840. "sSortAscending": ": activate to sort column ascending",
  9841. /**
  9842. * ARIA label that is added to the table headers when the column may be
  9843. * sorted descending by activing the column (click or return when focused).
  9844. * Note that the column header is prefixed to this string.
  9845. * @type string
  9846. * @default : activate to sort column ascending
  9847. *
  9848. * @dtopt Language
  9849. * @name DataTable.defaults.language.aria.sortDescending
  9850. *
  9851. * @example
  9852. * $(document).ready( function() {
  9853. * $('#example').dataTable( {
  9854. * "language": {
  9855. * "aria": {
  9856. * "sortDescending": " - click/return to sort descending"
  9857. * }
  9858. * }
  9859. * } );
  9860. * } );
  9861. */
  9862. "sSortDescending": ": activate to sort column descending"
  9863. },
  9864. /**
  9865. * Pagination string used by DataTables for the built-in pagination
  9866. * control types.
  9867. * @namespace
  9868. * @name DataTable.defaults.language.paginate
  9869. */
  9870. "oPaginate": {
  9871. /**
  9872. * Text to use when using the 'full_numbers' type of pagination for the
  9873. * button to take the user to the first page.
  9874. * @type string
  9875. * @default First
  9876. *
  9877. * @dtopt Language
  9878. * @name DataTable.defaults.language.paginate.first
  9879. *
  9880. * @example
  9881. * $(document).ready( function() {
  9882. * $('#example').dataTable( {
  9883. * "language": {
  9884. * "paginate": {
  9885. * "first": "First page"
  9886. * }
  9887. * }
  9888. * } );
  9889. * } );
  9890. */
  9891. "sFirst": "First",
  9892. /**
  9893. * Text to use when using the 'full_numbers' type of pagination for the
  9894. * button to take the user to the last page.
  9895. * @type string
  9896. * @default Last
  9897. *
  9898. * @dtopt Language
  9899. * @name DataTable.defaults.language.paginate.last
  9900. *
  9901. * @example
  9902. * $(document).ready( function() {
  9903. * $('#example').dataTable( {
  9904. * "language": {
  9905. * "paginate": {
  9906. * "last": "Last page"
  9907. * }
  9908. * }
  9909. * } );
  9910. * } );
  9911. */
  9912. "sLast": "Last",
  9913. /**
  9914. * Text to use for the 'next' pagination button (to take the user to the
  9915. * next page).
  9916. * @type string
  9917. * @default Next
  9918. *
  9919. * @dtopt Language
  9920. * @name DataTable.defaults.language.paginate.next
  9921. *
  9922. * @example
  9923. * $(document).ready( function() {
  9924. * $('#example').dataTable( {
  9925. * "language": {
  9926. * "paginate": {
  9927. * "next": "Next page"
  9928. * }
  9929. * }
  9930. * } );
  9931. * } );
  9932. */
  9933. "sNext": "Next",
  9934. /**
  9935. * Text to use for the 'previous' pagination button (to take the user to
  9936. * the previous page).
  9937. * @type string
  9938. * @default Previous
  9939. *
  9940. * @dtopt Language
  9941. * @name DataTable.defaults.language.paginate.previous
  9942. *
  9943. * @example
  9944. * $(document).ready( function() {
  9945. * $('#example').dataTable( {
  9946. * "language": {
  9947. * "paginate": {
  9948. * "previous": "Previous page"
  9949. * }
  9950. * }
  9951. * } );
  9952. * } );
  9953. */
  9954. "sPrevious": "Previous"
  9955. },
  9956. /**
  9957. * This string is shown in preference to `zeroRecords` when the table is
  9958. * empty of data (regardless of filtering). Note that this is an optional
  9959. * parameter - if it is not given, the value of `zeroRecords` will be used
  9960. * instead (either the default or given value).
  9961. * @type string
  9962. * @default No data available in table
  9963. *
  9964. * @dtopt Language
  9965. * @name DataTable.defaults.language.emptyTable
  9966. *
  9967. * @example
  9968. * $(document).ready( function() {
  9969. * $('#example').dataTable( {
  9970. * "language": {
  9971. * "emptyTable": "No data available in table"
  9972. * }
  9973. * } );
  9974. * } );
  9975. */
  9976. "sEmptyTable": "No data available in table",
  9977. /**
  9978. * This string gives information to the end user about the information
  9979. * that is current on display on the page. The following tokens can be
  9980. * used in the string and will be dynamically replaced as the table
  9981. * display updates. This tokens can be placed anywhere in the string, or
  9982. * removed as needed by the language requires:
  9983. *
  9984. * * `\_START\_` - Display index of the first record on the current page
  9985. * * `\_END\_` - Display index of the last record on the current page
  9986. * * `\_TOTAL\_` - Number of records in the table after filtering
  9987. * * `\_MAX\_` - Number of records in the table without filtering
  9988. * * `\_PAGE\_` - Current page number
  9989. * * `\_PAGES\_` - Total number of pages of data in the table
  9990. *
  9991. * @type string
  9992. * @default Showing _START_ to _END_ of _TOTAL_ entries
  9993. *
  9994. * @dtopt Language
  9995. * @name DataTable.defaults.language.info
  9996. *
  9997. * @example
  9998. * $(document).ready( function() {
  9999. * $('#example').dataTable( {
  10000. * "language": {
  10001. * "info": "Showing page _PAGE_ of _PAGES_"
  10002. * }
  10003. * } );
  10004. * } );
  10005. */
  10006. "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
  10007. /**
  10008. * Display information string for when the table is empty. Typically the
  10009. * format of this string should match `info`.
  10010. * @type string
  10011. * @default Showing 0 to 0 of 0 entries
  10012. *
  10013. * @dtopt Language
  10014. * @name DataTable.defaults.language.infoEmpty
  10015. *
  10016. * @example
  10017. * $(document).ready( function() {
  10018. * $('#example').dataTable( {
  10019. * "language": {
  10020. * "infoEmpty": "No entries to show"
  10021. * }
  10022. * } );
  10023. * } );
  10024. */
  10025. "sInfoEmpty": "Showing 0 to 0 of 0 entries",
  10026. /**
  10027. * When a user filters the information in a table, this string is appended
  10028. * to the information (`info`) to give an idea of how strong the filtering
  10029. * is. The variable _MAX_ is dynamically updated.
  10030. * @type string
  10031. * @default (filtered from _MAX_ total entries)
  10032. *
  10033. * @dtopt Language
  10034. * @name DataTable.defaults.language.infoFiltered
  10035. *
  10036. * @example
  10037. * $(document).ready( function() {
  10038. * $('#example').dataTable( {
  10039. * "language": {
  10040. * "infoFiltered": " - filtering from _MAX_ records"
  10041. * }
  10042. * } );
  10043. * } );
  10044. */
  10045. "sInfoFiltered": "(filtered from _MAX_ total entries)",
  10046. /**
  10047. * If can be useful to append extra information to the info string at times,
  10048. * and this variable does exactly that. This information will be appended to
  10049. * the `info` (`infoEmpty` and `infoFiltered` in whatever combination they are
  10050. * being used) at all times.
  10051. * @type string
  10052. * @default <i>Empty string</i>
  10053. *
  10054. * @dtopt Language
  10055. * @name DataTable.defaults.language.infoPostFix
  10056. *
  10057. * @example
  10058. * $(document).ready( function() {
  10059. * $('#example').dataTable( {
  10060. * "language": {
  10061. * "infoPostFix": "All records shown are derived from real information."
  10062. * }
  10063. * } );
  10064. * } );
  10065. */
  10066. "sInfoPostFix": "",
  10067. /**
  10068. * This decimal place operator is a little different from the other
  10069. * language options since DataTables doesn't output floating point
  10070. * numbers, so it won't ever use this for display of a number. Rather,
  10071. * what this parameter does is modify the sort methods of the table so
  10072. * that numbers which are in a format which has a character other than
  10073. * a period (`.`) as a decimal place will be sorted numerically.
  10074. *
  10075. * Note that numbers with different decimal places cannot be shown in
  10076. * the same table and still be sortable, the table must be consistent.
  10077. * However, multiple different tables on the page can use different
  10078. * decimal place characters.
  10079. * @type string
  10080. * @default
  10081. *
  10082. * @dtopt Language
  10083. * @name DataTable.defaults.language.decimal
  10084. *
  10085. * @example
  10086. * $(document).ready( function() {
  10087. * $('#example').dataTable( {
  10088. * "language": {
  10089. * "decimal": ","
  10090. * "thousands": "."
  10091. * }
  10092. * } );
  10093. * } );
  10094. */
  10095. "sDecimal": "",
  10096. /**
  10097. * DataTables has a build in number formatter (`formatNumber`) which is
  10098. * used to format large numbers that are used in the table information.
  10099. * By default a comma is used, but this can be trivially changed to any
  10100. * character you wish with this parameter.
  10101. * @type string
  10102. * @default ,
  10103. *
  10104. * @dtopt Language
  10105. * @name DataTable.defaults.language.thousands
  10106. *
  10107. * @example
  10108. * $(document).ready( function() {
  10109. * $('#example').dataTable( {
  10110. * "language": {
  10111. * "thousands": "'"
  10112. * }
  10113. * } );
  10114. * } );
  10115. */
  10116. "sThousands": ",",
  10117. /**
  10118. * Detail the action that will be taken when the drop down menu for the
  10119. * pagination length option is changed. The '_MENU_' variable is replaced
  10120. * with a default select list of 10, 25, 50 and 100, and can be replaced
  10121. * with a custom select box if required.
  10122. * @type string
  10123. * @default Show _MENU_ entries
  10124. *
  10125. * @dtopt Language
  10126. * @name DataTable.defaults.language.lengthMenu
  10127. *
  10128. * @example
  10129. * // Language change only
  10130. * $(document).ready( function() {
  10131. * $('#example').dataTable( {
  10132. * "language": {
  10133. * "lengthMenu": "Display _MENU_ records"
  10134. * }
  10135. * } );
  10136. * } );
  10137. *
  10138. * @example
  10139. * // Language and options change
  10140. * $(document).ready( function() {
  10141. * $('#example').dataTable( {
  10142. * "language": {
  10143. * "lengthMenu": 'Display <select>'+
  10144. * '<option value="10">10</option>'+
  10145. * '<option value="20">20</option>'+
  10146. * '<option value="30">30</option>'+
  10147. * '<option value="40">40</option>'+
  10148. * '<option value="50">50</option>'+
  10149. * '<option value="-1">All</option>'+
  10150. * '</select> records'
  10151. * }
  10152. * } );
  10153. * } );
  10154. */
  10155. "sLengthMenu": "Show _MENU_ entries",
  10156. /**
  10157. * When using Ajax sourced data and during the first draw when DataTables is
  10158. * gathering the data, this message is shown in an empty row in the table to
  10159. * indicate to the end user the the data is being loaded. Note that this
  10160. * parameter is not used when loading data by server-side processing, just
  10161. * Ajax sourced data with client-side processing.
  10162. * @type string
  10163. * @default Loading...
  10164. *
  10165. * @dtopt Language
  10166. * @name DataTable.defaults.language.loadingRecords
  10167. *
  10168. * @example
  10169. * $(document).ready( function() {
  10170. * $('#example').dataTable( {
  10171. * "language": {
  10172. * "loadingRecords": "Please wait - loading..."
  10173. * }
  10174. * } );
  10175. * } );
  10176. */
  10177. "sLoadingRecords": "Loading...",
  10178. /**
  10179. * Text which is displayed when the table is processing a user action
  10180. * (usually a sort command or similar).
  10181. * @type string
  10182. * @default Processing...
  10183. *
  10184. * @dtopt Language
  10185. * @name DataTable.defaults.language.processing
  10186. *
  10187. * @example
  10188. * $(document).ready( function() {
  10189. * $('#example').dataTable( {
  10190. * "language": {
  10191. * "processing": "DataTables is currently busy"
  10192. * }
  10193. * } );
  10194. * } );
  10195. */
  10196. "sProcessing": "Processing...",
  10197. /**
  10198. * Details the actions that will be taken when the user types into the
  10199. * filtering input text box. The variable "_INPUT_", if used in the string,
  10200. * is replaced with the HTML text box for the filtering input allowing
  10201. * control over where it appears in the string. If "_INPUT_" is not given
  10202. * then the input box is appended to the string automatically.
  10203. * @type string
  10204. * @default Search:
  10205. *
  10206. * @dtopt Language
  10207. * @name DataTable.defaults.language.search
  10208. *
  10209. * @example
  10210. * // Input text box will be appended at the end automatically
  10211. * $(document).ready( function() {
  10212. * $('#example').dataTable( {
  10213. * "language": {
  10214. * "search": "Filter records:"
  10215. * }
  10216. * } );
  10217. * } );
  10218. *
  10219. * @example
  10220. * // Specify where the filter should appear
  10221. * $(document).ready( function() {
  10222. * $('#example').dataTable( {
  10223. * "language": {
  10224. * "search": "Apply filter _INPUT_ to table"
  10225. * }
  10226. * } );
  10227. * } );
  10228. */
  10229. "sSearch": "Search:",
  10230. /**
  10231. * Assign a `placeholder` attribute to the search `input` element
  10232. * @type string
  10233. * @default
  10234. *
  10235. * @dtopt Language
  10236. * @name DataTable.defaults.language.searchPlaceholder
  10237. */
  10238. "sSearchPlaceholder": "",
  10239. /**
  10240. * All of the language information can be stored in a file on the
  10241. * server-side, which DataTables will look up if this parameter is passed.
  10242. * It must store the URL of the language file, which is in a JSON format,
  10243. * and the object has the same properties as the oLanguage object in the
  10244. * initialiser object (i.e. the above parameters). Please refer to one of
  10245. * the example language files to see how this works in action.
  10246. * @type string
  10247. * @default <i>Empty string - i.e. disabled</i>
  10248. *
  10249. * @dtopt Language
  10250. * @name DataTable.defaults.language.url
  10251. *
  10252. * @example
  10253. * $(document).ready( function() {
  10254. * $('#example').dataTable( {
  10255. * "language": {
  10256. * "url": "http://www.sprymedia.co.uk/dataTables/lang.txt"
  10257. * }
  10258. * } );
  10259. * } );
  10260. */
  10261. "sUrl": "",
  10262. /**
  10263. * Text shown inside the table records when the is no information to be
  10264. * displayed after filtering. `emptyTable` is shown when there is simply no
  10265. * information in the table at all (regardless of filtering).
  10266. * @type string
  10267. * @default No matching records found
  10268. *
  10269. * @dtopt Language
  10270. * @name DataTable.defaults.language.zeroRecords
  10271. *
  10272. * @example
  10273. * $(document).ready( function() {
  10274. * $('#example').dataTable( {
  10275. * "language": {
  10276. * "zeroRecords": "No records to display"
  10277. * }
  10278. * } );
  10279. * } );
  10280. */
  10281. "sZeroRecords": "No matching records found"
  10282. },
  10283. /**
  10284. * This parameter allows you to have define the global filtering state at
  10285. * initialisation time. As an object the `search` parameter must be
  10286. * defined, but all other parameters are optional. When `regex` is true,
  10287. * the search string will be treated as a regular expression, when false
  10288. * (default) it will be treated as a straight string. When `smart`
  10289. * DataTables will use it's smart filtering methods (to word match at
  10290. * any point in the data), when false this will not be done.
  10291. * @namespace
  10292. * @extends DataTable.models.oSearch
  10293. *
  10294. * @dtopt Options
  10295. * @name DataTable.defaults.search
  10296. *
  10297. * @example
  10298. * $(document).ready( function() {
  10299. * $('#example').dataTable( {
  10300. * "search": {"search": "Initial search"}
  10301. * } );
  10302. * } )
  10303. */
  10304. "oSearch": $.extend( {}, DataTable.models.oSearch ),
  10305. /**
  10306. * __Deprecated__ The functionality provided by this parameter has now been
  10307. * superseded by that provided through `ajax`, which should be used instead.
  10308. *
  10309. * By default DataTables will look for the property `data` (or `aaData` for
  10310. * compatibility with DataTables 1.9-) when obtaining data from an Ajax
  10311. * source or for server-side processing - this parameter allows that
  10312. * property to be changed. You can use Javascript dotted object notation to
  10313. * get a data source for multiple levels of nesting.
  10314. * @type string
  10315. * @default data
  10316. *
  10317. * @dtopt Options
  10318. * @dtopt Server-side
  10319. * @name DataTable.defaults.ajaxDataProp
  10320. *
  10321. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10322. */
  10323. "sAjaxDataProp": "data",
  10324. /**
  10325. * __Deprecated__ The functionality provided by this parameter has now been
  10326. * superseded by that provided through `ajax`, which should be used instead.
  10327. *
  10328. * You can instruct DataTables to load data from an external
  10329. * source using this parameter (use aData if you want to pass data in you
  10330. * already have). Simply provide a url a JSON object can be obtained from.
  10331. * @type string
  10332. * @default null
  10333. *
  10334. * @dtopt Options
  10335. * @dtopt Server-side
  10336. * @name DataTable.defaults.ajaxSource
  10337. *
  10338. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10339. */
  10340. "sAjaxSource": null,
  10341. /**
  10342. * This initialisation variable allows you to specify exactly where in the
  10343. * DOM you want DataTables to inject the various controls it adds to the page
  10344. * (for example you might want the pagination controls at the top of the
  10345. * table). DIV elements (with or without a custom class) can also be added to
  10346. * aid styling. The follow syntax is used:
  10347. * <ul>
  10348. * <li>The following options are allowed:
  10349. * <ul>
  10350. * <li>'l' - Length changing</li>
  10351. * <li>'f' - Filtering input</li>
  10352. * <li>'t' - The table!</li>
  10353. * <li>'i' - Information</li>
  10354. * <li>'p' - Pagination</li>
  10355. * <li>'r' - pRocessing</li>
  10356. * </ul>
  10357. * </li>
  10358. * <li>The following constants are allowed:
  10359. * <ul>
  10360. * <li>'H' - jQueryUI theme "header" classes ('fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix')</li>
  10361. * <li>'F' - jQueryUI theme "footer" classes ('fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix')</li>
  10362. * </ul>
  10363. * </li>
  10364. * <li>The following syntax is expected:
  10365. * <ul>
  10366. * <li>'&lt;' and '&gt;' - div elements</li>
  10367. * <li>'&lt;"class" and '&gt;' - div with a class</li>
  10368. * <li>'&lt;"#id" and '&gt;' - div with an ID</li>
  10369. * </ul>
  10370. * </li>
  10371. * <li>Examples:
  10372. * <ul>
  10373. * <li>'&lt;"wrapper"flipt&gt;'</li>
  10374. * <li>'&lt;lf&lt;t&gt;ip&gt;'</li>
  10375. * </ul>
  10376. * </li>
  10377. * </ul>
  10378. * @type string
  10379. * @default lfrtip <i>(when `jQueryUI` is false)</i> <b>or</b>
  10380. * <"H"lfr>t<"F"ip> <i>(when `jQueryUI` is true)</i>
  10381. *
  10382. * @dtopt Options
  10383. * @name DataTable.defaults.dom
  10384. *
  10385. * @example
  10386. * $(document).ready( function() {
  10387. * $('#example').dataTable( {
  10388. * "dom": '&lt;"top"i&gt;rt&lt;"bottom"flp&gt;&lt;"clear"&gt;'
  10389. * } );
  10390. * } );
  10391. */
  10392. "sDom": "lfrtip",
  10393. /**
  10394. * Search delay option. This will throttle full table searches that use the
  10395. * DataTables provided search input element (it does not effect calls to
  10396. * `dt-api search()`, providing a delay before the search is made.
  10397. * @type integer
  10398. * @default 0
  10399. *
  10400. * @dtopt Options
  10401. * @name DataTable.defaults.searchDelay
  10402. *
  10403. * @example
  10404. * $(document).ready( function() {
  10405. * $('#example').dataTable( {
  10406. * "searchDelay": 200
  10407. * } );
  10408. * } )
  10409. */
  10410. "searchDelay": null,
  10411. /**
  10412. * DataTables features six different built-in options for the buttons to
  10413. * display for pagination control:
  10414. *
  10415. * * `numbers` - Page number buttons only
  10416. * * `simple` - 'Previous' and 'Next' buttons only
  10417. * * 'simple_numbers` - 'Previous' and 'Next' buttons, plus page numbers
  10418. * * `full` - 'First', 'Previous', 'Next' and 'Last' buttons
  10419. * * `full_numbers` - 'First', 'Previous', 'Next' and 'Last' buttons, plus page numbers
  10420. * * `first_last_numbers` - 'First' and 'Last' buttons, plus page numbers
  10421. *
  10422. * Further methods can be added using {@link DataTable.ext.oPagination}.
  10423. * @type string
  10424. * @default simple_numbers
  10425. *
  10426. * @dtopt Options
  10427. * @name DataTable.defaults.pagingType
  10428. *
  10429. * @example
  10430. * $(document).ready( function() {
  10431. * $('#example').dataTable( {
  10432. * "pagingType": "full_numbers"
  10433. * } );
  10434. * } )
  10435. */
  10436. "sPaginationType": "simple_numbers",
  10437. /**
  10438. * Enable horizontal scrolling. When a table is too wide to fit into a
  10439. * certain layout, or you have a large number of columns in the table, you
  10440. * can enable x-scrolling to show the table in a viewport, which can be
  10441. * scrolled. This property can be `true` which will allow the table to
  10442. * scroll horizontally when needed, or any CSS unit, or a number (in which
  10443. * case it will be treated as a pixel measurement). Setting as simply `true`
  10444. * is recommended.
  10445. * @type boolean|string
  10446. * @default <i>blank string - i.e. disabled</i>
  10447. *
  10448. * @dtopt Features
  10449. * @name DataTable.defaults.scrollX
  10450. *
  10451. * @example
  10452. * $(document).ready( function() {
  10453. * $('#example').dataTable( {
  10454. * "scrollX": true,
  10455. * "scrollCollapse": true
  10456. * } );
  10457. * } );
  10458. */
  10459. "sScrollX": "",
  10460. /**
  10461. * This property can be used to force a DataTable to use more width than it
  10462. * might otherwise do when x-scrolling is enabled. For example if you have a
  10463. * table which requires to be well spaced, this parameter is useful for
  10464. * "over-sizing" the table, and thus forcing scrolling. This property can by
  10465. * any CSS unit, or a number (in which case it will be treated as a pixel
  10466. * measurement).
  10467. * @type string
  10468. * @default <i>blank string - i.e. disabled</i>
  10469. *
  10470. * @dtopt Options
  10471. * @name DataTable.defaults.scrollXInner
  10472. *
  10473. * @example
  10474. * $(document).ready( function() {
  10475. * $('#example').dataTable( {
  10476. * "scrollX": "100%",
  10477. * "scrollXInner": "110%"
  10478. * } );
  10479. * } );
  10480. */
  10481. "sScrollXInner": "",
  10482. /**
  10483. * Enable vertical scrolling. Vertical scrolling will constrain the DataTable
  10484. * to the given height, and enable scrolling for any data which overflows the
  10485. * current viewport. This can be used as an alternative to paging to display
  10486. * a lot of data in a small area (although paging and scrolling can both be
  10487. * enabled at the same time). This property can be any CSS unit, or a number
  10488. * (in which case it will be treated as a pixel measurement).
  10489. * @type string
  10490. * @default <i>blank string - i.e. disabled</i>
  10491. *
  10492. * @dtopt Features
  10493. * @name DataTable.defaults.scrollY
  10494. *
  10495. * @example
  10496. * $(document).ready( function() {
  10497. * $('#example').dataTable( {
  10498. * "scrollY": "200px",
  10499. * "paginate": false
  10500. * } );
  10501. * } );
  10502. */
  10503. "sScrollY": "",
  10504. /**
  10505. * __Deprecated__ The functionality provided by this parameter has now been
  10506. * superseded by that provided through `ajax`, which should be used instead.
  10507. *
  10508. * Set the HTTP method that is used to make the Ajax call for server-side
  10509. * processing or Ajax sourced data.
  10510. * @type string
  10511. * @default GET
  10512. *
  10513. * @dtopt Options
  10514. * @dtopt Server-side
  10515. * @name DataTable.defaults.serverMethod
  10516. *
  10517. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10518. */
  10519. "sServerMethod": "GET",
  10520. /**
  10521. * DataTables makes use of renderers when displaying HTML elements for
  10522. * a table. These renderers can be added or modified by plug-ins to
  10523. * generate suitable mark-up for a site. For example the Bootstrap
  10524. * integration plug-in for DataTables uses a paging button renderer to
  10525. * display pagination buttons in the mark-up required by Bootstrap.
  10526. *
  10527. * For further information about the renderers available see
  10528. * DataTable.ext.renderer
  10529. * @type string|object
  10530. * @default null
  10531. *
  10532. * @name DataTable.defaults.renderer
  10533. *
  10534. */
  10535. "renderer": null,
  10536. /**
  10537. * Set the data property name that DataTables should use to get a row's id
  10538. * to set as the `id` property in the node.
  10539. * @type string
  10540. * @default DT_RowId
  10541. *
  10542. * @name DataTable.defaults.rowId
  10543. */
  10544. "rowId": "DT_RowId"
  10545. };
  10546. _fnHungarianMap( DataTable.defaults );
  10547. /*
  10548. * Developer note - See note in model.defaults.js about the use of Hungarian
  10549. * notation and camel case.
  10550. */
  10551. /**
  10552. * Column options that can be given to DataTables at initialisation time.
  10553. * @namespace
  10554. */
  10555. DataTable.defaults.column = {
  10556. /**
  10557. * Define which column(s) an order will occur on for this column. This
  10558. * allows a column's ordering to take multiple columns into account when
  10559. * doing a sort or use the data from a different column. For example first
  10560. * name / last name columns make sense to do a multi-column sort over the
  10561. * two columns.
  10562. * @type array|int
  10563. * @default null <i>Takes the value of the column index automatically</i>
  10564. *
  10565. * @name DataTable.defaults.column.orderData
  10566. * @dtopt Columns
  10567. *
  10568. * @example
  10569. * // Using `columnDefs`
  10570. * $(document).ready( function() {
  10571. * $('#example').dataTable( {
  10572. * "columnDefs": [
  10573. * { "orderData": [ 0, 1 ], "targets": [ 0 ] },
  10574. * { "orderData": [ 1, 0 ], "targets": [ 1 ] },
  10575. * { "orderData": 2, "targets": [ 2 ] }
  10576. * ]
  10577. * } );
  10578. * } );
  10579. *
  10580. * @example
  10581. * // Using `columns`
  10582. * $(document).ready( function() {
  10583. * $('#example').dataTable( {
  10584. * "columns": [
  10585. * { "orderData": [ 0, 1 ] },
  10586. * { "orderData": [ 1, 0 ] },
  10587. * { "orderData": 2 },
  10588. * null,
  10589. * null
  10590. * ]
  10591. * } );
  10592. * } );
  10593. */
  10594. "aDataSort": null,
  10595. "iDataSort": -1,
  10596. /**
  10597. * You can control the default ordering direction, and even alter the
  10598. * behaviour of the sort handler (i.e. only allow ascending ordering etc)
  10599. * using this parameter.
  10600. * @type array
  10601. * @default [ 'asc', 'desc' ]
  10602. *
  10603. * @name DataTable.defaults.column.orderSequence
  10604. * @dtopt Columns
  10605. *
  10606. * @example
  10607. * // Using `columnDefs`
  10608. * $(document).ready( function() {
  10609. * $('#example').dataTable( {
  10610. * "columnDefs": [
  10611. * { "orderSequence": [ "asc" ], "targets": [ 1 ] },
  10612. * { "orderSequence": [ "desc", "asc", "asc" ], "targets": [ 2 ] },
  10613. * { "orderSequence": [ "desc" ], "targets": [ 3 ] }
  10614. * ]
  10615. * } );
  10616. * } );
  10617. *
  10618. * @example
  10619. * // Using `columns`
  10620. * $(document).ready( function() {
  10621. * $('#example').dataTable( {
  10622. * "columns": [
  10623. * null,
  10624. * { "orderSequence": [ "asc" ] },
  10625. * { "orderSequence": [ "desc", "asc", "asc" ] },
  10626. * { "orderSequence": [ "desc" ] },
  10627. * null
  10628. * ]
  10629. * } );
  10630. * } );
  10631. */
  10632. "asSorting": [ 'asc', 'desc' ],
  10633. /**
  10634. * Enable or disable filtering on the data in this column.
  10635. * @type boolean
  10636. * @default true
  10637. *
  10638. * @name DataTable.defaults.column.searchable
  10639. * @dtopt Columns
  10640. *
  10641. * @example
  10642. * // Using `columnDefs`
  10643. * $(document).ready( function() {
  10644. * $('#example').dataTable( {
  10645. * "columnDefs": [
  10646. * { "searchable": false, "targets": [ 0 ] }
  10647. * ] } );
  10648. * } );
  10649. *
  10650. * @example
  10651. * // Using `columns`
  10652. * $(document).ready( function() {
  10653. * $('#example').dataTable( {
  10654. * "columns": [
  10655. * { "searchable": false },
  10656. * null,
  10657. * null,
  10658. * null,
  10659. * null
  10660. * ] } );
  10661. * } );
  10662. */
  10663. "bSearchable": true,
  10664. /**
  10665. * Enable or disable ordering on this column.
  10666. * @type boolean
  10667. * @default true
  10668. *
  10669. * @name DataTable.defaults.column.orderable
  10670. * @dtopt Columns
  10671. *
  10672. * @example
  10673. * // Using `columnDefs`
  10674. * $(document).ready( function() {
  10675. * $('#example').dataTable( {
  10676. * "columnDefs": [
  10677. * { "orderable": false, "targets": [ 0 ] }
  10678. * ] } );
  10679. * } );
  10680. *
  10681. * @example
  10682. * // Using `columns`
  10683. * $(document).ready( function() {
  10684. * $('#example').dataTable( {
  10685. * "columns": [
  10686. * { "orderable": false },
  10687. * null,
  10688. * null,
  10689. * null,
  10690. * null
  10691. * ] } );
  10692. * } );
  10693. */
  10694. "bSortable": true,
  10695. /**
  10696. * Enable or disable the display of this column.
  10697. * @type boolean
  10698. * @default true
  10699. *
  10700. * @name DataTable.defaults.column.visible
  10701. * @dtopt Columns
  10702. *
  10703. * @example
  10704. * // Using `columnDefs`
  10705. * $(document).ready( function() {
  10706. * $('#example').dataTable( {
  10707. * "columnDefs": [
  10708. * { "visible": false, "targets": [ 0 ] }
  10709. * ] } );
  10710. * } );
  10711. *
  10712. * @example
  10713. * // Using `columns`
  10714. * $(document).ready( function() {
  10715. * $('#example').dataTable( {
  10716. * "columns": [
  10717. * { "visible": false },
  10718. * null,
  10719. * null,
  10720. * null,
  10721. * null
  10722. * ] } );
  10723. * } );
  10724. */
  10725. "bVisible": true,
  10726. /**
  10727. * Developer definable function that is called whenever a cell is created (Ajax source,
  10728. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  10729. * allowing you to modify the DOM element (add background colour for example) when the
  10730. * element is available.
  10731. * @type function
  10732. * @param {element} td The TD node that has been created
  10733. * @param {*} cellData The Data for the cell
  10734. * @param {array|object} rowData The data for the whole row
  10735. * @param {int} row The row index for the aoData data store
  10736. * @param {int} col The column index for aoColumns
  10737. *
  10738. * @name DataTable.defaults.column.createdCell
  10739. * @dtopt Columns
  10740. *
  10741. * @example
  10742. * $(document).ready( function() {
  10743. * $('#example').dataTable( {
  10744. * "columnDefs": [ {
  10745. * "targets": [3],
  10746. * "createdCell": function (td, cellData, rowData, row, col) {
  10747. * if ( cellData == "1.7" ) {
  10748. * $(td).css('color', 'blue')
  10749. * }
  10750. * }
  10751. * } ]
  10752. * });
  10753. * } );
  10754. */
  10755. "fnCreatedCell": null,
  10756. /**
  10757. * This parameter has been replaced by `data` in DataTables to ensure naming
  10758. * consistency. `dataProp` can still be used, as there is backwards
  10759. * compatibility in DataTables for this option, but it is strongly
  10760. * recommended that you use `data` in preference to `dataProp`.
  10761. * @name DataTable.defaults.column.dataProp
  10762. */
  10763. /**
  10764. * This property can be used to read data from any data source property,
  10765. * including deeply nested objects / properties. `data` can be given in a
  10766. * number of different ways which effect its behaviour:
  10767. *
  10768. * * `integer` - treated as an array index for the data source. This is the
  10769. * default that DataTables uses (incrementally increased for each column).
  10770. * * `string` - read an object property from the data source. There are
  10771. * three 'special' options that can be used in the string to alter how
  10772. * DataTables reads the data from the source object:
  10773. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10774. * Javascript to read from nested objects, so to can the options
  10775. * specified in `data`. For example: `browser.version` or
  10776. * `browser.name`. If your object parameter name contains a period, use
  10777. * `\\` to escape it - i.e. `first\\.name`.
  10778. * * `[]` - Array notation. DataTables can automatically combine data
  10779. * from and array source, joining the data with the characters provided
  10780. * between the two brackets. For example: `name[, ]` would provide a
  10781. * comma-space separated list from the source array. If no characters
  10782. * are provided between the brackets, the original array source is
  10783. * returned.
  10784. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10785. * execute a function of the name given. For example: `browser()` for a
  10786. * simple function on the data source, `browser.version()` for a
  10787. * function in a nested property or even `browser().version` to get an
  10788. * object property if the function called returns an object. Note that
  10789. * function notation is recommended for use in `render` rather than
  10790. * `data` as it is much simpler to use as a renderer.
  10791. * * `null` - use the original data source for the row rather than plucking
  10792. * data directly from it. This action has effects on two other
  10793. * initialisation options:
  10794. * * `defaultContent` - When null is given as the `data` option and
  10795. * `defaultContent` is specified for the column, the value defined by
  10796. * `defaultContent` will be used for the cell.
  10797. * * `render` - When null is used for the `data` option and the `render`
  10798. * option is specified for the column, the whole data source for the
  10799. * row is used for the renderer.
  10800. * * `function` - the function given will be executed whenever DataTables
  10801. * needs to set or get the data for a cell in the column. The function
  10802. * takes three parameters:
  10803. * * Parameters:
  10804. * * `{array|object}` The data source for the row
  10805. * * `{string}` The type call data requested - this will be 'set' when
  10806. * setting data or 'filter', 'display', 'type', 'sort' or undefined
  10807. * when gathering data. Note that when `undefined` is given for the
  10808. * type DataTables expects to get the raw data for the object back<
  10809. * * `{*}` Data to set when the second parameter is 'set'.
  10810. * * Return:
  10811. * * The return value from the function is not required when 'set' is
  10812. * the type of call, but otherwise the return is what will be used
  10813. * for the data requested.
  10814. *
  10815. * Note that `data` is a getter and setter option. If you just require
  10816. * formatting of data for output, you will likely want to use `render` which
  10817. * is simply a getter and thus simpler to use.
  10818. *
  10819. * Note that prior to DataTables 1.9.2 `data` was called `mDataProp`. The
  10820. * name change reflects the flexibility of this property and is consistent
  10821. * with the naming of mRender. If 'mDataProp' is given, then it will still
  10822. * be used by DataTables, as it automatically maps the old name to the new
  10823. * if required.
  10824. *
  10825. * @type string|int|function|null
  10826. * @default null <i>Use automatically calculated column index</i>
  10827. *
  10828. * @name DataTable.defaults.column.data
  10829. * @dtopt Columns
  10830. *
  10831. * @example
  10832. * // Read table data from objects
  10833. * // JSON structure for each row:
  10834. * // {
  10835. * // "engine": {value},
  10836. * // "browser": {value},
  10837. * // "platform": {value},
  10838. * // "version": {value},
  10839. * // "grade": {value}
  10840. * // }
  10841. * $(document).ready( function() {
  10842. * $('#example').dataTable( {
  10843. * "ajaxSource": "sources/objects.txt",
  10844. * "columns": [
  10845. * { "data": "engine" },
  10846. * { "data": "browser" },
  10847. * { "data": "platform" },
  10848. * { "data": "version" },
  10849. * { "data": "grade" }
  10850. * ]
  10851. * } );
  10852. * } );
  10853. *
  10854. * @example
  10855. * // Read information from deeply nested objects
  10856. * // JSON structure for each row:
  10857. * // {
  10858. * // "engine": {value},
  10859. * // "browser": {value},
  10860. * // "platform": {
  10861. * // "inner": {value}
  10862. * // },
  10863. * // "details": [
  10864. * // {value}, {value}
  10865. * // ]
  10866. * // }
  10867. * $(document).ready( function() {
  10868. * $('#example').dataTable( {
  10869. * "ajaxSource": "sources/deep.txt",
  10870. * "columns": [
  10871. * { "data": "engine" },
  10872. * { "data": "browser" },
  10873. * { "data": "platform.inner" },
  10874. * { "data": "details.0" },
  10875. * { "data": "details.1" }
  10876. * ]
  10877. * } );
  10878. * } );
  10879. *
  10880. * @example
  10881. * // Using `data` as a function to provide different information for
  10882. * // sorting, filtering and display. In this case, currency (price)
  10883. * $(document).ready( function() {
  10884. * $('#example').dataTable( {
  10885. * "columnDefs": [ {
  10886. * "targets": [ 0 ],
  10887. * "data": function ( source, type, val ) {
  10888. * if (type === 'set') {
  10889. * source.price = val;
  10890. * // Store the computed display and filter values for efficiency
  10891. * source.price_display = val=="" ? "" : "$"+numberFormat(val);
  10892. * source.price_filter = val=="" ? "" : "$"+numberFormat(val)+" "+val;
  10893. * return;
  10894. * }
  10895. * else if (type === 'display') {
  10896. * return source.price_display;
  10897. * }
  10898. * else if (type === 'filter') {
  10899. * return source.price_filter;
  10900. * }
  10901. * // 'sort', 'type' and undefined all just use the integer
  10902. * return source.price;
  10903. * }
  10904. * } ]
  10905. * } );
  10906. * } );
  10907. *
  10908. * @example
  10909. * // Using default content
  10910. * $(document).ready( function() {
  10911. * $('#example').dataTable( {
  10912. * "columnDefs": [ {
  10913. * "targets": [ 0 ],
  10914. * "data": null,
  10915. * "defaultContent": "Click to edit"
  10916. * } ]
  10917. * } );
  10918. * } );
  10919. *
  10920. * @example
  10921. * // Using array notation - outputting a list from an array
  10922. * $(document).ready( function() {
  10923. * $('#example').dataTable( {
  10924. * "columnDefs": [ {
  10925. * "targets": [ 0 ],
  10926. * "data": "name[, ]"
  10927. * } ]
  10928. * } );
  10929. * } );
  10930. *
  10931. */
  10932. "mData": null,
  10933. /**
  10934. * This property is the rendering partner to `data` and it is suggested that
  10935. * when you want to manipulate data for display (including filtering,
  10936. * sorting etc) without altering the underlying data for the table, use this
  10937. * property. `render` can be considered to be the the read only companion to
  10938. * `data` which is read / write (then as such more complex). Like `data`
  10939. * this option can be given in a number of different ways to effect its
  10940. * behaviour:
  10941. *
  10942. * * `integer` - treated as an array index for the data source. This is the
  10943. * default that DataTables uses (incrementally increased for each column).
  10944. * * `string` - read an object property from the data source. There are
  10945. * three 'special' options that can be used in the string to alter how
  10946. * DataTables reads the data from the source object:
  10947. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10948. * Javascript to read from nested objects, so to can the options
  10949. * specified in `data`. For example: `browser.version` or
  10950. * `browser.name`. If your object parameter name contains a period, use
  10951. * `\\` to escape it - i.e. `first\\.name`.
  10952. * * `[]` - Array notation. DataTables can automatically combine data
  10953. * from and array source, joining the data with the characters provided
  10954. * between the two brackets. For example: `name[, ]` would provide a
  10955. * comma-space separated list from the source array. If no characters
  10956. * are provided between the brackets, the original array source is
  10957. * returned.
  10958. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10959. * execute a function of the name given. For example: `browser()` for a
  10960. * simple function on the data source, `browser.version()` for a
  10961. * function in a nested property or even `browser().version` to get an
  10962. * object property if the function called returns an object.
  10963. * * `object` - use different data for the different data types requested by
  10964. * DataTables ('filter', 'display', 'type' or 'sort'). The property names
  10965. * of the object is the data type the property refers to and the value can
  10966. * defined using an integer, string or function using the same rules as
  10967. * `render` normally does. Note that an `_` option _must_ be specified.
  10968. * This is the default value to use if you haven't specified a value for
  10969. * the data type requested by DataTables.
  10970. * * `function` - the function given will be executed whenever DataTables
  10971. * needs to set or get the data for a cell in the column. The function
  10972. * takes three parameters:
  10973. * * Parameters:
  10974. * * {array|object} The data source for the row (based on `data`)
  10975. * * {string} The type call data requested - this will be 'filter',
  10976. * 'display', 'type' or 'sort'.
  10977. * * {array|object} The full data source for the row (not based on
  10978. * `data`)
  10979. * * Return:
  10980. * * The return value from the function is what will be used for the
  10981. * data requested.
  10982. *
  10983. * @type string|int|function|object|null
  10984. * @default null Use the data source value.
  10985. *
  10986. * @name DataTable.defaults.column.render
  10987. * @dtopt Columns
  10988. *
  10989. * @example
  10990. * // Create a comma separated list from an array of objects
  10991. * $(document).ready( function() {
  10992. * $('#example').dataTable( {
  10993. * "ajaxSource": "sources/deep.txt",
  10994. * "columns": [
  10995. * { "data": "engine" },
  10996. * { "data": "browser" },
  10997. * {
  10998. * "data": "platform",
  10999. * "render": "[, ].name"
  11000. * }
  11001. * ]
  11002. * } );
  11003. * } );
  11004. *
  11005. * @example
  11006. * // Execute a function to obtain data
  11007. * $(document).ready( function() {
  11008. * $('#example').dataTable( {
  11009. * "columnDefs": [ {
  11010. * "targets": [ 0 ],
  11011. * "data": null, // Use the full data source object for the renderer's source
  11012. * "render": "browserName()"
  11013. * } ]
  11014. * } );
  11015. * } );
  11016. *
  11017. * @example
  11018. * // As an object, extracting different data for the different types
  11019. * // This would be used with a data source such as:
  11020. * // { "phone": 5552368, "phone_filter": "5552368 555-2368", "phone_display": "555-2368" }
  11021. * // Here the `phone` integer is used for sorting and type detection, while `phone_filter`
  11022. * // (which has both forms) is used for filtering for if a user inputs either format, while
  11023. * // the formatted phone number is the one that is shown in the table.
  11024. * $(document).ready( function() {
  11025. * $('#example').dataTable( {
  11026. * "columnDefs": [ {
  11027. * "targets": [ 0 ],
  11028. * "data": null, // Use the full data source object for the renderer's source
  11029. * "render": {
  11030. * "_": "phone",
  11031. * "filter": "phone_filter",
  11032. * "display": "phone_display"
  11033. * }
  11034. * } ]
  11035. * } );
  11036. * } );
  11037. *
  11038. * @example
  11039. * // Use as a function to create a link from the data source
  11040. * $(document).ready( function() {
  11041. * $('#example').dataTable( {
  11042. * "columnDefs": [ {
  11043. * "targets": [ 0 ],
  11044. * "data": "download_link",
  11045. * "render": function ( data, type, full ) {
  11046. * return '<a href="'+data+'">Download</a>';
  11047. * }
  11048. * } ]
  11049. * } );
  11050. * } );
  11051. */
  11052. "mRender": null,
  11053. /**
  11054. * Change the cell type created for the column - either TD cells or TH cells. This
  11055. * can be useful as TH cells have semantic meaning in the table body, allowing them
  11056. * to act as a header for a row (you may wish to add scope='row' to the TH elements).
  11057. * @type string
  11058. * @default td
  11059. *
  11060. * @name DataTable.defaults.column.cellType
  11061. * @dtopt Columns
  11062. *
  11063. * @example
  11064. * // Make the first column use TH cells
  11065. * $(document).ready( function() {
  11066. * $('#example').dataTable( {
  11067. * "columnDefs": [ {
  11068. * "targets": [ 0 ],
  11069. * "cellType": "th"
  11070. * } ]
  11071. * } );
  11072. * } );
  11073. */
  11074. "sCellType": "td",
  11075. /**
  11076. * Class to give to each cell in this column.
  11077. * @type string
  11078. * @default <i>Empty string</i>
  11079. *
  11080. * @name DataTable.defaults.column.class
  11081. * @dtopt Columns
  11082. *
  11083. * @example
  11084. * // Using `columnDefs`
  11085. * $(document).ready( function() {
  11086. * $('#example').dataTable( {
  11087. * "columnDefs": [
  11088. * { "class": "my_class", "targets": [ 0 ] }
  11089. * ]
  11090. * } );
  11091. * } );
  11092. *
  11093. * @example
  11094. * // Using `columns`
  11095. * $(document).ready( function() {
  11096. * $('#example').dataTable( {
  11097. * "columns": [
  11098. * { "class": "my_class" },
  11099. * null,
  11100. * null,
  11101. * null,
  11102. * null
  11103. * ]
  11104. * } );
  11105. * } );
  11106. */
  11107. "sClass": "",
  11108. /**
  11109. * When DataTables calculates the column widths to assign to each column,
  11110. * it finds the longest string in each column and then constructs a
  11111. * temporary table and reads the widths from that. The problem with this
  11112. * is that "mmm" is much wider then "iiii", but the latter is a longer
  11113. * string - thus the calculation can go wrong (doing it properly and putting
  11114. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  11115. * a "work around" we provide this option. It will append its value to the
  11116. * text that is found to be the longest string for the column - i.e. padding.
  11117. * Generally you shouldn't need this!
  11118. * @type string
  11119. * @default <i>Empty string<i>
  11120. *
  11121. * @name DataTable.defaults.column.contentPadding
  11122. * @dtopt Columns
  11123. *
  11124. * @example
  11125. * // Using `columns`
  11126. * $(document).ready( function() {
  11127. * $('#example').dataTable( {
  11128. * "columns": [
  11129. * null,
  11130. * null,
  11131. * null,
  11132. * {
  11133. * "contentPadding": "mmm"
  11134. * }
  11135. * ]
  11136. * } );
  11137. * } );
  11138. */
  11139. "sContentPadding": "",
  11140. /**
  11141. * Allows a default value to be given for a column's data, and will be used
  11142. * whenever a null data source is encountered (this can be because `data`
  11143. * is set to null, or because the data source itself is null).
  11144. * @type string
  11145. * @default null
  11146. *
  11147. * @name DataTable.defaults.column.defaultContent
  11148. * @dtopt Columns
  11149. *
  11150. * @example
  11151. * // Using `columnDefs`
  11152. * $(document).ready( function() {
  11153. * $('#example').dataTable( {
  11154. * "columnDefs": [
  11155. * {
  11156. * "data": null,
  11157. * "defaultContent": "Edit",
  11158. * "targets": [ -1 ]
  11159. * }
  11160. * ]
  11161. * } );
  11162. * } );
  11163. *
  11164. * @example
  11165. * // Using `columns`
  11166. * $(document).ready( function() {
  11167. * $('#example').dataTable( {
  11168. * "columns": [
  11169. * null,
  11170. * null,
  11171. * null,
  11172. * {
  11173. * "data": null,
  11174. * "defaultContent": "Edit"
  11175. * }
  11176. * ]
  11177. * } );
  11178. * } );
  11179. */
  11180. "sDefaultContent": null,
  11181. /**
  11182. * This parameter is only used in DataTables' server-side processing. It can
  11183. * be exceptionally useful to know what columns are being displayed on the
  11184. * client side, and to map these to database fields. When defined, the names
  11185. * also allow DataTables to reorder information from the server if it comes
  11186. * back in an unexpected order (i.e. if you switch your columns around on the
  11187. * client-side, your server-side code does not also need updating).
  11188. * @type string
  11189. * @default <i>Empty string</i>
  11190. *
  11191. * @name DataTable.defaults.column.name
  11192. * @dtopt Columns
  11193. *
  11194. * @example
  11195. * // Using `columnDefs`
  11196. * $(document).ready( function() {
  11197. * $('#example').dataTable( {
  11198. * "columnDefs": [
  11199. * { "name": "engine", "targets": [ 0 ] },
  11200. * { "name": "browser", "targets": [ 1 ] },
  11201. * { "name": "platform", "targets": [ 2 ] },
  11202. * { "name": "version", "targets": [ 3 ] },
  11203. * { "name": "grade", "targets": [ 4 ] }
  11204. * ]
  11205. * } );
  11206. * } );
  11207. *
  11208. * @example
  11209. * // Using `columns`
  11210. * $(document).ready( function() {
  11211. * $('#example').dataTable( {
  11212. * "columns": [
  11213. * { "name": "engine" },
  11214. * { "name": "browser" },
  11215. * { "name": "platform" },
  11216. * { "name": "version" },
  11217. * { "name": "grade" }
  11218. * ]
  11219. * } );
  11220. * } );
  11221. */
  11222. "sName": "",
  11223. /**
  11224. * Defines a data source type for the ordering which can be used to read
  11225. * real-time information from the table (updating the internally cached
  11226. * version) prior to ordering. This allows ordering to occur on user
  11227. * editable elements such as form inputs.
  11228. * @type string
  11229. * @default std
  11230. *
  11231. * @name DataTable.defaults.column.orderDataType
  11232. * @dtopt Columns
  11233. *
  11234. * @example
  11235. * // Using `columnDefs`
  11236. * $(document).ready( function() {
  11237. * $('#example').dataTable( {
  11238. * "columnDefs": [
  11239. * { "orderDataType": "dom-text", "targets": [ 2, 3 ] },
  11240. * { "type": "numeric", "targets": [ 3 ] },
  11241. * { "orderDataType": "dom-select", "targets": [ 4 ] },
  11242. * { "orderDataType": "dom-checkbox", "targets": [ 5 ] }
  11243. * ]
  11244. * } );
  11245. * } );
  11246. *
  11247. * @example
  11248. * // Using `columns`
  11249. * $(document).ready( function() {
  11250. * $('#example').dataTable( {
  11251. * "columns": [
  11252. * null,
  11253. * null,
  11254. * { "orderDataType": "dom-text" },
  11255. * { "orderDataType": "dom-text", "type": "numeric" },
  11256. * { "orderDataType": "dom-select" },
  11257. * { "orderDataType": "dom-checkbox" }
  11258. * ]
  11259. * } );
  11260. * } );
  11261. */
  11262. "sSortDataType": "std",
  11263. /**
  11264. * The title of this column.
  11265. * @type string
  11266. * @default null <i>Derived from the 'TH' value for this column in the
  11267. * original HTML table.</i>
  11268. *
  11269. * @name DataTable.defaults.column.title
  11270. * @dtopt Columns
  11271. *
  11272. * @example
  11273. * // Using `columnDefs`
  11274. * $(document).ready( function() {
  11275. * $('#example').dataTable( {
  11276. * "columnDefs": [
  11277. * { "title": "My column title", "targets": [ 0 ] }
  11278. * ]
  11279. * } );
  11280. * } );
  11281. *
  11282. * @example
  11283. * // Using `columns`
  11284. * $(document).ready( function() {
  11285. * $('#example').dataTable( {
  11286. * "columns": [
  11287. * { "title": "My column title" },
  11288. * null,
  11289. * null,
  11290. * null,
  11291. * null
  11292. * ]
  11293. * } );
  11294. * } );
  11295. */
  11296. "sTitle": null,
  11297. /**
  11298. * The type allows you to specify how the data for this column will be
  11299. * ordered. Four types (string, numeric, date and html (which will strip
  11300. * HTML tags before ordering)) are currently available. Note that only date
  11301. * formats understood by Javascript's Date() object will be accepted as type
  11302. * date. For example: "Mar 26, 2008 5:03 PM". May take the values: 'string',
  11303. * 'numeric', 'date' or 'html' (by default). Further types can be adding
  11304. * through plug-ins.
  11305. * @type string
  11306. * @default null <i>Auto-detected from raw data</i>
  11307. *
  11308. * @name DataTable.defaults.column.type
  11309. * @dtopt Columns
  11310. *
  11311. * @example
  11312. * // Using `columnDefs`
  11313. * $(document).ready( function() {
  11314. * $('#example').dataTable( {
  11315. * "columnDefs": [
  11316. * { "type": "html", "targets": [ 0 ] }
  11317. * ]
  11318. * } );
  11319. * } );
  11320. *
  11321. * @example
  11322. * // Using `columns`
  11323. * $(document).ready( function() {
  11324. * $('#example').dataTable( {
  11325. * "columns": [
  11326. * { "type": "html" },
  11327. * null,
  11328. * null,
  11329. * null,
  11330. * null
  11331. * ]
  11332. * } );
  11333. * } );
  11334. */
  11335. "sType": null,
  11336. /**
  11337. * Defining the width of the column, this parameter may take any CSS value
  11338. * (3em, 20px etc). DataTables applies 'smart' widths to columns which have not
  11339. * been given a specific width through this interface ensuring that the table
  11340. * remains readable.
  11341. * @type string
  11342. * @default null <i>Automatic</i>
  11343. *
  11344. * @name DataTable.defaults.column.width
  11345. * @dtopt Columns
  11346. *
  11347. * @example
  11348. * // Using `columnDefs`
  11349. * $(document).ready( function() {
  11350. * $('#example').dataTable( {
  11351. * "columnDefs": [
  11352. * { "width": "20%", "targets": [ 0 ] }
  11353. * ]
  11354. * } );
  11355. * } );
  11356. *
  11357. * @example
  11358. * // Using `columns`
  11359. * $(document).ready( function() {
  11360. * $('#example').dataTable( {
  11361. * "columns": [
  11362. * { "width": "20%" },
  11363. * null,
  11364. * null,
  11365. * null,
  11366. * null
  11367. * ]
  11368. * } );
  11369. * } );
  11370. */
  11371. "sWidth": null
  11372. };
  11373. _fnHungarianMap( DataTable.defaults.column );
  11374. /**
  11375. * DataTables settings object - this holds all the information needed for a
  11376. * given table, including configuration, data and current application of the
  11377. * table options. DataTables does not have a single instance for each DataTable
  11378. * with the settings attached to that instance, but rather instances of the
  11379. * DataTable "class" are created on-the-fly as needed (typically by a
  11380. * $().dataTable() call) and the settings object is then applied to that
  11381. * instance.
  11382. *
  11383. * Note that this object is related to {@link DataTable.defaults} but this
  11384. * one is the internal data store for DataTables's cache of columns. It should
  11385. * NOT be manipulated outside of DataTables. Any configuration should be done
  11386. * through the initialisation options.
  11387. * @namespace
  11388. * @todo Really should attach the settings object to individual instances so we
  11389. * don't need to create new instances on each $().dataTable() call (if the
  11390. * table already exists). It would also save passing oSettings around and
  11391. * into every single function. However, this is a very significant
  11392. * architecture change for DataTables and will almost certainly break
  11393. * backwards compatibility with older installations. This is something that
  11394. * will be done in 2.0.
  11395. */
  11396. DataTable.models.oSettings = {
  11397. /**
  11398. * Primary features of DataTables and their enablement state.
  11399. * @namespace
  11400. */
  11401. "oFeatures": {
  11402. /**
  11403. * Flag to say if DataTables should automatically try to calculate the
  11404. * optimum table and columns widths (true) or not (false).
  11405. * Note that this parameter will be set by the initialisation routine. To
  11406. * set a default use {@link DataTable.defaults}.
  11407. * @type boolean
  11408. */
  11409. "bAutoWidth": null,
  11410. /**
  11411. * Delay the creation of TR and TD elements until they are actually
  11412. * needed by a driven page draw. This can give a significant speed
  11413. * increase for Ajax source and Javascript source data, but makes no
  11414. * difference at all for DOM and server-side processing tables.
  11415. * Note that this parameter will be set by the initialisation routine. To
  11416. * set a default use {@link DataTable.defaults}.
  11417. * @type boolean
  11418. */
  11419. "bDeferRender": null,
  11420. /**
  11421. * Enable filtering on the table or not. Note that if this is disabled
  11422. * then there is no filtering at all on the table, including fnFilter.
  11423. * To just remove the filtering input use sDom and remove the 'f' option.
  11424. * Note that this parameter will be set by the initialisation routine. To
  11425. * set a default use {@link DataTable.defaults}.
  11426. * @type boolean
  11427. */
  11428. "bFilter": null,
  11429. /**
  11430. * Table information element (the 'Showing x of y records' div) enable
  11431. * flag.
  11432. * Note that this parameter will be set by the initialisation routine. To
  11433. * set a default use {@link DataTable.defaults}.
  11434. * @type boolean
  11435. */
  11436. "bInfo": null,
  11437. /**
  11438. * Present a user control allowing the end user to change the page size
  11439. * when pagination is enabled.
  11440. * Note that this parameter will be set by the initialisation routine. To
  11441. * set a default use {@link DataTable.defaults}.
  11442. * @type boolean
  11443. */
  11444. "bLengthChange": null,
  11445. /**
  11446. * Pagination enabled or not. Note that if this is disabled then length
  11447. * changing must also be disabled.
  11448. * Note that this parameter will be set by the initialisation routine. To
  11449. * set a default use {@link DataTable.defaults}.
  11450. * @type boolean
  11451. */
  11452. "bPaginate": null,
  11453. /**
  11454. * Processing indicator enable flag whenever DataTables is enacting a
  11455. * user request - typically an Ajax request for server-side processing.
  11456. * Note that this parameter will be set by the initialisation routine. To
  11457. * set a default use {@link DataTable.defaults}.
  11458. * @type boolean
  11459. */
  11460. "bProcessing": null,
  11461. /**
  11462. * Server-side processing enabled flag - when enabled DataTables will
  11463. * get all data from the server for every draw - there is no filtering,
  11464. * sorting or paging done on the client-side.
  11465. * Note that this parameter will be set by the initialisation routine. To
  11466. * set a default use {@link DataTable.defaults}.
  11467. * @type boolean
  11468. */
  11469. "bServerSide": null,
  11470. /**
  11471. * Sorting enablement flag.
  11472. * Note that this parameter will be set by the initialisation routine. To
  11473. * set a default use {@link DataTable.defaults}.
  11474. * @type boolean
  11475. */
  11476. "bSort": null,
  11477. /**
  11478. * Multi-column sorting
  11479. * Note that this parameter will be set by the initialisation routine. To
  11480. * set a default use {@link DataTable.defaults}.
  11481. * @type boolean
  11482. */
  11483. "bSortMulti": null,
  11484. /**
  11485. * Apply a class to the columns which are being sorted to provide a
  11486. * visual highlight or not. This can slow things down when enabled since
  11487. * there is a lot of DOM interaction.
  11488. * Note that this parameter will be set by the initialisation routine. To
  11489. * set a default use {@link DataTable.defaults}.
  11490. * @type boolean
  11491. */
  11492. "bSortClasses": null,
  11493. /**
  11494. * State saving enablement flag.
  11495. * Note that this parameter will be set by the initialisation routine. To
  11496. * set a default use {@link DataTable.defaults}.
  11497. * @type boolean
  11498. */
  11499. "bStateSave": null
  11500. },
  11501. /**
  11502. * Scrolling settings for a table.
  11503. * @namespace
  11504. */
  11505. "oScroll": {
  11506. /**
  11507. * When the table is shorter in height than sScrollY, collapse the
  11508. * table container down to the height of the table (when true).
  11509. * Note that this parameter will be set by the initialisation routine. To
  11510. * set a default use {@link DataTable.defaults}.
  11511. * @type boolean
  11512. */
  11513. "bCollapse": null,
  11514. /**
  11515. * Width of the scrollbar for the web-browser's platform. Calculated
  11516. * during table initialisation.
  11517. * @type int
  11518. * @default 0
  11519. */
  11520. "iBarWidth": 0,
  11521. /**
  11522. * Viewport width for horizontal scrolling. Horizontal scrolling is
  11523. * disabled if an empty string.
  11524. * Note that this parameter will be set by the initialisation routine. To
  11525. * set a default use {@link DataTable.defaults}.
  11526. * @type string
  11527. */
  11528. "sX": null,
  11529. /**
  11530. * Width to expand the table to when using x-scrolling. Typically you
  11531. * should not need to use this.
  11532. * Note that this parameter will be set by the initialisation routine. To
  11533. * set a default use {@link DataTable.defaults}.
  11534. * @type string
  11535. * @deprecated
  11536. */
  11537. "sXInner": null,
  11538. /**
  11539. * Viewport height for vertical scrolling. Vertical scrolling is disabled
  11540. * if an empty string.
  11541. * Note that this parameter will be set by the initialisation routine. To
  11542. * set a default use {@link DataTable.defaults}.
  11543. * @type string
  11544. */
  11545. "sY": null
  11546. },
  11547. /**
  11548. * Language information for the table.
  11549. * @namespace
  11550. * @extends DataTable.defaults.oLanguage
  11551. */
  11552. "oLanguage": {
  11553. /**
  11554. * Information callback function. See
  11555. * {@link DataTable.defaults.fnInfoCallback}
  11556. * @type function
  11557. * @default null
  11558. */
  11559. "fnInfoCallback": null
  11560. },
  11561. /**
  11562. * Browser support parameters
  11563. * @namespace
  11564. */
  11565. "oBrowser": {
  11566. /**
  11567. * Indicate if the browser incorrectly calculates width:100% inside a
  11568. * scrolling element (IE6/7)
  11569. * @type boolean
  11570. * @default false
  11571. */
  11572. "bScrollOversize": false,
  11573. /**
  11574. * Determine if the vertical scrollbar is on the right or left of the
  11575. * scrolling container - needed for rtl language layout, although not
  11576. * all browsers move the scrollbar (Safari).
  11577. * @type boolean
  11578. * @default false
  11579. */
  11580. "bScrollbarLeft": false,
  11581. /**
  11582. * Flag for if `getBoundingClientRect` is fully supported or not
  11583. * @type boolean
  11584. * @default false
  11585. */
  11586. "bBounding": false,
  11587. /**
  11588. * Browser scrollbar width
  11589. * @type integer
  11590. * @default 0
  11591. */
  11592. "barWidth": 0
  11593. },
  11594. "ajax": null,
  11595. /**
  11596. * Array referencing the nodes which are used for the features. The
  11597. * parameters of this object match what is allowed by sDom - i.e.
  11598. * <ul>
  11599. * <li>'l' - Length changing</li>
  11600. * <li>'f' - Filtering input</li>
  11601. * <li>'t' - The table!</li>
  11602. * <li>'i' - Information</li>
  11603. * <li>'p' - Pagination</li>
  11604. * <li>'r' - pRocessing</li>
  11605. * </ul>
  11606. * @type array
  11607. * @default []
  11608. */
  11609. "aanFeatures": [],
  11610. /**
  11611. * Store data information - see {@link DataTable.models.oRow} for detailed
  11612. * information.
  11613. * @type array
  11614. * @default []
  11615. */
  11616. "aoData": [],
  11617. /**
  11618. * Array of indexes which are in the current display (after filtering etc)
  11619. * @type array
  11620. * @default []
  11621. */
  11622. "aiDisplay": [],
  11623. /**
  11624. * Array of indexes for display - no filtering
  11625. * @type array
  11626. * @default []
  11627. */
  11628. "aiDisplayMaster": [],
  11629. /**
  11630. * Map of row ids to data indexes
  11631. * @type object
  11632. * @default {}
  11633. */
  11634. "aIds": {},
  11635. /**
  11636. * Store information about each column that is in use
  11637. * @type array
  11638. * @default []
  11639. */
  11640. "aoColumns": [],
  11641. /**
  11642. * Store information about the table's header
  11643. * @type array
  11644. * @default []
  11645. */
  11646. "aoHeader": [],
  11647. /**
  11648. * Store information about the table's footer
  11649. * @type array
  11650. * @default []
  11651. */
  11652. "aoFooter": [],
  11653. /**
  11654. * Store the applied global search information in case we want to force a
  11655. * research or compare the old search to a new one.
  11656. * Note that this parameter will be set by the initialisation routine. To
  11657. * set a default use {@link DataTable.defaults}.
  11658. * @namespace
  11659. * @extends DataTable.models.oSearch
  11660. */
  11661. "oPreviousSearch": {},
  11662. /**
  11663. * Store the applied search for each column - see
  11664. * {@link DataTable.models.oSearch} for the format that is used for the
  11665. * filtering information for each column.
  11666. * @type array
  11667. * @default []
  11668. */
  11669. "aoPreSearchCols": [],
  11670. /**
  11671. * Sorting that is applied to the table. Note that the inner arrays are
  11672. * used in the following manner:
  11673. * <ul>
  11674. * <li>Index 0 - column number</li>
  11675. * <li>Index 1 - current sorting direction</li>
  11676. * </ul>
  11677. * Note that this parameter will be set by the initialisation routine. To
  11678. * set a default use {@link DataTable.defaults}.
  11679. * @type array
  11680. * @todo These inner arrays should really be objects
  11681. */
  11682. "aaSorting": null,
  11683. /**
  11684. * Sorting that is always applied to the table (i.e. prefixed in front of
  11685. * aaSorting).
  11686. * Note that this parameter will be set by the initialisation routine. To
  11687. * set a default use {@link DataTable.defaults}.
  11688. * @type array
  11689. * @default []
  11690. */
  11691. "aaSortingFixed": [],
  11692. /**
  11693. * Classes to use for the striping of a table.
  11694. * Note that this parameter will be set by the initialisation routine. To
  11695. * set a default use {@link DataTable.defaults}.
  11696. * @type array
  11697. * @default []
  11698. */
  11699. "asStripeClasses": null,
  11700. /**
  11701. * If restoring a table - we should restore its striping classes as well
  11702. * @type array
  11703. * @default []
  11704. */
  11705. "asDestroyStripes": [],
  11706. /**
  11707. * If restoring a table - we should restore its width
  11708. * @type int
  11709. * @default 0
  11710. */
  11711. "sDestroyWidth": 0,
  11712. /**
  11713. * Callback functions array for every time a row is inserted (i.e. on a draw).
  11714. * @type array
  11715. * @default []
  11716. */
  11717. "aoRowCallback": [],
  11718. /**
  11719. * Callback functions for the header on each draw.
  11720. * @type array
  11721. * @default []
  11722. */
  11723. "aoHeaderCallback": [],
  11724. /**
  11725. * Callback function for the footer on each draw.
  11726. * @type array
  11727. * @default []
  11728. */
  11729. "aoFooterCallback": [],
  11730. /**
  11731. * Array of callback functions for draw callback functions
  11732. * @type array
  11733. * @default []
  11734. */
  11735. "aoDrawCallback": [],
  11736. /**
  11737. * Array of callback functions for row created function
  11738. * @type array
  11739. * @default []
  11740. */
  11741. "aoRowCreatedCallback": [],
  11742. /**
  11743. * Callback functions for just before the table is redrawn. A return of
  11744. * false will be used to cancel the draw.
  11745. * @type array
  11746. * @default []
  11747. */
  11748. "aoPreDrawCallback": [],
  11749. /**
  11750. * Callback functions for when the table has been initialised.
  11751. * @type array
  11752. * @default []
  11753. */
  11754. "aoInitComplete": [],
  11755. /**
  11756. * Callbacks for modifying the settings to be stored for state saving, prior to
  11757. * saving state.
  11758. * @type array
  11759. * @default []
  11760. */
  11761. "aoStateSaveParams": [],
  11762. /**
  11763. * Callbacks for modifying the settings that have been stored for state saving
  11764. * prior to using the stored values to restore the state.
  11765. * @type array
  11766. * @default []
  11767. */
  11768. "aoStateLoadParams": [],
  11769. /**
  11770. * Callbacks for operating on the settings object once the saved state has been
  11771. * loaded
  11772. * @type array
  11773. * @default []
  11774. */
  11775. "aoStateLoaded": [],
  11776. /**
  11777. * Cache the table ID for quick access
  11778. * @type string
  11779. * @default <i>Empty string</i>
  11780. */
  11781. "sTableId": "",
  11782. /**
  11783. * The TABLE node for the main table
  11784. * @type node
  11785. * @default null
  11786. */
  11787. "nTable": null,
  11788. /**
  11789. * Permanent ref to the thead element
  11790. * @type node
  11791. * @default null
  11792. */
  11793. "nTHead": null,
  11794. /**
  11795. * Permanent ref to the tfoot element - if it exists
  11796. * @type node
  11797. * @default null
  11798. */
  11799. "nTFoot": null,
  11800. /**
  11801. * Permanent ref to the tbody element
  11802. * @type node
  11803. * @default null
  11804. */
  11805. "nTBody": null,
  11806. /**
  11807. * Cache the wrapper node (contains all DataTables controlled elements)
  11808. * @type node
  11809. * @default null
  11810. */
  11811. "nTableWrapper": null,
  11812. /**
  11813. * Indicate if when using server-side processing the loading of data
  11814. * should be deferred until the second draw.
  11815. * Note that this parameter will be set by the initialisation routine. To
  11816. * set a default use {@link DataTable.defaults}.
  11817. * @type boolean
  11818. * @default false
  11819. */
  11820. "bDeferLoading": false,
  11821. /**
  11822. * Indicate if all required information has been read in
  11823. * @type boolean
  11824. * @default false
  11825. */
  11826. "bInitialised": false,
  11827. /**
  11828. * Information about open rows. Each object in the array has the parameters
  11829. * 'nTr' and 'nParent'
  11830. * @type array
  11831. * @default []
  11832. */
  11833. "aoOpenRows": [],
  11834. /**
  11835. * Dictate the positioning of DataTables' control elements - see
  11836. * {@link DataTable.model.oInit.sDom}.
  11837. * Note that this parameter will be set by the initialisation routine. To
  11838. * set a default use {@link DataTable.defaults}.
  11839. * @type string
  11840. * @default null
  11841. */
  11842. "sDom": null,
  11843. /**
  11844. * Search delay (in mS)
  11845. * @type integer
  11846. * @default null
  11847. */
  11848. "searchDelay": null,
  11849. /**
  11850. * Which type of pagination should be used.
  11851. * Note that this parameter will be set by the initialisation routine. To
  11852. * set a default use {@link DataTable.defaults}.
  11853. * @type string
  11854. * @default two_button
  11855. */
  11856. "sPaginationType": "two_button",
  11857. /**
  11858. * The state duration (for `stateSave`) in seconds.
  11859. * Note that this parameter will be set by the initialisation routine. To
  11860. * set a default use {@link DataTable.defaults}.
  11861. * @type int
  11862. * @default 0
  11863. */
  11864. "iStateDuration": 0,
  11865. /**
  11866. * Array of callback functions for state saving. Each array element is an
  11867. * object with the following parameters:
  11868. * <ul>
  11869. * <li>function:fn - function to call. Takes two parameters, oSettings
  11870. * and the JSON string to save that has been thus far created. Returns
  11871. * a JSON string to be inserted into a json object
  11872. * (i.e. '"param": [ 0, 1, 2]')</li>
  11873. * <li>string:sName - name of callback</li>
  11874. * </ul>
  11875. * @type array
  11876. * @default []
  11877. */
  11878. "aoStateSave": [],
  11879. /**
  11880. * Array of callback functions for state loading. Each array element is an
  11881. * object with the following parameters:
  11882. * <ul>
  11883. * <li>function:fn - function to call. Takes two parameters, oSettings
  11884. * and the object stored. May return false to cancel state loading</li>
  11885. * <li>string:sName - name of callback</li>
  11886. * </ul>
  11887. * @type array
  11888. * @default []
  11889. */
  11890. "aoStateLoad": [],
  11891. /**
  11892. * State that was saved. Useful for back reference
  11893. * @type object
  11894. * @default null
  11895. */
  11896. "oSavedState": null,
  11897. /**
  11898. * State that was loaded. Useful for back reference
  11899. * @type object
  11900. * @default null
  11901. */
  11902. "oLoadedState": null,
  11903. /**
  11904. * Source url for AJAX data for the table.
  11905. * Note that this parameter will be set by the initialisation routine. To
  11906. * set a default use {@link DataTable.defaults}.
  11907. * @type string
  11908. * @default null
  11909. */
  11910. "sAjaxSource": null,
  11911. /**
  11912. * Property from a given object from which to read the table data from. This
  11913. * can be an empty string (when not server-side processing), in which case
  11914. * it is assumed an an array is given directly.
  11915. * Note that this parameter will be set by the initialisation routine. To
  11916. * set a default use {@link DataTable.defaults}.
  11917. * @type string
  11918. */
  11919. "sAjaxDataProp": null,
  11920. /**
  11921. * The last jQuery XHR object that was used for server-side data gathering.
  11922. * This can be used for working with the XHR information in one of the
  11923. * callbacks
  11924. * @type object
  11925. * @default null
  11926. */
  11927. "jqXHR": null,
  11928. /**
  11929. * JSON returned from the server in the last Ajax request
  11930. * @type object
  11931. * @default undefined
  11932. */
  11933. "json": undefined,
  11934. /**
  11935. * Data submitted as part of the last Ajax request
  11936. * @type object
  11937. * @default undefined
  11938. */
  11939. "oAjaxData": undefined,
  11940. /**
  11941. * Function to get the server-side data.
  11942. * Note that this parameter will be set by the initialisation routine. To
  11943. * set a default use {@link DataTable.defaults}.
  11944. * @type function
  11945. */
  11946. "fnServerData": null,
  11947. /**
  11948. * Functions which are called prior to sending an Ajax request so extra
  11949. * parameters can easily be sent to the server
  11950. * @type array
  11951. * @default []
  11952. */
  11953. "aoServerParams": [],
  11954. /**
  11955. * Send the XHR HTTP method - GET or POST (could be PUT or DELETE if
  11956. * required).
  11957. * Note that this parameter will be set by the initialisation routine. To
  11958. * set a default use {@link DataTable.defaults}.
  11959. * @type string
  11960. */
  11961. "sServerMethod": null,
  11962. /**
  11963. * Format numbers for display.
  11964. * Note that this parameter will be set by the initialisation routine. To
  11965. * set a default use {@link DataTable.defaults}.
  11966. * @type function
  11967. */
  11968. "fnFormatNumber": null,
  11969. /**
  11970. * List of options that can be used for the user selectable length menu.
  11971. * Note that this parameter will be set by the initialisation routine. To
  11972. * set a default use {@link DataTable.defaults}.
  11973. * @type array
  11974. * @default []
  11975. */
  11976. "aLengthMenu": null,
  11977. /**
  11978. * Counter for the draws that the table does. Also used as a tracker for
  11979. * server-side processing
  11980. * @type int
  11981. * @default 0
  11982. */
  11983. "iDraw": 0,
  11984. /**
  11985. * Indicate if a redraw is being done - useful for Ajax
  11986. * @type boolean
  11987. * @default false
  11988. */
  11989. "bDrawing": false,
  11990. /**
  11991. * Draw index (iDraw) of the last error when parsing the returned data
  11992. * @type int
  11993. * @default -1
  11994. */
  11995. "iDrawError": -1,
  11996. /**
  11997. * Paging display length
  11998. * @type int
  11999. * @default 10
  12000. */
  12001. "_iDisplayLength": 10,
  12002. /**
  12003. * Paging start point - aiDisplay index
  12004. * @type int
  12005. * @default 0
  12006. */
  12007. "_iDisplayStart": 0,
  12008. /**
  12009. * Server-side processing - number of records in the result set
  12010. * (i.e. before filtering), Use fnRecordsTotal rather than
  12011. * this property to get the value of the number of records, regardless of
  12012. * the server-side processing setting.
  12013. * @type int
  12014. * @default 0
  12015. * @private
  12016. */
  12017. "_iRecordsTotal": 0,
  12018. /**
  12019. * Server-side processing - number of records in the current display set
  12020. * (i.e. after filtering). Use fnRecordsDisplay rather than
  12021. * this property to get the value of the number of records, regardless of
  12022. * the server-side processing setting.
  12023. * @type boolean
  12024. * @default 0
  12025. * @private
  12026. */
  12027. "_iRecordsDisplay": 0,
  12028. /**
  12029. * The classes to use for the table
  12030. * @type object
  12031. * @default {}
  12032. */
  12033. "oClasses": {},
  12034. /**
  12035. * Flag attached to the settings object so you can check in the draw
  12036. * callback if filtering has been done in the draw. Deprecated in favour of
  12037. * events.
  12038. * @type boolean
  12039. * @default false
  12040. * @deprecated
  12041. */
  12042. "bFiltered": false,
  12043. /**
  12044. * Flag attached to the settings object so you can check in the draw
  12045. * callback if sorting has been done in the draw. Deprecated in favour of
  12046. * events.
  12047. * @type boolean
  12048. * @default false
  12049. * @deprecated
  12050. */
  12051. "bSorted": false,
  12052. /**
  12053. * Indicate that if multiple rows are in the header and there is more than
  12054. * one unique cell per column, if the top one (true) or bottom one (false)
  12055. * should be used for sorting / title by DataTables.
  12056. * Note that this parameter will be set by the initialisation routine. To
  12057. * set a default use {@link DataTable.defaults}.
  12058. * @type boolean
  12059. */
  12060. "bSortCellsTop": null,
  12061. /**
  12062. * Initialisation object that is used for the table
  12063. * @type object
  12064. * @default null
  12065. */
  12066. "oInit": null,
  12067. /**
  12068. * Destroy callback functions - for plug-ins to attach themselves to the
  12069. * destroy so they can clean up markup and events.
  12070. * @type array
  12071. * @default []
  12072. */
  12073. "aoDestroyCallback": [],
  12074. /**
  12075. * Get the number of records in the current record set, before filtering
  12076. * @type function
  12077. */
  12078. "fnRecordsTotal": function ()
  12079. {
  12080. return _fnDataSource( this ) == 'ssp' ?
  12081. this._iRecordsTotal * 1 :
  12082. this.aiDisplayMaster.length;
  12083. },
  12084. /**
  12085. * Get the number of records in the current record set, after filtering
  12086. * @type function
  12087. */
  12088. "fnRecordsDisplay": function ()
  12089. {
  12090. return _fnDataSource( this ) == 'ssp' ?
  12091. this._iRecordsDisplay * 1 :
  12092. this.aiDisplay.length;
  12093. },
  12094. /**
  12095. * Get the display end point - aiDisplay index
  12096. * @type function
  12097. */
  12098. "fnDisplayEnd": function ()
  12099. {
  12100. var
  12101. len = this._iDisplayLength,
  12102. start = this._iDisplayStart,
  12103. calc = start + len,
  12104. records = this.aiDisplay.length,
  12105. features = this.oFeatures,
  12106. paginate = features.bPaginate;
  12107. if ( features.bServerSide ) {
  12108. return paginate === false || len === -1 ?
  12109. start + records :
  12110. Math.min( start+len, this._iRecordsDisplay );
  12111. }
  12112. else {
  12113. return ! paginate || calc>records || len===-1 ?
  12114. records :
  12115. calc;
  12116. }
  12117. },
  12118. /**
  12119. * The DataTables object for this table
  12120. * @type object
  12121. * @default null
  12122. */
  12123. "oInstance": null,
  12124. /**
  12125. * Unique identifier for each instance of the DataTables object. If there
  12126. * is an ID on the table node, then it takes that value, otherwise an
  12127. * incrementing internal counter is used.
  12128. * @type string
  12129. * @default null
  12130. */
  12131. "sInstance": null,
  12132. /**
  12133. * tabindex attribute value that is added to DataTables control elements, allowing
  12134. * keyboard navigation of the table and its controls.
  12135. */
  12136. "iTabIndex": 0,
  12137. /**
  12138. * DIV container for the footer scrolling table if scrolling
  12139. */
  12140. "nScrollHead": null,
  12141. /**
  12142. * DIV container for the footer scrolling table if scrolling
  12143. */
  12144. "nScrollFoot": null,
  12145. /**
  12146. * Last applied sort
  12147. * @type array
  12148. * @default []
  12149. */
  12150. "aLastSort": [],
  12151. /**
  12152. * Stored plug-in instances
  12153. * @type object
  12154. * @default {}
  12155. */
  12156. "oPlugins": {},
  12157. /**
  12158. * Function used to get a row's id from the row's data
  12159. * @type function
  12160. * @default null
  12161. */
  12162. "rowIdFn": null,
  12163. /**
  12164. * Data location where to store a row's id
  12165. * @type string
  12166. * @default null
  12167. */
  12168. "rowId": null
  12169. };
  12170. /**
  12171. * Extension object for DataTables that is used to provide all extension
  12172. * options.
  12173. *
  12174. * Note that the `DataTable.ext` object is available through
  12175. * `jQuery.fn.dataTable.ext` where it may be accessed and manipulated. It is
  12176. * also aliased to `jQuery.fn.dataTableExt` for historic reasons.
  12177. * @namespace
  12178. * @extends DataTable.models.ext
  12179. */
  12180. /**
  12181. * DataTables extensions
  12182. *
  12183. * This namespace acts as a collection area for plug-ins that can be used to
  12184. * extend DataTables capabilities. Indeed many of the build in methods
  12185. * use this method to provide their own capabilities (sorting methods for
  12186. * example).
  12187. *
  12188. * Note that this namespace is aliased to `jQuery.fn.dataTableExt` for legacy
  12189. * reasons
  12190. *
  12191. * @namespace
  12192. */
  12193. DataTable.ext = _ext = {
  12194. /**
  12195. * Buttons. For use with the Buttons extension for DataTables. This is
  12196. * defined here so other extensions can define buttons regardless of load
  12197. * order. It is _not_ used by DataTables core.
  12198. *
  12199. * @type object
  12200. * @default {}
  12201. */
  12202. buttons: {},
  12203. /**
  12204. * Element class names
  12205. *
  12206. * @type object
  12207. * @default {}
  12208. */
  12209. classes: {},
  12210. /**
  12211. * DataTables build type (expanded by the download builder)
  12212. *
  12213. * @type string
  12214. */
  12215. builder: "-source-",
  12216. /**
  12217. * Error reporting.
  12218. *
  12219. * How should DataTables report an error. Can take the value 'alert',
  12220. * 'throw', 'none' or a function.
  12221. *
  12222. * @type string|function
  12223. * @default alert
  12224. */
  12225. errMode: "alert",
  12226. /**
  12227. * Feature plug-ins.
  12228. *
  12229. * This is an array of objects which describe the feature plug-ins that are
  12230. * available to DataTables. These feature plug-ins are then available for
  12231. * use through the `dom` initialisation option.
  12232. *
  12233. * Each feature plug-in is described by an object which must have the
  12234. * following properties:
  12235. *
  12236. * * `fnInit` - function that is used to initialise the plug-in,
  12237. * * `cFeature` - a character so the feature can be enabled by the `dom`
  12238. * instillation option. This is case sensitive.
  12239. *
  12240. * The `fnInit` function has the following input parameters:
  12241. *
  12242. * 1. `{object}` DataTables settings object: see
  12243. * {@link DataTable.models.oSettings}
  12244. *
  12245. * And the following return is expected:
  12246. *
  12247. * * {node|null} The element which contains your feature. Note that the
  12248. * return may also be void if your plug-in does not require to inject any
  12249. * DOM elements into DataTables control (`dom`) - for example this might
  12250. * be useful when developing a plug-in which allows table control via
  12251. * keyboard entry
  12252. *
  12253. * @type array
  12254. *
  12255. * @example
  12256. * $.fn.dataTable.ext.features.push( {
  12257. * "fnInit": function( oSettings ) {
  12258. * return new TableTools( { "oDTSettings": oSettings } );
  12259. * },
  12260. * "cFeature": "T"
  12261. * } );
  12262. */
  12263. feature: [],
  12264. /**
  12265. * Row searching.
  12266. *
  12267. * This method of searching is complimentary to the default type based
  12268. * searching, and a lot more comprehensive as it allows you complete control
  12269. * over the searching logic. Each element in this array is a function
  12270. * (parameters described below) that is called for every row in the table,
  12271. * and your logic decides if it should be included in the searching data set
  12272. * or not.
  12273. *
  12274. * Searching functions have the following input parameters:
  12275. *
  12276. * 1. `{object}` DataTables settings object: see
  12277. * {@link DataTable.models.oSettings}
  12278. * 2. `{array|object}` Data for the row to be processed (same as the
  12279. * original format that was passed in as the data source, or an array
  12280. * from a DOM data source
  12281. * 3. `{int}` Row index ({@link DataTable.models.oSettings.aoData}), which
  12282. * can be useful to retrieve the `TR` element if you need DOM interaction.
  12283. *
  12284. * And the following return is expected:
  12285. *
  12286. * * {boolean} Include the row in the searched result set (true) or not
  12287. * (false)
  12288. *
  12289. * Note that as with the main search ability in DataTables, technically this
  12290. * is "filtering", since it is subtractive. However, for consistency in
  12291. * naming we call it searching here.
  12292. *
  12293. * @type array
  12294. * @default []
  12295. *
  12296. * @example
  12297. * // The following example shows custom search being applied to the
  12298. * // fourth column (i.e. the data[3] index) based on two input values
  12299. * // from the end-user, matching the data in a certain range.
  12300. * $.fn.dataTable.ext.search.push(
  12301. * function( settings, data, dataIndex ) {
  12302. * var min = document.getElementById('min').value * 1;
  12303. * var max = document.getElementById('max').value * 1;
  12304. * var version = data[3] == "-" ? 0 : data[3]*1;
  12305. *
  12306. * if ( min == "" && max == "" ) {
  12307. * return true;
  12308. * }
  12309. * else if ( min == "" && version < max ) {
  12310. * return true;
  12311. * }
  12312. * else if ( min < version && "" == max ) {
  12313. * return true;
  12314. * }
  12315. * else if ( min < version && version < max ) {
  12316. * return true;
  12317. * }
  12318. * return false;
  12319. * }
  12320. * );
  12321. */
  12322. search: [],
  12323. /**
  12324. * Selector extensions
  12325. *
  12326. * The `selector` option can be used to extend the options available for the
  12327. * selector modifier options (`selector-modifier` object data type) that
  12328. * each of the three built in selector types offer (row, column and cell +
  12329. * their plural counterparts). For example the Select extension uses this
  12330. * mechanism to provide an option to select only rows, columns and cells
  12331. * that have been marked as selected by the end user (`{selected: true}`),
  12332. * which can be used in conjunction with the existing built in selector
  12333. * options.
  12334. *
  12335. * Each property is an array to which functions can be pushed. The functions
  12336. * take three attributes:
  12337. *
  12338. * * Settings object for the host table
  12339. * * Options object (`selector-modifier` object type)
  12340. * * Array of selected item indexes
  12341. *
  12342. * The return is an array of the resulting item indexes after the custom
  12343. * selector has been applied.
  12344. *
  12345. * @type object
  12346. */
  12347. selector: {
  12348. cell: [],
  12349. column: [],
  12350. row: []
  12351. },
  12352. /**
  12353. * Internal functions, exposed for used in plug-ins.
  12354. *
  12355. * Please note that you should not need to use the internal methods for
  12356. * anything other than a plug-in (and even then, try to avoid if possible).
  12357. * The internal function may change between releases.
  12358. *
  12359. * @type object
  12360. * @default {}
  12361. */
  12362. internal: {},
  12363. /**
  12364. * Legacy configuration options. Enable and disable legacy options that
  12365. * are available in DataTables.
  12366. *
  12367. * @type object
  12368. */
  12369. legacy: {
  12370. /**
  12371. * Enable / disable DataTables 1.9 compatible server-side processing
  12372. * requests
  12373. *
  12374. * @type boolean
  12375. * @default null
  12376. */
  12377. ajax: null
  12378. },
  12379. /**
  12380. * Pagination plug-in methods.
  12381. *
  12382. * Each entry in this object is a function and defines which buttons should
  12383. * be shown by the pagination rendering method that is used for the table:
  12384. * {@link DataTable.ext.renderer.pageButton}. The renderer addresses how the
  12385. * buttons are displayed in the document, while the functions here tell it
  12386. * what buttons to display. This is done by returning an array of button
  12387. * descriptions (what each button will do).
  12388. *
  12389. * Pagination types (the four built in options and any additional plug-in
  12390. * options defined here) can be used through the `paginationType`
  12391. * initialisation parameter.
  12392. *
  12393. * The functions defined take two parameters:
  12394. *
  12395. * 1. `{int} page` The current page index
  12396. * 2. `{int} pages` The number of pages in the table
  12397. *
  12398. * Each function is expected to return an array where each element of the
  12399. * array can be one of:
  12400. *
  12401. * * `first` - Jump to first page when activated
  12402. * * `last` - Jump to last page when activated
  12403. * * `previous` - Show previous page when activated
  12404. * * `next` - Show next page when activated
  12405. * * `{int}` - Show page of the index given
  12406. * * `{array}` - A nested array containing the above elements to add a
  12407. * containing 'DIV' element (might be useful for styling).
  12408. *
  12409. * Note that DataTables v1.9- used this object slightly differently whereby
  12410. * an object with two functions would be defined for each plug-in. That
  12411. * ability is still supported by DataTables 1.10+ to provide backwards
  12412. * compatibility, but this option of use is now decremented and no longer
  12413. * documented in DataTables 1.10+.
  12414. *
  12415. * @type object
  12416. * @default {}
  12417. *
  12418. * @example
  12419. * // Show previous, next and current page buttons only
  12420. * $.fn.dataTableExt.oPagination.current = function ( page, pages ) {
  12421. * return [ 'previous', page, 'next' ];
  12422. * };
  12423. */
  12424. pager: {},
  12425. renderer: {
  12426. pageButton: {},
  12427. header: {}
  12428. },
  12429. /**
  12430. * Ordering plug-ins - custom data source
  12431. *
  12432. * The extension options for ordering of data available here is complimentary
  12433. * to the default type based ordering that DataTables typically uses. It
  12434. * allows much greater control over the the data that is being used to
  12435. * order a column, but is necessarily therefore more complex.
  12436. *
  12437. * This type of ordering is useful if you want to do ordering based on data
  12438. * live from the DOM (for example the contents of an 'input' element) rather
  12439. * than just the static string that DataTables knows of.
  12440. *
  12441. * The way these plug-ins work is that you create an array of the values you
  12442. * wish to be ordering for the column in question and then return that
  12443. * array. The data in the array much be in the index order of the rows in
  12444. * the table (not the currently ordering order!). Which order data gathering
  12445. * function is run here depends on the `dt-init columns.orderDataType`
  12446. * parameter that is used for the column (if any).
  12447. *
  12448. * The functions defined take two parameters:
  12449. *
  12450. * 1. `{object}` DataTables settings object: see
  12451. * {@link DataTable.models.oSettings}
  12452. * 2. `{int}` Target column index
  12453. *
  12454. * Each function is expected to return an array:
  12455. *
  12456. * * `{array}` Data for the column to be ordering upon
  12457. *
  12458. * @type array
  12459. *
  12460. * @example
  12461. * // Ordering using `input` node values
  12462. * $.fn.dataTable.ext.order['dom-text'] = function ( settings, col )
  12463. * {
  12464. * return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
  12465. * return $('input', td).val();
  12466. * } );
  12467. * }
  12468. */
  12469. order: {},
  12470. /**
  12471. * Type based plug-ins.
  12472. *
  12473. * Each column in DataTables has a type assigned to it, either by automatic
  12474. * detection or by direct assignment using the `type` option for the column.
  12475. * The type of a column will effect how it is ordering and search (plug-ins
  12476. * can also make use of the column type if required).
  12477. *
  12478. * @namespace
  12479. */
  12480. type: {
  12481. /**
  12482. * Type detection functions.
  12483. *
  12484. * The functions defined in this object are used to automatically detect
  12485. * a column's type, making initialisation of DataTables super easy, even
  12486. * when complex data is in the table.
  12487. *
  12488. * The functions defined take two parameters:
  12489. *
  12490. * 1. `{*}` Data from the column cell to be analysed
  12491. * 2. `{settings}` DataTables settings object. This can be used to
  12492. * perform context specific type detection - for example detection
  12493. * based on language settings such as using a comma for a decimal
  12494. * place. Generally speaking the options from the settings will not
  12495. * be required
  12496. *
  12497. * Each function is expected to return:
  12498. *
  12499. * * `{string|null}` Data type detected, or null if unknown (and thus
  12500. * pass it on to the other type detection functions.
  12501. *
  12502. * @type array
  12503. *
  12504. * @example
  12505. * // Currency type detection plug-in:
  12506. * $.fn.dataTable.ext.type.detect.push(
  12507. * function ( data, settings ) {
  12508. * // Check the numeric part
  12509. * if ( ! data.substring(1).match(/[0-9]/) ) {
  12510. * return null;
  12511. * }
  12512. *
  12513. * // Check prefixed by currency
  12514. * if ( data.charAt(0) == '$' || data.charAt(0) == '&pound;' ) {
  12515. * return 'currency';
  12516. * }
  12517. * return null;
  12518. * }
  12519. * );
  12520. */
  12521. detect: [],
  12522. /**
  12523. * Type based search formatting.
  12524. *
  12525. * The type based searching functions can be used to pre-format the
  12526. * data to be search on. For example, it can be used to strip HTML
  12527. * tags or to de-format telephone numbers for numeric only searching.
  12528. *
  12529. * Note that is a search is not defined for a column of a given type,
  12530. * no search formatting will be performed.
  12531. *
  12532. * Pre-processing of searching data plug-ins - When you assign the sType
  12533. * for a column (or have it automatically detected for you by DataTables
  12534. * or a type detection plug-in), you will typically be using this for
  12535. * custom sorting, but it can also be used to provide custom searching
  12536. * by allowing you to pre-processing the data and returning the data in
  12537. * the format that should be searched upon. This is done by adding
  12538. * functions this object with a parameter name which matches the sType
  12539. * for that target column. This is the corollary of <i>afnSortData</i>
  12540. * for searching data.
  12541. *
  12542. * The functions defined take a single parameter:
  12543. *
  12544. * 1. `{*}` Data from the column cell to be prepared for searching
  12545. *
  12546. * Each function is expected to return:
  12547. *
  12548. * * `{string|null}` Formatted string that will be used for the searching.
  12549. *
  12550. * @type object
  12551. * @default {}
  12552. *
  12553. * @example
  12554. * $.fn.dataTable.ext.type.search['title-numeric'] = function ( d ) {
  12555. * return d.replace(/\n/g," ").replace( /<.*?>/g, "" );
  12556. * }
  12557. */
  12558. search: {},
  12559. /**
  12560. * Type based ordering.
  12561. *
  12562. * The column type tells DataTables what ordering to apply to the table
  12563. * when a column is sorted upon. The order for each type that is defined,
  12564. * is defined by the functions available in this object.
  12565. *
  12566. * Each ordering option can be described by three properties added to
  12567. * this object:
  12568. *
  12569. * * `{type}-pre` - Pre-formatting function
  12570. * * `{type}-asc` - Ascending order function
  12571. * * `{type}-desc` - Descending order function
  12572. *
  12573. * All three can be used together, only `{type}-pre` or only
  12574. * `{type}-asc` and `{type}-desc` together. It is generally recommended
  12575. * that only `{type}-pre` is used, as this provides the optimal
  12576. * implementation in terms of speed, although the others are provided
  12577. * for compatibility with existing Javascript sort functions.
  12578. *
  12579. * `{type}-pre`: Functions defined take a single parameter:
  12580. *
  12581. * 1. `{*}` Data from the column cell to be prepared for ordering
  12582. *
  12583. * And return:
  12584. *
  12585. * * `{*}` Data to be sorted upon
  12586. *
  12587. * `{type}-asc` and `{type}-desc`: Functions are typical Javascript sort
  12588. * functions, taking two parameters:
  12589. *
  12590. * 1. `{*}` Data to compare to the second parameter
  12591. * 2. `{*}` Data to compare to the first parameter
  12592. *
  12593. * And returning:
  12594. *
  12595. * * `{*}` Ordering match: <0 if first parameter should be sorted lower
  12596. * than the second parameter, ===0 if the two parameters are equal and
  12597. * >0 if the first parameter should be sorted height than the second
  12598. * parameter.
  12599. *
  12600. * @type object
  12601. * @default {}
  12602. *
  12603. * @example
  12604. * // Numeric ordering of formatted numbers with a pre-formatter
  12605. * $.extend( $.fn.dataTable.ext.type.order, {
  12606. * "string-pre": function(x) {
  12607. * a = (a === "-" || a === "") ? 0 : a.replace( /[^\d\-\.]/g, "" );
  12608. * return parseFloat( a );
  12609. * }
  12610. * } );
  12611. *
  12612. * @example
  12613. * // Case-sensitive string ordering, with no pre-formatting method
  12614. * $.extend( $.fn.dataTable.ext.order, {
  12615. * "string-case-asc": function(x,y) {
  12616. * return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12617. * },
  12618. * "string-case-desc": function(x,y) {
  12619. * return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12620. * }
  12621. * } );
  12622. */
  12623. order: {}
  12624. },
  12625. /**
  12626. * Unique DataTables instance counter
  12627. *
  12628. * @type int
  12629. * @private
  12630. */
  12631. _unique: 0,
  12632. //
  12633. // Depreciated
  12634. // The following properties are retained for backwards compatibility only.
  12635. // The should not be used in new projects and will be removed in a future
  12636. // version
  12637. //
  12638. /**
  12639. * Version check function.
  12640. * @type function
  12641. * @depreciated Since 1.10
  12642. */
  12643. fnVersionCheck: DataTable.fnVersionCheck,
  12644. /**
  12645. * Index for what 'this' index API functions should use
  12646. * @type int
  12647. * @deprecated Since v1.10
  12648. */
  12649. iApiIndex: 0,
  12650. /**
  12651. * jQuery UI class container
  12652. * @type object
  12653. * @deprecated Since v1.10
  12654. */
  12655. oJUIClasses: {},
  12656. /**
  12657. * Software version
  12658. * @type string
  12659. * @deprecated Since v1.10
  12660. */
  12661. sVersion: DataTable.version
  12662. };
  12663. //
  12664. // Backwards compatibility. Alias to pre 1.10 Hungarian notation counter parts
  12665. //
  12666. $.extend( _ext, {
  12667. afnFiltering: _ext.search,
  12668. aTypes: _ext.type.detect,
  12669. ofnSearch: _ext.type.search,
  12670. oSort: _ext.type.order,
  12671. afnSortData: _ext.order,
  12672. aoFeatures: _ext.feature,
  12673. oApi: _ext.internal,
  12674. oStdClasses: _ext.classes,
  12675. oPagination: _ext.pager
  12676. } );
  12677. $.extend( DataTable.ext.classes, {
  12678. "sTable": "dataTable",
  12679. "sNoFooter": "no-footer",
  12680. /* Paging buttons */
  12681. "sPageButton": "paginate_button",
  12682. "sPageButtonActive": "current",
  12683. "sPageButtonDisabled": "disabled",
  12684. /* Striping classes */
  12685. "sStripeOdd": "odd",
  12686. "sStripeEven": "even",
  12687. /* Empty row */
  12688. "sRowEmpty": "dataTables_empty",
  12689. /* Features */
  12690. "sWrapper": "dataTables_wrapper",
  12691. "sFilter": "dataTables_filter",
  12692. "sInfo": "dataTables_info",
  12693. "sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */
  12694. "sLength": "dataTables_length",
  12695. "sProcessing": "dataTables_processing",
  12696. /* Sorting */
  12697. "sSortAsc": "sorting_asc",
  12698. "sSortDesc": "sorting_desc",
  12699. "sSortable": "sorting", /* Sortable in both directions */
  12700. "sSortableAsc": "sorting_desc_disabled",
  12701. "sSortableDesc": "sorting_asc_disabled",
  12702. "sSortableNone": "sorting_disabled",
  12703. "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
  12704. /* Filtering */
  12705. "sFilterInput": "",
  12706. /* Page length */
  12707. "sLengthSelect": "",
  12708. /* Scrolling */
  12709. "sScrollWrapper": "dataTables_scroll",
  12710. "sScrollHead": "dataTables_scrollHead",
  12711. "sScrollHeadInner": "dataTables_scrollHeadInner",
  12712. "sScrollBody": "dataTables_scrollBody",
  12713. "sScrollFoot": "dataTables_scrollFoot",
  12714. "sScrollFootInner": "dataTables_scrollFootInner",
  12715. /* Misc */
  12716. "sHeaderTH": "",
  12717. "sFooterTH": "",
  12718. // Deprecated
  12719. "sSortJUIAsc": "",
  12720. "sSortJUIDesc": "",
  12721. "sSortJUI": "",
  12722. "sSortJUIAscAllowed": "",
  12723. "sSortJUIDescAllowed": "",
  12724. "sSortJUIWrapper": "",
  12725. "sSortIcon": "",
  12726. "sJUIHeader": "",
  12727. "sJUIFooter": ""
  12728. } );
  12729. var extPagination = DataTable.ext.pager;
  12730. function _numbers ( page, pages ) {
  12731. var
  12732. numbers = [],
  12733. buttons = extPagination.numbers_length,
  12734. half = Math.floor( buttons / 2 ),
  12735. i = 1;
  12736. if ( pages <= buttons ) {
  12737. numbers = _range( 0, pages );
  12738. }
  12739. else if ( page <= half ) {
  12740. numbers = _range( 0, buttons-2 );
  12741. numbers.push( 'ellipsis' );
  12742. numbers.push( pages-1 );
  12743. }
  12744. else if ( page >= pages - 1 - half ) {
  12745. numbers = _range( pages-(buttons-2), pages );
  12746. numbers.splice( 0, 0, 'ellipsis' ); // no unshift in ie6
  12747. numbers.splice( 0, 0, 0 );
  12748. }
  12749. else {
  12750. numbers = _range( page-half+2, page+half-1 );
  12751. numbers.push( 'ellipsis' );
  12752. numbers.push( pages-1 );
  12753. numbers.splice( 0, 0, 'ellipsis' );
  12754. numbers.splice( 0, 0, 0 );
  12755. }
  12756. numbers.DT_el = 'span';
  12757. return numbers;
  12758. }
  12759. $.extend( extPagination, {
  12760. simple: function ( page, pages ) {
  12761. return [ 'previous', 'next' ];
  12762. },
  12763. full: function ( page, pages ) {
  12764. return [ 'first', 'previous', 'next', 'last' ];
  12765. },
  12766. numbers: function ( page, pages ) {
  12767. return [ _numbers(page, pages) ];
  12768. },
  12769. simple_numbers: function ( page, pages ) {
  12770. return [ 'previous', _numbers(page, pages), 'next' ];
  12771. },
  12772. full_numbers: function ( page, pages ) {
  12773. return [ 'first', 'previous', _numbers(page, pages), 'next', 'last' ];
  12774. },
  12775. first_last_numbers: function (page, pages) {
  12776. return ['first', _numbers(page, pages), 'last'];
  12777. },
  12778. // For testing and plug-ins to use
  12779. _numbers: _numbers,
  12780. // Number of number buttons (including ellipsis) to show. _Must be odd!_
  12781. numbers_length: 7
  12782. } );
  12783. $.extend( true, DataTable.ext.renderer, {
  12784. pageButton: {
  12785. _: function ( settings, host, idx, buttons, page, pages ) {
  12786. var classes = settings.oClasses;
  12787. var lang = settings.oLanguage.oPaginate;
  12788. var aria = settings.oLanguage.oAria.paginate || {};
  12789. var btnDisplay, btnClass, counter=0;
  12790. var attach = function( container, buttons ) {
  12791. var i, ien, node, button, tabIndex;
  12792. var disabledClass = classes.sPageButtonDisabled;
  12793. var clickHandler = function ( e ) {
  12794. _fnPageChange( settings, e.data.action, true );
  12795. };
  12796. for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
  12797. button = buttons[i];
  12798. if ( Array.isArray( button ) ) {
  12799. var inner = $( '<'+(button.DT_el || 'div')+'/>' )
  12800. .appendTo( container );
  12801. attach( inner, button );
  12802. }
  12803. else {
  12804. btnDisplay = null;
  12805. btnClass = button;
  12806. tabIndex = settings.iTabIndex;
  12807. switch ( button ) {
  12808. case 'ellipsis':
  12809. container.append('<span class="ellipsis">&#x2026;</span>');
  12810. break;
  12811. case 'first':
  12812. btnDisplay = lang.sFirst;
  12813. if ( page === 0 ) {
  12814. tabIndex = -1;
  12815. btnClass += ' ' + disabledClass;
  12816. }
  12817. break;
  12818. case 'previous':
  12819. btnDisplay = lang.sPrevious;
  12820. if ( page === 0 ) {
  12821. tabIndex = -1;
  12822. btnClass += ' ' + disabledClass;
  12823. }
  12824. break;
  12825. case 'next':
  12826. btnDisplay = lang.sNext;
  12827. if ( pages === 0 || page === pages-1 ) {
  12828. tabIndex = -1;
  12829. btnClass += ' ' + disabledClass;
  12830. }
  12831. break;
  12832. case 'last':
  12833. btnDisplay = lang.sLast;
  12834. if ( pages === 0 || page === pages-1 ) {
  12835. tabIndex = -1;
  12836. btnClass += ' ' + disabledClass;
  12837. }
  12838. break;
  12839. default:
  12840. btnDisplay = settings.fnFormatNumber( button + 1 );
  12841. btnClass = page === button ?
  12842. classes.sPageButtonActive : '';
  12843. break;
  12844. }
  12845. if ( btnDisplay !== null ) {
  12846. node = $('<a>', {
  12847. 'class': classes.sPageButton+' '+btnClass,
  12848. 'aria-controls': settings.sTableId,
  12849. 'aria-label': aria[ button ],
  12850. 'data-dt-idx': counter,
  12851. 'tabindex': tabIndex,
  12852. 'id': idx === 0 && typeof button === 'string' ?
  12853. settings.sTableId +'_'+ button :
  12854. null
  12855. } )
  12856. .html( btnDisplay )
  12857. .appendTo( container );
  12858. _fnBindAction(
  12859. node, {action: button}, clickHandler
  12860. );
  12861. counter++;
  12862. }
  12863. }
  12864. }
  12865. };
  12866. // IE9 throws an 'unknown error' if document.activeElement is used
  12867. // inside an iframe or frame. Try / catch the error. Not good for
  12868. // accessibility, but neither are frames.
  12869. var activeEl;
  12870. try {
  12871. // Because this approach is destroying and recreating the paging
  12872. // elements, focus is lost on the select button which is bad for
  12873. // accessibility. So we want to restore focus once the draw has
  12874. // completed
  12875. activeEl = $(host).find(document.activeElement).data('dt-idx');
  12876. }
  12877. catch (e) {}
  12878. attach( $(host).empty(), buttons );
  12879. if ( activeEl !== undefined ) {
  12880. $(host).find( '[data-dt-idx='+activeEl+']' ).trigger('focus');
  12881. }
  12882. }
  12883. }
  12884. } );
  12885. // Built in type detection. See model.ext.aTypes for information about
  12886. // what is required from this methods.
  12887. $.extend( DataTable.ext.type.detect, [
  12888. // Plain numbers - first since V8 detects some plain numbers as dates
  12889. // e.g. Date.parse('55') (but not all, e.g. Date.parse('22')...).
  12890. function ( d, settings )
  12891. {
  12892. var decimal = settings.oLanguage.sDecimal;
  12893. return _isNumber( d, decimal ) ? 'num'+decimal : null;
  12894. },
  12895. // Dates (only those recognised by the browser's Date.parse)
  12896. function ( d, settings )
  12897. {
  12898. // V8 tries _very_ hard to make a string passed into `Date.parse()`
  12899. // valid, so we need to use a regex to restrict date formats. Use a
  12900. // plug-in for anything other than ISO8601 style strings
  12901. if ( d && !(d instanceof Date) && ! _re_date.test(d) ) {
  12902. return null;
  12903. }
  12904. var parsed = Date.parse(d);
  12905. return (parsed !== null && !isNaN(parsed)) || _empty(d) ? 'date' : null;
  12906. },
  12907. // Formatted numbers
  12908. function ( d, settings )
  12909. {
  12910. var decimal = settings.oLanguage.sDecimal;
  12911. return _isNumber( d, decimal, true ) ? 'num-fmt'+decimal : null;
  12912. },
  12913. // HTML numeric
  12914. function ( d, settings )
  12915. {
  12916. var decimal = settings.oLanguage.sDecimal;
  12917. return _htmlNumeric( d, decimal ) ? 'html-num'+decimal : null;
  12918. },
  12919. // HTML numeric, formatted
  12920. function ( d, settings )
  12921. {
  12922. var decimal = settings.oLanguage.sDecimal;
  12923. return _htmlNumeric( d, decimal, true ) ? 'html-num-fmt'+decimal : null;
  12924. },
  12925. // HTML (this is strict checking - there must be html)
  12926. function ( d, settings )
  12927. {
  12928. return _empty( d ) || (typeof d === 'string' && d.indexOf('<') !== -1) ?
  12929. 'html' : null;
  12930. }
  12931. ] );
  12932. // Filter formatting functions. See model.ext.ofnSearch for information about
  12933. // what is required from these methods.
  12934. //
  12935. // Note that additional search methods are added for the html numbers and
  12936. // html formatted numbers by `_addNumericSort()` when we know what the decimal
  12937. // place is
  12938. $.extend( DataTable.ext.type.search, {
  12939. html: function ( data ) {
  12940. return _empty(data) ?
  12941. data :
  12942. typeof data === 'string' ?
  12943. data
  12944. .replace( _re_new_lines, " " )
  12945. .replace( _re_html, "" ) :
  12946. '';
  12947. },
  12948. string: function ( data ) {
  12949. return _empty(data) ?
  12950. data :
  12951. typeof data === 'string' ?
  12952. data.replace( _re_new_lines, " " ) :
  12953. data;
  12954. }
  12955. } );
  12956. var __numericReplace = function ( d, decimalPlace, re1, re2 ) {
  12957. if ( d !== 0 && (!d || d === '-') ) {
  12958. return -Infinity;
  12959. }
  12960. // If a decimal place other than `.` is used, it needs to be given to the
  12961. // function so we can detect it and replace with a `.` which is the only
  12962. // decimal place Javascript recognises - it is not locale aware.
  12963. if ( decimalPlace ) {
  12964. d = _numToDecimal( d, decimalPlace );
  12965. }
  12966. if ( d.replace ) {
  12967. if ( re1 ) {
  12968. d = d.replace( re1, '' );
  12969. }
  12970. if ( re2 ) {
  12971. d = d.replace( re2, '' );
  12972. }
  12973. }
  12974. return d * 1;
  12975. };
  12976. // Add the numeric 'deformatting' functions for sorting and search. This is done
  12977. // in a function to provide an easy ability for the language options to add
  12978. // additional methods if a non-period decimal place is used.
  12979. function _addNumericSort ( decimalPlace ) {
  12980. $.each(
  12981. {
  12982. // Plain numbers
  12983. "num": function ( d ) {
  12984. return __numericReplace( d, decimalPlace );
  12985. },
  12986. // Formatted numbers
  12987. "num-fmt": function ( d ) {
  12988. return __numericReplace( d, decimalPlace, _re_formatted_numeric );
  12989. },
  12990. // HTML numeric
  12991. "html-num": function ( d ) {
  12992. return __numericReplace( d, decimalPlace, _re_html );
  12993. },
  12994. // HTML numeric, formatted
  12995. "html-num-fmt": function ( d ) {
  12996. return __numericReplace( d, decimalPlace, _re_html, _re_formatted_numeric );
  12997. }
  12998. },
  12999. function ( key, fn ) {
  13000. // Add the ordering method
  13001. _ext.type.order[ key+decimalPlace+'-pre' ] = fn;
  13002. // For HTML types add a search formatter that will strip the HTML
  13003. if ( key.match(/^html\-/) ) {
  13004. _ext.type.search[ key+decimalPlace ] = _ext.type.search.html;
  13005. }
  13006. }
  13007. );
  13008. }
  13009. // Default sort methods
  13010. $.extend( _ext.type.order, {
  13011. // Dates
  13012. "date-pre": function ( d ) {
  13013. var ts = Date.parse( d );
  13014. return isNaN(ts) ? -Infinity : ts;
  13015. },
  13016. // html
  13017. "html-pre": function ( a ) {
  13018. return _empty(a) ?
  13019. '' :
  13020. a.replace ?
  13021. a.replace( /<.*?>/g, "" ).toLowerCase() :
  13022. a+'';
  13023. },
  13024. // string
  13025. "string-pre": function ( a ) {
  13026. // This is a little complex, but faster than always calling toString,
  13027. // http://jsperf.com/tostring-v-check
  13028. return _empty(a) ?
  13029. '' :
  13030. typeof a === 'string' ?
  13031. a.toLowerCase() :
  13032. ! a.toString ?
  13033. '' :
  13034. a.toString();
  13035. },
  13036. // string-asc and -desc are retained only for compatibility with the old
  13037. // sort methods
  13038. "string-asc": function ( x, y ) {
  13039. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  13040. },
  13041. "string-desc": function ( x, y ) {
  13042. return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  13043. }
  13044. } );
  13045. // Numeric sorting types - order doesn't matter here
  13046. _addNumericSort( '' );
  13047. $.extend( true, DataTable.ext.renderer, {
  13048. header: {
  13049. _: function ( settings, cell, column, classes ) {
  13050. // No additional mark-up required
  13051. // Attach a sort listener to update on sort - note that using the
  13052. // `DT` namespace will allow the event to be removed automatically
  13053. // on destroy, while the `dt` namespaced event is the one we are
  13054. // listening for
  13055. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  13056. if ( settings !== ctx ) { // need to check this this is the host
  13057. return; // table, not a nested one
  13058. }
  13059. var colIdx = column.idx;
  13060. cell
  13061. .removeClass(
  13062. classes.sSortAsc +' '+
  13063. classes.sSortDesc
  13064. )
  13065. .addClass( columns[ colIdx ] == 'asc' ?
  13066. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  13067. classes.sSortDesc :
  13068. column.sSortingClass
  13069. );
  13070. } );
  13071. },
  13072. jqueryui: function ( settings, cell, column, classes ) {
  13073. $('<div/>')
  13074. .addClass( classes.sSortJUIWrapper )
  13075. .append( cell.contents() )
  13076. .append( $('<span/>')
  13077. .addClass( classes.sSortIcon+' '+column.sSortingClassJUI )
  13078. )
  13079. .appendTo( cell );
  13080. // Attach a sort listener to update on sort
  13081. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  13082. if ( settings !== ctx ) {
  13083. return;
  13084. }
  13085. var colIdx = column.idx;
  13086. cell
  13087. .removeClass( classes.sSortAsc +" "+classes.sSortDesc )
  13088. .addClass( columns[ colIdx ] == 'asc' ?
  13089. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  13090. classes.sSortDesc :
  13091. column.sSortingClass
  13092. );
  13093. cell
  13094. .find( 'span.'+classes.sSortIcon )
  13095. .removeClass(
  13096. classes.sSortJUIAsc +" "+
  13097. classes.sSortJUIDesc +" "+
  13098. classes.sSortJUI +" "+
  13099. classes.sSortJUIAscAllowed +" "+
  13100. classes.sSortJUIDescAllowed
  13101. )
  13102. .addClass( columns[ colIdx ] == 'asc' ?
  13103. classes.sSortJUIAsc : columns[ colIdx ] == 'desc' ?
  13104. classes.sSortJUIDesc :
  13105. column.sSortingClassJUI
  13106. );
  13107. } );
  13108. }
  13109. }
  13110. } );
  13111. /*
  13112. * Public helper functions. These aren't used internally by DataTables, or
  13113. * called by any of the options passed into DataTables, but they can be used
  13114. * externally by developers working with DataTables. They are helper functions
  13115. * to make working with DataTables a little bit easier.
  13116. */
  13117. var __htmlEscapeEntities = function ( d ) {
  13118. if (Array.isArray(d)) {
  13119. d = d.join(',');
  13120. }
  13121. return typeof d === 'string' ?
  13122. d
  13123. .replace(/&/g, '&amp;')
  13124. .replace(/</g, '&lt;')
  13125. .replace(/>/g, '&gt;')
  13126. .replace(/"/g, '&quot;') :
  13127. d;
  13128. };
  13129. /**
  13130. * Helpers for `columns.render`.
  13131. *
  13132. * The options defined here can be used with the `columns.render` initialisation
  13133. * option to provide a display renderer. The following functions are defined:
  13134. *
  13135. * * `number` - Will format numeric data (defined by `columns.data`) for
  13136. * display, retaining the original unformatted data for sorting and filtering.
  13137. * It takes 5 parameters:
  13138. * * `string` - Thousands grouping separator
  13139. * * `string` - Decimal point indicator
  13140. * * `integer` - Number of decimal points to show
  13141. * * `string` (optional) - Prefix.
  13142. * * `string` (optional) - Postfix (/suffix).
  13143. * * `text` - Escape HTML to help prevent XSS attacks. It has no optional
  13144. * parameters.
  13145. *
  13146. * @example
  13147. * // Column definition using the number renderer
  13148. * {
  13149. * data: "salary",
  13150. * render: $.fn.dataTable.render.number( '\'', '.', 0, '$' )
  13151. * }
  13152. *
  13153. * @namespace
  13154. */
  13155. DataTable.render = {
  13156. number: function ( thousands, decimal, precision, prefix, postfix ) {
  13157. return {
  13158. display: function ( d ) {
  13159. if ( typeof d !== 'number' && typeof d !== 'string' ) {
  13160. return d;
  13161. }
  13162. var negative = d < 0 ? '-' : '';
  13163. var flo = parseFloat( d );
  13164. // If NaN then there isn't much formatting that we can do - just
  13165. // return immediately, escaping any HTML (this was supposed to
  13166. // be a number after all)
  13167. if ( isNaN( flo ) ) {
  13168. return __htmlEscapeEntities( d );
  13169. }
  13170. flo = flo.toFixed( precision );
  13171. d = Math.abs( flo );
  13172. var intPart = parseInt( d, 10 );
  13173. var floatPart = precision ?
  13174. decimal+(d - intPart).toFixed( precision ).substring( 2 ):
  13175. '';
  13176. // If zero, then can't have a negative prefix
  13177. if (intPart === 0 && parseFloat(floatPart) === 0) {
  13178. negative = '';
  13179. }
  13180. return negative + (prefix||'') +
  13181. intPart.toString().replace(
  13182. /\B(?=(\d{3})+(?!\d))/g, thousands
  13183. ) +
  13184. floatPart +
  13185. (postfix||'');
  13186. }
  13187. };
  13188. },
  13189. text: function () {
  13190. return {
  13191. display: __htmlEscapeEntities,
  13192. filter: __htmlEscapeEntities
  13193. };
  13194. }
  13195. };
  13196. /*
  13197. * This is really a good bit rubbish this method of exposing the internal methods
  13198. * publicly... - To be fixed in 2.0 using methods on the prototype
  13199. */
  13200. /**
  13201. * Create a wrapper function for exporting an internal functions to an external API.
  13202. * @param {string} fn API function name
  13203. * @returns {function} wrapped function
  13204. * @memberof DataTable#internal
  13205. */
  13206. function _fnExternApiFunc (fn)
  13207. {
  13208. return function() {
  13209. var args = [_fnSettingsFromNode( this[DataTable.ext.iApiIndex] )].concat(
  13210. Array.prototype.slice.call(arguments)
  13211. );
  13212. return DataTable.ext.internal[fn].apply( this, args );
  13213. };
  13214. }
  13215. /**
  13216. * Reference to internal functions for use by plug-in developers. Note that
  13217. * these methods are references to internal functions and are considered to be
  13218. * private. If you use these methods, be aware that they are liable to change
  13219. * between versions.
  13220. * @namespace
  13221. */
  13222. $.extend( DataTable.ext.internal, {
  13223. _fnExternApiFunc: _fnExternApiFunc,
  13224. _fnBuildAjax: _fnBuildAjax,
  13225. _fnAjaxUpdate: _fnAjaxUpdate,
  13226. _fnAjaxParameters: _fnAjaxParameters,
  13227. _fnAjaxUpdateDraw: _fnAjaxUpdateDraw,
  13228. _fnAjaxDataSrc: _fnAjaxDataSrc,
  13229. _fnAddColumn: _fnAddColumn,
  13230. _fnColumnOptions: _fnColumnOptions,
  13231. _fnAdjustColumnSizing: _fnAdjustColumnSizing,
  13232. _fnVisibleToColumnIndex: _fnVisibleToColumnIndex,
  13233. _fnColumnIndexToVisible: _fnColumnIndexToVisible,
  13234. _fnVisbleColumns: _fnVisbleColumns,
  13235. _fnGetColumns: _fnGetColumns,
  13236. _fnColumnTypes: _fnColumnTypes,
  13237. _fnApplyColumnDefs: _fnApplyColumnDefs,
  13238. _fnHungarianMap: _fnHungarianMap,
  13239. _fnCamelToHungarian: _fnCamelToHungarian,
  13240. _fnLanguageCompat: _fnLanguageCompat,
  13241. _fnBrowserDetect: _fnBrowserDetect,
  13242. _fnAddData: _fnAddData,
  13243. _fnAddTr: _fnAddTr,
  13244. _fnNodeToDataIndex: _fnNodeToDataIndex,
  13245. _fnNodeToColumnIndex: _fnNodeToColumnIndex,
  13246. _fnGetCellData: _fnGetCellData,
  13247. _fnSetCellData: _fnSetCellData,
  13248. _fnSplitObjNotation: _fnSplitObjNotation,
  13249. _fnGetObjectDataFn: _fnGetObjectDataFn,
  13250. _fnSetObjectDataFn: _fnSetObjectDataFn,
  13251. _fnGetDataMaster: _fnGetDataMaster,
  13252. _fnClearTable: _fnClearTable,
  13253. _fnDeleteIndex: _fnDeleteIndex,
  13254. _fnInvalidate: _fnInvalidate,
  13255. _fnGetRowElements: _fnGetRowElements,
  13256. _fnCreateTr: _fnCreateTr,
  13257. _fnBuildHead: _fnBuildHead,
  13258. _fnDrawHead: _fnDrawHead,
  13259. _fnDraw: _fnDraw,
  13260. _fnReDraw: _fnReDraw,
  13261. _fnAddOptionsHtml: _fnAddOptionsHtml,
  13262. _fnDetectHeader: _fnDetectHeader,
  13263. _fnGetUniqueThs: _fnGetUniqueThs,
  13264. _fnFeatureHtmlFilter: _fnFeatureHtmlFilter,
  13265. _fnFilterComplete: _fnFilterComplete,
  13266. _fnFilterCustom: _fnFilterCustom,
  13267. _fnFilterColumn: _fnFilterColumn,
  13268. _fnFilter: _fnFilter,
  13269. _fnFilterCreateSearch: _fnFilterCreateSearch,
  13270. _fnEscapeRegex: _fnEscapeRegex,
  13271. _fnFilterData: _fnFilterData,
  13272. _fnFeatureHtmlInfo: _fnFeatureHtmlInfo,
  13273. _fnUpdateInfo: _fnUpdateInfo,
  13274. _fnInfoMacros: _fnInfoMacros,
  13275. _fnInitialise: _fnInitialise,
  13276. _fnInitComplete: _fnInitComplete,
  13277. _fnLengthChange: _fnLengthChange,
  13278. _fnFeatureHtmlLength: _fnFeatureHtmlLength,
  13279. _fnFeatureHtmlPaginate: _fnFeatureHtmlPaginate,
  13280. _fnPageChange: _fnPageChange,
  13281. _fnFeatureHtmlProcessing: _fnFeatureHtmlProcessing,
  13282. _fnProcessingDisplay: _fnProcessingDisplay,
  13283. _fnFeatureHtmlTable: _fnFeatureHtmlTable,
  13284. _fnScrollDraw: _fnScrollDraw,
  13285. _fnApplyToChildren: _fnApplyToChildren,
  13286. _fnCalculateColumnWidths: _fnCalculateColumnWidths,
  13287. _fnThrottle: _fnThrottle,
  13288. _fnConvertToWidth: _fnConvertToWidth,
  13289. _fnGetWidestNode: _fnGetWidestNode,
  13290. _fnGetMaxLenString: _fnGetMaxLenString,
  13291. _fnStringToCss: _fnStringToCss,
  13292. _fnSortFlatten: _fnSortFlatten,
  13293. _fnSort: _fnSort,
  13294. _fnSortAria: _fnSortAria,
  13295. _fnSortListener: _fnSortListener,
  13296. _fnSortAttachListener: _fnSortAttachListener,
  13297. _fnSortingClasses: _fnSortingClasses,
  13298. _fnSortData: _fnSortData,
  13299. _fnSaveState: _fnSaveState,
  13300. _fnLoadState: _fnLoadState,
  13301. _fnImplementState: _fnImplementState,
  13302. _fnSettingsFromNode: _fnSettingsFromNode,
  13303. _fnLog: _fnLog,
  13304. _fnMap: _fnMap,
  13305. _fnBindAction: _fnBindAction,
  13306. _fnCallbackReg: _fnCallbackReg,
  13307. _fnCallbackFire: _fnCallbackFire,
  13308. _fnLengthOverflow: _fnLengthOverflow,
  13309. _fnRenderer: _fnRenderer,
  13310. _fnDataSource: _fnDataSource,
  13311. _fnRowAttributes: _fnRowAttributes,
  13312. _fnExtend: _fnExtend,
  13313. _fnCalculateEnd: function () {} // Used by a lot of plug-ins, but redundant
  13314. // in 1.10, so this dead-end function is
  13315. // added to prevent errors
  13316. } );
  13317. // jQuery access
  13318. $.fn.dataTable = DataTable;
  13319. // Provide access to the host jQuery object (circular reference)
  13320. DataTable.$ = $;
  13321. // Legacy aliases
  13322. $.fn.dataTableSettings = DataTable.settings;
  13323. $.fn.dataTableExt = DataTable.ext;
  13324. // With a capital `D` we return a DataTables API instance rather than a
  13325. // jQuery object
  13326. $.fn.DataTable = function ( opts ) {
  13327. return $(this).dataTable( opts ).api();
  13328. };
  13329. // All properties that are available to $.fn.dataTable should also be
  13330. // available on $.fn.DataTable
  13331. $.each( DataTable, function ( prop, val ) {
  13332. $.fn.DataTable[ prop ] = val;
  13333. } );
  13334. return DataTable;
  13335. }));