jquery.dataTables.js 435 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242
  1. /*! DataTables 1.10.16
  2. * ©2008-2017 SpryMedia Ltd - datatables.net/license
  3. */
  4. /**
  5. * @summary DataTables
  6. * @description Paginate, search and order HTML tables
  7. * @version 1.10.16
  8. * @file jquery.dataTables.js
  9. * @author SpryMedia Ltd
  10. * @contact www.datatables.net
  11. * @copyright Copyright 2008-2017 SpryMedia Ltd.
  12. *
  13. * This source file is free software, available under the following license:
  14. * MIT license - http://datatables.net/license
  15. *
  16. * This source file is distributed in the hope that it will be useful, but
  17. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  18. * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
  19. *
  20. * For details please refer to: http://www.datatables.net
  21. */
  22. /*jslint evil: true, undef: true, browser: true */
  23. /*globals $,require,jQuery,define,_selector_run,_selector_opts,_selector_first,_selector_row_indexes,_ext,_Api,_api_register,_api_registerPlural,_re_new_lines,_re_html,_re_formatted_numeric,_re_escape_regex,_empty,_intVal,_numToDecimal,_isNumber,_isHtml,_htmlNumeric,_pluck,_pluck_order,_range,_stripHtml,_unique,_fnBuildAjax,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnAjaxDataSrc,_fnAddColumn,_fnColumnOptions,_fnAdjustColumnSizing,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnVisbleColumns,_fnGetColumns,_fnColumnTypes,_fnApplyColumnDefs,_fnHungarianMap,_fnCamelToHungarian,_fnLanguageCompat,_fnBrowserDetect,_fnAddData,_fnAddTr,_fnNodeToDataIndex,_fnNodeToColumnIndex,_fnGetCellData,_fnSetCellData,_fnSplitObjNotation,_fnGetObjectDataFn,_fnSetObjectDataFn,_fnGetDataMaster,_fnClearTable,_fnDeleteIndex,_fnInvalidate,_fnGetRowElements,_fnCreateTr,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAddOptionsHtml,_fnDetectHeader,_fnGetUniqueThs,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnFilterCreateSearch,_fnEscapeRegex,_fnFilterData,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnInfoMacros,_fnInitialise,_fnInitComplete,_fnLengthChange,_fnFeatureHtmlLength,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnFeatureHtmlTable,_fnScrollDraw,_fnApplyToChildren,_fnCalculateColumnWidths,_fnThrottle,_fnConvertToWidth,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnSortFlatten,_fnSort,_fnSortAria,_fnSortListener,_fnSortAttachListener,_fnSortingClasses,_fnSortData,_fnSaveState,_fnLoadState,_fnSettingsFromNode,_fnLog,_fnMap,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnLengthOverflow,_fnRenderer,_fnDataSource,_fnRowAttributes*/
  24. (function( factory ) {
  25. "use strict";
  26. if ( typeof define === 'function' && define.amd ) {
  27. // AMD
  28. define( ['jquery'], function ( $ ) {
  29. return factory( $, window, document );
  30. } );
  31. }
  32. else if ( typeof exports === 'object' ) {
  33. // CommonJS
  34. module.exports = function (root, $) {
  35. if ( ! root ) {
  36. // CommonJS environments without a window global must pass a
  37. // root. This will give an error otherwise
  38. root = window;
  39. }
  40. if ( ! $ ) {
  41. $ = typeof window !== 'undefined' ? // jQuery's factory checks for a global window
  42. require('jquery') :
  43. require('jquery')( root );
  44. }
  45. return factory( $, root, root.document );
  46. };
  47. }
  48. else {
  49. // Browser
  50. factory( jQuery, window, document );
  51. }
  52. }
  53. (function( $, window, document, undefined ) {
  54. "use strict";
  55. /**
  56. * DataTables is a plug-in for the jQuery Javascript library. It is a highly
  57. * flexible tool, based upon the foundations of progressive enhancement,
  58. * which will add advanced interaction controls to any HTML table. For a
  59. * full list of features please refer to
  60. * [DataTables.net](href="http://datatables.net).
  61. *
  62. * Note that the `DataTable` object is not a global variable but is aliased
  63. * to `jQuery.fn.DataTable` and `jQuery.fn.dataTable` through which it may
  64. * be accessed.
  65. *
  66. * @class
  67. * @param {object} [init={}] Configuration object for DataTables. Options
  68. * are defined by {@link DataTable.defaults}
  69. * @requires jQuery 1.7+
  70. *
  71. * @example
  72. * // Basic initialisation
  73. * $(document).ready( function {
  74. * $('#example').dataTable();
  75. * } );
  76. *
  77. * @example
  78. * // Initialisation with configuration options - in this case, disable
  79. * // pagination and sorting.
  80. * $(document).ready( function {
  81. * $('#example').dataTable( {
  82. * "paginate": false,
  83. * "sort": false
  84. * } );
  85. * } );
  86. */
  87. var DataTable = function ( options )
  88. {
  89. /**
  90. * Perform a jQuery selector action on the table's TR elements (from the tbody) and
  91. * return the resulting jQuery object.
  92. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  93. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  94. * @param {string} [oOpts.filter=none] Select TR elements that meet the current filter
  95. * criterion ("applied") or all TR elements (i.e. no filter).
  96. * @param {string} [oOpts.order=current] Order of the TR elements in the processed array.
  97. * Can be either 'current', whereby the current sorting of the table is used, or
  98. * 'original' whereby the original order the data was read into the table is used.
  99. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  100. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  101. * 'current' and filter is 'applied', regardless of what they might be given as.
  102. * @returns {object} jQuery object, filtered by the given selector.
  103. * @dtopt API
  104. * @deprecated Since v1.10
  105. *
  106. * @example
  107. * $(document).ready(function() {
  108. * var oTable = $('#example').dataTable();
  109. *
  110. * // Highlight every second row
  111. * oTable.$('tr:odd').css('backgroundColor', 'blue');
  112. * } );
  113. *
  114. * @example
  115. * $(document).ready(function() {
  116. * var oTable = $('#example').dataTable();
  117. *
  118. * // Filter to rows with 'Webkit' in them, add a background colour and then
  119. * // remove the filter, thus highlighting the 'Webkit' rows only.
  120. * oTable.fnFilter('Webkit');
  121. * oTable.$('tr', {"search": "applied"}).css('backgroundColor', 'blue');
  122. * oTable.fnFilter('');
  123. * } );
  124. */
  125. this.$ = function ( sSelector, oOpts )
  126. {
  127. return this.api(true).$( sSelector, oOpts );
  128. };
  129. /**
  130. * Almost identical to $ in operation, but in this case returns the data for the matched
  131. * rows - as such, the jQuery selector used should match TR row nodes or TD/TH cell nodes
  132. * rather than any descendants, so the data can be obtained for the row/cell. If matching
  133. * rows are found, the data returned is the original data array/object that was used to
  134. * create the row (or a generated array if from a DOM source).
  135. *
  136. * This method is often useful in-combination with $ where both functions are given the
  137. * same parameters and the array indexes will match identically.
  138. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  139. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  140. * @param {string} [oOpts.filter=none] Select elements that meet the current filter
  141. * criterion ("applied") or all elements (i.e. no filter).
  142. * @param {string} [oOpts.order=current] Order of the data in the processed array.
  143. * Can be either 'current', whereby the current sorting of the table is used, or
  144. * 'original' whereby the original order the data was read into the table is used.
  145. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  146. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  147. * 'current' and filter is 'applied', regardless of what they might be given as.
  148. * @returns {array} Data for the matched elements. If any elements, as a result of the
  149. * selector, were not TR, TD or TH elements in the DataTable, they will have a null
  150. * entry in the array.
  151. * @dtopt API
  152. * @deprecated Since v1.10
  153. *
  154. * @example
  155. * $(document).ready(function() {
  156. * var oTable = $('#example').dataTable();
  157. *
  158. * // Get the data from the first row in the table
  159. * var data = oTable._('tr:first');
  160. *
  161. * // Do something useful with the data
  162. * alert( "First cell is: "+data[0] );
  163. * } );
  164. *
  165. * @example
  166. * $(document).ready(function() {
  167. * var oTable = $('#example').dataTable();
  168. *
  169. * // Filter to 'Webkit' and get all data for
  170. * oTable.fnFilter('Webkit');
  171. * var data = oTable._('tr', {"search": "applied"});
  172. *
  173. * // Do something with the data
  174. * alert( data.length+" rows matched the search" );
  175. * } );
  176. */
  177. this._ = function ( sSelector, oOpts )
  178. {
  179. return this.api(true).rows( sSelector, oOpts ).data();
  180. };
  181. /**
  182. * Create a DataTables Api instance, with the currently selected tables for
  183. * the Api's context.
  184. * @param {boolean} [traditional=false] Set the API instance's context to be
  185. * only the table referred to by the `DataTable.ext.iApiIndex` option, as was
  186. * used in the API presented by DataTables 1.9- (i.e. the traditional mode),
  187. * or if all tables captured in the jQuery object should be used.
  188. * @return {DataTables.Api}
  189. */
  190. this.api = function ( traditional )
  191. {
  192. return traditional ?
  193. new _Api(
  194. _fnSettingsFromNode( this[ _ext.iApiIndex ] )
  195. ) :
  196. new _Api( this );
  197. };
  198. /**
  199. * Add a single new row or multiple rows of data to the table. Please note
  200. * that this is suitable for client-side processing only - if you are using
  201. * server-side processing (i.e. "bServerSide": true), then to add data, you
  202. * must add it to the data source, i.e. the server-side, through an Ajax call.
  203. * @param {array|object} data The data to be added to the table. This can be:
  204. * <ul>
  205. * <li>1D array of data - add a single row with the data provided</li>
  206. * <li>2D array of arrays - add multiple rows in a single call</li>
  207. * <li>object - data object when using <i>mData</i></li>
  208. * <li>array of objects - multiple data objects when using <i>mData</i></li>
  209. * </ul>
  210. * @param {bool} [redraw=true] redraw the table or not
  211. * @returns {array} An array of integers, representing the list of indexes in
  212. * <i>aoData</i> ({@link DataTable.models.oSettings}) that have been added to
  213. * the table.
  214. * @dtopt API
  215. * @deprecated Since v1.10
  216. *
  217. * @example
  218. * // Global var for counter
  219. * var giCount = 2;
  220. *
  221. * $(document).ready(function() {
  222. * $('#example').dataTable();
  223. * } );
  224. *
  225. * function fnClickAddRow() {
  226. * $('#example').dataTable().fnAddData( [
  227. * giCount+".1",
  228. * giCount+".2",
  229. * giCount+".3",
  230. * giCount+".4" ]
  231. * );
  232. *
  233. * giCount++;
  234. * }
  235. */
  236. this.fnAddData = function( data, redraw )
  237. {
  238. var api = this.api( true );
  239. /* Check if we want to add multiple rows or not */
  240. var rows = $.isArray(data) && ( $.isArray(data[0]) || $.isPlainObject(data[0]) ) ?
  241. api.rows.add( data ) :
  242. api.row.add( data );
  243. if ( redraw === undefined || redraw ) {
  244. api.draw();
  245. }
  246. return rows.flatten().toArray();
  247. };
  248. /**
  249. * This function will make DataTables recalculate the column sizes, based on the data
  250. * contained in the table and the sizes applied to the columns (in the DOM, CSS or
  251. * through the sWidth parameter). This can be useful when the width of the table's
  252. * parent element changes (for example a window resize).
  253. * @param {boolean} [bRedraw=true] Redraw the table or not, you will typically want to
  254. * @dtopt API
  255. * @deprecated Since v1.10
  256. *
  257. * @example
  258. * $(document).ready(function() {
  259. * var oTable = $('#example').dataTable( {
  260. * "sScrollY": "200px",
  261. * "bPaginate": false
  262. * } );
  263. *
  264. * $(window).on('resize', function () {
  265. * oTable.fnAdjustColumnSizing();
  266. * } );
  267. * } );
  268. */
  269. this.fnAdjustColumnSizing = function ( bRedraw )
  270. {
  271. var api = this.api( true ).columns.adjust();
  272. var settings = api.settings()[0];
  273. var scroll = settings.oScroll;
  274. if ( bRedraw === undefined || bRedraw ) {
  275. api.draw( false );
  276. }
  277. else if ( scroll.sX !== "" || scroll.sY !== "" ) {
  278. /* If not redrawing, but scrolling, we want to apply the new column sizes anyway */
  279. _fnScrollDraw( settings );
  280. }
  281. };
  282. /**
  283. * Quickly and simply clear a table
  284. * @param {bool} [bRedraw=true] redraw the table or not
  285. * @dtopt API
  286. * @deprecated Since v1.10
  287. *
  288. * @example
  289. * $(document).ready(function() {
  290. * var oTable = $('#example').dataTable();
  291. *
  292. * // Immediately 'nuke' the current rows (perhaps waiting for an Ajax callback...)
  293. * oTable.fnClearTable();
  294. * } );
  295. */
  296. this.fnClearTable = function( bRedraw )
  297. {
  298. var api = this.api( true ).clear();
  299. if ( bRedraw === undefined || bRedraw ) {
  300. api.draw();
  301. }
  302. };
  303. /**
  304. * The exact opposite of 'opening' a row, this function will close any rows which
  305. * are currently 'open'.
  306. * @param {node} nTr the table row to 'close'
  307. * @returns {int} 0 on success, or 1 if failed (can't find the row)
  308. * @dtopt API
  309. * @deprecated Since v1.10
  310. *
  311. * @example
  312. * $(document).ready(function() {
  313. * var oTable;
  314. *
  315. * // 'open' an information row when a row is clicked on
  316. * $('#example tbody tr').click( function () {
  317. * if ( oTable.fnIsOpen(this) ) {
  318. * oTable.fnClose( this );
  319. * } else {
  320. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  321. * }
  322. * } );
  323. *
  324. * oTable = $('#example').dataTable();
  325. * } );
  326. */
  327. this.fnClose = function( nTr )
  328. {
  329. this.api( true ).row( nTr ).child.hide();
  330. };
  331. /**
  332. * Remove a row for the table
  333. * @param {mixed} target The index of the row from aoData to be deleted, or
  334. * the TR element you want to delete
  335. * @param {function|null} [callBack] Callback function
  336. * @param {bool} [redraw=true] Redraw the table or not
  337. * @returns {array} The row that was deleted
  338. * @dtopt API
  339. * @deprecated Since v1.10
  340. *
  341. * @example
  342. * $(document).ready(function() {
  343. * var oTable = $('#example').dataTable();
  344. *
  345. * // Immediately remove the first row
  346. * oTable.fnDeleteRow( 0 );
  347. * } );
  348. */
  349. this.fnDeleteRow = function( target, callback, redraw )
  350. {
  351. var api = this.api( true );
  352. var rows = api.rows( target );
  353. var settings = rows.settings()[0];
  354. var data = settings.aoData[ rows[0][0] ];
  355. rows.remove();
  356. if ( callback ) {
  357. callback.call( this, settings, data );
  358. }
  359. if ( redraw === undefined || redraw ) {
  360. api.draw();
  361. }
  362. return data;
  363. };
  364. /**
  365. * Restore the table to it's original state in the DOM by removing all of DataTables
  366. * enhancements, alterations to the DOM structure of the table and event listeners.
  367. * @param {boolean} [remove=false] Completely remove the table from the DOM
  368. * @dtopt API
  369. * @deprecated Since v1.10
  370. *
  371. * @example
  372. * $(document).ready(function() {
  373. * // This example is fairly pointless in reality, but shows how fnDestroy can be used
  374. * var oTable = $('#example').dataTable();
  375. * oTable.fnDestroy();
  376. * } );
  377. */
  378. this.fnDestroy = function ( remove )
  379. {
  380. this.api( true ).destroy( remove );
  381. };
  382. /**
  383. * Redraw the table
  384. * @param {bool} [complete=true] Re-filter and resort (if enabled) the table before the draw.
  385. * @dtopt API
  386. * @deprecated Since v1.10
  387. *
  388. * @example
  389. * $(document).ready(function() {
  390. * var oTable = $('#example').dataTable();
  391. *
  392. * // Re-draw the table - you wouldn't want to do it here, but it's an example :-)
  393. * oTable.fnDraw();
  394. * } );
  395. */
  396. this.fnDraw = function( complete )
  397. {
  398. // Note that this isn't an exact match to the old call to _fnDraw - it takes
  399. // into account the new data, but can hold position.
  400. this.api( true ).draw( complete );
  401. };
  402. /**
  403. * Filter the input based on data
  404. * @param {string} sInput String to filter the table on
  405. * @param {int|null} [iColumn] Column to limit filtering to
  406. * @param {bool} [bRegex=false] Treat as regular expression or not
  407. * @param {bool} [bSmart=true] Perform smart filtering or not
  408. * @param {bool} [bShowGlobal=true] Show the input global filter in it's input box(es)
  409. * @param {bool} [bCaseInsensitive=true] Do case-insensitive matching (true) or not (false)
  410. * @dtopt API
  411. * @deprecated Since v1.10
  412. *
  413. * @example
  414. * $(document).ready(function() {
  415. * var oTable = $('#example').dataTable();
  416. *
  417. * // Sometime later - filter...
  418. * oTable.fnFilter( 'test string' );
  419. * } );
  420. */
  421. this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal, bCaseInsensitive )
  422. {
  423. var api = this.api( true );
  424. if ( iColumn === null || iColumn === undefined ) {
  425. api.search( sInput, bRegex, bSmart, bCaseInsensitive );
  426. }
  427. else {
  428. api.column( iColumn ).search( sInput, bRegex, bSmart, bCaseInsensitive );
  429. }
  430. api.draw();
  431. };
  432. /**
  433. * Get the data for the whole table, an individual row or an individual cell based on the
  434. * provided parameters.
  435. * @param {int|node} [src] A TR row node, TD/TH cell node or an integer. If given as
  436. * a TR node then the data source for the whole row will be returned. If given as a
  437. * TD/TH cell node then iCol will be automatically calculated and the data for the
  438. * cell returned. If given as an integer, then this is treated as the aoData internal
  439. * data index for the row (see fnGetPosition) and the data for that row used.
  440. * @param {int} [col] Optional column index that you want the data of.
  441. * @returns {array|object|string} If mRow is undefined, then the data for all rows is
  442. * returned. If mRow is defined, just data for that row, and is iCol is
  443. * defined, only data for the designated cell is returned.
  444. * @dtopt API
  445. * @deprecated Since v1.10
  446. *
  447. * @example
  448. * // Row data
  449. * $(document).ready(function() {
  450. * oTable = $('#example').dataTable();
  451. *
  452. * oTable.$('tr').click( function () {
  453. * var data = oTable.fnGetData( this );
  454. * // ... do something with the array / object of data for the row
  455. * } );
  456. * } );
  457. *
  458. * @example
  459. * // Individual cell data
  460. * $(document).ready(function() {
  461. * oTable = $('#example').dataTable();
  462. *
  463. * oTable.$('td').click( function () {
  464. * var sData = oTable.fnGetData( this );
  465. * alert( 'The cell clicked on had the value of '+sData );
  466. * } );
  467. * } );
  468. */
  469. this.fnGetData = function( src, col )
  470. {
  471. var api = this.api( true );
  472. if ( src !== undefined ) {
  473. var type = src.nodeName ? src.nodeName.toLowerCase() : '';
  474. return col !== undefined || type == 'td' || type == 'th' ?
  475. api.cell( src, col ).data() :
  476. api.row( src ).data() || null;
  477. }
  478. return api.data().toArray();
  479. };
  480. /**
  481. * Get an array of the TR nodes that are used in the table's body. Note that you will
  482. * typically want to use the '$' API method in preference to this as it is more
  483. * flexible.
  484. * @param {int} [iRow] Optional row index for the TR element you want
  485. * @returns {array|node} If iRow is undefined, returns an array of all TR elements
  486. * in the table's body, or iRow is defined, just the TR element requested.
  487. * @dtopt API
  488. * @deprecated Since v1.10
  489. *
  490. * @example
  491. * $(document).ready(function() {
  492. * var oTable = $('#example').dataTable();
  493. *
  494. * // Get the nodes from the table
  495. * var nNodes = oTable.fnGetNodes( );
  496. * } );
  497. */
  498. this.fnGetNodes = function( iRow )
  499. {
  500. var api = this.api( true );
  501. return iRow !== undefined ?
  502. api.row( iRow ).node() :
  503. api.rows().nodes().flatten().toArray();
  504. };
  505. /**
  506. * Get the array indexes of a particular cell from it's DOM element
  507. * and column index including hidden columns
  508. * @param {node} node this can either be a TR, TD or TH in the table's body
  509. * @returns {int} If nNode is given as a TR, then a single index is returned, or
  510. * if given as a cell, an array of [row index, column index (visible),
  511. * column index (all)] is given.
  512. * @dtopt API
  513. * @deprecated Since v1.10
  514. *
  515. * @example
  516. * $(document).ready(function() {
  517. * $('#example tbody td').click( function () {
  518. * // Get the position of the current data from the node
  519. * var aPos = oTable.fnGetPosition( this );
  520. *
  521. * // Get the data array for this row
  522. * var aData = oTable.fnGetData( aPos[0] );
  523. *
  524. * // Update the data array and return the value
  525. * aData[ aPos[1] ] = 'clicked';
  526. * this.innerHTML = 'clicked';
  527. * } );
  528. *
  529. * // Init DataTables
  530. * oTable = $('#example').dataTable();
  531. * } );
  532. */
  533. this.fnGetPosition = function( node )
  534. {
  535. var api = this.api( true );
  536. var nodeName = node.nodeName.toUpperCase();
  537. if ( nodeName == 'TR' ) {
  538. return api.row( node ).index();
  539. }
  540. else if ( nodeName == 'TD' || nodeName == 'TH' ) {
  541. var cell = api.cell( node ).index();
  542. return [
  543. cell.row,
  544. cell.columnVisible,
  545. cell.column
  546. ];
  547. }
  548. return null;
  549. };
  550. /**
  551. * Check to see if a row is 'open' or not.
  552. * @param {node} nTr the table row to check
  553. * @returns {boolean} true if the row is currently open, false otherwise
  554. * @dtopt API
  555. * @deprecated Since v1.10
  556. *
  557. * @example
  558. * $(document).ready(function() {
  559. * var oTable;
  560. *
  561. * // 'open' an information row when a row is clicked on
  562. * $('#example tbody tr').click( function () {
  563. * if ( oTable.fnIsOpen(this) ) {
  564. * oTable.fnClose( this );
  565. * } else {
  566. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  567. * }
  568. * } );
  569. *
  570. * oTable = $('#example').dataTable();
  571. * } );
  572. */
  573. this.fnIsOpen = function( nTr )
  574. {
  575. return this.api( true ).row( nTr ).child.isShown();
  576. };
  577. /**
  578. * This function will place a new row directly after a row which is currently
  579. * on display on the page, with the HTML contents that is passed into the
  580. * function. This can be used, for example, to ask for confirmation that a
  581. * particular record should be deleted.
  582. * @param {node} nTr The table row to 'open'
  583. * @param {string|node|jQuery} mHtml The HTML to put into the row
  584. * @param {string} sClass Class to give the new TD cell
  585. * @returns {node} The row opened. Note that if the table row passed in as the
  586. * first parameter, is not found in the table, this method will silently
  587. * return.
  588. * @dtopt API
  589. * @deprecated Since v1.10
  590. *
  591. * @example
  592. * $(document).ready(function() {
  593. * var oTable;
  594. *
  595. * // 'open' an information row when a row is clicked on
  596. * $('#example tbody tr').click( function () {
  597. * if ( oTable.fnIsOpen(this) ) {
  598. * oTable.fnClose( this );
  599. * } else {
  600. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  601. * }
  602. * } );
  603. *
  604. * oTable = $('#example').dataTable();
  605. * } );
  606. */
  607. this.fnOpen = function( nTr, mHtml, sClass )
  608. {
  609. return this.api( true )
  610. .row( nTr )
  611. .child( mHtml, sClass )
  612. .show()
  613. .child()[0];
  614. };
  615. /**
  616. * Change the pagination - provides the internal logic for pagination in a simple API
  617. * function. With this function you can have a DataTables table go to the next,
  618. * previous, first or last pages.
  619. * @param {string|int} mAction Paging action to take: "first", "previous", "next" or "last"
  620. * or page number to jump to (integer), note that page 0 is the first page.
  621. * @param {bool} [bRedraw=true] Redraw the table or not
  622. * @dtopt API
  623. * @deprecated Since v1.10
  624. *
  625. * @example
  626. * $(document).ready(function() {
  627. * var oTable = $('#example').dataTable();
  628. * oTable.fnPageChange( 'next' );
  629. * } );
  630. */
  631. this.fnPageChange = function ( mAction, bRedraw )
  632. {
  633. var api = this.api( true ).page( mAction );
  634. if ( bRedraw === undefined || bRedraw ) {
  635. api.draw(false);
  636. }
  637. };
  638. /**
  639. * Show a particular column
  640. * @param {int} iCol The column whose display should be changed
  641. * @param {bool} bShow Show (true) or hide (false) the column
  642. * @param {bool} [bRedraw=true] Redraw the table or not
  643. * @dtopt API
  644. * @deprecated Since v1.10
  645. *
  646. * @example
  647. * $(document).ready(function() {
  648. * var oTable = $('#example').dataTable();
  649. *
  650. * // Hide the second column after initialisation
  651. * oTable.fnSetColumnVis( 1, false );
  652. * } );
  653. */
  654. this.fnSetColumnVis = function ( iCol, bShow, bRedraw )
  655. {
  656. var api = this.api( true ).column( iCol ).visible( bShow );
  657. if ( bRedraw === undefined || bRedraw ) {
  658. api.columns.adjust().draw();
  659. }
  660. };
  661. /**
  662. * Get the settings for a particular table for external manipulation
  663. * @returns {object} DataTables settings object. See
  664. * {@link DataTable.models.oSettings}
  665. * @dtopt API
  666. * @deprecated Since v1.10
  667. *
  668. * @example
  669. * $(document).ready(function() {
  670. * var oTable = $('#example').dataTable();
  671. * var oSettings = oTable.fnSettings();
  672. *
  673. * // Show an example parameter from the settings
  674. * alert( oSettings._iDisplayStart );
  675. * } );
  676. */
  677. this.fnSettings = function()
  678. {
  679. return _fnSettingsFromNode( this[_ext.iApiIndex] );
  680. };
  681. /**
  682. * Sort the table by a particular column
  683. * @param {int} iCol the data index to sort on. Note that this will not match the
  684. * 'display index' if you have hidden data entries
  685. * @dtopt API
  686. * @deprecated Since v1.10
  687. *
  688. * @example
  689. * $(document).ready(function() {
  690. * var oTable = $('#example').dataTable();
  691. *
  692. * // Sort immediately with columns 0 and 1
  693. * oTable.fnSort( [ [0,'asc'], [1,'asc'] ] );
  694. * } );
  695. */
  696. this.fnSort = function( aaSort )
  697. {
  698. this.api( true ).order( aaSort ).draw();
  699. };
  700. /**
  701. * Attach a sort listener to an element for a given column
  702. * @param {node} nNode the element to attach the sort listener to
  703. * @param {int} iColumn the column that a click on this node will sort on
  704. * @param {function} [fnCallback] callback function when sort is run
  705. * @dtopt API
  706. * @deprecated Since v1.10
  707. *
  708. * @example
  709. * $(document).ready(function() {
  710. * var oTable = $('#example').dataTable();
  711. *
  712. * // Sort on column 1, when 'sorter' is clicked on
  713. * oTable.fnSortListener( document.getElementById('sorter'), 1 );
  714. * } );
  715. */
  716. this.fnSortListener = function( nNode, iColumn, fnCallback )
  717. {
  718. this.api( true ).order.listener( nNode, iColumn, fnCallback );
  719. };
  720. /**
  721. * Update a table cell or row - this method will accept either a single value to
  722. * update the cell with, an array of values with one element for each column or
  723. * an object in the same format as the original data source. The function is
  724. * self-referencing in order to make the multi column updates easier.
  725. * @param {object|array|string} mData Data to update the cell/row with
  726. * @param {node|int} mRow TR element you want to update or the aoData index
  727. * @param {int} [iColumn] The column to update, give as null or undefined to
  728. * update a whole row.
  729. * @param {bool} [bRedraw=true] Redraw the table or not
  730. * @param {bool} [bAction=true] Perform pre-draw actions or not
  731. * @returns {int} 0 on success, 1 on error
  732. * @dtopt API
  733. * @deprecated Since v1.10
  734. *
  735. * @example
  736. * $(document).ready(function() {
  737. * var oTable = $('#example').dataTable();
  738. * oTable.fnUpdate( 'Example update', 0, 0 ); // Single cell
  739. * oTable.fnUpdate( ['a', 'b', 'c', 'd', 'e'], $('tbody tr')[0] ); // Row
  740. * } );
  741. */
  742. this.fnUpdate = function( mData, mRow, iColumn, bRedraw, bAction )
  743. {
  744. var api = this.api( true );
  745. if ( iColumn === undefined || iColumn === null ) {
  746. api.row( mRow ).data( mData );
  747. }
  748. else {
  749. api.cell( mRow, iColumn ).data( mData );
  750. }
  751. if ( bAction === undefined || bAction ) {
  752. api.columns.adjust();
  753. }
  754. if ( bRedraw === undefined || bRedraw ) {
  755. api.draw();
  756. }
  757. return 0;
  758. };
  759. /**
  760. * Provide a common method for plug-ins to check the version of DataTables being used, in order
  761. * to ensure compatibility.
  762. * @param {string} sVersion Version string to check for, in the format "X.Y.Z". Note that the
  763. * formats "X" and "X.Y" are also acceptable.
  764. * @returns {boolean} true if this version of DataTables is greater or equal to the required
  765. * version, or false if this version of DataTales is not suitable
  766. * @method
  767. * @dtopt API
  768. * @deprecated Since v1.10
  769. *
  770. * @example
  771. * $(document).ready(function() {
  772. * var oTable = $('#example').dataTable();
  773. * alert( oTable.fnVersionCheck( '1.9.0' ) );
  774. * } );
  775. */
  776. this.fnVersionCheck = _ext.fnVersionCheck;
  777. var _that = this;
  778. var emptyInit = options === undefined;
  779. var len = this.length;
  780. if ( emptyInit ) {
  781. options = {};
  782. }
  783. this.oApi = this.internal = _ext.internal;
  784. // Extend with old style plug-in API methods
  785. for ( var fn in DataTable.ext.internal ) {
  786. if ( fn ) {
  787. this[fn] = _fnExternApiFunc(fn);
  788. }
  789. }
  790. this.each(function() {
  791. // For each initialisation we want to give it a clean initialisation
  792. // object that can be bashed around
  793. var o = {};
  794. var oInit = len > 1 ? // optimisation for single table case
  795. _fnExtend( o, options, true ) :
  796. options;
  797. /*global oInit,_that,emptyInit*/
  798. var i=0, iLen, j, jLen, k, kLen;
  799. var sId = this.getAttribute( 'id' );
  800. var bInitHandedOff = false;
  801. var defaults = DataTable.defaults;
  802. var $this = $(this);
  803. /* Sanity check */
  804. if ( this.nodeName.toLowerCase() != 'table' )
  805. {
  806. _fnLog( null, 0, 'Non-table node initialisation ('+this.nodeName+')', 2 );
  807. return;
  808. }
  809. /* Backwards compatibility for the defaults */
  810. _fnCompatOpts( defaults );
  811. _fnCompatCols( defaults.column );
  812. /* Convert the camel-case defaults to Hungarian */
  813. _fnCamelToHungarian( defaults, defaults, true );
  814. _fnCamelToHungarian( defaults.column, defaults.column, true );
  815. /* Setting up the initialisation object */
  816. _fnCamelToHungarian( defaults, $.extend( oInit, $this.data() ) );
  817. /* Check to see if we are re-initialising a table */
  818. var allSettings = DataTable.settings;
  819. for ( i=0, iLen=allSettings.length ; i<iLen ; i++ )
  820. {
  821. var s = allSettings[i];
  822. /* Base check on table node */
  823. if ( s.nTable == this || s.nTHead.parentNode == this || (s.nTFoot && s.nTFoot.parentNode == this) )
  824. {
  825. var bRetrieve = oInit.bRetrieve !== undefined ? oInit.bRetrieve : defaults.bRetrieve;
  826. var bDestroy = oInit.bDestroy !== undefined ? oInit.bDestroy : defaults.bDestroy;
  827. if ( emptyInit || bRetrieve )
  828. {
  829. return s.oInstance;
  830. }
  831. else if ( bDestroy )
  832. {
  833. s.oInstance.fnDestroy();
  834. break;
  835. }
  836. else
  837. {
  838. _fnLog( s, 0, 'Cannot reinitialise DataTable', 3 );
  839. return;
  840. }
  841. }
  842. /* If the element we are initialising has the same ID as a table which was previously
  843. * initialised, but the table nodes don't match (from before) then we destroy the old
  844. * instance by simply deleting it. This is under the assumption that the table has been
  845. * destroyed by other methods. Anyone using non-id selectors will need to do this manually
  846. */
  847. if ( s.sTableId == this.id )
  848. {
  849. allSettings.splice( i, 1 );
  850. break;
  851. }
  852. }
  853. /* Ensure the table has an ID - required for accessibility */
  854. if ( sId === null || sId === "" )
  855. {
  856. sId = "DataTables_Table_"+(DataTable.ext._unique++);
  857. this.id = sId;
  858. }
  859. /* Create the settings object for this table and set some of the default parameters */
  860. var oSettings = $.extend( true, {}, DataTable.models.oSettings, {
  861. "sDestroyWidth": $this[0].style.width,
  862. "sInstance": sId,
  863. "sTableId": sId
  864. } );
  865. oSettings.nTable = this;
  866. oSettings.oApi = _that.internal;
  867. oSettings.oInit = oInit;
  868. allSettings.push( oSettings );
  869. // Need to add the instance after the instance after the settings object has been added
  870. // to the settings array, so we can self reference the table instance if more than one
  871. oSettings.oInstance = (_that.length===1) ? _that : $this.dataTable();
  872. // Backwards compatibility, before we apply all the defaults
  873. _fnCompatOpts( oInit );
  874. if ( oInit.oLanguage )
  875. {
  876. _fnLanguageCompat( oInit.oLanguage );
  877. }
  878. // If the length menu is given, but the init display length is not, use the length menu
  879. if ( oInit.aLengthMenu && ! oInit.iDisplayLength )
  880. {
  881. oInit.iDisplayLength = $.isArray( oInit.aLengthMenu[0] ) ?
  882. oInit.aLengthMenu[0][0] : oInit.aLengthMenu[0];
  883. }
  884. // Apply the defaults and init options to make a single init object will all
  885. // options defined from defaults and instance options.
  886. oInit = _fnExtend( $.extend( true, {}, defaults ), oInit );
  887. // Map the initialisation options onto the settings object
  888. _fnMap( oSettings.oFeatures, oInit, [
  889. "bPaginate",
  890. "bLengthChange",
  891. "bFilter",
  892. "bSort",
  893. "bSortMulti",
  894. "bInfo",
  895. "bProcessing",
  896. "bAutoWidth",
  897. "bSortClasses",
  898. "bServerSide",
  899. "bDeferRender"
  900. ] );
  901. _fnMap( oSettings, oInit, [
  902. "asStripeClasses",
  903. "ajax",
  904. "fnServerData",
  905. "fnFormatNumber",
  906. "sServerMethod",
  907. "aaSorting",
  908. "aaSortingFixed",
  909. "aLengthMenu",
  910. "sPaginationType",
  911. "sAjaxSource",
  912. "sAjaxDataProp",
  913. "iStateDuration",
  914. "sDom",
  915. "bSortCellsTop",
  916. "iTabIndex",
  917. "fnStateLoadCallback",
  918. "fnStateSaveCallback",
  919. "renderer",
  920. "searchDelay",
  921. "rowId",
  922. [ "iCookieDuration", "iStateDuration" ], // backwards compat
  923. [ "oSearch", "oPreviousSearch" ],
  924. [ "aoSearchCols", "aoPreSearchCols" ],
  925. [ "iDisplayLength", "_iDisplayLength" ]
  926. ] );
  927. _fnMap( oSettings.oScroll, oInit, [
  928. [ "sScrollX", "sX" ],
  929. [ "sScrollXInner", "sXInner" ],
  930. [ "sScrollY", "sY" ],
  931. [ "bScrollCollapse", "bCollapse" ]
  932. ] );
  933. _fnMap( oSettings.oLanguage, oInit, "fnInfoCallback" );
  934. /* Callback functions which are array driven */
  935. _fnCallbackReg( oSettings, 'aoDrawCallback', oInit.fnDrawCallback, 'user' );
  936. _fnCallbackReg( oSettings, 'aoServerParams', oInit.fnServerParams, 'user' );
  937. _fnCallbackReg( oSettings, 'aoStateSaveParams', oInit.fnStateSaveParams, 'user' );
  938. _fnCallbackReg( oSettings, 'aoStateLoadParams', oInit.fnStateLoadParams, 'user' );
  939. _fnCallbackReg( oSettings, 'aoStateLoaded', oInit.fnStateLoaded, 'user' );
  940. _fnCallbackReg( oSettings, 'aoRowCallback', oInit.fnRowCallback, 'user' );
  941. _fnCallbackReg( oSettings, 'aoRowCreatedCallback', oInit.fnCreatedRow, 'user' );
  942. _fnCallbackReg( oSettings, 'aoHeaderCallback', oInit.fnHeaderCallback, 'user' );
  943. _fnCallbackReg( oSettings, 'aoFooterCallback', oInit.fnFooterCallback, 'user' );
  944. _fnCallbackReg( oSettings, 'aoInitComplete', oInit.fnInitComplete, 'user' );
  945. _fnCallbackReg( oSettings, 'aoPreDrawCallback', oInit.fnPreDrawCallback, 'user' );
  946. oSettings.rowIdFn = _fnGetObjectDataFn( oInit.rowId );
  947. /* Browser support detection */
  948. _fnBrowserDetect( oSettings );
  949. var oClasses = oSettings.oClasses;
  950. $.extend( oClasses, DataTable.ext.classes, oInit.oClasses );
  951. $this.addClass( oClasses.sTable );
  952. if ( oSettings.iInitDisplayStart === undefined )
  953. {
  954. /* Display start point, taking into account the save saving */
  955. oSettings.iInitDisplayStart = oInit.iDisplayStart;
  956. oSettings._iDisplayStart = oInit.iDisplayStart;
  957. }
  958. if ( oInit.iDeferLoading !== null )
  959. {
  960. oSettings.bDeferLoading = true;
  961. var tmp = $.isArray( oInit.iDeferLoading );
  962. oSettings._iRecordsDisplay = tmp ? oInit.iDeferLoading[0] : oInit.iDeferLoading;
  963. oSettings._iRecordsTotal = tmp ? oInit.iDeferLoading[1] : oInit.iDeferLoading;
  964. }
  965. /* Language definitions */
  966. var oLanguage = oSettings.oLanguage;
  967. $.extend( true, oLanguage, oInit.oLanguage );
  968. if ( oLanguage.sUrl )
  969. {
  970. /* Get the language definitions from a file - because this Ajax call makes the language
  971. * get async to the remainder of this function we use bInitHandedOff to indicate that
  972. * _fnInitialise will be fired by the returned Ajax handler, rather than the constructor
  973. */
  974. $.ajax( {
  975. dataType: 'json',
  976. url: oLanguage.sUrl,
  977. success: function ( json ) {
  978. _fnLanguageCompat( json );
  979. _fnCamelToHungarian( defaults.oLanguage, json );
  980. $.extend( true, oLanguage, json );
  981. _fnInitialise( oSettings );
  982. },
  983. error: function () {
  984. // Error occurred loading language file, continue on as best we can
  985. _fnInitialise( oSettings );
  986. }
  987. } );
  988. bInitHandedOff = true;
  989. }
  990. /*
  991. * Stripes
  992. */
  993. if ( oInit.asStripeClasses === null )
  994. {
  995. oSettings.asStripeClasses =[
  996. oClasses.sStripeOdd,
  997. oClasses.sStripeEven
  998. ];
  999. }
  1000. /* Remove row stripe classes if they are already on the table row */
  1001. var stripeClasses = oSettings.asStripeClasses;
  1002. var rowOne = $this.children('tbody').find('tr').eq(0);
  1003. if ( $.inArray( true, $.map( stripeClasses, function(el, i) {
  1004. return rowOne.hasClass(el);
  1005. } ) ) !== -1 ) {
  1006. $('tbody tr', this).removeClass( stripeClasses.join(' ') );
  1007. oSettings.asDestroyStripes = stripeClasses.slice();
  1008. }
  1009. /*
  1010. * Columns
  1011. * See if we should load columns automatically or use defined ones
  1012. */
  1013. var anThs = [];
  1014. var aoColumnsInit;
  1015. var nThead = this.getElementsByTagName('thead');
  1016. if ( nThead.length !== 0 )
  1017. {
  1018. _fnDetectHeader( oSettings.aoHeader, nThead[0] );
  1019. anThs = _fnGetUniqueThs( oSettings );
  1020. }
  1021. /* If not given a column array, generate one with nulls */
  1022. if ( oInit.aoColumns === null )
  1023. {
  1024. aoColumnsInit = [];
  1025. for ( i=0, iLen=anThs.length ; i<iLen ; i++ )
  1026. {
  1027. aoColumnsInit.push( null );
  1028. }
  1029. }
  1030. else
  1031. {
  1032. aoColumnsInit = oInit.aoColumns;
  1033. }
  1034. /* Add the columns */
  1035. for ( i=0, iLen=aoColumnsInit.length ; i<iLen ; i++ )
  1036. {
  1037. _fnAddColumn( oSettings, anThs ? anThs[i] : null );
  1038. }
  1039. /* Apply the column definitions */
  1040. _fnApplyColumnDefs( oSettings, oInit.aoColumnDefs, aoColumnsInit, function (iCol, oDef) {
  1041. _fnColumnOptions( oSettings, iCol, oDef );
  1042. } );
  1043. /* HTML5 attribute detection - build an mData object automatically if the
  1044. * attributes are found
  1045. */
  1046. if ( rowOne.length ) {
  1047. var a = function ( cell, name ) {
  1048. return cell.getAttribute( 'data-'+name ) !== null ? name : null;
  1049. };
  1050. $( rowOne[0] ).children('th, td').each( function (i, cell) {
  1051. var col = oSettings.aoColumns[i];
  1052. if ( col.mData === i ) {
  1053. var sort = a( cell, 'sort' ) || a( cell, 'order' );
  1054. var filter = a( cell, 'filter' ) || a( cell, 'search' );
  1055. if ( sort !== null || filter !== null ) {
  1056. col.mData = {
  1057. _: i+'.display',
  1058. sort: sort !== null ? i+'.@data-'+sort : undefined,
  1059. type: sort !== null ? i+'.@data-'+sort : undefined,
  1060. filter: filter !== null ? i+'.@data-'+filter : undefined
  1061. };
  1062. _fnColumnOptions( oSettings, i );
  1063. }
  1064. }
  1065. } );
  1066. }
  1067. var features = oSettings.oFeatures;
  1068. var loadedInit = function () {
  1069. /*
  1070. * Sorting
  1071. * @todo For modularisation (1.11) this needs to do into a sort start up handler
  1072. */
  1073. // If aaSorting is not defined, then we use the first indicator in asSorting
  1074. // in case that has been altered, so the default sort reflects that option
  1075. if ( oInit.aaSorting === undefined ) {
  1076. var sorting = oSettings.aaSorting;
  1077. for ( i=0, iLen=sorting.length ; i<iLen ; i++ ) {
  1078. sorting[i][1] = oSettings.aoColumns[ i ].asSorting[0];
  1079. }
  1080. }
  1081. /* Do a first pass on the sorting classes (allows any size changes to be taken into
  1082. * account, and also will apply sorting disabled classes if disabled
  1083. */
  1084. _fnSortingClasses( oSettings );
  1085. if ( features.bSort ) {
  1086. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  1087. if ( oSettings.bSorted ) {
  1088. var aSort = _fnSortFlatten( oSettings );
  1089. var sortedColumns = {};
  1090. $.each( aSort, function (i, val) {
  1091. sortedColumns[ val.src ] = val.dir;
  1092. } );
  1093. _fnCallbackFire( oSettings, null, 'order', [oSettings, aSort, sortedColumns] );
  1094. _fnSortAria( oSettings );
  1095. }
  1096. } );
  1097. }
  1098. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  1099. if ( oSettings.bSorted || _fnDataSource( oSettings ) === 'ssp' || features.bDeferRender ) {
  1100. _fnSortingClasses( oSettings );
  1101. }
  1102. }, 'sc' );
  1103. /*
  1104. * Final init
  1105. * Cache the header, body and footer as required, creating them if needed
  1106. */
  1107. // Work around for Webkit bug 83867 - store the caption-side before removing from doc
  1108. var captions = $this.children('caption').each( function () {
  1109. this._captionSide = $(this).css('caption-side');
  1110. } );
  1111. var thead = $this.children('thead');
  1112. if ( thead.length === 0 ) {
  1113. thead = $('<thead/>').appendTo($this);
  1114. }
  1115. oSettings.nTHead = thead[0];
  1116. var tbody = $this.children('tbody');
  1117. if ( tbody.length === 0 ) {
  1118. tbody = $('<tbody/>').appendTo($this);
  1119. }
  1120. oSettings.nTBody = tbody[0];
  1121. var tfoot = $this.children('tfoot');
  1122. if ( tfoot.length === 0 && captions.length > 0 && (oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "") ) {
  1123. // If we are a scrolling table, and no footer has been given, then we need to create
  1124. // a tfoot element for the caption element to be appended to
  1125. tfoot = $('<tfoot/>').appendTo($this);
  1126. }
  1127. if ( tfoot.length === 0 || tfoot.children().length === 0 ) {
  1128. $this.addClass( oClasses.sNoFooter );
  1129. }
  1130. else if ( tfoot.length > 0 ) {
  1131. oSettings.nTFoot = tfoot[0];
  1132. _fnDetectHeader( oSettings.aoFooter, oSettings.nTFoot );
  1133. }
  1134. /* Check if there is data passing into the constructor */
  1135. if ( oInit.aaData ) {
  1136. for ( i=0 ; i<oInit.aaData.length ; i++ ) {
  1137. _fnAddData( oSettings, oInit.aaData[ i ] );
  1138. }
  1139. }
  1140. else if ( oSettings.bDeferLoading || _fnDataSource( oSettings ) == 'dom' ) {
  1141. /* Grab the data from the page - only do this when deferred loading or no Ajax
  1142. * source since there is no point in reading the DOM data if we are then going
  1143. * to replace it with Ajax data
  1144. */
  1145. _fnAddTr( oSettings, $(oSettings.nTBody).children('tr') );
  1146. }
  1147. /* Copy the data index array */
  1148. oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
  1149. /* Initialisation complete - table can be drawn */
  1150. oSettings.bInitialised = true;
  1151. /* Check if we need to initialise the table (it might not have been handed off to the
  1152. * language processor)
  1153. */
  1154. if ( bInitHandedOff === false ) {
  1155. _fnInitialise( oSettings );
  1156. }
  1157. };
  1158. /* Must be done after everything which can be overridden by the state saving! */
  1159. if ( oInit.bStateSave )
  1160. {
  1161. features.bStateSave = true;
  1162. _fnCallbackReg( oSettings, 'aoDrawCallback', _fnSaveState, 'state_save' );
  1163. _fnLoadState( oSettings, oInit, loadedInit );
  1164. }
  1165. else {
  1166. loadedInit();
  1167. }
  1168. } );
  1169. _that = null;
  1170. return this;
  1171. };
  1172. /*
  1173. * It is useful to have variables which are scoped locally so only the
  1174. * DataTables functions can access them and they don't leak into global space.
  1175. * At the same time these functions are often useful over multiple files in the
  1176. * core and API, so we list, or at least document, all variables which are used
  1177. * by DataTables as private variables here. This also ensures that there is no
  1178. * clashing of variable names and that they can easily referenced for reuse.
  1179. */
  1180. // Defined else where
  1181. // _selector_run
  1182. // _selector_opts
  1183. // _selector_first
  1184. // _selector_row_indexes
  1185. var _ext; // DataTable.ext
  1186. var _Api; // DataTable.Api
  1187. var _api_register; // DataTable.Api.register
  1188. var _api_registerPlural; // DataTable.Api.registerPlural
  1189. var _re_dic = {};
  1190. var _re_new_lines = /[\r\n]/g;
  1191. var _re_html = /<.*?>/g;
  1192. // This is not strict ISO8601 - Date.parse() is quite lax, although
  1193. // implementations differ between browsers.
  1194. var _re_date = /^\d{2,4}[\.\/\-]\d{1,2}[\.\/\-]\d{1,2}([T ]{1}\d{1,2}[:\.]\d{2}([\.:]\d{2})?)?$/;
  1195. // Escape regular expression special characters
  1196. var _re_escape_regex = new RegExp( '(\\' + [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^', '-' ].join('|\\') + ')', 'g' );
  1197. // http://en.wikipedia.org/wiki/Foreign_exchange_market
  1198. // - \u20BD - Russian ruble.
  1199. // - \u20a9 - South Korean Won
  1200. // - \u20BA - Turkish Lira
  1201. // - \u20B9 - Indian Rupee
  1202. // - R - Brazil (R$) and South Africa
  1203. // - fr - Swiss Franc
  1204. // - kr - Swedish krona, Norwegian krone and Danish krone
  1205. // - \u2009 is thin space and \u202F is narrow no-break space, both used in many
  1206. // standards as thousands separators.
  1207. var _re_formatted_numeric = /[',$£€¥%\u2009\u202F\u20BD\u20a9\u20BArfk]/gi;
  1208. var _empty = function ( d ) {
  1209. return !d || d === true || d === '-' ? true : false;
  1210. };
  1211. var _intVal = function ( s ) {
  1212. var integer = parseInt( s, 10 );
  1213. return !isNaN(integer) && isFinite(s) ? integer : null;
  1214. };
  1215. // Convert from a formatted number with characters other than `.` as the
  1216. // decimal place, to a Javascript number
  1217. var _numToDecimal = function ( num, decimalPoint ) {
  1218. // Cache created regular expressions for speed as this function is called often
  1219. if ( ! _re_dic[ decimalPoint ] ) {
  1220. _re_dic[ decimalPoint ] = new RegExp( _fnEscapeRegex( decimalPoint ), 'g' );
  1221. }
  1222. return typeof num === 'string' && decimalPoint !== '.' ?
  1223. num.replace( /\./g, '' ).replace( _re_dic[ decimalPoint ], '.' ) :
  1224. num;
  1225. };
  1226. var _isNumber = function ( d, decimalPoint, formatted ) {
  1227. var strType = typeof d === 'string';
  1228. // If empty return immediately so there must be a number if it is a
  1229. // formatted string (this stops the string "k", or "kr", etc being detected
  1230. // as a formatted number for currency
  1231. if ( _empty( d ) ) {
  1232. return true;
  1233. }
  1234. if ( decimalPoint && strType ) {
  1235. d = _numToDecimal( d, decimalPoint );
  1236. }
  1237. if ( formatted && strType ) {
  1238. d = d.replace( _re_formatted_numeric, '' );
  1239. }
  1240. return !isNaN( parseFloat(d) ) && isFinite( d );
  1241. };
  1242. // A string without HTML in it can be considered to be HTML still
  1243. var _isHtml = function ( d ) {
  1244. return _empty( d ) || typeof d === 'string';
  1245. };
  1246. var _htmlNumeric = function ( d, decimalPoint, formatted ) {
  1247. if ( _empty( d ) ) {
  1248. return true;
  1249. }
  1250. var html = _isHtml( d );
  1251. return ! html ?
  1252. null :
  1253. _isNumber( _stripHtml( d ), decimalPoint, formatted ) ?
  1254. true :
  1255. null;
  1256. };
  1257. var _pluck = function ( a, prop, prop2 ) {
  1258. var out = [];
  1259. var i=0, ien=a.length;
  1260. // Could have the test in the loop for slightly smaller code, but speed
  1261. // is essential here
  1262. if ( prop2 !== undefined ) {
  1263. for ( ; i<ien ; i++ ) {
  1264. if ( a[i] && a[i][ prop ] ) {
  1265. out.push( a[i][ prop ][ prop2 ] );
  1266. }
  1267. }
  1268. }
  1269. else {
  1270. for ( ; i<ien ; i++ ) {
  1271. if ( a[i] ) {
  1272. out.push( a[i][ prop ] );
  1273. }
  1274. }
  1275. }
  1276. return out;
  1277. };
  1278. // Basically the same as _pluck, but rather than looping over `a` we use `order`
  1279. // as the indexes to pick from `a`
  1280. var _pluck_order = function ( a, order, prop, prop2 )
  1281. {
  1282. var out = [];
  1283. var i=0, ien=order.length;
  1284. // Could have the test in the loop for slightly smaller code, but speed
  1285. // is essential here
  1286. if ( prop2 !== undefined ) {
  1287. for ( ; i<ien ; i++ ) {
  1288. if ( a[ order[i] ][ prop ] ) {
  1289. out.push( a[ order[i] ][ prop ][ prop2 ] );
  1290. }
  1291. }
  1292. }
  1293. else {
  1294. for ( ; i<ien ; i++ ) {
  1295. out.push( a[ order[i] ][ prop ] );
  1296. }
  1297. }
  1298. return out;
  1299. };
  1300. var _range = function ( len, start )
  1301. {
  1302. var out = [];
  1303. var end;
  1304. if ( start === undefined ) {
  1305. start = 0;
  1306. end = len;
  1307. }
  1308. else {
  1309. end = start;
  1310. start = len;
  1311. }
  1312. for ( var i=start ; i<end ; i++ ) {
  1313. out.push( i );
  1314. }
  1315. return out;
  1316. };
  1317. var _removeEmpty = function ( a )
  1318. {
  1319. var out = [];
  1320. for ( var i=0, ien=a.length ; i<ien ; i++ ) {
  1321. if ( a[i] ) { // careful - will remove all falsy values!
  1322. out.push( a[i] );
  1323. }
  1324. }
  1325. return out;
  1326. };
  1327. var _stripHtml = function ( d ) {
  1328. return d.replace( _re_html, '' );
  1329. };
  1330. /**
  1331. * Determine if all values in the array are unique. This means we can short
  1332. * cut the _unique method at the cost of a single loop. A sorted array is used
  1333. * to easily check the values.
  1334. *
  1335. * @param {array} src Source array
  1336. * @return {boolean} true if all unique, false otherwise
  1337. * @ignore
  1338. */
  1339. var _areAllUnique = function ( src ) {
  1340. if ( src.length < 2 ) {
  1341. return true;
  1342. }
  1343. var sorted = src.slice().sort();
  1344. var last = sorted[0];
  1345. for ( var i=1, ien=sorted.length ; i<ien ; i++ ) {
  1346. if ( sorted[i] === last ) {
  1347. return false;
  1348. }
  1349. last = sorted[i];
  1350. }
  1351. return true;
  1352. };
  1353. /**
  1354. * Find the unique elements in a source array.
  1355. *
  1356. * @param {array} src Source array
  1357. * @return {array} Array of unique items
  1358. * @ignore
  1359. */
  1360. var _unique = function ( src )
  1361. {
  1362. if ( _areAllUnique( src ) ) {
  1363. return src.slice();
  1364. }
  1365. // A faster unique method is to use object keys to identify used values,
  1366. // but this doesn't work with arrays or objects, which we must also
  1367. // consider. See jsperf.com/compare-array-unique-versions/4 for more
  1368. // information.
  1369. var
  1370. out = [],
  1371. val,
  1372. i, ien=src.length,
  1373. j, k=0;
  1374. again: for ( i=0 ; i<ien ; i++ ) {
  1375. val = src[i];
  1376. for ( j=0 ; j<k ; j++ ) {
  1377. if ( out[j] === val ) {
  1378. continue again;
  1379. }
  1380. }
  1381. out.push( val );
  1382. k++;
  1383. }
  1384. return out;
  1385. };
  1386. /**
  1387. * DataTables utility methods
  1388. *
  1389. * This namespace provides helper methods that DataTables uses internally to
  1390. * create a DataTable, but which are not exclusively used only for DataTables.
  1391. * These methods can be used by extension authors to save the duplication of
  1392. * code.
  1393. *
  1394. * @namespace
  1395. */
  1396. DataTable.util = {
  1397. /**
  1398. * Throttle the calls to a function. Arguments and context are maintained
  1399. * for the throttled function.
  1400. *
  1401. * @param {function} fn Function to be called
  1402. * @param {integer} freq Call frequency in mS
  1403. * @return {function} Wrapped function
  1404. */
  1405. throttle: function ( fn, freq ) {
  1406. var
  1407. frequency = freq !== undefined ? freq : 200,
  1408. last,
  1409. timer;
  1410. return function () {
  1411. var
  1412. that = this,
  1413. now = +new Date(),
  1414. args = arguments;
  1415. if ( last && now < last + frequency ) {
  1416. clearTimeout( timer );
  1417. timer = setTimeout( function () {
  1418. last = undefined;
  1419. fn.apply( that, args );
  1420. }, frequency );
  1421. }
  1422. else {
  1423. last = now;
  1424. fn.apply( that, args );
  1425. }
  1426. };
  1427. },
  1428. /**
  1429. * Escape a string such that it can be used in a regular expression
  1430. *
  1431. * @param {string} val string to escape
  1432. * @returns {string} escaped string
  1433. */
  1434. escapeRegex: function ( val ) {
  1435. return val.replace( _re_escape_regex, '\\$1' );
  1436. }
  1437. };
  1438. /**
  1439. * Create a mapping object that allows camel case parameters to be looked up
  1440. * for their Hungarian counterparts. The mapping is stored in a private
  1441. * parameter called `_hungarianMap` which can be accessed on the source object.
  1442. * @param {object} o
  1443. * @memberof DataTable#oApi
  1444. */
  1445. function _fnHungarianMap ( o )
  1446. {
  1447. var
  1448. hungarian = 'a aa ai ao as b fn i m o s ',
  1449. match,
  1450. newKey,
  1451. map = {};
  1452. $.each( o, function (key, val) {
  1453. match = key.match(/^([^A-Z]+?)([A-Z])/);
  1454. if ( match && hungarian.indexOf(match[1]+' ') !== -1 )
  1455. {
  1456. newKey = key.replace( match[0], match[2].toLowerCase() );
  1457. map[ newKey ] = key;
  1458. if ( match[1] === 'o' )
  1459. {
  1460. _fnHungarianMap( o[key] );
  1461. }
  1462. }
  1463. } );
  1464. o._hungarianMap = map;
  1465. }
  1466. /**
  1467. * Convert from camel case parameters to Hungarian, based on a Hungarian map
  1468. * created by _fnHungarianMap.
  1469. * @param {object} src The model object which holds all parameters that can be
  1470. * mapped.
  1471. * @param {object} user The object to convert from camel case to Hungarian.
  1472. * @param {boolean} force When set to `true`, properties which already have a
  1473. * Hungarian value in the `user` object will be overwritten. Otherwise they
  1474. * won't be.
  1475. * @memberof DataTable#oApi
  1476. */
  1477. function _fnCamelToHungarian ( src, user, force )
  1478. {
  1479. if ( ! src._hungarianMap ) {
  1480. _fnHungarianMap( src );
  1481. }
  1482. var hungarianKey;
  1483. $.each( user, function (key, val) {
  1484. hungarianKey = src._hungarianMap[ key ];
  1485. if ( hungarianKey !== undefined && (force || user[hungarianKey] === undefined) )
  1486. {
  1487. // For objects, we need to buzz down into the object to copy parameters
  1488. if ( hungarianKey.charAt(0) === 'o' )
  1489. {
  1490. // Copy the camelCase options over to the hungarian
  1491. if ( ! user[ hungarianKey ] ) {
  1492. user[ hungarianKey ] = {};
  1493. }
  1494. $.extend( true, user[hungarianKey], user[key] );
  1495. _fnCamelToHungarian( src[hungarianKey], user[hungarianKey], force );
  1496. }
  1497. else {
  1498. user[hungarianKey] = user[ key ];
  1499. }
  1500. }
  1501. } );
  1502. }
  1503. /**
  1504. * Language compatibility - when certain options are given, and others aren't, we
  1505. * need to duplicate the values over, in order to provide backwards compatibility
  1506. * with older language files.
  1507. * @param {object} oSettings dataTables settings object
  1508. * @memberof DataTable#oApi
  1509. */
  1510. function _fnLanguageCompat( lang )
  1511. {
  1512. var defaults = DataTable.defaults.oLanguage;
  1513. var zeroRecords = lang.sZeroRecords;
  1514. /* Backwards compatibility - if there is no sEmptyTable given, then use the same as
  1515. * sZeroRecords - assuming that is given.
  1516. */
  1517. if ( ! lang.sEmptyTable && zeroRecords &&
  1518. defaults.sEmptyTable === "No data available in table" )
  1519. {
  1520. _fnMap( lang, lang, 'sZeroRecords', 'sEmptyTable' );
  1521. }
  1522. /* Likewise with loading records */
  1523. if ( ! lang.sLoadingRecords && zeroRecords &&
  1524. defaults.sLoadingRecords === "Loading..." )
  1525. {
  1526. _fnMap( lang, lang, 'sZeroRecords', 'sLoadingRecords' );
  1527. }
  1528. // Old parameter name of the thousands separator mapped onto the new
  1529. if ( lang.sInfoThousands ) {
  1530. lang.sThousands = lang.sInfoThousands;
  1531. }
  1532. var decimal = lang.sDecimal;
  1533. if ( decimal ) {
  1534. _addNumericSort( decimal );
  1535. }
  1536. }
  1537. /**
  1538. * Map one parameter onto another
  1539. * @param {object} o Object to map
  1540. * @param {*} knew The new parameter name
  1541. * @param {*} old The old parameter name
  1542. */
  1543. var _fnCompatMap = function ( o, knew, old ) {
  1544. if ( o[ knew ] !== undefined ) {
  1545. o[ old ] = o[ knew ];
  1546. }
  1547. };
  1548. /**
  1549. * Provide backwards compatibility for the main DT options. Note that the new
  1550. * options are mapped onto the old parameters, so this is an external interface
  1551. * change only.
  1552. * @param {object} init Object to map
  1553. */
  1554. function _fnCompatOpts ( init )
  1555. {
  1556. _fnCompatMap( init, 'ordering', 'bSort' );
  1557. _fnCompatMap( init, 'orderMulti', 'bSortMulti' );
  1558. _fnCompatMap( init, 'orderClasses', 'bSortClasses' );
  1559. _fnCompatMap( init, 'orderCellsTop', 'bSortCellsTop' );
  1560. _fnCompatMap( init, 'order', 'aaSorting' );
  1561. _fnCompatMap( init, 'orderFixed', 'aaSortingFixed' );
  1562. _fnCompatMap( init, 'paging', 'bPaginate' );
  1563. _fnCompatMap( init, 'pagingType', 'sPaginationType' );
  1564. _fnCompatMap( init, 'pageLength', 'iDisplayLength' );
  1565. _fnCompatMap( init, 'searching', 'bFilter' );
  1566. // Boolean initialisation of x-scrolling
  1567. if ( typeof init.sScrollX === 'boolean' ) {
  1568. init.sScrollX = init.sScrollX ? '100%' : '';
  1569. }
  1570. if ( typeof init.scrollX === 'boolean' ) {
  1571. init.scrollX = init.scrollX ? '100%' : '';
  1572. }
  1573. // Column search objects are in an array, so it needs to be converted
  1574. // element by element
  1575. var searchCols = init.aoSearchCols;
  1576. if ( searchCols ) {
  1577. for ( var i=0, ien=searchCols.length ; i<ien ; i++ ) {
  1578. if ( searchCols[i] ) {
  1579. _fnCamelToHungarian( DataTable.models.oSearch, searchCols[i] );
  1580. }
  1581. }
  1582. }
  1583. }
  1584. /**
  1585. * Provide backwards compatibility for column options. Note that the new options
  1586. * are mapped onto the old parameters, so this is an external interface change
  1587. * only.
  1588. * @param {object} init Object to map
  1589. */
  1590. function _fnCompatCols ( init )
  1591. {
  1592. _fnCompatMap( init, 'orderable', 'bSortable' );
  1593. _fnCompatMap( init, 'orderData', 'aDataSort' );
  1594. _fnCompatMap( init, 'orderSequence', 'asSorting' );
  1595. _fnCompatMap( init, 'orderDataType', 'sortDataType' );
  1596. // orderData can be given as an integer
  1597. var dataSort = init.aDataSort;
  1598. if ( typeof dataSort === 'number' && ! $.isArray( dataSort ) ) {
  1599. init.aDataSort = [ dataSort ];
  1600. }
  1601. }
  1602. /**
  1603. * Browser feature detection for capabilities, quirks
  1604. * @param {object} settings dataTables settings object
  1605. * @memberof DataTable#oApi
  1606. */
  1607. function _fnBrowserDetect( settings )
  1608. {
  1609. // We don't need to do this every time DataTables is constructed, the values
  1610. // calculated are specific to the browser and OS configuration which we
  1611. // don't expect to change between initialisations
  1612. if ( ! DataTable.__browser ) {
  1613. var browser = {};
  1614. DataTable.__browser = browser;
  1615. // Scrolling feature / quirks detection
  1616. var n = $('<div/>')
  1617. .css( {
  1618. position: 'fixed',
  1619. top: 0,
  1620. left: $(window).scrollLeft()*-1, // allow for scrolling
  1621. height: 1,
  1622. width: 1,
  1623. overflow: 'hidden'
  1624. } )
  1625. .append(
  1626. $('<div/>')
  1627. .css( {
  1628. position: 'absolute',
  1629. top: 1,
  1630. left: 1,
  1631. width: 100,
  1632. overflow: 'scroll'
  1633. } )
  1634. .append(
  1635. $('<div/>')
  1636. .css( {
  1637. width: '100%',
  1638. height: 10
  1639. } )
  1640. )
  1641. )
  1642. .appendTo( 'body' );
  1643. var outer = n.children();
  1644. var inner = outer.children();
  1645. // Numbers below, in order, are:
  1646. // inner.offsetWidth, inner.clientWidth, outer.offsetWidth, outer.clientWidth
  1647. //
  1648. // IE6 XP: 100 100 100 83
  1649. // IE7 Vista: 100 100 100 83
  1650. // IE 8+ Windows: 83 83 100 83
  1651. // Evergreen Windows: 83 83 100 83
  1652. // Evergreen Mac with scrollbars: 85 85 100 85
  1653. // Evergreen Mac without scrollbars: 100 100 100 100
  1654. // Get scrollbar width
  1655. browser.barWidth = outer[0].offsetWidth - outer[0].clientWidth;
  1656. // IE6/7 will oversize a width 100% element inside a scrolling element, to
  1657. // include the width of the scrollbar, while other browsers ensure the inner
  1658. // element is contained without forcing scrolling
  1659. browser.bScrollOversize = inner[0].offsetWidth === 100 && outer[0].clientWidth !== 100;
  1660. // In rtl text layout, some browsers (most, but not all) will place the
  1661. // scrollbar on the left, rather than the right.
  1662. browser.bScrollbarLeft = Math.round( inner.offset().left ) !== 1;
  1663. // IE8- don't provide height and width for getBoundingClientRect
  1664. browser.bBounding = n[0].getBoundingClientRect().width ? true : false;
  1665. n.remove();
  1666. }
  1667. $.extend( settings.oBrowser, DataTable.__browser );
  1668. settings.oScroll.iBarWidth = DataTable.__browser.barWidth;
  1669. }
  1670. /**
  1671. * Array.prototype reduce[Right] method, used for browsers which don't support
  1672. * JS 1.6. Done this way to reduce code size, since we iterate either way
  1673. * @param {object} settings dataTables settings object
  1674. * @memberof DataTable#oApi
  1675. */
  1676. function _fnReduce ( that, fn, init, start, end, inc )
  1677. {
  1678. var
  1679. i = start,
  1680. value,
  1681. isSet = false;
  1682. if ( init !== undefined ) {
  1683. value = init;
  1684. isSet = true;
  1685. }
  1686. while ( i !== end ) {
  1687. if ( ! that.hasOwnProperty(i) ) {
  1688. continue;
  1689. }
  1690. value = isSet ?
  1691. fn( value, that[i], i, that ) :
  1692. that[i];
  1693. isSet = true;
  1694. i += inc;
  1695. }
  1696. return value;
  1697. }
  1698. /**
  1699. * Add a column to the list used for the table with default values
  1700. * @param {object} oSettings dataTables settings object
  1701. * @param {node} nTh The th element for this column
  1702. * @memberof DataTable#oApi
  1703. */
  1704. function _fnAddColumn( oSettings, nTh )
  1705. {
  1706. // Add column to aoColumns array
  1707. var oDefaults = DataTable.defaults.column;
  1708. var iCol = oSettings.aoColumns.length;
  1709. var oCol = $.extend( {}, DataTable.models.oColumn, oDefaults, {
  1710. "nTh": nTh ? nTh : document.createElement('th'),
  1711. "sTitle": oDefaults.sTitle ? oDefaults.sTitle : nTh ? nTh.innerHTML : '',
  1712. "aDataSort": oDefaults.aDataSort ? oDefaults.aDataSort : [iCol],
  1713. "mData": oDefaults.mData ? oDefaults.mData : iCol,
  1714. idx: iCol
  1715. } );
  1716. oSettings.aoColumns.push( oCol );
  1717. // Add search object for column specific search. Note that the `searchCols[ iCol ]`
  1718. // passed into extend can be undefined. This allows the user to give a default
  1719. // with only some of the parameters defined, and also not give a default
  1720. var searchCols = oSettings.aoPreSearchCols;
  1721. searchCols[ iCol ] = $.extend( {}, DataTable.models.oSearch, searchCols[ iCol ] );
  1722. // Use the default column options function to initialise classes etc
  1723. _fnColumnOptions( oSettings, iCol, $(nTh).data() );
  1724. }
  1725. /**
  1726. * Apply options for a column
  1727. * @param {object} oSettings dataTables settings object
  1728. * @param {int} iCol column index to consider
  1729. * @param {object} oOptions object with sType, bVisible and bSearchable etc
  1730. * @memberof DataTable#oApi
  1731. */
  1732. function _fnColumnOptions( oSettings, iCol, oOptions )
  1733. {
  1734. var oCol = oSettings.aoColumns[ iCol ];
  1735. var oClasses = oSettings.oClasses;
  1736. var th = $(oCol.nTh);
  1737. // Try to get width information from the DOM. We can't get it from CSS
  1738. // as we'd need to parse the CSS stylesheet. `width` option can override
  1739. if ( ! oCol.sWidthOrig ) {
  1740. // Width attribute
  1741. oCol.sWidthOrig = th.attr('width') || null;
  1742. // Style attribute
  1743. var t = (th.attr('style') || '').match(/width:\s*(\d+[pxem%]+)/);
  1744. if ( t ) {
  1745. oCol.sWidthOrig = t[1];
  1746. }
  1747. }
  1748. /* User specified column options */
  1749. if ( oOptions !== undefined && oOptions !== null )
  1750. {
  1751. // Backwards compatibility
  1752. _fnCompatCols( oOptions );
  1753. // Map camel case parameters to their Hungarian counterparts
  1754. _fnCamelToHungarian( DataTable.defaults.column, oOptions );
  1755. /* Backwards compatibility for mDataProp */
  1756. if ( oOptions.mDataProp !== undefined && !oOptions.mData )
  1757. {
  1758. oOptions.mData = oOptions.mDataProp;
  1759. }
  1760. if ( oOptions.sType )
  1761. {
  1762. oCol._sManualType = oOptions.sType;
  1763. }
  1764. // `class` is a reserved word in Javascript, so we need to provide
  1765. // the ability to use a valid name for the camel case input
  1766. if ( oOptions.className && ! oOptions.sClass )
  1767. {
  1768. oOptions.sClass = oOptions.className;
  1769. }
  1770. if ( oOptions.sClass ) {
  1771. th.addClass( oOptions.sClass );
  1772. }
  1773. $.extend( oCol, oOptions );
  1774. _fnMap( oCol, oOptions, "sWidth", "sWidthOrig" );
  1775. /* iDataSort to be applied (backwards compatibility), but aDataSort will take
  1776. * priority if defined
  1777. */
  1778. if ( oOptions.iDataSort !== undefined )
  1779. {
  1780. oCol.aDataSort = [ oOptions.iDataSort ];
  1781. }
  1782. _fnMap( oCol, oOptions, "aDataSort" );
  1783. }
  1784. /* Cache the data get and set functions for speed */
  1785. var mDataSrc = oCol.mData;
  1786. var mData = _fnGetObjectDataFn( mDataSrc );
  1787. var mRender = oCol.mRender ? _fnGetObjectDataFn( oCol.mRender ) : null;
  1788. var attrTest = function( src ) {
  1789. return typeof src === 'string' && src.indexOf('@') !== -1;
  1790. };
  1791. oCol._bAttrSrc = $.isPlainObject( mDataSrc ) && (
  1792. attrTest(mDataSrc.sort) || attrTest(mDataSrc.type) || attrTest(mDataSrc.filter)
  1793. );
  1794. oCol._setter = null;
  1795. oCol.fnGetData = function (rowData, type, meta) {
  1796. var innerData = mData( rowData, type, undefined, meta );
  1797. return mRender && type ?
  1798. mRender( innerData, type, rowData, meta ) :
  1799. innerData;
  1800. };
  1801. oCol.fnSetData = function ( rowData, val, meta ) {
  1802. return _fnSetObjectDataFn( mDataSrc )( rowData, val, meta );
  1803. };
  1804. // Indicate if DataTables should read DOM data as an object or array
  1805. // Used in _fnGetRowElements
  1806. if ( typeof mDataSrc !== 'number' ) {
  1807. oSettings._rowReadObject = true;
  1808. }
  1809. /* Feature sorting overrides column specific when off */
  1810. if ( !oSettings.oFeatures.bSort )
  1811. {
  1812. oCol.bSortable = false;
  1813. th.addClass( oClasses.sSortableNone ); // Have to add class here as order event isn't called
  1814. }
  1815. /* Check that the class assignment is correct for sorting */
  1816. var bAsc = $.inArray('asc', oCol.asSorting) !== -1;
  1817. var bDesc = $.inArray('desc', oCol.asSorting) !== -1;
  1818. if ( !oCol.bSortable || (!bAsc && !bDesc) )
  1819. {
  1820. oCol.sSortingClass = oClasses.sSortableNone;
  1821. oCol.sSortingClassJUI = "";
  1822. }
  1823. else if ( bAsc && !bDesc )
  1824. {
  1825. oCol.sSortingClass = oClasses.sSortableAsc;
  1826. oCol.sSortingClassJUI = oClasses.sSortJUIAscAllowed;
  1827. }
  1828. else if ( !bAsc && bDesc )
  1829. {
  1830. oCol.sSortingClass = oClasses.sSortableDesc;
  1831. oCol.sSortingClassJUI = oClasses.sSortJUIDescAllowed;
  1832. }
  1833. else
  1834. {
  1835. oCol.sSortingClass = oClasses.sSortable;
  1836. oCol.sSortingClassJUI = oClasses.sSortJUI;
  1837. }
  1838. }
  1839. /**
  1840. * Adjust the table column widths for new data. Note: you would probably want to
  1841. * do a redraw after calling this function!
  1842. * @param {object} settings dataTables settings object
  1843. * @memberof DataTable#oApi
  1844. */
  1845. function _fnAdjustColumnSizing ( settings )
  1846. {
  1847. /* Not interested in doing column width calculation if auto-width is disabled */
  1848. if ( settings.oFeatures.bAutoWidth !== false )
  1849. {
  1850. var columns = settings.aoColumns;
  1851. _fnCalculateColumnWidths( settings );
  1852. for ( var i=0 , iLen=columns.length ; i<iLen ; i++ )
  1853. {
  1854. columns[i].nTh.style.width = columns[i].sWidth;
  1855. }
  1856. }
  1857. var scroll = settings.oScroll;
  1858. if ( scroll.sY !== '' || scroll.sX !== '')
  1859. {
  1860. _fnScrollDraw( settings );
  1861. }
  1862. _fnCallbackFire( settings, null, 'column-sizing', [settings] );
  1863. }
  1864. /**
  1865. * Covert the index of a visible column to the index in the data array (take account
  1866. * of hidden columns)
  1867. * @param {object} oSettings dataTables settings object
  1868. * @param {int} iMatch Visible column index to lookup
  1869. * @returns {int} i the data index
  1870. * @memberof DataTable#oApi
  1871. */
  1872. function _fnVisibleToColumnIndex( oSettings, iMatch )
  1873. {
  1874. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  1875. return typeof aiVis[iMatch] === 'number' ?
  1876. aiVis[iMatch] :
  1877. null;
  1878. }
  1879. /**
  1880. * Covert the index of an index in the data array and convert it to the visible
  1881. * column index (take account of hidden columns)
  1882. * @param {int} iMatch Column index to lookup
  1883. * @param {object} oSettings dataTables settings object
  1884. * @returns {int} i the data index
  1885. * @memberof DataTable#oApi
  1886. */
  1887. function _fnColumnIndexToVisible( oSettings, iMatch )
  1888. {
  1889. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  1890. var iPos = $.inArray( iMatch, aiVis );
  1891. return iPos !== -1 ? iPos : null;
  1892. }
  1893. /**
  1894. * Get the number of visible columns
  1895. * @param {object} oSettings dataTables settings object
  1896. * @returns {int} i the number of visible columns
  1897. * @memberof DataTable#oApi
  1898. */
  1899. function _fnVisbleColumns( oSettings )
  1900. {
  1901. var vis = 0;
  1902. // No reduce in IE8, use a loop for now
  1903. $.each( oSettings.aoColumns, function ( i, col ) {
  1904. if ( col.bVisible && $(col.nTh).css('display') !== 'none' ) {
  1905. vis++;
  1906. }
  1907. } );
  1908. return vis;
  1909. }
  1910. /**
  1911. * Get an array of column indexes that match a given property
  1912. * @param {object} oSettings dataTables settings object
  1913. * @param {string} sParam Parameter in aoColumns to look for - typically
  1914. * bVisible or bSearchable
  1915. * @returns {array} Array of indexes with matched properties
  1916. * @memberof DataTable#oApi
  1917. */
  1918. function _fnGetColumns( oSettings, sParam )
  1919. {
  1920. var a = [];
  1921. $.map( oSettings.aoColumns, function(val, i) {
  1922. if ( val[sParam] ) {
  1923. a.push( i );
  1924. }
  1925. } );
  1926. return a;
  1927. }
  1928. /**
  1929. * Calculate the 'type' of a column
  1930. * @param {object} settings dataTables settings object
  1931. * @memberof DataTable#oApi
  1932. */
  1933. function _fnColumnTypes ( settings )
  1934. {
  1935. var columns = settings.aoColumns;
  1936. var data = settings.aoData;
  1937. var types = DataTable.ext.type.detect;
  1938. var i, ien, j, jen, k, ken;
  1939. var col, cell, detectedType, cache;
  1940. // For each column, spin over the
  1941. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  1942. col = columns[i];
  1943. cache = [];
  1944. if ( ! col.sType && col._sManualType ) {
  1945. col.sType = col._sManualType;
  1946. }
  1947. else if ( ! col.sType ) {
  1948. for ( j=0, jen=types.length ; j<jen ; j++ ) {
  1949. for ( k=0, ken=data.length ; k<ken ; k++ ) {
  1950. // Use a cache array so we only need to get the type data
  1951. // from the formatter once (when using multiple detectors)
  1952. if ( cache[k] === undefined ) {
  1953. cache[k] = _fnGetCellData( settings, k, i, 'type' );
  1954. }
  1955. detectedType = types[j]( cache[k], settings );
  1956. // If null, then this type can't apply to this column, so
  1957. // rather than testing all cells, break out. There is an
  1958. // exception for the last type which is `html`. We need to
  1959. // scan all rows since it is possible to mix string and HTML
  1960. // types
  1961. if ( ! detectedType && j !== types.length-1 ) {
  1962. break;
  1963. }
  1964. // Only a single match is needed for html type since it is
  1965. // bottom of the pile and very similar to string
  1966. if ( detectedType === 'html' ) {
  1967. break;
  1968. }
  1969. }
  1970. // Type is valid for all data points in the column - use this
  1971. // type
  1972. if ( detectedType ) {
  1973. col.sType = detectedType;
  1974. break;
  1975. }
  1976. }
  1977. // Fall back - if no type was detected, always use string
  1978. if ( ! col.sType ) {
  1979. col.sType = 'string';
  1980. }
  1981. }
  1982. }
  1983. }
  1984. /**
  1985. * Take the column definitions and static columns arrays and calculate how
  1986. * they relate to column indexes. The callback function will then apply the
  1987. * definition found for a column to a suitable configuration object.
  1988. * @param {object} oSettings dataTables settings object
  1989. * @param {array} aoColDefs The aoColumnDefs array that is to be applied
  1990. * @param {array} aoCols The aoColumns array that defines columns individually
  1991. * @param {function} fn Callback function - takes two parameters, the calculated
  1992. * column index and the definition for that column.
  1993. * @memberof DataTable#oApi
  1994. */
  1995. function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, fn )
  1996. {
  1997. var i, iLen, j, jLen, k, kLen, def;
  1998. var columns = oSettings.aoColumns;
  1999. // Column definitions with aTargets
  2000. if ( aoColDefs )
  2001. {
  2002. /* Loop over the definitions array - loop in reverse so first instance has priority */
  2003. for ( i=aoColDefs.length-1 ; i>=0 ; i-- )
  2004. {
  2005. def = aoColDefs[i];
  2006. /* Each definition can target multiple columns, as it is an array */
  2007. var aTargets = def.targets !== undefined ?
  2008. def.targets :
  2009. def.aTargets;
  2010. if ( ! $.isArray( aTargets ) )
  2011. {
  2012. aTargets = [ aTargets ];
  2013. }
  2014. for ( j=0, jLen=aTargets.length ; j<jLen ; j++ )
  2015. {
  2016. if ( typeof aTargets[j] === 'number' && aTargets[j] >= 0 )
  2017. {
  2018. /* Add columns that we don't yet know about */
  2019. while( columns.length <= aTargets[j] )
  2020. {
  2021. _fnAddColumn( oSettings );
  2022. }
  2023. /* Integer, basic index */
  2024. fn( aTargets[j], def );
  2025. }
  2026. else if ( typeof aTargets[j] === 'number' && aTargets[j] < 0 )
  2027. {
  2028. /* Negative integer, right to left column counting */
  2029. fn( columns.length+aTargets[j], def );
  2030. }
  2031. else if ( typeof aTargets[j] === 'string' )
  2032. {
  2033. /* Class name matching on TH element */
  2034. for ( k=0, kLen=columns.length ; k<kLen ; k++ )
  2035. {
  2036. if ( aTargets[j] == "_all" ||
  2037. $(columns[k].nTh).hasClass( aTargets[j] ) )
  2038. {
  2039. fn( k, def );
  2040. }
  2041. }
  2042. }
  2043. }
  2044. }
  2045. }
  2046. // Statically defined columns array
  2047. if ( aoCols )
  2048. {
  2049. for ( i=0, iLen=aoCols.length ; i<iLen ; i++ )
  2050. {
  2051. fn( i, aoCols[i] );
  2052. }
  2053. }
  2054. }
  2055. /**
  2056. * Add a data array to the table, creating DOM node etc. This is the parallel to
  2057. * _fnGatherData, but for adding rows from a Javascript source, rather than a
  2058. * DOM source.
  2059. * @param {object} oSettings dataTables settings object
  2060. * @param {array} aData data array to be added
  2061. * @param {node} [nTr] TR element to add to the table - optional. If not given,
  2062. * DataTables will create a row automatically
  2063. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  2064. * if nTr is.
  2065. * @returns {int} >=0 if successful (index of new aoData entry), -1 if failed
  2066. * @memberof DataTable#oApi
  2067. */
  2068. function _fnAddData ( oSettings, aDataIn, nTr, anTds )
  2069. {
  2070. /* Create the object for storing information about this new row */
  2071. var iRow = oSettings.aoData.length;
  2072. var oData = $.extend( true, {}, DataTable.models.oRow, {
  2073. src: nTr ? 'dom' : 'data',
  2074. idx: iRow
  2075. } );
  2076. oData._aData = aDataIn;
  2077. oSettings.aoData.push( oData );
  2078. /* Create the cells */
  2079. var nTd, sThisType;
  2080. var columns = oSettings.aoColumns;
  2081. // Invalidate the column types as the new data needs to be revalidated
  2082. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  2083. {
  2084. columns[i].sType = null;
  2085. }
  2086. /* Add to the display array */
  2087. oSettings.aiDisplayMaster.push( iRow );
  2088. var id = oSettings.rowIdFn( aDataIn );
  2089. if ( id !== undefined ) {
  2090. oSettings.aIds[ id ] = oData;
  2091. }
  2092. /* Create the DOM information, or register it if already present */
  2093. if ( nTr || ! oSettings.oFeatures.bDeferRender )
  2094. {
  2095. _fnCreateTr( oSettings, iRow, nTr, anTds );
  2096. }
  2097. return iRow;
  2098. }
  2099. /**
  2100. * Add one or more TR elements to the table. Generally we'd expect to
  2101. * use this for reading data from a DOM sourced table, but it could be
  2102. * used for an TR element. Note that if a TR is given, it is used (i.e.
  2103. * it is not cloned).
  2104. * @param {object} settings dataTables settings object
  2105. * @param {array|node|jQuery} trs The TR element(s) to add to the table
  2106. * @returns {array} Array of indexes for the added rows
  2107. * @memberof DataTable#oApi
  2108. */
  2109. function _fnAddTr( settings, trs )
  2110. {
  2111. var row;
  2112. // Allow an individual node to be passed in
  2113. if ( ! (trs instanceof $) ) {
  2114. trs = $(trs);
  2115. }
  2116. return trs.map( function (i, el) {
  2117. row = _fnGetRowElements( settings, el );
  2118. return _fnAddData( settings, row.data, el, row.cells );
  2119. } );
  2120. }
  2121. /**
  2122. * Take a TR element and convert it to an index in aoData
  2123. * @param {object} oSettings dataTables settings object
  2124. * @param {node} n the TR element to find
  2125. * @returns {int} index if the node is found, null if not
  2126. * @memberof DataTable#oApi
  2127. */
  2128. function _fnNodeToDataIndex( oSettings, n )
  2129. {
  2130. return (n._DT_RowIndex!==undefined) ? n._DT_RowIndex : null;
  2131. }
  2132. /**
  2133. * Take a TD element and convert it into a column data index (not the visible index)
  2134. * @param {object} oSettings dataTables settings object
  2135. * @param {int} iRow The row number the TD/TH can be found in
  2136. * @param {node} n The TD/TH element to find
  2137. * @returns {int} index if the node is found, -1 if not
  2138. * @memberof DataTable#oApi
  2139. */
  2140. function _fnNodeToColumnIndex( oSettings, iRow, n )
  2141. {
  2142. return $.inArray( n, oSettings.aoData[ iRow ].anCells );
  2143. }
  2144. /**
  2145. * Get the data for a given cell from the internal cache, taking into account data mapping
  2146. * @param {object} settings dataTables settings object
  2147. * @param {int} rowIdx aoData row id
  2148. * @param {int} colIdx Column index
  2149. * @param {string} type data get type ('display', 'type' 'filter' 'sort')
  2150. * @returns {*} Cell data
  2151. * @memberof DataTable#oApi
  2152. */
  2153. function _fnGetCellData( settings, rowIdx, colIdx, type )
  2154. {
  2155. var draw = settings.iDraw;
  2156. var col = settings.aoColumns[colIdx];
  2157. var rowData = settings.aoData[rowIdx]._aData;
  2158. var defaultContent = col.sDefaultContent;
  2159. var cellData = col.fnGetData( rowData, type, {
  2160. settings: settings,
  2161. row: rowIdx,
  2162. col: colIdx
  2163. } );
  2164. if ( cellData === undefined ) {
  2165. if ( settings.iDrawError != draw && defaultContent === null ) {
  2166. _fnLog( settings, 0, "Requested unknown parameter "+
  2167. (typeof col.mData=='function' ? '{function}' : "'"+col.mData+"'")+
  2168. " for row "+rowIdx+", column "+colIdx, 4 );
  2169. settings.iDrawError = draw;
  2170. }
  2171. return defaultContent;
  2172. }
  2173. // When the data source is null and a specific data type is requested (i.e.
  2174. // not the original data), we can use default column data
  2175. if ( (cellData === rowData || cellData === null) && defaultContent !== null && type !== undefined ) {
  2176. cellData = defaultContent;
  2177. }
  2178. else if ( typeof cellData === 'function' ) {
  2179. // If the data source is a function, then we run it and use the return,
  2180. // executing in the scope of the data object (for instances)
  2181. return cellData.call( rowData );
  2182. }
  2183. if ( cellData === null && type == 'display' ) {
  2184. return '';
  2185. }
  2186. return cellData;
  2187. }
  2188. /**
  2189. * Set the value for a specific cell, into the internal data cache
  2190. * @param {object} settings dataTables settings object
  2191. * @param {int} rowIdx aoData row id
  2192. * @param {int} colIdx Column index
  2193. * @param {*} val Value to set
  2194. * @memberof DataTable#oApi
  2195. */
  2196. function _fnSetCellData( settings, rowIdx, colIdx, val )
  2197. {
  2198. var col = settings.aoColumns[colIdx];
  2199. var rowData = settings.aoData[rowIdx]._aData;
  2200. col.fnSetData( rowData, val, {
  2201. settings: settings,
  2202. row: rowIdx,
  2203. col: colIdx
  2204. } );
  2205. }
  2206. // Private variable that is used to match action syntax in the data property object
  2207. var __reArray = /\[.*?\]$/;
  2208. var __reFn = /\(\)$/;
  2209. /**
  2210. * Split string on periods, taking into account escaped periods
  2211. * @param {string} str String to split
  2212. * @return {array} Split string
  2213. */
  2214. function _fnSplitObjNotation( str )
  2215. {
  2216. return $.map( str.match(/(\\.|[^\.])+/g) || [''], function ( s ) {
  2217. return s.replace(/\\\./g, '.');
  2218. } );
  2219. }
  2220. /**
  2221. * Return a function that can be used to get data from a source object, taking
  2222. * into account the ability to use nested objects as a source
  2223. * @param {string|int|function} mSource The data source for the object
  2224. * @returns {function} Data get function
  2225. * @memberof DataTable#oApi
  2226. */
  2227. function _fnGetObjectDataFn( mSource )
  2228. {
  2229. if ( $.isPlainObject( mSource ) )
  2230. {
  2231. /* Build an object of get functions, and wrap them in a single call */
  2232. var o = {};
  2233. $.each( mSource, function (key, val) {
  2234. if ( val ) {
  2235. o[key] = _fnGetObjectDataFn( val );
  2236. }
  2237. } );
  2238. return function (data, type, row, meta) {
  2239. var t = o[type] || o._;
  2240. return t !== undefined ?
  2241. t(data, type, row, meta) :
  2242. data;
  2243. };
  2244. }
  2245. else if ( mSource === null )
  2246. {
  2247. /* Give an empty string for rendering / sorting etc */
  2248. return function (data) { // type, row and meta also passed, but not used
  2249. return data;
  2250. };
  2251. }
  2252. else if ( typeof mSource === 'function' )
  2253. {
  2254. return function (data, type, row, meta) {
  2255. return mSource( data, type, row, meta );
  2256. };
  2257. }
  2258. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  2259. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  2260. {
  2261. /* If there is a . in the source string then the data source is in a
  2262. * nested object so we loop over the data for each level to get the next
  2263. * level down. On each loop we test for undefined, and if found immediately
  2264. * return. This allows entire objects to be missing and sDefaultContent to
  2265. * be used if defined, rather than throwing an error
  2266. */
  2267. var fetchData = function (data, type, src) {
  2268. var arrayNotation, funcNotation, out, innerSrc;
  2269. if ( src !== "" )
  2270. {
  2271. var a = _fnSplitObjNotation( src );
  2272. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  2273. {
  2274. // Check if we are dealing with special notation
  2275. arrayNotation = a[i].match(__reArray);
  2276. funcNotation = a[i].match(__reFn);
  2277. if ( arrayNotation )
  2278. {
  2279. // Array notation
  2280. a[i] = a[i].replace(__reArray, '');
  2281. // Condition allows simply [] to be passed in
  2282. if ( a[i] !== "" ) {
  2283. data = data[ a[i] ];
  2284. }
  2285. out = [];
  2286. // Get the remainder of the nested object to get
  2287. a.splice( 0, i+1 );
  2288. innerSrc = a.join('.');
  2289. // Traverse each entry in the array getting the properties requested
  2290. if ( $.isArray( data ) ) {
  2291. for ( var j=0, jLen=data.length ; j<jLen ; j++ ) {
  2292. out.push( fetchData( data[j], type, innerSrc ) );
  2293. }
  2294. }
  2295. // If a string is given in between the array notation indicators, that
  2296. // is used to join the strings together, otherwise an array is returned
  2297. var join = arrayNotation[0].substring(1, arrayNotation[0].length-1);
  2298. data = (join==="") ? out : out.join(join);
  2299. // The inner call to fetchData has already traversed through the remainder
  2300. // of the source requested, so we exit from the loop
  2301. break;
  2302. }
  2303. else if ( funcNotation )
  2304. {
  2305. // Function call
  2306. a[i] = a[i].replace(__reFn, '');
  2307. data = data[ a[i] ]();
  2308. continue;
  2309. }
  2310. if ( data === null || data[ a[i] ] === undefined )
  2311. {
  2312. return undefined;
  2313. }
  2314. data = data[ a[i] ];
  2315. }
  2316. }
  2317. return data;
  2318. };
  2319. return function (data, type) { // row and meta also passed, but not used
  2320. return fetchData( data, type, mSource );
  2321. };
  2322. }
  2323. else
  2324. {
  2325. /* Array or flat object mapping */
  2326. return function (data, type) { // row and meta also passed, but not used
  2327. return data[mSource];
  2328. };
  2329. }
  2330. }
  2331. /**
  2332. * Return a function that can be used to set data from a source object, taking
  2333. * into account the ability to use nested objects as a source
  2334. * @param {string|int|function} mSource The data source for the object
  2335. * @returns {function} Data set function
  2336. * @memberof DataTable#oApi
  2337. */
  2338. function _fnSetObjectDataFn( mSource )
  2339. {
  2340. if ( $.isPlainObject( mSource ) )
  2341. {
  2342. /* Unlike get, only the underscore (global) option is used for for
  2343. * setting data since we don't know the type here. This is why an object
  2344. * option is not documented for `mData` (which is read/write), but it is
  2345. * for `mRender` which is read only.
  2346. */
  2347. return _fnSetObjectDataFn( mSource._ );
  2348. }
  2349. else if ( mSource === null )
  2350. {
  2351. /* Nothing to do when the data source is null */
  2352. return function () {};
  2353. }
  2354. else if ( typeof mSource === 'function' )
  2355. {
  2356. return function (data, val, meta) {
  2357. mSource( data, 'set', val, meta );
  2358. };
  2359. }
  2360. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  2361. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  2362. {
  2363. /* Like the get, we need to get data from a nested object */
  2364. var setData = function (data, val, src) {
  2365. var a = _fnSplitObjNotation( src ), b;
  2366. var aLast = a[a.length-1];
  2367. var arrayNotation, funcNotation, o, innerSrc;
  2368. for ( var i=0, iLen=a.length-1 ; i<iLen ; i++ )
  2369. {
  2370. // Check if we are dealing with an array notation request
  2371. arrayNotation = a[i].match(__reArray);
  2372. funcNotation = a[i].match(__reFn);
  2373. if ( arrayNotation )
  2374. {
  2375. a[i] = a[i].replace(__reArray, '');
  2376. data[ a[i] ] = [];
  2377. // Get the remainder of the nested object to set so we can recurse
  2378. b = a.slice();
  2379. b.splice( 0, i+1 );
  2380. innerSrc = b.join('.');
  2381. // Traverse each entry in the array setting the properties requested
  2382. if ( $.isArray( val ) )
  2383. {
  2384. for ( var j=0, jLen=val.length ; j<jLen ; j++ )
  2385. {
  2386. o = {};
  2387. setData( o, val[j], innerSrc );
  2388. data[ a[i] ].push( o );
  2389. }
  2390. }
  2391. else
  2392. {
  2393. // We've been asked to save data to an array, but it
  2394. // isn't array data to be saved. Best that can be done
  2395. // is to just save the value.
  2396. data[ a[i] ] = val;
  2397. }
  2398. // The inner call to setData has already traversed through the remainder
  2399. // of the source and has set the data, thus we can exit here
  2400. return;
  2401. }
  2402. else if ( funcNotation )
  2403. {
  2404. // Function call
  2405. a[i] = a[i].replace(__reFn, '');
  2406. data = data[ a[i] ]( val );
  2407. }
  2408. // If the nested object doesn't currently exist - since we are
  2409. // trying to set the value - create it
  2410. if ( data[ a[i] ] === null || data[ a[i] ] === undefined )
  2411. {
  2412. data[ a[i] ] = {};
  2413. }
  2414. data = data[ a[i] ];
  2415. }
  2416. // Last item in the input - i.e, the actual set
  2417. if ( aLast.match(__reFn ) )
  2418. {
  2419. // Function call
  2420. data = data[ aLast.replace(__reFn, '') ]( val );
  2421. }
  2422. else
  2423. {
  2424. // If array notation is used, we just want to strip it and use the property name
  2425. // and assign the value. If it isn't used, then we get the result we want anyway
  2426. data[ aLast.replace(__reArray, '') ] = val;
  2427. }
  2428. };
  2429. return function (data, val) { // meta is also passed in, but not used
  2430. return setData( data, val, mSource );
  2431. };
  2432. }
  2433. else
  2434. {
  2435. /* Array or flat object mapping */
  2436. return function (data, val) { // meta is also passed in, but not used
  2437. data[mSource] = val;
  2438. };
  2439. }
  2440. }
  2441. /**
  2442. * Return an array with the full table data
  2443. * @param {object} oSettings dataTables settings object
  2444. * @returns array {array} aData Master data array
  2445. * @memberof DataTable#oApi
  2446. */
  2447. function _fnGetDataMaster ( settings )
  2448. {
  2449. return _pluck( settings.aoData, '_aData' );
  2450. }
  2451. /**
  2452. * Nuke the table
  2453. * @param {object} oSettings dataTables settings object
  2454. * @memberof DataTable#oApi
  2455. */
  2456. function _fnClearTable( settings )
  2457. {
  2458. settings.aoData.length = 0;
  2459. settings.aiDisplayMaster.length = 0;
  2460. settings.aiDisplay.length = 0;
  2461. settings.aIds = {};
  2462. }
  2463. /**
  2464. * Take an array of integers (index array) and remove a target integer (value - not
  2465. * the key!)
  2466. * @param {array} a Index array to target
  2467. * @param {int} iTarget value to find
  2468. * @memberof DataTable#oApi
  2469. */
  2470. function _fnDeleteIndex( a, iTarget, splice )
  2471. {
  2472. var iTargetIndex = -1;
  2473. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  2474. {
  2475. if ( a[i] == iTarget )
  2476. {
  2477. iTargetIndex = i;
  2478. }
  2479. else if ( a[i] > iTarget )
  2480. {
  2481. a[i]--;
  2482. }
  2483. }
  2484. if ( iTargetIndex != -1 && splice === undefined )
  2485. {
  2486. a.splice( iTargetIndex, 1 );
  2487. }
  2488. }
  2489. /**
  2490. * Mark cached data as invalid such that a re-read of the data will occur when
  2491. * the cached data is next requested. Also update from the data source object.
  2492. *
  2493. * @param {object} settings DataTables settings object
  2494. * @param {int} rowIdx Row index to invalidate
  2495. * @param {string} [src] Source to invalidate from: undefined, 'auto', 'dom'
  2496. * or 'data'
  2497. * @param {int} [colIdx] Column index to invalidate. If undefined the whole
  2498. * row will be invalidated
  2499. * @memberof DataTable#oApi
  2500. *
  2501. * @todo For the modularisation of v1.11 this will need to become a callback, so
  2502. * the sort and filter methods can subscribe to it. That will required
  2503. * initialisation options for sorting, which is why it is not already baked in
  2504. */
  2505. function _fnInvalidate( settings, rowIdx, src, colIdx )
  2506. {
  2507. var row = settings.aoData[ rowIdx ];
  2508. var i, ien;
  2509. var cellWrite = function ( cell, col ) {
  2510. // This is very frustrating, but in IE if you just write directly
  2511. // to innerHTML, and elements that are overwritten are GC'ed,
  2512. // even if there is a reference to them elsewhere
  2513. while ( cell.childNodes.length ) {
  2514. cell.removeChild( cell.firstChild );
  2515. }
  2516. cell.innerHTML = _fnGetCellData( settings, rowIdx, col, 'display' );
  2517. };
  2518. // Are we reading last data from DOM or the data object?
  2519. if ( src === 'dom' || ((! src || src === 'auto') && row.src === 'dom') ) {
  2520. // Read the data from the DOM
  2521. row._aData = _fnGetRowElements(
  2522. settings, row, colIdx, colIdx === undefined ? undefined : row._aData
  2523. )
  2524. .data;
  2525. }
  2526. else {
  2527. // Reading from data object, update the DOM
  2528. var cells = row.anCells;
  2529. if ( cells ) {
  2530. if ( colIdx !== undefined ) {
  2531. cellWrite( cells[colIdx], colIdx );
  2532. }
  2533. else {
  2534. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  2535. cellWrite( cells[i], i );
  2536. }
  2537. }
  2538. }
  2539. }
  2540. // For both row and cell invalidation, the cached data for sorting and
  2541. // filtering is nulled out
  2542. row._aSortData = null;
  2543. row._aFilterData = null;
  2544. // Invalidate the type for a specific column (if given) or all columns since
  2545. // the data might have changed
  2546. var cols = settings.aoColumns;
  2547. if ( colIdx !== undefined ) {
  2548. cols[ colIdx ].sType = null;
  2549. }
  2550. else {
  2551. for ( i=0, ien=cols.length ; i<ien ; i++ ) {
  2552. cols[i].sType = null;
  2553. }
  2554. // Update DataTables special `DT_*` attributes for the row
  2555. _fnRowAttributes( settings, row );
  2556. }
  2557. }
  2558. /**
  2559. * Build a data source object from an HTML row, reading the contents of the
  2560. * cells that are in the row.
  2561. *
  2562. * @param {object} settings DataTables settings object
  2563. * @param {node|object} TR element from which to read data or existing row
  2564. * object from which to re-read the data from the cells
  2565. * @param {int} [colIdx] Optional column index
  2566. * @param {array|object} [d] Data source object. If `colIdx` is given then this
  2567. * parameter should also be given and will be used to write the data into.
  2568. * Only the column in question will be written
  2569. * @returns {object} Object with two parameters: `data` the data read, in
  2570. * document order, and `cells` and array of nodes (they can be useful to the
  2571. * caller, so rather than needing a second traversal to get them, just return
  2572. * them from here).
  2573. * @memberof DataTable#oApi
  2574. */
  2575. function _fnGetRowElements( settings, row, colIdx, d )
  2576. {
  2577. var
  2578. tds = [],
  2579. td = row.firstChild,
  2580. name, col, o, i=0, contents,
  2581. columns = settings.aoColumns,
  2582. objectRead = settings._rowReadObject;
  2583. // Allow the data object to be passed in, or construct
  2584. d = d !== undefined ?
  2585. d :
  2586. objectRead ?
  2587. {} :
  2588. [];
  2589. var attr = function ( str, td ) {
  2590. if ( typeof str === 'string' ) {
  2591. var idx = str.indexOf('@');
  2592. if ( idx !== -1 ) {
  2593. var attr = str.substring( idx+1 );
  2594. var setter = _fnSetObjectDataFn( str );
  2595. setter( d, td.getAttribute( attr ) );
  2596. }
  2597. }
  2598. };
  2599. // Read data from a cell and store into the data object
  2600. var cellProcess = function ( cell ) {
  2601. if ( colIdx === undefined || colIdx === i ) {
  2602. col = columns[i];
  2603. contents = $.trim(cell.innerHTML);
  2604. if ( col && col._bAttrSrc ) {
  2605. var setter = _fnSetObjectDataFn( col.mData._ );
  2606. setter( d, contents );
  2607. attr( col.mData.sort, cell );
  2608. attr( col.mData.type, cell );
  2609. attr( col.mData.filter, cell );
  2610. }
  2611. else {
  2612. // Depending on the `data` option for the columns the data can
  2613. // be read to either an object or an array.
  2614. if ( objectRead ) {
  2615. if ( ! col._setter ) {
  2616. // Cache the setter function
  2617. col._setter = _fnSetObjectDataFn( col.mData );
  2618. }
  2619. col._setter( d, contents );
  2620. }
  2621. else {
  2622. d[i] = contents;
  2623. }
  2624. }
  2625. }
  2626. i++;
  2627. };
  2628. if ( td ) {
  2629. // `tr` element was passed in
  2630. while ( td ) {
  2631. name = td.nodeName.toUpperCase();
  2632. if ( name == "TD" || name == "TH" ) {
  2633. cellProcess( td );
  2634. tds.push( td );
  2635. }
  2636. td = td.nextSibling;
  2637. }
  2638. }
  2639. else {
  2640. // Existing row object passed in
  2641. tds = row.anCells;
  2642. for ( var j=0, jen=tds.length ; j<jen ; j++ ) {
  2643. cellProcess( tds[j] );
  2644. }
  2645. }
  2646. // Read the ID from the DOM if present
  2647. var rowNode = row.firstChild ? row : row.nTr;
  2648. if ( rowNode ) {
  2649. var id = rowNode.getAttribute( 'id' );
  2650. if ( id ) {
  2651. _fnSetObjectDataFn( settings.rowId )( d, id );
  2652. }
  2653. }
  2654. return {
  2655. data: d,
  2656. cells: tds
  2657. };
  2658. }
  2659. /**
  2660. * Create a new TR element (and it's TD children) for a row
  2661. * @param {object} oSettings dataTables settings object
  2662. * @param {int} iRow Row to consider
  2663. * @param {node} [nTrIn] TR element to add to the table - optional. If not given,
  2664. * DataTables will create a row automatically
  2665. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  2666. * if nTr is.
  2667. * @memberof DataTable#oApi
  2668. */
  2669. function _fnCreateTr ( oSettings, iRow, nTrIn, anTds )
  2670. {
  2671. var
  2672. row = oSettings.aoData[iRow],
  2673. rowData = row._aData,
  2674. cells = [],
  2675. nTr, nTd, oCol,
  2676. i, iLen;
  2677. if ( row.nTr === null )
  2678. {
  2679. nTr = nTrIn || document.createElement('tr');
  2680. row.nTr = nTr;
  2681. row.anCells = cells;
  2682. /* Use a private property on the node to allow reserve mapping from the node
  2683. * to the aoData array for fast look up
  2684. */
  2685. nTr._DT_RowIndex = iRow;
  2686. /* Special parameters can be given by the data source to be used on the row */
  2687. _fnRowAttributes( oSettings, row );
  2688. /* Process each column */
  2689. for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
  2690. {
  2691. oCol = oSettings.aoColumns[i];
  2692. nTd = nTrIn ? anTds[i] : document.createElement( oCol.sCellType );
  2693. nTd._DT_CellIndex = {
  2694. row: iRow,
  2695. column: i
  2696. };
  2697. cells.push( nTd );
  2698. // Need to create the HTML if new, or if a rendering function is defined
  2699. if ( (!nTrIn || oCol.mRender || oCol.mData !== i) &&
  2700. (!$.isPlainObject(oCol.mData) || oCol.mData._ !== i+'.display')
  2701. ) {
  2702. nTd.innerHTML = _fnGetCellData( oSettings, iRow, i, 'display' );
  2703. }
  2704. /* Add user defined class */
  2705. if ( oCol.sClass )
  2706. {
  2707. nTd.className += ' '+oCol.sClass;
  2708. }
  2709. // Visibility - add or remove as required
  2710. if ( oCol.bVisible && ! nTrIn )
  2711. {
  2712. nTr.appendChild( nTd );
  2713. }
  2714. else if ( ! oCol.bVisible && nTrIn )
  2715. {
  2716. nTd.parentNode.removeChild( nTd );
  2717. }
  2718. if ( oCol.fnCreatedCell )
  2719. {
  2720. oCol.fnCreatedCell.call( oSettings.oInstance,
  2721. nTd, _fnGetCellData( oSettings, iRow, i ), rowData, iRow, i
  2722. );
  2723. }
  2724. }
  2725. _fnCallbackFire( oSettings, 'aoRowCreatedCallback', null, [nTr, rowData, iRow] );
  2726. }
  2727. // Remove once webkit bug 131819 and Chromium bug 365619 have been resolved
  2728. // and deployed
  2729. row.nTr.setAttribute( 'role', 'row' );
  2730. }
  2731. /**
  2732. * Add attributes to a row based on the special `DT_*` parameters in a data
  2733. * source object.
  2734. * @param {object} settings DataTables settings object
  2735. * @param {object} DataTables row object for the row to be modified
  2736. * @memberof DataTable#oApi
  2737. */
  2738. function _fnRowAttributes( settings, row )
  2739. {
  2740. var tr = row.nTr;
  2741. var data = row._aData;
  2742. if ( tr ) {
  2743. var id = settings.rowIdFn( data );
  2744. if ( id ) {
  2745. tr.id = id;
  2746. }
  2747. if ( data.DT_RowClass ) {
  2748. // Remove any classes added by DT_RowClass before
  2749. var a = data.DT_RowClass.split(' ');
  2750. row.__rowc = row.__rowc ?
  2751. _unique( row.__rowc.concat( a ) ) :
  2752. a;
  2753. $(tr)
  2754. .removeClass( row.__rowc.join(' ') )
  2755. .addClass( data.DT_RowClass );
  2756. }
  2757. if ( data.DT_RowAttr ) {
  2758. $(tr).attr( data.DT_RowAttr );
  2759. }
  2760. if ( data.DT_RowData ) {
  2761. $(tr).data( data.DT_RowData );
  2762. }
  2763. }
  2764. }
  2765. /**
  2766. * Create the HTML header for the table
  2767. * @param {object} oSettings dataTables settings object
  2768. * @memberof DataTable#oApi
  2769. */
  2770. function _fnBuildHead( oSettings )
  2771. {
  2772. var i, ien, cell, row, column;
  2773. var thead = oSettings.nTHead;
  2774. var tfoot = oSettings.nTFoot;
  2775. var createHeader = $('th, td', thead).length === 0;
  2776. var classes = oSettings.oClasses;
  2777. var columns = oSettings.aoColumns;
  2778. if ( createHeader ) {
  2779. row = $('<tr/>').appendTo( thead );
  2780. }
  2781. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  2782. column = columns[i];
  2783. cell = $( column.nTh ).addClass( column.sClass );
  2784. if ( createHeader ) {
  2785. cell.appendTo( row );
  2786. }
  2787. // 1.11 move into sorting
  2788. if ( oSettings.oFeatures.bSort ) {
  2789. cell.addClass( column.sSortingClass );
  2790. if ( column.bSortable !== false ) {
  2791. cell
  2792. .attr( 'tabindex', oSettings.iTabIndex )
  2793. .attr( 'aria-controls', oSettings.sTableId );
  2794. _fnSortAttachListener( oSettings, column.nTh, i );
  2795. }
  2796. }
  2797. if ( column.sTitle != cell[0].innerHTML ) {
  2798. cell.html( column.sTitle );
  2799. }
  2800. _fnRenderer( oSettings, 'header' )(
  2801. oSettings, cell, column, classes
  2802. );
  2803. }
  2804. if ( createHeader ) {
  2805. _fnDetectHeader( oSettings.aoHeader, thead );
  2806. }
  2807. /* ARIA role for the rows */
  2808. $(thead).find('>tr').attr('role', 'row');
  2809. /* Deal with the footer - add classes if required */
  2810. $(thead).find('>tr>th, >tr>td').addClass( classes.sHeaderTH );
  2811. $(tfoot).find('>tr>th, >tr>td').addClass( classes.sFooterTH );
  2812. // Cache the footer cells. Note that we only take the cells from the first
  2813. // row in the footer. If there is more than one row the user wants to
  2814. // interact with, they need to use the table().foot() method. Note also this
  2815. // allows cells to be used for multiple columns using colspan
  2816. if ( tfoot !== null ) {
  2817. var cells = oSettings.aoFooter[0];
  2818. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  2819. column = columns[i];
  2820. column.nTf = cells[i].cell;
  2821. if ( column.sClass ) {
  2822. $(column.nTf).addClass( column.sClass );
  2823. }
  2824. }
  2825. }
  2826. }
  2827. /**
  2828. * Draw the header (or footer) element based on the column visibility states. The
  2829. * methodology here is to use the layout array from _fnDetectHeader, modified for
  2830. * the instantaneous column visibility, to construct the new layout. The grid is
  2831. * traversed over cell at a time in a rows x columns grid fashion, although each
  2832. * cell insert can cover multiple elements in the grid - which is tracks using the
  2833. * aApplied array. Cell inserts in the grid will only occur where there isn't
  2834. * already a cell in that position.
  2835. * @param {object} oSettings dataTables settings object
  2836. * @param array {objects} aoSource Layout array from _fnDetectHeader
  2837. * @param {boolean} [bIncludeHidden=false] If true then include the hidden columns in the calc,
  2838. * @memberof DataTable#oApi
  2839. */
  2840. function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
  2841. {
  2842. var i, iLen, j, jLen, k, kLen, n, nLocalTr;
  2843. var aoLocal = [];
  2844. var aApplied = [];
  2845. var iColumns = oSettings.aoColumns.length;
  2846. var iRowspan, iColspan;
  2847. if ( ! aoSource )
  2848. {
  2849. return;
  2850. }
  2851. if ( bIncludeHidden === undefined )
  2852. {
  2853. bIncludeHidden = false;
  2854. }
  2855. /* Make a copy of the master layout array, but without the visible columns in it */
  2856. for ( i=0, iLen=aoSource.length ; i<iLen ; i++ )
  2857. {
  2858. aoLocal[i] = aoSource[i].slice();
  2859. aoLocal[i].nTr = aoSource[i].nTr;
  2860. /* Remove any columns which are currently hidden */
  2861. for ( j=iColumns-1 ; j>=0 ; j-- )
  2862. {
  2863. if ( !oSettings.aoColumns[j].bVisible && !bIncludeHidden )
  2864. {
  2865. aoLocal[i].splice( j, 1 );
  2866. }
  2867. }
  2868. /* Prep the applied array - it needs an element for each row */
  2869. aApplied.push( [] );
  2870. }
  2871. for ( i=0, iLen=aoLocal.length ; i<iLen ; i++ )
  2872. {
  2873. nLocalTr = aoLocal[i].nTr;
  2874. /* All cells are going to be replaced, so empty out the row */
  2875. if ( nLocalTr )
  2876. {
  2877. while( (n = nLocalTr.firstChild) )
  2878. {
  2879. nLocalTr.removeChild( n );
  2880. }
  2881. }
  2882. for ( j=0, jLen=aoLocal[i].length ; j<jLen ; j++ )
  2883. {
  2884. iRowspan = 1;
  2885. iColspan = 1;
  2886. /* Check to see if there is already a cell (row/colspan) covering our target
  2887. * insert point. If there is, then there is nothing to do.
  2888. */
  2889. if ( aApplied[i][j] === undefined )
  2890. {
  2891. nLocalTr.appendChild( aoLocal[i][j].cell );
  2892. aApplied[i][j] = 1;
  2893. /* Expand the cell to cover as many rows as needed */
  2894. while ( aoLocal[i+iRowspan] !== undefined &&
  2895. aoLocal[i][j].cell == aoLocal[i+iRowspan][j].cell )
  2896. {
  2897. aApplied[i+iRowspan][j] = 1;
  2898. iRowspan++;
  2899. }
  2900. /* Expand the cell to cover as many columns as needed */
  2901. while ( aoLocal[i][j+iColspan] !== undefined &&
  2902. aoLocal[i][j].cell == aoLocal[i][j+iColspan].cell )
  2903. {
  2904. /* Must update the applied array over the rows for the columns */
  2905. for ( k=0 ; k<iRowspan ; k++ )
  2906. {
  2907. aApplied[i+k][j+iColspan] = 1;
  2908. }
  2909. iColspan++;
  2910. }
  2911. /* Do the actual expansion in the DOM */
  2912. $(aoLocal[i][j].cell)
  2913. .attr('rowspan', iRowspan)
  2914. .attr('colspan', iColspan);
  2915. }
  2916. }
  2917. }
  2918. }
  2919. /**
  2920. * Insert the required TR nodes into the table for display
  2921. * @param {object} oSettings dataTables settings object
  2922. * @memberof DataTable#oApi
  2923. */
  2924. function _fnDraw( oSettings )
  2925. {
  2926. /* Provide a pre-callback function which can be used to cancel the draw is false is returned */
  2927. var aPreDraw = _fnCallbackFire( oSettings, 'aoPreDrawCallback', 'preDraw', [oSettings] );
  2928. if ( $.inArray( false, aPreDraw ) !== -1 )
  2929. {
  2930. _fnProcessingDisplay( oSettings, false );
  2931. return;
  2932. }
  2933. var i, iLen, n;
  2934. var anRows = [];
  2935. var iRowCount = 0;
  2936. var asStripeClasses = oSettings.asStripeClasses;
  2937. var iStripes = asStripeClasses.length;
  2938. var iOpenRows = oSettings.aoOpenRows.length;
  2939. var oLang = oSettings.oLanguage;
  2940. var iInitDisplayStart = oSettings.iInitDisplayStart;
  2941. var bServerSide = _fnDataSource( oSettings ) == 'ssp';
  2942. var aiDisplay = oSettings.aiDisplay;
  2943. oSettings.bDrawing = true;
  2944. /* Check and see if we have an initial draw position from state saving */
  2945. if ( iInitDisplayStart !== undefined && iInitDisplayStart !== -1 )
  2946. {
  2947. oSettings._iDisplayStart = bServerSide ?
  2948. iInitDisplayStart :
  2949. iInitDisplayStart >= oSettings.fnRecordsDisplay() ?
  2950. 0 :
  2951. iInitDisplayStart;
  2952. oSettings.iInitDisplayStart = -1;
  2953. }
  2954. var iDisplayStart = oSettings._iDisplayStart;
  2955. var iDisplayEnd = oSettings.fnDisplayEnd();
  2956. /* Server-side processing draw intercept */
  2957. if ( oSettings.bDeferLoading )
  2958. {
  2959. oSettings.bDeferLoading = false;
  2960. oSettings.iDraw++;
  2961. _fnProcessingDisplay( oSettings, false );
  2962. }
  2963. else if ( !bServerSide )
  2964. {
  2965. oSettings.iDraw++;
  2966. }
  2967. else if ( !oSettings.bDestroying && !_fnAjaxUpdate( oSettings ) )
  2968. {
  2969. return;
  2970. }
  2971. if ( aiDisplay.length !== 0 )
  2972. {
  2973. var iStart = bServerSide ? 0 : iDisplayStart;
  2974. var iEnd = bServerSide ? oSettings.aoData.length : iDisplayEnd;
  2975. for ( var j=iStart ; j<iEnd ; j++ )
  2976. {
  2977. var iDataIndex = aiDisplay[j];
  2978. var aoData = oSettings.aoData[ iDataIndex ];
  2979. if ( aoData.nTr === null )
  2980. {
  2981. _fnCreateTr( oSettings, iDataIndex );
  2982. }
  2983. var nRow = aoData.nTr;
  2984. /* Remove the old striping classes and then add the new one */
  2985. if ( iStripes !== 0 )
  2986. {
  2987. var sStripe = asStripeClasses[ iRowCount % iStripes ];
  2988. if ( aoData._sRowStripe != sStripe )
  2989. {
  2990. $(nRow).removeClass( aoData._sRowStripe ).addClass( sStripe );
  2991. aoData._sRowStripe = sStripe;
  2992. }
  2993. }
  2994. // Row callback functions - might want to manipulate the row
  2995. // iRowCount and j are not currently documented. Are they at all
  2996. // useful?
  2997. _fnCallbackFire( oSettings, 'aoRowCallback', null,
  2998. [nRow, aoData._aData, iRowCount, j] );
  2999. anRows.push( nRow );
  3000. iRowCount++;
  3001. }
  3002. }
  3003. else
  3004. {
  3005. /* Table is empty - create a row with an empty message in it */
  3006. var sZero = oLang.sZeroRecords;
  3007. if ( oSettings.iDraw == 1 && _fnDataSource( oSettings ) == 'ajax' )
  3008. {
  3009. sZero = oLang.sLoadingRecords;
  3010. }
  3011. else if ( oLang.sEmptyTable && oSettings.fnRecordsTotal() === 0 )
  3012. {
  3013. sZero = oLang.sEmptyTable;
  3014. }
  3015. anRows[ 0 ] = $( '<tr/>', { 'class': iStripes ? asStripeClasses[0] : '' } )
  3016. .append( $('<td />', {
  3017. 'valign': 'top',
  3018. 'colSpan': _fnVisbleColumns( oSettings ),
  3019. 'class': oSettings.oClasses.sRowEmpty
  3020. } ).html( sZero ) )[0];
  3021. }
  3022. /* Header and footer callbacks */
  3023. _fnCallbackFire( oSettings, 'aoHeaderCallback', 'header', [ $(oSettings.nTHead).children('tr')[0],
  3024. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  3025. _fnCallbackFire( oSettings, 'aoFooterCallback', 'footer', [ $(oSettings.nTFoot).children('tr')[0],
  3026. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  3027. var body = $(oSettings.nTBody);
  3028. body.children().detach();
  3029. body.append( $(anRows) );
  3030. /* Call all required callback functions for the end of a draw */
  3031. _fnCallbackFire( oSettings, 'aoDrawCallback', 'draw', [oSettings] );
  3032. /* Draw is complete, sorting and filtering must be as well */
  3033. oSettings.bSorted = false;
  3034. oSettings.bFiltered = false;
  3035. oSettings.bDrawing = false;
  3036. }
  3037. /**
  3038. * Redraw the table - taking account of the various features which are enabled
  3039. * @param {object} oSettings dataTables settings object
  3040. * @param {boolean} [holdPosition] Keep the current paging position. By default
  3041. * the paging is reset to the first page
  3042. * @memberof DataTable#oApi
  3043. */
  3044. function _fnReDraw( settings, holdPosition )
  3045. {
  3046. var
  3047. features = settings.oFeatures,
  3048. sort = features.bSort,
  3049. filter = features.bFilter;
  3050. if ( sort ) {
  3051. _fnSort( settings );
  3052. }
  3053. if ( filter ) {
  3054. _fnFilterComplete( settings, settings.oPreviousSearch );
  3055. }
  3056. else {
  3057. // No filtering, so we want to just use the display master
  3058. settings.aiDisplay = settings.aiDisplayMaster.slice();
  3059. }
  3060. if ( holdPosition !== true ) {
  3061. settings._iDisplayStart = 0;
  3062. }
  3063. // Let any modules know about the draw hold position state (used by
  3064. // scrolling internally)
  3065. settings._drawHold = holdPosition;
  3066. _fnDraw( settings );
  3067. settings._drawHold = false;
  3068. }
  3069. /**
  3070. * Add the options to the page HTML for the table
  3071. * @param {object} oSettings dataTables settings object
  3072. * @memberof DataTable#oApi
  3073. */
  3074. function _fnAddOptionsHtml ( oSettings )
  3075. {
  3076. var classes = oSettings.oClasses;
  3077. var table = $(oSettings.nTable);
  3078. var holding = $('<div/>').insertBefore( table ); // Holding element for speed
  3079. var features = oSettings.oFeatures;
  3080. // All DataTables are wrapped in a div
  3081. var insert = $('<div/>', {
  3082. id: oSettings.sTableId+'_wrapper',
  3083. 'class': classes.sWrapper + (oSettings.nTFoot ? '' : ' '+classes.sNoFooter)
  3084. } );
  3085. oSettings.nHolding = holding[0];
  3086. oSettings.nTableWrapper = insert[0];
  3087. oSettings.nTableReinsertBefore = oSettings.nTable.nextSibling;
  3088. /* Loop over the user set positioning and place the elements as needed */
  3089. var aDom = oSettings.sDom.split('');
  3090. var featureNode, cOption, nNewNode, cNext, sAttr, j;
  3091. for ( var i=0 ; i<aDom.length ; i++ )
  3092. {
  3093. featureNode = null;
  3094. cOption = aDom[i];
  3095. if ( cOption == '<' )
  3096. {
  3097. /* New container div */
  3098. nNewNode = $('<div/>')[0];
  3099. /* Check to see if we should append an id and/or a class name to the container */
  3100. cNext = aDom[i+1];
  3101. if ( cNext == "'" || cNext == '"' )
  3102. {
  3103. sAttr = "";
  3104. j = 2;
  3105. while ( aDom[i+j] != cNext )
  3106. {
  3107. sAttr += aDom[i+j];
  3108. j++;
  3109. }
  3110. /* Replace jQuery UI constants @todo depreciated */
  3111. if ( sAttr == "H" )
  3112. {
  3113. sAttr = classes.sJUIHeader;
  3114. }
  3115. else if ( sAttr == "F" )
  3116. {
  3117. sAttr = classes.sJUIFooter;
  3118. }
  3119. /* The attribute can be in the format of "#id.class", "#id" or "class" This logic
  3120. * breaks the string into parts and applies them as needed
  3121. */
  3122. if ( sAttr.indexOf('.') != -1 )
  3123. {
  3124. var aSplit = sAttr.split('.');
  3125. nNewNode.id = aSplit[0].substr(1, aSplit[0].length-1);
  3126. nNewNode.className = aSplit[1];
  3127. }
  3128. else if ( sAttr.charAt(0) == "#" )
  3129. {
  3130. nNewNode.id = sAttr.substr(1, sAttr.length-1);
  3131. }
  3132. else
  3133. {
  3134. nNewNode.className = sAttr;
  3135. }
  3136. i += j; /* Move along the position array */
  3137. }
  3138. insert.append( nNewNode );
  3139. insert = $(nNewNode);
  3140. }
  3141. else if ( cOption == '>' )
  3142. {
  3143. /* End container div */
  3144. insert = insert.parent();
  3145. }
  3146. // @todo Move options into their own plugins?
  3147. else if ( cOption == 'l' && features.bPaginate && features.bLengthChange )
  3148. {
  3149. /* Length */
  3150. featureNode = _fnFeatureHtmlLength( oSettings );
  3151. }
  3152. else if ( cOption == 'f' && features.bFilter )
  3153. {
  3154. /* Filter */
  3155. featureNode = _fnFeatureHtmlFilter( oSettings );
  3156. }
  3157. else if ( cOption == 'r' && features.bProcessing )
  3158. {
  3159. /* pRocessing */
  3160. featureNode = _fnFeatureHtmlProcessing( oSettings );
  3161. }
  3162. else if ( cOption == 't' )
  3163. {
  3164. /* Table */
  3165. featureNode = _fnFeatureHtmlTable( oSettings );
  3166. }
  3167. else if ( cOption == 'i' && features.bInfo )
  3168. {
  3169. /* Info */
  3170. featureNode = _fnFeatureHtmlInfo( oSettings );
  3171. }
  3172. else if ( cOption == 'p' && features.bPaginate )
  3173. {
  3174. /* Pagination */
  3175. featureNode = _fnFeatureHtmlPaginate( oSettings );
  3176. }
  3177. else if ( DataTable.ext.feature.length !== 0 )
  3178. {
  3179. /* Plug-in features */
  3180. var aoFeatures = DataTable.ext.feature;
  3181. for ( var k=0, kLen=aoFeatures.length ; k<kLen ; k++ )
  3182. {
  3183. if ( cOption == aoFeatures[k].cFeature )
  3184. {
  3185. featureNode = aoFeatures[k].fnInit( oSettings );
  3186. break;
  3187. }
  3188. }
  3189. }
  3190. /* Add to the 2D features array */
  3191. if ( featureNode )
  3192. {
  3193. var aanFeatures = oSettings.aanFeatures;
  3194. if ( ! aanFeatures[cOption] )
  3195. {
  3196. aanFeatures[cOption] = [];
  3197. }
  3198. aanFeatures[cOption].push( featureNode );
  3199. insert.append( featureNode );
  3200. }
  3201. }
  3202. /* Built our DOM structure - replace the holding div with what we want */
  3203. holding.replaceWith( insert );
  3204. oSettings.nHolding = null;
  3205. }
  3206. /**
  3207. * Use the DOM source to create up an array of header cells. The idea here is to
  3208. * create a layout grid (array) of rows x columns, which contains a reference
  3209. * to the cell that that point in the grid (regardless of col/rowspan), such that
  3210. * any column / row could be removed and the new grid constructed
  3211. * @param array {object} aLayout Array to store the calculated layout in
  3212. * @param {node} nThead The header/footer element for the table
  3213. * @memberof DataTable#oApi
  3214. */
  3215. function _fnDetectHeader ( aLayout, nThead )
  3216. {
  3217. var nTrs = $(nThead).children('tr');
  3218. var nTr, nCell;
  3219. var i, k, l, iLen, jLen, iColShifted, iColumn, iColspan, iRowspan;
  3220. var bUnique;
  3221. var fnShiftCol = function ( a, i, j ) {
  3222. var k = a[i];
  3223. while ( k[j] ) {
  3224. j++;
  3225. }
  3226. return j;
  3227. };
  3228. aLayout.splice( 0, aLayout.length );
  3229. /* We know how many rows there are in the layout - so prep it */
  3230. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  3231. {
  3232. aLayout.push( [] );
  3233. }
  3234. /* Calculate a layout array */
  3235. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  3236. {
  3237. nTr = nTrs[i];
  3238. iColumn = 0;
  3239. /* For every cell in the row... */
  3240. nCell = nTr.firstChild;
  3241. while ( nCell ) {
  3242. if ( nCell.nodeName.toUpperCase() == "TD" ||
  3243. nCell.nodeName.toUpperCase() == "TH" )
  3244. {
  3245. /* Get the col and rowspan attributes from the DOM and sanitise them */
  3246. iColspan = nCell.getAttribute('colspan') * 1;
  3247. iRowspan = nCell.getAttribute('rowspan') * 1;
  3248. iColspan = (!iColspan || iColspan===0 || iColspan===1) ? 1 : iColspan;
  3249. iRowspan = (!iRowspan || iRowspan===0 || iRowspan===1) ? 1 : iRowspan;
  3250. /* There might be colspan cells already in this row, so shift our target
  3251. * accordingly
  3252. */
  3253. iColShifted = fnShiftCol( aLayout, i, iColumn );
  3254. /* Cache calculation for unique columns */
  3255. bUnique = iColspan === 1 ? true : false;
  3256. /* If there is col / rowspan, copy the information into the layout grid */
  3257. for ( l=0 ; l<iColspan ; l++ )
  3258. {
  3259. for ( k=0 ; k<iRowspan ; k++ )
  3260. {
  3261. aLayout[i+k][iColShifted+l] = {
  3262. "cell": nCell,
  3263. "unique": bUnique
  3264. };
  3265. aLayout[i+k].nTr = nTr;
  3266. }
  3267. }
  3268. }
  3269. nCell = nCell.nextSibling;
  3270. }
  3271. }
  3272. }
  3273. /**
  3274. * Get an array of unique th elements, one for each column
  3275. * @param {object} oSettings dataTables settings object
  3276. * @param {node} nHeader automatically detect the layout from this node - optional
  3277. * @param {array} aLayout thead/tfoot layout from _fnDetectHeader - optional
  3278. * @returns array {node} aReturn list of unique th's
  3279. * @memberof DataTable#oApi
  3280. */
  3281. function _fnGetUniqueThs ( oSettings, nHeader, aLayout )
  3282. {
  3283. var aReturn = [];
  3284. if ( !aLayout )
  3285. {
  3286. aLayout = oSettings.aoHeader;
  3287. if ( nHeader )
  3288. {
  3289. aLayout = [];
  3290. _fnDetectHeader( aLayout, nHeader );
  3291. }
  3292. }
  3293. for ( var i=0, iLen=aLayout.length ; i<iLen ; i++ )
  3294. {
  3295. for ( var j=0, jLen=aLayout[i].length ; j<jLen ; j++ )
  3296. {
  3297. if ( aLayout[i][j].unique &&
  3298. (!aReturn[j] || !oSettings.bSortCellsTop) )
  3299. {
  3300. aReturn[j] = aLayout[i][j].cell;
  3301. }
  3302. }
  3303. }
  3304. return aReturn;
  3305. }
  3306. /**
  3307. * Create an Ajax call based on the table's settings, taking into account that
  3308. * parameters can have multiple forms, and backwards compatibility.
  3309. *
  3310. * @param {object} oSettings dataTables settings object
  3311. * @param {array} data Data to send to the server, required by
  3312. * DataTables - may be augmented by developer callbacks
  3313. * @param {function} fn Callback function to run when data is obtained
  3314. */
  3315. function _fnBuildAjax( oSettings, data, fn )
  3316. {
  3317. // Compatibility with 1.9-, allow fnServerData and event to manipulate
  3318. _fnCallbackFire( oSettings, 'aoServerParams', 'serverParams', [data] );
  3319. // Convert to object based for 1.10+ if using the old array scheme which can
  3320. // come from server-side processing or serverParams
  3321. if ( data && $.isArray(data) ) {
  3322. var tmp = {};
  3323. var rbracket = /(.*?)\[\]$/;
  3324. $.each( data, function (key, val) {
  3325. var match = val.name.match(rbracket);
  3326. if ( match ) {
  3327. // Support for arrays
  3328. var name = match[0];
  3329. if ( ! tmp[ name ] ) {
  3330. tmp[ name ] = [];
  3331. }
  3332. tmp[ name ].push( val.value );
  3333. }
  3334. else {
  3335. tmp[val.name] = val.value;
  3336. }
  3337. } );
  3338. data = tmp;
  3339. }
  3340. var ajaxData;
  3341. var ajax = oSettings.ajax;
  3342. var instance = oSettings.oInstance;
  3343. var callback = function ( json ) {
  3344. _fnCallbackFire( oSettings, null, 'xhr', [oSettings, json, oSettings.jqXHR] );
  3345. fn( json );
  3346. };
  3347. if ( $.isPlainObject( ajax ) && ajax.data )
  3348. {
  3349. ajaxData = ajax.data;
  3350. var newData = $.isFunction( ajaxData ) ?
  3351. ajaxData( data, oSettings ) : // fn can manipulate data or return
  3352. ajaxData; // an object object or array to merge
  3353. // If the function returned something, use that alone
  3354. data = $.isFunction( ajaxData ) && newData ?
  3355. newData :
  3356. $.extend( true, data, newData );
  3357. // Remove the data property as we've resolved it already and don't want
  3358. // jQuery to do it again (it is restored at the end of the function)
  3359. delete ajax.data;
  3360. }
  3361. var baseAjax = {
  3362. "data": data,
  3363. "success": function (json) {
  3364. var error = json.error || json.sError;
  3365. if ( error ) {
  3366. _fnLog( oSettings, 0, error );
  3367. }
  3368. oSettings.json = json;
  3369. callback( json );
  3370. },
  3371. "dataType": "json",
  3372. "cache": false,
  3373. "type": oSettings.sServerMethod,
  3374. "error": function (xhr, error, thrown) {
  3375. var ret = _fnCallbackFire( oSettings, null, 'xhr', [oSettings, null, oSettings.jqXHR] );
  3376. if ( $.inArray( true, ret ) === -1 ) {
  3377. if ( error == "parsererror" ) {
  3378. _fnLog( oSettings, 0, 'Invalid JSON response', 1 );
  3379. }
  3380. else if ( xhr.readyState === 4 ) {
  3381. _fnLog( oSettings, 0, 'Ajax error', 7 );
  3382. }
  3383. }
  3384. _fnProcessingDisplay( oSettings, false );
  3385. }
  3386. };
  3387. // Store the data submitted for the API
  3388. oSettings.oAjaxData = data;
  3389. // Allow plug-ins and external processes to modify the data
  3390. _fnCallbackFire( oSettings, null, 'preXhr', [oSettings, data] );
  3391. if ( oSettings.fnServerData )
  3392. {
  3393. // DataTables 1.9- compatibility
  3394. oSettings.fnServerData.call( instance,
  3395. oSettings.sAjaxSource,
  3396. $.map( data, function (val, key) { // Need to convert back to 1.9 trad format
  3397. return { name: key, value: val };
  3398. } ),
  3399. callback,
  3400. oSettings
  3401. );
  3402. }
  3403. else if ( oSettings.sAjaxSource || typeof ajax === 'string' )
  3404. {
  3405. // DataTables 1.9- compatibility
  3406. oSettings.jqXHR = $.ajax( $.extend( baseAjax, {
  3407. url: ajax || oSettings.sAjaxSource
  3408. } ) );
  3409. }
  3410. else if ( $.isFunction( ajax ) )
  3411. {
  3412. // Is a function - let the caller define what needs to be done
  3413. oSettings.jqXHR = ajax.call( instance, data, callback, oSettings );
  3414. }
  3415. else
  3416. {
  3417. // Object to extend the base settings
  3418. oSettings.jqXHR = $.ajax( $.extend( baseAjax, ajax ) );
  3419. // Restore for next time around
  3420. ajax.data = ajaxData;
  3421. }
  3422. }
  3423. /**
  3424. * Update the table using an Ajax call
  3425. * @param {object} settings dataTables settings object
  3426. * @returns {boolean} Block the table drawing or not
  3427. * @memberof DataTable#oApi
  3428. */
  3429. function _fnAjaxUpdate( settings )
  3430. {
  3431. if ( settings.bAjaxDataGet ) {
  3432. settings.iDraw++;
  3433. _fnProcessingDisplay( settings, true );
  3434. _fnBuildAjax(
  3435. settings,
  3436. _fnAjaxParameters( settings ),
  3437. function(json) {
  3438. _fnAjaxUpdateDraw( settings, json );
  3439. }
  3440. );
  3441. return false;
  3442. }
  3443. return true;
  3444. }
  3445. /**
  3446. * Build up the parameters in an object needed for a server-side processing
  3447. * request. Note that this is basically done twice, is different ways - a modern
  3448. * method which is used by default in DataTables 1.10 which uses objects and
  3449. * arrays, or the 1.9- method with is name / value pairs. 1.9 method is used if
  3450. * the sAjaxSource option is used in the initialisation, or the legacyAjax
  3451. * option is set.
  3452. * @param {object} oSettings dataTables settings object
  3453. * @returns {bool} block the table drawing or not
  3454. * @memberof DataTable#oApi
  3455. */
  3456. function _fnAjaxParameters( settings )
  3457. {
  3458. var
  3459. columns = settings.aoColumns,
  3460. columnCount = columns.length,
  3461. features = settings.oFeatures,
  3462. preSearch = settings.oPreviousSearch,
  3463. preColSearch = settings.aoPreSearchCols,
  3464. i, data = [], dataProp, column, columnSearch,
  3465. sort = _fnSortFlatten( settings ),
  3466. displayStart = settings._iDisplayStart,
  3467. displayLength = features.bPaginate !== false ?
  3468. settings._iDisplayLength :
  3469. -1;
  3470. var param = function ( name, value ) {
  3471. data.push( { 'name': name, 'value': value } );
  3472. };
  3473. // DataTables 1.9- compatible method
  3474. param( 'sEcho', settings.iDraw );
  3475. param( 'iColumns', columnCount );
  3476. param( 'sColumns', _pluck( columns, 'sName' ).join(',') );
  3477. param( 'iDisplayStart', displayStart );
  3478. param( 'iDisplayLength', displayLength );
  3479. // DataTables 1.10+ method
  3480. var d = {
  3481. draw: settings.iDraw,
  3482. columns: [],
  3483. order: [],
  3484. start: displayStart,
  3485. length: displayLength,
  3486. search: {
  3487. value: preSearch.sSearch,
  3488. regex: preSearch.bRegex
  3489. }
  3490. };
  3491. for ( i=0 ; i<columnCount ; i++ ) {
  3492. column = columns[i];
  3493. columnSearch = preColSearch[i];
  3494. dataProp = typeof column.mData=="function" ? 'function' : column.mData ;
  3495. d.columns.push( {
  3496. data: dataProp,
  3497. name: column.sName,
  3498. searchable: column.bSearchable,
  3499. orderable: column.bSortable,
  3500. search: {
  3501. value: columnSearch.sSearch,
  3502. regex: columnSearch.bRegex
  3503. }
  3504. } );
  3505. param( "mDataProp_"+i, dataProp );
  3506. if ( features.bFilter ) {
  3507. param( 'sSearch_'+i, columnSearch.sSearch );
  3508. param( 'bRegex_'+i, columnSearch.bRegex );
  3509. param( 'bSearchable_'+i, column.bSearchable );
  3510. }
  3511. if ( features.bSort ) {
  3512. param( 'bSortable_'+i, column.bSortable );
  3513. }
  3514. }
  3515. if ( features.bFilter ) {
  3516. param( 'sSearch', preSearch.sSearch );
  3517. param( 'bRegex', preSearch.bRegex );
  3518. }
  3519. if ( features.bSort ) {
  3520. $.each( sort, function ( i, val ) {
  3521. d.order.push( { column: val.col, dir: val.dir } );
  3522. param( 'iSortCol_'+i, val.col );
  3523. param( 'sSortDir_'+i, val.dir );
  3524. } );
  3525. param( 'iSortingCols', sort.length );
  3526. }
  3527. // If the legacy.ajax parameter is null, then we automatically decide which
  3528. // form to use, based on sAjaxSource
  3529. var legacy = DataTable.ext.legacy.ajax;
  3530. if ( legacy === null ) {
  3531. return settings.sAjaxSource ? data : d;
  3532. }
  3533. // Otherwise, if legacy has been specified then we use that to decide on the
  3534. // form
  3535. return legacy ? data : d;
  3536. }
  3537. /**
  3538. * Data the data from the server (nuking the old) and redraw the table
  3539. * @param {object} oSettings dataTables settings object
  3540. * @param {object} json json data return from the server.
  3541. * @param {string} json.sEcho Tracking flag for DataTables to match requests
  3542. * @param {int} json.iTotalRecords Number of records in the data set, not accounting for filtering
  3543. * @param {int} json.iTotalDisplayRecords Number of records in the data set, accounting for filtering
  3544. * @param {array} json.aaData The data to display on this page
  3545. * @param {string} [json.sColumns] Column ordering (sName, comma separated)
  3546. * @memberof DataTable#oApi
  3547. */
  3548. function _fnAjaxUpdateDraw ( settings, json )
  3549. {
  3550. // v1.10 uses camelCase variables, while 1.9 uses Hungarian notation.
  3551. // Support both
  3552. var compat = function ( old, modern ) {
  3553. return json[old] !== undefined ? json[old] : json[modern];
  3554. };
  3555. var data = _fnAjaxDataSrc( settings, json );
  3556. var draw = compat( 'sEcho', 'draw' );
  3557. var recordsTotal = compat( 'iTotalRecords', 'recordsTotal' );
  3558. var recordsFiltered = compat( 'iTotalDisplayRecords', 'recordsFiltered' );
  3559. if ( draw ) {
  3560. // Protect against out of sequence returns
  3561. if ( draw*1 < settings.iDraw ) {
  3562. return;
  3563. }
  3564. settings.iDraw = draw * 1;
  3565. }
  3566. _fnClearTable( settings );
  3567. settings._iRecordsTotal = parseInt(recordsTotal, 10);
  3568. settings._iRecordsDisplay = parseInt(recordsFiltered, 10);
  3569. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  3570. _fnAddData( settings, data[i] );
  3571. }
  3572. settings.aiDisplay = settings.aiDisplayMaster.slice();
  3573. settings.bAjaxDataGet = false;
  3574. _fnDraw( settings );
  3575. if ( ! settings._bInitComplete ) {
  3576. _fnInitComplete( settings, json );
  3577. }
  3578. settings.bAjaxDataGet = true;
  3579. _fnProcessingDisplay( settings, false );
  3580. }
  3581. /**
  3582. * Get the data from the JSON data source to use for drawing a table. Using
  3583. * `_fnGetObjectDataFn` allows the data to be sourced from a property of the
  3584. * source object, or from a processing function.
  3585. * @param {object} oSettings dataTables settings object
  3586. * @param {object} json Data source object / array from the server
  3587. * @return {array} Array of data to use
  3588. */
  3589. function _fnAjaxDataSrc ( oSettings, json )
  3590. {
  3591. var dataSrc = $.isPlainObject( oSettings.ajax ) && oSettings.ajax.dataSrc !== undefined ?
  3592. oSettings.ajax.dataSrc :
  3593. oSettings.sAjaxDataProp; // Compatibility with 1.9-.
  3594. // Compatibility with 1.9-. In order to read from aaData, check if the
  3595. // default has been changed, if not, check for aaData
  3596. if ( dataSrc === 'data' ) {
  3597. return json.aaData || json[dataSrc];
  3598. }
  3599. return dataSrc !== "" ?
  3600. _fnGetObjectDataFn( dataSrc )( json ) :
  3601. json;
  3602. }
  3603. /**
  3604. * Generate the node required for filtering text
  3605. * @returns {node} Filter control element
  3606. * @param {object} oSettings dataTables settings object
  3607. * @memberof DataTable#oApi
  3608. */
  3609. function _fnFeatureHtmlFilter ( settings )
  3610. {
  3611. var classes = settings.oClasses;
  3612. var tableId = settings.sTableId;
  3613. var language = settings.oLanguage;
  3614. var previousSearch = settings.oPreviousSearch;
  3615. var features = settings.aanFeatures;
  3616. var input = '<input type="search" class="'+classes.sFilterInput+'"/>';
  3617. var str = language.sSearch;
  3618. str = str.match(/_INPUT_/) ?
  3619. str.replace('_INPUT_', input) :
  3620. str+input;
  3621. var filter = $('<div/>', {
  3622. 'id': ! features.f ? tableId+'_filter' : null,
  3623. 'class': classes.sFilter
  3624. } )
  3625. .append( $('<label/>' ).append( str ) );
  3626. var searchFn = function() {
  3627. /* Update all other filter input elements for the new display */
  3628. var n = features.f;
  3629. var val = !this.value ? "" : this.value; // mental IE8 fix :-(
  3630. /* Now do the filter */
  3631. if ( val != previousSearch.sSearch ) {
  3632. _fnFilterComplete( settings, {
  3633. "sSearch": val,
  3634. "bRegex": previousSearch.bRegex,
  3635. "bSmart": previousSearch.bSmart ,
  3636. "bCaseInsensitive": previousSearch.bCaseInsensitive
  3637. } );
  3638. // Need to redraw, without resorting
  3639. settings._iDisplayStart = 0;
  3640. _fnDraw( settings );
  3641. }
  3642. };
  3643. var searchDelay = settings.searchDelay !== null ?
  3644. settings.searchDelay :
  3645. _fnDataSource( settings ) === 'ssp' ?
  3646. 400 :
  3647. 0;
  3648. var jqFilter = $('input', filter)
  3649. .val( previousSearch.sSearch )
  3650. .attr( 'placeholder', language.sSearchPlaceholder )
  3651. .on(
  3652. 'keyup.DT search.DT input.DT paste.DT cut.DT',
  3653. searchDelay ?
  3654. _fnThrottle( searchFn, searchDelay ) :
  3655. searchFn
  3656. )
  3657. .on( 'keypress.DT', function(e) {
  3658. /* Prevent form submission */
  3659. if ( e.keyCode == 13 ) {
  3660. return false;
  3661. }
  3662. } )
  3663. .attr('aria-controls', tableId);
  3664. // Update the input elements whenever the table is filtered
  3665. $(settings.nTable).on( 'search.dt.DT', function ( ev, s ) {
  3666. if ( settings === s ) {
  3667. // IE9 throws an 'unknown error' if document.activeElement is used
  3668. // inside an iframe or frame...
  3669. try {
  3670. if ( jqFilter[0] !== document.activeElement ) {
  3671. jqFilter.val( previousSearch.sSearch );
  3672. }
  3673. }
  3674. catch ( e ) {}
  3675. }
  3676. } );
  3677. return filter[0];
  3678. }
  3679. /**
  3680. * Filter the table using both the global filter and column based filtering
  3681. * @param {object} oSettings dataTables settings object
  3682. * @param {object} oSearch search information
  3683. * @param {int} [iForce] force a research of the master array (1) or not (undefined or 0)
  3684. * @memberof DataTable#oApi
  3685. */
  3686. function _fnFilterComplete ( oSettings, oInput, iForce )
  3687. {
  3688. var oPrevSearch = oSettings.oPreviousSearch;
  3689. var aoPrevSearch = oSettings.aoPreSearchCols;
  3690. var fnSaveFilter = function ( oFilter ) {
  3691. /* Save the filtering values */
  3692. oPrevSearch.sSearch = oFilter.sSearch;
  3693. oPrevSearch.bRegex = oFilter.bRegex;
  3694. oPrevSearch.bSmart = oFilter.bSmart;
  3695. oPrevSearch.bCaseInsensitive = oFilter.bCaseInsensitive;
  3696. };
  3697. var fnRegex = function ( o ) {
  3698. // Backwards compatibility with the bEscapeRegex option
  3699. return o.bEscapeRegex !== undefined ? !o.bEscapeRegex : o.bRegex;
  3700. };
  3701. // Resolve any column types that are unknown due to addition or invalidation
  3702. // @todo As per sort - can this be moved into an event handler?
  3703. _fnColumnTypes( oSettings );
  3704. /* In server-side processing all filtering is done by the server, so no point hanging around here */
  3705. if ( _fnDataSource( oSettings ) != 'ssp' )
  3706. {
  3707. /* Global filter */
  3708. _fnFilter( oSettings, oInput.sSearch, iForce, fnRegex(oInput), oInput.bSmart, oInput.bCaseInsensitive );
  3709. fnSaveFilter( oInput );
  3710. /* Now do the individual column filter */
  3711. for ( var i=0 ; i<aoPrevSearch.length ; i++ )
  3712. {
  3713. _fnFilterColumn( oSettings, aoPrevSearch[i].sSearch, i, fnRegex(aoPrevSearch[i]),
  3714. aoPrevSearch[i].bSmart, aoPrevSearch[i].bCaseInsensitive );
  3715. }
  3716. /* Custom filtering */
  3717. _fnFilterCustom( oSettings );
  3718. }
  3719. else
  3720. {
  3721. fnSaveFilter( oInput );
  3722. }
  3723. /* Tell the draw function we have been filtering */
  3724. oSettings.bFiltered = true;
  3725. _fnCallbackFire( oSettings, null, 'search', [oSettings] );
  3726. }
  3727. /**
  3728. * Apply custom filtering functions
  3729. * @param {object} oSettings dataTables settings object
  3730. * @memberof DataTable#oApi
  3731. */
  3732. function _fnFilterCustom( settings )
  3733. {
  3734. var filters = DataTable.ext.search;
  3735. var displayRows = settings.aiDisplay;
  3736. var row, rowIdx;
  3737. for ( var i=0, ien=filters.length ; i<ien ; i++ ) {
  3738. var rows = [];
  3739. // Loop over each row and see if it should be included
  3740. for ( var j=0, jen=displayRows.length ; j<jen ; j++ ) {
  3741. rowIdx = displayRows[ j ];
  3742. row = settings.aoData[ rowIdx ];
  3743. if ( filters[i]( settings, row._aFilterData, rowIdx, row._aData, j ) ) {
  3744. rows.push( rowIdx );
  3745. }
  3746. }
  3747. // So the array reference doesn't break set the results into the
  3748. // existing array
  3749. displayRows.length = 0;
  3750. $.merge( displayRows, rows );
  3751. }
  3752. }
  3753. /**
  3754. * Filter the table on a per-column basis
  3755. * @param {object} oSettings dataTables settings object
  3756. * @param {string} sInput string to filter on
  3757. * @param {int} iColumn column to filter
  3758. * @param {bool} bRegex treat search string as a regular expression or not
  3759. * @param {bool} bSmart use smart filtering or not
  3760. * @param {bool} bCaseInsensitive Do case insenstive matching or not
  3761. * @memberof DataTable#oApi
  3762. */
  3763. function _fnFilterColumn ( settings, searchStr, colIdx, regex, smart, caseInsensitive )
  3764. {
  3765. if ( searchStr === '' ) {
  3766. return;
  3767. }
  3768. var data;
  3769. var out = [];
  3770. var display = settings.aiDisplay;
  3771. var rpSearch = _fnFilterCreateSearch( searchStr, regex, smart, caseInsensitive );
  3772. for ( var i=0 ; i<display.length ; i++ ) {
  3773. data = settings.aoData[ display[i] ]._aFilterData[ colIdx ];
  3774. if ( rpSearch.test( data ) ) {
  3775. out.push( display[i] );
  3776. }
  3777. }
  3778. settings.aiDisplay = out;
  3779. }
  3780. /**
  3781. * Filter the data table based on user input and draw the table
  3782. * @param {object} settings dataTables settings object
  3783. * @param {string} input string to filter on
  3784. * @param {int} force optional - force a research of the master array (1) or not (undefined or 0)
  3785. * @param {bool} regex treat as a regular expression or not
  3786. * @param {bool} smart perform smart filtering or not
  3787. * @param {bool} caseInsensitive Do case insenstive matching or not
  3788. * @memberof DataTable#oApi
  3789. */
  3790. function _fnFilter( settings, input, force, regex, smart, caseInsensitive )
  3791. {
  3792. var rpSearch = _fnFilterCreateSearch( input, regex, smart, caseInsensitive );
  3793. var prevSearch = settings.oPreviousSearch.sSearch;
  3794. var displayMaster = settings.aiDisplayMaster;
  3795. var display, invalidated, i;
  3796. var filtered = [];
  3797. // Need to take account of custom filtering functions - always filter
  3798. if ( DataTable.ext.search.length !== 0 ) {
  3799. force = true;
  3800. }
  3801. // Check if any of the rows were invalidated
  3802. invalidated = _fnFilterData( settings );
  3803. // If the input is blank - we just want the full data set
  3804. if ( input.length <= 0 ) {
  3805. settings.aiDisplay = displayMaster.slice();
  3806. }
  3807. else {
  3808. // New search - start from the master array
  3809. if ( invalidated ||
  3810. force ||
  3811. prevSearch.length > input.length ||
  3812. input.indexOf(prevSearch) !== 0 ||
  3813. settings.bSorted // On resort, the display master needs to be
  3814. // re-filtered since indexes will have changed
  3815. ) {
  3816. settings.aiDisplay = displayMaster.slice();
  3817. }
  3818. // Search the display array
  3819. display = settings.aiDisplay;
  3820. for ( i=0 ; i<display.length ; i++ ) {
  3821. if ( rpSearch.test( settings.aoData[ display[i] ]._sFilterRow ) ) {
  3822. filtered.push( display[i] );
  3823. }
  3824. }
  3825. settings.aiDisplay = filtered;
  3826. }
  3827. }
  3828. /**
  3829. * Build a regular expression object suitable for searching a table
  3830. * @param {string} sSearch string to search for
  3831. * @param {bool} bRegex treat as a regular expression or not
  3832. * @param {bool} bSmart perform smart filtering or not
  3833. * @param {bool} bCaseInsensitive Do case insensitive matching or not
  3834. * @returns {RegExp} constructed object
  3835. * @memberof DataTable#oApi
  3836. */
  3837. function _fnFilterCreateSearch( search, regex, smart, caseInsensitive )
  3838. {
  3839. search = regex ?
  3840. search :
  3841. _fnEscapeRegex( search );
  3842. if ( smart ) {
  3843. /* For smart filtering we want to allow the search to work regardless of
  3844. * word order. We also want double quoted text to be preserved, so word
  3845. * order is important - a la google. So this is what we want to
  3846. * generate:
  3847. *
  3848. * ^(?=.*?\bone\b)(?=.*?\btwo three\b)(?=.*?\bfour\b).*$
  3849. */
  3850. var a = $.map( search.match( /"[^"]+"|[^ ]+/g ) || [''], function ( word ) {
  3851. if ( word.charAt(0) === '"' ) {
  3852. var m = word.match( /^"(.*)"$/ );
  3853. word = m ? m[1] : word;
  3854. }
  3855. return word.replace('"', '');
  3856. } );
  3857. search = '^(?=.*?'+a.join( ')(?=.*?' )+').*$';
  3858. }
  3859. return new RegExp( search, caseInsensitive ? 'i' : '' );
  3860. }
  3861. /**
  3862. * Escape a string such that it can be used in a regular expression
  3863. * @param {string} sVal string to escape
  3864. * @returns {string} escaped string
  3865. * @memberof DataTable#oApi
  3866. */
  3867. var _fnEscapeRegex = DataTable.util.escapeRegex;
  3868. var __filter_div = $('<div>')[0];
  3869. var __filter_div_textContent = __filter_div.textContent !== undefined;
  3870. // Update the filtering data for each row if needed (by invalidation or first run)
  3871. function _fnFilterData ( settings )
  3872. {
  3873. var columns = settings.aoColumns;
  3874. var column;
  3875. var i, j, ien, jen, filterData, cellData, row;
  3876. var fomatters = DataTable.ext.type.search;
  3877. var wasInvalidated = false;
  3878. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  3879. row = settings.aoData[i];
  3880. if ( ! row._aFilterData ) {
  3881. filterData = [];
  3882. for ( j=0, jen=columns.length ; j<jen ; j++ ) {
  3883. column = columns[j];
  3884. if ( column.bSearchable ) {
  3885. cellData = _fnGetCellData( settings, i, j, 'filter' );
  3886. if ( fomatters[ column.sType ] ) {
  3887. cellData = fomatters[ column.sType ]( cellData );
  3888. }
  3889. // Search in DataTables 1.10 is string based. In 1.11 this
  3890. // should be altered to also allow strict type checking.
  3891. if ( cellData === null ) {
  3892. cellData = '';
  3893. }
  3894. if ( typeof cellData !== 'string' && cellData.toString ) {
  3895. cellData = cellData.toString();
  3896. }
  3897. }
  3898. else {
  3899. cellData = '';
  3900. }
  3901. // If it looks like there is an HTML entity in the string,
  3902. // attempt to decode it so sorting works as expected. Note that
  3903. // we could use a single line of jQuery to do this, but the DOM
  3904. // method used here is much faster http://jsperf.com/html-decode
  3905. if ( cellData.indexOf && cellData.indexOf('&') !== -1 ) {
  3906. __filter_div.innerHTML = cellData;
  3907. cellData = __filter_div_textContent ?
  3908. __filter_div.textContent :
  3909. __filter_div.innerText;
  3910. }
  3911. if ( cellData.replace ) {
  3912. cellData = cellData.replace(/[\r\n]/g, '');
  3913. }
  3914. filterData.push( cellData );
  3915. }
  3916. row._aFilterData = filterData;
  3917. row._sFilterRow = filterData.join(' ');
  3918. wasInvalidated = true;
  3919. }
  3920. }
  3921. return wasInvalidated;
  3922. }
  3923. /**
  3924. * Convert from the internal Hungarian notation to camelCase for external
  3925. * interaction
  3926. * @param {object} obj Object to convert
  3927. * @returns {object} Inverted object
  3928. * @memberof DataTable#oApi
  3929. */
  3930. function _fnSearchToCamel ( obj )
  3931. {
  3932. return {
  3933. search: obj.sSearch,
  3934. smart: obj.bSmart,
  3935. regex: obj.bRegex,
  3936. caseInsensitive: obj.bCaseInsensitive
  3937. };
  3938. }
  3939. /**
  3940. * Convert from camelCase notation to the internal Hungarian. We could use the
  3941. * Hungarian convert function here, but this is cleaner
  3942. * @param {object} obj Object to convert
  3943. * @returns {object} Inverted object
  3944. * @memberof DataTable#oApi
  3945. */
  3946. function _fnSearchToHung ( obj )
  3947. {
  3948. return {
  3949. sSearch: obj.search,
  3950. bSmart: obj.smart,
  3951. bRegex: obj.regex,
  3952. bCaseInsensitive: obj.caseInsensitive
  3953. };
  3954. }
  3955. /**
  3956. * Generate the node required for the info display
  3957. * @param {object} oSettings dataTables settings object
  3958. * @returns {node} Information element
  3959. * @memberof DataTable#oApi
  3960. */
  3961. function _fnFeatureHtmlInfo ( settings )
  3962. {
  3963. var
  3964. tid = settings.sTableId,
  3965. nodes = settings.aanFeatures.i,
  3966. n = $('<div/>', {
  3967. 'class': settings.oClasses.sInfo,
  3968. 'id': ! nodes ? tid+'_info' : null
  3969. } );
  3970. if ( ! nodes ) {
  3971. // Update display on each draw
  3972. settings.aoDrawCallback.push( {
  3973. "fn": _fnUpdateInfo,
  3974. "sName": "information"
  3975. } );
  3976. n
  3977. .attr( 'role', 'status' )
  3978. .attr( 'aria-live', 'polite' );
  3979. // Table is described by our info div
  3980. $(settings.nTable).attr( 'aria-describedby', tid+'_info' );
  3981. }
  3982. return n[0];
  3983. }
  3984. /**
  3985. * Update the information elements in the display
  3986. * @param {object} settings dataTables settings object
  3987. * @memberof DataTable#oApi
  3988. */
  3989. function _fnUpdateInfo ( settings )
  3990. {
  3991. /* Show information about the table */
  3992. var nodes = settings.aanFeatures.i;
  3993. if ( nodes.length === 0 ) {
  3994. return;
  3995. }
  3996. var
  3997. lang = settings.oLanguage,
  3998. start = settings._iDisplayStart+1,
  3999. end = settings.fnDisplayEnd(),
  4000. max = settings.fnRecordsTotal(),
  4001. total = settings.fnRecordsDisplay(),
  4002. out = total ?
  4003. lang.sInfo :
  4004. lang.sInfoEmpty;
  4005. if ( total !== max ) {
  4006. /* Record set after filtering */
  4007. out += ' ' + lang.sInfoFiltered;
  4008. }
  4009. // Convert the macros
  4010. out += lang.sInfoPostFix;
  4011. out = _fnInfoMacros( settings, out );
  4012. var callback = lang.fnInfoCallback;
  4013. if ( callback !== null ) {
  4014. out = callback.call( settings.oInstance,
  4015. settings, start, end, max, total, out
  4016. );
  4017. }
  4018. $(nodes).html( out );
  4019. }
  4020. function _fnInfoMacros ( settings, str )
  4021. {
  4022. // When infinite scrolling, we are always starting at 1. _iDisplayStart is used only
  4023. // internally
  4024. var
  4025. formatter = settings.fnFormatNumber,
  4026. start = settings._iDisplayStart+1,
  4027. len = settings._iDisplayLength,
  4028. vis = settings.fnRecordsDisplay(),
  4029. all = len === -1;
  4030. return str.
  4031. replace(/_START_/g, formatter.call( settings, start ) ).
  4032. replace(/_END_/g, formatter.call( settings, settings.fnDisplayEnd() ) ).
  4033. replace(/_MAX_/g, formatter.call( settings, settings.fnRecordsTotal() ) ).
  4034. replace(/_TOTAL_/g, formatter.call( settings, vis ) ).
  4035. replace(/_PAGE_/g, formatter.call( settings, all ? 1 : Math.ceil( start / len ) ) ).
  4036. replace(/_PAGES_/g, formatter.call( settings, all ? 1 : Math.ceil( vis / len ) ) );
  4037. }
  4038. /**
  4039. * Draw the table for the first time, adding all required features
  4040. * @param {object} settings dataTables settings object
  4041. * @memberof DataTable#oApi
  4042. */
  4043. function _fnInitialise ( settings )
  4044. {
  4045. var i, iLen, iAjaxStart=settings.iInitDisplayStart;
  4046. var columns = settings.aoColumns, column;
  4047. var features = settings.oFeatures;
  4048. var deferLoading = settings.bDeferLoading; // value modified by the draw
  4049. /* Ensure that the table data is fully initialised */
  4050. if ( ! settings.bInitialised ) {
  4051. setTimeout( function(){ _fnInitialise( settings ); }, 200 );
  4052. return;
  4053. }
  4054. /* Show the display HTML options */
  4055. _fnAddOptionsHtml( settings );
  4056. /* Build and draw the header / footer for the table */
  4057. _fnBuildHead( settings );
  4058. _fnDrawHead( settings, settings.aoHeader );
  4059. _fnDrawHead( settings, settings.aoFooter );
  4060. /* Okay to show that something is going on now */
  4061. _fnProcessingDisplay( settings, true );
  4062. /* Calculate sizes for columns */
  4063. if ( features.bAutoWidth ) {
  4064. _fnCalculateColumnWidths( settings );
  4065. }
  4066. for ( i=0, iLen=columns.length ; i<iLen ; i++ ) {
  4067. column = columns[i];
  4068. if ( column.sWidth ) {
  4069. column.nTh.style.width = _fnStringToCss( column.sWidth );
  4070. }
  4071. }
  4072. _fnCallbackFire( settings, null, 'preInit', [settings] );
  4073. // If there is default sorting required - let's do it. The sort function
  4074. // will do the drawing for us. Otherwise we draw the table regardless of the
  4075. // Ajax source - this allows the table to look initialised for Ajax sourcing
  4076. // data (show 'loading' message possibly)
  4077. _fnReDraw( settings );
  4078. // Server-side processing init complete is done by _fnAjaxUpdateDraw
  4079. var dataSrc = _fnDataSource( settings );
  4080. if ( dataSrc != 'ssp' || deferLoading ) {
  4081. // if there is an ajax source load the data
  4082. if ( dataSrc == 'ajax' ) {
  4083. _fnBuildAjax( settings, [], function(json) {
  4084. var aData = _fnAjaxDataSrc( settings, json );
  4085. // Got the data - add it to the table
  4086. for ( i=0 ; i<aData.length ; i++ ) {
  4087. _fnAddData( settings, aData[i] );
  4088. }
  4089. // Reset the init display for cookie saving. We've already done
  4090. // a filter, and therefore cleared it before. So we need to make
  4091. // it appear 'fresh'
  4092. settings.iInitDisplayStart = iAjaxStart;
  4093. _fnReDraw( settings );
  4094. _fnProcessingDisplay( settings, false );
  4095. _fnInitComplete( settings, json );
  4096. }, settings );
  4097. }
  4098. else {
  4099. _fnProcessingDisplay( settings, false );
  4100. _fnInitComplete( settings );
  4101. }
  4102. }
  4103. }
  4104. /**
  4105. * Draw the table for the first time, adding all required features
  4106. * @param {object} oSettings dataTables settings object
  4107. * @param {object} [json] JSON from the server that completed the table, if using Ajax source
  4108. * with client-side processing (optional)
  4109. * @memberof DataTable#oApi
  4110. */
  4111. function _fnInitComplete ( settings, json )
  4112. {
  4113. settings._bInitComplete = true;
  4114. // When data was added after the initialisation (data or Ajax) we need to
  4115. // calculate the column sizing
  4116. if ( json || settings.oInit.aaData ) {
  4117. _fnAdjustColumnSizing( settings );
  4118. }
  4119. _fnCallbackFire( settings, null, 'plugin-init', [settings, json] );
  4120. _fnCallbackFire( settings, 'aoInitComplete', 'init', [settings, json] );
  4121. }
  4122. function _fnLengthChange ( settings, val )
  4123. {
  4124. var len = parseInt( val, 10 );
  4125. settings._iDisplayLength = len;
  4126. _fnLengthOverflow( settings );
  4127. // Fire length change event
  4128. _fnCallbackFire( settings, null, 'length', [settings, len] );
  4129. }
  4130. /**
  4131. * Generate the node required for user display length changing
  4132. * @param {object} settings dataTables settings object
  4133. * @returns {node} Display length feature node
  4134. * @memberof DataTable#oApi
  4135. */
  4136. function _fnFeatureHtmlLength ( settings )
  4137. {
  4138. var
  4139. classes = settings.oClasses,
  4140. tableId = settings.sTableId,
  4141. menu = settings.aLengthMenu,
  4142. d2 = $.isArray( menu[0] ),
  4143. lengths = d2 ? menu[0] : menu,
  4144. language = d2 ? menu[1] : menu;
  4145. var select = $('<select/>', {
  4146. 'name': tableId+'_length',
  4147. 'aria-controls': tableId,
  4148. 'class': classes.sLengthSelect
  4149. } );
  4150. for ( var i=0, ien=lengths.length ; i<ien ; i++ ) {
  4151. select[0][ i ] = new Option(
  4152. typeof language[i] === 'number' ?
  4153. settings.fnFormatNumber( language[i] ) :
  4154. language[i],
  4155. lengths[i]
  4156. );
  4157. }
  4158. var div = $('<div><label/></div>').addClass( classes.sLength );
  4159. if ( ! settings.aanFeatures.l ) {
  4160. div[0].id = tableId+'_length';
  4161. }
  4162. div.children().append(
  4163. settings.oLanguage.sLengthMenu.replace( '_MENU_', select[0].outerHTML )
  4164. );
  4165. // Can't use `select` variable as user might provide their own and the
  4166. // reference is broken by the use of outerHTML
  4167. $('select', div)
  4168. .val( settings._iDisplayLength )
  4169. .on( 'change.DT', function(e) {
  4170. _fnLengthChange( settings, $(this).val() );
  4171. _fnDraw( settings );
  4172. } );
  4173. // Update node value whenever anything changes the table's length
  4174. $(settings.nTable).on( 'length.dt.DT', function (e, s, len) {
  4175. if ( settings === s ) {
  4176. $('select', div).val( len );
  4177. }
  4178. } );
  4179. return div[0];
  4180. }
  4181. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  4182. * Note that most of the paging logic is done in
  4183. * DataTable.ext.pager
  4184. */
  4185. /**
  4186. * Generate the node required for default pagination
  4187. * @param {object} oSettings dataTables settings object
  4188. * @returns {node} Pagination feature node
  4189. * @memberof DataTable#oApi
  4190. */
  4191. function _fnFeatureHtmlPaginate ( settings )
  4192. {
  4193. var
  4194. type = settings.sPaginationType,
  4195. plugin = DataTable.ext.pager[ type ],
  4196. modern = typeof plugin === 'function',
  4197. redraw = function( settings ) {
  4198. _fnDraw( settings );
  4199. },
  4200. node = $('<div/>').addClass( settings.oClasses.sPaging + type )[0],
  4201. features = settings.aanFeatures;
  4202. if ( ! modern ) {
  4203. plugin.fnInit( settings, node, redraw );
  4204. }
  4205. /* Add a draw callback for the pagination on first instance, to update the paging display */
  4206. if ( ! features.p )
  4207. {
  4208. node.id = settings.sTableId+'_paginate';
  4209. settings.aoDrawCallback.push( {
  4210. "fn": function( settings ) {
  4211. if ( modern ) {
  4212. var
  4213. start = settings._iDisplayStart,
  4214. len = settings._iDisplayLength,
  4215. visRecords = settings.fnRecordsDisplay(),
  4216. all = len === -1,
  4217. page = all ? 0 : Math.ceil( start / len ),
  4218. pages = all ? 1 : Math.ceil( visRecords / len ),
  4219. buttons = plugin(page, pages),
  4220. i, ien;
  4221. for ( i=0, ien=features.p.length ; i<ien ; i++ ) {
  4222. _fnRenderer( settings, 'pageButton' )(
  4223. settings, features.p[i], i, buttons, page, pages
  4224. );
  4225. }
  4226. }
  4227. else {
  4228. plugin.fnUpdate( settings, redraw );
  4229. }
  4230. },
  4231. "sName": "pagination"
  4232. } );
  4233. }
  4234. return node;
  4235. }
  4236. /**
  4237. * Alter the display settings to change the page
  4238. * @param {object} settings DataTables settings object
  4239. * @param {string|int} action Paging action to take: "first", "previous",
  4240. * "next" or "last" or page number to jump to (integer)
  4241. * @param [bool] redraw Automatically draw the update or not
  4242. * @returns {bool} true page has changed, false - no change
  4243. * @memberof DataTable#oApi
  4244. */
  4245. function _fnPageChange ( settings, action, redraw )
  4246. {
  4247. var
  4248. start = settings._iDisplayStart,
  4249. len = settings._iDisplayLength,
  4250. records = settings.fnRecordsDisplay();
  4251. if ( records === 0 || len === -1 )
  4252. {
  4253. start = 0;
  4254. }
  4255. else if ( typeof action === "number" )
  4256. {
  4257. start = action * len;
  4258. if ( start > records )
  4259. {
  4260. start = 0;
  4261. }
  4262. }
  4263. else if ( action == "first" )
  4264. {
  4265. start = 0;
  4266. }
  4267. else if ( action == "previous" )
  4268. {
  4269. start = len >= 0 ?
  4270. start - len :
  4271. 0;
  4272. if ( start < 0 )
  4273. {
  4274. start = 0;
  4275. }
  4276. }
  4277. else if ( action == "next" )
  4278. {
  4279. if ( start + len < records )
  4280. {
  4281. start += len;
  4282. }
  4283. }
  4284. else if ( action == "last" )
  4285. {
  4286. start = Math.floor( (records-1) / len) * len;
  4287. }
  4288. else
  4289. {
  4290. _fnLog( settings, 0, "Unknown paging action: "+action, 5 );
  4291. }
  4292. var changed = settings._iDisplayStart !== start;
  4293. settings._iDisplayStart = start;
  4294. if ( changed ) {
  4295. _fnCallbackFire( settings, null, 'page', [settings] );
  4296. if ( redraw ) {
  4297. _fnDraw( settings );
  4298. }
  4299. }
  4300. return changed;
  4301. }
  4302. /**
  4303. * Generate the node required for the processing node
  4304. * @param {object} settings dataTables settings object
  4305. * @returns {node} Processing element
  4306. * @memberof DataTable#oApi
  4307. */
  4308. function _fnFeatureHtmlProcessing ( settings )
  4309. {
  4310. return $('<div/>', {
  4311. 'id': ! settings.aanFeatures.r ? settings.sTableId+'_processing' : null,
  4312. 'class': settings.oClasses.sProcessing
  4313. } )
  4314. .html( settings.oLanguage.sProcessing )
  4315. .insertBefore( settings.nTable )[0];
  4316. }
  4317. /**
  4318. * Display or hide the processing indicator
  4319. * @param {object} settings dataTables settings object
  4320. * @param {bool} show Show the processing indicator (true) or not (false)
  4321. * @memberof DataTable#oApi
  4322. */
  4323. function _fnProcessingDisplay ( settings, show )
  4324. {
  4325. if ( settings.oFeatures.bProcessing ) {
  4326. $(settings.aanFeatures.r).css( 'display', show ? 'block' : 'none' );
  4327. }
  4328. _fnCallbackFire( settings, null, 'processing', [settings, show] );
  4329. }
  4330. /**
  4331. * Add any control elements for the table - specifically scrolling
  4332. * @param {object} settings dataTables settings object
  4333. * @returns {node} Node to add to the DOM
  4334. * @memberof DataTable#oApi
  4335. */
  4336. function _fnFeatureHtmlTable ( settings )
  4337. {
  4338. var table = $(settings.nTable);
  4339. // Add the ARIA grid role to the table
  4340. table.attr( 'role', 'grid' );
  4341. // Scrolling from here on in
  4342. var scroll = settings.oScroll;
  4343. if ( scroll.sX === '' && scroll.sY === '' ) {
  4344. return settings.nTable;
  4345. }
  4346. var scrollX = scroll.sX;
  4347. var scrollY = scroll.sY;
  4348. var classes = settings.oClasses;
  4349. var caption = table.children('caption');
  4350. var captionSide = caption.length ? caption[0]._captionSide : null;
  4351. var headerClone = $( table[0].cloneNode(false) );
  4352. var footerClone = $( table[0].cloneNode(false) );
  4353. var footer = table.children('tfoot');
  4354. var _div = '<div/>';
  4355. var size = function ( s ) {
  4356. return !s ? null : _fnStringToCss( s );
  4357. };
  4358. if ( ! footer.length ) {
  4359. footer = null;
  4360. }
  4361. /*
  4362. * The HTML structure that we want to generate in this function is:
  4363. * div - scroller
  4364. * div - scroll head
  4365. * div - scroll head inner
  4366. * table - scroll head table
  4367. * thead - thead
  4368. * div - scroll body
  4369. * table - table (master table)
  4370. * thead - thead clone for sizing
  4371. * tbody - tbody
  4372. * div - scroll foot
  4373. * div - scroll foot inner
  4374. * table - scroll foot table
  4375. * tfoot - tfoot
  4376. */
  4377. var scroller = $( _div, { 'class': classes.sScrollWrapper } )
  4378. .append(
  4379. $(_div, { 'class': classes.sScrollHead } )
  4380. .css( {
  4381. overflow: 'hidden',
  4382. position: 'relative',
  4383. border: 0,
  4384. width: scrollX ? size(scrollX) : '100%'
  4385. } )
  4386. .append(
  4387. $(_div, { 'class': classes.sScrollHeadInner } )
  4388. .css( {
  4389. 'box-sizing': 'content-box',
  4390. width: scroll.sXInner || '100%'
  4391. } )
  4392. .append(
  4393. headerClone
  4394. .removeAttr('id')
  4395. .css( 'margin-left', 0 )
  4396. .append( captionSide === 'top' ? caption : null )
  4397. .append(
  4398. table.children('thead')
  4399. )
  4400. )
  4401. )
  4402. )
  4403. .append(
  4404. $(_div, { 'class': classes.sScrollBody } )
  4405. .css( {
  4406. position: 'relative',
  4407. overflow: 'auto',
  4408. width: size( scrollX )
  4409. } )
  4410. .append( table )
  4411. );
  4412. if ( footer ) {
  4413. scroller.append(
  4414. $(_div, { 'class': classes.sScrollFoot } )
  4415. .css( {
  4416. overflow: 'hidden',
  4417. border: 0,
  4418. width: scrollX ? size(scrollX) : '100%'
  4419. } )
  4420. .append(
  4421. $(_div, { 'class': classes.sScrollFootInner } )
  4422. .append(
  4423. footerClone
  4424. .removeAttr('id')
  4425. .css( 'margin-left', 0 )
  4426. .append( captionSide === 'bottom' ? caption : null )
  4427. .append(
  4428. table.children('tfoot')
  4429. )
  4430. )
  4431. )
  4432. );
  4433. }
  4434. var children = scroller.children();
  4435. var scrollHead = children[0];
  4436. var scrollBody = children[1];
  4437. var scrollFoot = footer ? children[2] : null;
  4438. // When the body is scrolled, then we also want to scroll the headers
  4439. if ( scrollX ) {
  4440. $(scrollBody).on( 'scroll.DT', function (e) {
  4441. var scrollLeft = this.scrollLeft;
  4442. scrollHead.scrollLeft = scrollLeft;
  4443. if ( footer ) {
  4444. scrollFoot.scrollLeft = scrollLeft;
  4445. }
  4446. } );
  4447. }
  4448. $(scrollBody).css(
  4449. scrollY && scroll.bCollapse ? 'max-height' : 'height',
  4450. scrollY
  4451. );
  4452. settings.nScrollHead = scrollHead;
  4453. settings.nScrollBody = scrollBody;
  4454. settings.nScrollFoot = scrollFoot;
  4455. // On redraw - align columns
  4456. settings.aoDrawCallback.push( {
  4457. "fn": _fnScrollDraw,
  4458. "sName": "scrolling"
  4459. } );
  4460. return scroller[0];
  4461. }
  4462. /**
  4463. * Update the header, footer and body tables for resizing - i.e. column
  4464. * alignment.
  4465. *
  4466. * Welcome to the most horrible function DataTables. The process that this
  4467. * function follows is basically:
  4468. * 1. Re-create the table inside the scrolling div
  4469. * 2. Take live measurements from the DOM
  4470. * 3. Apply the measurements to align the columns
  4471. * 4. Clean up
  4472. *
  4473. * @param {object} settings dataTables settings object
  4474. * @memberof DataTable#oApi
  4475. */
  4476. function _fnScrollDraw ( settings )
  4477. {
  4478. // Given that this is such a monster function, a lot of variables are use
  4479. // to try and keep the minimised size as small as possible
  4480. var
  4481. scroll = settings.oScroll,
  4482. scrollX = scroll.sX,
  4483. scrollXInner = scroll.sXInner,
  4484. scrollY = scroll.sY,
  4485. barWidth = scroll.iBarWidth,
  4486. divHeader = $(settings.nScrollHead),
  4487. divHeaderStyle = divHeader[0].style,
  4488. divHeaderInner = divHeader.children('div'),
  4489. divHeaderInnerStyle = divHeaderInner[0].style,
  4490. divHeaderTable = divHeaderInner.children('table'),
  4491. divBodyEl = settings.nScrollBody,
  4492. divBody = $(divBodyEl),
  4493. divBodyStyle = divBodyEl.style,
  4494. divFooter = $(settings.nScrollFoot),
  4495. divFooterInner = divFooter.children('div'),
  4496. divFooterTable = divFooterInner.children('table'),
  4497. header = $(settings.nTHead),
  4498. table = $(settings.nTable),
  4499. tableEl = table[0],
  4500. tableStyle = tableEl.style,
  4501. footer = settings.nTFoot ? $(settings.nTFoot) : null,
  4502. browser = settings.oBrowser,
  4503. ie67 = browser.bScrollOversize,
  4504. dtHeaderCells = _pluck( settings.aoColumns, 'nTh' ),
  4505. headerTrgEls, footerTrgEls,
  4506. headerSrcEls, footerSrcEls,
  4507. headerCopy, footerCopy,
  4508. headerWidths=[], footerWidths=[],
  4509. headerContent=[], footerContent=[],
  4510. idx, correction, sanityWidth,
  4511. zeroOut = function(nSizer) {
  4512. var style = nSizer.style;
  4513. style.paddingTop = "0";
  4514. style.paddingBottom = "0";
  4515. style.borderTopWidth = "0";
  4516. style.borderBottomWidth = "0";
  4517. style.height = 0;
  4518. };
  4519. // If the scrollbar visibility has changed from the last draw, we need to
  4520. // adjust the column sizes as the table width will have changed to account
  4521. // for the scrollbar
  4522. var scrollBarVis = divBodyEl.scrollHeight > divBodyEl.clientHeight;
  4523. if ( settings.scrollBarVis !== scrollBarVis && settings.scrollBarVis !== undefined ) {
  4524. settings.scrollBarVis = scrollBarVis;
  4525. _fnAdjustColumnSizing( settings );
  4526. return; // adjust column sizing will call this function again
  4527. }
  4528. else {
  4529. settings.scrollBarVis = scrollBarVis;
  4530. }
  4531. /*
  4532. * 1. Re-create the table inside the scrolling div
  4533. */
  4534. // Remove the old minimised thead and tfoot elements in the inner table
  4535. table.children('thead, tfoot').remove();
  4536. if ( footer ) {
  4537. footerCopy = footer.clone().prependTo( table );
  4538. footerTrgEls = footer.find('tr'); // the original tfoot is in its own table and must be sized
  4539. footerSrcEls = footerCopy.find('tr');
  4540. }
  4541. // Clone the current header and footer elements and then place it into the inner table
  4542. headerCopy = header.clone().prependTo( table );
  4543. headerTrgEls = header.find('tr'); // original header is in its own table
  4544. headerSrcEls = headerCopy.find('tr');
  4545. headerCopy.find('th, td').removeAttr('tabindex');
  4546. /*
  4547. * 2. Take live measurements from the DOM - do not alter the DOM itself!
  4548. */
  4549. // Remove old sizing and apply the calculated column widths
  4550. // Get the unique column headers in the newly created (cloned) header. We want to apply the
  4551. // calculated sizes to this header
  4552. if ( ! scrollX )
  4553. {
  4554. divBodyStyle.width = '100%';
  4555. divHeader[0].style.width = '100%';
  4556. }
  4557. $.each( _fnGetUniqueThs( settings, headerCopy ), function ( i, el ) {
  4558. idx = _fnVisibleToColumnIndex( settings, i );
  4559. el.style.width = settings.aoColumns[idx].sWidth;
  4560. } );
  4561. if ( footer ) {
  4562. _fnApplyToChildren( function(n) {
  4563. n.style.width = "";
  4564. }, footerSrcEls );
  4565. }
  4566. // Size the table as a whole
  4567. sanityWidth = table.outerWidth();
  4568. if ( scrollX === "" ) {
  4569. // No x scrolling
  4570. tableStyle.width = "100%";
  4571. // IE7 will make the width of the table when 100% include the scrollbar
  4572. // - which is shouldn't. When there is a scrollbar we need to take this
  4573. // into account.
  4574. if ( ie67 && (table.find('tbody').height() > divBodyEl.offsetHeight ||
  4575. divBody.css('overflow-y') == "scroll")
  4576. ) {
  4577. tableStyle.width = _fnStringToCss( table.outerWidth() - barWidth);
  4578. }
  4579. // Recalculate the sanity width
  4580. sanityWidth = table.outerWidth();
  4581. }
  4582. else if ( scrollXInner !== "" ) {
  4583. // legacy x scroll inner has been given - use it
  4584. tableStyle.width = _fnStringToCss(scrollXInner);
  4585. // Recalculate the sanity width
  4586. sanityWidth = table.outerWidth();
  4587. }
  4588. // Hidden header should have zero height, so remove padding and borders. Then
  4589. // set the width based on the real headers
  4590. // Apply all styles in one pass
  4591. _fnApplyToChildren( zeroOut, headerSrcEls );
  4592. // Read all widths in next pass
  4593. _fnApplyToChildren( function(nSizer) {
  4594. headerContent.push( nSizer.innerHTML );
  4595. headerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  4596. }, headerSrcEls );
  4597. // Apply all widths in final pass
  4598. _fnApplyToChildren( function(nToSize, i) {
  4599. // Only apply widths to the DataTables detected header cells - this
  4600. // prevents complex headers from having contradictory sizes applied
  4601. if ( $.inArray( nToSize, dtHeaderCells ) !== -1 ) {
  4602. nToSize.style.width = headerWidths[i];
  4603. }
  4604. }, headerTrgEls );
  4605. $(headerSrcEls).height(0);
  4606. /* Same again with the footer if we have one */
  4607. if ( footer )
  4608. {
  4609. _fnApplyToChildren( zeroOut, footerSrcEls );
  4610. _fnApplyToChildren( function(nSizer) {
  4611. footerContent.push( nSizer.innerHTML );
  4612. footerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  4613. }, footerSrcEls );
  4614. _fnApplyToChildren( function(nToSize, i) {
  4615. nToSize.style.width = footerWidths[i];
  4616. }, footerTrgEls );
  4617. $(footerSrcEls).height(0);
  4618. }
  4619. /*
  4620. * 3. Apply the measurements
  4621. */
  4622. // "Hide" the header and footer that we used for the sizing. We need to keep
  4623. // the content of the cell so that the width applied to the header and body
  4624. // both match, but we want to hide it completely. We want to also fix their
  4625. // width to what they currently are
  4626. _fnApplyToChildren( function(nSizer, i) {
  4627. nSizer.innerHTML = '<div class="dataTables_sizing" style="height:0;overflow:hidden;">'+headerContent[i]+'</div>';
  4628. nSizer.style.width = headerWidths[i];
  4629. }, headerSrcEls );
  4630. if ( footer )
  4631. {
  4632. _fnApplyToChildren( function(nSizer, i) {
  4633. nSizer.innerHTML = '<div class="dataTables_sizing" style="height:0;overflow:hidden;">'+footerContent[i]+'</div>';
  4634. nSizer.style.width = footerWidths[i];
  4635. }, footerSrcEls );
  4636. }
  4637. // Sanity check that the table is of a sensible width. If not then we are going to get
  4638. // misalignment - try to prevent this by not allowing the table to shrink below its min width
  4639. if ( table.outerWidth() < sanityWidth )
  4640. {
  4641. // The min width depends upon if we have a vertical scrollbar visible or not */
  4642. correction = ((divBodyEl.scrollHeight > divBodyEl.offsetHeight ||
  4643. divBody.css('overflow-y') == "scroll")) ?
  4644. sanityWidth+barWidth :
  4645. sanityWidth;
  4646. // IE6/7 are a law unto themselves...
  4647. if ( ie67 && (divBodyEl.scrollHeight >
  4648. divBodyEl.offsetHeight || divBody.css('overflow-y') == "scroll")
  4649. ) {
  4650. tableStyle.width = _fnStringToCss( correction-barWidth );
  4651. }
  4652. // And give the user a warning that we've stopped the table getting too small
  4653. if ( scrollX === "" || scrollXInner !== "" ) {
  4654. _fnLog( settings, 1, 'Possible column misalignment', 6 );
  4655. }
  4656. }
  4657. else
  4658. {
  4659. correction = '100%';
  4660. }
  4661. // Apply to the container elements
  4662. divBodyStyle.width = _fnStringToCss( correction );
  4663. divHeaderStyle.width = _fnStringToCss( correction );
  4664. if ( footer ) {
  4665. settings.nScrollFoot.style.width = _fnStringToCss( correction );
  4666. }
  4667. /*
  4668. * 4. Clean up
  4669. */
  4670. if ( ! scrollY ) {
  4671. /* IE7< puts a vertical scrollbar in place (when it shouldn't be) due to subtracting
  4672. * the scrollbar height from the visible display, rather than adding it on. We need to
  4673. * set the height in order to sort this. Don't want to do it in any other browsers.
  4674. */
  4675. if ( ie67 ) {
  4676. divBodyStyle.height = _fnStringToCss( tableEl.offsetHeight+barWidth );
  4677. }
  4678. }
  4679. /* Finally set the width's of the header and footer tables */
  4680. var iOuterWidth = table.outerWidth();
  4681. divHeaderTable[0].style.width = _fnStringToCss( iOuterWidth );
  4682. divHeaderInnerStyle.width = _fnStringToCss( iOuterWidth );
  4683. // Figure out if there are scrollbar present - if so then we need a the header and footer to
  4684. // provide a bit more space to allow "overflow" scrolling (i.e. past the scrollbar)
  4685. var bScrolling = table.height() > divBodyEl.clientHeight || divBody.css('overflow-y') == "scroll";
  4686. var padding = 'padding' + (browser.bScrollbarLeft ? 'Left' : 'Right' );
  4687. divHeaderInnerStyle[ padding ] = bScrolling ? barWidth+"px" : "0px";
  4688. if ( footer ) {
  4689. divFooterTable[0].style.width = _fnStringToCss( iOuterWidth );
  4690. divFooterInner[0].style.width = _fnStringToCss( iOuterWidth );
  4691. divFooterInner[0].style[padding] = bScrolling ? barWidth+"px" : "0px";
  4692. }
  4693. // Correct DOM ordering for colgroup - comes before the thead
  4694. table.children('colgroup').insertBefore( table.children('thead') );
  4695. /* Adjust the position of the header in case we loose the y-scrollbar */
  4696. divBody.scroll();
  4697. // If sorting or filtering has occurred, jump the scrolling back to the top
  4698. // only if we aren't holding the position
  4699. if ( (settings.bSorted || settings.bFiltered) && ! settings._drawHold ) {
  4700. divBodyEl.scrollTop = 0;
  4701. }
  4702. }
  4703. /**
  4704. * Apply a given function to the display child nodes of an element array (typically
  4705. * TD children of TR rows
  4706. * @param {function} fn Method to apply to the objects
  4707. * @param array {nodes} an1 List of elements to look through for display children
  4708. * @param array {nodes} an2 Another list (identical structure to the first) - optional
  4709. * @memberof DataTable#oApi
  4710. */
  4711. function _fnApplyToChildren( fn, an1, an2 )
  4712. {
  4713. var index=0, i=0, iLen=an1.length;
  4714. var nNode1, nNode2;
  4715. while ( i < iLen ) {
  4716. nNode1 = an1[i].firstChild;
  4717. nNode2 = an2 ? an2[i].firstChild : null;
  4718. while ( nNode1 ) {
  4719. if ( nNode1.nodeType === 1 ) {
  4720. if ( an2 ) {
  4721. fn( nNode1, nNode2, index );
  4722. }
  4723. else {
  4724. fn( nNode1, index );
  4725. }
  4726. index++;
  4727. }
  4728. nNode1 = nNode1.nextSibling;
  4729. nNode2 = an2 ? nNode2.nextSibling : null;
  4730. }
  4731. i++;
  4732. }
  4733. }
  4734. var __re_html_remove = /<.*?>/g;
  4735. /**
  4736. * Calculate the width of columns for the table
  4737. * @param {object} oSettings dataTables settings object
  4738. * @memberof DataTable#oApi
  4739. */
  4740. function _fnCalculateColumnWidths ( oSettings )
  4741. {
  4742. var
  4743. table = oSettings.nTable,
  4744. columns = oSettings.aoColumns,
  4745. scroll = oSettings.oScroll,
  4746. scrollY = scroll.sY,
  4747. scrollX = scroll.sX,
  4748. scrollXInner = scroll.sXInner,
  4749. columnCount = columns.length,
  4750. visibleColumns = _fnGetColumns( oSettings, 'bVisible' ),
  4751. headerCells = $('th', oSettings.nTHead),
  4752. tableWidthAttr = table.getAttribute('width'), // from DOM element
  4753. tableContainer = table.parentNode,
  4754. userInputs = false,
  4755. i, column, columnIdx, width, outerWidth,
  4756. browser = oSettings.oBrowser,
  4757. ie67 = browser.bScrollOversize;
  4758. var styleWidth = table.style.width;
  4759. if ( styleWidth && styleWidth.indexOf('%') !== -1 ) {
  4760. tableWidthAttr = styleWidth;
  4761. }
  4762. /* Convert any user input sizes into pixel sizes */
  4763. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4764. column = columns[ visibleColumns[i] ];
  4765. if ( column.sWidth !== null ) {
  4766. column.sWidth = _fnConvertToWidth( column.sWidthOrig, tableContainer );
  4767. userInputs = true;
  4768. }
  4769. }
  4770. /* If the number of columns in the DOM equals the number that we have to
  4771. * process in DataTables, then we can use the offsets that are created by
  4772. * the web- browser. No custom sizes can be set in order for this to happen,
  4773. * nor scrolling used
  4774. */
  4775. if ( ie67 || ! userInputs && ! scrollX && ! scrollY &&
  4776. columnCount == _fnVisbleColumns( oSettings ) &&
  4777. columnCount == headerCells.length
  4778. ) {
  4779. for ( i=0 ; i<columnCount ; i++ ) {
  4780. var colIdx = _fnVisibleToColumnIndex( oSettings, i );
  4781. if ( colIdx !== null ) {
  4782. columns[ colIdx ].sWidth = _fnStringToCss( headerCells.eq(i).width() );
  4783. }
  4784. }
  4785. }
  4786. else
  4787. {
  4788. // Otherwise construct a single row, worst case, table with the widest
  4789. // node in the data, assign any user defined widths, then insert it into
  4790. // the DOM and allow the browser to do all the hard work of calculating
  4791. // table widths
  4792. var tmpTable = $(table).clone() // don't use cloneNode - IE8 will remove events on the main table
  4793. .css( 'visibility', 'hidden' )
  4794. .removeAttr( 'id' );
  4795. // Clean up the table body
  4796. tmpTable.find('tbody tr').remove();
  4797. var tr = $('<tr/>').appendTo( tmpTable.find('tbody') );
  4798. // Clone the table header and footer - we can't use the header / footer
  4799. // from the cloned table, since if scrolling is active, the table's
  4800. // real header and footer are contained in different table tags
  4801. tmpTable.find('thead, tfoot').remove();
  4802. tmpTable
  4803. .append( $(oSettings.nTHead).clone() )
  4804. .append( $(oSettings.nTFoot).clone() );
  4805. // Remove any assigned widths from the footer (from scrolling)
  4806. tmpTable.find('tfoot th, tfoot td').css('width', '');
  4807. // Apply custom sizing to the cloned header
  4808. headerCells = _fnGetUniqueThs( oSettings, tmpTable.find('thead')[0] );
  4809. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4810. column = columns[ visibleColumns[i] ];
  4811. headerCells[i].style.width = column.sWidthOrig !== null && column.sWidthOrig !== '' ?
  4812. _fnStringToCss( column.sWidthOrig ) :
  4813. '';
  4814. // For scrollX we need to force the column width otherwise the
  4815. // browser will collapse it. If this width is smaller than the
  4816. // width the column requires, then it will have no effect
  4817. if ( column.sWidthOrig && scrollX ) {
  4818. $( headerCells[i] ).append( $('<div/>').css( {
  4819. width: column.sWidthOrig,
  4820. margin: 0,
  4821. padding: 0,
  4822. border: 0,
  4823. height: 1
  4824. } ) );
  4825. }
  4826. }
  4827. // Find the widest cell for each column and put it into the table
  4828. if ( oSettings.aoData.length ) {
  4829. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4830. columnIdx = visibleColumns[i];
  4831. column = columns[ columnIdx ];
  4832. $( _fnGetWidestNode( oSettings, columnIdx ) )
  4833. .clone( false )
  4834. .append( column.sContentPadding )
  4835. .appendTo( tr );
  4836. }
  4837. }
  4838. // Tidy the temporary table - remove name attributes so there aren't
  4839. // duplicated in the dom (radio elements for example)
  4840. $('[name]', tmpTable).removeAttr('name');
  4841. // Table has been built, attach to the document so we can work with it.
  4842. // A holding element is used, positioned at the top of the container
  4843. // with minimal height, so it has no effect on if the container scrolls
  4844. // or not. Otherwise it might trigger scrolling when it actually isn't
  4845. // needed
  4846. var holder = $('<div/>').css( scrollX || scrollY ?
  4847. {
  4848. position: 'absolute',
  4849. top: 0,
  4850. left: 0,
  4851. height: 1,
  4852. right: 0,
  4853. overflow: 'hidden'
  4854. } :
  4855. {}
  4856. )
  4857. .append( tmpTable )
  4858. .appendTo( tableContainer );
  4859. // When scrolling (X or Y) we want to set the width of the table as
  4860. // appropriate. However, when not scrolling leave the table width as it
  4861. // is. This results in slightly different, but I think correct behaviour
  4862. if ( scrollX && scrollXInner ) {
  4863. tmpTable.width( scrollXInner );
  4864. }
  4865. else if ( scrollX ) {
  4866. tmpTable.css( 'width', 'auto' );
  4867. tmpTable.removeAttr('width');
  4868. // If there is no width attribute or style, then allow the table to
  4869. // collapse
  4870. if ( tmpTable.width() < tableContainer.clientWidth && tableWidthAttr ) {
  4871. tmpTable.width( tableContainer.clientWidth );
  4872. }
  4873. }
  4874. else if ( scrollY ) {
  4875. tmpTable.width( tableContainer.clientWidth );
  4876. }
  4877. else if ( tableWidthAttr ) {
  4878. tmpTable.width( tableWidthAttr );
  4879. }
  4880. // Get the width of each column in the constructed table - we need to
  4881. // know the inner width (so it can be assigned to the other table's
  4882. // cells) and the outer width so we can calculate the full width of the
  4883. // table. This is safe since DataTables requires a unique cell for each
  4884. // column, but if ever a header can span multiple columns, this will
  4885. // need to be modified.
  4886. var total = 0;
  4887. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4888. var cell = $(headerCells[i]);
  4889. var border = cell.outerWidth() - cell.width();
  4890. // Use getBounding... where possible (not IE8-) because it can give
  4891. // sub-pixel accuracy, which we then want to round up!
  4892. var bounding = browser.bBounding ?
  4893. Math.ceil( headerCells[i].getBoundingClientRect().width ) :
  4894. cell.outerWidth();
  4895. // Total is tracked to remove any sub-pixel errors as the outerWidth
  4896. // of the table might not equal the total given here (IE!).
  4897. total += bounding;
  4898. // Width for each column to use
  4899. columns[ visibleColumns[i] ].sWidth = _fnStringToCss( bounding - border );
  4900. }
  4901. table.style.width = _fnStringToCss( total );
  4902. // Finished with the table - ditch it
  4903. holder.remove();
  4904. }
  4905. // If there is a width attr, we want to attach an event listener which
  4906. // allows the table sizing to automatically adjust when the window is
  4907. // resized. Use the width attr rather than CSS, since we can't know if the
  4908. // CSS is a relative value or absolute - DOM read is always px.
  4909. if ( tableWidthAttr ) {
  4910. table.style.width = _fnStringToCss( tableWidthAttr );
  4911. }
  4912. if ( (tableWidthAttr || scrollX) && ! oSettings._reszEvt ) {
  4913. var bindResize = function () {
  4914. $(window).on('resize.DT-'+oSettings.sInstance, _fnThrottle( function () {
  4915. _fnAdjustColumnSizing( oSettings );
  4916. } ) );
  4917. };
  4918. // IE6/7 will crash if we bind a resize event handler on page load.
  4919. // To be removed in 1.11 which drops IE6/7 support
  4920. if ( ie67 ) {
  4921. setTimeout( bindResize, 1000 );
  4922. }
  4923. else {
  4924. bindResize();
  4925. }
  4926. oSettings._reszEvt = true;
  4927. }
  4928. }
  4929. /**
  4930. * Throttle the calls to a function. Arguments and context are maintained for
  4931. * the throttled function
  4932. * @param {function} fn Function to be called
  4933. * @param {int} [freq=200] call frequency in mS
  4934. * @returns {function} wrapped function
  4935. * @memberof DataTable#oApi
  4936. */
  4937. var _fnThrottle = DataTable.util.throttle;
  4938. /**
  4939. * Convert a CSS unit width to pixels (e.g. 2em)
  4940. * @param {string} width width to be converted
  4941. * @param {node} parent parent to get the with for (required for relative widths) - optional
  4942. * @returns {int} width in pixels
  4943. * @memberof DataTable#oApi
  4944. */
  4945. function _fnConvertToWidth ( width, parent )
  4946. {
  4947. if ( ! width ) {
  4948. return 0;
  4949. }
  4950. var n = $('<div/>')
  4951. .css( 'width', _fnStringToCss( width ) )
  4952. .appendTo( parent || document.body );
  4953. var val = n[0].offsetWidth;
  4954. n.remove();
  4955. return val;
  4956. }
  4957. /**
  4958. * Get the widest node
  4959. * @param {object} settings dataTables settings object
  4960. * @param {int} colIdx column of interest
  4961. * @returns {node} widest table node
  4962. * @memberof DataTable#oApi
  4963. */
  4964. function _fnGetWidestNode( settings, colIdx )
  4965. {
  4966. var idx = _fnGetMaxLenString( settings, colIdx );
  4967. if ( idx < 0 ) {
  4968. return null;
  4969. }
  4970. var data = settings.aoData[ idx ];
  4971. return ! data.nTr ? // Might not have been created when deferred rendering
  4972. $('<td/>').html( _fnGetCellData( settings, idx, colIdx, 'display' ) )[0] :
  4973. data.anCells[ colIdx ];
  4974. }
  4975. /**
  4976. * Get the maximum strlen for each data column
  4977. * @param {object} settings dataTables settings object
  4978. * @param {int} colIdx column of interest
  4979. * @returns {string} max string length for each column
  4980. * @memberof DataTable#oApi
  4981. */
  4982. function _fnGetMaxLenString( settings, colIdx )
  4983. {
  4984. var s, max=-1, maxIdx = -1;
  4985. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  4986. s = _fnGetCellData( settings, i, colIdx, 'display' )+'';
  4987. s = s.replace( __re_html_remove, '' );
  4988. s = s.replace( /&nbsp;/g, ' ' );
  4989. if ( s.length > max ) {
  4990. max = s.length;
  4991. maxIdx = i;
  4992. }
  4993. }
  4994. return maxIdx;
  4995. }
  4996. /**
  4997. * Append a CSS unit (only if required) to a string
  4998. * @param {string} value to css-ify
  4999. * @returns {string} value with css unit
  5000. * @memberof DataTable#oApi
  5001. */
  5002. function _fnStringToCss( s )
  5003. {
  5004. if ( s === null ) {
  5005. return '0px';
  5006. }
  5007. if ( typeof s == 'number' ) {
  5008. return s < 0 ?
  5009. '0px' :
  5010. s+'px';
  5011. }
  5012. // Check it has a unit character already
  5013. return s.match(/\d$/) ?
  5014. s+'px' :
  5015. s;
  5016. }
  5017. function _fnSortFlatten ( settings )
  5018. {
  5019. var
  5020. i, iLen, k, kLen,
  5021. aSort = [],
  5022. aiOrig = [],
  5023. aoColumns = settings.aoColumns,
  5024. aDataSort, iCol, sType, srcCol,
  5025. fixed = settings.aaSortingFixed,
  5026. fixedObj = $.isPlainObject( fixed ),
  5027. nestedSort = [],
  5028. add = function ( a ) {
  5029. if ( a.length && ! $.isArray( a[0] ) ) {
  5030. // 1D array
  5031. nestedSort.push( a );
  5032. }
  5033. else {
  5034. // 2D array
  5035. $.merge( nestedSort, a );
  5036. }
  5037. };
  5038. // Build the sort array, with pre-fix and post-fix options if they have been
  5039. // specified
  5040. if ( $.isArray( fixed ) ) {
  5041. add( fixed );
  5042. }
  5043. if ( fixedObj && fixed.pre ) {
  5044. add( fixed.pre );
  5045. }
  5046. add( settings.aaSorting );
  5047. if (fixedObj && fixed.post ) {
  5048. add( fixed.post );
  5049. }
  5050. for ( i=0 ; i<nestedSort.length ; i++ )
  5051. {
  5052. srcCol = nestedSort[i][0];
  5053. aDataSort = aoColumns[ srcCol ].aDataSort;
  5054. for ( k=0, kLen=aDataSort.length ; k<kLen ; k++ )
  5055. {
  5056. iCol = aDataSort[k];
  5057. sType = aoColumns[ iCol ].sType || 'string';
  5058. if ( nestedSort[i]._idx === undefined ) {
  5059. nestedSort[i]._idx = $.inArray( nestedSort[i][1], aoColumns[iCol].asSorting );
  5060. }
  5061. aSort.push( {
  5062. src: srcCol,
  5063. col: iCol,
  5064. dir: nestedSort[i][1],
  5065. index: nestedSort[i]._idx,
  5066. type: sType,
  5067. formatter: DataTable.ext.type.order[ sType+"-pre" ]
  5068. } );
  5069. }
  5070. }
  5071. return aSort;
  5072. }
  5073. /**
  5074. * Change the order of the table
  5075. * @param {object} oSettings dataTables settings object
  5076. * @memberof DataTable#oApi
  5077. * @todo This really needs split up!
  5078. */
  5079. function _fnSort ( oSettings )
  5080. {
  5081. var
  5082. i, ien, iLen, j, jLen, k, kLen,
  5083. sDataType, nTh,
  5084. aiOrig = [],
  5085. oExtSort = DataTable.ext.type.order,
  5086. aoData = oSettings.aoData,
  5087. aoColumns = oSettings.aoColumns,
  5088. aDataSort, data, iCol, sType, oSort,
  5089. formatters = 0,
  5090. sortCol,
  5091. displayMaster = oSettings.aiDisplayMaster,
  5092. aSort;
  5093. // Resolve any column types that are unknown due to addition or invalidation
  5094. // @todo Can this be moved into a 'data-ready' handler which is called when
  5095. // data is going to be used in the table?
  5096. _fnColumnTypes( oSettings );
  5097. aSort = _fnSortFlatten( oSettings );
  5098. for ( i=0, ien=aSort.length ; i<ien ; i++ ) {
  5099. sortCol = aSort[i];
  5100. // Track if we can use the fast sort algorithm
  5101. if ( sortCol.formatter ) {
  5102. formatters++;
  5103. }
  5104. // Load the data needed for the sort, for each cell
  5105. _fnSortData( oSettings, sortCol.col );
  5106. }
  5107. /* No sorting required if server-side or no sorting array */
  5108. if ( _fnDataSource( oSettings ) != 'ssp' && aSort.length !== 0 )
  5109. {
  5110. // Create a value - key array of the current row positions such that we can use their
  5111. // current position during the sort, if values match, in order to perform stable sorting
  5112. for ( i=0, iLen=displayMaster.length ; i<iLen ; i++ ) {
  5113. aiOrig[ displayMaster[i] ] = i;
  5114. }
  5115. /* Do the sort - here we want multi-column sorting based on a given data source (column)
  5116. * and sorting function (from oSort) in a certain direction. It's reasonably complex to
  5117. * follow on it's own, but this is what we want (example two column sorting):
  5118. * fnLocalSorting = function(a,b){
  5119. * var iTest;
  5120. * iTest = oSort['string-asc']('data11', 'data12');
  5121. * if (iTest !== 0)
  5122. * return iTest;
  5123. * iTest = oSort['numeric-desc']('data21', 'data22');
  5124. * if (iTest !== 0)
  5125. * return iTest;
  5126. * return oSort['numeric-asc']( aiOrig[a], aiOrig[b] );
  5127. * }
  5128. * Basically we have a test for each sorting column, if the data in that column is equal,
  5129. * test the next column. If all columns match, then we use a numeric sort on the row
  5130. * positions in the original data array to provide a stable sort.
  5131. *
  5132. * Note - I know it seems excessive to have two sorting methods, but the first is around
  5133. * 15% faster, so the second is only maintained for backwards compatibility with sorting
  5134. * methods which do not have a pre-sort formatting function.
  5135. */
  5136. if ( formatters === aSort.length ) {
  5137. // All sort types have formatting functions
  5138. displayMaster.sort( function ( a, b ) {
  5139. var
  5140. x, y, k, test, sort,
  5141. len=aSort.length,
  5142. dataA = aoData[a]._aSortData,
  5143. dataB = aoData[b]._aSortData;
  5144. for ( k=0 ; k<len ; k++ ) {
  5145. sort = aSort[k];
  5146. x = dataA[ sort.col ];
  5147. y = dataB[ sort.col ];
  5148. test = x<y ? -1 : x>y ? 1 : 0;
  5149. if ( test !== 0 ) {
  5150. return sort.dir === 'asc' ? test : -test;
  5151. }
  5152. }
  5153. x = aiOrig[a];
  5154. y = aiOrig[b];
  5155. return x<y ? -1 : x>y ? 1 : 0;
  5156. } );
  5157. }
  5158. else {
  5159. // Depreciated - remove in 1.11 (providing a plug-in option)
  5160. // Not all sort types have formatting methods, so we have to call their sorting
  5161. // methods.
  5162. displayMaster.sort( function ( a, b ) {
  5163. var
  5164. x, y, k, l, test, sort, fn,
  5165. len=aSort.length,
  5166. dataA = aoData[a]._aSortData,
  5167. dataB = aoData[b]._aSortData;
  5168. for ( k=0 ; k<len ; k++ ) {
  5169. sort = aSort[k];
  5170. x = dataA[ sort.col ];
  5171. y = dataB[ sort.col ];
  5172. fn = oExtSort[ sort.type+"-"+sort.dir ] || oExtSort[ "string-"+sort.dir ];
  5173. test = fn( x, y );
  5174. if ( test !== 0 ) {
  5175. return test;
  5176. }
  5177. }
  5178. x = aiOrig[a];
  5179. y = aiOrig[b];
  5180. return x<y ? -1 : x>y ? 1 : 0;
  5181. } );
  5182. }
  5183. }
  5184. /* Tell the draw function that we have sorted the data */
  5185. oSettings.bSorted = true;
  5186. }
  5187. function _fnSortAria ( settings )
  5188. {
  5189. var label;
  5190. var nextSort;
  5191. var columns = settings.aoColumns;
  5192. var aSort = _fnSortFlatten( settings );
  5193. var oAria = settings.oLanguage.oAria;
  5194. // ARIA attributes - need to loop all columns, to update all (removing old
  5195. // attributes as needed)
  5196. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  5197. {
  5198. var col = columns[i];
  5199. var asSorting = col.asSorting;
  5200. var sTitle = col.sTitle.replace( /<.*?>/g, "" );
  5201. var th = col.nTh;
  5202. // IE7 is throwing an error when setting these properties with jQuery's
  5203. // attr() and removeAttr() methods...
  5204. th.removeAttribute('aria-sort');
  5205. /* In ARIA only the first sorting column can be marked as sorting - no multi-sort option */
  5206. if ( col.bSortable ) {
  5207. if ( aSort.length > 0 && aSort[0].col == i ) {
  5208. th.setAttribute('aria-sort', aSort[0].dir=="asc" ? "ascending" : "descending" );
  5209. nextSort = asSorting[ aSort[0].index+1 ] || asSorting[0];
  5210. }
  5211. else {
  5212. nextSort = asSorting[0];
  5213. }
  5214. label = sTitle + ( nextSort === "asc" ?
  5215. oAria.sSortAscending :
  5216. oAria.sSortDescending
  5217. );
  5218. }
  5219. else {
  5220. label = sTitle;
  5221. }
  5222. th.setAttribute('aria-label', label);
  5223. }
  5224. }
  5225. /**
  5226. * Function to run on user sort request
  5227. * @param {object} settings dataTables settings object
  5228. * @param {node} attachTo node to attach the handler to
  5229. * @param {int} colIdx column sorting index
  5230. * @param {boolean} [append=false] Append the requested sort to the existing
  5231. * sort if true (i.e. multi-column sort)
  5232. * @param {function} [callback] callback function
  5233. * @memberof DataTable#oApi
  5234. */
  5235. function _fnSortListener ( settings, colIdx, append, callback )
  5236. {
  5237. var col = settings.aoColumns[ colIdx ];
  5238. var sorting = settings.aaSorting;
  5239. var asSorting = col.asSorting;
  5240. var nextSortIdx;
  5241. var next = function ( a, overflow ) {
  5242. var idx = a._idx;
  5243. if ( idx === undefined ) {
  5244. idx = $.inArray( a[1], asSorting );
  5245. }
  5246. return idx+1 < asSorting.length ?
  5247. idx+1 :
  5248. overflow ?
  5249. null :
  5250. 0;
  5251. };
  5252. // Convert to 2D array if needed
  5253. if ( typeof sorting[0] === 'number' ) {
  5254. sorting = settings.aaSorting = [ sorting ];
  5255. }
  5256. // If appending the sort then we are multi-column sorting
  5257. if ( append && settings.oFeatures.bSortMulti ) {
  5258. // Are we already doing some kind of sort on this column?
  5259. var sortIdx = $.inArray( colIdx, _pluck(sorting, '0') );
  5260. if ( sortIdx !== -1 ) {
  5261. // Yes, modify the sort
  5262. nextSortIdx = next( sorting[sortIdx], true );
  5263. if ( nextSortIdx === null && sorting.length === 1 ) {
  5264. nextSortIdx = 0; // can't remove sorting completely
  5265. }
  5266. if ( nextSortIdx === null ) {
  5267. sorting.splice( sortIdx, 1 );
  5268. }
  5269. else {
  5270. sorting[sortIdx][1] = asSorting[ nextSortIdx ];
  5271. sorting[sortIdx]._idx = nextSortIdx;
  5272. }
  5273. }
  5274. else {
  5275. // No sort on this column yet
  5276. sorting.push( [ colIdx, asSorting[0], 0 ] );
  5277. sorting[sorting.length-1]._idx = 0;
  5278. }
  5279. }
  5280. else if ( sorting.length && sorting[0][0] == colIdx ) {
  5281. // Single column - already sorting on this column, modify the sort
  5282. nextSortIdx = next( sorting[0] );
  5283. sorting.length = 1;
  5284. sorting[0][1] = asSorting[ nextSortIdx ];
  5285. sorting[0]._idx = nextSortIdx;
  5286. }
  5287. else {
  5288. // Single column - sort only on this column
  5289. sorting.length = 0;
  5290. sorting.push( [ colIdx, asSorting[0] ] );
  5291. sorting[0]._idx = 0;
  5292. }
  5293. // Run the sort by calling a full redraw
  5294. _fnReDraw( settings );
  5295. // callback used for async user interaction
  5296. if ( typeof callback == 'function' ) {
  5297. callback( settings );
  5298. }
  5299. }
  5300. /**
  5301. * Attach a sort handler (click) to a node
  5302. * @param {object} settings dataTables settings object
  5303. * @param {node} attachTo node to attach the handler to
  5304. * @param {int} colIdx column sorting index
  5305. * @param {function} [callback] callback function
  5306. * @memberof DataTable#oApi
  5307. */
  5308. function _fnSortAttachListener ( settings, attachTo, colIdx, callback )
  5309. {
  5310. var col = settings.aoColumns[ colIdx ];
  5311. _fnBindAction( attachTo, {}, function (e) {
  5312. /* If the column is not sortable - don't to anything */
  5313. if ( col.bSortable === false ) {
  5314. return;
  5315. }
  5316. // If processing is enabled use a timeout to allow the processing
  5317. // display to be shown - otherwise to it synchronously
  5318. if ( settings.oFeatures.bProcessing ) {
  5319. _fnProcessingDisplay( settings, true );
  5320. setTimeout( function() {
  5321. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  5322. // In server-side processing, the draw callback will remove the
  5323. // processing display
  5324. if ( _fnDataSource( settings ) !== 'ssp' ) {
  5325. _fnProcessingDisplay( settings, false );
  5326. }
  5327. }, 0 );
  5328. }
  5329. else {
  5330. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  5331. }
  5332. } );
  5333. }
  5334. /**
  5335. * Set the sorting classes on table's body, Note: it is safe to call this function
  5336. * when bSort and bSortClasses are false
  5337. * @param {object} oSettings dataTables settings object
  5338. * @memberof DataTable#oApi
  5339. */
  5340. function _fnSortingClasses( settings )
  5341. {
  5342. var oldSort = settings.aLastSort;
  5343. var sortClass = settings.oClasses.sSortColumn;
  5344. var sort = _fnSortFlatten( settings );
  5345. var features = settings.oFeatures;
  5346. var i, ien, colIdx;
  5347. if ( features.bSort && features.bSortClasses ) {
  5348. // Remove old sorting classes
  5349. for ( i=0, ien=oldSort.length ; i<ien ; i++ ) {
  5350. colIdx = oldSort[i].src;
  5351. // Remove column sorting
  5352. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  5353. .removeClass( sortClass + (i<2 ? i+1 : 3) );
  5354. }
  5355. // Add new column sorting
  5356. for ( i=0, ien=sort.length ; i<ien ; i++ ) {
  5357. colIdx = sort[i].src;
  5358. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  5359. .addClass( sortClass + (i<2 ? i+1 : 3) );
  5360. }
  5361. }
  5362. settings.aLastSort = sort;
  5363. }
  5364. // Get the data to sort a column, be it from cache, fresh (populating the
  5365. // cache), or from a sort formatter
  5366. function _fnSortData( settings, idx )
  5367. {
  5368. // Custom sorting function - provided by the sort data type
  5369. var column = settings.aoColumns[ idx ];
  5370. var customSort = DataTable.ext.order[ column.sSortDataType ];
  5371. var customData;
  5372. if ( customSort ) {
  5373. customData = customSort.call( settings.oInstance, settings, idx,
  5374. _fnColumnIndexToVisible( settings, idx )
  5375. );
  5376. }
  5377. // Use / populate cache
  5378. var row, cellData;
  5379. var formatter = DataTable.ext.type.order[ column.sType+"-pre" ];
  5380. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  5381. row = settings.aoData[i];
  5382. if ( ! row._aSortData ) {
  5383. row._aSortData = [];
  5384. }
  5385. if ( ! row._aSortData[idx] || customSort ) {
  5386. cellData = customSort ?
  5387. customData[i] : // If there was a custom sort function, use data from there
  5388. _fnGetCellData( settings, i, idx, 'sort' );
  5389. row._aSortData[ idx ] = formatter ?
  5390. formatter( cellData ) :
  5391. cellData;
  5392. }
  5393. }
  5394. }
  5395. /**
  5396. * Save the state of a table
  5397. * @param {object} oSettings dataTables settings object
  5398. * @memberof DataTable#oApi
  5399. */
  5400. function _fnSaveState ( settings )
  5401. {
  5402. if ( !settings.oFeatures.bStateSave || settings.bDestroying )
  5403. {
  5404. return;
  5405. }
  5406. /* Store the interesting variables */
  5407. var state = {
  5408. time: +new Date(),
  5409. start: settings._iDisplayStart,
  5410. length: settings._iDisplayLength,
  5411. order: $.extend( true, [], settings.aaSorting ),
  5412. search: _fnSearchToCamel( settings.oPreviousSearch ),
  5413. columns: $.map( settings.aoColumns, function ( col, i ) {
  5414. return {
  5415. visible: col.bVisible,
  5416. search: _fnSearchToCamel( settings.aoPreSearchCols[i] )
  5417. };
  5418. } )
  5419. };
  5420. _fnCallbackFire( settings, "aoStateSaveParams", 'stateSaveParams', [settings, state] );
  5421. settings.oSavedState = state;
  5422. settings.fnStateSaveCallback.call( settings.oInstance, settings, state );
  5423. }
  5424. /**
  5425. * Attempt to load a saved table state
  5426. * @param {object} oSettings dataTables settings object
  5427. * @param {object} oInit DataTables init object so we can override settings
  5428. * @param {function} callback Callback to execute when the state has been loaded
  5429. * @memberof DataTable#oApi
  5430. */
  5431. function _fnLoadState ( settings, oInit, callback )
  5432. {
  5433. var i, ien;
  5434. var columns = settings.aoColumns;
  5435. var loaded = function ( s ) {
  5436. if ( ! s || ! s.time ) {
  5437. callback();
  5438. return;
  5439. }
  5440. // Allow custom and plug-in manipulation functions to alter the saved data set and
  5441. // cancelling of loading by returning false
  5442. var abStateLoad = _fnCallbackFire( settings, 'aoStateLoadParams', 'stateLoadParams', [settings, s] );
  5443. if ( $.inArray( false, abStateLoad ) !== -1 ) {
  5444. callback();
  5445. return;
  5446. }
  5447. // Reject old data
  5448. var duration = settings.iStateDuration;
  5449. if ( duration > 0 && s.time < +new Date() - (duration*1000) ) {
  5450. callback();
  5451. return;
  5452. }
  5453. // Number of columns have changed - all bets are off, no restore of settings
  5454. if ( s.columns && columns.length !== s.columns.length ) {
  5455. callback();
  5456. return;
  5457. }
  5458. // Store the saved state so it might be accessed at any time
  5459. settings.oLoadedState = $.extend( true, {}, s );
  5460. // Restore key features - todo - for 1.11 this needs to be done by
  5461. // subscribed events
  5462. if ( s.start !== undefined ) {
  5463. settings._iDisplayStart = s.start;
  5464. settings.iInitDisplayStart = s.start;
  5465. }
  5466. if ( s.length !== undefined ) {
  5467. settings._iDisplayLength = s.length;
  5468. }
  5469. // Order
  5470. if ( s.order !== undefined ) {
  5471. settings.aaSorting = [];
  5472. $.each( s.order, function ( i, col ) {
  5473. settings.aaSorting.push( col[0] >= columns.length ?
  5474. [ 0, col[1] ] :
  5475. col
  5476. );
  5477. } );
  5478. }
  5479. // Search
  5480. if ( s.search !== undefined ) {
  5481. $.extend( settings.oPreviousSearch, _fnSearchToHung( s.search ) );
  5482. }
  5483. // Columns
  5484. //
  5485. if ( s.columns ) {
  5486. for ( i=0, ien=s.columns.length ; i<ien ; i++ ) {
  5487. var col = s.columns[i];
  5488. // Visibility
  5489. if ( col.visible !== undefined ) {
  5490. columns[i].bVisible = col.visible;
  5491. }
  5492. // Search
  5493. if ( col.search !== undefined ) {
  5494. $.extend( settings.aoPreSearchCols[i], _fnSearchToHung( col.search ) );
  5495. }
  5496. }
  5497. }
  5498. _fnCallbackFire( settings, 'aoStateLoaded', 'stateLoaded', [settings, s] );
  5499. callback();
  5500. }
  5501. if ( ! settings.oFeatures.bStateSave ) {
  5502. callback();
  5503. return;
  5504. }
  5505. var state = settings.fnStateLoadCallback.call( settings.oInstance, settings, loaded );
  5506. if ( state !== undefined ) {
  5507. loaded( state );
  5508. }
  5509. // otherwise, wait for the loaded callback to be executed
  5510. }
  5511. /**
  5512. * Return the settings object for a particular table
  5513. * @param {node} table table we are using as a dataTable
  5514. * @returns {object} Settings object - or null if not found
  5515. * @memberof DataTable#oApi
  5516. */
  5517. function _fnSettingsFromNode ( table )
  5518. {
  5519. var settings = DataTable.settings;
  5520. var idx = $.inArray( table, _pluck( settings, 'nTable' ) );
  5521. return idx !== -1 ?
  5522. settings[ idx ] :
  5523. null;
  5524. }
  5525. /**
  5526. * Log an error message
  5527. * @param {object} settings dataTables settings object
  5528. * @param {int} level log error messages, or display them to the user
  5529. * @param {string} msg error message
  5530. * @param {int} tn Technical note id to get more information about the error.
  5531. * @memberof DataTable#oApi
  5532. */
  5533. function _fnLog( settings, level, msg, tn )
  5534. {
  5535. msg = 'DataTables warning: '+
  5536. (settings ? 'table id='+settings.sTableId+' - ' : '')+msg;
  5537. if ( tn ) {
  5538. msg += '. For more information about this error, please see '+
  5539. 'http://datatables.net/tn/'+tn;
  5540. }
  5541. if ( ! level ) {
  5542. // Backwards compatibility pre 1.10
  5543. var ext = DataTable.ext;
  5544. var type = ext.sErrMode || ext.errMode;
  5545. if ( settings ) {
  5546. _fnCallbackFire( settings, null, 'error', [ settings, tn, msg ] );
  5547. }
  5548. if ( type == 'alert' ) {
  5549. alert( msg );
  5550. }
  5551. else if ( type == 'throw' ) {
  5552. throw new Error(msg);
  5553. }
  5554. else if ( typeof type == 'function' ) {
  5555. type( settings, tn, msg );
  5556. }
  5557. }
  5558. else if ( window.console && console.log ) {
  5559. console.log( msg );
  5560. }
  5561. }
  5562. /**
  5563. * See if a property is defined on one object, if so assign it to the other object
  5564. * @param {object} ret target object
  5565. * @param {object} src source object
  5566. * @param {string} name property
  5567. * @param {string} [mappedName] name to map too - optional, name used if not given
  5568. * @memberof DataTable#oApi
  5569. */
  5570. function _fnMap( ret, src, name, mappedName )
  5571. {
  5572. if ( $.isArray( name ) ) {
  5573. $.each( name, function (i, val) {
  5574. if ( $.isArray( val ) ) {
  5575. _fnMap( ret, src, val[0], val[1] );
  5576. }
  5577. else {
  5578. _fnMap( ret, src, val );
  5579. }
  5580. } );
  5581. return;
  5582. }
  5583. if ( mappedName === undefined ) {
  5584. mappedName = name;
  5585. }
  5586. if ( src[name] !== undefined ) {
  5587. ret[mappedName] = src[name];
  5588. }
  5589. }
  5590. /**
  5591. * Extend objects - very similar to jQuery.extend, but deep copy objects, and
  5592. * shallow copy arrays. The reason we need to do this, is that we don't want to
  5593. * deep copy array init values (such as aaSorting) since the dev wouldn't be
  5594. * able to override them, but we do want to deep copy arrays.
  5595. * @param {object} out Object to extend
  5596. * @param {object} extender Object from which the properties will be applied to
  5597. * out
  5598. * @param {boolean} breakRefs If true, then arrays will be sliced to take an
  5599. * independent copy with the exception of the `data` or `aaData` parameters
  5600. * if they are present. This is so you can pass in a collection to
  5601. * DataTables and have that used as your data source without breaking the
  5602. * references
  5603. * @returns {object} out Reference, just for convenience - out === the return.
  5604. * @memberof DataTable#oApi
  5605. * @todo This doesn't take account of arrays inside the deep copied objects.
  5606. */
  5607. function _fnExtend( out, extender, breakRefs )
  5608. {
  5609. var val;
  5610. for ( var prop in extender ) {
  5611. if ( extender.hasOwnProperty(prop) ) {
  5612. val = extender[prop];
  5613. if ( $.isPlainObject( val ) ) {
  5614. if ( ! $.isPlainObject( out[prop] ) ) {
  5615. out[prop] = {};
  5616. }
  5617. $.extend( true, out[prop], val );
  5618. }
  5619. else if ( breakRefs && prop !== 'data' && prop !== 'aaData' && $.isArray(val) ) {
  5620. out[prop] = val.slice();
  5621. }
  5622. else {
  5623. out[prop] = val;
  5624. }
  5625. }
  5626. }
  5627. return out;
  5628. }
  5629. /**
  5630. * Bind an event handers to allow a click or return key to activate the callback.
  5631. * This is good for accessibility since a return on the keyboard will have the
  5632. * same effect as a click, if the element has focus.
  5633. * @param {element} n Element to bind the action to
  5634. * @param {object} oData Data object to pass to the triggered function
  5635. * @param {function} fn Callback function for when the event is triggered
  5636. * @memberof DataTable#oApi
  5637. */
  5638. function _fnBindAction( n, oData, fn )
  5639. {
  5640. $(n)
  5641. .on( 'click.DT', oData, function (e) {
  5642. n.blur(); // Remove focus outline for mouse users
  5643. fn(e);
  5644. } )
  5645. .on( 'keypress.DT', oData, function (e){
  5646. if ( e.which === 13 ) {
  5647. e.preventDefault();
  5648. fn(e);
  5649. }
  5650. } )
  5651. .on( 'selectstart.DT', function () {
  5652. /* Take the brutal approach to cancelling text selection */
  5653. return false;
  5654. } );
  5655. }
  5656. /**
  5657. * Register a callback function. Easily allows a callback function to be added to
  5658. * an array store of callback functions that can then all be called together.
  5659. * @param {object} oSettings dataTables settings object
  5660. * @param {string} sStore Name of the array storage for the callbacks in oSettings
  5661. * @param {function} fn Function to be called back
  5662. * @param {string} sName Identifying name for the callback (i.e. a label)
  5663. * @memberof DataTable#oApi
  5664. */
  5665. function _fnCallbackReg( oSettings, sStore, fn, sName )
  5666. {
  5667. if ( fn )
  5668. {
  5669. oSettings[sStore].push( {
  5670. "fn": fn,
  5671. "sName": sName
  5672. } );
  5673. }
  5674. }
  5675. /**
  5676. * Fire callback functions and trigger events. Note that the loop over the
  5677. * callback array store is done backwards! Further note that you do not want to
  5678. * fire off triggers in time sensitive applications (for example cell creation)
  5679. * as its slow.
  5680. * @param {object} settings dataTables settings object
  5681. * @param {string} callbackArr Name of the array storage for the callbacks in
  5682. * oSettings
  5683. * @param {string} eventName Name of the jQuery custom event to trigger. If
  5684. * null no trigger is fired
  5685. * @param {array} args Array of arguments to pass to the callback function /
  5686. * trigger
  5687. * @memberof DataTable#oApi
  5688. */
  5689. function _fnCallbackFire( settings, callbackArr, eventName, args )
  5690. {
  5691. var ret = [];
  5692. if ( callbackArr ) {
  5693. ret = $.map( settings[callbackArr].slice().reverse(), function (val, i) {
  5694. return val.fn.apply( settings.oInstance, args );
  5695. } );
  5696. }
  5697. if ( eventName !== null ) {
  5698. var e = $.Event( eventName+'.dt' );
  5699. $(settings.nTable).trigger( e, args );
  5700. ret.push( e.result );
  5701. }
  5702. return ret;
  5703. }
  5704. function _fnLengthOverflow ( settings )
  5705. {
  5706. var
  5707. start = settings._iDisplayStart,
  5708. end = settings.fnDisplayEnd(),
  5709. len = settings._iDisplayLength;
  5710. /* If we have space to show extra rows (backing up from the end point - then do so */
  5711. if ( start >= end )
  5712. {
  5713. start = end - len;
  5714. }
  5715. // Keep the start record on the current page
  5716. start -= (start % len);
  5717. if ( len === -1 || start < 0 )
  5718. {
  5719. start = 0;
  5720. }
  5721. settings._iDisplayStart = start;
  5722. }
  5723. function _fnRenderer( settings, type )
  5724. {
  5725. var renderer = settings.renderer;
  5726. var host = DataTable.ext.renderer[type];
  5727. if ( $.isPlainObject( renderer ) && renderer[type] ) {
  5728. // Specific renderer for this type. If available use it, otherwise use
  5729. // the default.
  5730. return host[renderer[type]] || host._;
  5731. }
  5732. else if ( typeof renderer === 'string' ) {
  5733. // Common renderer - if there is one available for this type use it,
  5734. // otherwise use the default
  5735. return host[renderer] || host._;
  5736. }
  5737. // Use the default
  5738. return host._;
  5739. }
  5740. /**
  5741. * Detect the data source being used for the table. Used to simplify the code
  5742. * a little (ajax) and to make it compress a little smaller.
  5743. *
  5744. * @param {object} settings dataTables settings object
  5745. * @returns {string} Data source
  5746. * @memberof DataTable#oApi
  5747. */
  5748. function _fnDataSource ( settings )
  5749. {
  5750. if ( settings.oFeatures.bServerSide ) {
  5751. return 'ssp';
  5752. }
  5753. else if ( settings.ajax || settings.sAjaxSource ) {
  5754. return 'ajax';
  5755. }
  5756. return 'dom';
  5757. }
  5758. /**
  5759. * Computed structure of the DataTables API, defined by the options passed to
  5760. * `DataTable.Api.register()` when building the API.
  5761. *
  5762. * The structure is built in order to speed creation and extension of the Api
  5763. * objects since the extensions are effectively pre-parsed.
  5764. *
  5765. * The array is an array of objects with the following structure, where this
  5766. * base array represents the Api prototype base:
  5767. *
  5768. * [
  5769. * {
  5770. * name: 'data' -- string - Property name
  5771. * val: function () {}, -- function - Api method (or undefined if just an object
  5772. * methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  5773. * propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  5774. * },
  5775. * {
  5776. * name: 'row'
  5777. * val: {},
  5778. * methodExt: [ ... ],
  5779. * propExt: [
  5780. * {
  5781. * name: 'data'
  5782. * val: function () {},
  5783. * methodExt: [ ... ],
  5784. * propExt: [ ... ]
  5785. * },
  5786. * ...
  5787. * ]
  5788. * }
  5789. * ]
  5790. *
  5791. * @type {Array}
  5792. * @ignore
  5793. */
  5794. var __apiStruct = [];
  5795. /**
  5796. * `Array.prototype` reference.
  5797. *
  5798. * @type object
  5799. * @ignore
  5800. */
  5801. var __arrayProto = Array.prototype;
  5802. /**
  5803. * Abstraction for `context` parameter of the `Api` constructor to allow it to
  5804. * take several different forms for ease of use.
  5805. *
  5806. * Each of the input parameter types will be converted to a DataTables settings
  5807. * object where possible.
  5808. *
  5809. * @param {string|node|jQuery|object} mixed DataTable identifier. Can be one
  5810. * of:
  5811. *
  5812. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5813. * with be found and used.
  5814. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5815. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5816. * * `object` - DataTables settings object
  5817. * * `DataTables.Api` - API instance
  5818. * @return {array|null} Matching DataTables settings objects. `null` or
  5819. * `undefined` is returned if no matching DataTable is found.
  5820. * @ignore
  5821. */
  5822. var _toSettings = function ( mixed )
  5823. {
  5824. var idx, jq;
  5825. var settings = DataTable.settings;
  5826. var tables = $.map( settings, function (el, i) {
  5827. return el.nTable;
  5828. } );
  5829. if ( ! mixed ) {
  5830. return [];
  5831. }
  5832. else if ( mixed.nTable && mixed.oApi ) {
  5833. // DataTables settings object
  5834. return [ mixed ];
  5835. }
  5836. else if ( mixed.nodeName && mixed.nodeName.toLowerCase() === 'table' ) {
  5837. // Table node
  5838. idx = $.inArray( mixed, tables );
  5839. return idx !== -1 ? [ settings[idx] ] : null;
  5840. }
  5841. else if ( mixed && typeof mixed.settings === 'function' ) {
  5842. return mixed.settings().toArray();
  5843. }
  5844. else if ( typeof mixed === 'string' ) {
  5845. // jQuery selector
  5846. jq = $(mixed);
  5847. }
  5848. else if ( mixed instanceof $ ) {
  5849. // jQuery object (also DataTables instance)
  5850. jq = mixed;
  5851. }
  5852. if ( jq ) {
  5853. return jq.map( function(i) {
  5854. idx = $.inArray( this, tables );
  5855. return idx !== -1 ? settings[idx] : null;
  5856. } ).toArray();
  5857. }
  5858. };
  5859. /**
  5860. * DataTables API class - used to control and interface with one or more
  5861. * DataTables enhanced tables.
  5862. *
  5863. * The API class is heavily based on jQuery, presenting a chainable interface
  5864. * that you can use to interact with tables. Each instance of the API class has
  5865. * a "context" - i.e. the tables that it will operate on. This could be a single
  5866. * table, all tables on a page or a sub-set thereof.
  5867. *
  5868. * Additionally the API is designed to allow you to easily work with the data in
  5869. * the tables, retrieving and manipulating it as required. This is done by
  5870. * presenting the API class as an array like interface. The contents of the
  5871. * array depend upon the actions requested by each method (for example
  5872. * `rows().nodes()` will return an array of nodes, while `rows().data()` will
  5873. * return an array of objects or arrays depending upon your table's
  5874. * configuration). The API object has a number of array like methods (`push`,
  5875. * `pop`, `reverse` etc) as well as additional helper methods (`each`, `pluck`,
  5876. * `unique` etc) to assist your working with the data held in a table.
  5877. *
  5878. * Most methods (those which return an Api instance) are chainable, which means
  5879. * the return from a method call also has all of the methods available that the
  5880. * top level object had. For example, these two calls are equivalent:
  5881. *
  5882. * // Not chained
  5883. * api.row.add( {...} );
  5884. * api.draw();
  5885. *
  5886. * // Chained
  5887. * api.row.add( {...} ).draw();
  5888. *
  5889. * @class DataTable.Api
  5890. * @param {array|object|string|jQuery} context DataTable identifier. This is
  5891. * used to define which DataTables enhanced tables this API will operate on.
  5892. * Can be one of:
  5893. *
  5894. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5895. * with be found and used.
  5896. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5897. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5898. * * `object` - DataTables settings object
  5899. * @param {array} [data] Data to initialise the Api instance with.
  5900. *
  5901. * @example
  5902. * // Direct initialisation during DataTables construction
  5903. * var api = $('#example').DataTable();
  5904. *
  5905. * @example
  5906. * // Initialisation using a DataTables jQuery object
  5907. * var api = $('#example').dataTable().api();
  5908. *
  5909. * @example
  5910. * // Initialisation as a constructor
  5911. * var api = new $.fn.DataTable.Api( 'table.dataTable' );
  5912. */
  5913. _Api = function ( context, data )
  5914. {
  5915. if ( ! (this instanceof _Api) ) {
  5916. return new _Api( context, data );
  5917. }
  5918. var settings = [];
  5919. var ctxSettings = function ( o ) {
  5920. var a = _toSettings( o );
  5921. if ( a ) {
  5922. settings = settings.concat( a );
  5923. }
  5924. };
  5925. if ( $.isArray( context ) ) {
  5926. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  5927. ctxSettings( context[i] );
  5928. }
  5929. }
  5930. else {
  5931. ctxSettings( context );
  5932. }
  5933. // Remove duplicates
  5934. this.context = _unique( settings );
  5935. // Initial data
  5936. if ( data ) {
  5937. $.merge( this, data );
  5938. }
  5939. // selector
  5940. this.selector = {
  5941. rows: null,
  5942. cols: null,
  5943. opts: null
  5944. };
  5945. _Api.extend( this, this, __apiStruct );
  5946. };
  5947. DataTable.Api = _Api;
  5948. // Don't destroy the existing prototype, just extend it. Required for jQuery 2's
  5949. // isPlainObject.
  5950. $.extend( _Api.prototype, {
  5951. any: function ()
  5952. {
  5953. return this.count() !== 0;
  5954. },
  5955. concat: __arrayProto.concat,
  5956. context: [], // array of table settings objects
  5957. count: function ()
  5958. {
  5959. return this.flatten().length;
  5960. },
  5961. each: function ( fn )
  5962. {
  5963. for ( var i=0, ien=this.length ; i<ien; i++ ) {
  5964. fn.call( this, this[i], i, this );
  5965. }
  5966. return this;
  5967. },
  5968. eq: function ( idx )
  5969. {
  5970. var ctx = this.context;
  5971. return ctx.length > idx ?
  5972. new _Api( ctx[idx], this[idx] ) :
  5973. null;
  5974. },
  5975. filter: function ( fn )
  5976. {
  5977. var a = [];
  5978. if ( __arrayProto.filter ) {
  5979. a = __arrayProto.filter.call( this, fn, this );
  5980. }
  5981. else {
  5982. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  5983. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  5984. if ( fn.call( this, this[i], i, this ) ) {
  5985. a.push( this[i] );
  5986. }
  5987. }
  5988. }
  5989. return new _Api( this.context, a );
  5990. },
  5991. flatten: function ()
  5992. {
  5993. var a = [];
  5994. return new _Api( this.context, a.concat.apply( a, this.toArray() ) );
  5995. },
  5996. join: __arrayProto.join,
  5997. indexOf: __arrayProto.indexOf || function (obj, start)
  5998. {
  5999. for ( var i=(start || 0), ien=this.length ; i<ien ; i++ ) {
  6000. if ( this[i] === obj ) {
  6001. return i;
  6002. }
  6003. }
  6004. return -1;
  6005. },
  6006. iterator: function ( flatten, type, fn, alwaysNew ) {
  6007. var
  6008. a = [], ret,
  6009. i, ien, j, jen,
  6010. context = this.context,
  6011. rows, items, item,
  6012. selector = this.selector;
  6013. // Argument shifting
  6014. if ( typeof flatten === 'string' ) {
  6015. alwaysNew = fn;
  6016. fn = type;
  6017. type = flatten;
  6018. flatten = false;
  6019. }
  6020. for ( i=0, ien=context.length ; i<ien ; i++ ) {
  6021. var apiInst = new _Api( context[i] );
  6022. if ( type === 'table' ) {
  6023. ret = fn.call( apiInst, context[i], i );
  6024. if ( ret !== undefined ) {
  6025. a.push( ret );
  6026. }
  6027. }
  6028. else if ( type === 'columns' || type === 'rows' ) {
  6029. // this has same length as context - one entry for each table
  6030. ret = fn.call( apiInst, context[i], this[i], i );
  6031. if ( ret !== undefined ) {
  6032. a.push( ret );
  6033. }
  6034. }
  6035. else if ( type === 'column' || type === 'column-rows' || type === 'row' || type === 'cell' ) {
  6036. // columns and rows share the same structure.
  6037. // 'this' is an array of column indexes for each context
  6038. items = this[i];
  6039. if ( type === 'column-rows' ) {
  6040. rows = _selector_row_indexes( context[i], selector.opts );
  6041. }
  6042. for ( j=0, jen=items.length ; j<jen ; j++ ) {
  6043. item = items[j];
  6044. if ( type === 'cell' ) {
  6045. ret = fn.call( apiInst, context[i], item.row, item.column, i, j );
  6046. }
  6047. else {
  6048. ret = fn.call( apiInst, context[i], item, i, j, rows );
  6049. }
  6050. if ( ret !== undefined ) {
  6051. a.push( ret );
  6052. }
  6053. }
  6054. }
  6055. }
  6056. if ( a.length || alwaysNew ) {
  6057. var api = new _Api( context, flatten ? a.concat.apply( [], a ) : a );
  6058. var apiSelector = api.selector;
  6059. apiSelector.rows = selector.rows;
  6060. apiSelector.cols = selector.cols;
  6061. apiSelector.opts = selector.opts;
  6062. return api;
  6063. }
  6064. return this;
  6065. },
  6066. lastIndexOf: __arrayProto.lastIndexOf || function (obj, start)
  6067. {
  6068. // Bit cheeky...
  6069. return this.indexOf.apply( this.toArray.reverse(), arguments );
  6070. },
  6071. length: 0,
  6072. map: function ( fn )
  6073. {
  6074. var a = [];
  6075. if ( __arrayProto.map ) {
  6076. a = __arrayProto.map.call( this, fn, this );
  6077. }
  6078. else {
  6079. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  6080. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  6081. a.push( fn.call( this, this[i], i ) );
  6082. }
  6083. }
  6084. return new _Api( this.context, a );
  6085. },
  6086. pluck: function ( prop )
  6087. {
  6088. return this.map( function ( el ) {
  6089. return el[ prop ];
  6090. } );
  6091. },
  6092. pop: __arrayProto.pop,
  6093. push: __arrayProto.push,
  6094. // Does not return an API instance
  6095. reduce: __arrayProto.reduce || function ( fn, init )
  6096. {
  6097. return _fnReduce( this, fn, init, 0, this.length, 1 );
  6098. },
  6099. reduceRight: __arrayProto.reduceRight || function ( fn, init )
  6100. {
  6101. return _fnReduce( this, fn, init, this.length-1, -1, -1 );
  6102. },
  6103. reverse: __arrayProto.reverse,
  6104. // Object with rows, columns and opts
  6105. selector: null,
  6106. shift: __arrayProto.shift,
  6107. slice: function () {
  6108. return new _Api( this.context, this );
  6109. },
  6110. sort: __arrayProto.sort, // ? name - order?
  6111. splice: __arrayProto.splice,
  6112. toArray: function ()
  6113. {
  6114. return __arrayProto.slice.call( this );
  6115. },
  6116. to$: function ()
  6117. {
  6118. return $( this );
  6119. },
  6120. toJQuery: function ()
  6121. {
  6122. return $( this );
  6123. },
  6124. unique: function ()
  6125. {
  6126. return new _Api( this.context, _unique(this) );
  6127. },
  6128. unshift: __arrayProto.unshift
  6129. } );
  6130. _Api.extend = function ( scope, obj, ext )
  6131. {
  6132. // Only extend API instances and static properties of the API
  6133. if ( ! ext.length || ! obj || ( ! (obj instanceof _Api) && ! obj.__dt_wrapper ) ) {
  6134. return;
  6135. }
  6136. var
  6137. i, ien,
  6138. j, jen,
  6139. struct, inner,
  6140. methodScoping = function ( scope, fn, struc ) {
  6141. return function () {
  6142. var ret = fn.apply( scope, arguments );
  6143. // Method extension
  6144. _Api.extend( ret, ret, struc.methodExt );
  6145. return ret;
  6146. };
  6147. };
  6148. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  6149. struct = ext[i];
  6150. // Value
  6151. obj[ struct.name ] = typeof struct.val === 'function' ?
  6152. methodScoping( scope, struct.val, struct ) :
  6153. $.isPlainObject( struct.val ) ?
  6154. {} :
  6155. struct.val;
  6156. obj[ struct.name ].__dt_wrapper = true;
  6157. // Property extension
  6158. _Api.extend( scope, obj[ struct.name ], struct.propExt );
  6159. }
  6160. };
  6161. // @todo - Is there need for an augment function?
  6162. // _Api.augment = function ( inst, name )
  6163. // {
  6164. // // Find src object in the structure from the name
  6165. // var parts = name.split('.');
  6166. // _Api.extend( inst, obj );
  6167. // };
  6168. // [
  6169. // {
  6170. // name: 'data' -- string - Property name
  6171. // val: function () {}, -- function - Api method (or undefined if just an object
  6172. // methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  6173. // propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  6174. // },
  6175. // {
  6176. // name: 'row'
  6177. // val: {},
  6178. // methodExt: [ ... ],
  6179. // propExt: [
  6180. // {
  6181. // name: 'data'
  6182. // val: function () {},
  6183. // methodExt: [ ... ],
  6184. // propExt: [ ... ]
  6185. // },
  6186. // ...
  6187. // ]
  6188. // }
  6189. // ]
  6190. _Api.register = _api_register = function ( name, val )
  6191. {
  6192. if ( $.isArray( name ) ) {
  6193. for ( var j=0, jen=name.length ; j<jen ; j++ ) {
  6194. _Api.register( name[j], val );
  6195. }
  6196. return;
  6197. }
  6198. var
  6199. i, ien,
  6200. heir = name.split('.'),
  6201. struct = __apiStruct,
  6202. key, method;
  6203. var find = function ( src, name ) {
  6204. for ( var i=0, ien=src.length ; i<ien ; i++ ) {
  6205. if ( src[i].name === name ) {
  6206. return src[i];
  6207. }
  6208. }
  6209. return null;
  6210. };
  6211. for ( i=0, ien=heir.length ; i<ien ; i++ ) {
  6212. method = heir[i].indexOf('()') !== -1;
  6213. key = method ?
  6214. heir[i].replace('()', '') :
  6215. heir[i];
  6216. var src = find( struct, key );
  6217. if ( ! src ) {
  6218. src = {
  6219. name: key,
  6220. val: {},
  6221. methodExt: [],
  6222. propExt: []
  6223. };
  6224. struct.push( src );
  6225. }
  6226. if ( i === ien-1 ) {
  6227. src.val = val;
  6228. }
  6229. else {
  6230. struct = method ?
  6231. src.methodExt :
  6232. src.propExt;
  6233. }
  6234. }
  6235. };
  6236. _Api.registerPlural = _api_registerPlural = function ( pluralName, singularName, val ) {
  6237. _Api.register( pluralName, val );
  6238. _Api.register( singularName, function () {
  6239. var ret = val.apply( this, arguments );
  6240. if ( ret === this ) {
  6241. // Returned item is the API instance that was passed in, return it
  6242. return this;
  6243. }
  6244. else if ( ret instanceof _Api ) {
  6245. // New API instance returned, want the value from the first item
  6246. // in the returned array for the singular result.
  6247. return ret.length ?
  6248. $.isArray( ret[0] ) ?
  6249. new _Api( ret.context, ret[0] ) : // Array results are 'enhanced'
  6250. ret[0] :
  6251. undefined;
  6252. }
  6253. // Non-API return - just fire it back
  6254. return ret;
  6255. } );
  6256. };
  6257. /**
  6258. * Selector for HTML tables. Apply the given selector to the give array of
  6259. * DataTables settings objects.
  6260. *
  6261. * @param {string|integer} [selector] jQuery selector string or integer
  6262. * @param {array} Array of DataTables settings objects to be filtered
  6263. * @return {array}
  6264. * @ignore
  6265. */
  6266. var __table_selector = function ( selector, a )
  6267. {
  6268. // Integer is used to pick out a table by index
  6269. if ( typeof selector === 'number' ) {
  6270. return [ a[ selector ] ];
  6271. }
  6272. // Perform a jQuery selector on the table nodes
  6273. var nodes = $.map( a, function (el, i) {
  6274. return el.nTable;
  6275. } );
  6276. return $(nodes)
  6277. .filter( selector )
  6278. .map( function (i) {
  6279. // Need to translate back from the table node to the settings
  6280. var idx = $.inArray( this, nodes );
  6281. return a[ idx ];
  6282. } )
  6283. .toArray();
  6284. };
  6285. /**
  6286. * Context selector for the API's context (i.e. the tables the API instance
  6287. * refers to.
  6288. *
  6289. * @name DataTable.Api#tables
  6290. * @param {string|integer} [selector] Selector to pick which tables the iterator
  6291. * should operate on. If not given, all tables in the current context are
  6292. * used. This can be given as a jQuery selector (for example `':gt(0)'`) to
  6293. * select multiple tables or as an integer to select a single table.
  6294. * @returns {DataTable.Api} Returns a new API instance if a selector is given.
  6295. */
  6296. _api_register( 'tables()', function ( selector ) {
  6297. // A new instance is created if there was a selector specified
  6298. return selector ?
  6299. new _Api( __table_selector( selector, this.context ) ) :
  6300. this;
  6301. } );
  6302. _api_register( 'table()', function ( selector ) {
  6303. var tables = this.tables( selector );
  6304. var ctx = tables.context;
  6305. // Truncate to the first matched table
  6306. return ctx.length ?
  6307. new _Api( ctx[0] ) :
  6308. tables;
  6309. } );
  6310. _api_registerPlural( 'tables().nodes()', 'table().node()' , function () {
  6311. return this.iterator( 'table', function ( ctx ) {
  6312. return ctx.nTable;
  6313. }, 1 );
  6314. } );
  6315. _api_registerPlural( 'tables().body()', 'table().body()' , function () {
  6316. return this.iterator( 'table', function ( ctx ) {
  6317. return ctx.nTBody;
  6318. }, 1 );
  6319. } );
  6320. _api_registerPlural( 'tables().header()', 'table().header()' , function () {
  6321. return this.iterator( 'table', function ( ctx ) {
  6322. return ctx.nTHead;
  6323. }, 1 );
  6324. } );
  6325. _api_registerPlural( 'tables().footer()', 'table().footer()' , function () {
  6326. return this.iterator( 'table', function ( ctx ) {
  6327. return ctx.nTFoot;
  6328. }, 1 );
  6329. } );
  6330. _api_registerPlural( 'tables().containers()', 'table().container()' , function () {
  6331. return this.iterator( 'table', function ( ctx ) {
  6332. return ctx.nTableWrapper;
  6333. }, 1 );
  6334. } );
  6335. /**
  6336. * Redraw the tables in the current context.
  6337. */
  6338. _api_register( 'draw()', function ( paging ) {
  6339. return this.iterator( 'table', function ( settings ) {
  6340. if ( paging === 'page' ) {
  6341. _fnDraw( settings );
  6342. }
  6343. else {
  6344. if ( typeof paging === 'string' ) {
  6345. paging = paging === 'full-hold' ?
  6346. false :
  6347. true;
  6348. }
  6349. _fnReDraw( settings, paging===false );
  6350. }
  6351. } );
  6352. } );
  6353. /**
  6354. * Get the current page index.
  6355. *
  6356. * @return {integer} Current page index (zero based)
  6357. *//**
  6358. * Set the current page.
  6359. *
  6360. * Note that if you attempt to show a page which does not exist, DataTables will
  6361. * not throw an error, but rather reset the paging.
  6362. *
  6363. * @param {integer|string} action The paging action to take. This can be one of:
  6364. * * `integer` - The page index to jump to
  6365. * * `string` - An action to take:
  6366. * * `first` - Jump to first page.
  6367. * * `next` - Jump to the next page
  6368. * * `previous` - Jump to previous page
  6369. * * `last` - Jump to the last page.
  6370. * @returns {DataTables.Api} this
  6371. */
  6372. _api_register( 'page()', function ( action ) {
  6373. if ( action === undefined ) {
  6374. return this.page.info().page; // not an expensive call
  6375. }
  6376. // else, have an action to take on all tables
  6377. return this.iterator( 'table', function ( settings ) {
  6378. _fnPageChange( settings, action );
  6379. } );
  6380. } );
  6381. /**
  6382. * Paging information for the first table in the current context.
  6383. *
  6384. * If you require paging information for another table, use the `table()` method
  6385. * with a suitable selector.
  6386. *
  6387. * @return {object} Object with the following properties set:
  6388. * * `page` - Current page index (zero based - i.e. the first page is `0`)
  6389. * * `pages` - Total number of pages
  6390. * * `start` - Display index for the first record shown on the current page
  6391. * * `end` - Display index for the last record shown on the current page
  6392. * * `length` - Display length (number of records). Note that generally `start
  6393. * + length = end`, but this is not always true, for example if there are
  6394. * only 2 records to show on the final page, with a length of 10.
  6395. * * `recordsTotal` - Full data set length
  6396. * * `recordsDisplay` - Data set length once the current filtering criterion
  6397. * are applied.
  6398. */
  6399. _api_register( 'page.info()', function ( action ) {
  6400. if ( this.context.length === 0 ) {
  6401. return undefined;
  6402. }
  6403. var
  6404. settings = this.context[0],
  6405. start = settings._iDisplayStart,
  6406. len = settings.oFeatures.bPaginate ? settings._iDisplayLength : -1,
  6407. visRecords = settings.fnRecordsDisplay(),
  6408. all = len === -1;
  6409. return {
  6410. "page": all ? 0 : Math.floor( start / len ),
  6411. "pages": all ? 1 : Math.ceil( visRecords / len ),
  6412. "start": start,
  6413. "end": settings.fnDisplayEnd(),
  6414. "length": len,
  6415. "recordsTotal": settings.fnRecordsTotal(),
  6416. "recordsDisplay": visRecords,
  6417. "serverSide": _fnDataSource( settings ) === 'ssp'
  6418. };
  6419. } );
  6420. /**
  6421. * Get the current page length.
  6422. *
  6423. * @return {integer} Current page length. Note `-1` indicates that all records
  6424. * are to be shown.
  6425. *//**
  6426. * Set the current page length.
  6427. *
  6428. * @param {integer} Page length to set. Use `-1` to show all records.
  6429. * @returns {DataTables.Api} this
  6430. */
  6431. _api_register( 'page.len()', function ( len ) {
  6432. // Note that we can't call this function 'length()' because `length`
  6433. // is a Javascript property of functions which defines how many arguments
  6434. // the function expects.
  6435. if ( len === undefined ) {
  6436. return this.context.length !== 0 ?
  6437. this.context[0]._iDisplayLength :
  6438. undefined;
  6439. }
  6440. // else, set the page length
  6441. return this.iterator( 'table', function ( settings ) {
  6442. _fnLengthChange( settings, len );
  6443. } );
  6444. } );
  6445. var __reload = function ( settings, holdPosition, callback ) {
  6446. // Use the draw event to trigger a callback
  6447. if ( callback ) {
  6448. var api = new _Api( settings );
  6449. api.one( 'draw', function () {
  6450. callback( api.ajax.json() );
  6451. } );
  6452. }
  6453. if ( _fnDataSource( settings ) == 'ssp' ) {
  6454. _fnReDraw( settings, holdPosition );
  6455. }
  6456. else {
  6457. _fnProcessingDisplay( settings, true );
  6458. // Cancel an existing request
  6459. var xhr = settings.jqXHR;
  6460. if ( xhr && xhr.readyState !== 4 ) {
  6461. xhr.abort();
  6462. }
  6463. // Trigger xhr
  6464. _fnBuildAjax( settings, [], function( json ) {
  6465. _fnClearTable( settings );
  6466. var data = _fnAjaxDataSrc( settings, json );
  6467. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6468. _fnAddData( settings, data[i] );
  6469. }
  6470. _fnReDraw( settings, holdPosition );
  6471. _fnProcessingDisplay( settings, false );
  6472. } );
  6473. }
  6474. };
  6475. /**
  6476. * Get the JSON response from the last Ajax request that DataTables made to the
  6477. * server. Note that this returns the JSON from the first table in the current
  6478. * context.
  6479. *
  6480. * @return {object} JSON received from the server.
  6481. */
  6482. _api_register( 'ajax.json()', function () {
  6483. var ctx = this.context;
  6484. if ( ctx.length > 0 ) {
  6485. return ctx[0].json;
  6486. }
  6487. // else return undefined;
  6488. } );
  6489. /**
  6490. * Get the data submitted in the last Ajax request
  6491. */
  6492. _api_register( 'ajax.params()', function () {
  6493. var ctx = this.context;
  6494. if ( ctx.length > 0 ) {
  6495. return ctx[0].oAjaxData;
  6496. }
  6497. // else return undefined;
  6498. } );
  6499. /**
  6500. * Reload tables from the Ajax data source. Note that this function will
  6501. * automatically re-draw the table when the remote data has been loaded.
  6502. *
  6503. * @param {boolean} [reset=true] Reset (default) or hold the current paging
  6504. * position. A full re-sort and re-filter is performed when this method is
  6505. * called, which is why the pagination reset is the default action.
  6506. * @returns {DataTables.Api} this
  6507. */
  6508. _api_register( 'ajax.reload()', function ( callback, resetPaging ) {
  6509. return this.iterator( 'table', function (settings) {
  6510. __reload( settings, resetPaging===false, callback );
  6511. } );
  6512. } );
  6513. /**
  6514. * Get the current Ajax URL. Note that this returns the URL from the first
  6515. * table in the current context.
  6516. *
  6517. * @return {string} Current Ajax source URL
  6518. *//**
  6519. * Set the Ajax URL. Note that this will set the URL for all tables in the
  6520. * current context.
  6521. *
  6522. * @param {string} url URL to set.
  6523. * @returns {DataTables.Api} this
  6524. */
  6525. _api_register( 'ajax.url()', function ( url ) {
  6526. var ctx = this.context;
  6527. if ( url === undefined ) {
  6528. // get
  6529. if ( ctx.length === 0 ) {
  6530. return undefined;
  6531. }
  6532. ctx = ctx[0];
  6533. return ctx.ajax ?
  6534. $.isPlainObject( ctx.ajax ) ?
  6535. ctx.ajax.url :
  6536. ctx.ajax :
  6537. ctx.sAjaxSource;
  6538. }
  6539. // set
  6540. return this.iterator( 'table', function ( settings ) {
  6541. if ( $.isPlainObject( settings.ajax ) ) {
  6542. settings.ajax.url = url;
  6543. }
  6544. else {
  6545. settings.ajax = url;
  6546. }
  6547. // No need to consider sAjaxSource here since DataTables gives priority
  6548. // to `ajax` over `sAjaxSource`. So setting `ajax` here, renders any
  6549. // value of `sAjaxSource` redundant.
  6550. } );
  6551. } );
  6552. /**
  6553. * Load data from the newly set Ajax URL. Note that this method is only
  6554. * available when `ajax.url()` is used to set a URL. Additionally, this method
  6555. * has the same effect as calling `ajax.reload()` but is provided for
  6556. * convenience when setting a new URL. Like `ajax.reload()` it will
  6557. * automatically redraw the table once the remote data has been loaded.
  6558. *
  6559. * @returns {DataTables.Api} this
  6560. */
  6561. _api_register( 'ajax.url().load()', function ( callback, resetPaging ) {
  6562. // Same as a reload, but makes sense to present it for easy access after a
  6563. // url change
  6564. return this.iterator( 'table', function ( ctx ) {
  6565. __reload( ctx, resetPaging===false, callback );
  6566. } );
  6567. } );
  6568. var _selector_run = function ( type, selector, selectFn, settings, opts )
  6569. {
  6570. var
  6571. out = [], res,
  6572. a, i, ien, j, jen,
  6573. selectorType = typeof selector;
  6574. // Can't just check for isArray here, as an API or jQuery instance might be
  6575. // given with their array like look
  6576. if ( ! selector || selectorType === 'string' || selectorType === 'function' || selector.length === undefined ) {
  6577. selector = [ selector ];
  6578. }
  6579. for ( i=0, ien=selector.length ; i<ien ; i++ ) {
  6580. // Only split on simple strings - complex expressions will be jQuery selectors
  6581. a = selector[i] && selector[i].split && ! selector[i].match(/[\[\(:]/) ?
  6582. selector[i].split(',') :
  6583. [ selector[i] ];
  6584. for ( j=0, jen=a.length ; j<jen ; j++ ) {
  6585. res = selectFn( typeof a[j] === 'string' ? $.trim(a[j]) : a[j] );
  6586. if ( res && res.length ) {
  6587. out = out.concat( res );
  6588. }
  6589. }
  6590. }
  6591. // selector extensions
  6592. var ext = _ext.selector[ type ];
  6593. if ( ext.length ) {
  6594. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  6595. out = ext[i]( settings, opts, out );
  6596. }
  6597. }
  6598. return _unique( out );
  6599. };
  6600. var _selector_opts = function ( opts )
  6601. {
  6602. if ( ! opts ) {
  6603. opts = {};
  6604. }
  6605. // Backwards compatibility for 1.9- which used the terminology filter rather
  6606. // than search
  6607. if ( opts.filter && opts.search === undefined ) {
  6608. opts.search = opts.filter;
  6609. }
  6610. return $.extend( {
  6611. search: 'none',
  6612. order: 'current',
  6613. page: 'all'
  6614. }, opts );
  6615. };
  6616. var _selector_first = function ( inst )
  6617. {
  6618. // Reduce the API instance to the first item found
  6619. for ( var i=0, ien=inst.length ; i<ien ; i++ ) {
  6620. if ( inst[i].length > 0 ) {
  6621. // Assign the first element to the first item in the instance
  6622. // and truncate the instance and context
  6623. inst[0] = inst[i];
  6624. inst[0].length = 1;
  6625. inst.length = 1;
  6626. inst.context = [ inst.context[i] ];
  6627. return inst;
  6628. }
  6629. }
  6630. // Not found - return an empty instance
  6631. inst.length = 0;
  6632. return inst;
  6633. };
  6634. var _selector_row_indexes = function ( settings, opts )
  6635. {
  6636. var
  6637. i, ien, tmp, a=[],
  6638. displayFiltered = settings.aiDisplay,
  6639. displayMaster = settings.aiDisplayMaster;
  6640. var
  6641. search = opts.search, // none, applied, removed
  6642. order = opts.order, // applied, current, index (original - compatibility with 1.9)
  6643. page = opts.page; // all, current
  6644. if ( _fnDataSource( settings ) == 'ssp' ) {
  6645. // In server-side processing mode, most options are irrelevant since
  6646. // rows not shown don't exist and the index order is the applied order
  6647. // Removed is a special case - for consistency just return an empty
  6648. // array
  6649. return search === 'removed' ?
  6650. [] :
  6651. _range( 0, displayMaster.length );
  6652. }
  6653. else if ( page == 'current' ) {
  6654. // Current page implies that order=current and fitler=applied, since it is
  6655. // fairly senseless otherwise, regardless of what order and search actually
  6656. // are
  6657. for ( i=settings._iDisplayStart, ien=settings.fnDisplayEnd() ; i<ien ; i++ ) {
  6658. a.push( displayFiltered[i] );
  6659. }
  6660. }
  6661. else if ( order == 'current' || order == 'applied' ) {
  6662. a = search == 'none' ?
  6663. displayMaster.slice() : // no search
  6664. search == 'applied' ?
  6665. displayFiltered.slice() : // applied search
  6666. $.map( displayMaster, function (el, i) { // removed search
  6667. return $.inArray( el, displayFiltered ) === -1 ? el : null;
  6668. } );
  6669. }
  6670. else if ( order == 'index' || order == 'original' ) {
  6671. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  6672. if ( search == 'none' ) {
  6673. a.push( i );
  6674. }
  6675. else { // applied | removed
  6676. tmp = $.inArray( i, displayFiltered );
  6677. if ((tmp === -1 && search == 'removed') ||
  6678. (tmp >= 0 && search == 'applied') )
  6679. {
  6680. a.push( i );
  6681. }
  6682. }
  6683. }
  6684. }
  6685. return a;
  6686. };
  6687. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6688. * Rows
  6689. *
  6690. * {} - no selector - use all available rows
  6691. * {integer} - row aoData index
  6692. * {node} - TR node
  6693. * {string} - jQuery selector to apply to the TR elements
  6694. * {array} - jQuery array of nodes, or simply an array of TR nodes
  6695. *
  6696. */
  6697. var __row_selector = function ( settings, selector, opts )
  6698. {
  6699. var rows;
  6700. var run = function ( sel ) {
  6701. var selInt = _intVal( sel );
  6702. var i, ien;
  6703. // Short cut - selector is a number and no options provided (default is
  6704. // all records, so no need to check if the index is in there, since it
  6705. // must be - dev error if the index doesn't exist).
  6706. if ( selInt !== null && ! opts ) {
  6707. return [ selInt ];
  6708. }
  6709. if ( ! rows ) {
  6710. rows = _selector_row_indexes( settings, opts );
  6711. }
  6712. if ( selInt !== null && $.inArray( selInt, rows ) !== -1 ) {
  6713. // Selector - integer
  6714. return [ selInt ];
  6715. }
  6716. else if ( sel === null || sel === undefined || sel === '' ) {
  6717. // Selector - none
  6718. return rows;
  6719. }
  6720. // Selector - function
  6721. if ( typeof sel === 'function' ) {
  6722. return $.map( rows, function (idx) {
  6723. var row = settings.aoData[ idx ];
  6724. return sel( idx, row._aData, row.nTr ) ? idx : null;
  6725. } );
  6726. }
  6727. // Get nodes in the order from the `rows` array with null values removed
  6728. var nodes = _removeEmpty(
  6729. _pluck_order( settings.aoData, rows, 'nTr' )
  6730. );
  6731. // Selector - node
  6732. if ( sel.nodeName ) {
  6733. if ( sel._DT_RowIndex !== undefined ) {
  6734. return [ sel._DT_RowIndex ]; // Property added by DT for fast lookup
  6735. }
  6736. else if ( sel._DT_CellIndex ) {
  6737. return [ sel._DT_CellIndex.row ];
  6738. }
  6739. else {
  6740. var host = $(sel).closest('*[data-dt-row]');
  6741. return host.length ?
  6742. [ host.data('dt-row') ] :
  6743. [];
  6744. }
  6745. }
  6746. // ID selector. Want to always be able to select rows by id, regardless
  6747. // of if the tr element has been created or not, so can't rely upon
  6748. // jQuery here - hence a custom implementation. This does not match
  6749. // Sizzle's fast selector or HTML4 - in HTML5 the ID can be anything,
  6750. // but to select it using a CSS selector engine (like Sizzle or
  6751. // querySelect) it would need to need to be escaped for some characters.
  6752. // DataTables simplifies this for row selectors since you can select
  6753. // only a row. A # indicates an id any anything that follows is the id -
  6754. // unescaped.
  6755. if ( typeof sel === 'string' && sel.charAt(0) === '#' ) {
  6756. // get row index from id
  6757. var rowObj = settings.aIds[ sel.replace( /^#/, '' ) ];
  6758. if ( rowObj !== undefined ) {
  6759. return [ rowObj.idx ];
  6760. }
  6761. // need to fall through to jQuery in case there is DOM id that
  6762. // matches
  6763. }
  6764. // Selector - jQuery selector string, array of nodes or jQuery object/
  6765. // As jQuery's .filter() allows jQuery objects to be passed in filter,
  6766. // it also allows arrays, so this will cope with all three options
  6767. return $(nodes)
  6768. .filter( sel )
  6769. .map( function () {
  6770. return this._DT_RowIndex;
  6771. } )
  6772. .toArray();
  6773. };
  6774. return _selector_run( 'row', selector, run, settings, opts );
  6775. };
  6776. _api_register( 'rows()', function ( selector, opts ) {
  6777. // argument shifting
  6778. if ( selector === undefined ) {
  6779. selector = '';
  6780. }
  6781. else if ( $.isPlainObject( selector ) ) {
  6782. opts = selector;
  6783. selector = '';
  6784. }
  6785. opts = _selector_opts( opts );
  6786. var inst = this.iterator( 'table', function ( settings ) {
  6787. return __row_selector( settings, selector, opts );
  6788. }, 1 );
  6789. // Want argument shifting here and in __row_selector?
  6790. inst.selector.rows = selector;
  6791. inst.selector.opts = opts;
  6792. return inst;
  6793. } );
  6794. _api_register( 'rows().nodes()', function () {
  6795. return this.iterator( 'row', function ( settings, row ) {
  6796. return settings.aoData[ row ].nTr || undefined;
  6797. }, 1 );
  6798. } );
  6799. _api_register( 'rows().data()', function () {
  6800. return this.iterator( true, 'rows', function ( settings, rows ) {
  6801. return _pluck_order( settings.aoData, rows, '_aData' );
  6802. }, 1 );
  6803. } );
  6804. _api_registerPlural( 'rows().cache()', 'row().cache()', function ( type ) {
  6805. return this.iterator( 'row', function ( settings, row ) {
  6806. var r = settings.aoData[ row ];
  6807. return type === 'search' ? r._aFilterData : r._aSortData;
  6808. }, 1 );
  6809. } );
  6810. _api_registerPlural( 'rows().invalidate()', 'row().invalidate()', function ( src ) {
  6811. return this.iterator( 'row', function ( settings, row ) {
  6812. _fnInvalidate( settings, row, src );
  6813. } );
  6814. } );
  6815. _api_registerPlural( 'rows().indexes()', 'row().index()', function () {
  6816. return this.iterator( 'row', function ( settings, row ) {
  6817. return row;
  6818. }, 1 );
  6819. } );
  6820. _api_registerPlural( 'rows().ids()', 'row().id()', function ( hash ) {
  6821. var a = [];
  6822. var context = this.context;
  6823. // `iterator` will drop undefined values, but in this case we want them
  6824. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  6825. for ( var j=0, jen=this[i].length ; j<jen ; j++ ) {
  6826. var id = context[i].rowIdFn( context[i].aoData[ this[i][j] ]._aData );
  6827. a.push( (hash === true ? '#' : '' )+ id );
  6828. }
  6829. }
  6830. return new _Api( context, a );
  6831. } );
  6832. _api_registerPlural( 'rows().remove()', 'row().remove()', function () {
  6833. var that = this;
  6834. this.iterator( 'row', function ( settings, row, thatIdx ) {
  6835. var data = settings.aoData;
  6836. var rowData = data[ row ];
  6837. var i, ien, j, jen;
  6838. var loopRow, loopCells;
  6839. data.splice( row, 1 );
  6840. // Update the cached indexes
  6841. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  6842. loopRow = data[i];
  6843. loopCells = loopRow.anCells;
  6844. // Rows
  6845. if ( loopRow.nTr !== null ) {
  6846. loopRow.nTr._DT_RowIndex = i;
  6847. }
  6848. // Cells
  6849. if ( loopCells !== null ) {
  6850. for ( j=0, jen=loopCells.length ; j<jen ; j++ ) {
  6851. loopCells[j]._DT_CellIndex.row = i;
  6852. }
  6853. }
  6854. }
  6855. // Delete from the display arrays
  6856. _fnDeleteIndex( settings.aiDisplayMaster, row );
  6857. _fnDeleteIndex( settings.aiDisplay, row );
  6858. _fnDeleteIndex( that[ thatIdx ], row, false ); // maintain local indexes
  6859. // For server-side processing tables - subtract the deleted row from the count
  6860. if ( settings._iRecordsDisplay > 0 ) {
  6861. settings._iRecordsDisplay--;
  6862. }
  6863. // Check for an 'overflow' they case for displaying the table
  6864. _fnLengthOverflow( settings );
  6865. // Remove the row's ID reference if there is one
  6866. var id = settings.rowIdFn( rowData._aData );
  6867. if ( id !== undefined ) {
  6868. delete settings.aIds[ id ];
  6869. }
  6870. } );
  6871. this.iterator( 'table', function ( settings ) {
  6872. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  6873. settings.aoData[i].idx = i;
  6874. }
  6875. } );
  6876. return this;
  6877. } );
  6878. _api_register( 'rows.add()', function ( rows ) {
  6879. var newRows = this.iterator( 'table', function ( settings ) {
  6880. var row, i, ien;
  6881. var out = [];
  6882. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  6883. row = rows[i];
  6884. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  6885. out.push( _fnAddTr( settings, row )[0] );
  6886. }
  6887. else {
  6888. out.push( _fnAddData( settings, row ) );
  6889. }
  6890. }
  6891. return out;
  6892. }, 1 );
  6893. // Return an Api.rows() extended instance, so rows().nodes() etc can be used
  6894. var modRows = this.rows( -1 );
  6895. modRows.pop();
  6896. $.merge( modRows, newRows );
  6897. return modRows;
  6898. } );
  6899. /**
  6900. *
  6901. */
  6902. _api_register( 'row()', function ( selector, opts ) {
  6903. return _selector_first( this.rows( selector, opts ) );
  6904. } );
  6905. _api_register( 'row().data()', function ( data ) {
  6906. var ctx = this.context;
  6907. if ( data === undefined ) {
  6908. // Get
  6909. return ctx.length && this.length ?
  6910. ctx[0].aoData[ this[0] ]._aData :
  6911. undefined;
  6912. }
  6913. // Set
  6914. ctx[0].aoData[ this[0] ]._aData = data;
  6915. // Automatically invalidate
  6916. _fnInvalidate( ctx[0], this[0], 'data' );
  6917. return this;
  6918. } );
  6919. _api_register( 'row().node()', function () {
  6920. var ctx = this.context;
  6921. return ctx.length && this.length ?
  6922. ctx[0].aoData[ this[0] ].nTr || null :
  6923. null;
  6924. } );
  6925. _api_register( 'row.add()', function ( row ) {
  6926. // Allow a jQuery object to be passed in - only a single row is added from
  6927. // it though - the first element in the set
  6928. if ( row instanceof $ && row.length ) {
  6929. row = row[0];
  6930. }
  6931. var rows = this.iterator( 'table', function ( settings ) {
  6932. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  6933. return _fnAddTr( settings, row )[0];
  6934. }
  6935. return _fnAddData( settings, row );
  6936. } );
  6937. // Return an Api.rows() extended instance, with the newly added row selected
  6938. return this.row( rows[0] );
  6939. } );
  6940. var __details_add = function ( ctx, row, data, klass )
  6941. {
  6942. // Convert to array of TR elements
  6943. var rows = [];
  6944. var addRow = function ( r, k ) {
  6945. // Recursion to allow for arrays of jQuery objects
  6946. if ( $.isArray( r ) || r instanceof $ ) {
  6947. for ( var i=0, ien=r.length ; i<ien ; i++ ) {
  6948. addRow( r[i], k );
  6949. }
  6950. return;
  6951. }
  6952. // If we get a TR element, then just add it directly - up to the dev
  6953. // to add the correct number of columns etc
  6954. if ( r.nodeName && r.nodeName.toLowerCase() === 'tr' ) {
  6955. rows.push( r );
  6956. }
  6957. else {
  6958. // Otherwise create a row with a wrapper
  6959. var created = $('<tr><td/></tr>').addClass( k );
  6960. $('td', created)
  6961. .addClass( k )
  6962. .html( r )
  6963. [0].colSpan = _fnVisbleColumns( ctx );
  6964. rows.push( created[0] );
  6965. }
  6966. };
  6967. addRow( data, klass );
  6968. if ( row._details ) {
  6969. row._details.detach();
  6970. }
  6971. row._details = $(rows);
  6972. // If the children were already shown, that state should be retained
  6973. if ( row._detailsShow ) {
  6974. row._details.insertAfter( row.nTr );
  6975. }
  6976. };
  6977. var __details_remove = function ( api, idx )
  6978. {
  6979. var ctx = api.context;
  6980. if ( ctx.length ) {
  6981. var row = ctx[0].aoData[ idx !== undefined ? idx : api[0] ];
  6982. if ( row && row._details ) {
  6983. row._details.remove();
  6984. row._detailsShow = undefined;
  6985. row._details = undefined;
  6986. }
  6987. }
  6988. };
  6989. var __details_display = function ( api, show ) {
  6990. var ctx = api.context;
  6991. if ( ctx.length && api.length ) {
  6992. var row = ctx[0].aoData[ api[0] ];
  6993. if ( row._details ) {
  6994. row._detailsShow = show;
  6995. if ( show ) {
  6996. row._details.insertAfter( row.nTr );
  6997. }
  6998. else {
  6999. row._details.detach();
  7000. }
  7001. __details_events( ctx[0] );
  7002. }
  7003. }
  7004. };
  7005. var __details_events = function ( settings )
  7006. {
  7007. var api = new _Api( settings );
  7008. var namespace = '.dt.DT_details';
  7009. var drawEvent = 'draw'+namespace;
  7010. var colvisEvent = 'column-visibility'+namespace;
  7011. var destroyEvent = 'destroy'+namespace;
  7012. var data = settings.aoData;
  7013. api.off( drawEvent +' '+ colvisEvent +' '+ destroyEvent );
  7014. if ( _pluck( data, '_details' ).length > 0 ) {
  7015. // On each draw, insert the required elements into the document
  7016. api.on( drawEvent, function ( e, ctx ) {
  7017. if ( settings !== ctx ) {
  7018. return;
  7019. }
  7020. api.rows( {page:'current'} ).eq(0).each( function (idx) {
  7021. // Internal data grab
  7022. var row = data[ idx ];
  7023. if ( row._detailsShow ) {
  7024. row._details.insertAfter( row.nTr );
  7025. }
  7026. } );
  7027. } );
  7028. // Column visibility change - update the colspan
  7029. api.on( colvisEvent, function ( e, ctx, idx, vis ) {
  7030. if ( settings !== ctx ) {
  7031. return;
  7032. }
  7033. // Update the colspan for the details rows (note, only if it already has
  7034. // a colspan)
  7035. var row, visible = _fnVisbleColumns( ctx );
  7036. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  7037. row = data[i];
  7038. if ( row._details ) {
  7039. row._details.children('td[colspan]').attr('colspan', visible );
  7040. }
  7041. }
  7042. } );
  7043. // Table destroyed - nuke any child rows
  7044. api.on( destroyEvent, function ( e, ctx ) {
  7045. if ( settings !== ctx ) {
  7046. return;
  7047. }
  7048. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  7049. if ( data[i]._details ) {
  7050. __details_remove( api, i );
  7051. }
  7052. }
  7053. } );
  7054. }
  7055. };
  7056. // Strings for the method names to help minification
  7057. var _emp = '';
  7058. var _child_obj = _emp+'row().child';
  7059. var _child_mth = _child_obj+'()';
  7060. // data can be:
  7061. // tr
  7062. // string
  7063. // jQuery or array of any of the above
  7064. _api_register( _child_mth, function ( data, klass ) {
  7065. var ctx = this.context;
  7066. if ( data === undefined ) {
  7067. // get
  7068. return ctx.length && this.length ?
  7069. ctx[0].aoData[ this[0] ]._details :
  7070. undefined;
  7071. }
  7072. else if ( data === true ) {
  7073. // show
  7074. this.child.show();
  7075. }
  7076. else if ( data === false ) {
  7077. // remove
  7078. __details_remove( this );
  7079. }
  7080. else if ( ctx.length && this.length ) {
  7081. // set
  7082. __details_add( ctx[0], ctx[0].aoData[ this[0] ], data, klass );
  7083. }
  7084. return this;
  7085. } );
  7086. _api_register( [
  7087. _child_obj+'.show()',
  7088. _child_mth+'.show()' // only when `child()` was called with parameters (without
  7089. ], function ( show ) { // it returns an object and this method is not executed)
  7090. __details_display( this, true );
  7091. return this;
  7092. } );
  7093. _api_register( [
  7094. _child_obj+'.hide()',
  7095. _child_mth+'.hide()' // only when `child()` was called with parameters (without
  7096. ], function () { // it returns an object and this method is not executed)
  7097. __details_display( this, false );
  7098. return this;
  7099. } );
  7100. _api_register( [
  7101. _child_obj+'.remove()',
  7102. _child_mth+'.remove()' // only when `child()` was called with parameters (without
  7103. ], function () { // it returns an object and this method is not executed)
  7104. __details_remove( this );
  7105. return this;
  7106. } );
  7107. _api_register( _child_obj+'.isShown()', function () {
  7108. var ctx = this.context;
  7109. if ( ctx.length && this.length ) {
  7110. // _detailsShown as false or undefined will fall through to return false
  7111. return ctx[0].aoData[ this[0] ]._detailsShow || false;
  7112. }
  7113. return false;
  7114. } );
  7115. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  7116. * Columns
  7117. *
  7118. * {integer} - column index (>=0 count from left, <0 count from right)
  7119. * "{integer}:visIdx" - visible column index (i.e. translate to column index) (>=0 count from left, <0 count from right)
  7120. * "{integer}:visible" - alias for {integer}:visIdx (>=0 count from left, <0 count from right)
  7121. * "{string}:name" - column name
  7122. * "{string}" - jQuery selector on column header nodes
  7123. *
  7124. */
  7125. // can be an array of these items, comma separated list, or an array of comma
  7126. // separated lists
  7127. var __re_column_selector = /^([^:]+):(name|visIdx|visible)$/;
  7128. // r1 and r2 are redundant - but it means that the parameters match for the
  7129. // iterator callback in columns().data()
  7130. var __columnData = function ( settings, column, r1, r2, rows ) {
  7131. var a = [];
  7132. for ( var row=0, ien=rows.length ; row<ien ; row++ ) {
  7133. a.push( _fnGetCellData( settings, rows[row], column ) );
  7134. }
  7135. return a;
  7136. };
  7137. var __column_selector = function ( settings, selector, opts )
  7138. {
  7139. var
  7140. columns = settings.aoColumns,
  7141. names = _pluck( columns, 'sName' ),
  7142. nodes = _pluck( columns, 'nTh' );
  7143. var run = function ( s ) {
  7144. var selInt = _intVal( s );
  7145. // Selector - all
  7146. if ( s === '' ) {
  7147. return _range( columns.length );
  7148. }
  7149. // Selector - index
  7150. if ( selInt !== null ) {
  7151. return [ selInt >= 0 ?
  7152. selInt : // Count from left
  7153. columns.length + selInt // Count from right (+ because its a negative value)
  7154. ];
  7155. }
  7156. // Selector = function
  7157. if ( typeof s === 'function' ) {
  7158. var rows = _selector_row_indexes( settings, opts );
  7159. return $.map( columns, function (col, idx) {
  7160. return s(
  7161. idx,
  7162. __columnData( settings, idx, 0, 0, rows ),
  7163. nodes[ idx ]
  7164. ) ? idx : null;
  7165. } );
  7166. }
  7167. // jQuery or string selector
  7168. var match = typeof s === 'string' ?
  7169. s.match( __re_column_selector ) :
  7170. '';
  7171. if ( match ) {
  7172. switch( match[2] ) {
  7173. case 'visIdx':
  7174. case 'visible':
  7175. var idx = parseInt( match[1], 10 );
  7176. // Visible index given, convert to column index
  7177. if ( idx < 0 ) {
  7178. // Counting from the right
  7179. var visColumns = $.map( columns, function (col,i) {
  7180. return col.bVisible ? i : null;
  7181. } );
  7182. return [ visColumns[ visColumns.length + idx ] ];
  7183. }
  7184. // Counting from the left
  7185. return [ _fnVisibleToColumnIndex( settings, idx ) ];
  7186. case 'name':
  7187. // match by name. `names` is column index complete and in order
  7188. return $.map( names, function (name, i) {
  7189. return name === match[1] ? i : null;
  7190. } );
  7191. default:
  7192. return [];
  7193. }
  7194. }
  7195. // Cell in the table body
  7196. if ( s.nodeName && s._DT_CellIndex ) {
  7197. return [ s._DT_CellIndex.column ];
  7198. }
  7199. // jQuery selector on the TH elements for the columns
  7200. var jqResult = $( nodes )
  7201. .filter( s )
  7202. .map( function () {
  7203. return $.inArray( this, nodes ); // `nodes` is column index complete and in order
  7204. } )
  7205. .toArray();
  7206. if ( jqResult.length || ! s.nodeName ) {
  7207. return jqResult;
  7208. }
  7209. // Otherwise a node which might have a `dt-column` data attribute, or be
  7210. // a child or such an element
  7211. var host = $(s).closest('*[data-dt-column]');
  7212. return host.length ?
  7213. [ host.data('dt-column') ] :
  7214. [];
  7215. };
  7216. return _selector_run( 'column', selector, run, settings, opts );
  7217. };
  7218. var __setColumnVis = function ( settings, column, vis ) {
  7219. var
  7220. cols = settings.aoColumns,
  7221. col = cols[ column ],
  7222. data = settings.aoData,
  7223. row, cells, i, ien, tr;
  7224. // Get
  7225. if ( vis === undefined ) {
  7226. return col.bVisible;
  7227. }
  7228. // Set
  7229. // No change
  7230. if ( col.bVisible === vis ) {
  7231. return;
  7232. }
  7233. if ( vis ) {
  7234. // Insert column
  7235. // Need to decide if we should use appendChild or insertBefore
  7236. var insertBefore = $.inArray( true, _pluck(cols, 'bVisible'), column+1 );
  7237. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  7238. tr = data[i].nTr;
  7239. cells = data[i].anCells;
  7240. if ( tr ) {
  7241. // insertBefore can act like appendChild if 2nd arg is null
  7242. tr.insertBefore( cells[ column ], cells[ insertBefore ] || null );
  7243. }
  7244. }
  7245. }
  7246. else {
  7247. // Remove column
  7248. $( _pluck( settings.aoData, 'anCells', column ) ).detach();
  7249. }
  7250. // Common actions
  7251. col.bVisible = vis;
  7252. _fnDrawHead( settings, settings.aoHeader );
  7253. _fnDrawHead( settings, settings.aoFooter );
  7254. _fnSaveState( settings );
  7255. };
  7256. _api_register( 'columns()', function ( selector, opts ) {
  7257. // argument shifting
  7258. if ( selector === undefined ) {
  7259. selector = '';
  7260. }
  7261. else if ( $.isPlainObject( selector ) ) {
  7262. opts = selector;
  7263. selector = '';
  7264. }
  7265. opts = _selector_opts( opts );
  7266. var inst = this.iterator( 'table', function ( settings ) {
  7267. return __column_selector( settings, selector, opts );
  7268. }, 1 );
  7269. // Want argument shifting here and in _row_selector?
  7270. inst.selector.cols = selector;
  7271. inst.selector.opts = opts;
  7272. return inst;
  7273. } );
  7274. _api_registerPlural( 'columns().header()', 'column().header()', function ( selector, opts ) {
  7275. return this.iterator( 'column', function ( settings, column ) {
  7276. return settings.aoColumns[column].nTh;
  7277. }, 1 );
  7278. } );
  7279. _api_registerPlural( 'columns().footer()', 'column().footer()', function ( selector, opts ) {
  7280. return this.iterator( 'column', function ( settings, column ) {
  7281. return settings.aoColumns[column].nTf;
  7282. }, 1 );
  7283. } );
  7284. _api_registerPlural( 'columns().data()', 'column().data()', function () {
  7285. return this.iterator( 'column-rows', __columnData, 1 );
  7286. } );
  7287. _api_registerPlural( 'columns().dataSrc()', 'column().dataSrc()', function () {
  7288. return this.iterator( 'column', function ( settings, column ) {
  7289. return settings.aoColumns[column].mData;
  7290. }, 1 );
  7291. } );
  7292. _api_registerPlural( 'columns().cache()', 'column().cache()', function ( type ) {
  7293. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7294. return _pluck_order( settings.aoData, rows,
  7295. type === 'search' ? '_aFilterData' : '_aSortData', column
  7296. );
  7297. }, 1 );
  7298. } );
  7299. _api_registerPlural( 'columns().nodes()', 'column().nodes()', function () {
  7300. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7301. return _pluck_order( settings.aoData, rows, 'anCells', column ) ;
  7302. }, 1 );
  7303. } );
  7304. _api_registerPlural( 'columns().visible()', 'column().visible()', function ( vis, calc ) {
  7305. var ret = this.iterator( 'column', function ( settings, column ) {
  7306. if ( vis === undefined ) {
  7307. return settings.aoColumns[ column ].bVisible;
  7308. } // else
  7309. __setColumnVis( settings, column, vis );
  7310. } );
  7311. // Group the column visibility changes
  7312. if ( vis !== undefined ) {
  7313. // Second loop once the first is done for events
  7314. this.iterator( 'column', function ( settings, column ) {
  7315. _fnCallbackFire( settings, null, 'column-visibility', [settings, column, vis, calc] );
  7316. } );
  7317. if ( calc === undefined || calc ) {
  7318. this.columns.adjust();
  7319. }
  7320. }
  7321. return ret;
  7322. } );
  7323. _api_registerPlural( 'columns().indexes()', 'column().index()', function ( type ) {
  7324. return this.iterator( 'column', function ( settings, column ) {
  7325. return type === 'visible' ?
  7326. _fnColumnIndexToVisible( settings, column ) :
  7327. column;
  7328. }, 1 );
  7329. } );
  7330. _api_register( 'columns.adjust()', function () {
  7331. return this.iterator( 'table', function ( settings ) {
  7332. _fnAdjustColumnSizing( settings );
  7333. }, 1 );
  7334. } );
  7335. _api_register( 'column.index()', function ( type, idx ) {
  7336. if ( this.context.length !== 0 ) {
  7337. var ctx = this.context[0];
  7338. if ( type === 'fromVisible' || type === 'toData' ) {
  7339. return _fnVisibleToColumnIndex( ctx, idx );
  7340. }
  7341. else if ( type === 'fromData' || type === 'toVisible' ) {
  7342. return _fnColumnIndexToVisible( ctx, idx );
  7343. }
  7344. }
  7345. } );
  7346. _api_register( 'column()', function ( selector, opts ) {
  7347. return _selector_first( this.columns( selector, opts ) );
  7348. } );
  7349. var __cell_selector = function ( settings, selector, opts )
  7350. {
  7351. var data = settings.aoData;
  7352. var rows = _selector_row_indexes( settings, opts );
  7353. var cells = _removeEmpty( _pluck_order( data, rows, 'anCells' ) );
  7354. var allCells = $( [].concat.apply([], cells) );
  7355. var row;
  7356. var columns = settings.aoColumns.length;
  7357. var a, i, ien, j, o, host;
  7358. var run = function ( s ) {
  7359. var fnSelector = typeof s === 'function';
  7360. if ( s === null || s === undefined || fnSelector ) {
  7361. // All cells and function selectors
  7362. a = [];
  7363. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  7364. row = rows[i];
  7365. for ( j=0 ; j<columns ; j++ ) {
  7366. o = {
  7367. row: row,
  7368. column: j
  7369. };
  7370. if ( fnSelector ) {
  7371. // Selector - function
  7372. host = data[ row ];
  7373. if ( s( o, _fnGetCellData(settings, row, j), host.anCells ? host.anCells[j] : null ) ) {
  7374. a.push( o );
  7375. }
  7376. }
  7377. else {
  7378. // Selector - all
  7379. a.push( o );
  7380. }
  7381. }
  7382. }
  7383. return a;
  7384. }
  7385. // Selector - index
  7386. if ( $.isPlainObject( s ) ) {
  7387. return [s];
  7388. }
  7389. // Selector - jQuery filtered cells
  7390. var jqResult = allCells
  7391. .filter( s )
  7392. .map( function (i, el) {
  7393. return { // use a new object, in case someone changes the values
  7394. row: el._DT_CellIndex.row,
  7395. column: el._DT_CellIndex.column
  7396. };
  7397. } )
  7398. .toArray();
  7399. if ( jqResult.length || ! s.nodeName ) {
  7400. return jqResult;
  7401. }
  7402. // Otherwise the selector is a node, and there is one last option - the
  7403. // element might be a child of an element which has dt-row and dt-column
  7404. // data attributes
  7405. host = $(s).closest('*[data-dt-row]');
  7406. return host.length ?
  7407. [ {
  7408. row: host.data('dt-row'),
  7409. column: host.data('dt-column')
  7410. } ] :
  7411. [];
  7412. };
  7413. return _selector_run( 'cell', selector, run, settings, opts );
  7414. };
  7415. _api_register( 'cells()', function ( rowSelector, columnSelector, opts ) {
  7416. // Argument shifting
  7417. if ( $.isPlainObject( rowSelector ) ) {
  7418. // Indexes
  7419. if ( rowSelector.row === undefined ) {
  7420. // Selector options in first parameter
  7421. opts = rowSelector;
  7422. rowSelector = null;
  7423. }
  7424. else {
  7425. // Cell index objects in first parameter
  7426. opts = columnSelector;
  7427. columnSelector = null;
  7428. }
  7429. }
  7430. if ( $.isPlainObject( columnSelector ) ) {
  7431. opts = columnSelector;
  7432. columnSelector = null;
  7433. }
  7434. // Cell selector
  7435. if ( columnSelector === null || columnSelector === undefined ) {
  7436. return this.iterator( 'table', function ( settings ) {
  7437. return __cell_selector( settings, rowSelector, _selector_opts( opts ) );
  7438. } );
  7439. }
  7440. // Row + column selector
  7441. var columns = this.columns( columnSelector, opts );
  7442. var rows = this.rows( rowSelector, opts );
  7443. var a, i, ien, j, jen;
  7444. var cells = this.iterator( 'table', function ( settings, idx ) {
  7445. a = [];
  7446. for ( i=0, ien=rows[idx].length ; i<ien ; i++ ) {
  7447. for ( j=0, jen=columns[idx].length ; j<jen ; j++ ) {
  7448. a.push( {
  7449. row: rows[idx][i],
  7450. column: columns[idx][j]
  7451. } );
  7452. }
  7453. }
  7454. return a;
  7455. }, 1 );
  7456. $.extend( cells.selector, {
  7457. cols: columnSelector,
  7458. rows: rowSelector,
  7459. opts: opts
  7460. } );
  7461. return cells;
  7462. } );
  7463. _api_registerPlural( 'cells().nodes()', 'cell().node()', function () {
  7464. return this.iterator( 'cell', function ( settings, row, column ) {
  7465. var data = settings.aoData[ row ];
  7466. return data && data.anCells ?
  7467. data.anCells[ column ] :
  7468. undefined;
  7469. }, 1 );
  7470. } );
  7471. _api_register( 'cells().data()', function () {
  7472. return this.iterator( 'cell', function ( settings, row, column ) {
  7473. return _fnGetCellData( settings, row, column );
  7474. }, 1 );
  7475. } );
  7476. _api_registerPlural( 'cells().cache()', 'cell().cache()', function ( type ) {
  7477. type = type === 'search' ? '_aFilterData' : '_aSortData';
  7478. return this.iterator( 'cell', function ( settings, row, column ) {
  7479. return settings.aoData[ row ][ type ][ column ];
  7480. }, 1 );
  7481. } );
  7482. _api_registerPlural( 'cells().render()', 'cell().render()', function ( type ) {
  7483. return this.iterator( 'cell', function ( settings, row, column ) {
  7484. return _fnGetCellData( settings, row, column, type );
  7485. }, 1 );
  7486. } );
  7487. _api_registerPlural( 'cells().indexes()', 'cell().index()', function () {
  7488. return this.iterator( 'cell', function ( settings, row, column ) {
  7489. return {
  7490. row: row,
  7491. column: column,
  7492. columnVisible: _fnColumnIndexToVisible( settings, column )
  7493. };
  7494. }, 1 );
  7495. } );
  7496. _api_registerPlural( 'cells().invalidate()', 'cell().invalidate()', function ( src ) {
  7497. return this.iterator( 'cell', function ( settings, row, column ) {
  7498. _fnInvalidate( settings, row, src, column );
  7499. } );
  7500. } );
  7501. _api_register( 'cell()', function ( rowSelector, columnSelector, opts ) {
  7502. return _selector_first( this.cells( rowSelector, columnSelector, opts ) );
  7503. } );
  7504. _api_register( 'cell().data()', function ( data ) {
  7505. var ctx = this.context;
  7506. var cell = this[0];
  7507. if ( data === undefined ) {
  7508. // Get
  7509. return ctx.length && cell.length ?
  7510. _fnGetCellData( ctx[0], cell[0].row, cell[0].column ) :
  7511. undefined;
  7512. }
  7513. // Set
  7514. _fnSetCellData( ctx[0], cell[0].row, cell[0].column, data );
  7515. _fnInvalidate( ctx[0], cell[0].row, 'data', cell[0].column );
  7516. return this;
  7517. } );
  7518. /**
  7519. * Get current ordering (sorting) that has been applied to the table.
  7520. *
  7521. * @returns {array} 2D array containing the sorting information for the first
  7522. * table in the current context. Each element in the parent array represents
  7523. * a column being sorted upon (i.e. multi-sorting with two columns would have
  7524. * 2 inner arrays). The inner arrays may have 2 or 3 elements. The first is
  7525. * the column index that the sorting condition applies to, the second is the
  7526. * direction of the sort (`desc` or `asc`) and, optionally, the third is the
  7527. * index of the sorting order from the `column.sorting` initialisation array.
  7528. *//**
  7529. * Set the ordering for the table.
  7530. *
  7531. * @param {integer} order Column index to sort upon.
  7532. * @param {string} direction Direction of the sort to be applied (`asc` or `desc`)
  7533. * @returns {DataTables.Api} this
  7534. *//**
  7535. * Set the ordering for the table.
  7536. *
  7537. * @param {array} order 1D array of sorting information to be applied.
  7538. * @param {array} [...] Optional additional sorting conditions
  7539. * @returns {DataTables.Api} this
  7540. *//**
  7541. * Set the ordering for the table.
  7542. *
  7543. * @param {array} order 2D array of sorting information to be applied.
  7544. * @returns {DataTables.Api} this
  7545. */
  7546. _api_register( 'order()', function ( order, dir ) {
  7547. var ctx = this.context;
  7548. if ( order === undefined ) {
  7549. // get
  7550. return ctx.length !== 0 ?
  7551. ctx[0].aaSorting :
  7552. undefined;
  7553. }
  7554. // set
  7555. if ( typeof order === 'number' ) {
  7556. // Simple column / direction passed in
  7557. order = [ [ order, dir ] ];
  7558. }
  7559. else if ( order.length && ! $.isArray( order[0] ) ) {
  7560. // Arguments passed in (list of 1D arrays)
  7561. order = Array.prototype.slice.call( arguments );
  7562. }
  7563. // otherwise a 2D array was passed in
  7564. return this.iterator( 'table', function ( settings ) {
  7565. settings.aaSorting = order.slice();
  7566. } );
  7567. } );
  7568. /**
  7569. * Attach a sort listener to an element for a given column
  7570. *
  7571. * @param {node|jQuery|string} node Identifier for the element(s) to attach the
  7572. * listener to. This can take the form of a single DOM node, a jQuery
  7573. * collection of nodes or a jQuery selector which will identify the node(s).
  7574. * @param {integer} column the column that a click on this node will sort on
  7575. * @param {function} [callback] callback function when sort is run
  7576. * @returns {DataTables.Api} this
  7577. */
  7578. _api_register( 'order.listener()', function ( node, column, callback ) {
  7579. return this.iterator( 'table', function ( settings ) {
  7580. _fnSortAttachListener( settings, node, column, callback );
  7581. } );
  7582. } );
  7583. _api_register( 'order.fixed()', function ( set ) {
  7584. if ( ! set ) {
  7585. var ctx = this.context;
  7586. var fixed = ctx.length ?
  7587. ctx[0].aaSortingFixed :
  7588. undefined;
  7589. return $.isArray( fixed ) ?
  7590. { pre: fixed } :
  7591. fixed;
  7592. }
  7593. return this.iterator( 'table', function ( settings ) {
  7594. settings.aaSortingFixed = $.extend( true, {}, set );
  7595. } );
  7596. } );
  7597. // Order by the selected column(s)
  7598. _api_register( [
  7599. 'columns().order()',
  7600. 'column().order()'
  7601. ], function ( dir ) {
  7602. var that = this;
  7603. return this.iterator( 'table', function ( settings, i ) {
  7604. var sort = [];
  7605. $.each( that[i], function (j, col) {
  7606. sort.push( [ col, dir ] );
  7607. } );
  7608. settings.aaSorting = sort;
  7609. } );
  7610. } );
  7611. _api_register( 'search()', function ( input, regex, smart, caseInsen ) {
  7612. var ctx = this.context;
  7613. if ( input === undefined ) {
  7614. // get
  7615. return ctx.length !== 0 ?
  7616. ctx[0].oPreviousSearch.sSearch :
  7617. undefined;
  7618. }
  7619. // set
  7620. return this.iterator( 'table', function ( settings ) {
  7621. if ( ! settings.oFeatures.bFilter ) {
  7622. return;
  7623. }
  7624. _fnFilterComplete( settings, $.extend( {}, settings.oPreviousSearch, {
  7625. "sSearch": input+"",
  7626. "bRegex": regex === null ? false : regex,
  7627. "bSmart": smart === null ? true : smart,
  7628. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7629. } ), 1 );
  7630. } );
  7631. } );
  7632. _api_registerPlural(
  7633. 'columns().search()',
  7634. 'column().search()',
  7635. function ( input, regex, smart, caseInsen ) {
  7636. return this.iterator( 'column', function ( settings, column ) {
  7637. var preSearch = settings.aoPreSearchCols;
  7638. if ( input === undefined ) {
  7639. // get
  7640. return preSearch[ column ].sSearch;
  7641. }
  7642. // set
  7643. if ( ! settings.oFeatures.bFilter ) {
  7644. return;
  7645. }
  7646. $.extend( preSearch[ column ], {
  7647. "sSearch": input+"",
  7648. "bRegex": regex === null ? false : regex,
  7649. "bSmart": smart === null ? true : smart,
  7650. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7651. } );
  7652. _fnFilterComplete( settings, settings.oPreviousSearch, 1 );
  7653. } );
  7654. }
  7655. );
  7656. /*
  7657. * State API methods
  7658. */
  7659. _api_register( 'state()', function () {
  7660. return this.context.length ?
  7661. this.context[0].oSavedState :
  7662. null;
  7663. } );
  7664. _api_register( 'state.clear()', function () {
  7665. return this.iterator( 'table', function ( settings ) {
  7666. // Save an empty object
  7667. settings.fnStateSaveCallback.call( settings.oInstance, settings, {} );
  7668. } );
  7669. } );
  7670. _api_register( 'state.loaded()', function () {
  7671. return this.context.length ?
  7672. this.context[0].oLoadedState :
  7673. null;
  7674. } );
  7675. _api_register( 'state.save()', function () {
  7676. return this.iterator( 'table', function ( settings ) {
  7677. _fnSaveState( settings );
  7678. } );
  7679. } );
  7680. /**
  7681. * Provide a common method for plug-ins to check the version of DataTables being
  7682. * used, in order to ensure compatibility.
  7683. *
  7684. * @param {string} version Version string to check for, in the format "X.Y.Z".
  7685. * Note that the formats "X" and "X.Y" are also acceptable.
  7686. * @returns {boolean} true if this version of DataTables is greater or equal to
  7687. * the required version, or false if this version of DataTales is not
  7688. * suitable
  7689. * @static
  7690. * @dtopt API-Static
  7691. *
  7692. * @example
  7693. * alert( $.fn.dataTable.versionCheck( '1.9.0' ) );
  7694. */
  7695. DataTable.versionCheck = DataTable.fnVersionCheck = function( version )
  7696. {
  7697. var aThis = DataTable.version.split('.');
  7698. var aThat = version.split('.');
  7699. var iThis, iThat;
  7700. for ( var i=0, iLen=aThat.length ; i<iLen ; i++ ) {
  7701. iThis = parseInt( aThis[i], 10 ) || 0;
  7702. iThat = parseInt( aThat[i], 10 ) || 0;
  7703. // Parts are the same, keep comparing
  7704. if (iThis === iThat) {
  7705. continue;
  7706. }
  7707. // Parts are different, return immediately
  7708. return iThis > iThat;
  7709. }
  7710. return true;
  7711. };
  7712. /**
  7713. * Check if a `<table>` node is a DataTable table already or not.
  7714. *
  7715. * @param {node|jquery|string} table Table node, jQuery object or jQuery
  7716. * selector for the table to test. Note that if more than more than one
  7717. * table is passed on, only the first will be checked
  7718. * @returns {boolean} true the table given is a DataTable, or false otherwise
  7719. * @static
  7720. * @dtopt API-Static
  7721. *
  7722. * @example
  7723. * if ( ! $.fn.DataTable.isDataTable( '#example' ) ) {
  7724. * $('#example').dataTable();
  7725. * }
  7726. */
  7727. DataTable.isDataTable = DataTable.fnIsDataTable = function ( table )
  7728. {
  7729. var t = $(table).get(0);
  7730. var is = false;
  7731. if ( table instanceof DataTable.Api ) {
  7732. return true;
  7733. }
  7734. $.each( DataTable.settings, function (i, o) {
  7735. var head = o.nScrollHead ? $('table', o.nScrollHead)[0] : null;
  7736. var foot = o.nScrollFoot ? $('table', o.nScrollFoot)[0] : null;
  7737. if ( o.nTable === t || head === t || foot === t ) {
  7738. is = true;
  7739. }
  7740. } );
  7741. return is;
  7742. };
  7743. /**
  7744. * Get all DataTable tables that have been initialised - optionally you can
  7745. * select to get only currently visible tables.
  7746. *
  7747. * @param {boolean} [visible=false] Flag to indicate if you want all (default)
  7748. * or visible tables only.
  7749. * @returns {array} Array of `table` nodes (not DataTable instances) which are
  7750. * DataTables
  7751. * @static
  7752. * @dtopt API-Static
  7753. *
  7754. * @example
  7755. * $.each( $.fn.dataTable.tables(true), function () {
  7756. * $(table).DataTable().columns.adjust();
  7757. * } );
  7758. */
  7759. DataTable.tables = DataTable.fnTables = function ( visible )
  7760. {
  7761. var api = false;
  7762. if ( $.isPlainObject( visible ) ) {
  7763. api = visible.api;
  7764. visible = visible.visible;
  7765. }
  7766. var a = $.map( DataTable.settings, function (o) {
  7767. if ( !visible || (visible && $(o.nTable).is(':visible')) ) {
  7768. return o.nTable;
  7769. }
  7770. } );
  7771. return api ?
  7772. new _Api( a ) :
  7773. a;
  7774. };
  7775. /**
  7776. * Convert from camel case parameters to Hungarian notation. This is made public
  7777. * for the extensions to provide the same ability as DataTables core to accept
  7778. * either the 1.9 style Hungarian notation, or the 1.10+ style camelCase
  7779. * parameters.
  7780. *
  7781. * @param {object} src The model object which holds all parameters that can be
  7782. * mapped.
  7783. * @param {object} user The object to convert from camel case to Hungarian.
  7784. * @param {boolean} force When set to `true`, properties which already have a
  7785. * Hungarian value in the `user` object will be overwritten. Otherwise they
  7786. * won't be.
  7787. */
  7788. DataTable.camelToHungarian = _fnCamelToHungarian;
  7789. /**
  7790. *
  7791. */
  7792. _api_register( '$()', function ( selector, opts ) {
  7793. var
  7794. rows = this.rows( opts ).nodes(), // Get all rows
  7795. jqRows = $(rows);
  7796. return $( [].concat(
  7797. jqRows.filter( selector ).toArray(),
  7798. jqRows.find( selector ).toArray()
  7799. ) );
  7800. } );
  7801. // jQuery functions to operate on the tables
  7802. $.each( [ 'on', 'one', 'off' ], function (i, key) {
  7803. _api_register( key+'()', function ( /* event, handler */ ) {
  7804. var args = Array.prototype.slice.call(arguments);
  7805. // Add the `dt` namespace automatically if it isn't already present
  7806. args[0] = $.map( args[0].split( /\s/ ), function ( e ) {
  7807. return ! e.match(/\.dt\b/) ?
  7808. e+'.dt' :
  7809. e;
  7810. } ).join( ' ' );
  7811. var inst = $( this.tables().nodes() );
  7812. inst[key].apply( inst, args );
  7813. return this;
  7814. } );
  7815. } );
  7816. _api_register( 'clear()', function () {
  7817. return this.iterator( 'table', function ( settings ) {
  7818. _fnClearTable( settings );
  7819. } );
  7820. } );
  7821. _api_register( 'settings()', function () {
  7822. return new _Api( this.context, this.context );
  7823. } );
  7824. _api_register( 'init()', function () {
  7825. var ctx = this.context;
  7826. return ctx.length ? ctx[0].oInit : null;
  7827. } );
  7828. _api_register( 'data()', function () {
  7829. return this.iterator( 'table', function ( settings ) {
  7830. return _pluck( settings.aoData, '_aData' );
  7831. } ).flatten();
  7832. } );
  7833. _api_register( 'destroy()', function ( remove ) {
  7834. remove = remove || false;
  7835. return this.iterator( 'table', function ( settings ) {
  7836. var orig = settings.nTableWrapper.parentNode;
  7837. var classes = settings.oClasses;
  7838. var table = settings.nTable;
  7839. var tbody = settings.nTBody;
  7840. var thead = settings.nTHead;
  7841. var tfoot = settings.nTFoot;
  7842. var jqTable = $(table);
  7843. var jqTbody = $(tbody);
  7844. var jqWrapper = $(settings.nTableWrapper);
  7845. var rows = $.map( settings.aoData, function (r) { return r.nTr; } );
  7846. var i, ien;
  7847. // Flag to note that the table is currently being destroyed - no action
  7848. // should be taken
  7849. settings.bDestroying = true;
  7850. // Fire off the destroy callbacks for plug-ins etc
  7851. _fnCallbackFire( settings, "aoDestroyCallback", "destroy", [settings] );
  7852. // If not being removed from the document, make all columns visible
  7853. if ( ! remove ) {
  7854. new _Api( settings ).columns().visible( true );
  7855. }
  7856. // Blitz all `DT` namespaced events (these are internal events, the
  7857. // lowercase, `dt` events are user subscribed and they are responsible
  7858. // for removing them
  7859. jqWrapper.off('.DT').find(':not(tbody *)').off('.DT');
  7860. $(window).off('.DT-'+settings.sInstance);
  7861. // When scrolling we had to break the table up - restore it
  7862. if ( table != thead.parentNode ) {
  7863. jqTable.children('thead').detach();
  7864. jqTable.append( thead );
  7865. }
  7866. if ( tfoot && table != tfoot.parentNode ) {
  7867. jqTable.children('tfoot').detach();
  7868. jqTable.append( tfoot );
  7869. }
  7870. settings.aaSorting = [];
  7871. settings.aaSortingFixed = [];
  7872. _fnSortingClasses( settings );
  7873. $( rows ).removeClass( settings.asStripeClasses.join(' ') );
  7874. $('th, td', thead).removeClass( classes.sSortable+' '+
  7875. classes.sSortableAsc+' '+classes.sSortableDesc+' '+classes.sSortableNone
  7876. );
  7877. // Add the TR elements back into the table in their original order
  7878. jqTbody.children().detach();
  7879. jqTbody.append( rows );
  7880. // Remove the DataTables generated nodes, events and classes
  7881. var removedMethod = remove ? 'remove' : 'detach';
  7882. jqTable[ removedMethod ]();
  7883. jqWrapper[ removedMethod ]();
  7884. // If we need to reattach the table to the document
  7885. if ( ! remove && orig ) {
  7886. // insertBefore acts like appendChild if !arg[1]
  7887. orig.insertBefore( table, settings.nTableReinsertBefore );
  7888. // Restore the width of the original table - was read from the style property,
  7889. // so we can restore directly to that
  7890. jqTable
  7891. .css( 'width', settings.sDestroyWidth )
  7892. .removeClass( classes.sTable );
  7893. // If the were originally stripe classes - then we add them back here.
  7894. // Note this is not fool proof (for example if not all rows had stripe
  7895. // classes - but it's a good effort without getting carried away
  7896. ien = settings.asDestroyStripes.length;
  7897. if ( ien ) {
  7898. jqTbody.children().each( function (i) {
  7899. $(this).addClass( settings.asDestroyStripes[i % ien] );
  7900. } );
  7901. }
  7902. }
  7903. /* Remove the settings object from the settings array */
  7904. var idx = $.inArray( settings, DataTable.settings );
  7905. if ( idx !== -1 ) {
  7906. DataTable.settings.splice( idx, 1 );
  7907. }
  7908. } );
  7909. } );
  7910. // Add the `every()` method for rows, columns and cells in a compact form
  7911. $.each( [ 'column', 'row', 'cell' ], function ( i, type ) {
  7912. _api_register( type+'s().every()', function ( fn ) {
  7913. var opts = this.selector.opts;
  7914. var api = this;
  7915. return this.iterator( type, function ( settings, arg1, arg2, arg3, arg4 ) {
  7916. // Rows and columns:
  7917. // arg1 - index
  7918. // arg2 - table counter
  7919. // arg3 - loop counter
  7920. // arg4 - undefined
  7921. // Cells:
  7922. // arg1 - row index
  7923. // arg2 - column index
  7924. // arg3 - table counter
  7925. // arg4 - loop counter
  7926. fn.call(
  7927. api[ type ](
  7928. arg1,
  7929. type==='cell' ? arg2 : opts,
  7930. type==='cell' ? opts : undefined
  7931. ),
  7932. arg1, arg2, arg3, arg4
  7933. );
  7934. } );
  7935. } );
  7936. } );
  7937. // i18n method for extensions to be able to use the language object from the
  7938. // DataTable
  7939. _api_register( 'i18n()', function ( token, def, plural ) {
  7940. var ctx = this.context[0];
  7941. var resolved = _fnGetObjectDataFn( token )( ctx.oLanguage );
  7942. if ( resolved === undefined ) {
  7943. resolved = def;
  7944. }
  7945. if ( plural !== undefined && $.isPlainObject( resolved ) ) {
  7946. resolved = resolved[ plural ] !== undefined ?
  7947. resolved[ plural ] :
  7948. resolved._;
  7949. }
  7950. return resolved.replace( '%d', plural ); // nb: plural might be undefined,
  7951. } );
  7952. /**
  7953. * Version string for plug-ins to check compatibility. Allowed format is
  7954. * `a.b.c-d` where: a:int, b:int, c:int, d:string(dev|beta|alpha). `d` is used
  7955. * only for non-release builds. See http://semver.org/ for more information.
  7956. * @member
  7957. * @type string
  7958. * @default Version number
  7959. */
  7960. DataTable.version = "1.10.16";
  7961. /**
  7962. * Private data store, containing all of the settings objects that are
  7963. * created for the tables on a given page.
  7964. *
  7965. * Note that the `DataTable.settings` object is aliased to
  7966. * `jQuery.fn.dataTableExt` through which it may be accessed and
  7967. * manipulated, or `jQuery.fn.dataTable.settings`.
  7968. * @member
  7969. * @type array
  7970. * @default []
  7971. * @private
  7972. */
  7973. DataTable.settings = [];
  7974. /**
  7975. * Object models container, for the various models that DataTables has
  7976. * available to it. These models define the objects that are used to hold
  7977. * the active state and configuration of the table.
  7978. * @namespace
  7979. */
  7980. DataTable.models = {};
  7981. /**
  7982. * Template object for the way in which DataTables holds information about
  7983. * search information for the global filter and individual column filters.
  7984. * @namespace
  7985. */
  7986. DataTable.models.oSearch = {
  7987. /**
  7988. * Flag to indicate if the filtering should be case insensitive or not
  7989. * @type boolean
  7990. * @default true
  7991. */
  7992. "bCaseInsensitive": true,
  7993. /**
  7994. * Applied search term
  7995. * @type string
  7996. * @default <i>Empty string</i>
  7997. */
  7998. "sSearch": "",
  7999. /**
  8000. * Flag to indicate if the search term should be interpreted as a
  8001. * regular expression (true) or not (false) and therefore and special
  8002. * regex characters escaped.
  8003. * @type boolean
  8004. * @default false
  8005. */
  8006. "bRegex": false,
  8007. /**
  8008. * Flag to indicate if DataTables is to use its smart filtering or not.
  8009. * @type boolean
  8010. * @default true
  8011. */
  8012. "bSmart": true
  8013. };
  8014. /**
  8015. * Template object for the way in which DataTables holds information about
  8016. * each individual row. This is the object format used for the settings
  8017. * aoData array.
  8018. * @namespace
  8019. */
  8020. DataTable.models.oRow = {
  8021. /**
  8022. * TR element for the row
  8023. * @type node
  8024. * @default null
  8025. */
  8026. "nTr": null,
  8027. /**
  8028. * Array of TD elements for each row. This is null until the row has been
  8029. * created.
  8030. * @type array nodes
  8031. * @default []
  8032. */
  8033. "anCells": null,
  8034. /**
  8035. * Data object from the original data source for the row. This is either
  8036. * an array if using the traditional form of DataTables, or an object if
  8037. * using mData options. The exact type will depend on the passed in
  8038. * data from the data source, or will be an array if using DOM a data
  8039. * source.
  8040. * @type array|object
  8041. * @default []
  8042. */
  8043. "_aData": [],
  8044. /**
  8045. * Sorting data cache - this array is ostensibly the same length as the
  8046. * number of columns (although each index is generated only as it is
  8047. * needed), and holds the data that is used for sorting each column in the
  8048. * row. We do this cache generation at the start of the sort in order that
  8049. * the formatting of the sort data need be done only once for each cell
  8050. * per sort. This array should not be read from or written to by anything
  8051. * other than the master sorting methods.
  8052. * @type array
  8053. * @default null
  8054. * @private
  8055. */
  8056. "_aSortData": null,
  8057. /**
  8058. * Per cell filtering data cache. As per the sort data cache, used to
  8059. * increase the performance of the filtering in DataTables
  8060. * @type array
  8061. * @default null
  8062. * @private
  8063. */
  8064. "_aFilterData": null,
  8065. /**
  8066. * Filtering data cache. This is the same as the cell filtering cache, but
  8067. * in this case a string rather than an array. This is easily computed with
  8068. * a join on `_aFilterData`, but is provided as a cache so the join isn't
  8069. * needed on every search (memory traded for performance)
  8070. * @type array
  8071. * @default null
  8072. * @private
  8073. */
  8074. "_sFilterRow": null,
  8075. /**
  8076. * Cache of the class name that DataTables has applied to the row, so we
  8077. * can quickly look at this variable rather than needing to do a DOM check
  8078. * on className for the nTr property.
  8079. * @type string
  8080. * @default <i>Empty string</i>
  8081. * @private
  8082. */
  8083. "_sRowStripe": "",
  8084. /**
  8085. * Denote if the original data source was from the DOM, or the data source
  8086. * object. This is used for invalidating data, so DataTables can
  8087. * automatically read data from the original source, unless uninstructed
  8088. * otherwise.
  8089. * @type string
  8090. * @default null
  8091. * @private
  8092. */
  8093. "src": null,
  8094. /**
  8095. * Index in the aoData array. This saves an indexOf lookup when we have the
  8096. * object, but want to know the index
  8097. * @type integer
  8098. * @default -1
  8099. * @private
  8100. */
  8101. "idx": -1
  8102. };
  8103. /**
  8104. * Template object for the column information object in DataTables. This object
  8105. * is held in the settings aoColumns array and contains all the information that
  8106. * DataTables needs about each individual column.
  8107. *
  8108. * Note that this object is related to {@link DataTable.defaults.column}
  8109. * but this one is the internal data store for DataTables's cache of columns.
  8110. * It should NOT be manipulated outside of DataTables. Any configuration should
  8111. * be done through the initialisation options.
  8112. * @namespace
  8113. */
  8114. DataTable.models.oColumn = {
  8115. /**
  8116. * Column index. This could be worked out on-the-fly with $.inArray, but it
  8117. * is faster to just hold it as a variable
  8118. * @type integer
  8119. * @default null
  8120. */
  8121. "idx": null,
  8122. /**
  8123. * A list of the columns that sorting should occur on when this column
  8124. * is sorted. That this property is an array allows multi-column sorting
  8125. * to be defined for a column (for example first name / last name columns
  8126. * would benefit from this). The values are integers pointing to the
  8127. * columns to be sorted on (typically it will be a single integer pointing
  8128. * at itself, but that doesn't need to be the case).
  8129. * @type array
  8130. */
  8131. "aDataSort": null,
  8132. /**
  8133. * Define the sorting directions that are applied to the column, in sequence
  8134. * as the column is repeatedly sorted upon - i.e. the first value is used
  8135. * as the sorting direction when the column if first sorted (clicked on).
  8136. * Sort it again (click again) and it will move on to the next index.
  8137. * Repeat until loop.
  8138. * @type array
  8139. */
  8140. "asSorting": null,
  8141. /**
  8142. * Flag to indicate if the column is searchable, and thus should be included
  8143. * in the filtering or not.
  8144. * @type boolean
  8145. */
  8146. "bSearchable": null,
  8147. /**
  8148. * Flag to indicate if the column is sortable or not.
  8149. * @type boolean
  8150. */
  8151. "bSortable": null,
  8152. /**
  8153. * Flag to indicate if the column is currently visible in the table or not
  8154. * @type boolean
  8155. */
  8156. "bVisible": null,
  8157. /**
  8158. * Store for manual type assignment using the `column.type` option. This
  8159. * is held in store so we can manipulate the column's `sType` property.
  8160. * @type string
  8161. * @default null
  8162. * @private
  8163. */
  8164. "_sManualType": null,
  8165. /**
  8166. * Flag to indicate if HTML5 data attributes should be used as the data
  8167. * source for filtering or sorting. True is either are.
  8168. * @type boolean
  8169. * @default false
  8170. * @private
  8171. */
  8172. "_bAttrSrc": false,
  8173. /**
  8174. * Developer definable function that is called whenever a cell is created (Ajax source,
  8175. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  8176. * allowing you to modify the DOM element (add background colour for example) when the
  8177. * element is available.
  8178. * @type function
  8179. * @param {element} nTd The TD node that has been created
  8180. * @param {*} sData The Data for the cell
  8181. * @param {array|object} oData The data for the whole row
  8182. * @param {int} iRow The row index for the aoData data store
  8183. * @default null
  8184. */
  8185. "fnCreatedCell": null,
  8186. /**
  8187. * Function to get data from a cell in a column. You should <b>never</b>
  8188. * access data directly through _aData internally in DataTables - always use
  8189. * the method attached to this property. It allows mData to function as
  8190. * required. This function is automatically assigned by the column
  8191. * initialisation method
  8192. * @type function
  8193. * @param {array|object} oData The data array/object for the array
  8194. * (i.e. aoData[]._aData)
  8195. * @param {string} sSpecific The specific data type you want to get -
  8196. * 'display', 'type' 'filter' 'sort'
  8197. * @returns {*} The data for the cell from the given row's data
  8198. * @default null
  8199. */
  8200. "fnGetData": null,
  8201. /**
  8202. * Function to set data for a cell in the column. You should <b>never</b>
  8203. * set the data directly to _aData internally in DataTables - always use
  8204. * this method. It allows mData to function as required. This function
  8205. * is automatically assigned by the column initialisation method
  8206. * @type function
  8207. * @param {array|object} oData The data array/object for the array
  8208. * (i.e. aoData[]._aData)
  8209. * @param {*} sValue Value to set
  8210. * @default null
  8211. */
  8212. "fnSetData": null,
  8213. /**
  8214. * Property to read the value for the cells in the column from the data
  8215. * source array / object. If null, then the default content is used, if a
  8216. * function is given then the return from the function is used.
  8217. * @type function|int|string|null
  8218. * @default null
  8219. */
  8220. "mData": null,
  8221. /**
  8222. * Partner property to mData which is used (only when defined) to get
  8223. * the data - i.e. it is basically the same as mData, but without the
  8224. * 'set' option, and also the data fed to it is the result from mData.
  8225. * This is the rendering method to match the data method of mData.
  8226. * @type function|int|string|null
  8227. * @default null
  8228. */
  8229. "mRender": null,
  8230. /**
  8231. * Unique header TH/TD element for this column - this is what the sorting
  8232. * listener is attached to (if sorting is enabled.)
  8233. * @type node
  8234. * @default null
  8235. */
  8236. "nTh": null,
  8237. /**
  8238. * Unique footer TH/TD element for this column (if there is one). Not used
  8239. * in DataTables as such, but can be used for plug-ins to reference the
  8240. * footer for each column.
  8241. * @type node
  8242. * @default null
  8243. */
  8244. "nTf": null,
  8245. /**
  8246. * The class to apply to all TD elements in the table's TBODY for the column
  8247. * @type string
  8248. * @default null
  8249. */
  8250. "sClass": null,
  8251. /**
  8252. * When DataTables calculates the column widths to assign to each column,
  8253. * it finds the longest string in each column and then constructs a
  8254. * temporary table and reads the widths from that. The problem with this
  8255. * is that "mmm" is much wider then "iiii", but the latter is a longer
  8256. * string - thus the calculation can go wrong (doing it properly and putting
  8257. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  8258. * a "work around" we provide this option. It will append its value to the
  8259. * text that is found to be the longest string for the column - i.e. padding.
  8260. * @type string
  8261. */
  8262. "sContentPadding": null,
  8263. /**
  8264. * Allows a default value to be given for a column's data, and will be used
  8265. * whenever a null data source is encountered (this can be because mData
  8266. * is set to null, or because the data source itself is null).
  8267. * @type string
  8268. * @default null
  8269. */
  8270. "sDefaultContent": null,
  8271. /**
  8272. * Name for the column, allowing reference to the column by name as well as
  8273. * by index (needs a lookup to work by name).
  8274. * @type string
  8275. */
  8276. "sName": null,
  8277. /**
  8278. * Custom sorting data type - defines which of the available plug-ins in
  8279. * afnSortData the custom sorting will use - if any is defined.
  8280. * @type string
  8281. * @default std
  8282. */
  8283. "sSortDataType": 'std',
  8284. /**
  8285. * Class to be applied to the header element when sorting on this column
  8286. * @type string
  8287. * @default null
  8288. */
  8289. "sSortingClass": null,
  8290. /**
  8291. * Class to be applied to the header element when sorting on this column -
  8292. * when jQuery UI theming is used.
  8293. * @type string
  8294. * @default null
  8295. */
  8296. "sSortingClassJUI": null,
  8297. /**
  8298. * Title of the column - what is seen in the TH element (nTh).
  8299. * @type string
  8300. */
  8301. "sTitle": null,
  8302. /**
  8303. * Column sorting and filtering type
  8304. * @type string
  8305. * @default null
  8306. */
  8307. "sType": null,
  8308. /**
  8309. * Width of the column
  8310. * @type string
  8311. * @default null
  8312. */
  8313. "sWidth": null,
  8314. /**
  8315. * Width of the column when it was first "encountered"
  8316. * @type string
  8317. * @default null
  8318. */
  8319. "sWidthOrig": null
  8320. };
  8321. /*
  8322. * Developer note: The properties of the object below are given in Hungarian
  8323. * notation, that was used as the interface for DataTables prior to v1.10, however
  8324. * from v1.10 onwards the primary interface is camel case. In order to avoid
  8325. * breaking backwards compatibility utterly with this change, the Hungarian
  8326. * version is still, internally the primary interface, but is is not documented
  8327. * - hence the @name tags in each doc comment. This allows a Javascript function
  8328. * to create a map from Hungarian notation to camel case (going the other direction
  8329. * would require each property to be listed, which would at around 3K to the size
  8330. * of DataTables, while this method is about a 0.5K hit.
  8331. *
  8332. * Ultimately this does pave the way for Hungarian notation to be dropped
  8333. * completely, but that is a massive amount of work and will break current
  8334. * installs (therefore is on-hold until v2).
  8335. */
  8336. /**
  8337. * Initialisation options that can be given to DataTables at initialisation
  8338. * time.
  8339. * @namespace
  8340. */
  8341. DataTable.defaults = {
  8342. /**
  8343. * An array of data to use for the table, passed in at initialisation which
  8344. * will be used in preference to any data which is already in the DOM. This is
  8345. * particularly useful for constructing tables purely in Javascript, for
  8346. * example with a custom Ajax call.
  8347. * @type array
  8348. * @default null
  8349. *
  8350. * @dtopt Option
  8351. * @name DataTable.defaults.data
  8352. *
  8353. * @example
  8354. * // Using a 2D array data source
  8355. * $(document).ready( function () {
  8356. * $('#example').dataTable( {
  8357. * "data": [
  8358. * ['Trident', 'Internet Explorer 4.0', 'Win 95+', 4, 'X'],
  8359. * ['Trident', 'Internet Explorer 5.0', 'Win 95+', 5, 'C'],
  8360. * ],
  8361. * "columns": [
  8362. * { "title": "Engine" },
  8363. * { "title": "Browser" },
  8364. * { "title": "Platform" },
  8365. * { "title": "Version" },
  8366. * { "title": "Grade" }
  8367. * ]
  8368. * } );
  8369. * } );
  8370. *
  8371. * @example
  8372. * // Using an array of objects as a data source (`data`)
  8373. * $(document).ready( function () {
  8374. * $('#example').dataTable( {
  8375. * "data": [
  8376. * {
  8377. * "engine": "Trident",
  8378. * "browser": "Internet Explorer 4.0",
  8379. * "platform": "Win 95+",
  8380. * "version": 4,
  8381. * "grade": "X"
  8382. * },
  8383. * {
  8384. * "engine": "Trident",
  8385. * "browser": "Internet Explorer 5.0",
  8386. * "platform": "Win 95+",
  8387. * "version": 5,
  8388. * "grade": "C"
  8389. * }
  8390. * ],
  8391. * "columns": [
  8392. * { "title": "Engine", "data": "engine" },
  8393. * { "title": "Browser", "data": "browser" },
  8394. * { "title": "Platform", "data": "platform" },
  8395. * { "title": "Version", "data": "version" },
  8396. * { "title": "Grade", "data": "grade" }
  8397. * ]
  8398. * } );
  8399. * } );
  8400. */
  8401. "aaData": null,
  8402. /**
  8403. * If ordering is enabled, then DataTables will perform a first pass sort on
  8404. * initialisation. You can define which column(s) the sort is performed
  8405. * upon, and the sorting direction, with this variable. The `sorting` array
  8406. * should contain an array for each column to be sorted initially containing
  8407. * the column's index and a direction string ('asc' or 'desc').
  8408. * @type array
  8409. * @default [[0,'asc']]
  8410. *
  8411. * @dtopt Option
  8412. * @name DataTable.defaults.order
  8413. *
  8414. * @example
  8415. * // Sort by 3rd column first, and then 4th column
  8416. * $(document).ready( function() {
  8417. * $('#example').dataTable( {
  8418. * "order": [[2,'asc'], [3,'desc']]
  8419. * } );
  8420. * } );
  8421. *
  8422. * // No initial sorting
  8423. * $(document).ready( function() {
  8424. * $('#example').dataTable( {
  8425. * "order": []
  8426. * } );
  8427. * } );
  8428. */
  8429. "aaSorting": [[0,'asc']],
  8430. /**
  8431. * This parameter is basically identical to the `sorting` parameter, but
  8432. * cannot be overridden by user interaction with the table. What this means
  8433. * is that you could have a column (visible or hidden) which the sorting
  8434. * will always be forced on first - any sorting after that (from the user)
  8435. * will then be performed as required. This can be useful for grouping rows
  8436. * together.
  8437. * @type array
  8438. * @default null
  8439. *
  8440. * @dtopt Option
  8441. * @name DataTable.defaults.orderFixed
  8442. *
  8443. * @example
  8444. * $(document).ready( function() {
  8445. * $('#example').dataTable( {
  8446. * "orderFixed": [[0,'asc']]
  8447. * } );
  8448. * } )
  8449. */
  8450. "aaSortingFixed": [],
  8451. /**
  8452. * DataTables can be instructed to load data to display in the table from a
  8453. * Ajax source. This option defines how that Ajax call is made and where to.
  8454. *
  8455. * The `ajax` property has three different modes of operation, depending on
  8456. * how it is defined. These are:
  8457. *
  8458. * * `string` - Set the URL from where the data should be loaded from.
  8459. * * `object` - Define properties for `jQuery.ajax`.
  8460. * * `function` - Custom data get function
  8461. *
  8462. * `string`
  8463. * --------
  8464. *
  8465. * As a string, the `ajax` property simply defines the URL from which
  8466. * DataTables will load data.
  8467. *
  8468. * `object`
  8469. * --------
  8470. *
  8471. * As an object, the parameters in the object are passed to
  8472. * [jQuery.ajax](http://api.jquery.com/jQuery.ajax/) allowing fine control
  8473. * of the Ajax request. DataTables has a number of default parameters which
  8474. * you can override using this option. Please refer to the jQuery
  8475. * documentation for a full description of the options available, although
  8476. * the following parameters provide additional options in DataTables or
  8477. * require special consideration:
  8478. *
  8479. * * `data` - As with jQuery, `data` can be provided as an object, but it
  8480. * can also be used as a function to manipulate the data DataTables sends
  8481. * to the server. The function takes a single parameter, an object of
  8482. * parameters with the values that DataTables has readied for sending. An
  8483. * object may be returned which will be merged into the DataTables
  8484. * defaults, or you can add the items to the object that was passed in and
  8485. * not return anything from the function. This supersedes `fnServerParams`
  8486. * from DataTables 1.9-.
  8487. *
  8488. * * `dataSrc` - By default DataTables will look for the property `data` (or
  8489. * `aaData` for compatibility with DataTables 1.9-) when obtaining data
  8490. * from an Ajax source or for server-side processing - this parameter
  8491. * allows that property to be changed. You can use Javascript dotted
  8492. * object notation to get a data source for multiple levels of nesting, or
  8493. * it my be used as a function. As a function it takes a single parameter,
  8494. * the JSON returned from the server, which can be manipulated as
  8495. * required, with the returned value being that used by DataTables as the
  8496. * data source for the table. This supersedes `sAjaxDataProp` from
  8497. * DataTables 1.9-.
  8498. *
  8499. * * `success` - Should not be overridden it is used internally in
  8500. * DataTables. To manipulate / transform the data returned by the server
  8501. * use `ajax.dataSrc`, or use `ajax` as a function (see below).
  8502. *
  8503. * `function`
  8504. * ----------
  8505. *
  8506. * As a function, making the Ajax call is left up to yourself allowing
  8507. * complete control of the Ajax request. Indeed, if desired, a method other
  8508. * than Ajax could be used to obtain the required data, such as Web storage
  8509. * or an AIR database.
  8510. *
  8511. * The function is given four parameters and no return is required. The
  8512. * parameters are:
  8513. *
  8514. * 1. _object_ - Data to send to the server
  8515. * 2. _function_ - Callback function that must be executed when the required
  8516. * data has been obtained. That data should be passed into the callback
  8517. * as the only parameter
  8518. * 3. _object_ - DataTables settings object for the table
  8519. *
  8520. * Note that this supersedes `fnServerData` from DataTables 1.9-.
  8521. *
  8522. * @type string|object|function
  8523. * @default null
  8524. *
  8525. * @dtopt Option
  8526. * @name DataTable.defaults.ajax
  8527. * @since 1.10.0
  8528. *
  8529. * @example
  8530. * // Get JSON data from a file via Ajax.
  8531. * // Note DataTables expects data in the form `{ data: [ ...data... ] }` by default).
  8532. * $('#example').dataTable( {
  8533. * "ajax": "data.json"
  8534. * } );
  8535. *
  8536. * @example
  8537. * // Get JSON data from a file via Ajax, using `dataSrc` to change
  8538. * // `data` to `tableData` (i.e. `{ tableData: [ ...data... ] }`)
  8539. * $('#example').dataTable( {
  8540. * "ajax": {
  8541. * "url": "data.json",
  8542. * "dataSrc": "tableData"
  8543. * }
  8544. * } );
  8545. *
  8546. * @example
  8547. * // Get JSON data from a file via Ajax, using `dataSrc` to read data
  8548. * // from a plain array rather than an array in an object
  8549. * $('#example').dataTable( {
  8550. * "ajax": {
  8551. * "url": "data.json",
  8552. * "dataSrc": ""
  8553. * }
  8554. * } );
  8555. *
  8556. * @example
  8557. * // Manipulate the data returned from the server - add a link to data
  8558. * // (note this can, should, be done using `render` for the column - this
  8559. * // is just a simple example of how the data can be manipulated).
  8560. * $('#example').dataTable( {
  8561. * "ajax": {
  8562. * "url": "data.json",
  8563. * "dataSrc": function ( json ) {
  8564. * for ( var i=0, ien=json.length ; i<ien ; i++ ) {
  8565. * json[i][0] = '<a href="/message/'+json[i][0]+'>View message</a>';
  8566. * }
  8567. * return json;
  8568. * }
  8569. * }
  8570. * } );
  8571. *
  8572. * @example
  8573. * // Add data to the request
  8574. * $('#example').dataTable( {
  8575. * "ajax": {
  8576. * "url": "data.json",
  8577. * "data": function ( d ) {
  8578. * return {
  8579. * "extra_search": $('#extra').val()
  8580. * };
  8581. * }
  8582. * }
  8583. * } );
  8584. *
  8585. * @example
  8586. * // Send request as POST
  8587. * $('#example').dataTable( {
  8588. * "ajax": {
  8589. * "url": "data.json",
  8590. * "type": "POST"
  8591. * }
  8592. * } );
  8593. *
  8594. * @example
  8595. * // Get the data from localStorage (could interface with a form for
  8596. * // adding, editing and removing rows).
  8597. * $('#example').dataTable( {
  8598. * "ajax": function (data, callback, settings) {
  8599. * callback(
  8600. * JSON.parse( localStorage.getItem('dataTablesData') )
  8601. * );
  8602. * }
  8603. * } );
  8604. */
  8605. "ajax": null,
  8606. /**
  8607. * This parameter allows you to readily specify the entries in the length drop
  8608. * down menu that DataTables shows when pagination is enabled. It can be
  8609. * either a 1D array of options which will be used for both the displayed
  8610. * option and the value, or a 2D array which will use the array in the first
  8611. * position as the value, and the array in the second position as the
  8612. * displayed options (useful for language strings such as 'All').
  8613. *
  8614. * Note that the `pageLength` property will be automatically set to the
  8615. * first value given in this array, unless `pageLength` is also provided.
  8616. * @type array
  8617. * @default [ 10, 25, 50, 100 ]
  8618. *
  8619. * @dtopt Option
  8620. * @name DataTable.defaults.lengthMenu
  8621. *
  8622. * @example
  8623. * $(document).ready( function() {
  8624. * $('#example').dataTable( {
  8625. * "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
  8626. * } );
  8627. * } );
  8628. */
  8629. "aLengthMenu": [ 10, 25, 50, 100 ],
  8630. /**
  8631. * The `columns` option in the initialisation parameter allows you to define
  8632. * details about the way individual columns behave. For a full list of
  8633. * column options that can be set, please see
  8634. * {@link DataTable.defaults.column}. Note that if you use `columns` to
  8635. * define your columns, you must have an entry in the array for every single
  8636. * column that you have in your table (these can be null if you don't which
  8637. * to specify any options).
  8638. * @member
  8639. *
  8640. * @name DataTable.defaults.column
  8641. */
  8642. "aoColumns": null,
  8643. /**
  8644. * Very similar to `columns`, `columnDefs` allows you to target a specific
  8645. * column, multiple columns, or all columns, using the `targets` property of
  8646. * each object in the array. This allows great flexibility when creating
  8647. * tables, as the `columnDefs` arrays can be of any length, targeting the
  8648. * columns you specifically want. `columnDefs` may use any of the column
  8649. * options available: {@link DataTable.defaults.column}, but it _must_
  8650. * have `targets` defined in each object in the array. Values in the `targets`
  8651. * array may be:
  8652. * <ul>
  8653. * <li>a string - class name will be matched on the TH for the column</li>
  8654. * <li>0 or a positive integer - column index counting from the left</li>
  8655. * <li>a negative integer - column index counting from the right</li>
  8656. * <li>the string "_all" - all columns (i.e. assign a default)</li>
  8657. * </ul>
  8658. * @member
  8659. *
  8660. * @name DataTable.defaults.columnDefs
  8661. */
  8662. "aoColumnDefs": null,
  8663. /**
  8664. * Basically the same as `search`, this parameter defines the individual column
  8665. * filtering state at initialisation time. The array must be of the same size
  8666. * as the number of columns, and each element be an object with the parameters
  8667. * `search` and `escapeRegex` (the latter is optional). 'null' is also
  8668. * accepted and the default will be used.
  8669. * @type array
  8670. * @default []
  8671. *
  8672. * @dtopt Option
  8673. * @name DataTable.defaults.searchCols
  8674. *
  8675. * @example
  8676. * $(document).ready( function() {
  8677. * $('#example').dataTable( {
  8678. * "searchCols": [
  8679. * null,
  8680. * { "search": "My filter" },
  8681. * null,
  8682. * { "search": "^[0-9]", "escapeRegex": false }
  8683. * ]
  8684. * } );
  8685. * } )
  8686. */
  8687. "aoSearchCols": [],
  8688. /**
  8689. * An array of CSS classes that should be applied to displayed rows. This
  8690. * array may be of any length, and DataTables will apply each class
  8691. * sequentially, looping when required.
  8692. * @type array
  8693. * @default null <i>Will take the values determined by the `oClasses.stripe*`
  8694. * options</i>
  8695. *
  8696. * @dtopt Option
  8697. * @name DataTable.defaults.stripeClasses
  8698. *
  8699. * @example
  8700. * $(document).ready( function() {
  8701. * $('#example').dataTable( {
  8702. * "stripeClasses": [ 'strip1', 'strip2', 'strip3' ]
  8703. * } );
  8704. * } )
  8705. */
  8706. "asStripeClasses": null,
  8707. /**
  8708. * Enable or disable automatic column width calculation. This can be disabled
  8709. * as an optimisation (it takes some time to calculate the widths) if the
  8710. * tables widths are passed in using `columns`.
  8711. * @type boolean
  8712. * @default true
  8713. *
  8714. * @dtopt Features
  8715. * @name DataTable.defaults.autoWidth
  8716. *
  8717. * @example
  8718. * $(document).ready( function () {
  8719. * $('#example').dataTable( {
  8720. * "autoWidth": false
  8721. * } );
  8722. * } );
  8723. */
  8724. "bAutoWidth": true,
  8725. /**
  8726. * Deferred rendering can provide DataTables with a huge speed boost when you
  8727. * are using an Ajax or JS data source for the table. This option, when set to
  8728. * true, will cause DataTables to defer the creation of the table elements for
  8729. * each row until they are needed for a draw - saving a significant amount of
  8730. * time.
  8731. * @type boolean
  8732. * @default false
  8733. *
  8734. * @dtopt Features
  8735. * @name DataTable.defaults.deferRender
  8736. *
  8737. * @example
  8738. * $(document).ready( function() {
  8739. * $('#example').dataTable( {
  8740. * "ajax": "sources/arrays.txt",
  8741. * "deferRender": true
  8742. * } );
  8743. * } );
  8744. */
  8745. "bDeferRender": false,
  8746. /**
  8747. * Replace a DataTable which matches the given selector and replace it with
  8748. * one which has the properties of the new initialisation object passed. If no
  8749. * table matches the selector, then the new DataTable will be constructed as
  8750. * per normal.
  8751. * @type boolean
  8752. * @default false
  8753. *
  8754. * @dtopt Options
  8755. * @name DataTable.defaults.destroy
  8756. *
  8757. * @example
  8758. * $(document).ready( function() {
  8759. * $('#example').dataTable( {
  8760. * "srollY": "200px",
  8761. * "paginate": false
  8762. * } );
  8763. *
  8764. * // Some time later....
  8765. * $('#example').dataTable( {
  8766. * "filter": false,
  8767. * "destroy": true
  8768. * } );
  8769. * } );
  8770. */
  8771. "bDestroy": false,
  8772. /**
  8773. * Enable or disable filtering of data. Filtering in DataTables is "smart" in
  8774. * that it allows the end user to input multiple words (space separated) and
  8775. * will match a row containing those words, even if not in the order that was
  8776. * specified (this allow matching across multiple columns). Note that if you
  8777. * wish to use filtering in DataTables this must remain 'true' - to remove the
  8778. * default filtering input box and retain filtering abilities, please use
  8779. * {@link DataTable.defaults.dom}.
  8780. * @type boolean
  8781. * @default true
  8782. *
  8783. * @dtopt Features
  8784. * @name DataTable.defaults.searching
  8785. *
  8786. * @example
  8787. * $(document).ready( function () {
  8788. * $('#example').dataTable( {
  8789. * "searching": false
  8790. * } );
  8791. * } );
  8792. */
  8793. "bFilter": true,
  8794. /**
  8795. * Enable or disable the table information display. This shows information
  8796. * about the data that is currently visible on the page, including information
  8797. * about filtered data if that action is being performed.
  8798. * @type boolean
  8799. * @default true
  8800. *
  8801. * @dtopt Features
  8802. * @name DataTable.defaults.info
  8803. *
  8804. * @example
  8805. * $(document).ready( function () {
  8806. * $('#example').dataTable( {
  8807. * "info": false
  8808. * } );
  8809. * } );
  8810. */
  8811. "bInfo": true,
  8812. /**
  8813. * Allows the end user to select the size of a formatted page from a select
  8814. * menu (sizes are 10, 25, 50 and 100). Requires pagination (`paginate`).
  8815. * @type boolean
  8816. * @default true
  8817. *
  8818. * @dtopt Features
  8819. * @name DataTable.defaults.lengthChange
  8820. *
  8821. * @example
  8822. * $(document).ready( function () {
  8823. * $('#example').dataTable( {
  8824. * "lengthChange": false
  8825. * } );
  8826. * } );
  8827. */
  8828. "bLengthChange": true,
  8829. /**
  8830. * Enable or disable pagination.
  8831. * @type boolean
  8832. * @default true
  8833. *
  8834. * @dtopt Features
  8835. * @name DataTable.defaults.paging
  8836. *
  8837. * @example
  8838. * $(document).ready( function () {
  8839. * $('#example').dataTable( {
  8840. * "paging": false
  8841. * } );
  8842. * } );
  8843. */
  8844. "bPaginate": true,
  8845. /**
  8846. * Enable or disable the display of a 'processing' indicator when the table is
  8847. * being processed (e.g. a sort). This is particularly useful for tables with
  8848. * large amounts of data where it can take a noticeable amount of time to sort
  8849. * the entries.
  8850. * @type boolean
  8851. * @default false
  8852. *
  8853. * @dtopt Features
  8854. * @name DataTable.defaults.processing
  8855. *
  8856. * @example
  8857. * $(document).ready( function () {
  8858. * $('#example').dataTable( {
  8859. * "processing": true
  8860. * } );
  8861. * } );
  8862. */
  8863. "bProcessing": false,
  8864. /**
  8865. * Retrieve the DataTables object for the given selector. Note that if the
  8866. * table has already been initialised, this parameter will cause DataTables
  8867. * to simply return the object that has already been set up - it will not take
  8868. * account of any changes you might have made to the initialisation object
  8869. * passed to DataTables (setting this parameter to true is an acknowledgement
  8870. * that you understand this). `destroy` can be used to reinitialise a table if
  8871. * you need.
  8872. * @type boolean
  8873. * @default false
  8874. *
  8875. * @dtopt Options
  8876. * @name DataTable.defaults.retrieve
  8877. *
  8878. * @example
  8879. * $(document).ready( function() {
  8880. * initTable();
  8881. * tableActions();
  8882. * } );
  8883. *
  8884. * function initTable ()
  8885. * {
  8886. * return $('#example').dataTable( {
  8887. * "scrollY": "200px",
  8888. * "paginate": false,
  8889. * "retrieve": true
  8890. * } );
  8891. * }
  8892. *
  8893. * function tableActions ()
  8894. * {
  8895. * var table = initTable();
  8896. * // perform API operations with oTable
  8897. * }
  8898. */
  8899. "bRetrieve": false,
  8900. /**
  8901. * When vertical (y) scrolling is enabled, DataTables will force the height of
  8902. * the table's viewport to the given height at all times (useful for layout).
  8903. * However, this can look odd when filtering data down to a small data set,
  8904. * and the footer is left "floating" further down. This parameter (when
  8905. * enabled) will cause DataTables to collapse the table's viewport down when
  8906. * the result set will fit within the given Y height.
  8907. * @type boolean
  8908. * @default false
  8909. *
  8910. * @dtopt Options
  8911. * @name DataTable.defaults.scrollCollapse
  8912. *
  8913. * @example
  8914. * $(document).ready( function() {
  8915. * $('#example').dataTable( {
  8916. * "scrollY": "200",
  8917. * "scrollCollapse": true
  8918. * } );
  8919. * } );
  8920. */
  8921. "bScrollCollapse": false,
  8922. /**
  8923. * Configure DataTables to use server-side processing. Note that the
  8924. * `ajax` parameter must also be given in order to give DataTables a
  8925. * source to obtain the required data for each draw.
  8926. * @type boolean
  8927. * @default false
  8928. *
  8929. * @dtopt Features
  8930. * @dtopt Server-side
  8931. * @name DataTable.defaults.serverSide
  8932. *
  8933. * @example
  8934. * $(document).ready( function () {
  8935. * $('#example').dataTable( {
  8936. * "serverSide": true,
  8937. * "ajax": "xhr.php"
  8938. * } );
  8939. * } );
  8940. */
  8941. "bServerSide": false,
  8942. /**
  8943. * Enable or disable sorting of columns. Sorting of individual columns can be
  8944. * disabled by the `sortable` option for each column.
  8945. * @type boolean
  8946. * @default true
  8947. *
  8948. * @dtopt Features
  8949. * @name DataTable.defaults.ordering
  8950. *
  8951. * @example
  8952. * $(document).ready( function () {
  8953. * $('#example').dataTable( {
  8954. * "ordering": false
  8955. * } );
  8956. * } );
  8957. */
  8958. "bSort": true,
  8959. /**
  8960. * Enable or display DataTables' ability to sort multiple columns at the
  8961. * same time (activated by shift-click by the user).
  8962. * @type boolean
  8963. * @default true
  8964. *
  8965. * @dtopt Options
  8966. * @name DataTable.defaults.orderMulti
  8967. *
  8968. * @example
  8969. * // Disable multiple column sorting ability
  8970. * $(document).ready( function () {
  8971. * $('#example').dataTable( {
  8972. * "orderMulti": false
  8973. * } );
  8974. * } );
  8975. */
  8976. "bSortMulti": true,
  8977. /**
  8978. * Allows control over whether DataTables should use the top (true) unique
  8979. * cell that is found for a single column, or the bottom (false - default).
  8980. * This is useful when using complex headers.
  8981. * @type boolean
  8982. * @default false
  8983. *
  8984. * @dtopt Options
  8985. * @name DataTable.defaults.orderCellsTop
  8986. *
  8987. * @example
  8988. * $(document).ready( function() {
  8989. * $('#example').dataTable( {
  8990. * "orderCellsTop": true
  8991. * } );
  8992. * } );
  8993. */
  8994. "bSortCellsTop": false,
  8995. /**
  8996. * Enable or disable the addition of the classes `sorting\_1`, `sorting\_2` and
  8997. * `sorting\_3` to the columns which are currently being sorted on. This is
  8998. * presented as a feature switch as it can increase processing time (while
  8999. * classes are removed and added) so for large data sets you might want to
  9000. * turn this off.
  9001. * @type boolean
  9002. * @default true
  9003. *
  9004. * @dtopt Features
  9005. * @name DataTable.defaults.orderClasses
  9006. *
  9007. * @example
  9008. * $(document).ready( function () {
  9009. * $('#example').dataTable( {
  9010. * "orderClasses": false
  9011. * } );
  9012. * } );
  9013. */
  9014. "bSortClasses": true,
  9015. /**
  9016. * Enable or disable state saving. When enabled HTML5 `localStorage` will be
  9017. * used to save table display information such as pagination information,
  9018. * display length, filtering and sorting. As such when the end user reloads
  9019. * the page the display display will match what thy had previously set up.
  9020. *
  9021. * Due to the use of `localStorage` the default state saving is not supported
  9022. * in IE6 or 7. If state saving is required in those browsers, use
  9023. * `stateSaveCallback` to provide a storage solution such as cookies.
  9024. * @type boolean
  9025. * @default false
  9026. *
  9027. * @dtopt Features
  9028. * @name DataTable.defaults.stateSave
  9029. *
  9030. * @example
  9031. * $(document).ready( function () {
  9032. * $('#example').dataTable( {
  9033. * "stateSave": true
  9034. * } );
  9035. * } );
  9036. */
  9037. "bStateSave": false,
  9038. /**
  9039. * This function is called when a TR element is created (and all TD child
  9040. * elements have been inserted), or registered if using a DOM source, allowing
  9041. * manipulation of the TR element (adding classes etc).
  9042. * @type function
  9043. * @param {node} row "TR" element for the current row
  9044. * @param {array} data Raw data array for this row
  9045. * @param {int} dataIndex The index of this row in the internal aoData array
  9046. *
  9047. * @dtopt Callbacks
  9048. * @name DataTable.defaults.createdRow
  9049. *
  9050. * @example
  9051. * $(document).ready( function() {
  9052. * $('#example').dataTable( {
  9053. * "createdRow": function( row, data, dataIndex ) {
  9054. * // Bold the grade for all 'A' grade browsers
  9055. * if ( data[4] == "A" )
  9056. * {
  9057. * $('td:eq(4)', row).html( '<b>A</b>' );
  9058. * }
  9059. * }
  9060. * } );
  9061. * } );
  9062. */
  9063. "fnCreatedRow": null,
  9064. /**
  9065. * This function is called on every 'draw' event, and allows you to
  9066. * dynamically modify any aspect you want about the created DOM.
  9067. * @type function
  9068. * @param {object} settings DataTables settings object
  9069. *
  9070. * @dtopt Callbacks
  9071. * @name DataTable.defaults.drawCallback
  9072. *
  9073. * @example
  9074. * $(document).ready( function() {
  9075. * $('#example').dataTable( {
  9076. * "drawCallback": function( settings ) {
  9077. * alert( 'DataTables has redrawn the table' );
  9078. * }
  9079. * } );
  9080. * } );
  9081. */
  9082. "fnDrawCallback": null,
  9083. /**
  9084. * Identical to fnHeaderCallback() but for the table footer this function
  9085. * allows you to modify the table footer on every 'draw' event.
  9086. * @type function
  9087. * @param {node} foot "TR" element for the footer
  9088. * @param {array} data Full table data (as derived from the original HTML)
  9089. * @param {int} start Index for the current display starting point in the
  9090. * display array
  9091. * @param {int} end Index for the current display ending point in the
  9092. * display array
  9093. * @param {array int} display Index array to translate the visual position
  9094. * to the full data array
  9095. *
  9096. * @dtopt Callbacks
  9097. * @name DataTable.defaults.footerCallback
  9098. *
  9099. * @example
  9100. * $(document).ready( function() {
  9101. * $('#example').dataTable( {
  9102. * "footerCallback": function( tfoot, data, start, end, display ) {
  9103. * tfoot.getElementsByTagName('th')[0].innerHTML = "Starting index is "+start;
  9104. * }
  9105. * } );
  9106. * } )
  9107. */
  9108. "fnFooterCallback": null,
  9109. /**
  9110. * When rendering large numbers in the information element for the table
  9111. * (i.e. "Showing 1 to 10 of 57 entries") DataTables will render large numbers
  9112. * to have a comma separator for the 'thousands' units (e.g. 1 million is
  9113. * rendered as "1,000,000") to help readability for the end user. This
  9114. * function will override the default method DataTables uses.
  9115. * @type function
  9116. * @member
  9117. * @param {int} toFormat number to be formatted
  9118. * @returns {string} formatted string for DataTables to show the number
  9119. *
  9120. * @dtopt Callbacks
  9121. * @name DataTable.defaults.formatNumber
  9122. *
  9123. * @example
  9124. * // Format a number using a single quote for the separator (note that
  9125. * // this can also be done with the language.thousands option)
  9126. * $(document).ready( function() {
  9127. * $('#example').dataTable( {
  9128. * "formatNumber": function ( toFormat ) {
  9129. * return toFormat.toString().replace(
  9130. * /\B(?=(\d{3})+(?!\d))/g, "'"
  9131. * );
  9132. * };
  9133. * } );
  9134. * } );
  9135. */
  9136. "fnFormatNumber": function ( toFormat ) {
  9137. return toFormat.toString().replace(
  9138. /\B(?=(\d{3})+(?!\d))/g,
  9139. this.oLanguage.sThousands
  9140. );
  9141. },
  9142. /**
  9143. * This function is called on every 'draw' event, and allows you to
  9144. * dynamically modify the header row. This can be used to calculate and
  9145. * display useful information about the table.
  9146. * @type function
  9147. * @param {node} head "TR" element for the header
  9148. * @param {array} data Full table data (as derived from the original HTML)
  9149. * @param {int} start Index for the current display starting point in the
  9150. * display array
  9151. * @param {int} end Index for the current display ending point in the
  9152. * display array
  9153. * @param {array int} display Index array to translate the visual position
  9154. * to the full data array
  9155. *
  9156. * @dtopt Callbacks
  9157. * @name DataTable.defaults.headerCallback
  9158. *
  9159. * @example
  9160. * $(document).ready( function() {
  9161. * $('#example').dataTable( {
  9162. * "fheaderCallback": function( head, data, start, end, display ) {
  9163. * head.getElementsByTagName('th')[0].innerHTML = "Displaying "+(end-start)+" records";
  9164. * }
  9165. * } );
  9166. * } )
  9167. */
  9168. "fnHeaderCallback": null,
  9169. /**
  9170. * The information element can be used to convey information about the current
  9171. * state of the table. Although the internationalisation options presented by
  9172. * DataTables are quite capable of dealing with most customisations, there may
  9173. * be times where you wish to customise the string further. This callback
  9174. * allows you to do exactly that.
  9175. * @type function
  9176. * @param {object} oSettings DataTables settings object
  9177. * @param {int} start Starting position in data for the draw
  9178. * @param {int} end End position in data for the draw
  9179. * @param {int} max Total number of rows in the table (regardless of
  9180. * filtering)
  9181. * @param {int} total Total number of rows in the data set, after filtering
  9182. * @param {string} pre The string that DataTables has formatted using it's
  9183. * own rules
  9184. * @returns {string} The string to be displayed in the information element.
  9185. *
  9186. * @dtopt Callbacks
  9187. * @name DataTable.defaults.infoCallback
  9188. *
  9189. * @example
  9190. * $('#example').dataTable( {
  9191. * "infoCallback": function( settings, start, end, max, total, pre ) {
  9192. * return start +" to "+ end;
  9193. * }
  9194. * } );
  9195. */
  9196. "fnInfoCallback": null,
  9197. /**
  9198. * Called when the table has been initialised. Normally DataTables will
  9199. * initialise sequentially and there will be no need for this function,
  9200. * however, this does not hold true when using external language information
  9201. * since that is obtained using an async XHR call.
  9202. * @type function
  9203. * @param {object} settings DataTables settings object
  9204. * @param {object} json The JSON object request from the server - only
  9205. * present if client-side Ajax sourced data is used
  9206. *
  9207. * @dtopt Callbacks
  9208. * @name DataTable.defaults.initComplete
  9209. *
  9210. * @example
  9211. * $(document).ready( function() {
  9212. * $('#example').dataTable( {
  9213. * "initComplete": function(settings, json) {
  9214. * alert( 'DataTables has finished its initialisation.' );
  9215. * }
  9216. * } );
  9217. * } )
  9218. */
  9219. "fnInitComplete": null,
  9220. /**
  9221. * Called at the very start of each table draw and can be used to cancel the
  9222. * draw by returning false, any other return (including undefined) results in
  9223. * the full draw occurring).
  9224. * @type function
  9225. * @param {object} settings DataTables settings object
  9226. * @returns {boolean} False will cancel the draw, anything else (including no
  9227. * return) will allow it to complete.
  9228. *
  9229. * @dtopt Callbacks
  9230. * @name DataTable.defaults.preDrawCallback
  9231. *
  9232. * @example
  9233. * $(document).ready( function() {
  9234. * $('#example').dataTable( {
  9235. * "preDrawCallback": function( settings ) {
  9236. * if ( $('#test').val() == 1 ) {
  9237. * return false;
  9238. * }
  9239. * }
  9240. * } );
  9241. * } );
  9242. */
  9243. "fnPreDrawCallback": null,
  9244. /**
  9245. * This function allows you to 'post process' each row after it have been
  9246. * generated for each table draw, but before it is rendered on screen. This
  9247. * function might be used for setting the row class name etc.
  9248. * @type function
  9249. * @param {node} row "TR" element for the current row
  9250. * @param {array} data Raw data array for this row
  9251. * @param {int} displayIndex The display index for the current table draw
  9252. * @param {int} displayIndexFull The index of the data in the full list of
  9253. * rows (after filtering)
  9254. *
  9255. * @dtopt Callbacks
  9256. * @name DataTable.defaults.rowCallback
  9257. *
  9258. * @example
  9259. * $(document).ready( function() {
  9260. * $('#example').dataTable( {
  9261. * "rowCallback": function( row, data, displayIndex, displayIndexFull ) {
  9262. * // Bold the grade for all 'A' grade browsers
  9263. * if ( data[4] == "A" ) {
  9264. * $('td:eq(4)', row).html( '<b>A</b>' );
  9265. * }
  9266. * }
  9267. * } );
  9268. * } );
  9269. */
  9270. "fnRowCallback": null,
  9271. /**
  9272. * __Deprecated__ The functionality provided by this parameter has now been
  9273. * superseded by that provided through `ajax`, which should be used instead.
  9274. *
  9275. * This parameter allows you to override the default function which obtains
  9276. * the data from the server so something more suitable for your application.
  9277. * For example you could use POST data, or pull information from a Gears or
  9278. * AIR database.
  9279. * @type function
  9280. * @member
  9281. * @param {string} source HTTP source to obtain the data from (`ajax`)
  9282. * @param {array} data A key/value pair object containing the data to send
  9283. * to the server
  9284. * @param {function} callback to be called on completion of the data get
  9285. * process that will draw the data on the page.
  9286. * @param {object} settings DataTables settings object
  9287. *
  9288. * @dtopt Callbacks
  9289. * @dtopt Server-side
  9290. * @name DataTable.defaults.serverData
  9291. *
  9292. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9293. */
  9294. "fnServerData": null,
  9295. /**
  9296. * __Deprecated__ The functionality provided by this parameter has now been
  9297. * superseded by that provided through `ajax`, which should be used instead.
  9298. *
  9299. * It is often useful to send extra data to the server when making an Ajax
  9300. * request - for example custom filtering information, and this callback
  9301. * function makes it trivial to send extra information to the server. The
  9302. * passed in parameter is the data set that has been constructed by
  9303. * DataTables, and you can add to this or modify it as you require.
  9304. * @type function
  9305. * @param {array} data Data array (array of objects which are name/value
  9306. * pairs) that has been constructed by DataTables and will be sent to the
  9307. * server. In the case of Ajax sourced data with server-side processing
  9308. * this will be an empty array, for server-side processing there will be a
  9309. * significant number of parameters!
  9310. * @returns {undefined} Ensure that you modify the data array passed in,
  9311. * as this is passed by reference.
  9312. *
  9313. * @dtopt Callbacks
  9314. * @dtopt Server-side
  9315. * @name DataTable.defaults.serverParams
  9316. *
  9317. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9318. */
  9319. "fnServerParams": null,
  9320. /**
  9321. * Load the table state. With this function you can define from where, and how, the
  9322. * state of a table is loaded. By default DataTables will load from `localStorage`
  9323. * but you might wish to use a server-side database or cookies.
  9324. * @type function
  9325. * @member
  9326. * @param {object} settings DataTables settings object
  9327. * @param {object} callback Callback that can be executed when done. It
  9328. * should be passed the loaded state object.
  9329. * @return {object} The DataTables state object to be loaded
  9330. *
  9331. * @dtopt Callbacks
  9332. * @name DataTable.defaults.stateLoadCallback
  9333. *
  9334. * @example
  9335. * $(document).ready( function() {
  9336. * $('#example').dataTable( {
  9337. * "stateSave": true,
  9338. * "stateLoadCallback": function (settings, callback) {
  9339. * $.ajax( {
  9340. * "url": "/state_load",
  9341. * "dataType": "json",
  9342. * "success": function (json) {
  9343. * callback( json );
  9344. * }
  9345. * } );
  9346. * }
  9347. * } );
  9348. * } );
  9349. */
  9350. "fnStateLoadCallback": function ( settings ) {
  9351. try {
  9352. return JSON.parse(
  9353. (settings.iStateDuration === -1 ? sessionStorage : localStorage).getItem(
  9354. 'DataTables_'+settings.sInstance+'_'+location.pathname
  9355. )
  9356. );
  9357. } catch (e) {}
  9358. },
  9359. /**
  9360. * Callback which allows modification of the saved state prior to loading that state.
  9361. * This callback is called when the table is loading state from the stored data, but
  9362. * prior to the settings object being modified by the saved state. Note that for
  9363. * plug-in authors, you should use the `stateLoadParams` event to load parameters for
  9364. * a plug-in.
  9365. * @type function
  9366. * @param {object} settings DataTables settings object
  9367. * @param {object} data The state object that is to be loaded
  9368. *
  9369. * @dtopt Callbacks
  9370. * @name DataTable.defaults.stateLoadParams
  9371. *
  9372. * @example
  9373. * // Remove a saved filter, so filtering is never loaded
  9374. * $(document).ready( function() {
  9375. * $('#example').dataTable( {
  9376. * "stateSave": true,
  9377. * "stateLoadParams": function (settings, data) {
  9378. * data.oSearch.sSearch = "";
  9379. * }
  9380. * } );
  9381. * } );
  9382. *
  9383. * @example
  9384. * // Disallow state loading by returning false
  9385. * $(document).ready( function() {
  9386. * $('#example').dataTable( {
  9387. * "stateSave": true,
  9388. * "stateLoadParams": function (settings, data) {
  9389. * return false;
  9390. * }
  9391. * } );
  9392. * } );
  9393. */
  9394. "fnStateLoadParams": null,
  9395. /**
  9396. * Callback that is called when the state has been loaded from the state saving method
  9397. * and the DataTables settings object has been modified as a result of the loaded state.
  9398. * @type function
  9399. * @param {object} settings DataTables settings object
  9400. * @param {object} data The state object that was loaded
  9401. *
  9402. * @dtopt Callbacks
  9403. * @name DataTable.defaults.stateLoaded
  9404. *
  9405. * @example
  9406. * // Show an alert with the filtering value that was saved
  9407. * $(document).ready( function() {
  9408. * $('#example').dataTable( {
  9409. * "stateSave": true,
  9410. * "stateLoaded": function (settings, data) {
  9411. * alert( 'Saved filter was: '+data.oSearch.sSearch );
  9412. * }
  9413. * } );
  9414. * } );
  9415. */
  9416. "fnStateLoaded": null,
  9417. /**
  9418. * Save the table state. This function allows you to define where and how the state
  9419. * information for the table is stored By default DataTables will use `localStorage`
  9420. * but you might wish to use a server-side database or cookies.
  9421. * @type function
  9422. * @member
  9423. * @param {object} settings DataTables settings object
  9424. * @param {object} data The state object to be saved
  9425. *
  9426. * @dtopt Callbacks
  9427. * @name DataTable.defaults.stateSaveCallback
  9428. *
  9429. * @example
  9430. * $(document).ready( function() {
  9431. * $('#example').dataTable( {
  9432. * "stateSave": true,
  9433. * "stateSaveCallback": function (settings, data) {
  9434. * // Send an Ajax request to the server with the state object
  9435. * $.ajax( {
  9436. * "url": "/state_save",
  9437. * "data": data,
  9438. * "dataType": "json",
  9439. * "method": "POST"
  9440. * "success": function () {}
  9441. * } );
  9442. * }
  9443. * } );
  9444. * } );
  9445. */
  9446. "fnStateSaveCallback": function ( settings, data ) {
  9447. try {
  9448. (settings.iStateDuration === -1 ? sessionStorage : localStorage).setItem(
  9449. 'DataTables_'+settings.sInstance+'_'+location.pathname,
  9450. JSON.stringify( data )
  9451. );
  9452. } catch (e) {}
  9453. },
  9454. /**
  9455. * Callback which allows modification of the state to be saved. Called when the table
  9456. * has changed state a new state save is required. This method allows modification of
  9457. * the state saving object prior to actually doing the save, including addition or
  9458. * other state properties or modification. Note that for plug-in authors, you should
  9459. * use the `stateSaveParams` event to save parameters for a plug-in.
  9460. * @type function
  9461. * @param {object} settings DataTables settings object
  9462. * @param {object} data The state object to be saved
  9463. *
  9464. * @dtopt Callbacks
  9465. * @name DataTable.defaults.stateSaveParams
  9466. *
  9467. * @example
  9468. * // Remove a saved filter, so filtering is never saved
  9469. * $(document).ready( function() {
  9470. * $('#example').dataTable( {
  9471. * "stateSave": true,
  9472. * "stateSaveParams": function (settings, data) {
  9473. * data.oSearch.sSearch = "";
  9474. * }
  9475. * } );
  9476. * } );
  9477. */
  9478. "fnStateSaveParams": null,
  9479. /**
  9480. * Duration for which the saved state information is considered valid. After this period
  9481. * has elapsed the state will be returned to the default.
  9482. * Value is given in seconds.
  9483. * @type int
  9484. * @default 7200 <i>(2 hours)</i>
  9485. *
  9486. * @dtopt Options
  9487. * @name DataTable.defaults.stateDuration
  9488. *
  9489. * @example
  9490. * $(document).ready( function() {
  9491. * $('#example').dataTable( {
  9492. * "stateDuration": 60*60*24; // 1 day
  9493. * } );
  9494. * } )
  9495. */
  9496. "iStateDuration": 7200,
  9497. /**
  9498. * When enabled DataTables will not make a request to the server for the first
  9499. * page draw - rather it will use the data already on the page (no sorting etc
  9500. * will be applied to it), thus saving on an XHR at load time. `deferLoading`
  9501. * is used to indicate that deferred loading is required, but it is also used
  9502. * to tell DataTables how many records there are in the full table (allowing
  9503. * the information element and pagination to be displayed correctly). In the case
  9504. * where a filtering is applied to the table on initial load, this can be
  9505. * indicated by giving the parameter as an array, where the first element is
  9506. * the number of records available after filtering and the second element is the
  9507. * number of records without filtering (allowing the table information element
  9508. * to be shown correctly).
  9509. * @type int | array
  9510. * @default null
  9511. *
  9512. * @dtopt Options
  9513. * @name DataTable.defaults.deferLoading
  9514. *
  9515. * @example
  9516. * // 57 records available in the table, no filtering applied
  9517. * $(document).ready( function() {
  9518. * $('#example').dataTable( {
  9519. * "serverSide": true,
  9520. * "ajax": "scripts/server_processing.php",
  9521. * "deferLoading": 57
  9522. * } );
  9523. * } );
  9524. *
  9525. * @example
  9526. * // 57 records after filtering, 100 without filtering (an initial filter applied)
  9527. * $(document).ready( function() {
  9528. * $('#example').dataTable( {
  9529. * "serverSide": true,
  9530. * "ajax": "scripts/server_processing.php",
  9531. * "deferLoading": [ 57, 100 ],
  9532. * "search": {
  9533. * "search": "my_filter"
  9534. * }
  9535. * } );
  9536. * } );
  9537. */
  9538. "iDeferLoading": null,
  9539. /**
  9540. * Number of rows to display on a single page when using pagination. If
  9541. * feature enabled (`lengthChange`) then the end user will be able to override
  9542. * this to a custom setting using a pop-up menu.
  9543. * @type int
  9544. * @default 10
  9545. *
  9546. * @dtopt Options
  9547. * @name DataTable.defaults.pageLength
  9548. *
  9549. * @example
  9550. * $(document).ready( function() {
  9551. * $('#example').dataTable( {
  9552. * "pageLength": 50
  9553. * } );
  9554. * } )
  9555. */
  9556. "iDisplayLength": 10,
  9557. /**
  9558. * Define the starting point for data display when using DataTables with
  9559. * pagination. Note that this parameter is the number of records, rather than
  9560. * the page number, so if you have 10 records per page and want to start on
  9561. * the third page, it should be "20".
  9562. * @type int
  9563. * @default 0
  9564. *
  9565. * @dtopt Options
  9566. * @name DataTable.defaults.displayStart
  9567. *
  9568. * @example
  9569. * $(document).ready( function() {
  9570. * $('#example').dataTable( {
  9571. * "displayStart": 20
  9572. * } );
  9573. * } )
  9574. */
  9575. "iDisplayStart": 0,
  9576. /**
  9577. * By default DataTables allows keyboard navigation of the table (sorting, paging,
  9578. * and filtering) by adding a `tabindex` attribute to the required elements. This
  9579. * allows you to tab through the controls and press the enter key to activate them.
  9580. * The tabindex is default 0, meaning that the tab follows the flow of the document.
  9581. * You can overrule this using this parameter if you wish. Use a value of -1 to
  9582. * disable built-in keyboard navigation.
  9583. * @type int
  9584. * @default 0
  9585. *
  9586. * @dtopt Options
  9587. * @name DataTable.defaults.tabIndex
  9588. *
  9589. * @example
  9590. * $(document).ready( function() {
  9591. * $('#example').dataTable( {
  9592. * "tabIndex": 1
  9593. * } );
  9594. * } );
  9595. */
  9596. "iTabIndex": 0,
  9597. /**
  9598. * Classes that DataTables assigns to the various components and features
  9599. * that it adds to the HTML table. This allows classes to be configured
  9600. * during initialisation in addition to through the static
  9601. * {@link DataTable.ext.oStdClasses} object).
  9602. * @namespace
  9603. * @name DataTable.defaults.classes
  9604. */
  9605. "oClasses": {},
  9606. /**
  9607. * All strings that DataTables uses in the user interface that it creates
  9608. * are defined in this object, allowing you to modified them individually or
  9609. * completely replace them all as required.
  9610. * @namespace
  9611. * @name DataTable.defaults.language
  9612. */
  9613. "oLanguage": {
  9614. /**
  9615. * Strings that are used for WAI-ARIA labels and controls only (these are not
  9616. * actually visible on the page, but will be read by screenreaders, and thus
  9617. * must be internationalised as well).
  9618. * @namespace
  9619. * @name DataTable.defaults.language.aria
  9620. */
  9621. "oAria": {
  9622. /**
  9623. * ARIA label that is added to the table headers when the column may be
  9624. * sorted ascending by activing the column (click or return when focused).
  9625. * Note that the column header is prefixed to this string.
  9626. * @type string
  9627. * @default : activate to sort column ascending
  9628. *
  9629. * @dtopt Language
  9630. * @name DataTable.defaults.language.aria.sortAscending
  9631. *
  9632. * @example
  9633. * $(document).ready( function() {
  9634. * $('#example').dataTable( {
  9635. * "language": {
  9636. * "aria": {
  9637. * "sortAscending": " - click/return to sort ascending"
  9638. * }
  9639. * }
  9640. * } );
  9641. * } );
  9642. */
  9643. "sSortAscending": ": activate to sort column ascending",
  9644. /**
  9645. * ARIA label that is added to the table headers when the column may be
  9646. * sorted descending by activing the column (click or return when focused).
  9647. * Note that the column header is prefixed to this string.
  9648. * @type string
  9649. * @default : activate to sort column ascending
  9650. *
  9651. * @dtopt Language
  9652. * @name DataTable.defaults.language.aria.sortDescending
  9653. *
  9654. * @example
  9655. * $(document).ready( function() {
  9656. * $('#example').dataTable( {
  9657. * "language": {
  9658. * "aria": {
  9659. * "sortDescending": " - click/return to sort descending"
  9660. * }
  9661. * }
  9662. * } );
  9663. * } );
  9664. */
  9665. "sSortDescending": ": activate to sort column descending"
  9666. },
  9667. /**
  9668. * Pagination string used by DataTables for the built-in pagination
  9669. * control types.
  9670. * @namespace
  9671. * @name DataTable.defaults.language.paginate
  9672. */
  9673. "oPaginate": {
  9674. /**
  9675. * Text to use when using the 'full_numbers' type of pagination for the
  9676. * button to take the user to the first page.
  9677. * @type string
  9678. * @default First
  9679. *
  9680. * @dtopt Language
  9681. * @name DataTable.defaults.language.paginate.first
  9682. *
  9683. * @example
  9684. * $(document).ready( function() {
  9685. * $('#example').dataTable( {
  9686. * "language": {
  9687. * "paginate": {
  9688. * "first": "First page"
  9689. * }
  9690. * }
  9691. * } );
  9692. * } );
  9693. */
  9694. "sFirst": "First",
  9695. /**
  9696. * Text to use when using the 'full_numbers' type of pagination for the
  9697. * button to take the user to the last page.
  9698. * @type string
  9699. * @default Last
  9700. *
  9701. * @dtopt Language
  9702. * @name DataTable.defaults.language.paginate.last
  9703. *
  9704. * @example
  9705. * $(document).ready( function() {
  9706. * $('#example').dataTable( {
  9707. * "language": {
  9708. * "paginate": {
  9709. * "last": "Last page"
  9710. * }
  9711. * }
  9712. * } );
  9713. * } );
  9714. */
  9715. "sLast": "Last",
  9716. /**
  9717. * Text to use for the 'next' pagination button (to take the user to the
  9718. * next page).
  9719. * @type string
  9720. * @default Next
  9721. *
  9722. * @dtopt Language
  9723. * @name DataTable.defaults.language.paginate.next
  9724. *
  9725. * @example
  9726. * $(document).ready( function() {
  9727. * $('#example').dataTable( {
  9728. * "language": {
  9729. * "paginate": {
  9730. * "next": "Next page"
  9731. * }
  9732. * }
  9733. * } );
  9734. * } );
  9735. */
  9736. "sNext": "Next",
  9737. /**
  9738. * Text to use for the 'previous' pagination button (to take the user to
  9739. * the previous page).
  9740. * @type string
  9741. * @default Previous
  9742. *
  9743. * @dtopt Language
  9744. * @name DataTable.defaults.language.paginate.previous
  9745. *
  9746. * @example
  9747. * $(document).ready( function() {
  9748. * $('#example').dataTable( {
  9749. * "language": {
  9750. * "paginate": {
  9751. * "previous": "Previous page"
  9752. * }
  9753. * }
  9754. * } );
  9755. * } );
  9756. */
  9757. "sPrevious": "Previous"
  9758. },
  9759. /**
  9760. * This string is shown in preference to `zeroRecords` when the table is
  9761. * empty of data (regardless of filtering). Note that this is an optional
  9762. * parameter - if it is not given, the value of `zeroRecords` will be used
  9763. * instead (either the default or given value).
  9764. * @type string
  9765. * @default No data available in table
  9766. *
  9767. * @dtopt Language
  9768. * @name DataTable.defaults.language.emptyTable
  9769. *
  9770. * @example
  9771. * $(document).ready( function() {
  9772. * $('#example').dataTable( {
  9773. * "language": {
  9774. * "emptyTable": "No data available in table"
  9775. * }
  9776. * } );
  9777. * } );
  9778. */
  9779. "sEmptyTable": "No data available in table",
  9780. /**
  9781. * This string gives information to the end user about the information
  9782. * that is current on display on the page. The following tokens can be
  9783. * used in the string and will be dynamically replaced as the table
  9784. * display updates. This tokens can be placed anywhere in the string, or
  9785. * removed as needed by the language requires:
  9786. *
  9787. * * `\_START\_` - Display index of the first record on the current page
  9788. * * `\_END\_` - Display index of the last record on the current page
  9789. * * `\_TOTAL\_` - Number of records in the table after filtering
  9790. * * `\_MAX\_` - Number of records in the table without filtering
  9791. * * `\_PAGE\_` - Current page number
  9792. * * `\_PAGES\_` - Total number of pages of data in the table
  9793. *
  9794. * @type string
  9795. * @default Showing _START_ to _END_ of _TOTAL_ entries
  9796. *
  9797. * @dtopt Language
  9798. * @name DataTable.defaults.language.info
  9799. *
  9800. * @example
  9801. * $(document).ready( function() {
  9802. * $('#example').dataTable( {
  9803. * "language": {
  9804. * "info": "Showing page _PAGE_ of _PAGES_"
  9805. * }
  9806. * } );
  9807. * } );
  9808. */
  9809. "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
  9810. /**
  9811. * Display information string for when the table is empty. Typically the
  9812. * format of this string should match `info`.
  9813. * @type string
  9814. * @default Showing 0 to 0 of 0 entries
  9815. *
  9816. * @dtopt Language
  9817. * @name DataTable.defaults.language.infoEmpty
  9818. *
  9819. * @example
  9820. * $(document).ready( function() {
  9821. * $('#example').dataTable( {
  9822. * "language": {
  9823. * "infoEmpty": "No entries to show"
  9824. * }
  9825. * } );
  9826. * } );
  9827. */
  9828. "sInfoEmpty": "Showing 0 to 0 of 0 entries",
  9829. /**
  9830. * When a user filters the information in a table, this string is appended
  9831. * to the information (`info`) to give an idea of how strong the filtering
  9832. * is. The variable _MAX_ is dynamically updated.
  9833. * @type string
  9834. * @default (filtered from _MAX_ total entries)
  9835. *
  9836. * @dtopt Language
  9837. * @name DataTable.defaults.language.infoFiltered
  9838. *
  9839. * @example
  9840. * $(document).ready( function() {
  9841. * $('#example').dataTable( {
  9842. * "language": {
  9843. * "infoFiltered": " - filtering from _MAX_ records"
  9844. * }
  9845. * } );
  9846. * } );
  9847. */
  9848. "sInfoFiltered": "(filtered from _MAX_ total entries)",
  9849. /**
  9850. * If can be useful to append extra information to the info string at times,
  9851. * and this variable does exactly that. This information will be appended to
  9852. * the `info` (`infoEmpty` and `infoFiltered` in whatever combination they are
  9853. * being used) at all times.
  9854. * @type string
  9855. * @default <i>Empty string</i>
  9856. *
  9857. * @dtopt Language
  9858. * @name DataTable.defaults.language.infoPostFix
  9859. *
  9860. * @example
  9861. * $(document).ready( function() {
  9862. * $('#example').dataTable( {
  9863. * "language": {
  9864. * "infoPostFix": "All records shown are derived from real information."
  9865. * }
  9866. * } );
  9867. * } );
  9868. */
  9869. "sInfoPostFix": "",
  9870. /**
  9871. * This decimal place operator is a little different from the other
  9872. * language options since DataTables doesn't output floating point
  9873. * numbers, so it won't ever use this for display of a number. Rather,
  9874. * what this parameter does is modify the sort methods of the table so
  9875. * that numbers which are in a format which has a character other than
  9876. * a period (`.`) as a decimal place will be sorted numerically.
  9877. *
  9878. * Note that numbers with different decimal places cannot be shown in
  9879. * the same table and still be sortable, the table must be consistent.
  9880. * However, multiple different tables on the page can use different
  9881. * decimal place characters.
  9882. * @type string
  9883. * @default
  9884. *
  9885. * @dtopt Language
  9886. * @name DataTable.defaults.language.decimal
  9887. *
  9888. * @example
  9889. * $(document).ready( function() {
  9890. * $('#example').dataTable( {
  9891. * "language": {
  9892. * "decimal": ","
  9893. * "thousands": "."
  9894. * }
  9895. * } );
  9896. * } );
  9897. */
  9898. "sDecimal": "",
  9899. /**
  9900. * DataTables has a build in number formatter (`formatNumber`) which is
  9901. * used to format large numbers that are used in the table information.
  9902. * By default a comma is used, but this can be trivially changed to any
  9903. * character you wish with this parameter.
  9904. * @type string
  9905. * @default ,
  9906. *
  9907. * @dtopt Language
  9908. * @name DataTable.defaults.language.thousands
  9909. *
  9910. * @example
  9911. * $(document).ready( function() {
  9912. * $('#example').dataTable( {
  9913. * "language": {
  9914. * "thousands": "'"
  9915. * }
  9916. * } );
  9917. * } );
  9918. */
  9919. "sThousands": ",",
  9920. /**
  9921. * Detail the action that will be taken when the drop down menu for the
  9922. * pagination length option is changed. The '_MENU_' variable is replaced
  9923. * with a default select list of 10, 25, 50 and 100, and can be replaced
  9924. * with a custom select box if required.
  9925. * @type string
  9926. * @default Show _MENU_ entries
  9927. *
  9928. * @dtopt Language
  9929. * @name DataTable.defaults.language.lengthMenu
  9930. *
  9931. * @example
  9932. * // Language change only
  9933. * $(document).ready( function() {
  9934. * $('#example').dataTable( {
  9935. * "language": {
  9936. * "lengthMenu": "Display _MENU_ records"
  9937. * }
  9938. * } );
  9939. * } );
  9940. *
  9941. * @example
  9942. * // Language and options change
  9943. * $(document).ready( function() {
  9944. * $('#example').dataTable( {
  9945. * "language": {
  9946. * "lengthMenu": 'Display <select>'+
  9947. * '<option value="10">10</option>'+
  9948. * '<option value="20">20</option>'+
  9949. * '<option value="30">30</option>'+
  9950. * '<option value="40">40</option>'+
  9951. * '<option value="50">50</option>'+
  9952. * '<option value="-1">All</option>'+
  9953. * '</select> records'
  9954. * }
  9955. * } );
  9956. * } );
  9957. */
  9958. "sLengthMenu": "Show _MENU_ entries",
  9959. /**
  9960. * When using Ajax sourced data and during the first draw when DataTables is
  9961. * gathering the data, this message is shown in an empty row in the table to
  9962. * indicate to the end user the the data is being loaded. Note that this
  9963. * parameter is not used when loading data by server-side processing, just
  9964. * Ajax sourced data with client-side processing.
  9965. * @type string
  9966. * @default Loading...
  9967. *
  9968. * @dtopt Language
  9969. * @name DataTable.defaults.language.loadingRecords
  9970. *
  9971. * @example
  9972. * $(document).ready( function() {
  9973. * $('#example').dataTable( {
  9974. * "language": {
  9975. * "loadingRecords": "Please wait - loading..."
  9976. * }
  9977. * } );
  9978. * } );
  9979. */
  9980. "sLoadingRecords": "Loading...",
  9981. /**
  9982. * Text which is displayed when the table is processing a user action
  9983. * (usually a sort command or similar).
  9984. * @type string
  9985. * @default Processing...
  9986. *
  9987. * @dtopt Language
  9988. * @name DataTable.defaults.language.processing
  9989. *
  9990. * @example
  9991. * $(document).ready( function() {
  9992. * $('#example').dataTable( {
  9993. * "language": {
  9994. * "processing": "DataTables is currently busy"
  9995. * }
  9996. * } );
  9997. * } );
  9998. */
  9999. "sProcessing": "Processing...",
  10000. /**
  10001. * Details the actions that will be taken when the user types into the
  10002. * filtering input text box. The variable "_INPUT_", if used in the string,
  10003. * is replaced with the HTML text box for the filtering input allowing
  10004. * control over where it appears in the string. If "_INPUT_" is not given
  10005. * then the input box is appended to the string automatically.
  10006. * @type string
  10007. * @default Search:
  10008. *
  10009. * @dtopt Language
  10010. * @name DataTable.defaults.language.search
  10011. *
  10012. * @example
  10013. * // Input text box will be appended at the end automatically
  10014. * $(document).ready( function() {
  10015. * $('#example').dataTable( {
  10016. * "language": {
  10017. * "search": "Filter records:"
  10018. * }
  10019. * } );
  10020. * } );
  10021. *
  10022. * @example
  10023. * // Specify where the filter should appear
  10024. * $(document).ready( function() {
  10025. * $('#example').dataTable( {
  10026. * "language": {
  10027. * "search": "Apply filter _INPUT_ to table"
  10028. * }
  10029. * } );
  10030. * } );
  10031. */
  10032. "sSearch": "Search:",
  10033. /**
  10034. * Assign a `placeholder` attribute to the search `input` element
  10035. * @type string
  10036. * @default
  10037. *
  10038. * @dtopt Language
  10039. * @name DataTable.defaults.language.searchPlaceholder
  10040. */
  10041. "sSearchPlaceholder": "",
  10042. /**
  10043. * All of the language information can be stored in a file on the
  10044. * server-side, which DataTables will look up if this parameter is passed.
  10045. * It must store the URL of the language file, which is in a JSON format,
  10046. * and the object has the same properties as the oLanguage object in the
  10047. * initialiser object (i.e. the above parameters). Please refer to one of
  10048. * the example language files to see how this works in action.
  10049. * @type string
  10050. * @default <i>Empty string - i.e. disabled</i>
  10051. *
  10052. * @dtopt Language
  10053. * @name DataTable.defaults.language.url
  10054. *
  10055. * @example
  10056. * $(document).ready( function() {
  10057. * $('#example').dataTable( {
  10058. * "language": {
  10059. * "url": "http://www.sprymedia.co.uk/dataTables/lang.txt"
  10060. * }
  10061. * } );
  10062. * } );
  10063. */
  10064. "sUrl": "",
  10065. /**
  10066. * Text shown inside the table records when the is no information to be
  10067. * displayed after filtering. `emptyTable` is shown when there is simply no
  10068. * information in the table at all (regardless of filtering).
  10069. * @type string
  10070. * @default No matching records found
  10071. *
  10072. * @dtopt Language
  10073. * @name DataTable.defaults.language.zeroRecords
  10074. *
  10075. * @example
  10076. * $(document).ready( function() {
  10077. * $('#example').dataTable( {
  10078. * "language": {
  10079. * "zeroRecords": "No records to display"
  10080. * }
  10081. * } );
  10082. * } );
  10083. */
  10084. "sZeroRecords": "No matching records found"
  10085. },
  10086. /**
  10087. * This parameter allows you to have define the global filtering state at
  10088. * initialisation time. As an object the `search` parameter must be
  10089. * defined, but all other parameters are optional. When `regex` is true,
  10090. * the search string will be treated as a regular expression, when false
  10091. * (default) it will be treated as a straight string. When `smart`
  10092. * DataTables will use it's smart filtering methods (to word match at
  10093. * any point in the data), when false this will not be done.
  10094. * @namespace
  10095. * @extends DataTable.models.oSearch
  10096. *
  10097. * @dtopt Options
  10098. * @name DataTable.defaults.search
  10099. *
  10100. * @example
  10101. * $(document).ready( function() {
  10102. * $('#example').dataTable( {
  10103. * "search": {"search": "Initial search"}
  10104. * } );
  10105. * } )
  10106. */
  10107. "oSearch": $.extend( {}, DataTable.models.oSearch ),
  10108. /**
  10109. * __Deprecated__ The functionality provided by this parameter has now been
  10110. * superseded by that provided through `ajax`, which should be used instead.
  10111. *
  10112. * By default DataTables will look for the property `data` (or `aaData` for
  10113. * compatibility with DataTables 1.9-) when obtaining data from an Ajax
  10114. * source or for server-side processing - this parameter allows that
  10115. * property to be changed. You can use Javascript dotted object notation to
  10116. * get a data source for multiple levels of nesting.
  10117. * @type string
  10118. * @default data
  10119. *
  10120. * @dtopt Options
  10121. * @dtopt Server-side
  10122. * @name DataTable.defaults.ajaxDataProp
  10123. *
  10124. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10125. */
  10126. "sAjaxDataProp": "data",
  10127. /**
  10128. * __Deprecated__ The functionality provided by this parameter has now been
  10129. * superseded by that provided through `ajax`, which should be used instead.
  10130. *
  10131. * You can instruct DataTables to load data from an external
  10132. * source using this parameter (use aData if you want to pass data in you
  10133. * already have). Simply provide a url a JSON object can be obtained from.
  10134. * @type string
  10135. * @default null
  10136. *
  10137. * @dtopt Options
  10138. * @dtopt Server-side
  10139. * @name DataTable.defaults.ajaxSource
  10140. *
  10141. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10142. */
  10143. "sAjaxSource": null,
  10144. /**
  10145. * This initialisation variable allows you to specify exactly where in the
  10146. * DOM you want DataTables to inject the various controls it adds to the page
  10147. * (for example you might want the pagination controls at the top of the
  10148. * table). DIV elements (with or without a custom class) can also be added to
  10149. * aid styling. The follow syntax is used:
  10150. * <ul>
  10151. * <li>The following options are allowed:
  10152. * <ul>
  10153. * <li>'l' - Length changing</li>
  10154. * <li>'f' - Filtering input</li>
  10155. * <li>'t' - The table!</li>
  10156. * <li>'i' - Information</li>
  10157. * <li>'p' - Pagination</li>
  10158. * <li>'r' - pRocessing</li>
  10159. * </ul>
  10160. * </li>
  10161. * <li>The following constants are allowed:
  10162. * <ul>
  10163. * <li>'H' - jQueryUI theme "header" classes ('fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix')</li>
  10164. * <li>'F' - jQueryUI theme "footer" classes ('fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix')</li>
  10165. * </ul>
  10166. * </li>
  10167. * <li>The following syntax is expected:
  10168. * <ul>
  10169. * <li>'&lt;' and '&gt;' - div elements</li>
  10170. * <li>'&lt;"class" and '&gt;' - div with a class</li>
  10171. * <li>'&lt;"#id" and '&gt;' - div with an ID</li>
  10172. * </ul>
  10173. * </li>
  10174. * <li>Examples:
  10175. * <ul>
  10176. * <li>'&lt;"wrapper"flipt&gt;'</li>
  10177. * <li>'&lt;lf&lt;t&gt;ip&gt;'</li>
  10178. * </ul>
  10179. * </li>
  10180. * </ul>
  10181. * @type string
  10182. * @default lfrtip <i>(when `jQueryUI` is false)</i> <b>or</b>
  10183. * <"H"lfr>t<"F"ip> <i>(when `jQueryUI` is true)</i>
  10184. *
  10185. * @dtopt Options
  10186. * @name DataTable.defaults.dom
  10187. *
  10188. * @example
  10189. * $(document).ready( function() {
  10190. * $('#example').dataTable( {
  10191. * "dom": '&lt;"top"i&gt;rt&lt;"bottom"flp&gt;&lt;"clear"&gt;'
  10192. * } );
  10193. * } );
  10194. */
  10195. "sDom": "lfrtip",
  10196. /**
  10197. * Search delay option. This will throttle full table searches that use the
  10198. * DataTables provided search input element (it does not effect calls to
  10199. * `dt-api search()`, providing a delay before the search is made.
  10200. * @type integer
  10201. * @default 0
  10202. *
  10203. * @dtopt Options
  10204. * @name DataTable.defaults.searchDelay
  10205. *
  10206. * @example
  10207. * $(document).ready( function() {
  10208. * $('#example').dataTable( {
  10209. * "searchDelay": 200
  10210. * } );
  10211. * } )
  10212. */
  10213. "searchDelay": null,
  10214. /**
  10215. * DataTables features six different built-in options for the buttons to
  10216. * display for pagination control:
  10217. *
  10218. * * `numbers` - Page number buttons only
  10219. * * `simple` - 'Previous' and 'Next' buttons only
  10220. * * 'simple_numbers` - 'Previous' and 'Next' buttons, plus page numbers
  10221. * * `full` - 'First', 'Previous', 'Next' and 'Last' buttons
  10222. * * `full_numbers` - 'First', 'Previous', 'Next' and 'Last' buttons, plus page numbers
  10223. * * `first_last_numbers` - 'First' and 'Last' buttons, plus page numbers
  10224. *
  10225. * Further methods can be added using {@link DataTable.ext.oPagination}.
  10226. * @type string
  10227. * @default simple_numbers
  10228. *
  10229. * @dtopt Options
  10230. * @name DataTable.defaults.pagingType
  10231. *
  10232. * @example
  10233. * $(document).ready( function() {
  10234. * $('#example').dataTable( {
  10235. * "pagingType": "full_numbers"
  10236. * } );
  10237. * } )
  10238. */
  10239. "sPaginationType": "simple_numbers",
  10240. /**
  10241. * Enable horizontal scrolling. When a table is too wide to fit into a
  10242. * certain layout, or you have a large number of columns in the table, you
  10243. * can enable x-scrolling to show the table in a viewport, which can be
  10244. * scrolled. This property can be `true` which will allow the table to
  10245. * scroll horizontally when needed, or any CSS unit, or a number (in which
  10246. * case it will be treated as a pixel measurement). Setting as simply `true`
  10247. * is recommended.
  10248. * @type boolean|string
  10249. * @default <i>blank string - i.e. disabled</i>
  10250. *
  10251. * @dtopt Features
  10252. * @name DataTable.defaults.scrollX
  10253. *
  10254. * @example
  10255. * $(document).ready( function() {
  10256. * $('#example').dataTable( {
  10257. * "scrollX": true,
  10258. * "scrollCollapse": true
  10259. * } );
  10260. * } );
  10261. */
  10262. "sScrollX": "",
  10263. /**
  10264. * This property can be used to force a DataTable to use more width than it
  10265. * might otherwise do when x-scrolling is enabled. For example if you have a
  10266. * table which requires to be well spaced, this parameter is useful for
  10267. * "over-sizing" the table, and thus forcing scrolling. This property can by
  10268. * any CSS unit, or a number (in which case it will be treated as a pixel
  10269. * measurement).
  10270. * @type string
  10271. * @default <i>blank string - i.e. disabled</i>
  10272. *
  10273. * @dtopt Options
  10274. * @name DataTable.defaults.scrollXInner
  10275. *
  10276. * @example
  10277. * $(document).ready( function() {
  10278. * $('#example').dataTable( {
  10279. * "scrollX": "100%",
  10280. * "scrollXInner": "110%"
  10281. * } );
  10282. * } );
  10283. */
  10284. "sScrollXInner": "",
  10285. /**
  10286. * Enable vertical scrolling. Vertical scrolling will constrain the DataTable
  10287. * to the given height, and enable scrolling for any data which overflows the
  10288. * current viewport. This can be used as an alternative to paging to display
  10289. * a lot of data in a small area (although paging and scrolling can both be
  10290. * enabled at the same time). This property can be any CSS unit, or a number
  10291. * (in which case it will be treated as a pixel measurement).
  10292. * @type string
  10293. * @default <i>blank string - i.e. disabled</i>
  10294. *
  10295. * @dtopt Features
  10296. * @name DataTable.defaults.scrollY
  10297. *
  10298. * @example
  10299. * $(document).ready( function() {
  10300. * $('#example').dataTable( {
  10301. * "scrollY": "200px",
  10302. * "paginate": false
  10303. * } );
  10304. * } );
  10305. */
  10306. "sScrollY": "",
  10307. /**
  10308. * __Deprecated__ The functionality provided by this parameter has now been
  10309. * superseded by that provided through `ajax`, which should be used instead.
  10310. *
  10311. * Set the HTTP method that is used to make the Ajax call for server-side
  10312. * processing or Ajax sourced data.
  10313. * @type string
  10314. * @default GET
  10315. *
  10316. * @dtopt Options
  10317. * @dtopt Server-side
  10318. * @name DataTable.defaults.serverMethod
  10319. *
  10320. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10321. */
  10322. "sServerMethod": "GET",
  10323. /**
  10324. * DataTables makes use of renderers when displaying HTML elements for
  10325. * a table. These renderers can be added or modified by plug-ins to
  10326. * generate suitable mark-up for a site. For example the Bootstrap
  10327. * integration plug-in for DataTables uses a paging button renderer to
  10328. * display pagination buttons in the mark-up required by Bootstrap.
  10329. *
  10330. * For further information about the renderers available see
  10331. * DataTable.ext.renderer
  10332. * @type string|object
  10333. * @default null
  10334. *
  10335. * @name DataTable.defaults.renderer
  10336. *
  10337. */
  10338. "renderer": null,
  10339. /**
  10340. * Set the data property name that DataTables should use to get a row's id
  10341. * to set as the `id` property in the node.
  10342. * @type string
  10343. * @default DT_RowId
  10344. *
  10345. * @name DataTable.defaults.rowId
  10346. */
  10347. "rowId": "DT_RowId"
  10348. };
  10349. _fnHungarianMap( DataTable.defaults );
  10350. /*
  10351. * Developer note - See note in model.defaults.js about the use of Hungarian
  10352. * notation and camel case.
  10353. */
  10354. /**
  10355. * Column options that can be given to DataTables at initialisation time.
  10356. * @namespace
  10357. */
  10358. DataTable.defaults.column = {
  10359. /**
  10360. * Define which column(s) an order will occur on for this column. This
  10361. * allows a column's ordering to take multiple columns into account when
  10362. * doing a sort or use the data from a different column. For example first
  10363. * name / last name columns make sense to do a multi-column sort over the
  10364. * two columns.
  10365. * @type array|int
  10366. * @default null <i>Takes the value of the column index automatically</i>
  10367. *
  10368. * @name DataTable.defaults.column.orderData
  10369. * @dtopt Columns
  10370. *
  10371. * @example
  10372. * // Using `columnDefs`
  10373. * $(document).ready( function() {
  10374. * $('#example').dataTable( {
  10375. * "columnDefs": [
  10376. * { "orderData": [ 0, 1 ], "targets": [ 0 ] },
  10377. * { "orderData": [ 1, 0 ], "targets": [ 1 ] },
  10378. * { "orderData": 2, "targets": [ 2 ] }
  10379. * ]
  10380. * } );
  10381. * } );
  10382. *
  10383. * @example
  10384. * // Using `columns`
  10385. * $(document).ready( function() {
  10386. * $('#example').dataTable( {
  10387. * "columns": [
  10388. * { "orderData": [ 0, 1 ] },
  10389. * { "orderData": [ 1, 0 ] },
  10390. * { "orderData": 2 },
  10391. * null,
  10392. * null
  10393. * ]
  10394. * } );
  10395. * } );
  10396. */
  10397. "aDataSort": null,
  10398. "iDataSort": -1,
  10399. /**
  10400. * You can control the default ordering direction, and even alter the
  10401. * behaviour of the sort handler (i.e. only allow ascending ordering etc)
  10402. * using this parameter.
  10403. * @type array
  10404. * @default [ 'asc', 'desc' ]
  10405. *
  10406. * @name DataTable.defaults.column.orderSequence
  10407. * @dtopt Columns
  10408. *
  10409. * @example
  10410. * // Using `columnDefs`
  10411. * $(document).ready( function() {
  10412. * $('#example').dataTable( {
  10413. * "columnDefs": [
  10414. * { "orderSequence": [ "asc" ], "targets": [ 1 ] },
  10415. * { "orderSequence": [ "desc", "asc", "asc" ], "targets": [ 2 ] },
  10416. * { "orderSequence": [ "desc" ], "targets": [ 3 ] }
  10417. * ]
  10418. * } );
  10419. * } );
  10420. *
  10421. * @example
  10422. * // Using `columns`
  10423. * $(document).ready( function() {
  10424. * $('#example').dataTable( {
  10425. * "columns": [
  10426. * null,
  10427. * { "orderSequence": [ "asc" ] },
  10428. * { "orderSequence": [ "desc", "asc", "asc" ] },
  10429. * { "orderSequence": [ "desc" ] },
  10430. * null
  10431. * ]
  10432. * } );
  10433. * } );
  10434. */
  10435. "asSorting": [ 'asc', 'desc' ],
  10436. /**
  10437. * Enable or disable filtering on the data in this column.
  10438. * @type boolean
  10439. * @default true
  10440. *
  10441. * @name DataTable.defaults.column.searchable
  10442. * @dtopt Columns
  10443. *
  10444. * @example
  10445. * // Using `columnDefs`
  10446. * $(document).ready( function() {
  10447. * $('#example').dataTable( {
  10448. * "columnDefs": [
  10449. * { "searchable": false, "targets": [ 0 ] }
  10450. * ] } );
  10451. * } );
  10452. *
  10453. * @example
  10454. * // Using `columns`
  10455. * $(document).ready( function() {
  10456. * $('#example').dataTable( {
  10457. * "columns": [
  10458. * { "searchable": false },
  10459. * null,
  10460. * null,
  10461. * null,
  10462. * null
  10463. * ] } );
  10464. * } );
  10465. */
  10466. "bSearchable": true,
  10467. /**
  10468. * Enable or disable ordering on this column.
  10469. * @type boolean
  10470. * @default true
  10471. *
  10472. * @name DataTable.defaults.column.orderable
  10473. * @dtopt Columns
  10474. *
  10475. * @example
  10476. * // Using `columnDefs`
  10477. * $(document).ready( function() {
  10478. * $('#example').dataTable( {
  10479. * "columnDefs": [
  10480. * { "orderable": false, "targets": [ 0 ] }
  10481. * ] } );
  10482. * } );
  10483. *
  10484. * @example
  10485. * // Using `columns`
  10486. * $(document).ready( function() {
  10487. * $('#example').dataTable( {
  10488. * "columns": [
  10489. * { "orderable": false },
  10490. * null,
  10491. * null,
  10492. * null,
  10493. * null
  10494. * ] } );
  10495. * } );
  10496. */
  10497. "bSortable": true,
  10498. /**
  10499. * Enable or disable the display of this column.
  10500. * @type boolean
  10501. * @default true
  10502. *
  10503. * @name DataTable.defaults.column.visible
  10504. * @dtopt Columns
  10505. *
  10506. * @example
  10507. * // Using `columnDefs`
  10508. * $(document).ready( function() {
  10509. * $('#example').dataTable( {
  10510. * "columnDefs": [
  10511. * { "visible": false, "targets": [ 0 ] }
  10512. * ] } );
  10513. * } );
  10514. *
  10515. * @example
  10516. * // Using `columns`
  10517. * $(document).ready( function() {
  10518. * $('#example').dataTable( {
  10519. * "columns": [
  10520. * { "visible": false },
  10521. * null,
  10522. * null,
  10523. * null,
  10524. * null
  10525. * ] } );
  10526. * } );
  10527. */
  10528. "bVisible": true,
  10529. /**
  10530. * Developer definable function that is called whenever a cell is created (Ajax source,
  10531. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  10532. * allowing you to modify the DOM element (add background colour for example) when the
  10533. * element is available.
  10534. * @type function
  10535. * @param {element} td The TD node that has been created
  10536. * @param {*} cellData The Data for the cell
  10537. * @param {array|object} rowData The data for the whole row
  10538. * @param {int} row The row index for the aoData data store
  10539. * @param {int} col The column index for aoColumns
  10540. *
  10541. * @name DataTable.defaults.column.createdCell
  10542. * @dtopt Columns
  10543. *
  10544. * @example
  10545. * $(document).ready( function() {
  10546. * $('#example').dataTable( {
  10547. * "columnDefs": [ {
  10548. * "targets": [3],
  10549. * "createdCell": function (td, cellData, rowData, row, col) {
  10550. * if ( cellData == "1.7" ) {
  10551. * $(td).css('color', 'blue')
  10552. * }
  10553. * }
  10554. * } ]
  10555. * });
  10556. * } );
  10557. */
  10558. "fnCreatedCell": null,
  10559. /**
  10560. * This parameter has been replaced by `data` in DataTables to ensure naming
  10561. * consistency. `dataProp` can still be used, as there is backwards
  10562. * compatibility in DataTables for this option, but it is strongly
  10563. * recommended that you use `data` in preference to `dataProp`.
  10564. * @name DataTable.defaults.column.dataProp
  10565. */
  10566. /**
  10567. * This property can be used to read data from any data source property,
  10568. * including deeply nested objects / properties. `data` can be given in a
  10569. * number of different ways which effect its behaviour:
  10570. *
  10571. * * `integer` - treated as an array index for the data source. This is the
  10572. * default that DataTables uses (incrementally increased for each column).
  10573. * * `string` - read an object property from the data source. There are
  10574. * three 'special' options that can be used in the string to alter how
  10575. * DataTables reads the data from the source object:
  10576. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10577. * Javascript to read from nested objects, so to can the options
  10578. * specified in `data`. For example: `browser.version` or
  10579. * `browser.name`. If your object parameter name contains a period, use
  10580. * `\\` to escape it - i.e. `first\\.name`.
  10581. * * `[]` - Array notation. DataTables can automatically combine data
  10582. * from and array source, joining the data with the characters provided
  10583. * between the two brackets. For example: `name[, ]` would provide a
  10584. * comma-space separated list from the source array. If no characters
  10585. * are provided between the brackets, the original array source is
  10586. * returned.
  10587. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10588. * execute a function of the name given. For example: `browser()` for a
  10589. * simple function on the data source, `browser.version()` for a
  10590. * function in a nested property or even `browser().version` to get an
  10591. * object property if the function called returns an object. Note that
  10592. * function notation is recommended for use in `render` rather than
  10593. * `data` as it is much simpler to use as a renderer.
  10594. * * `null` - use the original data source for the row rather than plucking
  10595. * data directly from it. This action has effects on two other
  10596. * initialisation options:
  10597. * * `defaultContent` - When null is given as the `data` option and
  10598. * `defaultContent` is specified for the column, the value defined by
  10599. * `defaultContent` will be used for the cell.
  10600. * * `render` - When null is used for the `data` option and the `render`
  10601. * option is specified for the column, the whole data source for the
  10602. * row is used for the renderer.
  10603. * * `function` - the function given will be executed whenever DataTables
  10604. * needs to set or get the data for a cell in the column. The function
  10605. * takes three parameters:
  10606. * * Parameters:
  10607. * * `{array|object}` The data source for the row
  10608. * * `{string}` The type call data requested - this will be 'set' when
  10609. * setting data or 'filter', 'display', 'type', 'sort' or undefined
  10610. * when gathering data. Note that when `undefined` is given for the
  10611. * type DataTables expects to get the raw data for the object back<
  10612. * * `{*}` Data to set when the second parameter is 'set'.
  10613. * * Return:
  10614. * * The return value from the function is not required when 'set' is
  10615. * the type of call, but otherwise the return is what will be used
  10616. * for the data requested.
  10617. *
  10618. * Note that `data` is a getter and setter option. If you just require
  10619. * formatting of data for output, you will likely want to use `render` which
  10620. * is simply a getter and thus simpler to use.
  10621. *
  10622. * Note that prior to DataTables 1.9.2 `data` was called `mDataProp`. The
  10623. * name change reflects the flexibility of this property and is consistent
  10624. * with the naming of mRender. If 'mDataProp' is given, then it will still
  10625. * be used by DataTables, as it automatically maps the old name to the new
  10626. * if required.
  10627. *
  10628. * @type string|int|function|null
  10629. * @default null <i>Use automatically calculated column index</i>
  10630. *
  10631. * @name DataTable.defaults.column.data
  10632. * @dtopt Columns
  10633. *
  10634. * @example
  10635. * // Read table data from objects
  10636. * // JSON structure for each row:
  10637. * // {
  10638. * // "engine": {value},
  10639. * // "browser": {value},
  10640. * // "platform": {value},
  10641. * // "version": {value},
  10642. * // "grade": {value}
  10643. * // }
  10644. * $(document).ready( function() {
  10645. * $('#example').dataTable( {
  10646. * "ajaxSource": "sources/objects.txt",
  10647. * "columns": [
  10648. * { "data": "engine" },
  10649. * { "data": "browser" },
  10650. * { "data": "platform" },
  10651. * { "data": "version" },
  10652. * { "data": "grade" }
  10653. * ]
  10654. * } );
  10655. * } );
  10656. *
  10657. * @example
  10658. * // Read information from deeply nested objects
  10659. * // JSON structure for each row:
  10660. * // {
  10661. * // "engine": {value},
  10662. * // "browser": {value},
  10663. * // "platform": {
  10664. * // "inner": {value}
  10665. * // },
  10666. * // "details": [
  10667. * // {value}, {value}
  10668. * // ]
  10669. * // }
  10670. * $(document).ready( function() {
  10671. * $('#example').dataTable( {
  10672. * "ajaxSource": "sources/deep.txt",
  10673. * "columns": [
  10674. * { "data": "engine" },
  10675. * { "data": "browser" },
  10676. * { "data": "platform.inner" },
  10677. * { "data": "platform.details.0" },
  10678. * { "data": "platform.details.1" }
  10679. * ]
  10680. * } );
  10681. * } );
  10682. *
  10683. * @example
  10684. * // Using `data` as a function to provide different information for
  10685. * // sorting, filtering and display. In this case, currency (price)
  10686. * $(document).ready( function() {
  10687. * $('#example').dataTable( {
  10688. * "columnDefs": [ {
  10689. * "targets": [ 0 ],
  10690. * "data": function ( source, type, val ) {
  10691. * if (type === 'set') {
  10692. * source.price = val;
  10693. * // Store the computed dislay and filter values for efficiency
  10694. * source.price_display = val=="" ? "" : "$"+numberFormat(val);
  10695. * source.price_filter = val=="" ? "" : "$"+numberFormat(val)+" "+val;
  10696. * return;
  10697. * }
  10698. * else if (type === 'display') {
  10699. * return source.price_display;
  10700. * }
  10701. * else if (type === 'filter') {
  10702. * return source.price_filter;
  10703. * }
  10704. * // 'sort', 'type' and undefined all just use the integer
  10705. * return source.price;
  10706. * }
  10707. * } ]
  10708. * } );
  10709. * } );
  10710. *
  10711. * @example
  10712. * // Using default content
  10713. * $(document).ready( function() {
  10714. * $('#example').dataTable( {
  10715. * "columnDefs": [ {
  10716. * "targets": [ 0 ],
  10717. * "data": null,
  10718. * "defaultContent": "Click to edit"
  10719. * } ]
  10720. * } );
  10721. * } );
  10722. *
  10723. * @example
  10724. * // Using array notation - outputting a list from an array
  10725. * $(document).ready( function() {
  10726. * $('#example').dataTable( {
  10727. * "columnDefs": [ {
  10728. * "targets": [ 0 ],
  10729. * "data": "name[, ]"
  10730. * } ]
  10731. * } );
  10732. * } );
  10733. *
  10734. */
  10735. "mData": null,
  10736. /**
  10737. * This property is the rendering partner to `data` and it is suggested that
  10738. * when you want to manipulate data for display (including filtering,
  10739. * sorting etc) without altering the underlying data for the table, use this
  10740. * property. `render` can be considered to be the the read only companion to
  10741. * `data` which is read / write (then as such more complex). Like `data`
  10742. * this option can be given in a number of different ways to effect its
  10743. * behaviour:
  10744. *
  10745. * * `integer` - treated as an array index for the data source. This is the
  10746. * default that DataTables uses (incrementally increased for each column).
  10747. * * `string` - read an object property from the data source. There are
  10748. * three 'special' options that can be used in the string to alter how
  10749. * DataTables reads the data from the source object:
  10750. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10751. * Javascript to read from nested objects, so to can the options
  10752. * specified in `data`. For example: `browser.version` or
  10753. * `browser.name`. If your object parameter name contains a period, use
  10754. * `\\` to escape it - i.e. `first\\.name`.
  10755. * * `[]` - Array notation. DataTables can automatically combine data
  10756. * from and array source, joining the data with the characters provided
  10757. * between the two brackets. For example: `name[, ]` would provide a
  10758. * comma-space separated list from the source array. If no characters
  10759. * are provided between the brackets, the original array source is
  10760. * returned.
  10761. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10762. * execute a function of the name given. For example: `browser()` for a
  10763. * simple function on the data source, `browser.version()` for a
  10764. * function in a nested property or even `browser().version` to get an
  10765. * object property if the function called returns an object.
  10766. * * `object` - use different data for the different data types requested by
  10767. * DataTables ('filter', 'display', 'type' or 'sort'). The property names
  10768. * of the object is the data type the property refers to and the value can
  10769. * defined using an integer, string or function using the same rules as
  10770. * `render` normally does. Note that an `_` option _must_ be specified.
  10771. * This is the default value to use if you haven't specified a value for
  10772. * the data type requested by DataTables.
  10773. * * `function` - the function given will be executed whenever DataTables
  10774. * needs to set or get the data for a cell in the column. The function
  10775. * takes three parameters:
  10776. * * Parameters:
  10777. * * {array|object} The data source for the row (based on `data`)
  10778. * * {string} The type call data requested - this will be 'filter',
  10779. * 'display', 'type' or 'sort'.
  10780. * * {array|object} The full data source for the row (not based on
  10781. * `data`)
  10782. * * Return:
  10783. * * The return value from the function is what will be used for the
  10784. * data requested.
  10785. *
  10786. * @type string|int|function|object|null
  10787. * @default null Use the data source value.
  10788. *
  10789. * @name DataTable.defaults.column.render
  10790. * @dtopt Columns
  10791. *
  10792. * @example
  10793. * // Create a comma separated list from an array of objects
  10794. * $(document).ready( function() {
  10795. * $('#example').dataTable( {
  10796. * "ajaxSource": "sources/deep.txt",
  10797. * "columns": [
  10798. * { "data": "engine" },
  10799. * { "data": "browser" },
  10800. * {
  10801. * "data": "platform",
  10802. * "render": "[, ].name"
  10803. * }
  10804. * ]
  10805. * } );
  10806. * } );
  10807. *
  10808. * @example
  10809. * // Execute a function to obtain data
  10810. * $(document).ready( function() {
  10811. * $('#example').dataTable( {
  10812. * "columnDefs": [ {
  10813. * "targets": [ 0 ],
  10814. * "data": null, // Use the full data source object for the renderer's source
  10815. * "render": "browserName()"
  10816. * } ]
  10817. * } );
  10818. * } );
  10819. *
  10820. * @example
  10821. * // As an object, extracting different data for the different types
  10822. * // This would be used with a data source such as:
  10823. * // { "phone": 5552368, "phone_filter": "5552368 555-2368", "phone_display": "555-2368" }
  10824. * // Here the `phone` integer is used for sorting and type detection, while `phone_filter`
  10825. * // (which has both forms) is used for filtering for if a user inputs either format, while
  10826. * // the formatted phone number is the one that is shown in the table.
  10827. * $(document).ready( function() {
  10828. * $('#example').dataTable( {
  10829. * "columnDefs": [ {
  10830. * "targets": [ 0 ],
  10831. * "data": null, // Use the full data source object for the renderer's source
  10832. * "render": {
  10833. * "_": "phone",
  10834. * "filter": "phone_filter",
  10835. * "display": "phone_display"
  10836. * }
  10837. * } ]
  10838. * } );
  10839. * } );
  10840. *
  10841. * @example
  10842. * // Use as a function to create a link from the data source
  10843. * $(document).ready( function() {
  10844. * $('#example').dataTable( {
  10845. * "columnDefs": [ {
  10846. * "targets": [ 0 ],
  10847. * "data": "download_link",
  10848. * "render": function ( data, type, full ) {
  10849. * return '<a href="'+data+'">Download</a>';
  10850. * }
  10851. * } ]
  10852. * } );
  10853. * } );
  10854. */
  10855. "mRender": null,
  10856. /**
  10857. * Change the cell type created for the column - either TD cells or TH cells. This
  10858. * can be useful as TH cells have semantic meaning in the table body, allowing them
  10859. * to act as a header for a row (you may wish to add scope='row' to the TH elements).
  10860. * @type string
  10861. * @default td
  10862. *
  10863. * @name DataTable.defaults.column.cellType
  10864. * @dtopt Columns
  10865. *
  10866. * @example
  10867. * // Make the first column use TH cells
  10868. * $(document).ready( function() {
  10869. * $('#example').dataTable( {
  10870. * "columnDefs": [ {
  10871. * "targets": [ 0 ],
  10872. * "cellType": "th"
  10873. * } ]
  10874. * } );
  10875. * } );
  10876. */
  10877. "sCellType": "td",
  10878. /**
  10879. * Class to give to each cell in this column.
  10880. * @type string
  10881. * @default <i>Empty string</i>
  10882. *
  10883. * @name DataTable.defaults.column.class
  10884. * @dtopt Columns
  10885. *
  10886. * @example
  10887. * // Using `columnDefs`
  10888. * $(document).ready( function() {
  10889. * $('#example').dataTable( {
  10890. * "columnDefs": [
  10891. * { "class": "my_class", "targets": [ 0 ] }
  10892. * ]
  10893. * } );
  10894. * } );
  10895. *
  10896. * @example
  10897. * // Using `columns`
  10898. * $(document).ready( function() {
  10899. * $('#example').dataTable( {
  10900. * "columns": [
  10901. * { "class": "my_class" },
  10902. * null,
  10903. * null,
  10904. * null,
  10905. * null
  10906. * ]
  10907. * } );
  10908. * } );
  10909. */
  10910. "sClass": "",
  10911. /**
  10912. * When DataTables calculates the column widths to assign to each column,
  10913. * it finds the longest string in each column and then constructs a
  10914. * temporary table and reads the widths from that. The problem with this
  10915. * is that "mmm" is much wider then "iiii", but the latter is a longer
  10916. * string - thus the calculation can go wrong (doing it properly and putting
  10917. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  10918. * a "work around" we provide this option. It will append its value to the
  10919. * text that is found to be the longest string for the column - i.e. padding.
  10920. * Generally you shouldn't need this!
  10921. * @type string
  10922. * @default <i>Empty string<i>
  10923. *
  10924. * @name DataTable.defaults.column.contentPadding
  10925. * @dtopt Columns
  10926. *
  10927. * @example
  10928. * // Using `columns`
  10929. * $(document).ready( function() {
  10930. * $('#example').dataTable( {
  10931. * "columns": [
  10932. * null,
  10933. * null,
  10934. * null,
  10935. * {
  10936. * "contentPadding": "mmm"
  10937. * }
  10938. * ]
  10939. * } );
  10940. * } );
  10941. */
  10942. "sContentPadding": "",
  10943. /**
  10944. * Allows a default value to be given for a column's data, and will be used
  10945. * whenever a null data source is encountered (this can be because `data`
  10946. * is set to null, or because the data source itself is null).
  10947. * @type string
  10948. * @default null
  10949. *
  10950. * @name DataTable.defaults.column.defaultContent
  10951. * @dtopt Columns
  10952. *
  10953. * @example
  10954. * // Using `columnDefs`
  10955. * $(document).ready( function() {
  10956. * $('#example').dataTable( {
  10957. * "columnDefs": [
  10958. * {
  10959. * "data": null,
  10960. * "defaultContent": "Edit",
  10961. * "targets": [ -1 ]
  10962. * }
  10963. * ]
  10964. * } );
  10965. * } );
  10966. *
  10967. * @example
  10968. * // Using `columns`
  10969. * $(document).ready( function() {
  10970. * $('#example').dataTable( {
  10971. * "columns": [
  10972. * null,
  10973. * null,
  10974. * null,
  10975. * {
  10976. * "data": null,
  10977. * "defaultContent": "Edit"
  10978. * }
  10979. * ]
  10980. * } );
  10981. * } );
  10982. */
  10983. "sDefaultContent": null,
  10984. /**
  10985. * This parameter is only used in DataTables' server-side processing. It can
  10986. * be exceptionally useful to know what columns are being displayed on the
  10987. * client side, and to map these to database fields. When defined, the names
  10988. * also allow DataTables to reorder information from the server if it comes
  10989. * back in an unexpected order (i.e. if you switch your columns around on the
  10990. * client-side, your server-side code does not also need updating).
  10991. * @type string
  10992. * @default <i>Empty string</i>
  10993. *
  10994. * @name DataTable.defaults.column.name
  10995. * @dtopt Columns
  10996. *
  10997. * @example
  10998. * // Using `columnDefs`
  10999. * $(document).ready( function() {
  11000. * $('#example').dataTable( {
  11001. * "columnDefs": [
  11002. * { "name": "engine", "targets": [ 0 ] },
  11003. * { "name": "browser", "targets": [ 1 ] },
  11004. * { "name": "platform", "targets": [ 2 ] },
  11005. * { "name": "version", "targets": [ 3 ] },
  11006. * { "name": "grade", "targets": [ 4 ] }
  11007. * ]
  11008. * } );
  11009. * } );
  11010. *
  11011. * @example
  11012. * // Using `columns`
  11013. * $(document).ready( function() {
  11014. * $('#example').dataTable( {
  11015. * "columns": [
  11016. * { "name": "engine" },
  11017. * { "name": "browser" },
  11018. * { "name": "platform" },
  11019. * { "name": "version" },
  11020. * { "name": "grade" }
  11021. * ]
  11022. * } );
  11023. * } );
  11024. */
  11025. "sName": "",
  11026. /**
  11027. * Defines a data source type for the ordering which can be used to read
  11028. * real-time information from the table (updating the internally cached
  11029. * version) prior to ordering. This allows ordering to occur on user
  11030. * editable elements such as form inputs.
  11031. * @type string
  11032. * @default std
  11033. *
  11034. * @name DataTable.defaults.column.orderDataType
  11035. * @dtopt Columns
  11036. *
  11037. * @example
  11038. * // Using `columnDefs`
  11039. * $(document).ready( function() {
  11040. * $('#example').dataTable( {
  11041. * "columnDefs": [
  11042. * { "orderDataType": "dom-text", "targets": [ 2, 3 ] },
  11043. * { "type": "numeric", "targets": [ 3 ] },
  11044. * { "orderDataType": "dom-select", "targets": [ 4 ] },
  11045. * { "orderDataType": "dom-checkbox", "targets": [ 5 ] }
  11046. * ]
  11047. * } );
  11048. * } );
  11049. *
  11050. * @example
  11051. * // Using `columns`
  11052. * $(document).ready( function() {
  11053. * $('#example').dataTable( {
  11054. * "columns": [
  11055. * null,
  11056. * null,
  11057. * { "orderDataType": "dom-text" },
  11058. * { "orderDataType": "dom-text", "type": "numeric" },
  11059. * { "orderDataType": "dom-select" },
  11060. * { "orderDataType": "dom-checkbox" }
  11061. * ]
  11062. * } );
  11063. * } );
  11064. */
  11065. "sSortDataType": "std",
  11066. /**
  11067. * The title of this column.
  11068. * @type string
  11069. * @default null <i>Derived from the 'TH' value for this column in the
  11070. * original HTML table.</i>
  11071. *
  11072. * @name DataTable.defaults.column.title
  11073. * @dtopt Columns
  11074. *
  11075. * @example
  11076. * // Using `columnDefs`
  11077. * $(document).ready( function() {
  11078. * $('#example').dataTable( {
  11079. * "columnDefs": [
  11080. * { "title": "My column title", "targets": [ 0 ] }
  11081. * ]
  11082. * } );
  11083. * } );
  11084. *
  11085. * @example
  11086. * // Using `columns`
  11087. * $(document).ready( function() {
  11088. * $('#example').dataTable( {
  11089. * "columns": [
  11090. * { "title": "My column title" },
  11091. * null,
  11092. * null,
  11093. * null,
  11094. * null
  11095. * ]
  11096. * } );
  11097. * } );
  11098. */
  11099. "sTitle": null,
  11100. /**
  11101. * The type allows you to specify how the data for this column will be
  11102. * ordered. Four types (string, numeric, date and html (which will strip
  11103. * HTML tags before ordering)) are currently available. Note that only date
  11104. * formats understood by Javascript's Date() object will be accepted as type
  11105. * date. For example: "Mar 26, 2008 5:03 PM". May take the values: 'string',
  11106. * 'numeric', 'date' or 'html' (by default). Further types can be adding
  11107. * through plug-ins.
  11108. * @type string
  11109. * @default null <i>Auto-detected from raw data</i>
  11110. *
  11111. * @name DataTable.defaults.column.type
  11112. * @dtopt Columns
  11113. *
  11114. * @example
  11115. * // Using `columnDefs`
  11116. * $(document).ready( function() {
  11117. * $('#example').dataTable( {
  11118. * "columnDefs": [
  11119. * { "type": "html", "targets": [ 0 ] }
  11120. * ]
  11121. * } );
  11122. * } );
  11123. *
  11124. * @example
  11125. * // Using `columns`
  11126. * $(document).ready( function() {
  11127. * $('#example').dataTable( {
  11128. * "columns": [
  11129. * { "type": "html" },
  11130. * null,
  11131. * null,
  11132. * null,
  11133. * null
  11134. * ]
  11135. * } );
  11136. * } );
  11137. */
  11138. "sType": null,
  11139. /**
  11140. * Defining the width of the column, this parameter may take any CSS value
  11141. * (3em, 20px etc). DataTables applies 'smart' widths to columns which have not
  11142. * been given a specific width through this interface ensuring that the table
  11143. * remains readable.
  11144. * @type string
  11145. * @default null <i>Automatic</i>
  11146. *
  11147. * @name DataTable.defaults.column.width
  11148. * @dtopt Columns
  11149. *
  11150. * @example
  11151. * // Using `columnDefs`
  11152. * $(document).ready( function() {
  11153. * $('#example').dataTable( {
  11154. * "columnDefs": [
  11155. * { "width": "20%", "targets": [ 0 ] }
  11156. * ]
  11157. * } );
  11158. * } );
  11159. *
  11160. * @example
  11161. * // Using `columns`
  11162. * $(document).ready( function() {
  11163. * $('#example').dataTable( {
  11164. * "columns": [
  11165. * { "width": "20%" },
  11166. * null,
  11167. * null,
  11168. * null,
  11169. * null
  11170. * ]
  11171. * } );
  11172. * } );
  11173. */
  11174. "sWidth": null
  11175. };
  11176. _fnHungarianMap( DataTable.defaults.column );
  11177. /**
  11178. * DataTables settings object - this holds all the information needed for a
  11179. * given table, including configuration, data and current application of the
  11180. * table options. DataTables does not have a single instance for each DataTable
  11181. * with the settings attached to that instance, but rather instances of the
  11182. * DataTable "class" are created on-the-fly as needed (typically by a
  11183. * $().dataTable() call) and the settings object is then applied to that
  11184. * instance.
  11185. *
  11186. * Note that this object is related to {@link DataTable.defaults} but this
  11187. * one is the internal data store for DataTables's cache of columns. It should
  11188. * NOT be manipulated outside of DataTables. Any configuration should be done
  11189. * through the initialisation options.
  11190. * @namespace
  11191. * @todo Really should attach the settings object to individual instances so we
  11192. * don't need to create new instances on each $().dataTable() call (if the
  11193. * table already exists). It would also save passing oSettings around and
  11194. * into every single function. However, this is a very significant
  11195. * architecture change for DataTables and will almost certainly break
  11196. * backwards compatibility with older installations. This is something that
  11197. * will be done in 2.0.
  11198. */
  11199. DataTable.models.oSettings = {
  11200. /**
  11201. * Primary features of DataTables and their enablement state.
  11202. * @namespace
  11203. */
  11204. "oFeatures": {
  11205. /**
  11206. * Flag to say if DataTables should automatically try to calculate the
  11207. * optimum table and columns widths (true) or not (false).
  11208. * Note that this parameter will be set by the initialisation routine. To
  11209. * set a default use {@link DataTable.defaults}.
  11210. * @type boolean
  11211. */
  11212. "bAutoWidth": null,
  11213. /**
  11214. * Delay the creation of TR and TD elements until they are actually
  11215. * needed by a driven page draw. This can give a significant speed
  11216. * increase for Ajax source and Javascript source data, but makes no
  11217. * difference at all fro DOM and server-side processing tables.
  11218. * Note that this parameter will be set by the initialisation routine. To
  11219. * set a default use {@link DataTable.defaults}.
  11220. * @type boolean
  11221. */
  11222. "bDeferRender": null,
  11223. /**
  11224. * Enable filtering on the table or not. Note that if this is disabled
  11225. * then there is no filtering at all on the table, including fnFilter.
  11226. * To just remove the filtering input use sDom and remove the 'f' option.
  11227. * Note that this parameter will be set by the initialisation routine. To
  11228. * set a default use {@link DataTable.defaults}.
  11229. * @type boolean
  11230. */
  11231. "bFilter": null,
  11232. /**
  11233. * Table information element (the 'Showing x of y records' div) enable
  11234. * flag.
  11235. * Note that this parameter will be set by the initialisation routine. To
  11236. * set a default use {@link DataTable.defaults}.
  11237. * @type boolean
  11238. */
  11239. "bInfo": null,
  11240. /**
  11241. * Present a user control allowing the end user to change the page size
  11242. * when pagination is enabled.
  11243. * Note that this parameter will be set by the initialisation routine. To
  11244. * set a default use {@link DataTable.defaults}.
  11245. * @type boolean
  11246. */
  11247. "bLengthChange": null,
  11248. /**
  11249. * Pagination enabled or not. Note that if this is disabled then length
  11250. * changing must also be disabled.
  11251. * Note that this parameter will be set by the initialisation routine. To
  11252. * set a default use {@link DataTable.defaults}.
  11253. * @type boolean
  11254. */
  11255. "bPaginate": null,
  11256. /**
  11257. * Processing indicator enable flag whenever DataTables is enacting a
  11258. * user request - typically an Ajax request for server-side processing.
  11259. * Note that this parameter will be set by the initialisation routine. To
  11260. * set a default use {@link DataTable.defaults}.
  11261. * @type boolean
  11262. */
  11263. "bProcessing": null,
  11264. /**
  11265. * Server-side processing enabled flag - when enabled DataTables will
  11266. * get all data from the server for every draw - there is no filtering,
  11267. * sorting or paging done on the client-side.
  11268. * Note that this parameter will be set by the initialisation routine. To
  11269. * set a default use {@link DataTable.defaults}.
  11270. * @type boolean
  11271. */
  11272. "bServerSide": null,
  11273. /**
  11274. * Sorting enablement flag.
  11275. * Note that this parameter will be set by the initialisation routine. To
  11276. * set a default use {@link DataTable.defaults}.
  11277. * @type boolean
  11278. */
  11279. "bSort": null,
  11280. /**
  11281. * Multi-column sorting
  11282. * Note that this parameter will be set by the initialisation routine. To
  11283. * set a default use {@link DataTable.defaults}.
  11284. * @type boolean
  11285. */
  11286. "bSortMulti": null,
  11287. /**
  11288. * Apply a class to the columns which are being sorted to provide a
  11289. * visual highlight or not. This can slow things down when enabled since
  11290. * there is a lot of DOM interaction.
  11291. * Note that this parameter will be set by the initialisation routine. To
  11292. * set a default use {@link DataTable.defaults}.
  11293. * @type boolean
  11294. */
  11295. "bSortClasses": null,
  11296. /**
  11297. * State saving enablement flag.
  11298. * Note that this parameter will be set by the initialisation routine. To
  11299. * set a default use {@link DataTable.defaults}.
  11300. * @type boolean
  11301. */
  11302. "bStateSave": null
  11303. },
  11304. /**
  11305. * Scrolling settings for a table.
  11306. * @namespace
  11307. */
  11308. "oScroll": {
  11309. /**
  11310. * When the table is shorter in height than sScrollY, collapse the
  11311. * table container down to the height of the table (when true).
  11312. * Note that this parameter will be set by the initialisation routine. To
  11313. * set a default use {@link DataTable.defaults}.
  11314. * @type boolean
  11315. */
  11316. "bCollapse": null,
  11317. /**
  11318. * Width of the scrollbar for the web-browser's platform. Calculated
  11319. * during table initialisation.
  11320. * @type int
  11321. * @default 0
  11322. */
  11323. "iBarWidth": 0,
  11324. /**
  11325. * Viewport width for horizontal scrolling. Horizontal scrolling is
  11326. * disabled if an empty string.
  11327. * Note that this parameter will be set by the initialisation routine. To
  11328. * set a default use {@link DataTable.defaults}.
  11329. * @type string
  11330. */
  11331. "sX": null,
  11332. /**
  11333. * Width to expand the table to when using x-scrolling. Typically you
  11334. * should not need to use this.
  11335. * Note that this parameter will be set by the initialisation routine. To
  11336. * set a default use {@link DataTable.defaults}.
  11337. * @type string
  11338. * @deprecated
  11339. */
  11340. "sXInner": null,
  11341. /**
  11342. * Viewport height for vertical scrolling. Vertical scrolling is disabled
  11343. * if an empty string.
  11344. * Note that this parameter will be set by the initialisation routine. To
  11345. * set a default use {@link DataTable.defaults}.
  11346. * @type string
  11347. */
  11348. "sY": null
  11349. },
  11350. /**
  11351. * Language information for the table.
  11352. * @namespace
  11353. * @extends DataTable.defaults.oLanguage
  11354. */
  11355. "oLanguage": {
  11356. /**
  11357. * Information callback function. See
  11358. * {@link DataTable.defaults.fnInfoCallback}
  11359. * @type function
  11360. * @default null
  11361. */
  11362. "fnInfoCallback": null
  11363. },
  11364. /**
  11365. * Browser support parameters
  11366. * @namespace
  11367. */
  11368. "oBrowser": {
  11369. /**
  11370. * Indicate if the browser incorrectly calculates width:100% inside a
  11371. * scrolling element (IE6/7)
  11372. * @type boolean
  11373. * @default false
  11374. */
  11375. "bScrollOversize": false,
  11376. /**
  11377. * Determine if the vertical scrollbar is on the right or left of the
  11378. * scrolling container - needed for rtl language layout, although not
  11379. * all browsers move the scrollbar (Safari).
  11380. * @type boolean
  11381. * @default false
  11382. */
  11383. "bScrollbarLeft": false,
  11384. /**
  11385. * Flag for if `getBoundingClientRect` is fully supported or not
  11386. * @type boolean
  11387. * @default false
  11388. */
  11389. "bBounding": false,
  11390. /**
  11391. * Browser scrollbar width
  11392. * @type integer
  11393. * @default 0
  11394. */
  11395. "barWidth": 0
  11396. },
  11397. "ajax": null,
  11398. /**
  11399. * Array referencing the nodes which are used for the features. The
  11400. * parameters of this object match what is allowed by sDom - i.e.
  11401. * <ul>
  11402. * <li>'l' - Length changing</li>
  11403. * <li>'f' - Filtering input</li>
  11404. * <li>'t' - The table!</li>
  11405. * <li>'i' - Information</li>
  11406. * <li>'p' - Pagination</li>
  11407. * <li>'r' - pRocessing</li>
  11408. * </ul>
  11409. * @type array
  11410. * @default []
  11411. */
  11412. "aanFeatures": [],
  11413. /**
  11414. * Store data information - see {@link DataTable.models.oRow} for detailed
  11415. * information.
  11416. * @type array
  11417. * @default []
  11418. */
  11419. "aoData": [],
  11420. /**
  11421. * Array of indexes which are in the current display (after filtering etc)
  11422. * @type array
  11423. * @default []
  11424. */
  11425. "aiDisplay": [],
  11426. /**
  11427. * Array of indexes for display - no filtering
  11428. * @type array
  11429. * @default []
  11430. */
  11431. "aiDisplayMaster": [],
  11432. /**
  11433. * Map of row ids to data indexes
  11434. * @type object
  11435. * @default {}
  11436. */
  11437. "aIds": {},
  11438. /**
  11439. * Store information about each column that is in use
  11440. * @type array
  11441. * @default []
  11442. */
  11443. "aoColumns": [],
  11444. /**
  11445. * Store information about the table's header
  11446. * @type array
  11447. * @default []
  11448. */
  11449. "aoHeader": [],
  11450. /**
  11451. * Store information about the table's footer
  11452. * @type array
  11453. * @default []
  11454. */
  11455. "aoFooter": [],
  11456. /**
  11457. * Store the applied global search information in case we want to force a
  11458. * research or compare the old search to a new one.
  11459. * Note that this parameter will be set by the initialisation routine. To
  11460. * set a default use {@link DataTable.defaults}.
  11461. * @namespace
  11462. * @extends DataTable.models.oSearch
  11463. */
  11464. "oPreviousSearch": {},
  11465. /**
  11466. * Store the applied search for each column - see
  11467. * {@link DataTable.models.oSearch} for the format that is used for the
  11468. * filtering information for each column.
  11469. * @type array
  11470. * @default []
  11471. */
  11472. "aoPreSearchCols": [],
  11473. /**
  11474. * Sorting that is applied to the table. Note that the inner arrays are
  11475. * used in the following manner:
  11476. * <ul>
  11477. * <li>Index 0 - column number</li>
  11478. * <li>Index 1 - current sorting direction</li>
  11479. * </ul>
  11480. * Note that this parameter will be set by the initialisation routine. To
  11481. * set a default use {@link DataTable.defaults}.
  11482. * @type array
  11483. * @todo These inner arrays should really be objects
  11484. */
  11485. "aaSorting": null,
  11486. /**
  11487. * Sorting that is always applied to the table (i.e. prefixed in front of
  11488. * aaSorting).
  11489. * Note that this parameter will be set by the initialisation routine. To
  11490. * set a default use {@link DataTable.defaults}.
  11491. * @type array
  11492. * @default []
  11493. */
  11494. "aaSortingFixed": [],
  11495. /**
  11496. * Classes to use for the striping of a table.
  11497. * Note that this parameter will be set by the initialisation routine. To
  11498. * set a default use {@link DataTable.defaults}.
  11499. * @type array
  11500. * @default []
  11501. */
  11502. "asStripeClasses": null,
  11503. /**
  11504. * If restoring a table - we should restore its striping classes as well
  11505. * @type array
  11506. * @default []
  11507. */
  11508. "asDestroyStripes": [],
  11509. /**
  11510. * If restoring a table - we should restore its width
  11511. * @type int
  11512. * @default 0
  11513. */
  11514. "sDestroyWidth": 0,
  11515. /**
  11516. * Callback functions array for every time a row is inserted (i.e. on a draw).
  11517. * @type array
  11518. * @default []
  11519. */
  11520. "aoRowCallback": [],
  11521. /**
  11522. * Callback functions for the header on each draw.
  11523. * @type array
  11524. * @default []
  11525. */
  11526. "aoHeaderCallback": [],
  11527. /**
  11528. * Callback function for the footer on each draw.
  11529. * @type array
  11530. * @default []
  11531. */
  11532. "aoFooterCallback": [],
  11533. /**
  11534. * Array of callback functions for draw callback functions
  11535. * @type array
  11536. * @default []
  11537. */
  11538. "aoDrawCallback": [],
  11539. /**
  11540. * Array of callback functions for row created function
  11541. * @type array
  11542. * @default []
  11543. */
  11544. "aoRowCreatedCallback": [],
  11545. /**
  11546. * Callback functions for just before the table is redrawn. A return of
  11547. * false will be used to cancel the draw.
  11548. * @type array
  11549. * @default []
  11550. */
  11551. "aoPreDrawCallback": [],
  11552. /**
  11553. * Callback functions for when the table has been initialised.
  11554. * @type array
  11555. * @default []
  11556. */
  11557. "aoInitComplete": [],
  11558. /**
  11559. * Callbacks for modifying the settings to be stored for state saving, prior to
  11560. * saving state.
  11561. * @type array
  11562. * @default []
  11563. */
  11564. "aoStateSaveParams": [],
  11565. /**
  11566. * Callbacks for modifying the settings that have been stored for state saving
  11567. * prior to using the stored values to restore the state.
  11568. * @type array
  11569. * @default []
  11570. */
  11571. "aoStateLoadParams": [],
  11572. /**
  11573. * Callbacks for operating on the settings object once the saved state has been
  11574. * loaded
  11575. * @type array
  11576. * @default []
  11577. */
  11578. "aoStateLoaded": [],
  11579. /**
  11580. * Cache the table ID for quick access
  11581. * @type string
  11582. * @default <i>Empty string</i>
  11583. */
  11584. "sTableId": "",
  11585. /**
  11586. * The TABLE node for the main table
  11587. * @type node
  11588. * @default null
  11589. */
  11590. "nTable": null,
  11591. /**
  11592. * Permanent ref to the thead element
  11593. * @type node
  11594. * @default null
  11595. */
  11596. "nTHead": null,
  11597. /**
  11598. * Permanent ref to the tfoot element - if it exists
  11599. * @type node
  11600. * @default null
  11601. */
  11602. "nTFoot": null,
  11603. /**
  11604. * Permanent ref to the tbody element
  11605. * @type node
  11606. * @default null
  11607. */
  11608. "nTBody": null,
  11609. /**
  11610. * Cache the wrapper node (contains all DataTables controlled elements)
  11611. * @type node
  11612. * @default null
  11613. */
  11614. "nTableWrapper": null,
  11615. /**
  11616. * Indicate if when using server-side processing the loading of data
  11617. * should be deferred until the second draw.
  11618. * Note that this parameter will be set by the initialisation routine. To
  11619. * set a default use {@link DataTable.defaults}.
  11620. * @type boolean
  11621. * @default false
  11622. */
  11623. "bDeferLoading": false,
  11624. /**
  11625. * Indicate if all required information has been read in
  11626. * @type boolean
  11627. * @default false
  11628. */
  11629. "bInitialised": false,
  11630. /**
  11631. * Information about open rows. Each object in the array has the parameters
  11632. * 'nTr' and 'nParent'
  11633. * @type array
  11634. * @default []
  11635. */
  11636. "aoOpenRows": [],
  11637. /**
  11638. * Dictate the positioning of DataTables' control elements - see
  11639. * {@link DataTable.model.oInit.sDom}.
  11640. * Note that this parameter will be set by the initialisation routine. To
  11641. * set a default use {@link DataTable.defaults}.
  11642. * @type string
  11643. * @default null
  11644. */
  11645. "sDom": null,
  11646. /**
  11647. * Search delay (in mS)
  11648. * @type integer
  11649. * @default null
  11650. */
  11651. "searchDelay": null,
  11652. /**
  11653. * Which type of pagination should be used.
  11654. * Note that this parameter will be set by the initialisation routine. To
  11655. * set a default use {@link DataTable.defaults}.
  11656. * @type string
  11657. * @default two_button
  11658. */
  11659. "sPaginationType": "two_button",
  11660. /**
  11661. * The state duration (for `stateSave`) in seconds.
  11662. * Note that this parameter will be set by the initialisation routine. To
  11663. * set a default use {@link DataTable.defaults}.
  11664. * @type int
  11665. * @default 0
  11666. */
  11667. "iStateDuration": 0,
  11668. /**
  11669. * Array of callback functions for state saving. Each array element is an
  11670. * object with the following parameters:
  11671. * <ul>
  11672. * <li>function:fn - function to call. Takes two parameters, oSettings
  11673. * and the JSON string to save that has been thus far created. Returns
  11674. * a JSON string to be inserted into a json object
  11675. * (i.e. '"param": [ 0, 1, 2]')</li>
  11676. * <li>string:sName - name of callback</li>
  11677. * </ul>
  11678. * @type array
  11679. * @default []
  11680. */
  11681. "aoStateSave": [],
  11682. /**
  11683. * Array of callback functions for state loading. Each array element is an
  11684. * object with the following parameters:
  11685. * <ul>
  11686. * <li>function:fn - function to call. Takes two parameters, oSettings
  11687. * and the object stored. May return false to cancel state loading</li>
  11688. * <li>string:sName - name of callback</li>
  11689. * </ul>
  11690. * @type array
  11691. * @default []
  11692. */
  11693. "aoStateLoad": [],
  11694. /**
  11695. * State that was saved. Useful for back reference
  11696. * @type object
  11697. * @default null
  11698. */
  11699. "oSavedState": null,
  11700. /**
  11701. * State that was loaded. Useful for back reference
  11702. * @type object
  11703. * @default null
  11704. */
  11705. "oLoadedState": null,
  11706. /**
  11707. * Source url for AJAX data for the table.
  11708. * Note that this parameter will be set by the initialisation routine. To
  11709. * set a default use {@link DataTable.defaults}.
  11710. * @type string
  11711. * @default null
  11712. */
  11713. "sAjaxSource": null,
  11714. /**
  11715. * Property from a given object from which to read the table data from. This
  11716. * can be an empty string (when not server-side processing), in which case
  11717. * it is assumed an an array is given directly.
  11718. * Note that this parameter will be set by the initialisation routine. To
  11719. * set a default use {@link DataTable.defaults}.
  11720. * @type string
  11721. */
  11722. "sAjaxDataProp": null,
  11723. /**
  11724. * Note if draw should be blocked while getting data
  11725. * @type boolean
  11726. * @default true
  11727. */
  11728. "bAjaxDataGet": true,
  11729. /**
  11730. * The last jQuery XHR object that was used for server-side data gathering.
  11731. * This can be used for working with the XHR information in one of the
  11732. * callbacks
  11733. * @type object
  11734. * @default null
  11735. */
  11736. "jqXHR": null,
  11737. /**
  11738. * JSON returned from the server in the last Ajax request
  11739. * @type object
  11740. * @default undefined
  11741. */
  11742. "json": undefined,
  11743. /**
  11744. * Data submitted as part of the last Ajax request
  11745. * @type object
  11746. * @default undefined
  11747. */
  11748. "oAjaxData": undefined,
  11749. /**
  11750. * Function to get the server-side data.
  11751. * Note that this parameter will be set by the initialisation routine. To
  11752. * set a default use {@link DataTable.defaults}.
  11753. * @type function
  11754. */
  11755. "fnServerData": null,
  11756. /**
  11757. * Functions which are called prior to sending an Ajax request so extra
  11758. * parameters can easily be sent to the server
  11759. * @type array
  11760. * @default []
  11761. */
  11762. "aoServerParams": [],
  11763. /**
  11764. * Send the XHR HTTP method - GET or POST (could be PUT or DELETE if
  11765. * required).
  11766. * Note that this parameter will be set by the initialisation routine. To
  11767. * set a default use {@link DataTable.defaults}.
  11768. * @type string
  11769. */
  11770. "sServerMethod": null,
  11771. /**
  11772. * Format numbers for display.
  11773. * Note that this parameter will be set by the initialisation routine. To
  11774. * set a default use {@link DataTable.defaults}.
  11775. * @type function
  11776. */
  11777. "fnFormatNumber": null,
  11778. /**
  11779. * List of options that can be used for the user selectable length menu.
  11780. * Note that this parameter will be set by the initialisation routine. To
  11781. * set a default use {@link DataTable.defaults}.
  11782. * @type array
  11783. * @default []
  11784. */
  11785. "aLengthMenu": null,
  11786. /**
  11787. * Counter for the draws that the table does. Also used as a tracker for
  11788. * server-side processing
  11789. * @type int
  11790. * @default 0
  11791. */
  11792. "iDraw": 0,
  11793. /**
  11794. * Indicate if a redraw is being done - useful for Ajax
  11795. * @type boolean
  11796. * @default false
  11797. */
  11798. "bDrawing": false,
  11799. /**
  11800. * Draw index (iDraw) of the last error when parsing the returned data
  11801. * @type int
  11802. * @default -1
  11803. */
  11804. "iDrawError": -1,
  11805. /**
  11806. * Paging display length
  11807. * @type int
  11808. * @default 10
  11809. */
  11810. "_iDisplayLength": 10,
  11811. /**
  11812. * Paging start point - aiDisplay index
  11813. * @type int
  11814. * @default 0
  11815. */
  11816. "_iDisplayStart": 0,
  11817. /**
  11818. * Server-side processing - number of records in the result set
  11819. * (i.e. before filtering), Use fnRecordsTotal rather than
  11820. * this property to get the value of the number of records, regardless of
  11821. * the server-side processing setting.
  11822. * @type int
  11823. * @default 0
  11824. * @private
  11825. */
  11826. "_iRecordsTotal": 0,
  11827. /**
  11828. * Server-side processing - number of records in the current display set
  11829. * (i.e. after filtering). Use fnRecordsDisplay rather than
  11830. * this property to get the value of the number of records, regardless of
  11831. * the server-side processing setting.
  11832. * @type boolean
  11833. * @default 0
  11834. * @private
  11835. */
  11836. "_iRecordsDisplay": 0,
  11837. /**
  11838. * The classes to use for the table
  11839. * @type object
  11840. * @default {}
  11841. */
  11842. "oClasses": {},
  11843. /**
  11844. * Flag attached to the settings object so you can check in the draw
  11845. * callback if filtering has been done in the draw. Deprecated in favour of
  11846. * events.
  11847. * @type boolean
  11848. * @default false
  11849. * @deprecated
  11850. */
  11851. "bFiltered": false,
  11852. /**
  11853. * Flag attached to the settings object so you can check in the draw
  11854. * callback if sorting has been done in the draw. Deprecated in favour of
  11855. * events.
  11856. * @type boolean
  11857. * @default false
  11858. * @deprecated
  11859. */
  11860. "bSorted": false,
  11861. /**
  11862. * Indicate that if multiple rows are in the header and there is more than
  11863. * one unique cell per column, if the top one (true) or bottom one (false)
  11864. * should be used for sorting / title by DataTables.
  11865. * Note that this parameter will be set by the initialisation routine. To
  11866. * set a default use {@link DataTable.defaults}.
  11867. * @type boolean
  11868. */
  11869. "bSortCellsTop": null,
  11870. /**
  11871. * Initialisation object that is used for the table
  11872. * @type object
  11873. * @default null
  11874. */
  11875. "oInit": null,
  11876. /**
  11877. * Destroy callback functions - for plug-ins to attach themselves to the
  11878. * destroy so they can clean up markup and events.
  11879. * @type array
  11880. * @default []
  11881. */
  11882. "aoDestroyCallback": [],
  11883. /**
  11884. * Get the number of records in the current record set, before filtering
  11885. * @type function
  11886. */
  11887. "fnRecordsTotal": function ()
  11888. {
  11889. return _fnDataSource( this ) == 'ssp' ?
  11890. this._iRecordsTotal * 1 :
  11891. this.aiDisplayMaster.length;
  11892. },
  11893. /**
  11894. * Get the number of records in the current record set, after filtering
  11895. * @type function
  11896. */
  11897. "fnRecordsDisplay": function ()
  11898. {
  11899. return _fnDataSource( this ) == 'ssp' ?
  11900. this._iRecordsDisplay * 1 :
  11901. this.aiDisplay.length;
  11902. },
  11903. /**
  11904. * Get the display end point - aiDisplay index
  11905. * @type function
  11906. */
  11907. "fnDisplayEnd": function ()
  11908. {
  11909. var
  11910. len = this._iDisplayLength,
  11911. start = this._iDisplayStart,
  11912. calc = start + len,
  11913. records = this.aiDisplay.length,
  11914. features = this.oFeatures,
  11915. paginate = features.bPaginate;
  11916. if ( features.bServerSide ) {
  11917. return paginate === false || len === -1 ?
  11918. start + records :
  11919. Math.min( start+len, this._iRecordsDisplay );
  11920. }
  11921. else {
  11922. return ! paginate || calc>records || len===-1 ?
  11923. records :
  11924. calc;
  11925. }
  11926. },
  11927. /**
  11928. * The DataTables object for this table
  11929. * @type object
  11930. * @default null
  11931. */
  11932. "oInstance": null,
  11933. /**
  11934. * Unique identifier for each instance of the DataTables object. If there
  11935. * is an ID on the table node, then it takes that value, otherwise an
  11936. * incrementing internal counter is used.
  11937. * @type string
  11938. * @default null
  11939. */
  11940. "sInstance": null,
  11941. /**
  11942. * tabindex attribute value that is added to DataTables control elements, allowing
  11943. * keyboard navigation of the table and its controls.
  11944. */
  11945. "iTabIndex": 0,
  11946. /**
  11947. * DIV container for the footer scrolling table if scrolling
  11948. */
  11949. "nScrollHead": null,
  11950. /**
  11951. * DIV container for the footer scrolling table if scrolling
  11952. */
  11953. "nScrollFoot": null,
  11954. /**
  11955. * Last applied sort
  11956. * @type array
  11957. * @default []
  11958. */
  11959. "aLastSort": [],
  11960. /**
  11961. * Stored plug-in instances
  11962. * @type object
  11963. * @default {}
  11964. */
  11965. "oPlugins": {},
  11966. /**
  11967. * Function used to get a row's id from the row's data
  11968. * @type function
  11969. * @default null
  11970. */
  11971. "rowIdFn": null,
  11972. /**
  11973. * Data location where to store a row's id
  11974. * @type string
  11975. * @default null
  11976. */
  11977. "rowId": null
  11978. };
  11979. /**
  11980. * Extension object for DataTables that is used to provide all extension
  11981. * options.
  11982. *
  11983. * Note that the `DataTable.ext` object is available through
  11984. * `jQuery.fn.dataTable.ext` where it may be accessed and manipulated. It is
  11985. * also aliased to `jQuery.fn.dataTableExt` for historic reasons.
  11986. * @namespace
  11987. * @extends DataTable.models.ext
  11988. */
  11989. /**
  11990. * DataTables extensions
  11991. *
  11992. * This namespace acts as a collection area for plug-ins that can be used to
  11993. * extend DataTables capabilities. Indeed many of the build in methods
  11994. * use this method to provide their own capabilities (sorting methods for
  11995. * example).
  11996. *
  11997. * Note that this namespace is aliased to `jQuery.fn.dataTableExt` for legacy
  11998. * reasons
  11999. *
  12000. * @namespace
  12001. */
  12002. DataTable.ext = _ext = {
  12003. /**
  12004. * Buttons. For use with the Buttons extension for DataTables. This is
  12005. * defined here so other extensions can define buttons regardless of load
  12006. * order. It is _not_ used by DataTables core.
  12007. *
  12008. * @type object
  12009. * @default {}
  12010. */
  12011. buttons: {},
  12012. /**
  12013. * Element class names
  12014. *
  12015. * @type object
  12016. * @default {}
  12017. */
  12018. classes: {},
  12019. /**
  12020. * DataTables build type (expanded by the download builder)
  12021. *
  12022. * @type string
  12023. */
  12024. builder: "-source-",
  12025. /**
  12026. * Error reporting.
  12027. *
  12028. * How should DataTables report an error. Can take the value 'alert',
  12029. * 'throw', 'none' or a function.
  12030. *
  12031. * @type string|function
  12032. * @default alert
  12033. */
  12034. errMode: "alert",
  12035. /**
  12036. * Feature plug-ins.
  12037. *
  12038. * This is an array of objects which describe the feature plug-ins that are
  12039. * available to DataTables. These feature plug-ins are then available for
  12040. * use through the `dom` initialisation option.
  12041. *
  12042. * Each feature plug-in is described by an object which must have the
  12043. * following properties:
  12044. *
  12045. * * `fnInit` - function that is used to initialise the plug-in,
  12046. * * `cFeature` - a character so the feature can be enabled by the `dom`
  12047. * instillation option. This is case sensitive.
  12048. *
  12049. * The `fnInit` function has the following input parameters:
  12050. *
  12051. * 1. `{object}` DataTables settings object: see
  12052. * {@link DataTable.models.oSettings}
  12053. *
  12054. * And the following return is expected:
  12055. *
  12056. * * {node|null} The element which contains your feature. Note that the
  12057. * return may also be void if your plug-in does not require to inject any
  12058. * DOM elements into DataTables control (`dom`) - for example this might
  12059. * be useful when developing a plug-in which allows table control via
  12060. * keyboard entry
  12061. *
  12062. * @type array
  12063. *
  12064. * @example
  12065. * $.fn.dataTable.ext.features.push( {
  12066. * "fnInit": function( oSettings ) {
  12067. * return new TableTools( { "oDTSettings": oSettings } );
  12068. * },
  12069. * "cFeature": "T"
  12070. * } );
  12071. */
  12072. feature: [],
  12073. /**
  12074. * Row searching.
  12075. *
  12076. * This method of searching is complimentary to the default type based
  12077. * searching, and a lot more comprehensive as it allows you complete control
  12078. * over the searching logic. Each element in this array is a function
  12079. * (parameters described below) that is called for every row in the table,
  12080. * and your logic decides if it should be included in the searching data set
  12081. * or not.
  12082. *
  12083. * Searching functions have the following input parameters:
  12084. *
  12085. * 1. `{object}` DataTables settings object: see
  12086. * {@link DataTable.models.oSettings}
  12087. * 2. `{array|object}` Data for the row to be processed (same as the
  12088. * original format that was passed in as the data source, or an array
  12089. * from a DOM data source
  12090. * 3. `{int}` Row index ({@link DataTable.models.oSettings.aoData}), which
  12091. * can be useful to retrieve the `TR` element if you need DOM interaction.
  12092. *
  12093. * And the following return is expected:
  12094. *
  12095. * * {boolean} Include the row in the searched result set (true) or not
  12096. * (false)
  12097. *
  12098. * Note that as with the main search ability in DataTables, technically this
  12099. * is "filtering", since it is subtractive. However, for consistency in
  12100. * naming we call it searching here.
  12101. *
  12102. * @type array
  12103. * @default []
  12104. *
  12105. * @example
  12106. * // The following example shows custom search being applied to the
  12107. * // fourth column (i.e. the data[3] index) based on two input values
  12108. * // from the end-user, matching the data in a certain range.
  12109. * $.fn.dataTable.ext.search.push(
  12110. * function( settings, data, dataIndex ) {
  12111. * var min = document.getElementById('min').value * 1;
  12112. * var max = document.getElementById('max').value * 1;
  12113. * var version = data[3] == "-" ? 0 : data[3]*1;
  12114. *
  12115. * if ( min == "" && max == "" ) {
  12116. * return true;
  12117. * }
  12118. * else if ( min == "" && version < max ) {
  12119. * return true;
  12120. * }
  12121. * else if ( min < version && "" == max ) {
  12122. * return true;
  12123. * }
  12124. * else if ( min < version && version < max ) {
  12125. * return true;
  12126. * }
  12127. * return false;
  12128. * }
  12129. * );
  12130. */
  12131. search: [],
  12132. /**
  12133. * Selector extensions
  12134. *
  12135. * The `selector` option can be used to extend the options available for the
  12136. * selector modifier options (`selector-modifier` object data type) that
  12137. * each of the three built in selector types offer (row, column and cell +
  12138. * their plural counterparts). For example the Select extension uses this
  12139. * mechanism to provide an option to select only rows, columns and cells
  12140. * that have been marked as selected by the end user (`{selected: true}`),
  12141. * which can be used in conjunction with the existing built in selector
  12142. * options.
  12143. *
  12144. * Each property is an array to which functions can be pushed. The functions
  12145. * take three attributes:
  12146. *
  12147. * * Settings object for the host table
  12148. * * Options object (`selector-modifier` object type)
  12149. * * Array of selected item indexes
  12150. *
  12151. * The return is an array of the resulting item indexes after the custom
  12152. * selector has been applied.
  12153. *
  12154. * @type object
  12155. */
  12156. selector: {
  12157. cell: [],
  12158. column: [],
  12159. row: []
  12160. },
  12161. /**
  12162. * Internal functions, exposed for used in plug-ins.
  12163. *
  12164. * Please note that you should not need to use the internal methods for
  12165. * anything other than a plug-in (and even then, try to avoid if possible).
  12166. * The internal function may change between releases.
  12167. *
  12168. * @type object
  12169. * @default {}
  12170. */
  12171. internal: {},
  12172. /**
  12173. * Legacy configuration options. Enable and disable legacy options that
  12174. * are available in DataTables.
  12175. *
  12176. * @type object
  12177. */
  12178. legacy: {
  12179. /**
  12180. * Enable / disable DataTables 1.9 compatible server-side processing
  12181. * requests
  12182. *
  12183. * @type boolean
  12184. * @default null
  12185. */
  12186. ajax: null
  12187. },
  12188. /**
  12189. * Pagination plug-in methods.
  12190. *
  12191. * Each entry in this object is a function and defines which buttons should
  12192. * be shown by the pagination rendering method that is used for the table:
  12193. * {@link DataTable.ext.renderer.pageButton}. The renderer addresses how the
  12194. * buttons are displayed in the document, while the functions here tell it
  12195. * what buttons to display. This is done by returning an array of button
  12196. * descriptions (what each button will do).
  12197. *
  12198. * Pagination types (the four built in options and any additional plug-in
  12199. * options defined here) can be used through the `paginationType`
  12200. * initialisation parameter.
  12201. *
  12202. * The functions defined take two parameters:
  12203. *
  12204. * 1. `{int} page` The current page index
  12205. * 2. `{int} pages` The number of pages in the table
  12206. *
  12207. * Each function is expected to return an array where each element of the
  12208. * array can be one of:
  12209. *
  12210. * * `first` - Jump to first page when activated
  12211. * * `last` - Jump to last page when activated
  12212. * * `previous` - Show previous page when activated
  12213. * * `next` - Show next page when activated
  12214. * * `{int}` - Show page of the index given
  12215. * * `{array}` - A nested array containing the above elements to add a
  12216. * containing 'DIV' element (might be useful for styling).
  12217. *
  12218. * Note that DataTables v1.9- used this object slightly differently whereby
  12219. * an object with two functions would be defined for each plug-in. That
  12220. * ability is still supported by DataTables 1.10+ to provide backwards
  12221. * compatibility, but this option of use is now decremented and no longer
  12222. * documented in DataTables 1.10+.
  12223. *
  12224. * @type object
  12225. * @default {}
  12226. *
  12227. * @example
  12228. * // Show previous, next and current page buttons only
  12229. * $.fn.dataTableExt.oPagination.current = function ( page, pages ) {
  12230. * return [ 'previous', page, 'next' ];
  12231. * };
  12232. */
  12233. pager: {},
  12234. renderer: {
  12235. pageButton: {},
  12236. header: {}
  12237. },
  12238. /**
  12239. * Ordering plug-ins - custom data source
  12240. *
  12241. * The extension options for ordering of data available here is complimentary
  12242. * to the default type based ordering that DataTables typically uses. It
  12243. * allows much greater control over the the data that is being used to
  12244. * order a column, but is necessarily therefore more complex.
  12245. *
  12246. * This type of ordering is useful if you want to do ordering based on data
  12247. * live from the DOM (for example the contents of an 'input' element) rather
  12248. * than just the static string that DataTables knows of.
  12249. *
  12250. * The way these plug-ins work is that you create an array of the values you
  12251. * wish to be ordering for the column in question and then return that
  12252. * array. The data in the array much be in the index order of the rows in
  12253. * the table (not the currently ordering order!). Which order data gathering
  12254. * function is run here depends on the `dt-init columns.orderDataType`
  12255. * parameter that is used for the column (if any).
  12256. *
  12257. * The functions defined take two parameters:
  12258. *
  12259. * 1. `{object}` DataTables settings object: see
  12260. * {@link DataTable.models.oSettings}
  12261. * 2. `{int}` Target column index
  12262. *
  12263. * Each function is expected to return an array:
  12264. *
  12265. * * `{array}` Data for the column to be ordering upon
  12266. *
  12267. * @type array
  12268. *
  12269. * @example
  12270. * // Ordering using `input` node values
  12271. * $.fn.dataTable.ext.order['dom-text'] = function ( settings, col )
  12272. * {
  12273. * return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
  12274. * return $('input', td).val();
  12275. * } );
  12276. * }
  12277. */
  12278. order: {},
  12279. /**
  12280. * Type based plug-ins.
  12281. *
  12282. * Each column in DataTables has a type assigned to it, either by automatic
  12283. * detection or by direct assignment using the `type` option for the column.
  12284. * The type of a column will effect how it is ordering and search (plug-ins
  12285. * can also make use of the column type if required).
  12286. *
  12287. * @namespace
  12288. */
  12289. type: {
  12290. /**
  12291. * Type detection functions.
  12292. *
  12293. * The functions defined in this object are used to automatically detect
  12294. * a column's type, making initialisation of DataTables super easy, even
  12295. * when complex data is in the table.
  12296. *
  12297. * The functions defined take two parameters:
  12298. *
  12299. * 1. `{*}` Data from the column cell to be analysed
  12300. * 2. `{settings}` DataTables settings object. This can be used to
  12301. * perform context specific type detection - for example detection
  12302. * based on language settings such as using a comma for a decimal
  12303. * place. Generally speaking the options from the settings will not
  12304. * be required
  12305. *
  12306. * Each function is expected to return:
  12307. *
  12308. * * `{string|null}` Data type detected, or null if unknown (and thus
  12309. * pass it on to the other type detection functions.
  12310. *
  12311. * @type array
  12312. *
  12313. * @example
  12314. * // Currency type detection plug-in:
  12315. * $.fn.dataTable.ext.type.detect.push(
  12316. * function ( data, settings ) {
  12317. * // Check the numeric part
  12318. * if ( ! $.isNumeric( data.substring(1) ) ) {
  12319. * return null;
  12320. * }
  12321. *
  12322. * // Check prefixed by currency
  12323. * if ( data.charAt(0) == '$' || data.charAt(0) == '&pound;' ) {
  12324. * return 'currency';
  12325. * }
  12326. * return null;
  12327. * }
  12328. * );
  12329. */
  12330. detect: [],
  12331. /**
  12332. * Type based search formatting.
  12333. *
  12334. * The type based searching functions can be used to pre-format the
  12335. * data to be search on. For example, it can be used to strip HTML
  12336. * tags or to de-format telephone numbers for numeric only searching.
  12337. *
  12338. * Note that is a search is not defined for a column of a given type,
  12339. * no search formatting will be performed.
  12340. *
  12341. * Pre-processing of searching data plug-ins - When you assign the sType
  12342. * for a column (or have it automatically detected for you by DataTables
  12343. * or a type detection plug-in), you will typically be using this for
  12344. * custom sorting, but it can also be used to provide custom searching
  12345. * by allowing you to pre-processing the data and returning the data in
  12346. * the format that should be searched upon. This is done by adding
  12347. * functions this object with a parameter name which matches the sType
  12348. * for that target column. This is the corollary of <i>afnSortData</i>
  12349. * for searching data.
  12350. *
  12351. * The functions defined take a single parameter:
  12352. *
  12353. * 1. `{*}` Data from the column cell to be prepared for searching
  12354. *
  12355. * Each function is expected to return:
  12356. *
  12357. * * `{string|null}` Formatted string that will be used for the searching.
  12358. *
  12359. * @type object
  12360. * @default {}
  12361. *
  12362. * @example
  12363. * $.fn.dataTable.ext.type.search['title-numeric'] = function ( d ) {
  12364. * return d.replace(/\n/g," ").replace( /<.*?>/g, "" );
  12365. * }
  12366. */
  12367. search: {},
  12368. /**
  12369. * Type based ordering.
  12370. *
  12371. * The column type tells DataTables what ordering to apply to the table
  12372. * when a column is sorted upon. The order for each type that is defined,
  12373. * is defined by the functions available in this object.
  12374. *
  12375. * Each ordering option can be described by three properties added to
  12376. * this object:
  12377. *
  12378. * * `{type}-pre` - Pre-formatting function
  12379. * * `{type}-asc` - Ascending order function
  12380. * * `{type}-desc` - Descending order function
  12381. *
  12382. * All three can be used together, only `{type}-pre` or only
  12383. * `{type}-asc` and `{type}-desc` together. It is generally recommended
  12384. * that only `{type}-pre` is used, as this provides the optimal
  12385. * implementation in terms of speed, although the others are provided
  12386. * for compatibility with existing Javascript sort functions.
  12387. *
  12388. * `{type}-pre`: Functions defined take a single parameter:
  12389. *
  12390. * 1. `{*}` Data from the column cell to be prepared for ordering
  12391. *
  12392. * And return:
  12393. *
  12394. * * `{*}` Data to be sorted upon
  12395. *
  12396. * `{type}-asc` and `{type}-desc`: Functions are typical Javascript sort
  12397. * functions, taking two parameters:
  12398. *
  12399. * 1. `{*}` Data to compare to the second parameter
  12400. * 2. `{*}` Data to compare to the first parameter
  12401. *
  12402. * And returning:
  12403. *
  12404. * * `{*}` Ordering match: <0 if first parameter should be sorted lower
  12405. * than the second parameter, ===0 if the two parameters are equal and
  12406. * >0 if the first parameter should be sorted height than the second
  12407. * parameter.
  12408. *
  12409. * @type object
  12410. * @default {}
  12411. *
  12412. * @example
  12413. * // Numeric ordering of formatted numbers with a pre-formatter
  12414. * $.extend( $.fn.dataTable.ext.type.order, {
  12415. * "string-pre": function(x) {
  12416. * a = (a === "-" || a === "") ? 0 : a.replace( /[^\d\-\.]/g, "" );
  12417. * return parseFloat( a );
  12418. * }
  12419. * } );
  12420. *
  12421. * @example
  12422. * // Case-sensitive string ordering, with no pre-formatting method
  12423. * $.extend( $.fn.dataTable.ext.order, {
  12424. * "string-case-asc": function(x,y) {
  12425. * return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12426. * },
  12427. * "string-case-desc": function(x,y) {
  12428. * return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12429. * }
  12430. * } );
  12431. */
  12432. order: {}
  12433. },
  12434. /**
  12435. * Unique DataTables instance counter
  12436. *
  12437. * @type int
  12438. * @private
  12439. */
  12440. _unique: 0,
  12441. //
  12442. // Depreciated
  12443. // The following properties are retained for backwards compatiblity only.
  12444. // The should not be used in new projects and will be removed in a future
  12445. // version
  12446. //
  12447. /**
  12448. * Version check function.
  12449. * @type function
  12450. * @depreciated Since 1.10
  12451. */
  12452. fnVersionCheck: DataTable.fnVersionCheck,
  12453. /**
  12454. * Index for what 'this' index API functions should use
  12455. * @type int
  12456. * @deprecated Since v1.10
  12457. */
  12458. iApiIndex: 0,
  12459. /**
  12460. * jQuery UI class container
  12461. * @type object
  12462. * @deprecated Since v1.10
  12463. */
  12464. oJUIClasses: {},
  12465. /**
  12466. * Software version
  12467. * @type string
  12468. * @deprecated Since v1.10
  12469. */
  12470. sVersion: DataTable.version
  12471. };
  12472. //
  12473. // Backwards compatibility. Alias to pre 1.10 Hungarian notation counter parts
  12474. //
  12475. $.extend( _ext, {
  12476. afnFiltering: _ext.search,
  12477. aTypes: _ext.type.detect,
  12478. ofnSearch: _ext.type.search,
  12479. oSort: _ext.type.order,
  12480. afnSortData: _ext.order,
  12481. aoFeatures: _ext.feature,
  12482. oApi: _ext.internal,
  12483. oStdClasses: _ext.classes,
  12484. oPagination: _ext.pager
  12485. } );
  12486. $.extend( DataTable.ext.classes, {
  12487. "sTable": "dataTable",
  12488. "sNoFooter": "no-footer",
  12489. /* Paging buttons */
  12490. "sPageButton": "paginate_button",
  12491. "sPageButtonActive": "current",
  12492. "sPageButtonDisabled": "disabled",
  12493. /* Striping classes */
  12494. "sStripeOdd": "odd",
  12495. "sStripeEven": "even",
  12496. /* Empty row */
  12497. "sRowEmpty": "dataTables_empty",
  12498. /* Features */
  12499. "sWrapper": "dataTables_wrapper",
  12500. "sFilter": "dataTables_filter",
  12501. "sInfo": "dataTables_info",
  12502. "sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */
  12503. "sLength": "dataTables_length",
  12504. "sProcessing": "dataTables_processing",
  12505. /* Sorting */
  12506. "sSortAsc": "sorting_asc",
  12507. "sSortDesc": "sorting_desc",
  12508. "sSortable": "sorting", /* Sortable in both directions */
  12509. "sSortableAsc": "sorting_asc_disabled",
  12510. "sSortableDesc": "sorting_desc_disabled",
  12511. "sSortableNone": "sorting_disabled",
  12512. "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
  12513. /* Filtering */
  12514. "sFilterInput": "",
  12515. /* Page length */
  12516. "sLengthSelect": "",
  12517. /* Scrolling */
  12518. "sScrollWrapper": "dataTables_scroll",
  12519. "sScrollHead": "dataTables_scrollHead",
  12520. "sScrollHeadInner": "dataTables_scrollHeadInner",
  12521. "sScrollBody": "dataTables_scrollBody",
  12522. "sScrollFoot": "dataTables_scrollFoot",
  12523. "sScrollFootInner": "dataTables_scrollFootInner",
  12524. /* Misc */
  12525. "sHeaderTH": "",
  12526. "sFooterTH": "",
  12527. // Deprecated
  12528. "sSortJUIAsc": "",
  12529. "sSortJUIDesc": "",
  12530. "sSortJUI": "",
  12531. "sSortJUIAscAllowed": "",
  12532. "sSortJUIDescAllowed": "",
  12533. "sSortJUIWrapper": "",
  12534. "sSortIcon": "",
  12535. "sJUIHeader": "",
  12536. "sJUIFooter": ""
  12537. } );
  12538. var extPagination = DataTable.ext.pager;
  12539. function _numbers ( page, pages ) {
  12540. var
  12541. numbers = [],
  12542. buttons = extPagination.numbers_length,
  12543. half = Math.floor( buttons / 2 ),
  12544. i = 1;
  12545. if ( pages <= buttons ) {
  12546. numbers = _range( 0, pages );
  12547. }
  12548. else if ( page <= half ) {
  12549. numbers = _range( 0, buttons-2 );
  12550. numbers.push( 'ellipsis' );
  12551. numbers.push( pages-1 );
  12552. }
  12553. else if ( page >= pages - 1 - half ) {
  12554. numbers = _range( pages-(buttons-2), pages );
  12555. numbers.splice( 0, 0, 'ellipsis' ); // no unshift in ie6
  12556. numbers.splice( 0, 0, 0 );
  12557. }
  12558. else {
  12559. numbers = _range( page-half+2, page+half-1 );
  12560. numbers.push( 'ellipsis' );
  12561. numbers.push( pages-1 );
  12562. numbers.splice( 0, 0, 'ellipsis' );
  12563. numbers.splice( 0, 0, 0 );
  12564. }
  12565. numbers.DT_el = 'span';
  12566. return numbers;
  12567. }
  12568. $.extend( extPagination, {
  12569. simple: function ( page, pages ) {
  12570. return [ 'previous', 'next' ];
  12571. },
  12572. full: function ( page, pages ) {
  12573. return [ 'first', 'previous', 'next', 'last' ];
  12574. },
  12575. numbers: function ( page, pages ) {
  12576. return [ _numbers(page, pages) ];
  12577. },
  12578. simple_numbers: function ( page, pages ) {
  12579. return [ 'previous', _numbers(page, pages), 'next' ];
  12580. },
  12581. full_numbers: function ( page, pages ) {
  12582. return [ 'first', 'previous', _numbers(page, pages), 'next', 'last' ];
  12583. },
  12584. first_last_numbers: function (page, pages) {
  12585. return ['first', _numbers(page, pages), 'last'];
  12586. },
  12587. // For testing and plug-ins to use
  12588. _numbers: _numbers,
  12589. // Number of number buttons (including ellipsis) to show. _Must be odd!_
  12590. numbers_length: 7
  12591. } );
  12592. $.extend( true, DataTable.ext.renderer, {
  12593. pageButton: {
  12594. _: function ( settings, host, idx, buttons, page, pages ) {
  12595. var classes = settings.oClasses;
  12596. var lang = settings.oLanguage.oPaginate;
  12597. var aria = settings.oLanguage.oAria.paginate || {};
  12598. var btnDisplay, btnClass, counter=0;
  12599. var attach = function( container, buttons ) {
  12600. var i, ien, node, button;
  12601. var clickHandler = function ( e ) {
  12602. _fnPageChange( settings, e.data.action, true );
  12603. };
  12604. for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
  12605. button = buttons[i];
  12606. if ( $.isArray( button ) ) {
  12607. var inner = $( '<'+(button.DT_el || 'div')+'/>' )
  12608. .appendTo( container );
  12609. attach( inner, button );
  12610. }
  12611. else {
  12612. btnDisplay = null;
  12613. btnClass = '';
  12614. switch ( button ) {
  12615. case 'ellipsis':
  12616. container.append('<span class="ellipsis">&#x2026;</span>');
  12617. break;
  12618. case 'first':
  12619. btnDisplay = lang.sFirst;
  12620. btnClass = button + (page > 0 ?
  12621. '' : ' '+classes.sPageButtonDisabled);
  12622. break;
  12623. case 'previous':
  12624. btnDisplay = lang.sPrevious;
  12625. btnClass = button + (page > 0 ?
  12626. '' : ' '+classes.sPageButtonDisabled);
  12627. break;
  12628. case 'next':
  12629. btnDisplay = lang.sNext;
  12630. btnClass = button + (page < pages-1 ?
  12631. '' : ' '+classes.sPageButtonDisabled);
  12632. break;
  12633. case 'last':
  12634. btnDisplay = lang.sLast;
  12635. btnClass = button + (page < pages-1 ?
  12636. '' : ' '+classes.sPageButtonDisabled);
  12637. break;
  12638. default:
  12639. btnDisplay = button + 1;
  12640. btnClass = page === button ?
  12641. classes.sPageButtonActive : '';
  12642. break;
  12643. }
  12644. if ( btnDisplay !== null ) {
  12645. node = $('<a>', {
  12646. 'class': classes.sPageButton+' '+btnClass,
  12647. 'aria-controls': settings.sTableId,
  12648. 'aria-label': aria[ button ],
  12649. 'data-dt-idx': counter,
  12650. 'tabindex': settings.iTabIndex,
  12651. 'id': idx === 0 && typeof button === 'string' ?
  12652. settings.sTableId +'_'+ button :
  12653. null
  12654. } )
  12655. .html( btnDisplay )
  12656. .appendTo( container );
  12657. _fnBindAction(
  12658. node, {action: button}, clickHandler
  12659. );
  12660. counter++;
  12661. }
  12662. }
  12663. }
  12664. };
  12665. // IE9 throws an 'unknown error' if document.activeElement is used
  12666. // inside an iframe or frame. Try / catch the error. Not good for
  12667. // accessibility, but neither are frames.
  12668. var activeEl;
  12669. try {
  12670. // Because this approach is destroying and recreating the paging
  12671. // elements, focus is lost on the select button which is bad for
  12672. // accessibility. So we want to restore focus once the draw has
  12673. // completed
  12674. activeEl = $(host).find(document.activeElement).data('dt-idx');
  12675. }
  12676. catch (e) {}
  12677. attach( $(host).empty(), buttons );
  12678. if ( activeEl !== undefined ) {
  12679. $(host).find( '[data-dt-idx='+activeEl+']' ).focus();
  12680. }
  12681. }
  12682. }
  12683. } );
  12684. // Built in type detection. See model.ext.aTypes for information about
  12685. // what is required from this methods.
  12686. $.extend( DataTable.ext.type.detect, [
  12687. // Plain numbers - first since V8 detects some plain numbers as dates
  12688. // e.g. Date.parse('55') (but not all, e.g. Date.parse('22')...).
  12689. function ( d, settings )
  12690. {
  12691. var decimal = settings.oLanguage.sDecimal;
  12692. return _isNumber( d, decimal ) ? 'num'+decimal : null;
  12693. },
  12694. // Dates (only those recognised by the browser's Date.parse)
  12695. function ( d, settings )
  12696. {
  12697. // V8 tries _very_ hard to make a string passed into `Date.parse()`
  12698. // valid, so we need to use a regex to restrict date formats. Use a
  12699. // plug-in for anything other than ISO8601 style strings
  12700. if ( d && !(d instanceof Date) && ! _re_date.test(d) ) {
  12701. return null;
  12702. }
  12703. var parsed = Date.parse(d);
  12704. return (parsed !== null && !isNaN(parsed)) || _empty(d) ? 'date' : null;
  12705. },
  12706. // Formatted numbers
  12707. function ( d, settings )
  12708. {
  12709. var decimal = settings.oLanguage.sDecimal;
  12710. return _isNumber( d, decimal, true ) ? 'num-fmt'+decimal : null;
  12711. },
  12712. // HTML numeric
  12713. function ( d, settings )
  12714. {
  12715. var decimal = settings.oLanguage.sDecimal;
  12716. return _htmlNumeric( d, decimal ) ? 'html-num'+decimal : null;
  12717. },
  12718. // HTML numeric, formatted
  12719. function ( d, settings )
  12720. {
  12721. var decimal = settings.oLanguage.sDecimal;
  12722. return _htmlNumeric( d, decimal, true ) ? 'html-num-fmt'+decimal : null;
  12723. },
  12724. // HTML (this is strict checking - there must be html)
  12725. function ( d, settings )
  12726. {
  12727. return _empty( d ) || (typeof d === 'string' && d.indexOf('<') !== -1) ?
  12728. 'html' : null;
  12729. }
  12730. ] );
  12731. // Filter formatting functions. See model.ext.ofnSearch for information about
  12732. // what is required from these methods.
  12733. //
  12734. // Note that additional search methods are added for the html numbers and
  12735. // html formatted numbers by `_addNumericSort()` when we know what the decimal
  12736. // place is
  12737. $.extend( DataTable.ext.type.search, {
  12738. html: function ( data ) {
  12739. return _empty(data) ?
  12740. data :
  12741. typeof data === 'string' ?
  12742. data
  12743. .replace( _re_new_lines, " " )
  12744. .replace( _re_html, "" ) :
  12745. '';
  12746. },
  12747. string: function ( data ) {
  12748. return _empty(data) ?
  12749. data :
  12750. typeof data === 'string' ?
  12751. data.replace( _re_new_lines, " " ) :
  12752. data;
  12753. }
  12754. } );
  12755. var __numericReplace = function ( d, decimalPlace, re1, re2 ) {
  12756. if ( d !== 0 && (!d || d === '-') ) {
  12757. return -Infinity;
  12758. }
  12759. // If a decimal place other than `.` is used, it needs to be given to the
  12760. // function so we can detect it and replace with a `.` which is the only
  12761. // decimal place Javascript recognises - it is not locale aware.
  12762. if ( decimalPlace ) {
  12763. d = _numToDecimal( d, decimalPlace );
  12764. }
  12765. if ( d.replace ) {
  12766. if ( re1 ) {
  12767. d = d.replace( re1, '' );
  12768. }
  12769. if ( re2 ) {
  12770. d = d.replace( re2, '' );
  12771. }
  12772. }
  12773. return d * 1;
  12774. };
  12775. // Add the numeric 'deformatting' functions for sorting and search. This is done
  12776. // in a function to provide an easy ability for the language options to add
  12777. // additional methods if a non-period decimal place is used.
  12778. function _addNumericSort ( decimalPlace ) {
  12779. $.each(
  12780. {
  12781. // Plain numbers
  12782. "num": function ( d ) {
  12783. return __numericReplace( d, decimalPlace );
  12784. },
  12785. // Formatted numbers
  12786. "num-fmt": function ( d ) {
  12787. return __numericReplace( d, decimalPlace, _re_formatted_numeric );
  12788. },
  12789. // HTML numeric
  12790. "html-num": function ( d ) {
  12791. return __numericReplace( d, decimalPlace, _re_html );
  12792. },
  12793. // HTML numeric, formatted
  12794. "html-num-fmt": function ( d ) {
  12795. return __numericReplace( d, decimalPlace, _re_html, _re_formatted_numeric );
  12796. }
  12797. },
  12798. function ( key, fn ) {
  12799. // Add the ordering method
  12800. _ext.type.order[ key+decimalPlace+'-pre' ] = fn;
  12801. // For HTML types add a search formatter that will strip the HTML
  12802. if ( key.match(/^html\-/) ) {
  12803. _ext.type.search[ key+decimalPlace ] = _ext.type.search.html;
  12804. }
  12805. }
  12806. );
  12807. }
  12808. // Default sort methods
  12809. $.extend( _ext.type.order, {
  12810. // Dates
  12811. "date-pre": function ( d ) {
  12812. return Date.parse( d ) || -Infinity;
  12813. },
  12814. // html
  12815. "html-pre": function ( a ) {
  12816. return _empty(a) ?
  12817. '' :
  12818. a.replace ?
  12819. a.replace( /<.*?>/g, "" ).toLowerCase() :
  12820. a+'';
  12821. },
  12822. // string
  12823. "string-pre": function ( a ) {
  12824. // This is a little complex, but faster than always calling toString,
  12825. // http://jsperf.com/tostring-v-check
  12826. return _empty(a) ?
  12827. '' :
  12828. typeof a === 'string' ?
  12829. a.toLowerCase() :
  12830. ! a.toString ?
  12831. '' :
  12832. a.toString();
  12833. },
  12834. // string-asc and -desc are retained only for compatibility with the old
  12835. // sort methods
  12836. "string-asc": function ( x, y ) {
  12837. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12838. },
  12839. "string-desc": function ( x, y ) {
  12840. return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12841. }
  12842. } );
  12843. // Numeric sorting types - order doesn't matter here
  12844. _addNumericSort( '' );
  12845. $.extend( true, DataTable.ext.renderer, {
  12846. header: {
  12847. _: function ( settings, cell, column, classes ) {
  12848. // No additional mark-up required
  12849. // Attach a sort listener to update on sort - note that using the
  12850. // `DT` namespace will allow the event to be removed automatically
  12851. // on destroy, while the `dt` namespaced event is the one we are
  12852. // listening for
  12853. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  12854. if ( settings !== ctx ) { // need to check this this is the host
  12855. return; // table, not a nested one
  12856. }
  12857. var colIdx = column.idx;
  12858. cell
  12859. .removeClass(
  12860. column.sSortingClass +' '+
  12861. classes.sSortAsc +' '+
  12862. classes.sSortDesc
  12863. )
  12864. .addClass( columns[ colIdx ] == 'asc' ?
  12865. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  12866. classes.sSortDesc :
  12867. column.sSortingClass
  12868. );
  12869. } );
  12870. },
  12871. jqueryui: function ( settings, cell, column, classes ) {
  12872. $('<div/>')
  12873. .addClass( classes.sSortJUIWrapper )
  12874. .append( cell.contents() )
  12875. .append( $('<span/>')
  12876. .addClass( classes.sSortIcon+' '+column.sSortingClassJUI )
  12877. )
  12878. .appendTo( cell );
  12879. // Attach a sort listener to update on sort
  12880. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  12881. if ( settings !== ctx ) {
  12882. return;
  12883. }
  12884. var colIdx = column.idx;
  12885. cell
  12886. .removeClass( classes.sSortAsc +" "+classes.sSortDesc )
  12887. .addClass( columns[ colIdx ] == 'asc' ?
  12888. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  12889. classes.sSortDesc :
  12890. column.sSortingClass
  12891. );
  12892. cell
  12893. .find( 'span.'+classes.sSortIcon )
  12894. .removeClass(
  12895. classes.sSortJUIAsc +" "+
  12896. classes.sSortJUIDesc +" "+
  12897. classes.sSortJUI +" "+
  12898. classes.sSortJUIAscAllowed +" "+
  12899. classes.sSortJUIDescAllowed
  12900. )
  12901. .addClass( columns[ colIdx ] == 'asc' ?
  12902. classes.sSortJUIAsc : columns[ colIdx ] == 'desc' ?
  12903. classes.sSortJUIDesc :
  12904. column.sSortingClassJUI
  12905. );
  12906. } );
  12907. }
  12908. }
  12909. } );
  12910. /*
  12911. * Public helper functions. These aren't used internally by DataTables, or
  12912. * called by any of the options passed into DataTables, but they can be used
  12913. * externally by developers working with DataTables. They are helper functions
  12914. * to make working with DataTables a little bit easier.
  12915. */
  12916. var __htmlEscapeEntities = function ( d ) {
  12917. return typeof d === 'string' ?
  12918. d.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;') :
  12919. d;
  12920. };
  12921. /**
  12922. * Helpers for `columns.render`.
  12923. *
  12924. * The options defined here can be used with the `columns.render` initialisation
  12925. * option to provide a display renderer. The following functions are defined:
  12926. *
  12927. * * `number` - Will format numeric data (defined by `columns.data`) for
  12928. * display, retaining the original unformatted data for sorting and filtering.
  12929. * It takes 5 parameters:
  12930. * * `string` - Thousands grouping separator
  12931. * * `string` - Decimal point indicator
  12932. * * `integer` - Number of decimal points to show
  12933. * * `string` (optional) - Prefix.
  12934. * * `string` (optional) - Postfix (/suffix).
  12935. * * `text` - Escape HTML to help prevent XSS attacks. It has no optional
  12936. * parameters.
  12937. *
  12938. * @example
  12939. * // Column definition using the number renderer
  12940. * {
  12941. * data: "salary",
  12942. * render: $.fn.dataTable.render.number( '\'', '.', 0, '$' )
  12943. * }
  12944. *
  12945. * @namespace
  12946. */
  12947. DataTable.render = {
  12948. number: function ( thousands, decimal, precision, prefix, postfix ) {
  12949. return {
  12950. display: function ( d ) {
  12951. if ( typeof d !== 'number' && typeof d !== 'string' ) {
  12952. return d;
  12953. }
  12954. var negative = d < 0 ? '-' : '';
  12955. var flo = parseFloat( d );
  12956. // If NaN then there isn't much formatting that we can do - just
  12957. // return immediately, escaping any HTML (this was supposed to
  12958. // be a number after all)
  12959. if ( isNaN( flo ) ) {
  12960. return __htmlEscapeEntities( d );
  12961. }
  12962. flo = flo.toFixed( precision );
  12963. d = Math.abs( flo );
  12964. var intPart = parseInt( d, 10 );
  12965. var floatPart = precision ?
  12966. decimal+(d - intPart).toFixed( precision ).substring( 2 ):
  12967. '';
  12968. return negative + (prefix||'') +
  12969. intPart.toString().replace(
  12970. /\B(?=(\d{3})+(?!\d))/g, thousands
  12971. ) +
  12972. floatPart +
  12973. (postfix||'');
  12974. }
  12975. };
  12976. },
  12977. text: function () {
  12978. return {
  12979. display: __htmlEscapeEntities
  12980. };
  12981. }
  12982. };
  12983. /*
  12984. * This is really a good bit rubbish this method of exposing the internal methods
  12985. * publicly... - To be fixed in 2.0 using methods on the prototype
  12986. */
  12987. /**
  12988. * Create a wrapper function for exporting an internal functions to an external API.
  12989. * @param {string} fn API function name
  12990. * @returns {function} wrapped function
  12991. * @memberof DataTable#internal
  12992. */
  12993. function _fnExternApiFunc (fn)
  12994. {
  12995. return function() {
  12996. var args = [_fnSettingsFromNode( this[DataTable.ext.iApiIndex] )].concat(
  12997. Array.prototype.slice.call(arguments)
  12998. );
  12999. return DataTable.ext.internal[fn].apply( this, args );
  13000. };
  13001. }
  13002. /**
  13003. * Reference to internal functions for use by plug-in developers. Note that
  13004. * these methods are references to internal functions and are considered to be
  13005. * private. If you use these methods, be aware that they are liable to change
  13006. * between versions.
  13007. * @namespace
  13008. */
  13009. $.extend( DataTable.ext.internal, {
  13010. _fnExternApiFunc: _fnExternApiFunc,
  13011. _fnBuildAjax: _fnBuildAjax,
  13012. _fnAjaxUpdate: _fnAjaxUpdate,
  13013. _fnAjaxParameters: _fnAjaxParameters,
  13014. _fnAjaxUpdateDraw: _fnAjaxUpdateDraw,
  13015. _fnAjaxDataSrc: _fnAjaxDataSrc,
  13016. _fnAddColumn: _fnAddColumn,
  13017. _fnColumnOptions: _fnColumnOptions,
  13018. _fnAdjustColumnSizing: _fnAdjustColumnSizing,
  13019. _fnVisibleToColumnIndex: _fnVisibleToColumnIndex,
  13020. _fnColumnIndexToVisible: _fnColumnIndexToVisible,
  13021. _fnVisbleColumns: _fnVisbleColumns,
  13022. _fnGetColumns: _fnGetColumns,
  13023. _fnColumnTypes: _fnColumnTypes,
  13024. _fnApplyColumnDefs: _fnApplyColumnDefs,
  13025. _fnHungarianMap: _fnHungarianMap,
  13026. _fnCamelToHungarian: _fnCamelToHungarian,
  13027. _fnLanguageCompat: _fnLanguageCompat,
  13028. _fnBrowserDetect: _fnBrowserDetect,
  13029. _fnAddData: _fnAddData,
  13030. _fnAddTr: _fnAddTr,
  13031. _fnNodeToDataIndex: _fnNodeToDataIndex,
  13032. _fnNodeToColumnIndex: _fnNodeToColumnIndex,
  13033. _fnGetCellData: _fnGetCellData,
  13034. _fnSetCellData: _fnSetCellData,
  13035. _fnSplitObjNotation: _fnSplitObjNotation,
  13036. _fnGetObjectDataFn: _fnGetObjectDataFn,
  13037. _fnSetObjectDataFn: _fnSetObjectDataFn,
  13038. _fnGetDataMaster: _fnGetDataMaster,
  13039. _fnClearTable: _fnClearTable,
  13040. _fnDeleteIndex: _fnDeleteIndex,
  13041. _fnInvalidate: _fnInvalidate,
  13042. _fnGetRowElements: _fnGetRowElements,
  13043. _fnCreateTr: _fnCreateTr,
  13044. _fnBuildHead: _fnBuildHead,
  13045. _fnDrawHead: _fnDrawHead,
  13046. _fnDraw: _fnDraw,
  13047. _fnReDraw: _fnReDraw,
  13048. _fnAddOptionsHtml: _fnAddOptionsHtml,
  13049. _fnDetectHeader: _fnDetectHeader,
  13050. _fnGetUniqueThs: _fnGetUniqueThs,
  13051. _fnFeatureHtmlFilter: _fnFeatureHtmlFilter,
  13052. _fnFilterComplete: _fnFilterComplete,
  13053. _fnFilterCustom: _fnFilterCustom,
  13054. _fnFilterColumn: _fnFilterColumn,
  13055. _fnFilter: _fnFilter,
  13056. _fnFilterCreateSearch: _fnFilterCreateSearch,
  13057. _fnEscapeRegex: _fnEscapeRegex,
  13058. _fnFilterData: _fnFilterData,
  13059. _fnFeatureHtmlInfo: _fnFeatureHtmlInfo,
  13060. _fnUpdateInfo: _fnUpdateInfo,
  13061. _fnInfoMacros: _fnInfoMacros,
  13062. _fnInitialise: _fnInitialise,
  13063. _fnInitComplete: _fnInitComplete,
  13064. _fnLengthChange: _fnLengthChange,
  13065. _fnFeatureHtmlLength: _fnFeatureHtmlLength,
  13066. _fnFeatureHtmlPaginate: _fnFeatureHtmlPaginate,
  13067. _fnPageChange: _fnPageChange,
  13068. _fnFeatureHtmlProcessing: _fnFeatureHtmlProcessing,
  13069. _fnProcessingDisplay: _fnProcessingDisplay,
  13070. _fnFeatureHtmlTable: _fnFeatureHtmlTable,
  13071. _fnScrollDraw: _fnScrollDraw,
  13072. _fnApplyToChildren: _fnApplyToChildren,
  13073. _fnCalculateColumnWidths: _fnCalculateColumnWidths,
  13074. _fnThrottle: _fnThrottle,
  13075. _fnConvertToWidth: _fnConvertToWidth,
  13076. _fnGetWidestNode: _fnGetWidestNode,
  13077. _fnGetMaxLenString: _fnGetMaxLenString,
  13078. _fnStringToCss: _fnStringToCss,
  13079. _fnSortFlatten: _fnSortFlatten,
  13080. _fnSort: _fnSort,
  13081. _fnSortAria: _fnSortAria,
  13082. _fnSortListener: _fnSortListener,
  13083. _fnSortAttachListener: _fnSortAttachListener,
  13084. _fnSortingClasses: _fnSortingClasses,
  13085. _fnSortData: _fnSortData,
  13086. _fnSaveState: _fnSaveState,
  13087. _fnLoadState: _fnLoadState,
  13088. _fnSettingsFromNode: _fnSettingsFromNode,
  13089. _fnLog: _fnLog,
  13090. _fnMap: _fnMap,
  13091. _fnBindAction: _fnBindAction,
  13092. _fnCallbackReg: _fnCallbackReg,
  13093. _fnCallbackFire: _fnCallbackFire,
  13094. _fnLengthOverflow: _fnLengthOverflow,
  13095. _fnRenderer: _fnRenderer,
  13096. _fnDataSource: _fnDataSource,
  13097. _fnRowAttributes: _fnRowAttributes,
  13098. _fnCalculateEnd: function () {} // Used by a lot of plug-ins, but redundant
  13099. // in 1.10, so this dead-end function is
  13100. // added to prevent errors
  13101. } );
  13102. // jQuery access
  13103. $.fn.dataTable = DataTable;
  13104. // Provide access to the host jQuery object (circular reference)
  13105. DataTable.$ = $;
  13106. // Legacy aliases
  13107. $.fn.dataTableSettings = DataTable.settings;
  13108. $.fn.dataTableExt = DataTable.ext;
  13109. // With a capital `D` we return a DataTables API instance rather than a
  13110. // jQuery object
  13111. $.fn.DataTable = function ( opts ) {
  13112. return $(this).dataTable( opts ).api();
  13113. };
  13114. // All properties that are available to $.fn.dataTable should also be
  13115. // available on $.fn.DataTable
  13116. $.each( DataTable, function ( prop, val ) {
  13117. $.fn.DataTable[ prop ] = val;
  13118. } );
  13119. // Information about events fired by DataTables - for documentation.
  13120. /**
  13121. * Draw event, fired whenever the table is redrawn on the page, at the same
  13122. * point as fnDrawCallback. This may be useful for binding events or
  13123. * performing calculations when the table is altered at all.
  13124. * @name DataTable#draw.dt
  13125. * @event
  13126. * @param {event} e jQuery event object
  13127. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13128. */
  13129. /**
  13130. * Search event, fired when the searching applied to the table (using the
  13131. * built-in global search, or column filters) is altered.
  13132. * @name DataTable#search.dt
  13133. * @event
  13134. * @param {event} e jQuery event object
  13135. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13136. */
  13137. /**
  13138. * Page change event, fired when the paging of the table is altered.
  13139. * @name DataTable#page.dt
  13140. * @event
  13141. * @param {event} e jQuery event object
  13142. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13143. */
  13144. /**
  13145. * Order event, fired when the ordering applied to the table is altered.
  13146. * @name DataTable#order.dt
  13147. * @event
  13148. * @param {event} e jQuery event object
  13149. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13150. */
  13151. /**
  13152. * DataTables initialisation complete event, fired when the table is fully
  13153. * drawn, including Ajax data loaded, if Ajax data is required.
  13154. * @name DataTable#init.dt
  13155. * @event
  13156. * @param {event} e jQuery event object
  13157. * @param {object} oSettings DataTables settings object
  13158. * @param {object} json The JSON object request from the server - only
  13159. * present if client-side Ajax sourced data is used</li></ol>
  13160. */
  13161. /**
  13162. * State save event, fired when the table has changed state a new state save
  13163. * is required. This event allows modification of the state saving object
  13164. * prior to actually doing the save, including addition or other state
  13165. * properties (for plug-ins) or modification of a DataTables core property.
  13166. * @name DataTable#stateSaveParams.dt
  13167. * @event
  13168. * @param {event} e jQuery event object
  13169. * @param {object} oSettings DataTables settings object
  13170. * @param {object} json The state information to be saved
  13171. */
  13172. /**
  13173. * State load event, fired when the table is loading state from the stored
  13174. * data, but prior to the settings object being modified by the saved state
  13175. * - allowing modification of the saved state is required or loading of
  13176. * state for a plug-in.
  13177. * @name DataTable#stateLoadParams.dt
  13178. * @event
  13179. * @param {event} e jQuery event object
  13180. * @param {object} oSettings DataTables settings object
  13181. * @param {object} json The saved state information
  13182. */
  13183. /**
  13184. * State loaded event, fired when state has been loaded from stored data and
  13185. * the settings object has been modified by the loaded data.
  13186. * @name DataTable#stateLoaded.dt
  13187. * @event
  13188. * @param {event} e jQuery event object
  13189. * @param {object} oSettings DataTables settings object
  13190. * @param {object} json The saved state information
  13191. */
  13192. /**
  13193. * Processing event, fired when DataTables is doing some kind of processing
  13194. * (be it, order, searcg or anything else). It can be used to indicate to
  13195. * the end user that there is something happening, or that something has
  13196. * finished.
  13197. * @name DataTable#processing.dt
  13198. * @event
  13199. * @param {event} e jQuery event object
  13200. * @param {object} oSettings DataTables settings object
  13201. * @param {boolean} bShow Flag for if DataTables is doing processing or not
  13202. */
  13203. /**
  13204. * Ajax (XHR) event, fired whenever an Ajax request is completed from a
  13205. * request to made to the server for new data. This event is called before
  13206. * DataTables processed the returned data, so it can also be used to pre-
  13207. * process the data returned from the server, if needed.
  13208. *
  13209. * Note that this trigger is called in `fnServerData`, if you override
  13210. * `fnServerData` and which to use this event, you need to trigger it in you
  13211. * success function.
  13212. * @name DataTable#xhr.dt
  13213. * @event
  13214. * @param {event} e jQuery event object
  13215. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13216. * @param {object} json JSON returned from the server
  13217. *
  13218. * @example
  13219. * // Use a custom property returned from the server in another DOM element
  13220. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  13221. * $('#status').html( json.status );
  13222. * } );
  13223. *
  13224. * @example
  13225. * // Pre-process the data returned from the server
  13226. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  13227. * for ( var i=0, ien=json.aaData.length ; i<ien ; i++ ) {
  13228. * json.aaData[i].sum = json.aaData[i].one + json.aaData[i].two;
  13229. * }
  13230. * // Note no return - manipulate the data directly in the JSON object.
  13231. * } );
  13232. */
  13233. /**
  13234. * Destroy event, fired when the DataTable is destroyed by calling fnDestroy
  13235. * or passing the bDestroy:true parameter in the initialisation object. This
  13236. * can be used to remove bound events, added DOM nodes, etc.
  13237. * @name DataTable#destroy.dt
  13238. * @event
  13239. * @param {event} e jQuery event object
  13240. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13241. */
  13242. /**
  13243. * Page length change event, fired when number of records to show on each
  13244. * page (the length) is changed.
  13245. * @name DataTable#length.dt
  13246. * @event
  13247. * @param {event} e jQuery event object
  13248. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13249. * @param {integer} len New length
  13250. */
  13251. /**
  13252. * Column sizing has changed.
  13253. * @name DataTable#column-sizing.dt
  13254. * @event
  13255. * @param {event} e jQuery event object
  13256. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13257. */
  13258. /**
  13259. * Column visibility has changed.
  13260. * @name DataTable#column-visibility.dt
  13261. * @event
  13262. * @param {event} e jQuery event object
  13263. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13264. * @param {int} column Column index
  13265. * @param {bool} vis `false` if column now hidden, or `true` if visible
  13266. */
  13267. return $.fn.dataTable;
  13268. }));