jquery.dataTables.js 440 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383
  1. /*! DataTables 1.10.23
  2. * ©2008-2020 SpryMedia Ltd - datatables.net/license
  3. */
  4. /**
  5. * @summary DataTables
  6. * @description Paginate, search and order HTML tables
  7. * @version 1.10.23
  8. * @file jquery.dataTables.js
  9. * @author SpryMedia Ltd
  10. * @contact www.datatables.net
  11. * @copyright Copyright 2008-2020 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 = Array.isArray(data) && ( Array.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() ), true );
  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 (
  824. s.nTable == this ||
  825. (s.nTHead && s.nTHead.parentNode == this) ||
  826. (s.nTFoot && s.nTFoot.parentNode == this)
  827. ) {
  828. var bRetrieve = oInit.bRetrieve !== undefined ? oInit.bRetrieve : defaults.bRetrieve;
  829. var bDestroy = oInit.bDestroy !== undefined ? oInit.bDestroy : defaults.bDestroy;
  830. if ( emptyInit || bRetrieve )
  831. {
  832. return s.oInstance;
  833. }
  834. else if ( bDestroy )
  835. {
  836. s.oInstance.fnDestroy();
  837. break;
  838. }
  839. else
  840. {
  841. _fnLog( s, 0, 'Cannot reinitialise DataTable', 3 );
  842. return;
  843. }
  844. }
  845. /* If the element we are initialising has the same ID as a table which was previously
  846. * initialised, but the table nodes don't match (from before) then we destroy the old
  847. * instance by simply deleting it. This is under the assumption that the table has been
  848. * destroyed by other methods. Anyone using non-id selectors will need to do this manually
  849. */
  850. if ( s.sTableId == this.id )
  851. {
  852. allSettings.splice( i, 1 );
  853. break;
  854. }
  855. }
  856. /* Ensure the table has an ID - required for accessibility */
  857. if ( sId === null || sId === "" )
  858. {
  859. sId = "DataTables_Table_"+(DataTable.ext._unique++);
  860. this.id = sId;
  861. }
  862. /* Create the settings object for this table and set some of the default parameters */
  863. var oSettings = $.extend( true, {}, DataTable.models.oSettings, {
  864. "sDestroyWidth": $this[0].style.width,
  865. "sInstance": sId,
  866. "sTableId": sId
  867. } );
  868. oSettings.nTable = this;
  869. oSettings.oApi = _that.internal;
  870. oSettings.oInit = oInit;
  871. allSettings.push( oSettings );
  872. // Need to add the instance after the instance after the settings object has been added
  873. // to the settings array, so we can self reference the table instance if more than one
  874. oSettings.oInstance = (_that.length===1) ? _that : $this.dataTable();
  875. // Backwards compatibility, before we apply all the defaults
  876. _fnCompatOpts( oInit );
  877. _fnLanguageCompat( oInit.oLanguage );
  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 = Array.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 = Array.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\u2028]/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. // - Ƀ - Bitcoin
  1207. // - Ξ - Ethereum
  1208. // standards as thousands separators.
  1209. var _re_formatted_numeric = /['\u00A0,$£€¥%\u2009\u202F\u20BD\u20a9\u20BArfkɃΞ]/gi;
  1210. var _empty = function ( d ) {
  1211. return !d || d === true || d === '-' ? true : false;
  1212. };
  1213. var _intVal = function ( s ) {
  1214. var integer = parseInt( s, 10 );
  1215. return !isNaN(integer) && isFinite(s) ? integer : null;
  1216. };
  1217. // Convert from a formatted number with characters other than `.` as the
  1218. // decimal place, to a Javascript number
  1219. var _numToDecimal = function ( num, decimalPoint ) {
  1220. // Cache created regular expressions for speed as this function is called often
  1221. if ( ! _re_dic[ decimalPoint ] ) {
  1222. _re_dic[ decimalPoint ] = new RegExp( _fnEscapeRegex( decimalPoint ), 'g' );
  1223. }
  1224. return typeof num === 'string' && decimalPoint !== '.' ?
  1225. num.replace( /\./g, '' ).replace( _re_dic[ decimalPoint ], '.' ) :
  1226. num;
  1227. };
  1228. var _isNumber = function ( d, decimalPoint, formatted ) {
  1229. var strType = typeof d === 'string';
  1230. // If empty return immediately so there must be a number if it is a
  1231. // formatted string (this stops the string "k", or "kr", etc being detected
  1232. // as a formatted number for currency
  1233. if ( _empty( d ) ) {
  1234. return true;
  1235. }
  1236. if ( decimalPoint && strType ) {
  1237. d = _numToDecimal( d, decimalPoint );
  1238. }
  1239. if ( formatted && strType ) {
  1240. d = d.replace( _re_formatted_numeric, '' );
  1241. }
  1242. return !isNaN( parseFloat(d) ) && isFinite( d );
  1243. };
  1244. // A string without HTML in it can be considered to be HTML still
  1245. var _isHtml = function ( d ) {
  1246. return _empty( d ) || typeof d === 'string';
  1247. };
  1248. var _htmlNumeric = function ( d, decimalPoint, formatted ) {
  1249. if ( _empty( d ) ) {
  1250. return true;
  1251. }
  1252. var html = _isHtml( d );
  1253. return ! html ?
  1254. null :
  1255. _isNumber( _stripHtml( d ), decimalPoint, formatted ) ?
  1256. true :
  1257. null;
  1258. };
  1259. var _pluck = function ( a, prop, prop2 ) {
  1260. var out = [];
  1261. var i=0, ien=a.length;
  1262. // Could have the test in the loop for slightly smaller code, but speed
  1263. // is essential here
  1264. if ( prop2 !== undefined ) {
  1265. for ( ; i<ien ; i++ ) {
  1266. if ( a[i] && a[i][ prop ] ) {
  1267. out.push( a[i][ prop ][ prop2 ] );
  1268. }
  1269. }
  1270. }
  1271. else {
  1272. for ( ; i<ien ; i++ ) {
  1273. if ( a[i] ) {
  1274. out.push( a[i][ prop ] );
  1275. }
  1276. }
  1277. }
  1278. return out;
  1279. };
  1280. // Basically the same as _pluck, but rather than looping over `a` we use `order`
  1281. // as the indexes to pick from `a`
  1282. var _pluck_order = function ( a, order, prop, prop2 )
  1283. {
  1284. var out = [];
  1285. var i=0, ien=order.length;
  1286. // Could have the test in the loop for slightly smaller code, but speed
  1287. // is essential here
  1288. if ( prop2 !== undefined ) {
  1289. for ( ; i<ien ; i++ ) {
  1290. if ( a[ order[i] ][ prop ] ) {
  1291. out.push( a[ order[i] ][ prop ][ prop2 ] );
  1292. }
  1293. }
  1294. }
  1295. else {
  1296. for ( ; i<ien ; i++ ) {
  1297. out.push( a[ order[i] ][ prop ] );
  1298. }
  1299. }
  1300. return out;
  1301. };
  1302. var _range = function ( len, start )
  1303. {
  1304. var out = [];
  1305. var end;
  1306. if ( start === undefined ) {
  1307. start = 0;
  1308. end = len;
  1309. }
  1310. else {
  1311. end = start;
  1312. start = len;
  1313. }
  1314. for ( var i=start ; i<end ; i++ ) {
  1315. out.push( i );
  1316. }
  1317. return out;
  1318. };
  1319. var _removeEmpty = function ( a )
  1320. {
  1321. var out = [];
  1322. for ( var i=0, ien=a.length ; i<ien ; i++ ) {
  1323. if ( a[i] ) { // careful - will remove all falsy values!
  1324. out.push( a[i] );
  1325. }
  1326. }
  1327. return out;
  1328. };
  1329. var _stripHtml = function ( d ) {
  1330. return d.replace( _re_html, '' );
  1331. };
  1332. /**
  1333. * Determine if all values in the array are unique. This means we can short
  1334. * cut the _unique method at the cost of a single loop. A sorted array is used
  1335. * to easily check the values.
  1336. *
  1337. * @param {array} src Source array
  1338. * @return {boolean} true if all unique, false otherwise
  1339. * @ignore
  1340. */
  1341. var _areAllUnique = function ( src ) {
  1342. if ( src.length < 2 ) {
  1343. return true;
  1344. }
  1345. var sorted = src.slice().sort();
  1346. var last = sorted[0];
  1347. for ( var i=1, ien=sorted.length ; i<ien ; i++ ) {
  1348. if ( sorted[i] === last ) {
  1349. return false;
  1350. }
  1351. last = sorted[i];
  1352. }
  1353. return true;
  1354. };
  1355. /**
  1356. * Find the unique elements in a source array.
  1357. *
  1358. * @param {array} src Source array
  1359. * @return {array} Array of unique items
  1360. * @ignore
  1361. */
  1362. var _unique = function ( src )
  1363. {
  1364. if ( _areAllUnique( src ) ) {
  1365. return src.slice();
  1366. }
  1367. // A faster unique method is to use object keys to identify used values,
  1368. // but this doesn't work with arrays or objects, which we must also
  1369. // consider. See jsperf.com/compare-array-unique-versions/4 for more
  1370. // information.
  1371. var
  1372. out = [],
  1373. val,
  1374. i, ien=src.length,
  1375. j, k=0;
  1376. again: for ( i=0 ; i<ien ; i++ ) {
  1377. val = src[i];
  1378. for ( j=0 ; j<k ; j++ ) {
  1379. if ( out[j] === val ) {
  1380. continue again;
  1381. }
  1382. }
  1383. out.push( val );
  1384. k++;
  1385. }
  1386. return out;
  1387. };
  1388. // Surprisingly this is faster than [].concat.apply
  1389. // https://jsperf.com/flatten-an-array-loop-vs-reduce/2
  1390. var _flatten = function (out, val) {
  1391. if (Array.isArray(val)) {
  1392. for (var i=0 ; i<val.length ; i++) {
  1393. _flatten(out, val[i]);
  1394. }
  1395. }
  1396. else {
  1397. out.push(val);
  1398. }
  1399. return out;
  1400. }
  1401. // Array.isArray polyfill.
  1402. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
  1403. if (! Array.isArray) {
  1404. Array.isArray = function(arg) {
  1405. return Object.prototype.toString.call(arg) === '[object Array]';
  1406. };
  1407. }
  1408. // .trim() polyfill
  1409. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim
  1410. if (!String.prototype.trim) {
  1411. String.prototype.trim = function () {
  1412. return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
  1413. };
  1414. }
  1415. /**
  1416. * DataTables utility methods
  1417. *
  1418. * This namespace provides helper methods that DataTables uses internally to
  1419. * create a DataTable, but which are not exclusively used only for DataTables.
  1420. * These methods can be used by extension authors to save the duplication of
  1421. * code.
  1422. *
  1423. * @namespace
  1424. */
  1425. DataTable.util = {
  1426. /**
  1427. * Throttle the calls to a function. Arguments and context are maintained
  1428. * for the throttled function.
  1429. *
  1430. * @param {function} fn Function to be called
  1431. * @param {integer} freq Call frequency in mS
  1432. * @return {function} Wrapped function
  1433. */
  1434. throttle: function ( fn, freq ) {
  1435. var
  1436. frequency = freq !== undefined ? freq : 200,
  1437. last,
  1438. timer;
  1439. return function () {
  1440. var
  1441. that = this,
  1442. now = +new Date(),
  1443. args = arguments;
  1444. if ( last && now < last + frequency ) {
  1445. clearTimeout( timer );
  1446. timer = setTimeout( function () {
  1447. last = undefined;
  1448. fn.apply( that, args );
  1449. }, frequency );
  1450. }
  1451. else {
  1452. last = now;
  1453. fn.apply( that, args );
  1454. }
  1455. };
  1456. },
  1457. /**
  1458. * Escape a string such that it can be used in a regular expression
  1459. *
  1460. * @param {string} val string to escape
  1461. * @returns {string} escaped string
  1462. */
  1463. escapeRegex: function ( val ) {
  1464. return val.replace( _re_escape_regex, '\\$1' );
  1465. }
  1466. };
  1467. /**
  1468. * Create a mapping object that allows camel case parameters to be looked up
  1469. * for their Hungarian counterparts. The mapping is stored in a private
  1470. * parameter called `_hungarianMap` which can be accessed on the source object.
  1471. * @param {object} o
  1472. * @memberof DataTable#oApi
  1473. */
  1474. function _fnHungarianMap ( o )
  1475. {
  1476. var
  1477. hungarian = 'a aa ai ao as b fn i m o s ',
  1478. match,
  1479. newKey,
  1480. map = {};
  1481. $.each( o, function (key, val) {
  1482. match = key.match(/^([^A-Z]+?)([A-Z])/);
  1483. if ( match && hungarian.indexOf(match[1]+' ') !== -1 )
  1484. {
  1485. newKey = key.replace( match[0], match[2].toLowerCase() );
  1486. map[ newKey ] = key;
  1487. if ( match[1] === 'o' )
  1488. {
  1489. _fnHungarianMap( o[key] );
  1490. }
  1491. }
  1492. } );
  1493. o._hungarianMap = map;
  1494. }
  1495. /**
  1496. * Convert from camel case parameters to Hungarian, based on a Hungarian map
  1497. * created by _fnHungarianMap.
  1498. * @param {object} src The model object which holds all parameters that can be
  1499. * mapped.
  1500. * @param {object} user The object to convert from camel case to Hungarian.
  1501. * @param {boolean} force When set to `true`, properties which already have a
  1502. * Hungarian value in the `user` object will be overwritten. Otherwise they
  1503. * won't be.
  1504. * @memberof DataTable#oApi
  1505. */
  1506. function _fnCamelToHungarian ( src, user, force )
  1507. {
  1508. if ( ! src._hungarianMap ) {
  1509. _fnHungarianMap( src );
  1510. }
  1511. var hungarianKey;
  1512. $.each( user, function (key, val) {
  1513. hungarianKey = src._hungarianMap[ key ];
  1514. if ( hungarianKey !== undefined && (force || user[hungarianKey] === undefined) )
  1515. {
  1516. // For objects, we need to buzz down into the object to copy parameters
  1517. if ( hungarianKey.charAt(0) === 'o' )
  1518. {
  1519. // Copy the camelCase options over to the hungarian
  1520. if ( ! user[ hungarianKey ] ) {
  1521. user[ hungarianKey ] = {};
  1522. }
  1523. $.extend( true, user[hungarianKey], user[key] );
  1524. _fnCamelToHungarian( src[hungarianKey], user[hungarianKey], force );
  1525. }
  1526. else {
  1527. user[hungarianKey] = user[ key ];
  1528. }
  1529. }
  1530. } );
  1531. }
  1532. /**
  1533. * Language compatibility - when certain options are given, and others aren't, we
  1534. * need to duplicate the values over, in order to provide backwards compatibility
  1535. * with older language files.
  1536. * @param {object} oSettings dataTables settings object
  1537. * @memberof DataTable#oApi
  1538. */
  1539. function _fnLanguageCompat( lang )
  1540. {
  1541. // Note the use of the Hungarian notation for the parameters in this method as
  1542. // this is called after the mapping of camelCase to Hungarian
  1543. var defaults = DataTable.defaults.oLanguage;
  1544. // Default mapping
  1545. var defaultDecimal = defaults.sDecimal;
  1546. if ( defaultDecimal ) {
  1547. _addNumericSort( defaultDecimal );
  1548. }
  1549. if ( lang ) {
  1550. var zeroRecords = lang.sZeroRecords;
  1551. // Backwards compatibility - if there is no sEmptyTable given, then use the same as
  1552. // sZeroRecords - assuming that is given.
  1553. if ( ! lang.sEmptyTable && zeroRecords &&
  1554. defaults.sEmptyTable === "No data available in table" )
  1555. {
  1556. _fnMap( lang, lang, 'sZeroRecords', 'sEmptyTable' );
  1557. }
  1558. // Likewise with loading records
  1559. if ( ! lang.sLoadingRecords && zeroRecords &&
  1560. defaults.sLoadingRecords === "Loading..." )
  1561. {
  1562. _fnMap( lang, lang, 'sZeroRecords', 'sLoadingRecords' );
  1563. }
  1564. // Old parameter name of the thousands separator mapped onto the new
  1565. if ( lang.sInfoThousands ) {
  1566. lang.sThousands = lang.sInfoThousands;
  1567. }
  1568. var decimal = lang.sDecimal;
  1569. if ( decimal && defaultDecimal !== decimal ) {
  1570. _addNumericSort( decimal );
  1571. }
  1572. }
  1573. }
  1574. /**
  1575. * Map one parameter onto another
  1576. * @param {object} o Object to map
  1577. * @param {*} knew The new parameter name
  1578. * @param {*} old The old parameter name
  1579. */
  1580. var _fnCompatMap = function ( o, knew, old ) {
  1581. if ( o[ knew ] !== undefined ) {
  1582. o[ old ] = o[ knew ];
  1583. }
  1584. };
  1585. /**
  1586. * Provide backwards compatibility for the main DT options. Note that the new
  1587. * options are mapped onto the old parameters, so this is an external interface
  1588. * change only.
  1589. * @param {object} init Object to map
  1590. */
  1591. function _fnCompatOpts ( init )
  1592. {
  1593. _fnCompatMap( init, 'ordering', 'bSort' );
  1594. _fnCompatMap( init, 'orderMulti', 'bSortMulti' );
  1595. _fnCompatMap( init, 'orderClasses', 'bSortClasses' );
  1596. _fnCompatMap( init, 'orderCellsTop', 'bSortCellsTop' );
  1597. _fnCompatMap( init, 'order', 'aaSorting' );
  1598. _fnCompatMap( init, 'orderFixed', 'aaSortingFixed' );
  1599. _fnCompatMap( init, 'paging', 'bPaginate' );
  1600. _fnCompatMap( init, 'pagingType', 'sPaginationType' );
  1601. _fnCompatMap( init, 'pageLength', 'iDisplayLength' );
  1602. _fnCompatMap( init, 'searching', 'bFilter' );
  1603. // Boolean initialisation of x-scrolling
  1604. if ( typeof init.sScrollX === 'boolean' ) {
  1605. init.sScrollX = init.sScrollX ? '100%' : '';
  1606. }
  1607. if ( typeof init.scrollX === 'boolean' ) {
  1608. init.scrollX = init.scrollX ? '100%' : '';
  1609. }
  1610. // Column search objects are in an array, so it needs to be converted
  1611. // element by element
  1612. var searchCols = init.aoSearchCols;
  1613. if ( searchCols ) {
  1614. for ( var i=0, ien=searchCols.length ; i<ien ; i++ ) {
  1615. if ( searchCols[i] ) {
  1616. _fnCamelToHungarian( DataTable.models.oSearch, searchCols[i] );
  1617. }
  1618. }
  1619. }
  1620. }
  1621. /**
  1622. * Provide backwards compatibility for column options. Note that the new options
  1623. * are mapped onto the old parameters, so this is an external interface change
  1624. * only.
  1625. * @param {object} init Object to map
  1626. */
  1627. function _fnCompatCols ( init )
  1628. {
  1629. _fnCompatMap( init, 'orderable', 'bSortable' );
  1630. _fnCompatMap( init, 'orderData', 'aDataSort' );
  1631. _fnCompatMap( init, 'orderSequence', 'asSorting' );
  1632. _fnCompatMap( init, 'orderDataType', 'sortDataType' );
  1633. // orderData can be given as an integer
  1634. var dataSort = init.aDataSort;
  1635. if ( typeof dataSort === 'number' && ! Array.isArray( dataSort ) ) {
  1636. init.aDataSort = [ dataSort ];
  1637. }
  1638. }
  1639. /**
  1640. * Browser feature detection for capabilities, quirks
  1641. * @param {object} settings dataTables settings object
  1642. * @memberof DataTable#oApi
  1643. */
  1644. function _fnBrowserDetect( settings )
  1645. {
  1646. // We don't need to do this every time DataTables is constructed, the values
  1647. // calculated are specific to the browser and OS configuration which we
  1648. // don't expect to change between initialisations
  1649. if ( ! DataTable.__browser ) {
  1650. var browser = {};
  1651. DataTable.__browser = browser;
  1652. // Scrolling feature / quirks detection
  1653. var n = $('<div/>')
  1654. .css( {
  1655. position: 'fixed',
  1656. top: 0,
  1657. left: $(window).scrollLeft()*-1, // allow for scrolling
  1658. height: 1,
  1659. width: 1,
  1660. overflow: 'hidden'
  1661. } )
  1662. .append(
  1663. $('<div/>')
  1664. .css( {
  1665. position: 'absolute',
  1666. top: 1,
  1667. left: 1,
  1668. width: 100,
  1669. overflow: 'scroll'
  1670. } )
  1671. .append(
  1672. $('<div/>')
  1673. .css( {
  1674. width: '100%',
  1675. height: 10
  1676. } )
  1677. )
  1678. )
  1679. .appendTo( 'body' );
  1680. var outer = n.children();
  1681. var inner = outer.children();
  1682. // Numbers below, in order, are:
  1683. // inner.offsetWidth, inner.clientWidth, outer.offsetWidth, outer.clientWidth
  1684. //
  1685. // IE6 XP: 100 100 100 83
  1686. // IE7 Vista: 100 100 100 83
  1687. // IE 8+ Windows: 83 83 100 83
  1688. // Evergreen Windows: 83 83 100 83
  1689. // Evergreen Mac with scrollbars: 85 85 100 85
  1690. // Evergreen Mac without scrollbars: 100 100 100 100
  1691. // Get scrollbar width
  1692. browser.barWidth = outer[0].offsetWidth - outer[0].clientWidth;
  1693. // IE6/7 will oversize a width 100% element inside a scrolling element, to
  1694. // include the width of the scrollbar, while other browsers ensure the inner
  1695. // element is contained without forcing scrolling
  1696. browser.bScrollOversize = inner[0].offsetWidth === 100 && outer[0].clientWidth !== 100;
  1697. // In rtl text layout, some browsers (most, but not all) will place the
  1698. // scrollbar on the left, rather than the right.
  1699. browser.bScrollbarLeft = Math.round( inner.offset().left ) !== 1;
  1700. // IE8- don't provide height and width for getBoundingClientRect
  1701. browser.bBounding = n[0].getBoundingClientRect().width ? true : false;
  1702. n.remove();
  1703. }
  1704. $.extend( settings.oBrowser, DataTable.__browser );
  1705. settings.oScroll.iBarWidth = DataTable.__browser.barWidth;
  1706. }
  1707. /**
  1708. * Array.prototype reduce[Right] method, used for browsers which don't support
  1709. * JS 1.6. Done this way to reduce code size, since we iterate either way
  1710. * @param {object} settings dataTables settings object
  1711. * @memberof DataTable#oApi
  1712. */
  1713. function _fnReduce ( that, fn, init, start, end, inc )
  1714. {
  1715. var
  1716. i = start,
  1717. value,
  1718. isSet = false;
  1719. if ( init !== undefined ) {
  1720. value = init;
  1721. isSet = true;
  1722. }
  1723. while ( i !== end ) {
  1724. if ( ! that.hasOwnProperty(i) ) {
  1725. continue;
  1726. }
  1727. value = isSet ?
  1728. fn( value, that[i], i, that ) :
  1729. that[i];
  1730. isSet = true;
  1731. i += inc;
  1732. }
  1733. return value;
  1734. }
  1735. /**
  1736. * Add a column to the list used for the table with default values
  1737. * @param {object} oSettings dataTables settings object
  1738. * @param {node} nTh The th element for this column
  1739. * @memberof DataTable#oApi
  1740. */
  1741. function _fnAddColumn( oSettings, nTh )
  1742. {
  1743. // Add column to aoColumns array
  1744. var oDefaults = DataTable.defaults.column;
  1745. var iCol = oSettings.aoColumns.length;
  1746. var oCol = $.extend( {}, DataTable.models.oColumn, oDefaults, {
  1747. "nTh": nTh ? nTh : document.createElement('th'),
  1748. "sTitle": oDefaults.sTitle ? oDefaults.sTitle : nTh ? nTh.innerHTML : '',
  1749. "aDataSort": oDefaults.aDataSort ? oDefaults.aDataSort : [iCol],
  1750. "mData": oDefaults.mData ? oDefaults.mData : iCol,
  1751. idx: iCol
  1752. } );
  1753. oSettings.aoColumns.push( oCol );
  1754. // Add search object for column specific search. Note that the `searchCols[ iCol ]`
  1755. // passed into extend can be undefined. This allows the user to give a default
  1756. // with only some of the parameters defined, and also not give a default
  1757. var searchCols = oSettings.aoPreSearchCols;
  1758. searchCols[ iCol ] = $.extend( {}, DataTable.models.oSearch, searchCols[ iCol ] );
  1759. // Use the default column options function to initialise classes etc
  1760. _fnColumnOptions( oSettings, iCol, $(nTh).data() );
  1761. }
  1762. /**
  1763. * Apply options for a column
  1764. * @param {object} oSettings dataTables settings object
  1765. * @param {int} iCol column index to consider
  1766. * @param {object} oOptions object with sType, bVisible and bSearchable etc
  1767. * @memberof DataTable#oApi
  1768. */
  1769. function _fnColumnOptions( oSettings, iCol, oOptions )
  1770. {
  1771. var oCol = oSettings.aoColumns[ iCol ];
  1772. var oClasses = oSettings.oClasses;
  1773. var th = $(oCol.nTh);
  1774. // Try to get width information from the DOM. We can't get it from CSS
  1775. // as we'd need to parse the CSS stylesheet. `width` option can override
  1776. if ( ! oCol.sWidthOrig ) {
  1777. // Width attribute
  1778. oCol.sWidthOrig = th.attr('width') || null;
  1779. // Style attribute
  1780. var t = (th.attr('style') || '').match(/width:\s*(\d+[pxem%]+)/);
  1781. if ( t ) {
  1782. oCol.sWidthOrig = t[1];
  1783. }
  1784. }
  1785. /* User specified column options */
  1786. if ( oOptions !== undefined && oOptions !== null )
  1787. {
  1788. // Backwards compatibility
  1789. _fnCompatCols( oOptions );
  1790. // Map camel case parameters to their Hungarian counterparts
  1791. _fnCamelToHungarian( DataTable.defaults.column, oOptions, true );
  1792. /* Backwards compatibility for mDataProp */
  1793. if ( oOptions.mDataProp !== undefined && !oOptions.mData )
  1794. {
  1795. oOptions.mData = oOptions.mDataProp;
  1796. }
  1797. if ( oOptions.sType )
  1798. {
  1799. oCol._sManualType = oOptions.sType;
  1800. }
  1801. // `class` is a reserved word in Javascript, so we need to provide
  1802. // the ability to use a valid name for the camel case input
  1803. if ( oOptions.className && ! oOptions.sClass )
  1804. {
  1805. oOptions.sClass = oOptions.className;
  1806. }
  1807. if ( oOptions.sClass ) {
  1808. th.addClass( oOptions.sClass );
  1809. }
  1810. $.extend( oCol, oOptions );
  1811. _fnMap( oCol, oOptions, "sWidth", "sWidthOrig" );
  1812. /* iDataSort to be applied (backwards compatibility), but aDataSort will take
  1813. * priority if defined
  1814. */
  1815. if ( oOptions.iDataSort !== undefined )
  1816. {
  1817. oCol.aDataSort = [ oOptions.iDataSort ];
  1818. }
  1819. _fnMap( oCol, oOptions, "aDataSort" );
  1820. }
  1821. /* Cache the data get and set functions for speed */
  1822. var mDataSrc = oCol.mData;
  1823. var mData = _fnGetObjectDataFn( mDataSrc );
  1824. var mRender = oCol.mRender ? _fnGetObjectDataFn( oCol.mRender ) : null;
  1825. var attrTest = function( src ) {
  1826. return typeof src === 'string' && src.indexOf('@') !== -1;
  1827. };
  1828. oCol._bAttrSrc = $.isPlainObject( mDataSrc ) && (
  1829. attrTest(mDataSrc.sort) || attrTest(mDataSrc.type) || attrTest(mDataSrc.filter)
  1830. );
  1831. oCol._setter = null;
  1832. oCol.fnGetData = function (rowData, type, meta) {
  1833. var innerData = mData( rowData, type, undefined, meta );
  1834. return mRender && type ?
  1835. mRender( innerData, type, rowData, meta ) :
  1836. innerData;
  1837. };
  1838. oCol.fnSetData = function ( rowData, val, meta ) {
  1839. return _fnSetObjectDataFn( mDataSrc )( rowData, val, meta );
  1840. };
  1841. // Indicate if DataTables should read DOM data as an object or array
  1842. // Used in _fnGetRowElements
  1843. if ( typeof mDataSrc !== 'number' ) {
  1844. oSettings._rowReadObject = true;
  1845. }
  1846. /* Feature sorting overrides column specific when off */
  1847. if ( !oSettings.oFeatures.bSort )
  1848. {
  1849. oCol.bSortable = false;
  1850. th.addClass( oClasses.sSortableNone ); // Have to add class here as order event isn't called
  1851. }
  1852. /* Check that the class assignment is correct for sorting */
  1853. var bAsc = $.inArray('asc', oCol.asSorting) !== -1;
  1854. var bDesc = $.inArray('desc', oCol.asSorting) !== -1;
  1855. if ( !oCol.bSortable || (!bAsc && !bDesc) )
  1856. {
  1857. oCol.sSortingClass = oClasses.sSortableNone;
  1858. oCol.sSortingClassJUI = "";
  1859. }
  1860. else if ( bAsc && !bDesc )
  1861. {
  1862. oCol.sSortingClass = oClasses.sSortableAsc;
  1863. oCol.sSortingClassJUI = oClasses.sSortJUIAscAllowed;
  1864. }
  1865. else if ( !bAsc && bDesc )
  1866. {
  1867. oCol.sSortingClass = oClasses.sSortableDesc;
  1868. oCol.sSortingClassJUI = oClasses.sSortJUIDescAllowed;
  1869. }
  1870. else
  1871. {
  1872. oCol.sSortingClass = oClasses.sSortable;
  1873. oCol.sSortingClassJUI = oClasses.sSortJUI;
  1874. }
  1875. }
  1876. /**
  1877. * Adjust the table column widths for new data. Note: you would probably want to
  1878. * do a redraw after calling this function!
  1879. * @param {object} settings dataTables settings object
  1880. * @memberof DataTable#oApi
  1881. */
  1882. function _fnAdjustColumnSizing ( settings )
  1883. {
  1884. /* Not interested in doing column width calculation if auto-width is disabled */
  1885. if ( settings.oFeatures.bAutoWidth !== false )
  1886. {
  1887. var columns = settings.aoColumns;
  1888. _fnCalculateColumnWidths( settings );
  1889. for ( var i=0 , iLen=columns.length ; i<iLen ; i++ )
  1890. {
  1891. columns[i].nTh.style.width = columns[i].sWidth;
  1892. }
  1893. }
  1894. var scroll = settings.oScroll;
  1895. if ( scroll.sY !== '' || scroll.sX !== '')
  1896. {
  1897. _fnScrollDraw( settings );
  1898. }
  1899. _fnCallbackFire( settings, null, 'column-sizing', [settings] );
  1900. }
  1901. /**
  1902. * Covert the index of a visible column to the index in the data array (take account
  1903. * of hidden columns)
  1904. * @param {object} oSettings dataTables settings object
  1905. * @param {int} iMatch Visible column index to lookup
  1906. * @returns {int} i the data index
  1907. * @memberof DataTable#oApi
  1908. */
  1909. function _fnVisibleToColumnIndex( oSettings, iMatch )
  1910. {
  1911. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  1912. return typeof aiVis[iMatch] === 'number' ?
  1913. aiVis[iMatch] :
  1914. null;
  1915. }
  1916. /**
  1917. * Covert the index of an index in the data array and convert it to the visible
  1918. * column index (take account of hidden columns)
  1919. * @param {int} iMatch Column index to lookup
  1920. * @param {object} oSettings dataTables settings object
  1921. * @returns {int} i the data index
  1922. * @memberof DataTable#oApi
  1923. */
  1924. function _fnColumnIndexToVisible( oSettings, iMatch )
  1925. {
  1926. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  1927. var iPos = $.inArray( iMatch, aiVis );
  1928. return iPos !== -1 ? iPos : null;
  1929. }
  1930. /**
  1931. * Get the number of visible columns
  1932. * @param {object} oSettings dataTables settings object
  1933. * @returns {int} i the number of visible columns
  1934. * @memberof DataTable#oApi
  1935. */
  1936. function _fnVisbleColumns( oSettings )
  1937. {
  1938. var vis = 0;
  1939. // No reduce in IE8, use a loop for now
  1940. $.each( oSettings.aoColumns, function ( i, col ) {
  1941. if ( col.bVisible && $(col.nTh).css('display') !== 'none' ) {
  1942. vis++;
  1943. }
  1944. } );
  1945. return vis;
  1946. }
  1947. /**
  1948. * Get an array of column indexes that match a given property
  1949. * @param {object} oSettings dataTables settings object
  1950. * @param {string} sParam Parameter in aoColumns to look for - typically
  1951. * bVisible or bSearchable
  1952. * @returns {array} Array of indexes with matched properties
  1953. * @memberof DataTable#oApi
  1954. */
  1955. function _fnGetColumns( oSettings, sParam )
  1956. {
  1957. var a = [];
  1958. $.map( oSettings.aoColumns, function(val, i) {
  1959. if ( val[sParam] ) {
  1960. a.push( i );
  1961. }
  1962. } );
  1963. return a;
  1964. }
  1965. /**
  1966. * Calculate the 'type' of a column
  1967. * @param {object} settings dataTables settings object
  1968. * @memberof DataTable#oApi
  1969. */
  1970. function _fnColumnTypes ( settings )
  1971. {
  1972. var columns = settings.aoColumns;
  1973. var data = settings.aoData;
  1974. var types = DataTable.ext.type.detect;
  1975. var i, ien, j, jen, k, ken;
  1976. var col, cell, detectedType, cache;
  1977. // For each column, spin over the
  1978. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  1979. col = columns[i];
  1980. cache = [];
  1981. if ( ! col.sType && col._sManualType ) {
  1982. col.sType = col._sManualType;
  1983. }
  1984. else if ( ! col.sType ) {
  1985. for ( j=0, jen=types.length ; j<jen ; j++ ) {
  1986. for ( k=0, ken=data.length ; k<ken ; k++ ) {
  1987. // Use a cache array so we only need to get the type data
  1988. // from the formatter once (when using multiple detectors)
  1989. if ( cache[k] === undefined ) {
  1990. cache[k] = _fnGetCellData( settings, k, i, 'type' );
  1991. }
  1992. detectedType = types[j]( cache[k], settings );
  1993. // If null, then this type can't apply to this column, so
  1994. // rather than testing all cells, break out. There is an
  1995. // exception for the last type which is `html`. We need to
  1996. // scan all rows since it is possible to mix string and HTML
  1997. // types
  1998. if ( ! detectedType && j !== types.length-1 ) {
  1999. break;
  2000. }
  2001. // Only a single match is needed for html type since it is
  2002. // bottom of the pile and very similar to string
  2003. if ( detectedType === 'html' ) {
  2004. break;
  2005. }
  2006. }
  2007. // Type is valid for all data points in the column - use this
  2008. // type
  2009. if ( detectedType ) {
  2010. col.sType = detectedType;
  2011. break;
  2012. }
  2013. }
  2014. // Fall back - if no type was detected, always use string
  2015. if ( ! col.sType ) {
  2016. col.sType = 'string';
  2017. }
  2018. }
  2019. }
  2020. }
  2021. /**
  2022. * Take the column definitions and static columns arrays and calculate how
  2023. * they relate to column indexes. The callback function will then apply the
  2024. * definition found for a column to a suitable configuration object.
  2025. * @param {object} oSettings dataTables settings object
  2026. * @param {array} aoColDefs The aoColumnDefs array that is to be applied
  2027. * @param {array} aoCols The aoColumns array that defines columns individually
  2028. * @param {function} fn Callback function - takes two parameters, the calculated
  2029. * column index and the definition for that column.
  2030. * @memberof DataTable#oApi
  2031. */
  2032. function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, fn )
  2033. {
  2034. var i, iLen, j, jLen, k, kLen, def;
  2035. var columns = oSettings.aoColumns;
  2036. // Column definitions with aTargets
  2037. if ( aoColDefs )
  2038. {
  2039. /* Loop over the definitions array - loop in reverse so first instance has priority */
  2040. for ( i=aoColDefs.length-1 ; i>=0 ; i-- )
  2041. {
  2042. def = aoColDefs[i];
  2043. /* Each definition can target multiple columns, as it is an array */
  2044. var aTargets = def.targets !== undefined ?
  2045. def.targets :
  2046. def.aTargets;
  2047. if ( ! Array.isArray( aTargets ) )
  2048. {
  2049. aTargets = [ aTargets ];
  2050. }
  2051. for ( j=0, jLen=aTargets.length ; j<jLen ; j++ )
  2052. {
  2053. if ( typeof aTargets[j] === 'number' && aTargets[j] >= 0 )
  2054. {
  2055. /* Add columns that we don't yet know about */
  2056. while( columns.length <= aTargets[j] )
  2057. {
  2058. _fnAddColumn( oSettings );
  2059. }
  2060. /* Integer, basic index */
  2061. fn( aTargets[j], def );
  2062. }
  2063. else if ( typeof aTargets[j] === 'number' && aTargets[j] < 0 )
  2064. {
  2065. /* Negative integer, right to left column counting */
  2066. fn( columns.length+aTargets[j], def );
  2067. }
  2068. else if ( typeof aTargets[j] === 'string' )
  2069. {
  2070. /* Class name matching on TH element */
  2071. for ( k=0, kLen=columns.length ; k<kLen ; k++ )
  2072. {
  2073. if ( aTargets[j] == "_all" ||
  2074. $(columns[k].nTh).hasClass( aTargets[j] ) )
  2075. {
  2076. fn( k, def );
  2077. }
  2078. }
  2079. }
  2080. }
  2081. }
  2082. }
  2083. // Statically defined columns array
  2084. if ( aoCols )
  2085. {
  2086. for ( i=0, iLen=aoCols.length ; i<iLen ; i++ )
  2087. {
  2088. fn( i, aoCols[i] );
  2089. }
  2090. }
  2091. }
  2092. /**
  2093. * Add a data array to the table, creating DOM node etc. This is the parallel to
  2094. * _fnGatherData, but for adding rows from a Javascript source, rather than a
  2095. * DOM source.
  2096. * @param {object} oSettings dataTables settings object
  2097. * @param {array} aData data array to be added
  2098. * @param {node} [nTr] TR element to add to the table - optional. If not given,
  2099. * DataTables will create a row automatically
  2100. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  2101. * if nTr is.
  2102. * @returns {int} >=0 if successful (index of new aoData entry), -1 if failed
  2103. * @memberof DataTable#oApi
  2104. */
  2105. function _fnAddData ( oSettings, aDataIn, nTr, anTds )
  2106. {
  2107. /* Create the object for storing information about this new row */
  2108. var iRow = oSettings.aoData.length;
  2109. var oData = $.extend( true, {}, DataTable.models.oRow, {
  2110. src: nTr ? 'dom' : 'data',
  2111. idx: iRow
  2112. } );
  2113. oData._aData = aDataIn;
  2114. oSettings.aoData.push( oData );
  2115. /* Create the cells */
  2116. var nTd, sThisType;
  2117. var columns = oSettings.aoColumns;
  2118. // Invalidate the column types as the new data needs to be revalidated
  2119. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  2120. {
  2121. columns[i].sType = null;
  2122. }
  2123. /* Add to the display array */
  2124. oSettings.aiDisplayMaster.push( iRow );
  2125. var id = oSettings.rowIdFn( aDataIn );
  2126. if ( id !== undefined ) {
  2127. oSettings.aIds[ id ] = oData;
  2128. }
  2129. /* Create the DOM information, or register it if already present */
  2130. if ( nTr || ! oSettings.oFeatures.bDeferRender )
  2131. {
  2132. _fnCreateTr( oSettings, iRow, nTr, anTds );
  2133. }
  2134. return iRow;
  2135. }
  2136. /**
  2137. * Add one or more TR elements to the table. Generally we'd expect to
  2138. * use this for reading data from a DOM sourced table, but it could be
  2139. * used for an TR element. Note that if a TR is given, it is used (i.e.
  2140. * it is not cloned).
  2141. * @param {object} settings dataTables settings object
  2142. * @param {array|node|jQuery} trs The TR element(s) to add to the table
  2143. * @returns {array} Array of indexes for the added rows
  2144. * @memberof DataTable#oApi
  2145. */
  2146. function _fnAddTr( settings, trs )
  2147. {
  2148. var row;
  2149. // Allow an individual node to be passed in
  2150. if ( ! (trs instanceof $) ) {
  2151. trs = $(trs);
  2152. }
  2153. return trs.map( function (i, el) {
  2154. row = _fnGetRowElements( settings, el );
  2155. return _fnAddData( settings, row.data, el, row.cells );
  2156. } );
  2157. }
  2158. /**
  2159. * Take a TR element and convert it to an index in aoData
  2160. * @param {object} oSettings dataTables settings object
  2161. * @param {node} n the TR element to find
  2162. * @returns {int} index if the node is found, null if not
  2163. * @memberof DataTable#oApi
  2164. */
  2165. function _fnNodeToDataIndex( oSettings, n )
  2166. {
  2167. return (n._DT_RowIndex!==undefined) ? n._DT_RowIndex : null;
  2168. }
  2169. /**
  2170. * Take a TD element and convert it into a column data index (not the visible index)
  2171. * @param {object} oSettings dataTables settings object
  2172. * @param {int} iRow The row number the TD/TH can be found in
  2173. * @param {node} n The TD/TH element to find
  2174. * @returns {int} index if the node is found, -1 if not
  2175. * @memberof DataTable#oApi
  2176. */
  2177. function _fnNodeToColumnIndex( oSettings, iRow, n )
  2178. {
  2179. return $.inArray( n, oSettings.aoData[ iRow ].anCells );
  2180. }
  2181. /**
  2182. * Get the data for a given cell from the internal cache, taking into account data mapping
  2183. * @param {object} settings dataTables settings object
  2184. * @param {int} rowIdx aoData row id
  2185. * @param {int} colIdx Column index
  2186. * @param {string} type data get type ('display', 'type' 'filter' 'sort')
  2187. * @returns {*} Cell data
  2188. * @memberof DataTable#oApi
  2189. */
  2190. function _fnGetCellData( settings, rowIdx, colIdx, type )
  2191. {
  2192. var draw = settings.iDraw;
  2193. var col = settings.aoColumns[colIdx];
  2194. var rowData = settings.aoData[rowIdx]._aData;
  2195. var defaultContent = col.sDefaultContent;
  2196. var cellData = col.fnGetData( rowData, type, {
  2197. settings: settings,
  2198. row: rowIdx,
  2199. col: colIdx
  2200. } );
  2201. if ( cellData === undefined ) {
  2202. if ( settings.iDrawError != draw && defaultContent === null ) {
  2203. _fnLog( settings, 0, "Requested unknown parameter "+
  2204. (typeof col.mData=='function' ? '{function}' : "'"+col.mData+"'")+
  2205. " for row "+rowIdx+", column "+colIdx, 4 );
  2206. settings.iDrawError = draw;
  2207. }
  2208. return defaultContent;
  2209. }
  2210. // When the data source is null and a specific data type is requested (i.e.
  2211. // not the original data), we can use default column data
  2212. if ( (cellData === rowData || cellData === null) && defaultContent !== null && type !== undefined ) {
  2213. cellData = defaultContent;
  2214. }
  2215. else if ( typeof cellData === 'function' ) {
  2216. // If the data source is a function, then we run it and use the return,
  2217. // executing in the scope of the data object (for instances)
  2218. return cellData.call( rowData );
  2219. }
  2220. if ( cellData === null && type == 'display' ) {
  2221. return '';
  2222. }
  2223. return cellData;
  2224. }
  2225. /**
  2226. * Set the value for a specific cell, into the internal data cache
  2227. * @param {object} settings dataTables settings object
  2228. * @param {int} rowIdx aoData row id
  2229. * @param {int} colIdx Column index
  2230. * @param {*} val Value to set
  2231. * @memberof DataTable#oApi
  2232. */
  2233. function _fnSetCellData( settings, rowIdx, colIdx, val )
  2234. {
  2235. var col = settings.aoColumns[colIdx];
  2236. var rowData = settings.aoData[rowIdx]._aData;
  2237. col.fnSetData( rowData, val, {
  2238. settings: settings,
  2239. row: rowIdx,
  2240. col: colIdx
  2241. } );
  2242. }
  2243. // Private variable that is used to match action syntax in the data property object
  2244. var __reArray = /\[.*?\]$/;
  2245. var __reFn = /\(\)$/;
  2246. /**
  2247. * Split string on periods, taking into account escaped periods
  2248. * @param {string} str String to split
  2249. * @return {array} Split string
  2250. */
  2251. function _fnSplitObjNotation( str )
  2252. {
  2253. return $.map( str.match(/(\\.|[^\.])+/g) || [''], function ( s ) {
  2254. return s.replace(/\\\./g, '.');
  2255. } );
  2256. }
  2257. /**
  2258. * Return a function that can be used to get data from a source object, taking
  2259. * into account the ability to use nested objects as a source
  2260. * @param {string|int|function} mSource The data source for the object
  2261. * @returns {function} Data get function
  2262. * @memberof DataTable#oApi
  2263. */
  2264. function _fnGetObjectDataFn( mSource )
  2265. {
  2266. if ( $.isPlainObject( mSource ) )
  2267. {
  2268. /* Build an object of get functions, and wrap them in a single call */
  2269. var o = {};
  2270. $.each( mSource, function (key, val) {
  2271. if ( val ) {
  2272. o[key] = _fnGetObjectDataFn( val );
  2273. }
  2274. } );
  2275. return function (data, type, row, meta) {
  2276. var t = o[type] || o._;
  2277. return t !== undefined ?
  2278. t(data, type, row, meta) :
  2279. data;
  2280. };
  2281. }
  2282. else if ( mSource === null )
  2283. {
  2284. /* Give an empty string for rendering / sorting etc */
  2285. return function (data) { // type, row and meta also passed, but not used
  2286. return data;
  2287. };
  2288. }
  2289. else if ( typeof mSource === 'function' )
  2290. {
  2291. return function (data, type, row, meta) {
  2292. return mSource( data, type, row, meta );
  2293. };
  2294. }
  2295. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  2296. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  2297. {
  2298. /* If there is a . in the source string then the data source is in a
  2299. * nested object so we loop over the data for each level to get the next
  2300. * level down. On each loop we test for undefined, and if found immediately
  2301. * return. This allows entire objects to be missing and sDefaultContent to
  2302. * be used if defined, rather than throwing an error
  2303. */
  2304. var fetchData = function (data, type, src) {
  2305. var arrayNotation, funcNotation, out, innerSrc;
  2306. if ( src !== "" )
  2307. {
  2308. var a = _fnSplitObjNotation( src );
  2309. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  2310. {
  2311. // Check if we are dealing with special notation
  2312. arrayNotation = a[i].match(__reArray);
  2313. funcNotation = a[i].match(__reFn);
  2314. if ( arrayNotation )
  2315. {
  2316. // Array notation
  2317. a[i] = a[i].replace(__reArray, '');
  2318. // Condition allows simply [] to be passed in
  2319. if ( a[i] !== "" ) {
  2320. data = data[ a[i] ];
  2321. }
  2322. out = [];
  2323. // Get the remainder of the nested object to get
  2324. a.splice( 0, i+1 );
  2325. innerSrc = a.join('.');
  2326. // Traverse each entry in the array getting the properties requested
  2327. if ( Array.isArray( data ) ) {
  2328. for ( var j=0, jLen=data.length ; j<jLen ; j++ ) {
  2329. out.push( fetchData( data[j], type, innerSrc ) );
  2330. }
  2331. }
  2332. // If a string is given in between the array notation indicators, that
  2333. // is used to join the strings together, otherwise an array is returned
  2334. var join = arrayNotation[0].substring(1, arrayNotation[0].length-1);
  2335. data = (join==="") ? out : out.join(join);
  2336. // The inner call to fetchData has already traversed through the remainder
  2337. // of the source requested, so we exit from the loop
  2338. break;
  2339. }
  2340. else if ( funcNotation )
  2341. {
  2342. // Function call
  2343. a[i] = a[i].replace(__reFn, '');
  2344. data = data[ a[i] ]();
  2345. continue;
  2346. }
  2347. if ( data === null || data[ a[i] ] === undefined )
  2348. {
  2349. return undefined;
  2350. }
  2351. data = data[ a[i] ];
  2352. }
  2353. }
  2354. return data;
  2355. };
  2356. return function (data, type) { // row and meta also passed, but not used
  2357. return fetchData( data, type, mSource );
  2358. };
  2359. }
  2360. else
  2361. {
  2362. /* Array or flat object mapping */
  2363. return function (data, type) { // row and meta also passed, but not used
  2364. return data[mSource];
  2365. };
  2366. }
  2367. }
  2368. /**
  2369. * Return a function that can be used to set data from a source object, taking
  2370. * into account the ability to use nested objects as a source
  2371. * @param {string|int|function} mSource The data source for the object
  2372. * @returns {function} Data set function
  2373. * @memberof DataTable#oApi
  2374. */
  2375. function _fnSetObjectDataFn( mSource )
  2376. {
  2377. if ( $.isPlainObject( mSource ) )
  2378. {
  2379. /* Unlike get, only the underscore (global) option is used for for
  2380. * setting data since we don't know the type here. This is why an object
  2381. * option is not documented for `mData` (which is read/write), but it is
  2382. * for `mRender` which is read only.
  2383. */
  2384. return _fnSetObjectDataFn( mSource._ );
  2385. }
  2386. else if ( mSource === null )
  2387. {
  2388. /* Nothing to do when the data source is null */
  2389. return function () {};
  2390. }
  2391. else if ( typeof mSource === 'function' )
  2392. {
  2393. return function (data, val, meta) {
  2394. mSource( data, 'set', val, meta );
  2395. };
  2396. }
  2397. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  2398. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  2399. {
  2400. /* Like the get, we need to get data from a nested object */
  2401. var setData = function (data, val, src) {
  2402. var a = _fnSplitObjNotation( src ), b;
  2403. var aLast = a[a.length-1];
  2404. var arrayNotation, funcNotation, o, innerSrc;
  2405. for ( var i=0, iLen=a.length-1 ; i<iLen ; i++ )
  2406. {
  2407. // Protect against prototype pollution
  2408. if (a[i] === '__proto__' || a[i] === 'constructor') {
  2409. throw new Error('Cannot set prototype values');
  2410. }
  2411. // Check if we are dealing with an array notation request
  2412. arrayNotation = a[i].match(__reArray);
  2413. funcNotation = a[i].match(__reFn);
  2414. if ( arrayNotation )
  2415. {
  2416. a[i] = a[i].replace(__reArray, '');
  2417. data[ a[i] ] = [];
  2418. // Get the remainder of the nested object to set so we can recurse
  2419. b = a.slice();
  2420. b.splice( 0, i+1 );
  2421. innerSrc = b.join('.');
  2422. // Traverse each entry in the array setting the properties requested
  2423. if ( Array.isArray( val ) )
  2424. {
  2425. for ( var j=0, jLen=val.length ; j<jLen ; j++ )
  2426. {
  2427. o = {};
  2428. setData( o, val[j], innerSrc );
  2429. data[ a[i] ].push( o );
  2430. }
  2431. }
  2432. else
  2433. {
  2434. // We've been asked to save data to an array, but it
  2435. // isn't array data to be saved. Best that can be done
  2436. // is to just save the value.
  2437. data[ a[i] ] = val;
  2438. }
  2439. // The inner call to setData has already traversed through the remainder
  2440. // of the source and has set the data, thus we can exit here
  2441. return;
  2442. }
  2443. else if ( funcNotation )
  2444. {
  2445. // Function call
  2446. a[i] = a[i].replace(__reFn, '');
  2447. data = data[ a[i] ]( val );
  2448. }
  2449. // If the nested object doesn't currently exist - since we are
  2450. // trying to set the value - create it
  2451. if ( data[ a[i] ] === null || data[ a[i] ] === undefined )
  2452. {
  2453. data[ a[i] ] = {};
  2454. }
  2455. data = data[ a[i] ];
  2456. }
  2457. // Last item in the input - i.e, the actual set
  2458. if ( aLast.match(__reFn ) )
  2459. {
  2460. // Function call
  2461. data = data[ aLast.replace(__reFn, '') ]( val );
  2462. }
  2463. else
  2464. {
  2465. // If array notation is used, we just want to strip it and use the property name
  2466. // and assign the value. If it isn't used, then we get the result we want anyway
  2467. data[ aLast.replace(__reArray, '') ] = val;
  2468. }
  2469. };
  2470. return function (data, val) { // meta is also passed in, but not used
  2471. return setData( data, val, mSource );
  2472. };
  2473. }
  2474. else
  2475. {
  2476. /* Array or flat object mapping */
  2477. return function (data, val) { // meta is also passed in, but not used
  2478. data[mSource] = val;
  2479. };
  2480. }
  2481. }
  2482. /**
  2483. * Return an array with the full table data
  2484. * @param {object} oSettings dataTables settings object
  2485. * @returns array {array} aData Master data array
  2486. * @memberof DataTable#oApi
  2487. */
  2488. function _fnGetDataMaster ( settings )
  2489. {
  2490. return _pluck( settings.aoData, '_aData' );
  2491. }
  2492. /**
  2493. * Nuke the table
  2494. * @param {object} oSettings dataTables settings object
  2495. * @memberof DataTable#oApi
  2496. */
  2497. function _fnClearTable( settings )
  2498. {
  2499. settings.aoData.length = 0;
  2500. settings.aiDisplayMaster.length = 0;
  2501. settings.aiDisplay.length = 0;
  2502. settings.aIds = {};
  2503. }
  2504. /**
  2505. * Take an array of integers (index array) and remove a target integer (value - not
  2506. * the key!)
  2507. * @param {array} a Index array to target
  2508. * @param {int} iTarget value to find
  2509. * @memberof DataTable#oApi
  2510. */
  2511. function _fnDeleteIndex( a, iTarget, splice )
  2512. {
  2513. var iTargetIndex = -1;
  2514. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  2515. {
  2516. if ( a[i] == iTarget )
  2517. {
  2518. iTargetIndex = i;
  2519. }
  2520. else if ( a[i] > iTarget )
  2521. {
  2522. a[i]--;
  2523. }
  2524. }
  2525. if ( iTargetIndex != -1 && splice === undefined )
  2526. {
  2527. a.splice( iTargetIndex, 1 );
  2528. }
  2529. }
  2530. /**
  2531. * Mark cached data as invalid such that a re-read of the data will occur when
  2532. * the cached data is next requested. Also update from the data source object.
  2533. *
  2534. * @param {object} settings DataTables settings object
  2535. * @param {int} rowIdx Row index to invalidate
  2536. * @param {string} [src] Source to invalidate from: undefined, 'auto', 'dom'
  2537. * or 'data'
  2538. * @param {int} [colIdx] Column index to invalidate. If undefined the whole
  2539. * row will be invalidated
  2540. * @memberof DataTable#oApi
  2541. *
  2542. * @todo For the modularisation of v1.11 this will need to become a callback, so
  2543. * the sort and filter methods can subscribe to it. That will required
  2544. * initialisation options for sorting, which is why it is not already baked in
  2545. */
  2546. function _fnInvalidate( settings, rowIdx, src, colIdx )
  2547. {
  2548. var row = settings.aoData[ rowIdx ];
  2549. var i, ien;
  2550. var cellWrite = function ( cell, col ) {
  2551. // This is very frustrating, but in IE if you just write directly
  2552. // to innerHTML, and elements that are overwritten are GC'ed,
  2553. // even if there is a reference to them elsewhere
  2554. while ( cell.childNodes.length ) {
  2555. cell.removeChild( cell.firstChild );
  2556. }
  2557. cell.innerHTML = _fnGetCellData( settings, rowIdx, col, 'display' );
  2558. };
  2559. // Are we reading last data from DOM or the data object?
  2560. if ( src === 'dom' || ((! src || src === 'auto') && row.src === 'dom') ) {
  2561. // Read the data from the DOM
  2562. row._aData = _fnGetRowElements(
  2563. settings, row, colIdx, colIdx === undefined ? undefined : row._aData
  2564. )
  2565. .data;
  2566. }
  2567. else {
  2568. // Reading from data object, update the DOM
  2569. var cells = row.anCells;
  2570. if ( cells ) {
  2571. if ( colIdx !== undefined ) {
  2572. cellWrite( cells[colIdx], colIdx );
  2573. }
  2574. else {
  2575. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  2576. cellWrite( cells[i], i );
  2577. }
  2578. }
  2579. }
  2580. }
  2581. // For both row and cell invalidation, the cached data for sorting and
  2582. // filtering is nulled out
  2583. row._aSortData = null;
  2584. row._aFilterData = null;
  2585. // Invalidate the type for a specific column (if given) or all columns since
  2586. // the data might have changed
  2587. var cols = settings.aoColumns;
  2588. if ( colIdx !== undefined ) {
  2589. cols[ colIdx ].sType = null;
  2590. }
  2591. else {
  2592. for ( i=0, ien=cols.length ; i<ien ; i++ ) {
  2593. cols[i].sType = null;
  2594. }
  2595. // Update DataTables special `DT_*` attributes for the row
  2596. _fnRowAttributes( settings, row );
  2597. }
  2598. }
  2599. /**
  2600. * Build a data source object from an HTML row, reading the contents of the
  2601. * cells that are in the row.
  2602. *
  2603. * @param {object} settings DataTables settings object
  2604. * @param {node|object} TR element from which to read data or existing row
  2605. * object from which to re-read the data from the cells
  2606. * @param {int} [colIdx] Optional column index
  2607. * @param {array|object} [d] Data source object. If `colIdx` is given then this
  2608. * parameter should also be given and will be used to write the data into.
  2609. * Only the column in question will be written
  2610. * @returns {object} Object with two parameters: `data` the data read, in
  2611. * document order, and `cells` and array of nodes (they can be useful to the
  2612. * caller, so rather than needing a second traversal to get them, just return
  2613. * them from here).
  2614. * @memberof DataTable#oApi
  2615. */
  2616. function _fnGetRowElements( settings, row, colIdx, d )
  2617. {
  2618. var
  2619. tds = [],
  2620. td = row.firstChild,
  2621. name, col, o, i=0, contents,
  2622. columns = settings.aoColumns,
  2623. objectRead = settings._rowReadObject;
  2624. // Allow the data object to be passed in, or construct
  2625. d = d !== undefined ?
  2626. d :
  2627. objectRead ?
  2628. {} :
  2629. [];
  2630. var attr = function ( str, td ) {
  2631. if ( typeof str === 'string' ) {
  2632. var idx = str.indexOf('@');
  2633. if ( idx !== -1 ) {
  2634. var attr = str.substring( idx+1 );
  2635. var setter = _fnSetObjectDataFn( str );
  2636. setter( d, td.getAttribute( attr ) );
  2637. }
  2638. }
  2639. };
  2640. // Read data from a cell and store into the data object
  2641. var cellProcess = function ( cell ) {
  2642. if ( colIdx === undefined || colIdx === i ) {
  2643. col = columns[i];
  2644. contents = (cell.innerHTML).trim();
  2645. if ( col && col._bAttrSrc ) {
  2646. var setter = _fnSetObjectDataFn( col.mData._ );
  2647. setter( d, contents );
  2648. attr( col.mData.sort, cell );
  2649. attr( col.mData.type, cell );
  2650. attr( col.mData.filter, cell );
  2651. }
  2652. else {
  2653. // Depending on the `data` option for the columns the data can
  2654. // be read to either an object or an array.
  2655. if ( objectRead ) {
  2656. if ( ! col._setter ) {
  2657. // Cache the setter function
  2658. col._setter = _fnSetObjectDataFn( col.mData );
  2659. }
  2660. col._setter( d, contents );
  2661. }
  2662. else {
  2663. d[i] = contents;
  2664. }
  2665. }
  2666. }
  2667. i++;
  2668. };
  2669. if ( td ) {
  2670. // `tr` element was passed in
  2671. while ( td ) {
  2672. name = td.nodeName.toUpperCase();
  2673. if ( name == "TD" || name == "TH" ) {
  2674. cellProcess( td );
  2675. tds.push( td );
  2676. }
  2677. td = td.nextSibling;
  2678. }
  2679. }
  2680. else {
  2681. // Existing row object passed in
  2682. tds = row.anCells;
  2683. for ( var j=0, jen=tds.length ; j<jen ; j++ ) {
  2684. cellProcess( tds[j] );
  2685. }
  2686. }
  2687. // Read the ID from the DOM if present
  2688. var rowNode = row.firstChild ? row : row.nTr;
  2689. if ( rowNode ) {
  2690. var id = rowNode.getAttribute( 'id' );
  2691. if ( id ) {
  2692. _fnSetObjectDataFn( settings.rowId )( d, id );
  2693. }
  2694. }
  2695. return {
  2696. data: d,
  2697. cells: tds
  2698. };
  2699. }
  2700. /**
  2701. * Create a new TR element (and it's TD children) for a row
  2702. * @param {object} oSettings dataTables settings object
  2703. * @param {int} iRow Row to consider
  2704. * @param {node} [nTrIn] TR element to add to the table - optional. If not given,
  2705. * DataTables will create a row automatically
  2706. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  2707. * if nTr is.
  2708. * @memberof DataTable#oApi
  2709. */
  2710. function _fnCreateTr ( oSettings, iRow, nTrIn, anTds )
  2711. {
  2712. var
  2713. row = oSettings.aoData[iRow],
  2714. rowData = row._aData,
  2715. cells = [],
  2716. nTr, nTd, oCol,
  2717. i, iLen, create;
  2718. if ( row.nTr === null )
  2719. {
  2720. nTr = nTrIn || document.createElement('tr');
  2721. row.nTr = nTr;
  2722. row.anCells = cells;
  2723. /* Use a private property on the node to allow reserve mapping from the node
  2724. * to the aoData array for fast look up
  2725. */
  2726. nTr._DT_RowIndex = iRow;
  2727. /* Special parameters can be given by the data source to be used on the row */
  2728. _fnRowAttributes( oSettings, row );
  2729. /* Process each column */
  2730. for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
  2731. {
  2732. oCol = oSettings.aoColumns[i];
  2733. create = nTrIn ? false : true;
  2734. nTd = create ? document.createElement( oCol.sCellType ) : anTds[i];
  2735. nTd._DT_CellIndex = {
  2736. row: iRow,
  2737. column: i
  2738. };
  2739. cells.push( nTd );
  2740. // Need to create the HTML if new, or if a rendering function is defined
  2741. if ( create || ((oCol.mRender || oCol.mData !== i) &&
  2742. (!$.isPlainObject(oCol.mData) || oCol.mData._ !== i+'.display')
  2743. )) {
  2744. nTd.innerHTML = _fnGetCellData( oSettings, iRow, i, 'display' );
  2745. }
  2746. /* Add user defined class */
  2747. if ( oCol.sClass )
  2748. {
  2749. nTd.className += ' '+oCol.sClass;
  2750. }
  2751. // Visibility - add or remove as required
  2752. if ( oCol.bVisible && ! nTrIn )
  2753. {
  2754. nTr.appendChild( nTd );
  2755. }
  2756. else if ( ! oCol.bVisible && nTrIn )
  2757. {
  2758. nTd.parentNode.removeChild( nTd );
  2759. }
  2760. if ( oCol.fnCreatedCell )
  2761. {
  2762. oCol.fnCreatedCell.call( oSettings.oInstance,
  2763. nTd, _fnGetCellData( oSettings, iRow, i ), rowData, iRow, i
  2764. );
  2765. }
  2766. }
  2767. _fnCallbackFire( oSettings, 'aoRowCreatedCallback', null, [nTr, rowData, iRow, cells] );
  2768. }
  2769. }
  2770. /**
  2771. * Add attributes to a row based on the special `DT_*` parameters in a data
  2772. * source object.
  2773. * @param {object} settings DataTables settings object
  2774. * @param {object} DataTables row object for the row to be modified
  2775. * @memberof DataTable#oApi
  2776. */
  2777. function _fnRowAttributes( settings, row )
  2778. {
  2779. var tr = row.nTr;
  2780. var data = row._aData;
  2781. if ( tr ) {
  2782. var id = settings.rowIdFn( data );
  2783. if ( id ) {
  2784. tr.id = id;
  2785. }
  2786. if ( data.DT_RowClass ) {
  2787. // Remove any classes added by DT_RowClass before
  2788. var a = data.DT_RowClass.split(' ');
  2789. row.__rowc = row.__rowc ?
  2790. _unique( row.__rowc.concat( a ) ) :
  2791. a;
  2792. $(tr)
  2793. .removeClass( row.__rowc.join(' ') )
  2794. .addClass( data.DT_RowClass );
  2795. }
  2796. if ( data.DT_RowAttr ) {
  2797. $(tr).attr( data.DT_RowAttr );
  2798. }
  2799. if ( data.DT_RowData ) {
  2800. $(tr).data( data.DT_RowData );
  2801. }
  2802. }
  2803. }
  2804. /**
  2805. * Create the HTML header for the table
  2806. * @param {object} oSettings dataTables settings object
  2807. * @memberof DataTable#oApi
  2808. */
  2809. function _fnBuildHead( oSettings )
  2810. {
  2811. var i, ien, cell, row, column;
  2812. var thead = oSettings.nTHead;
  2813. var tfoot = oSettings.nTFoot;
  2814. var createHeader = $('th, td', thead).length === 0;
  2815. var classes = oSettings.oClasses;
  2816. var columns = oSettings.aoColumns;
  2817. if ( createHeader ) {
  2818. row = $('<tr/>').appendTo( thead );
  2819. }
  2820. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  2821. column = columns[i];
  2822. cell = $( column.nTh ).addClass( column.sClass );
  2823. if ( createHeader ) {
  2824. cell.appendTo( row );
  2825. }
  2826. // 1.11 move into sorting
  2827. if ( oSettings.oFeatures.bSort ) {
  2828. cell.addClass( column.sSortingClass );
  2829. if ( column.bSortable !== false ) {
  2830. cell
  2831. .attr( 'tabindex', oSettings.iTabIndex )
  2832. .attr( 'aria-controls', oSettings.sTableId );
  2833. _fnSortAttachListener( oSettings, column.nTh, i );
  2834. }
  2835. }
  2836. if ( column.sTitle != cell[0].innerHTML ) {
  2837. cell.html( column.sTitle );
  2838. }
  2839. _fnRenderer( oSettings, 'header' )(
  2840. oSettings, cell, column, classes
  2841. );
  2842. }
  2843. if ( createHeader ) {
  2844. _fnDetectHeader( oSettings.aoHeader, thead );
  2845. }
  2846. /* ARIA role for the rows */
  2847. $(thead).children('tr').attr('role', 'row');
  2848. /* Deal with the footer - add classes if required */
  2849. $(thead).children('tr').children('th, td').addClass( classes.sHeaderTH );
  2850. $(tfoot).children('tr').children('th, td').addClass( classes.sFooterTH );
  2851. // Cache the footer cells. Note that we only take the cells from the first
  2852. // row in the footer. If there is more than one row the user wants to
  2853. // interact with, they need to use the table().foot() method. Note also this
  2854. // allows cells to be used for multiple columns using colspan
  2855. if ( tfoot !== null ) {
  2856. var cells = oSettings.aoFooter[0];
  2857. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  2858. column = columns[i];
  2859. column.nTf = cells[i].cell;
  2860. if ( column.sClass ) {
  2861. $(column.nTf).addClass( column.sClass );
  2862. }
  2863. }
  2864. }
  2865. }
  2866. /**
  2867. * Draw the header (or footer) element based on the column visibility states. The
  2868. * methodology here is to use the layout array from _fnDetectHeader, modified for
  2869. * the instantaneous column visibility, to construct the new layout. The grid is
  2870. * traversed over cell at a time in a rows x columns grid fashion, although each
  2871. * cell insert can cover multiple elements in the grid - which is tracks using the
  2872. * aApplied array. Cell inserts in the grid will only occur where there isn't
  2873. * already a cell in that position.
  2874. * @param {object} oSettings dataTables settings object
  2875. * @param array {objects} aoSource Layout array from _fnDetectHeader
  2876. * @param {boolean} [bIncludeHidden=false] If true then include the hidden columns in the calc,
  2877. * @memberof DataTable#oApi
  2878. */
  2879. function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
  2880. {
  2881. var i, iLen, j, jLen, k, kLen, n, nLocalTr;
  2882. var aoLocal = [];
  2883. var aApplied = [];
  2884. var iColumns = oSettings.aoColumns.length;
  2885. var iRowspan, iColspan;
  2886. if ( ! aoSource )
  2887. {
  2888. return;
  2889. }
  2890. if ( bIncludeHidden === undefined )
  2891. {
  2892. bIncludeHidden = false;
  2893. }
  2894. /* Make a copy of the master layout array, but without the visible columns in it */
  2895. for ( i=0, iLen=aoSource.length ; i<iLen ; i++ )
  2896. {
  2897. aoLocal[i] = aoSource[i].slice();
  2898. aoLocal[i].nTr = aoSource[i].nTr;
  2899. /* Remove any columns which are currently hidden */
  2900. for ( j=iColumns-1 ; j>=0 ; j-- )
  2901. {
  2902. if ( !oSettings.aoColumns[j].bVisible && !bIncludeHidden )
  2903. {
  2904. aoLocal[i].splice( j, 1 );
  2905. }
  2906. }
  2907. /* Prep the applied array - it needs an element for each row */
  2908. aApplied.push( [] );
  2909. }
  2910. for ( i=0, iLen=aoLocal.length ; i<iLen ; i++ )
  2911. {
  2912. nLocalTr = aoLocal[i].nTr;
  2913. /* All cells are going to be replaced, so empty out the row */
  2914. if ( nLocalTr )
  2915. {
  2916. while( (n = nLocalTr.firstChild) )
  2917. {
  2918. nLocalTr.removeChild( n );
  2919. }
  2920. }
  2921. for ( j=0, jLen=aoLocal[i].length ; j<jLen ; j++ )
  2922. {
  2923. iRowspan = 1;
  2924. iColspan = 1;
  2925. /* Check to see if there is already a cell (row/colspan) covering our target
  2926. * insert point. If there is, then there is nothing to do.
  2927. */
  2928. if ( aApplied[i][j] === undefined )
  2929. {
  2930. nLocalTr.appendChild( aoLocal[i][j].cell );
  2931. aApplied[i][j] = 1;
  2932. /* Expand the cell to cover as many rows as needed */
  2933. while ( aoLocal[i+iRowspan] !== undefined &&
  2934. aoLocal[i][j].cell == aoLocal[i+iRowspan][j].cell )
  2935. {
  2936. aApplied[i+iRowspan][j] = 1;
  2937. iRowspan++;
  2938. }
  2939. /* Expand the cell to cover as many columns as needed */
  2940. while ( aoLocal[i][j+iColspan] !== undefined &&
  2941. aoLocal[i][j].cell == aoLocal[i][j+iColspan].cell )
  2942. {
  2943. /* Must update the applied array over the rows for the columns */
  2944. for ( k=0 ; k<iRowspan ; k++ )
  2945. {
  2946. aApplied[i+k][j+iColspan] = 1;
  2947. }
  2948. iColspan++;
  2949. }
  2950. /* Do the actual expansion in the DOM */
  2951. $(aoLocal[i][j].cell)
  2952. .attr('rowspan', iRowspan)
  2953. .attr('colspan', iColspan);
  2954. }
  2955. }
  2956. }
  2957. }
  2958. /**
  2959. * Insert the required TR nodes into the table for display
  2960. * @param {object} oSettings dataTables settings object
  2961. * @memberof DataTable#oApi
  2962. */
  2963. function _fnDraw( oSettings )
  2964. {
  2965. /* Provide a pre-callback function which can be used to cancel the draw is false is returned */
  2966. var aPreDraw = _fnCallbackFire( oSettings, 'aoPreDrawCallback', 'preDraw', [oSettings] );
  2967. if ( $.inArray( false, aPreDraw ) !== -1 )
  2968. {
  2969. _fnProcessingDisplay( oSettings, false );
  2970. return;
  2971. }
  2972. var i, iLen, n;
  2973. var anRows = [];
  2974. var iRowCount = 0;
  2975. var asStripeClasses = oSettings.asStripeClasses;
  2976. var iStripes = asStripeClasses.length;
  2977. var iOpenRows = oSettings.aoOpenRows.length;
  2978. var oLang = oSettings.oLanguage;
  2979. var iInitDisplayStart = oSettings.iInitDisplayStart;
  2980. var bServerSide = _fnDataSource( oSettings ) == 'ssp';
  2981. var aiDisplay = oSettings.aiDisplay;
  2982. oSettings.bDrawing = true;
  2983. /* Check and see if we have an initial draw position from state saving */
  2984. if ( iInitDisplayStart !== undefined && iInitDisplayStart !== -1 )
  2985. {
  2986. oSettings._iDisplayStart = bServerSide ?
  2987. iInitDisplayStart :
  2988. iInitDisplayStart >= oSettings.fnRecordsDisplay() ?
  2989. 0 :
  2990. iInitDisplayStart;
  2991. oSettings.iInitDisplayStart = -1;
  2992. }
  2993. var iDisplayStart = oSettings._iDisplayStart;
  2994. var iDisplayEnd = oSettings.fnDisplayEnd();
  2995. /* Server-side processing draw intercept */
  2996. if ( oSettings.bDeferLoading )
  2997. {
  2998. oSettings.bDeferLoading = false;
  2999. oSettings.iDraw++;
  3000. _fnProcessingDisplay( oSettings, false );
  3001. }
  3002. else if ( !bServerSide )
  3003. {
  3004. oSettings.iDraw++;
  3005. }
  3006. else if ( !oSettings.bDestroying && !_fnAjaxUpdate( oSettings ) )
  3007. {
  3008. return;
  3009. }
  3010. if ( aiDisplay.length !== 0 )
  3011. {
  3012. var iStart = bServerSide ? 0 : iDisplayStart;
  3013. var iEnd = bServerSide ? oSettings.aoData.length : iDisplayEnd;
  3014. for ( var j=iStart ; j<iEnd ; j++ )
  3015. {
  3016. var iDataIndex = aiDisplay[j];
  3017. var aoData = oSettings.aoData[ iDataIndex ];
  3018. if ( aoData.nTr === null )
  3019. {
  3020. _fnCreateTr( oSettings, iDataIndex );
  3021. }
  3022. var nRow = aoData.nTr;
  3023. /* Remove the old striping classes and then add the new one */
  3024. if ( iStripes !== 0 )
  3025. {
  3026. var sStripe = asStripeClasses[ iRowCount % iStripes ];
  3027. if ( aoData._sRowStripe != sStripe )
  3028. {
  3029. $(nRow).removeClass( aoData._sRowStripe ).addClass( sStripe );
  3030. aoData._sRowStripe = sStripe;
  3031. }
  3032. }
  3033. // Row callback functions - might want to manipulate the row
  3034. // iRowCount and j are not currently documented. Are they at all
  3035. // useful?
  3036. _fnCallbackFire( oSettings, 'aoRowCallback', null,
  3037. [nRow, aoData._aData, iRowCount, j, iDataIndex] );
  3038. anRows.push( nRow );
  3039. iRowCount++;
  3040. }
  3041. }
  3042. else
  3043. {
  3044. /* Table is empty - create a row with an empty message in it */
  3045. var sZero = oLang.sZeroRecords;
  3046. if ( oSettings.iDraw == 1 && _fnDataSource( oSettings ) == 'ajax' )
  3047. {
  3048. sZero = oLang.sLoadingRecords;
  3049. }
  3050. else if ( oLang.sEmptyTable && oSettings.fnRecordsTotal() === 0 )
  3051. {
  3052. sZero = oLang.sEmptyTable;
  3053. }
  3054. anRows[ 0 ] = $( '<tr/>', { 'class': iStripes ? asStripeClasses[0] : '' } )
  3055. .append( $('<td />', {
  3056. 'valign': 'top',
  3057. 'colSpan': _fnVisbleColumns( oSettings ),
  3058. 'class': oSettings.oClasses.sRowEmpty
  3059. } ).html( sZero ) )[0];
  3060. }
  3061. /* Header and footer callbacks */
  3062. _fnCallbackFire( oSettings, 'aoHeaderCallback', 'header', [ $(oSettings.nTHead).children('tr')[0],
  3063. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  3064. _fnCallbackFire( oSettings, 'aoFooterCallback', 'footer', [ $(oSettings.nTFoot).children('tr')[0],
  3065. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  3066. var body = $(oSettings.nTBody);
  3067. body.children().detach();
  3068. body.append( $(anRows) );
  3069. /* Call all required callback functions for the end of a draw */
  3070. _fnCallbackFire( oSettings, 'aoDrawCallback', 'draw', [oSettings] );
  3071. /* Draw is complete, sorting and filtering must be as well */
  3072. oSettings.bSorted = false;
  3073. oSettings.bFiltered = false;
  3074. oSettings.bDrawing = false;
  3075. }
  3076. /**
  3077. * Redraw the table - taking account of the various features which are enabled
  3078. * @param {object} oSettings dataTables settings object
  3079. * @param {boolean} [holdPosition] Keep the current paging position. By default
  3080. * the paging is reset to the first page
  3081. * @memberof DataTable#oApi
  3082. */
  3083. function _fnReDraw( settings, holdPosition )
  3084. {
  3085. var
  3086. features = settings.oFeatures,
  3087. sort = features.bSort,
  3088. filter = features.bFilter;
  3089. if ( sort ) {
  3090. _fnSort( settings );
  3091. }
  3092. if ( filter ) {
  3093. _fnFilterComplete( settings, settings.oPreviousSearch );
  3094. }
  3095. else {
  3096. // No filtering, so we want to just use the display master
  3097. settings.aiDisplay = settings.aiDisplayMaster.slice();
  3098. }
  3099. if ( holdPosition !== true ) {
  3100. settings._iDisplayStart = 0;
  3101. }
  3102. // Let any modules know about the draw hold position state (used by
  3103. // scrolling internally)
  3104. settings._drawHold = holdPosition;
  3105. _fnDraw( settings );
  3106. settings._drawHold = false;
  3107. }
  3108. /**
  3109. * Add the options to the page HTML for the table
  3110. * @param {object} oSettings dataTables settings object
  3111. * @memberof DataTable#oApi
  3112. */
  3113. function _fnAddOptionsHtml ( oSettings )
  3114. {
  3115. var classes = oSettings.oClasses;
  3116. var table = $(oSettings.nTable);
  3117. var holding = $('<div/>').insertBefore( table ); // Holding element for speed
  3118. var features = oSettings.oFeatures;
  3119. // All DataTables are wrapped in a div
  3120. var insert = $('<div/>', {
  3121. id: oSettings.sTableId+'_wrapper',
  3122. 'class': classes.sWrapper + (oSettings.nTFoot ? '' : ' '+classes.sNoFooter)
  3123. } );
  3124. oSettings.nHolding = holding[0];
  3125. oSettings.nTableWrapper = insert[0];
  3126. oSettings.nTableReinsertBefore = oSettings.nTable.nextSibling;
  3127. /* Loop over the user set positioning and place the elements as needed */
  3128. var aDom = oSettings.sDom.split('');
  3129. var featureNode, cOption, nNewNode, cNext, sAttr, j;
  3130. for ( var i=0 ; i<aDom.length ; i++ )
  3131. {
  3132. featureNode = null;
  3133. cOption = aDom[i];
  3134. if ( cOption == '<' )
  3135. {
  3136. /* New container div */
  3137. nNewNode = $('<div/>')[0];
  3138. /* Check to see if we should append an id and/or a class name to the container */
  3139. cNext = aDom[i+1];
  3140. if ( cNext == "'" || cNext == '"' )
  3141. {
  3142. sAttr = "";
  3143. j = 2;
  3144. while ( aDom[i+j] != cNext )
  3145. {
  3146. sAttr += aDom[i+j];
  3147. j++;
  3148. }
  3149. /* Replace jQuery UI constants @todo depreciated */
  3150. if ( sAttr == "H" )
  3151. {
  3152. sAttr = classes.sJUIHeader;
  3153. }
  3154. else if ( sAttr == "F" )
  3155. {
  3156. sAttr = classes.sJUIFooter;
  3157. }
  3158. /* The attribute can be in the format of "#id.class", "#id" or "class" This logic
  3159. * breaks the string into parts and applies them as needed
  3160. */
  3161. if ( sAttr.indexOf('.') != -1 )
  3162. {
  3163. var aSplit = sAttr.split('.');
  3164. nNewNode.id = aSplit[0].substr(1, aSplit[0].length-1);
  3165. nNewNode.className = aSplit[1];
  3166. }
  3167. else if ( sAttr.charAt(0) == "#" )
  3168. {
  3169. nNewNode.id = sAttr.substr(1, sAttr.length-1);
  3170. }
  3171. else
  3172. {
  3173. nNewNode.className = sAttr;
  3174. }
  3175. i += j; /* Move along the position array */
  3176. }
  3177. insert.append( nNewNode );
  3178. insert = $(nNewNode);
  3179. }
  3180. else if ( cOption == '>' )
  3181. {
  3182. /* End container div */
  3183. insert = insert.parent();
  3184. }
  3185. // @todo Move options into their own plugins?
  3186. else if ( cOption == 'l' && features.bPaginate && features.bLengthChange )
  3187. {
  3188. /* Length */
  3189. featureNode = _fnFeatureHtmlLength( oSettings );
  3190. }
  3191. else if ( cOption == 'f' && features.bFilter )
  3192. {
  3193. /* Filter */
  3194. featureNode = _fnFeatureHtmlFilter( oSettings );
  3195. }
  3196. else if ( cOption == 'r' && features.bProcessing )
  3197. {
  3198. /* pRocessing */
  3199. featureNode = _fnFeatureHtmlProcessing( oSettings );
  3200. }
  3201. else if ( cOption == 't' )
  3202. {
  3203. /* Table */
  3204. featureNode = _fnFeatureHtmlTable( oSettings );
  3205. }
  3206. else if ( cOption == 'i' && features.bInfo )
  3207. {
  3208. /* Info */
  3209. featureNode = _fnFeatureHtmlInfo( oSettings );
  3210. }
  3211. else if ( cOption == 'p' && features.bPaginate )
  3212. {
  3213. /* Pagination */
  3214. featureNode = _fnFeatureHtmlPaginate( oSettings );
  3215. }
  3216. else if ( DataTable.ext.feature.length !== 0 )
  3217. {
  3218. /* Plug-in features */
  3219. var aoFeatures = DataTable.ext.feature;
  3220. for ( var k=0, kLen=aoFeatures.length ; k<kLen ; k++ )
  3221. {
  3222. if ( cOption == aoFeatures[k].cFeature )
  3223. {
  3224. featureNode = aoFeatures[k].fnInit( oSettings );
  3225. break;
  3226. }
  3227. }
  3228. }
  3229. /* Add to the 2D features array */
  3230. if ( featureNode )
  3231. {
  3232. var aanFeatures = oSettings.aanFeatures;
  3233. if ( ! aanFeatures[cOption] )
  3234. {
  3235. aanFeatures[cOption] = [];
  3236. }
  3237. aanFeatures[cOption].push( featureNode );
  3238. insert.append( featureNode );
  3239. }
  3240. }
  3241. /* Built our DOM structure - replace the holding div with what we want */
  3242. holding.replaceWith( insert );
  3243. oSettings.nHolding = null;
  3244. }
  3245. /**
  3246. * Use the DOM source to create up an array of header cells. The idea here is to
  3247. * create a layout grid (array) of rows x columns, which contains a reference
  3248. * to the cell that that point in the grid (regardless of col/rowspan), such that
  3249. * any column / row could be removed and the new grid constructed
  3250. * @param array {object} aLayout Array to store the calculated layout in
  3251. * @param {node} nThead The header/footer element for the table
  3252. * @memberof DataTable#oApi
  3253. */
  3254. function _fnDetectHeader ( aLayout, nThead )
  3255. {
  3256. var nTrs = $(nThead).children('tr');
  3257. var nTr, nCell;
  3258. var i, k, l, iLen, jLen, iColShifted, iColumn, iColspan, iRowspan;
  3259. var bUnique;
  3260. var fnShiftCol = function ( a, i, j ) {
  3261. var k = a[i];
  3262. while ( k[j] ) {
  3263. j++;
  3264. }
  3265. return j;
  3266. };
  3267. aLayout.splice( 0, aLayout.length );
  3268. /* We know how many rows there are in the layout - so prep it */
  3269. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  3270. {
  3271. aLayout.push( [] );
  3272. }
  3273. /* Calculate a layout array */
  3274. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  3275. {
  3276. nTr = nTrs[i];
  3277. iColumn = 0;
  3278. /* For every cell in the row... */
  3279. nCell = nTr.firstChild;
  3280. while ( nCell ) {
  3281. if ( nCell.nodeName.toUpperCase() == "TD" ||
  3282. nCell.nodeName.toUpperCase() == "TH" )
  3283. {
  3284. /* Get the col and rowspan attributes from the DOM and sanitise them */
  3285. iColspan = nCell.getAttribute('colspan') * 1;
  3286. iRowspan = nCell.getAttribute('rowspan') * 1;
  3287. iColspan = (!iColspan || iColspan===0 || iColspan===1) ? 1 : iColspan;
  3288. iRowspan = (!iRowspan || iRowspan===0 || iRowspan===1) ? 1 : iRowspan;
  3289. /* There might be colspan cells already in this row, so shift our target
  3290. * accordingly
  3291. */
  3292. iColShifted = fnShiftCol( aLayout, i, iColumn );
  3293. /* Cache calculation for unique columns */
  3294. bUnique = iColspan === 1 ? true : false;
  3295. /* If there is col / rowspan, copy the information into the layout grid */
  3296. for ( l=0 ; l<iColspan ; l++ )
  3297. {
  3298. for ( k=0 ; k<iRowspan ; k++ )
  3299. {
  3300. aLayout[i+k][iColShifted+l] = {
  3301. "cell": nCell,
  3302. "unique": bUnique
  3303. };
  3304. aLayout[i+k].nTr = nTr;
  3305. }
  3306. }
  3307. }
  3308. nCell = nCell.nextSibling;
  3309. }
  3310. }
  3311. }
  3312. /**
  3313. * Get an array of unique th elements, one for each column
  3314. * @param {object} oSettings dataTables settings object
  3315. * @param {node} nHeader automatically detect the layout from this node - optional
  3316. * @param {array} aLayout thead/tfoot layout from _fnDetectHeader - optional
  3317. * @returns array {node} aReturn list of unique th's
  3318. * @memberof DataTable#oApi
  3319. */
  3320. function _fnGetUniqueThs ( oSettings, nHeader, aLayout )
  3321. {
  3322. var aReturn = [];
  3323. if ( !aLayout )
  3324. {
  3325. aLayout = oSettings.aoHeader;
  3326. if ( nHeader )
  3327. {
  3328. aLayout = [];
  3329. _fnDetectHeader( aLayout, nHeader );
  3330. }
  3331. }
  3332. for ( var i=0, iLen=aLayout.length ; i<iLen ; i++ )
  3333. {
  3334. for ( var j=0, jLen=aLayout[i].length ; j<jLen ; j++ )
  3335. {
  3336. if ( aLayout[i][j].unique &&
  3337. (!aReturn[j] || !oSettings.bSortCellsTop) )
  3338. {
  3339. aReturn[j] = aLayout[i][j].cell;
  3340. }
  3341. }
  3342. }
  3343. return aReturn;
  3344. }
  3345. /**
  3346. * Create an Ajax call based on the table's settings, taking into account that
  3347. * parameters can have multiple forms, and backwards compatibility.
  3348. *
  3349. * @param {object} oSettings dataTables settings object
  3350. * @param {array} data Data to send to the server, required by
  3351. * DataTables - may be augmented by developer callbacks
  3352. * @param {function} fn Callback function to run when data is obtained
  3353. */
  3354. function _fnBuildAjax( oSettings, data, fn )
  3355. {
  3356. // Compatibility with 1.9-, allow fnServerData and event to manipulate
  3357. _fnCallbackFire( oSettings, 'aoServerParams', 'serverParams', [data] );
  3358. // Convert to object based for 1.10+ if using the old array scheme which can
  3359. // come from server-side processing or serverParams
  3360. if ( data && Array.isArray(data) ) {
  3361. var tmp = {};
  3362. var rbracket = /(.*?)\[\]$/;
  3363. $.each( data, function (key, val) {
  3364. var match = val.name.match(rbracket);
  3365. if ( match ) {
  3366. // Support for arrays
  3367. var name = match[0];
  3368. if ( ! tmp[ name ] ) {
  3369. tmp[ name ] = [];
  3370. }
  3371. tmp[ name ].push( val.value );
  3372. }
  3373. else {
  3374. tmp[val.name] = val.value;
  3375. }
  3376. } );
  3377. data = tmp;
  3378. }
  3379. var ajaxData;
  3380. var ajax = oSettings.ajax;
  3381. var instance = oSettings.oInstance;
  3382. var callback = function ( json ) {
  3383. _fnCallbackFire( oSettings, null, 'xhr', [oSettings, json, oSettings.jqXHR] );
  3384. fn( json );
  3385. };
  3386. if ( $.isPlainObject( ajax ) && ajax.data )
  3387. {
  3388. ajaxData = ajax.data;
  3389. var newData = typeof ajaxData === 'function' ?
  3390. ajaxData( data, oSettings ) : // fn can manipulate data or return
  3391. ajaxData; // an object object or array to merge
  3392. // If the function returned something, use that alone
  3393. data = typeof ajaxData === 'function' && newData ?
  3394. newData :
  3395. $.extend( true, data, newData );
  3396. // Remove the data property as we've resolved it already and don't want
  3397. // jQuery to do it again (it is restored at the end of the function)
  3398. delete ajax.data;
  3399. }
  3400. var baseAjax = {
  3401. "data": data,
  3402. "success": function (json) {
  3403. var error = json.error || json.sError;
  3404. if ( error ) {
  3405. _fnLog( oSettings, 0, error );
  3406. }
  3407. oSettings.json = json;
  3408. callback( json );
  3409. },
  3410. "dataType": "json",
  3411. "cache": false,
  3412. "type": oSettings.sServerMethod,
  3413. "error": function (xhr, error, thrown) {
  3414. var ret = _fnCallbackFire( oSettings, null, 'xhr', [oSettings, null, oSettings.jqXHR] );
  3415. if ( $.inArray( true, ret ) === -1 ) {
  3416. if ( error == "parsererror" ) {
  3417. _fnLog( oSettings, 0, 'Invalid JSON response', 1 );
  3418. }
  3419. else if ( xhr.readyState === 4 ) {
  3420. _fnLog( oSettings, 0, 'Ajax error', 7 );
  3421. }
  3422. }
  3423. _fnProcessingDisplay( oSettings, false );
  3424. }
  3425. };
  3426. // Store the data submitted for the API
  3427. oSettings.oAjaxData = data;
  3428. // Allow plug-ins and external processes to modify the data
  3429. _fnCallbackFire( oSettings, null, 'preXhr', [oSettings, data] );
  3430. if ( oSettings.fnServerData )
  3431. {
  3432. // DataTables 1.9- compatibility
  3433. oSettings.fnServerData.call( instance,
  3434. oSettings.sAjaxSource,
  3435. $.map( data, function (val, key) { // Need to convert back to 1.9 trad format
  3436. return { name: key, value: val };
  3437. } ),
  3438. callback,
  3439. oSettings
  3440. );
  3441. }
  3442. else if ( oSettings.sAjaxSource || typeof ajax === 'string' )
  3443. {
  3444. // DataTables 1.9- compatibility
  3445. oSettings.jqXHR = $.ajax( $.extend( baseAjax, {
  3446. url: ajax || oSettings.sAjaxSource
  3447. } ) );
  3448. }
  3449. else if ( typeof ajax === 'function' )
  3450. {
  3451. // Is a function - let the caller define what needs to be done
  3452. oSettings.jqXHR = ajax.call( instance, data, callback, oSettings );
  3453. }
  3454. else
  3455. {
  3456. // Object to extend the base settings
  3457. oSettings.jqXHR = $.ajax( $.extend( baseAjax, ajax ) );
  3458. // Restore for next time around
  3459. ajax.data = ajaxData;
  3460. }
  3461. }
  3462. /**
  3463. * Update the table using an Ajax call
  3464. * @param {object} settings dataTables settings object
  3465. * @returns {boolean} Block the table drawing or not
  3466. * @memberof DataTable#oApi
  3467. */
  3468. function _fnAjaxUpdate( settings )
  3469. {
  3470. if ( settings.bAjaxDataGet ) {
  3471. settings.iDraw++;
  3472. _fnProcessingDisplay( settings, true );
  3473. _fnBuildAjax(
  3474. settings,
  3475. _fnAjaxParameters( settings ),
  3476. function(json) {
  3477. _fnAjaxUpdateDraw( settings, json );
  3478. }
  3479. );
  3480. return false;
  3481. }
  3482. return true;
  3483. }
  3484. /**
  3485. * Build up the parameters in an object needed for a server-side processing
  3486. * request. Note that this is basically done twice, is different ways - a modern
  3487. * method which is used by default in DataTables 1.10 which uses objects and
  3488. * arrays, or the 1.9- method with is name / value pairs. 1.9 method is used if
  3489. * the sAjaxSource option is used in the initialisation, or the legacyAjax
  3490. * option is set.
  3491. * @param {object} oSettings dataTables settings object
  3492. * @returns {bool} block the table drawing or not
  3493. * @memberof DataTable#oApi
  3494. */
  3495. function _fnAjaxParameters( settings )
  3496. {
  3497. var
  3498. columns = settings.aoColumns,
  3499. columnCount = columns.length,
  3500. features = settings.oFeatures,
  3501. preSearch = settings.oPreviousSearch,
  3502. preColSearch = settings.aoPreSearchCols,
  3503. i, data = [], dataProp, column, columnSearch,
  3504. sort = _fnSortFlatten( settings ),
  3505. displayStart = settings._iDisplayStart,
  3506. displayLength = features.bPaginate !== false ?
  3507. settings._iDisplayLength :
  3508. -1;
  3509. var param = function ( name, value ) {
  3510. data.push( { 'name': name, 'value': value } );
  3511. };
  3512. // DataTables 1.9- compatible method
  3513. param( 'sEcho', settings.iDraw );
  3514. param( 'iColumns', columnCount );
  3515. param( 'sColumns', _pluck( columns, 'sName' ).join(',') );
  3516. param( 'iDisplayStart', displayStart );
  3517. param( 'iDisplayLength', displayLength );
  3518. // DataTables 1.10+ method
  3519. var d = {
  3520. draw: settings.iDraw,
  3521. columns: [],
  3522. order: [],
  3523. start: displayStart,
  3524. length: displayLength,
  3525. search: {
  3526. value: preSearch.sSearch,
  3527. regex: preSearch.bRegex
  3528. }
  3529. };
  3530. for ( i=0 ; i<columnCount ; i++ ) {
  3531. column = columns[i];
  3532. columnSearch = preColSearch[i];
  3533. dataProp = typeof column.mData=="function" ? 'function' : column.mData ;
  3534. d.columns.push( {
  3535. data: dataProp,
  3536. name: column.sName,
  3537. searchable: column.bSearchable,
  3538. orderable: column.bSortable,
  3539. search: {
  3540. value: columnSearch.sSearch,
  3541. regex: columnSearch.bRegex
  3542. }
  3543. } );
  3544. param( "mDataProp_"+i, dataProp );
  3545. if ( features.bFilter ) {
  3546. param( 'sSearch_'+i, columnSearch.sSearch );
  3547. param( 'bRegex_'+i, columnSearch.bRegex );
  3548. param( 'bSearchable_'+i, column.bSearchable );
  3549. }
  3550. if ( features.bSort ) {
  3551. param( 'bSortable_'+i, column.bSortable );
  3552. }
  3553. }
  3554. if ( features.bFilter ) {
  3555. param( 'sSearch', preSearch.sSearch );
  3556. param( 'bRegex', preSearch.bRegex );
  3557. }
  3558. if ( features.bSort ) {
  3559. $.each( sort, function ( i, val ) {
  3560. d.order.push( { column: val.col, dir: val.dir } );
  3561. param( 'iSortCol_'+i, val.col );
  3562. param( 'sSortDir_'+i, val.dir );
  3563. } );
  3564. param( 'iSortingCols', sort.length );
  3565. }
  3566. // If the legacy.ajax parameter is null, then we automatically decide which
  3567. // form to use, based on sAjaxSource
  3568. var legacy = DataTable.ext.legacy.ajax;
  3569. if ( legacy === null ) {
  3570. return settings.sAjaxSource ? data : d;
  3571. }
  3572. // Otherwise, if legacy has been specified then we use that to decide on the
  3573. // form
  3574. return legacy ? data : d;
  3575. }
  3576. /**
  3577. * Data the data from the server (nuking the old) and redraw the table
  3578. * @param {object} oSettings dataTables settings object
  3579. * @param {object} json json data return from the server.
  3580. * @param {string} json.sEcho Tracking flag for DataTables to match requests
  3581. * @param {int} json.iTotalRecords Number of records in the data set, not accounting for filtering
  3582. * @param {int} json.iTotalDisplayRecords Number of records in the data set, accounting for filtering
  3583. * @param {array} json.aaData The data to display on this page
  3584. * @param {string} [json.sColumns] Column ordering (sName, comma separated)
  3585. * @memberof DataTable#oApi
  3586. */
  3587. function _fnAjaxUpdateDraw ( settings, json )
  3588. {
  3589. // v1.10 uses camelCase variables, while 1.9 uses Hungarian notation.
  3590. // Support both
  3591. var compat = function ( old, modern ) {
  3592. return json[old] !== undefined ? json[old] : json[modern];
  3593. };
  3594. var data = _fnAjaxDataSrc( settings, json );
  3595. var draw = compat( 'sEcho', 'draw' );
  3596. var recordsTotal = compat( 'iTotalRecords', 'recordsTotal' );
  3597. var recordsFiltered = compat( 'iTotalDisplayRecords', 'recordsFiltered' );
  3598. if ( draw !== undefined ) {
  3599. // Protect against out of sequence returns
  3600. if ( draw*1 < settings.iDraw ) {
  3601. return;
  3602. }
  3603. settings.iDraw = draw * 1;
  3604. }
  3605. _fnClearTable( settings );
  3606. settings._iRecordsTotal = parseInt(recordsTotal, 10);
  3607. settings._iRecordsDisplay = parseInt(recordsFiltered, 10);
  3608. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  3609. _fnAddData( settings, data[i] );
  3610. }
  3611. settings.aiDisplay = settings.aiDisplayMaster.slice();
  3612. settings.bAjaxDataGet = false;
  3613. _fnDraw( settings );
  3614. if ( ! settings._bInitComplete ) {
  3615. _fnInitComplete( settings, json );
  3616. }
  3617. settings.bAjaxDataGet = true;
  3618. _fnProcessingDisplay( settings, false );
  3619. }
  3620. /**
  3621. * Get the data from the JSON data source to use for drawing a table. Using
  3622. * `_fnGetObjectDataFn` allows the data to be sourced from a property of the
  3623. * source object, or from a processing function.
  3624. * @param {object} oSettings dataTables settings object
  3625. * @param {object} json Data source object / array from the server
  3626. * @return {array} Array of data to use
  3627. */
  3628. function _fnAjaxDataSrc ( oSettings, json )
  3629. {
  3630. var dataSrc = $.isPlainObject( oSettings.ajax ) && oSettings.ajax.dataSrc !== undefined ?
  3631. oSettings.ajax.dataSrc :
  3632. oSettings.sAjaxDataProp; // Compatibility with 1.9-.
  3633. // Compatibility with 1.9-. In order to read from aaData, check if the
  3634. // default has been changed, if not, check for aaData
  3635. if ( dataSrc === 'data' ) {
  3636. return json.aaData || json[dataSrc];
  3637. }
  3638. return dataSrc !== "" ?
  3639. _fnGetObjectDataFn( dataSrc )( json ) :
  3640. json;
  3641. }
  3642. /**
  3643. * Generate the node required for filtering text
  3644. * @returns {node} Filter control element
  3645. * @param {object} oSettings dataTables settings object
  3646. * @memberof DataTable#oApi
  3647. */
  3648. function _fnFeatureHtmlFilter ( settings )
  3649. {
  3650. var classes = settings.oClasses;
  3651. var tableId = settings.sTableId;
  3652. var language = settings.oLanguage;
  3653. var previousSearch = settings.oPreviousSearch;
  3654. var features = settings.aanFeatures;
  3655. var input = '<input type="search" class="'+classes.sFilterInput+'"/>';
  3656. var str = language.sSearch;
  3657. str = str.match(/_INPUT_/) ?
  3658. str.replace('_INPUT_', input) :
  3659. str+input;
  3660. var filter = $('<div/>', {
  3661. 'id': ! features.f ? tableId+'_filter' : null,
  3662. 'class': classes.sFilter
  3663. } )
  3664. .append( $('<label/>' ).append( str ) );
  3665. var searchFn = function() {
  3666. /* Update all other filter input elements for the new display */
  3667. var n = features.f;
  3668. var val = !this.value ? "" : this.value; // mental IE8 fix :-(
  3669. /* Now do the filter */
  3670. if ( val != previousSearch.sSearch ) {
  3671. _fnFilterComplete( settings, {
  3672. "sSearch": val,
  3673. "bRegex": previousSearch.bRegex,
  3674. "bSmart": previousSearch.bSmart ,
  3675. "bCaseInsensitive": previousSearch.bCaseInsensitive
  3676. } );
  3677. // Need to redraw, without resorting
  3678. settings._iDisplayStart = 0;
  3679. _fnDraw( settings );
  3680. }
  3681. };
  3682. var searchDelay = settings.searchDelay !== null ?
  3683. settings.searchDelay :
  3684. _fnDataSource( settings ) === 'ssp' ?
  3685. 400 :
  3686. 0;
  3687. var jqFilter = $('input', filter)
  3688. .val( previousSearch.sSearch )
  3689. .attr( 'placeholder', language.sSearchPlaceholder )
  3690. .on(
  3691. 'keyup.DT search.DT input.DT paste.DT cut.DT',
  3692. searchDelay ?
  3693. _fnThrottle( searchFn, searchDelay ) :
  3694. searchFn
  3695. )
  3696. .on( 'mouseup', function(e) {
  3697. // Edge fix! Edge 17 does not trigger anything other than mouse events when clicking
  3698. // on the clear icon (Edge bug 17584515). This is safe in other browsers as `searchFn`
  3699. // checks the value to see if it has changed. In other browsers it won't have.
  3700. setTimeout( function () {
  3701. searchFn.call(jqFilter[0]);
  3702. }, 10);
  3703. } )
  3704. .on( 'keypress.DT', function(e) {
  3705. /* Prevent form submission */
  3706. if ( e.keyCode == 13 ) {
  3707. return false;
  3708. }
  3709. } )
  3710. .attr('aria-controls', tableId);
  3711. // Update the input elements whenever the table is filtered
  3712. $(settings.nTable).on( 'search.dt.DT', function ( ev, s ) {
  3713. if ( settings === s ) {
  3714. // IE9 throws an 'unknown error' if document.activeElement is used
  3715. // inside an iframe or frame...
  3716. try {
  3717. if ( jqFilter[0] !== document.activeElement ) {
  3718. jqFilter.val( previousSearch.sSearch );
  3719. }
  3720. }
  3721. catch ( e ) {}
  3722. }
  3723. } );
  3724. return filter[0];
  3725. }
  3726. /**
  3727. * Filter the table using both the global filter and column based filtering
  3728. * @param {object} oSettings dataTables settings object
  3729. * @param {object} oSearch search information
  3730. * @param {int} [iForce] force a research of the master array (1) or not (undefined or 0)
  3731. * @memberof DataTable#oApi
  3732. */
  3733. function _fnFilterComplete ( oSettings, oInput, iForce )
  3734. {
  3735. var oPrevSearch = oSettings.oPreviousSearch;
  3736. var aoPrevSearch = oSettings.aoPreSearchCols;
  3737. var fnSaveFilter = function ( oFilter ) {
  3738. /* Save the filtering values */
  3739. oPrevSearch.sSearch = oFilter.sSearch;
  3740. oPrevSearch.bRegex = oFilter.bRegex;
  3741. oPrevSearch.bSmart = oFilter.bSmart;
  3742. oPrevSearch.bCaseInsensitive = oFilter.bCaseInsensitive;
  3743. };
  3744. var fnRegex = function ( o ) {
  3745. // Backwards compatibility with the bEscapeRegex option
  3746. return o.bEscapeRegex !== undefined ? !o.bEscapeRegex : o.bRegex;
  3747. };
  3748. // Resolve any column types that are unknown due to addition or invalidation
  3749. // @todo As per sort - can this be moved into an event handler?
  3750. _fnColumnTypes( oSettings );
  3751. /* In server-side processing all filtering is done by the server, so no point hanging around here */
  3752. if ( _fnDataSource( oSettings ) != 'ssp' )
  3753. {
  3754. /* Global filter */
  3755. _fnFilter( oSettings, oInput.sSearch, iForce, fnRegex(oInput), oInput.bSmart, oInput.bCaseInsensitive );
  3756. fnSaveFilter( oInput );
  3757. /* Now do the individual column filter */
  3758. for ( var i=0 ; i<aoPrevSearch.length ; i++ )
  3759. {
  3760. _fnFilterColumn( oSettings, aoPrevSearch[i].sSearch, i, fnRegex(aoPrevSearch[i]),
  3761. aoPrevSearch[i].bSmart, aoPrevSearch[i].bCaseInsensitive );
  3762. }
  3763. /* Custom filtering */
  3764. _fnFilterCustom( oSettings );
  3765. }
  3766. else
  3767. {
  3768. fnSaveFilter( oInput );
  3769. }
  3770. /* Tell the draw function we have been filtering */
  3771. oSettings.bFiltered = true;
  3772. _fnCallbackFire( oSettings, null, 'search', [oSettings] );
  3773. }
  3774. /**
  3775. * Apply custom filtering functions
  3776. * @param {object} oSettings dataTables settings object
  3777. * @memberof DataTable#oApi
  3778. */
  3779. function _fnFilterCustom( settings )
  3780. {
  3781. var filters = DataTable.ext.search;
  3782. var displayRows = settings.aiDisplay;
  3783. var row, rowIdx;
  3784. for ( var i=0, ien=filters.length ; i<ien ; i++ ) {
  3785. var rows = [];
  3786. // Loop over each row and see if it should be included
  3787. for ( var j=0, jen=displayRows.length ; j<jen ; j++ ) {
  3788. rowIdx = displayRows[ j ];
  3789. row = settings.aoData[ rowIdx ];
  3790. if ( filters[i]( settings, row._aFilterData, rowIdx, row._aData, j ) ) {
  3791. rows.push( rowIdx );
  3792. }
  3793. }
  3794. // So the array reference doesn't break set the results into the
  3795. // existing array
  3796. displayRows.length = 0;
  3797. $.merge( displayRows, rows );
  3798. }
  3799. }
  3800. /**
  3801. * Filter the table on a per-column basis
  3802. * @param {object} oSettings dataTables settings object
  3803. * @param {string} sInput string to filter on
  3804. * @param {int} iColumn column to filter
  3805. * @param {bool} bRegex treat search string as a regular expression or not
  3806. * @param {bool} bSmart use smart filtering or not
  3807. * @param {bool} bCaseInsensitive Do case insenstive matching or not
  3808. * @memberof DataTable#oApi
  3809. */
  3810. function _fnFilterColumn ( settings, searchStr, colIdx, regex, smart, caseInsensitive )
  3811. {
  3812. if ( searchStr === '' ) {
  3813. return;
  3814. }
  3815. var data;
  3816. var out = [];
  3817. var display = settings.aiDisplay;
  3818. var rpSearch = _fnFilterCreateSearch( searchStr, regex, smart, caseInsensitive );
  3819. for ( var i=0 ; i<display.length ; i++ ) {
  3820. data = settings.aoData[ display[i] ]._aFilterData[ colIdx ];
  3821. if ( rpSearch.test( data ) ) {
  3822. out.push( display[i] );
  3823. }
  3824. }
  3825. settings.aiDisplay = out;
  3826. }
  3827. /**
  3828. * Filter the data table based on user input and draw the table
  3829. * @param {object} settings dataTables settings object
  3830. * @param {string} input string to filter on
  3831. * @param {int} force optional - force a research of the master array (1) or not (undefined or 0)
  3832. * @param {bool} regex treat as a regular expression or not
  3833. * @param {bool} smart perform smart filtering or not
  3834. * @param {bool} caseInsensitive Do case insenstive matching or not
  3835. * @memberof DataTable#oApi
  3836. */
  3837. function _fnFilter( settings, input, force, regex, smart, caseInsensitive )
  3838. {
  3839. var rpSearch = _fnFilterCreateSearch( input, regex, smart, caseInsensitive );
  3840. var prevSearch = settings.oPreviousSearch.sSearch;
  3841. var displayMaster = settings.aiDisplayMaster;
  3842. var display, invalidated, i;
  3843. var filtered = [];
  3844. // Need to take account of custom filtering functions - always filter
  3845. if ( DataTable.ext.search.length !== 0 ) {
  3846. force = true;
  3847. }
  3848. // Check if any of the rows were invalidated
  3849. invalidated = _fnFilterData( settings );
  3850. // If the input is blank - we just want the full data set
  3851. if ( input.length <= 0 ) {
  3852. settings.aiDisplay = displayMaster.slice();
  3853. }
  3854. else {
  3855. // New search - start from the master array
  3856. if ( invalidated ||
  3857. force ||
  3858. regex ||
  3859. prevSearch.length > input.length ||
  3860. input.indexOf(prevSearch) !== 0 ||
  3861. settings.bSorted // On resort, the display master needs to be
  3862. // re-filtered since indexes will have changed
  3863. ) {
  3864. settings.aiDisplay = displayMaster.slice();
  3865. }
  3866. // Search the display array
  3867. display = settings.aiDisplay;
  3868. for ( i=0 ; i<display.length ; i++ ) {
  3869. if ( rpSearch.test( settings.aoData[ display[i] ]._sFilterRow ) ) {
  3870. filtered.push( display[i] );
  3871. }
  3872. }
  3873. settings.aiDisplay = filtered;
  3874. }
  3875. }
  3876. /**
  3877. * Build a regular expression object suitable for searching a table
  3878. * @param {string} sSearch string to search for
  3879. * @param {bool} bRegex treat as a regular expression or not
  3880. * @param {bool} bSmart perform smart filtering or not
  3881. * @param {bool} bCaseInsensitive Do case insensitive matching or not
  3882. * @returns {RegExp} constructed object
  3883. * @memberof DataTable#oApi
  3884. */
  3885. function _fnFilterCreateSearch( search, regex, smart, caseInsensitive )
  3886. {
  3887. search = regex ?
  3888. search :
  3889. _fnEscapeRegex( search );
  3890. if ( smart ) {
  3891. /* For smart filtering we want to allow the search to work regardless of
  3892. * word order. We also want double quoted text to be preserved, so word
  3893. * order is important - a la google. So this is what we want to
  3894. * generate:
  3895. *
  3896. * ^(?=.*?\bone\b)(?=.*?\btwo three\b)(?=.*?\bfour\b).*$
  3897. */
  3898. var a = $.map( search.match( /"[^"]+"|[^ ]+/g ) || [''], function ( word ) {
  3899. if ( word.charAt(0) === '"' ) {
  3900. var m = word.match( /^"(.*)"$/ );
  3901. word = m ? m[1] : word;
  3902. }
  3903. return word.replace('"', '');
  3904. } );
  3905. search = '^(?=.*?'+a.join( ')(?=.*?' )+').*$';
  3906. }
  3907. return new RegExp( search, caseInsensitive ? 'i' : '' );
  3908. }
  3909. /**
  3910. * Escape a string such that it can be used in a regular expression
  3911. * @param {string} sVal string to escape
  3912. * @returns {string} escaped string
  3913. * @memberof DataTable#oApi
  3914. */
  3915. var _fnEscapeRegex = DataTable.util.escapeRegex;
  3916. var __filter_div = $('<div>')[0];
  3917. var __filter_div_textContent = __filter_div.textContent !== undefined;
  3918. // Update the filtering data for each row if needed (by invalidation or first run)
  3919. function _fnFilterData ( settings )
  3920. {
  3921. var columns = settings.aoColumns;
  3922. var column;
  3923. var i, j, ien, jen, filterData, cellData, row;
  3924. var fomatters = DataTable.ext.type.search;
  3925. var wasInvalidated = false;
  3926. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  3927. row = settings.aoData[i];
  3928. if ( ! row._aFilterData ) {
  3929. filterData = [];
  3930. for ( j=0, jen=columns.length ; j<jen ; j++ ) {
  3931. column = columns[j];
  3932. if ( column.bSearchable ) {
  3933. cellData = _fnGetCellData( settings, i, j, 'filter' );
  3934. if ( fomatters[ column.sType ] ) {
  3935. cellData = fomatters[ column.sType ]( cellData );
  3936. }
  3937. // Search in DataTables 1.10 is string based. In 1.11 this
  3938. // should be altered to also allow strict type checking.
  3939. if ( cellData === null ) {
  3940. cellData = '';
  3941. }
  3942. if ( typeof cellData !== 'string' && cellData.toString ) {
  3943. cellData = cellData.toString();
  3944. }
  3945. }
  3946. else {
  3947. cellData = '';
  3948. }
  3949. // If it looks like there is an HTML entity in the string,
  3950. // attempt to decode it so sorting works as expected. Note that
  3951. // we could use a single line of jQuery to do this, but the DOM
  3952. // method used here is much faster http://jsperf.com/html-decode
  3953. if ( cellData.indexOf && cellData.indexOf('&') !== -1 ) {
  3954. __filter_div.innerHTML = cellData;
  3955. cellData = __filter_div_textContent ?
  3956. __filter_div.textContent :
  3957. __filter_div.innerText;
  3958. }
  3959. if ( cellData.replace ) {
  3960. cellData = cellData.replace(/[\r\n\u2028]/g, '');
  3961. }
  3962. filterData.push( cellData );
  3963. }
  3964. row._aFilterData = filterData;
  3965. row._sFilterRow = filterData.join(' ');
  3966. wasInvalidated = true;
  3967. }
  3968. }
  3969. return wasInvalidated;
  3970. }
  3971. /**
  3972. * Convert from the internal Hungarian notation to camelCase for external
  3973. * interaction
  3974. * @param {object} obj Object to convert
  3975. * @returns {object} Inverted object
  3976. * @memberof DataTable#oApi
  3977. */
  3978. function _fnSearchToCamel ( obj )
  3979. {
  3980. return {
  3981. search: obj.sSearch,
  3982. smart: obj.bSmart,
  3983. regex: obj.bRegex,
  3984. caseInsensitive: obj.bCaseInsensitive
  3985. };
  3986. }
  3987. /**
  3988. * Convert from camelCase notation to the internal Hungarian. We could use the
  3989. * Hungarian convert function here, but this is cleaner
  3990. * @param {object} obj Object to convert
  3991. * @returns {object} Inverted object
  3992. * @memberof DataTable#oApi
  3993. */
  3994. function _fnSearchToHung ( obj )
  3995. {
  3996. return {
  3997. sSearch: obj.search,
  3998. bSmart: obj.smart,
  3999. bRegex: obj.regex,
  4000. bCaseInsensitive: obj.caseInsensitive
  4001. };
  4002. }
  4003. /**
  4004. * Generate the node required for the info display
  4005. * @param {object} oSettings dataTables settings object
  4006. * @returns {node} Information element
  4007. * @memberof DataTable#oApi
  4008. */
  4009. function _fnFeatureHtmlInfo ( settings )
  4010. {
  4011. var
  4012. tid = settings.sTableId,
  4013. nodes = settings.aanFeatures.i,
  4014. n = $('<div/>', {
  4015. 'class': settings.oClasses.sInfo,
  4016. 'id': ! nodes ? tid+'_info' : null
  4017. } );
  4018. if ( ! nodes ) {
  4019. // Update display on each draw
  4020. settings.aoDrawCallback.push( {
  4021. "fn": _fnUpdateInfo,
  4022. "sName": "information"
  4023. } );
  4024. n
  4025. .attr( 'role', 'status' )
  4026. .attr( 'aria-live', 'polite' );
  4027. // Table is described by our info div
  4028. $(settings.nTable).attr( 'aria-describedby', tid+'_info' );
  4029. }
  4030. return n[0];
  4031. }
  4032. /**
  4033. * Update the information elements in the display
  4034. * @param {object} settings dataTables settings object
  4035. * @memberof DataTable#oApi
  4036. */
  4037. function _fnUpdateInfo ( settings )
  4038. {
  4039. /* Show information about the table */
  4040. var nodes = settings.aanFeatures.i;
  4041. if ( nodes.length === 0 ) {
  4042. return;
  4043. }
  4044. var
  4045. lang = settings.oLanguage,
  4046. start = settings._iDisplayStart+1,
  4047. end = settings.fnDisplayEnd(),
  4048. max = settings.fnRecordsTotal(),
  4049. total = settings.fnRecordsDisplay(),
  4050. out = total ?
  4051. lang.sInfo :
  4052. lang.sInfoEmpty;
  4053. if ( total !== max ) {
  4054. /* Record set after filtering */
  4055. out += ' ' + lang.sInfoFiltered;
  4056. }
  4057. // Convert the macros
  4058. out += lang.sInfoPostFix;
  4059. out = _fnInfoMacros( settings, out );
  4060. var callback = lang.fnInfoCallback;
  4061. if ( callback !== null ) {
  4062. out = callback.call( settings.oInstance,
  4063. settings, start, end, max, total, out
  4064. );
  4065. }
  4066. $(nodes).html( out );
  4067. }
  4068. function _fnInfoMacros ( settings, str )
  4069. {
  4070. // When infinite scrolling, we are always starting at 1. _iDisplayStart is used only
  4071. // internally
  4072. var
  4073. formatter = settings.fnFormatNumber,
  4074. start = settings._iDisplayStart+1,
  4075. len = settings._iDisplayLength,
  4076. vis = settings.fnRecordsDisplay(),
  4077. all = len === -1;
  4078. return str.
  4079. replace(/_START_/g, formatter.call( settings, start ) ).
  4080. replace(/_END_/g, formatter.call( settings, settings.fnDisplayEnd() ) ).
  4081. replace(/_MAX_/g, formatter.call( settings, settings.fnRecordsTotal() ) ).
  4082. replace(/_TOTAL_/g, formatter.call( settings, vis ) ).
  4083. replace(/_PAGE_/g, formatter.call( settings, all ? 1 : Math.ceil( start / len ) ) ).
  4084. replace(/_PAGES_/g, formatter.call( settings, all ? 1 : Math.ceil( vis / len ) ) );
  4085. }
  4086. /**
  4087. * Draw the table for the first time, adding all required features
  4088. * @param {object} settings dataTables settings object
  4089. * @memberof DataTable#oApi
  4090. */
  4091. function _fnInitialise ( settings )
  4092. {
  4093. var i, iLen, iAjaxStart=settings.iInitDisplayStart;
  4094. var columns = settings.aoColumns, column;
  4095. var features = settings.oFeatures;
  4096. var deferLoading = settings.bDeferLoading; // value modified by the draw
  4097. /* Ensure that the table data is fully initialised */
  4098. if ( ! settings.bInitialised ) {
  4099. setTimeout( function(){ _fnInitialise( settings ); }, 200 );
  4100. return;
  4101. }
  4102. /* Show the display HTML options */
  4103. _fnAddOptionsHtml( settings );
  4104. /* Build and draw the header / footer for the table */
  4105. _fnBuildHead( settings );
  4106. _fnDrawHead( settings, settings.aoHeader );
  4107. _fnDrawHead( settings, settings.aoFooter );
  4108. /* Okay to show that something is going on now */
  4109. _fnProcessingDisplay( settings, true );
  4110. /* Calculate sizes for columns */
  4111. if ( features.bAutoWidth ) {
  4112. _fnCalculateColumnWidths( settings );
  4113. }
  4114. for ( i=0, iLen=columns.length ; i<iLen ; i++ ) {
  4115. column = columns[i];
  4116. if ( column.sWidth ) {
  4117. column.nTh.style.width = _fnStringToCss( column.sWidth );
  4118. }
  4119. }
  4120. _fnCallbackFire( settings, null, 'preInit', [settings] );
  4121. // If there is default sorting required - let's do it. The sort function
  4122. // will do the drawing for us. Otherwise we draw the table regardless of the
  4123. // Ajax source - this allows the table to look initialised for Ajax sourcing
  4124. // data (show 'loading' message possibly)
  4125. _fnReDraw( settings );
  4126. // Server-side processing init complete is done by _fnAjaxUpdateDraw
  4127. var dataSrc = _fnDataSource( settings );
  4128. if ( dataSrc != 'ssp' || deferLoading ) {
  4129. // if there is an ajax source load the data
  4130. if ( dataSrc == 'ajax' ) {
  4131. _fnBuildAjax( settings, [], function(json) {
  4132. var aData = _fnAjaxDataSrc( settings, json );
  4133. // Got the data - add it to the table
  4134. for ( i=0 ; i<aData.length ; i++ ) {
  4135. _fnAddData( settings, aData[i] );
  4136. }
  4137. // Reset the init display for cookie saving. We've already done
  4138. // a filter, and therefore cleared it before. So we need to make
  4139. // it appear 'fresh'
  4140. settings.iInitDisplayStart = iAjaxStart;
  4141. _fnReDraw( settings );
  4142. _fnProcessingDisplay( settings, false );
  4143. _fnInitComplete( settings, json );
  4144. }, settings );
  4145. }
  4146. else {
  4147. _fnProcessingDisplay( settings, false );
  4148. _fnInitComplete( settings );
  4149. }
  4150. }
  4151. }
  4152. /**
  4153. * Draw the table for the first time, adding all required features
  4154. * @param {object} oSettings dataTables settings object
  4155. * @param {object} [json] JSON from the server that completed the table, if using Ajax source
  4156. * with client-side processing (optional)
  4157. * @memberof DataTable#oApi
  4158. */
  4159. function _fnInitComplete ( settings, json )
  4160. {
  4161. settings._bInitComplete = true;
  4162. // When data was added after the initialisation (data or Ajax) we need to
  4163. // calculate the column sizing
  4164. if ( json || settings.oInit.aaData ) {
  4165. _fnAdjustColumnSizing( settings );
  4166. }
  4167. _fnCallbackFire( settings, null, 'plugin-init', [settings, json] );
  4168. _fnCallbackFire( settings, 'aoInitComplete', 'init', [settings, json] );
  4169. }
  4170. function _fnLengthChange ( settings, val )
  4171. {
  4172. var len = parseInt( val, 10 );
  4173. settings._iDisplayLength = len;
  4174. _fnLengthOverflow( settings );
  4175. // Fire length change event
  4176. _fnCallbackFire( settings, null, 'length', [settings, len] );
  4177. }
  4178. /**
  4179. * Generate the node required for user display length changing
  4180. * @param {object} settings dataTables settings object
  4181. * @returns {node} Display length feature node
  4182. * @memberof DataTable#oApi
  4183. */
  4184. function _fnFeatureHtmlLength ( settings )
  4185. {
  4186. var
  4187. classes = settings.oClasses,
  4188. tableId = settings.sTableId,
  4189. menu = settings.aLengthMenu,
  4190. d2 = Array.isArray( menu[0] ),
  4191. lengths = d2 ? menu[0] : menu,
  4192. language = d2 ? menu[1] : menu;
  4193. var select = $('<select/>', {
  4194. 'name': tableId+'_length',
  4195. 'aria-controls': tableId,
  4196. 'class': classes.sLengthSelect
  4197. } );
  4198. for ( var i=0, ien=lengths.length ; i<ien ; i++ ) {
  4199. select[0][ i ] = new Option(
  4200. typeof language[i] === 'number' ?
  4201. settings.fnFormatNumber( language[i] ) :
  4202. language[i],
  4203. lengths[i]
  4204. );
  4205. }
  4206. var div = $('<div><label/></div>').addClass( classes.sLength );
  4207. if ( ! settings.aanFeatures.l ) {
  4208. div[0].id = tableId+'_length';
  4209. }
  4210. div.children().append(
  4211. settings.oLanguage.sLengthMenu.replace( '_MENU_', select[0].outerHTML )
  4212. );
  4213. // Can't use `select` variable as user might provide their own and the
  4214. // reference is broken by the use of outerHTML
  4215. $('select', div)
  4216. .val( settings._iDisplayLength )
  4217. .on( 'change.DT', function(e) {
  4218. _fnLengthChange( settings, $(this).val() );
  4219. _fnDraw( settings );
  4220. } );
  4221. // Update node value whenever anything changes the table's length
  4222. $(settings.nTable).on( 'length.dt.DT', function (e, s, len) {
  4223. if ( settings === s ) {
  4224. $('select', div).val( len );
  4225. }
  4226. } );
  4227. return div[0];
  4228. }
  4229. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  4230. * Note that most of the paging logic is done in
  4231. * DataTable.ext.pager
  4232. */
  4233. /**
  4234. * Generate the node required for default pagination
  4235. * @param {object} oSettings dataTables settings object
  4236. * @returns {node} Pagination feature node
  4237. * @memberof DataTable#oApi
  4238. */
  4239. function _fnFeatureHtmlPaginate ( settings )
  4240. {
  4241. var
  4242. type = settings.sPaginationType,
  4243. plugin = DataTable.ext.pager[ type ],
  4244. modern = typeof plugin === 'function',
  4245. redraw = function( settings ) {
  4246. _fnDraw( settings );
  4247. },
  4248. node = $('<div/>').addClass( settings.oClasses.sPaging + type )[0],
  4249. features = settings.aanFeatures;
  4250. if ( ! modern ) {
  4251. plugin.fnInit( settings, node, redraw );
  4252. }
  4253. /* Add a draw callback for the pagination on first instance, to update the paging display */
  4254. if ( ! features.p )
  4255. {
  4256. node.id = settings.sTableId+'_paginate';
  4257. settings.aoDrawCallback.push( {
  4258. "fn": function( settings ) {
  4259. if ( modern ) {
  4260. var
  4261. start = settings._iDisplayStart,
  4262. len = settings._iDisplayLength,
  4263. visRecords = settings.fnRecordsDisplay(),
  4264. all = len === -1,
  4265. page = all ? 0 : Math.ceil( start / len ),
  4266. pages = all ? 1 : Math.ceil( visRecords / len ),
  4267. buttons = plugin(page, pages),
  4268. i, ien;
  4269. for ( i=0, ien=features.p.length ; i<ien ; i++ ) {
  4270. _fnRenderer( settings, 'pageButton' )(
  4271. settings, features.p[i], i, buttons, page, pages
  4272. );
  4273. }
  4274. }
  4275. else {
  4276. plugin.fnUpdate( settings, redraw );
  4277. }
  4278. },
  4279. "sName": "pagination"
  4280. } );
  4281. }
  4282. return node;
  4283. }
  4284. /**
  4285. * Alter the display settings to change the page
  4286. * @param {object} settings DataTables settings object
  4287. * @param {string|int} action Paging action to take: "first", "previous",
  4288. * "next" or "last" or page number to jump to (integer)
  4289. * @param [bool] redraw Automatically draw the update or not
  4290. * @returns {bool} true page has changed, false - no change
  4291. * @memberof DataTable#oApi
  4292. */
  4293. function _fnPageChange ( settings, action, redraw )
  4294. {
  4295. var
  4296. start = settings._iDisplayStart,
  4297. len = settings._iDisplayLength,
  4298. records = settings.fnRecordsDisplay();
  4299. if ( records === 0 || len === -1 )
  4300. {
  4301. start = 0;
  4302. }
  4303. else if ( typeof action === "number" )
  4304. {
  4305. start = action * len;
  4306. if ( start > records )
  4307. {
  4308. start = 0;
  4309. }
  4310. }
  4311. else if ( action == "first" )
  4312. {
  4313. start = 0;
  4314. }
  4315. else if ( action == "previous" )
  4316. {
  4317. start = len >= 0 ?
  4318. start - len :
  4319. 0;
  4320. if ( start < 0 )
  4321. {
  4322. start = 0;
  4323. }
  4324. }
  4325. else if ( action == "next" )
  4326. {
  4327. if ( start + len < records )
  4328. {
  4329. start += len;
  4330. }
  4331. }
  4332. else if ( action == "last" )
  4333. {
  4334. start = Math.floor( (records-1) / len) * len;
  4335. }
  4336. else
  4337. {
  4338. _fnLog( settings, 0, "Unknown paging action: "+action, 5 );
  4339. }
  4340. var changed = settings._iDisplayStart !== start;
  4341. settings._iDisplayStart = start;
  4342. if ( changed ) {
  4343. _fnCallbackFire( settings, null, 'page', [settings] );
  4344. if ( redraw ) {
  4345. _fnDraw( settings );
  4346. }
  4347. }
  4348. return changed;
  4349. }
  4350. /**
  4351. * Generate the node required for the processing node
  4352. * @param {object} settings dataTables settings object
  4353. * @returns {node} Processing element
  4354. * @memberof DataTable#oApi
  4355. */
  4356. function _fnFeatureHtmlProcessing ( settings )
  4357. {
  4358. return $('<div/>', {
  4359. 'id': ! settings.aanFeatures.r ? settings.sTableId+'_processing' : null,
  4360. 'class': settings.oClasses.sProcessing
  4361. } )
  4362. .html( settings.oLanguage.sProcessing )
  4363. .insertBefore( settings.nTable )[0];
  4364. }
  4365. /**
  4366. * Display or hide the processing indicator
  4367. * @param {object} settings dataTables settings object
  4368. * @param {bool} show Show the processing indicator (true) or not (false)
  4369. * @memberof DataTable#oApi
  4370. */
  4371. function _fnProcessingDisplay ( settings, show )
  4372. {
  4373. if ( settings.oFeatures.bProcessing ) {
  4374. $(settings.aanFeatures.r).css( 'display', show ? 'block' : 'none' );
  4375. }
  4376. _fnCallbackFire( settings, null, 'processing', [settings, show] );
  4377. }
  4378. /**
  4379. * Add any control elements for the table - specifically scrolling
  4380. * @param {object} settings dataTables settings object
  4381. * @returns {node} Node to add to the DOM
  4382. * @memberof DataTable#oApi
  4383. */
  4384. function _fnFeatureHtmlTable ( settings )
  4385. {
  4386. var table = $(settings.nTable);
  4387. // Add the ARIA grid role to the table
  4388. table.attr( 'role', 'grid' );
  4389. // Scrolling from here on in
  4390. var scroll = settings.oScroll;
  4391. if ( scroll.sX === '' && scroll.sY === '' ) {
  4392. return settings.nTable;
  4393. }
  4394. var scrollX = scroll.sX;
  4395. var scrollY = scroll.sY;
  4396. var classes = settings.oClasses;
  4397. var caption = table.children('caption');
  4398. var captionSide = caption.length ? caption[0]._captionSide : null;
  4399. var headerClone = $( table[0].cloneNode(false) );
  4400. var footerClone = $( table[0].cloneNode(false) );
  4401. var footer = table.children('tfoot');
  4402. var _div = '<div/>';
  4403. var size = function ( s ) {
  4404. return !s ? null : _fnStringToCss( s );
  4405. };
  4406. if ( ! footer.length ) {
  4407. footer = null;
  4408. }
  4409. /*
  4410. * The HTML structure that we want to generate in this function is:
  4411. * div - scroller
  4412. * div - scroll head
  4413. * div - scroll head inner
  4414. * table - scroll head table
  4415. * thead - thead
  4416. * div - scroll body
  4417. * table - table (master table)
  4418. * thead - thead clone for sizing
  4419. * tbody - tbody
  4420. * div - scroll foot
  4421. * div - scroll foot inner
  4422. * table - scroll foot table
  4423. * tfoot - tfoot
  4424. */
  4425. var scroller = $( _div, { 'class': classes.sScrollWrapper } )
  4426. .append(
  4427. $(_div, { 'class': classes.sScrollHead } )
  4428. .css( {
  4429. overflow: 'hidden',
  4430. position: 'relative',
  4431. border: 0,
  4432. width: scrollX ? size(scrollX) : '100%'
  4433. } )
  4434. .append(
  4435. $(_div, { 'class': classes.sScrollHeadInner } )
  4436. .css( {
  4437. 'box-sizing': 'content-box',
  4438. width: scroll.sXInner || '100%'
  4439. } )
  4440. .append(
  4441. headerClone
  4442. .removeAttr('id')
  4443. .css( 'margin-left', 0 )
  4444. .append( captionSide === 'top' ? caption : null )
  4445. .append(
  4446. table.children('thead')
  4447. )
  4448. )
  4449. )
  4450. )
  4451. .append(
  4452. $(_div, { 'class': classes.sScrollBody } )
  4453. .css( {
  4454. position: 'relative',
  4455. overflow: 'auto',
  4456. width: size( scrollX )
  4457. } )
  4458. .append( table )
  4459. );
  4460. if ( footer ) {
  4461. scroller.append(
  4462. $(_div, { 'class': classes.sScrollFoot } )
  4463. .css( {
  4464. overflow: 'hidden',
  4465. border: 0,
  4466. width: scrollX ? size(scrollX) : '100%'
  4467. } )
  4468. .append(
  4469. $(_div, { 'class': classes.sScrollFootInner } )
  4470. .append(
  4471. footerClone
  4472. .removeAttr('id')
  4473. .css( 'margin-left', 0 )
  4474. .append( captionSide === 'bottom' ? caption : null )
  4475. .append(
  4476. table.children('tfoot')
  4477. )
  4478. )
  4479. )
  4480. );
  4481. }
  4482. var children = scroller.children();
  4483. var scrollHead = children[0];
  4484. var scrollBody = children[1];
  4485. var scrollFoot = footer ? children[2] : null;
  4486. // When the body is scrolled, then we also want to scroll the headers
  4487. if ( scrollX ) {
  4488. $(scrollBody).on( 'scroll.DT', function (e) {
  4489. var scrollLeft = this.scrollLeft;
  4490. scrollHead.scrollLeft = scrollLeft;
  4491. if ( footer ) {
  4492. scrollFoot.scrollLeft = scrollLeft;
  4493. }
  4494. } );
  4495. }
  4496. $(scrollBody).css('max-height', scrollY);
  4497. if (! scroll.bCollapse) {
  4498. $(scrollBody).css('height', scrollY);
  4499. }
  4500. settings.nScrollHead = scrollHead;
  4501. settings.nScrollBody = scrollBody;
  4502. settings.nScrollFoot = scrollFoot;
  4503. // On redraw - align columns
  4504. settings.aoDrawCallback.push( {
  4505. "fn": _fnScrollDraw,
  4506. "sName": "scrolling"
  4507. } );
  4508. return scroller[0];
  4509. }
  4510. /**
  4511. * Update the header, footer and body tables for resizing - i.e. column
  4512. * alignment.
  4513. *
  4514. * Welcome to the most horrible function DataTables. The process that this
  4515. * function follows is basically:
  4516. * 1. Re-create the table inside the scrolling div
  4517. * 2. Take live measurements from the DOM
  4518. * 3. Apply the measurements to align the columns
  4519. * 4. Clean up
  4520. *
  4521. * @param {object} settings dataTables settings object
  4522. * @memberof DataTable#oApi
  4523. */
  4524. function _fnScrollDraw ( settings )
  4525. {
  4526. // Given that this is such a monster function, a lot of variables are use
  4527. // to try and keep the minimised size as small as possible
  4528. var
  4529. scroll = settings.oScroll,
  4530. scrollX = scroll.sX,
  4531. scrollXInner = scroll.sXInner,
  4532. scrollY = scroll.sY,
  4533. barWidth = scroll.iBarWidth,
  4534. divHeader = $(settings.nScrollHead),
  4535. divHeaderStyle = divHeader[0].style,
  4536. divHeaderInner = divHeader.children('div'),
  4537. divHeaderInnerStyle = divHeaderInner[0].style,
  4538. divHeaderTable = divHeaderInner.children('table'),
  4539. divBodyEl = settings.nScrollBody,
  4540. divBody = $(divBodyEl),
  4541. divBodyStyle = divBodyEl.style,
  4542. divFooter = $(settings.nScrollFoot),
  4543. divFooterInner = divFooter.children('div'),
  4544. divFooterTable = divFooterInner.children('table'),
  4545. header = $(settings.nTHead),
  4546. table = $(settings.nTable),
  4547. tableEl = table[0],
  4548. tableStyle = tableEl.style,
  4549. footer = settings.nTFoot ? $(settings.nTFoot) : null,
  4550. browser = settings.oBrowser,
  4551. ie67 = browser.bScrollOversize,
  4552. dtHeaderCells = _pluck( settings.aoColumns, 'nTh' ),
  4553. headerTrgEls, footerTrgEls,
  4554. headerSrcEls, footerSrcEls,
  4555. headerCopy, footerCopy,
  4556. headerWidths=[], footerWidths=[],
  4557. headerContent=[], footerContent=[],
  4558. idx, correction, sanityWidth,
  4559. zeroOut = function(nSizer) {
  4560. var style = nSizer.style;
  4561. style.paddingTop = "0";
  4562. style.paddingBottom = "0";
  4563. style.borderTopWidth = "0";
  4564. style.borderBottomWidth = "0";
  4565. style.height = 0;
  4566. };
  4567. // If the scrollbar visibility has changed from the last draw, we need to
  4568. // adjust the column sizes as the table width will have changed to account
  4569. // for the scrollbar
  4570. var scrollBarVis = divBodyEl.scrollHeight > divBodyEl.clientHeight;
  4571. if ( settings.scrollBarVis !== scrollBarVis && settings.scrollBarVis !== undefined ) {
  4572. settings.scrollBarVis = scrollBarVis;
  4573. _fnAdjustColumnSizing( settings );
  4574. return; // adjust column sizing will call this function again
  4575. }
  4576. else {
  4577. settings.scrollBarVis = scrollBarVis;
  4578. }
  4579. /*
  4580. * 1. Re-create the table inside the scrolling div
  4581. */
  4582. // Remove the old minimised thead and tfoot elements in the inner table
  4583. table.children('thead, tfoot').remove();
  4584. if ( footer ) {
  4585. footerCopy = footer.clone().prependTo( table );
  4586. footerTrgEls = footer.find('tr'); // the original tfoot is in its own table and must be sized
  4587. footerSrcEls = footerCopy.find('tr');
  4588. }
  4589. // Clone the current header and footer elements and then place it into the inner table
  4590. headerCopy = header.clone().prependTo( table );
  4591. headerTrgEls = header.find('tr'); // original header is in its own table
  4592. headerSrcEls = headerCopy.find('tr');
  4593. headerCopy.find('th, td').removeAttr('tabindex');
  4594. /*
  4595. * 2. Take live measurements from the DOM - do not alter the DOM itself!
  4596. */
  4597. // Remove old sizing and apply the calculated column widths
  4598. // Get the unique column headers in the newly created (cloned) header. We want to apply the
  4599. // calculated sizes to this header
  4600. if ( ! scrollX )
  4601. {
  4602. divBodyStyle.width = '100%';
  4603. divHeader[0].style.width = '100%';
  4604. }
  4605. $.each( _fnGetUniqueThs( settings, headerCopy ), function ( i, el ) {
  4606. idx = _fnVisibleToColumnIndex( settings, i );
  4607. el.style.width = settings.aoColumns[idx].sWidth;
  4608. } );
  4609. if ( footer ) {
  4610. _fnApplyToChildren( function(n) {
  4611. n.style.width = "";
  4612. }, footerSrcEls );
  4613. }
  4614. // Size the table as a whole
  4615. sanityWidth = table.outerWidth();
  4616. if ( scrollX === "" ) {
  4617. // No x scrolling
  4618. tableStyle.width = "100%";
  4619. // IE7 will make the width of the table when 100% include the scrollbar
  4620. // - which is shouldn't. When there is a scrollbar we need to take this
  4621. // into account.
  4622. if ( ie67 && (table.find('tbody').height() > divBodyEl.offsetHeight ||
  4623. divBody.css('overflow-y') == "scroll")
  4624. ) {
  4625. tableStyle.width = _fnStringToCss( table.outerWidth() - barWidth);
  4626. }
  4627. // Recalculate the sanity width
  4628. sanityWidth = table.outerWidth();
  4629. }
  4630. else if ( scrollXInner !== "" ) {
  4631. // legacy x scroll inner has been given - use it
  4632. tableStyle.width = _fnStringToCss(scrollXInner);
  4633. // Recalculate the sanity width
  4634. sanityWidth = table.outerWidth();
  4635. }
  4636. // Hidden header should have zero height, so remove padding and borders. Then
  4637. // set the width based on the real headers
  4638. // Apply all styles in one pass
  4639. _fnApplyToChildren( zeroOut, headerSrcEls );
  4640. // Read all widths in next pass
  4641. _fnApplyToChildren( function(nSizer) {
  4642. headerContent.push( nSizer.innerHTML );
  4643. headerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  4644. }, headerSrcEls );
  4645. // Apply all widths in final pass
  4646. _fnApplyToChildren( function(nToSize, i) {
  4647. // Only apply widths to the DataTables detected header cells - this
  4648. // prevents complex headers from having contradictory sizes applied
  4649. if ( $.inArray( nToSize, dtHeaderCells ) !== -1 ) {
  4650. nToSize.style.width = headerWidths[i];
  4651. }
  4652. }, headerTrgEls );
  4653. $(headerSrcEls).height(0);
  4654. /* Same again with the footer if we have one */
  4655. if ( footer )
  4656. {
  4657. _fnApplyToChildren( zeroOut, footerSrcEls );
  4658. _fnApplyToChildren( function(nSizer) {
  4659. footerContent.push( nSizer.innerHTML );
  4660. footerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  4661. }, footerSrcEls );
  4662. _fnApplyToChildren( function(nToSize, i) {
  4663. nToSize.style.width = footerWidths[i];
  4664. }, footerTrgEls );
  4665. $(footerSrcEls).height(0);
  4666. }
  4667. /*
  4668. * 3. Apply the measurements
  4669. */
  4670. // "Hide" the header and footer that we used for the sizing. We need to keep
  4671. // the content of the cell so that the width applied to the header and body
  4672. // both match, but we want to hide it completely. We want to also fix their
  4673. // width to what they currently are
  4674. _fnApplyToChildren( function(nSizer, i) {
  4675. nSizer.innerHTML = '<div class="dataTables_sizing">'+headerContent[i]+'</div>';
  4676. nSizer.childNodes[0].style.height = "0";
  4677. nSizer.childNodes[0].style.overflow = "hidden";
  4678. nSizer.style.width = headerWidths[i];
  4679. }, headerSrcEls );
  4680. if ( footer )
  4681. {
  4682. _fnApplyToChildren( function(nSizer, i) {
  4683. nSizer.innerHTML = '<div class="dataTables_sizing">'+footerContent[i]+'</div>';
  4684. nSizer.childNodes[0].style.height = "0";
  4685. nSizer.childNodes[0].style.overflow = "hidden";
  4686. nSizer.style.width = footerWidths[i];
  4687. }, footerSrcEls );
  4688. }
  4689. // Sanity check that the table is of a sensible width. If not then we are going to get
  4690. // misalignment - try to prevent this by not allowing the table to shrink below its min width
  4691. if ( table.outerWidth() < sanityWidth )
  4692. {
  4693. // The min width depends upon if we have a vertical scrollbar visible or not */
  4694. correction = ((divBodyEl.scrollHeight > divBodyEl.offsetHeight ||
  4695. divBody.css('overflow-y') == "scroll")) ?
  4696. sanityWidth+barWidth :
  4697. sanityWidth;
  4698. // IE6/7 are a law unto themselves...
  4699. if ( ie67 && (divBodyEl.scrollHeight >
  4700. divBodyEl.offsetHeight || divBody.css('overflow-y') == "scroll")
  4701. ) {
  4702. tableStyle.width = _fnStringToCss( correction-barWidth );
  4703. }
  4704. // And give the user a warning that we've stopped the table getting too small
  4705. if ( scrollX === "" || scrollXInner !== "" ) {
  4706. _fnLog( settings, 1, 'Possible column misalignment', 6 );
  4707. }
  4708. }
  4709. else
  4710. {
  4711. correction = '100%';
  4712. }
  4713. // Apply to the container elements
  4714. divBodyStyle.width = _fnStringToCss( correction );
  4715. divHeaderStyle.width = _fnStringToCss( correction );
  4716. if ( footer ) {
  4717. settings.nScrollFoot.style.width = _fnStringToCss( correction );
  4718. }
  4719. /*
  4720. * 4. Clean up
  4721. */
  4722. if ( ! scrollY ) {
  4723. /* IE7< puts a vertical scrollbar in place (when it shouldn't be) due to subtracting
  4724. * the scrollbar height from the visible display, rather than adding it on. We need to
  4725. * set the height in order to sort this. Don't want to do it in any other browsers.
  4726. */
  4727. if ( ie67 ) {
  4728. divBodyStyle.height = _fnStringToCss( tableEl.offsetHeight+barWidth );
  4729. }
  4730. }
  4731. /* Finally set the width's of the header and footer tables */
  4732. var iOuterWidth = table.outerWidth();
  4733. divHeaderTable[0].style.width = _fnStringToCss( iOuterWidth );
  4734. divHeaderInnerStyle.width = _fnStringToCss( iOuterWidth );
  4735. // Figure out if there are scrollbar present - if so then we need a the header and footer to
  4736. // provide a bit more space to allow "overflow" scrolling (i.e. past the scrollbar)
  4737. var bScrolling = table.height() > divBodyEl.clientHeight || divBody.css('overflow-y') == "scroll";
  4738. var padding = 'padding' + (browser.bScrollbarLeft ? 'Left' : 'Right' );
  4739. divHeaderInnerStyle[ padding ] = bScrolling ? barWidth+"px" : "0px";
  4740. if ( footer ) {
  4741. divFooterTable[0].style.width = _fnStringToCss( iOuterWidth );
  4742. divFooterInner[0].style.width = _fnStringToCss( iOuterWidth );
  4743. divFooterInner[0].style[padding] = bScrolling ? barWidth+"px" : "0px";
  4744. }
  4745. // Correct DOM ordering for colgroup - comes before the thead
  4746. table.children('colgroup').insertBefore( table.children('thead') );
  4747. /* Adjust the position of the header in case we loose the y-scrollbar */
  4748. divBody.trigger('scroll');
  4749. // If sorting or filtering has occurred, jump the scrolling back to the top
  4750. // only if we aren't holding the position
  4751. if ( (settings.bSorted || settings.bFiltered) && ! settings._drawHold ) {
  4752. divBodyEl.scrollTop = 0;
  4753. }
  4754. }
  4755. /**
  4756. * Apply a given function to the display child nodes of an element array (typically
  4757. * TD children of TR rows
  4758. * @param {function} fn Method to apply to the objects
  4759. * @param array {nodes} an1 List of elements to look through for display children
  4760. * @param array {nodes} an2 Another list (identical structure to the first) - optional
  4761. * @memberof DataTable#oApi
  4762. */
  4763. function _fnApplyToChildren( fn, an1, an2 )
  4764. {
  4765. var index=0, i=0, iLen=an1.length;
  4766. var nNode1, nNode2;
  4767. while ( i < iLen ) {
  4768. nNode1 = an1[i].firstChild;
  4769. nNode2 = an2 ? an2[i].firstChild : null;
  4770. while ( nNode1 ) {
  4771. if ( nNode1.nodeType === 1 ) {
  4772. if ( an2 ) {
  4773. fn( nNode1, nNode2, index );
  4774. }
  4775. else {
  4776. fn( nNode1, index );
  4777. }
  4778. index++;
  4779. }
  4780. nNode1 = nNode1.nextSibling;
  4781. nNode2 = an2 ? nNode2.nextSibling : null;
  4782. }
  4783. i++;
  4784. }
  4785. }
  4786. var __re_html_remove = /<.*?>/g;
  4787. /**
  4788. * Calculate the width of columns for the table
  4789. * @param {object} oSettings dataTables settings object
  4790. * @memberof DataTable#oApi
  4791. */
  4792. function _fnCalculateColumnWidths ( oSettings )
  4793. {
  4794. var
  4795. table = oSettings.nTable,
  4796. columns = oSettings.aoColumns,
  4797. scroll = oSettings.oScroll,
  4798. scrollY = scroll.sY,
  4799. scrollX = scroll.sX,
  4800. scrollXInner = scroll.sXInner,
  4801. columnCount = columns.length,
  4802. visibleColumns = _fnGetColumns( oSettings, 'bVisible' ),
  4803. headerCells = $('th', oSettings.nTHead),
  4804. tableWidthAttr = table.getAttribute('width'), // from DOM element
  4805. tableContainer = table.parentNode,
  4806. userInputs = false,
  4807. i, column, columnIdx, width, outerWidth,
  4808. browser = oSettings.oBrowser,
  4809. ie67 = browser.bScrollOversize;
  4810. var styleWidth = table.style.width;
  4811. if ( styleWidth && styleWidth.indexOf('%') !== -1 ) {
  4812. tableWidthAttr = styleWidth;
  4813. }
  4814. /* Convert any user input sizes into pixel sizes */
  4815. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4816. column = columns[ visibleColumns[i] ];
  4817. if ( column.sWidth !== null ) {
  4818. column.sWidth = _fnConvertToWidth( column.sWidthOrig, tableContainer );
  4819. userInputs = true;
  4820. }
  4821. }
  4822. /* If the number of columns in the DOM equals the number that we have to
  4823. * process in DataTables, then we can use the offsets that are created by
  4824. * the web- browser. No custom sizes can be set in order for this to happen,
  4825. * nor scrolling used
  4826. */
  4827. if ( ie67 || ! userInputs && ! scrollX && ! scrollY &&
  4828. columnCount == _fnVisbleColumns( oSettings ) &&
  4829. columnCount == headerCells.length
  4830. ) {
  4831. for ( i=0 ; i<columnCount ; i++ ) {
  4832. var colIdx = _fnVisibleToColumnIndex( oSettings, i );
  4833. if ( colIdx !== null ) {
  4834. columns[ colIdx ].sWidth = _fnStringToCss( headerCells.eq(i).width() );
  4835. }
  4836. }
  4837. }
  4838. else
  4839. {
  4840. // Otherwise construct a single row, worst case, table with the widest
  4841. // node in the data, assign any user defined widths, then insert it into
  4842. // the DOM and allow the browser to do all the hard work of calculating
  4843. // table widths
  4844. var tmpTable = $(table).clone() // don't use cloneNode - IE8 will remove events on the main table
  4845. .css( 'visibility', 'hidden' )
  4846. .removeAttr( 'id' );
  4847. // Clean up the table body
  4848. tmpTable.find('tbody tr').remove();
  4849. var tr = $('<tr/>').appendTo( tmpTable.find('tbody') );
  4850. // Clone the table header and footer - we can't use the header / footer
  4851. // from the cloned table, since if scrolling is active, the table's
  4852. // real header and footer are contained in different table tags
  4853. tmpTable.find('thead, tfoot').remove();
  4854. tmpTable
  4855. .append( $(oSettings.nTHead).clone() )
  4856. .append( $(oSettings.nTFoot).clone() );
  4857. // Remove any assigned widths from the footer (from scrolling)
  4858. tmpTable.find('tfoot th, tfoot td').css('width', '');
  4859. // Apply custom sizing to the cloned header
  4860. headerCells = _fnGetUniqueThs( oSettings, tmpTable.find('thead')[0] );
  4861. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4862. column = columns[ visibleColumns[i] ];
  4863. headerCells[i].style.width = column.sWidthOrig !== null && column.sWidthOrig !== '' ?
  4864. _fnStringToCss( column.sWidthOrig ) :
  4865. '';
  4866. // For scrollX we need to force the column width otherwise the
  4867. // browser will collapse it. If this width is smaller than the
  4868. // width the column requires, then it will have no effect
  4869. if ( column.sWidthOrig && scrollX ) {
  4870. $( headerCells[i] ).append( $('<div/>').css( {
  4871. width: column.sWidthOrig,
  4872. margin: 0,
  4873. padding: 0,
  4874. border: 0,
  4875. height: 1
  4876. } ) );
  4877. }
  4878. }
  4879. // Find the widest cell for each column and put it into the table
  4880. if ( oSettings.aoData.length ) {
  4881. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4882. columnIdx = visibleColumns[i];
  4883. column = columns[ columnIdx ];
  4884. $( _fnGetWidestNode( oSettings, columnIdx ) )
  4885. .clone( false )
  4886. .append( column.sContentPadding )
  4887. .appendTo( tr );
  4888. }
  4889. }
  4890. // Tidy the temporary table - remove name attributes so there aren't
  4891. // duplicated in the dom (radio elements for example)
  4892. $('[name]', tmpTable).removeAttr('name');
  4893. // Table has been built, attach to the document so we can work with it.
  4894. // A holding element is used, positioned at the top of the container
  4895. // with minimal height, so it has no effect on if the container scrolls
  4896. // or not. Otherwise it might trigger scrolling when it actually isn't
  4897. // needed
  4898. var holder = $('<div/>').css( scrollX || scrollY ?
  4899. {
  4900. position: 'absolute',
  4901. top: 0,
  4902. left: 0,
  4903. height: 1,
  4904. right: 0,
  4905. overflow: 'hidden'
  4906. } :
  4907. {}
  4908. )
  4909. .append( tmpTable )
  4910. .appendTo( tableContainer );
  4911. // When scrolling (X or Y) we want to set the width of the table as
  4912. // appropriate. However, when not scrolling leave the table width as it
  4913. // is. This results in slightly different, but I think correct behaviour
  4914. if ( scrollX && scrollXInner ) {
  4915. tmpTable.width( scrollXInner );
  4916. }
  4917. else if ( scrollX ) {
  4918. tmpTable.css( 'width', 'auto' );
  4919. tmpTable.removeAttr('width');
  4920. // If there is no width attribute or style, then allow the table to
  4921. // collapse
  4922. if ( tmpTable.width() < tableContainer.clientWidth && tableWidthAttr ) {
  4923. tmpTable.width( tableContainer.clientWidth );
  4924. }
  4925. }
  4926. else if ( scrollY ) {
  4927. tmpTable.width( tableContainer.clientWidth );
  4928. }
  4929. else if ( tableWidthAttr ) {
  4930. tmpTable.width( tableWidthAttr );
  4931. }
  4932. // Get the width of each column in the constructed table - we need to
  4933. // know the inner width (so it can be assigned to the other table's
  4934. // cells) and the outer width so we can calculate the full width of the
  4935. // table. This is safe since DataTables requires a unique cell for each
  4936. // column, but if ever a header can span multiple columns, this will
  4937. // need to be modified.
  4938. var total = 0;
  4939. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4940. var cell = $(headerCells[i]);
  4941. var border = cell.outerWidth() - cell.width();
  4942. // Use getBounding... where possible (not IE8-) because it can give
  4943. // sub-pixel accuracy, which we then want to round up!
  4944. var bounding = browser.bBounding ?
  4945. Math.ceil( headerCells[i].getBoundingClientRect().width ) :
  4946. cell.outerWidth();
  4947. // Total is tracked to remove any sub-pixel errors as the outerWidth
  4948. // of the table might not equal the total given here (IE!).
  4949. total += bounding;
  4950. // Width for each column to use
  4951. columns[ visibleColumns[i] ].sWidth = _fnStringToCss( bounding - border );
  4952. }
  4953. table.style.width = _fnStringToCss( total );
  4954. // Finished with the table - ditch it
  4955. holder.remove();
  4956. }
  4957. // If there is a width attr, we want to attach an event listener which
  4958. // allows the table sizing to automatically adjust when the window is
  4959. // resized. Use the width attr rather than CSS, since we can't know if the
  4960. // CSS is a relative value or absolute - DOM read is always px.
  4961. if ( tableWidthAttr ) {
  4962. table.style.width = _fnStringToCss( tableWidthAttr );
  4963. }
  4964. if ( (tableWidthAttr || scrollX) && ! oSettings._reszEvt ) {
  4965. var bindResize = function () {
  4966. $(window).on('resize.DT-'+oSettings.sInstance, _fnThrottle( function () {
  4967. _fnAdjustColumnSizing( oSettings );
  4968. } ) );
  4969. };
  4970. // IE6/7 will crash if we bind a resize event handler on page load.
  4971. // To be removed in 1.11 which drops IE6/7 support
  4972. if ( ie67 ) {
  4973. setTimeout( bindResize, 1000 );
  4974. }
  4975. else {
  4976. bindResize();
  4977. }
  4978. oSettings._reszEvt = true;
  4979. }
  4980. }
  4981. /**
  4982. * Throttle the calls to a function. Arguments and context are maintained for
  4983. * the throttled function
  4984. * @param {function} fn Function to be called
  4985. * @param {int} [freq=200] call frequency in mS
  4986. * @returns {function} wrapped function
  4987. * @memberof DataTable#oApi
  4988. */
  4989. var _fnThrottle = DataTable.util.throttle;
  4990. /**
  4991. * Convert a CSS unit width to pixels (e.g. 2em)
  4992. * @param {string} width width to be converted
  4993. * @param {node} parent parent to get the with for (required for relative widths) - optional
  4994. * @returns {int} width in pixels
  4995. * @memberof DataTable#oApi
  4996. */
  4997. function _fnConvertToWidth ( width, parent )
  4998. {
  4999. if ( ! width ) {
  5000. return 0;
  5001. }
  5002. var n = $('<div/>')
  5003. .css( 'width', _fnStringToCss( width ) )
  5004. .appendTo( parent || document.body );
  5005. var val = n[0].offsetWidth;
  5006. n.remove();
  5007. return val;
  5008. }
  5009. /**
  5010. * Get the widest node
  5011. * @param {object} settings dataTables settings object
  5012. * @param {int} colIdx column of interest
  5013. * @returns {node} widest table node
  5014. * @memberof DataTable#oApi
  5015. */
  5016. function _fnGetWidestNode( settings, colIdx )
  5017. {
  5018. var idx = _fnGetMaxLenString( settings, colIdx );
  5019. if ( idx < 0 ) {
  5020. return null;
  5021. }
  5022. var data = settings.aoData[ idx ];
  5023. return ! data.nTr ? // Might not have been created when deferred rendering
  5024. $('<td/>').html( _fnGetCellData( settings, idx, colIdx, 'display' ) )[0] :
  5025. data.anCells[ colIdx ];
  5026. }
  5027. /**
  5028. * Get the maximum strlen for each data column
  5029. * @param {object} settings dataTables settings object
  5030. * @param {int} colIdx column of interest
  5031. * @returns {string} max string length for each column
  5032. * @memberof DataTable#oApi
  5033. */
  5034. function _fnGetMaxLenString( settings, colIdx )
  5035. {
  5036. var s, max=-1, maxIdx = -1;
  5037. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  5038. s = _fnGetCellData( settings, i, colIdx, 'display' )+'';
  5039. s = s.replace( __re_html_remove, '' );
  5040. s = s.replace( /&nbsp;/g, ' ' );
  5041. if ( s.length > max ) {
  5042. max = s.length;
  5043. maxIdx = i;
  5044. }
  5045. }
  5046. return maxIdx;
  5047. }
  5048. /**
  5049. * Append a CSS unit (only if required) to a string
  5050. * @param {string} value to css-ify
  5051. * @returns {string} value with css unit
  5052. * @memberof DataTable#oApi
  5053. */
  5054. function _fnStringToCss( s )
  5055. {
  5056. if ( s === null ) {
  5057. return '0px';
  5058. }
  5059. if ( typeof s == 'number' ) {
  5060. return s < 0 ?
  5061. '0px' :
  5062. s+'px';
  5063. }
  5064. // Check it has a unit character already
  5065. return s.match(/\d$/) ?
  5066. s+'px' :
  5067. s;
  5068. }
  5069. function _fnSortFlatten ( settings )
  5070. {
  5071. var
  5072. i, iLen, k, kLen,
  5073. aSort = [],
  5074. aiOrig = [],
  5075. aoColumns = settings.aoColumns,
  5076. aDataSort, iCol, sType, srcCol,
  5077. fixed = settings.aaSortingFixed,
  5078. fixedObj = $.isPlainObject( fixed ),
  5079. nestedSort = [],
  5080. add = function ( a ) {
  5081. if ( a.length && ! Array.isArray( a[0] ) ) {
  5082. // 1D array
  5083. nestedSort.push( a );
  5084. }
  5085. else {
  5086. // 2D array
  5087. $.merge( nestedSort, a );
  5088. }
  5089. };
  5090. // Build the sort array, with pre-fix and post-fix options if they have been
  5091. // specified
  5092. if ( Array.isArray( fixed ) ) {
  5093. add( fixed );
  5094. }
  5095. if ( fixedObj && fixed.pre ) {
  5096. add( fixed.pre );
  5097. }
  5098. add( settings.aaSorting );
  5099. if (fixedObj && fixed.post ) {
  5100. add( fixed.post );
  5101. }
  5102. for ( i=0 ; i<nestedSort.length ; i++ )
  5103. {
  5104. srcCol = nestedSort[i][0];
  5105. aDataSort = aoColumns[ srcCol ].aDataSort;
  5106. for ( k=0, kLen=aDataSort.length ; k<kLen ; k++ )
  5107. {
  5108. iCol = aDataSort[k];
  5109. sType = aoColumns[ iCol ].sType || 'string';
  5110. if ( nestedSort[i]._idx === undefined ) {
  5111. nestedSort[i]._idx = $.inArray( nestedSort[i][1], aoColumns[iCol].asSorting );
  5112. }
  5113. aSort.push( {
  5114. src: srcCol,
  5115. col: iCol,
  5116. dir: nestedSort[i][1],
  5117. index: nestedSort[i]._idx,
  5118. type: sType,
  5119. formatter: DataTable.ext.type.order[ sType+"-pre" ]
  5120. } );
  5121. }
  5122. }
  5123. return aSort;
  5124. }
  5125. /**
  5126. * Change the order of the table
  5127. * @param {object} oSettings dataTables settings object
  5128. * @memberof DataTable#oApi
  5129. * @todo This really needs split up!
  5130. */
  5131. function _fnSort ( oSettings )
  5132. {
  5133. var
  5134. i, ien, iLen, j, jLen, k, kLen,
  5135. sDataType, nTh,
  5136. aiOrig = [],
  5137. oExtSort = DataTable.ext.type.order,
  5138. aoData = oSettings.aoData,
  5139. aoColumns = oSettings.aoColumns,
  5140. aDataSort, data, iCol, sType, oSort,
  5141. formatters = 0,
  5142. sortCol,
  5143. displayMaster = oSettings.aiDisplayMaster,
  5144. aSort;
  5145. // Resolve any column types that are unknown due to addition or invalidation
  5146. // @todo Can this be moved into a 'data-ready' handler which is called when
  5147. // data is going to be used in the table?
  5148. _fnColumnTypes( oSettings );
  5149. aSort = _fnSortFlatten( oSettings );
  5150. for ( i=0, ien=aSort.length ; i<ien ; i++ ) {
  5151. sortCol = aSort[i];
  5152. // Track if we can use the fast sort algorithm
  5153. if ( sortCol.formatter ) {
  5154. formatters++;
  5155. }
  5156. // Load the data needed for the sort, for each cell
  5157. _fnSortData( oSettings, sortCol.col );
  5158. }
  5159. /* No sorting required if server-side or no sorting array */
  5160. if ( _fnDataSource( oSettings ) != 'ssp' && aSort.length !== 0 )
  5161. {
  5162. // Create a value - key array of the current row positions such that we can use their
  5163. // current position during the sort, if values match, in order to perform stable sorting
  5164. for ( i=0, iLen=displayMaster.length ; i<iLen ; i++ ) {
  5165. aiOrig[ displayMaster[i] ] = i;
  5166. }
  5167. /* Do the sort - here we want multi-column sorting based on a given data source (column)
  5168. * and sorting function (from oSort) in a certain direction. It's reasonably complex to
  5169. * follow on it's own, but this is what we want (example two column sorting):
  5170. * fnLocalSorting = function(a,b){
  5171. * var iTest;
  5172. * iTest = oSort['string-asc']('data11', 'data12');
  5173. * if (iTest !== 0)
  5174. * return iTest;
  5175. * iTest = oSort['numeric-desc']('data21', 'data22');
  5176. * if (iTest !== 0)
  5177. * return iTest;
  5178. * return oSort['numeric-asc']( aiOrig[a], aiOrig[b] );
  5179. * }
  5180. * Basically we have a test for each sorting column, if the data in that column is equal,
  5181. * test the next column. If all columns match, then we use a numeric sort on the row
  5182. * positions in the original data array to provide a stable sort.
  5183. *
  5184. * Note - I know it seems excessive to have two sorting methods, but the first is around
  5185. * 15% faster, so the second is only maintained for backwards compatibility with sorting
  5186. * methods which do not have a pre-sort formatting function.
  5187. */
  5188. if ( formatters === aSort.length ) {
  5189. // All sort types have formatting functions
  5190. displayMaster.sort( function ( a, b ) {
  5191. var
  5192. x, y, k, test, sort,
  5193. len=aSort.length,
  5194. dataA = aoData[a]._aSortData,
  5195. dataB = aoData[b]._aSortData;
  5196. for ( k=0 ; k<len ; k++ ) {
  5197. sort = aSort[k];
  5198. x = dataA[ sort.col ];
  5199. y = dataB[ sort.col ];
  5200. test = x<y ? -1 : x>y ? 1 : 0;
  5201. if ( test !== 0 ) {
  5202. return sort.dir === 'asc' ? test : -test;
  5203. }
  5204. }
  5205. x = aiOrig[a];
  5206. y = aiOrig[b];
  5207. return x<y ? -1 : x>y ? 1 : 0;
  5208. } );
  5209. }
  5210. else {
  5211. // Depreciated - remove in 1.11 (providing a plug-in option)
  5212. // Not all sort types have formatting methods, so we have to call their sorting
  5213. // methods.
  5214. displayMaster.sort( function ( a, b ) {
  5215. var
  5216. x, y, k, l, test, sort, fn,
  5217. len=aSort.length,
  5218. dataA = aoData[a]._aSortData,
  5219. dataB = aoData[b]._aSortData;
  5220. for ( k=0 ; k<len ; k++ ) {
  5221. sort = aSort[k];
  5222. x = dataA[ sort.col ];
  5223. y = dataB[ sort.col ];
  5224. fn = oExtSort[ sort.type+"-"+sort.dir ] || oExtSort[ "string-"+sort.dir ];
  5225. test = fn( x, y );
  5226. if ( test !== 0 ) {
  5227. return test;
  5228. }
  5229. }
  5230. x = aiOrig[a];
  5231. y = aiOrig[b];
  5232. return x<y ? -1 : x>y ? 1 : 0;
  5233. } );
  5234. }
  5235. }
  5236. /* Tell the draw function that we have sorted the data */
  5237. oSettings.bSorted = true;
  5238. }
  5239. function _fnSortAria ( settings )
  5240. {
  5241. var label;
  5242. var nextSort;
  5243. var columns = settings.aoColumns;
  5244. var aSort = _fnSortFlatten( settings );
  5245. var oAria = settings.oLanguage.oAria;
  5246. // ARIA attributes - need to loop all columns, to update all (removing old
  5247. // attributes as needed)
  5248. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  5249. {
  5250. var col = columns[i];
  5251. var asSorting = col.asSorting;
  5252. var sTitle = col.sTitle.replace( /<.*?>/g, "" );
  5253. var th = col.nTh;
  5254. // IE7 is throwing an error when setting these properties with jQuery's
  5255. // attr() and removeAttr() methods...
  5256. th.removeAttribute('aria-sort');
  5257. /* In ARIA only the first sorting column can be marked as sorting - no multi-sort option */
  5258. if ( col.bSortable ) {
  5259. if ( aSort.length > 0 && aSort[0].col == i ) {
  5260. th.setAttribute('aria-sort', aSort[0].dir=="asc" ? "ascending" : "descending" );
  5261. nextSort = asSorting[ aSort[0].index+1 ] || asSorting[0];
  5262. }
  5263. else {
  5264. nextSort = asSorting[0];
  5265. }
  5266. label = sTitle + ( nextSort === "asc" ?
  5267. oAria.sSortAscending :
  5268. oAria.sSortDescending
  5269. );
  5270. }
  5271. else {
  5272. label = sTitle;
  5273. }
  5274. th.setAttribute('aria-label', label);
  5275. }
  5276. }
  5277. /**
  5278. * Function to run on user sort request
  5279. * @param {object} settings dataTables settings object
  5280. * @param {node} attachTo node to attach the handler to
  5281. * @param {int} colIdx column sorting index
  5282. * @param {boolean} [append=false] Append the requested sort to the existing
  5283. * sort if true (i.e. multi-column sort)
  5284. * @param {function} [callback] callback function
  5285. * @memberof DataTable#oApi
  5286. */
  5287. function _fnSortListener ( settings, colIdx, append, callback )
  5288. {
  5289. var col = settings.aoColumns[ colIdx ];
  5290. var sorting = settings.aaSorting;
  5291. var asSorting = col.asSorting;
  5292. var nextSortIdx;
  5293. var next = function ( a, overflow ) {
  5294. var idx = a._idx;
  5295. if ( idx === undefined ) {
  5296. idx = $.inArray( a[1], asSorting );
  5297. }
  5298. return idx+1 < asSorting.length ?
  5299. idx+1 :
  5300. overflow ?
  5301. null :
  5302. 0;
  5303. };
  5304. // Convert to 2D array if needed
  5305. if ( typeof sorting[0] === 'number' ) {
  5306. sorting = settings.aaSorting = [ sorting ];
  5307. }
  5308. // If appending the sort then we are multi-column sorting
  5309. if ( append && settings.oFeatures.bSortMulti ) {
  5310. // Are we already doing some kind of sort on this column?
  5311. var sortIdx = $.inArray( colIdx, _pluck(sorting, '0') );
  5312. if ( sortIdx !== -1 ) {
  5313. // Yes, modify the sort
  5314. nextSortIdx = next( sorting[sortIdx], true );
  5315. if ( nextSortIdx === null && sorting.length === 1 ) {
  5316. nextSortIdx = 0; // can't remove sorting completely
  5317. }
  5318. if ( nextSortIdx === null ) {
  5319. sorting.splice( sortIdx, 1 );
  5320. }
  5321. else {
  5322. sorting[sortIdx][1] = asSorting[ nextSortIdx ];
  5323. sorting[sortIdx]._idx = nextSortIdx;
  5324. }
  5325. }
  5326. else {
  5327. // No sort on this column yet
  5328. sorting.push( [ colIdx, asSorting[0], 0 ] );
  5329. sorting[sorting.length-1]._idx = 0;
  5330. }
  5331. }
  5332. else if ( sorting.length && sorting[0][0] == colIdx ) {
  5333. // Single column - already sorting on this column, modify the sort
  5334. nextSortIdx = next( sorting[0] );
  5335. sorting.length = 1;
  5336. sorting[0][1] = asSorting[ nextSortIdx ];
  5337. sorting[0]._idx = nextSortIdx;
  5338. }
  5339. else {
  5340. // Single column - sort only on this column
  5341. sorting.length = 0;
  5342. sorting.push( [ colIdx, asSorting[0] ] );
  5343. sorting[0]._idx = 0;
  5344. }
  5345. // Run the sort by calling a full redraw
  5346. _fnReDraw( settings );
  5347. // callback used for async user interaction
  5348. if ( typeof callback == 'function' ) {
  5349. callback( settings );
  5350. }
  5351. }
  5352. /**
  5353. * Attach a sort handler (click) to a node
  5354. * @param {object} settings dataTables settings object
  5355. * @param {node} attachTo node to attach the handler to
  5356. * @param {int} colIdx column sorting index
  5357. * @param {function} [callback] callback function
  5358. * @memberof DataTable#oApi
  5359. */
  5360. function _fnSortAttachListener ( settings, attachTo, colIdx, callback )
  5361. {
  5362. var col = settings.aoColumns[ colIdx ];
  5363. _fnBindAction( attachTo, {}, function (e) {
  5364. /* If the column is not sortable - don't to anything */
  5365. if ( col.bSortable === false ) {
  5366. return;
  5367. }
  5368. // If processing is enabled use a timeout to allow the processing
  5369. // display to be shown - otherwise to it synchronously
  5370. if ( settings.oFeatures.bProcessing ) {
  5371. _fnProcessingDisplay( settings, true );
  5372. setTimeout( function() {
  5373. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  5374. // In server-side processing, the draw callback will remove the
  5375. // processing display
  5376. if ( _fnDataSource( settings ) !== 'ssp' ) {
  5377. _fnProcessingDisplay( settings, false );
  5378. }
  5379. }, 0 );
  5380. }
  5381. else {
  5382. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  5383. }
  5384. } );
  5385. }
  5386. /**
  5387. * Set the sorting classes on table's body, Note: it is safe to call this function
  5388. * when bSort and bSortClasses are false
  5389. * @param {object} oSettings dataTables settings object
  5390. * @memberof DataTable#oApi
  5391. */
  5392. function _fnSortingClasses( settings )
  5393. {
  5394. var oldSort = settings.aLastSort;
  5395. var sortClass = settings.oClasses.sSortColumn;
  5396. var sort = _fnSortFlatten( settings );
  5397. var features = settings.oFeatures;
  5398. var i, ien, colIdx;
  5399. if ( features.bSort && features.bSortClasses ) {
  5400. // Remove old sorting classes
  5401. for ( i=0, ien=oldSort.length ; i<ien ; i++ ) {
  5402. colIdx = oldSort[i].src;
  5403. // Remove column sorting
  5404. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  5405. .removeClass( sortClass + (i<2 ? i+1 : 3) );
  5406. }
  5407. // Add new column sorting
  5408. for ( i=0, ien=sort.length ; i<ien ; i++ ) {
  5409. colIdx = sort[i].src;
  5410. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  5411. .addClass( sortClass + (i<2 ? i+1 : 3) );
  5412. }
  5413. }
  5414. settings.aLastSort = sort;
  5415. }
  5416. // Get the data to sort a column, be it from cache, fresh (populating the
  5417. // cache), or from a sort formatter
  5418. function _fnSortData( settings, idx )
  5419. {
  5420. // Custom sorting function - provided by the sort data type
  5421. var column = settings.aoColumns[ idx ];
  5422. var customSort = DataTable.ext.order[ column.sSortDataType ];
  5423. var customData;
  5424. if ( customSort ) {
  5425. customData = customSort.call( settings.oInstance, settings, idx,
  5426. _fnColumnIndexToVisible( settings, idx )
  5427. );
  5428. }
  5429. // Use / populate cache
  5430. var row, cellData;
  5431. var formatter = DataTable.ext.type.order[ column.sType+"-pre" ];
  5432. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  5433. row = settings.aoData[i];
  5434. if ( ! row._aSortData ) {
  5435. row._aSortData = [];
  5436. }
  5437. if ( ! row._aSortData[idx] || customSort ) {
  5438. cellData = customSort ?
  5439. customData[i] : // If there was a custom sort function, use data from there
  5440. _fnGetCellData( settings, i, idx, 'sort' );
  5441. row._aSortData[ idx ] = formatter ?
  5442. formatter( cellData ) :
  5443. cellData;
  5444. }
  5445. }
  5446. }
  5447. /**
  5448. * Save the state of a table
  5449. * @param {object} oSettings dataTables settings object
  5450. * @memberof DataTable#oApi
  5451. */
  5452. function _fnSaveState ( settings )
  5453. {
  5454. if ( !settings.oFeatures.bStateSave || settings.bDestroying )
  5455. {
  5456. return;
  5457. }
  5458. /* Store the interesting variables */
  5459. var state = {
  5460. time: +new Date(),
  5461. start: settings._iDisplayStart,
  5462. length: settings._iDisplayLength,
  5463. order: $.extend( true, [], settings.aaSorting ),
  5464. search: _fnSearchToCamel( settings.oPreviousSearch ),
  5465. columns: $.map( settings.aoColumns, function ( col, i ) {
  5466. return {
  5467. visible: col.bVisible,
  5468. search: _fnSearchToCamel( settings.aoPreSearchCols[i] )
  5469. };
  5470. } )
  5471. };
  5472. _fnCallbackFire( settings, "aoStateSaveParams", 'stateSaveParams', [settings, state] );
  5473. settings.oSavedState = state;
  5474. settings.fnStateSaveCallback.call( settings.oInstance, settings, state );
  5475. }
  5476. /**
  5477. * Attempt to load a saved table state
  5478. * @param {object} oSettings dataTables settings object
  5479. * @param {object} oInit DataTables init object so we can override settings
  5480. * @param {function} callback Callback to execute when the state has been loaded
  5481. * @memberof DataTable#oApi
  5482. */
  5483. function _fnLoadState ( settings, oInit, callback )
  5484. {
  5485. var i, ien;
  5486. var columns = settings.aoColumns;
  5487. var loaded = function ( s ) {
  5488. if ( ! s || ! s.time ) {
  5489. callback();
  5490. return;
  5491. }
  5492. // Allow custom and plug-in manipulation functions to alter the saved data set and
  5493. // cancelling of loading by returning false
  5494. var abStateLoad = _fnCallbackFire( settings, 'aoStateLoadParams', 'stateLoadParams', [settings, s] );
  5495. if ( $.inArray( false, abStateLoad ) !== -1 ) {
  5496. callback();
  5497. return;
  5498. }
  5499. // Reject old data
  5500. var duration = settings.iStateDuration;
  5501. if ( duration > 0 && s.time < +new Date() - (duration*1000) ) {
  5502. callback();
  5503. return;
  5504. }
  5505. // Number of columns have changed - all bets are off, no restore of settings
  5506. if ( s.columns && columns.length !== s.columns.length ) {
  5507. callback();
  5508. return;
  5509. }
  5510. // Store the saved state so it might be accessed at any time
  5511. settings.oLoadedState = $.extend( true, {}, s );
  5512. // Restore key features - todo - for 1.11 this needs to be done by
  5513. // subscribed events
  5514. if ( s.start !== undefined ) {
  5515. settings._iDisplayStart = s.start;
  5516. settings.iInitDisplayStart = s.start;
  5517. }
  5518. if ( s.length !== undefined ) {
  5519. settings._iDisplayLength = s.length;
  5520. }
  5521. // Order
  5522. if ( s.order !== undefined ) {
  5523. settings.aaSorting = [];
  5524. $.each( s.order, function ( i, col ) {
  5525. settings.aaSorting.push( col[0] >= columns.length ?
  5526. [ 0, col[1] ] :
  5527. col
  5528. );
  5529. } );
  5530. }
  5531. // Search
  5532. if ( s.search !== undefined ) {
  5533. $.extend( settings.oPreviousSearch, _fnSearchToHung( s.search ) );
  5534. }
  5535. // Columns
  5536. //
  5537. if ( s.columns ) {
  5538. for ( i=0, ien=s.columns.length ; i<ien ; i++ ) {
  5539. var col = s.columns[i];
  5540. // Visibility
  5541. if ( col.visible !== undefined ) {
  5542. columns[i].bVisible = col.visible;
  5543. }
  5544. // Search
  5545. if ( col.search !== undefined ) {
  5546. $.extend( settings.aoPreSearchCols[i], _fnSearchToHung( col.search ) );
  5547. }
  5548. }
  5549. }
  5550. _fnCallbackFire( settings, 'aoStateLoaded', 'stateLoaded', [settings, s] );
  5551. callback();
  5552. };
  5553. if ( ! settings.oFeatures.bStateSave ) {
  5554. callback();
  5555. return;
  5556. }
  5557. var state = settings.fnStateLoadCallback.call( settings.oInstance, settings, loaded );
  5558. if ( state !== undefined ) {
  5559. loaded( state );
  5560. }
  5561. // otherwise, wait for the loaded callback to be executed
  5562. }
  5563. /**
  5564. * Return the settings object for a particular table
  5565. * @param {node} table table we are using as a dataTable
  5566. * @returns {object} Settings object - or null if not found
  5567. * @memberof DataTable#oApi
  5568. */
  5569. function _fnSettingsFromNode ( table )
  5570. {
  5571. var settings = DataTable.settings;
  5572. var idx = $.inArray( table, _pluck( settings, 'nTable' ) );
  5573. return idx !== -1 ?
  5574. settings[ idx ] :
  5575. null;
  5576. }
  5577. /**
  5578. * Log an error message
  5579. * @param {object} settings dataTables settings object
  5580. * @param {int} level log error messages, or display them to the user
  5581. * @param {string} msg error message
  5582. * @param {int} tn Technical note id to get more information about the error.
  5583. * @memberof DataTable#oApi
  5584. */
  5585. function _fnLog( settings, level, msg, tn )
  5586. {
  5587. msg = 'DataTables warning: '+
  5588. (settings ? 'table id='+settings.sTableId+' - ' : '')+msg;
  5589. if ( tn ) {
  5590. msg += '. For more information about this error, please see '+
  5591. 'http://datatables.net/tn/'+tn;
  5592. }
  5593. if ( ! level ) {
  5594. // Backwards compatibility pre 1.10
  5595. var ext = DataTable.ext;
  5596. var type = ext.sErrMode || ext.errMode;
  5597. if ( settings ) {
  5598. _fnCallbackFire( settings, null, 'error', [ settings, tn, msg ] );
  5599. }
  5600. if ( type == 'alert' ) {
  5601. alert( msg );
  5602. }
  5603. else if ( type == 'throw' ) {
  5604. throw new Error(msg);
  5605. }
  5606. else if ( typeof type == 'function' ) {
  5607. type( settings, tn, msg );
  5608. }
  5609. }
  5610. else if ( window.console && console.log ) {
  5611. console.log( msg );
  5612. }
  5613. }
  5614. /**
  5615. * See if a property is defined on one object, if so assign it to the other object
  5616. * @param {object} ret target object
  5617. * @param {object} src source object
  5618. * @param {string} name property
  5619. * @param {string} [mappedName] name to map too - optional, name used if not given
  5620. * @memberof DataTable#oApi
  5621. */
  5622. function _fnMap( ret, src, name, mappedName )
  5623. {
  5624. if ( Array.isArray( name ) ) {
  5625. $.each( name, function (i, val) {
  5626. if ( Array.isArray( val ) ) {
  5627. _fnMap( ret, src, val[0], val[1] );
  5628. }
  5629. else {
  5630. _fnMap( ret, src, val );
  5631. }
  5632. } );
  5633. return;
  5634. }
  5635. if ( mappedName === undefined ) {
  5636. mappedName = name;
  5637. }
  5638. if ( src[name] !== undefined ) {
  5639. ret[mappedName] = src[name];
  5640. }
  5641. }
  5642. /**
  5643. * Extend objects - very similar to jQuery.extend, but deep copy objects, and
  5644. * shallow copy arrays. The reason we need to do this, is that we don't want to
  5645. * deep copy array init values (such as aaSorting) since the dev wouldn't be
  5646. * able to override them, but we do want to deep copy arrays.
  5647. * @param {object} out Object to extend
  5648. * @param {object} extender Object from which the properties will be applied to
  5649. * out
  5650. * @param {boolean} breakRefs If true, then arrays will be sliced to take an
  5651. * independent copy with the exception of the `data` or `aaData` parameters
  5652. * if they are present. This is so you can pass in a collection to
  5653. * DataTables and have that used as your data source without breaking the
  5654. * references
  5655. * @returns {object} out Reference, just for convenience - out === the return.
  5656. * @memberof DataTable#oApi
  5657. * @todo This doesn't take account of arrays inside the deep copied objects.
  5658. */
  5659. function _fnExtend( out, extender, breakRefs )
  5660. {
  5661. var val;
  5662. for ( var prop in extender ) {
  5663. if ( extender.hasOwnProperty(prop) ) {
  5664. val = extender[prop];
  5665. if ( $.isPlainObject( val ) ) {
  5666. if ( ! $.isPlainObject( out[prop] ) ) {
  5667. out[prop] = {};
  5668. }
  5669. $.extend( true, out[prop], val );
  5670. }
  5671. else if ( breakRefs && prop !== 'data' && prop !== 'aaData' && Array.isArray(val) ) {
  5672. out[prop] = val.slice();
  5673. }
  5674. else {
  5675. out[prop] = val;
  5676. }
  5677. }
  5678. }
  5679. return out;
  5680. }
  5681. /**
  5682. * Bind an event handers to allow a click or return key to activate the callback.
  5683. * This is good for accessibility since a return on the keyboard will have the
  5684. * same effect as a click, if the element has focus.
  5685. * @param {element} n Element to bind the action to
  5686. * @param {object} oData Data object to pass to the triggered function
  5687. * @param {function} fn Callback function for when the event is triggered
  5688. * @memberof DataTable#oApi
  5689. */
  5690. function _fnBindAction( n, oData, fn )
  5691. {
  5692. $(n)
  5693. .on( 'click.DT', oData, function (e) {
  5694. $(n).trigger('blur'); // Remove focus outline for mouse users
  5695. fn(e);
  5696. } )
  5697. .on( 'keypress.DT', oData, function (e){
  5698. if ( e.which === 13 ) {
  5699. e.preventDefault();
  5700. fn(e);
  5701. }
  5702. } )
  5703. .on( 'selectstart.DT', function () {
  5704. /* Take the brutal approach to cancelling text selection */
  5705. return false;
  5706. } );
  5707. }
  5708. /**
  5709. * Register a callback function. Easily allows a callback function to be added to
  5710. * an array store of callback functions that can then all be called together.
  5711. * @param {object} oSettings dataTables settings object
  5712. * @param {string} sStore Name of the array storage for the callbacks in oSettings
  5713. * @param {function} fn Function to be called back
  5714. * @param {string} sName Identifying name for the callback (i.e. a label)
  5715. * @memberof DataTable#oApi
  5716. */
  5717. function _fnCallbackReg( oSettings, sStore, fn, sName )
  5718. {
  5719. if ( fn )
  5720. {
  5721. oSettings[sStore].push( {
  5722. "fn": fn,
  5723. "sName": sName
  5724. } );
  5725. }
  5726. }
  5727. /**
  5728. * Fire callback functions and trigger events. Note that the loop over the
  5729. * callback array store is done backwards! Further note that you do not want to
  5730. * fire off triggers in time sensitive applications (for example cell creation)
  5731. * as its slow.
  5732. * @param {object} settings dataTables settings object
  5733. * @param {string} callbackArr Name of the array storage for the callbacks in
  5734. * oSettings
  5735. * @param {string} eventName Name of the jQuery custom event to trigger. If
  5736. * null no trigger is fired
  5737. * @param {array} args Array of arguments to pass to the callback function /
  5738. * trigger
  5739. * @memberof DataTable#oApi
  5740. */
  5741. function _fnCallbackFire( settings, callbackArr, eventName, args )
  5742. {
  5743. var ret = [];
  5744. if ( callbackArr ) {
  5745. ret = $.map( settings[callbackArr].slice().reverse(), function (val, i) {
  5746. return val.fn.apply( settings.oInstance, args );
  5747. } );
  5748. }
  5749. if ( eventName !== null ) {
  5750. var e = $.Event( eventName+'.dt' );
  5751. $(settings.nTable).trigger( e, args );
  5752. ret.push( e.result );
  5753. }
  5754. return ret;
  5755. }
  5756. function _fnLengthOverflow ( settings )
  5757. {
  5758. var
  5759. start = settings._iDisplayStart,
  5760. end = settings.fnDisplayEnd(),
  5761. len = settings._iDisplayLength;
  5762. /* If we have space to show extra rows (backing up from the end point - then do so */
  5763. if ( start >= end )
  5764. {
  5765. start = end - len;
  5766. }
  5767. // Keep the start record on the current page
  5768. start -= (start % len);
  5769. if ( len === -1 || start < 0 )
  5770. {
  5771. start = 0;
  5772. }
  5773. settings._iDisplayStart = start;
  5774. }
  5775. function _fnRenderer( settings, type )
  5776. {
  5777. var renderer = settings.renderer;
  5778. var host = DataTable.ext.renderer[type];
  5779. if ( $.isPlainObject( renderer ) && renderer[type] ) {
  5780. // Specific renderer for this type. If available use it, otherwise use
  5781. // the default.
  5782. return host[renderer[type]] || host._;
  5783. }
  5784. else if ( typeof renderer === 'string' ) {
  5785. // Common renderer - if there is one available for this type use it,
  5786. // otherwise use the default
  5787. return host[renderer] || host._;
  5788. }
  5789. // Use the default
  5790. return host._;
  5791. }
  5792. /**
  5793. * Detect the data source being used for the table. Used to simplify the code
  5794. * a little (ajax) and to make it compress a little smaller.
  5795. *
  5796. * @param {object} settings dataTables settings object
  5797. * @returns {string} Data source
  5798. * @memberof DataTable#oApi
  5799. */
  5800. function _fnDataSource ( settings )
  5801. {
  5802. if ( settings.oFeatures.bServerSide ) {
  5803. return 'ssp';
  5804. }
  5805. else if ( settings.ajax || settings.sAjaxSource ) {
  5806. return 'ajax';
  5807. }
  5808. return 'dom';
  5809. }
  5810. /**
  5811. * Computed structure of the DataTables API, defined by the options passed to
  5812. * `DataTable.Api.register()` when building the API.
  5813. *
  5814. * The structure is built in order to speed creation and extension of the Api
  5815. * objects since the extensions are effectively pre-parsed.
  5816. *
  5817. * The array is an array of objects with the following structure, where this
  5818. * base array represents the Api prototype base:
  5819. *
  5820. * [
  5821. * {
  5822. * name: 'data' -- string - Property name
  5823. * val: function () {}, -- function - Api method (or undefined if just an object
  5824. * methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  5825. * propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  5826. * },
  5827. * {
  5828. * name: 'row'
  5829. * val: {},
  5830. * methodExt: [ ... ],
  5831. * propExt: [
  5832. * {
  5833. * name: 'data'
  5834. * val: function () {},
  5835. * methodExt: [ ... ],
  5836. * propExt: [ ... ]
  5837. * },
  5838. * ...
  5839. * ]
  5840. * }
  5841. * ]
  5842. *
  5843. * @type {Array}
  5844. * @ignore
  5845. */
  5846. var __apiStruct = [];
  5847. /**
  5848. * `Array.prototype` reference.
  5849. *
  5850. * @type object
  5851. * @ignore
  5852. */
  5853. var __arrayProto = Array.prototype;
  5854. /**
  5855. * Abstraction for `context` parameter of the `Api` constructor to allow it to
  5856. * take several different forms for ease of use.
  5857. *
  5858. * Each of the input parameter types will be converted to a DataTables settings
  5859. * object where possible.
  5860. *
  5861. * @param {string|node|jQuery|object} mixed DataTable identifier. Can be one
  5862. * of:
  5863. *
  5864. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5865. * with be found and used.
  5866. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5867. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5868. * * `object` - DataTables settings object
  5869. * * `DataTables.Api` - API instance
  5870. * @return {array|null} Matching DataTables settings objects. `null` or
  5871. * `undefined` is returned if no matching DataTable is found.
  5872. * @ignore
  5873. */
  5874. var _toSettings = function ( mixed )
  5875. {
  5876. var idx, jq;
  5877. var settings = DataTable.settings;
  5878. var tables = $.map( settings, function (el, i) {
  5879. return el.nTable;
  5880. } );
  5881. if ( ! mixed ) {
  5882. return [];
  5883. }
  5884. else if ( mixed.nTable && mixed.oApi ) {
  5885. // DataTables settings object
  5886. return [ mixed ];
  5887. }
  5888. else if ( mixed.nodeName && mixed.nodeName.toLowerCase() === 'table' ) {
  5889. // Table node
  5890. idx = $.inArray( mixed, tables );
  5891. return idx !== -1 ? [ settings[idx] ] : null;
  5892. }
  5893. else if ( mixed && typeof mixed.settings === 'function' ) {
  5894. return mixed.settings().toArray();
  5895. }
  5896. else if ( typeof mixed === 'string' ) {
  5897. // jQuery selector
  5898. jq = $(mixed);
  5899. }
  5900. else if ( mixed instanceof $ ) {
  5901. // jQuery object (also DataTables instance)
  5902. jq = mixed;
  5903. }
  5904. if ( jq ) {
  5905. return jq.map( function(i) {
  5906. idx = $.inArray( this, tables );
  5907. return idx !== -1 ? settings[idx] : null;
  5908. } ).toArray();
  5909. }
  5910. };
  5911. /**
  5912. * DataTables API class - used to control and interface with one or more
  5913. * DataTables enhanced tables.
  5914. *
  5915. * The API class is heavily based on jQuery, presenting a chainable interface
  5916. * that you can use to interact with tables. Each instance of the API class has
  5917. * a "context" - i.e. the tables that it will operate on. This could be a single
  5918. * table, all tables on a page or a sub-set thereof.
  5919. *
  5920. * Additionally the API is designed to allow you to easily work with the data in
  5921. * the tables, retrieving and manipulating it as required. This is done by
  5922. * presenting the API class as an array like interface. The contents of the
  5923. * array depend upon the actions requested by each method (for example
  5924. * `rows().nodes()` will return an array of nodes, while `rows().data()` will
  5925. * return an array of objects or arrays depending upon your table's
  5926. * configuration). The API object has a number of array like methods (`push`,
  5927. * `pop`, `reverse` etc) as well as additional helper methods (`each`, `pluck`,
  5928. * `unique` etc) to assist your working with the data held in a table.
  5929. *
  5930. * Most methods (those which return an Api instance) are chainable, which means
  5931. * the return from a method call also has all of the methods available that the
  5932. * top level object had. For example, these two calls are equivalent:
  5933. *
  5934. * // Not chained
  5935. * api.row.add( {...} );
  5936. * api.draw();
  5937. *
  5938. * // Chained
  5939. * api.row.add( {...} ).draw();
  5940. *
  5941. * @class DataTable.Api
  5942. * @param {array|object|string|jQuery} context DataTable identifier. This is
  5943. * used to define which DataTables enhanced tables this API will operate on.
  5944. * Can be one of:
  5945. *
  5946. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5947. * with be found and used.
  5948. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5949. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5950. * * `object` - DataTables settings object
  5951. * @param {array} [data] Data to initialise the Api instance with.
  5952. *
  5953. * @example
  5954. * // Direct initialisation during DataTables construction
  5955. * var api = $('#example').DataTable();
  5956. *
  5957. * @example
  5958. * // Initialisation using a DataTables jQuery object
  5959. * var api = $('#example').dataTable().api();
  5960. *
  5961. * @example
  5962. * // Initialisation as a constructor
  5963. * var api = new $.fn.DataTable.Api( 'table.dataTable' );
  5964. */
  5965. _Api = function ( context, data )
  5966. {
  5967. if ( ! (this instanceof _Api) ) {
  5968. return new _Api( context, data );
  5969. }
  5970. var settings = [];
  5971. var ctxSettings = function ( o ) {
  5972. var a = _toSettings( o );
  5973. if ( a ) {
  5974. settings.push.apply( settings, a );
  5975. }
  5976. };
  5977. if ( Array.isArray( context ) ) {
  5978. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  5979. ctxSettings( context[i] );
  5980. }
  5981. }
  5982. else {
  5983. ctxSettings( context );
  5984. }
  5985. // Remove duplicates
  5986. this.context = _unique( settings );
  5987. // Initial data
  5988. if ( data ) {
  5989. $.merge( this, data );
  5990. }
  5991. // selector
  5992. this.selector = {
  5993. rows: null,
  5994. cols: null,
  5995. opts: null
  5996. };
  5997. _Api.extend( this, this, __apiStruct );
  5998. };
  5999. DataTable.Api = _Api;
  6000. // Don't destroy the existing prototype, just extend it. Required for jQuery 2's
  6001. // isPlainObject.
  6002. $.extend( _Api.prototype, {
  6003. any: function ()
  6004. {
  6005. return this.count() !== 0;
  6006. },
  6007. concat: __arrayProto.concat,
  6008. context: [], // array of table settings objects
  6009. count: function ()
  6010. {
  6011. return this.flatten().length;
  6012. },
  6013. each: function ( fn )
  6014. {
  6015. for ( var i=0, ien=this.length ; i<ien; i++ ) {
  6016. fn.call( this, this[i], i, this );
  6017. }
  6018. return this;
  6019. },
  6020. eq: function ( idx )
  6021. {
  6022. var ctx = this.context;
  6023. return ctx.length > idx ?
  6024. new _Api( ctx[idx], this[idx] ) :
  6025. null;
  6026. },
  6027. filter: function ( fn )
  6028. {
  6029. var a = [];
  6030. if ( __arrayProto.filter ) {
  6031. a = __arrayProto.filter.call( this, fn, this );
  6032. }
  6033. else {
  6034. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  6035. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  6036. if ( fn.call( this, this[i], i, this ) ) {
  6037. a.push( this[i] );
  6038. }
  6039. }
  6040. }
  6041. return new _Api( this.context, a );
  6042. },
  6043. flatten: function ()
  6044. {
  6045. var a = [];
  6046. return new _Api( this.context, a.concat.apply( a, this.toArray() ) );
  6047. },
  6048. join: __arrayProto.join,
  6049. indexOf: __arrayProto.indexOf || function (obj, start)
  6050. {
  6051. for ( var i=(start || 0), ien=this.length ; i<ien ; i++ ) {
  6052. if ( this[i] === obj ) {
  6053. return i;
  6054. }
  6055. }
  6056. return -1;
  6057. },
  6058. iterator: function ( flatten, type, fn, alwaysNew ) {
  6059. var
  6060. a = [], ret,
  6061. i, ien, j, jen,
  6062. context = this.context,
  6063. rows, items, item,
  6064. selector = this.selector;
  6065. // Argument shifting
  6066. if ( typeof flatten === 'string' ) {
  6067. alwaysNew = fn;
  6068. fn = type;
  6069. type = flatten;
  6070. flatten = false;
  6071. }
  6072. for ( i=0, ien=context.length ; i<ien ; i++ ) {
  6073. var apiInst = new _Api( context[i] );
  6074. if ( type === 'table' ) {
  6075. ret = fn.call( apiInst, context[i], i );
  6076. if ( ret !== undefined ) {
  6077. a.push( ret );
  6078. }
  6079. }
  6080. else if ( type === 'columns' || type === 'rows' ) {
  6081. // this has same length as context - one entry for each table
  6082. ret = fn.call( apiInst, context[i], this[i], i );
  6083. if ( ret !== undefined ) {
  6084. a.push( ret );
  6085. }
  6086. }
  6087. else if ( type === 'column' || type === 'column-rows' || type === 'row' || type === 'cell' ) {
  6088. // columns and rows share the same structure.
  6089. // 'this' is an array of column indexes for each context
  6090. items = this[i];
  6091. if ( type === 'column-rows' ) {
  6092. rows = _selector_row_indexes( context[i], selector.opts );
  6093. }
  6094. for ( j=0, jen=items.length ; j<jen ; j++ ) {
  6095. item = items[j];
  6096. if ( type === 'cell' ) {
  6097. ret = fn.call( apiInst, context[i], item.row, item.column, i, j );
  6098. }
  6099. else {
  6100. ret = fn.call( apiInst, context[i], item, i, j, rows );
  6101. }
  6102. if ( ret !== undefined ) {
  6103. a.push( ret );
  6104. }
  6105. }
  6106. }
  6107. }
  6108. if ( a.length || alwaysNew ) {
  6109. var api = new _Api( context, flatten ? a.concat.apply( [], a ) : a );
  6110. var apiSelector = api.selector;
  6111. apiSelector.rows = selector.rows;
  6112. apiSelector.cols = selector.cols;
  6113. apiSelector.opts = selector.opts;
  6114. return api;
  6115. }
  6116. return this;
  6117. },
  6118. lastIndexOf: __arrayProto.lastIndexOf || function (obj, start)
  6119. {
  6120. // Bit cheeky...
  6121. return this.indexOf.apply( this.toArray.reverse(), arguments );
  6122. },
  6123. length: 0,
  6124. map: function ( fn )
  6125. {
  6126. var a = [];
  6127. if ( __arrayProto.map ) {
  6128. a = __arrayProto.map.call( this, fn, this );
  6129. }
  6130. else {
  6131. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  6132. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  6133. a.push( fn.call( this, this[i], i ) );
  6134. }
  6135. }
  6136. return new _Api( this.context, a );
  6137. },
  6138. pluck: function ( prop )
  6139. {
  6140. return this.map( function ( el ) {
  6141. return el[ prop ];
  6142. } );
  6143. },
  6144. pop: __arrayProto.pop,
  6145. push: __arrayProto.push,
  6146. // Does not return an API instance
  6147. reduce: __arrayProto.reduce || function ( fn, init )
  6148. {
  6149. return _fnReduce( this, fn, init, 0, this.length, 1 );
  6150. },
  6151. reduceRight: __arrayProto.reduceRight || function ( fn, init )
  6152. {
  6153. return _fnReduce( this, fn, init, this.length-1, -1, -1 );
  6154. },
  6155. reverse: __arrayProto.reverse,
  6156. // Object with rows, columns and opts
  6157. selector: null,
  6158. shift: __arrayProto.shift,
  6159. slice: function () {
  6160. return new _Api( this.context, this );
  6161. },
  6162. sort: __arrayProto.sort, // ? name - order?
  6163. splice: __arrayProto.splice,
  6164. toArray: function ()
  6165. {
  6166. return __arrayProto.slice.call( this );
  6167. },
  6168. to$: function ()
  6169. {
  6170. return $( this );
  6171. },
  6172. toJQuery: function ()
  6173. {
  6174. return $( this );
  6175. },
  6176. unique: function ()
  6177. {
  6178. return new _Api( this.context, _unique(this) );
  6179. },
  6180. unshift: __arrayProto.unshift
  6181. } );
  6182. _Api.extend = function ( scope, obj, ext )
  6183. {
  6184. // Only extend API instances and static properties of the API
  6185. if ( ! ext.length || ! obj || ( ! (obj instanceof _Api) && ! obj.__dt_wrapper ) ) {
  6186. return;
  6187. }
  6188. var
  6189. i, ien,
  6190. struct,
  6191. methodScoping = function ( scope, fn, struc ) {
  6192. return function () {
  6193. var ret = fn.apply( scope, arguments );
  6194. // Method extension
  6195. _Api.extend( ret, ret, struc.methodExt );
  6196. return ret;
  6197. };
  6198. };
  6199. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  6200. struct = ext[i];
  6201. // Value
  6202. obj[ struct.name ] = struct.type === 'function' ?
  6203. methodScoping( scope, struct.val, struct ) :
  6204. struct.type === 'object' ?
  6205. {} :
  6206. struct.val;
  6207. obj[ struct.name ].__dt_wrapper = true;
  6208. // Property extension
  6209. _Api.extend( scope, obj[ struct.name ], struct.propExt );
  6210. }
  6211. };
  6212. // @todo - Is there need for an augment function?
  6213. // _Api.augment = function ( inst, name )
  6214. // {
  6215. // // Find src object in the structure from the name
  6216. // var parts = name.split('.');
  6217. // _Api.extend( inst, obj );
  6218. // };
  6219. // [
  6220. // {
  6221. // name: 'data' -- string - Property name
  6222. // val: function () {}, -- function - Api method (or undefined if just an object
  6223. // methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  6224. // propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  6225. // },
  6226. // {
  6227. // name: 'row'
  6228. // val: {},
  6229. // methodExt: [ ... ],
  6230. // propExt: [
  6231. // {
  6232. // name: 'data'
  6233. // val: function () {},
  6234. // methodExt: [ ... ],
  6235. // propExt: [ ... ]
  6236. // },
  6237. // ...
  6238. // ]
  6239. // }
  6240. // ]
  6241. _Api.register = _api_register = function ( name, val )
  6242. {
  6243. if ( Array.isArray( name ) ) {
  6244. for ( var j=0, jen=name.length ; j<jen ; j++ ) {
  6245. _Api.register( name[j], val );
  6246. }
  6247. return;
  6248. }
  6249. var
  6250. i, ien,
  6251. heir = name.split('.'),
  6252. struct = __apiStruct,
  6253. key, method;
  6254. var find = function ( src, name ) {
  6255. for ( var i=0, ien=src.length ; i<ien ; i++ ) {
  6256. if ( src[i].name === name ) {
  6257. return src[i];
  6258. }
  6259. }
  6260. return null;
  6261. };
  6262. for ( i=0, ien=heir.length ; i<ien ; i++ ) {
  6263. method = heir[i].indexOf('()') !== -1;
  6264. key = method ?
  6265. heir[i].replace('()', '') :
  6266. heir[i];
  6267. var src = find( struct, key );
  6268. if ( ! src ) {
  6269. src = {
  6270. name: key,
  6271. val: {},
  6272. methodExt: [],
  6273. propExt: [],
  6274. type: 'object'
  6275. };
  6276. struct.push( src );
  6277. }
  6278. if ( i === ien-1 ) {
  6279. src.val = val;
  6280. src.type = typeof val === 'function' ?
  6281. 'function' :
  6282. $.isPlainObject( val ) ?
  6283. 'object' :
  6284. 'other';
  6285. }
  6286. else {
  6287. struct = method ?
  6288. src.methodExt :
  6289. src.propExt;
  6290. }
  6291. }
  6292. };
  6293. _Api.registerPlural = _api_registerPlural = function ( pluralName, singularName, val ) {
  6294. _Api.register( pluralName, val );
  6295. _Api.register( singularName, function () {
  6296. var ret = val.apply( this, arguments );
  6297. if ( ret === this ) {
  6298. // Returned item is the API instance that was passed in, return it
  6299. return this;
  6300. }
  6301. else if ( ret instanceof _Api ) {
  6302. // New API instance returned, want the value from the first item
  6303. // in the returned array for the singular result.
  6304. return ret.length ?
  6305. Array.isArray( ret[0] ) ?
  6306. new _Api( ret.context, ret[0] ) : // Array results are 'enhanced'
  6307. ret[0] :
  6308. undefined;
  6309. }
  6310. // Non-API return - just fire it back
  6311. return ret;
  6312. } );
  6313. };
  6314. /**
  6315. * Selector for HTML tables. Apply the given selector to the give array of
  6316. * DataTables settings objects.
  6317. *
  6318. * @param {string|integer} [selector] jQuery selector string or integer
  6319. * @param {array} Array of DataTables settings objects to be filtered
  6320. * @return {array}
  6321. * @ignore
  6322. */
  6323. var __table_selector = function ( selector, a )
  6324. {
  6325. if ( Array.isArray(selector) ) {
  6326. return $.map( selector, function (item) {
  6327. return __table_selector(item, a);
  6328. } );
  6329. }
  6330. // Integer is used to pick out a table by index
  6331. if ( typeof selector === 'number' ) {
  6332. return [ a[ selector ] ];
  6333. }
  6334. // Perform a jQuery selector on the table nodes
  6335. var nodes = $.map( a, function (el, i) {
  6336. return el.nTable;
  6337. } );
  6338. return $(nodes)
  6339. .filter( selector )
  6340. .map( function (i) {
  6341. // Need to translate back from the table node to the settings
  6342. var idx = $.inArray( this, nodes );
  6343. return a[ idx ];
  6344. } )
  6345. .toArray();
  6346. };
  6347. /**
  6348. * Context selector for the API's context (i.e. the tables the API instance
  6349. * refers to.
  6350. *
  6351. * @name DataTable.Api#tables
  6352. * @param {string|integer} [selector] Selector to pick which tables the iterator
  6353. * should operate on. If not given, all tables in the current context are
  6354. * used. This can be given as a jQuery selector (for example `':gt(0)'`) to
  6355. * select multiple tables or as an integer to select a single table.
  6356. * @returns {DataTable.Api} Returns a new API instance if a selector is given.
  6357. */
  6358. _api_register( 'tables()', function ( selector ) {
  6359. // A new instance is created if there was a selector specified
  6360. return selector !== undefined && selector !== null ?
  6361. new _Api( __table_selector( selector, this.context ) ) :
  6362. this;
  6363. } );
  6364. _api_register( 'table()', function ( selector ) {
  6365. var tables = this.tables( selector );
  6366. var ctx = tables.context;
  6367. // Truncate to the first matched table
  6368. return ctx.length ?
  6369. new _Api( ctx[0] ) :
  6370. tables;
  6371. } );
  6372. _api_registerPlural( 'tables().nodes()', 'table().node()' , function () {
  6373. return this.iterator( 'table', function ( ctx ) {
  6374. return ctx.nTable;
  6375. }, 1 );
  6376. } );
  6377. _api_registerPlural( 'tables().body()', 'table().body()' , function () {
  6378. return this.iterator( 'table', function ( ctx ) {
  6379. return ctx.nTBody;
  6380. }, 1 );
  6381. } );
  6382. _api_registerPlural( 'tables().header()', 'table().header()' , function () {
  6383. return this.iterator( 'table', function ( ctx ) {
  6384. return ctx.nTHead;
  6385. }, 1 );
  6386. } );
  6387. _api_registerPlural( 'tables().footer()', 'table().footer()' , function () {
  6388. return this.iterator( 'table', function ( ctx ) {
  6389. return ctx.nTFoot;
  6390. }, 1 );
  6391. } );
  6392. _api_registerPlural( 'tables().containers()', 'table().container()' , function () {
  6393. return this.iterator( 'table', function ( ctx ) {
  6394. return ctx.nTableWrapper;
  6395. }, 1 );
  6396. } );
  6397. /**
  6398. * Redraw the tables in the current context.
  6399. */
  6400. _api_register( 'draw()', function ( paging ) {
  6401. return this.iterator( 'table', function ( settings ) {
  6402. if ( paging === 'page' ) {
  6403. _fnDraw( settings );
  6404. }
  6405. else {
  6406. if ( typeof paging === 'string' ) {
  6407. paging = paging === 'full-hold' ?
  6408. false :
  6409. true;
  6410. }
  6411. _fnReDraw( settings, paging===false );
  6412. }
  6413. } );
  6414. } );
  6415. /**
  6416. * Get the current page index.
  6417. *
  6418. * @return {integer} Current page index (zero based)
  6419. *//**
  6420. * Set the current page.
  6421. *
  6422. * Note that if you attempt to show a page which does not exist, DataTables will
  6423. * not throw an error, but rather reset the paging.
  6424. *
  6425. * @param {integer|string} action The paging action to take. This can be one of:
  6426. * * `integer` - The page index to jump to
  6427. * * `string` - An action to take:
  6428. * * `first` - Jump to first page.
  6429. * * `next` - Jump to the next page
  6430. * * `previous` - Jump to previous page
  6431. * * `last` - Jump to the last page.
  6432. * @returns {DataTables.Api} this
  6433. */
  6434. _api_register( 'page()', function ( action ) {
  6435. if ( action === undefined ) {
  6436. return this.page.info().page; // not an expensive call
  6437. }
  6438. // else, have an action to take on all tables
  6439. return this.iterator( 'table', function ( settings ) {
  6440. _fnPageChange( settings, action );
  6441. } );
  6442. } );
  6443. /**
  6444. * Paging information for the first table in the current context.
  6445. *
  6446. * If you require paging information for another table, use the `table()` method
  6447. * with a suitable selector.
  6448. *
  6449. * @return {object} Object with the following properties set:
  6450. * * `page` - Current page index (zero based - i.e. the first page is `0`)
  6451. * * `pages` - Total number of pages
  6452. * * `start` - Display index for the first record shown on the current page
  6453. * * `end` - Display index for the last record shown on the current page
  6454. * * `length` - Display length (number of records). Note that generally `start
  6455. * + length = end`, but this is not always true, for example if there are
  6456. * only 2 records to show on the final page, with a length of 10.
  6457. * * `recordsTotal` - Full data set length
  6458. * * `recordsDisplay` - Data set length once the current filtering criterion
  6459. * are applied.
  6460. */
  6461. _api_register( 'page.info()', function ( action ) {
  6462. if ( this.context.length === 0 ) {
  6463. return undefined;
  6464. }
  6465. var
  6466. settings = this.context[0],
  6467. start = settings._iDisplayStart,
  6468. len = settings.oFeatures.bPaginate ? settings._iDisplayLength : -1,
  6469. visRecords = settings.fnRecordsDisplay(),
  6470. all = len === -1;
  6471. return {
  6472. "page": all ? 0 : Math.floor( start / len ),
  6473. "pages": all ? 1 : Math.ceil( visRecords / len ),
  6474. "start": start,
  6475. "end": settings.fnDisplayEnd(),
  6476. "length": len,
  6477. "recordsTotal": settings.fnRecordsTotal(),
  6478. "recordsDisplay": visRecords,
  6479. "serverSide": _fnDataSource( settings ) === 'ssp'
  6480. };
  6481. } );
  6482. /**
  6483. * Get the current page length.
  6484. *
  6485. * @return {integer} Current page length. Note `-1` indicates that all records
  6486. * are to be shown.
  6487. *//**
  6488. * Set the current page length.
  6489. *
  6490. * @param {integer} Page length to set. Use `-1` to show all records.
  6491. * @returns {DataTables.Api} this
  6492. */
  6493. _api_register( 'page.len()', function ( len ) {
  6494. // Note that we can't call this function 'length()' because `length`
  6495. // is a Javascript property of functions which defines how many arguments
  6496. // the function expects.
  6497. if ( len === undefined ) {
  6498. return this.context.length !== 0 ?
  6499. this.context[0]._iDisplayLength :
  6500. undefined;
  6501. }
  6502. // else, set the page length
  6503. return this.iterator( 'table', function ( settings ) {
  6504. _fnLengthChange( settings, len );
  6505. } );
  6506. } );
  6507. var __reload = function ( settings, holdPosition, callback ) {
  6508. // Use the draw event to trigger a callback
  6509. if ( callback ) {
  6510. var api = new _Api( settings );
  6511. api.one( 'draw', function () {
  6512. callback( api.ajax.json() );
  6513. } );
  6514. }
  6515. if ( _fnDataSource( settings ) == 'ssp' ) {
  6516. _fnReDraw( settings, holdPosition );
  6517. }
  6518. else {
  6519. _fnProcessingDisplay( settings, true );
  6520. // Cancel an existing request
  6521. var xhr = settings.jqXHR;
  6522. if ( xhr && xhr.readyState !== 4 ) {
  6523. xhr.abort();
  6524. }
  6525. // Trigger xhr
  6526. _fnBuildAjax( settings, [], function( json ) {
  6527. _fnClearTable( settings );
  6528. var data = _fnAjaxDataSrc( settings, json );
  6529. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6530. _fnAddData( settings, data[i] );
  6531. }
  6532. _fnReDraw( settings, holdPosition );
  6533. _fnProcessingDisplay( settings, false );
  6534. } );
  6535. }
  6536. };
  6537. /**
  6538. * Get the JSON response from the last Ajax request that DataTables made to the
  6539. * server. Note that this returns the JSON from the first table in the current
  6540. * context.
  6541. *
  6542. * @return {object} JSON received from the server.
  6543. */
  6544. _api_register( 'ajax.json()', function () {
  6545. var ctx = this.context;
  6546. if ( ctx.length > 0 ) {
  6547. return ctx[0].json;
  6548. }
  6549. // else return undefined;
  6550. } );
  6551. /**
  6552. * Get the data submitted in the last Ajax request
  6553. */
  6554. _api_register( 'ajax.params()', function () {
  6555. var ctx = this.context;
  6556. if ( ctx.length > 0 ) {
  6557. return ctx[0].oAjaxData;
  6558. }
  6559. // else return undefined;
  6560. } );
  6561. /**
  6562. * Reload tables from the Ajax data source. Note that this function will
  6563. * automatically re-draw the table when the remote data has been loaded.
  6564. *
  6565. * @param {boolean} [reset=true] Reset (default) or hold the current paging
  6566. * position. A full re-sort and re-filter is performed when this method is
  6567. * called, which is why the pagination reset is the default action.
  6568. * @returns {DataTables.Api} this
  6569. */
  6570. _api_register( 'ajax.reload()', function ( callback, resetPaging ) {
  6571. return this.iterator( 'table', function (settings) {
  6572. __reload( settings, resetPaging===false, callback );
  6573. } );
  6574. } );
  6575. /**
  6576. * Get the current Ajax URL. Note that this returns the URL from the first
  6577. * table in the current context.
  6578. *
  6579. * @return {string} Current Ajax source URL
  6580. *//**
  6581. * Set the Ajax URL. Note that this will set the URL for all tables in the
  6582. * current context.
  6583. *
  6584. * @param {string} url URL to set.
  6585. * @returns {DataTables.Api} this
  6586. */
  6587. _api_register( 'ajax.url()', function ( url ) {
  6588. var ctx = this.context;
  6589. if ( url === undefined ) {
  6590. // get
  6591. if ( ctx.length === 0 ) {
  6592. return undefined;
  6593. }
  6594. ctx = ctx[0];
  6595. return ctx.ajax ?
  6596. $.isPlainObject( ctx.ajax ) ?
  6597. ctx.ajax.url :
  6598. ctx.ajax :
  6599. ctx.sAjaxSource;
  6600. }
  6601. // set
  6602. return this.iterator( 'table', function ( settings ) {
  6603. if ( $.isPlainObject( settings.ajax ) ) {
  6604. settings.ajax.url = url;
  6605. }
  6606. else {
  6607. settings.ajax = url;
  6608. }
  6609. // No need to consider sAjaxSource here since DataTables gives priority
  6610. // to `ajax` over `sAjaxSource`. So setting `ajax` here, renders any
  6611. // value of `sAjaxSource` redundant.
  6612. } );
  6613. } );
  6614. /**
  6615. * Load data from the newly set Ajax URL. Note that this method is only
  6616. * available when `ajax.url()` is used to set a URL. Additionally, this method
  6617. * has the same effect as calling `ajax.reload()` but is provided for
  6618. * convenience when setting a new URL. Like `ajax.reload()` it will
  6619. * automatically redraw the table once the remote data has been loaded.
  6620. *
  6621. * @returns {DataTables.Api} this
  6622. */
  6623. _api_register( 'ajax.url().load()', function ( callback, resetPaging ) {
  6624. // Same as a reload, but makes sense to present it for easy access after a
  6625. // url change
  6626. return this.iterator( 'table', function ( ctx ) {
  6627. __reload( ctx, resetPaging===false, callback );
  6628. } );
  6629. } );
  6630. var _selector_run = function ( type, selector, selectFn, settings, opts )
  6631. {
  6632. var
  6633. out = [], res,
  6634. a, i, ien, j, jen,
  6635. selectorType = typeof selector;
  6636. // Can't just check for isArray here, as an API or jQuery instance might be
  6637. // given with their array like look
  6638. if ( ! selector || selectorType === 'string' || selectorType === 'function' || selector.length === undefined ) {
  6639. selector = [ selector ];
  6640. }
  6641. for ( i=0, ien=selector.length ; i<ien ; i++ ) {
  6642. // Only split on simple strings - complex expressions will be jQuery selectors
  6643. a = selector[i] && selector[i].split && ! selector[i].match(/[\[\(:]/) ?
  6644. selector[i].split(',') :
  6645. [ selector[i] ];
  6646. for ( j=0, jen=a.length ; j<jen ; j++ ) {
  6647. res = selectFn( typeof a[j] === 'string' ? (a[j]).trim() : a[j] );
  6648. if ( res && res.length ) {
  6649. out = out.concat( res );
  6650. }
  6651. }
  6652. }
  6653. // selector extensions
  6654. var ext = _ext.selector[ type ];
  6655. if ( ext.length ) {
  6656. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  6657. out = ext[i]( settings, opts, out );
  6658. }
  6659. }
  6660. return _unique( out );
  6661. };
  6662. var _selector_opts = function ( opts )
  6663. {
  6664. if ( ! opts ) {
  6665. opts = {};
  6666. }
  6667. // Backwards compatibility for 1.9- which used the terminology filter rather
  6668. // than search
  6669. if ( opts.filter && opts.search === undefined ) {
  6670. opts.search = opts.filter;
  6671. }
  6672. return $.extend( {
  6673. search: 'none',
  6674. order: 'current',
  6675. page: 'all'
  6676. }, opts );
  6677. };
  6678. var _selector_first = function ( inst )
  6679. {
  6680. // Reduce the API instance to the first item found
  6681. for ( var i=0, ien=inst.length ; i<ien ; i++ ) {
  6682. if ( inst[i].length > 0 ) {
  6683. // Assign the first element to the first item in the instance
  6684. // and truncate the instance and context
  6685. inst[0] = inst[i];
  6686. inst[0].length = 1;
  6687. inst.length = 1;
  6688. inst.context = [ inst.context[i] ];
  6689. return inst;
  6690. }
  6691. }
  6692. // Not found - return an empty instance
  6693. inst.length = 0;
  6694. return inst;
  6695. };
  6696. var _selector_row_indexes = function ( settings, opts )
  6697. {
  6698. var
  6699. i, ien, tmp, a=[],
  6700. displayFiltered = settings.aiDisplay,
  6701. displayMaster = settings.aiDisplayMaster;
  6702. var
  6703. search = opts.search, // none, applied, removed
  6704. order = opts.order, // applied, current, index (original - compatibility with 1.9)
  6705. page = opts.page; // all, current
  6706. if ( _fnDataSource( settings ) == 'ssp' ) {
  6707. // In server-side processing mode, most options are irrelevant since
  6708. // rows not shown don't exist and the index order is the applied order
  6709. // Removed is a special case - for consistency just return an empty
  6710. // array
  6711. return search === 'removed' ?
  6712. [] :
  6713. _range( 0, displayMaster.length );
  6714. }
  6715. else if ( page == 'current' ) {
  6716. // Current page implies that order=current and fitler=applied, since it is
  6717. // fairly senseless otherwise, regardless of what order and search actually
  6718. // are
  6719. for ( i=settings._iDisplayStart, ien=settings.fnDisplayEnd() ; i<ien ; i++ ) {
  6720. a.push( displayFiltered[i] );
  6721. }
  6722. }
  6723. else if ( order == 'current' || order == 'applied' ) {
  6724. if ( search == 'none') {
  6725. a = displayMaster.slice();
  6726. }
  6727. else if ( search == 'applied' ) {
  6728. a = displayFiltered.slice();
  6729. }
  6730. else if ( search == 'removed' ) {
  6731. // O(n+m) solution by creating a hash map
  6732. var displayFilteredMap = {};
  6733. for ( var i=0, ien=displayFiltered.length ; i<ien ; i++ ) {
  6734. displayFilteredMap[displayFiltered[i]] = null;
  6735. }
  6736. a = $.map( displayMaster, function (el) {
  6737. return ! displayFilteredMap.hasOwnProperty(el) ?
  6738. el :
  6739. null;
  6740. } );
  6741. }
  6742. }
  6743. else if ( order == 'index' || order == 'original' ) {
  6744. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  6745. if ( search == 'none' ) {
  6746. a.push( i );
  6747. }
  6748. else { // applied | removed
  6749. tmp = $.inArray( i, displayFiltered );
  6750. if ((tmp === -1 && search == 'removed') ||
  6751. (tmp >= 0 && search == 'applied') )
  6752. {
  6753. a.push( i );
  6754. }
  6755. }
  6756. }
  6757. }
  6758. return a;
  6759. };
  6760. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6761. * Rows
  6762. *
  6763. * {} - no selector - use all available rows
  6764. * {integer} - row aoData index
  6765. * {node} - TR node
  6766. * {string} - jQuery selector to apply to the TR elements
  6767. * {array} - jQuery array of nodes, or simply an array of TR nodes
  6768. *
  6769. */
  6770. var __row_selector = function ( settings, selector, opts )
  6771. {
  6772. var rows;
  6773. var run = function ( sel ) {
  6774. var selInt = _intVal( sel );
  6775. var i, ien;
  6776. var aoData = settings.aoData;
  6777. // Short cut - selector is a number and no options provided (default is
  6778. // all records, so no need to check if the index is in there, since it
  6779. // must be - dev error if the index doesn't exist).
  6780. if ( selInt !== null && ! opts ) {
  6781. return [ selInt ];
  6782. }
  6783. if ( ! rows ) {
  6784. rows = _selector_row_indexes( settings, opts );
  6785. }
  6786. if ( selInt !== null && $.inArray( selInt, rows ) !== -1 ) {
  6787. // Selector - integer
  6788. return [ selInt ];
  6789. }
  6790. else if ( sel === null || sel === undefined || sel === '' ) {
  6791. // Selector - none
  6792. return rows;
  6793. }
  6794. // Selector - function
  6795. if ( typeof sel === 'function' ) {
  6796. return $.map( rows, function (idx) {
  6797. var row = aoData[ idx ];
  6798. return sel( idx, row._aData, row.nTr ) ? idx : null;
  6799. } );
  6800. }
  6801. // Selector - node
  6802. if ( sel.nodeName ) {
  6803. var rowIdx = sel._DT_RowIndex; // Property added by DT for fast lookup
  6804. var cellIdx = sel._DT_CellIndex;
  6805. if ( rowIdx !== undefined ) {
  6806. // Make sure that the row is actually still present in the table
  6807. return aoData[ rowIdx ] && aoData[ rowIdx ].nTr === sel ?
  6808. [ rowIdx ] :
  6809. [];
  6810. }
  6811. else if ( cellIdx ) {
  6812. return aoData[ cellIdx.row ] && aoData[ cellIdx.row ].nTr === sel.parentNode ?
  6813. [ cellIdx.row ] :
  6814. [];
  6815. }
  6816. else {
  6817. var host = $(sel).closest('*[data-dt-row]');
  6818. return host.length ?
  6819. [ host.data('dt-row') ] :
  6820. [];
  6821. }
  6822. }
  6823. // ID selector. Want to always be able to select rows by id, regardless
  6824. // of if the tr element has been created or not, so can't rely upon
  6825. // jQuery here - hence a custom implementation. This does not match
  6826. // Sizzle's fast selector or HTML4 - in HTML5 the ID can be anything,
  6827. // but to select it using a CSS selector engine (like Sizzle or
  6828. // querySelect) it would need to need to be escaped for some characters.
  6829. // DataTables simplifies this for row selectors since you can select
  6830. // only a row. A # indicates an id any anything that follows is the id -
  6831. // unescaped.
  6832. if ( typeof sel === 'string' && sel.charAt(0) === '#' ) {
  6833. // get row index from id
  6834. var rowObj = settings.aIds[ sel.replace( /^#/, '' ) ];
  6835. if ( rowObj !== undefined ) {
  6836. return [ rowObj.idx ];
  6837. }
  6838. // need to fall through to jQuery in case there is DOM id that
  6839. // matches
  6840. }
  6841. // Get nodes in the order from the `rows` array with null values removed
  6842. var nodes = _removeEmpty(
  6843. _pluck_order( settings.aoData, rows, 'nTr' )
  6844. );
  6845. // Selector - jQuery selector string, array of nodes or jQuery object/
  6846. // As jQuery's .filter() allows jQuery objects to be passed in filter,
  6847. // it also allows arrays, so this will cope with all three options
  6848. return $(nodes)
  6849. .filter( sel )
  6850. .map( function () {
  6851. return this._DT_RowIndex;
  6852. } )
  6853. .toArray();
  6854. };
  6855. return _selector_run( 'row', selector, run, settings, opts );
  6856. };
  6857. _api_register( 'rows()', function ( selector, opts ) {
  6858. // argument shifting
  6859. if ( selector === undefined ) {
  6860. selector = '';
  6861. }
  6862. else if ( $.isPlainObject( selector ) ) {
  6863. opts = selector;
  6864. selector = '';
  6865. }
  6866. opts = _selector_opts( opts );
  6867. var inst = this.iterator( 'table', function ( settings ) {
  6868. return __row_selector( settings, selector, opts );
  6869. }, 1 );
  6870. // Want argument shifting here and in __row_selector?
  6871. inst.selector.rows = selector;
  6872. inst.selector.opts = opts;
  6873. return inst;
  6874. } );
  6875. _api_register( 'rows().nodes()', function () {
  6876. return this.iterator( 'row', function ( settings, row ) {
  6877. return settings.aoData[ row ].nTr || undefined;
  6878. }, 1 );
  6879. } );
  6880. _api_register( 'rows().data()', function () {
  6881. return this.iterator( true, 'rows', function ( settings, rows ) {
  6882. return _pluck_order( settings.aoData, rows, '_aData' );
  6883. }, 1 );
  6884. } );
  6885. _api_registerPlural( 'rows().cache()', 'row().cache()', function ( type ) {
  6886. return this.iterator( 'row', function ( settings, row ) {
  6887. var r = settings.aoData[ row ];
  6888. return type === 'search' ? r._aFilterData : r._aSortData;
  6889. }, 1 );
  6890. } );
  6891. _api_registerPlural( 'rows().invalidate()', 'row().invalidate()', function ( src ) {
  6892. return this.iterator( 'row', function ( settings, row ) {
  6893. _fnInvalidate( settings, row, src );
  6894. } );
  6895. } );
  6896. _api_registerPlural( 'rows().indexes()', 'row().index()', function () {
  6897. return this.iterator( 'row', function ( settings, row ) {
  6898. return row;
  6899. }, 1 );
  6900. } );
  6901. _api_registerPlural( 'rows().ids()', 'row().id()', function ( hash ) {
  6902. var a = [];
  6903. var context = this.context;
  6904. // `iterator` will drop undefined values, but in this case we want them
  6905. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  6906. for ( var j=0, jen=this[i].length ; j<jen ; j++ ) {
  6907. var id = context[i].rowIdFn( context[i].aoData[ this[i][j] ]._aData );
  6908. a.push( (hash === true ? '#' : '' )+ id );
  6909. }
  6910. }
  6911. return new _Api( context, a );
  6912. } );
  6913. _api_registerPlural( 'rows().remove()', 'row().remove()', function () {
  6914. var that = this;
  6915. this.iterator( 'row', function ( settings, row, thatIdx ) {
  6916. var data = settings.aoData;
  6917. var rowData = data[ row ];
  6918. var i, ien, j, jen;
  6919. var loopRow, loopCells;
  6920. data.splice( row, 1 );
  6921. // Update the cached indexes
  6922. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  6923. loopRow = data[i];
  6924. loopCells = loopRow.anCells;
  6925. // Rows
  6926. if ( loopRow.nTr !== null ) {
  6927. loopRow.nTr._DT_RowIndex = i;
  6928. }
  6929. // Cells
  6930. if ( loopCells !== null ) {
  6931. for ( j=0, jen=loopCells.length ; j<jen ; j++ ) {
  6932. loopCells[j]._DT_CellIndex.row = i;
  6933. }
  6934. }
  6935. }
  6936. // Delete from the display arrays
  6937. _fnDeleteIndex( settings.aiDisplayMaster, row );
  6938. _fnDeleteIndex( settings.aiDisplay, row );
  6939. _fnDeleteIndex( that[ thatIdx ], row, false ); // maintain local indexes
  6940. // For server-side processing tables - subtract the deleted row from the count
  6941. if ( settings._iRecordsDisplay > 0 ) {
  6942. settings._iRecordsDisplay--;
  6943. }
  6944. // Check for an 'overflow' they case for displaying the table
  6945. _fnLengthOverflow( settings );
  6946. // Remove the row's ID reference if there is one
  6947. var id = settings.rowIdFn( rowData._aData );
  6948. if ( id !== undefined ) {
  6949. delete settings.aIds[ id ];
  6950. }
  6951. } );
  6952. this.iterator( 'table', function ( settings ) {
  6953. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  6954. settings.aoData[i].idx = i;
  6955. }
  6956. } );
  6957. return this;
  6958. } );
  6959. _api_register( 'rows.add()', function ( rows ) {
  6960. var newRows = this.iterator( 'table', function ( settings ) {
  6961. var row, i, ien;
  6962. var out = [];
  6963. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  6964. row = rows[i];
  6965. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  6966. out.push( _fnAddTr( settings, row )[0] );
  6967. }
  6968. else {
  6969. out.push( _fnAddData( settings, row ) );
  6970. }
  6971. }
  6972. return out;
  6973. }, 1 );
  6974. // Return an Api.rows() extended instance, so rows().nodes() etc can be used
  6975. var modRows = this.rows( -1 );
  6976. modRows.pop();
  6977. $.merge( modRows, newRows );
  6978. return modRows;
  6979. } );
  6980. /**
  6981. *
  6982. */
  6983. _api_register( 'row()', function ( selector, opts ) {
  6984. return _selector_first( this.rows( selector, opts ) );
  6985. } );
  6986. _api_register( 'row().data()', function ( data ) {
  6987. var ctx = this.context;
  6988. if ( data === undefined ) {
  6989. // Get
  6990. return ctx.length && this.length ?
  6991. ctx[0].aoData[ this[0] ]._aData :
  6992. undefined;
  6993. }
  6994. // Set
  6995. var row = ctx[0].aoData[ this[0] ];
  6996. row._aData = data;
  6997. // If the DOM has an id, and the data source is an array
  6998. if ( Array.isArray( data ) && row.nTr && row.nTr.id ) {
  6999. _fnSetObjectDataFn( ctx[0].rowId )( data, row.nTr.id );
  7000. }
  7001. // Automatically invalidate
  7002. _fnInvalidate( ctx[0], this[0], 'data' );
  7003. return this;
  7004. } );
  7005. _api_register( 'row().node()', function () {
  7006. var ctx = this.context;
  7007. return ctx.length && this.length ?
  7008. ctx[0].aoData[ this[0] ].nTr || null :
  7009. null;
  7010. } );
  7011. _api_register( 'row.add()', function ( row ) {
  7012. // Allow a jQuery object to be passed in - only a single row is added from
  7013. // it though - the first element in the set
  7014. if ( row instanceof $ && row.length ) {
  7015. row = row[0];
  7016. }
  7017. var rows = this.iterator( 'table', function ( settings ) {
  7018. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  7019. return _fnAddTr( settings, row )[0];
  7020. }
  7021. return _fnAddData( settings, row );
  7022. } );
  7023. // Return an Api.rows() extended instance, with the newly added row selected
  7024. return this.row( rows[0] );
  7025. } );
  7026. var __details_add = function ( ctx, row, data, klass )
  7027. {
  7028. // Convert to array of TR elements
  7029. var rows = [];
  7030. var addRow = function ( r, k ) {
  7031. // Recursion to allow for arrays of jQuery objects
  7032. if ( Array.isArray( r ) || r instanceof $ ) {
  7033. for ( var i=0, ien=r.length ; i<ien ; i++ ) {
  7034. addRow( r[i], k );
  7035. }
  7036. return;
  7037. }
  7038. // If we get a TR element, then just add it directly - up to the dev
  7039. // to add the correct number of columns etc
  7040. if ( r.nodeName && r.nodeName.toLowerCase() === 'tr' ) {
  7041. rows.push( r );
  7042. }
  7043. else {
  7044. // Otherwise create a row with a wrapper
  7045. var created = $('<tr><td></td></tr>').addClass( k );
  7046. $('td', created)
  7047. .addClass( k )
  7048. .html( r )
  7049. [0].colSpan = _fnVisbleColumns( ctx );
  7050. rows.push( created[0] );
  7051. }
  7052. };
  7053. addRow( data, klass );
  7054. if ( row._details ) {
  7055. row._details.detach();
  7056. }
  7057. row._details = $(rows);
  7058. // If the children were already shown, that state should be retained
  7059. if ( row._detailsShow ) {
  7060. row._details.insertAfter( row.nTr );
  7061. }
  7062. };
  7063. var __details_remove = function ( api, idx )
  7064. {
  7065. var ctx = api.context;
  7066. if ( ctx.length ) {
  7067. var row = ctx[0].aoData[ idx !== undefined ? idx : api[0] ];
  7068. if ( row && row._details ) {
  7069. row._details.remove();
  7070. row._detailsShow = undefined;
  7071. row._details = undefined;
  7072. }
  7073. }
  7074. };
  7075. var __details_display = function ( api, show ) {
  7076. var ctx = api.context;
  7077. if ( ctx.length && api.length ) {
  7078. var row = ctx[0].aoData[ api[0] ];
  7079. if ( row._details ) {
  7080. row._detailsShow = show;
  7081. if ( show ) {
  7082. row._details.insertAfter( row.nTr );
  7083. }
  7084. else {
  7085. row._details.detach();
  7086. }
  7087. __details_events( ctx[0] );
  7088. }
  7089. }
  7090. };
  7091. var __details_events = function ( settings )
  7092. {
  7093. var api = new _Api( settings );
  7094. var namespace = '.dt.DT_details';
  7095. var drawEvent = 'draw'+namespace;
  7096. var colvisEvent = 'column-visibility'+namespace;
  7097. var destroyEvent = 'destroy'+namespace;
  7098. var data = settings.aoData;
  7099. api.off( drawEvent +' '+ colvisEvent +' '+ destroyEvent );
  7100. if ( _pluck( data, '_details' ).length > 0 ) {
  7101. // On each draw, insert the required elements into the document
  7102. api.on( drawEvent, function ( e, ctx ) {
  7103. if ( settings !== ctx ) {
  7104. return;
  7105. }
  7106. api.rows( {page:'current'} ).eq(0).each( function (idx) {
  7107. // Internal data grab
  7108. var row = data[ idx ];
  7109. if ( row._detailsShow ) {
  7110. row._details.insertAfter( row.nTr );
  7111. }
  7112. } );
  7113. } );
  7114. // Column visibility change - update the colspan
  7115. api.on( colvisEvent, function ( e, ctx, idx, vis ) {
  7116. if ( settings !== ctx ) {
  7117. return;
  7118. }
  7119. // Update the colspan for the details rows (note, only if it already has
  7120. // a colspan)
  7121. var row, visible = _fnVisbleColumns( ctx );
  7122. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  7123. row = data[i];
  7124. if ( row._details ) {
  7125. row._details.children('td[colspan]').attr('colspan', visible );
  7126. }
  7127. }
  7128. } );
  7129. // Table destroyed - nuke any child rows
  7130. api.on( destroyEvent, function ( e, ctx ) {
  7131. if ( settings !== ctx ) {
  7132. return;
  7133. }
  7134. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  7135. if ( data[i]._details ) {
  7136. __details_remove( api, i );
  7137. }
  7138. }
  7139. } );
  7140. }
  7141. };
  7142. // Strings for the method names to help minification
  7143. var _emp = '';
  7144. var _child_obj = _emp+'row().child';
  7145. var _child_mth = _child_obj+'()';
  7146. // data can be:
  7147. // tr
  7148. // string
  7149. // jQuery or array of any of the above
  7150. _api_register( _child_mth, function ( data, klass ) {
  7151. var ctx = this.context;
  7152. if ( data === undefined ) {
  7153. // get
  7154. return ctx.length && this.length ?
  7155. ctx[0].aoData[ this[0] ]._details :
  7156. undefined;
  7157. }
  7158. else if ( data === true ) {
  7159. // show
  7160. this.child.show();
  7161. }
  7162. else if ( data === false ) {
  7163. // remove
  7164. __details_remove( this );
  7165. }
  7166. else if ( ctx.length && this.length ) {
  7167. // set
  7168. __details_add( ctx[0], ctx[0].aoData[ this[0] ], data, klass );
  7169. }
  7170. return this;
  7171. } );
  7172. _api_register( [
  7173. _child_obj+'.show()',
  7174. _child_mth+'.show()' // only when `child()` was called with parameters (without
  7175. ], function ( show ) { // it returns an object and this method is not executed)
  7176. __details_display( this, true );
  7177. return this;
  7178. } );
  7179. _api_register( [
  7180. _child_obj+'.hide()',
  7181. _child_mth+'.hide()' // only when `child()` was called with parameters (without
  7182. ], function () { // it returns an object and this method is not executed)
  7183. __details_display( this, false );
  7184. return this;
  7185. } );
  7186. _api_register( [
  7187. _child_obj+'.remove()',
  7188. _child_mth+'.remove()' // only when `child()` was called with parameters (without
  7189. ], function () { // it returns an object and this method is not executed)
  7190. __details_remove( this );
  7191. return this;
  7192. } );
  7193. _api_register( _child_obj+'.isShown()', function () {
  7194. var ctx = this.context;
  7195. if ( ctx.length && this.length ) {
  7196. // _detailsShown as false or undefined will fall through to return false
  7197. return ctx[0].aoData[ this[0] ]._detailsShow || false;
  7198. }
  7199. return false;
  7200. } );
  7201. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  7202. * Columns
  7203. *
  7204. * {integer} - column index (>=0 count from left, <0 count from right)
  7205. * "{integer}:visIdx" - visible column index (i.e. translate to column index) (>=0 count from left, <0 count from right)
  7206. * "{integer}:visible" - alias for {integer}:visIdx (>=0 count from left, <0 count from right)
  7207. * "{string}:name" - column name
  7208. * "{string}" - jQuery selector on column header nodes
  7209. *
  7210. */
  7211. // can be an array of these items, comma separated list, or an array of comma
  7212. // separated lists
  7213. var __re_column_selector = /^([^:]+):(name|visIdx|visible)$/;
  7214. // r1 and r2 are redundant - but it means that the parameters match for the
  7215. // iterator callback in columns().data()
  7216. var __columnData = function ( settings, column, r1, r2, rows ) {
  7217. var a = [];
  7218. for ( var row=0, ien=rows.length ; row<ien ; row++ ) {
  7219. a.push( _fnGetCellData( settings, rows[row], column ) );
  7220. }
  7221. return a;
  7222. };
  7223. var __column_selector = function ( settings, selector, opts )
  7224. {
  7225. var
  7226. columns = settings.aoColumns,
  7227. names = _pluck( columns, 'sName' ),
  7228. nodes = _pluck( columns, 'nTh' );
  7229. var run = function ( s ) {
  7230. var selInt = _intVal( s );
  7231. // Selector - all
  7232. if ( s === '' ) {
  7233. return _range( columns.length );
  7234. }
  7235. // Selector - index
  7236. if ( selInt !== null ) {
  7237. return [ selInt >= 0 ?
  7238. selInt : // Count from left
  7239. columns.length + selInt // Count from right (+ because its a negative value)
  7240. ];
  7241. }
  7242. // Selector = function
  7243. if ( typeof s === 'function' ) {
  7244. var rows = _selector_row_indexes( settings, opts );
  7245. return $.map( columns, function (col, idx) {
  7246. return s(
  7247. idx,
  7248. __columnData( settings, idx, 0, 0, rows ),
  7249. nodes[ idx ]
  7250. ) ? idx : null;
  7251. } );
  7252. }
  7253. // jQuery or string selector
  7254. var match = typeof s === 'string' ?
  7255. s.match( __re_column_selector ) :
  7256. '';
  7257. if ( match ) {
  7258. switch( match[2] ) {
  7259. case 'visIdx':
  7260. case 'visible':
  7261. var idx = parseInt( match[1], 10 );
  7262. // Visible index given, convert to column index
  7263. if ( idx < 0 ) {
  7264. // Counting from the right
  7265. var visColumns = $.map( columns, function (col,i) {
  7266. return col.bVisible ? i : null;
  7267. } );
  7268. return [ visColumns[ visColumns.length + idx ] ];
  7269. }
  7270. // Counting from the left
  7271. return [ _fnVisibleToColumnIndex( settings, idx ) ];
  7272. case 'name':
  7273. // match by name. `names` is column index complete and in order
  7274. return $.map( names, function (name, i) {
  7275. return name === match[1] ? i : null;
  7276. } );
  7277. default:
  7278. return [];
  7279. }
  7280. }
  7281. // Cell in the table body
  7282. if ( s.nodeName && s._DT_CellIndex ) {
  7283. return [ s._DT_CellIndex.column ];
  7284. }
  7285. // jQuery selector on the TH elements for the columns
  7286. var jqResult = $( nodes )
  7287. .filter( s )
  7288. .map( function () {
  7289. return $.inArray( this, nodes ); // `nodes` is column index complete and in order
  7290. } )
  7291. .toArray();
  7292. if ( jqResult.length || ! s.nodeName ) {
  7293. return jqResult;
  7294. }
  7295. // Otherwise a node which might have a `dt-column` data attribute, or be
  7296. // a child or such an element
  7297. var host = $(s).closest('*[data-dt-column]');
  7298. return host.length ?
  7299. [ host.data('dt-column') ] :
  7300. [];
  7301. };
  7302. return _selector_run( 'column', selector, run, settings, opts );
  7303. };
  7304. var __setColumnVis = function ( settings, column, vis ) {
  7305. var
  7306. cols = settings.aoColumns,
  7307. col = cols[ column ],
  7308. data = settings.aoData,
  7309. row, cells, i, ien, tr;
  7310. // Get
  7311. if ( vis === undefined ) {
  7312. return col.bVisible;
  7313. }
  7314. // Set
  7315. // No change
  7316. if ( col.bVisible === vis ) {
  7317. return;
  7318. }
  7319. if ( vis ) {
  7320. // Insert column
  7321. // Need to decide if we should use appendChild or insertBefore
  7322. var insertBefore = $.inArray( true, _pluck(cols, 'bVisible'), column+1 );
  7323. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  7324. tr = data[i].nTr;
  7325. cells = data[i].anCells;
  7326. if ( tr ) {
  7327. // insertBefore can act like appendChild if 2nd arg is null
  7328. tr.insertBefore( cells[ column ], cells[ insertBefore ] || null );
  7329. }
  7330. }
  7331. }
  7332. else {
  7333. // Remove column
  7334. $( _pluck( settings.aoData, 'anCells', column ) ).detach();
  7335. }
  7336. // Common actions
  7337. col.bVisible = vis;
  7338. };
  7339. _api_register( 'columns()', function ( selector, opts ) {
  7340. // argument shifting
  7341. if ( selector === undefined ) {
  7342. selector = '';
  7343. }
  7344. else if ( $.isPlainObject( selector ) ) {
  7345. opts = selector;
  7346. selector = '';
  7347. }
  7348. opts = _selector_opts( opts );
  7349. var inst = this.iterator( 'table', function ( settings ) {
  7350. return __column_selector( settings, selector, opts );
  7351. }, 1 );
  7352. // Want argument shifting here and in _row_selector?
  7353. inst.selector.cols = selector;
  7354. inst.selector.opts = opts;
  7355. return inst;
  7356. } );
  7357. _api_registerPlural( 'columns().header()', 'column().header()', function ( selector, opts ) {
  7358. return this.iterator( 'column', function ( settings, column ) {
  7359. return settings.aoColumns[column].nTh;
  7360. }, 1 );
  7361. } );
  7362. _api_registerPlural( 'columns().footer()', 'column().footer()', function ( selector, opts ) {
  7363. return this.iterator( 'column', function ( settings, column ) {
  7364. return settings.aoColumns[column].nTf;
  7365. }, 1 );
  7366. } );
  7367. _api_registerPlural( 'columns().data()', 'column().data()', function () {
  7368. return this.iterator( 'column-rows', __columnData, 1 );
  7369. } );
  7370. _api_registerPlural( 'columns().dataSrc()', 'column().dataSrc()', function () {
  7371. return this.iterator( 'column', function ( settings, column ) {
  7372. return settings.aoColumns[column].mData;
  7373. }, 1 );
  7374. } );
  7375. _api_registerPlural( 'columns().cache()', 'column().cache()', function ( type ) {
  7376. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7377. return _pluck_order( settings.aoData, rows,
  7378. type === 'search' ? '_aFilterData' : '_aSortData', column
  7379. );
  7380. }, 1 );
  7381. } );
  7382. _api_registerPlural( 'columns().nodes()', 'column().nodes()', function () {
  7383. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7384. return _pluck_order( settings.aoData, rows, 'anCells', column ) ;
  7385. }, 1 );
  7386. } );
  7387. _api_registerPlural( 'columns().visible()', 'column().visible()', function ( vis, calc ) {
  7388. var that = this;
  7389. var ret = this.iterator( 'column', function ( settings, column ) {
  7390. if ( vis === undefined ) {
  7391. return settings.aoColumns[ column ].bVisible;
  7392. } // else
  7393. __setColumnVis( settings, column, vis );
  7394. } );
  7395. // Group the column visibility changes
  7396. if ( vis !== undefined ) {
  7397. this.iterator( 'table', function ( settings ) {
  7398. // Redraw the header after changes
  7399. _fnDrawHead( settings, settings.aoHeader );
  7400. _fnDrawHead( settings, settings.aoFooter );
  7401. // Update colspan for no records display. Child rows and extensions will use their own
  7402. // listeners to do this - only need to update the empty table item here
  7403. if ( ! settings.aiDisplay.length ) {
  7404. $(settings.nTBody).find('td[colspan]').attr('colspan', _fnVisbleColumns(settings));
  7405. }
  7406. _fnSaveState( settings );
  7407. // Second loop once the first is done for events
  7408. that.iterator( 'column', function ( settings, column ) {
  7409. _fnCallbackFire( settings, null, 'column-visibility', [settings, column, vis, calc] );
  7410. } );
  7411. if ( calc === undefined || calc ) {
  7412. that.columns.adjust();
  7413. }
  7414. });
  7415. }
  7416. return ret;
  7417. } );
  7418. _api_registerPlural( 'columns().indexes()', 'column().index()', function ( type ) {
  7419. return this.iterator( 'column', function ( settings, column ) {
  7420. return type === 'visible' ?
  7421. _fnColumnIndexToVisible( settings, column ) :
  7422. column;
  7423. }, 1 );
  7424. } );
  7425. _api_register( 'columns.adjust()', function () {
  7426. return this.iterator( 'table', function ( settings ) {
  7427. _fnAdjustColumnSizing( settings );
  7428. }, 1 );
  7429. } );
  7430. _api_register( 'column.index()', function ( type, idx ) {
  7431. if ( this.context.length !== 0 ) {
  7432. var ctx = this.context[0];
  7433. if ( type === 'fromVisible' || type === 'toData' ) {
  7434. return _fnVisibleToColumnIndex( ctx, idx );
  7435. }
  7436. else if ( type === 'fromData' || type === 'toVisible' ) {
  7437. return _fnColumnIndexToVisible( ctx, idx );
  7438. }
  7439. }
  7440. } );
  7441. _api_register( 'column()', function ( selector, opts ) {
  7442. return _selector_first( this.columns( selector, opts ) );
  7443. } );
  7444. var __cell_selector = function ( settings, selector, opts )
  7445. {
  7446. var data = settings.aoData;
  7447. var rows = _selector_row_indexes( settings, opts );
  7448. var cells = _removeEmpty( _pluck_order( data, rows, 'anCells' ) );
  7449. var allCells = $(_flatten( [], cells ));
  7450. var row;
  7451. var columns = settings.aoColumns.length;
  7452. var a, i, ien, j, o, host;
  7453. var run = function ( s ) {
  7454. var fnSelector = typeof s === 'function';
  7455. if ( s === null || s === undefined || fnSelector ) {
  7456. // All cells and function selectors
  7457. a = [];
  7458. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  7459. row = rows[i];
  7460. for ( j=0 ; j<columns ; j++ ) {
  7461. o = {
  7462. row: row,
  7463. column: j
  7464. };
  7465. if ( fnSelector ) {
  7466. // Selector - function
  7467. host = data[ row ];
  7468. if ( s( o, _fnGetCellData(settings, row, j), host.anCells ? host.anCells[j] : null ) ) {
  7469. a.push( o );
  7470. }
  7471. }
  7472. else {
  7473. // Selector - all
  7474. a.push( o );
  7475. }
  7476. }
  7477. }
  7478. return a;
  7479. }
  7480. // Selector - index
  7481. if ( $.isPlainObject( s ) ) {
  7482. // Valid cell index and its in the array of selectable rows
  7483. return s.column !== undefined && s.row !== undefined && $.inArray( s.row, rows ) !== -1 ?
  7484. [s] :
  7485. [];
  7486. }
  7487. // Selector - jQuery filtered cells
  7488. var jqResult = allCells
  7489. .filter( s )
  7490. .map( function (i, el) {
  7491. return { // use a new object, in case someone changes the values
  7492. row: el._DT_CellIndex.row,
  7493. column: el._DT_CellIndex.column
  7494. };
  7495. } )
  7496. .toArray();
  7497. if ( jqResult.length || ! s.nodeName ) {
  7498. return jqResult;
  7499. }
  7500. // Otherwise the selector is a node, and there is one last option - the
  7501. // element might be a child of an element which has dt-row and dt-column
  7502. // data attributes
  7503. host = $(s).closest('*[data-dt-row]');
  7504. return host.length ?
  7505. [ {
  7506. row: host.data('dt-row'),
  7507. column: host.data('dt-column')
  7508. } ] :
  7509. [];
  7510. };
  7511. return _selector_run( 'cell', selector, run, settings, opts );
  7512. };
  7513. _api_register( 'cells()', function ( rowSelector, columnSelector, opts ) {
  7514. // Argument shifting
  7515. if ( $.isPlainObject( rowSelector ) ) {
  7516. // Indexes
  7517. if ( rowSelector.row === undefined ) {
  7518. // Selector options in first parameter
  7519. opts = rowSelector;
  7520. rowSelector = null;
  7521. }
  7522. else {
  7523. // Cell index objects in first parameter
  7524. opts = columnSelector;
  7525. columnSelector = null;
  7526. }
  7527. }
  7528. if ( $.isPlainObject( columnSelector ) ) {
  7529. opts = columnSelector;
  7530. columnSelector = null;
  7531. }
  7532. // Cell selector
  7533. if ( columnSelector === null || columnSelector === undefined ) {
  7534. return this.iterator( 'table', function ( settings ) {
  7535. return __cell_selector( settings, rowSelector, _selector_opts( opts ) );
  7536. } );
  7537. }
  7538. // The default built in options need to apply to row and columns
  7539. var internalOpts = opts ? {
  7540. page: opts.page,
  7541. order: opts.order,
  7542. search: opts.search
  7543. } : {};
  7544. // Row + column selector
  7545. var columns = this.columns( columnSelector, internalOpts );
  7546. var rows = this.rows( rowSelector, internalOpts );
  7547. var i, ien, j, jen;
  7548. var cellsNoOpts = this.iterator( 'table', function ( settings, idx ) {
  7549. var a = [];
  7550. for ( i=0, ien=rows[idx].length ; i<ien ; i++ ) {
  7551. for ( j=0, jen=columns[idx].length ; j<jen ; j++ ) {
  7552. a.push( {
  7553. row: rows[idx][i],
  7554. column: columns[idx][j]
  7555. } );
  7556. }
  7557. }
  7558. return a;
  7559. }, 1 );
  7560. // There is currently only one extension which uses a cell selector extension
  7561. // It is a _major_ performance drag to run this if it isn't needed, so this is
  7562. // an extension specific check at the moment
  7563. var cells = opts && opts.selected ?
  7564. this.cells( cellsNoOpts, opts ) :
  7565. cellsNoOpts;
  7566. $.extend( cells.selector, {
  7567. cols: columnSelector,
  7568. rows: rowSelector,
  7569. opts: opts
  7570. } );
  7571. return cells;
  7572. } );
  7573. _api_registerPlural( 'cells().nodes()', 'cell().node()', function () {
  7574. return this.iterator( 'cell', function ( settings, row, column ) {
  7575. var data = settings.aoData[ row ];
  7576. return data && data.anCells ?
  7577. data.anCells[ column ] :
  7578. undefined;
  7579. }, 1 );
  7580. } );
  7581. _api_register( 'cells().data()', function () {
  7582. return this.iterator( 'cell', function ( settings, row, column ) {
  7583. return _fnGetCellData( settings, row, column );
  7584. }, 1 );
  7585. } );
  7586. _api_registerPlural( 'cells().cache()', 'cell().cache()', function ( type ) {
  7587. type = type === 'search' ? '_aFilterData' : '_aSortData';
  7588. return this.iterator( 'cell', function ( settings, row, column ) {
  7589. return settings.aoData[ row ][ type ][ column ];
  7590. }, 1 );
  7591. } );
  7592. _api_registerPlural( 'cells().render()', 'cell().render()', function ( type ) {
  7593. return this.iterator( 'cell', function ( settings, row, column ) {
  7594. return _fnGetCellData( settings, row, column, type );
  7595. }, 1 );
  7596. } );
  7597. _api_registerPlural( 'cells().indexes()', 'cell().index()', function () {
  7598. return this.iterator( 'cell', function ( settings, row, column ) {
  7599. return {
  7600. row: row,
  7601. column: column,
  7602. columnVisible: _fnColumnIndexToVisible( settings, column )
  7603. };
  7604. }, 1 );
  7605. } );
  7606. _api_registerPlural( 'cells().invalidate()', 'cell().invalidate()', function ( src ) {
  7607. return this.iterator( 'cell', function ( settings, row, column ) {
  7608. _fnInvalidate( settings, row, src, column );
  7609. } );
  7610. } );
  7611. _api_register( 'cell()', function ( rowSelector, columnSelector, opts ) {
  7612. return _selector_first( this.cells( rowSelector, columnSelector, opts ) );
  7613. } );
  7614. _api_register( 'cell().data()', function ( data ) {
  7615. var ctx = this.context;
  7616. var cell = this[0];
  7617. if ( data === undefined ) {
  7618. // Get
  7619. return ctx.length && cell.length ?
  7620. _fnGetCellData( ctx[0], cell[0].row, cell[0].column ) :
  7621. undefined;
  7622. }
  7623. // Set
  7624. _fnSetCellData( ctx[0], cell[0].row, cell[0].column, data );
  7625. _fnInvalidate( ctx[0], cell[0].row, 'data', cell[0].column );
  7626. return this;
  7627. } );
  7628. /**
  7629. * Get current ordering (sorting) that has been applied to the table.
  7630. *
  7631. * @returns {array} 2D array containing the sorting information for the first
  7632. * table in the current context. Each element in the parent array represents
  7633. * a column being sorted upon (i.e. multi-sorting with two columns would have
  7634. * 2 inner arrays). The inner arrays may have 2 or 3 elements. The first is
  7635. * the column index that the sorting condition applies to, the second is the
  7636. * direction of the sort (`desc` or `asc`) and, optionally, the third is the
  7637. * index of the sorting order from the `column.sorting` initialisation array.
  7638. *//**
  7639. * Set the ordering for the table.
  7640. *
  7641. * @param {integer} order Column index to sort upon.
  7642. * @param {string} direction Direction of the sort to be applied (`asc` or `desc`)
  7643. * @returns {DataTables.Api} this
  7644. *//**
  7645. * Set the ordering for the table.
  7646. *
  7647. * @param {array} order 1D array of sorting information to be applied.
  7648. * @param {array} [...] Optional additional sorting conditions
  7649. * @returns {DataTables.Api} this
  7650. *//**
  7651. * Set the ordering for the table.
  7652. *
  7653. * @param {array} order 2D array of sorting information to be applied.
  7654. * @returns {DataTables.Api} this
  7655. */
  7656. _api_register( 'order()', function ( order, dir ) {
  7657. var ctx = this.context;
  7658. if ( order === undefined ) {
  7659. // get
  7660. return ctx.length !== 0 ?
  7661. ctx[0].aaSorting :
  7662. undefined;
  7663. }
  7664. // set
  7665. if ( typeof order === 'number' ) {
  7666. // Simple column / direction passed in
  7667. order = [ [ order, dir ] ];
  7668. }
  7669. else if ( order.length && ! Array.isArray( order[0] ) ) {
  7670. // Arguments passed in (list of 1D arrays)
  7671. order = Array.prototype.slice.call( arguments );
  7672. }
  7673. // otherwise a 2D array was passed in
  7674. return this.iterator( 'table', function ( settings ) {
  7675. settings.aaSorting = order.slice();
  7676. } );
  7677. } );
  7678. /**
  7679. * Attach a sort listener to an element for a given column
  7680. *
  7681. * @param {node|jQuery|string} node Identifier for the element(s) to attach the
  7682. * listener to. This can take the form of a single DOM node, a jQuery
  7683. * collection of nodes or a jQuery selector which will identify the node(s).
  7684. * @param {integer} column the column that a click on this node will sort on
  7685. * @param {function} [callback] callback function when sort is run
  7686. * @returns {DataTables.Api} this
  7687. */
  7688. _api_register( 'order.listener()', function ( node, column, callback ) {
  7689. return this.iterator( 'table', function ( settings ) {
  7690. _fnSortAttachListener( settings, node, column, callback );
  7691. } );
  7692. } );
  7693. _api_register( 'order.fixed()', function ( set ) {
  7694. if ( ! set ) {
  7695. var ctx = this.context;
  7696. var fixed = ctx.length ?
  7697. ctx[0].aaSortingFixed :
  7698. undefined;
  7699. return Array.isArray( fixed ) ?
  7700. { pre: fixed } :
  7701. fixed;
  7702. }
  7703. return this.iterator( 'table', function ( settings ) {
  7704. settings.aaSortingFixed = $.extend( true, {}, set );
  7705. } );
  7706. } );
  7707. // Order by the selected column(s)
  7708. _api_register( [
  7709. 'columns().order()',
  7710. 'column().order()'
  7711. ], function ( dir ) {
  7712. var that = this;
  7713. return this.iterator( 'table', function ( settings, i ) {
  7714. var sort = [];
  7715. $.each( that[i], function (j, col) {
  7716. sort.push( [ col, dir ] );
  7717. } );
  7718. settings.aaSorting = sort;
  7719. } );
  7720. } );
  7721. _api_register( 'search()', function ( input, regex, smart, caseInsen ) {
  7722. var ctx = this.context;
  7723. if ( input === undefined ) {
  7724. // get
  7725. return ctx.length !== 0 ?
  7726. ctx[0].oPreviousSearch.sSearch :
  7727. undefined;
  7728. }
  7729. // set
  7730. return this.iterator( 'table', function ( settings ) {
  7731. if ( ! settings.oFeatures.bFilter ) {
  7732. return;
  7733. }
  7734. _fnFilterComplete( settings, $.extend( {}, settings.oPreviousSearch, {
  7735. "sSearch": input+"",
  7736. "bRegex": regex === null ? false : regex,
  7737. "bSmart": smart === null ? true : smart,
  7738. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7739. } ), 1 );
  7740. } );
  7741. } );
  7742. _api_registerPlural(
  7743. 'columns().search()',
  7744. 'column().search()',
  7745. function ( input, regex, smart, caseInsen ) {
  7746. return this.iterator( 'column', function ( settings, column ) {
  7747. var preSearch = settings.aoPreSearchCols;
  7748. if ( input === undefined ) {
  7749. // get
  7750. return preSearch[ column ].sSearch;
  7751. }
  7752. // set
  7753. if ( ! settings.oFeatures.bFilter ) {
  7754. return;
  7755. }
  7756. $.extend( preSearch[ column ], {
  7757. "sSearch": input+"",
  7758. "bRegex": regex === null ? false : regex,
  7759. "bSmart": smart === null ? true : smart,
  7760. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7761. } );
  7762. _fnFilterComplete( settings, settings.oPreviousSearch, 1 );
  7763. } );
  7764. }
  7765. );
  7766. /*
  7767. * State API methods
  7768. */
  7769. _api_register( 'state()', function () {
  7770. return this.context.length ?
  7771. this.context[0].oSavedState :
  7772. null;
  7773. } );
  7774. _api_register( 'state.clear()', function () {
  7775. return this.iterator( 'table', function ( settings ) {
  7776. // Save an empty object
  7777. settings.fnStateSaveCallback.call( settings.oInstance, settings, {} );
  7778. } );
  7779. } );
  7780. _api_register( 'state.loaded()', function () {
  7781. return this.context.length ?
  7782. this.context[0].oLoadedState :
  7783. null;
  7784. } );
  7785. _api_register( 'state.save()', function () {
  7786. return this.iterator( 'table', function ( settings ) {
  7787. _fnSaveState( settings );
  7788. } );
  7789. } );
  7790. /**
  7791. * Provide a common method for plug-ins to check the version of DataTables being
  7792. * used, in order to ensure compatibility.
  7793. *
  7794. * @param {string} version Version string to check for, in the format "X.Y.Z".
  7795. * Note that the formats "X" and "X.Y" are also acceptable.
  7796. * @returns {boolean} true if this version of DataTables is greater or equal to
  7797. * the required version, or false if this version of DataTales is not
  7798. * suitable
  7799. * @static
  7800. * @dtopt API-Static
  7801. *
  7802. * @example
  7803. * alert( $.fn.dataTable.versionCheck( '1.9.0' ) );
  7804. */
  7805. DataTable.versionCheck = DataTable.fnVersionCheck = function( version )
  7806. {
  7807. var aThis = DataTable.version.split('.');
  7808. var aThat = version.split('.');
  7809. var iThis, iThat;
  7810. for ( var i=0, iLen=aThat.length ; i<iLen ; i++ ) {
  7811. iThis = parseInt( aThis[i], 10 ) || 0;
  7812. iThat = parseInt( aThat[i], 10 ) || 0;
  7813. // Parts are the same, keep comparing
  7814. if (iThis === iThat) {
  7815. continue;
  7816. }
  7817. // Parts are different, return immediately
  7818. return iThis > iThat;
  7819. }
  7820. return true;
  7821. };
  7822. /**
  7823. * Check if a `<table>` node is a DataTable table already or not.
  7824. *
  7825. * @param {node|jquery|string} table Table node, jQuery object or jQuery
  7826. * selector for the table to test. Note that if more than more than one
  7827. * table is passed on, only the first will be checked
  7828. * @returns {boolean} true the table given is a DataTable, or false otherwise
  7829. * @static
  7830. * @dtopt API-Static
  7831. *
  7832. * @example
  7833. * if ( ! $.fn.DataTable.isDataTable( '#example' ) ) {
  7834. * $('#example').dataTable();
  7835. * }
  7836. */
  7837. DataTable.isDataTable = DataTable.fnIsDataTable = function ( table )
  7838. {
  7839. var t = $(table).get(0);
  7840. var is = false;
  7841. if ( table instanceof DataTable.Api ) {
  7842. return true;
  7843. }
  7844. $.each( DataTable.settings, function (i, o) {
  7845. var head = o.nScrollHead ? $('table', o.nScrollHead)[0] : null;
  7846. var foot = o.nScrollFoot ? $('table', o.nScrollFoot)[0] : null;
  7847. if ( o.nTable === t || head === t || foot === t ) {
  7848. is = true;
  7849. }
  7850. } );
  7851. return is;
  7852. };
  7853. /**
  7854. * Get all DataTable tables that have been initialised - optionally you can
  7855. * select to get only currently visible tables.
  7856. *
  7857. * @param {boolean} [visible=false] Flag to indicate if you want all (default)
  7858. * or visible tables only.
  7859. * @returns {array} Array of `table` nodes (not DataTable instances) which are
  7860. * DataTables
  7861. * @static
  7862. * @dtopt API-Static
  7863. *
  7864. * @example
  7865. * $.each( $.fn.dataTable.tables(true), function () {
  7866. * $(table).DataTable().columns.adjust();
  7867. * } );
  7868. */
  7869. DataTable.tables = DataTable.fnTables = function ( visible )
  7870. {
  7871. var api = false;
  7872. if ( $.isPlainObject( visible ) ) {
  7873. api = visible.api;
  7874. visible = visible.visible;
  7875. }
  7876. var a = $.map( DataTable.settings, function (o) {
  7877. if ( !visible || (visible && $(o.nTable).is(':visible')) ) {
  7878. return o.nTable;
  7879. }
  7880. } );
  7881. return api ?
  7882. new _Api( a ) :
  7883. a;
  7884. };
  7885. /**
  7886. * Convert from camel case parameters to Hungarian notation. This is made public
  7887. * for the extensions to provide the same ability as DataTables core to accept
  7888. * either the 1.9 style Hungarian notation, or the 1.10+ style camelCase
  7889. * parameters.
  7890. *
  7891. * @param {object} src The model object which holds all parameters that can be
  7892. * mapped.
  7893. * @param {object} user The object to convert from camel case to Hungarian.
  7894. * @param {boolean} force When set to `true`, properties which already have a
  7895. * Hungarian value in the `user` object will be overwritten. Otherwise they
  7896. * won't be.
  7897. */
  7898. DataTable.camelToHungarian = _fnCamelToHungarian;
  7899. /**
  7900. *
  7901. */
  7902. _api_register( '$()', function ( selector, opts ) {
  7903. var
  7904. rows = this.rows( opts ).nodes(), // Get all rows
  7905. jqRows = $(rows);
  7906. return $( [].concat(
  7907. jqRows.filter( selector ).toArray(),
  7908. jqRows.find( selector ).toArray()
  7909. ) );
  7910. } );
  7911. // jQuery functions to operate on the tables
  7912. $.each( [ 'on', 'one', 'off' ], function (i, key) {
  7913. _api_register( key+'()', function ( /* event, handler */ ) {
  7914. var args = Array.prototype.slice.call(arguments);
  7915. // Add the `dt` namespace automatically if it isn't already present
  7916. args[0] = $.map( args[0].split( /\s/ ), function ( e ) {
  7917. return ! e.match(/\.dt\b/) ?
  7918. e+'.dt' :
  7919. e;
  7920. } ).join( ' ' );
  7921. var inst = $( this.tables().nodes() );
  7922. inst[key].apply( inst, args );
  7923. return this;
  7924. } );
  7925. } );
  7926. _api_register( 'clear()', function () {
  7927. return this.iterator( 'table', function ( settings ) {
  7928. _fnClearTable( settings );
  7929. } );
  7930. } );
  7931. _api_register( 'settings()', function () {
  7932. return new _Api( this.context, this.context );
  7933. } );
  7934. _api_register( 'init()', function () {
  7935. var ctx = this.context;
  7936. return ctx.length ? ctx[0].oInit : null;
  7937. } );
  7938. _api_register( 'data()', function () {
  7939. return this.iterator( 'table', function ( settings ) {
  7940. return _pluck( settings.aoData, '_aData' );
  7941. } ).flatten();
  7942. } );
  7943. _api_register( 'destroy()', function ( remove ) {
  7944. remove = remove || false;
  7945. return this.iterator( 'table', function ( settings ) {
  7946. var orig = settings.nTableWrapper.parentNode;
  7947. var classes = settings.oClasses;
  7948. var table = settings.nTable;
  7949. var tbody = settings.nTBody;
  7950. var thead = settings.nTHead;
  7951. var tfoot = settings.nTFoot;
  7952. var jqTable = $(table);
  7953. var jqTbody = $(tbody);
  7954. var jqWrapper = $(settings.nTableWrapper);
  7955. var rows = $.map( settings.aoData, function (r) { return r.nTr; } );
  7956. var i, ien;
  7957. // Flag to note that the table is currently being destroyed - no action
  7958. // should be taken
  7959. settings.bDestroying = true;
  7960. // Fire off the destroy callbacks for plug-ins etc
  7961. _fnCallbackFire( settings, "aoDestroyCallback", "destroy", [settings] );
  7962. // If not being removed from the document, make all columns visible
  7963. if ( ! remove ) {
  7964. new _Api( settings ).columns().visible( true );
  7965. }
  7966. // Blitz all `DT` namespaced events (these are internal events, the
  7967. // lowercase, `dt` events are user subscribed and they are responsible
  7968. // for removing them
  7969. jqWrapper.off('.DT').find(':not(tbody *)').off('.DT');
  7970. $(window).off('.DT-'+settings.sInstance);
  7971. // When scrolling we had to break the table up - restore it
  7972. if ( table != thead.parentNode ) {
  7973. jqTable.children('thead').detach();
  7974. jqTable.append( thead );
  7975. }
  7976. if ( tfoot && table != tfoot.parentNode ) {
  7977. jqTable.children('tfoot').detach();
  7978. jqTable.append( tfoot );
  7979. }
  7980. settings.aaSorting = [];
  7981. settings.aaSortingFixed = [];
  7982. _fnSortingClasses( settings );
  7983. $( rows ).removeClass( settings.asStripeClasses.join(' ') );
  7984. $('th, td', thead).removeClass( classes.sSortable+' '+
  7985. classes.sSortableAsc+' '+classes.sSortableDesc+' '+classes.sSortableNone
  7986. );
  7987. // Add the TR elements back into the table in their original order
  7988. jqTbody.children().detach();
  7989. jqTbody.append( rows );
  7990. // Remove the DataTables generated nodes, events and classes
  7991. var removedMethod = remove ? 'remove' : 'detach';
  7992. jqTable[ removedMethod ]();
  7993. jqWrapper[ removedMethod ]();
  7994. // If we need to reattach the table to the document
  7995. if ( ! remove && orig ) {
  7996. // insertBefore acts like appendChild if !arg[1]
  7997. orig.insertBefore( table, settings.nTableReinsertBefore );
  7998. // Restore the width of the original table - was read from the style property,
  7999. // so we can restore directly to that
  8000. jqTable
  8001. .css( 'width', settings.sDestroyWidth )
  8002. .removeClass( classes.sTable );
  8003. // If the were originally stripe classes - then we add them back here.
  8004. // Note this is not fool proof (for example if not all rows had stripe
  8005. // classes - but it's a good effort without getting carried away
  8006. ien = settings.asDestroyStripes.length;
  8007. if ( ien ) {
  8008. jqTbody.children().each( function (i) {
  8009. $(this).addClass( settings.asDestroyStripes[i % ien] );
  8010. } );
  8011. }
  8012. }
  8013. /* Remove the settings object from the settings array */
  8014. var idx = $.inArray( settings, DataTable.settings );
  8015. if ( idx !== -1 ) {
  8016. DataTable.settings.splice( idx, 1 );
  8017. }
  8018. } );
  8019. } );
  8020. // Add the `every()` method for rows, columns and cells in a compact form
  8021. $.each( [ 'column', 'row', 'cell' ], function ( i, type ) {
  8022. _api_register( type+'s().every()', function ( fn ) {
  8023. var opts = this.selector.opts;
  8024. var api = this;
  8025. return this.iterator( type, function ( settings, arg1, arg2, arg3, arg4 ) {
  8026. // Rows and columns:
  8027. // arg1 - index
  8028. // arg2 - table counter
  8029. // arg3 - loop counter
  8030. // arg4 - undefined
  8031. // Cells:
  8032. // arg1 - row index
  8033. // arg2 - column index
  8034. // arg3 - table counter
  8035. // arg4 - loop counter
  8036. fn.call(
  8037. api[ type ](
  8038. arg1,
  8039. type==='cell' ? arg2 : opts,
  8040. type==='cell' ? opts : undefined
  8041. ),
  8042. arg1, arg2, arg3, arg4
  8043. );
  8044. } );
  8045. } );
  8046. } );
  8047. // i18n method for extensions to be able to use the language object from the
  8048. // DataTable
  8049. _api_register( 'i18n()', function ( token, def, plural ) {
  8050. var ctx = this.context[0];
  8051. var resolved = _fnGetObjectDataFn( token )( ctx.oLanguage );
  8052. if ( resolved === undefined ) {
  8053. resolved = def;
  8054. }
  8055. if ( plural !== undefined && $.isPlainObject( resolved ) ) {
  8056. resolved = resolved[ plural ] !== undefined ?
  8057. resolved[ plural ] :
  8058. resolved._;
  8059. }
  8060. return resolved.replace( '%d', plural ); // nb: plural might be undefined,
  8061. } );
  8062. /**
  8063. * Version string for plug-ins to check compatibility. Allowed format is
  8064. * `a.b.c-d` where: a:int, b:int, c:int, d:string(dev|beta|alpha). `d` is used
  8065. * only for non-release builds. See http://semver.org/ for more information.
  8066. * @member
  8067. * @type string
  8068. * @default Version number
  8069. */
  8070. DataTable.version = "1.10.23";
  8071. /**
  8072. * Private data store, containing all of the settings objects that are
  8073. * created for the tables on a given page.
  8074. *
  8075. * Note that the `DataTable.settings` object is aliased to
  8076. * `jQuery.fn.dataTableExt` through which it may be accessed and
  8077. * manipulated, or `jQuery.fn.dataTable.settings`.
  8078. * @member
  8079. * @type array
  8080. * @default []
  8081. * @private
  8082. */
  8083. DataTable.settings = [];
  8084. /**
  8085. * Object models container, for the various models that DataTables has
  8086. * available to it. These models define the objects that are used to hold
  8087. * the active state and configuration of the table.
  8088. * @namespace
  8089. */
  8090. DataTable.models = {};
  8091. /**
  8092. * Template object for the way in which DataTables holds information about
  8093. * search information for the global filter and individual column filters.
  8094. * @namespace
  8095. */
  8096. DataTable.models.oSearch = {
  8097. /**
  8098. * Flag to indicate if the filtering should be case insensitive or not
  8099. * @type boolean
  8100. * @default true
  8101. */
  8102. "bCaseInsensitive": true,
  8103. /**
  8104. * Applied search term
  8105. * @type string
  8106. * @default <i>Empty string</i>
  8107. */
  8108. "sSearch": "",
  8109. /**
  8110. * Flag to indicate if the search term should be interpreted as a
  8111. * regular expression (true) or not (false) and therefore and special
  8112. * regex characters escaped.
  8113. * @type boolean
  8114. * @default false
  8115. */
  8116. "bRegex": false,
  8117. /**
  8118. * Flag to indicate if DataTables is to use its smart filtering or not.
  8119. * @type boolean
  8120. * @default true
  8121. */
  8122. "bSmart": true
  8123. };
  8124. /**
  8125. * Template object for the way in which DataTables holds information about
  8126. * each individual row. This is the object format used for the settings
  8127. * aoData array.
  8128. * @namespace
  8129. */
  8130. DataTable.models.oRow = {
  8131. /**
  8132. * TR element for the row
  8133. * @type node
  8134. * @default null
  8135. */
  8136. "nTr": null,
  8137. /**
  8138. * Array of TD elements for each row. This is null until the row has been
  8139. * created.
  8140. * @type array nodes
  8141. * @default []
  8142. */
  8143. "anCells": null,
  8144. /**
  8145. * Data object from the original data source for the row. This is either
  8146. * an array if using the traditional form of DataTables, or an object if
  8147. * using mData options. The exact type will depend on the passed in
  8148. * data from the data source, or will be an array if using DOM a data
  8149. * source.
  8150. * @type array|object
  8151. * @default []
  8152. */
  8153. "_aData": [],
  8154. /**
  8155. * Sorting data cache - this array is ostensibly the same length as the
  8156. * number of columns (although each index is generated only as it is
  8157. * needed), and holds the data that is used for sorting each column in the
  8158. * row. We do this cache generation at the start of the sort in order that
  8159. * the formatting of the sort data need be done only once for each cell
  8160. * per sort. This array should not be read from or written to by anything
  8161. * other than the master sorting methods.
  8162. * @type array
  8163. * @default null
  8164. * @private
  8165. */
  8166. "_aSortData": null,
  8167. /**
  8168. * Per cell filtering data cache. As per the sort data cache, used to
  8169. * increase the performance of the filtering in DataTables
  8170. * @type array
  8171. * @default null
  8172. * @private
  8173. */
  8174. "_aFilterData": null,
  8175. /**
  8176. * Filtering data cache. This is the same as the cell filtering cache, but
  8177. * in this case a string rather than an array. This is easily computed with
  8178. * a join on `_aFilterData`, but is provided as a cache so the join isn't
  8179. * needed on every search (memory traded for performance)
  8180. * @type array
  8181. * @default null
  8182. * @private
  8183. */
  8184. "_sFilterRow": null,
  8185. /**
  8186. * Cache of the class name that DataTables has applied to the row, so we
  8187. * can quickly look at this variable rather than needing to do a DOM check
  8188. * on className for the nTr property.
  8189. * @type string
  8190. * @default <i>Empty string</i>
  8191. * @private
  8192. */
  8193. "_sRowStripe": "",
  8194. /**
  8195. * Denote if the original data source was from the DOM, or the data source
  8196. * object. This is used for invalidating data, so DataTables can
  8197. * automatically read data from the original source, unless uninstructed
  8198. * otherwise.
  8199. * @type string
  8200. * @default null
  8201. * @private
  8202. */
  8203. "src": null,
  8204. /**
  8205. * Index in the aoData array. This saves an indexOf lookup when we have the
  8206. * object, but want to know the index
  8207. * @type integer
  8208. * @default -1
  8209. * @private
  8210. */
  8211. "idx": -1
  8212. };
  8213. /**
  8214. * Template object for the column information object in DataTables. This object
  8215. * is held in the settings aoColumns array and contains all the information that
  8216. * DataTables needs about each individual column.
  8217. *
  8218. * Note that this object is related to {@link DataTable.defaults.column}
  8219. * but this one is the internal data store for DataTables's cache of columns.
  8220. * It should NOT be manipulated outside of DataTables. Any configuration should
  8221. * be done through the initialisation options.
  8222. * @namespace
  8223. */
  8224. DataTable.models.oColumn = {
  8225. /**
  8226. * Column index. This could be worked out on-the-fly with $.inArray, but it
  8227. * is faster to just hold it as a variable
  8228. * @type integer
  8229. * @default null
  8230. */
  8231. "idx": null,
  8232. /**
  8233. * A list of the columns that sorting should occur on when this column
  8234. * is sorted. That this property is an array allows multi-column sorting
  8235. * to be defined for a column (for example first name / last name columns
  8236. * would benefit from this). The values are integers pointing to the
  8237. * columns to be sorted on (typically it will be a single integer pointing
  8238. * at itself, but that doesn't need to be the case).
  8239. * @type array
  8240. */
  8241. "aDataSort": null,
  8242. /**
  8243. * Define the sorting directions that are applied to the column, in sequence
  8244. * as the column is repeatedly sorted upon - i.e. the first value is used
  8245. * as the sorting direction when the column if first sorted (clicked on).
  8246. * Sort it again (click again) and it will move on to the next index.
  8247. * Repeat until loop.
  8248. * @type array
  8249. */
  8250. "asSorting": null,
  8251. /**
  8252. * Flag to indicate if the column is searchable, and thus should be included
  8253. * in the filtering or not.
  8254. * @type boolean
  8255. */
  8256. "bSearchable": null,
  8257. /**
  8258. * Flag to indicate if the column is sortable or not.
  8259. * @type boolean
  8260. */
  8261. "bSortable": null,
  8262. /**
  8263. * Flag to indicate if the column is currently visible in the table or not
  8264. * @type boolean
  8265. */
  8266. "bVisible": null,
  8267. /**
  8268. * Store for manual type assignment using the `column.type` option. This
  8269. * is held in store so we can manipulate the column's `sType` property.
  8270. * @type string
  8271. * @default null
  8272. * @private
  8273. */
  8274. "_sManualType": null,
  8275. /**
  8276. * Flag to indicate if HTML5 data attributes should be used as the data
  8277. * source for filtering or sorting. True is either are.
  8278. * @type boolean
  8279. * @default false
  8280. * @private
  8281. */
  8282. "_bAttrSrc": false,
  8283. /**
  8284. * Developer definable function that is called whenever a cell is created (Ajax source,
  8285. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  8286. * allowing you to modify the DOM element (add background colour for example) when the
  8287. * element is available.
  8288. * @type function
  8289. * @param {element} nTd The TD node that has been created
  8290. * @param {*} sData The Data for the cell
  8291. * @param {array|object} oData The data for the whole row
  8292. * @param {int} iRow The row index for the aoData data store
  8293. * @default null
  8294. */
  8295. "fnCreatedCell": null,
  8296. /**
  8297. * Function to get data from a cell in a column. You should <b>never</b>
  8298. * access data directly through _aData internally in DataTables - always use
  8299. * the method attached to this property. It allows mData to function as
  8300. * required. This function is automatically assigned by the column
  8301. * initialisation method
  8302. * @type function
  8303. * @param {array|object} oData The data array/object for the array
  8304. * (i.e. aoData[]._aData)
  8305. * @param {string} sSpecific The specific data type you want to get -
  8306. * 'display', 'type' 'filter' 'sort'
  8307. * @returns {*} The data for the cell from the given row's data
  8308. * @default null
  8309. */
  8310. "fnGetData": null,
  8311. /**
  8312. * Function to set data for a cell in the column. You should <b>never</b>
  8313. * set the data directly to _aData internally in DataTables - always use
  8314. * this method. It allows mData to function as required. This function
  8315. * is automatically assigned by the column initialisation method
  8316. * @type function
  8317. * @param {array|object} oData The data array/object for the array
  8318. * (i.e. aoData[]._aData)
  8319. * @param {*} sValue Value to set
  8320. * @default null
  8321. */
  8322. "fnSetData": null,
  8323. /**
  8324. * Property to read the value for the cells in the column from the data
  8325. * source array / object. If null, then the default content is used, if a
  8326. * function is given then the return from the function is used.
  8327. * @type function|int|string|null
  8328. * @default null
  8329. */
  8330. "mData": null,
  8331. /**
  8332. * Partner property to mData which is used (only when defined) to get
  8333. * the data - i.e. it is basically the same as mData, but without the
  8334. * 'set' option, and also the data fed to it is the result from mData.
  8335. * This is the rendering method to match the data method of mData.
  8336. * @type function|int|string|null
  8337. * @default null
  8338. */
  8339. "mRender": null,
  8340. /**
  8341. * Unique header TH/TD element for this column - this is what the sorting
  8342. * listener is attached to (if sorting is enabled.)
  8343. * @type node
  8344. * @default null
  8345. */
  8346. "nTh": null,
  8347. /**
  8348. * Unique footer TH/TD element for this column (if there is one). Not used
  8349. * in DataTables as such, but can be used for plug-ins to reference the
  8350. * footer for each column.
  8351. * @type node
  8352. * @default null
  8353. */
  8354. "nTf": null,
  8355. /**
  8356. * The class to apply to all TD elements in the table's TBODY for the column
  8357. * @type string
  8358. * @default null
  8359. */
  8360. "sClass": null,
  8361. /**
  8362. * When DataTables calculates the column widths to assign to each column,
  8363. * it finds the longest string in each column and then constructs a
  8364. * temporary table and reads the widths from that. The problem with this
  8365. * is that "mmm" is much wider then "iiii", but the latter is a longer
  8366. * string - thus the calculation can go wrong (doing it properly and putting
  8367. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  8368. * a "work around" we provide this option. It will append its value to the
  8369. * text that is found to be the longest string for the column - i.e. padding.
  8370. * @type string
  8371. */
  8372. "sContentPadding": null,
  8373. /**
  8374. * Allows a default value to be given for a column's data, and will be used
  8375. * whenever a null data source is encountered (this can be because mData
  8376. * is set to null, or because the data source itself is null).
  8377. * @type string
  8378. * @default null
  8379. */
  8380. "sDefaultContent": null,
  8381. /**
  8382. * Name for the column, allowing reference to the column by name as well as
  8383. * by index (needs a lookup to work by name).
  8384. * @type string
  8385. */
  8386. "sName": null,
  8387. /**
  8388. * Custom sorting data type - defines which of the available plug-ins in
  8389. * afnSortData the custom sorting will use - if any is defined.
  8390. * @type string
  8391. * @default std
  8392. */
  8393. "sSortDataType": 'std',
  8394. /**
  8395. * Class to be applied to the header element when sorting on this column
  8396. * @type string
  8397. * @default null
  8398. */
  8399. "sSortingClass": null,
  8400. /**
  8401. * Class to be applied to the header element when sorting on this column -
  8402. * when jQuery UI theming is used.
  8403. * @type string
  8404. * @default null
  8405. */
  8406. "sSortingClassJUI": null,
  8407. /**
  8408. * Title of the column - what is seen in the TH element (nTh).
  8409. * @type string
  8410. */
  8411. "sTitle": null,
  8412. /**
  8413. * Column sorting and filtering type
  8414. * @type string
  8415. * @default null
  8416. */
  8417. "sType": null,
  8418. /**
  8419. * Width of the column
  8420. * @type string
  8421. * @default null
  8422. */
  8423. "sWidth": null,
  8424. /**
  8425. * Width of the column when it was first "encountered"
  8426. * @type string
  8427. * @default null
  8428. */
  8429. "sWidthOrig": null
  8430. };
  8431. /*
  8432. * Developer note: The properties of the object below are given in Hungarian
  8433. * notation, that was used as the interface for DataTables prior to v1.10, however
  8434. * from v1.10 onwards the primary interface is camel case. In order to avoid
  8435. * breaking backwards compatibility utterly with this change, the Hungarian
  8436. * version is still, internally the primary interface, but is is not documented
  8437. * - hence the @name tags in each doc comment. This allows a Javascript function
  8438. * to create a map from Hungarian notation to camel case (going the other direction
  8439. * would require each property to be listed, which would add around 3K to the size
  8440. * of DataTables, while this method is about a 0.5K hit).
  8441. *
  8442. * Ultimately this does pave the way for Hungarian notation to be dropped
  8443. * completely, but that is a massive amount of work and will break current
  8444. * installs (therefore is on-hold until v2).
  8445. */
  8446. /**
  8447. * Initialisation options that can be given to DataTables at initialisation
  8448. * time.
  8449. * @namespace
  8450. */
  8451. DataTable.defaults = {
  8452. /**
  8453. * An array of data to use for the table, passed in at initialisation which
  8454. * will be used in preference to any data which is already in the DOM. This is
  8455. * particularly useful for constructing tables purely in Javascript, for
  8456. * example with a custom Ajax call.
  8457. * @type array
  8458. * @default null
  8459. *
  8460. * @dtopt Option
  8461. * @name DataTable.defaults.data
  8462. *
  8463. * @example
  8464. * // Using a 2D array data source
  8465. * $(document).ready( function () {
  8466. * $('#example').dataTable( {
  8467. * "data": [
  8468. * ['Trident', 'Internet Explorer 4.0', 'Win 95+', 4, 'X'],
  8469. * ['Trident', 'Internet Explorer 5.0', 'Win 95+', 5, 'C'],
  8470. * ],
  8471. * "columns": [
  8472. * { "title": "Engine" },
  8473. * { "title": "Browser" },
  8474. * { "title": "Platform" },
  8475. * { "title": "Version" },
  8476. * { "title": "Grade" }
  8477. * ]
  8478. * } );
  8479. * } );
  8480. *
  8481. * @example
  8482. * // Using an array of objects as a data source (`data`)
  8483. * $(document).ready( function () {
  8484. * $('#example').dataTable( {
  8485. * "data": [
  8486. * {
  8487. * "engine": "Trident",
  8488. * "browser": "Internet Explorer 4.0",
  8489. * "platform": "Win 95+",
  8490. * "version": 4,
  8491. * "grade": "X"
  8492. * },
  8493. * {
  8494. * "engine": "Trident",
  8495. * "browser": "Internet Explorer 5.0",
  8496. * "platform": "Win 95+",
  8497. * "version": 5,
  8498. * "grade": "C"
  8499. * }
  8500. * ],
  8501. * "columns": [
  8502. * { "title": "Engine", "data": "engine" },
  8503. * { "title": "Browser", "data": "browser" },
  8504. * { "title": "Platform", "data": "platform" },
  8505. * { "title": "Version", "data": "version" },
  8506. * { "title": "Grade", "data": "grade" }
  8507. * ]
  8508. * } );
  8509. * } );
  8510. */
  8511. "aaData": null,
  8512. /**
  8513. * If ordering is enabled, then DataTables will perform a first pass sort on
  8514. * initialisation. You can define which column(s) the sort is performed
  8515. * upon, and the sorting direction, with this variable. The `sorting` array
  8516. * should contain an array for each column to be sorted initially containing
  8517. * the column's index and a direction string ('asc' or 'desc').
  8518. * @type array
  8519. * @default [[0,'asc']]
  8520. *
  8521. * @dtopt Option
  8522. * @name DataTable.defaults.order
  8523. *
  8524. * @example
  8525. * // Sort by 3rd column first, and then 4th column
  8526. * $(document).ready( function() {
  8527. * $('#example').dataTable( {
  8528. * "order": [[2,'asc'], [3,'desc']]
  8529. * } );
  8530. * } );
  8531. *
  8532. * // No initial sorting
  8533. * $(document).ready( function() {
  8534. * $('#example').dataTable( {
  8535. * "order": []
  8536. * } );
  8537. * } );
  8538. */
  8539. "aaSorting": [[0,'asc']],
  8540. /**
  8541. * This parameter is basically identical to the `sorting` parameter, but
  8542. * cannot be overridden by user interaction with the table. What this means
  8543. * is that you could have a column (visible or hidden) which the sorting
  8544. * will always be forced on first - any sorting after that (from the user)
  8545. * will then be performed as required. This can be useful for grouping rows
  8546. * together.
  8547. * @type array
  8548. * @default null
  8549. *
  8550. * @dtopt Option
  8551. * @name DataTable.defaults.orderFixed
  8552. *
  8553. * @example
  8554. * $(document).ready( function() {
  8555. * $('#example').dataTable( {
  8556. * "orderFixed": [[0,'asc']]
  8557. * } );
  8558. * } )
  8559. */
  8560. "aaSortingFixed": [],
  8561. /**
  8562. * DataTables can be instructed to load data to display in the table from a
  8563. * Ajax source. This option defines how that Ajax call is made and where to.
  8564. *
  8565. * The `ajax` property has three different modes of operation, depending on
  8566. * how it is defined. These are:
  8567. *
  8568. * * `string` - Set the URL from where the data should be loaded from.
  8569. * * `object` - Define properties for `jQuery.ajax`.
  8570. * * `function` - Custom data get function
  8571. *
  8572. * `string`
  8573. * --------
  8574. *
  8575. * As a string, the `ajax` property simply defines the URL from which
  8576. * DataTables will load data.
  8577. *
  8578. * `object`
  8579. * --------
  8580. *
  8581. * As an object, the parameters in the object are passed to
  8582. * [jQuery.ajax](http://api.jquery.com/jQuery.ajax/) allowing fine control
  8583. * of the Ajax request. DataTables has a number of default parameters which
  8584. * you can override using this option. Please refer to the jQuery
  8585. * documentation for a full description of the options available, although
  8586. * the following parameters provide additional options in DataTables or
  8587. * require special consideration:
  8588. *
  8589. * * `data` - As with jQuery, `data` can be provided as an object, but it
  8590. * can also be used as a function to manipulate the data DataTables sends
  8591. * to the server. The function takes a single parameter, an object of
  8592. * parameters with the values that DataTables has readied for sending. An
  8593. * object may be returned which will be merged into the DataTables
  8594. * defaults, or you can add the items to the object that was passed in and
  8595. * not return anything from the function. This supersedes `fnServerParams`
  8596. * from DataTables 1.9-.
  8597. *
  8598. * * `dataSrc` - By default DataTables will look for the property `data` (or
  8599. * `aaData` for compatibility with DataTables 1.9-) when obtaining data
  8600. * from an Ajax source or for server-side processing - this parameter
  8601. * allows that property to be changed. You can use Javascript dotted
  8602. * object notation to get a data source for multiple levels of nesting, or
  8603. * it my be used as a function. As a function it takes a single parameter,
  8604. * the JSON returned from the server, which can be manipulated as
  8605. * required, with the returned value being that used by DataTables as the
  8606. * data source for the table. This supersedes `sAjaxDataProp` from
  8607. * DataTables 1.9-.
  8608. *
  8609. * * `success` - Should not be overridden it is used internally in
  8610. * DataTables. To manipulate / transform the data returned by the server
  8611. * use `ajax.dataSrc`, or use `ajax` as a function (see below).
  8612. *
  8613. * `function`
  8614. * ----------
  8615. *
  8616. * As a function, making the Ajax call is left up to yourself allowing
  8617. * complete control of the Ajax request. Indeed, if desired, a method other
  8618. * than Ajax could be used to obtain the required data, such as Web storage
  8619. * or an AIR database.
  8620. *
  8621. * The function is given four parameters and no return is required. The
  8622. * parameters are:
  8623. *
  8624. * 1. _object_ - Data to send to the server
  8625. * 2. _function_ - Callback function that must be executed when the required
  8626. * data has been obtained. That data should be passed into the callback
  8627. * as the only parameter
  8628. * 3. _object_ - DataTables settings object for the table
  8629. *
  8630. * Note that this supersedes `fnServerData` from DataTables 1.9-.
  8631. *
  8632. * @type string|object|function
  8633. * @default null
  8634. *
  8635. * @dtopt Option
  8636. * @name DataTable.defaults.ajax
  8637. * @since 1.10.0
  8638. *
  8639. * @example
  8640. * // Get JSON data from a file via Ajax.
  8641. * // Note DataTables expects data in the form `{ data: [ ...data... ] }` by default).
  8642. * $('#example').dataTable( {
  8643. * "ajax": "data.json"
  8644. * } );
  8645. *
  8646. * @example
  8647. * // Get JSON data from a file via Ajax, using `dataSrc` to change
  8648. * // `data` to `tableData` (i.e. `{ tableData: [ ...data... ] }`)
  8649. * $('#example').dataTable( {
  8650. * "ajax": {
  8651. * "url": "data.json",
  8652. * "dataSrc": "tableData"
  8653. * }
  8654. * } );
  8655. *
  8656. * @example
  8657. * // Get JSON data from a file via Ajax, using `dataSrc` to read data
  8658. * // from a plain array rather than an array in an object
  8659. * $('#example').dataTable( {
  8660. * "ajax": {
  8661. * "url": "data.json",
  8662. * "dataSrc": ""
  8663. * }
  8664. * } );
  8665. *
  8666. * @example
  8667. * // Manipulate the data returned from the server - add a link to data
  8668. * // (note this can, should, be done using `render` for the column - this
  8669. * // is just a simple example of how the data can be manipulated).
  8670. * $('#example').dataTable( {
  8671. * "ajax": {
  8672. * "url": "data.json",
  8673. * "dataSrc": function ( json ) {
  8674. * for ( var i=0, ien=json.length ; i<ien ; i++ ) {
  8675. * json[i][0] = '<a href="/message/'+json[i][0]+'>View message</a>';
  8676. * }
  8677. * return json;
  8678. * }
  8679. * }
  8680. * } );
  8681. *
  8682. * @example
  8683. * // Add data to the request
  8684. * $('#example').dataTable( {
  8685. * "ajax": {
  8686. * "url": "data.json",
  8687. * "data": function ( d ) {
  8688. * return {
  8689. * "extra_search": $('#extra').val()
  8690. * };
  8691. * }
  8692. * }
  8693. * } );
  8694. *
  8695. * @example
  8696. * // Send request as POST
  8697. * $('#example').dataTable( {
  8698. * "ajax": {
  8699. * "url": "data.json",
  8700. * "type": "POST"
  8701. * }
  8702. * } );
  8703. *
  8704. * @example
  8705. * // Get the data from localStorage (could interface with a form for
  8706. * // adding, editing and removing rows).
  8707. * $('#example').dataTable( {
  8708. * "ajax": function (data, callback, settings) {
  8709. * callback(
  8710. * JSON.parse( localStorage.getItem('dataTablesData') )
  8711. * );
  8712. * }
  8713. * } );
  8714. */
  8715. "ajax": null,
  8716. /**
  8717. * This parameter allows you to readily specify the entries in the length drop
  8718. * down menu that DataTables shows when pagination is enabled. It can be
  8719. * either a 1D array of options which will be used for both the displayed
  8720. * option and the value, or a 2D array which will use the array in the first
  8721. * position as the value, and the array in the second position as the
  8722. * displayed options (useful for language strings such as 'All').
  8723. *
  8724. * Note that the `pageLength` property will be automatically set to the
  8725. * first value given in this array, unless `pageLength` is also provided.
  8726. * @type array
  8727. * @default [ 10, 25, 50, 100 ]
  8728. *
  8729. * @dtopt Option
  8730. * @name DataTable.defaults.lengthMenu
  8731. *
  8732. * @example
  8733. * $(document).ready( function() {
  8734. * $('#example').dataTable( {
  8735. * "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
  8736. * } );
  8737. * } );
  8738. */
  8739. "aLengthMenu": [ 10, 25, 50, 100 ],
  8740. /**
  8741. * The `columns` option in the initialisation parameter allows you to define
  8742. * details about the way individual columns behave. For a full list of
  8743. * column options that can be set, please see
  8744. * {@link DataTable.defaults.column}. Note that if you use `columns` to
  8745. * define your columns, you must have an entry in the array for every single
  8746. * column that you have in your table (these can be null if you don't which
  8747. * to specify any options).
  8748. * @member
  8749. *
  8750. * @name DataTable.defaults.column
  8751. */
  8752. "aoColumns": null,
  8753. /**
  8754. * Very similar to `columns`, `columnDefs` allows you to target a specific
  8755. * column, multiple columns, or all columns, using the `targets` property of
  8756. * each object in the array. This allows great flexibility when creating
  8757. * tables, as the `columnDefs` arrays can be of any length, targeting the
  8758. * columns you specifically want. `columnDefs` may use any of the column
  8759. * options available: {@link DataTable.defaults.column}, but it _must_
  8760. * have `targets` defined in each object in the array. Values in the `targets`
  8761. * array may be:
  8762. * <ul>
  8763. * <li>a string - class name will be matched on the TH for the column</li>
  8764. * <li>0 or a positive integer - column index counting from the left</li>
  8765. * <li>a negative integer - column index counting from the right</li>
  8766. * <li>the string "_all" - all columns (i.e. assign a default)</li>
  8767. * </ul>
  8768. * @member
  8769. *
  8770. * @name DataTable.defaults.columnDefs
  8771. */
  8772. "aoColumnDefs": null,
  8773. /**
  8774. * Basically the same as `search`, this parameter defines the individual column
  8775. * filtering state at initialisation time. The array must be of the same size
  8776. * as the number of columns, and each element be an object with the parameters
  8777. * `search` and `escapeRegex` (the latter is optional). 'null' is also
  8778. * accepted and the default will be used.
  8779. * @type array
  8780. * @default []
  8781. *
  8782. * @dtopt Option
  8783. * @name DataTable.defaults.searchCols
  8784. *
  8785. * @example
  8786. * $(document).ready( function() {
  8787. * $('#example').dataTable( {
  8788. * "searchCols": [
  8789. * null,
  8790. * { "search": "My filter" },
  8791. * null,
  8792. * { "search": "^[0-9]", "escapeRegex": false }
  8793. * ]
  8794. * } );
  8795. * } )
  8796. */
  8797. "aoSearchCols": [],
  8798. /**
  8799. * An array of CSS classes that should be applied to displayed rows. This
  8800. * array may be of any length, and DataTables will apply each class
  8801. * sequentially, looping when required.
  8802. * @type array
  8803. * @default null <i>Will take the values determined by the `oClasses.stripe*`
  8804. * options</i>
  8805. *
  8806. * @dtopt Option
  8807. * @name DataTable.defaults.stripeClasses
  8808. *
  8809. * @example
  8810. * $(document).ready( function() {
  8811. * $('#example').dataTable( {
  8812. * "stripeClasses": [ 'strip1', 'strip2', 'strip3' ]
  8813. * } );
  8814. * } )
  8815. */
  8816. "asStripeClasses": null,
  8817. /**
  8818. * Enable or disable automatic column width calculation. This can be disabled
  8819. * as an optimisation (it takes some time to calculate the widths) if the
  8820. * tables widths are passed in using `columns`.
  8821. * @type boolean
  8822. * @default true
  8823. *
  8824. * @dtopt Features
  8825. * @name DataTable.defaults.autoWidth
  8826. *
  8827. * @example
  8828. * $(document).ready( function () {
  8829. * $('#example').dataTable( {
  8830. * "autoWidth": false
  8831. * } );
  8832. * } );
  8833. */
  8834. "bAutoWidth": true,
  8835. /**
  8836. * Deferred rendering can provide DataTables with a huge speed boost when you
  8837. * are using an Ajax or JS data source for the table. This option, when set to
  8838. * true, will cause DataTables to defer the creation of the table elements for
  8839. * each row until they are needed for a draw - saving a significant amount of
  8840. * time.
  8841. * @type boolean
  8842. * @default false
  8843. *
  8844. * @dtopt Features
  8845. * @name DataTable.defaults.deferRender
  8846. *
  8847. * @example
  8848. * $(document).ready( function() {
  8849. * $('#example').dataTable( {
  8850. * "ajax": "sources/arrays.txt",
  8851. * "deferRender": true
  8852. * } );
  8853. * } );
  8854. */
  8855. "bDeferRender": false,
  8856. /**
  8857. * Replace a DataTable which matches the given selector and replace it with
  8858. * one which has the properties of the new initialisation object passed. If no
  8859. * table matches the selector, then the new DataTable will be constructed as
  8860. * per normal.
  8861. * @type boolean
  8862. * @default false
  8863. *
  8864. * @dtopt Options
  8865. * @name DataTable.defaults.destroy
  8866. *
  8867. * @example
  8868. * $(document).ready( function() {
  8869. * $('#example').dataTable( {
  8870. * "srollY": "200px",
  8871. * "paginate": false
  8872. * } );
  8873. *
  8874. * // Some time later....
  8875. * $('#example').dataTable( {
  8876. * "filter": false,
  8877. * "destroy": true
  8878. * } );
  8879. * } );
  8880. */
  8881. "bDestroy": false,
  8882. /**
  8883. * Enable or disable filtering of data. Filtering in DataTables is "smart" in
  8884. * that it allows the end user to input multiple words (space separated) and
  8885. * will match a row containing those words, even if not in the order that was
  8886. * specified (this allow matching across multiple columns). Note that if you
  8887. * wish to use filtering in DataTables this must remain 'true' - to remove the
  8888. * default filtering input box and retain filtering abilities, please use
  8889. * {@link DataTable.defaults.dom}.
  8890. * @type boolean
  8891. * @default true
  8892. *
  8893. * @dtopt Features
  8894. * @name DataTable.defaults.searching
  8895. *
  8896. * @example
  8897. * $(document).ready( function () {
  8898. * $('#example').dataTable( {
  8899. * "searching": false
  8900. * } );
  8901. * } );
  8902. */
  8903. "bFilter": true,
  8904. /**
  8905. * Enable or disable the table information display. This shows information
  8906. * about the data that is currently visible on the page, including information
  8907. * about filtered data if that action is being performed.
  8908. * @type boolean
  8909. * @default true
  8910. *
  8911. * @dtopt Features
  8912. * @name DataTable.defaults.info
  8913. *
  8914. * @example
  8915. * $(document).ready( function () {
  8916. * $('#example').dataTable( {
  8917. * "info": false
  8918. * } );
  8919. * } );
  8920. */
  8921. "bInfo": true,
  8922. /**
  8923. * Allows the end user to select the size of a formatted page from a select
  8924. * menu (sizes are 10, 25, 50 and 100). Requires pagination (`paginate`).
  8925. * @type boolean
  8926. * @default true
  8927. *
  8928. * @dtopt Features
  8929. * @name DataTable.defaults.lengthChange
  8930. *
  8931. * @example
  8932. * $(document).ready( function () {
  8933. * $('#example').dataTable( {
  8934. * "lengthChange": false
  8935. * } );
  8936. * } );
  8937. */
  8938. "bLengthChange": true,
  8939. /**
  8940. * Enable or disable pagination.
  8941. * @type boolean
  8942. * @default true
  8943. *
  8944. * @dtopt Features
  8945. * @name DataTable.defaults.paging
  8946. *
  8947. * @example
  8948. * $(document).ready( function () {
  8949. * $('#example').dataTable( {
  8950. * "paging": false
  8951. * } );
  8952. * } );
  8953. */
  8954. "bPaginate": true,
  8955. /**
  8956. * Enable or disable the display of a 'processing' indicator when the table is
  8957. * being processed (e.g. a sort). This is particularly useful for tables with
  8958. * large amounts of data where it can take a noticeable amount of time to sort
  8959. * the entries.
  8960. * @type boolean
  8961. * @default false
  8962. *
  8963. * @dtopt Features
  8964. * @name DataTable.defaults.processing
  8965. *
  8966. * @example
  8967. * $(document).ready( function () {
  8968. * $('#example').dataTable( {
  8969. * "processing": true
  8970. * } );
  8971. * } );
  8972. */
  8973. "bProcessing": false,
  8974. /**
  8975. * Retrieve the DataTables object for the given selector. Note that if the
  8976. * table has already been initialised, this parameter will cause DataTables
  8977. * to simply return the object that has already been set up - it will not take
  8978. * account of any changes you might have made to the initialisation object
  8979. * passed to DataTables (setting this parameter to true is an acknowledgement
  8980. * that you understand this). `destroy` can be used to reinitialise a table if
  8981. * you need.
  8982. * @type boolean
  8983. * @default false
  8984. *
  8985. * @dtopt Options
  8986. * @name DataTable.defaults.retrieve
  8987. *
  8988. * @example
  8989. * $(document).ready( function() {
  8990. * initTable();
  8991. * tableActions();
  8992. * } );
  8993. *
  8994. * function initTable ()
  8995. * {
  8996. * return $('#example').dataTable( {
  8997. * "scrollY": "200px",
  8998. * "paginate": false,
  8999. * "retrieve": true
  9000. * } );
  9001. * }
  9002. *
  9003. * function tableActions ()
  9004. * {
  9005. * var table = initTable();
  9006. * // perform API operations with oTable
  9007. * }
  9008. */
  9009. "bRetrieve": false,
  9010. /**
  9011. * When vertical (y) scrolling is enabled, DataTables will force the height of
  9012. * the table's viewport to the given height at all times (useful for layout).
  9013. * However, this can look odd when filtering data down to a small data set,
  9014. * and the footer is left "floating" further down. This parameter (when
  9015. * enabled) will cause DataTables to collapse the table's viewport down when
  9016. * the result set will fit within the given Y height.
  9017. * @type boolean
  9018. * @default false
  9019. *
  9020. * @dtopt Options
  9021. * @name DataTable.defaults.scrollCollapse
  9022. *
  9023. * @example
  9024. * $(document).ready( function() {
  9025. * $('#example').dataTable( {
  9026. * "scrollY": "200",
  9027. * "scrollCollapse": true
  9028. * } );
  9029. * } );
  9030. */
  9031. "bScrollCollapse": false,
  9032. /**
  9033. * Configure DataTables to use server-side processing. Note that the
  9034. * `ajax` parameter must also be given in order to give DataTables a
  9035. * source to obtain the required data for each draw.
  9036. * @type boolean
  9037. * @default false
  9038. *
  9039. * @dtopt Features
  9040. * @dtopt Server-side
  9041. * @name DataTable.defaults.serverSide
  9042. *
  9043. * @example
  9044. * $(document).ready( function () {
  9045. * $('#example').dataTable( {
  9046. * "serverSide": true,
  9047. * "ajax": "xhr.php"
  9048. * } );
  9049. * } );
  9050. */
  9051. "bServerSide": false,
  9052. /**
  9053. * Enable or disable sorting of columns. Sorting of individual columns can be
  9054. * disabled by the `sortable` option for each column.
  9055. * @type boolean
  9056. * @default true
  9057. *
  9058. * @dtopt Features
  9059. * @name DataTable.defaults.ordering
  9060. *
  9061. * @example
  9062. * $(document).ready( function () {
  9063. * $('#example').dataTable( {
  9064. * "ordering": false
  9065. * } );
  9066. * } );
  9067. */
  9068. "bSort": true,
  9069. /**
  9070. * Enable or display DataTables' ability to sort multiple columns at the
  9071. * same time (activated by shift-click by the user).
  9072. * @type boolean
  9073. * @default true
  9074. *
  9075. * @dtopt Options
  9076. * @name DataTable.defaults.orderMulti
  9077. *
  9078. * @example
  9079. * // Disable multiple column sorting ability
  9080. * $(document).ready( function () {
  9081. * $('#example').dataTable( {
  9082. * "orderMulti": false
  9083. * } );
  9084. * } );
  9085. */
  9086. "bSortMulti": true,
  9087. /**
  9088. * Allows control over whether DataTables should use the top (true) unique
  9089. * cell that is found for a single column, or the bottom (false - default).
  9090. * This is useful when using complex headers.
  9091. * @type boolean
  9092. * @default false
  9093. *
  9094. * @dtopt Options
  9095. * @name DataTable.defaults.orderCellsTop
  9096. *
  9097. * @example
  9098. * $(document).ready( function() {
  9099. * $('#example').dataTable( {
  9100. * "orderCellsTop": true
  9101. * } );
  9102. * } );
  9103. */
  9104. "bSortCellsTop": false,
  9105. /**
  9106. * Enable or disable the addition of the classes `sorting\_1`, `sorting\_2` and
  9107. * `sorting\_3` to the columns which are currently being sorted on. This is
  9108. * presented as a feature switch as it can increase processing time (while
  9109. * classes are removed and added) so for large data sets you might want to
  9110. * turn this off.
  9111. * @type boolean
  9112. * @default true
  9113. *
  9114. * @dtopt Features
  9115. * @name DataTable.defaults.orderClasses
  9116. *
  9117. * @example
  9118. * $(document).ready( function () {
  9119. * $('#example').dataTable( {
  9120. * "orderClasses": false
  9121. * } );
  9122. * } );
  9123. */
  9124. "bSortClasses": true,
  9125. /**
  9126. * Enable or disable state saving. When enabled HTML5 `localStorage` will be
  9127. * used to save table display information such as pagination information,
  9128. * display length, filtering and sorting. As such when the end user reloads
  9129. * the page the display display will match what thy had previously set up.
  9130. *
  9131. * Due to the use of `localStorage` the default state saving is not supported
  9132. * in IE6 or 7. If state saving is required in those browsers, use
  9133. * `stateSaveCallback` to provide a storage solution such as cookies.
  9134. * @type boolean
  9135. * @default false
  9136. *
  9137. * @dtopt Features
  9138. * @name DataTable.defaults.stateSave
  9139. *
  9140. * @example
  9141. * $(document).ready( function () {
  9142. * $('#example').dataTable( {
  9143. * "stateSave": true
  9144. * } );
  9145. * } );
  9146. */
  9147. "bStateSave": false,
  9148. /**
  9149. * This function is called when a TR element is created (and all TD child
  9150. * elements have been inserted), or registered if using a DOM source, allowing
  9151. * manipulation of the TR element (adding classes etc).
  9152. * @type function
  9153. * @param {node} row "TR" element for the current row
  9154. * @param {array} data Raw data array for this row
  9155. * @param {int} dataIndex The index of this row in the internal aoData array
  9156. *
  9157. * @dtopt Callbacks
  9158. * @name DataTable.defaults.createdRow
  9159. *
  9160. * @example
  9161. * $(document).ready( function() {
  9162. * $('#example').dataTable( {
  9163. * "createdRow": function( row, data, dataIndex ) {
  9164. * // Bold the grade for all 'A' grade browsers
  9165. * if ( data[4] == "A" )
  9166. * {
  9167. * $('td:eq(4)', row).html( '<b>A</b>' );
  9168. * }
  9169. * }
  9170. * } );
  9171. * } );
  9172. */
  9173. "fnCreatedRow": null,
  9174. /**
  9175. * This function is called on every 'draw' event, and allows you to
  9176. * dynamically modify any aspect you want about the created DOM.
  9177. * @type function
  9178. * @param {object} settings DataTables settings object
  9179. *
  9180. * @dtopt Callbacks
  9181. * @name DataTable.defaults.drawCallback
  9182. *
  9183. * @example
  9184. * $(document).ready( function() {
  9185. * $('#example').dataTable( {
  9186. * "drawCallback": function( settings ) {
  9187. * alert( 'DataTables has redrawn the table' );
  9188. * }
  9189. * } );
  9190. * } );
  9191. */
  9192. "fnDrawCallback": null,
  9193. /**
  9194. * Identical to fnHeaderCallback() but for the table footer this function
  9195. * allows you to modify the table footer on every 'draw' event.
  9196. * @type function
  9197. * @param {node} foot "TR" element for the footer
  9198. * @param {array} data Full table data (as derived from the original HTML)
  9199. * @param {int} start Index for the current display starting point in the
  9200. * display array
  9201. * @param {int} end Index for the current display ending point in the
  9202. * display array
  9203. * @param {array int} display Index array to translate the visual position
  9204. * to the full data array
  9205. *
  9206. * @dtopt Callbacks
  9207. * @name DataTable.defaults.footerCallback
  9208. *
  9209. * @example
  9210. * $(document).ready( function() {
  9211. * $('#example').dataTable( {
  9212. * "footerCallback": function( tfoot, data, start, end, display ) {
  9213. * tfoot.getElementsByTagName('th')[0].innerHTML = "Starting index is "+start;
  9214. * }
  9215. * } );
  9216. * } )
  9217. */
  9218. "fnFooterCallback": null,
  9219. /**
  9220. * When rendering large numbers in the information element for the table
  9221. * (i.e. "Showing 1 to 10 of 57 entries") DataTables will render large numbers
  9222. * to have a comma separator for the 'thousands' units (e.g. 1 million is
  9223. * rendered as "1,000,000") to help readability for the end user. This
  9224. * function will override the default method DataTables uses.
  9225. * @type function
  9226. * @member
  9227. * @param {int} toFormat number to be formatted
  9228. * @returns {string} formatted string for DataTables to show the number
  9229. *
  9230. * @dtopt Callbacks
  9231. * @name DataTable.defaults.formatNumber
  9232. *
  9233. * @example
  9234. * // Format a number using a single quote for the separator (note that
  9235. * // this can also be done with the language.thousands option)
  9236. * $(document).ready( function() {
  9237. * $('#example').dataTable( {
  9238. * "formatNumber": function ( toFormat ) {
  9239. * return toFormat.toString().replace(
  9240. * /\B(?=(\d{3})+(?!\d))/g, "'"
  9241. * );
  9242. * };
  9243. * } );
  9244. * } );
  9245. */
  9246. "fnFormatNumber": function ( toFormat ) {
  9247. return toFormat.toString().replace(
  9248. /\B(?=(\d{3})+(?!\d))/g,
  9249. this.oLanguage.sThousands
  9250. );
  9251. },
  9252. /**
  9253. * This function is called on every 'draw' event, and allows you to
  9254. * dynamically modify the header row. This can be used to calculate and
  9255. * display useful information about the table.
  9256. * @type function
  9257. * @param {node} head "TR" element for the header
  9258. * @param {array} data Full table data (as derived from the original HTML)
  9259. * @param {int} start Index for the current display starting point in the
  9260. * display array
  9261. * @param {int} end Index for the current display ending point in the
  9262. * display array
  9263. * @param {array int} display Index array to translate the visual position
  9264. * to the full data array
  9265. *
  9266. * @dtopt Callbacks
  9267. * @name DataTable.defaults.headerCallback
  9268. *
  9269. * @example
  9270. * $(document).ready( function() {
  9271. * $('#example').dataTable( {
  9272. * "fheaderCallback": function( head, data, start, end, display ) {
  9273. * head.getElementsByTagName('th')[0].innerHTML = "Displaying "+(end-start)+" records";
  9274. * }
  9275. * } );
  9276. * } )
  9277. */
  9278. "fnHeaderCallback": null,
  9279. /**
  9280. * The information element can be used to convey information about the current
  9281. * state of the table. Although the internationalisation options presented by
  9282. * DataTables are quite capable of dealing with most customisations, there may
  9283. * be times where you wish to customise the string further. This callback
  9284. * allows you to do exactly that.
  9285. * @type function
  9286. * @param {object} oSettings DataTables settings object
  9287. * @param {int} start Starting position in data for the draw
  9288. * @param {int} end End position in data for the draw
  9289. * @param {int} max Total number of rows in the table (regardless of
  9290. * filtering)
  9291. * @param {int} total Total number of rows in the data set, after filtering
  9292. * @param {string} pre The string that DataTables has formatted using it's
  9293. * own rules
  9294. * @returns {string} The string to be displayed in the information element.
  9295. *
  9296. * @dtopt Callbacks
  9297. * @name DataTable.defaults.infoCallback
  9298. *
  9299. * @example
  9300. * $('#example').dataTable( {
  9301. * "infoCallback": function( settings, start, end, max, total, pre ) {
  9302. * return start +" to "+ end;
  9303. * }
  9304. * } );
  9305. */
  9306. "fnInfoCallback": null,
  9307. /**
  9308. * Called when the table has been initialised. Normally DataTables will
  9309. * initialise sequentially and there will be no need for this function,
  9310. * however, this does not hold true when using external language information
  9311. * since that is obtained using an async XHR call.
  9312. * @type function
  9313. * @param {object} settings DataTables settings object
  9314. * @param {object} json The JSON object request from the server - only
  9315. * present if client-side Ajax sourced data is used
  9316. *
  9317. * @dtopt Callbacks
  9318. * @name DataTable.defaults.initComplete
  9319. *
  9320. * @example
  9321. * $(document).ready( function() {
  9322. * $('#example').dataTable( {
  9323. * "initComplete": function(settings, json) {
  9324. * alert( 'DataTables has finished its initialisation.' );
  9325. * }
  9326. * } );
  9327. * } )
  9328. */
  9329. "fnInitComplete": null,
  9330. /**
  9331. * Called at the very start of each table draw and can be used to cancel the
  9332. * draw by returning false, any other return (including undefined) results in
  9333. * the full draw occurring).
  9334. * @type function
  9335. * @param {object} settings DataTables settings object
  9336. * @returns {boolean} False will cancel the draw, anything else (including no
  9337. * return) will allow it to complete.
  9338. *
  9339. * @dtopt Callbacks
  9340. * @name DataTable.defaults.preDrawCallback
  9341. *
  9342. * @example
  9343. * $(document).ready( function() {
  9344. * $('#example').dataTable( {
  9345. * "preDrawCallback": function( settings ) {
  9346. * if ( $('#test').val() == 1 ) {
  9347. * return false;
  9348. * }
  9349. * }
  9350. * } );
  9351. * } );
  9352. */
  9353. "fnPreDrawCallback": null,
  9354. /**
  9355. * This function allows you to 'post process' each row after it have been
  9356. * generated for each table draw, but before it is rendered on screen. This
  9357. * function might be used for setting the row class name etc.
  9358. * @type function
  9359. * @param {node} row "TR" element for the current row
  9360. * @param {array} data Raw data array for this row
  9361. * @param {int} displayIndex The display index for the current table draw
  9362. * @param {int} displayIndexFull The index of the data in the full list of
  9363. * rows (after filtering)
  9364. *
  9365. * @dtopt Callbacks
  9366. * @name DataTable.defaults.rowCallback
  9367. *
  9368. * @example
  9369. * $(document).ready( function() {
  9370. * $('#example').dataTable( {
  9371. * "rowCallback": function( row, data, displayIndex, displayIndexFull ) {
  9372. * // Bold the grade for all 'A' grade browsers
  9373. * if ( data[4] == "A" ) {
  9374. * $('td:eq(4)', row).html( '<b>A</b>' );
  9375. * }
  9376. * }
  9377. * } );
  9378. * } );
  9379. */
  9380. "fnRowCallback": null,
  9381. /**
  9382. * __Deprecated__ The functionality provided by this parameter has now been
  9383. * superseded by that provided through `ajax`, which should be used instead.
  9384. *
  9385. * This parameter allows you to override the default function which obtains
  9386. * the data from the server so something more suitable for your application.
  9387. * For example you could use POST data, or pull information from a Gears or
  9388. * AIR database.
  9389. * @type function
  9390. * @member
  9391. * @param {string} source HTTP source to obtain the data from (`ajax`)
  9392. * @param {array} data A key/value pair object containing the data to send
  9393. * to the server
  9394. * @param {function} callback to be called on completion of the data get
  9395. * process that will draw the data on the page.
  9396. * @param {object} settings DataTables settings object
  9397. *
  9398. * @dtopt Callbacks
  9399. * @dtopt Server-side
  9400. * @name DataTable.defaults.serverData
  9401. *
  9402. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9403. */
  9404. "fnServerData": null,
  9405. /**
  9406. * __Deprecated__ The functionality provided by this parameter has now been
  9407. * superseded by that provided through `ajax`, which should be used instead.
  9408. *
  9409. * It is often useful to send extra data to the server when making an Ajax
  9410. * request - for example custom filtering information, and this callback
  9411. * function makes it trivial to send extra information to the server. The
  9412. * passed in parameter is the data set that has been constructed by
  9413. * DataTables, and you can add to this or modify it as you require.
  9414. * @type function
  9415. * @param {array} data Data array (array of objects which are name/value
  9416. * pairs) that has been constructed by DataTables and will be sent to the
  9417. * server. In the case of Ajax sourced data with server-side processing
  9418. * this will be an empty array, for server-side processing there will be a
  9419. * significant number of parameters!
  9420. * @returns {undefined} Ensure that you modify the data array passed in,
  9421. * as this is passed by reference.
  9422. *
  9423. * @dtopt Callbacks
  9424. * @dtopt Server-side
  9425. * @name DataTable.defaults.serverParams
  9426. *
  9427. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9428. */
  9429. "fnServerParams": null,
  9430. /**
  9431. * Load the table state. With this function you can define from where, and how, the
  9432. * state of a table is loaded. By default DataTables will load from `localStorage`
  9433. * but you might wish to use a server-side database or cookies.
  9434. * @type function
  9435. * @member
  9436. * @param {object} settings DataTables settings object
  9437. * @param {object} callback Callback that can be executed when done. It
  9438. * should be passed the loaded state object.
  9439. * @return {object} The DataTables state object to be loaded
  9440. *
  9441. * @dtopt Callbacks
  9442. * @name DataTable.defaults.stateLoadCallback
  9443. *
  9444. * @example
  9445. * $(document).ready( function() {
  9446. * $('#example').dataTable( {
  9447. * "stateSave": true,
  9448. * "stateLoadCallback": function (settings, callback) {
  9449. * $.ajax( {
  9450. * "url": "/state_load",
  9451. * "dataType": "json",
  9452. * "success": function (json) {
  9453. * callback( json );
  9454. * }
  9455. * } );
  9456. * }
  9457. * } );
  9458. * } );
  9459. */
  9460. "fnStateLoadCallback": function ( settings ) {
  9461. try {
  9462. return JSON.parse(
  9463. (settings.iStateDuration === -1 ? sessionStorage : localStorage).getItem(
  9464. 'DataTables_'+settings.sInstance+'_'+location.pathname
  9465. )
  9466. );
  9467. } catch (e) {
  9468. return {};
  9469. }
  9470. },
  9471. /**
  9472. * Callback which allows modification of the saved state prior to loading that state.
  9473. * This callback is called when the table is loading state from the stored data, but
  9474. * prior to the settings object being modified by the saved state. Note that for
  9475. * plug-in authors, you should use the `stateLoadParams` event to load parameters for
  9476. * a plug-in.
  9477. * @type function
  9478. * @param {object} settings DataTables settings object
  9479. * @param {object} data The state object that is to be loaded
  9480. *
  9481. * @dtopt Callbacks
  9482. * @name DataTable.defaults.stateLoadParams
  9483. *
  9484. * @example
  9485. * // Remove a saved filter, so filtering is never loaded
  9486. * $(document).ready( function() {
  9487. * $('#example').dataTable( {
  9488. * "stateSave": true,
  9489. * "stateLoadParams": function (settings, data) {
  9490. * data.oSearch.sSearch = "";
  9491. * }
  9492. * } );
  9493. * } );
  9494. *
  9495. * @example
  9496. * // Disallow state loading by returning false
  9497. * $(document).ready( function() {
  9498. * $('#example').dataTable( {
  9499. * "stateSave": true,
  9500. * "stateLoadParams": function (settings, data) {
  9501. * return false;
  9502. * }
  9503. * } );
  9504. * } );
  9505. */
  9506. "fnStateLoadParams": null,
  9507. /**
  9508. * Callback that is called when the state has been loaded from the state saving method
  9509. * and the DataTables settings object has been modified as a result of the loaded state.
  9510. * @type function
  9511. * @param {object} settings DataTables settings object
  9512. * @param {object} data The state object that was loaded
  9513. *
  9514. * @dtopt Callbacks
  9515. * @name DataTable.defaults.stateLoaded
  9516. *
  9517. * @example
  9518. * // Show an alert with the filtering value that was saved
  9519. * $(document).ready( function() {
  9520. * $('#example').dataTable( {
  9521. * "stateSave": true,
  9522. * "stateLoaded": function (settings, data) {
  9523. * alert( 'Saved filter was: '+data.oSearch.sSearch );
  9524. * }
  9525. * } );
  9526. * } );
  9527. */
  9528. "fnStateLoaded": null,
  9529. /**
  9530. * Save the table state. This function allows you to define where and how the state
  9531. * information for the table is stored By default DataTables will use `localStorage`
  9532. * but you might wish to use a server-side database or cookies.
  9533. * @type function
  9534. * @member
  9535. * @param {object} settings DataTables settings object
  9536. * @param {object} data The state object to be saved
  9537. *
  9538. * @dtopt Callbacks
  9539. * @name DataTable.defaults.stateSaveCallback
  9540. *
  9541. * @example
  9542. * $(document).ready( function() {
  9543. * $('#example').dataTable( {
  9544. * "stateSave": true,
  9545. * "stateSaveCallback": function (settings, data) {
  9546. * // Send an Ajax request to the server with the state object
  9547. * $.ajax( {
  9548. * "url": "/state_save",
  9549. * "data": data,
  9550. * "dataType": "json",
  9551. * "method": "POST"
  9552. * "success": function () {}
  9553. * } );
  9554. * }
  9555. * } );
  9556. * } );
  9557. */
  9558. "fnStateSaveCallback": function ( settings, data ) {
  9559. try {
  9560. (settings.iStateDuration === -1 ? sessionStorage : localStorage).setItem(
  9561. 'DataTables_'+settings.sInstance+'_'+location.pathname,
  9562. JSON.stringify( data )
  9563. );
  9564. } catch (e) {}
  9565. },
  9566. /**
  9567. * Callback which allows modification of the state to be saved. Called when the table
  9568. * has changed state a new state save is required. This method allows modification of
  9569. * the state saving object prior to actually doing the save, including addition or
  9570. * other state properties or modification. Note that for plug-in authors, you should
  9571. * use the `stateSaveParams` event to save parameters for a plug-in.
  9572. * @type function
  9573. * @param {object} settings DataTables settings object
  9574. * @param {object} data The state object to be saved
  9575. *
  9576. * @dtopt Callbacks
  9577. * @name DataTable.defaults.stateSaveParams
  9578. *
  9579. * @example
  9580. * // Remove a saved filter, so filtering is never saved
  9581. * $(document).ready( function() {
  9582. * $('#example').dataTable( {
  9583. * "stateSave": true,
  9584. * "stateSaveParams": function (settings, data) {
  9585. * data.oSearch.sSearch = "";
  9586. * }
  9587. * } );
  9588. * } );
  9589. */
  9590. "fnStateSaveParams": null,
  9591. /**
  9592. * Duration for which the saved state information is considered valid. After this period
  9593. * has elapsed the state will be returned to the default.
  9594. * Value is given in seconds.
  9595. * @type int
  9596. * @default 7200 <i>(2 hours)</i>
  9597. *
  9598. * @dtopt Options
  9599. * @name DataTable.defaults.stateDuration
  9600. *
  9601. * @example
  9602. * $(document).ready( function() {
  9603. * $('#example').dataTable( {
  9604. * "stateDuration": 60*60*24; // 1 day
  9605. * } );
  9606. * } )
  9607. */
  9608. "iStateDuration": 7200,
  9609. /**
  9610. * When enabled DataTables will not make a request to the server for the first
  9611. * page draw - rather it will use the data already on the page (no sorting etc
  9612. * will be applied to it), thus saving on an XHR at load time. `deferLoading`
  9613. * is used to indicate that deferred loading is required, but it is also used
  9614. * to tell DataTables how many records there are in the full table (allowing
  9615. * the information element and pagination to be displayed correctly). In the case
  9616. * where a filtering is applied to the table on initial load, this can be
  9617. * indicated by giving the parameter as an array, where the first element is
  9618. * the number of records available after filtering and the second element is the
  9619. * number of records without filtering (allowing the table information element
  9620. * to be shown correctly).
  9621. * @type int | array
  9622. * @default null
  9623. *
  9624. * @dtopt Options
  9625. * @name DataTable.defaults.deferLoading
  9626. *
  9627. * @example
  9628. * // 57 records available in the table, no filtering applied
  9629. * $(document).ready( function() {
  9630. * $('#example').dataTable( {
  9631. * "serverSide": true,
  9632. * "ajax": "scripts/server_processing.php",
  9633. * "deferLoading": 57
  9634. * } );
  9635. * } );
  9636. *
  9637. * @example
  9638. * // 57 records after filtering, 100 without filtering (an initial filter applied)
  9639. * $(document).ready( function() {
  9640. * $('#example').dataTable( {
  9641. * "serverSide": true,
  9642. * "ajax": "scripts/server_processing.php",
  9643. * "deferLoading": [ 57, 100 ],
  9644. * "search": {
  9645. * "search": "my_filter"
  9646. * }
  9647. * } );
  9648. * } );
  9649. */
  9650. "iDeferLoading": null,
  9651. /**
  9652. * Number of rows to display on a single page when using pagination. If
  9653. * feature enabled (`lengthChange`) then the end user will be able to override
  9654. * this to a custom setting using a pop-up menu.
  9655. * @type int
  9656. * @default 10
  9657. *
  9658. * @dtopt Options
  9659. * @name DataTable.defaults.pageLength
  9660. *
  9661. * @example
  9662. * $(document).ready( function() {
  9663. * $('#example').dataTable( {
  9664. * "pageLength": 50
  9665. * } );
  9666. * } )
  9667. */
  9668. "iDisplayLength": 10,
  9669. /**
  9670. * Define the starting point for data display when using DataTables with
  9671. * pagination. Note that this parameter is the number of records, rather than
  9672. * the page number, so if you have 10 records per page and want to start on
  9673. * the third page, it should be "20".
  9674. * @type int
  9675. * @default 0
  9676. *
  9677. * @dtopt Options
  9678. * @name DataTable.defaults.displayStart
  9679. *
  9680. * @example
  9681. * $(document).ready( function() {
  9682. * $('#example').dataTable( {
  9683. * "displayStart": 20
  9684. * } );
  9685. * } )
  9686. */
  9687. "iDisplayStart": 0,
  9688. /**
  9689. * By default DataTables allows keyboard navigation of the table (sorting, paging,
  9690. * and filtering) by adding a `tabindex` attribute to the required elements. This
  9691. * allows you to tab through the controls and press the enter key to activate them.
  9692. * The tabindex is default 0, meaning that the tab follows the flow of the document.
  9693. * You can overrule this using this parameter if you wish. Use a value of -1 to
  9694. * disable built-in keyboard navigation.
  9695. * @type int
  9696. * @default 0
  9697. *
  9698. * @dtopt Options
  9699. * @name DataTable.defaults.tabIndex
  9700. *
  9701. * @example
  9702. * $(document).ready( function() {
  9703. * $('#example').dataTable( {
  9704. * "tabIndex": 1
  9705. * } );
  9706. * } );
  9707. */
  9708. "iTabIndex": 0,
  9709. /**
  9710. * Classes that DataTables assigns to the various components and features
  9711. * that it adds to the HTML table. This allows classes to be configured
  9712. * during initialisation in addition to through the static
  9713. * {@link DataTable.ext.oStdClasses} object).
  9714. * @namespace
  9715. * @name DataTable.defaults.classes
  9716. */
  9717. "oClasses": {},
  9718. /**
  9719. * All strings that DataTables uses in the user interface that it creates
  9720. * are defined in this object, allowing you to modified them individually or
  9721. * completely replace them all as required.
  9722. * @namespace
  9723. * @name DataTable.defaults.language
  9724. */
  9725. "oLanguage": {
  9726. /**
  9727. * Strings that are used for WAI-ARIA labels and controls only (these are not
  9728. * actually visible on the page, but will be read by screenreaders, and thus
  9729. * must be internationalised as well).
  9730. * @namespace
  9731. * @name DataTable.defaults.language.aria
  9732. */
  9733. "oAria": {
  9734. /**
  9735. * ARIA label that is added to the table headers when the column may be
  9736. * sorted ascending by activing the column (click or return when focused).
  9737. * Note that the column header is prefixed to this string.
  9738. * @type string
  9739. * @default : activate to sort column ascending
  9740. *
  9741. * @dtopt Language
  9742. * @name DataTable.defaults.language.aria.sortAscending
  9743. *
  9744. * @example
  9745. * $(document).ready( function() {
  9746. * $('#example').dataTable( {
  9747. * "language": {
  9748. * "aria": {
  9749. * "sortAscending": " - click/return to sort ascending"
  9750. * }
  9751. * }
  9752. * } );
  9753. * } );
  9754. */
  9755. "sSortAscending": ": activate to sort column ascending",
  9756. /**
  9757. * ARIA label that is added to the table headers when the column may be
  9758. * sorted descending by activing the column (click or return when focused).
  9759. * Note that the column header is prefixed to this string.
  9760. * @type string
  9761. * @default : activate to sort column ascending
  9762. *
  9763. * @dtopt Language
  9764. * @name DataTable.defaults.language.aria.sortDescending
  9765. *
  9766. * @example
  9767. * $(document).ready( function() {
  9768. * $('#example').dataTable( {
  9769. * "language": {
  9770. * "aria": {
  9771. * "sortDescending": " - click/return to sort descending"
  9772. * }
  9773. * }
  9774. * } );
  9775. * } );
  9776. */
  9777. "sSortDescending": ": activate to sort column descending"
  9778. },
  9779. /**
  9780. * Pagination string used by DataTables for the built-in pagination
  9781. * control types.
  9782. * @namespace
  9783. * @name DataTable.defaults.language.paginate
  9784. */
  9785. "oPaginate": {
  9786. /**
  9787. * Text to use when using the 'full_numbers' type of pagination for the
  9788. * button to take the user to the first page.
  9789. * @type string
  9790. * @default First
  9791. *
  9792. * @dtopt Language
  9793. * @name DataTable.defaults.language.paginate.first
  9794. *
  9795. * @example
  9796. * $(document).ready( function() {
  9797. * $('#example').dataTable( {
  9798. * "language": {
  9799. * "paginate": {
  9800. * "first": "First page"
  9801. * }
  9802. * }
  9803. * } );
  9804. * } );
  9805. */
  9806. "sFirst": "First",
  9807. /**
  9808. * Text to use when using the 'full_numbers' type of pagination for the
  9809. * button to take the user to the last page.
  9810. * @type string
  9811. * @default Last
  9812. *
  9813. * @dtopt Language
  9814. * @name DataTable.defaults.language.paginate.last
  9815. *
  9816. * @example
  9817. * $(document).ready( function() {
  9818. * $('#example').dataTable( {
  9819. * "language": {
  9820. * "paginate": {
  9821. * "last": "Last page"
  9822. * }
  9823. * }
  9824. * } );
  9825. * } );
  9826. */
  9827. "sLast": "Last",
  9828. /**
  9829. * Text to use for the 'next' pagination button (to take the user to the
  9830. * next page).
  9831. * @type string
  9832. * @default Next
  9833. *
  9834. * @dtopt Language
  9835. * @name DataTable.defaults.language.paginate.next
  9836. *
  9837. * @example
  9838. * $(document).ready( function() {
  9839. * $('#example').dataTable( {
  9840. * "language": {
  9841. * "paginate": {
  9842. * "next": "Next page"
  9843. * }
  9844. * }
  9845. * } );
  9846. * } );
  9847. */
  9848. "sNext": "Next",
  9849. /**
  9850. * Text to use for the 'previous' pagination button (to take the user to
  9851. * the previous page).
  9852. * @type string
  9853. * @default Previous
  9854. *
  9855. * @dtopt Language
  9856. * @name DataTable.defaults.language.paginate.previous
  9857. *
  9858. * @example
  9859. * $(document).ready( function() {
  9860. * $('#example').dataTable( {
  9861. * "language": {
  9862. * "paginate": {
  9863. * "previous": "Previous page"
  9864. * }
  9865. * }
  9866. * } );
  9867. * } );
  9868. */
  9869. "sPrevious": "Previous"
  9870. },
  9871. /**
  9872. * This string is shown in preference to `zeroRecords` when the table is
  9873. * empty of data (regardless of filtering). Note that this is an optional
  9874. * parameter - if it is not given, the value of `zeroRecords` will be used
  9875. * instead (either the default or given value).
  9876. * @type string
  9877. * @default No data available in table
  9878. *
  9879. * @dtopt Language
  9880. * @name DataTable.defaults.language.emptyTable
  9881. *
  9882. * @example
  9883. * $(document).ready( function() {
  9884. * $('#example').dataTable( {
  9885. * "language": {
  9886. * "emptyTable": "No data available in table"
  9887. * }
  9888. * } );
  9889. * } );
  9890. */
  9891. "sEmptyTable": "No data available in table",
  9892. /**
  9893. * This string gives information to the end user about the information
  9894. * that is current on display on the page. The following tokens can be
  9895. * used in the string and will be dynamically replaced as the table
  9896. * display updates. This tokens can be placed anywhere in the string, or
  9897. * removed as needed by the language requires:
  9898. *
  9899. * * `\_START\_` - Display index of the first record on the current page
  9900. * * `\_END\_` - Display index of the last record on the current page
  9901. * * `\_TOTAL\_` - Number of records in the table after filtering
  9902. * * `\_MAX\_` - Number of records in the table without filtering
  9903. * * `\_PAGE\_` - Current page number
  9904. * * `\_PAGES\_` - Total number of pages of data in the table
  9905. *
  9906. * @type string
  9907. * @default Showing _START_ to _END_ of _TOTAL_ entries
  9908. *
  9909. * @dtopt Language
  9910. * @name DataTable.defaults.language.info
  9911. *
  9912. * @example
  9913. * $(document).ready( function() {
  9914. * $('#example').dataTable( {
  9915. * "language": {
  9916. * "info": "Showing page _PAGE_ of _PAGES_"
  9917. * }
  9918. * } );
  9919. * } );
  9920. */
  9921. "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
  9922. /**
  9923. * Display information string for when the table is empty. Typically the
  9924. * format of this string should match `info`.
  9925. * @type string
  9926. * @default Showing 0 to 0 of 0 entries
  9927. *
  9928. * @dtopt Language
  9929. * @name DataTable.defaults.language.infoEmpty
  9930. *
  9931. * @example
  9932. * $(document).ready( function() {
  9933. * $('#example').dataTable( {
  9934. * "language": {
  9935. * "infoEmpty": "No entries to show"
  9936. * }
  9937. * } );
  9938. * } );
  9939. */
  9940. "sInfoEmpty": "Showing 0 to 0 of 0 entries",
  9941. /**
  9942. * When a user filters the information in a table, this string is appended
  9943. * to the information (`info`) to give an idea of how strong the filtering
  9944. * is. The variable _MAX_ is dynamically updated.
  9945. * @type string
  9946. * @default (filtered from _MAX_ total entries)
  9947. *
  9948. * @dtopt Language
  9949. * @name DataTable.defaults.language.infoFiltered
  9950. *
  9951. * @example
  9952. * $(document).ready( function() {
  9953. * $('#example').dataTable( {
  9954. * "language": {
  9955. * "infoFiltered": " - filtering from _MAX_ records"
  9956. * }
  9957. * } );
  9958. * } );
  9959. */
  9960. "sInfoFiltered": "(filtered from _MAX_ total entries)",
  9961. /**
  9962. * If can be useful to append extra information to the info string at times,
  9963. * and this variable does exactly that. This information will be appended to
  9964. * the `info` (`infoEmpty` and `infoFiltered` in whatever combination they are
  9965. * being used) at all times.
  9966. * @type string
  9967. * @default <i>Empty string</i>
  9968. *
  9969. * @dtopt Language
  9970. * @name DataTable.defaults.language.infoPostFix
  9971. *
  9972. * @example
  9973. * $(document).ready( function() {
  9974. * $('#example').dataTable( {
  9975. * "language": {
  9976. * "infoPostFix": "All records shown are derived from real information."
  9977. * }
  9978. * } );
  9979. * } );
  9980. */
  9981. "sInfoPostFix": "",
  9982. /**
  9983. * This decimal place operator is a little different from the other
  9984. * language options since DataTables doesn't output floating point
  9985. * numbers, so it won't ever use this for display of a number. Rather,
  9986. * what this parameter does is modify the sort methods of the table so
  9987. * that numbers which are in a format which has a character other than
  9988. * a period (`.`) as a decimal place will be sorted numerically.
  9989. *
  9990. * Note that numbers with different decimal places cannot be shown in
  9991. * the same table and still be sortable, the table must be consistent.
  9992. * However, multiple different tables on the page can use different
  9993. * decimal place characters.
  9994. * @type string
  9995. * @default
  9996. *
  9997. * @dtopt Language
  9998. * @name DataTable.defaults.language.decimal
  9999. *
  10000. * @example
  10001. * $(document).ready( function() {
  10002. * $('#example').dataTable( {
  10003. * "language": {
  10004. * "decimal": ","
  10005. * "thousands": "."
  10006. * }
  10007. * } );
  10008. * } );
  10009. */
  10010. "sDecimal": "",
  10011. /**
  10012. * DataTables has a build in number formatter (`formatNumber`) which is
  10013. * used to format large numbers that are used in the table information.
  10014. * By default a comma is used, but this can be trivially changed to any
  10015. * character you wish with this parameter.
  10016. * @type string
  10017. * @default ,
  10018. *
  10019. * @dtopt Language
  10020. * @name DataTable.defaults.language.thousands
  10021. *
  10022. * @example
  10023. * $(document).ready( function() {
  10024. * $('#example').dataTable( {
  10025. * "language": {
  10026. * "thousands": "'"
  10027. * }
  10028. * } );
  10029. * } );
  10030. */
  10031. "sThousands": ",",
  10032. /**
  10033. * Detail the action that will be taken when the drop down menu for the
  10034. * pagination length option is changed. The '_MENU_' variable is replaced
  10035. * with a default select list of 10, 25, 50 and 100, and can be replaced
  10036. * with a custom select box if required.
  10037. * @type string
  10038. * @default Show _MENU_ entries
  10039. *
  10040. * @dtopt Language
  10041. * @name DataTable.defaults.language.lengthMenu
  10042. *
  10043. * @example
  10044. * // Language change only
  10045. * $(document).ready( function() {
  10046. * $('#example').dataTable( {
  10047. * "language": {
  10048. * "lengthMenu": "Display _MENU_ records"
  10049. * }
  10050. * } );
  10051. * } );
  10052. *
  10053. * @example
  10054. * // Language and options change
  10055. * $(document).ready( function() {
  10056. * $('#example').dataTable( {
  10057. * "language": {
  10058. * "lengthMenu": 'Display <select>'+
  10059. * '<option value="10">10</option>'+
  10060. * '<option value="20">20</option>'+
  10061. * '<option value="30">30</option>'+
  10062. * '<option value="40">40</option>'+
  10063. * '<option value="50">50</option>'+
  10064. * '<option value="-1">All</option>'+
  10065. * '</select> records'
  10066. * }
  10067. * } );
  10068. * } );
  10069. */
  10070. "sLengthMenu": "Show _MENU_ entries",
  10071. /**
  10072. * When using Ajax sourced data and during the first draw when DataTables is
  10073. * gathering the data, this message is shown in an empty row in the table to
  10074. * indicate to the end user the the data is being loaded. Note that this
  10075. * parameter is not used when loading data by server-side processing, just
  10076. * Ajax sourced data with client-side processing.
  10077. * @type string
  10078. * @default Loading...
  10079. *
  10080. * @dtopt Language
  10081. * @name DataTable.defaults.language.loadingRecords
  10082. *
  10083. * @example
  10084. * $(document).ready( function() {
  10085. * $('#example').dataTable( {
  10086. * "language": {
  10087. * "loadingRecords": "Please wait - loading..."
  10088. * }
  10089. * } );
  10090. * } );
  10091. */
  10092. "sLoadingRecords": "Loading...",
  10093. /**
  10094. * Text which is displayed when the table is processing a user action
  10095. * (usually a sort command or similar).
  10096. * @type string
  10097. * @default Processing...
  10098. *
  10099. * @dtopt Language
  10100. * @name DataTable.defaults.language.processing
  10101. *
  10102. * @example
  10103. * $(document).ready( function() {
  10104. * $('#example').dataTable( {
  10105. * "language": {
  10106. * "processing": "DataTables is currently busy"
  10107. * }
  10108. * } );
  10109. * } );
  10110. */
  10111. "sProcessing": "Processing...",
  10112. /**
  10113. * Details the actions that will be taken when the user types into the
  10114. * filtering input text box. The variable "_INPUT_", if used in the string,
  10115. * is replaced with the HTML text box for the filtering input allowing
  10116. * control over where it appears in the string. If "_INPUT_" is not given
  10117. * then the input box is appended to the string automatically.
  10118. * @type string
  10119. * @default Search:
  10120. *
  10121. * @dtopt Language
  10122. * @name DataTable.defaults.language.search
  10123. *
  10124. * @example
  10125. * // Input text box will be appended at the end automatically
  10126. * $(document).ready( function() {
  10127. * $('#example').dataTable( {
  10128. * "language": {
  10129. * "search": "Filter records:"
  10130. * }
  10131. * } );
  10132. * } );
  10133. *
  10134. * @example
  10135. * // Specify where the filter should appear
  10136. * $(document).ready( function() {
  10137. * $('#example').dataTable( {
  10138. * "language": {
  10139. * "search": "Apply filter _INPUT_ to table"
  10140. * }
  10141. * } );
  10142. * } );
  10143. */
  10144. "sSearch": "Search:",
  10145. /**
  10146. * Assign a `placeholder` attribute to the search `input` element
  10147. * @type string
  10148. * @default
  10149. *
  10150. * @dtopt Language
  10151. * @name DataTable.defaults.language.searchPlaceholder
  10152. */
  10153. "sSearchPlaceholder": "",
  10154. /**
  10155. * All of the language information can be stored in a file on the
  10156. * server-side, which DataTables will look up if this parameter is passed.
  10157. * It must store the URL of the language file, which is in a JSON format,
  10158. * and the object has the same properties as the oLanguage object in the
  10159. * initialiser object (i.e. the above parameters). Please refer to one of
  10160. * the example language files to see how this works in action.
  10161. * @type string
  10162. * @default <i>Empty string - i.e. disabled</i>
  10163. *
  10164. * @dtopt Language
  10165. * @name DataTable.defaults.language.url
  10166. *
  10167. * @example
  10168. * $(document).ready( function() {
  10169. * $('#example').dataTable( {
  10170. * "language": {
  10171. * "url": "http://www.sprymedia.co.uk/dataTables/lang.txt"
  10172. * }
  10173. * } );
  10174. * } );
  10175. */
  10176. "sUrl": "",
  10177. /**
  10178. * Text shown inside the table records when the is no information to be
  10179. * displayed after filtering. `emptyTable` is shown when there is simply no
  10180. * information in the table at all (regardless of filtering).
  10181. * @type string
  10182. * @default No matching records found
  10183. *
  10184. * @dtopt Language
  10185. * @name DataTable.defaults.language.zeroRecords
  10186. *
  10187. * @example
  10188. * $(document).ready( function() {
  10189. * $('#example').dataTable( {
  10190. * "language": {
  10191. * "zeroRecords": "No records to display"
  10192. * }
  10193. * } );
  10194. * } );
  10195. */
  10196. "sZeroRecords": "No matching records found"
  10197. },
  10198. /**
  10199. * This parameter allows you to have define the global filtering state at
  10200. * initialisation time. As an object the `search` parameter must be
  10201. * defined, but all other parameters are optional. When `regex` is true,
  10202. * the search string will be treated as a regular expression, when false
  10203. * (default) it will be treated as a straight string. When `smart`
  10204. * DataTables will use it's smart filtering methods (to word match at
  10205. * any point in the data), when false this will not be done.
  10206. * @namespace
  10207. * @extends DataTable.models.oSearch
  10208. *
  10209. * @dtopt Options
  10210. * @name DataTable.defaults.search
  10211. *
  10212. * @example
  10213. * $(document).ready( function() {
  10214. * $('#example').dataTable( {
  10215. * "search": {"search": "Initial search"}
  10216. * } );
  10217. * } )
  10218. */
  10219. "oSearch": $.extend( {}, DataTable.models.oSearch ),
  10220. /**
  10221. * __Deprecated__ The functionality provided by this parameter has now been
  10222. * superseded by that provided through `ajax`, which should be used instead.
  10223. *
  10224. * By default DataTables will look for the property `data` (or `aaData` for
  10225. * compatibility with DataTables 1.9-) when obtaining data from an Ajax
  10226. * source or for server-side processing - this parameter allows that
  10227. * property to be changed. You can use Javascript dotted object notation to
  10228. * get a data source for multiple levels of nesting.
  10229. * @type string
  10230. * @default data
  10231. *
  10232. * @dtopt Options
  10233. * @dtopt Server-side
  10234. * @name DataTable.defaults.ajaxDataProp
  10235. *
  10236. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10237. */
  10238. "sAjaxDataProp": "data",
  10239. /**
  10240. * __Deprecated__ The functionality provided by this parameter has now been
  10241. * superseded by that provided through `ajax`, which should be used instead.
  10242. *
  10243. * You can instruct DataTables to load data from an external
  10244. * source using this parameter (use aData if you want to pass data in you
  10245. * already have). Simply provide a url a JSON object can be obtained from.
  10246. * @type string
  10247. * @default null
  10248. *
  10249. * @dtopt Options
  10250. * @dtopt Server-side
  10251. * @name DataTable.defaults.ajaxSource
  10252. *
  10253. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10254. */
  10255. "sAjaxSource": null,
  10256. /**
  10257. * This initialisation variable allows you to specify exactly where in the
  10258. * DOM you want DataTables to inject the various controls it adds to the page
  10259. * (for example you might want the pagination controls at the top of the
  10260. * table). DIV elements (with or without a custom class) can also be added to
  10261. * aid styling. The follow syntax is used:
  10262. * <ul>
  10263. * <li>The following options are allowed:
  10264. * <ul>
  10265. * <li>'l' - Length changing</li>
  10266. * <li>'f' - Filtering input</li>
  10267. * <li>'t' - The table!</li>
  10268. * <li>'i' - Information</li>
  10269. * <li>'p' - Pagination</li>
  10270. * <li>'r' - pRocessing</li>
  10271. * </ul>
  10272. * </li>
  10273. * <li>The following constants are allowed:
  10274. * <ul>
  10275. * <li>'H' - jQueryUI theme "header" classes ('fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix')</li>
  10276. * <li>'F' - jQueryUI theme "footer" classes ('fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix')</li>
  10277. * </ul>
  10278. * </li>
  10279. * <li>The following syntax is expected:
  10280. * <ul>
  10281. * <li>'&lt;' and '&gt;' - div elements</li>
  10282. * <li>'&lt;"class" and '&gt;' - div with a class</li>
  10283. * <li>'&lt;"#id" and '&gt;' - div with an ID</li>
  10284. * </ul>
  10285. * </li>
  10286. * <li>Examples:
  10287. * <ul>
  10288. * <li>'&lt;"wrapper"flipt&gt;'</li>
  10289. * <li>'&lt;lf&lt;t&gt;ip&gt;'</li>
  10290. * </ul>
  10291. * </li>
  10292. * </ul>
  10293. * @type string
  10294. * @default lfrtip <i>(when `jQueryUI` is false)</i> <b>or</b>
  10295. * <"H"lfr>t<"F"ip> <i>(when `jQueryUI` is true)</i>
  10296. *
  10297. * @dtopt Options
  10298. * @name DataTable.defaults.dom
  10299. *
  10300. * @example
  10301. * $(document).ready( function() {
  10302. * $('#example').dataTable( {
  10303. * "dom": '&lt;"top"i&gt;rt&lt;"bottom"flp&gt;&lt;"clear"&gt;'
  10304. * } );
  10305. * } );
  10306. */
  10307. "sDom": "lfrtip",
  10308. /**
  10309. * Search delay option. This will throttle full table searches that use the
  10310. * DataTables provided search input element (it does not effect calls to
  10311. * `dt-api search()`, providing a delay before the search is made.
  10312. * @type integer
  10313. * @default 0
  10314. *
  10315. * @dtopt Options
  10316. * @name DataTable.defaults.searchDelay
  10317. *
  10318. * @example
  10319. * $(document).ready( function() {
  10320. * $('#example').dataTable( {
  10321. * "searchDelay": 200
  10322. * } );
  10323. * } )
  10324. */
  10325. "searchDelay": null,
  10326. /**
  10327. * DataTables features six different built-in options for the buttons to
  10328. * display for pagination control:
  10329. *
  10330. * * `numbers` - Page number buttons only
  10331. * * `simple` - 'Previous' and 'Next' buttons only
  10332. * * 'simple_numbers` - 'Previous' and 'Next' buttons, plus page numbers
  10333. * * `full` - 'First', 'Previous', 'Next' and 'Last' buttons
  10334. * * `full_numbers` - 'First', 'Previous', 'Next' and 'Last' buttons, plus page numbers
  10335. * * `first_last_numbers` - 'First' and 'Last' buttons, plus page numbers
  10336. *
  10337. * Further methods can be added using {@link DataTable.ext.oPagination}.
  10338. * @type string
  10339. * @default simple_numbers
  10340. *
  10341. * @dtopt Options
  10342. * @name DataTable.defaults.pagingType
  10343. *
  10344. * @example
  10345. * $(document).ready( function() {
  10346. * $('#example').dataTable( {
  10347. * "pagingType": "full_numbers"
  10348. * } );
  10349. * } )
  10350. */
  10351. "sPaginationType": "simple_numbers",
  10352. /**
  10353. * Enable horizontal scrolling. When a table is too wide to fit into a
  10354. * certain layout, or you have a large number of columns in the table, you
  10355. * can enable x-scrolling to show the table in a viewport, which can be
  10356. * scrolled. This property can be `true` which will allow the table to
  10357. * scroll horizontally when needed, or any CSS unit, or a number (in which
  10358. * case it will be treated as a pixel measurement). Setting as simply `true`
  10359. * is recommended.
  10360. * @type boolean|string
  10361. * @default <i>blank string - i.e. disabled</i>
  10362. *
  10363. * @dtopt Features
  10364. * @name DataTable.defaults.scrollX
  10365. *
  10366. * @example
  10367. * $(document).ready( function() {
  10368. * $('#example').dataTable( {
  10369. * "scrollX": true,
  10370. * "scrollCollapse": true
  10371. * } );
  10372. * } );
  10373. */
  10374. "sScrollX": "",
  10375. /**
  10376. * This property can be used to force a DataTable to use more width than it
  10377. * might otherwise do when x-scrolling is enabled. For example if you have a
  10378. * table which requires to be well spaced, this parameter is useful for
  10379. * "over-sizing" the table, and thus forcing scrolling. This property can by
  10380. * any CSS unit, or a number (in which case it will be treated as a pixel
  10381. * measurement).
  10382. * @type string
  10383. * @default <i>blank string - i.e. disabled</i>
  10384. *
  10385. * @dtopt Options
  10386. * @name DataTable.defaults.scrollXInner
  10387. *
  10388. * @example
  10389. * $(document).ready( function() {
  10390. * $('#example').dataTable( {
  10391. * "scrollX": "100%",
  10392. * "scrollXInner": "110%"
  10393. * } );
  10394. * } );
  10395. */
  10396. "sScrollXInner": "",
  10397. /**
  10398. * Enable vertical scrolling. Vertical scrolling will constrain the DataTable
  10399. * to the given height, and enable scrolling for any data which overflows the
  10400. * current viewport. This can be used as an alternative to paging to display
  10401. * a lot of data in a small area (although paging and scrolling can both be
  10402. * enabled at the same time). This property can be any CSS unit, or a number
  10403. * (in which case it will be treated as a pixel measurement).
  10404. * @type string
  10405. * @default <i>blank string - i.e. disabled</i>
  10406. *
  10407. * @dtopt Features
  10408. * @name DataTable.defaults.scrollY
  10409. *
  10410. * @example
  10411. * $(document).ready( function() {
  10412. * $('#example').dataTable( {
  10413. * "scrollY": "200px",
  10414. * "paginate": false
  10415. * } );
  10416. * } );
  10417. */
  10418. "sScrollY": "",
  10419. /**
  10420. * __Deprecated__ The functionality provided by this parameter has now been
  10421. * superseded by that provided through `ajax`, which should be used instead.
  10422. *
  10423. * Set the HTTP method that is used to make the Ajax call for server-side
  10424. * processing or Ajax sourced data.
  10425. * @type string
  10426. * @default GET
  10427. *
  10428. * @dtopt Options
  10429. * @dtopt Server-side
  10430. * @name DataTable.defaults.serverMethod
  10431. *
  10432. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10433. */
  10434. "sServerMethod": "GET",
  10435. /**
  10436. * DataTables makes use of renderers when displaying HTML elements for
  10437. * a table. These renderers can be added or modified by plug-ins to
  10438. * generate suitable mark-up for a site. For example the Bootstrap
  10439. * integration plug-in for DataTables uses a paging button renderer to
  10440. * display pagination buttons in the mark-up required by Bootstrap.
  10441. *
  10442. * For further information about the renderers available see
  10443. * DataTable.ext.renderer
  10444. * @type string|object
  10445. * @default null
  10446. *
  10447. * @name DataTable.defaults.renderer
  10448. *
  10449. */
  10450. "renderer": null,
  10451. /**
  10452. * Set the data property name that DataTables should use to get a row's id
  10453. * to set as the `id` property in the node.
  10454. * @type string
  10455. * @default DT_RowId
  10456. *
  10457. * @name DataTable.defaults.rowId
  10458. */
  10459. "rowId": "DT_RowId"
  10460. };
  10461. _fnHungarianMap( DataTable.defaults );
  10462. /*
  10463. * Developer note - See note in model.defaults.js about the use of Hungarian
  10464. * notation and camel case.
  10465. */
  10466. /**
  10467. * Column options that can be given to DataTables at initialisation time.
  10468. * @namespace
  10469. */
  10470. DataTable.defaults.column = {
  10471. /**
  10472. * Define which column(s) an order will occur on for this column. This
  10473. * allows a column's ordering to take multiple columns into account when
  10474. * doing a sort or use the data from a different column. For example first
  10475. * name / last name columns make sense to do a multi-column sort over the
  10476. * two columns.
  10477. * @type array|int
  10478. * @default null <i>Takes the value of the column index automatically</i>
  10479. *
  10480. * @name DataTable.defaults.column.orderData
  10481. * @dtopt Columns
  10482. *
  10483. * @example
  10484. * // Using `columnDefs`
  10485. * $(document).ready( function() {
  10486. * $('#example').dataTable( {
  10487. * "columnDefs": [
  10488. * { "orderData": [ 0, 1 ], "targets": [ 0 ] },
  10489. * { "orderData": [ 1, 0 ], "targets": [ 1 ] },
  10490. * { "orderData": 2, "targets": [ 2 ] }
  10491. * ]
  10492. * } );
  10493. * } );
  10494. *
  10495. * @example
  10496. * // Using `columns`
  10497. * $(document).ready( function() {
  10498. * $('#example').dataTable( {
  10499. * "columns": [
  10500. * { "orderData": [ 0, 1 ] },
  10501. * { "orderData": [ 1, 0 ] },
  10502. * { "orderData": 2 },
  10503. * null,
  10504. * null
  10505. * ]
  10506. * } );
  10507. * } );
  10508. */
  10509. "aDataSort": null,
  10510. "iDataSort": -1,
  10511. /**
  10512. * You can control the default ordering direction, and even alter the
  10513. * behaviour of the sort handler (i.e. only allow ascending ordering etc)
  10514. * using this parameter.
  10515. * @type array
  10516. * @default [ 'asc', 'desc' ]
  10517. *
  10518. * @name DataTable.defaults.column.orderSequence
  10519. * @dtopt Columns
  10520. *
  10521. * @example
  10522. * // Using `columnDefs`
  10523. * $(document).ready( function() {
  10524. * $('#example').dataTable( {
  10525. * "columnDefs": [
  10526. * { "orderSequence": [ "asc" ], "targets": [ 1 ] },
  10527. * { "orderSequence": [ "desc", "asc", "asc" ], "targets": [ 2 ] },
  10528. * { "orderSequence": [ "desc" ], "targets": [ 3 ] }
  10529. * ]
  10530. * } );
  10531. * } );
  10532. *
  10533. * @example
  10534. * // Using `columns`
  10535. * $(document).ready( function() {
  10536. * $('#example').dataTable( {
  10537. * "columns": [
  10538. * null,
  10539. * { "orderSequence": [ "asc" ] },
  10540. * { "orderSequence": [ "desc", "asc", "asc" ] },
  10541. * { "orderSequence": [ "desc" ] },
  10542. * null
  10543. * ]
  10544. * } );
  10545. * } );
  10546. */
  10547. "asSorting": [ 'asc', 'desc' ],
  10548. /**
  10549. * Enable or disable filtering on the data in this column.
  10550. * @type boolean
  10551. * @default true
  10552. *
  10553. * @name DataTable.defaults.column.searchable
  10554. * @dtopt Columns
  10555. *
  10556. * @example
  10557. * // Using `columnDefs`
  10558. * $(document).ready( function() {
  10559. * $('#example').dataTable( {
  10560. * "columnDefs": [
  10561. * { "searchable": false, "targets": [ 0 ] }
  10562. * ] } );
  10563. * } );
  10564. *
  10565. * @example
  10566. * // Using `columns`
  10567. * $(document).ready( function() {
  10568. * $('#example').dataTable( {
  10569. * "columns": [
  10570. * { "searchable": false },
  10571. * null,
  10572. * null,
  10573. * null,
  10574. * null
  10575. * ] } );
  10576. * } );
  10577. */
  10578. "bSearchable": true,
  10579. /**
  10580. * Enable or disable ordering on this column.
  10581. * @type boolean
  10582. * @default true
  10583. *
  10584. * @name DataTable.defaults.column.orderable
  10585. * @dtopt Columns
  10586. *
  10587. * @example
  10588. * // Using `columnDefs`
  10589. * $(document).ready( function() {
  10590. * $('#example').dataTable( {
  10591. * "columnDefs": [
  10592. * { "orderable": false, "targets": [ 0 ] }
  10593. * ] } );
  10594. * } );
  10595. *
  10596. * @example
  10597. * // Using `columns`
  10598. * $(document).ready( function() {
  10599. * $('#example').dataTable( {
  10600. * "columns": [
  10601. * { "orderable": false },
  10602. * null,
  10603. * null,
  10604. * null,
  10605. * null
  10606. * ] } );
  10607. * } );
  10608. */
  10609. "bSortable": true,
  10610. /**
  10611. * Enable or disable the display of this column.
  10612. * @type boolean
  10613. * @default true
  10614. *
  10615. * @name DataTable.defaults.column.visible
  10616. * @dtopt Columns
  10617. *
  10618. * @example
  10619. * // Using `columnDefs`
  10620. * $(document).ready( function() {
  10621. * $('#example').dataTable( {
  10622. * "columnDefs": [
  10623. * { "visible": false, "targets": [ 0 ] }
  10624. * ] } );
  10625. * } );
  10626. *
  10627. * @example
  10628. * // Using `columns`
  10629. * $(document).ready( function() {
  10630. * $('#example').dataTable( {
  10631. * "columns": [
  10632. * { "visible": false },
  10633. * null,
  10634. * null,
  10635. * null,
  10636. * null
  10637. * ] } );
  10638. * } );
  10639. */
  10640. "bVisible": true,
  10641. /**
  10642. * Developer definable function that is called whenever a cell is created (Ajax source,
  10643. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  10644. * allowing you to modify the DOM element (add background colour for example) when the
  10645. * element is available.
  10646. * @type function
  10647. * @param {element} td The TD node that has been created
  10648. * @param {*} cellData The Data for the cell
  10649. * @param {array|object} rowData The data for the whole row
  10650. * @param {int} row The row index for the aoData data store
  10651. * @param {int} col The column index for aoColumns
  10652. *
  10653. * @name DataTable.defaults.column.createdCell
  10654. * @dtopt Columns
  10655. *
  10656. * @example
  10657. * $(document).ready( function() {
  10658. * $('#example').dataTable( {
  10659. * "columnDefs": [ {
  10660. * "targets": [3],
  10661. * "createdCell": function (td, cellData, rowData, row, col) {
  10662. * if ( cellData == "1.7" ) {
  10663. * $(td).css('color', 'blue')
  10664. * }
  10665. * }
  10666. * } ]
  10667. * });
  10668. * } );
  10669. */
  10670. "fnCreatedCell": null,
  10671. /**
  10672. * This parameter has been replaced by `data` in DataTables to ensure naming
  10673. * consistency. `dataProp` can still be used, as there is backwards
  10674. * compatibility in DataTables for this option, but it is strongly
  10675. * recommended that you use `data` in preference to `dataProp`.
  10676. * @name DataTable.defaults.column.dataProp
  10677. */
  10678. /**
  10679. * This property can be used to read data from any data source property,
  10680. * including deeply nested objects / properties. `data` can be given in a
  10681. * number of different ways which effect its behaviour:
  10682. *
  10683. * * `integer` - treated as an array index for the data source. This is the
  10684. * default that DataTables uses (incrementally increased for each column).
  10685. * * `string` - read an object property from the data source. There are
  10686. * three 'special' options that can be used in the string to alter how
  10687. * DataTables reads the data from the source object:
  10688. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10689. * Javascript to read from nested objects, so to can the options
  10690. * specified in `data`. For example: `browser.version` or
  10691. * `browser.name`. If your object parameter name contains a period, use
  10692. * `\\` to escape it - i.e. `first\\.name`.
  10693. * * `[]` - Array notation. DataTables can automatically combine data
  10694. * from and array source, joining the data with the characters provided
  10695. * between the two brackets. For example: `name[, ]` would provide a
  10696. * comma-space separated list from the source array. If no characters
  10697. * are provided between the brackets, the original array source is
  10698. * returned.
  10699. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10700. * execute a function of the name given. For example: `browser()` for a
  10701. * simple function on the data source, `browser.version()` for a
  10702. * function in a nested property or even `browser().version` to get an
  10703. * object property if the function called returns an object. Note that
  10704. * function notation is recommended for use in `render` rather than
  10705. * `data` as it is much simpler to use as a renderer.
  10706. * * `null` - use the original data source for the row rather than plucking
  10707. * data directly from it. This action has effects on two other
  10708. * initialisation options:
  10709. * * `defaultContent` - When null is given as the `data` option and
  10710. * `defaultContent` is specified for the column, the value defined by
  10711. * `defaultContent` will be used for the cell.
  10712. * * `render` - When null is used for the `data` option and the `render`
  10713. * option is specified for the column, the whole data source for the
  10714. * row is used for the renderer.
  10715. * * `function` - the function given will be executed whenever DataTables
  10716. * needs to set or get the data for a cell in the column. The function
  10717. * takes three parameters:
  10718. * * Parameters:
  10719. * * `{array|object}` The data source for the row
  10720. * * `{string}` The type call data requested - this will be 'set' when
  10721. * setting data or 'filter', 'display', 'type', 'sort' or undefined
  10722. * when gathering data. Note that when `undefined` is given for the
  10723. * type DataTables expects to get the raw data for the object back<
  10724. * * `{*}` Data to set when the second parameter is 'set'.
  10725. * * Return:
  10726. * * The return value from the function is not required when 'set' is
  10727. * the type of call, but otherwise the return is what will be used
  10728. * for the data requested.
  10729. *
  10730. * Note that `data` is a getter and setter option. If you just require
  10731. * formatting of data for output, you will likely want to use `render` which
  10732. * is simply a getter and thus simpler to use.
  10733. *
  10734. * Note that prior to DataTables 1.9.2 `data` was called `mDataProp`. The
  10735. * name change reflects the flexibility of this property and is consistent
  10736. * with the naming of mRender. If 'mDataProp' is given, then it will still
  10737. * be used by DataTables, as it automatically maps the old name to the new
  10738. * if required.
  10739. *
  10740. * @type string|int|function|null
  10741. * @default null <i>Use automatically calculated column index</i>
  10742. *
  10743. * @name DataTable.defaults.column.data
  10744. * @dtopt Columns
  10745. *
  10746. * @example
  10747. * // Read table data from objects
  10748. * // JSON structure for each row:
  10749. * // {
  10750. * // "engine": {value},
  10751. * // "browser": {value},
  10752. * // "platform": {value},
  10753. * // "version": {value},
  10754. * // "grade": {value}
  10755. * // }
  10756. * $(document).ready( function() {
  10757. * $('#example').dataTable( {
  10758. * "ajaxSource": "sources/objects.txt",
  10759. * "columns": [
  10760. * { "data": "engine" },
  10761. * { "data": "browser" },
  10762. * { "data": "platform" },
  10763. * { "data": "version" },
  10764. * { "data": "grade" }
  10765. * ]
  10766. * } );
  10767. * } );
  10768. *
  10769. * @example
  10770. * // Read information from deeply nested objects
  10771. * // JSON structure for each row:
  10772. * // {
  10773. * // "engine": {value},
  10774. * // "browser": {value},
  10775. * // "platform": {
  10776. * // "inner": {value}
  10777. * // },
  10778. * // "details": [
  10779. * // {value}, {value}
  10780. * // ]
  10781. * // }
  10782. * $(document).ready( function() {
  10783. * $('#example').dataTable( {
  10784. * "ajaxSource": "sources/deep.txt",
  10785. * "columns": [
  10786. * { "data": "engine" },
  10787. * { "data": "browser" },
  10788. * { "data": "platform.inner" },
  10789. * { "data": "details.0" },
  10790. * { "data": "details.1" }
  10791. * ]
  10792. * } );
  10793. * } );
  10794. *
  10795. * @example
  10796. * // Using `data` as a function to provide different information for
  10797. * // sorting, filtering and display. In this case, currency (price)
  10798. * $(document).ready( function() {
  10799. * $('#example').dataTable( {
  10800. * "columnDefs": [ {
  10801. * "targets": [ 0 ],
  10802. * "data": function ( source, type, val ) {
  10803. * if (type === 'set') {
  10804. * source.price = val;
  10805. * // Store the computed dislay and filter values for efficiency
  10806. * source.price_display = val=="" ? "" : "$"+numberFormat(val);
  10807. * source.price_filter = val=="" ? "" : "$"+numberFormat(val)+" "+val;
  10808. * return;
  10809. * }
  10810. * else if (type === 'display') {
  10811. * return source.price_display;
  10812. * }
  10813. * else if (type === 'filter') {
  10814. * return source.price_filter;
  10815. * }
  10816. * // 'sort', 'type' and undefined all just use the integer
  10817. * return source.price;
  10818. * }
  10819. * } ]
  10820. * } );
  10821. * } );
  10822. *
  10823. * @example
  10824. * // Using default content
  10825. * $(document).ready( function() {
  10826. * $('#example').dataTable( {
  10827. * "columnDefs": [ {
  10828. * "targets": [ 0 ],
  10829. * "data": null,
  10830. * "defaultContent": "Click to edit"
  10831. * } ]
  10832. * } );
  10833. * } );
  10834. *
  10835. * @example
  10836. * // Using array notation - outputting a list from an array
  10837. * $(document).ready( function() {
  10838. * $('#example').dataTable( {
  10839. * "columnDefs": [ {
  10840. * "targets": [ 0 ],
  10841. * "data": "name[, ]"
  10842. * } ]
  10843. * } );
  10844. * } );
  10845. *
  10846. */
  10847. "mData": null,
  10848. /**
  10849. * This property is the rendering partner to `data` and it is suggested that
  10850. * when you want to manipulate data for display (including filtering,
  10851. * sorting etc) without altering the underlying data for the table, use this
  10852. * property. `render` can be considered to be the the read only companion to
  10853. * `data` which is read / write (then as such more complex). Like `data`
  10854. * this option can be given in a number of different ways to effect its
  10855. * behaviour:
  10856. *
  10857. * * `integer` - treated as an array index for the data source. This is the
  10858. * default that DataTables uses (incrementally increased for each column).
  10859. * * `string` - read an object property from the data source. There are
  10860. * three 'special' options that can be used in the string to alter how
  10861. * DataTables reads the data from the source object:
  10862. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10863. * Javascript to read from nested objects, so to can the options
  10864. * specified in `data`. For example: `browser.version` or
  10865. * `browser.name`. If your object parameter name contains a period, use
  10866. * `\\` to escape it - i.e. `first\\.name`.
  10867. * * `[]` - Array notation. DataTables can automatically combine data
  10868. * from and array source, joining the data with the characters provided
  10869. * between the two brackets. For example: `name[, ]` would provide a
  10870. * comma-space separated list from the source array. If no characters
  10871. * are provided between the brackets, the original array source is
  10872. * returned.
  10873. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10874. * execute a function of the name given. For example: `browser()` for a
  10875. * simple function on the data source, `browser.version()` for a
  10876. * function in a nested property or even `browser().version` to get an
  10877. * object property if the function called returns an object.
  10878. * * `object` - use different data for the different data types requested by
  10879. * DataTables ('filter', 'display', 'type' or 'sort'). The property names
  10880. * of the object is the data type the property refers to and the value can
  10881. * defined using an integer, string or function using the same rules as
  10882. * `render` normally does. Note that an `_` option _must_ be specified.
  10883. * This is the default value to use if you haven't specified a value for
  10884. * the data type requested by DataTables.
  10885. * * `function` - the function given will be executed whenever DataTables
  10886. * needs to set or get the data for a cell in the column. The function
  10887. * takes three parameters:
  10888. * * Parameters:
  10889. * * {array|object} The data source for the row (based on `data`)
  10890. * * {string} The type call data requested - this will be 'filter',
  10891. * 'display', 'type' or 'sort'.
  10892. * * {array|object} The full data source for the row (not based on
  10893. * `data`)
  10894. * * Return:
  10895. * * The return value from the function is what will be used for the
  10896. * data requested.
  10897. *
  10898. * @type string|int|function|object|null
  10899. * @default null Use the data source value.
  10900. *
  10901. * @name DataTable.defaults.column.render
  10902. * @dtopt Columns
  10903. *
  10904. * @example
  10905. * // Create a comma separated list from an array of objects
  10906. * $(document).ready( function() {
  10907. * $('#example').dataTable( {
  10908. * "ajaxSource": "sources/deep.txt",
  10909. * "columns": [
  10910. * { "data": "engine" },
  10911. * { "data": "browser" },
  10912. * {
  10913. * "data": "platform",
  10914. * "render": "[, ].name"
  10915. * }
  10916. * ]
  10917. * } );
  10918. * } );
  10919. *
  10920. * @example
  10921. * // Execute a function to obtain data
  10922. * $(document).ready( function() {
  10923. * $('#example').dataTable( {
  10924. * "columnDefs": [ {
  10925. * "targets": [ 0 ],
  10926. * "data": null, // Use the full data source object for the renderer's source
  10927. * "render": "browserName()"
  10928. * } ]
  10929. * } );
  10930. * } );
  10931. *
  10932. * @example
  10933. * // As an object, extracting different data for the different types
  10934. * // This would be used with a data source such as:
  10935. * // { "phone": 5552368, "phone_filter": "5552368 555-2368", "phone_display": "555-2368" }
  10936. * // Here the `phone` integer is used for sorting and type detection, while `phone_filter`
  10937. * // (which has both forms) is used for filtering for if a user inputs either format, while
  10938. * // the formatted phone number is the one that is shown in the table.
  10939. * $(document).ready( function() {
  10940. * $('#example').dataTable( {
  10941. * "columnDefs": [ {
  10942. * "targets": [ 0 ],
  10943. * "data": null, // Use the full data source object for the renderer's source
  10944. * "render": {
  10945. * "_": "phone",
  10946. * "filter": "phone_filter",
  10947. * "display": "phone_display"
  10948. * }
  10949. * } ]
  10950. * } );
  10951. * } );
  10952. *
  10953. * @example
  10954. * // Use as a function to create a link from the data source
  10955. * $(document).ready( function() {
  10956. * $('#example').dataTable( {
  10957. * "columnDefs": [ {
  10958. * "targets": [ 0 ],
  10959. * "data": "download_link",
  10960. * "render": function ( data, type, full ) {
  10961. * return '<a href="'+data+'">Download</a>';
  10962. * }
  10963. * } ]
  10964. * } );
  10965. * } );
  10966. */
  10967. "mRender": null,
  10968. /**
  10969. * Change the cell type created for the column - either TD cells or TH cells. This
  10970. * can be useful as TH cells have semantic meaning in the table body, allowing them
  10971. * to act as a header for a row (you may wish to add scope='row' to the TH elements).
  10972. * @type string
  10973. * @default td
  10974. *
  10975. * @name DataTable.defaults.column.cellType
  10976. * @dtopt Columns
  10977. *
  10978. * @example
  10979. * // Make the first column use TH cells
  10980. * $(document).ready( function() {
  10981. * $('#example').dataTable( {
  10982. * "columnDefs": [ {
  10983. * "targets": [ 0 ],
  10984. * "cellType": "th"
  10985. * } ]
  10986. * } );
  10987. * } );
  10988. */
  10989. "sCellType": "td",
  10990. /**
  10991. * Class to give to each cell in this column.
  10992. * @type string
  10993. * @default <i>Empty string</i>
  10994. *
  10995. * @name DataTable.defaults.column.class
  10996. * @dtopt Columns
  10997. *
  10998. * @example
  10999. * // Using `columnDefs`
  11000. * $(document).ready( function() {
  11001. * $('#example').dataTable( {
  11002. * "columnDefs": [
  11003. * { "class": "my_class", "targets": [ 0 ] }
  11004. * ]
  11005. * } );
  11006. * } );
  11007. *
  11008. * @example
  11009. * // Using `columns`
  11010. * $(document).ready( function() {
  11011. * $('#example').dataTable( {
  11012. * "columns": [
  11013. * { "class": "my_class" },
  11014. * null,
  11015. * null,
  11016. * null,
  11017. * null
  11018. * ]
  11019. * } );
  11020. * } );
  11021. */
  11022. "sClass": "",
  11023. /**
  11024. * When DataTables calculates the column widths to assign to each column,
  11025. * it finds the longest string in each column and then constructs a
  11026. * temporary table and reads the widths from that. The problem with this
  11027. * is that "mmm" is much wider then "iiii", but the latter is a longer
  11028. * string - thus the calculation can go wrong (doing it properly and putting
  11029. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  11030. * a "work around" we provide this option. It will append its value to the
  11031. * text that is found to be the longest string for the column - i.e. padding.
  11032. * Generally you shouldn't need this!
  11033. * @type string
  11034. * @default <i>Empty string<i>
  11035. *
  11036. * @name DataTable.defaults.column.contentPadding
  11037. * @dtopt Columns
  11038. *
  11039. * @example
  11040. * // Using `columns`
  11041. * $(document).ready( function() {
  11042. * $('#example').dataTable( {
  11043. * "columns": [
  11044. * null,
  11045. * null,
  11046. * null,
  11047. * {
  11048. * "contentPadding": "mmm"
  11049. * }
  11050. * ]
  11051. * } );
  11052. * } );
  11053. */
  11054. "sContentPadding": "",
  11055. /**
  11056. * Allows a default value to be given for a column's data, and will be used
  11057. * whenever a null data source is encountered (this can be because `data`
  11058. * is set to null, or because the data source itself is null).
  11059. * @type string
  11060. * @default null
  11061. *
  11062. * @name DataTable.defaults.column.defaultContent
  11063. * @dtopt Columns
  11064. *
  11065. * @example
  11066. * // Using `columnDefs`
  11067. * $(document).ready( function() {
  11068. * $('#example').dataTable( {
  11069. * "columnDefs": [
  11070. * {
  11071. * "data": null,
  11072. * "defaultContent": "Edit",
  11073. * "targets": [ -1 ]
  11074. * }
  11075. * ]
  11076. * } );
  11077. * } );
  11078. *
  11079. * @example
  11080. * // Using `columns`
  11081. * $(document).ready( function() {
  11082. * $('#example').dataTable( {
  11083. * "columns": [
  11084. * null,
  11085. * null,
  11086. * null,
  11087. * {
  11088. * "data": null,
  11089. * "defaultContent": "Edit"
  11090. * }
  11091. * ]
  11092. * } );
  11093. * } );
  11094. */
  11095. "sDefaultContent": null,
  11096. /**
  11097. * This parameter is only used in DataTables' server-side processing. It can
  11098. * be exceptionally useful to know what columns are being displayed on the
  11099. * client side, and to map these to database fields. When defined, the names
  11100. * also allow DataTables to reorder information from the server if it comes
  11101. * back in an unexpected order (i.e. if you switch your columns around on the
  11102. * client-side, your server-side code does not also need updating).
  11103. * @type string
  11104. * @default <i>Empty string</i>
  11105. *
  11106. * @name DataTable.defaults.column.name
  11107. * @dtopt Columns
  11108. *
  11109. * @example
  11110. * // Using `columnDefs`
  11111. * $(document).ready( function() {
  11112. * $('#example').dataTable( {
  11113. * "columnDefs": [
  11114. * { "name": "engine", "targets": [ 0 ] },
  11115. * { "name": "browser", "targets": [ 1 ] },
  11116. * { "name": "platform", "targets": [ 2 ] },
  11117. * { "name": "version", "targets": [ 3 ] },
  11118. * { "name": "grade", "targets": [ 4 ] }
  11119. * ]
  11120. * } );
  11121. * } );
  11122. *
  11123. * @example
  11124. * // Using `columns`
  11125. * $(document).ready( function() {
  11126. * $('#example').dataTable( {
  11127. * "columns": [
  11128. * { "name": "engine" },
  11129. * { "name": "browser" },
  11130. * { "name": "platform" },
  11131. * { "name": "version" },
  11132. * { "name": "grade" }
  11133. * ]
  11134. * } );
  11135. * } );
  11136. */
  11137. "sName": "",
  11138. /**
  11139. * Defines a data source type for the ordering which can be used to read
  11140. * real-time information from the table (updating the internally cached
  11141. * version) prior to ordering. This allows ordering to occur on user
  11142. * editable elements such as form inputs.
  11143. * @type string
  11144. * @default std
  11145. *
  11146. * @name DataTable.defaults.column.orderDataType
  11147. * @dtopt Columns
  11148. *
  11149. * @example
  11150. * // Using `columnDefs`
  11151. * $(document).ready( function() {
  11152. * $('#example').dataTable( {
  11153. * "columnDefs": [
  11154. * { "orderDataType": "dom-text", "targets": [ 2, 3 ] },
  11155. * { "type": "numeric", "targets": [ 3 ] },
  11156. * { "orderDataType": "dom-select", "targets": [ 4 ] },
  11157. * { "orderDataType": "dom-checkbox", "targets": [ 5 ] }
  11158. * ]
  11159. * } );
  11160. * } );
  11161. *
  11162. * @example
  11163. * // Using `columns`
  11164. * $(document).ready( function() {
  11165. * $('#example').dataTable( {
  11166. * "columns": [
  11167. * null,
  11168. * null,
  11169. * { "orderDataType": "dom-text" },
  11170. * { "orderDataType": "dom-text", "type": "numeric" },
  11171. * { "orderDataType": "dom-select" },
  11172. * { "orderDataType": "dom-checkbox" }
  11173. * ]
  11174. * } );
  11175. * } );
  11176. */
  11177. "sSortDataType": "std",
  11178. /**
  11179. * The title of this column.
  11180. * @type string
  11181. * @default null <i>Derived from the 'TH' value for this column in the
  11182. * original HTML table.</i>
  11183. *
  11184. * @name DataTable.defaults.column.title
  11185. * @dtopt Columns
  11186. *
  11187. * @example
  11188. * // Using `columnDefs`
  11189. * $(document).ready( function() {
  11190. * $('#example').dataTable( {
  11191. * "columnDefs": [
  11192. * { "title": "My column title", "targets": [ 0 ] }
  11193. * ]
  11194. * } );
  11195. * } );
  11196. *
  11197. * @example
  11198. * // Using `columns`
  11199. * $(document).ready( function() {
  11200. * $('#example').dataTable( {
  11201. * "columns": [
  11202. * { "title": "My column title" },
  11203. * null,
  11204. * null,
  11205. * null,
  11206. * null
  11207. * ]
  11208. * } );
  11209. * } );
  11210. */
  11211. "sTitle": null,
  11212. /**
  11213. * The type allows you to specify how the data for this column will be
  11214. * ordered. Four types (string, numeric, date and html (which will strip
  11215. * HTML tags before ordering)) are currently available. Note that only date
  11216. * formats understood by Javascript's Date() object will be accepted as type
  11217. * date. For example: "Mar 26, 2008 5:03 PM". May take the values: 'string',
  11218. * 'numeric', 'date' or 'html' (by default). Further types can be adding
  11219. * through plug-ins.
  11220. * @type string
  11221. * @default null <i>Auto-detected from raw data</i>
  11222. *
  11223. * @name DataTable.defaults.column.type
  11224. * @dtopt Columns
  11225. *
  11226. * @example
  11227. * // Using `columnDefs`
  11228. * $(document).ready( function() {
  11229. * $('#example').dataTable( {
  11230. * "columnDefs": [
  11231. * { "type": "html", "targets": [ 0 ] }
  11232. * ]
  11233. * } );
  11234. * } );
  11235. *
  11236. * @example
  11237. * // Using `columns`
  11238. * $(document).ready( function() {
  11239. * $('#example').dataTable( {
  11240. * "columns": [
  11241. * { "type": "html" },
  11242. * null,
  11243. * null,
  11244. * null,
  11245. * null
  11246. * ]
  11247. * } );
  11248. * } );
  11249. */
  11250. "sType": null,
  11251. /**
  11252. * Defining the width of the column, this parameter may take any CSS value
  11253. * (3em, 20px etc). DataTables applies 'smart' widths to columns which have not
  11254. * been given a specific width through this interface ensuring that the table
  11255. * remains readable.
  11256. * @type string
  11257. * @default null <i>Automatic</i>
  11258. *
  11259. * @name DataTable.defaults.column.width
  11260. * @dtopt Columns
  11261. *
  11262. * @example
  11263. * // Using `columnDefs`
  11264. * $(document).ready( function() {
  11265. * $('#example').dataTable( {
  11266. * "columnDefs": [
  11267. * { "width": "20%", "targets": [ 0 ] }
  11268. * ]
  11269. * } );
  11270. * } );
  11271. *
  11272. * @example
  11273. * // Using `columns`
  11274. * $(document).ready( function() {
  11275. * $('#example').dataTable( {
  11276. * "columns": [
  11277. * { "width": "20%" },
  11278. * null,
  11279. * null,
  11280. * null,
  11281. * null
  11282. * ]
  11283. * } );
  11284. * } );
  11285. */
  11286. "sWidth": null
  11287. };
  11288. _fnHungarianMap( DataTable.defaults.column );
  11289. /**
  11290. * DataTables settings object - this holds all the information needed for a
  11291. * given table, including configuration, data and current application of the
  11292. * table options. DataTables does not have a single instance for each DataTable
  11293. * with the settings attached to that instance, but rather instances of the
  11294. * DataTable "class" are created on-the-fly as needed (typically by a
  11295. * $().dataTable() call) and the settings object is then applied to that
  11296. * instance.
  11297. *
  11298. * Note that this object is related to {@link DataTable.defaults} but this
  11299. * one is the internal data store for DataTables's cache of columns. It should
  11300. * NOT be manipulated outside of DataTables. Any configuration should be done
  11301. * through the initialisation options.
  11302. * @namespace
  11303. * @todo Really should attach the settings object to individual instances so we
  11304. * don't need to create new instances on each $().dataTable() call (if the
  11305. * table already exists). It would also save passing oSettings around and
  11306. * into every single function. However, this is a very significant
  11307. * architecture change for DataTables and will almost certainly break
  11308. * backwards compatibility with older installations. This is something that
  11309. * will be done in 2.0.
  11310. */
  11311. DataTable.models.oSettings = {
  11312. /**
  11313. * Primary features of DataTables and their enablement state.
  11314. * @namespace
  11315. */
  11316. "oFeatures": {
  11317. /**
  11318. * Flag to say if DataTables should automatically try to calculate the
  11319. * optimum table and columns widths (true) or not (false).
  11320. * Note that this parameter will be set by the initialisation routine. To
  11321. * set a default use {@link DataTable.defaults}.
  11322. * @type boolean
  11323. */
  11324. "bAutoWidth": null,
  11325. /**
  11326. * Delay the creation of TR and TD elements until they are actually
  11327. * needed by a driven page draw. This can give a significant speed
  11328. * increase for Ajax source and Javascript source data, but makes no
  11329. * difference at all fro DOM and server-side processing tables.
  11330. * Note that this parameter will be set by the initialisation routine. To
  11331. * set a default use {@link DataTable.defaults}.
  11332. * @type boolean
  11333. */
  11334. "bDeferRender": null,
  11335. /**
  11336. * Enable filtering on the table or not. Note that if this is disabled
  11337. * then there is no filtering at all on the table, including fnFilter.
  11338. * To just remove the filtering input use sDom and remove the 'f' option.
  11339. * Note that this parameter will be set by the initialisation routine. To
  11340. * set a default use {@link DataTable.defaults}.
  11341. * @type boolean
  11342. */
  11343. "bFilter": null,
  11344. /**
  11345. * Table information element (the 'Showing x of y records' div) enable
  11346. * flag.
  11347. * Note that this parameter will be set by the initialisation routine. To
  11348. * set a default use {@link DataTable.defaults}.
  11349. * @type boolean
  11350. */
  11351. "bInfo": null,
  11352. /**
  11353. * Present a user control allowing the end user to change the page size
  11354. * when pagination is enabled.
  11355. * Note that this parameter will be set by the initialisation routine. To
  11356. * set a default use {@link DataTable.defaults}.
  11357. * @type boolean
  11358. */
  11359. "bLengthChange": null,
  11360. /**
  11361. * Pagination enabled or not. Note that if this is disabled then length
  11362. * changing must also be disabled.
  11363. * Note that this parameter will be set by the initialisation routine. To
  11364. * set a default use {@link DataTable.defaults}.
  11365. * @type boolean
  11366. */
  11367. "bPaginate": null,
  11368. /**
  11369. * Processing indicator enable flag whenever DataTables is enacting a
  11370. * user request - typically an Ajax request for server-side processing.
  11371. * Note that this parameter will be set by the initialisation routine. To
  11372. * set a default use {@link DataTable.defaults}.
  11373. * @type boolean
  11374. */
  11375. "bProcessing": null,
  11376. /**
  11377. * Server-side processing enabled flag - when enabled DataTables will
  11378. * get all data from the server for every draw - there is no filtering,
  11379. * sorting or paging done on the client-side.
  11380. * Note that this parameter will be set by the initialisation routine. To
  11381. * set a default use {@link DataTable.defaults}.
  11382. * @type boolean
  11383. */
  11384. "bServerSide": null,
  11385. /**
  11386. * Sorting enablement flag.
  11387. * Note that this parameter will be set by the initialisation routine. To
  11388. * set a default use {@link DataTable.defaults}.
  11389. * @type boolean
  11390. */
  11391. "bSort": null,
  11392. /**
  11393. * Multi-column sorting
  11394. * Note that this parameter will be set by the initialisation routine. To
  11395. * set a default use {@link DataTable.defaults}.
  11396. * @type boolean
  11397. */
  11398. "bSortMulti": null,
  11399. /**
  11400. * Apply a class to the columns which are being sorted to provide a
  11401. * visual highlight or not. This can slow things down when enabled since
  11402. * there is a lot of DOM interaction.
  11403. * Note that this parameter will be set by the initialisation routine. To
  11404. * set a default use {@link DataTable.defaults}.
  11405. * @type boolean
  11406. */
  11407. "bSortClasses": null,
  11408. /**
  11409. * State saving enablement flag.
  11410. * Note that this parameter will be set by the initialisation routine. To
  11411. * set a default use {@link DataTable.defaults}.
  11412. * @type boolean
  11413. */
  11414. "bStateSave": null
  11415. },
  11416. /**
  11417. * Scrolling settings for a table.
  11418. * @namespace
  11419. */
  11420. "oScroll": {
  11421. /**
  11422. * When the table is shorter in height than sScrollY, collapse the
  11423. * table container down to the height of the table (when true).
  11424. * Note that this parameter will be set by the initialisation routine. To
  11425. * set a default use {@link DataTable.defaults}.
  11426. * @type boolean
  11427. */
  11428. "bCollapse": null,
  11429. /**
  11430. * Width of the scrollbar for the web-browser's platform. Calculated
  11431. * during table initialisation.
  11432. * @type int
  11433. * @default 0
  11434. */
  11435. "iBarWidth": 0,
  11436. /**
  11437. * Viewport width for horizontal scrolling. Horizontal scrolling is
  11438. * disabled if an empty string.
  11439. * Note that this parameter will be set by the initialisation routine. To
  11440. * set a default use {@link DataTable.defaults}.
  11441. * @type string
  11442. */
  11443. "sX": null,
  11444. /**
  11445. * Width to expand the table to when using x-scrolling. Typically you
  11446. * should not need to use this.
  11447. * Note that this parameter will be set by the initialisation routine. To
  11448. * set a default use {@link DataTable.defaults}.
  11449. * @type string
  11450. * @deprecated
  11451. */
  11452. "sXInner": null,
  11453. /**
  11454. * Viewport height for vertical scrolling. Vertical scrolling is disabled
  11455. * if an empty string.
  11456. * Note that this parameter will be set by the initialisation routine. To
  11457. * set a default use {@link DataTable.defaults}.
  11458. * @type string
  11459. */
  11460. "sY": null
  11461. },
  11462. /**
  11463. * Language information for the table.
  11464. * @namespace
  11465. * @extends DataTable.defaults.oLanguage
  11466. */
  11467. "oLanguage": {
  11468. /**
  11469. * Information callback function. See
  11470. * {@link DataTable.defaults.fnInfoCallback}
  11471. * @type function
  11472. * @default null
  11473. */
  11474. "fnInfoCallback": null
  11475. },
  11476. /**
  11477. * Browser support parameters
  11478. * @namespace
  11479. */
  11480. "oBrowser": {
  11481. /**
  11482. * Indicate if the browser incorrectly calculates width:100% inside a
  11483. * scrolling element (IE6/7)
  11484. * @type boolean
  11485. * @default false
  11486. */
  11487. "bScrollOversize": false,
  11488. /**
  11489. * Determine if the vertical scrollbar is on the right or left of the
  11490. * scrolling container - needed for rtl language layout, although not
  11491. * all browsers move the scrollbar (Safari).
  11492. * @type boolean
  11493. * @default false
  11494. */
  11495. "bScrollbarLeft": false,
  11496. /**
  11497. * Flag for if `getBoundingClientRect` is fully supported or not
  11498. * @type boolean
  11499. * @default false
  11500. */
  11501. "bBounding": false,
  11502. /**
  11503. * Browser scrollbar width
  11504. * @type integer
  11505. * @default 0
  11506. */
  11507. "barWidth": 0
  11508. },
  11509. "ajax": null,
  11510. /**
  11511. * Array referencing the nodes which are used for the features. The
  11512. * parameters of this object match what is allowed by sDom - i.e.
  11513. * <ul>
  11514. * <li>'l' - Length changing</li>
  11515. * <li>'f' - Filtering input</li>
  11516. * <li>'t' - The table!</li>
  11517. * <li>'i' - Information</li>
  11518. * <li>'p' - Pagination</li>
  11519. * <li>'r' - pRocessing</li>
  11520. * </ul>
  11521. * @type array
  11522. * @default []
  11523. */
  11524. "aanFeatures": [],
  11525. /**
  11526. * Store data information - see {@link DataTable.models.oRow} for detailed
  11527. * information.
  11528. * @type array
  11529. * @default []
  11530. */
  11531. "aoData": [],
  11532. /**
  11533. * Array of indexes which are in the current display (after filtering etc)
  11534. * @type array
  11535. * @default []
  11536. */
  11537. "aiDisplay": [],
  11538. /**
  11539. * Array of indexes for display - no filtering
  11540. * @type array
  11541. * @default []
  11542. */
  11543. "aiDisplayMaster": [],
  11544. /**
  11545. * Map of row ids to data indexes
  11546. * @type object
  11547. * @default {}
  11548. */
  11549. "aIds": {},
  11550. /**
  11551. * Store information about each column that is in use
  11552. * @type array
  11553. * @default []
  11554. */
  11555. "aoColumns": [],
  11556. /**
  11557. * Store information about the table's header
  11558. * @type array
  11559. * @default []
  11560. */
  11561. "aoHeader": [],
  11562. /**
  11563. * Store information about the table's footer
  11564. * @type array
  11565. * @default []
  11566. */
  11567. "aoFooter": [],
  11568. /**
  11569. * Store the applied global search information in case we want to force a
  11570. * research or compare the old search to a new one.
  11571. * Note that this parameter will be set by the initialisation routine. To
  11572. * set a default use {@link DataTable.defaults}.
  11573. * @namespace
  11574. * @extends DataTable.models.oSearch
  11575. */
  11576. "oPreviousSearch": {},
  11577. /**
  11578. * Store the applied search for each column - see
  11579. * {@link DataTable.models.oSearch} for the format that is used for the
  11580. * filtering information for each column.
  11581. * @type array
  11582. * @default []
  11583. */
  11584. "aoPreSearchCols": [],
  11585. /**
  11586. * Sorting that is applied to the table. Note that the inner arrays are
  11587. * used in the following manner:
  11588. * <ul>
  11589. * <li>Index 0 - column number</li>
  11590. * <li>Index 1 - current sorting direction</li>
  11591. * </ul>
  11592. * Note that this parameter will be set by the initialisation routine. To
  11593. * set a default use {@link DataTable.defaults}.
  11594. * @type array
  11595. * @todo These inner arrays should really be objects
  11596. */
  11597. "aaSorting": null,
  11598. /**
  11599. * Sorting that is always applied to the table (i.e. prefixed in front of
  11600. * aaSorting).
  11601. * Note that this parameter will be set by the initialisation routine. To
  11602. * set a default use {@link DataTable.defaults}.
  11603. * @type array
  11604. * @default []
  11605. */
  11606. "aaSortingFixed": [],
  11607. /**
  11608. * Classes to use for the striping of a table.
  11609. * Note that this parameter will be set by the initialisation routine. To
  11610. * set a default use {@link DataTable.defaults}.
  11611. * @type array
  11612. * @default []
  11613. */
  11614. "asStripeClasses": null,
  11615. /**
  11616. * If restoring a table - we should restore its striping classes as well
  11617. * @type array
  11618. * @default []
  11619. */
  11620. "asDestroyStripes": [],
  11621. /**
  11622. * If restoring a table - we should restore its width
  11623. * @type int
  11624. * @default 0
  11625. */
  11626. "sDestroyWidth": 0,
  11627. /**
  11628. * Callback functions array for every time a row is inserted (i.e. on a draw).
  11629. * @type array
  11630. * @default []
  11631. */
  11632. "aoRowCallback": [],
  11633. /**
  11634. * Callback functions for the header on each draw.
  11635. * @type array
  11636. * @default []
  11637. */
  11638. "aoHeaderCallback": [],
  11639. /**
  11640. * Callback function for the footer on each draw.
  11641. * @type array
  11642. * @default []
  11643. */
  11644. "aoFooterCallback": [],
  11645. /**
  11646. * Array of callback functions for draw callback functions
  11647. * @type array
  11648. * @default []
  11649. */
  11650. "aoDrawCallback": [],
  11651. /**
  11652. * Array of callback functions for row created function
  11653. * @type array
  11654. * @default []
  11655. */
  11656. "aoRowCreatedCallback": [],
  11657. /**
  11658. * Callback functions for just before the table is redrawn. A return of
  11659. * false will be used to cancel the draw.
  11660. * @type array
  11661. * @default []
  11662. */
  11663. "aoPreDrawCallback": [],
  11664. /**
  11665. * Callback functions for when the table has been initialised.
  11666. * @type array
  11667. * @default []
  11668. */
  11669. "aoInitComplete": [],
  11670. /**
  11671. * Callbacks for modifying the settings to be stored for state saving, prior to
  11672. * saving state.
  11673. * @type array
  11674. * @default []
  11675. */
  11676. "aoStateSaveParams": [],
  11677. /**
  11678. * Callbacks for modifying the settings that have been stored for state saving
  11679. * prior to using the stored values to restore the state.
  11680. * @type array
  11681. * @default []
  11682. */
  11683. "aoStateLoadParams": [],
  11684. /**
  11685. * Callbacks for operating on the settings object once the saved state has been
  11686. * loaded
  11687. * @type array
  11688. * @default []
  11689. */
  11690. "aoStateLoaded": [],
  11691. /**
  11692. * Cache the table ID for quick access
  11693. * @type string
  11694. * @default <i>Empty string</i>
  11695. */
  11696. "sTableId": "",
  11697. /**
  11698. * The TABLE node for the main table
  11699. * @type node
  11700. * @default null
  11701. */
  11702. "nTable": null,
  11703. /**
  11704. * Permanent ref to the thead element
  11705. * @type node
  11706. * @default null
  11707. */
  11708. "nTHead": null,
  11709. /**
  11710. * Permanent ref to the tfoot element - if it exists
  11711. * @type node
  11712. * @default null
  11713. */
  11714. "nTFoot": null,
  11715. /**
  11716. * Permanent ref to the tbody element
  11717. * @type node
  11718. * @default null
  11719. */
  11720. "nTBody": null,
  11721. /**
  11722. * Cache the wrapper node (contains all DataTables controlled elements)
  11723. * @type node
  11724. * @default null
  11725. */
  11726. "nTableWrapper": null,
  11727. /**
  11728. * Indicate if when using server-side processing the loading of data
  11729. * should be deferred until the second draw.
  11730. * Note that this parameter will be set by the initialisation routine. To
  11731. * set a default use {@link DataTable.defaults}.
  11732. * @type boolean
  11733. * @default false
  11734. */
  11735. "bDeferLoading": false,
  11736. /**
  11737. * Indicate if all required information has been read in
  11738. * @type boolean
  11739. * @default false
  11740. */
  11741. "bInitialised": false,
  11742. /**
  11743. * Information about open rows. Each object in the array has the parameters
  11744. * 'nTr' and 'nParent'
  11745. * @type array
  11746. * @default []
  11747. */
  11748. "aoOpenRows": [],
  11749. /**
  11750. * Dictate the positioning of DataTables' control elements - see
  11751. * {@link DataTable.model.oInit.sDom}.
  11752. * Note that this parameter will be set by the initialisation routine. To
  11753. * set a default use {@link DataTable.defaults}.
  11754. * @type string
  11755. * @default null
  11756. */
  11757. "sDom": null,
  11758. /**
  11759. * Search delay (in mS)
  11760. * @type integer
  11761. * @default null
  11762. */
  11763. "searchDelay": null,
  11764. /**
  11765. * Which type of pagination should be used.
  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. * @default two_button
  11770. */
  11771. "sPaginationType": "two_button",
  11772. /**
  11773. * The state duration (for `stateSave`) in seconds.
  11774. * Note that this parameter will be set by the initialisation routine. To
  11775. * set a default use {@link DataTable.defaults}.
  11776. * @type int
  11777. * @default 0
  11778. */
  11779. "iStateDuration": 0,
  11780. /**
  11781. * Array of callback functions for state saving. Each array element is an
  11782. * object with the following parameters:
  11783. * <ul>
  11784. * <li>function:fn - function to call. Takes two parameters, oSettings
  11785. * and the JSON string to save that has been thus far created. Returns
  11786. * a JSON string to be inserted into a json object
  11787. * (i.e. '"param": [ 0, 1, 2]')</li>
  11788. * <li>string:sName - name of callback</li>
  11789. * </ul>
  11790. * @type array
  11791. * @default []
  11792. */
  11793. "aoStateSave": [],
  11794. /**
  11795. * Array of callback functions for state loading. Each array element is an
  11796. * object with the following parameters:
  11797. * <ul>
  11798. * <li>function:fn - function to call. Takes two parameters, oSettings
  11799. * and the object stored. May return false to cancel state loading</li>
  11800. * <li>string:sName - name of callback</li>
  11801. * </ul>
  11802. * @type array
  11803. * @default []
  11804. */
  11805. "aoStateLoad": [],
  11806. /**
  11807. * State that was saved. Useful for back reference
  11808. * @type object
  11809. * @default null
  11810. */
  11811. "oSavedState": null,
  11812. /**
  11813. * State that was loaded. Useful for back reference
  11814. * @type object
  11815. * @default null
  11816. */
  11817. "oLoadedState": null,
  11818. /**
  11819. * Source url for AJAX data for the table.
  11820. * Note that this parameter will be set by the initialisation routine. To
  11821. * set a default use {@link DataTable.defaults}.
  11822. * @type string
  11823. * @default null
  11824. */
  11825. "sAjaxSource": null,
  11826. /**
  11827. * Property from a given object from which to read the table data from. This
  11828. * can be an empty string (when not server-side processing), in which case
  11829. * it is assumed an an array is given directly.
  11830. * Note that this parameter will be set by the initialisation routine. To
  11831. * set a default use {@link DataTable.defaults}.
  11832. * @type string
  11833. */
  11834. "sAjaxDataProp": null,
  11835. /**
  11836. * Note if draw should be blocked while getting data
  11837. * @type boolean
  11838. * @default true
  11839. */
  11840. "bAjaxDataGet": true,
  11841. /**
  11842. * The last jQuery XHR object that was used for server-side data gathering.
  11843. * This can be used for working with the XHR information in one of the
  11844. * callbacks
  11845. * @type object
  11846. * @default null
  11847. */
  11848. "jqXHR": null,
  11849. /**
  11850. * JSON returned from the server in the last Ajax request
  11851. * @type object
  11852. * @default undefined
  11853. */
  11854. "json": undefined,
  11855. /**
  11856. * Data submitted as part of the last Ajax request
  11857. * @type object
  11858. * @default undefined
  11859. */
  11860. "oAjaxData": undefined,
  11861. /**
  11862. * Function to get the server-side data.
  11863. * Note that this parameter will be set by the initialisation routine. To
  11864. * set a default use {@link DataTable.defaults}.
  11865. * @type function
  11866. */
  11867. "fnServerData": null,
  11868. /**
  11869. * Functions which are called prior to sending an Ajax request so extra
  11870. * parameters can easily be sent to the server
  11871. * @type array
  11872. * @default []
  11873. */
  11874. "aoServerParams": [],
  11875. /**
  11876. * Send the XHR HTTP method - GET or POST (could be PUT or DELETE if
  11877. * required).
  11878. * Note that this parameter will be set by the initialisation routine. To
  11879. * set a default use {@link DataTable.defaults}.
  11880. * @type string
  11881. */
  11882. "sServerMethod": null,
  11883. /**
  11884. * Format numbers for display.
  11885. * Note that this parameter will be set by the initialisation routine. To
  11886. * set a default use {@link DataTable.defaults}.
  11887. * @type function
  11888. */
  11889. "fnFormatNumber": null,
  11890. /**
  11891. * List of options that can be used for the user selectable length menu.
  11892. * Note that this parameter will be set by the initialisation routine. To
  11893. * set a default use {@link DataTable.defaults}.
  11894. * @type array
  11895. * @default []
  11896. */
  11897. "aLengthMenu": null,
  11898. /**
  11899. * Counter for the draws that the table does. Also used as a tracker for
  11900. * server-side processing
  11901. * @type int
  11902. * @default 0
  11903. */
  11904. "iDraw": 0,
  11905. /**
  11906. * Indicate if a redraw is being done - useful for Ajax
  11907. * @type boolean
  11908. * @default false
  11909. */
  11910. "bDrawing": false,
  11911. /**
  11912. * Draw index (iDraw) of the last error when parsing the returned data
  11913. * @type int
  11914. * @default -1
  11915. */
  11916. "iDrawError": -1,
  11917. /**
  11918. * Paging display length
  11919. * @type int
  11920. * @default 10
  11921. */
  11922. "_iDisplayLength": 10,
  11923. /**
  11924. * Paging start point - aiDisplay index
  11925. * @type int
  11926. * @default 0
  11927. */
  11928. "_iDisplayStart": 0,
  11929. /**
  11930. * Server-side processing - number of records in the result set
  11931. * (i.e. before filtering), Use fnRecordsTotal rather than
  11932. * this property to get the value of the number of records, regardless of
  11933. * the server-side processing setting.
  11934. * @type int
  11935. * @default 0
  11936. * @private
  11937. */
  11938. "_iRecordsTotal": 0,
  11939. /**
  11940. * Server-side processing - number of records in the current display set
  11941. * (i.e. after filtering). Use fnRecordsDisplay rather than
  11942. * this property to get the value of the number of records, regardless of
  11943. * the server-side processing setting.
  11944. * @type boolean
  11945. * @default 0
  11946. * @private
  11947. */
  11948. "_iRecordsDisplay": 0,
  11949. /**
  11950. * The classes to use for the table
  11951. * @type object
  11952. * @default {}
  11953. */
  11954. "oClasses": {},
  11955. /**
  11956. * Flag attached to the settings object so you can check in the draw
  11957. * callback if filtering has been done in the draw. Deprecated in favour of
  11958. * events.
  11959. * @type boolean
  11960. * @default false
  11961. * @deprecated
  11962. */
  11963. "bFiltered": false,
  11964. /**
  11965. * Flag attached to the settings object so you can check in the draw
  11966. * callback if sorting has been done in the draw. Deprecated in favour of
  11967. * events.
  11968. * @type boolean
  11969. * @default false
  11970. * @deprecated
  11971. */
  11972. "bSorted": false,
  11973. /**
  11974. * Indicate that if multiple rows are in the header and there is more than
  11975. * one unique cell per column, if the top one (true) or bottom one (false)
  11976. * should be used for sorting / title by DataTables.
  11977. * Note that this parameter will be set by the initialisation routine. To
  11978. * set a default use {@link DataTable.defaults}.
  11979. * @type boolean
  11980. */
  11981. "bSortCellsTop": null,
  11982. /**
  11983. * Initialisation object that is used for the table
  11984. * @type object
  11985. * @default null
  11986. */
  11987. "oInit": null,
  11988. /**
  11989. * Destroy callback functions - for plug-ins to attach themselves to the
  11990. * destroy so they can clean up markup and events.
  11991. * @type array
  11992. * @default []
  11993. */
  11994. "aoDestroyCallback": [],
  11995. /**
  11996. * Get the number of records in the current record set, before filtering
  11997. * @type function
  11998. */
  11999. "fnRecordsTotal": function ()
  12000. {
  12001. return _fnDataSource( this ) == 'ssp' ?
  12002. this._iRecordsTotal * 1 :
  12003. this.aiDisplayMaster.length;
  12004. },
  12005. /**
  12006. * Get the number of records in the current record set, after filtering
  12007. * @type function
  12008. */
  12009. "fnRecordsDisplay": function ()
  12010. {
  12011. return _fnDataSource( this ) == 'ssp' ?
  12012. this._iRecordsDisplay * 1 :
  12013. this.aiDisplay.length;
  12014. },
  12015. /**
  12016. * Get the display end point - aiDisplay index
  12017. * @type function
  12018. */
  12019. "fnDisplayEnd": function ()
  12020. {
  12021. var
  12022. len = this._iDisplayLength,
  12023. start = this._iDisplayStart,
  12024. calc = start + len,
  12025. records = this.aiDisplay.length,
  12026. features = this.oFeatures,
  12027. paginate = features.bPaginate;
  12028. if ( features.bServerSide ) {
  12029. return paginate === false || len === -1 ?
  12030. start + records :
  12031. Math.min( start+len, this._iRecordsDisplay );
  12032. }
  12033. else {
  12034. return ! paginate || calc>records || len===-1 ?
  12035. records :
  12036. calc;
  12037. }
  12038. },
  12039. /**
  12040. * The DataTables object for this table
  12041. * @type object
  12042. * @default null
  12043. */
  12044. "oInstance": null,
  12045. /**
  12046. * Unique identifier for each instance of the DataTables object. If there
  12047. * is an ID on the table node, then it takes that value, otherwise an
  12048. * incrementing internal counter is used.
  12049. * @type string
  12050. * @default null
  12051. */
  12052. "sInstance": null,
  12053. /**
  12054. * tabindex attribute value that is added to DataTables control elements, allowing
  12055. * keyboard navigation of the table and its controls.
  12056. */
  12057. "iTabIndex": 0,
  12058. /**
  12059. * DIV container for the footer scrolling table if scrolling
  12060. */
  12061. "nScrollHead": null,
  12062. /**
  12063. * DIV container for the footer scrolling table if scrolling
  12064. */
  12065. "nScrollFoot": null,
  12066. /**
  12067. * Last applied sort
  12068. * @type array
  12069. * @default []
  12070. */
  12071. "aLastSort": [],
  12072. /**
  12073. * Stored plug-in instances
  12074. * @type object
  12075. * @default {}
  12076. */
  12077. "oPlugins": {},
  12078. /**
  12079. * Function used to get a row's id from the row's data
  12080. * @type function
  12081. * @default null
  12082. */
  12083. "rowIdFn": null,
  12084. /**
  12085. * Data location where to store a row's id
  12086. * @type string
  12087. * @default null
  12088. */
  12089. "rowId": null
  12090. };
  12091. /**
  12092. * Extension object for DataTables that is used to provide all extension
  12093. * options.
  12094. *
  12095. * Note that the `DataTable.ext` object is available through
  12096. * `jQuery.fn.dataTable.ext` where it may be accessed and manipulated. It is
  12097. * also aliased to `jQuery.fn.dataTableExt` for historic reasons.
  12098. * @namespace
  12099. * @extends DataTable.models.ext
  12100. */
  12101. /**
  12102. * DataTables extensions
  12103. *
  12104. * This namespace acts as a collection area for plug-ins that can be used to
  12105. * extend DataTables capabilities. Indeed many of the build in methods
  12106. * use this method to provide their own capabilities (sorting methods for
  12107. * example).
  12108. *
  12109. * Note that this namespace is aliased to `jQuery.fn.dataTableExt` for legacy
  12110. * reasons
  12111. *
  12112. * @namespace
  12113. */
  12114. DataTable.ext = _ext = {
  12115. /**
  12116. * Buttons. For use with the Buttons extension for DataTables. This is
  12117. * defined here so other extensions can define buttons regardless of load
  12118. * order. It is _not_ used by DataTables core.
  12119. *
  12120. * @type object
  12121. * @default {}
  12122. */
  12123. buttons: {},
  12124. /**
  12125. * Element class names
  12126. *
  12127. * @type object
  12128. * @default {}
  12129. */
  12130. classes: {},
  12131. /**
  12132. * DataTables build type (expanded by the download builder)
  12133. *
  12134. * @type string
  12135. */
  12136. builder: "-source-",
  12137. /**
  12138. * Error reporting.
  12139. *
  12140. * How should DataTables report an error. Can take the value 'alert',
  12141. * 'throw', 'none' or a function.
  12142. *
  12143. * @type string|function
  12144. * @default alert
  12145. */
  12146. errMode: "alert",
  12147. /**
  12148. * Feature plug-ins.
  12149. *
  12150. * This is an array of objects which describe the feature plug-ins that are
  12151. * available to DataTables. These feature plug-ins are then available for
  12152. * use through the `dom` initialisation option.
  12153. *
  12154. * Each feature plug-in is described by an object which must have the
  12155. * following properties:
  12156. *
  12157. * * `fnInit` - function that is used to initialise the plug-in,
  12158. * * `cFeature` - a character so the feature can be enabled by the `dom`
  12159. * instillation option. This is case sensitive.
  12160. *
  12161. * The `fnInit` function has the following input parameters:
  12162. *
  12163. * 1. `{object}` DataTables settings object: see
  12164. * {@link DataTable.models.oSettings}
  12165. *
  12166. * And the following return is expected:
  12167. *
  12168. * * {node|null} The element which contains your feature. Note that the
  12169. * return may also be void if your plug-in does not require to inject any
  12170. * DOM elements into DataTables control (`dom`) - for example this might
  12171. * be useful when developing a plug-in which allows table control via
  12172. * keyboard entry
  12173. *
  12174. * @type array
  12175. *
  12176. * @example
  12177. * $.fn.dataTable.ext.features.push( {
  12178. * "fnInit": function( oSettings ) {
  12179. * return new TableTools( { "oDTSettings": oSettings } );
  12180. * },
  12181. * "cFeature": "T"
  12182. * } );
  12183. */
  12184. feature: [],
  12185. /**
  12186. * Row searching.
  12187. *
  12188. * This method of searching is complimentary to the default type based
  12189. * searching, and a lot more comprehensive as it allows you complete control
  12190. * over the searching logic. Each element in this array is a function
  12191. * (parameters described below) that is called for every row in the table,
  12192. * and your logic decides if it should be included in the searching data set
  12193. * or not.
  12194. *
  12195. * Searching functions have the following input parameters:
  12196. *
  12197. * 1. `{object}` DataTables settings object: see
  12198. * {@link DataTable.models.oSettings}
  12199. * 2. `{array|object}` Data for the row to be processed (same as the
  12200. * original format that was passed in as the data source, or an array
  12201. * from a DOM data source
  12202. * 3. `{int}` Row index ({@link DataTable.models.oSettings.aoData}), which
  12203. * can be useful to retrieve the `TR` element if you need DOM interaction.
  12204. *
  12205. * And the following return is expected:
  12206. *
  12207. * * {boolean} Include the row in the searched result set (true) or not
  12208. * (false)
  12209. *
  12210. * Note that as with the main search ability in DataTables, technically this
  12211. * is "filtering", since it is subtractive. However, for consistency in
  12212. * naming we call it searching here.
  12213. *
  12214. * @type array
  12215. * @default []
  12216. *
  12217. * @example
  12218. * // The following example shows custom search being applied to the
  12219. * // fourth column (i.e. the data[3] index) based on two input values
  12220. * // from the end-user, matching the data in a certain range.
  12221. * $.fn.dataTable.ext.search.push(
  12222. * function( settings, data, dataIndex ) {
  12223. * var min = document.getElementById('min').value * 1;
  12224. * var max = document.getElementById('max').value * 1;
  12225. * var version = data[3] == "-" ? 0 : data[3]*1;
  12226. *
  12227. * if ( min == "" && max == "" ) {
  12228. * return true;
  12229. * }
  12230. * else if ( min == "" && version < max ) {
  12231. * return true;
  12232. * }
  12233. * else if ( min < version && "" == max ) {
  12234. * return true;
  12235. * }
  12236. * else if ( min < version && version < max ) {
  12237. * return true;
  12238. * }
  12239. * return false;
  12240. * }
  12241. * );
  12242. */
  12243. search: [],
  12244. /**
  12245. * Selector extensions
  12246. *
  12247. * The `selector` option can be used to extend the options available for the
  12248. * selector modifier options (`selector-modifier` object data type) that
  12249. * each of the three built in selector types offer (row, column and cell +
  12250. * their plural counterparts). For example the Select extension uses this
  12251. * mechanism to provide an option to select only rows, columns and cells
  12252. * that have been marked as selected by the end user (`{selected: true}`),
  12253. * which can be used in conjunction with the existing built in selector
  12254. * options.
  12255. *
  12256. * Each property is an array to which functions can be pushed. The functions
  12257. * take three attributes:
  12258. *
  12259. * * Settings object for the host table
  12260. * * Options object (`selector-modifier` object type)
  12261. * * Array of selected item indexes
  12262. *
  12263. * The return is an array of the resulting item indexes after the custom
  12264. * selector has been applied.
  12265. *
  12266. * @type object
  12267. */
  12268. selector: {
  12269. cell: [],
  12270. column: [],
  12271. row: []
  12272. },
  12273. /**
  12274. * Internal functions, exposed for used in plug-ins.
  12275. *
  12276. * Please note that you should not need to use the internal methods for
  12277. * anything other than a plug-in (and even then, try to avoid if possible).
  12278. * The internal function may change between releases.
  12279. *
  12280. * @type object
  12281. * @default {}
  12282. */
  12283. internal: {},
  12284. /**
  12285. * Legacy configuration options. Enable and disable legacy options that
  12286. * are available in DataTables.
  12287. *
  12288. * @type object
  12289. */
  12290. legacy: {
  12291. /**
  12292. * Enable / disable DataTables 1.9 compatible server-side processing
  12293. * requests
  12294. *
  12295. * @type boolean
  12296. * @default null
  12297. */
  12298. ajax: null
  12299. },
  12300. /**
  12301. * Pagination plug-in methods.
  12302. *
  12303. * Each entry in this object is a function and defines which buttons should
  12304. * be shown by the pagination rendering method that is used for the table:
  12305. * {@link DataTable.ext.renderer.pageButton}. The renderer addresses how the
  12306. * buttons are displayed in the document, while the functions here tell it
  12307. * what buttons to display. This is done by returning an array of button
  12308. * descriptions (what each button will do).
  12309. *
  12310. * Pagination types (the four built in options and any additional plug-in
  12311. * options defined here) can be used through the `paginationType`
  12312. * initialisation parameter.
  12313. *
  12314. * The functions defined take two parameters:
  12315. *
  12316. * 1. `{int} page` The current page index
  12317. * 2. `{int} pages` The number of pages in the table
  12318. *
  12319. * Each function is expected to return an array where each element of the
  12320. * array can be one of:
  12321. *
  12322. * * `first` - Jump to first page when activated
  12323. * * `last` - Jump to last page when activated
  12324. * * `previous` - Show previous page when activated
  12325. * * `next` - Show next page when activated
  12326. * * `{int}` - Show page of the index given
  12327. * * `{array}` - A nested array containing the above elements to add a
  12328. * containing 'DIV' element (might be useful for styling).
  12329. *
  12330. * Note that DataTables v1.9- used this object slightly differently whereby
  12331. * an object with two functions would be defined for each plug-in. That
  12332. * ability is still supported by DataTables 1.10+ to provide backwards
  12333. * compatibility, but this option of use is now decremented and no longer
  12334. * documented in DataTables 1.10+.
  12335. *
  12336. * @type object
  12337. * @default {}
  12338. *
  12339. * @example
  12340. * // Show previous, next and current page buttons only
  12341. * $.fn.dataTableExt.oPagination.current = function ( page, pages ) {
  12342. * return [ 'previous', page, 'next' ];
  12343. * };
  12344. */
  12345. pager: {},
  12346. renderer: {
  12347. pageButton: {},
  12348. header: {}
  12349. },
  12350. /**
  12351. * Ordering plug-ins - custom data source
  12352. *
  12353. * The extension options for ordering of data available here is complimentary
  12354. * to the default type based ordering that DataTables typically uses. It
  12355. * allows much greater control over the the data that is being used to
  12356. * order a column, but is necessarily therefore more complex.
  12357. *
  12358. * This type of ordering is useful if you want to do ordering based on data
  12359. * live from the DOM (for example the contents of an 'input' element) rather
  12360. * than just the static string that DataTables knows of.
  12361. *
  12362. * The way these plug-ins work is that you create an array of the values you
  12363. * wish to be ordering for the column in question and then return that
  12364. * array. The data in the array much be in the index order of the rows in
  12365. * the table (not the currently ordering order!). Which order data gathering
  12366. * function is run here depends on the `dt-init columns.orderDataType`
  12367. * parameter that is used for the column (if any).
  12368. *
  12369. * The functions defined take two parameters:
  12370. *
  12371. * 1. `{object}` DataTables settings object: see
  12372. * {@link DataTable.models.oSettings}
  12373. * 2. `{int}` Target column index
  12374. *
  12375. * Each function is expected to return an array:
  12376. *
  12377. * * `{array}` Data for the column to be ordering upon
  12378. *
  12379. * @type array
  12380. *
  12381. * @example
  12382. * // Ordering using `input` node values
  12383. * $.fn.dataTable.ext.order['dom-text'] = function ( settings, col )
  12384. * {
  12385. * return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
  12386. * return $('input', td).val();
  12387. * } );
  12388. * }
  12389. */
  12390. order: {},
  12391. /**
  12392. * Type based plug-ins.
  12393. *
  12394. * Each column in DataTables has a type assigned to it, either by automatic
  12395. * detection or by direct assignment using the `type` option for the column.
  12396. * The type of a column will effect how it is ordering and search (plug-ins
  12397. * can also make use of the column type if required).
  12398. *
  12399. * @namespace
  12400. */
  12401. type: {
  12402. /**
  12403. * Type detection functions.
  12404. *
  12405. * The functions defined in this object are used to automatically detect
  12406. * a column's type, making initialisation of DataTables super easy, even
  12407. * when complex data is in the table.
  12408. *
  12409. * The functions defined take two parameters:
  12410. *
  12411. * 1. `{*}` Data from the column cell to be analysed
  12412. * 2. `{settings}` DataTables settings object. This can be used to
  12413. * perform context specific type detection - for example detection
  12414. * based on language settings such as using a comma for a decimal
  12415. * place. Generally speaking the options from the settings will not
  12416. * be required
  12417. *
  12418. * Each function is expected to return:
  12419. *
  12420. * * `{string|null}` Data type detected, or null if unknown (and thus
  12421. * pass it on to the other type detection functions.
  12422. *
  12423. * @type array
  12424. *
  12425. * @example
  12426. * // Currency type detection plug-in:
  12427. * $.fn.dataTable.ext.type.detect.push(
  12428. * function ( data, settings ) {
  12429. * // Check the numeric part
  12430. * if ( ! data.substring(1).match(/[0-9]/) ) {
  12431. * return null;
  12432. * }
  12433. *
  12434. * // Check prefixed by currency
  12435. * if ( data.charAt(0) == '$' || data.charAt(0) == '&pound;' ) {
  12436. * return 'currency';
  12437. * }
  12438. * return null;
  12439. * }
  12440. * );
  12441. */
  12442. detect: [],
  12443. /**
  12444. * Type based search formatting.
  12445. *
  12446. * The type based searching functions can be used to pre-format the
  12447. * data to be search on. For example, it can be used to strip HTML
  12448. * tags or to de-format telephone numbers for numeric only searching.
  12449. *
  12450. * Note that is a search is not defined for a column of a given type,
  12451. * no search formatting will be performed.
  12452. *
  12453. * Pre-processing of searching data plug-ins - When you assign the sType
  12454. * for a column (or have it automatically detected for you by DataTables
  12455. * or a type detection plug-in), you will typically be using this for
  12456. * custom sorting, but it can also be used to provide custom searching
  12457. * by allowing you to pre-processing the data and returning the data in
  12458. * the format that should be searched upon. This is done by adding
  12459. * functions this object with a parameter name which matches the sType
  12460. * for that target column. This is the corollary of <i>afnSortData</i>
  12461. * for searching data.
  12462. *
  12463. * The functions defined take a single parameter:
  12464. *
  12465. * 1. `{*}` Data from the column cell to be prepared for searching
  12466. *
  12467. * Each function is expected to return:
  12468. *
  12469. * * `{string|null}` Formatted string that will be used for the searching.
  12470. *
  12471. * @type object
  12472. * @default {}
  12473. *
  12474. * @example
  12475. * $.fn.dataTable.ext.type.search['title-numeric'] = function ( d ) {
  12476. * return d.replace(/\n/g," ").replace( /<.*?>/g, "" );
  12477. * }
  12478. */
  12479. search: {},
  12480. /**
  12481. * Type based ordering.
  12482. *
  12483. * The column type tells DataTables what ordering to apply to the table
  12484. * when a column is sorted upon. The order for each type that is defined,
  12485. * is defined by the functions available in this object.
  12486. *
  12487. * Each ordering option can be described by three properties added to
  12488. * this object:
  12489. *
  12490. * * `{type}-pre` - Pre-formatting function
  12491. * * `{type}-asc` - Ascending order function
  12492. * * `{type}-desc` - Descending order function
  12493. *
  12494. * All three can be used together, only `{type}-pre` or only
  12495. * `{type}-asc` and `{type}-desc` together. It is generally recommended
  12496. * that only `{type}-pre` is used, as this provides the optimal
  12497. * implementation in terms of speed, although the others are provided
  12498. * for compatibility with existing Javascript sort functions.
  12499. *
  12500. * `{type}-pre`: Functions defined take a single parameter:
  12501. *
  12502. * 1. `{*}` Data from the column cell to be prepared for ordering
  12503. *
  12504. * And return:
  12505. *
  12506. * * `{*}` Data to be sorted upon
  12507. *
  12508. * `{type}-asc` and `{type}-desc`: Functions are typical Javascript sort
  12509. * functions, taking two parameters:
  12510. *
  12511. * 1. `{*}` Data to compare to the second parameter
  12512. * 2. `{*}` Data to compare to the first parameter
  12513. *
  12514. * And returning:
  12515. *
  12516. * * `{*}` Ordering match: <0 if first parameter should be sorted lower
  12517. * than the second parameter, ===0 if the two parameters are equal and
  12518. * >0 if the first parameter should be sorted height than the second
  12519. * parameter.
  12520. *
  12521. * @type object
  12522. * @default {}
  12523. *
  12524. * @example
  12525. * // Numeric ordering of formatted numbers with a pre-formatter
  12526. * $.extend( $.fn.dataTable.ext.type.order, {
  12527. * "string-pre": function(x) {
  12528. * a = (a === "-" || a === "") ? 0 : a.replace( /[^\d\-\.]/g, "" );
  12529. * return parseFloat( a );
  12530. * }
  12531. * } );
  12532. *
  12533. * @example
  12534. * // Case-sensitive string ordering, with no pre-formatting method
  12535. * $.extend( $.fn.dataTable.ext.order, {
  12536. * "string-case-asc": function(x,y) {
  12537. * return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12538. * },
  12539. * "string-case-desc": function(x,y) {
  12540. * return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12541. * }
  12542. * } );
  12543. */
  12544. order: {}
  12545. },
  12546. /**
  12547. * Unique DataTables instance counter
  12548. *
  12549. * @type int
  12550. * @private
  12551. */
  12552. _unique: 0,
  12553. //
  12554. // Depreciated
  12555. // The following properties are retained for backwards compatiblity only.
  12556. // The should not be used in new projects and will be removed in a future
  12557. // version
  12558. //
  12559. /**
  12560. * Version check function.
  12561. * @type function
  12562. * @depreciated Since 1.10
  12563. */
  12564. fnVersionCheck: DataTable.fnVersionCheck,
  12565. /**
  12566. * Index for what 'this' index API functions should use
  12567. * @type int
  12568. * @deprecated Since v1.10
  12569. */
  12570. iApiIndex: 0,
  12571. /**
  12572. * jQuery UI class container
  12573. * @type object
  12574. * @deprecated Since v1.10
  12575. */
  12576. oJUIClasses: {},
  12577. /**
  12578. * Software version
  12579. * @type string
  12580. * @deprecated Since v1.10
  12581. */
  12582. sVersion: DataTable.version
  12583. };
  12584. //
  12585. // Backwards compatibility. Alias to pre 1.10 Hungarian notation counter parts
  12586. //
  12587. $.extend( _ext, {
  12588. afnFiltering: _ext.search,
  12589. aTypes: _ext.type.detect,
  12590. ofnSearch: _ext.type.search,
  12591. oSort: _ext.type.order,
  12592. afnSortData: _ext.order,
  12593. aoFeatures: _ext.feature,
  12594. oApi: _ext.internal,
  12595. oStdClasses: _ext.classes,
  12596. oPagination: _ext.pager
  12597. } );
  12598. $.extend( DataTable.ext.classes, {
  12599. "sTable": "dataTable",
  12600. "sNoFooter": "no-footer",
  12601. /* Paging buttons */
  12602. "sPageButton": "paginate_button",
  12603. "sPageButtonActive": "current",
  12604. "sPageButtonDisabled": "disabled",
  12605. /* Striping classes */
  12606. "sStripeOdd": "odd",
  12607. "sStripeEven": "even",
  12608. /* Empty row */
  12609. "sRowEmpty": "dataTables_empty",
  12610. /* Features */
  12611. "sWrapper": "dataTables_wrapper",
  12612. "sFilter": "dataTables_filter",
  12613. "sInfo": "dataTables_info",
  12614. "sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */
  12615. "sLength": "dataTables_length",
  12616. "sProcessing": "dataTables_processing",
  12617. /* Sorting */
  12618. "sSortAsc": "sorting_asc",
  12619. "sSortDesc": "sorting_desc",
  12620. "sSortable": "sorting", /* Sortable in both directions */
  12621. "sSortableAsc": "sorting_asc_disabled",
  12622. "sSortableDesc": "sorting_desc_disabled",
  12623. "sSortableNone": "sorting_disabled",
  12624. "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
  12625. /* Filtering */
  12626. "sFilterInput": "",
  12627. /* Page length */
  12628. "sLengthSelect": "",
  12629. /* Scrolling */
  12630. "sScrollWrapper": "dataTables_scroll",
  12631. "sScrollHead": "dataTables_scrollHead",
  12632. "sScrollHeadInner": "dataTables_scrollHeadInner",
  12633. "sScrollBody": "dataTables_scrollBody",
  12634. "sScrollFoot": "dataTables_scrollFoot",
  12635. "sScrollFootInner": "dataTables_scrollFootInner",
  12636. /* Misc */
  12637. "sHeaderTH": "",
  12638. "sFooterTH": "",
  12639. // Deprecated
  12640. "sSortJUIAsc": "",
  12641. "sSortJUIDesc": "",
  12642. "sSortJUI": "",
  12643. "sSortJUIAscAllowed": "",
  12644. "sSortJUIDescAllowed": "",
  12645. "sSortJUIWrapper": "",
  12646. "sSortIcon": "",
  12647. "sJUIHeader": "",
  12648. "sJUIFooter": ""
  12649. } );
  12650. var extPagination = DataTable.ext.pager;
  12651. function _numbers ( page, pages ) {
  12652. var
  12653. numbers = [],
  12654. buttons = extPagination.numbers_length,
  12655. half = Math.floor( buttons / 2 ),
  12656. i = 1;
  12657. if ( pages <= buttons ) {
  12658. numbers = _range( 0, pages );
  12659. }
  12660. else if ( page <= half ) {
  12661. numbers = _range( 0, buttons-2 );
  12662. numbers.push( 'ellipsis' );
  12663. numbers.push( pages-1 );
  12664. }
  12665. else if ( page >= pages - 1 - half ) {
  12666. numbers = _range( pages-(buttons-2), pages );
  12667. numbers.splice( 0, 0, 'ellipsis' ); // no unshift in ie6
  12668. numbers.splice( 0, 0, 0 );
  12669. }
  12670. else {
  12671. numbers = _range( page-half+2, page+half-1 );
  12672. numbers.push( 'ellipsis' );
  12673. numbers.push( pages-1 );
  12674. numbers.splice( 0, 0, 'ellipsis' );
  12675. numbers.splice( 0, 0, 0 );
  12676. }
  12677. numbers.DT_el = 'span';
  12678. return numbers;
  12679. }
  12680. $.extend( extPagination, {
  12681. simple: function ( page, pages ) {
  12682. return [ 'previous', 'next' ];
  12683. },
  12684. full: function ( page, pages ) {
  12685. return [ 'first', 'previous', 'next', 'last' ];
  12686. },
  12687. numbers: function ( page, pages ) {
  12688. return [ _numbers(page, pages) ];
  12689. },
  12690. simple_numbers: function ( page, pages ) {
  12691. return [ 'previous', _numbers(page, pages), 'next' ];
  12692. },
  12693. full_numbers: function ( page, pages ) {
  12694. return [ 'first', 'previous', _numbers(page, pages), 'next', 'last' ];
  12695. },
  12696. first_last_numbers: function (page, pages) {
  12697. return ['first', _numbers(page, pages), 'last'];
  12698. },
  12699. // For testing and plug-ins to use
  12700. _numbers: _numbers,
  12701. // Number of number buttons (including ellipsis) to show. _Must be odd!_
  12702. numbers_length: 7
  12703. } );
  12704. $.extend( true, DataTable.ext.renderer, {
  12705. pageButton: {
  12706. _: function ( settings, host, idx, buttons, page, pages ) {
  12707. var classes = settings.oClasses;
  12708. var lang = settings.oLanguage.oPaginate;
  12709. var aria = settings.oLanguage.oAria.paginate || {};
  12710. var btnDisplay, btnClass, counter=0;
  12711. var attach = function( container, buttons ) {
  12712. var i, ien, node, button, tabIndex;
  12713. var disabledClass = classes.sPageButtonDisabled;
  12714. var clickHandler = function ( e ) {
  12715. _fnPageChange( settings, e.data.action, true );
  12716. };
  12717. for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
  12718. button = buttons[i];
  12719. if ( Array.isArray( button ) ) {
  12720. var inner = $( '<'+(button.DT_el || 'div')+'/>' )
  12721. .appendTo( container );
  12722. attach( inner, button );
  12723. }
  12724. else {
  12725. btnDisplay = null;
  12726. btnClass = button;
  12727. tabIndex = settings.iTabIndex;
  12728. switch ( button ) {
  12729. case 'ellipsis':
  12730. container.append('<span class="ellipsis">&#x2026;</span>');
  12731. break;
  12732. case 'first':
  12733. btnDisplay = lang.sFirst;
  12734. if ( page === 0 ) {
  12735. tabIndex = -1;
  12736. btnClass += ' ' + disabledClass;
  12737. }
  12738. break;
  12739. case 'previous':
  12740. btnDisplay = lang.sPrevious;
  12741. if ( page === 0 ) {
  12742. tabIndex = -1;
  12743. btnClass += ' ' + disabledClass;
  12744. }
  12745. break;
  12746. case 'next':
  12747. btnDisplay = lang.sNext;
  12748. if ( pages === 0 || page === pages-1 ) {
  12749. tabIndex = -1;
  12750. btnClass += ' ' + disabledClass;
  12751. }
  12752. break;
  12753. case 'last':
  12754. btnDisplay = lang.sLast;
  12755. if ( pages === 0 || page === pages-1 ) {
  12756. tabIndex = -1;
  12757. btnClass += ' ' + disabledClass;
  12758. }
  12759. break;
  12760. default:
  12761. btnDisplay = settings.fnFormatNumber( button + 1 );
  12762. btnClass = page === button ?
  12763. classes.sPageButtonActive : '';
  12764. break;
  12765. }
  12766. if ( btnDisplay !== null ) {
  12767. node = $('<a>', {
  12768. 'class': classes.sPageButton+' '+btnClass,
  12769. 'aria-controls': settings.sTableId,
  12770. 'aria-label': aria[ button ],
  12771. 'data-dt-idx': counter,
  12772. 'tabindex': tabIndex,
  12773. 'id': idx === 0 && typeof button === 'string' ?
  12774. settings.sTableId +'_'+ button :
  12775. null
  12776. } )
  12777. .html( btnDisplay )
  12778. .appendTo( container );
  12779. _fnBindAction(
  12780. node, {action: button}, clickHandler
  12781. );
  12782. counter++;
  12783. }
  12784. }
  12785. }
  12786. };
  12787. // IE9 throws an 'unknown error' if document.activeElement is used
  12788. // inside an iframe or frame. Try / catch the error. Not good for
  12789. // accessibility, but neither are frames.
  12790. var activeEl;
  12791. try {
  12792. // Because this approach is destroying and recreating the paging
  12793. // elements, focus is lost on the select button which is bad for
  12794. // accessibility. So we want to restore focus once the draw has
  12795. // completed
  12796. activeEl = $(host).find(document.activeElement).data('dt-idx');
  12797. }
  12798. catch (e) {}
  12799. attach( $(host).empty(), buttons );
  12800. if ( activeEl !== undefined ) {
  12801. $(host).find( '[data-dt-idx='+activeEl+']' ).trigger('focus');
  12802. }
  12803. }
  12804. }
  12805. } );
  12806. // Built in type detection. See model.ext.aTypes for information about
  12807. // what is required from this methods.
  12808. $.extend( DataTable.ext.type.detect, [
  12809. // Plain numbers - first since V8 detects some plain numbers as dates
  12810. // e.g. Date.parse('55') (but not all, e.g. Date.parse('22')...).
  12811. function ( d, settings )
  12812. {
  12813. var decimal = settings.oLanguage.sDecimal;
  12814. return _isNumber( d, decimal ) ? 'num'+decimal : null;
  12815. },
  12816. // Dates (only those recognised by the browser's Date.parse)
  12817. function ( d, settings )
  12818. {
  12819. // V8 tries _very_ hard to make a string passed into `Date.parse()`
  12820. // valid, so we need to use a regex to restrict date formats. Use a
  12821. // plug-in for anything other than ISO8601 style strings
  12822. if ( d && !(d instanceof Date) && ! _re_date.test(d) ) {
  12823. return null;
  12824. }
  12825. var parsed = Date.parse(d);
  12826. return (parsed !== null && !isNaN(parsed)) || _empty(d) ? 'date' : null;
  12827. },
  12828. // Formatted numbers
  12829. function ( d, settings )
  12830. {
  12831. var decimal = settings.oLanguage.sDecimal;
  12832. return _isNumber( d, decimal, true ) ? 'num-fmt'+decimal : null;
  12833. },
  12834. // HTML numeric
  12835. function ( d, settings )
  12836. {
  12837. var decimal = settings.oLanguage.sDecimal;
  12838. return _htmlNumeric( d, decimal ) ? 'html-num'+decimal : null;
  12839. },
  12840. // HTML numeric, formatted
  12841. function ( d, settings )
  12842. {
  12843. var decimal = settings.oLanguage.sDecimal;
  12844. return _htmlNumeric( d, decimal, true ) ? 'html-num-fmt'+decimal : null;
  12845. },
  12846. // HTML (this is strict checking - there must be html)
  12847. function ( d, settings )
  12848. {
  12849. return _empty( d ) || (typeof d === 'string' && d.indexOf('<') !== -1) ?
  12850. 'html' : null;
  12851. }
  12852. ] );
  12853. // Filter formatting functions. See model.ext.ofnSearch for information about
  12854. // what is required from these methods.
  12855. //
  12856. // Note that additional search methods are added for the html numbers and
  12857. // html formatted numbers by `_addNumericSort()` when we know what the decimal
  12858. // place is
  12859. $.extend( DataTable.ext.type.search, {
  12860. html: function ( data ) {
  12861. return _empty(data) ?
  12862. data :
  12863. typeof data === 'string' ?
  12864. data
  12865. .replace( _re_new_lines, " " )
  12866. .replace( _re_html, "" ) :
  12867. '';
  12868. },
  12869. string: function ( data ) {
  12870. return _empty(data) ?
  12871. data :
  12872. typeof data === 'string' ?
  12873. data.replace( _re_new_lines, " " ) :
  12874. data;
  12875. }
  12876. } );
  12877. var __numericReplace = function ( d, decimalPlace, re1, re2 ) {
  12878. if ( d !== 0 && (!d || d === '-') ) {
  12879. return -Infinity;
  12880. }
  12881. // If a decimal place other than `.` is used, it needs to be given to the
  12882. // function so we can detect it and replace with a `.` which is the only
  12883. // decimal place Javascript recognises - it is not locale aware.
  12884. if ( decimalPlace ) {
  12885. d = _numToDecimal( d, decimalPlace );
  12886. }
  12887. if ( d.replace ) {
  12888. if ( re1 ) {
  12889. d = d.replace( re1, '' );
  12890. }
  12891. if ( re2 ) {
  12892. d = d.replace( re2, '' );
  12893. }
  12894. }
  12895. return d * 1;
  12896. };
  12897. // Add the numeric 'deformatting' functions for sorting and search. This is done
  12898. // in a function to provide an easy ability for the language options to add
  12899. // additional methods if a non-period decimal place is used.
  12900. function _addNumericSort ( decimalPlace ) {
  12901. $.each(
  12902. {
  12903. // Plain numbers
  12904. "num": function ( d ) {
  12905. return __numericReplace( d, decimalPlace );
  12906. },
  12907. // Formatted numbers
  12908. "num-fmt": function ( d ) {
  12909. return __numericReplace( d, decimalPlace, _re_formatted_numeric );
  12910. },
  12911. // HTML numeric
  12912. "html-num": function ( d ) {
  12913. return __numericReplace( d, decimalPlace, _re_html );
  12914. },
  12915. // HTML numeric, formatted
  12916. "html-num-fmt": function ( d ) {
  12917. return __numericReplace( d, decimalPlace, _re_html, _re_formatted_numeric );
  12918. }
  12919. },
  12920. function ( key, fn ) {
  12921. // Add the ordering method
  12922. _ext.type.order[ key+decimalPlace+'-pre' ] = fn;
  12923. // For HTML types add a search formatter that will strip the HTML
  12924. if ( key.match(/^html\-/) ) {
  12925. _ext.type.search[ key+decimalPlace ] = _ext.type.search.html;
  12926. }
  12927. }
  12928. );
  12929. }
  12930. // Default sort methods
  12931. $.extend( _ext.type.order, {
  12932. // Dates
  12933. "date-pre": function ( d ) {
  12934. var ts = Date.parse( d );
  12935. return isNaN(ts) ? -Infinity : ts;
  12936. },
  12937. // html
  12938. "html-pre": function ( a ) {
  12939. return _empty(a) ?
  12940. '' :
  12941. a.replace ?
  12942. a.replace( /<.*?>/g, "" ).toLowerCase() :
  12943. a+'';
  12944. },
  12945. // string
  12946. "string-pre": function ( a ) {
  12947. // This is a little complex, but faster than always calling toString,
  12948. // http://jsperf.com/tostring-v-check
  12949. return _empty(a) ?
  12950. '' :
  12951. typeof a === 'string' ?
  12952. a.toLowerCase() :
  12953. ! a.toString ?
  12954. '' :
  12955. a.toString();
  12956. },
  12957. // string-asc and -desc are retained only for compatibility with the old
  12958. // sort methods
  12959. "string-asc": function ( x, y ) {
  12960. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12961. },
  12962. "string-desc": function ( x, y ) {
  12963. return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12964. }
  12965. } );
  12966. // Numeric sorting types - order doesn't matter here
  12967. _addNumericSort( '' );
  12968. $.extend( true, DataTable.ext.renderer, {
  12969. header: {
  12970. _: function ( settings, cell, column, classes ) {
  12971. // No additional mark-up required
  12972. // Attach a sort listener to update on sort - note that using the
  12973. // `DT` namespace will allow the event to be removed automatically
  12974. // on destroy, while the `dt` namespaced event is the one we are
  12975. // listening for
  12976. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  12977. if ( settings !== ctx ) { // need to check this this is the host
  12978. return; // table, not a nested one
  12979. }
  12980. var colIdx = column.idx;
  12981. cell
  12982. .removeClass(
  12983. column.sSortingClass +' '+
  12984. classes.sSortAsc +' '+
  12985. classes.sSortDesc
  12986. )
  12987. .addClass( columns[ colIdx ] == 'asc' ?
  12988. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  12989. classes.sSortDesc :
  12990. column.sSortingClass
  12991. );
  12992. } );
  12993. },
  12994. jqueryui: function ( settings, cell, column, classes ) {
  12995. $('<div/>')
  12996. .addClass( classes.sSortJUIWrapper )
  12997. .append( cell.contents() )
  12998. .append( $('<span/>')
  12999. .addClass( classes.sSortIcon+' '+column.sSortingClassJUI )
  13000. )
  13001. .appendTo( cell );
  13002. // Attach a sort listener to update on sort
  13003. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  13004. if ( settings !== ctx ) {
  13005. return;
  13006. }
  13007. var colIdx = column.idx;
  13008. cell
  13009. .removeClass( classes.sSortAsc +" "+classes.sSortDesc )
  13010. .addClass( columns[ colIdx ] == 'asc' ?
  13011. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  13012. classes.sSortDesc :
  13013. column.sSortingClass
  13014. );
  13015. cell
  13016. .find( 'span.'+classes.sSortIcon )
  13017. .removeClass(
  13018. classes.sSortJUIAsc +" "+
  13019. classes.sSortJUIDesc +" "+
  13020. classes.sSortJUI +" "+
  13021. classes.sSortJUIAscAllowed +" "+
  13022. classes.sSortJUIDescAllowed
  13023. )
  13024. .addClass( columns[ colIdx ] == 'asc' ?
  13025. classes.sSortJUIAsc : columns[ colIdx ] == 'desc' ?
  13026. classes.sSortJUIDesc :
  13027. column.sSortingClassJUI
  13028. );
  13029. } );
  13030. }
  13031. }
  13032. } );
  13033. /*
  13034. * Public helper functions. These aren't used internally by DataTables, or
  13035. * called by any of the options passed into DataTables, but they can be used
  13036. * externally by developers working with DataTables. They are helper functions
  13037. * to make working with DataTables a little bit easier.
  13038. */
  13039. var __htmlEscapeEntities = function ( d ) {
  13040. return typeof d === 'string' ?
  13041. d
  13042. .replace(/&/g, '&amp;')
  13043. .replace(/</g, '&lt;')
  13044. .replace(/>/g, '&gt;')
  13045. .replace(/"/g, '&quot;') :
  13046. d;
  13047. };
  13048. /**
  13049. * Helpers for `columns.render`.
  13050. *
  13051. * The options defined here can be used with the `columns.render` initialisation
  13052. * option to provide a display renderer. The following functions are defined:
  13053. *
  13054. * * `number` - Will format numeric data (defined by `columns.data`) for
  13055. * display, retaining the original unformatted data for sorting and filtering.
  13056. * It takes 5 parameters:
  13057. * * `string` - Thousands grouping separator
  13058. * * `string` - Decimal point indicator
  13059. * * `integer` - Number of decimal points to show
  13060. * * `string` (optional) - Prefix.
  13061. * * `string` (optional) - Postfix (/suffix).
  13062. * * `text` - Escape HTML to help prevent XSS attacks. It has no optional
  13063. * parameters.
  13064. *
  13065. * @example
  13066. * // Column definition using the number renderer
  13067. * {
  13068. * data: "salary",
  13069. * render: $.fn.dataTable.render.number( '\'', '.', 0, '$' )
  13070. * }
  13071. *
  13072. * @namespace
  13073. */
  13074. DataTable.render = {
  13075. number: function ( thousands, decimal, precision, prefix, postfix ) {
  13076. return {
  13077. display: function ( d ) {
  13078. if ( typeof d !== 'number' && typeof d !== 'string' ) {
  13079. return d;
  13080. }
  13081. var negative = d < 0 ? '-' : '';
  13082. var flo = parseFloat( d );
  13083. // If NaN then there isn't much formatting that we can do - just
  13084. // return immediately, escaping any HTML (this was supposed to
  13085. // be a number after all)
  13086. if ( isNaN( flo ) ) {
  13087. return __htmlEscapeEntities( d );
  13088. }
  13089. flo = flo.toFixed( precision );
  13090. d = Math.abs( flo );
  13091. var intPart = parseInt( d, 10 );
  13092. var floatPart = precision ?
  13093. decimal+(d - intPart).toFixed( precision ).substring( 2 ):
  13094. '';
  13095. return negative + (prefix||'') +
  13096. intPart.toString().replace(
  13097. /\B(?=(\d{3})+(?!\d))/g, thousands
  13098. ) +
  13099. floatPart +
  13100. (postfix||'');
  13101. }
  13102. };
  13103. },
  13104. text: function () {
  13105. return {
  13106. display: __htmlEscapeEntities,
  13107. filter: __htmlEscapeEntities
  13108. };
  13109. }
  13110. };
  13111. /*
  13112. * This is really a good bit rubbish this method of exposing the internal methods
  13113. * publicly... - To be fixed in 2.0 using methods on the prototype
  13114. */
  13115. /**
  13116. * Create a wrapper function for exporting an internal functions to an external API.
  13117. * @param {string} fn API function name
  13118. * @returns {function} wrapped function
  13119. * @memberof DataTable#internal
  13120. */
  13121. function _fnExternApiFunc (fn)
  13122. {
  13123. return function() {
  13124. var args = [_fnSettingsFromNode( this[DataTable.ext.iApiIndex] )].concat(
  13125. Array.prototype.slice.call(arguments)
  13126. );
  13127. return DataTable.ext.internal[fn].apply( this, args );
  13128. };
  13129. }
  13130. /**
  13131. * Reference to internal functions for use by plug-in developers. Note that
  13132. * these methods are references to internal functions and are considered to be
  13133. * private. If you use these methods, be aware that they are liable to change
  13134. * between versions.
  13135. * @namespace
  13136. */
  13137. $.extend( DataTable.ext.internal, {
  13138. _fnExternApiFunc: _fnExternApiFunc,
  13139. _fnBuildAjax: _fnBuildAjax,
  13140. _fnAjaxUpdate: _fnAjaxUpdate,
  13141. _fnAjaxParameters: _fnAjaxParameters,
  13142. _fnAjaxUpdateDraw: _fnAjaxUpdateDraw,
  13143. _fnAjaxDataSrc: _fnAjaxDataSrc,
  13144. _fnAddColumn: _fnAddColumn,
  13145. _fnColumnOptions: _fnColumnOptions,
  13146. _fnAdjustColumnSizing: _fnAdjustColumnSizing,
  13147. _fnVisibleToColumnIndex: _fnVisibleToColumnIndex,
  13148. _fnColumnIndexToVisible: _fnColumnIndexToVisible,
  13149. _fnVisbleColumns: _fnVisbleColumns,
  13150. _fnGetColumns: _fnGetColumns,
  13151. _fnColumnTypes: _fnColumnTypes,
  13152. _fnApplyColumnDefs: _fnApplyColumnDefs,
  13153. _fnHungarianMap: _fnHungarianMap,
  13154. _fnCamelToHungarian: _fnCamelToHungarian,
  13155. _fnLanguageCompat: _fnLanguageCompat,
  13156. _fnBrowserDetect: _fnBrowserDetect,
  13157. _fnAddData: _fnAddData,
  13158. _fnAddTr: _fnAddTr,
  13159. _fnNodeToDataIndex: _fnNodeToDataIndex,
  13160. _fnNodeToColumnIndex: _fnNodeToColumnIndex,
  13161. _fnGetCellData: _fnGetCellData,
  13162. _fnSetCellData: _fnSetCellData,
  13163. _fnSplitObjNotation: _fnSplitObjNotation,
  13164. _fnGetObjectDataFn: _fnGetObjectDataFn,
  13165. _fnSetObjectDataFn: _fnSetObjectDataFn,
  13166. _fnGetDataMaster: _fnGetDataMaster,
  13167. _fnClearTable: _fnClearTable,
  13168. _fnDeleteIndex: _fnDeleteIndex,
  13169. _fnInvalidate: _fnInvalidate,
  13170. _fnGetRowElements: _fnGetRowElements,
  13171. _fnCreateTr: _fnCreateTr,
  13172. _fnBuildHead: _fnBuildHead,
  13173. _fnDrawHead: _fnDrawHead,
  13174. _fnDraw: _fnDraw,
  13175. _fnReDraw: _fnReDraw,
  13176. _fnAddOptionsHtml: _fnAddOptionsHtml,
  13177. _fnDetectHeader: _fnDetectHeader,
  13178. _fnGetUniqueThs: _fnGetUniqueThs,
  13179. _fnFeatureHtmlFilter: _fnFeatureHtmlFilter,
  13180. _fnFilterComplete: _fnFilterComplete,
  13181. _fnFilterCustom: _fnFilterCustom,
  13182. _fnFilterColumn: _fnFilterColumn,
  13183. _fnFilter: _fnFilter,
  13184. _fnFilterCreateSearch: _fnFilterCreateSearch,
  13185. _fnEscapeRegex: _fnEscapeRegex,
  13186. _fnFilterData: _fnFilterData,
  13187. _fnFeatureHtmlInfo: _fnFeatureHtmlInfo,
  13188. _fnUpdateInfo: _fnUpdateInfo,
  13189. _fnInfoMacros: _fnInfoMacros,
  13190. _fnInitialise: _fnInitialise,
  13191. _fnInitComplete: _fnInitComplete,
  13192. _fnLengthChange: _fnLengthChange,
  13193. _fnFeatureHtmlLength: _fnFeatureHtmlLength,
  13194. _fnFeatureHtmlPaginate: _fnFeatureHtmlPaginate,
  13195. _fnPageChange: _fnPageChange,
  13196. _fnFeatureHtmlProcessing: _fnFeatureHtmlProcessing,
  13197. _fnProcessingDisplay: _fnProcessingDisplay,
  13198. _fnFeatureHtmlTable: _fnFeatureHtmlTable,
  13199. _fnScrollDraw: _fnScrollDraw,
  13200. _fnApplyToChildren: _fnApplyToChildren,
  13201. _fnCalculateColumnWidths: _fnCalculateColumnWidths,
  13202. _fnThrottle: _fnThrottle,
  13203. _fnConvertToWidth: _fnConvertToWidth,
  13204. _fnGetWidestNode: _fnGetWidestNode,
  13205. _fnGetMaxLenString: _fnGetMaxLenString,
  13206. _fnStringToCss: _fnStringToCss,
  13207. _fnSortFlatten: _fnSortFlatten,
  13208. _fnSort: _fnSort,
  13209. _fnSortAria: _fnSortAria,
  13210. _fnSortListener: _fnSortListener,
  13211. _fnSortAttachListener: _fnSortAttachListener,
  13212. _fnSortingClasses: _fnSortingClasses,
  13213. _fnSortData: _fnSortData,
  13214. _fnSaveState: _fnSaveState,
  13215. _fnLoadState: _fnLoadState,
  13216. _fnSettingsFromNode: _fnSettingsFromNode,
  13217. _fnLog: _fnLog,
  13218. _fnMap: _fnMap,
  13219. _fnBindAction: _fnBindAction,
  13220. _fnCallbackReg: _fnCallbackReg,
  13221. _fnCallbackFire: _fnCallbackFire,
  13222. _fnLengthOverflow: _fnLengthOverflow,
  13223. _fnRenderer: _fnRenderer,
  13224. _fnDataSource: _fnDataSource,
  13225. _fnRowAttributes: _fnRowAttributes,
  13226. _fnExtend: _fnExtend,
  13227. _fnCalculateEnd: function () {} // Used by a lot of plug-ins, but redundant
  13228. // in 1.10, so this dead-end function is
  13229. // added to prevent errors
  13230. } );
  13231. // jQuery access
  13232. $.fn.dataTable = DataTable;
  13233. // Provide access to the host jQuery object (circular reference)
  13234. DataTable.$ = $;
  13235. // Legacy aliases
  13236. $.fn.dataTableSettings = DataTable.settings;
  13237. $.fn.dataTableExt = DataTable.ext;
  13238. // With a capital `D` we return a DataTables API instance rather than a
  13239. // jQuery object
  13240. $.fn.DataTable = function ( opts ) {
  13241. return $(this).dataTable( opts ).api();
  13242. };
  13243. // All properties that are available to $.fn.dataTable should also be
  13244. // available on $.fn.DataTable
  13245. $.each( DataTable, function ( prop, val ) {
  13246. $.fn.DataTable[ prop ] = val;
  13247. } );
  13248. // Information about events fired by DataTables - for documentation.
  13249. /**
  13250. * Draw event, fired whenever the table is redrawn on the page, at the same
  13251. * point as fnDrawCallback. This may be useful for binding events or
  13252. * performing calculations when the table is altered at all.
  13253. * @name DataTable#draw.dt
  13254. * @event
  13255. * @param {event} e jQuery event object
  13256. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13257. */
  13258. /**
  13259. * Search event, fired when the searching applied to the table (using the
  13260. * built-in global search, or column filters) is altered.
  13261. * @name DataTable#search.dt
  13262. * @event
  13263. * @param {event} e jQuery event object
  13264. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13265. */
  13266. /**
  13267. * Page change event, fired when the paging of the table is altered.
  13268. * @name DataTable#page.dt
  13269. * @event
  13270. * @param {event} e jQuery event object
  13271. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13272. */
  13273. /**
  13274. * Order event, fired when the ordering applied to the table is altered.
  13275. * @name DataTable#order.dt
  13276. * @event
  13277. * @param {event} e jQuery event object
  13278. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13279. */
  13280. /**
  13281. * DataTables initialisation complete event, fired when the table is fully
  13282. * drawn, including Ajax data loaded, if Ajax data is required.
  13283. * @name DataTable#init.dt
  13284. * @event
  13285. * @param {event} e jQuery event object
  13286. * @param {object} oSettings DataTables settings object
  13287. * @param {object} json The JSON object request from the server - only
  13288. * present if client-side Ajax sourced data is used</li></ol>
  13289. */
  13290. /**
  13291. * State save event, fired when the table has changed state a new state save
  13292. * is required. This event allows modification of the state saving object
  13293. * prior to actually doing the save, including addition or other state
  13294. * properties (for plug-ins) or modification of a DataTables core property.
  13295. * @name DataTable#stateSaveParams.dt
  13296. * @event
  13297. * @param {event} e jQuery event object
  13298. * @param {object} oSettings DataTables settings object
  13299. * @param {object} json The state information to be saved
  13300. */
  13301. /**
  13302. * State load event, fired when the table is loading state from the stored
  13303. * data, but prior to the settings object being modified by the saved state
  13304. * - allowing modification of the saved state is required or loading of
  13305. * state for a plug-in.
  13306. * @name DataTable#stateLoadParams.dt
  13307. * @event
  13308. * @param {event} e jQuery event object
  13309. * @param {object} oSettings DataTables settings object
  13310. * @param {object} json The saved state information
  13311. */
  13312. /**
  13313. * State loaded event, fired when state has been loaded from stored data and
  13314. * the settings object has been modified by the loaded data.
  13315. * @name DataTable#stateLoaded.dt
  13316. * @event
  13317. * @param {event} e jQuery event object
  13318. * @param {object} oSettings DataTables settings object
  13319. * @param {object} json The saved state information
  13320. */
  13321. /**
  13322. * Processing event, fired when DataTables is doing some kind of processing
  13323. * (be it, order, search or anything else). It can be used to indicate to
  13324. * the end user that there is something happening, or that something has
  13325. * finished.
  13326. * @name DataTable#processing.dt
  13327. * @event
  13328. * @param {event} e jQuery event object
  13329. * @param {object} oSettings DataTables settings object
  13330. * @param {boolean} bShow Flag for if DataTables is doing processing or not
  13331. */
  13332. /**
  13333. * Ajax (XHR) event, fired whenever an Ajax request is completed from a
  13334. * request to made to the server for new data. This event is called before
  13335. * DataTables processed the returned data, so it can also be used to pre-
  13336. * process the data returned from the server, if needed.
  13337. *
  13338. * Note that this trigger is called in `fnServerData`, if you override
  13339. * `fnServerData` and which to use this event, you need to trigger it in you
  13340. * success function.
  13341. * @name DataTable#xhr.dt
  13342. * @event
  13343. * @param {event} e jQuery event object
  13344. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13345. * @param {object} json JSON returned from the server
  13346. *
  13347. * @example
  13348. * // Use a custom property returned from the server in another DOM element
  13349. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  13350. * $('#status').html( json.status );
  13351. * } );
  13352. *
  13353. * @example
  13354. * // Pre-process the data returned from the server
  13355. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  13356. * for ( var i=0, ien=json.aaData.length ; i<ien ; i++ ) {
  13357. * json.aaData[i].sum = json.aaData[i].one + json.aaData[i].two;
  13358. * }
  13359. * // Note no return - manipulate the data directly in the JSON object.
  13360. * } );
  13361. */
  13362. /**
  13363. * Destroy event, fired when the DataTable is destroyed by calling fnDestroy
  13364. * or passing the bDestroy:true parameter in the initialisation object. This
  13365. * can be used to remove bound events, added DOM nodes, etc.
  13366. * @name DataTable#destroy.dt
  13367. * @event
  13368. * @param {event} e jQuery event object
  13369. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13370. */
  13371. /**
  13372. * Page length change event, fired when number of records to show on each
  13373. * page (the length) is changed.
  13374. * @name DataTable#length.dt
  13375. * @event
  13376. * @param {event} e jQuery event object
  13377. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13378. * @param {integer} len New length
  13379. */
  13380. /**
  13381. * Column sizing has changed.
  13382. * @name DataTable#column-sizing.dt
  13383. * @event
  13384. * @param {event} e jQuery event object
  13385. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13386. */
  13387. /**
  13388. * Column visibility has changed.
  13389. * @name DataTable#column-visibility.dt
  13390. * @event
  13391. * @param {event} e jQuery event object
  13392. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13393. * @param {int} column Column index
  13394. * @param {bool} vis `false` if column now hidden, or `true` if visible
  13395. */
  13396. return $.fn.dataTable;
  13397. }));