選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

jquery.dataTables.js 438KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345
  1. /*! DataTables 1.11.4
  2. * ©2008-2021 SpryMedia Ltd - datatables.net/license
  3. */
  4. /**
  5. * @summary DataTables
  6. * @description Paginate, search and order HTML tables
  7. * @version 1.11.4
  8. * @file jquery.dataTables.js
  9. * @author SpryMedia Ltd
  10. * @contact www.datatables.net
  11. * @copyright Copyright 2008-2021 SpryMedia Ltd.
  12. *
  13. * This source file is free software, available under the following license:
  14. * MIT license - http://datatables.net/license
  15. *
  16. * This source file is distributed in the hope that it will be useful, but
  17. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  18. * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
  19. *
  20. * For details please refer to: http://www.datatables.net
  21. */
  22. /*jslint evil: true, undef: true, browser: true */
  23. /*globals $,require,jQuery,define,_selector_run,_selector_opts,_selector_first,_selector_row_indexes,_ext,_Api,_api_register,_api_registerPlural,_re_new_lines,_re_html,_re_formatted_numeric,_re_escape_regex,_empty,_intVal,_numToDecimal,_isNumber,_isHtml,_htmlNumeric,_pluck,_pluck_order,_range,_stripHtml,_unique,_fnBuildAjax,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnAjaxDataSrc,_fnAddColumn,_fnColumnOptions,_fnAdjustColumnSizing,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnVisbleColumns,_fnGetColumns,_fnColumnTypes,_fnApplyColumnDefs,_fnHungarianMap,_fnCamelToHungarian,_fnLanguageCompat,_fnBrowserDetect,_fnAddData,_fnAddTr,_fnNodeToDataIndex,_fnNodeToColumnIndex,_fnGetCellData,_fnSetCellData,_fnSplitObjNotation,_fnGetObjectDataFn,_fnSetObjectDataFn,_fnGetDataMaster,_fnClearTable,_fnDeleteIndex,_fnInvalidate,_fnGetRowElements,_fnCreateTr,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAddOptionsHtml,_fnDetectHeader,_fnGetUniqueThs,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnFilterCreateSearch,_fnEscapeRegex,_fnFilterData,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnInfoMacros,_fnInitialise,_fnInitComplete,_fnLengthChange,_fnFeatureHtmlLength,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnFeatureHtmlTable,_fnScrollDraw,_fnApplyToChildren,_fnCalculateColumnWidths,_fnThrottle,_fnConvertToWidth,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnSortFlatten,_fnSort,_fnSortAria,_fnSortListener,_fnSortAttachListener,_fnSortingClasses,_fnSortData,_fnSaveState,_fnLoadState,_fnSettingsFromNode,_fnLog,_fnMap,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnLengthOverflow,_fnRenderer,_fnDataSource,_fnRowAttributes*/
  24. (function( factory ) {
  25. "use strict";
  26. if ( typeof define === 'function' && define.amd ) {
  27. // AMD
  28. define( ['jquery'], function ( $ ) {
  29. return factory( $, window, document );
  30. } );
  31. }
  32. else if ( typeof exports === 'object' ) {
  33. // CommonJS
  34. module.exports = function (root, $) {
  35. if ( ! root ) {
  36. // CommonJS environments without a window global must pass a
  37. // root. This will give an error otherwise
  38. root = window;
  39. }
  40. if ( ! $ ) {
  41. $ = typeof window !== 'undefined' ? // jQuery's factory checks for a global window
  42. require('jquery') :
  43. require('jquery')( root );
  44. }
  45. return factory( $, root, root.document );
  46. };
  47. }
  48. else {
  49. // Browser
  50. window.DataTable = factory( jQuery, window, document );
  51. }
  52. }
  53. (function( $, window, document, undefined ) {
  54. "use strict";
  55. /**
  56. * DataTables is a plug-in for the jQuery Javascript library. It is a highly
  57. * flexible tool, based upon the foundations of progressive enhancement,
  58. * which will add advanced interaction controls to any HTML table. For a
  59. * full list of features please refer to
  60. * [DataTables.net](href="http://datatables.net).
  61. *
  62. * Note that the `DataTable` object is not a global variable but is aliased
  63. * to `jQuery.fn.DataTable` and `jQuery.fn.dataTable` through which it may
  64. * be accessed.
  65. *
  66. * @class
  67. * @param {object} [init={}] Configuration object for DataTables. Options
  68. * are defined by {@link DataTable.defaults}
  69. * @requires jQuery 1.7+
  70. *
  71. * @example
  72. * // Basic initialisation
  73. * $(document).ready( function {
  74. * $('#example').dataTable();
  75. * } );
  76. *
  77. * @example
  78. * // Initialisation with configuration options - in this case, disable
  79. * // pagination and sorting.
  80. * $(document).ready( function {
  81. * $('#example').dataTable( {
  82. * "paginate": false,
  83. * "sort": false
  84. * } );
  85. * } );
  86. */
  87. var DataTable = function ( selector, options )
  88. {
  89. // When creating with `new`, create a new DataTable, returning the API instance
  90. if (this instanceof DataTable) {
  91. return $(selector).DataTable(options);
  92. }
  93. else {
  94. // Argument switching
  95. options = selector;
  96. }
  97. /**
  98. * Perform a jQuery selector action on the table's TR elements (from the tbody) and
  99. * return the resulting jQuery object.
  100. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  101. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  102. * @param {string} [oOpts.filter=none] Select TR elements that meet the current filter
  103. * criterion ("applied") or all TR elements (i.e. no filter).
  104. * @param {string} [oOpts.order=current] Order of the TR elements in the processed array.
  105. * Can be either 'current', whereby the current sorting of the table is used, or
  106. * 'original' whereby the original order the data was read into the table is used.
  107. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  108. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  109. * 'current' and filter is 'applied', regardless of what they might be given as.
  110. * @returns {object} jQuery object, filtered by the given selector.
  111. * @dtopt API
  112. * @deprecated Since v1.10
  113. *
  114. * @example
  115. * $(document).ready(function() {
  116. * var oTable = $('#example').dataTable();
  117. *
  118. * // Highlight every second row
  119. * oTable.$('tr:odd').css('backgroundColor', 'blue');
  120. * } );
  121. *
  122. * @example
  123. * $(document).ready(function() {
  124. * var oTable = $('#example').dataTable();
  125. *
  126. * // Filter to rows with 'Webkit' in them, add a background colour and then
  127. * // remove the filter, thus highlighting the 'Webkit' rows only.
  128. * oTable.fnFilter('Webkit');
  129. * oTable.$('tr', {"search": "applied"}).css('backgroundColor', 'blue');
  130. * oTable.fnFilter('');
  131. * } );
  132. */
  133. this.$ = function ( sSelector, oOpts )
  134. {
  135. return this.api(true).$( sSelector, oOpts );
  136. };
  137. /**
  138. * Almost identical to $ in operation, but in this case returns the data for the matched
  139. * rows - as such, the jQuery selector used should match TR row nodes or TD/TH cell nodes
  140. * rather than any descendants, so the data can be obtained for the row/cell. If matching
  141. * rows are found, the data returned is the original data array/object that was used to
  142. * create the row (or a generated array if from a DOM source).
  143. *
  144. * This method is often useful in-combination with $ where both functions are given the
  145. * same parameters and the array indexes will match identically.
  146. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  147. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  148. * @param {string} [oOpts.filter=none] Select elements that meet the current filter
  149. * criterion ("applied") or all elements (i.e. no filter).
  150. * @param {string} [oOpts.order=current] Order of the data in the processed array.
  151. * Can be either 'current', whereby the current sorting of the table is used, or
  152. * 'original' whereby the original order the data was read into the table is used.
  153. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  154. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  155. * 'current' and filter is 'applied', regardless of what they might be given as.
  156. * @returns {array} Data for the matched elements. If any elements, as a result of the
  157. * selector, were not TR, TD or TH elements in the DataTable, they will have a null
  158. * entry in the array.
  159. * @dtopt API
  160. * @deprecated Since v1.10
  161. *
  162. * @example
  163. * $(document).ready(function() {
  164. * var oTable = $('#example').dataTable();
  165. *
  166. * // Get the data from the first row in the table
  167. * var data = oTable._('tr:first');
  168. *
  169. * // Do something useful with the data
  170. * alert( "First cell is: "+data[0] );
  171. * } );
  172. *
  173. * @example
  174. * $(document).ready(function() {
  175. * var oTable = $('#example').dataTable();
  176. *
  177. * // Filter to 'Webkit' and get all data for
  178. * oTable.fnFilter('Webkit');
  179. * var data = oTable._('tr', {"search": "applied"});
  180. *
  181. * // Do something with the data
  182. * alert( data.length+" rows matched the search" );
  183. * } );
  184. */
  185. this._ = function ( sSelector, oOpts )
  186. {
  187. return this.api(true).rows( sSelector, oOpts ).data();
  188. };
  189. /**
  190. * Create a DataTables Api instance, with the currently selected tables for
  191. * the Api's context.
  192. * @param {boolean} [traditional=false] Set the API instance's context to be
  193. * only the table referred to by the `DataTable.ext.iApiIndex` option, as was
  194. * used in the API presented by DataTables 1.9- (i.e. the traditional mode),
  195. * or if all tables captured in the jQuery object should be used.
  196. * @return {DataTables.Api}
  197. */
  198. this.api = function ( traditional )
  199. {
  200. return traditional ?
  201. new _Api(
  202. _fnSettingsFromNode( this[ _ext.iApiIndex ] )
  203. ) :
  204. new _Api( this );
  205. };
  206. /**
  207. * Add a single new row or multiple rows of data to the table. Please note
  208. * that this is suitable for client-side processing only - if you are using
  209. * server-side processing (i.e. "bServerSide": true), then to add data, you
  210. * must add it to the data source, i.e. the server-side, through an Ajax call.
  211. * @param {array|object} data The data to be added to the table. This can be:
  212. * <ul>
  213. * <li>1D array of data - add a single row with the data provided</li>
  214. * <li>2D array of arrays - add multiple rows in a single call</li>
  215. * <li>object - data object when using <i>mData</i></li>
  216. * <li>array of objects - multiple data objects when using <i>mData</i></li>
  217. * </ul>
  218. * @param {bool} [redraw=true] redraw the table or not
  219. * @returns {array} An array of integers, representing the list of indexes in
  220. * <i>aoData</i> ({@link DataTable.models.oSettings}) that have been added to
  221. * the table.
  222. * @dtopt API
  223. * @deprecated Since v1.10
  224. *
  225. * @example
  226. * // Global var for counter
  227. * var giCount = 2;
  228. *
  229. * $(document).ready(function() {
  230. * $('#example').dataTable();
  231. * } );
  232. *
  233. * function fnClickAddRow() {
  234. * $('#example').dataTable().fnAddData( [
  235. * giCount+".1",
  236. * giCount+".2",
  237. * giCount+".3",
  238. * giCount+".4" ]
  239. * );
  240. *
  241. * giCount++;
  242. * }
  243. */
  244. this.fnAddData = function( data, redraw )
  245. {
  246. var api = this.api( true );
  247. /* Check if we want to add multiple rows or not */
  248. var rows = Array.isArray(data) && ( Array.isArray(data[0]) || $.isPlainObject(data[0]) ) ?
  249. api.rows.add( data ) :
  250. api.row.add( data );
  251. if ( redraw === undefined || redraw ) {
  252. api.draw();
  253. }
  254. return rows.flatten().toArray();
  255. };
  256. /**
  257. * This function will make DataTables recalculate the column sizes, based on the data
  258. * contained in the table and the sizes applied to the columns (in the DOM, CSS or
  259. * through the sWidth parameter). This can be useful when the width of the table's
  260. * parent element changes (for example a window resize).
  261. * @param {boolean} [bRedraw=true] Redraw the table or not, you will typically want to
  262. * @dtopt API
  263. * @deprecated Since v1.10
  264. *
  265. * @example
  266. * $(document).ready(function() {
  267. * var oTable = $('#example').dataTable( {
  268. * "sScrollY": "200px",
  269. * "bPaginate": false
  270. * } );
  271. *
  272. * $(window).on('resize', function () {
  273. * oTable.fnAdjustColumnSizing();
  274. * } );
  275. * } );
  276. */
  277. this.fnAdjustColumnSizing = function ( bRedraw )
  278. {
  279. var api = this.api( true ).columns.adjust();
  280. var settings = api.settings()[0];
  281. var scroll = settings.oScroll;
  282. if ( bRedraw === undefined || bRedraw ) {
  283. api.draw( false );
  284. }
  285. else if ( scroll.sX !== "" || scroll.sY !== "" ) {
  286. /* If not redrawing, but scrolling, we want to apply the new column sizes anyway */
  287. _fnScrollDraw( settings );
  288. }
  289. };
  290. /**
  291. * Quickly and simply clear a table
  292. * @param {bool} [bRedraw=true] redraw the table or not
  293. * @dtopt API
  294. * @deprecated Since v1.10
  295. *
  296. * @example
  297. * $(document).ready(function() {
  298. * var oTable = $('#example').dataTable();
  299. *
  300. * // Immediately 'nuke' the current rows (perhaps waiting for an Ajax callback...)
  301. * oTable.fnClearTable();
  302. * } );
  303. */
  304. this.fnClearTable = function( bRedraw )
  305. {
  306. var api = this.api( true ).clear();
  307. if ( bRedraw === undefined || bRedraw ) {
  308. api.draw();
  309. }
  310. };
  311. /**
  312. * The exact opposite of 'opening' a row, this function will close any rows which
  313. * are currently 'open'.
  314. * @param {node} nTr the table row to 'close'
  315. * @returns {int} 0 on success, or 1 if failed (can't find the row)
  316. * @dtopt API
  317. * @deprecated Since v1.10
  318. *
  319. * @example
  320. * $(document).ready(function() {
  321. * var oTable;
  322. *
  323. * // 'open' an information row when a row is clicked on
  324. * $('#example tbody tr').click( function () {
  325. * if ( oTable.fnIsOpen(this) ) {
  326. * oTable.fnClose( this );
  327. * } else {
  328. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  329. * }
  330. * } );
  331. *
  332. * oTable = $('#example').dataTable();
  333. * } );
  334. */
  335. this.fnClose = function( nTr )
  336. {
  337. this.api( true ).row( nTr ).child.hide();
  338. };
  339. /**
  340. * Remove a row for the table
  341. * @param {mixed} target The index of the row from aoData to be deleted, or
  342. * the TR element you want to delete
  343. * @param {function|null} [callBack] Callback function
  344. * @param {bool} [redraw=true] Redraw the table or not
  345. * @returns {array} The row that was deleted
  346. * @dtopt API
  347. * @deprecated Since v1.10
  348. *
  349. * @example
  350. * $(document).ready(function() {
  351. * var oTable = $('#example').dataTable();
  352. *
  353. * // Immediately remove the first row
  354. * oTable.fnDeleteRow( 0 );
  355. * } );
  356. */
  357. this.fnDeleteRow = function( target, callback, redraw )
  358. {
  359. var api = this.api( true );
  360. var rows = api.rows( target );
  361. var settings = rows.settings()[0];
  362. var data = settings.aoData[ rows[0][0] ];
  363. rows.remove();
  364. if ( callback ) {
  365. callback.call( this, settings, data );
  366. }
  367. if ( redraw === undefined || redraw ) {
  368. api.draw();
  369. }
  370. return data;
  371. };
  372. /**
  373. * Restore the table to it's original state in the DOM by removing all of DataTables
  374. * enhancements, alterations to the DOM structure of the table and event listeners.
  375. * @param {boolean} [remove=false] Completely remove the table from the DOM
  376. * @dtopt API
  377. * @deprecated Since v1.10
  378. *
  379. * @example
  380. * $(document).ready(function() {
  381. * // This example is fairly pointless in reality, but shows how fnDestroy can be used
  382. * var oTable = $('#example').dataTable();
  383. * oTable.fnDestroy();
  384. * } );
  385. */
  386. this.fnDestroy = function ( remove )
  387. {
  388. this.api( true ).destroy( remove );
  389. };
  390. /**
  391. * Redraw the table
  392. * @param {bool} [complete=true] Re-filter and resort (if enabled) the table before the draw.
  393. * @dtopt API
  394. * @deprecated Since v1.10
  395. *
  396. * @example
  397. * $(document).ready(function() {
  398. * var oTable = $('#example').dataTable();
  399. *
  400. * // Re-draw the table - you wouldn't want to do it here, but it's an example :-)
  401. * oTable.fnDraw();
  402. * } );
  403. */
  404. this.fnDraw = function( complete )
  405. {
  406. // Note that this isn't an exact match to the old call to _fnDraw - it takes
  407. // into account the new data, but can hold position.
  408. this.api( true ).draw( complete );
  409. };
  410. /**
  411. * Filter the input based on data
  412. * @param {string} sInput String to filter the table on
  413. * @param {int|null} [iColumn] Column to limit filtering to
  414. * @param {bool} [bRegex=false] Treat as regular expression or not
  415. * @param {bool} [bSmart=true] Perform smart filtering or not
  416. * @param {bool} [bShowGlobal=true] Show the input global filter in it's input box(es)
  417. * @param {bool} [bCaseInsensitive=true] Do case-insensitive matching (true) or not (false)
  418. * @dtopt API
  419. * @deprecated Since v1.10
  420. *
  421. * @example
  422. * $(document).ready(function() {
  423. * var oTable = $('#example').dataTable();
  424. *
  425. * // Sometime later - filter...
  426. * oTable.fnFilter( 'test string' );
  427. * } );
  428. */
  429. this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal, bCaseInsensitive )
  430. {
  431. var api = this.api( true );
  432. if ( iColumn === null || iColumn === undefined ) {
  433. api.search( sInput, bRegex, bSmart, bCaseInsensitive );
  434. }
  435. else {
  436. api.column( iColumn ).search( sInput, bRegex, bSmart, bCaseInsensitive );
  437. }
  438. api.draw();
  439. };
  440. /**
  441. * Get the data for the whole table, an individual row or an individual cell based on the
  442. * provided parameters.
  443. * @param {int|node} [src] A TR row node, TD/TH cell node or an integer. If given as
  444. * a TR node then the data source for the whole row will be returned. If given as a
  445. * TD/TH cell node then iCol will be automatically calculated and the data for the
  446. * cell returned. If given as an integer, then this is treated as the aoData internal
  447. * data index for the row (see fnGetPosition) and the data for that row used.
  448. * @param {int} [col] Optional column index that you want the data of.
  449. * @returns {array|object|string} If mRow is undefined, then the data for all rows is
  450. * returned. If mRow is defined, just data for that row, and is iCol is
  451. * defined, only data for the designated cell is returned.
  452. * @dtopt API
  453. * @deprecated Since v1.10
  454. *
  455. * @example
  456. * // Row data
  457. * $(document).ready(function() {
  458. * oTable = $('#example').dataTable();
  459. *
  460. * oTable.$('tr').click( function () {
  461. * var data = oTable.fnGetData( this );
  462. * // ... do something with the array / object of data for the row
  463. * } );
  464. * } );
  465. *
  466. * @example
  467. * // Individual cell data
  468. * $(document).ready(function() {
  469. * oTable = $('#example').dataTable();
  470. *
  471. * oTable.$('td').click( function () {
  472. * var sData = oTable.fnGetData( this );
  473. * alert( 'The cell clicked on had the value of '+sData );
  474. * } );
  475. * } );
  476. */
  477. this.fnGetData = function( src, col )
  478. {
  479. var api = this.api( true );
  480. if ( src !== undefined ) {
  481. var type = src.nodeName ? src.nodeName.toLowerCase() : '';
  482. return col !== undefined || type == 'td' || type == 'th' ?
  483. api.cell( src, col ).data() :
  484. api.row( src ).data() || null;
  485. }
  486. return api.data().toArray();
  487. };
  488. /**
  489. * Get an array of the TR nodes that are used in the table's body. Note that you will
  490. * typically want to use the '$' API method in preference to this as it is more
  491. * flexible.
  492. * @param {int} [iRow] Optional row index for the TR element you want
  493. * @returns {array|node} If iRow is undefined, returns an array of all TR elements
  494. * in the table's body, or iRow is defined, just the TR element requested.
  495. * @dtopt API
  496. * @deprecated Since v1.10
  497. *
  498. * @example
  499. * $(document).ready(function() {
  500. * var oTable = $('#example').dataTable();
  501. *
  502. * // Get the nodes from the table
  503. * var nNodes = oTable.fnGetNodes( );
  504. * } );
  505. */
  506. this.fnGetNodes = function( iRow )
  507. {
  508. var api = this.api( true );
  509. return iRow !== undefined ?
  510. api.row( iRow ).node() :
  511. api.rows().nodes().flatten().toArray();
  512. };
  513. /**
  514. * Get the array indexes of a particular cell from it's DOM element
  515. * and column index including hidden columns
  516. * @param {node} node this can either be a TR, TD or TH in the table's body
  517. * @returns {int} If nNode is given as a TR, then a single index is returned, or
  518. * if given as a cell, an array of [row index, column index (visible),
  519. * column index (all)] is given.
  520. * @dtopt API
  521. * @deprecated Since v1.10
  522. *
  523. * @example
  524. * $(document).ready(function() {
  525. * $('#example tbody td').click( function () {
  526. * // Get the position of the current data from the node
  527. * var aPos = oTable.fnGetPosition( this );
  528. *
  529. * // Get the data array for this row
  530. * var aData = oTable.fnGetData( aPos[0] );
  531. *
  532. * // Update the data array and return the value
  533. * aData[ aPos[1] ] = 'clicked';
  534. * this.innerHTML = 'clicked';
  535. * } );
  536. *
  537. * // Init DataTables
  538. * oTable = $('#example').dataTable();
  539. * } );
  540. */
  541. this.fnGetPosition = function( node )
  542. {
  543. var api = this.api( true );
  544. var nodeName = node.nodeName.toUpperCase();
  545. if ( nodeName == 'TR' ) {
  546. return api.row( node ).index();
  547. }
  548. else if ( nodeName == 'TD' || nodeName == 'TH' ) {
  549. var cell = api.cell( node ).index();
  550. return [
  551. cell.row,
  552. cell.columnVisible,
  553. cell.column
  554. ];
  555. }
  556. return null;
  557. };
  558. /**
  559. * Check to see if a row is 'open' or not.
  560. * @param {node} nTr the table row to check
  561. * @returns {boolean} true if the row is currently open, false otherwise
  562. * @dtopt API
  563. * @deprecated Since v1.10
  564. *
  565. * @example
  566. * $(document).ready(function() {
  567. * var oTable;
  568. *
  569. * // 'open' an information row when a row is clicked on
  570. * $('#example tbody tr').click( function () {
  571. * if ( oTable.fnIsOpen(this) ) {
  572. * oTable.fnClose( this );
  573. * } else {
  574. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  575. * }
  576. * } );
  577. *
  578. * oTable = $('#example').dataTable();
  579. * } );
  580. */
  581. this.fnIsOpen = function( nTr )
  582. {
  583. return this.api( true ).row( nTr ).child.isShown();
  584. };
  585. /**
  586. * This function will place a new row directly after a row which is currently
  587. * on display on the page, with the HTML contents that is passed into the
  588. * function. This can be used, for example, to ask for confirmation that a
  589. * particular record should be deleted.
  590. * @param {node} nTr The table row to 'open'
  591. * @param {string|node|jQuery} mHtml The HTML to put into the row
  592. * @param {string} sClass Class to give the new TD cell
  593. * @returns {node} The row opened. Note that if the table row passed in as the
  594. * first parameter, is not found in the table, this method will silently
  595. * return.
  596. * @dtopt API
  597. * @deprecated Since v1.10
  598. *
  599. * @example
  600. * $(document).ready(function() {
  601. * var oTable;
  602. *
  603. * // 'open' an information row when a row is clicked on
  604. * $('#example tbody tr').click( function () {
  605. * if ( oTable.fnIsOpen(this) ) {
  606. * oTable.fnClose( this );
  607. * } else {
  608. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  609. * }
  610. * } );
  611. *
  612. * oTable = $('#example').dataTable();
  613. * } );
  614. */
  615. this.fnOpen = function( nTr, mHtml, sClass )
  616. {
  617. return this.api( true )
  618. .row( nTr )
  619. .child( mHtml, sClass )
  620. .show()
  621. .child()[0];
  622. };
  623. /**
  624. * Change the pagination - provides the internal logic for pagination in a simple API
  625. * function. With this function you can have a DataTables table go to the next,
  626. * previous, first or last pages.
  627. * @param {string|int} mAction Paging action to take: "first", "previous", "next" or "last"
  628. * or page number to jump to (integer), note that page 0 is the first page.
  629. * @param {bool} [bRedraw=true] Redraw the table or not
  630. * @dtopt API
  631. * @deprecated Since v1.10
  632. *
  633. * @example
  634. * $(document).ready(function() {
  635. * var oTable = $('#example').dataTable();
  636. * oTable.fnPageChange( 'next' );
  637. * } );
  638. */
  639. this.fnPageChange = function ( mAction, bRedraw )
  640. {
  641. var api = this.api( true ).page( mAction );
  642. if ( bRedraw === undefined || bRedraw ) {
  643. api.draw(false);
  644. }
  645. };
  646. /**
  647. * Show a particular column
  648. * @param {int} iCol The column whose display should be changed
  649. * @param {bool} bShow Show (true) or hide (false) the column
  650. * @param {bool} [bRedraw=true] Redraw the table or not
  651. * @dtopt API
  652. * @deprecated Since v1.10
  653. *
  654. * @example
  655. * $(document).ready(function() {
  656. * var oTable = $('#example').dataTable();
  657. *
  658. * // Hide the second column after initialisation
  659. * oTable.fnSetColumnVis( 1, false );
  660. * } );
  661. */
  662. this.fnSetColumnVis = function ( iCol, bShow, bRedraw )
  663. {
  664. var api = this.api( true ).column( iCol ).visible( bShow );
  665. if ( bRedraw === undefined || bRedraw ) {
  666. api.columns.adjust().draw();
  667. }
  668. };
  669. /**
  670. * Get the settings for a particular table for external manipulation
  671. * @returns {object} DataTables settings object. See
  672. * {@link DataTable.models.oSettings}
  673. * @dtopt API
  674. * @deprecated Since v1.10
  675. *
  676. * @example
  677. * $(document).ready(function() {
  678. * var oTable = $('#example').dataTable();
  679. * var oSettings = oTable.fnSettings();
  680. *
  681. * // Show an example parameter from the settings
  682. * alert( oSettings._iDisplayStart );
  683. * } );
  684. */
  685. this.fnSettings = function()
  686. {
  687. return _fnSettingsFromNode( this[_ext.iApiIndex] );
  688. };
  689. /**
  690. * Sort the table by a particular column
  691. * @param {int} iCol the data index to sort on. Note that this will not match the
  692. * 'display index' if you have hidden data entries
  693. * @dtopt API
  694. * @deprecated Since v1.10
  695. *
  696. * @example
  697. * $(document).ready(function() {
  698. * var oTable = $('#example').dataTable();
  699. *
  700. * // Sort immediately with columns 0 and 1
  701. * oTable.fnSort( [ [0,'asc'], [1,'asc'] ] );
  702. * } );
  703. */
  704. this.fnSort = function( aaSort )
  705. {
  706. this.api( true ).order( aaSort ).draw();
  707. };
  708. /**
  709. * Attach a sort listener to an element for a given column
  710. * @param {node} nNode the element to attach the sort listener to
  711. * @param {int} iColumn the column that a click on this node will sort on
  712. * @param {function} [fnCallback] callback function when sort is run
  713. * @dtopt API
  714. * @deprecated Since v1.10
  715. *
  716. * @example
  717. * $(document).ready(function() {
  718. * var oTable = $('#example').dataTable();
  719. *
  720. * // Sort on column 1, when 'sorter' is clicked on
  721. * oTable.fnSortListener( document.getElementById('sorter'), 1 );
  722. * } );
  723. */
  724. this.fnSortListener = function( nNode, iColumn, fnCallback )
  725. {
  726. this.api( true ).order.listener( nNode, iColumn, fnCallback );
  727. };
  728. /**
  729. * Update a table cell or row - this method will accept either a single value to
  730. * update the cell with, an array of values with one element for each column or
  731. * an object in the same format as the original data source. The function is
  732. * self-referencing in order to make the multi column updates easier.
  733. * @param {object|array|string} mData Data to update the cell/row with
  734. * @param {node|int} mRow TR element you want to update or the aoData index
  735. * @param {int} [iColumn] The column to update, give as null or undefined to
  736. * update a whole row.
  737. * @param {bool} [bRedraw=true] Redraw the table or not
  738. * @param {bool} [bAction=true] Perform pre-draw actions or not
  739. * @returns {int} 0 on success, 1 on error
  740. * @dtopt API
  741. * @deprecated Since v1.10
  742. *
  743. * @example
  744. * $(document).ready(function() {
  745. * var oTable = $('#example').dataTable();
  746. * oTable.fnUpdate( 'Example update', 0, 0 ); // Single cell
  747. * oTable.fnUpdate( ['a', 'b', 'c', 'd', 'e'], $('tbody tr')[0] ); // Row
  748. * } );
  749. */
  750. this.fnUpdate = function( mData, mRow, iColumn, bRedraw, bAction )
  751. {
  752. var api = this.api( true );
  753. if ( iColumn === undefined || iColumn === null ) {
  754. api.row( mRow ).data( mData );
  755. }
  756. else {
  757. api.cell( mRow, iColumn ).data( mData );
  758. }
  759. if ( bAction === undefined || bAction ) {
  760. api.columns.adjust();
  761. }
  762. if ( bRedraw === undefined || bRedraw ) {
  763. api.draw();
  764. }
  765. return 0;
  766. };
  767. /**
  768. * Provide a common method for plug-ins to check the version of DataTables being used, in order
  769. * to ensure compatibility.
  770. * @param {string} sVersion Version string to check for, in the format "X.Y.Z". Note that the
  771. * formats "X" and "X.Y" are also acceptable.
  772. * @returns {boolean} true if this version of DataTables is greater or equal to the required
  773. * version, or false if this version of DataTales is not suitable
  774. * @method
  775. * @dtopt API
  776. * @deprecated Since v1.10
  777. *
  778. * @example
  779. * $(document).ready(function() {
  780. * var oTable = $('#example').dataTable();
  781. * alert( oTable.fnVersionCheck( '1.9.0' ) );
  782. * } );
  783. */
  784. this.fnVersionCheck = _ext.fnVersionCheck;
  785. var _that = this;
  786. var emptyInit = options === undefined;
  787. var len = this.length;
  788. if ( emptyInit ) {
  789. options = {};
  790. }
  791. this.oApi = this.internal = _ext.internal;
  792. // Extend with old style plug-in API methods
  793. for ( var fn in DataTable.ext.internal ) {
  794. if ( fn ) {
  795. this[fn] = _fnExternApiFunc(fn);
  796. }
  797. }
  798. this.each(function() {
  799. // For each initialisation we want to give it a clean initialisation
  800. // object that can be bashed around
  801. var o = {};
  802. var oInit = len > 1 ? // optimisation for single table case
  803. _fnExtend( o, options, true ) :
  804. options;
  805. /*global oInit,_that,emptyInit*/
  806. var i=0, iLen, j, jLen, k, kLen;
  807. var sId = this.getAttribute( 'id' );
  808. var bInitHandedOff = false;
  809. var defaults = DataTable.defaults;
  810. var $this = $(this);
  811. /* Sanity check */
  812. if ( this.nodeName.toLowerCase() != 'table' )
  813. {
  814. _fnLog( null, 0, 'Non-table node initialisation ('+this.nodeName+')', 2 );
  815. return;
  816. }
  817. /* Backwards compatibility for the defaults */
  818. _fnCompatOpts( defaults );
  819. _fnCompatCols( defaults.column );
  820. /* Convert the camel-case defaults to Hungarian */
  821. _fnCamelToHungarian( defaults, defaults, true );
  822. _fnCamelToHungarian( defaults.column, defaults.column, true );
  823. /* Setting up the initialisation object */
  824. _fnCamelToHungarian( defaults, $.extend( oInit, $this.data() ), true );
  825. /* Check to see if we are re-initialising a table */
  826. var allSettings = DataTable.settings;
  827. for ( i=0, iLen=allSettings.length ; i<iLen ; i++ )
  828. {
  829. var s = allSettings[i];
  830. /* Base check on table node */
  831. if (
  832. s.nTable == this ||
  833. (s.nTHead && s.nTHead.parentNode == this) ||
  834. (s.nTFoot && s.nTFoot.parentNode == this)
  835. ) {
  836. var bRetrieve = oInit.bRetrieve !== undefined ? oInit.bRetrieve : defaults.bRetrieve;
  837. var bDestroy = oInit.bDestroy !== undefined ? oInit.bDestroy : defaults.bDestroy;
  838. if ( emptyInit || bRetrieve )
  839. {
  840. return s.oInstance;
  841. }
  842. else if ( bDestroy )
  843. {
  844. s.oInstance.fnDestroy();
  845. break;
  846. }
  847. else
  848. {
  849. _fnLog( s, 0, 'Cannot reinitialise DataTable', 3 );
  850. return;
  851. }
  852. }
  853. /* If the element we are initialising has the same ID as a table which was previously
  854. * initialised, but the table nodes don't match (from before) then we destroy the old
  855. * instance by simply deleting it. This is under the assumption that the table has been
  856. * destroyed by other methods. Anyone using non-id selectors will need to do this manually
  857. */
  858. if ( s.sTableId == this.id )
  859. {
  860. allSettings.splice( i, 1 );
  861. break;
  862. }
  863. }
  864. /* Ensure the table has an ID - required for accessibility */
  865. if ( sId === null || sId === "" )
  866. {
  867. sId = "DataTables_Table_"+(DataTable.ext._unique++);
  868. this.id = sId;
  869. }
  870. /* Create the settings object for this table and set some of the default parameters */
  871. var oSettings = $.extend( true, {}, DataTable.models.oSettings, {
  872. "sDestroyWidth": $this[0].style.width,
  873. "sInstance": sId,
  874. "sTableId": sId
  875. } );
  876. oSettings.nTable = this;
  877. oSettings.oApi = _that.internal;
  878. oSettings.oInit = oInit;
  879. allSettings.push( oSettings );
  880. // Need to add the instance after the instance after the settings object has been added
  881. // to the settings array, so we can self reference the table instance if more than one
  882. oSettings.oInstance = (_that.length===1) ? _that : $this.dataTable();
  883. // Backwards compatibility, before we apply all the defaults
  884. _fnCompatOpts( oInit );
  885. _fnLanguageCompat( oInit.oLanguage );
  886. // If the length menu is given, but the init display length is not, use the length menu
  887. if ( oInit.aLengthMenu && ! oInit.iDisplayLength )
  888. {
  889. oInit.iDisplayLength = Array.isArray( oInit.aLengthMenu[0] ) ?
  890. oInit.aLengthMenu[0][0] : oInit.aLengthMenu[0];
  891. }
  892. // Apply the defaults and init options to make a single init object will all
  893. // options defined from defaults and instance options.
  894. oInit = _fnExtend( $.extend( true, {}, defaults ), oInit );
  895. // Map the initialisation options onto the settings object
  896. _fnMap( oSettings.oFeatures, oInit, [
  897. "bPaginate",
  898. "bLengthChange",
  899. "bFilter",
  900. "bSort",
  901. "bSortMulti",
  902. "bInfo",
  903. "bProcessing",
  904. "bAutoWidth",
  905. "bSortClasses",
  906. "bServerSide",
  907. "bDeferRender"
  908. ] );
  909. _fnMap( oSettings, oInit, [
  910. "asStripeClasses",
  911. "ajax",
  912. "fnServerData",
  913. "fnFormatNumber",
  914. "sServerMethod",
  915. "aaSorting",
  916. "aaSortingFixed",
  917. "aLengthMenu",
  918. "sPaginationType",
  919. "sAjaxSource",
  920. "sAjaxDataProp",
  921. "iStateDuration",
  922. "sDom",
  923. "bSortCellsTop",
  924. "iTabIndex",
  925. "fnStateLoadCallback",
  926. "fnStateSaveCallback",
  927. "renderer",
  928. "searchDelay",
  929. "rowId",
  930. [ "iCookieDuration", "iStateDuration" ], // backwards compat
  931. [ "oSearch", "oPreviousSearch" ],
  932. [ "aoSearchCols", "aoPreSearchCols" ],
  933. [ "iDisplayLength", "_iDisplayLength" ]
  934. ] );
  935. _fnMap( oSettings.oScroll, oInit, [
  936. [ "sScrollX", "sX" ],
  937. [ "sScrollXInner", "sXInner" ],
  938. [ "sScrollY", "sY" ],
  939. [ "bScrollCollapse", "bCollapse" ]
  940. ] );
  941. _fnMap( oSettings.oLanguage, oInit, "fnInfoCallback" );
  942. /* Callback functions which are array driven */
  943. _fnCallbackReg( oSettings, 'aoDrawCallback', oInit.fnDrawCallback, 'user' );
  944. _fnCallbackReg( oSettings, 'aoServerParams', oInit.fnServerParams, 'user' );
  945. _fnCallbackReg( oSettings, 'aoStateSaveParams', oInit.fnStateSaveParams, 'user' );
  946. _fnCallbackReg( oSettings, 'aoStateLoadParams', oInit.fnStateLoadParams, 'user' );
  947. _fnCallbackReg( oSettings, 'aoStateLoaded', oInit.fnStateLoaded, 'user' );
  948. _fnCallbackReg( oSettings, 'aoRowCallback', oInit.fnRowCallback, 'user' );
  949. _fnCallbackReg( oSettings, 'aoRowCreatedCallback', oInit.fnCreatedRow, 'user' );
  950. _fnCallbackReg( oSettings, 'aoHeaderCallback', oInit.fnHeaderCallback, 'user' );
  951. _fnCallbackReg( oSettings, 'aoFooterCallback', oInit.fnFooterCallback, 'user' );
  952. _fnCallbackReg( oSettings, 'aoInitComplete', oInit.fnInitComplete, 'user' );
  953. _fnCallbackReg( oSettings, 'aoPreDrawCallback', oInit.fnPreDrawCallback, 'user' );
  954. oSettings.rowIdFn = _fnGetObjectDataFn( oInit.rowId );
  955. /* Browser support detection */
  956. _fnBrowserDetect( oSettings );
  957. var oClasses = oSettings.oClasses;
  958. $.extend( oClasses, DataTable.ext.classes, oInit.oClasses );
  959. $this.addClass( oClasses.sTable );
  960. if ( oSettings.iInitDisplayStart === undefined )
  961. {
  962. /* Display start point, taking into account the save saving */
  963. oSettings.iInitDisplayStart = oInit.iDisplayStart;
  964. oSettings._iDisplayStart = oInit.iDisplayStart;
  965. }
  966. if ( oInit.iDeferLoading !== null )
  967. {
  968. oSettings.bDeferLoading = true;
  969. var tmp = Array.isArray( oInit.iDeferLoading );
  970. oSettings._iRecordsDisplay = tmp ? oInit.iDeferLoading[0] : oInit.iDeferLoading;
  971. oSettings._iRecordsTotal = tmp ? oInit.iDeferLoading[1] : oInit.iDeferLoading;
  972. }
  973. /* Language definitions */
  974. var oLanguage = oSettings.oLanguage;
  975. $.extend( true, oLanguage, oInit.oLanguage );
  976. if ( oLanguage.sUrl )
  977. {
  978. /* Get the language definitions from a file - because this Ajax call makes the language
  979. * get async to the remainder of this function we use bInitHandedOff to indicate that
  980. * _fnInitialise will be fired by the returned Ajax handler, rather than the constructor
  981. */
  982. $.ajax( {
  983. dataType: 'json',
  984. url: oLanguage.sUrl,
  985. success: function ( json ) {
  986. _fnCamelToHungarian( defaults.oLanguage, json );
  987. _fnLanguageCompat( json );
  988. $.extend( true, oLanguage, json );
  989. _fnCallbackFire( oSettings, null, 'i18n', [oSettings]);
  990. _fnInitialise( oSettings );
  991. },
  992. error: function () {
  993. // Error occurred loading language file, continue on as best we can
  994. _fnInitialise( oSettings );
  995. }
  996. } );
  997. bInitHandedOff = true;
  998. }
  999. else {
  1000. _fnCallbackFire( oSettings, null, 'i18n', [oSettings]);
  1001. }
  1002. /*
  1003. * Stripes
  1004. */
  1005. if ( oInit.asStripeClasses === null )
  1006. {
  1007. oSettings.asStripeClasses =[
  1008. oClasses.sStripeOdd,
  1009. oClasses.sStripeEven
  1010. ];
  1011. }
  1012. /* Remove row stripe classes if they are already on the table row */
  1013. var stripeClasses = oSettings.asStripeClasses;
  1014. var rowOne = $this.children('tbody').find('tr').eq(0);
  1015. if ( $.inArray( true, $.map( stripeClasses, function(el, i) {
  1016. return rowOne.hasClass(el);
  1017. } ) ) !== -1 ) {
  1018. $('tbody tr', this).removeClass( stripeClasses.join(' ') );
  1019. oSettings.asDestroyStripes = stripeClasses.slice();
  1020. }
  1021. /*
  1022. * Columns
  1023. * See if we should load columns automatically or use defined ones
  1024. */
  1025. var anThs = [];
  1026. var aoColumnsInit;
  1027. var nThead = this.getElementsByTagName('thead');
  1028. if ( nThead.length !== 0 )
  1029. {
  1030. _fnDetectHeader( oSettings.aoHeader, nThead[0] );
  1031. anThs = _fnGetUniqueThs( oSettings );
  1032. }
  1033. /* If not given a column array, generate one with nulls */
  1034. if ( oInit.aoColumns === null )
  1035. {
  1036. aoColumnsInit = [];
  1037. for ( i=0, iLen=anThs.length ; i<iLen ; i++ )
  1038. {
  1039. aoColumnsInit.push( null );
  1040. }
  1041. }
  1042. else
  1043. {
  1044. aoColumnsInit = oInit.aoColumns;
  1045. }
  1046. /* Add the columns */
  1047. for ( i=0, iLen=aoColumnsInit.length ; i<iLen ; i++ )
  1048. {
  1049. _fnAddColumn( oSettings, anThs ? anThs[i] : null );
  1050. }
  1051. /* Apply the column definitions */
  1052. _fnApplyColumnDefs( oSettings, oInit.aoColumnDefs, aoColumnsInit, function (iCol, oDef) {
  1053. _fnColumnOptions( oSettings, iCol, oDef );
  1054. } );
  1055. /* HTML5 attribute detection - build an mData object automatically if the
  1056. * attributes are found
  1057. */
  1058. if ( rowOne.length ) {
  1059. var a = function ( cell, name ) {
  1060. return cell.getAttribute( 'data-'+name ) !== null ? name : null;
  1061. };
  1062. $( rowOne[0] ).children('th, td').each( function (i, cell) {
  1063. var col = oSettings.aoColumns[i];
  1064. if ( col.mData === i ) {
  1065. var sort = a( cell, 'sort' ) || a( cell, 'order' );
  1066. var filter = a( cell, 'filter' ) || a( cell, 'search' );
  1067. if ( sort !== null || filter !== null ) {
  1068. col.mData = {
  1069. _: i+'.display',
  1070. sort: sort !== null ? i+'.@data-'+sort : undefined,
  1071. type: sort !== null ? i+'.@data-'+sort : undefined,
  1072. filter: filter !== null ? i+'.@data-'+filter : undefined
  1073. };
  1074. _fnColumnOptions( oSettings, i );
  1075. }
  1076. }
  1077. } );
  1078. }
  1079. var features = oSettings.oFeatures;
  1080. var loadedInit = function () {
  1081. /*
  1082. * Sorting
  1083. * @todo For modularisation (1.11) this needs to do into a sort start up handler
  1084. */
  1085. // If aaSorting is not defined, then we use the first indicator in asSorting
  1086. // in case that has been altered, so the default sort reflects that option
  1087. if ( oInit.aaSorting === undefined ) {
  1088. var sorting = oSettings.aaSorting;
  1089. for ( i=0, iLen=sorting.length ; i<iLen ; i++ ) {
  1090. sorting[i][1] = oSettings.aoColumns[ i ].asSorting[0];
  1091. }
  1092. }
  1093. /* Do a first pass on the sorting classes (allows any size changes to be taken into
  1094. * account, and also will apply sorting disabled classes if disabled
  1095. */
  1096. _fnSortingClasses( oSettings );
  1097. if ( features.bSort ) {
  1098. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  1099. if ( oSettings.bSorted ) {
  1100. var aSort = _fnSortFlatten( oSettings );
  1101. var sortedColumns = {};
  1102. $.each( aSort, function (i, val) {
  1103. sortedColumns[ val.src ] = val.dir;
  1104. } );
  1105. _fnCallbackFire( oSettings, null, 'order', [oSettings, aSort, sortedColumns] );
  1106. _fnSortAria( oSettings );
  1107. }
  1108. } );
  1109. }
  1110. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  1111. if ( oSettings.bSorted || _fnDataSource( oSettings ) === 'ssp' || features.bDeferRender ) {
  1112. _fnSortingClasses( oSettings );
  1113. }
  1114. }, 'sc' );
  1115. /*
  1116. * Final init
  1117. * Cache the header, body and footer as required, creating them if needed
  1118. */
  1119. // Work around for Webkit bug 83867 - store the caption-side before removing from doc
  1120. var captions = $this.children('caption').each( function () {
  1121. this._captionSide = $(this).css('caption-side');
  1122. } );
  1123. var thead = $this.children('thead');
  1124. if ( thead.length === 0 ) {
  1125. thead = $('<thead/>').appendTo($this);
  1126. }
  1127. oSettings.nTHead = thead[0];
  1128. var tbody = $this.children('tbody');
  1129. if ( tbody.length === 0 ) {
  1130. tbody = $('<tbody/>').insertAfter(thead);
  1131. }
  1132. oSettings.nTBody = tbody[0];
  1133. var tfoot = $this.children('tfoot');
  1134. if ( tfoot.length === 0 && captions.length > 0 && (oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "") ) {
  1135. // If we are a scrolling table, and no footer has been given, then we need to create
  1136. // a tfoot element for the caption element to be appended to
  1137. tfoot = $('<tfoot/>').appendTo($this);
  1138. }
  1139. if ( tfoot.length === 0 || tfoot.children().length === 0 ) {
  1140. $this.addClass( oClasses.sNoFooter );
  1141. }
  1142. else if ( tfoot.length > 0 ) {
  1143. oSettings.nTFoot = tfoot[0];
  1144. _fnDetectHeader( oSettings.aoFooter, oSettings.nTFoot );
  1145. }
  1146. /* Check if there is data passing into the constructor */
  1147. if ( oInit.aaData ) {
  1148. for ( i=0 ; i<oInit.aaData.length ; i++ ) {
  1149. _fnAddData( oSettings, oInit.aaData[ i ] );
  1150. }
  1151. }
  1152. else if ( oSettings.bDeferLoading || _fnDataSource( oSettings ) == 'dom' ) {
  1153. /* Grab the data from the page - only do this when deferred loading or no Ajax
  1154. * source since there is no point in reading the DOM data if we are then going
  1155. * to replace it with Ajax data
  1156. */
  1157. _fnAddTr( oSettings, $(oSettings.nTBody).children('tr') );
  1158. }
  1159. /* Copy the data index array */
  1160. oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
  1161. /* Initialisation complete - table can be drawn */
  1162. oSettings.bInitialised = true;
  1163. /* Check if we need to initialise the table (it might not have been handed off to the
  1164. * language processor)
  1165. */
  1166. if ( bInitHandedOff === false ) {
  1167. _fnInitialise( oSettings );
  1168. }
  1169. };
  1170. /* Must be done after everything which can be overridden by the state saving! */
  1171. _fnCallbackReg( oSettings, 'aoDrawCallback', _fnSaveState, 'state_save' );
  1172. if ( oInit.bStateSave )
  1173. {
  1174. features.bStateSave = true;
  1175. _fnLoadState( oSettings, oInit, loadedInit );
  1176. }
  1177. else {
  1178. loadedInit();
  1179. }
  1180. } );
  1181. _that = null;
  1182. return this;
  1183. };
  1184. /*
  1185. * It is useful to have variables which are scoped locally so only the
  1186. * DataTables functions can access them and they don't leak into global space.
  1187. * At the same time these functions are often useful over multiple files in the
  1188. * core and API, so we list, or at least document, all variables which are used
  1189. * by DataTables as private variables here. This also ensures that there is no
  1190. * clashing of variable names and that they can easily referenced for reuse.
  1191. */
  1192. // Defined else where
  1193. // _selector_run
  1194. // _selector_opts
  1195. // _selector_first
  1196. // _selector_row_indexes
  1197. var _ext; // DataTable.ext
  1198. var _Api; // DataTable.Api
  1199. var _api_register; // DataTable.Api.register
  1200. var _api_registerPlural; // DataTable.Api.registerPlural
  1201. var _re_dic = {};
  1202. var _re_new_lines = /[\r\n\u2028]/g;
  1203. var _re_html = /<.*?>/g;
  1204. // This is not strict ISO8601 - Date.parse() is quite lax, although
  1205. // implementations differ between browsers.
  1206. var _re_date = /^\d{2,4}[\.\/\-]\d{1,2}[\.\/\-]\d{1,2}([T ]{1}\d{1,2}[:\.]\d{2}([\.:]\d{2})?)?$/;
  1207. // Escape regular expression special characters
  1208. var _re_escape_regex = new RegExp( '(\\' + [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^', '-' ].join('|\\') + ')', 'g' );
  1209. // http://en.wikipedia.org/wiki/Foreign_exchange_market
  1210. // - \u20BD - Russian ruble.
  1211. // - \u20a9 - South Korean Won
  1212. // - \u20BA - Turkish Lira
  1213. // - \u20B9 - Indian Rupee
  1214. // - R - Brazil (R$) and South Africa
  1215. // - fr - Swiss Franc
  1216. // - kr - Swedish krona, Norwegian krone and Danish krone
  1217. // - \u2009 is thin space and \u202F is narrow no-break space, both used in many
  1218. // - Ƀ - Bitcoin
  1219. // - Ξ - Ethereum
  1220. // standards as thousands separators.
  1221. var _re_formatted_numeric = /['\u00A0,$£€¥%\u2009\u202F\u20BD\u20a9\u20BArfkɃΞ]/gi;
  1222. var _empty = function ( d ) {
  1223. return !d || d === true || d === '-' ? true : false;
  1224. };
  1225. var _intVal = function ( s ) {
  1226. var integer = parseInt( s, 10 );
  1227. return !isNaN(integer) && isFinite(s) ? integer : null;
  1228. };
  1229. // Convert from a formatted number with characters other than `.` as the
  1230. // decimal place, to a Javascript number
  1231. var _numToDecimal = function ( num, decimalPoint ) {
  1232. // Cache created regular expressions for speed as this function is called often
  1233. if ( ! _re_dic[ decimalPoint ] ) {
  1234. _re_dic[ decimalPoint ] = new RegExp( _fnEscapeRegex( decimalPoint ), 'g' );
  1235. }
  1236. return typeof num === 'string' && decimalPoint !== '.' ?
  1237. num.replace( /\./g, '' ).replace( _re_dic[ decimalPoint ], '.' ) :
  1238. num;
  1239. };
  1240. var _isNumber = function ( d, decimalPoint, formatted ) {
  1241. var strType = typeof d === 'string';
  1242. // If empty return immediately so there must be a number if it is a
  1243. // formatted string (this stops the string "k", or "kr", etc being detected
  1244. // as a formatted number for currency
  1245. if ( _empty( d ) ) {
  1246. return true;
  1247. }
  1248. if ( decimalPoint && strType ) {
  1249. d = _numToDecimal( d, decimalPoint );
  1250. }
  1251. if ( formatted && strType ) {
  1252. d = d.replace( _re_formatted_numeric, '' );
  1253. }
  1254. return !isNaN( parseFloat(d) ) && isFinite( d );
  1255. };
  1256. // A string without HTML in it can be considered to be HTML still
  1257. var _isHtml = function ( d ) {
  1258. return _empty( d ) || typeof d === 'string';
  1259. };
  1260. var _htmlNumeric = function ( d, decimalPoint, formatted ) {
  1261. if ( _empty( d ) ) {
  1262. return true;
  1263. }
  1264. var html = _isHtml( d );
  1265. return ! html ?
  1266. null :
  1267. _isNumber( _stripHtml( d ), decimalPoint, formatted ) ?
  1268. true :
  1269. null;
  1270. };
  1271. var _pluck = function ( a, prop, prop2 ) {
  1272. var out = [];
  1273. var i=0, ien=a.length;
  1274. // Could have the test in the loop for slightly smaller code, but speed
  1275. // is essential here
  1276. if ( prop2 !== undefined ) {
  1277. for ( ; i<ien ; i++ ) {
  1278. if ( a[i] && a[i][ prop ] ) {
  1279. out.push( a[i][ prop ][ prop2 ] );
  1280. }
  1281. }
  1282. }
  1283. else {
  1284. for ( ; i<ien ; i++ ) {
  1285. if ( a[i] ) {
  1286. out.push( a[i][ prop ] );
  1287. }
  1288. }
  1289. }
  1290. return out;
  1291. };
  1292. // Basically the same as _pluck, but rather than looping over `a` we use `order`
  1293. // as the indexes to pick from `a`
  1294. var _pluck_order = function ( a, order, prop, prop2 )
  1295. {
  1296. var out = [];
  1297. var i=0, ien=order.length;
  1298. // Could have the test in the loop for slightly smaller code, but speed
  1299. // is essential here
  1300. if ( prop2 !== undefined ) {
  1301. for ( ; i<ien ; i++ ) {
  1302. if ( a[ order[i] ][ prop ] ) {
  1303. out.push( a[ order[i] ][ prop ][ prop2 ] );
  1304. }
  1305. }
  1306. }
  1307. else {
  1308. for ( ; i<ien ; i++ ) {
  1309. out.push( a[ order[i] ][ prop ] );
  1310. }
  1311. }
  1312. return out;
  1313. };
  1314. var _range = function ( len, start )
  1315. {
  1316. var out = [];
  1317. var end;
  1318. if ( start === undefined ) {
  1319. start = 0;
  1320. end = len;
  1321. }
  1322. else {
  1323. end = start;
  1324. start = len;
  1325. }
  1326. for ( var i=start ; i<end ; i++ ) {
  1327. out.push( i );
  1328. }
  1329. return out;
  1330. };
  1331. var _removeEmpty = function ( a )
  1332. {
  1333. var out = [];
  1334. for ( var i=0, ien=a.length ; i<ien ; i++ ) {
  1335. if ( a[i] ) { // careful - will remove all falsy values!
  1336. out.push( a[i] );
  1337. }
  1338. }
  1339. return out;
  1340. };
  1341. var _stripHtml = function ( d ) {
  1342. return d.replace( _re_html, '' );
  1343. };
  1344. /**
  1345. * Determine if all values in the array are unique. This means we can short
  1346. * cut the _unique method at the cost of a single loop. A sorted array is used
  1347. * to easily check the values.
  1348. *
  1349. * @param {array} src Source array
  1350. * @return {boolean} true if all unique, false otherwise
  1351. * @ignore
  1352. */
  1353. var _areAllUnique = function ( src ) {
  1354. if ( src.length < 2 ) {
  1355. return true;
  1356. }
  1357. var sorted = src.slice().sort();
  1358. var last = sorted[0];
  1359. for ( var i=1, ien=sorted.length ; i<ien ; i++ ) {
  1360. if ( sorted[i] === last ) {
  1361. return false;
  1362. }
  1363. last = sorted[i];
  1364. }
  1365. return true;
  1366. };
  1367. /**
  1368. * Find the unique elements in a source array.
  1369. *
  1370. * @param {array} src Source array
  1371. * @return {array} Array of unique items
  1372. * @ignore
  1373. */
  1374. var _unique = function ( src )
  1375. {
  1376. if ( _areAllUnique( src ) ) {
  1377. return src.slice();
  1378. }
  1379. // A faster unique method is to use object keys to identify used values,
  1380. // but this doesn't work with arrays or objects, which we must also
  1381. // consider. See jsperf.com/compare-array-unique-versions/4 for more
  1382. // information.
  1383. var
  1384. out = [],
  1385. val,
  1386. i, ien=src.length,
  1387. j, k=0;
  1388. again: for ( i=0 ; i<ien ; i++ ) {
  1389. val = src[i];
  1390. for ( j=0 ; j<k ; j++ ) {
  1391. if ( out[j] === val ) {
  1392. continue again;
  1393. }
  1394. }
  1395. out.push( val );
  1396. k++;
  1397. }
  1398. return out;
  1399. };
  1400. // Surprisingly this is faster than [].concat.apply
  1401. // https://jsperf.com/flatten-an-array-loop-vs-reduce/2
  1402. var _flatten = function (out, val) {
  1403. if (Array.isArray(val)) {
  1404. for (var i=0 ; i<val.length ; i++) {
  1405. _flatten(out, val[i]);
  1406. }
  1407. }
  1408. else {
  1409. out.push(val);
  1410. }
  1411. return out;
  1412. }
  1413. var _includes = function (search, start) {
  1414. if (start === undefined) {
  1415. start = 0;
  1416. }
  1417. return this.indexOf(search, start) !== -1;
  1418. };
  1419. // Array.isArray polyfill.
  1420. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
  1421. if (! Array.isArray) {
  1422. Array.isArray = function(arg) {
  1423. return Object.prototype.toString.call(arg) === '[object Array]';
  1424. };
  1425. }
  1426. if (! Array.prototype.includes) {
  1427. Array.prototype.includes = _includes;
  1428. }
  1429. // .trim() polyfill
  1430. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim
  1431. if (!String.prototype.trim) {
  1432. String.prototype.trim = function () {
  1433. return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
  1434. };
  1435. }
  1436. if (! String.prototype.includes) {
  1437. String.prototype.includes = _includes;
  1438. }
  1439. /**
  1440. * DataTables utility methods
  1441. *
  1442. * This namespace provides helper methods that DataTables uses internally to
  1443. * create a DataTable, but which are not exclusively used only for DataTables.
  1444. * These methods can be used by extension authors to save the duplication of
  1445. * code.
  1446. *
  1447. * @namespace
  1448. */
  1449. DataTable.util = {
  1450. /**
  1451. * Throttle the calls to a function. Arguments and context are maintained
  1452. * for the throttled function.
  1453. *
  1454. * @param {function} fn Function to be called
  1455. * @param {integer} freq Call frequency in mS
  1456. * @return {function} Wrapped function
  1457. */
  1458. throttle: function ( fn, freq ) {
  1459. var
  1460. frequency = freq !== undefined ? freq : 200,
  1461. last,
  1462. timer;
  1463. return function () {
  1464. var
  1465. that = this,
  1466. now = +new Date(),
  1467. args = arguments;
  1468. if ( last && now < last + frequency ) {
  1469. clearTimeout( timer );
  1470. timer = setTimeout( function () {
  1471. last = undefined;
  1472. fn.apply( that, args );
  1473. }, frequency );
  1474. }
  1475. else {
  1476. last = now;
  1477. fn.apply( that, args );
  1478. }
  1479. };
  1480. },
  1481. /**
  1482. * Escape a string such that it can be used in a regular expression
  1483. *
  1484. * @param {string} val string to escape
  1485. * @returns {string} escaped string
  1486. */
  1487. escapeRegex: function ( val ) {
  1488. return val.replace( _re_escape_regex, '\\$1' );
  1489. },
  1490. /**
  1491. * Create a function that will write to a nested object or array
  1492. * @param {*} source JSON notation string
  1493. * @returns Write function
  1494. */
  1495. set: function ( source ) {
  1496. if ( $.isPlainObject( source ) ) {
  1497. /* Unlike get, only the underscore (global) option is used for for
  1498. * setting data since we don't know the type here. This is why an object
  1499. * option is not documented for `mData` (which is read/write), but it is
  1500. * for `mRender` which is read only.
  1501. */
  1502. return DataTable.util.set( source._ );
  1503. }
  1504. else if ( source === null ) {
  1505. // Nothing to do when the data source is null
  1506. return function () {};
  1507. }
  1508. else if ( typeof source === 'function' ) {
  1509. return function (data, val, meta) {
  1510. source( data, 'set', val, meta );
  1511. };
  1512. }
  1513. else if ( typeof source === 'string' && (source.indexOf('.') !== -1 ||
  1514. source.indexOf('[') !== -1 || source.indexOf('(') !== -1) )
  1515. {
  1516. // Like the get, we need to get data from a nested object
  1517. var setData = function (data, val, src) {
  1518. var a = _fnSplitObjNotation( src ), b;
  1519. var aLast = a[a.length-1];
  1520. var arrayNotation, funcNotation, o, innerSrc;
  1521. for ( var i=0, iLen=a.length-1 ; i<iLen ; i++ ) {
  1522. // Protect against prototype pollution
  1523. if (a[i] === '__proto__' || a[i] === 'constructor') {
  1524. throw new Error('Cannot set prototype values');
  1525. }
  1526. // Check if we are dealing with an array notation request
  1527. arrayNotation = a[i].match(__reArray);
  1528. funcNotation = a[i].match(__reFn);
  1529. if ( arrayNotation ) {
  1530. a[i] = a[i].replace(__reArray, '');
  1531. data[ a[i] ] = [];
  1532. // Get the remainder of the nested object to set so we can recurse
  1533. b = a.slice();
  1534. b.splice( 0, i+1 );
  1535. innerSrc = b.join('.');
  1536. // Traverse each entry in the array setting the properties requested
  1537. if ( Array.isArray( val ) ) {
  1538. for ( var j=0, jLen=val.length ; j<jLen ; j++ ) {
  1539. o = {};
  1540. setData( o, val[j], innerSrc );
  1541. data[ a[i] ].push( o );
  1542. }
  1543. }
  1544. else {
  1545. // We've been asked to save data to an array, but it
  1546. // isn't array data to be saved. Best that can be done
  1547. // is to just save the value.
  1548. data[ a[i] ] = val;
  1549. }
  1550. // The inner call to setData has already traversed through the remainder
  1551. // of the source and has set the data, thus we can exit here
  1552. return;
  1553. }
  1554. else if ( funcNotation ) {
  1555. // Function call
  1556. a[i] = a[i].replace(__reFn, '');
  1557. data = data[ a[i] ]( val );
  1558. }
  1559. // If the nested object doesn't currently exist - since we are
  1560. // trying to set the value - create it
  1561. if ( data[ a[i] ] === null || data[ a[i] ] === undefined ) {
  1562. data[ a[i] ] = {};
  1563. }
  1564. data = data[ a[i] ];
  1565. }
  1566. // Last item in the input - i.e, the actual set
  1567. if ( aLast.match(__reFn ) ) {
  1568. // Function call
  1569. data = data[ aLast.replace(__reFn, '') ]( val );
  1570. }
  1571. else {
  1572. // If array notation is used, we just want to strip it and use the property name
  1573. // and assign the value. If it isn't used, then we get the result we want anyway
  1574. data[ aLast.replace(__reArray, '') ] = val;
  1575. }
  1576. };
  1577. return function (data, val) { // meta is also passed in, but not used
  1578. return setData( data, val, source );
  1579. };
  1580. }
  1581. else {
  1582. // Array or flat object mapping
  1583. return function (data, val) { // meta is also passed in, but not used
  1584. data[source] = val;
  1585. };
  1586. }
  1587. },
  1588. /**
  1589. * Create a function that will read nested objects from arrays, based on JSON notation
  1590. * @param {*} source JSON notation string
  1591. * @returns Value read
  1592. */
  1593. get: function ( source ) {
  1594. if ( $.isPlainObject( source ) ) {
  1595. // Build an object of get functions, and wrap them in a single call
  1596. var o = {};
  1597. $.each( source, function (key, val) {
  1598. if ( val ) {
  1599. o[key] = DataTable.util.get( val );
  1600. }
  1601. } );
  1602. return function (data, type, row, meta) {
  1603. var t = o[type] || o._;
  1604. return t !== undefined ?
  1605. t(data, type, row, meta) :
  1606. data;
  1607. };
  1608. }
  1609. else if ( source === null ) {
  1610. // Give an empty string for rendering / sorting etc
  1611. return function (data) { // type, row and meta also passed, but not used
  1612. return data;
  1613. };
  1614. }
  1615. else if ( typeof source === 'function' ) {
  1616. return function (data, type, row, meta) {
  1617. return source( data, type, row, meta );
  1618. };
  1619. }
  1620. else if ( typeof source === 'string' && (source.indexOf('.') !== -1 ||
  1621. source.indexOf('[') !== -1 || source.indexOf('(') !== -1) )
  1622. {
  1623. /* If there is a . in the source string then the data source is in a
  1624. * nested object so we loop over the data for each level to get the next
  1625. * level down. On each loop we test for undefined, and if found immediately
  1626. * return. This allows entire objects to be missing and sDefaultContent to
  1627. * be used if defined, rather than throwing an error
  1628. */
  1629. var fetchData = function (data, type, src) {
  1630. var arrayNotation, funcNotation, out, innerSrc;
  1631. if ( src !== "" ) {
  1632. var a = _fnSplitObjNotation( src );
  1633. for ( var i=0, iLen=a.length ; i<iLen ; i++ ) {
  1634. // Check if we are dealing with special notation
  1635. arrayNotation = a[i].match(__reArray);
  1636. funcNotation = a[i].match(__reFn);
  1637. if ( arrayNotation ) {
  1638. // Array notation
  1639. a[i] = a[i].replace(__reArray, '');
  1640. // Condition allows simply [] to be passed in
  1641. if ( a[i] !== "" ) {
  1642. data = data[ a[i] ];
  1643. }
  1644. out = [];
  1645. // Get the remainder of the nested object to get
  1646. a.splice( 0, i+1 );
  1647. innerSrc = a.join('.');
  1648. // Traverse each entry in the array getting the properties requested
  1649. if ( Array.isArray( data ) ) {
  1650. for ( var j=0, jLen=data.length ; j<jLen ; j++ ) {
  1651. out.push( fetchData( data[j], type, innerSrc ) );
  1652. }
  1653. }
  1654. // If a string is given in between the array notation indicators, that
  1655. // is used to join the strings together, otherwise an array is returned
  1656. var join = arrayNotation[0].substring(1, arrayNotation[0].length-1);
  1657. data = (join==="") ? out : out.join(join);
  1658. // The inner call to fetchData has already traversed through the remainder
  1659. // of the source requested, so we exit from the loop
  1660. break;
  1661. }
  1662. else if ( funcNotation ) {
  1663. // Function call
  1664. a[i] = a[i].replace(__reFn, '');
  1665. data = data[ a[i] ]();
  1666. continue;
  1667. }
  1668. if ( data === null || data[ a[i] ] === undefined ) {
  1669. return undefined;
  1670. }
  1671. data = data[ a[i] ];
  1672. }
  1673. }
  1674. return data;
  1675. };
  1676. return function (data, type) { // row and meta also passed, but not used
  1677. return fetchData( data, type, source );
  1678. };
  1679. }
  1680. else {
  1681. // Array or flat object mapping
  1682. return function (data, type) { // row and meta also passed, but not used
  1683. return data[source];
  1684. };
  1685. }
  1686. }
  1687. };
  1688. /**
  1689. * Create a mapping object that allows camel case parameters to be looked up
  1690. * for their Hungarian counterparts. The mapping is stored in a private
  1691. * parameter called `_hungarianMap` which can be accessed on the source object.
  1692. * @param {object} o
  1693. * @memberof DataTable#oApi
  1694. */
  1695. function _fnHungarianMap ( o )
  1696. {
  1697. var
  1698. hungarian = 'a aa ai ao as b fn i m o s ',
  1699. match,
  1700. newKey,
  1701. map = {};
  1702. $.each( o, function (key, val) {
  1703. match = key.match(/^([^A-Z]+?)([A-Z])/);
  1704. if ( match && hungarian.indexOf(match[1]+' ') !== -1 )
  1705. {
  1706. newKey = key.replace( match[0], match[2].toLowerCase() );
  1707. map[ newKey ] = key;
  1708. if ( match[1] === 'o' )
  1709. {
  1710. _fnHungarianMap( o[key] );
  1711. }
  1712. }
  1713. } );
  1714. o._hungarianMap = map;
  1715. }
  1716. /**
  1717. * Convert from camel case parameters to Hungarian, based on a Hungarian map
  1718. * created by _fnHungarianMap.
  1719. * @param {object} src The model object which holds all parameters that can be
  1720. * mapped.
  1721. * @param {object} user The object to convert from camel case to Hungarian.
  1722. * @param {boolean} force When set to `true`, properties which already have a
  1723. * Hungarian value in the `user` object will be overwritten. Otherwise they
  1724. * won't be.
  1725. * @memberof DataTable#oApi
  1726. */
  1727. function _fnCamelToHungarian ( src, user, force )
  1728. {
  1729. if ( ! src._hungarianMap ) {
  1730. _fnHungarianMap( src );
  1731. }
  1732. var hungarianKey;
  1733. $.each( user, function (key, val) {
  1734. hungarianKey = src._hungarianMap[ key ];
  1735. if ( hungarianKey !== undefined && (force || user[hungarianKey] === undefined) )
  1736. {
  1737. // For objects, we need to buzz down into the object to copy parameters
  1738. if ( hungarianKey.charAt(0) === 'o' )
  1739. {
  1740. // Copy the camelCase options over to the hungarian
  1741. if ( ! user[ hungarianKey ] ) {
  1742. user[ hungarianKey ] = {};
  1743. }
  1744. $.extend( true, user[hungarianKey], user[key] );
  1745. _fnCamelToHungarian( src[hungarianKey], user[hungarianKey], force );
  1746. }
  1747. else {
  1748. user[hungarianKey] = user[ key ];
  1749. }
  1750. }
  1751. } );
  1752. }
  1753. /**
  1754. * Language compatibility - when certain options are given, and others aren't, we
  1755. * need to duplicate the values over, in order to provide backwards compatibility
  1756. * with older language files.
  1757. * @param {object} oSettings dataTables settings object
  1758. * @memberof DataTable#oApi
  1759. */
  1760. function _fnLanguageCompat( lang )
  1761. {
  1762. // Note the use of the Hungarian notation for the parameters in this method as
  1763. // this is called after the mapping of camelCase to Hungarian
  1764. var defaults = DataTable.defaults.oLanguage;
  1765. // Default mapping
  1766. var defaultDecimal = defaults.sDecimal;
  1767. if ( defaultDecimal ) {
  1768. _addNumericSort( defaultDecimal );
  1769. }
  1770. if ( lang ) {
  1771. var zeroRecords = lang.sZeroRecords;
  1772. // Backwards compatibility - if there is no sEmptyTable given, then use the same as
  1773. // sZeroRecords - assuming that is given.
  1774. if ( ! lang.sEmptyTable && zeroRecords &&
  1775. defaults.sEmptyTable === "No data available in table" )
  1776. {
  1777. _fnMap( lang, lang, 'sZeroRecords', 'sEmptyTable' );
  1778. }
  1779. // Likewise with loading records
  1780. if ( ! lang.sLoadingRecords && zeroRecords &&
  1781. defaults.sLoadingRecords === "Loading..." )
  1782. {
  1783. _fnMap( lang, lang, 'sZeroRecords', 'sLoadingRecords' );
  1784. }
  1785. // Old parameter name of the thousands separator mapped onto the new
  1786. if ( lang.sInfoThousands ) {
  1787. lang.sThousands = lang.sInfoThousands;
  1788. }
  1789. var decimal = lang.sDecimal;
  1790. if ( decimal && defaultDecimal !== decimal ) {
  1791. _addNumericSort( decimal );
  1792. }
  1793. }
  1794. }
  1795. /**
  1796. * Map one parameter onto another
  1797. * @param {object} o Object to map
  1798. * @param {*} knew The new parameter name
  1799. * @param {*} old The old parameter name
  1800. */
  1801. var _fnCompatMap = function ( o, knew, old ) {
  1802. if ( o[ knew ] !== undefined ) {
  1803. o[ old ] = o[ knew ];
  1804. }
  1805. };
  1806. /**
  1807. * Provide backwards compatibility for the main DT options. Note that the new
  1808. * options are mapped onto the old parameters, so this is an external interface
  1809. * change only.
  1810. * @param {object} init Object to map
  1811. */
  1812. function _fnCompatOpts ( init )
  1813. {
  1814. _fnCompatMap( init, 'ordering', 'bSort' );
  1815. _fnCompatMap( init, 'orderMulti', 'bSortMulti' );
  1816. _fnCompatMap( init, 'orderClasses', 'bSortClasses' );
  1817. _fnCompatMap( init, 'orderCellsTop', 'bSortCellsTop' );
  1818. _fnCompatMap( init, 'order', 'aaSorting' );
  1819. _fnCompatMap( init, 'orderFixed', 'aaSortingFixed' );
  1820. _fnCompatMap( init, 'paging', 'bPaginate' );
  1821. _fnCompatMap( init, 'pagingType', 'sPaginationType' );
  1822. _fnCompatMap( init, 'pageLength', 'iDisplayLength' );
  1823. _fnCompatMap( init, 'searching', 'bFilter' );
  1824. // Boolean initialisation of x-scrolling
  1825. if ( typeof init.sScrollX === 'boolean' ) {
  1826. init.sScrollX = init.sScrollX ? '100%' : '';
  1827. }
  1828. if ( typeof init.scrollX === 'boolean' ) {
  1829. init.scrollX = init.scrollX ? '100%' : '';
  1830. }
  1831. // Column search objects are in an array, so it needs to be converted
  1832. // element by element
  1833. var searchCols = init.aoSearchCols;
  1834. if ( searchCols ) {
  1835. for ( var i=0, ien=searchCols.length ; i<ien ; i++ ) {
  1836. if ( searchCols[i] ) {
  1837. _fnCamelToHungarian( DataTable.models.oSearch, searchCols[i] );
  1838. }
  1839. }
  1840. }
  1841. }
  1842. /**
  1843. * Provide backwards compatibility for column options. Note that the new options
  1844. * are mapped onto the old parameters, so this is an external interface change
  1845. * only.
  1846. * @param {object} init Object to map
  1847. */
  1848. function _fnCompatCols ( init )
  1849. {
  1850. _fnCompatMap( init, 'orderable', 'bSortable' );
  1851. _fnCompatMap( init, 'orderData', 'aDataSort' );
  1852. _fnCompatMap( init, 'orderSequence', 'asSorting' );
  1853. _fnCompatMap( init, 'orderDataType', 'sortDataType' );
  1854. // orderData can be given as an integer
  1855. var dataSort = init.aDataSort;
  1856. if ( typeof dataSort === 'number' && ! Array.isArray( dataSort ) ) {
  1857. init.aDataSort = [ dataSort ];
  1858. }
  1859. }
  1860. /**
  1861. * Browser feature detection for capabilities, quirks
  1862. * @param {object} settings dataTables settings object
  1863. * @memberof DataTable#oApi
  1864. */
  1865. function _fnBrowserDetect( settings )
  1866. {
  1867. // We don't need to do this every time DataTables is constructed, the values
  1868. // calculated are specific to the browser and OS configuration which we
  1869. // don't expect to change between initialisations
  1870. if ( ! DataTable.__browser ) {
  1871. var browser = {};
  1872. DataTable.__browser = browser;
  1873. // Scrolling feature / quirks detection
  1874. var n = $('<div/>')
  1875. .css( {
  1876. position: 'fixed',
  1877. top: 0,
  1878. left: $(window).scrollLeft()*-1, // allow for scrolling
  1879. height: 1,
  1880. width: 1,
  1881. overflow: 'hidden'
  1882. } )
  1883. .append(
  1884. $('<div/>')
  1885. .css( {
  1886. position: 'absolute',
  1887. top: 1,
  1888. left: 1,
  1889. width: 100,
  1890. overflow: 'scroll'
  1891. } )
  1892. .append(
  1893. $('<div/>')
  1894. .css( {
  1895. width: '100%',
  1896. height: 10
  1897. } )
  1898. )
  1899. )
  1900. .appendTo( 'body' );
  1901. var outer = n.children();
  1902. var inner = outer.children();
  1903. // Numbers below, in order, are:
  1904. // inner.offsetWidth, inner.clientWidth, outer.offsetWidth, outer.clientWidth
  1905. //
  1906. // IE6 XP: 100 100 100 83
  1907. // IE7 Vista: 100 100 100 83
  1908. // IE 8+ Windows: 83 83 100 83
  1909. // Evergreen Windows: 83 83 100 83
  1910. // Evergreen Mac with scrollbars: 85 85 100 85
  1911. // Evergreen Mac without scrollbars: 100 100 100 100
  1912. // Get scrollbar width
  1913. browser.barWidth = outer[0].offsetWidth - outer[0].clientWidth;
  1914. // IE6/7 will oversize a width 100% element inside a scrolling element, to
  1915. // include the width of the scrollbar, while other browsers ensure the inner
  1916. // element is contained without forcing scrolling
  1917. browser.bScrollOversize = inner[0].offsetWidth === 100 && outer[0].clientWidth !== 100;
  1918. // In rtl text layout, some browsers (most, but not all) will place the
  1919. // scrollbar on the left, rather than the right.
  1920. browser.bScrollbarLeft = Math.round( inner.offset().left ) !== 1;
  1921. // IE8- don't provide height and width for getBoundingClientRect
  1922. browser.bBounding = n[0].getBoundingClientRect().width ? true : false;
  1923. n.remove();
  1924. }
  1925. $.extend( settings.oBrowser, DataTable.__browser );
  1926. settings.oScroll.iBarWidth = DataTable.__browser.barWidth;
  1927. }
  1928. /**
  1929. * Array.prototype reduce[Right] method, used for browsers which don't support
  1930. * JS 1.6. Done this way to reduce code size, since we iterate either way
  1931. * @param {object} settings dataTables settings object
  1932. * @memberof DataTable#oApi
  1933. */
  1934. function _fnReduce ( that, fn, init, start, end, inc )
  1935. {
  1936. var
  1937. i = start,
  1938. value,
  1939. isSet = false;
  1940. if ( init !== undefined ) {
  1941. value = init;
  1942. isSet = true;
  1943. }
  1944. while ( i !== end ) {
  1945. if ( ! that.hasOwnProperty(i) ) {
  1946. continue;
  1947. }
  1948. value = isSet ?
  1949. fn( value, that[i], i, that ) :
  1950. that[i];
  1951. isSet = true;
  1952. i += inc;
  1953. }
  1954. return value;
  1955. }
  1956. /**
  1957. * Add a column to the list used for the table with default values
  1958. * @param {object} oSettings dataTables settings object
  1959. * @param {node} nTh The th element for this column
  1960. * @memberof DataTable#oApi
  1961. */
  1962. function _fnAddColumn( oSettings, nTh )
  1963. {
  1964. // Add column to aoColumns array
  1965. var oDefaults = DataTable.defaults.column;
  1966. var iCol = oSettings.aoColumns.length;
  1967. var oCol = $.extend( {}, DataTable.models.oColumn, oDefaults, {
  1968. "nTh": nTh ? nTh : document.createElement('th'),
  1969. "sTitle": oDefaults.sTitle ? oDefaults.sTitle : nTh ? nTh.innerHTML : '',
  1970. "aDataSort": oDefaults.aDataSort ? oDefaults.aDataSort : [iCol],
  1971. "mData": oDefaults.mData ? oDefaults.mData : iCol,
  1972. idx: iCol
  1973. } );
  1974. oSettings.aoColumns.push( oCol );
  1975. // Add search object for column specific search. Note that the `searchCols[ iCol ]`
  1976. // passed into extend can be undefined. This allows the user to give a default
  1977. // with only some of the parameters defined, and also not give a default
  1978. var searchCols = oSettings.aoPreSearchCols;
  1979. searchCols[ iCol ] = $.extend( {}, DataTable.models.oSearch, searchCols[ iCol ] );
  1980. // Use the default column options function to initialise classes etc
  1981. _fnColumnOptions( oSettings, iCol, $(nTh).data() );
  1982. }
  1983. /**
  1984. * Apply options for a column
  1985. * @param {object} oSettings dataTables settings object
  1986. * @param {int} iCol column index to consider
  1987. * @param {object} oOptions object with sType, bVisible and bSearchable etc
  1988. * @memberof DataTable#oApi
  1989. */
  1990. function _fnColumnOptions( oSettings, iCol, oOptions )
  1991. {
  1992. var oCol = oSettings.aoColumns[ iCol ];
  1993. var oClasses = oSettings.oClasses;
  1994. var th = $(oCol.nTh);
  1995. // Try to get width information from the DOM. We can't get it from CSS
  1996. // as we'd need to parse the CSS stylesheet. `width` option can override
  1997. if ( ! oCol.sWidthOrig ) {
  1998. // Width attribute
  1999. oCol.sWidthOrig = th.attr('width') || null;
  2000. // Style attribute
  2001. var t = (th.attr('style') || '').match(/width:\s*(\d+[pxem%]+)/);
  2002. if ( t ) {
  2003. oCol.sWidthOrig = t[1];
  2004. }
  2005. }
  2006. /* User specified column options */
  2007. if ( oOptions !== undefined && oOptions !== null )
  2008. {
  2009. // Backwards compatibility
  2010. _fnCompatCols( oOptions );
  2011. // Map camel case parameters to their Hungarian counterparts
  2012. _fnCamelToHungarian( DataTable.defaults.column, oOptions, true );
  2013. /* Backwards compatibility for mDataProp */
  2014. if ( oOptions.mDataProp !== undefined && !oOptions.mData )
  2015. {
  2016. oOptions.mData = oOptions.mDataProp;
  2017. }
  2018. if ( oOptions.sType )
  2019. {
  2020. oCol._sManualType = oOptions.sType;
  2021. }
  2022. // `class` is a reserved word in Javascript, so we need to provide
  2023. // the ability to use a valid name for the camel case input
  2024. if ( oOptions.className && ! oOptions.sClass )
  2025. {
  2026. oOptions.sClass = oOptions.className;
  2027. }
  2028. if ( oOptions.sClass ) {
  2029. th.addClass( oOptions.sClass );
  2030. }
  2031. $.extend( oCol, oOptions );
  2032. _fnMap( oCol, oOptions, "sWidth", "sWidthOrig" );
  2033. /* iDataSort to be applied (backwards compatibility), but aDataSort will take
  2034. * priority if defined
  2035. */
  2036. if ( oOptions.iDataSort !== undefined )
  2037. {
  2038. oCol.aDataSort = [ oOptions.iDataSort ];
  2039. }
  2040. _fnMap( oCol, oOptions, "aDataSort" );
  2041. }
  2042. /* Cache the data get and set functions for speed */
  2043. var mDataSrc = oCol.mData;
  2044. var mData = _fnGetObjectDataFn( mDataSrc );
  2045. var mRender = oCol.mRender ? _fnGetObjectDataFn( oCol.mRender ) : null;
  2046. var attrTest = function( src ) {
  2047. return typeof src === 'string' && src.indexOf('@') !== -1;
  2048. };
  2049. oCol._bAttrSrc = $.isPlainObject( mDataSrc ) && (
  2050. attrTest(mDataSrc.sort) || attrTest(mDataSrc.type) || attrTest(mDataSrc.filter)
  2051. );
  2052. oCol._setter = null;
  2053. oCol.fnGetData = function (rowData, type, meta) {
  2054. var innerData = mData( rowData, type, undefined, meta );
  2055. return mRender && type ?
  2056. mRender( innerData, type, rowData, meta ) :
  2057. innerData;
  2058. };
  2059. oCol.fnSetData = function ( rowData, val, meta ) {
  2060. return _fnSetObjectDataFn( mDataSrc )( rowData, val, meta );
  2061. };
  2062. // Indicate if DataTables should read DOM data as an object or array
  2063. // Used in _fnGetRowElements
  2064. if ( typeof mDataSrc !== 'number' ) {
  2065. oSettings._rowReadObject = true;
  2066. }
  2067. /* Feature sorting overrides column specific when off */
  2068. if ( !oSettings.oFeatures.bSort )
  2069. {
  2070. oCol.bSortable = false;
  2071. th.addClass( oClasses.sSortableNone ); // Have to add class here as order event isn't called
  2072. }
  2073. /* Check that the class assignment is correct for sorting */
  2074. var bAsc = $.inArray('asc', oCol.asSorting) !== -1;
  2075. var bDesc = $.inArray('desc', oCol.asSorting) !== -1;
  2076. if ( !oCol.bSortable || (!bAsc && !bDesc) )
  2077. {
  2078. oCol.sSortingClass = oClasses.sSortableNone;
  2079. oCol.sSortingClassJUI = "";
  2080. }
  2081. else if ( bAsc && !bDesc )
  2082. {
  2083. oCol.sSortingClass = oClasses.sSortableAsc;
  2084. oCol.sSortingClassJUI = oClasses.sSortJUIAscAllowed;
  2085. }
  2086. else if ( !bAsc && bDesc )
  2087. {
  2088. oCol.sSortingClass = oClasses.sSortableDesc;
  2089. oCol.sSortingClassJUI = oClasses.sSortJUIDescAllowed;
  2090. }
  2091. else
  2092. {
  2093. oCol.sSortingClass = oClasses.sSortable;
  2094. oCol.sSortingClassJUI = oClasses.sSortJUI;
  2095. }
  2096. }
  2097. /**
  2098. * Adjust the table column widths for new data. Note: you would probably want to
  2099. * do a redraw after calling this function!
  2100. * @param {object} settings dataTables settings object
  2101. * @memberof DataTable#oApi
  2102. */
  2103. function _fnAdjustColumnSizing ( settings )
  2104. {
  2105. /* Not interested in doing column width calculation if auto-width is disabled */
  2106. if ( settings.oFeatures.bAutoWidth !== false )
  2107. {
  2108. var columns = settings.aoColumns;
  2109. _fnCalculateColumnWidths( settings );
  2110. for ( var i=0 , iLen=columns.length ; i<iLen ; i++ )
  2111. {
  2112. columns[i].nTh.style.width = columns[i].sWidth;
  2113. }
  2114. }
  2115. var scroll = settings.oScroll;
  2116. if ( scroll.sY !== '' || scroll.sX !== '')
  2117. {
  2118. _fnScrollDraw( settings );
  2119. }
  2120. _fnCallbackFire( settings, null, 'column-sizing', [settings] );
  2121. }
  2122. /**
  2123. * Convert the index of a visible column to the index in the data array (take account
  2124. * of hidden columns)
  2125. * @param {object} oSettings dataTables settings object
  2126. * @param {int} iMatch Visible column index to lookup
  2127. * @returns {int} i the data index
  2128. * @memberof DataTable#oApi
  2129. */
  2130. function _fnVisibleToColumnIndex( oSettings, iMatch )
  2131. {
  2132. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  2133. return typeof aiVis[iMatch] === 'number' ?
  2134. aiVis[iMatch] :
  2135. null;
  2136. }
  2137. /**
  2138. * Convert the index of an index in the data array and convert it to the visible
  2139. * column index (take account of hidden columns)
  2140. * @param {int} iMatch Column index to lookup
  2141. * @param {object} oSettings dataTables settings object
  2142. * @returns {int} i the data index
  2143. * @memberof DataTable#oApi
  2144. */
  2145. function _fnColumnIndexToVisible( oSettings, iMatch )
  2146. {
  2147. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  2148. var iPos = $.inArray( iMatch, aiVis );
  2149. return iPos !== -1 ? iPos : null;
  2150. }
  2151. /**
  2152. * Get the number of visible columns
  2153. * @param {object} oSettings dataTables settings object
  2154. * @returns {int} i the number of visible columns
  2155. * @memberof DataTable#oApi
  2156. */
  2157. function _fnVisbleColumns( oSettings )
  2158. {
  2159. var vis = 0;
  2160. // No reduce in IE8, use a loop for now
  2161. $.each( oSettings.aoColumns, function ( i, col ) {
  2162. if ( col.bVisible && $(col.nTh).css('display') !== 'none' ) {
  2163. vis++;
  2164. }
  2165. } );
  2166. return vis;
  2167. }
  2168. /**
  2169. * Get an array of column indexes that match a given property
  2170. * @param {object} oSettings dataTables settings object
  2171. * @param {string} sParam Parameter in aoColumns to look for - typically
  2172. * bVisible or bSearchable
  2173. * @returns {array} Array of indexes with matched properties
  2174. * @memberof DataTable#oApi
  2175. */
  2176. function _fnGetColumns( oSettings, sParam )
  2177. {
  2178. var a = [];
  2179. $.map( oSettings.aoColumns, function(val, i) {
  2180. if ( val[sParam] ) {
  2181. a.push( i );
  2182. }
  2183. } );
  2184. return a;
  2185. }
  2186. /**
  2187. * Calculate the 'type' of a column
  2188. * @param {object} settings dataTables settings object
  2189. * @memberof DataTable#oApi
  2190. */
  2191. function _fnColumnTypes ( settings )
  2192. {
  2193. var columns = settings.aoColumns;
  2194. var data = settings.aoData;
  2195. var types = DataTable.ext.type.detect;
  2196. var i, ien, j, jen, k, ken;
  2197. var col, cell, detectedType, cache;
  2198. // For each column, spin over the
  2199. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  2200. col = columns[i];
  2201. cache = [];
  2202. if ( ! col.sType && col._sManualType ) {
  2203. col.sType = col._sManualType;
  2204. }
  2205. else if ( ! col.sType ) {
  2206. for ( j=0, jen=types.length ; j<jen ; j++ ) {
  2207. for ( k=0, ken=data.length ; k<ken ; k++ ) {
  2208. // Use a cache array so we only need to get the type data
  2209. // from the formatter once (when using multiple detectors)
  2210. if ( cache[k] === undefined ) {
  2211. cache[k] = _fnGetCellData( settings, k, i, 'type' );
  2212. }
  2213. detectedType = types[j]( cache[k], settings );
  2214. // If null, then this type can't apply to this column, so
  2215. // rather than testing all cells, break out. There is an
  2216. // exception for the last type which is `html`. We need to
  2217. // scan all rows since it is possible to mix string and HTML
  2218. // types
  2219. if ( ! detectedType && j !== types.length-1 ) {
  2220. break;
  2221. }
  2222. // Only a single match is needed for html type since it is
  2223. // bottom of the pile and very similar to string - but it
  2224. // must not be empty
  2225. if ( detectedType === 'html' && ! _empty(cache[k]) ) {
  2226. break;
  2227. }
  2228. }
  2229. // Type is valid for all data points in the column - use this
  2230. // type
  2231. if ( detectedType ) {
  2232. col.sType = detectedType;
  2233. break;
  2234. }
  2235. }
  2236. // Fall back - if no type was detected, always use string
  2237. if ( ! col.sType ) {
  2238. col.sType = 'string';
  2239. }
  2240. }
  2241. }
  2242. }
  2243. /**
  2244. * Take the column definitions and static columns arrays and calculate how
  2245. * they relate to column indexes. The callback function will then apply the
  2246. * definition found for a column to a suitable configuration object.
  2247. * @param {object} oSettings dataTables settings object
  2248. * @param {array} aoColDefs The aoColumnDefs array that is to be applied
  2249. * @param {array} aoCols The aoColumns array that defines columns individually
  2250. * @param {function} fn Callback function - takes two parameters, the calculated
  2251. * column index and the definition for that column.
  2252. * @memberof DataTable#oApi
  2253. */
  2254. function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, fn )
  2255. {
  2256. var i, iLen, j, jLen, k, kLen, def;
  2257. var columns = oSettings.aoColumns;
  2258. // Column definitions with aTargets
  2259. if ( aoColDefs )
  2260. {
  2261. /* Loop over the definitions array - loop in reverse so first instance has priority */
  2262. for ( i=aoColDefs.length-1 ; i>=0 ; i-- )
  2263. {
  2264. def = aoColDefs[i];
  2265. /* Each definition can target multiple columns, as it is an array */
  2266. var aTargets = def.targets !== undefined ?
  2267. def.targets :
  2268. def.aTargets;
  2269. if ( ! Array.isArray( aTargets ) )
  2270. {
  2271. aTargets = [ aTargets ];
  2272. }
  2273. for ( j=0, jLen=aTargets.length ; j<jLen ; j++ )
  2274. {
  2275. if ( typeof aTargets[j] === 'number' && aTargets[j] >= 0 )
  2276. {
  2277. /* Add columns that we don't yet know about */
  2278. while( columns.length <= aTargets[j] )
  2279. {
  2280. _fnAddColumn( oSettings );
  2281. }
  2282. /* Integer, basic index */
  2283. fn( aTargets[j], def );
  2284. }
  2285. else if ( typeof aTargets[j] === 'number' && aTargets[j] < 0 )
  2286. {
  2287. /* Negative integer, right to left column counting */
  2288. fn( columns.length+aTargets[j], def );
  2289. }
  2290. else if ( typeof aTargets[j] === 'string' )
  2291. {
  2292. /* Class name matching on TH element */
  2293. for ( k=0, kLen=columns.length ; k<kLen ; k++ )
  2294. {
  2295. if ( aTargets[j] == "_all" ||
  2296. $(columns[k].nTh).hasClass( aTargets[j] ) )
  2297. {
  2298. fn( k, def );
  2299. }
  2300. }
  2301. }
  2302. }
  2303. }
  2304. }
  2305. // Statically defined columns array
  2306. if ( aoCols )
  2307. {
  2308. for ( i=0, iLen=aoCols.length ; i<iLen ; i++ )
  2309. {
  2310. fn( i, aoCols[i] );
  2311. }
  2312. }
  2313. }
  2314. /**
  2315. * Add a data array to the table, creating DOM node etc. This is the parallel to
  2316. * _fnGatherData, but for adding rows from a Javascript source, rather than a
  2317. * DOM source.
  2318. * @param {object} oSettings dataTables settings object
  2319. * @param {array} aData data array to be added
  2320. * @param {node} [nTr] TR element to add to the table - optional. If not given,
  2321. * DataTables will create a row automatically
  2322. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  2323. * if nTr is.
  2324. * @returns {int} >=0 if successful (index of new aoData entry), -1 if failed
  2325. * @memberof DataTable#oApi
  2326. */
  2327. function _fnAddData ( oSettings, aDataIn, nTr, anTds )
  2328. {
  2329. /* Create the object for storing information about this new row */
  2330. var iRow = oSettings.aoData.length;
  2331. var oData = $.extend( true, {}, DataTable.models.oRow, {
  2332. src: nTr ? 'dom' : 'data',
  2333. idx: iRow
  2334. } );
  2335. oData._aData = aDataIn;
  2336. oSettings.aoData.push( oData );
  2337. /* Create the cells */
  2338. var nTd, sThisType;
  2339. var columns = oSettings.aoColumns;
  2340. // Invalidate the column types as the new data needs to be revalidated
  2341. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  2342. {
  2343. columns[i].sType = null;
  2344. }
  2345. /* Add to the display array */
  2346. oSettings.aiDisplayMaster.push( iRow );
  2347. var id = oSettings.rowIdFn( aDataIn );
  2348. if ( id !== undefined ) {
  2349. oSettings.aIds[ id ] = oData;
  2350. }
  2351. /* Create the DOM information, or register it if already present */
  2352. if ( nTr || ! oSettings.oFeatures.bDeferRender )
  2353. {
  2354. _fnCreateTr( oSettings, iRow, nTr, anTds );
  2355. }
  2356. return iRow;
  2357. }
  2358. /**
  2359. * Add one or more TR elements to the table. Generally we'd expect to
  2360. * use this for reading data from a DOM sourced table, but it could be
  2361. * used for an TR element. Note that if a TR is given, it is used (i.e.
  2362. * it is not cloned).
  2363. * @param {object} settings dataTables settings object
  2364. * @param {array|node|jQuery} trs The TR element(s) to add to the table
  2365. * @returns {array} Array of indexes for the added rows
  2366. * @memberof DataTable#oApi
  2367. */
  2368. function _fnAddTr( settings, trs )
  2369. {
  2370. var row;
  2371. // Allow an individual node to be passed in
  2372. if ( ! (trs instanceof $) ) {
  2373. trs = $(trs);
  2374. }
  2375. return trs.map( function (i, el) {
  2376. row = _fnGetRowElements( settings, el );
  2377. return _fnAddData( settings, row.data, el, row.cells );
  2378. } );
  2379. }
  2380. /**
  2381. * Take a TR element and convert it to an index in aoData
  2382. * @param {object} oSettings dataTables settings object
  2383. * @param {node} n the TR element to find
  2384. * @returns {int} index if the node is found, null if not
  2385. * @memberof DataTable#oApi
  2386. */
  2387. function _fnNodeToDataIndex( oSettings, n )
  2388. {
  2389. return (n._DT_RowIndex!==undefined) ? n._DT_RowIndex : null;
  2390. }
  2391. /**
  2392. * Take a TD element and convert it into a column data index (not the visible index)
  2393. * @param {object} oSettings dataTables settings object
  2394. * @param {int} iRow The row number the TD/TH can be found in
  2395. * @param {node} n The TD/TH element to find
  2396. * @returns {int} index if the node is found, -1 if not
  2397. * @memberof DataTable#oApi
  2398. */
  2399. function _fnNodeToColumnIndex( oSettings, iRow, n )
  2400. {
  2401. return $.inArray( n, oSettings.aoData[ iRow ].anCells );
  2402. }
  2403. /**
  2404. * Get the data for a given cell from the internal cache, taking into account data mapping
  2405. * @param {object} settings dataTables settings object
  2406. * @param {int} rowIdx aoData row id
  2407. * @param {int} colIdx Column index
  2408. * @param {string} type data get type ('display', 'type' 'filter|search' 'sort|order')
  2409. * @returns {*} Cell data
  2410. * @memberof DataTable#oApi
  2411. */
  2412. function _fnGetCellData( settings, rowIdx, colIdx, type )
  2413. {
  2414. if (type === 'search') {
  2415. type = 'filter';
  2416. }
  2417. else if (type === 'order') {
  2418. type = 'sort';
  2419. }
  2420. var draw = settings.iDraw;
  2421. var col = settings.aoColumns[colIdx];
  2422. var rowData = settings.aoData[rowIdx]._aData;
  2423. var defaultContent = col.sDefaultContent;
  2424. var cellData = col.fnGetData( rowData, type, {
  2425. settings: settings,
  2426. row: rowIdx,
  2427. col: colIdx
  2428. } );
  2429. if ( cellData === undefined ) {
  2430. if ( settings.iDrawError != draw && defaultContent === null ) {
  2431. _fnLog( settings, 0, "Requested unknown parameter "+
  2432. (typeof col.mData=='function' ? '{function}' : "'"+col.mData+"'")+
  2433. " for row "+rowIdx+", column "+colIdx, 4 );
  2434. settings.iDrawError = draw;
  2435. }
  2436. return defaultContent;
  2437. }
  2438. // When the data source is null and a specific data type is requested (i.e.
  2439. // not the original data), we can use default column data
  2440. if ( (cellData === rowData || cellData === null) && defaultContent !== null && type !== undefined ) {
  2441. cellData = defaultContent;
  2442. }
  2443. else if ( typeof cellData === 'function' ) {
  2444. // If the data source is a function, then we run it and use the return,
  2445. // executing in the scope of the data object (for instances)
  2446. return cellData.call( rowData );
  2447. }
  2448. if ( cellData === null && type === 'display' ) {
  2449. return '';
  2450. }
  2451. if ( type === 'filter' ) {
  2452. var fomatters = DataTable.ext.type.search;
  2453. if ( fomatters[ col.sType ] ) {
  2454. cellData = fomatters[ col.sType ]( cellData );
  2455. }
  2456. }
  2457. return cellData;
  2458. }
  2459. /**
  2460. * Set the value for a specific cell, into the internal data cache
  2461. * @param {object} settings dataTables settings object
  2462. * @param {int} rowIdx aoData row id
  2463. * @param {int} colIdx Column index
  2464. * @param {*} val Value to set
  2465. * @memberof DataTable#oApi
  2466. */
  2467. function _fnSetCellData( settings, rowIdx, colIdx, val )
  2468. {
  2469. var col = settings.aoColumns[colIdx];
  2470. var rowData = settings.aoData[rowIdx]._aData;
  2471. col.fnSetData( rowData, val, {
  2472. settings: settings,
  2473. row: rowIdx,
  2474. col: colIdx
  2475. } );
  2476. }
  2477. // Private variable that is used to match action syntax in the data property object
  2478. var __reArray = /\[.*?\]$/;
  2479. var __reFn = /\(\)$/;
  2480. /**
  2481. * Split string on periods, taking into account escaped periods
  2482. * @param {string} str String to split
  2483. * @return {array} Split string
  2484. */
  2485. function _fnSplitObjNotation( str )
  2486. {
  2487. return $.map( str.match(/(\\.|[^\.])+/g) || [''], function ( s ) {
  2488. return s.replace(/\\\./g, '.');
  2489. } );
  2490. }
  2491. /**
  2492. * Return a function that can be used to get data from a source object, taking
  2493. * into account the ability to use nested objects as a source
  2494. * @param {string|int|function} mSource The data source for the object
  2495. * @returns {function} Data get function
  2496. * @memberof DataTable#oApi
  2497. */
  2498. var _fnGetObjectDataFn = DataTable.util.get;
  2499. /**
  2500. * Return a function that can be used to set data from a source object, taking
  2501. * into account the ability to use nested objects as a source
  2502. * @param {string|int|function} mSource The data source for the object
  2503. * @returns {function} Data set function
  2504. * @memberof DataTable#oApi
  2505. */
  2506. var _fnSetObjectDataFn = DataTable.util.set;
  2507. /**
  2508. * Return an array with the full table data
  2509. * @param {object} oSettings dataTables settings object
  2510. * @returns array {array} aData Master data array
  2511. * @memberof DataTable#oApi
  2512. */
  2513. function _fnGetDataMaster ( settings )
  2514. {
  2515. return _pluck( settings.aoData, '_aData' );
  2516. }
  2517. /**
  2518. * Nuke the table
  2519. * @param {object} oSettings dataTables settings object
  2520. * @memberof DataTable#oApi
  2521. */
  2522. function _fnClearTable( settings )
  2523. {
  2524. settings.aoData.length = 0;
  2525. settings.aiDisplayMaster.length = 0;
  2526. settings.aiDisplay.length = 0;
  2527. settings.aIds = {};
  2528. }
  2529. /**
  2530. * Take an array of integers (index array) and remove a target integer (value - not
  2531. * the key!)
  2532. * @param {array} a Index array to target
  2533. * @param {int} iTarget value to find
  2534. * @memberof DataTable#oApi
  2535. */
  2536. function _fnDeleteIndex( a, iTarget, splice )
  2537. {
  2538. var iTargetIndex = -1;
  2539. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  2540. {
  2541. if ( a[i] == iTarget )
  2542. {
  2543. iTargetIndex = i;
  2544. }
  2545. else if ( a[i] > iTarget )
  2546. {
  2547. a[i]--;
  2548. }
  2549. }
  2550. if ( iTargetIndex != -1 && splice === undefined )
  2551. {
  2552. a.splice( iTargetIndex, 1 );
  2553. }
  2554. }
  2555. /**
  2556. * Mark cached data as invalid such that a re-read of the data will occur when
  2557. * the cached data is next requested. Also update from the data source object.
  2558. *
  2559. * @param {object} settings DataTables settings object
  2560. * @param {int} rowIdx Row index to invalidate
  2561. * @param {string} [src] Source to invalidate from: undefined, 'auto', 'dom'
  2562. * or 'data'
  2563. * @param {int} [colIdx] Column index to invalidate. If undefined the whole
  2564. * row will be invalidated
  2565. * @memberof DataTable#oApi
  2566. *
  2567. * @todo For the modularisation of v1.11 this will need to become a callback, so
  2568. * the sort and filter methods can subscribe to it. That will required
  2569. * initialisation options for sorting, which is why it is not already baked in
  2570. */
  2571. function _fnInvalidate( settings, rowIdx, src, colIdx )
  2572. {
  2573. var row = settings.aoData[ rowIdx ];
  2574. var i, ien;
  2575. var cellWrite = function ( cell, col ) {
  2576. // This is very frustrating, but in IE if you just write directly
  2577. // to innerHTML, and elements that are overwritten are GC'ed,
  2578. // even if there is a reference to them elsewhere
  2579. while ( cell.childNodes.length ) {
  2580. cell.removeChild( cell.firstChild );
  2581. }
  2582. cell.innerHTML = _fnGetCellData( settings, rowIdx, col, 'display' );
  2583. };
  2584. // Are we reading last data from DOM or the data object?
  2585. if ( src === 'dom' || ((! src || src === 'auto') && row.src === 'dom') ) {
  2586. // Read the data from the DOM
  2587. row._aData = _fnGetRowElements(
  2588. settings, row, colIdx, colIdx === undefined ? undefined : row._aData
  2589. )
  2590. .data;
  2591. }
  2592. else {
  2593. // Reading from data object, update the DOM
  2594. var cells = row.anCells;
  2595. if ( cells ) {
  2596. if ( colIdx !== undefined ) {
  2597. cellWrite( cells[colIdx], colIdx );
  2598. }
  2599. else {
  2600. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  2601. cellWrite( cells[i], i );
  2602. }
  2603. }
  2604. }
  2605. }
  2606. // For both row and cell invalidation, the cached data for sorting and
  2607. // filtering is nulled out
  2608. row._aSortData = null;
  2609. row._aFilterData = null;
  2610. // Invalidate the type for a specific column (if given) or all columns since
  2611. // the data might have changed
  2612. var cols = settings.aoColumns;
  2613. if ( colIdx !== undefined ) {
  2614. cols[ colIdx ].sType = null;
  2615. }
  2616. else {
  2617. for ( i=0, ien=cols.length ; i<ien ; i++ ) {
  2618. cols[i].sType = null;
  2619. }
  2620. // Update DataTables special `DT_*` attributes for the row
  2621. _fnRowAttributes( settings, row );
  2622. }
  2623. }
  2624. /**
  2625. * Build a data source object from an HTML row, reading the contents of the
  2626. * cells that are in the row.
  2627. *
  2628. * @param {object} settings DataTables settings object
  2629. * @param {node|object} TR element from which to read data or existing row
  2630. * object from which to re-read the data from the cells
  2631. * @param {int} [colIdx] Optional column index
  2632. * @param {array|object} [d] Data source object. If `colIdx` is given then this
  2633. * parameter should also be given and will be used to write the data into.
  2634. * Only the column in question will be written
  2635. * @returns {object} Object with two parameters: `data` the data read, in
  2636. * document order, and `cells` and array of nodes (they can be useful to the
  2637. * caller, so rather than needing a second traversal to get them, just return
  2638. * them from here).
  2639. * @memberof DataTable#oApi
  2640. */
  2641. function _fnGetRowElements( settings, row, colIdx, d )
  2642. {
  2643. var
  2644. tds = [],
  2645. td = row.firstChild,
  2646. name, col, o, i=0, contents,
  2647. columns = settings.aoColumns,
  2648. objectRead = settings._rowReadObject;
  2649. // Allow the data object to be passed in, or construct
  2650. d = d !== undefined ?
  2651. d :
  2652. objectRead ?
  2653. {} :
  2654. [];
  2655. var attr = function ( str, td ) {
  2656. if ( typeof str === 'string' ) {
  2657. var idx = str.indexOf('@');
  2658. if ( idx !== -1 ) {
  2659. var attr = str.substring( idx+1 );
  2660. var setter = _fnSetObjectDataFn( str );
  2661. setter( d, td.getAttribute( attr ) );
  2662. }
  2663. }
  2664. };
  2665. // Read data from a cell and store into the data object
  2666. var cellProcess = function ( cell ) {
  2667. if ( colIdx === undefined || colIdx === i ) {
  2668. col = columns[i];
  2669. contents = (cell.innerHTML).trim();
  2670. if ( col && col._bAttrSrc ) {
  2671. var setter = _fnSetObjectDataFn( col.mData._ );
  2672. setter( d, contents );
  2673. attr( col.mData.sort, cell );
  2674. attr( col.mData.type, cell );
  2675. attr( col.mData.filter, cell );
  2676. }
  2677. else {
  2678. // Depending on the `data` option for the columns the data can
  2679. // be read to either an object or an array.
  2680. if ( objectRead ) {
  2681. if ( ! col._setter ) {
  2682. // Cache the setter function
  2683. col._setter = _fnSetObjectDataFn( col.mData );
  2684. }
  2685. col._setter( d, contents );
  2686. }
  2687. else {
  2688. d[i] = contents;
  2689. }
  2690. }
  2691. }
  2692. i++;
  2693. };
  2694. if ( td ) {
  2695. // `tr` element was passed in
  2696. while ( td ) {
  2697. name = td.nodeName.toUpperCase();
  2698. if ( name == "TD" || name == "TH" ) {
  2699. cellProcess( td );
  2700. tds.push( td );
  2701. }
  2702. td = td.nextSibling;
  2703. }
  2704. }
  2705. else {
  2706. // Existing row object passed in
  2707. tds = row.anCells;
  2708. for ( var j=0, jen=tds.length ; j<jen ; j++ ) {
  2709. cellProcess( tds[j] );
  2710. }
  2711. }
  2712. // Read the ID from the DOM if present
  2713. var rowNode = row.firstChild ? row : row.nTr;
  2714. if ( rowNode ) {
  2715. var id = rowNode.getAttribute( 'id' );
  2716. if ( id ) {
  2717. _fnSetObjectDataFn( settings.rowId )( d, id );
  2718. }
  2719. }
  2720. return {
  2721. data: d,
  2722. cells: tds
  2723. };
  2724. }
  2725. /**
  2726. * Create a new TR element (and it's TD children) for a row
  2727. * @param {object} oSettings dataTables settings object
  2728. * @param {int} iRow Row to consider
  2729. * @param {node} [nTrIn] TR element to add to the table - optional. If not given,
  2730. * DataTables will create a row automatically
  2731. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  2732. * if nTr is.
  2733. * @memberof DataTable#oApi
  2734. */
  2735. function _fnCreateTr ( oSettings, iRow, nTrIn, anTds )
  2736. {
  2737. var
  2738. row = oSettings.aoData[iRow],
  2739. rowData = row._aData,
  2740. cells = [],
  2741. nTr, nTd, oCol,
  2742. i, iLen, create;
  2743. if ( row.nTr === null )
  2744. {
  2745. nTr = nTrIn || document.createElement('tr');
  2746. row.nTr = nTr;
  2747. row.anCells = cells;
  2748. /* Use a private property on the node to allow reserve mapping from the node
  2749. * to the aoData array for fast look up
  2750. */
  2751. nTr._DT_RowIndex = iRow;
  2752. /* Special parameters can be given by the data source to be used on the row */
  2753. _fnRowAttributes( oSettings, row );
  2754. /* Process each column */
  2755. for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
  2756. {
  2757. oCol = oSettings.aoColumns[i];
  2758. create = nTrIn ? false : true;
  2759. nTd = create ? document.createElement( oCol.sCellType ) : anTds[i];
  2760. nTd._DT_CellIndex = {
  2761. row: iRow,
  2762. column: i
  2763. };
  2764. cells.push( nTd );
  2765. // Need to create the HTML if new, or if a rendering function is defined
  2766. if ( create || ((oCol.mRender || oCol.mData !== i) &&
  2767. (!$.isPlainObject(oCol.mData) || oCol.mData._ !== i+'.display')
  2768. )) {
  2769. nTd.innerHTML = _fnGetCellData( oSettings, iRow, i, 'display' );
  2770. }
  2771. /* Add user defined class */
  2772. if ( oCol.sClass )
  2773. {
  2774. nTd.className += ' '+oCol.sClass;
  2775. }
  2776. // Visibility - add or remove as required
  2777. if ( oCol.bVisible && ! nTrIn )
  2778. {
  2779. nTr.appendChild( nTd );
  2780. }
  2781. else if ( ! oCol.bVisible && nTrIn )
  2782. {
  2783. nTd.parentNode.removeChild( nTd );
  2784. }
  2785. if ( oCol.fnCreatedCell )
  2786. {
  2787. oCol.fnCreatedCell.call( oSettings.oInstance,
  2788. nTd, _fnGetCellData( oSettings, iRow, i ), rowData, iRow, i
  2789. );
  2790. }
  2791. }
  2792. _fnCallbackFire( oSettings, 'aoRowCreatedCallback', null, [nTr, rowData, iRow, cells] );
  2793. }
  2794. }
  2795. /**
  2796. * Add attributes to a row based on the special `DT_*` parameters in a data
  2797. * source object.
  2798. * @param {object} settings DataTables settings object
  2799. * @param {object} DataTables row object for the row to be modified
  2800. * @memberof DataTable#oApi
  2801. */
  2802. function _fnRowAttributes( settings, row )
  2803. {
  2804. var tr = row.nTr;
  2805. var data = row._aData;
  2806. if ( tr ) {
  2807. var id = settings.rowIdFn( data );
  2808. if ( id ) {
  2809. tr.id = id;
  2810. }
  2811. if ( data.DT_RowClass ) {
  2812. // Remove any classes added by DT_RowClass before
  2813. var a = data.DT_RowClass.split(' ');
  2814. row.__rowc = row.__rowc ?
  2815. _unique( row.__rowc.concat( a ) ) :
  2816. a;
  2817. $(tr)
  2818. .removeClass( row.__rowc.join(' ') )
  2819. .addClass( data.DT_RowClass );
  2820. }
  2821. if ( data.DT_RowAttr ) {
  2822. $(tr).attr( data.DT_RowAttr );
  2823. }
  2824. if ( data.DT_RowData ) {
  2825. $(tr).data( data.DT_RowData );
  2826. }
  2827. }
  2828. }
  2829. /**
  2830. * Create the HTML header for the table
  2831. * @param {object} oSettings dataTables settings object
  2832. * @memberof DataTable#oApi
  2833. */
  2834. function _fnBuildHead( oSettings )
  2835. {
  2836. var i, ien, cell, row, column;
  2837. var thead = oSettings.nTHead;
  2838. var tfoot = oSettings.nTFoot;
  2839. var createHeader = $('th, td', thead).length === 0;
  2840. var classes = oSettings.oClasses;
  2841. var columns = oSettings.aoColumns;
  2842. if ( createHeader ) {
  2843. row = $('<tr/>').appendTo( thead );
  2844. }
  2845. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  2846. column = columns[i];
  2847. cell = $( column.nTh ).addClass( column.sClass );
  2848. if ( createHeader ) {
  2849. cell.appendTo( row );
  2850. }
  2851. // 1.11 move into sorting
  2852. if ( oSettings.oFeatures.bSort ) {
  2853. cell.addClass( column.sSortingClass );
  2854. if ( column.bSortable !== false ) {
  2855. cell
  2856. .attr( 'tabindex', oSettings.iTabIndex )
  2857. .attr( 'aria-controls', oSettings.sTableId );
  2858. _fnSortAttachListener( oSettings, column.nTh, i );
  2859. }
  2860. }
  2861. if ( column.sTitle != cell[0].innerHTML ) {
  2862. cell.html( column.sTitle );
  2863. }
  2864. _fnRenderer( oSettings, 'header' )(
  2865. oSettings, cell, column, classes
  2866. );
  2867. }
  2868. if ( createHeader ) {
  2869. _fnDetectHeader( oSettings.aoHeader, thead );
  2870. }
  2871. /* Deal with the footer - add classes if required */
  2872. $(thead).children('tr').children('th, td').addClass( classes.sHeaderTH );
  2873. $(tfoot).children('tr').children('th, td').addClass( classes.sFooterTH );
  2874. // Cache the footer cells. Note that we only take the cells from the first
  2875. // row in the footer. If there is more than one row the user wants to
  2876. // interact with, they need to use the table().foot() method. Note also this
  2877. // allows cells to be used for multiple columns using colspan
  2878. if ( tfoot !== null ) {
  2879. var cells = oSettings.aoFooter[0];
  2880. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  2881. column = columns[i];
  2882. column.nTf = cells[i].cell;
  2883. if ( column.sClass ) {
  2884. $(column.nTf).addClass( column.sClass );
  2885. }
  2886. }
  2887. }
  2888. }
  2889. /**
  2890. * Draw the header (or footer) element based on the column visibility states. The
  2891. * methodology here is to use the layout array from _fnDetectHeader, modified for
  2892. * the instantaneous column visibility, to construct the new layout. The grid is
  2893. * traversed over cell at a time in a rows x columns grid fashion, although each
  2894. * cell insert can cover multiple elements in the grid - which is tracks using the
  2895. * aApplied array. Cell inserts in the grid will only occur where there isn't
  2896. * already a cell in that position.
  2897. * @param {object} oSettings dataTables settings object
  2898. * @param array {objects} aoSource Layout array from _fnDetectHeader
  2899. * @param {boolean} [bIncludeHidden=false] If true then include the hidden columns in the calc,
  2900. * @memberof DataTable#oApi
  2901. */
  2902. function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
  2903. {
  2904. var i, iLen, j, jLen, k, kLen, n, nLocalTr;
  2905. var aoLocal = [];
  2906. var aApplied = [];
  2907. var iColumns = oSettings.aoColumns.length;
  2908. var iRowspan, iColspan;
  2909. if ( ! aoSource )
  2910. {
  2911. return;
  2912. }
  2913. if ( bIncludeHidden === undefined )
  2914. {
  2915. bIncludeHidden = false;
  2916. }
  2917. /* Make a copy of the master layout array, but without the visible columns in it */
  2918. for ( i=0, iLen=aoSource.length ; i<iLen ; i++ )
  2919. {
  2920. aoLocal[i] = aoSource[i].slice();
  2921. aoLocal[i].nTr = aoSource[i].nTr;
  2922. /* Remove any columns which are currently hidden */
  2923. for ( j=iColumns-1 ; j>=0 ; j-- )
  2924. {
  2925. if ( !oSettings.aoColumns[j].bVisible && !bIncludeHidden )
  2926. {
  2927. aoLocal[i].splice( j, 1 );
  2928. }
  2929. }
  2930. /* Prep the applied array - it needs an element for each row */
  2931. aApplied.push( [] );
  2932. }
  2933. for ( i=0, iLen=aoLocal.length ; i<iLen ; i++ )
  2934. {
  2935. nLocalTr = aoLocal[i].nTr;
  2936. /* All cells are going to be replaced, so empty out the row */
  2937. if ( nLocalTr )
  2938. {
  2939. while( (n = nLocalTr.firstChild) )
  2940. {
  2941. nLocalTr.removeChild( n );
  2942. }
  2943. }
  2944. for ( j=0, jLen=aoLocal[i].length ; j<jLen ; j++ )
  2945. {
  2946. iRowspan = 1;
  2947. iColspan = 1;
  2948. /* Check to see if there is already a cell (row/colspan) covering our target
  2949. * insert point. If there is, then there is nothing to do.
  2950. */
  2951. if ( aApplied[i][j] === undefined )
  2952. {
  2953. nLocalTr.appendChild( aoLocal[i][j].cell );
  2954. aApplied[i][j] = 1;
  2955. /* Expand the cell to cover as many rows as needed */
  2956. while ( aoLocal[i+iRowspan] !== undefined &&
  2957. aoLocal[i][j].cell == aoLocal[i+iRowspan][j].cell )
  2958. {
  2959. aApplied[i+iRowspan][j] = 1;
  2960. iRowspan++;
  2961. }
  2962. /* Expand the cell to cover as many columns as needed */
  2963. while ( aoLocal[i][j+iColspan] !== undefined &&
  2964. aoLocal[i][j].cell == aoLocal[i][j+iColspan].cell )
  2965. {
  2966. /* Must update the applied array over the rows for the columns */
  2967. for ( k=0 ; k<iRowspan ; k++ )
  2968. {
  2969. aApplied[i+k][j+iColspan] = 1;
  2970. }
  2971. iColspan++;
  2972. }
  2973. /* Do the actual expansion in the DOM */
  2974. $(aoLocal[i][j].cell)
  2975. .attr('rowspan', iRowspan)
  2976. .attr('colspan', iColspan);
  2977. }
  2978. }
  2979. }
  2980. }
  2981. /**
  2982. * Insert the required TR nodes into the table for display
  2983. * @param {object} oSettings dataTables settings object
  2984. * @param ajaxComplete true after ajax call to complete rendering
  2985. * @memberof DataTable#oApi
  2986. */
  2987. function _fnDraw( oSettings, ajaxComplete )
  2988. {
  2989. // Allow for state saving and a custom start position
  2990. _fnStart( oSettings );
  2991. /* Provide a pre-callback function which can be used to cancel the draw is false is returned */
  2992. var aPreDraw = _fnCallbackFire( oSettings, 'aoPreDrawCallback', 'preDraw', [oSettings] );
  2993. if ( $.inArray( false, aPreDraw ) !== -1 )
  2994. {
  2995. _fnProcessingDisplay( oSettings, false );
  2996. return;
  2997. }
  2998. var anRows = [];
  2999. var iRowCount = 0;
  3000. var asStripeClasses = oSettings.asStripeClasses;
  3001. var iStripes = asStripeClasses.length;
  3002. var oLang = oSettings.oLanguage;
  3003. var bServerSide = _fnDataSource( oSettings ) == 'ssp';
  3004. var aiDisplay = oSettings.aiDisplay;
  3005. var iDisplayStart = oSettings._iDisplayStart;
  3006. var iDisplayEnd = oSettings.fnDisplayEnd();
  3007. oSettings.bDrawing = true;
  3008. /* Server-side processing draw intercept */
  3009. if ( oSettings.bDeferLoading )
  3010. {
  3011. oSettings.bDeferLoading = false;
  3012. oSettings.iDraw++;
  3013. _fnProcessingDisplay( oSettings, false );
  3014. }
  3015. else if ( !bServerSide )
  3016. {
  3017. oSettings.iDraw++;
  3018. }
  3019. else if ( !oSettings.bDestroying && !ajaxComplete)
  3020. {
  3021. _fnAjaxUpdate( oSettings );
  3022. return;
  3023. }
  3024. if ( aiDisplay.length !== 0 )
  3025. {
  3026. var iStart = bServerSide ? 0 : iDisplayStart;
  3027. var iEnd = bServerSide ? oSettings.aoData.length : iDisplayEnd;
  3028. for ( var j=iStart ; j<iEnd ; j++ )
  3029. {
  3030. var iDataIndex = aiDisplay[j];
  3031. var aoData = oSettings.aoData[ iDataIndex ];
  3032. if ( aoData.nTr === null )
  3033. {
  3034. _fnCreateTr( oSettings, iDataIndex );
  3035. }
  3036. var nRow = aoData.nTr;
  3037. /* Remove the old striping classes and then add the new one */
  3038. if ( iStripes !== 0 )
  3039. {
  3040. var sStripe = asStripeClasses[ iRowCount % iStripes ];
  3041. if ( aoData._sRowStripe != sStripe )
  3042. {
  3043. $(nRow).removeClass( aoData._sRowStripe ).addClass( sStripe );
  3044. aoData._sRowStripe = sStripe;
  3045. }
  3046. }
  3047. // Row callback functions - might want to manipulate the row
  3048. // iRowCount and j are not currently documented. Are they at all
  3049. // useful?
  3050. _fnCallbackFire( oSettings, 'aoRowCallback', null,
  3051. [nRow, aoData._aData, iRowCount, j, iDataIndex] );
  3052. anRows.push( nRow );
  3053. iRowCount++;
  3054. }
  3055. }
  3056. else
  3057. {
  3058. /* Table is empty - create a row with an empty message in it */
  3059. var sZero = oLang.sZeroRecords;
  3060. if ( oSettings.iDraw == 1 && _fnDataSource( oSettings ) == 'ajax' )
  3061. {
  3062. sZero = oLang.sLoadingRecords;
  3063. }
  3064. else if ( oLang.sEmptyTable && oSettings.fnRecordsTotal() === 0 )
  3065. {
  3066. sZero = oLang.sEmptyTable;
  3067. }
  3068. anRows[ 0 ] = $( '<tr/>', { 'class': iStripes ? asStripeClasses[0] : '' } )
  3069. .append( $('<td />', {
  3070. 'valign': 'top',
  3071. 'colSpan': _fnVisbleColumns( oSettings ),
  3072. 'class': oSettings.oClasses.sRowEmpty
  3073. } ).html( sZero ) )[0];
  3074. }
  3075. /* Header and footer callbacks */
  3076. _fnCallbackFire( oSettings, 'aoHeaderCallback', 'header', [ $(oSettings.nTHead).children('tr')[0],
  3077. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  3078. _fnCallbackFire( oSettings, 'aoFooterCallback', 'footer', [ $(oSettings.nTFoot).children('tr')[0],
  3079. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  3080. var body = $(oSettings.nTBody);
  3081. body.children().detach();
  3082. body.append( $(anRows) );
  3083. /* Call all required callback functions for the end of a draw */
  3084. _fnCallbackFire( oSettings, 'aoDrawCallback', 'draw', [oSettings] );
  3085. /* Draw is complete, sorting and filtering must be as well */
  3086. oSettings.bSorted = false;
  3087. oSettings.bFiltered = false;
  3088. oSettings.bDrawing = false;
  3089. }
  3090. /**
  3091. * Redraw the table - taking account of the various features which are enabled
  3092. * @param {object} oSettings dataTables settings object
  3093. * @param {boolean} [holdPosition] Keep the current paging position. By default
  3094. * the paging is reset to the first page
  3095. * @memberof DataTable#oApi
  3096. */
  3097. function _fnReDraw( settings, holdPosition )
  3098. {
  3099. var
  3100. features = settings.oFeatures,
  3101. sort = features.bSort,
  3102. filter = features.bFilter;
  3103. if ( sort ) {
  3104. _fnSort( settings );
  3105. }
  3106. if ( filter ) {
  3107. _fnFilterComplete( settings, settings.oPreviousSearch );
  3108. }
  3109. else {
  3110. // No filtering, so we want to just use the display master
  3111. settings.aiDisplay = settings.aiDisplayMaster.slice();
  3112. }
  3113. if ( holdPosition !== true ) {
  3114. settings._iDisplayStart = 0;
  3115. }
  3116. // Let any modules know about the draw hold position state (used by
  3117. // scrolling internally)
  3118. settings._drawHold = holdPosition;
  3119. _fnDraw( settings );
  3120. settings._drawHold = false;
  3121. }
  3122. /**
  3123. * Add the options to the page HTML for the table
  3124. * @param {object} oSettings dataTables settings object
  3125. * @memberof DataTable#oApi
  3126. */
  3127. function _fnAddOptionsHtml ( oSettings )
  3128. {
  3129. var classes = oSettings.oClasses;
  3130. var table = $(oSettings.nTable);
  3131. var holding = $('<div/>').insertBefore( table ); // Holding element for speed
  3132. var features = oSettings.oFeatures;
  3133. // All DataTables are wrapped in a div
  3134. var insert = $('<div/>', {
  3135. id: oSettings.sTableId+'_wrapper',
  3136. 'class': classes.sWrapper + (oSettings.nTFoot ? '' : ' '+classes.sNoFooter)
  3137. } );
  3138. oSettings.nHolding = holding[0];
  3139. oSettings.nTableWrapper = insert[0];
  3140. oSettings.nTableReinsertBefore = oSettings.nTable.nextSibling;
  3141. /* Loop over the user set positioning and place the elements as needed */
  3142. var aDom = oSettings.sDom.split('');
  3143. var featureNode, cOption, nNewNode, cNext, sAttr, j;
  3144. for ( var i=0 ; i<aDom.length ; i++ )
  3145. {
  3146. featureNode = null;
  3147. cOption = aDom[i];
  3148. if ( cOption == '<' )
  3149. {
  3150. /* New container div */
  3151. nNewNode = $('<div/>')[0];
  3152. /* Check to see if we should append an id and/or a class name to the container */
  3153. cNext = aDom[i+1];
  3154. if ( cNext == "'" || cNext == '"' )
  3155. {
  3156. sAttr = "";
  3157. j = 2;
  3158. while ( aDom[i+j] != cNext )
  3159. {
  3160. sAttr += aDom[i+j];
  3161. j++;
  3162. }
  3163. /* Replace jQuery UI constants @todo depreciated */
  3164. if ( sAttr == "H" )
  3165. {
  3166. sAttr = classes.sJUIHeader;
  3167. }
  3168. else if ( sAttr == "F" )
  3169. {
  3170. sAttr = classes.sJUIFooter;
  3171. }
  3172. /* The attribute can be in the format of "#id.class", "#id" or "class" This logic
  3173. * breaks the string into parts and applies them as needed
  3174. */
  3175. if ( sAttr.indexOf('.') != -1 )
  3176. {
  3177. var aSplit = sAttr.split('.');
  3178. nNewNode.id = aSplit[0].substr(1, aSplit[0].length-1);
  3179. nNewNode.className = aSplit[1];
  3180. }
  3181. else if ( sAttr.charAt(0) == "#" )
  3182. {
  3183. nNewNode.id = sAttr.substr(1, sAttr.length-1);
  3184. }
  3185. else
  3186. {
  3187. nNewNode.className = sAttr;
  3188. }
  3189. i += j; /* Move along the position array */
  3190. }
  3191. insert.append( nNewNode );
  3192. insert = $(nNewNode);
  3193. }
  3194. else if ( cOption == '>' )
  3195. {
  3196. /* End container div */
  3197. insert = insert.parent();
  3198. }
  3199. // @todo Move options into their own plugins?
  3200. else if ( cOption == 'l' && features.bPaginate && features.bLengthChange )
  3201. {
  3202. /* Length */
  3203. featureNode = _fnFeatureHtmlLength( oSettings );
  3204. }
  3205. else if ( cOption == 'f' && features.bFilter )
  3206. {
  3207. /* Filter */
  3208. featureNode = _fnFeatureHtmlFilter( oSettings );
  3209. }
  3210. else if ( cOption == 'r' && features.bProcessing )
  3211. {
  3212. /* pRocessing */
  3213. featureNode = _fnFeatureHtmlProcessing( oSettings );
  3214. }
  3215. else if ( cOption == 't' )
  3216. {
  3217. /* Table */
  3218. featureNode = _fnFeatureHtmlTable( oSettings );
  3219. }
  3220. else if ( cOption == 'i' && features.bInfo )
  3221. {
  3222. /* Info */
  3223. featureNode = _fnFeatureHtmlInfo( oSettings );
  3224. }
  3225. else if ( cOption == 'p' && features.bPaginate )
  3226. {
  3227. /* Pagination */
  3228. featureNode = _fnFeatureHtmlPaginate( oSettings );
  3229. }
  3230. else if ( DataTable.ext.feature.length !== 0 )
  3231. {
  3232. /* Plug-in features */
  3233. var aoFeatures = DataTable.ext.feature;
  3234. for ( var k=0, kLen=aoFeatures.length ; k<kLen ; k++ )
  3235. {
  3236. if ( cOption == aoFeatures[k].cFeature )
  3237. {
  3238. featureNode = aoFeatures[k].fnInit( oSettings );
  3239. break;
  3240. }
  3241. }
  3242. }
  3243. /* Add to the 2D features array */
  3244. if ( featureNode )
  3245. {
  3246. var aanFeatures = oSettings.aanFeatures;
  3247. if ( ! aanFeatures[cOption] )
  3248. {
  3249. aanFeatures[cOption] = [];
  3250. }
  3251. aanFeatures[cOption].push( featureNode );
  3252. insert.append( featureNode );
  3253. }
  3254. }
  3255. /* Built our DOM structure - replace the holding div with what we want */
  3256. holding.replaceWith( insert );
  3257. oSettings.nHolding = null;
  3258. }
  3259. /**
  3260. * Use the DOM source to create up an array of header cells. The idea here is to
  3261. * create a layout grid (array) of rows x columns, which contains a reference
  3262. * to the cell that that point in the grid (regardless of col/rowspan), such that
  3263. * any column / row could be removed and the new grid constructed
  3264. * @param array {object} aLayout Array to store the calculated layout in
  3265. * @param {node} nThead The header/footer element for the table
  3266. * @memberof DataTable#oApi
  3267. */
  3268. function _fnDetectHeader ( aLayout, nThead )
  3269. {
  3270. var nTrs = $(nThead).children('tr');
  3271. var nTr, nCell;
  3272. var i, k, l, iLen, jLen, iColShifted, iColumn, iColspan, iRowspan;
  3273. var bUnique;
  3274. var fnShiftCol = function ( a, i, j ) {
  3275. var k = a[i];
  3276. while ( k[j] ) {
  3277. j++;
  3278. }
  3279. return j;
  3280. };
  3281. aLayout.splice( 0, aLayout.length );
  3282. /* We know how many rows there are in the layout - so prep it */
  3283. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  3284. {
  3285. aLayout.push( [] );
  3286. }
  3287. /* Calculate a layout array */
  3288. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  3289. {
  3290. nTr = nTrs[i];
  3291. iColumn = 0;
  3292. /* For every cell in the row... */
  3293. nCell = nTr.firstChild;
  3294. while ( nCell ) {
  3295. if ( nCell.nodeName.toUpperCase() == "TD" ||
  3296. nCell.nodeName.toUpperCase() == "TH" )
  3297. {
  3298. /* Get the col and rowspan attributes from the DOM and sanitise them */
  3299. iColspan = nCell.getAttribute('colspan') * 1;
  3300. iRowspan = nCell.getAttribute('rowspan') * 1;
  3301. iColspan = (!iColspan || iColspan===0 || iColspan===1) ? 1 : iColspan;
  3302. iRowspan = (!iRowspan || iRowspan===0 || iRowspan===1) ? 1 : iRowspan;
  3303. /* There might be colspan cells already in this row, so shift our target
  3304. * accordingly
  3305. */
  3306. iColShifted = fnShiftCol( aLayout, i, iColumn );
  3307. /* Cache calculation for unique columns */
  3308. bUnique = iColspan === 1 ? true : false;
  3309. /* If there is col / rowspan, copy the information into the layout grid */
  3310. for ( l=0 ; l<iColspan ; l++ )
  3311. {
  3312. for ( k=0 ; k<iRowspan ; k++ )
  3313. {
  3314. aLayout[i+k][iColShifted+l] = {
  3315. "cell": nCell,
  3316. "unique": bUnique
  3317. };
  3318. aLayout[i+k].nTr = nTr;
  3319. }
  3320. }
  3321. }
  3322. nCell = nCell.nextSibling;
  3323. }
  3324. }
  3325. }
  3326. /**
  3327. * Get an array of unique th elements, one for each column
  3328. * @param {object} oSettings dataTables settings object
  3329. * @param {node} nHeader automatically detect the layout from this node - optional
  3330. * @param {array} aLayout thead/tfoot layout from _fnDetectHeader - optional
  3331. * @returns array {node} aReturn list of unique th's
  3332. * @memberof DataTable#oApi
  3333. */
  3334. function _fnGetUniqueThs ( oSettings, nHeader, aLayout )
  3335. {
  3336. var aReturn = [];
  3337. if ( !aLayout )
  3338. {
  3339. aLayout = oSettings.aoHeader;
  3340. if ( nHeader )
  3341. {
  3342. aLayout = [];
  3343. _fnDetectHeader( aLayout, nHeader );
  3344. }
  3345. }
  3346. for ( var i=0, iLen=aLayout.length ; i<iLen ; i++ )
  3347. {
  3348. for ( var j=0, jLen=aLayout[i].length ; j<jLen ; j++ )
  3349. {
  3350. if ( aLayout[i][j].unique &&
  3351. (!aReturn[j] || !oSettings.bSortCellsTop) )
  3352. {
  3353. aReturn[j] = aLayout[i][j].cell;
  3354. }
  3355. }
  3356. }
  3357. return aReturn;
  3358. }
  3359. /**
  3360. * Set the start position for draw
  3361. * @param {object} oSettings dataTables settings object
  3362. */
  3363. function _fnStart( oSettings )
  3364. {
  3365. var bServerSide = _fnDataSource( oSettings ) == 'ssp';
  3366. var iInitDisplayStart = oSettings.iInitDisplayStart;
  3367. // Check and see if we have an initial draw position from state saving
  3368. if ( iInitDisplayStart !== undefined && iInitDisplayStart !== -1 )
  3369. {
  3370. oSettings._iDisplayStart = bServerSide ?
  3371. iInitDisplayStart :
  3372. iInitDisplayStart >= oSettings.fnRecordsDisplay() ?
  3373. 0 :
  3374. iInitDisplayStart;
  3375. oSettings.iInitDisplayStart = -1;
  3376. }
  3377. }
  3378. /**
  3379. * Create an Ajax call based on the table's settings, taking into account that
  3380. * parameters can have multiple forms, and backwards compatibility.
  3381. *
  3382. * @param {object} oSettings dataTables settings object
  3383. * @param {array} data Data to send to the server, required by
  3384. * DataTables - may be augmented by developer callbacks
  3385. * @param {function} fn Callback function to run when data is obtained
  3386. */
  3387. function _fnBuildAjax( oSettings, data, fn )
  3388. {
  3389. // Compatibility with 1.9-, allow fnServerData and event to manipulate
  3390. _fnCallbackFire( oSettings, 'aoServerParams', 'serverParams', [data] );
  3391. // Convert to object based for 1.10+ if using the old array scheme which can
  3392. // come from server-side processing or serverParams
  3393. if ( data && Array.isArray(data) ) {
  3394. var tmp = {};
  3395. var rbracket = /(.*?)\[\]$/;
  3396. $.each( data, function (key, val) {
  3397. var match = val.name.match(rbracket);
  3398. if ( match ) {
  3399. // Support for arrays
  3400. var name = match[0];
  3401. if ( ! tmp[ name ] ) {
  3402. tmp[ name ] = [];
  3403. }
  3404. tmp[ name ].push( val.value );
  3405. }
  3406. else {
  3407. tmp[val.name] = val.value;
  3408. }
  3409. } );
  3410. data = tmp;
  3411. }
  3412. var ajaxData;
  3413. var ajax = oSettings.ajax;
  3414. var instance = oSettings.oInstance;
  3415. var callback = function ( json ) {
  3416. var status = oSettings.jqXHR
  3417. ? oSettings.jqXHR.status
  3418. : null;
  3419. if ( json === null || (typeof status === 'number' && status == 204 ) ) {
  3420. json = {};
  3421. _fnAjaxDataSrc( oSettings, json, [] );
  3422. }
  3423. var error = json.error || json.sError;
  3424. if ( error ) {
  3425. _fnLog( oSettings, 0, error );
  3426. }
  3427. oSettings.json = json;
  3428. _fnCallbackFire( oSettings, null, 'xhr', [oSettings, json, oSettings.jqXHR] );
  3429. fn( json );
  3430. };
  3431. if ( $.isPlainObject( ajax ) && ajax.data )
  3432. {
  3433. ajaxData = ajax.data;
  3434. var newData = typeof ajaxData === 'function' ?
  3435. ajaxData( data, oSettings ) : // fn can manipulate data or return
  3436. ajaxData; // an object object or array to merge
  3437. // If the function returned something, use that alone
  3438. data = typeof ajaxData === 'function' && newData ?
  3439. newData :
  3440. $.extend( true, data, newData );
  3441. // Remove the data property as we've resolved it already and don't want
  3442. // jQuery to do it again (it is restored at the end of the function)
  3443. delete ajax.data;
  3444. }
  3445. var baseAjax = {
  3446. "data": data,
  3447. "success": callback,
  3448. "dataType": "json",
  3449. "cache": false,
  3450. "type": oSettings.sServerMethod,
  3451. "error": function (xhr, error, thrown) {
  3452. var ret = _fnCallbackFire( oSettings, null, 'xhr', [oSettings, null, oSettings.jqXHR] );
  3453. if ( $.inArray( true, ret ) === -1 ) {
  3454. if ( error == "parsererror" ) {
  3455. _fnLog( oSettings, 0, 'Invalid JSON response', 1 );
  3456. }
  3457. else if ( xhr.readyState === 4 ) {
  3458. _fnLog( oSettings, 0, 'Ajax error', 7 );
  3459. }
  3460. }
  3461. _fnProcessingDisplay( oSettings, false );
  3462. }
  3463. };
  3464. // Store the data submitted for the API
  3465. oSettings.oAjaxData = data;
  3466. // Allow plug-ins and external processes to modify the data
  3467. _fnCallbackFire( oSettings, null, 'preXhr', [oSettings, data] );
  3468. if ( oSettings.fnServerData )
  3469. {
  3470. // DataTables 1.9- compatibility
  3471. oSettings.fnServerData.call( instance,
  3472. oSettings.sAjaxSource,
  3473. $.map( data, function (val, key) { // Need to convert back to 1.9 trad format
  3474. return { name: key, value: val };
  3475. } ),
  3476. callback,
  3477. oSettings
  3478. );
  3479. }
  3480. else if ( oSettings.sAjaxSource || typeof ajax === 'string' )
  3481. {
  3482. // DataTables 1.9- compatibility
  3483. oSettings.jqXHR = $.ajax( $.extend( baseAjax, {
  3484. url: ajax || oSettings.sAjaxSource
  3485. } ) );
  3486. }
  3487. else if ( typeof ajax === 'function' )
  3488. {
  3489. // Is a function - let the caller define what needs to be done
  3490. oSettings.jqXHR = ajax.call( instance, data, callback, oSettings );
  3491. }
  3492. else
  3493. {
  3494. // Object to extend the base settings
  3495. oSettings.jqXHR = $.ajax( $.extend( baseAjax, ajax ) );
  3496. // Restore for next time around
  3497. ajax.data = ajaxData;
  3498. }
  3499. }
  3500. /**
  3501. * Update the table using an Ajax call
  3502. * @param {object} settings dataTables settings object
  3503. * @returns {boolean} Block the table drawing or not
  3504. * @memberof DataTable#oApi
  3505. */
  3506. function _fnAjaxUpdate( settings )
  3507. {
  3508. settings.iDraw++;
  3509. _fnProcessingDisplay( settings, true );
  3510. _fnBuildAjax(
  3511. settings,
  3512. _fnAjaxParameters( settings ),
  3513. function(json) {
  3514. _fnAjaxUpdateDraw( settings, json );
  3515. }
  3516. );
  3517. }
  3518. /**
  3519. * Build up the parameters in an object needed for a server-side processing
  3520. * request. Note that this is basically done twice, is different ways - a modern
  3521. * method which is used by default in DataTables 1.10 which uses objects and
  3522. * arrays, or the 1.9- method with is name / value pairs. 1.9 method is used if
  3523. * the sAjaxSource option is used in the initialisation, or the legacyAjax
  3524. * option is set.
  3525. * @param {object} oSettings dataTables settings object
  3526. * @returns {bool} block the table drawing or not
  3527. * @memberof DataTable#oApi
  3528. */
  3529. function _fnAjaxParameters( settings )
  3530. {
  3531. var
  3532. columns = settings.aoColumns,
  3533. columnCount = columns.length,
  3534. features = settings.oFeatures,
  3535. preSearch = settings.oPreviousSearch,
  3536. preColSearch = settings.aoPreSearchCols,
  3537. i, data = [], dataProp, column, columnSearch,
  3538. sort = _fnSortFlatten( settings ),
  3539. displayStart = settings._iDisplayStart,
  3540. displayLength = features.bPaginate !== false ?
  3541. settings._iDisplayLength :
  3542. -1;
  3543. var param = function ( name, value ) {
  3544. data.push( { 'name': name, 'value': value } );
  3545. };
  3546. // DataTables 1.9- compatible method
  3547. param( 'sEcho', settings.iDraw );
  3548. param( 'iColumns', columnCount );
  3549. param( 'sColumns', _pluck( columns, 'sName' ).join(',') );
  3550. param( 'iDisplayStart', displayStart );
  3551. param( 'iDisplayLength', displayLength );
  3552. // DataTables 1.10+ method
  3553. var d = {
  3554. draw: settings.iDraw,
  3555. columns: [],
  3556. order: [],
  3557. start: displayStart,
  3558. length: displayLength,
  3559. search: {
  3560. value: preSearch.sSearch,
  3561. regex: preSearch.bRegex
  3562. }
  3563. };
  3564. for ( i=0 ; i<columnCount ; i++ ) {
  3565. column = columns[i];
  3566. columnSearch = preColSearch[i];
  3567. dataProp = typeof column.mData=="function" ? 'function' : column.mData ;
  3568. d.columns.push( {
  3569. data: dataProp,
  3570. name: column.sName,
  3571. searchable: column.bSearchable,
  3572. orderable: column.bSortable,
  3573. search: {
  3574. value: columnSearch.sSearch,
  3575. regex: columnSearch.bRegex
  3576. }
  3577. } );
  3578. param( "mDataProp_"+i, dataProp );
  3579. if ( features.bFilter ) {
  3580. param( 'sSearch_'+i, columnSearch.sSearch );
  3581. param( 'bRegex_'+i, columnSearch.bRegex );
  3582. param( 'bSearchable_'+i, column.bSearchable );
  3583. }
  3584. if ( features.bSort ) {
  3585. param( 'bSortable_'+i, column.bSortable );
  3586. }
  3587. }
  3588. if ( features.bFilter ) {
  3589. param( 'sSearch', preSearch.sSearch );
  3590. param( 'bRegex', preSearch.bRegex );
  3591. }
  3592. if ( features.bSort ) {
  3593. $.each( sort, function ( i, val ) {
  3594. d.order.push( { column: val.col, dir: val.dir } );
  3595. param( 'iSortCol_'+i, val.col );
  3596. param( 'sSortDir_'+i, val.dir );
  3597. } );
  3598. param( 'iSortingCols', sort.length );
  3599. }
  3600. // If the legacy.ajax parameter is null, then we automatically decide which
  3601. // form to use, based on sAjaxSource
  3602. var legacy = DataTable.ext.legacy.ajax;
  3603. if ( legacy === null ) {
  3604. return settings.sAjaxSource ? data : d;
  3605. }
  3606. // Otherwise, if legacy has been specified then we use that to decide on the
  3607. // form
  3608. return legacy ? data : d;
  3609. }
  3610. /**
  3611. * Data the data from the server (nuking the old) and redraw the table
  3612. * @param {object} oSettings dataTables settings object
  3613. * @param {object} json json data return from the server.
  3614. * @param {string} json.sEcho Tracking flag for DataTables to match requests
  3615. * @param {int} json.iTotalRecords Number of records in the data set, not accounting for filtering
  3616. * @param {int} json.iTotalDisplayRecords Number of records in the data set, accounting for filtering
  3617. * @param {array} json.aaData The data to display on this page
  3618. * @param {string} [json.sColumns] Column ordering (sName, comma separated)
  3619. * @memberof DataTable#oApi
  3620. */
  3621. function _fnAjaxUpdateDraw ( settings, json )
  3622. {
  3623. // v1.10 uses camelCase variables, while 1.9 uses Hungarian notation.
  3624. // Support both
  3625. var compat = function ( old, modern ) {
  3626. return json[old] !== undefined ? json[old] : json[modern];
  3627. };
  3628. var data = _fnAjaxDataSrc( settings, json );
  3629. var draw = compat( 'sEcho', 'draw' );
  3630. var recordsTotal = compat( 'iTotalRecords', 'recordsTotal' );
  3631. var recordsFiltered = compat( 'iTotalDisplayRecords', 'recordsFiltered' );
  3632. if ( draw !== undefined ) {
  3633. // Protect against out of sequence returns
  3634. if ( draw*1 < settings.iDraw ) {
  3635. return;
  3636. }
  3637. settings.iDraw = draw * 1;
  3638. }
  3639. // No data in returned object, so rather than an array, we show an empty table
  3640. if ( ! data ) {
  3641. data = [];
  3642. }
  3643. _fnClearTable( settings );
  3644. settings._iRecordsTotal = parseInt(recordsTotal, 10);
  3645. settings._iRecordsDisplay = parseInt(recordsFiltered, 10);
  3646. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  3647. _fnAddData( settings, data[i] );
  3648. }
  3649. settings.aiDisplay = settings.aiDisplayMaster.slice();
  3650. _fnDraw( settings, true );
  3651. if ( ! settings._bInitComplete ) {
  3652. _fnInitComplete( settings, json );
  3653. }
  3654. _fnProcessingDisplay( settings, false );
  3655. }
  3656. /**
  3657. * Get the data from the JSON data source to use for drawing a table. Using
  3658. * `_fnGetObjectDataFn` allows the data to be sourced from a property of the
  3659. * source object, or from a processing function.
  3660. * @param {object} oSettings dataTables settings object
  3661. * @param {object} json Data source object / array from the server
  3662. * @return {array} Array of data to use
  3663. */
  3664. function _fnAjaxDataSrc ( oSettings, json, write )
  3665. {
  3666. var dataSrc = $.isPlainObject( oSettings.ajax ) && oSettings.ajax.dataSrc !== undefined ?
  3667. oSettings.ajax.dataSrc :
  3668. oSettings.sAjaxDataProp; // Compatibility with 1.9-.
  3669. if ( ! write ) {
  3670. if ( dataSrc === 'data' ) {
  3671. // If the default, then we still want to support the old style, and safely ignore
  3672. // it if possible
  3673. return json.aaData || json[dataSrc];
  3674. }
  3675. return dataSrc !== "" ?
  3676. _fnGetObjectDataFn( dataSrc )( json ) :
  3677. json;
  3678. }
  3679. // set
  3680. _fnSetObjectDataFn( dataSrc )( json, write );
  3681. }
  3682. /**
  3683. * Generate the node required for filtering text
  3684. * @returns {node} Filter control element
  3685. * @param {object} oSettings dataTables settings object
  3686. * @memberof DataTable#oApi
  3687. */
  3688. function _fnFeatureHtmlFilter ( settings )
  3689. {
  3690. var classes = settings.oClasses;
  3691. var tableId = settings.sTableId;
  3692. var language = settings.oLanguage;
  3693. var previousSearch = settings.oPreviousSearch;
  3694. var features = settings.aanFeatures;
  3695. var input = '<input type="search" class="'+classes.sFilterInput+'"/>';
  3696. var str = language.sSearch;
  3697. str = str.match(/_INPUT_/) ?
  3698. str.replace('_INPUT_', input) :
  3699. str+input;
  3700. var filter = $('<div/>', {
  3701. 'id': ! features.f ? tableId+'_filter' : null,
  3702. 'class': classes.sFilter
  3703. } )
  3704. .append( $('<label/>' ).append( str ) );
  3705. var searchFn = function(event) {
  3706. /* Update all other filter input elements for the new display */
  3707. var n = features.f;
  3708. var val = !this.value ? "" : this.value; // mental IE8 fix :-(
  3709. if(previousSearch.return && event.key !== "Enter") {
  3710. return;
  3711. }
  3712. /* Now do the filter */
  3713. if ( val != previousSearch.sSearch ) {
  3714. _fnFilterComplete( settings, {
  3715. "sSearch": val,
  3716. "bRegex": previousSearch.bRegex,
  3717. "bSmart": previousSearch.bSmart ,
  3718. "bCaseInsensitive": previousSearch.bCaseInsensitive,
  3719. "return": previousSearch.return
  3720. } );
  3721. // Need to redraw, without resorting
  3722. settings._iDisplayStart = 0;
  3723. _fnDraw( settings );
  3724. }
  3725. };
  3726. var searchDelay = settings.searchDelay !== null ?
  3727. settings.searchDelay :
  3728. _fnDataSource( settings ) === 'ssp' ?
  3729. 400 :
  3730. 0;
  3731. var jqFilter = $('input', filter)
  3732. .val( previousSearch.sSearch )
  3733. .attr( 'placeholder', language.sSearchPlaceholder )
  3734. .on(
  3735. 'keyup.DT search.DT input.DT paste.DT cut.DT',
  3736. searchDelay ?
  3737. _fnThrottle( searchFn, searchDelay ) :
  3738. searchFn
  3739. )
  3740. .on( 'mouseup', function(e) {
  3741. // Edge fix! Edge 17 does not trigger anything other than mouse events when clicking
  3742. // on the clear icon (Edge bug 17584515). This is safe in other browsers as `searchFn`
  3743. // checks the value to see if it has changed. In other browsers it won't have.
  3744. setTimeout( function () {
  3745. searchFn.call(jqFilter[0], e);
  3746. }, 10);
  3747. } )
  3748. .on( 'keypress.DT', function(e) {
  3749. /* Prevent form submission */
  3750. if ( e.keyCode == 13 ) {
  3751. return false;
  3752. }
  3753. } )
  3754. .attr('aria-controls', tableId);
  3755. // Update the input elements whenever the table is filtered
  3756. $(settings.nTable).on( 'search.dt.DT', function ( ev, s ) {
  3757. if ( settings === s ) {
  3758. // IE9 throws an 'unknown error' if document.activeElement is used
  3759. // inside an iframe or frame...
  3760. try {
  3761. if ( jqFilter[0] !== document.activeElement ) {
  3762. jqFilter.val( previousSearch.sSearch );
  3763. }
  3764. }
  3765. catch ( e ) {}
  3766. }
  3767. } );
  3768. return filter[0];
  3769. }
  3770. /**
  3771. * Filter the table using both the global filter and column based filtering
  3772. * @param {object} oSettings dataTables settings object
  3773. * @param {object} oSearch search information
  3774. * @param {int} [iForce] force a research of the master array (1) or not (undefined or 0)
  3775. * @memberof DataTable#oApi
  3776. */
  3777. function _fnFilterComplete ( oSettings, oInput, iForce )
  3778. {
  3779. var oPrevSearch = oSettings.oPreviousSearch;
  3780. var aoPrevSearch = oSettings.aoPreSearchCols;
  3781. var fnSaveFilter = function ( oFilter ) {
  3782. /* Save the filtering values */
  3783. oPrevSearch.sSearch = oFilter.sSearch;
  3784. oPrevSearch.bRegex = oFilter.bRegex;
  3785. oPrevSearch.bSmart = oFilter.bSmart;
  3786. oPrevSearch.bCaseInsensitive = oFilter.bCaseInsensitive;
  3787. oPrevSearch.return = oFilter.return;
  3788. };
  3789. var fnRegex = function ( o ) {
  3790. // Backwards compatibility with the bEscapeRegex option
  3791. return o.bEscapeRegex !== undefined ? !o.bEscapeRegex : o.bRegex;
  3792. };
  3793. // Resolve any column types that are unknown due to addition or invalidation
  3794. // @todo As per sort - can this be moved into an event handler?
  3795. _fnColumnTypes( oSettings );
  3796. /* In server-side processing all filtering is done by the server, so no point hanging around here */
  3797. if ( _fnDataSource( oSettings ) != 'ssp' )
  3798. {
  3799. /* Global filter */
  3800. _fnFilter( oSettings, oInput.sSearch, iForce, fnRegex(oInput), oInput.bSmart, oInput.bCaseInsensitive, oInput.return );
  3801. fnSaveFilter( oInput );
  3802. /* Now do the individual column filter */
  3803. for ( var i=0 ; i<aoPrevSearch.length ; i++ )
  3804. {
  3805. _fnFilterColumn( oSettings, aoPrevSearch[i].sSearch, i, fnRegex(aoPrevSearch[i]),
  3806. aoPrevSearch[i].bSmart, aoPrevSearch[i].bCaseInsensitive );
  3807. }
  3808. /* Custom filtering */
  3809. _fnFilterCustom( oSettings );
  3810. }
  3811. else
  3812. {
  3813. fnSaveFilter( oInput );
  3814. }
  3815. /* Tell the draw function we have been filtering */
  3816. oSettings.bFiltered = true;
  3817. _fnCallbackFire( oSettings, null, 'search', [oSettings] );
  3818. }
  3819. /**
  3820. * Apply custom filtering functions
  3821. * @param {object} oSettings dataTables settings object
  3822. * @memberof DataTable#oApi
  3823. */
  3824. function _fnFilterCustom( settings )
  3825. {
  3826. var filters = DataTable.ext.search;
  3827. var displayRows = settings.aiDisplay;
  3828. var row, rowIdx;
  3829. for ( var i=0, ien=filters.length ; i<ien ; i++ ) {
  3830. var rows = [];
  3831. // Loop over each row and see if it should be included
  3832. for ( var j=0, jen=displayRows.length ; j<jen ; j++ ) {
  3833. rowIdx = displayRows[ j ];
  3834. row = settings.aoData[ rowIdx ];
  3835. if ( filters[i]( settings, row._aFilterData, rowIdx, row._aData, j ) ) {
  3836. rows.push( rowIdx );
  3837. }
  3838. }
  3839. // So the array reference doesn't break set the results into the
  3840. // existing array
  3841. displayRows.length = 0;
  3842. $.merge( displayRows, rows );
  3843. }
  3844. }
  3845. /**
  3846. * Filter the table on a per-column basis
  3847. * @param {object} oSettings dataTables settings object
  3848. * @param {string} sInput string to filter on
  3849. * @param {int} iColumn column to filter
  3850. * @param {bool} bRegex treat search string as a regular expression or not
  3851. * @param {bool} bSmart use smart filtering or not
  3852. * @param {bool} bCaseInsensitive Do case insensitive matching or not
  3853. * @memberof DataTable#oApi
  3854. */
  3855. function _fnFilterColumn ( settings, searchStr, colIdx, regex, smart, caseInsensitive )
  3856. {
  3857. if ( searchStr === '' ) {
  3858. return;
  3859. }
  3860. var data;
  3861. var out = [];
  3862. var display = settings.aiDisplay;
  3863. var rpSearch = _fnFilterCreateSearch( searchStr, regex, smart, caseInsensitive );
  3864. for ( var i=0 ; i<display.length ; i++ ) {
  3865. data = settings.aoData[ display[i] ]._aFilterData[ colIdx ];
  3866. if ( rpSearch.test( data ) ) {
  3867. out.push( display[i] );
  3868. }
  3869. }
  3870. settings.aiDisplay = out;
  3871. }
  3872. /**
  3873. * Filter the data table based on user input and draw the table
  3874. * @param {object} settings dataTables settings object
  3875. * @param {string} input string to filter on
  3876. * @param {int} force optional - force a research of the master array (1) or not (undefined or 0)
  3877. * @param {bool} regex treat as a regular expression or not
  3878. * @param {bool} smart perform smart filtering or not
  3879. * @param {bool} caseInsensitive Do case insensitive matching or not
  3880. * @memberof DataTable#oApi
  3881. */
  3882. function _fnFilter( settings, input, force, regex, smart, caseInsensitive )
  3883. {
  3884. var rpSearch = _fnFilterCreateSearch( input, regex, smart, caseInsensitive );
  3885. var prevSearch = settings.oPreviousSearch.sSearch;
  3886. var displayMaster = settings.aiDisplayMaster;
  3887. var display, invalidated, i;
  3888. var filtered = [];
  3889. // Need to take account of custom filtering functions - always filter
  3890. if ( DataTable.ext.search.length !== 0 ) {
  3891. force = true;
  3892. }
  3893. // Check if any of the rows were invalidated
  3894. invalidated = _fnFilterData( settings );
  3895. // If the input is blank - we just want the full data set
  3896. if ( input.length <= 0 ) {
  3897. settings.aiDisplay = displayMaster.slice();
  3898. }
  3899. else {
  3900. // New search - start from the master array
  3901. if ( invalidated ||
  3902. force ||
  3903. regex ||
  3904. prevSearch.length > input.length ||
  3905. input.indexOf(prevSearch) !== 0 ||
  3906. settings.bSorted // On resort, the display master needs to be
  3907. // re-filtered since indexes will have changed
  3908. ) {
  3909. settings.aiDisplay = displayMaster.slice();
  3910. }
  3911. // Search the display array
  3912. display = settings.aiDisplay;
  3913. for ( i=0 ; i<display.length ; i++ ) {
  3914. if ( rpSearch.test( settings.aoData[ display[i] ]._sFilterRow ) ) {
  3915. filtered.push( display[i] );
  3916. }
  3917. }
  3918. settings.aiDisplay = filtered;
  3919. }
  3920. }
  3921. /**
  3922. * Build a regular expression object suitable for searching a table
  3923. * @param {string} sSearch string to search for
  3924. * @param {bool} bRegex treat as a regular expression or not
  3925. * @param {bool} bSmart perform smart filtering or not
  3926. * @param {bool} bCaseInsensitive Do case insensitive matching or not
  3927. * @returns {RegExp} constructed object
  3928. * @memberof DataTable#oApi
  3929. */
  3930. function _fnFilterCreateSearch( search, regex, smart, caseInsensitive )
  3931. {
  3932. search = regex ?
  3933. search :
  3934. _fnEscapeRegex( search );
  3935. if ( smart ) {
  3936. /* For smart filtering we want to allow the search to work regardless of
  3937. * word order. We also want double quoted text to be preserved, so word
  3938. * order is important - a la google. So this is what we want to
  3939. * generate:
  3940. *
  3941. * ^(?=.*?\bone\b)(?=.*?\btwo three\b)(?=.*?\bfour\b).*$
  3942. */
  3943. var a = $.map( search.match( /"[^"]+"|[^ ]+/g ) || [''], function ( word ) {
  3944. if ( word.charAt(0) === '"' ) {
  3945. var m = word.match( /^"(.*)"$/ );
  3946. word = m ? m[1] : word;
  3947. }
  3948. return word.replace('"', '');
  3949. } );
  3950. search = '^(?=.*?'+a.join( ')(?=.*?' )+').*$';
  3951. }
  3952. return new RegExp( search, caseInsensitive ? 'i' : '' );
  3953. }
  3954. /**
  3955. * Escape a string such that it can be used in a regular expression
  3956. * @param {string} sVal string to escape
  3957. * @returns {string} escaped string
  3958. * @memberof DataTable#oApi
  3959. */
  3960. var _fnEscapeRegex = DataTable.util.escapeRegex;
  3961. var __filter_div = $('<div>')[0];
  3962. var __filter_div_textContent = __filter_div.textContent !== undefined;
  3963. // Update the filtering data for each row if needed (by invalidation or first run)
  3964. function _fnFilterData ( settings )
  3965. {
  3966. var columns = settings.aoColumns;
  3967. var column;
  3968. var i, j, ien, jen, filterData, cellData, row;
  3969. var wasInvalidated = false;
  3970. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  3971. row = settings.aoData[i];
  3972. if ( ! row._aFilterData ) {
  3973. filterData = [];
  3974. for ( j=0, jen=columns.length ; j<jen ; j++ ) {
  3975. column = columns[j];
  3976. if ( column.bSearchable ) {
  3977. cellData = _fnGetCellData( settings, i, j, 'filter' );
  3978. // Search in DataTables 1.10 is string based. In 1.11 this
  3979. // should be altered to also allow strict type checking.
  3980. if ( cellData === null ) {
  3981. cellData = '';
  3982. }
  3983. if ( typeof cellData !== 'string' && cellData.toString ) {
  3984. cellData = cellData.toString();
  3985. }
  3986. }
  3987. else {
  3988. cellData = '';
  3989. }
  3990. // If it looks like there is an HTML entity in the string,
  3991. // attempt to decode it so sorting works as expected. Note that
  3992. // we could use a single line of jQuery to do this, but the DOM
  3993. // method used here is much faster http://jsperf.com/html-decode
  3994. if ( cellData.indexOf && cellData.indexOf('&') !== -1 ) {
  3995. __filter_div.innerHTML = cellData;
  3996. cellData = __filter_div_textContent ?
  3997. __filter_div.textContent :
  3998. __filter_div.innerText;
  3999. }
  4000. if ( cellData.replace ) {
  4001. cellData = cellData.replace(/[\r\n\u2028]/g, '');
  4002. }
  4003. filterData.push( cellData );
  4004. }
  4005. row._aFilterData = filterData;
  4006. row._sFilterRow = filterData.join(' ');
  4007. wasInvalidated = true;
  4008. }
  4009. }
  4010. return wasInvalidated;
  4011. }
  4012. /**
  4013. * Convert from the internal Hungarian notation to camelCase for external
  4014. * interaction
  4015. * @param {object} obj Object to convert
  4016. * @returns {object} Inverted object
  4017. * @memberof DataTable#oApi
  4018. */
  4019. function _fnSearchToCamel ( obj )
  4020. {
  4021. return {
  4022. search: obj.sSearch,
  4023. smart: obj.bSmart,
  4024. regex: obj.bRegex,
  4025. caseInsensitive: obj.bCaseInsensitive
  4026. };
  4027. }
  4028. /**
  4029. * Convert from camelCase notation to the internal Hungarian. We could use the
  4030. * Hungarian convert function here, but this is cleaner
  4031. * @param {object} obj Object to convert
  4032. * @returns {object} Inverted object
  4033. * @memberof DataTable#oApi
  4034. */
  4035. function _fnSearchToHung ( obj )
  4036. {
  4037. return {
  4038. sSearch: obj.search,
  4039. bSmart: obj.smart,
  4040. bRegex: obj.regex,
  4041. bCaseInsensitive: obj.caseInsensitive
  4042. };
  4043. }
  4044. /**
  4045. * Generate the node required for the info display
  4046. * @param {object} oSettings dataTables settings object
  4047. * @returns {node} Information element
  4048. * @memberof DataTable#oApi
  4049. */
  4050. function _fnFeatureHtmlInfo ( settings )
  4051. {
  4052. var
  4053. tid = settings.sTableId,
  4054. nodes = settings.aanFeatures.i,
  4055. n = $('<div/>', {
  4056. 'class': settings.oClasses.sInfo,
  4057. 'id': ! nodes ? tid+'_info' : null
  4058. } );
  4059. if ( ! nodes ) {
  4060. // Update display on each draw
  4061. settings.aoDrawCallback.push( {
  4062. "fn": _fnUpdateInfo,
  4063. "sName": "information"
  4064. } );
  4065. n
  4066. .attr( 'role', 'status' )
  4067. .attr( 'aria-live', 'polite' );
  4068. // Table is described by our info div
  4069. $(settings.nTable).attr( 'aria-describedby', tid+'_info' );
  4070. }
  4071. return n[0];
  4072. }
  4073. /**
  4074. * Update the information elements in the display
  4075. * @param {object} settings dataTables settings object
  4076. * @memberof DataTable#oApi
  4077. */
  4078. function _fnUpdateInfo ( settings )
  4079. {
  4080. /* Show information about the table */
  4081. var nodes = settings.aanFeatures.i;
  4082. if ( nodes.length === 0 ) {
  4083. return;
  4084. }
  4085. var
  4086. lang = settings.oLanguage,
  4087. start = settings._iDisplayStart+1,
  4088. end = settings.fnDisplayEnd(),
  4089. max = settings.fnRecordsTotal(),
  4090. total = settings.fnRecordsDisplay(),
  4091. out = total ?
  4092. lang.sInfo :
  4093. lang.sInfoEmpty;
  4094. if ( total !== max ) {
  4095. /* Record set after filtering */
  4096. out += ' ' + lang.sInfoFiltered;
  4097. }
  4098. // Convert the macros
  4099. out += lang.sInfoPostFix;
  4100. out = _fnInfoMacros( settings, out );
  4101. var callback = lang.fnInfoCallback;
  4102. if ( callback !== null ) {
  4103. out = callback.call( settings.oInstance,
  4104. settings, start, end, max, total, out
  4105. );
  4106. }
  4107. $(nodes).html( out );
  4108. }
  4109. function _fnInfoMacros ( settings, str )
  4110. {
  4111. // When infinite scrolling, we are always starting at 1. _iDisplayStart is used only
  4112. // internally
  4113. var
  4114. formatter = settings.fnFormatNumber,
  4115. start = settings._iDisplayStart+1,
  4116. len = settings._iDisplayLength,
  4117. vis = settings.fnRecordsDisplay(),
  4118. all = len === -1;
  4119. return str.
  4120. replace(/_START_/g, formatter.call( settings, start ) ).
  4121. replace(/_END_/g, formatter.call( settings, settings.fnDisplayEnd() ) ).
  4122. replace(/_MAX_/g, formatter.call( settings, settings.fnRecordsTotal() ) ).
  4123. replace(/_TOTAL_/g, formatter.call( settings, vis ) ).
  4124. replace(/_PAGE_/g, formatter.call( settings, all ? 1 : Math.ceil( start / len ) ) ).
  4125. replace(/_PAGES_/g, formatter.call( settings, all ? 1 : Math.ceil( vis / len ) ) );
  4126. }
  4127. /**
  4128. * Draw the table for the first time, adding all required features
  4129. * @param {object} settings dataTables settings object
  4130. * @memberof DataTable#oApi
  4131. */
  4132. function _fnInitialise ( settings )
  4133. {
  4134. var i, iLen, iAjaxStart=settings.iInitDisplayStart;
  4135. var columns = settings.aoColumns, column;
  4136. var features = settings.oFeatures;
  4137. var deferLoading = settings.bDeferLoading; // value modified by the draw
  4138. /* Ensure that the table data is fully initialised */
  4139. if ( ! settings.bInitialised ) {
  4140. setTimeout( function(){ _fnInitialise( settings ); }, 200 );
  4141. return;
  4142. }
  4143. /* Show the display HTML options */
  4144. _fnAddOptionsHtml( settings );
  4145. /* Build and draw the header / footer for the table */
  4146. _fnBuildHead( settings );
  4147. _fnDrawHead( settings, settings.aoHeader );
  4148. _fnDrawHead( settings, settings.aoFooter );
  4149. /* Okay to show that something is going on now */
  4150. _fnProcessingDisplay( settings, true );
  4151. /* Calculate sizes for columns */
  4152. if ( features.bAutoWidth ) {
  4153. _fnCalculateColumnWidths( settings );
  4154. }
  4155. for ( i=0, iLen=columns.length ; i<iLen ; i++ ) {
  4156. column = columns[i];
  4157. if ( column.sWidth ) {
  4158. column.nTh.style.width = _fnStringToCss( column.sWidth );
  4159. }
  4160. }
  4161. _fnCallbackFire( settings, null, 'preInit', [settings] );
  4162. // If there is default sorting required - let's do it. The sort function
  4163. // will do the drawing for us. Otherwise we draw the table regardless of the
  4164. // Ajax source - this allows the table to look initialised for Ajax sourcing
  4165. // data (show 'loading' message possibly)
  4166. _fnReDraw( settings );
  4167. // Server-side processing init complete is done by _fnAjaxUpdateDraw
  4168. var dataSrc = _fnDataSource( settings );
  4169. if ( dataSrc != 'ssp' || deferLoading ) {
  4170. // if there is an ajax source load the data
  4171. if ( dataSrc == 'ajax' ) {
  4172. _fnBuildAjax( settings, [], function(json) {
  4173. var aData = _fnAjaxDataSrc( settings, json );
  4174. // Got the data - add it to the table
  4175. for ( i=0 ; i<aData.length ; i++ ) {
  4176. _fnAddData( settings, aData[i] );
  4177. }
  4178. // Reset the init display for cookie saving. We've already done
  4179. // a filter, and therefore cleared it before. So we need to make
  4180. // it appear 'fresh'
  4181. settings.iInitDisplayStart = iAjaxStart;
  4182. _fnReDraw( settings );
  4183. _fnProcessingDisplay( settings, false );
  4184. _fnInitComplete( settings, json );
  4185. }, settings );
  4186. }
  4187. else {
  4188. _fnProcessingDisplay( settings, false );
  4189. _fnInitComplete( settings );
  4190. }
  4191. }
  4192. }
  4193. /**
  4194. * Draw the table for the first time, adding all required features
  4195. * @param {object} oSettings dataTables settings object
  4196. * @param {object} [json] JSON from the server that completed the table, if using Ajax source
  4197. * with client-side processing (optional)
  4198. * @memberof DataTable#oApi
  4199. */
  4200. function _fnInitComplete ( settings, json )
  4201. {
  4202. settings._bInitComplete = true;
  4203. // When data was added after the initialisation (data or Ajax) we need to
  4204. // calculate the column sizing
  4205. if ( json || settings.oInit.aaData ) {
  4206. _fnAdjustColumnSizing( settings );
  4207. }
  4208. _fnCallbackFire( settings, null, 'plugin-init', [settings, json] );
  4209. _fnCallbackFire( settings, 'aoInitComplete', 'init', [settings, json] );
  4210. }
  4211. function _fnLengthChange ( settings, val )
  4212. {
  4213. var len = parseInt( val, 10 );
  4214. settings._iDisplayLength = len;
  4215. _fnLengthOverflow( settings );
  4216. // Fire length change event
  4217. _fnCallbackFire( settings, null, 'length', [settings, len] );
  4218. }
  4219. /**
  4220. * Generate the node required for user display length changing
  4221. * @param {object} settings dataTables settings object
  4222. * @returns {node} Display length feature node
  4223. * @memberof DataTable#oApi
  4224. */
  4225. function _fnFeatureHtmlLength ( settings )
  4226. {
  4227. var
  4228. classes = settings.oClasses,
  4229. tableId = settings.sTableId,
  4230. menu = settings.aLengthMenu,
  4231. d2 = Array.isArray( menu[0] ),
  4232. lengths = d2 ? menu[0] : menu,
  4233. language = d2 ? menu[1] : menu;
  4234. var select = $('<select/>', {
  4235. 'name': tableId+'_length',
  4236. 'aria-controls': tableId,
  4237. 'class': classes.sLengthSelect
  4238. } );
  4239. for ( var i=0, ien=lengths.length ; i<ien ; i++ ) {
  4240. select[0][ i ] = new Option(
  4241. typeof language[i] === 'number' ?
  4242. settings.fnFormatNumber( language[i] ) :
  4243. language[i],
  4244. lengths[i]
  4245. );
  4246. }
  4247. var div = $('<div><label/></div>').addClass( classes.sLength );
  4248. if ( ! settings.aanFeatures.l ) {
  4249. div[0].id = tableId+'_length';
  4250. }
  4251. div.children().append(
  4252. settings.oLanguage.sLengthMenu.replace( '_MENU_', select[0].outerHTML )
  4253. );
  4254. // Can't use `select` variable as user might provide their own and the
  4255. // reference is broken by the use of outerHTML
  4256. $('select', div)
  4257. .val( settings._iDisplayLength )
  4258. .on( 'change.DT', function(e) {
  4259. _fnLengthChange( settings, $(this).val() );
  4260. _fnDraw( settings );
  4261. } );
  4262. // Update node value whenever anything changes the table's length
  4263. $(settings.nTable).on( 'length.dt.DT', function (e, s, len) {
  4264. if ( settings === s ) {
  4265. $('select', div).val( len );
  4266. }
  4267. } );
  4268. return div[0];
  4269. }
  4270. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  4271. * Note that most of the paging logic is done in
  4272. * DataTable.ext.pager
  4273. */
  4274. /**
  4275. * Generate the node required for default pagination
  4276. * @param {object} oSettings dataTables settings object
  4277. * @returns {node} Pagination feature node
  4278. * @memberof DataTable#oApi
  4279. */
  4280. function _fnFeatureHtmlPaginate ( settings )
  4281. {
  4282. var
  4283. type = settings.sPaginationType,
  4284. plugin = DataTable.ext.pager[ type ],
  4285. modern = typeof plugin === 'function',
  4286. redraw = function( settings ) {
  4287. _fnDraw( settings );
  4288. },
  4289. node = $('<div/>').addClass( settings.oClasses.sPaging + type )[0],
  4290. features = settings.aanFeatures;
  4291. if ( ! modern ) {
  4292. plugin.fnInit( settings, node, redraw );
  4293. }
  4294. /* Add a draw callback for the pagination on first instance, to update the paging display */
  4295. if ( ! features.p )
  4296. {
  4297. node.id = settings.sTableId+'_paginate';
  4298. settings.aoDrawCallback.push( {
  4299. "fn": function( settings ) {
  4300. if ( modern ) {
  4301. var
  4302. start = settings._iDisplayStart,
  4303. len = settings._iDisplayLength,
  4304. visRecords = settings.fnRecordsDisplay(),
  4305. all = len === -1,
  4306. page = all ? 0 : Math.ceil( start / len ),
  4307. pages = all ? 1 : Math.ceil( visRecords / len ),
  4308. buttons = plugin(page, pages),
  4309. i, ien;
  4310. for ( i=0, ien=features.p.length ; i<ien ; i++ ) {
  4311. _fnRenderer( settings, 'pageButton' )(
  4312. settings, features.p[i], i, buttons, page, pages
  4313. );
  4314. }
  4315. }
  4316. else {
  4317. plugin.fnUpdate( settings, redraw );
  4318. }
  4319. },
  4320. "sName": "pagination"
  4321. } );
  4322. }
  4323. return node;
  4324. }
  4325. /**
  4326. * Alter the display settings to change the page
  4327. * @param {object} settings DataTables settings object
  4328. * @param {string|int} action Paging action to take: "first", "previous",
  4329. * "next" or "last" or page number to jump to (integer)
  4330. * @param [bool] redraw Automatically draw the update or not
  4331. * @returns {bool} true page has changed, false - no change
  4332. * @memberof DataTable#oApi
  4333. */
  4334. function _fnPageChange ( settings, action, redraw )
  4335. {
  4336. var
  4337. start = settings._iDisplayStart,
  4338. len = settings._iDisplayLength,
  4339. records = settings.fnRecordsDisplay();
  4340. if ( records === 0 || len === -1 )
  4341. {
  4342. start = 0;
  4343. }
  4344. else if ( typeof action === "number" )
  4345. {
  4346. start = action * len;
  4347. if ( start > records )
  4348. {
  4349. start = 0;
  4350. }
  4351. }
  4352. else if ( action == "first" )
  4353. {
  4354. start = 0;
  4355. }
  4356. else if ( action == "previous" )
  4357. {
  4358. start = len >= 0 ?
  4359. start - len :
  4360. 0;
  4361. if ( start < 0 )
  4362. {
  4363. start = 0;
  4364. }
  4365. }
  4366. else if ( action == "next" )
  4367. {
  4368. if ( start + len < records )
  4369. {
  4370. start += len;
  4371. }
  4372. }
  4373. else if ( action == "last" )
  4374. {
  4375. start = Math.floor( (records-1) / len) * len;
  4376. }
  4377. else
  4378. {
  4379. _fnLog( settings, 0, "Unknown paging action: "+action, 5 );
  4380. }
  4381. var changed = settings._iDisplayStart !== start;
  4382. settings._iDisplayStart = start;
  4383. if ( changed ) {
  4384. _fnCallbackFire( settings, null, 'page', [settings] );
  4385. if ( redraw ) {
  4386. _fnDraw( settings );
  4387. }
  4388. }
  4389. return changed;
  4390. }
  4391. /**
  4392. * Generate the node required for the processing node
  4393. * @param {object} settings dataTables settings object
  4394. * @returns {node} Processing element
  4395. * @memberof DataTable#oApi
  4396. */
  4397. function _fnFeatureHtmlProcessing ( settings )
  4398. {
  4399. return $('<div/>', {
  4400. 'id': ! settings.aanFeatures.r ? settings.sTableId+'_processing' : null,
  4401. 'class': settings.oClasses.sProcessing
  4402. } )
  4403. .html( settings.oLanguage.sProcessing )
  4404. .insertBefore( settings.nTable )[0];
  4405. }
  4406. /**
  4407. * Display or hide the processing indicator
  4408. * @param {object} settings dataTables settings object
  4409. * @param {bool} show Show the processing indicator (true) or not (false)
  4410. * @memberof DataTable#oApi
  4411. */
  4412. function _fnProcessingDisplay ( settings, show )
  4413. {
  4414. if ( settings.oFeatures.bProcessing ) {
  4415. $(settings.aanFeatures.r).css( 'display', show ? 'block' : 'none' );
  4416. }
  4417. _fnCallbackFire( settings, null, 'processing', [settings, show] );
  4418. }
  4419. /**
  4420. * Add any control elements for the table - specifically scrolling
  4421. * @param {object} settings dataTables settings object
  4422. * @returns {node} Node to add to the DOM
  4423. * @memberof DataTable#oApi
  4424. */
  4425. function _fnFeatureHtmlTable ( settings )
  4426. {
  4427. var table = $(settings.nTable);
  4428. // Scrolling from here on in
  4429. var scroll = settings.oScroll;
  4430. if ( scroll.sX === '' && scroll.sY === '' ) {
  4431. return settings.nTable;
  4432. }
  4433. var scrollX = scroll.sX;
  4434. var scrollY = scroll.sY;
  4435. var classes = settings.oClasses;
  4436. var caption = table.children('caption');
  4437. var captionSide = caption.length ? caption[0]._captionSide : null;
  4438. var headerClone = $( table[0].cloneNode(false) );
  4439. var footerClone = $( table[0].cloneNode(false) );
  4440. var footer = table.children('tfoot');
  4441. var _div = '<div/>';
  4442. var size = function ( s ) {
  4443. return !s ? null : _fnStringToCss( s );
  4444. };
  4445. if ( ! footer.length ) {
  4446. footer = null;
  4447. }
  4448. /*
  4449. * The HTML structure that we want to generate in this function is:
  4450. * div - scroller
  4451. * div - scroll head
  4452. * div - scroll head inner
  4453. * table - scroll head table
  4454. * thead - thead
  4455. * div - scroll body
  4456. * table - table (master table)
  4457. * thead - thead clone for sizing
  4458. * tbody - tbody
  4459. * div - scroll foot
  4460. * div - scroll foot inner
  4461. * table - scroll foot table
  4462. * tfoot - tfoot
  4463. */
  4464. var scroller = $( _div, { 'class': classes.sScrollWrapper } )
  4465. .append(
  4466. $(_div, { 'class': classes.sScrollHead } )
  4467. .css( {
  4468. overflow: 'hidden',
  4469. position: 'relative',
  4470. border: 0,
  4471. width: scrollX ? size(scrollX) : '100%'
  4472. } )
  4473. .append(
  4474. $(_div, { 'class': classes.sScrollHeadInner } )
  4475. .css( {
  4476. 'box-sizing': 'content-box',
  4477. width: scroll.sXInner || '100%'
  4478. } )
  4479. .append(
  4480. headerClone
  4481. .removeAttr('id')
  4482. .css( 'margin-left', 0 )
  4483. .append( captionSide === 'top' ? caption : null )
  4484. .append(
  4485. table.children('thead')
  4486. )
  4487. )
  4488. )
  4489. )
  4490. .append(
  4491. $(_div, { 'class': classes.sScrollBody } )
  4492. .css( {
  4493. position: 'relative',
  4494. overflow: 'auto',
  4495. width: size( scrollX )
  4496. } )
  4497. .append( table )
  4498. );
  4499. if ( footer ) {
  4500. scroller.append(
  4501. $(_div, { 'class': classes.sScrollFoot } )
  4502. .css( {
  4503. overflow: 'hidden',
  4504. border: 0,
  4505. width: scrollX ? size(scrollX) : '100%'
  4506. } )
  4507. .append(
  4508. $(_div, { 'class': classes.sScrollFootInner } )
  4509. .append(
  4510. footerClone
  4511. .removeAttr('id')
  4512. .css( 'margin-left', 0 )
  4513. .append( captionSide === 'bottom' ? caption : null )
  4514. .append(
  4515. table.children('tfoot')
  4516. )
  4517. )
  4518. )
  4519. );
  4520. }
  4521. var children = scroller.children();
  4522. var scrollHead = children[0];
  4523. var scrollBody = children[1];
  4524. var scrollFoot = footer ? children[2] : null;
  4525. // When the body is scrolled, then we also want to scroll the headers
  4526. if ( scrollX ) {
  4527. $(scrollBody).on( 'scroll.DT', function (e) {
  4528. var scrollLeft = this.scrollLeft;
  4529. scrollHead.scrollLeft = scrollLeft;
  4530. if ( footer ) {
  4531. scrollFoot.scrollLeft = scrollLeft;
  4532. }
  4533. } );
  4534. }
  4535. $(scrollBody).css('max-height', scrollY);
  4536. if (! scroll.bCollapse) {
  4537. $(scrollBody).css('height', scrollY);
  4538. }
  4539. settings.nScrollHead = scrollHead;
  4540. settings.nScrollBody = scrollBody;
  4541. settings.nScrollFoot = scrollFoot;
  4542. // On redraw - align columns
  4543. settings.aoDrawCallback.push( {
  4544. "fn": _fnScrollDraw,
  4545. "sName": "scrolling"
  4546. } );
  4547. return scroller[0];
  4548. }
  4549. /**
  4550. * Update the header, footer and body tables for resizing - i.e. column
  4551. * alignment.
  4552. *
  4553. * Welcome to the most horrible function DataTables. The process that this
  4554. * function follows is basically:
  4555. * 1. Re-create the table inside the scrolling div
  4556. * 2. Take live measurements from the DOM
  4557. * 3. Apply the measurements to align the columns
  4558. * 4. Clean up
  4559. *
  4560. * @param {object} settings dataTables settings object
  4561. * @memberof DataTable#oApi
  4562. */
  4563. function _fnScrollDraw ( settings )
  4564. {
  4565. // Given that this is such a monster function, a lot of variables are use
  4566. // to try and keep the minimised size as small as possible
  4567. var
  4568. scroll = settings.oScroll,
  4569. scrollX = scroll.sX,
  4570. scrollXInner = scroll.sXInner,
  4571. scrollY = scroll.sY,
  4572. barWidth = scroll.iBarWidth,
  4573. divHeader = $(settings.nScrollHead),
  4574. divHeaderStyle = divHeader[0].style,
  4575. divHeaderInner = divHeader.children('div'),
  4576. divHeaderInnerStyle = divHeaderInner[0].style,
  4577. divHeaderTable = divHeaderInner.children('table'),
  4578. divBodyEl = settings.nScrollBody,
  4579. divBody = $(divBodyEl),
  4580. divBodyStyle = divBodyEl.style,
  4581. divFooter = $(settings.nScrollFoot),
  4582. divFooterInner = divFooter.children('div'),
  4583. divFooterTable = divFooterInner.children('table'),
  4584. header = $(settings.nTHead),
  4585. table = $(settings.nTable),
  4586. tableEl = table[0],
  4587. tableStyle = tableEl.style,
  4588. footer = settings.nTFoot ? $(settings.nTFoot) : null,
  4589. browser = settings.oBrowser,
  4590. ie67 = browser.bScrollOversize,
  4591. dtHeaderCells = _pluck( settings.aoColumns, 'nTh' ),
  4592. headerTrgEls, footerTrgEls,
  4593. headerSrcEls, footerSrcEls,
  4594. headerCopy, footerCopy,
  4595. headerWidths=[], footerWidths=[],
  4596. headerContent=[], footerContent=[],
  4597. idx, correction, sanityWidth,
  4598. zeroOut = function(nSizer) {
  4599. var style = nSizer.style;
  4600. style.paddingTop = "0";
  4601. style.paddingBottom = "0";
  4602. style.borderTopWidth = "0";
  4603. style.borderBottomWidth = "0";
  4604. style.height = 0;
  4605. };
  4606. // If the scrollbar visibility has changed from the last draw, we need to
  4607. // adjust the column sizes as the table width will have changed to account
  4608. // for the scrollbar
  4609. var scrollBarVis = divBodyEl.scrollHeight > divBodyEl.clientHeight;
  4610. if ( settings.scrollBarVis !== scrollBarVis && settings.scrollBarVis !== undefined ) {
  4611. settings.scrollBarVis = scrollBarVis;
  4612. _fnAdjustColumnSizing( settings );
  4613. return; // adjust column sizing will call this function again
  4614. }
  4615. else {
  4616. settings.scrollBarVis = scrollBarVis;
  4617. }
  4618. /*
  4619. * 1. Re-create the table inside the scrolling div
  4620. */
  4621. // Remove the old minimised thead and tfoot elements in the inner table
  4622. table.children('thead, tfoot').remove();
  4623. if ( footer ) {
  4624. footerCopy = footer.clone().prependTo( table );
  4625. footerTrgEls = footer.find('tr'); // the original tfoot is in its own table and must be sized
  4626. footerSrcEls = footerCopy.find('tr');
  4627. }
  4628. // Clone the current header and footer elements and then place it into the inner table
  4629. headerCopy = header.clone().prependTo( table );
  4630. headerTrgEls = header.find('tr'); // original header is in its own table
  4631. headerSrcEls = headerCopy.find('tr');
  4632. headerCopy.find('th, td').removeAttr('tabindex');
  4633. /*
  4634. * 2. Take live measurements from the DOM - do not alter the DOM itself!
  4635. */
  4636. // Remove old sizing and apply the calculated column widths
  4637. // Get the unique column headers in the newly created (cloned) header. We want to apply the
  4638. // calculated sizes to this header
  4639. if ( ! scrollX )
  4640. {
  4641. divBodyStyle.width = '100%';
  4642. divHeader[0].style.width = '100%';
  4643. }
  4644. $.each( _fnGetUniqueThs( settings, headerCopy ), function ( i, el ) {
  4645. idx = _fnVisibleToColumnIndex( settings, i );
  4646. el.style.width = settings.aoColumns[idx].sWidth;
  4647. } );
  4648. if ( footer ) {
  4649. _fnApplyToChildren( function(n) {
  4650. n.style.width = "";
  4651. }, footerSrcEls );
  4652. }
  4653. // Size the table as a whole
  4654. sanityWidth = table.outerWidth();
  4655. if ( scrollX === "" ) {
  4656. // No x scrolling
  4657. tableStyle.width = "100%";
  4658. // IE7 will make the width of the table when 100% include the scrollbar
  4659. // - which is shouldn't. When there is a scrollbar we need to take this
  4660. // into account.
  4661. if ( ie67 && (table.find('tbody').height() > divBodyEl.offsetHeight ||
  4662. divBody.css('overflow-y') == "scroll")
  4663. ) {
  4664. tableStyle.width = _fnStringToCss( table.outerWidth() - barWidth);
  4665. }
  4666. // Recalculate the sanity width
  4667. sanityWidth = table.outerWidth();
  4668. }
  4669. else if ( scrollXInner !== "" ) {
  4670. // legacy x scroll inner has been given - use it
  4671. tableStyle.width = _fnStringToCss(scrollXInner);
  4672. // Recalculate the sanity width
  4673. sanityWidth = table.outerWidth();
  4674. }
  4675. // Hidden header should have zero height, so remove padding and borders. Then
  4676. // set the width based on the real headers
  4677. // Apply all styles in one pass
  4678. _fnApplyToChildren( zeroOut, headerSrcEls );
  4679. // Read all widths in next pass
  4680. _fnApplyToChildren( function(nSizer) {
  4681. var style = window.getComputedStyle ?
  4682. window.getComputedStyle(nSizer).width :
  4683. _fnStringToCss( $(nSizer).width() );
  4684. headerContent.push( nSizer.innerHTML );
  4685. headerWidths.push( style );
  4686. }, headerSrcEls );
  4687. // Apply all widths in final pass
  4688. _fnApplyToChildren( function(nToSize, i) {
  4689. nToSize.style.width = headerWidths[i];
  4690. }, headerTrgEls );
  4691. $(headerSrcEls).height(0);
  4692. /* Same again with the footer if we have one */
  4693. if ( footer )
  4694. {
  4695. _fnApplyToChildren( zeroOut, footerSrcEls );
  4696. _fnApplyToChildren( function(nSizer) {
  4697. footerContent.push( nSizer.innerHTML );
  4698. footerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  4699. }, footerSrcEls );
  4700. _fnApplyToChildren( function(nToSize, i) {
  4701. nToSize.style.width = footerWidths[i];
  4702. }, footerTrgEls );
  4703. $(footerSrcEls).height(0);
  4704. }
  4705. /*
  4706. * 3. Apply the measurements
  4707. */
  4708. // "Hide" the header and footer that we used for the sizing. We need to keep
  4709. // the content of the cell so that the width applied to the header and body
  4710. // both match, but we want to hide it completely. We want to also fix their
  4711. // width to what they currently are
  4712. _fnApplyToChildren( function(nSizer, i) {
  4713. nSizer.innerHTML = '<div class="dataTables_sizing">'+headerContent[i]+'</div>';
  4714. nSizer.childNodes[0].style.height = "0";
  4715. nSizer.childNodes[0].style.overflow = "hidden";
  4716. nSizer.style.width = headerWidths[i];
  4717. }, headerSrcEls );
  4718. if ( footer )
  4719. {
  4720. _fnApplyToChildren( function(nSizer, i) {
  4721. nSizer.innerHTML = '<div class="dataTables_sizing">'+footerContent[i]+'</div>';
  4722. nSizer.childNodes[0].style.height = "0";
  4723. nSizer.childNodes[0].style.overflow = "hidden";
  4724. nSizer.style.width = footerWidths[i];
  4725. }, footerSrcEls );
  4726. }
  4727. // Sanity check that the table is of a sensible width. If not then we are going to get
  4728. // misalignment - try to prevent this by not allowing the table to shrink below its min width
  4729. if ( Math.round(table.outerWidth()) < Math.round(sanityWidth) )
  4730. {
  4731. // The min width depends upon if we have a vertical scrollbar visible or not */
  4732. correction = ((divBodyEl.scrollHeight > divBodyEl.offsetHeight ||
  4733. divBody.css('overflow-y') == "scroll")) ?
  4734. sanityWidth+barWidth :
  4735. sanityWidth;
  4736. // IE6/7 are a law unto themselves...
  4737. if ( ie67 && (divBodyEl.scrollHeight >
  4738. divBodyEl.offsetHeight || divBody.css('overflow-y') == "scroll")
  4739. ) {
  4740. tableStyle.width = _fnStringToCss( correction-barWidth );
  4741. }
  4742. // And give the user a warning that we've stopped the table getting too small
  4743. if ( scrollX === "" || scrollXInner !== "" ) {
  4744. _fnLog( settings, 1, 'Possible column misalignment', 6 );
  4745. }
  4746. }
  4747. else
  4748. {
  4749. correction = '100%';
  4750. }
  4751. // Apply to the container elements
  4752. divBodyStyle.width = _fnStringToCss( correction );
  4753. divHeaderStyle.width = _fnStringToCss( correction );
  4754. if ( footer ) {
  4755. settings.nScrollFoot.style.width = _fnStringToCss( correction );
  4756. }
  4757. /*
  4758. * 4. Clean up
  4759. */
  4760. if ( ! scrollY ) {
  4761. /* IE7< puts a vertical scrollbar in place (when it shouldn't be) due to subtracting
  4762. * the scrollbar height from the visible display, rather than adding it on. We need to
  4763. * set the height in order to sort this. Don't want to do it in any other browsers.
  4764. */
  4765. if ( ie67 ) {
  4766. divBodyStyle.height = _fnStringToCss( tableEl.offsetHeight+barWidth );
  4767. }
  4768. }
  4769. /* Finally set the width's of the header and footer tables */
  4770. var iOuterWidth = table.outerWidth();
  4771. divHeaderTable[0].style.width = _fnStringToCss( iOuterWidth );
  4772. divHeaderInnerStyle.width = _fnStringToCss( iOuterWidth );
  4773. // Figure out if there are scrollbar present - if so then we need a the header and footer to
  4774. // provide a bit more space to allow "overflow" scrolling (i.e. past the scrollbar)
  4775. var bScrolling = table.height() > divBodyEl.clientHeight || divBody.css('overflow-y') == "scroll";
  4776. var padding = 'padding' + (browser.bScrollbarLeft ? 'Left' : 'Right' );
  4777. divHeaderInnerStyle[ padding ] = bScrolling ? barWidth+"px" : "0px";
  4778. if ( footer ) {
  4779. divFooterTable[0].style.width = _fnStringToCss( iOuterWidth );
  4780. divFooterInner[0].style.width = _fnStringToCss( iOuterWidth );
  4781. divFooterInner[0].style[padding] = bScrolling ? barWidth+"px" : "0px";
  4782. }
  4783. // Correct DOM ordering for colgroup - comes before the thead
  4784. table.children('colgroup').insertBefore( table.children('thead') );
  4785. /* Adjust the position of the header in case we loose the y-scrollbar */
  4786. divBody.trigger('scroll');
  4787. // If sorting or filtering has occurred, jump the scrolling back to the top
  4788. // only if we aren't holding the position
  4789. if ( (settings.bSorted || settings.bFiltered) && ! settings._drawHold ) {
  4790. divBodyEl.scrollTop = 0;
  4791. }
  4792. }
  4793. /**
  4794. * Apply a given function to the display child nodes of an element array (typically
  4795. * TD children of TR rows
  4796. * @param {function} fn Method to apply to the objects
  4797. * @param array {nodes} an1 List of elements to look through for display children
  4798. * @param array {nodes} an2 Another list (identical structure to the first) - optional
  4799. * @memberof DataTable#oApi
  4800. */
  4801. function _fnApplyToChildren( fn, an1, an2 )
  4802. {
  4803. var index=0, i=0, iLen=an1.length;
  4804. var nNode1, nNode2;
  4805. while ( i < iLen ) {
  4806. nNode1 = an1[i].firstChild;
  4807. nNode2 = an2 ? an2[i].firstChild : null;
  4808. while ( nNode1 ) {
  4809. if ( nNode1.nodeType === 1 ) {
  4810. if ( an2 ) {
  4811. fn( nNode1, nNode2, index );
  4812. }
  4813. else {
  4814. fn( nNode1, index );
  4815. }
  4816. index++;
  4817. }
  4818. nNode1 = nNode1.nextSibling;
  4819. nNode2 = an2 ? nNode2.nextSibling : null;
  4820. }
  4821. i++;
  4822. }
  4823. }
  4824. var __re_html_remove = /<.*?>/g;
  4825. /**
  4826. * Calculate the width of columns for the table
  4827. * @param {object} oSettings dataTables settings object
  4828. * @memberof DataTable#oApi
  4829. */
  4830. function _fnCalculateColumnWidths ( oSettings )
  4831. {
  4832. var
  4833. table = oSettings.nTable,
  4834. columns = oSettings.aoColumns,
  4835. scroll = oSettings.oScroll,
  4836. scrollY = scroll.sY,
  4837. scrollX = scroll.sX,
  4838. scrollXInner = scroll.sXInner,
  4839. columnCount = columns.length,
  4840. visibleColumns = _fnGetColumns( oSettings, 'bVisible' ),
  4841. headerCells = $('th', oSettings.nTHead),
  4842. tableWidthAttr = table.getAttribute('width'), // from DOM element
  4843. tableContainer = table.parentNode,
  4844. userInputs = false,
  4845. i, column, columnIdx, width, outerWidth,
  4846. browser = oSettings.oBrowser,
  4847. ie67 = browser.bScrollOversize;
  4848. var styleWidth = table.style.width;
  4849. if ( styleWidth && styleWidth.indexOf('%') !== -1 ) {
  4850. tableWidthAttr = styleWidth;
  4851. }
  4852. /* Convert any user input sizes into pixel sizes */
  4853. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4854. column = columns[ visibleColumns[i] ];
  4855. if ( column.sWidth !== null ) {
  4856. column.sWidth = _fnConvertToWidth( column.sWidthOrig, tableContainer );
  4857. userInputs = true;
  4858. }
  4859. }
  4860. /* If the number of columns in the DOM equals the number that we have to
  4861. * process in DataTables, then we can use the offsets that are created by
  4862. * the web- browser. No custom sizes can be set in order for this to happen,
  4863. * nor scrolling used
  4864. */
  4865. if ( ie67 || ! userInputs && ! scrollX && ! scrollY &&
  4866. columnCount == _fnVisbleColumns( oSettings ) &&
  4867. columnCount == headerCells.length
  4868. ) {
  4869. for ( i=0 ; i<columnCount ; i++ ) {
  4870. var colIdx = _fnVisibleToColumnIndex( oSettings, i );
  4871. if ( colIdx !== null ) {
  4872. columns[ colIdx ].sWidth = _fnStringToCss( headerCells.eq(i).width() );
  4873. }
  4874. }
  4875. }
  4876. else
  4877. {
  4878. // Otherwise construct a single row, worst case, table with the widest
  4879. // node in the data, assign any user defined widths, then insert it into
  4880. // the DOM and allow the browser to do all the hard work of calculating
  4881. // table widths
  4882. var tmpTable = $(table).clone() // don't use cloneNode - IE8 will remove events on the main table
  4883. .css( 'visibility', 'hidden' )
  4884. .removeAttr( 'id' );
  4885. // Clean up the table body
  4886. tmpTable.find('tbody tr').remove();
  4887. var tr = $('<tr/>').appendTo( tmpTable.find('tbody') );
  4888. // Clone the table header and footer - we can't use the header / footer
  4889. // from the cloned table, since if scrolling is active, the table's
  4890. // real header and footer are contained in different table tags
  4891. tmpTable.find('thead, tfoot').remove();
  4892. tmpTable
  4893. .append( $(oSettings.nTHead).clone() )
  4894. .append( $(oSettings.nTFoot).clone() );
  4895. // Remove any assigned widths from the footer (from scrolling)
  4896. tmpTable.find('tfoot th, tfoot td').css('width', '');
  4897. // Apply custom sizing to the cloned header
  4898. headerCells = _fnGetUniqueThs( oSettings, tmpTable.find('thead')[0] );
  4899. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4900. column = columns[ visibleColumns[i] ];
  4901. headerCells[i].style.width = column.sWidthOrig !== null && column.sWidthOrig !== '' ?
  4902. _fnStringToCss( column.sWidthOrig ) :
  4903. '';
  4904. // For scrollX we need to force the column width otherwise the
  4905. // browser will collapse it. If this width is smaller than the
  4906. // width the column requires, then it will have no effect
  4907. if ( column.sWidthOrig && scrollX ) {
  4908. $( headerCells[i] ).append( $('<div/>').css( {
  4909. width: column.sWidthOrig,
  4910. margin: 0,
  4911. padding: 0,
  4912. border: 0,
  4913. height: 1
  4914. } ) );
  4915. }
  4916. }
  4917. // Find the widest cell for each column and put it into the table
  4918. if ( oSettings.aoData.length ) {
  4919. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4920. columnIdx = visibleColumns[i];
  4921. column = columns[ columnIdx ];
  4922. $( _fnGetWidestNode( oSettings, columnIdx ) )
  4923. .clone( false )
  4924. .append( column.sContentPadding )
  4925. .appendTo( tr );
  4926. }
  4927. }
  4928. // Tidy the temporary table - remove name attributes so there aren't
  4929. // duplicated in the dom (radio elements for example)
  4930. $('[name]', tmpTable).removeAttr('name');
  4931. // Table has been built, attach to the document so we can work with it.
  4932. // A holding element is used, positioned at the top of the container
  4933. // with minimal height, so it has no effect on if the container scrolls
  4934. // or not. Otherwise it might trigger scrolling when it actually isn't
  4935. // needed
  4936. var holder = $('<div/>').css( scrollX || scrollY ?
  4937. {
  4938. position: 'absolute',
  4939. top: 0,
  4940. left: 0,
  4941. height: 1,
  4942. right: 0,
  4943. overflow: 'hidden'
  4944. } :
  4945. {}
  4946. )
  4947. .append( tmpTable )
  4948. .appendTo( tableContainer );
  4949. // When scrolling (X or Y) we want to set the width of the table as
  4950. // appropriate. However, when not scrolling leave the table width as it
  4951. // is. This results in slightly different, but I think correct behaviour
  4952. if ( scrollX && scrollXInner ) {
  4953. tmpTable.width( scrollXInner );
  4954. }
  4955. else if ( scrollX ) {
  4956. tmpTable.css( 'width', 'auto' );
  4957. tmpTable.removeAttr('width');
  4958. // If there is no width attribute or style, then allow the table to
  4959. // collapse
  4960. if ( tmpTable.width() < tableContainer.clientWidth && tableWidthAttr ) {
  4961. tmpTable.width( tableContainer.clientWidth );
  4962. }
  4963. }
  4964. else if ( scrollY ) {
  4965. tmpTable.width( tableContainer.clientWidth );
  4966. }
  4967. else if ( tableWidthAttr ) {
  4968. tmpTable.width( tableWidthAttr );
  4969. }
  4970. // Get the width of each column in the constructed table - we need to
  4971. // know the inner width (so it can be assigned to the other table's
  4972. // cells) and the outer width so we can calculate the full width of the
  4973. // table. This is safe since DataTables requires a unique cell for each
  4974. // column, but if ever a header can span multiple columns, this will
  4975. // need to be modified.
  4976. var total = 0;
  4977. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4978. var cell = $(headerCells[i]);
  4979. var border = cell.outerWidth() - cell.width();
  4980. // Use getBounding... where possible (not IE8-) because it can give
  4981. // sub-pixel accuracy, which we then want to round up!
  4982. var bounding = browser.bBounding ?
  4983. Math.ceil( headerCells[i].getBoundingClientRect().width ) :
  4984. cell.outerWidth();
  4985. // Total is tracked to remove any sub-pixel errors as the outerWidth
  4986. // of the table might not equal the total given here (IE!).
  4987. total += bounding;
  4988. // Width for each column to use
  4989. columns[ visibleColumns[i] ].sWidth = _fnStringToCss( bounding - border );
  4990. }
  4991. table.style.width = _fnStringToCss( total );
  4992. // Finished with the table - ditch it
  4993. holder.remove();
  4994. }
  4995. // If there is a width attr, we want to attach an event listener which
  4996. // allows the table sizing to automatically adjust when the window is
  4997. // resized. Use the width attr rather than CSS, since we can't know if the
  4998. // CSS is a relative value or absolute - DOM read is always px.
  4999. if ( tableWidthAttr ) {
  5000. table.style.width = _fnStringToCss( tableWidthAttr );
  5001. }
  5002. if ( (tableWidthAttr || scrollX) && ! oSettings._reszEvt ) {
  5003. var bindResize = function () {
  5004. $(window).on('resize.DT-'+oSettings.sInstance, _fnThrottle( function () {
  5005. _fnAdjustColumnSizing( oSettings );
  5006. } ) );
  5007. };
  5008. // IE6/7 will crash if we bind a resize event handler on page load.
  5009. // To be removed in 1.11 which drops IE6/7 support
  5010. if ( ie67 ) {
  5011. setTimeout( bindResize, 1000 );
  5012. }
  5013. else {
  5014. bindResize();
  5015. }
  5016. oSettings._reszEvt = true;
  5017. }
  5018. }
  5019. /**
  5020. * Throttle the calls to a function. Arguments and context are maintained for
  5021. * the throttled function
  5022. * @param {function} fn Function to be called
  5023. * @param {int} [freq=200] call frequency in mS
  5024. * @returns {function} wrapped function
  5025. * @memberof DataTable#oApi
  5026. */
  5027. var _fnThrottle = DataTable.util.throttle;
  5028. /**
  5029. * Convert a CSS unit width to pixels (e.g. 2em)
  5030. * @param {string} width width to be converted
  5031. * @param {node} parent parent to get the with for (required for relative widths) - optional
  5032. * @returns {int} width in pixels
  5033. * @memberof DataTable#oApi
  5034. */
  5035. function _fnConvertToWidth ( width, parent )
  5036. {
  5037. if ( ! width ) {
  5038. return 0;
  5039. }
  5040. var n = $('<div/>')
  5041. .css( 'width', _fnStringToCss( width ) )
  5042. .appendTo( parent || document.body );
  5043. var val = n[0].offsetWidth;
  5044. n.remove();
  5045. return val;
  5046. }
  5047. /**
  5048. * Get the widest node
  5049. * @param {object} settings dataTables settings object
  5050. * @param {int} colIdx column of interest
  5051. * @returns {node} widest table node
  5052. * @memberof DataTable#oApi
  5053. */
  5054. function _fnGetWidestNode( settings, colIdx )
  5055. {
  5056. var idx = _fnGetMaxLenString( settings, colIdx );
  5057. if ( idx < 0 ) {
  5058. return null;
  5059. }
  5060. var data = settings.aoData[ idx ];
  5061. return ! data.nTr ? // Might not have been created when deferred rendering
  5062. $('<td/>').html( _fnGetCellData( settings, idx, colIdx, 'display' ) )[0] :
  5063. data.anCells[ colIdx ];
  5064. }
  5065. /**
  5066. * Get the maximum strlen for each data column
  5067. * @param {object} settings dataTables settings object
  5068. * @param {int} colIdx column of interest
  5069. * @returns {string} max string length for each column
  5070. * @memberof DataTable#oApi
  5071. */
  5072. function _fnGetMaxLenString( settings, colIdx )
  5073. {
  5074. var s, max=-1, maxIdx = -1;
  5075. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  5076. s = _fnGetCellData( settings, i, colIdx, 'display' )+'';
  5077. s = s.replace( __re_html_remove, '' );
  5078. s = s.replace( /&nbsp;/g, ' ' );
  5079. if ( s.length > max ) {
  5080. max = s.length;
  5081. maxIdx = i;
  5082. }
  5083. }
  5084. return maxIdx;
  5085. }
  5086. /**
  5087. * Append a CSS unit (only if required) to a string
  5088. * @param {string} value to css-ify
  5089. * @returns {string} value with css unit
  5090. * @memberof DataTable#oApi
  5091. */
  5092. function _fnStringToCss( s )
  5093. {
  5094. if ( s === null ) {
  5095. return '0px';
  5096. }
  5097. if ( typeof s == 'number' ) {
  5098. return s < 0 ?
  5099. '0px' :
  5100. s+'px';
  5101. }
  5102. // Check it has a unit character already
  5103. return s.match(/\d$/) ?
  5104. s+'px' :
  5105. s;
  5106. }
  5107. function _fnSortFlatten ( settings )
  5108. {
  5109. var
  5110. i, iLen, k, kLen,
  5111. aSort = [],
  5112. aiOrig = [],
  5113. aoColumns = settings.aoColumns,
  5114. aDataSort, iCol, sType, srcCol,
  5115. fixed = settings.aaSortingFixed,
  5116. fixedObj = $.isPlainObject( fixed ),
  5117. nestedSort = [],
  5118. add = function ( a ) {
  5119. if ( a.length && ! Array.isArray( a[0] ) ) {
  5120. // 1D array
  5121. nestedSort.push( a );
  5122. }
  5123. else {
  5124. // 2D array
  5125. $.merge( nestedSort, a );
  5126. }
  5127. };
  5128. // Build the sort array, with pre-fix and post-fix options if they have been
  5129. // specified
  5130. if ( Array.isArray( fixed ) ) {
  5131. add( fixed );
  5132. }
  5133. if ( fixedObj && fixed.pre ) {
  5134. add( fixed.pre );
  5135. }
  5136. add( settings.aaSorting );
  5137. if (fixedObj && fixed.post ) {
  5138. add( fixed.post );
  5139. }
  5140. for ( i=0 ; i<nestedSort.length ; i++ )
  5141. {
  5142. srcCol = nestedSort[i][0];
  5143. aDataSort = aoColumns[ srcCol ].aDataSort;
  5144. for ( k=0, kLen=aDataSort.length ; k<kLen ; k++ )
  5145. {
  5146. iCol = aDataSort[k];
  5147. sType = aoColumns[ iCol ].sType || 'string';
  5148. if ( nestedSort[i]._idx === undefined ) {
  5149. nestedSort[i]._idx = $.inArray( nestedSort[i][1], aoColumns[iCol].asSorting );
  5150. }
  5151. aSort.push( {
  5152. src: srcCol,
  5153. col: iCol,
  5154. dir: nestedSort[i][1],
  5155. index: nestedSort[i]._idx,
  5156. type: sType,
  5157. formatter: DataTable.ext.type.order[ sType+"-pre" ]
  5158. } );
  5159. }
  5160. }
  5161. return aSort;
  5162. }
  5163. /**
  5164. * Change the order of the table
  5165. * @param {object} oSettings dataTables settings object
  5166. * @memberof DataTable#oApi
  5167. * @todo This really needs split up!
  5168. */
  5169. function _fnSort ( oSettings )
  5170. {
  5171. var
  5172. i, ien, iLen, j, jLen, k, kLen,
  5173. sDataType, nTh,
  5174. aiOrig = [],
  5175. oExtSort = DataTable.ext.type.order,
  5176. aoData = oSettings.aoData,
  5177. aoColumns = oSettings.aoColumns,
  5178. aDataSort, data, iCol, sType, oSort,
  5179. formatters = 0,
  5180. sortCol,
  5181. displayMaster = oSettings.aiDisplayMaster,
  5182. aSort;
  5183. // Resolve any column types that are unknown due to addition or invalidation
  5184. // @todo Can this be moved into a 'data-ready' handler which is called when
  5185. // data is going to be used in the table?
  5186. _fnColumnTypes( oSettings );
  5187. aSort = _fnSortFlatten( oSettings );
  5188. for ( i=0, ien=aSort.length ; i<ien ; i++ ) {
  5189. sortCol = aSort[i];
  5190. // Track if we can use the fast sort algorithm
  5191. if ( sortCol.formatter ) {
  5192. formatters++;
  5193. }
  5194. // Load the data needed for the sort, for each cell
  5195. _fnSortData( oSettings, sortCol.col );
  5196. }
  5197. /* No sorting required if server-side or no sorting array */
  5198. if ( _fnDataSource( oSettings ) != 'ssp' && aSort.length !== 0 )
  5199. {
  5200. // Create a value - key array of the current row positions such that we can use their
  5201. // current position during the sort, if values match, in order to perform stable sorting
  5202. for ( i=0, iLen=displayMaster.length ; i<iLen ; i++ ) {
  5203. aiOrig[ displayMaster[i] ] = i;
  5204. }
  5205. /* Do the sort - here we want multi-column sorting based on a given data source (column)
  5206. * and sorting function (from oSort) in a certain direction. It's reasonably complex to
  5207. * follow on it's own, but this is what we want (example two column sorting):
  5208. * fnLocalSorting = function(a,b){
  5209. * var iTest;
  5210. * iTest = oSort['string-asc']('data11', 'data12');
  5211. * if (iTest !== 0)
  5212. * return iTest;
  5213. * iTest = oSort['numeric-desc']('data21', 'data22');
  5214. * if (iTest !== 0)
  5215. * return iTest;
  5216. * return oSort['numeric-asc']( aiOrig[a], aiOrig[b] );
  5217. * }
  5218. * Basically we have a test for each sorting column, if the data in that column is equal,
  5219. * test the next column. If all columns match, then we use a numeric sort on the row
  5220. * positions in the original data array to provide a stable sort.
  5221. *
  5222. * Note - I know it seems excessive to have two sorting methods, but the first is around
  5223. * 15% faster, so the second is only maintained for backwards compatibility with sorting
  5224. * methods which do not have a pre-sort formatting function.
  5225. */
  5226. if ( formatters === aSort.length ) {
  5227. // All sort types have formatting functions
  5228. displayMaster.sort( function ( a, b ) {
  5229. var
  5230. x, y, k, test, sort,
  5231. len=aSort.length,
  5232. dataA = aoData[a]._aSortData,
  5233. dataB = aoData[b]._aSortData;
  5234. for ( k=0 ; k<len ; k++ ) {
  5235. sort = aSort[k];
  5236. x = dataA[ sort.col ];
  5237. y = dataB[ sort.col ];
  5238. test = x<y ? -1 : x>y ? 1 : 0;
  5239. if ( test !== 0 ) {
  5240. return sort.dir === 'asc' ? test : -test;
  5241. }
  5242. }
  5243. x = aiOrig[a];
  5244. y = aiOrig[b];
  5245. return x<y ? -1 : x>y ? 1 : 0;
  5246. } );
  5247. }
  5248. else {
  5249. // Depreciated - remove in 1.11 (providing a plug-in option)
  5250. // Not all sort types have formatting methods, so we have to call their sorting
  5251. // methods.
  5252. displayMaster.sort( function ( a, b ) {
  5253. var
  5254. x, y, k, l, test, sort, fn,
  5255. len=aSort.length,
  5256. dataA = aoData[a]._aSortData,
  5257. dataB = aoData[b]._aSortData;
  5258. for ( k=0 ; k<len ; k++ ) {
  5259. sort = aSort[k];
  5260. x = dataA[ sort.col ];
  5261. y = dataB[ sort.col ];
  5262. fn = oExtSort[ sort.type+"-"+sort.dir ] || oExtSort[ "string-"+sort.dir ];
  5263. test = fn( x, y );
  5264. if ( test !== 0 ) {
  5265. return test;
  5266. }
  5267. }
  5268. x = aiOrig[a];
  5269. y = aiOrig[b];
  5270. return x<y ? -1 : x>y ? 1 : 0;
  5271. } );
  5272. }
  5273. }
  5274. /* Tell the draw function that we have sorted the data */
  5275. oSettings.bSorted = true;
  5276. }
  5277. function _fnSortAria ( settings )
  5278. {
  5279. var label;
  5280. var nextSort;
  5281. var columns = settings.aoColumns;
  5282. var aSort = _fnSortFlatten( settings );
  5283. var oAria = settings.oLanguage.oAria;
  5284. // ARIA attributes - need to loop all columns, to update all (removing old
  5285. // attributes as needed)
  5286. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  5287. {
  5288. var col = columns[i];
  5289. var asSorting = col.asSorting;
  5290. var sTitle = col.ariaTitle || col.sTitle.replace( /<.*?>/g, "" );
  5291. var th = col.nTh;
  5292. // IE7 is throwing an error when setting these properties with jQuery's
  5293. // attr() and removeAttr() methods...
  5294. th.removeAttribute('aria-sort');
  5295. /* In ARIA only the first sorting column can be marked as sorting - no multi-sort option */
  5296. if ( col.bSortable ) {
  5297. if ( aSort.length > 0 && aSort[0].col == i ) {
  5298. th.setAttribute('aria-sort', aSort[0].dir=="asc" ? "ascending" : "descending" );
  5299. nextSort = asSorting[ aSort[0].index+1 ] || asSorting[0];
  5300. }
  5301. else {
  5302. nextSort = asSorting[0];
  5303. }
  5304. label = sTitle + ( nextSort === "asc" ?
  5305. oAria.sSortAscending :
  5306. oAria.sSortDescending
  5307. );
  5308. }
  5309. else {
  5310. label = sTitle;
  5311. }
  5312. th.setAttribute('aria-label', label);
  5313. }
  5314. }
  5315. /**
  5316. * Function to run on user sort request
  5317. * @param {object} settings dataTables settings object
  5318. * @param {node} attachTo node to attach the handler to
  5319. * @param {int} colIdx column sorting index
  5320. * @param {boolean} [append=false] Append the requested sort to the existing
  5321. * sort if true (i.e. multi-column sort)
  5322. * @param {function} [callback] callback function
  5323. * @memberof DataTable#oApi
  5324. */
  5325. function _fnSortListener ( settings, colIdx, append, callback )
  5326. {
  5327. var col = settings.aoColumns[ colIdx ];
  5328. var sorting = settings.aaSorting;
  5329. var asSorting = col.asSorting;
  5330. var nextSortIdx;
  5331. var next = function ( a, overflow ) {
  5332. var idx = a._idx;
  5333. if ( idx === undefined ) {
  5334. idx = $.inArray( a[1], asSorting );
  5335. }
  5336. return idx+1 < asSorting.length ?
  5337. idx+1 :
  5338. overflow ?
  5339. null :
  5340. 0;
  5341. };
  5342. // Convert to 2D array if needed
  5343. if ( typeof sorting[0] === 'number' ) {
  5344. sorting = settings.aaSorting = [ sorting ];
  5345. }
  5346. // If appending the sort then we are multi-column sorting
  5347. if ( append && settings.oFeatures.bSortMulti ) {
  5348. // Are we already doing some kind of sort on this column?
  5349. var sortIdx = $.inArray( colIdx, _pluck(sorting, '0') );
  5350. if ( sortIdx !== -1 ) {
  5351. // Yes, modify the sort
  5352. nextSortIdx = next( sorting[sortIdx], true );
  5353. if ( nextSortIdx === null && sorting.length === 1 ) {
  5354. nextSortIdx = 0; // can't remove sorting completely
  5355. }
  5356. if ( nextSortIdx === null ) {
  5357. sorting.splice( sortIdx, 1 );
  5358. }
  5359. else {
  5360. sorting[sortIdx][1] = asSorting[ nextSortIdx ];
  5361. sorting[sortIdx]._idx = nextSortIdx;
  5362. }
  5363. }
  5364. else {
  5365. // No sort on this column yet
  5366. sorting.push( [ colIdx, asSorting[0], 0 ] );
  5367. sorting[sorting.length-1]._idx = 0;
  5368. }
  5369. }
  5370. else if ( sorting.length && sorting[0][0] == colIdx ) {
  5371. // Single column - already sorting on this column, modify the sort
  5372. nextSortIdx = next( sorting[0] );
  5373. sorting.length = 1;
  5374. sorting[0][1] = asSorting[ nextSortIdx ];
  5375. sorting[0]._idx = nextSortIdx;
  5376. }
  5377. else {
  5378. // Single column - sort only on this column
  5379. sorting.length = 0;
  5380. sorting.push( [ colIdx, asSorting[0] ] );
  5381. sorting[0]._idx = 0;
  5382. }
  5383. // Run the sort by calling a full redraw
  5384. _fnReDraw( settings );
  5385. // callback used for async user interaction
  5386. if ( typeof callback == 'function' ) {
  5387. callback( settings );
  5388. }
  5389. }
  5390. /**
  5391. * Attach a sort handler (click) to a node
  5392. * @param {object} settings dataTables settings object
  5393. * @param {node} attachTo node to attach the handler to
  5394. * @param {int} colIdx column sorting index
  5395. * @param {function} [callback] callback function
  5396. * @memberof DataTable#oApi
  5397. */
  5398. function _fnSortAttachListener ( settings, attachTo, colIdx, callback )
  5399. {
  5400. var col = settings.aoColumns[ colIdx ];
  5401. _fnBindAction( attachTo, {}, function (e) {
  5402. /* If the column is not sortable - don't to anything */
  5403. if ( col.bSortable === false ) {
  5404. return;
  5405. }
  5406. // If processing is enabled use a timeout to allow the processing
  5407. // display to be shown - otherwise to it synchronously
  5408. if ( settings.oFeatures.bProcessing ) {
  5409. _fnProcessingDisplay( settings, true );
  5410. setTimeout( function() {
  5411. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  5412. // In server-side processing, the draw callback will remove the
  5413. // processing display
  5414. if ( _fnDataSource( settings ) !== 'ssp' ) {
  5415. _fnProcessingDisplay( settings, false );
  5416. }
  5417. }, 0 );
  5418. }
  5419. else {
  5420. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  5421. }
  5422. } );
  5423. }
  5424. /**
  5425. * Set the sorting classes on table's body, Note: it is safe to call this function
  5426. * when bSort and bSortClasses are false
  5427. * @param {object} oSettings dataTables settings object
  5428. * @memberof DataTable#oApi
  5429. */
  5430. function _fnSortingClasses( settings )
  5431. {
  5432. var oldSort = settings.aLastSort;
  5433. var sortClass = settings.oClasses.sSortColumn;
  5434. var sort = _fnSortFlatten( settings );
  5435. var features = settings.oFeatures;
  5436. var i, ien, colIdx;
  5437. if ( features.bSort && features.bSortClasses ) {
  5438. // Remove old sorting classes
  5439. for ( i=0, ien=oldSort.length ; i<ien ; i++ ) {
  5440. colIdx = oldSort[i].src;
  5441. // Remove column sorting
  5442. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  5443. .removeClass( sortClass + (i<2 ? i+1 : 3) );
  5444. }
  5445. // Add new column sorting
  5446. for ( i=0, ien=sort.length ; i<ien ; i++ ) {
  5447. colIdx = sort[i].src;
  5448. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  5449. .addClass( sortClass + (i<2 ? i+1 : 3) );
  5450. }
  5451. }
  5452. settings.aLastSort = sort;
  5453. }
  5454. // Get the data to sort a column, be it from cache, fresh (populating the
  5455. // cache), or from a sort formatter
  5456. function _fnSortData( settings, idx )
  5457. {
  5458. // Custom sorting function - provided by the sort data type
  5459. var column = settings.aoColumns[ idx ];
  5460. var customSort = DataTable.ext.order[ column.sSortDataType ];
  5461. var customData;
  5462. if ( customSort ) {
  5463. customData = customSort.call( settings.oInstance, settings, idx,
  5464. _fnColumnIndexToVisible( settings, idx )
  5465. );
  5466. }
  5467. // Use / populate cache
  5468. var row, cellData;
  5469. var formatter = DataTable.ext.type.order[ column.sType+"-pre" ];
  5470. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  5471. row = settings.aoData[i];
  5472. if ( ! row._aSortData ) {
  5473. row._aSortData = [];
  5474. }
  5475. if ( ! row._aSortData[idx] || customSort ) {
  5476. cellData = customSort ?
  5477. customData[i] : // If there was a custom sort function, use data from there
  5478. _fnGetCellData( settings, i, idx, 'sort' );
  5479. row._aSortData[ idx ] = formatter ?
  5480. formatter( cellData ) :
  5481. cellData;
  5482. }
  5483. }
  5484. }
  5485. /**
  5486. * Save the state of a table
  5487. * @param {object} oSettings dataTables settings object
  5488. * @memberof DataTable#oApi
  5489. */
  5490. function _fnSaveState ( settings )
  5491. {
  5492. if (settings._bLoadingState) {
  5493. return;
  5494. }
  5495. /* Store the interesting variables */
  5496. var state = {
  5497. time: +new Date(),
  5498. start: settings._iDisplayStart,
  5499. length: settings._iDisplayLength,
  5500. order: $.extend( true, [], settings.aaSorting ),
  5501. search: _fnSearchToCamel( settings.oPreviousSearch ),
  5502. columns: $.map( settings.aoColumns, function ( col, i ) {
  5503. return {
  5504. visible: col.bVisible,
  5505. search: _fnSearchToCamel( settings.aoPreSearchCols[i] )
  5506. };
  5507. } )
  5508. };
  5509. settings.oSavedState = state;
  5510. _fnCallbackFire( settings, "aoStateSaveParams", 'stateSaveParams', [settings, state] );
  5511. if ( settings.oFeatures.bStateSave && !settings.bDestroying )
  5512. {
  5513. settings.fnStateSaveCallback.call( settings.oInstance, settings, state );
  5514. }
  5515. }
  5516. /**
  5517. * Attempt to load a saved table state
  5518. * @param {object} oSettings dataTables settings object
  5519. * @param {object} oInit DataTables init object so we can override settings
  5520. * @param {function} callback Callback to execute when the state has been loaded
  5521. * @memberof DataTable#oApi
  5522. */
  5523. function _fnLoadState ( settings, oInit, callback )
  5524. {
  5525. if ( ! settings.oFeatures.bStateSave ) {
  5526. callback();
  5527. return;
  5528. }
  5529. var loaded = function(state) {
  5530. _fnImplementState(settings, state, callback);
  5531. }
  5532. var state = settings.fnStateLoadCallback.call( settings.oInstance, settings, loaded );
  5533. if ( state !== undefined ) {
  5534. _fnImplementState( settings, state, callback );
  5535. }
  5536. // otherwise, wait for the loaded callback to be executed
  5537. return true;
  5538. }
  5539. function _fnImplementState ( settings, s, callback) {
  5540. var i, ien;
  5541. var columns = settings.aoColumns;
  5542. settings._bLoadingState = true;
  5543. // When StateRestore was introduced the state could now be implemented at any time
  5544. // Not just initialisation. To do this an api instance is required in some places
  5545. var api = settings._bInitComplete ? new DataTable.Api(settings) : null;
  5546. if ( ! s || ! s.time ) {
  5547. settings._bLoadingState = false;
  5548. callback();
  5549. return;
  5550. }
  5551. // Allow custom and plug-in manipulation functions to alter the saved data set and
  5552. // cancelling of loading by returning false
  5553. var abStateLoad = _fnCallbackFire( settings, 'aoStateLoadParams', 'stateLoadParams', [settings, s] );
  5554. if ( $.inArray( false, abStateLoad ) !== -1 ) {
  5555. settings._bLoadingState = false;
  5556. callback();
  5557. return;
  5558. }
  5559. // Reject old data
  5560. var duration = settings.iStateDuration;
  5561. if ( duration > 0 && s.time < +new Date() - (duration*1000) ) {
  5562. settings._bLoadingState = false;
  5563. callback();
  5564. return;
  5565. }
  5566. // Number of columns have changed - all bets are off, no restore of settings
  5567. if ( s.columns && columns.length !== s.columns.length ) {
  5568. settings._bLoadingState = false;
  5569. callback();
  5570. return;
  5571. }
  5572. // Store the saved state so it might be accessed at any time
  5573. settings.oLoadedState = $.extend( true, {}, s );
  5574. // Restore key features - todo - for 1.11 this needs to be done by
  5575. // subscribed events
  5576. if ( s.start !== undefined ) {
  5577. if(api === null) {
  5578. settings._iDisplayStart = s.start;
  5579. settings.iInitDisplayStart = s.start;
  5580. }
  5581. else {
  5582. _fnPageChange(settings, s.start/s.length);
  5583. }
  5584. }
  5585. if ( s.length !== undefined ) {
  5586. settings._iDisplayLength = s.length;
  5587. }
  5588. // Order
  5589. if ( s.order !== undefined ) {
  5590. settings.aaSorting = [];
  5591. $.each( s.order, function ( i, col ) {
  5592. settings.aaSorting.push( col[0] >= columns.length ?
  5593. [ 0, col[1] ] :
  5594. col
  5595. );
  5596. } );
  5597. }
  5598. // Search
  5599. if ( s.search !== undefined ) {
  5600. $.extend( settings.oPreviousSearch, _fnSearchToHung( s.search ) );
  5601. }
  5602. // Columns
  5603. if ( s.columns ) {
  5604. for ( i=0, ien=s.columns.length ; i<ien ; i++ ) {
  5605. var col = s.columns[i];
  5606. // Visibility
  5607. if ( col.visible !== undefined ) {
  5608. // If the api is defined, the table has been initialised so we need to use it rather than internal settings
  5609. if (api) {
  5610. // Don't redraw the columns on every iteration of this loop, we will do this at the end instead
  5611. api.column(i).visible(col.visible, false);
  5612. }
  5613. else {
  5614. columns[i].bVisible = col.visible;
  5615. }
  5616. }
  5617. // Search
  5618. if ( col.search !== undefined ) {
  5619. $.extend( settings.aoPreSearchCols[i], _fnSearchToHung( col.search ) );
  5620. }
  5621. }
  5622. // If the api is defined then we need to adjust the columns once the visibility has been changed
  5623. if (api) {
  5624. api.columns.adjust();
  5625. }
  5626. }
  5627. settings._bLoadingState = false;
  5628. _fnCallbackFire( settings, 'aoStateLoaded', 'stateLoaded', [settings, s] );
  5629. callback();
  5630. };
  5631. /**
  5632. * Return the settings object for a particular table
  5633. * @param {node} table table we are using as a dataTable
  5634. * @returns {object} Settings object - or null if not found
  5635. * @memberof DataTable#oApi
  5636. */
  5637. function _fnSettingsFromNode ( table )
  5638. {
  5639. var settings = DataTable.settings;
  5640. var idx = $.inArray( table, _pluck( settings, 'nTable' ) );
  5641. return idx !== -1 ?
  5642. settings[ idx ] :
  5643. null;
  5644. }
  5645. /**
  5646. * Log an error message
  5647. * @param {object} settings dataTables settings object
  5648. * @param {int} level log error messages, or display them to the user
  5649. * @param {string} msg error message
  5650. * @param {int} tn Technical note id to get more information about the error.
  5651. * @memberof DataTable#oApi
  5652. */
  5653. function _fnLog( settings, level, msg, tn )
  5654. {
  5655. msg = 'DataTables warning: '+
  5656. (settings ? 'table id='+settings.sTableId+' - ' : '')+msg;
  5657. if ( tn ) {
  5658. msg += '. For more information about this error, please see '+
  5659. 'http://datatables.net/tn/'+tn;
  5660. }
  5661. if ( ! level ) {
  5662. // Backwards compatibility pre 1.10
  5663. var ext = DataTable.ext;
  5664. var type = ext.sErrMode || ext.errMode;
  5665. if ( settings ) {
  5666. _fnCallbackFire( settings, null, 'error', [ settings, tn, msg ] );
  5667. }
  5668. if ( type == 'alert' ) {
  5669. alert( msg );
  5670. }
  5671. else if ( type == 'throw' ) {
  5672. throw new Error(msg);
  5673. }
  5674. else if ( typeof type == 'function' ) {
  5675. type( settings, tn, msg );
  5676. }
  5677. }
  5678. else if ( window.console && console.log ) {
  5679. console.log( msg );
  5680. }
  5681. }
  5682. /**
  5683. * See if a property is defined on one object, if so assign it to the other object
  5684. * @param {object} ret target object
  5685. * @param {object} src source object
  5686. * @param {string} name property
  5687. * @param {string} [mappedName] name to map too - optional, name used if not given
  5688. * @memberof DataTable#oApi
  5689. */
  5690. function _fnMap( ret, src, name, mappedName )
  5691. {
  5692. if ( Array.isArray( name ) ) {
  5693. $.each( name, function (i, val) {
  5694. if ( Array.isArray( val ) ) {
  5695. _fnMap( ret, src, val[0], val[1] );
  5696. }
  5697. else {
  5698. _fnMap( ret, src, val );
  5699. }
  5700. } );
  5701. return;
  5702. }
  5703. if ( mappedName === undefined ) {
  5704. mappedName = name;
  5705. }
  5706. if ( src[name] !== undefined ) {
  5707. ret[mappedName] = src[name];
  5708. }
  5709. }
  5710. /**
  5711. * Extend objects - very similar to jQuery.extend, but deep copy objects, and
  5712. * shallow copy arrays. The reason we need to do this, is that we don't want to
  5713. * deep copy array init values (such as aaSorting) since the dev wouldn't be
  5714. * able to override them, but we do want to deep copy arrays.
  5715. * @param {object} out Object to extend
  5716. * @param {object} extender Object from which the properties will be applied to
  5717. * out
  5718. * @param {boolean} breakRefs If true, then arrays will be sliced to take an
  5719. * independent copy with the exception of the `data` or `aaData` parameters
  5720. * if they are present. This is so you can pass in a collection to
  5721. * DataTables and have that used as your data source without breaking the
  5722. * references
  5723. * @returns {object} out Reference, just for convenience - out === the return.
  5724. * @memberof DataTable#oApi
  5725. * @todo This doesn't take account of arrays inside the deep copied objects.
  5726. */
  5727. function _fnExtend( out, extender, breakRefs )
  5728. {
  5729. var val;
  5730. for ( var prop in extender ) {
  5731. if ( extender.hasOwnProperty(prop) ) {
  5732. val = extender[prop];
  5733. if ( $.isPlainObject( val ) ) {
  5734. if ( ! $.isPlainObject( out[prop] ) ) {
  5735. out[prop] = {};
  5736. }
  5737. $.extend( true, out[prop], val );
  5738. }
  5739. else if ( breakRefs && prop !== 'data' && prop !== 'aaData' && Array.isArray(val) ) {
  5740. out[prop] = val.slice();
  5741. }
  5742. else {
  5743. out[prop] = val;
  5744. }
  5745. }
  5746. }
  5747. return out;
  5748. }
  5749. /**
  5750. * Bind an event handers to allow a click or return key to activate the callback.
  5751. * This is good for accessibility since a return on the keyboard will have the
  5752. * same effect as a click, if the element has focus.
  5753. * @param {element} n Element to bind the action to
  5754. * @param {object} oData Data object to pass to the triggered function
  5755. * @param {function} fn Callback function for when the event is triggered
  5756. * @memberof DataTable#oApi
  5757. */
  5758. function _fnBindAction( n, oData, fn )
  5759. {
  5760. $(n)
  5761. .on( 'click.DT', oData, function (e) {
  5762. $(n).trigger('blur'); // Remove focus outline for mouse users
  5763. fn(e);
  5764. } )
  5765. .on( 'keypress.DT', oData, function (e){
  5766. if ( e.which === 13 ) {
  5767. e.preventDefault();
  5768. fn(e);
  5769. }
  5770. } )
  5771. .on( 'selectstart.DT', function () {
  5772. /* Take the brutal approach to cancelling text selection */
  5773. return false;
  5774. } );
  5775. }
  5776. /**
  5777. * Register a callback function. Easily allows a callback function to be added to
  5778. * an array store of callback functions that can then all be called together.
  5779. * @param {object} oSettings dataTables settings object
  5780. * @param {string} sStore Name of the array storage for the callbacks in oSettings
  5781. * @param {function} fn Function to be called back
  5782. * @param {string} sName Identifying name for the callback (i.e. a label)
  5783. * @memberof DataTable#oApi
  5784. */
  5785. function _fnCallbackReg( oSettings, sStore, fn, sName )
  5786. {
  5787. if ( fn )
  5788. {
  5789. oSettings[sStore].push( {
  5790. "fn": fn,
  5791. "sName": sName
  5792. } );
  5793. }
  5794. }
  5795. /**
  5796. * Fire callback functions and trigger events. Note that the loop over the
  5797. * callback array store is done backwards! Further note that you do not want to
  5798. * fire off triggers in time sensitive applications (for example cell creation)
  5799. * as its slow.
  5800. * @param {object} settings dataTables settings object
  5801. * @param {string} callbackArr Name of the array storage for the callbacks in
  5802. * oSettings
  5803. * @param {string} eventName Name of the jQuery custom event to trigger. If
  5804. * null no trigger is fired
  5805. * @param {array} args Array of arguments to pass to the callback function /
  5806. * trigger
  5807. * @memberof DataTable#oApi
  5808. */
  5809. function _fnCallbackFire( settings, callbackArr, eventName, args )
  5810. {
  5811. var ret = [];
  5812. if ( callbackArr ) {
  5813. ret = $.map( settings[callbackArr].slice().reverse(), function (val, i) {
  5814. return val.fn.apply( settings.oInstance, args );
  5815. } );
  5816. }
  5817. if ( eventName !== null ) {
  5818. var e = $.Event( eventName+'.dt' );
  5819. $(settings.nTable).trigger( e, args );
  5820. ret.push( e.result );
  5821. }
  5822. return ret;
  5823. }
  5824. function _fnLengthOverflow ( settings )
  5825. {
  5826. var
  5827. start = settings._iDisplayStart,
  5828. end = settings.fnDisplayEnd(),
  5829. len = settings._iDisplayLength;
  5830. /* If we have space to show extra rows (backing up from the end point - then do so */
  5831. if ( start >= end )
  5832. {
  5833. start = end - len;
  5834. }
  5835. // Keep the start record on the current page
  5836. start -= (start % len);
  5837. if ( len === -1 || start < 0 )
  5838. {
  5839. start = 0;
  5840. }
  5841. settings._iDisplayStart = start;
  5842. }
  5843. function _fnRenderer( settings, type )
  5844. {
  5845. var renderer = settings.renderer;
  5846. var host = DataTable.ext.renderer[type];
  5847. if ( $.isPlainObject( renderer ) && renderer[type] ) {
  5848. // Specific renderer for this type. If available use it, otherwise use
  5849. // the default.
  5850. return host[renderer[type]] || host._;
  5851. }
  5852. else if ( typeof renderer === 'string' ) {
  5853. // Common renderer - if there is one available for this type use it,
  5854. // otherwise use the default
  5855. return host[renderer] || host._;
  5856. }
  5857. // Use the default
  5858. return host._;
  5859. }
  5860. /**
  5861. * Detect the data source being used for the table. Used to simplify the code
  5862. * a little (ajax) and to make it compress a little smaller.
  5863. *
  5864. * @param {object} settings dataTables settings object
  5865. * @returns {string} Data source
  5866. * @memberof DataTable#oApi
  5867. */
  5868. function _fnDataSource ( settings )
  5869. {
  5870. if ( settings.oFeatures.bServerSide ) {
  5871. return 'ssp';
  5872. }
  5873. else if ( settings.ajax || settings.sAjaxSource ) {
  5874. return 'ajax';
  5875. }
  5876. return 'dom';
  5877. }
  5878. /**
  5879. * Computed structure of the DataTables API, defined by the options passed to
  5880. * `DataTable.Api.register()` when building the API.
  5881. *
  5882. * The structure is built in order to speed creation and extension of the Api
  5883. * objects since the extensions are effectively pre-parsed.
  5884. *
  5885. * The array is an array of objects with the following structure, where this
  5886. * base array represents the Api prototype base:
  5887. *
  5888. * [
  5889. * {
  5890. * name: 'data' -- string - Property name
  5891. * val: function () {}, -- function - Api method (or undefined if just an object
  5892. * methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  5893. * propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  5894. * },
  5895. * {
  5896. * name: 'row'
  5897. * val: {},
  5898. * methodExt: [ ... ],
  5899. * propExt: [
  5900. * {
  5901. * name: 'data'
  5902. * val: function () {},
  5903. * methodExt: [ ... ],
  5904. * propExt: [ ... ]
  5905. * },
  5906. * ...
  5907. * ]
  5908. * }
  5909. * ]
  5910. *
  5911. * @type {Array}
  5912. * @ignore
  5913. */
  5914. var __apiStruct = [];
  5915. /**
  5916. * `Array.prototype` reference.
  5917. *
  5918. * @type object
  5919. * @ignore
  5920. */
  5921. var __arrayProto = Array.prototype;
  5922. /**
  5923. * Abstraction for `context` parameter of the `Api` constructor to allow it to
  5924. * take several different forms for ease of use.
  5925. *
  5926. * Each of the input parameter types will be converted to a DataTables settings
  5927. * object where possible.
  5928. *
  5929. * @param {string|node|jQuery|object} mixed DataTable identifier. Can be one
  5930. * of:
  5931. *
  5932. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5933. * with be found and used.
  5934. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5935. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5936. * * `object` - DataTables settings object
  5937. * * `DataTables.Api` - API instance
  5938. * @return {array|null} Matching DataTables settings objects. `null` or
  5939. * `undefined` is returned if no matching DataTable is found.
  5940. * @ignore
  5941. */
  5942. var _toSettings = function ( mixed )
  5943. {
  5944. var idx, jq;
  5945. var settings = DataTable.settings;
  5946. var tables = $.map( settings, function (el, i) {
  5947. return el.nTable;
  5948. } );
  5949. if ( ! mixed ) {
  5950. return [];
  5951. }
  5952. else if ( mixed.nTable && mixed.oApi ) {
  5953. // DataTables settings object
  5954. return [ mixed ];
  5955. }
  5956. else if ( mixed.nodeName && mixed.nodeName.toLowerCase() === 'table' ) {
  5957. // Table node
  5958. idx = $.inArray( mixed, tables );
  5959. return idx !== -1 ? [ settings[idx] ] : null;
  5960. }
  5961. else if ( mixed && typeof mixed.settings === 'function' ) {
  5962. return mixed.settings().toArray();
  5963. }
  5964. else if ( typeof mixed === 'string' ) {
  5965. // jQuery selector
  5966. jq = $(mixed);
  5967. }
  5968. else if ( mixed instanceof $ ) {
  5969. // jQuery object (also DataTables instance)
  5970. jq = mixed;
  5971. }
  5972. if ( jq ) {
  5973. return jq.map( function(i) {
  5974. idx = $.inArray( this, tables );
  5975. return idx !== -1 ? settings[idx] : null;
  5976. } ).toArray();
  5977. }
  5978. };
  5979. /**
  5980. * DataTables API class - used to control and interface with one or more
  5981. * DataTables enhanced tables.
  5982. *
  5983. * The API class is heavily based on jQuery, presenting a chainable interface
  5984. * that you can use to interact with tables. Each instance of the API class has
  5985. * a "context" - i.e. the tables that it will operate on. This could be a single
  5986. * table, all tables on a page or a sub-set thereof.
  5987. *
  5988. * Additionally the API is designed to allow you to easily work with the data in
  5989. * the tables, retrieving and manipulating it as required. This is done by
  5990. * presenting the API class as an array like interface. The contents of the
  5991. * array depend upon the actions requested by each method (for example
  5992. * `rows().nodes()` will return an array of nodes, while `rows().data()` will
  5993. * return an array of objects or arrays depending upon your table's
  5994. * configuration). The API object has a number of array like methods (`push`,
  5995. * `pop`, `reverse` etc) as well as additional helper methods (`each`, `pluck`,
  5996. * `unique` etc) to assist your working with the data held in a table.
  5997. *
  5998. * Most methods (those which return an Api instance) are chainable, which means
  5999. * the return from a method call also has all of the methods available that the
  6000. * top level object had. For example, these two calls are equivalent:
  6001. *
  6002. * // Not chained
  6003. * api.row.add( {...} );
  6004. * api.draw();
  6005. *
  6006. * // Chained
  6007. * api.row.add( {...} ).draw();
  6008. *
  6009. * @class DataTable.Api
  6010. * @param {array|object|string|jQuery} context DataTable identifier. This is
  6011. * used to define which DataTables enhanced tables this API will operate on.
  6012. * Can be one of:
  6013. *
  6014. * * `string` - jQuery selector. Any DataTables' matching the given selector
  6015. * with be found and used.
  6016. * * `node` - `TABLE` node which has already been formed into a DataTable.
  6017. * * `jQuery` - A jQuery object of `TABLE` nodes.
  6018. * * `object` - DataTables settings object
  6019. * @param {array} [data] Data to initialise the Api instance with.
  6020. *
  6021. * @example
  6022. * // Direct initialisation during DataTables construction
  6023. * var api = $('#example').DataTable();
  6024. *
  6025. * @example
  6026. * // Initialisation using a DataTables jQuery object
  6027. * var api = $('#example').dataTable().api();
  6028. *
  6029. * @example
  6030. * // Initialisation as a constructor
  6031. * var api = new $.fn.DataTable.Api( 'table.dataTable' );
  6032. */
  6033. _Api = function ( context, data )
  6034. {
  6035. if ( ! (this instanceof _Api) ) {
  6036. return new _Api( context, data );
  6037. }
  6038. var settings = [];
  6039. var ctxSettings = function ( o ) {
  6040. var a = _toSettings( o );
  6041. if ( a ) {
  6042. settings.push.apply( settings, a );
  6043. }
  6044. };
  6045. if ( Array.isArray( context ) ) {
  6046. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  6047. ctxSettings( context[i] );
  6048. }
  6049. }
  6050. else {
  6051. ctxSettings( context );
  6052. }
  6053. // Remove duplicates
  6054. this.context = _unique( settings );
  6055. // Initial data
  6056. if ( data ) {
  6057. $.merge( this, data );
  6058. }
  6059. // selector
  6060. this.selector = {
  6061. rows: null,
  6062. cols: null,
  6063. opts: null
  6064. };
  6065. _Api.extend( this, this, __apiStruct );
  6066. };
  6067. DataTable.Api = _Api;
  6068. // Don't destroy the existing prototype, just extend it. Required for jQuery 2's
  6069. // isPlainObject.
  6070. $.extend( _Api.prototype, {
  6071. any: function ()
  6072. {
  6073. return this.count() !== 0;
  6074. },
  6075. concat: __arrayProto.concat,
  6076. context: [], // array of table settings objects
  6077. count: function ()
  6078. {
  6079. return this.flatten().length;
  6080. },
  6081. each: function ( fn )
  6082. {
  6083. for ( var i=0, ien=this.length ; i<ien; i++ ) {
  6084. fn.call( this, this[i], i, this );
  6085. }
  6086. return this;
  6087. },
  6088. eq: function ( idx )
  6089. {
  6090. var ctx = this.context;
  6091. return ctx.length > idx ?
  6092. new _Api( ctx[idx], this[idx] ) :
  6093. null;
  6094. },
  6095. filter: function ( fn )
  6096. {
  6097. var a = [];
  6098. if ( __arrayProto.filter ) {
  6099. a = __arrayProto.filter.call( this, fn, this );
  6100. }
  6101. else {
  6102. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  6103. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  6104. if ( fn.call( this, this[i], i, this ) ) {
  6105. a.push( this[i] );
  6106. }
  6107. }
  6108. }
  6109. return new _Api( this.context, a );
  6110. },
  6111. flatten: function ()
  6112. {
  6113. var a = [];
  6114. return new _Api( this.context, a.concat.apply( a, this.toArray() ) );
  6115. },
  6116. join: __arrayProto.join,
  6117. indexOf: __arrayProto.indexOf || function (obj, start)
  6118. {
  6119. for ( var i=(start || 0), ien=this.length ; i<ien ; i++ ) {
  6120. if ( this[i] === obj ) {
  6121. return i;
  6122. }
  6123. }
  6124. return -1;
  6125. },
  6126. iterator: function ( flatten, type, fn, alwaysNew ) {
  6127. var
  6128. a = [], ret,
  6129. i, ien, j, jen,
  6130. context = this.context,
  6131. rows, items, item,
  6132. selector = this.selector;
  6133. // Argument shifting
  6134. if ( typeof flatten === 'string' ) {
  6135. alwaysNew = fn;
  6136. fn = type;
  6137. type = flatten;
  6138. flatten = false;
  6139. }
  6140. for ( i=0, ien=context.length ; i<ien ; i++ ) {
  6141. var apiInst = new _Api( context[i] );
  6142. if ( type === 'table' ) {
  6143. ret = fn.call( apiInst, context[i], i );
  6144. if ( ret !== undefined ) {
  6145. a.push( ret );
  6146. }
  6147. }
  6148. else if ( type === 'columns' || type === 'rows' ) {
  6149. // this has same length as context - one entry for each table
  6150. ret = fn.call( apiInst, context[i], this[i], i );
  6151. if ( ret !== undefined ) {
  6152. a.push( ret );
  6153. }
  6154. }
  6155. else if ( type === 'column' || type === 'column-rows' || type === 'row' || type === 'cell' ) {
  6156. // columns and rows share the same structure.
  6157. // 'this' is an array of column indexes for each context
  6158. items = this[i];
  6159. if ( type === 'column-rows' ) {
  6160. rows = _selector_row_indexes( context[i], selector.opts );
  6161. }
  6162. for ( j=0, jen=items.length ; j<jen ; j++ ) {
  6163. item = items[j];
  6164. if ( type === 'cell' ) {
  6165. ret = fn.call( apiInst, context[i], item.row, item.column, i, j );
  6166. }
  6167. else {
  6168. ret = fn.call( apiInst, context[i], item, i, j, rows );
  6169. }
  6170. if ( ret !== undefined ) {
  6171. a.push( ret );
  6172. }
  6173. }
  6174. }
  6175. }
  6176. if ( a.length || alwaysNew ) {
  6177. var api = new _Api( context, flatten ? a.concat.apply( [], a ) : a );
  6178. var apiSelector = api.selector;
  6179. apiSelector.rows = selector.rows;
  6180. apiSelector.cols = selector.cols;
  6181. apiSelector.opts = selector.opts;
  6182. return api;
  6183. }
  6184. return this;
  6185. },
  6186. lastIndexOf: __arrayProto.lastIndexOf || function (obj, start)
  6187. {
  6188. // Bit cheeky...
  6189. return this.indexOf.apply( this.toArray.reverse(), arguments );
  6190. },
  6191. length: 0,
  6192. map: function ( fn )
  6193. {
  6194. var a = [];
  6195. if ( __arrayProto.map ) {
  6196. a = __arrayProto.map.call( this, fn, this );
  6197. }
  6198. else {
  6199. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  6200. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  6201. a.push( fn.call( this, this[i], i ) );
  6202. }
  6203. }
  6204. return new _Api( this.context, a );
  6205. },
  6206. pluck: function ( prop )
  6207. {
  6208. return this.map( function ( el ) {
  6209. return el[ prop ];
  6210. } );
  6211. },
  6212. pop: __arrayProto.pop,
  6213. push: __arrayProto.push,
  6214. // Does not return an API instance
  6215. reduce: __arrayProto.reduce || function ( fn, init )
  6216. {
  6217. return _fnReduce( this, fn, init, 0, this.length, 1 );
  6218. },
  6219. reduceRight: __arrayProto.reduceRight || function ( fn, init )
  6220. {
  6221. return _fnReduce( this, fn, init, this.length-1, -1, -1 );
  6222. },
  6223. reverse: __arrayProto.reverse,
  6224. // Object with rows, columns and opts
  6225. selector: null,
  6226. shift: __arrayProto.shift,
  6227. slice: function () {
  6228. return new _Api( this.context, this );
  6229. },
  6230. sort: __arrayProto.sort, // ? name - order?
  6231. splice: __arrayProto.splice,
  6232. toArray: function ()
  6233. {
  6234. return __arrayProto.slice.call( this );
  6235. },
  6236. to$: function ()
  6237. {
  6238. return $( this );
  6239. },
  6240. toJQuery: function ()
  6241. {
  6242. return $( this );
  6243. },
  6244. unique: function ()
  6245. {
  6246. return new _Api( this.context, _unique(this) );
  6247. },
  6248. unshift: __arrayProto.unshift
  6249. } );
  6250. _Api.extend = function ( scope, obj, ext )
  6251. {
  6252. // Only extend API instances and static properties of the API
  6253. if ( ! ext.length || ! obj || ( ! (obj instanceof _Api) && ! obj.__dt_wrapper ) ) {
  6254. return;
  6255. }
  6256. var
  6257. i, ien,
  6258. struct,
  6259. methodScoping = function ( scope, fn, struc ) {
  6260. return function () {
  6261. var ret = fn.apply( scope, arguments );
  6262. // Method extension
  6263. _Api.extend( ret, ret, struc.methodExt );
  6264. return ret;
  6265. };
  6266. };
  6267. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  6268. struct = ext[i];
  6269. // Value
  6270. obj[ struct.name ] = struct.type === 'function' ?
  6271. methodScoping( scope, struct.val, struct ) :
  6272. struct.type === 'object' ?
  6273. {} :
  6274. struct.val;
  6275. obj[ struct.name ].__dt_wrapper = true;
  6276. // Property extension
  6277. _Api.extend( scope, obj[ struct.name ], struct.propExt );
  6278. }
  6279. };
  6280. // @todo - Is there need for an augment function?
  6281. // _Api.augment = function ( inst, name )
  6282. // {
  6283. // // Find src object in the structure from the name
  6284. // var parts = name.split('.');
  6285. // _Api.extend( inst, obj );
  6286. // };
  6287. // [
  6288. // {
  6289. // name: 'data' -- string - Property name
  6290. // val: function () {}, -- function - Api method (or undefined if just an object
  6291. // methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  6292. // propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  6293. // },
  6294. // {
  6295. // name: 'row'
  6296. // val: {},
  6297. // methodExt: [ ... ],
  6298. // propExt: [
  6299. // {
  6300. // name: 'data'
  6301. // val: function () {},
  6302. // methodExt: [ ... ],
  6303. // propExt: [ ... ]
  6304. // },
  6305. // ...
  6306. // ]
  6307. // }
  6308. // ]
  6309. _Api.register = _api_register = function ( name, val )
  6310. {
  6311. if ( Array.isArray( name ) ) {
  6312. for ( var j=0, jen=name.length ; j<jen ; j++ ) {
  6313. _Api.register( name[j], val );
  6314. }
  6315. return;
  6316. }
  6317. var
  6318. i, ien,
  6319. heir = name.split('.'),
  6320. struct = __apiStruct,
  6321. key, method;
  6322. var find = function ( src, name ) {
  6323. for ( var i=0, ien=src.length ; i<ien ; i++ ) {
  6324. if ( src[i].name === name ) {
  6325. return src[i];
  6326. }
  6327. }
  6328. return null;
  6329. };
  6330. for ( i=0, ien=heir.length ; i<ien ; i++ ) {
  6331. method = heir[i].indexOf('()') !== -1;
  6332. key = method ?
  6333. heir[i].replace('()', '') :
  6334. heir[i];
  6335. var src = find( struct, key );
  6336. if ( ! src ) {
  6337. src = {
  6338. name: key,
  6339. val: {},
  6340. methodExt: [],
  6341. propExt: [],
  6342. type: 'object'
  6343. };
  6344. struct.push( src );
  6345. }
  6346. if ( i === ien-1 ) {
  6347. src.val = val;
  6348. src.type = typeof val === 'function' ?
  6349. 'function' :
  6350. $.isPlainObject( val ) ?
  6351. 'object' :
  6352. 'other';
  6353. }
  6354. else {
  6355. struct = method ?
  6356. src.methodExt :
  6357. src.propExt;
  6358. }
  6359. }
  6360. };
  6361. _Api.registerPlural = _api_registerPlural = function ( pluralName, singularName, val ) {
  6362. _Api.register( pluralName, val );
  6363. _Api.register( singularName, function () {
  6364. var ret = val.apply( this, arguments );
  6365. if ( ret === this ) {
  6366. // Returned item is the API instance that was passed in, return it
  6367. return this;
  6368. }
  6369. else if ( ret instanceof _Api ) {
  6370. // New API instance returned, want the value from the first item
  6371. // in the returned array for the singular result.
  6372. return ret.length ?
  6373. Array.isArray( ret[0] ) ?
  6374. new _Api( ret.context, ret[0] ) : // Array results are 'enhanced'
  6375. ret[0] :
  6376. undefined;
  6377. }
  6378. // Non-API return - just fire it back
  6379. return ret;
  6380. } );
  6381. };
  6382. /**
  6383. * Selector for HTML tables. Apply the given selector to the give array of
  6384. * DataTables settings objects.
  6385. *
  6386. * @param {string|integer} [selector] jQuery selector string or integer
  6387. * @param {array} Array of DataTables settings objects to be filtered
  6388. * @return {array}
  6389. * @ignore
  6390. */
  6391. var __table_selector = function ( selector, a )
  6392. {
  6393. if ( Array.isArray(selector) ) {
  6394. return $.map( selector, function (item) {
  6395. return __table_selector(item, a);
  6396. } );
  6397. }
  6398. // Integer is used to pick out a table by index
  6399. if ( typeof selector === 'number' ) {
  6400. return [ a[ selector ] ];
  6401. }
  6402. // Perform a jQuery selector on the table nodes
  6403. var nodes = $.map( a, function (el, i) {
  6404. return el.nTable;
  6405. } );
  6406. return $(nodes)
  6407. .filter( selector )
  6408. .map( function (i) {
  6409. // Need to translate back from the table node to the settings
  6410. var idx = $.inArray( this, nodes );
  6411. return a[ idx ];
  6412. } )
  6413. .toArray();
  6414. };
  6415. /**
  6416. * Context selector for the API's context (i.e. the tables the API instance
  6417. * refers to.
  6418. *
  6419. * @name DataTable.Api#tables
  6420. * @param {string|integer} [selector] Selector to pick which tables the iterator
  6421. * should operate on. If not given, all tables in the current context are
  6422. * used. This can be given as a jQuery selector (for example `':gt(0)'`) to
  6423. * select multiple tables or as an integer to select a single table.
  6424. * @returns {DataTable.Api} Returns a new API instance if a selector is given.
  6425. */
  6426. _api_register( 'tables()', function ( selector ) {
  6427. // A new instance is created if there was a selector specified
  6428. return selector !== undefined && selector !== null ?
  6429. new _Api( __table_selector( selector, this.context ) ) :
  6430. this;
  6431. } );
  6432. _api_register( 'table()', function ( selector ) {
  6433. var tables = this.tables( selector );
  6434. var ctx = tables.context;
  6435. // Truncate to the first matched table
  6436. return ctx.length ?
  6437. new _Api( ctx[0] ) :
  6438. tables;
  6439. } );
  6440. _api_registerPlural( 'tables().nodes()', 'table().node()' , function () {
  6441. return this.iterator( 'table', function ( ctx ) {
  6442. return ctx.nTable;
  6443. }, 1 );
  6444. } );
  6445. _api_registerPlural( 'tables().body()', 'table().body()' , function () {
  6446. return this.iterator( 'table', function ( ctx ) {
  6447. return ctx.nTBody;
  6448. }, 1 );
  6449. } );
  6450. _api_registerPlural( 'tables().header()', 'table().header()' , function () {
  6451. return this.iterator( 'table', function ( ctx ) {
  6452. return ctx.nTHead;
  6453. }, 1 );
  6454. } );
  6455. _api_registerPlural( 'tables().footer()', 'table().footer()' , function () {
  6456. return this.iterator( 'table', function ( ctx ) {
  6457. return ctx.nTFoot;
  6458. }, 1 );
  6459. } );
  6460. _api_registerPlural( 'tables().containers()', 'table().container()' , function () {
  6461. return this.iterator( 'table', function ( ctx ) {
  6462. return ctx.nTableWrapper;
  6463. }, 1 );
  6464. } );
  6465. /**
  6466. * Redraw the tables in the current context.
  6467. */
  6468. _api_register( 'draw()', function ( paging ) {
  6469. return this.iterator( 'table', function ( settings ) {
  6470. if ( paging === 'page' ) {
  6471. _fnDraw( settings );
  6472. }
  6473. else {
  6474. if ( typeof paging === 'string' ) {
  6475. paging = paging === 'full-hold' ?
  6476. false :
  6477. true;
  6478. }
  6479. _fnReDraw( settings, paging===false );
  6480. }
  6481. } );
  6482. } );
  6483. /**
  6484. * Get the current page index.
  6485. *
  6486. * @return {integer} Current page index (zero based)
  6487. *//**
  6488. * Set the current page.
  6489. *
  6490. * Note that if you attempt to show a page which does not exist, DataTables will
  6491. * not throw an error, but rather reset the paging.
  6492. *
  6493. * @param {integer|string} action The paging action to take. This can be one of:
  6494. * * `integer` - The page index to jump to
  6495. * * `string` - An action to take:
  6496. * * `first` - Jump to first page.
  6497. * * `next` - Jump to the next page
  6498. * * `previous` - Jump to previous page
  6499. * * `last` - Jump to the last page.
  6500. * @returns {DataTables.Api} this
  6501. */
  6502. _api_register( 'page()', function ( action ) {
  6503. if ( action === undefined ) {
  6504. return this.page.info().page; // not an expensive call
  6505. }
  6506. // else, have an action to take on all tables
  6507. return this.iterator( 'table', function ( settings ) {
  6508. _fnPageChange( settings, action );
  6509. } );
  6510. } );
  6511. /**
  6512. * Paging information for the first table in the current context.
  6513. *
  6514. * If you require paging information for another table, use the `table()` method
  6515. * with a suitable selector.
  6516. *
  6517. * @return {object} Object with the following properties set:
  6518. * * `page` - Current page index (zero based - i.e. the first page is `0`)
  6519. * * `pages` - Total number of pages
  6520. * * `start` - Display index for the first record shown on the current page
  6521. * * `end` - Display index for the last record shown on the current page
  6522. * * `length` - Display length (number of records). Note that generally `start
  6523. * + length = end`, but this is not always true, for example if there are
  6524. * only 2 records to show on the final page, with a length of 10.
  6525. * * `recordsTotal` - Full data set length
  6526. * * `recordsDisplay` - Data set length once the current filtering criterion
  6527. * are applied.
  6528. */
  6529. _api_register( 'page.info()', function ( action ) {
  6530. if ( this.context.length === 0 ) {
  6531. return undefined;
  6532. }
  6533. var
  6534. settings = this.context[0],
  6535. start = settings._iDisplayStart,
  6536. len = settings.oFeatures.bPaginate ? settings._iDisplayLength : -1,
  6537. visRecords = settings.fnRecordsDisplay(),
  6538. all = len === -1;
  6539. return {
  6540. "page": all ? 0 : Math.floor( start / len ),
  6541. "pages": all ? 1 : Math.ceil( visRecords / len ),
  6542. "start": start,
  6543. "end": settings.fnDisplayEnd(),
  6544. "length": len,
  6545. "recordsTotal": settings.fnRecordsTotal(),
  6546. "recordsDisplay": visRecords,
  6547. "serverSide": _fnDataSource( settings ) === 'ssp'
  6548. };
  6549. } );
  6550. /**
  6551. * Get the current page length.
  6552. *
  6553. * @return {integer} Current page length. Note `-1` indicates that all records
  6554. * are to be shown.
  6555. *//**
  6556. * Set the current page length.
  6557. *
  6558. * @param {integer} Page length to set. Use `-1` to show all records.
  6559. * @returns {DataTables.Api} this
  6560. */
  6561. _api_register( 'page.len()', function ( len ) {
  6562. // Note that we can't call this function 'length()' because `length`
  6563. // is a Javascript property of functions which defines how many arguments
  6564. // the function expects.
  6565. if ( len === undefined ) {
  6566. return this.context.length !== 0 ?
  6567. this.context[0]._iDisplayLength :
  6568. undefined;
  6569. }
  6570. // else, set the page length
  6571. return this.iterator( 'table', function ( settings ) {
  6572. _fnLengthChange( settings, len );
  6573. } );
  6574. } );
  6575. var __reload = function ( settings, holdPosition, callback ) {
  6576. // Use the draw event to trigger a callback
  6577. if ( callback ) {
  6578. var api = new _Api( settings );
  6579. api.one( 'draw', function () {
  6580. callback( api.ajax.json() );
  6581. } );
  6582. }
  6583. if ( _fnDataSource( settings ) == 'ssp' ) {
  6584. _fnReDraw( settings, holdPosition );
  6585. }
  6586. else {
  6587. _fnProcessingDisplay( settings, true );
  6588. // Cancel an existing request
  6589. var xhr = settings.jqXHR;
  6590. if ( xhr && xhr.readyState !== 4 ) {
  6591. xhr.abort();
  6592. }
  6593. // Trigger xhr
  6594. _fnBuildAjax( settings, [], function( json ) {
  6595. _fnClearTable( settings );
  6596. var data = _fnAjaxDataSrc( settings, json );
  6597. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6598. _fnAddData( settings, data[i] );
  6599. }
  6600. _fnReDraw( settings, holdPosition );
  6601. _fnProcessingDisplay( settings, false );
  6602. } );
  6603. }
  6604. };
  6605. /**
  6606. * Get the JSON response from the last Ajax request that DataTables made to the
  6607. * server. Note that this returns the JSON from the first table in the current
  6608. * context.
  6609. *
  6610. * @return {object} JSON received from the server.
  6611. */
  6612. _api_register( 'ajax.json()', function () {
  6613. var ctx = this.context;
  6614. if ( ctx.length > 0 ) {
  6615. return ctx[0].json;
  6616. }
  6617. // else return undefined;
  6618. } );
  6619. /**
  6620. * Get the data submitted in the last Ajax request
  6621. */
  6622. _api_register( 'ajax.params()', function () {
  6623. var ctx = this.context;
  6624. if ( ctx.length > 0 ) {
  6625. return ctx[0].oAjaxData;
  6626. }
  6627. // else return undefined;
  6628. } );
  6629. /**
  6630. * Reload tables from the Ajax data source. Note that this function will
  6631. * automatically re-draw the table when the remote data has been loaded.
  6632. *
  6633. * @param {boolean} [reset=true] Reset (default) or hold the current paging
  6634. * position. A full re-sort and re-filter is performed when this method is
  6635. * called, which is why the pagination reset is the default action.
  6636. * @returns {DataTables.Api} this
  6637. */
  6638. _api_register( 'ajax.reload()', function ( callback, resetPaging ) {
  6639. return this.iterator( 'table', function (settings) {
  6640. __reload( settings, resetPaging===false, callback );
  6641. } );
  6642. } );
  6643. /**
  6644. * Get the current Ajax URL. Note that this returns the URL from the first
  6645. * table in the current context.
  6646. *
  6647. * @return {string} Current Ajax source URL
  6648. *//**
  6649. * Set the Ajax URL. Note that this will set the URL for all tables in the
  6650. * current context.
  6651. *
  6652. * @param {string} url URL to set.
  6653. * @returns {DataTables.Api} this
  6654. */
  6655. _api_register( 'ajax.url()', function ( url ) {
  6656. var ctx = this.context;
  6657. if ( url === undefined ) {
  6658. // get
  6659. if ( ctx.length === 0 ) {
  6660. return undefined;
  6661. }
  6662. ctx = ctx[0];
  6663. return ctx.ajax ?
  6664. $.isPlainObject( ctx.ajax ) ?
  6665. ctx.ajax.url :
  6666. ctx.ajax :
  6667. ctx.sAjaxSource;
  6668. }
  6669. // set
  6670. return this.iterator( 'table', function ( settings ) {
  6671. if ( $.isPlainObject( settings.ajax ) ) {
  6672. settings.ajax.url = url;
  6673. }
  6674. else {
  6675. settings.ajax = url;
  6676. }
  6677. // No need to consider sAjaxSource here since DataTables gives priority
  6678. // to `ajax` over `sAjaxSource`. So setting `ajax` here, renders any
  6679. // value of `sAjaxSource` redundant.
  6680. } );
  6681. } );
  6682. /**
  6683. * Load data from the newly set Ajax URL. Note that this method is only
  6684. * available when `ajax.url()` is used to set a URL. Additionally, this method
  6685. * has the same effect as calling `ajax.reload()` but is provided for
  6686. * convenience when setting a new URL. Like `ajax.reload()` it will
  6687. * automatically redraw the table once the remote data has been loaded.
  6688. *
  6689. * @returns {DataTables.Api} this
  6690. */
  6691. _api_register( 'ajax.url().load()', function ( callback, resetPaging ) {
  6692. // Same as a reload, but makes sense to present it for easy access after a
  6693. // url change
  6694. return this.iterator( 'table', function ( ctx ) {
  6695. __reload( ctx, resetPaging===false, callback );
  6696. } );
  6697. } );
  6698. var _selector_run = function ( type, selector, selectFn, settings, opts )
  6699. {
  6700. var
  6701. out = [], res,
  6702. a, i, ien, j, jen,
  6703. selectorType = typeof selector;
  6704. // Can't just check for isArray here, as an API or jQuery instance might be
  6705. // given with their array like look
  6706. if ( ! selector || selectorType === 'string' || selectorType === 'function' || selector.length === undefined ) {
  6707. selector = [ selector ];
  6708. }
  6709. for ( i=0, ien=selector.length ; i<ien ; i++ ) {
  6710. // Only split on simple strings - complex expressions will be jQuery selectors
  6711. a = selector[i] && selector[i].split && ! selector[i].match(/[\[\(:]/) ?
  6712. selector[i].split(',') :
  6713. [ selector[i] ];
  6714. for ( j=0, jen=a.length ; j<jen ; j++ ) {
  6715. res = selectFn( typeof a[j] === 'string' ? (a[j]).trim() : a[j] );
  6716. if ( res && res.length ) {
  6717. out = out.concat( res );
  6718. }
  6719. }
  6720. }
  6721. // selector extensions
  6722. var ext = _ext.selector[ type ];
  6723. if ( ext.length ) {
  6724. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  6725. out = ext[i]( settings, opts, out );
  6726. }
  6727. }
  6728. return _unique( out );
  6729. };
  6730. var _selector_opts = function ( opts )
  6731. {
  6732. if ( ! opts ) {
  6733. opts = {};
  6734. }
  6735. // Backwards compatibility for 1.9- which used the terminology filter rather
  6736. // than search
  6737. if ( opts.filter && opts.search === undefined ) {
  6738. opts.search = opts.filter;
  6739. }
  6740. return $.extend( {
  6741. search: 'none',
  6742. order: 'current',
  6743. page: 'all'
  6744. }, opts );
  6745. };
  6746. var _selector_first = function ( inst )
  6747. {
  6748. // Reduce the API instance to the first item found
  6749. for ( var i=0, ien=inst.length ; i<ien ; i++ ) {
  6750. if ( inst[i].length > 0 ) {
  6751. // Assign the first element to the first item in the instance
  6752. // and truncate the instance and context
  6753. inst[0] = inst[i];
  6754. inst[0].length = 1;
  6755. inst.length = 1;
  6756. inst.context = [ inst.context[i] ];
  6757. return inst;
  6758. }
  6759. }
  6760. // Not found - return an empty instance
  6761. inst.length = 0;
  6762. return inst;
  6763. };
  6764. var _selector_row_indexes = function ( settings, opts )
  6765. {
  6766. var
  6767. i, ien, tmp, a=[],
  6768. displayFiltered = settings.aiDisplay,
  6769. displayMaster = settings.aiDisplayMaster;
  6770. var
  6771. search = opts.search, // none, applied, removed
  6772. order = opts.order, // applied, current, index (original - compatibility with 1.9)
  6773. page = opts.page; // all, current
  6774. if ( _fnDataSource( settings ) == 'ssp' ) {
  6775. // In server-side processing mode, most options are irrelevant since
  6776. // rows not shown don't exist and the index order is the applied order
  6777. // Removed is a special case - for consistency just return an empty
  6778. // array
  6779. return search === 'removed' ?
  6780. [] :
  6781. _range( 0, displayMaster.length );
  6782. }
  6783. else if ( page == 'current' ) {
  6784. // Current page implies that order=current and filter=applied, since it is
  6785. // fairly senseless otherwise, regardless of what order and search actually
  6786. // are
  6787. for ( i=settings._iDisplayStart, ien=settings.fnDisplayEnd() ; i<ien ; i++ ) {
  6788. a.push( displayFiltered[i] );
  6789. }
  6790. }
  6791. else if ( order == 'current' || order == 'applied' ) {
  6792. if ( search == 'none') {
  6793. a = displayMaster.slice();
  6794. }
  6795. else if ( search == 'applied' ) {
  6796. a = displayFiltered.slice();
  6797. }
  6798. else if ( search == 'removed' ) {
  6799. // O(n+m) solution by creating a hash map
  6800. var displayFilteredMap = {};
  6801. for ( var i=0, ien=displayFiltered.length ; i<ien ; i++ ) {
  6802. displayFilteredMap[displayFiltered[i]] = null;
  6803. }
  6804. a = $.map( displayMaster, function (el) {
  6805. return ! displayFilteredMap.hasOwnProperty(el) ?
  6806. el :
  6807. null;
  6808. } );
  6809. }
  6810. }
  6811. else if ( order == 'index' || order == 'original' ) {
  6812. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  6813. if ( search == 'none' ) {
  6814. a.push( i );
  6815. }
  6816. else { // applied | removed
  6817. tmp = $.inArray( i, displayFiltered );
  6818. if ((tmp === -1 && search == 'removed') ||
  6819. (tmp >= 0 && search == 'applied') )
  6820. {
  6821. a.push( i );
  6822. }
  6823. }
  6824. }
  6825. }
  6826. return a;
  6827. };
  6828. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6829. * Rows
  6830. *
  6831. * {} - no selector - use all available rows
  6832. * {integer} - row aoData index
  6833. * {node} - TR node
  6834. * {string} - jQuery selector to apply to the TR elements
  6835. * {array} - jQuery array of nodes, or simply an array of TR nodes
  6836. *
  6837. */
  6838. var __row_selector = function ( settings, selector, opts )
  6839. {
  6840. var rows;
  6841. var run = function ( sel ) {
  6842. var selInt = _intVal( sel );
  6843. var i, ien;
  6844. var aoData = settings.aoData;
  6845. // Short cut - selector is a number and no options provided (default is
  6846. // all records, so no need to check if the index is in there, since it
  6847. // must be - dev error if the index doesn't exist).
  6848. if ( selInt !== null && ! opts ) {
  6849. return [ selInt ];
  6850. }
  6851. if ( ! rows ) {
  6852. rows = _selector_row_indexes( settings, opts );
  6853. }
  6854. if ( selInt !== null && $.inArray( selInt, rows ) !== -1 ) {
  6855. // Selector - integer
  6856. return [ selInt ];
  6857. }
  6858. else if ( sel === null || sel === undefined || sel === '' ) {
  6859. // Selector - none
  6860. return rows;
  6861. }
  6862. // Selector - function
  6863. if ( typeof sel === 'function' ) {
  6864. return $.map( rows, function (idx) {
  6865. var row = aoData[ idx ];
  6866. return sel( idx, row._aData, row.nTr ) ? idx : null;
  6867. } );
  6868. }
  6869. // Selector - node
  6870. if ( sel.nodeName ) {
  6871. var rowIdx = sel._DT_RowIndex; // Property added by DT for fast lookup
  6872. var cellIdx = sel._DT_CellIndex;
  6873. if ( rowIdx !== undefined ) {
  6874. // Make sure that the row is actually still present in the table
  6875. return aoData[ rowIdx ] && aoData[ rowIdx ].nTr === sel ?
  6876. [ rowIdx ] :
  6877. [];
  6878. }
  6879. else if ( cellIdx ) {
  6880. return aoData[ cellIdx.row ] && aoData[ cellIdx.row ].nTr === sel.parentNode ?
  6881. [ cellIdx.row ] :
  6882. [];
  6883. }
  6884. else {
  6885. var host = $(sel).closest('*[data-dt-row]');
  6886. return host.length ?
  6887. [ host.data('dt-row') ] :
  6888. [];
  6889. }
  6890. }
  6891. // ID selector. Want to always be able to select rows by id, regardless
  6892. // of if the tr element has been created or not, so can't rely upon
  6893. // jQuery here - hence a custom implementation. This does not match
  6894. // Sizzle's fast selector or HTML4 - in HTML5 the ID can be anything,
  6895. // but to select it using a CSS selector engine (like Sizzle or
  6896. // querySelect) it would need to need to be escaped for some characters.
  6897. // DataTables simplifies this for row selectors since you can select
  6898. // only a row. A # indicates an id any anything that follows is the id -
  6899. // unescaped.
  6900. if ( typeof sel === 'string' && sel.charAt(0) === '#' ) {
  6901. // get row index from id
  6902. var rowObj = settings.aIds[ sel.replace( /^#/, '' ) ];
  6903. if ( rowObj !== undefined ) {
  6904. return [ rowObj.idx ];
  6905. }
  6906. // need to fall through to jQuery in case there is DOM id that
  6907. // matches
  6908. }
  6909. // Get nodes in the order from the `rows` array with null values removed
  6910. var nodes = _removeEmpty(
  6911. _pluck_order( settings.aoData, rows, 'nTr' )
  6912. );
  6913. // Selector - jQuery selector string, array of nodes or jQuery object/
  6914. // As jQuery's .filter() allows jQuery objects to be passed in filter,
  6915. // it also allows arrays, so this will cope with all three options
  6916. return $(nodes)
  6917. .filter( sel )
  6918. .map( function () {
  6919. return this._DT_RowIndex;
  6920. } )
  6921. .toArray();
  6922. };
  6923. return _selector_run( 'row', selector, run, settings, opts );
  6924. };
  6925. _api_register( 'rows()', function ( selector, opts ) {
  6926. // argument shifting
  6927. if ( selector === undefined ) {
  6928. selector = '';
  6929. }
  6930. else if ( $.isPlainObject( selector ) ) {
  6931. opts = selector;
  6932. selector = '';
  6933. }
  6934. opts = _selector_opts( opts );
  6935. var inst = this.iterator( 'table', function ( settings ) {
  6936. return __row_selector( settings, selector, opts );
  6937. }, 1 );
  6938. // Want argument shifting here and in __row_selector?
  6939. inst.selector.rows = selector;
  6940. inst.selector.opts = opts;
  6941. return inst;
  6942. } );
  6943. _api_register( 'rows().nodes()', function () {
  6944. return this.iterator( 'row', function ( settings, row ) {
  6945. return settings.aoData[ row ].nTr || undefined;
  6946. }, 1 );
  6947. } );
  6948. _api_register( 'rows().data()', function () {
  6949. return this.iterator( true, 'rows', function ( settings, rows ) {
  6950. return _pluck_order( settings.aoData, rows, '_aData' );
  6951. }, 1 );
  6952. } );
  6953. _api_registerPlural( 'rows().cache()', 'row().cache()', function ( type ) {
  6954. return this.iterator( 'row', function ( settings, row ) {
  6955. var r = settings.aoData[ row ];
  6956. return type === 'search' ? r._aFilterData : r._aSortData;
  6957. }, 1 );
  6958. } );
  6959. _api_registerPlural( 'rows().invalidate()', 'row().invalidate()', function ( src ) {
  6960. return this.iterator( 'row', function ( settings, row ) {
  6961. _fnInvalidate( settings, row, src );
  6962. } );
  6963. } );
  6964. _api_registerPlural( 'rows().indexes()', 'row().index()', function () {
  6965. return this.iterator( 'row', function ( settings, row ) {
  6966. return row;
  6967. }, 1 );
  6968. } );
  6969. _api_registerPlural( 'rows().ids()', 'row().id()', function ( hash ) {
  6970. var a = [];
  6971. var context = this.context;
  6972. // `iterator` will drop undefined values, but in this case we want them
  6973. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  6974. for ( var j=0, jen=this[i].length ; j<jen ; j++ ) {
  6975. var id = context[i].rowIdFn( context[i].aoData[ this[i][j] ]._aData );
  6976. a.push( (hash === true ? '#' : '' )+ id );
  6977. }
  6978. }
  6979. return new _Api( context, a );
  6980. } );
  6981. _api_registerPlural( 'rows().remove()', 'row().remove()', function () {
  6982. var that = this;
  6983. this.iterator( 'row', function ( settings, row, thatIdx ) {
  6984. var data = settings.aoData;
  6985. var rowData = data[ row ];
  6986. var i, ien, j, jen;
  6987. var loopRow, loopCells;
  6988. data.splice( row, 1 );
  6989. // Update the cached indexes
  6990. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  6991. loopRow = data[i];
  6992. loopCells = loopRow.anCells;
  6993. // Rows
  6994. if ( loopRow.nTr !== null ) {
  6995. loopRow.nTr._DT_RowIndex = i;
  6996. }
  6997. // Cells
  6998. if ( loopCells !== null ) {
  6999. for ( j=0, jen=loopCells.length ; j<jen ; j++ ) {
  7000. loopCells[j]._DT_CellIndex.row = i;
  7001. }
  7002. }
  7003. }
  7004. // Delete from the display arrays
  7005. _fnDeleteIndex( settings.aiDisplayMaster, row );
  7006. _fnDeleteIndex( settings.aiDisplay, row );
  7007. _fnDeleteIndex( that[ thatIdx ], row, false ); // maintain local indexes
  7008. // For server-side processing tables - subtract the deleted row from the count
  7009. if ( settings._iRecordsDisplay > 0 ) {
  7010. settings._iRecordsDisplay--;
  7011. }
  7012. // Check for an 'overflow' they case for displaying the table
  7013. _fnLengthOverflow( settings );
  7014. // Remove the row's ID reference if there is one
  7015. var id = settings.rowIdFn( rowData._aData );
  7016. if ( id !== undefined ) {
  7017. delete settings.aIds[ id ];
  7018. }
  7019. } );
  7020. this.iterator( 'table', function ( settings ) {
  7021. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  7022. settings.aoData[i].idx = i;
  7023. }
  7024. } );
  7025. return this;
  7026. } );
  7027. _api_register( 'rows.add()', function ( rows ) {
  7028. var newRows = this.iterator( 'table', function ( settings ) {
  7029. var row, i, ien;
  7030. var out = [];
  7031. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  7032. row = rows[i];
  7033. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  7034. out.push( _fnAddTr( settings, row )[0] );
  7035. }
  7036. else {
  7037. out.push( _fnAddData( settings, row ) );
  7038. }
  7039. }
  7040. return out;
  7041. }, 1 );
  7042. // Return an Api.rows() extended instance, so rows().nodes() etc can be used
  7043. var modRows = this.rows( -1 );
  7044. modRows.pop();
  7045. $.merge( modRows, newRows );
  7046. return modRows;
  7047. } );
  7048. /**
  7049. *
  7050. */
  7051. _api_register( 'row()', function ( selector, opts ) {
  7052. return _selector_first( this.rows( selector, opts ) );
  7053. } );
  7054. _api_register( 'row().data()', function ( data ) {
  7055. var ctx = this.context;
  7056. if ( data === undefined ) {
  7057. // Get
  7058. return ctx.length && this.length ?
  7059. ctx[0].aoData[ this[0] ]._aData :
  7060. undefined;
  7061. }
  7062. // Set
  7063. var row = ctx[0].aoData[ this[0] ];
  7064. row._aData = data;
  7065. // If the DOM has an id, and the data source is an array
  7066. if ( Array.isArray( data ) && row.nTr && row.nTr.id ) {
  7067. _fnSetObjectDataFn( ctx[0].rowId )( data, row.nTr.id );
  7068. }
  7069. // Automatically invalidate
  7070. _fnInvalidate( ctx[0], this[0], 'data' );
  7071. return this;
  7072. } );
  7073. _api_register( 'row().node()', function () {
  7074. var ctx = this.context;
  7075. return ctx.length && this.length ?
  7076. ctx[0].aoData[ this[0] ].nTr || null :
  7077. null;
  7078. } );
  7079. _api_register( 'row.add()', function ( row ) {
  7080. // Allow a jQuery object to be passed in - only a single row is added from
  7081. // it though - the first element in the set
  7082. if ( row instanceof $ && row.length ) {
  7083. row = row[0];
  7084. }
  7085. var rows = this.iterator( 'table', function ( settings ) {
  7086. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  7087. return _fnAddTr( settings, row )[0];
  7088. }
  7089. return _fnAddData( settings, row );
  7090. } );
  7091. // Return an Api.rows() extended instance, with the newly added row selected
  7092. return this.row( rows[0] );
  7093. } );
  7094. $(document).on('plugin-init.dt', function (e, context) {
  7095. var api = new _Api( context );
  7096. api.on( 'stateSaveParams', function ( e, settings, data ) {
  7097. var indexes = api.rows().iterator( 'row', function ( settings, idx ) {
  7098. return settings.aoData[idx]._detailsShow ? idx : undefined;
  7099. });
  7100. data.childRows = api.rows( indexes ).ids( true ).toArray();
  7101. })
  7102. var loaded = api.state.loaded();
  7103. if ( loaded && loaded.childRows ) {
  7104. api.rows( loaded.childRows ).every( function () {
  7105. _fnCallbackFire( context, null, 'requestChild', [ this ] )
  7106. })
  7107. }
  7108. })
  7109. var __details_add = function ( ctx, row, data, klass )
  7110. {
  7111. // Convert to array of TR elements
  7112. var rows = [];
  7113. var addRow = function ( r, k ) {
  7114. // Recursion to allow for arrays of jQuery objects
  7115. if ( Array.isArray( r ) || r instanceof $ ) {
  7116. for ( var i=0, ien=r.length ; i<ien ; i++ ) {
  7117. addRow( r[i], k );
  7118. }
  7119. return;
  7120. }
  7121. // If we get a TR element, then just add it directly - up to the dev
  7122. // to add the correct number of columns etc
  7123. if ( r.nodeName && r.nodeName.toLowerCase() === 'tr' ) {
  7124. rows.push( r );
  7125. }
  7126. else {
  7127. // Otherwise create a row with a wrapper
  7128. var created = $('<tr><td></td></tr>').addClass( k );
  7129. $('td', created)
  7130. .addClass( k )
  7131. .html( r )
  7132. [0].colSpan = _fnVisbleColumns( ctx );
  7133. rows.push( created[0] );
  7134. }
  7135. };
  7136. addRow( data, klass );
  7137. if ( row._details ) {
  7138. row._details.detach();
  7139. }
  7140. row._details = $(rows);
  7141. // If the children were already shown, that state should be retained
  7142. if ( row._detailsShow ) {
  7143. row._details.insertAfter( row.nTr );
  7144. }
  7145. };
  7146. var __details_remove = function ( api, idx )
  7147. {
  7148. var ctx = api.context;
  7149. if ( ctx.length ) {
  7150. var row = ctx[0].aoData[ idx !== undefined ? idx : api[0] ];
  7151. if ( row && row._details ) {
  7152. row._details.remove();
  7153. row._detailsShow = undefined;
  7154. row._details = undefined;
  7155. $( row.nTr ).removeClass( 'dt-hasChild' );
  7156. _fnSaveState( ctx[0] );
  7157. }
  7158. }
  7159. };
  7160. var __details_display = function ( api, show ) {
  7161. var ctx = api.context;
  7162. if ( ctx.length && api.length ) {
  7163. var row = ctx[0].aoData[ api[0] ];
  7164. if ( row._details ) {
  7165. row._detailsShow = show;
  7166. if ( show ) {
  7167. row._details.insertAfter( row.nTr );
  7168. $( row.nTr ).addClass( 'dt-hasChild' );
  7169. }
  7170. else {
  7171. row._details.detach();
  7172. $( row.nTr ).removeClass( 'dt-hasChild' );
  7173. }
  7174. _fnCallbackFire( ctx[0], null, 'childRow', [ show, api.row( api[0] ) ] )
  7175. __details_events( ctx[0] );
  7176. _fnSaveState( ctx[0] );
  7177. }
  7178. }
  7179. };
  7180. var __details_events = function ( settings )
  7181. {
  7182. var api = new _Api( settings );
  7183. var namespace = '.dt.DT_details';
  7184. var drawEvent = 'draw'+namespace;
  7185. var colvisEvent = 'column-visibility'+namespace;
  7186. var destroyEvent = 'destroy'+namespace;
  7187. var data = settings.aoData;
  7188. api.off( drawEvent +' '+ colvisEvent +' '+ destroyEvent );
  7189. if ( _pluck( data, '_details' ).length > 0 ) {
  7190. // On each draw, insert the required elements into the document
  7191. api.on( drawEvent, function ( e, ctx ) {
  7192. if ( settings !== ctx ) {
  7193. return;
  7194. }
  7195. api.rows( {page:'current'} ).eq(0).each( function (idx) {
  7196. // Internal data grab
  7197. var row = data[ idx ];
  7198. if ( row._detailsShow ) {
  7199. row._details.insertAfter( row.nTr );
  7200. }
  7201. } );
  7202. } );
  7203. // Column visibility change - update the colspan
  7204. api.on( colvisEvent, function ( e, ctx, idx, vis ) {
  7205. if ( settings !== ctx ) {
  7206. return;
  7207. }
  7208. // Update the colspan for the details rows (note, only if it already has
  7209. // a colspan)
  7210. var row, visible = _fnVisbleColumns( ctx );
  7211. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  7212. row = data[i];
  7213. if ( row._details ) {
  7214. row._details.children('td[colspan]').attr('colspan', visible );
  7215. }
  7216. }
  7217. } );
  7218. // Table destroyed - nuke any child rows
  7219. api.on( destroyEvent, function ( e, ctx ) {
  7220. if ( settings !== ctx ) {
  7221. return;
  7222. }
  7223. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  7224. if ( data[i]._details ) {
  7225. __details_remove( api, i );
  7226. }
  7227. }
  7228. } );
  7229. }
  7230. };
  7231. // Strings for the method names to help minification
  7232. var _emp = '';
  7233. var _child_obj = _emp+'row().child';
  7234. var _child_mth = _child_obj+'()';
  7235. // data can be:
  7236. // tr
  7237. // string
  7238. // jQuery or array of any of the above
  7239. _api_register( _child_mth, function ( data, klass ) {
  7240. var ctx = this.context;
  7241. if ( data === undefined ) {
  7242. // get
  7243. return ctx.length && this.length ?
  7244. ctx[0].aoData[ this[0] ]._details :
  7245. undefined;
  7246. }
  7247. else if ( data === true ) {
  7248. // show
  7249. this.child.show();
  7250. }
  7251. else if ( data === false ) {
  7252. // remove
  7253. __details_remove( this );
  7254. }
  7255. else if ( ctx.length && this.length ) {
  7256. // set
  7257. __details_add( ctx[0], ctx[0].aoData[ this[0] ], data, klass );
  7258. }
  7259. return this;
  7260. } );
  7261. _api_register( [
  7262. _child_obj+'.show()',
  7263. _child_mth+'.show()' // only when `child()` was called with parameters (without
  7264. ], function ( show ) { // it returns an object and this method is not executed)
  7265. __details_display( this, true );
  7266. return this;
  7267. } );
  7268. _api_register( [
  7269. _child_obj+'.hide()',
  7270. _child_mth+'.hide()' // only when `child()` was called with parameters (without
  7271. ], function () { // it returns an object and this method is not executed)
  7272. __details_display( this, false );
  7273. return this;
  7274. } );
  7275. _api_register( [
  7276. _child_obj+'.remove()',
  7277. _child_mth+'.remove()' // only when `child()` was called with parameters (without
  7278. ], function () { // it returns an object and this method is not executed)
  7279. __details_remove( this );
  7280. return this;
  7281. } );
  7282. _api_register( _child_obj+'.isShown()', function () {
  7283. var ctx = this.context;
  7284. if ( ctx.length && this.length ) {
  7285. // _detailsShown as false or undefined will fall through to return false
  7286. return ctx[0].aoData[ this[0] ]._detailsShow || false;
  7287. }
  7288. return false;
  7289. } );
  7290. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  7291. * Columns
  7292. *
  7293. * {integer} - column index (>=0 count from left, <0 count from right)
  7294. * "{integer}:visIdx" - visible column index (i.e. translate to column index) (>=0 count from left, <0 count from right)
  7295. * "{integer}:visible" - alias for {integer}:visIdx (>=0 count from left, <0 count from right)
  7296. * "{string}:name" - column name
  7297. * "{string}" - jQuery selector on column header nodes
  7298. *
  7299. */
  7300. // can be an array of these items, comma separated list, or an array of comma
  7301. // separated lists
  7302. var __re_column_selector = /^([^:]+):(name|visIdx|visible)$/;
  7303. // r1 and r2 are redundant - but it means that the parameters match for the
  7304. // iterator callback in columns().data()
  7305. var __columnData = function ( settings, column, r1, r2, rows ) {
  7306. var a = [];
  7307. for ( var row=0, ien=rows.length ; row<ien ; row++ ) {
  7308. a.push( _fnGetCellData( settings, rows[row], column ) );
  7309. }
  7310. return a;
  7311. };
  7312. var __column_selector = function ( settings, selector, opts )
  7313. {
  7314. var
  7315. columns = settings.aoColumns,
  7316. names = _pluck( columns, 'sName' ),
  7317. nodes = _pluck( columns, 'nTh' );
  7318. var run = function ( s ) {
  7319. var selInt = _intVal( s );
  7320. // Selector - all
  7321. if ( s === '' ) {
  7322. return _range( columns.length );
  7323. }
  7324. // Selector - index
  7325. if ( selInt !== null ) {
  7326. return [ selInt >= 0 ?
  7327. selInt : // Count from left
  7328. columns.length + selInt // Count from right (+ because its a negative value)
  7329. ];
  7330. }
  7331. // Selector = function
  7332. if ( typeof s === 'function' ) {
  7333. var rows = _selector_row_indexes( settings, opts );
  7334. return $.map( columns, function (col, idx) {
  7335. return s(
  7336. idx,
  7337. __columnData( settings, idx, 0, 0, rows ),
  7338. nodes[ idx ]
  7339. ) ? idx : null;
  7340. } );
  7341. }
  7342. // jQuery or string selector
  7343. var match = typeof s === 'string' ?
  7344. s.match( __re_column_selector ) :
  7345. '';
  7346. if ( match ) {
  7347. switch( match[2] ) {
  7348. case 'visIdx':
  7349. case 'visible':
  7350. var idx = parseInt( match[1], 10 );
  7351. // Visible index given, convert to column index
  7352. if ( idx < 0 ) {
  7353. // Counting from the right
  7354. var visColumns = $.map( columns, function (col,i) {
  7355. return col.bVisible ? i : null;
  7356. } );
  7357. return [ visColumns[ visColumns.length + idx ] ];
  7358. }
  7359. // Counting from the left
  7360. return [ _fnVisibleToColumnIndex( settings, idx ) ];
  7361. case 'name':
  7362. // match by name. `names` is column index complete and in order
  7363. return $.map( names, function (name, i) {
  7364. return name === match[1] ? i : null;
  7365. } );
  7366. default:
  7367. return [];
  7368. }
  7369. }
  7370. // Cell in the table body
  7371. if ( s.nodeName && s._DT_CellIndex ) {
  7372. return [ s._DT_CellIndex.column ];
  7373. }
  7374. // jQuery selector on the TH elements for the columns
  7375. var jqResult = $( nodes )
  7376. .filter( s )
  7377. .map( function () {
  7378. return $.inArray( this, nodes ); // `nodes` is column index complete and in order
  7379. } )
  7380. .toArray();
  7381. if ( jqResult.length || ! s.nodeName ) {
  7382. return jqResult;
  7383. }
  7384. // Otherwise a node which might have a `dt-column` data attribute, or be
  7385. // a child or such an element
  7386. var host = $(s).closest('*[data-dt-column]');
  7387. return host.length ?
  7388. [ host.data('dt-column') ] :
  7389. [];
  7390. };
  7391. return _selector_run( 'column', selector, run, settings, opts );
  7392. };
  7393. var __setColumnVis = function ( settings, column, vis ) {
  7394. var
  7395. cols = settings.aoColumns,
  7396. col = cols[ column ],
  7397. data = settings.aoData,
  7398. row, cells, i, ien, tr;
  7399. // Get
  7400. if ( vis === undefined ) {
  7401. return col.bVisible;
  7402. }
  7403. // Set
  7404. // No change
  7405. if ( col.bVisible === vis ) {
  7406. return;
  7407. }
  7408. if ( vis ) {
  7409. // Insert column
  7410. // Need to decide if we should use appendChild or insertBefore
  7411. var insertBefore = $.inArray( true, _pluck(cols, 'bVisible'), column+1 );
  7412. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  7413. tr = data[i].nTr;
  7414. cells = data[i].anCells;
  7415. if ( tr ) {
  7416. // insertBefore can act like appendChild if 2nd arg is null
  7417. tr.insertBefore( cells[ column ], cells[ insertBefore ] || null );
  7418. }
  7419. }
  7420. }
  7421. else {
  7422. // Remove column
  7423. $( _pluck( settings.aoData, 'anCells', column ) ).detach();
  7424. }
  7425. // Common actions
  7426. col.bVisible = vis;
  7427. };
  7428. _api_register( 'columns()', function ( selector, opts ) {
  7429. // argument shifting
  7430. if ( selector === undefined ) {
  7431. selector = '';
  7432. }
  7433. else if ( $.isPlainObject( selector ) ) {
  7434. opts = selector;
  7435. selector = '';
  7436. }
  7437. opts = _selector_opts( opts );
  7438. var inst = this.iterator( 'table', function ( settings ) {
  7439. return __column_selector( settings, selector, opts );
  7440. }, 1 );
  7441. // Want argument shifting here and in _row_selector?
  7442. inst.selector.cols = selector;
  7443. inst.selector.opts = opts;
  7444. return inst;
  7445. } );
  7446. _api_registerPlural( 'columns().header()', 'column().header()', function ( selector, opts ) {
  7447. return this.iterator( 'column', function ( settings, column ) {
  7448. return settings.aoColumns[column].nTh;
  7449. }, 1 );
  7450. } );
  7451. _api_registerPlural( 'columns().footer()', 'column().footer()', function ( selector, opts ) {
  7452. return this.iterator( 'column', function ( settings, column ) {
  7453. return settings.aoColumns[column].nTf;
  7454. }, 1 );
  7455. } );
  7456. _api_registerPlural( 'columns().data()', 'column().data()', function () {
  7457. return this.iterator( 'column-rows', __columnData, 1 );
  7458. } );
  7459. _api_registerPlural( 'columns().dataSrc()', 'column().dataSrc()', function () {
  7460. return this.iterator( 'column', function ( settings, column ) {
  7461. return settings.aoColumns[column].mData;
  7462. }, 1 );
  7463. } );
  7464. _api_registerPlural( 'columns().cache()', 'column().cache()', function ( type ) {
  7465. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7466. return _pluck_order( settings.aoData, rows,
  7467. type === 'search' ? '_aFilterData' : '_aSortData', column
  7468. );
  7469. }, 1 );
  7470. } );
  7471. _api_registerPlural( 'columns().nodes()', 'column().nodes()', function () {
  7472. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7473. return _pluck_order( settings.aoData, rows, 'anCells', column ) ;
  7474. }, 1 );
  7475. } );
  7476. _api_registerPlural( 'columns().visible()', 'column().visible()', function ( vis, calc ) {
  7477. var that = this;
  7478. var ret = this.iterator( 'column', function ( settings, column ) {
  7479. if ( vis === undefined ) {
  7480. return settings.aoColumns[ column ].bVisible;
  7481. } // else
  7482. __setColumnVis( settings, column, vis );
  7483. } );
  7484. // Group the column visibility changes
  7485. if ( vis !== undefined ) {
  7486. this.iterator( 'table', function ( settings ) {
  7487. // Redraw the header after changes
  7488. _fnDrawHead( settings, settings.aoHeader );
  7489. _fnDrawHead( settings, settings.aoFooter );
  7490. // Update colspan for no records display. Child rows and extensions will use their own
  7491. // listeners to do this - only need to update the empty table item here
  7492. if ( ! settings.aiDisplay.length ) {
  7493. $(settings.nTBody).find('td[colspan]').attr('colspan', _fnVisbleColumns(settings));
  7494. }
  7495. _fnSaveState( settings );
  7496. // Second loop once the first is done for events
  7497. that.iterator( 'column', function ( settings, column ) {
  7498. _fnCallbackFire( settings, null, 'column-visibility', [settings, column, vis, calc] );
  7499. } );
  7500. if ( calc === undefined || calc ) {
  7501. that.columns.adjust();
  7502. }
  7503. });
  7504. }
  7505. return ret;
  7506. } );
  7507. _api_registerPlural( 'columns().indexes()', 'column().index()', function ( type ) {
  7508. return this.iterator( 'column', function ( settings, column ) {
  7509. return type === 'visible' ?
  7510. _fnColumnIndexToVisible( settings, column ) :
  7511. column;
  7512. }, 1 );
  7513. } );
  7514. _api_register( 'columns.adjust()', function () {
  7515. return this.iterator( 'table', function ( settings ) {
  7516. _fnAdjustColumnSizing( settings );
  7517. }, 1 );
  7518. } );
  7519. _api_register( 'column.index()', function ( type, idx ) {
  7520. if ( this.context.length !== 0 ) {
  7521. var ctx = this.context[0];
  7522. if ( type === 'fromVisible' || type === 'toData' ) {
  7523. return _fnVisibleToColumnIndex( ctx, idx );
  7524. }
  7525. else if ( type === 'fromData' || type === 'toVisible' ) {
  7526. return _fnColumnIndexToVisible( ctx, idx );
  7527. }
  7528. }
  7529. } );
  7530. _api_register( 'column()', function ( selector, opts ) {
  7531. return _selector_first( this.columns( selector, opts ) );
  7532. } );
  7533. var __cell_selector = function ( settings, selector, opts )
  7534. {
  7535. var data = settings.aoData;
  7536. var rows = _selector_row_indexes( settings, opts );
  7537. var cells = _removeEmpty( _pluck_order( data, rows, 'anCells' ) );
  7538. var allCells = $(_flatten( [], cells ));
  7539. var row;
  7540. var columns = settings.aoColumns.length;
  7541. var a, i, ien, j, o, host;
  7542. var run = function ( s ) {
  7543. var fnSelector = typeof s === 'function';
  7544. if ( s === null || s === undefined || fnSelector ) {
  7545. // All cells and function selectors
  7546. a = [];
  7547. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  7548. row = rows[i];
  7549. for ( j=0 ; j<columns ; j++ ) {
  7550. o = {
  7551. row: row,
  7552. column: j
  7553. };
  7554. if ( fnSelector ) {
  7555. // Selector - function
  7556. host = data[ row ];
  7557. if ( s( o, _fnGetCellData(settings, row, j), host.anCells ? host.anCells[j] : null ) ) {
  7558. a.push( o );
  7559. }
  7560. }
  7561. else {
  7562. // Selector - all
  7563. a.push( o );
  7564. }
  7565. }
  7566. }
  7567. return a;
  7568. }
  7569. // Selector - index
  7570. if ( $.isPlainObject( s ) ) {
  7571. // Valid cell index and its in the array of selectable rows
  7572. return s.column !== undefined && s.row !== undefined && $.inArray( s.row, rows ) !== -1 ?
  7573. [s] :
  7574. [];
  7575. }
  7576. // Selector - jQuery filtered cells
  7577. var jqResult = allCells
  7578. .filter( s )
  7579. .map( function (i, el) {
  7580. return { // use a new object, in case someone changes the values
  7581. row: el._DT_CellIndex.row,
  7582. column: el._DT_CellIndex.column
  7583. };
  7584. } )
  7585. .toArray();
  7586. if ( jqResult.length || ! s.nodeName ) {
  7587. return jqResult;
  7588. }
  7589. // Otherwise the selector is a node, and there is one last option - the
  7590. // element might be a child of an element which has dt-row and dt-column
  7591. // data attributes
  7592. host = $(s).closest('*[data-dt-row]');
  7593. return host.length ?
  7594. [ {
  7595. row: host.data('dt-row'),
  7596. column: host.data('dt-column')
  7597. } ] :
  7598. [];
  7599. };
  7600. return _selector_run( 'cell', selector, run, settings, opts );
  7601. };
  7602. _api_register( 'cells()', function ( rowSelector, columnSelector, opts ) {
  7603. // Argument shifting
  7604. if ( $.isPlainObject( rowSelector ) ) {
  7605. // Indexes
  7606. if ( rowSelector.row === undefined ) {
  7607. // Selector options in first parameter
  7608. opts = rowSelector;
  7609. rowSelector = null;
  7610. }
  7611. else {
  7612. // Cell index objects in first parameter
  7613. opts = columnSelector;
  7614. columnSelector = null;
  7615. }
  7616. }
  7617. if ( $.isPlainObject( columnSelector ) ) {
  7618. opts = columnSelector;
  7619. columnSelector = null;
  7620. }
  7621. // Cell selector
  7622. if ( columnSelector === null || columnSelector === undefined ) {
  7623. return this.iterator( 'table', function ( settings ) {
  7624. return __cell_selector( settings, rowSelector, _selector_opts( opts ) );
  7625. } );
  7626. }
  7627. // The default built in options need to apply to row and columns
  7628. var internalOpts = opts ? {
  7629. page: opts.page,
  7630. order: opts.order,
  7631. search: opts.search
  7632. } : {};
  7633. // Row + column selector
  7634. var columns = this.columns( columnSelector, internalOpts );
  7635. var rows = this.rows( rowSelector, internalOpts );
  7636. var i, ien, j, jen;
  7637. var cellsNoOpts = this.iterator( 'table', function ( settings, idx ) {
  7638. var a = [];
  7639. for ( i=0, ien=rows[idx].length ; i<ien ; i++ ) {
  7640. for ( j=0, jen=columns[idx].length ; j<jen ; j++ ) {
  7641. a.push( {
  7642. row: rows[idx][i],
  7643. column: columns[idx][j]
  7644. } );
  7645. }
  7646. }
  7647. return a;
  7648. }, 1 );
  7649. // There is currently only one extension which uses a cell selector extension
  7650. // It is a _major_ performance drag to run this if it isn't needed, so this is
  7651. // an extension specific check at the moment
  7652. var cells = opts && opts.selected ?
  7653. this.cells( cellsNoOpts, opts ) :
  7654. cellsNoOpts;
  7655. $.extend( cells.selector, {
  7656. cols: columnSelector,
  7657. rows: rowSelector,
  7658. opts: opts
  7659. } );
  7660. return cells;
  7661. } );
  7662. _api_registerPlural( 'cells().nodes()', 'cell().node()', function () {
  7663. return this.iterator( 'cell', function ( settings, row, column ) {
  7664. var data = settings.aoData[ row ];
  7665. return data && data.anCells ?
  7666. data.anCells[ column ] :
  7667. undefined;
  7668. }, 1 );
  7669. } );
  7670. _api_register( 'cells().data()', function () {
  7671. return this.iterator( 'cell', function ( settings, row, column ) {
  7672. return _fnGetCellData( settings, row, column );
  7673. }, 1 );
  7674. } );
  7675. _api_registerPlural( 'cells().cache()', 'cell().cache()', function ( type ) {
  7676. type = type === 'search' ? '_aFilterData' : '_aSortData';
  7677. return this.iterator( 'cell', function ( settings, row, column ) {
  7678. return settings.aoData[ row ][ type ][ column ];
  7679. }, 1 );
  7680. } );
  7681. _api_registerPlural( 'cells().render()', 'cell().render()', function ( type ) {
  7682. return this.iterator( 'cell', function ( settings, row, column ) {
  7683. return _fnGetCellData( settings, row, column, type );
  7684. }, 1 );
  7685. } );
  7686. _api_registerPlural( 'cells().indexes()', 'cell().index()', function () {
  7687. return this.iterator( 'cell', function ( settings, row, column ) {
  7688. return {
  7689. row: row,
  7690. column: column,
  7691. columnVisible: _fnColumnIndexToVisible( settings, column )
  7692. };
  7693. }, 1 );
  7694. } );
  7695. _api_registerPlural( 'cells().invalidate()', 'cell().invalidate()', function ( src ) {
  7696. return this.iterator( 'cell', function ( settings, row, column ) {
  7697. _fnInvalidate( settings, row, src, column );
  7698. } );
  7699. } );
  7700. _api_register( 'cell()', function ( rowSelector, columnSelector, opts ) {
  7701. return _selector_first( this.cells( rowSelector, columnSelector, opts ) );
  7702. } );
  7703. _api_register( 'cell().data()', function ( data ) {
  7704. var ctx = this.context;
  7705. var cell = this[0];
  7706. if ( data === undefined ) {
  7707. // Get
  7708. return ctx.length && cell.length ?
  7709. _fnGetCellData( ctx[0], cell[0].row, cell[0].column ) :
  7710. undefined;
  7711. }
  7712. // Set
  7713. _fnSetCellData( ctx[0], cell[0].row, cell[0].column, data );
  7714. _fnInvalidate( ctx[0], cell[0].row, 'data', cell[0].column );
  7715. return this;
  7716. } );
  7717. /**
  7718. * Get current ordering (sorting) that has been applied to the table.
  7719. *
  7720. * @returns {array} 2D array containing the sorting information for the first
  7721. * table in the current context. Each element in the parent array represents
  7722. * a column being sorted upon (i.e. multi-sorting with two columns would have
  7723. * 2 inner arrays). The inner arrays may have 2 or 3 elements. The first is
  7724. * the column index that the sorting condition applies to, the second is the
  7725. * direction of the sort (`desc` or `asc`) and, optionally, the third is the
  7726. * index of the sorting order from the `column.sorting` initialisation array.
  7727. *//**
  7728. * Set the ordering for the table.
  7729. *
  7730. * @param {integer} order Column index to sort upon.
  7731. * @param {string} direction Direction of the sort to be applied (`asc` or `desc`)
  7732. * @returns {DataTables.Api} this
  7733. *//**
  7734. * Set the ordering for the table.
  7735. *
  7736. * @param {array} order 1D array of sorting information to be applied.
  7737. * @param {array} [...] Optional additional sorting conditions
  7738. * @returns {DataTables.Api} this
  7739. *//**
  7740. * Set the ordering for the table.
  7741. *
  7742. * @param {array} order 2D array of sorting information to be applied.
  7743. * @returns {DataTables.Api} this
  7744. */
  7745. _api_register( 'order()', function ( order, dir ) {
  7746. var ctx = this.context;
  7747. if ( order === undefined ) {
  7748. // get
  7749. return ctx.length !== 0 ?
  7750. ctx[0].aaSorting :
  7751. undefined;
  7752. }
  7753. // set
  7754. if ( typeof order === 'number' ) {
  7755. // Simple column / direction passed in
  7756. order = [ [ order, dir ] ];
  7757. }
  7758. else if ( order.length && ! Array.isArray( order[0] ) ) {
  7759. // Arguments passed in (list of 1D arrays)
  7760. order = Array.prototype.slice.call( arguments );
  7761. }
  7762. // otherwise a 2D array was passed in
  7763. return this.iterator( 'table', function ( settings ) {
  7764. settings.aaSorting = order.slice();
  7765. } );
  7766. } );
  7767. /**
  7768. * Attach a sort listener to an element for a given column
  7769. *
  7770. * @param {node|jQuery|string} node Identifier for the element(s) to attach the
  7771. * listener to. This can take the form of a single DOM node, a jQuery
  7772. * collection of nodes or a jQuery selector which will identify the node(s).
  7773. * @param {integer} column the column that a click on this node will sort on
  7774. * @param {function} [callback] callback function when sort is run
  7775. * @returns {DataTables.Api} this
  7776. */
  7777. _api_register( 'order.listener()', function ( node, column, callback ) {
  7778. return this.iterator( 'table', function ( settings ) {
  7779. _fnSortAttachListener( settings, node, column, callback );
  7780. } );
  7781. } );
  7782. _api_register( 'order.fixed()', function ( set ) {
  7783. if ( ! set ) {
  7784. var ctx = this.context;
  7785. var fixed = ctx.length ?
  7786. ctx[0].aaSortingFixed :
  7787. undefined;
  7788. return Array.isArray( fixed ) ?
  7789. { pre: fixed } :
  7790. fixed;
  7791. }
  7792. return this.iterator( 'table', function ( settings ) {
  7793. settings.aaSortingFixed = $.extend( true, {}, set );
  7794. } );
  7795. } );
  7796. // Order by the selected column(s)
  7797. _api_register( [
  7798. 'columns().order()',
  7799. 'column().order()'
  7800. ], function ( dir ) {
  7801. var that = this;
  7802. return this.iterator( 'table', function ( settings, i ) {
  7803. var sort = [];
  7804. $.each( that[i], function (j, col) {
  7805. sort.push( [ col, dir ] );
  7806. } );
  7807. settings.aaSorting = sort;
  7808. } );
  7809. } );
  7810. _api_register( 'search()', function ( input, regex, smart, caseInsen ) {
  7811. var ctx = this.context;
  7812. if ( input === undefined ) {
  7813. // get
  7814. return ctx.length !== 0 ?
  7815. ctx[0].oPreviousSearch.sSearch :
  7816. undefined;
  7817. }
  7818. // set
  7819. return this.iterator( 'table', function ( settings ) {
  7820. if ( ! settings.oFeatures.bFilter ) {
  7821. return;
  7822. }
  7823. _fnFilterComplete( settings, $.extend( {}, settings.oPreviousSearch, {
  7824. "sSearch": input+"",
  7825. "bRegex": regex === null ? false : regex,
  7826. "bSmart": smart === null ? true : smart,
  7827. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7828. } ), 1 );
  7829. } );
  7830. } );
  7831. _api_registerPlural(
  7832. 'columns().search()',
  7833. 'column().search()',
  7834. function ( input, regex, smart, caseInsen ) {
  7835. return this.iterator( 'column', function ( settings, column ) {
  7836. var preSearch = settings.aoPreSearchCols;
  7837. if ( input === undefined ) {
  7838. // get
  7839. return preSearch[ column ].sSearch;
  7840. }
  7841. // set
  7842. if ( ! settings.oFeatures.bFilter ) {
  7843. return;
  7844. }
  7845. $.extend( preSearch[ column ], {
  7846. "sSearch": input+"",
  7847. "bRegex": regex === null ? false : regex,
  7848. "bSmart": smart === null ? true : smart,
  7849. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7850. } );
  7851. _fnFilterComplete( settings, settings.oPreviousSearch, 1 );
  7852. } );
  7853. }
  7854. );
  7855. /*
  7856. * State API methods
  7857. */
  7858. _api_register( 'state()', function () {
  7859. return this.context.length ?
  7860. this.context[0].oSavedState :
  7861. null;
  7862. } );
  7863. _api_register( 'state.clear()', function () {
  7864. return this.iterator( 'table', function ( settings ) {
  7865. // Save an empty object
  7866. settings.fnStateSaveCallback.call( settings.oInstance, settings, {} );
  7867. } );
  7868. } );
  7869. _api_register( 'state.loaded()', function () {
  7870. return this.context.length ?
  7871. this.context[0].oLoadedState :
  7872. null;
  7873. } );
  7874. _api_register( 'state.save()', function () {
  7875. return this.iterator( 'table', function ( settings ) {
  7876. _fnSaveState( settings );
  7877. } );
  7878. } );
  7879. /**
  7880. * Provide a common method for plug-ins to check the version of DataTables being
  7881. * used, in order to ensure compatibility.
  7882. *
  7883. * @param {string} version Version string to check for, in the format "X.Y.Z".
  7884. * Note that the formats "X" and "X.Y" are also acceptable.
  7885. * @returns {boolean} true if this version of DataTables is greater or equal to
  7886. * the required version, or false if this version of DataTales is not
  7887. * suitable
  7888. * @static
  7889. * @dtopt API-Static
  7890. *
  7891. * @example
  7892. * alert( $.fn.dataTable.versionCheck( '1.9.0' ) );
  7893. */
  7894. DataTable.versionCheck = DataTable.fnVersionCheck = function( version )
  7895. {
  7896. var aThis = DataTable.version.split('.');
  7897. var aThat = version.split('.');
  7898. var iThis, iThat;
  7899. for ( var i=0, iLen=aThat.length ; i<iLen ; i++ ) {
  7900. iThis = parseInt( aThis[i], 10 ) || 0;
  7901. iThat = parseInt( aThat[i], 10 ) || 0;
  7902. // Parts are the same, keep comparing
  7903. if (iThis === iThat) {
  7904. continue;
  7905. }
  7906. // Parts are different, return immediately
  7907. return iThis > iThat;
  7908. }
  7909. return true;
  7910. };
  7911. /**
  7912. * Check if a `<table>` node is a DataTable table already or not.
  7913. *
  7914. * @param {node|jquery|string} table Table node, jQuery object or jQuery
  7915. * selector for the table to test. Note that if more than more than one
  7916. * table is passed on, only the first will be checked
  7917. * @returns {boolean} true the table given is a DataTable, or false otherwise
  7918. * @static
  7919. * @dtopt API-Static
  7920. *
  7921. * @example
  7922. * if ( ! $.fn.DataTable.isDataTable( '#example' ) ) {
  7923. * $('#example').dataTable();
  7924. * }
  7925. */
  7926. DataTable.isDataTable = DataTable.fnIsDataTable = function ( table )
  7927. {
  7928. var t = $(table).get(0);
  7929. var is = false;
  7930. if ( table instanceof DataTable.Api ) {
  7931. return true;
  7932. }
  7933. $.each( DataTable.settings, function (i, o) {
  7934. var head = o.nScrollHead ? $('table', o.nScrollHead)[0] : null;
  7935. var foot = o.nScrollFoot ? $('table', o.nScrollFoot)[0] : null;
  7936. if ( o.nTable === t || head === t || foot === t ) {
  7937. is = true;
  7938. }
  7939. } );
  7940. return is;
  7941. };
  7942. /**
  7943. * Get all DataTable tables that have been initialised - optionally you can
  7944. * select to get only currently visible tables.
  7945. *
  7946. * @param {boolean} [visible=false] Flag to indicate if you want all (default)
  7947. * or visible tables only.
  7948. * @returns {array} Array of `table` nodes (not DataTable instances) which are
  7949. * DataTables
  7950. * @static
  7951. * @dtopt API-Static
  7952. *
  7953. * @example
  7954. * $.each( $.fn.dataTable.tables(true), function () {
  7955. * $(table).DataTable().columns.adjust();
  7956. * } );
  7957. */
  7958. DataTable.tables = DataTable.fnTables = function ( visible )
  7959. {
  7960. var api = false;
  7961. if ( $.isPlainObject( visible ) ) {
  7962. api = visible.api;
  7963. visible = visible.visible;
  7964. }
  7965. var a = $.map( DataTable.settings, function (o) {
  7966. if ( !visible || (visible && $(o.nTable).is(':visible')) ) {
  7967. return o.nTable;
  7968. }
  7969. } );
  7970. return api ?
  7971. new _Api( a ) :
  7972. a;
  7973. };
  7974. /**
  7975. * Convert from camel case parameters to Hungarian notation. This is made public
  7976. * for the extensions to provide the same ability as DataTables core to accept
  7977. * either the 1.9 style Hungarian notation, or the 1.10+ style camelCase
  7978. * parameters.
  7979. *
  7980. * @param {object} src The model object which holds all parameters that can be
  7981. * mapped.
  7982. * @param {object} user The object to convert from camel case to Hungarian.
  7983. * @param {boolean} force When set to `true`, properties which already have a
  7984. * Hungarian value in the `user` object will be overwritten. Otherwise they
  7985. * won't be.
  7986. */
  7987. DataTable.camelToHungarian = _fnCamelToHungarian;
  7988. /**
  7989. *
  7990. */
  7991. _api_register( '$()', function ( selector, opts ) {
  7992. var
  7993. rows = this.rows( opts ).nodes(), // Get all rows
  7994. jqRows = $(rows);
  7995. return $( [].concat(
  7996. jqRows.filter( selector ).toArray(),
  7997. jqRows.find( selector ).toArray()
  7998. ) );
  7999. } );
  8000. // jQuery functions to operate on the tables
  8001. $.each( [ 'on', 'one', 'off' ], function (i, key) {
  8002. _api_register( key+'()', function ( /* event, handler */ ) {
  8003. var args = Array.prototype.slice.call(arguments);
  8004. // Add the `dt` namespace automatically if it isn't already present
  8005. args[0] = $.map( args[0].split( /\s/ ), function ( e ) {
  8006. return ! e.match(/\.dt\b/) ?
  8007. e+'.dt' :
  8008. e;
  8009. } ).join( ' ' );
  8010. var inst = $( this.tables().nodes() );
  8011. inst[key].apply( inst, args );
  8012. return this;
  8013. } );
  8014. } );
  8015. _api_register( 'clear()', function () {
  8016. return this.iterator( 'table', function ( settings ) {
  8017. _fnClearTable( settings );
  8018. } );
  8019. } );
  8020. _api_register( 'settings()', function () {
  8021. return new _Api( this.context, this.context );
  8022. } );
  8023. _api_register( 'init()', function () {
  8024. var ctx = this.context;
  8025. return ctx.length ? ctx[0].oInit : null;
  8026. } );
  8027. _api_register( 'data()', function () {
  8028. return this.iterator( 'table', function ( settings ) {
  8029. return _pluck( settings.aoData, '_aData' );
  8030. } ).flatten();
  8031. } );
  8032. _api_register( 'destroy()', function ( remove ) {
  8033. remove = remove || false;
  8034. return this.iterator( 'table', function ( settings ) {
  8035. var orig = settings.nTableWrapper.parentNode;
  8036. var classes = settings.oClasses;
  8037. var table = settings.nTable;
  8038. var tbody = settings.nTBody;
  8039. var thead = settings.nTHead;
  8040. var tfoot = settings.nTFoot;
  8041. var jqTable = $(table);
  8042. var jqTbody = $(tbody);
  8043. var jqWrapper = $(settings.nTableWrapper);
  8044. var rows = $.map( settings.aoData, function (r) { return r.nTr; } );
  8045. var i, ien;
  8046. // Flag to note that the table is currently being destroyed - no action
  8047. // should be taken
  8048. settings.bDestroying = true;
  8049. // Fire off the destroy callbacks for plug-ins etc
  8050. _fnCallbackFire( settings, "aoDestroyCallback", "destroy", [settings] );
  8051. // If not being removed from the document, make all columns visible
  8052. if ( ! remove ) {
  8053. new _Api( settings ).columns().visible( true );
  8054. }
  8055. // Blitz all `DT` namespaced events (these are internal events, the
  8056. // lowercase, `dt` events are user subscribed and they are responsible
  8057. // for removing them
  8058. jqWrapper.off('.DT').find(':not(tbody *)').off('.DT');
  8059. $(window).off('.DT-'+settings.sInstance);
  8060. // When scrolling we had to break the table up - restore it
  8061. if ( table != thead.parentNode ) {
  8062. jqTable.children('thead').detach();
  8063. jqTable.append( thead );
  8064. }
  8065. if ( tfoot && table != tfoot.parentNode ) {
  8066. jqTable.children('tfoot').detach();
  8067. jqTable.append( tfoot );
  8068. }
  8069. settings.aaSorting = [];
  8070. settings.aaSortingFixed = [];
  8071. _fnSortingClasses( settings );
  8072. $( rows ).removeClass( settings.asStripeClasses.join(' ') );
  8073. $('th, td', thead).removeClass( classes.sSortable+' '+
  8074. classes.sSortableAsc+' '+classes.sSortableDesc+' '+classes.sSortableNone
  8075. );
  8076. // Add the TR elements back into the table in their original order
  8077. jqTbody.children().detach();
  8078. jqTbody.append( rows );
  8079. // Remove the DataTables generated nodes, events and classes
  8080. var removedMethod = remove ? 'remove' : 'detach';
  8081. jqTable[ removedMethod ]();
  8082. jqWrapper[ removedMethod ]();
  8083. // If we need to reattach the table to the document
  8084. if ( ! remove && orig ) {
  8085. // insertBefore acts like appendChild if !arg[1]
  8086. orig.insertBefore( table, settings.nTableReinsertBefore );
  8087. // Restore the width of the original table - was read from the style property,
  8088. // so we can restore directly to that
  8089. jqTable
  8090. .css( 'width', settings.sDestroyWidth )
  8091. .removeClass( classes.sTable );
  8092. // If the were originally stripe classes - then we add them back here.
  8093. // Note this is not fool proof (for example if not all rows had stripe
  8094. // classes - but it's a good effort without getting carried away
  8095. ien = settings.asDestroyStripes.length;
  8096. if ( ien ) {
  8097. jqTbody.children().each( function (i) {
  8098. $(this).addClass( settings.asDestroyStripes[i % ien] );
  8099. } );
  8100. }
  8101. }
  8102. /* Remove the settings object from the settings array */
  8103. var idx = $.inArray( settings, DataTable.settings );
  8104. if ( idx !== -1 ) {
  8105. DataTable.settings.splice( idx, 1 );
  8106. }
  8107. } );
  8108. } );
  8109. // Add the `every()` method for rows, columns and cells in a compact form
  8110. $.each( [ 'column', 'row', 'cell' ], function ( i, type ) {
  8111. _api_register( type+'s().every()', function ( fn ) {
  8112. var opts = this.selector.opts;
  8113. var api = this;
  8114. return this.iterator( type, function ( settings, arg1, arg2, arg3, arg4 ) {
  8115. // Rows and columns:
  8116. // arg1 - index
  8117. // arg2 - table counter
  8118. // arg3 - loop counter
  8119. // arg4 - undefined
  8120. // Cells:
  8121. // arg1 - row index
  8122. // arg2 - column index
  8123. // arg3 - table counter
  8124. // arg4 - loop counter
  8125. fn.call(
  8126. api[ type ](
  8127. arg1,
  8128. type==='cell' ? arg2 : opts,
  8129. type==='cell' ? opts : undefined
  8130. ),
  8131. arg1, arg2, arg3, arg4
  8132. );
  8133. } );
  8134. } );
  8135. } );
  8136. // i18n method for extensions to be able to use the language object from the
  8137. // DataTable
  8138. _api_register( 'i18n()', function ( token, def, plural ) {
  8139. var ctx = this.context[0];
  8140. var resolved = _fnGetObjectDataFn( token )( ctx.oLanguage );
  8141. if ( resolved === undefined ) {
  8142. resolved = def;
  8143. }
  8144. if ( plural !== undefined && $.isPlainObject( resolved ) ) {
  8145. resolved = resolved[ plural ] !== undefined ?
  8146. resolved[ plural ] :
  8147. resolved._;
  8148. }
  8149. return resolved.replace( '%d', plural ); // nb: plural might be undefined,
  8150. } );
  8151. /**
  8152. * Version string for plug-ins to check compatibility. Allowed format is
  8153. * `a.b.c-d` where: a:int, b:int, c:int, d:string(dev|beta|alpha). `d` is used
  8154. * only for non-release builds. See http://semver.org/ for more information.
  8155. * @member
  8156. * @type string
  8157. * @default Version number
  8158. */
  8159. DataTable.version = "1.11.4";
  8160. /**
  8161. * Private data store, containing all of the settings objects that are
  8162. * created for the tables on a given page.
  8163. *
  8164. * Note that the `DataTable.settings` object is aliased to
  8165. * `jQuery.fn.dataTableExt` through which it may be accessed and
  8166. * manipulated, or `jQuery.fn.dataTable.settings`.
  8167. * @member
  8168. * @type array
  8169. * @default []
  8170. * @private
  8171. */
  8172. DataTable.settings = [];
  8173. /**
  8174. * Object models container, for the various models that DataTables has
  8175. * available to it. These models define the objects that are used to hold
  8176. * the active state and configuration of the table.
  8177. * @namespace
  8178. */
  8179. DataTable.models = {};
  8180. /**
  8181. * Template object for the way in which DataTables holds information about
  8182. * search information for the global filter and individual column filters.
  8183. * @namespace
  8184. */
  8185. DataTable.models.oSearch = {
  8186. /**
  8187. * Flag to indicate if the filtering should be case insensitive or not
  8188. * @type boolean
  8189. * @default true
  8190. */
  8191. "bCaseInsensitive": true,
  8192. /**
  8193. * Applied search term
  8194. * @type string
  8195. * @default <i>Empty string</i>
  8196. */
  8197. "sSearch": "",
  8198. /**
  8199. * Flag to indicate if the search term should be interpreted as a
  8200. * regular expression (true) or not (false) and therefore and special
  8201. * regex characters escaped.
  8202. * @type boolean
  8203. * @default false
  8204. */
  8205. "bRegex": false,
  8206. /**
  8207. * Flag to indicate if DataTables is to use its smart filtering or not.
  8208. * @type boolean
  8209. * @default true
  8210. */
  8211. "bSmart": true,
  8212. /**
  8213. * Flag to indicate if DataTables should only trigger a search when
  8214. * the return key is pressed.
  8215. * @type boolean
  8216. * @default false
  8217. */
  8218. "return": false
  8219. };
  8220. /**
  8221. * Template object for the way in which DataTables holds information about
  8222. * each individual row. This is the object format used for the settings
  8223. * aoData array.
  8224. * @namespace
  8225. */
  8226. DataTable.models.oRow = {
  8227. /**
  8228. * TR element for the row
  8229. * @type node
  8230. * @default null
  8231. */
  8232. "nTr": null,
  8233. /**
  8234. * Array of TD elements for each row. This is null until the row has been
  8235. * created.
  8236. * @type array nodes
  8237. * @default []
  8238. */
  8239. "anCells": null,
  8240. /**
  8241. * Data object from the original data source for the row. This is either
  8242. * an array if using the traditional form of DataTables, or an object if
  8243. * using mData options. The exact type will depend on the passed in
  8244. * data from the data source, or will be an array if using DOM a data
  8245. * source.
  8246. * @type array|object
  8247. * @default []
  8248. */
  8249. "_aData": [],
  8250. /**
  8251. * Sorting data cache - this array is ostensibly the same length as the
  8252. * number of columns (although each index is generated only as it is
  8253. * needed), and holds the data that is used for sorting each column in the
  8254. * row. We do this cache generation at the start of the sort in order that
  8255. * the formatting of the sort data need be done only once for each cell
  8256. * per sort. This array should not be read from or written to by anything
  8257. * other than the master sorting methods.
  8258. * @type array
  8259. * @default null
  8260. * @private
  8261. */
  8262. "_aSortData": null,
  8263. /**
  8264. * Per cell filtering data cache. As per the sort data cache, used to
  8265. * increase the performance of the filtering in DataTables
  8266. * @type array
  8267. * @default null
  8268. * @private
  8269. */
  8270. "_aFilterData": null,
  8271. /**
  8272. * Filtering data cache. This is the same as the cell filtering cache, but
  8273. * in this case a string rather than an array. This is easily computed with
  8274. * a join on `_aFilterData`, but is provided as a cache so the join isn't
  8275. * needed on every search (memory traded for performance)
  8276. * @type array
  8277. * @default null
  8278. * @private
  8279. */
  8280. "_sFilterRow": null,
  8281. /**
  8282. * Cache of the class name that DataTables has applied to the row, so we
  8283. * can quickly look at this variable rather than needing to do a DOM check
  8284. * on className for the nTr property.
  8285. * @type string
  8286. * @default <i>Empty string</i>
  8287. * @private
  8288. */
  8289. "_sRowStripe": "",
  8290. /**
  8291. * Denote if the original data source was from the DOM, or the data source
  8292. * object. This is used for invalidating data, so DataTables can
  8293. * automatically read data from the original source, unless uninstructed
  8294. * otherwise.
  8295. * @type string
  8296. * @default null
  8297. * @private
  8298. */
  8299. "src": null,
  8300. /**
  8301. * Index in the aoData array. This saves an indexOf lookup when we have the
  8302. * object, but want to know the index
  8303. * @type integer
  8304. * @default -1
  8305. * @private
  8306. */
  8307. "idx": -1
  8308. };
  8309. /**
  8310. * Template object for the column information object in DataTables. This object
  8311. * is held in the settings aoColumns array and contains all the information that
  8312. * DataTables needs about each individual column.
  8313. *
  8314. * Note that this object is related to {@link DataTable.defaults.column}
  8315. * but this one is the internal data store for DataTables's cache of columns.
  8316. * It should NOT be manipulated outside of DataTables. Any configuration should
  8317. * be done through the initialisation options.
  8318. * @namespace
  8319. */
  8320. DataTable.models.oColumn = {
  8321. /**
  8322. * Column index. This could be worked out on-the-fly with $.inArray, but it
  8323. * is faster to just hold it as a variable
  8324. * @type integer
  8325. * @default null
  8326. */
  8327. "idx": null,
  8328. /**
  8329. * A list of the columns that sorting should occur on when this column
  8330. * is sorted. That this property is an array allows multi-column sorting
  8331. * to be defined for a column (for example first name / last name columns
  8332. * would benefit from this). The values are integers pointing to the
  8333. * columns to be sorted on (typically it will be a single integer pointing
  8334. * at itself, but that doesn't need to be the case).
  8335. * @type array
  8336. */
  8337. "aDataSort": null,
  8338. /**
  8339. * Define the sorting directions that are applied to the column, in sequence
  8340. * as the column is repeatedly sorted upon - i.e. the first value is used
  8341. * as the sorting direction when the column if first sorted (clicked on).
  8342. * Sort it again (click again) and it will move on to the next index.
  8343. * Repeat until loop.
  8344. * @type array
  8345. */
  8346. "asSorting": null,
  8347. /**
  8348. * Flag to indicate if the column is searchable, and thus should be included
  8349. * in the filtering or not.
  8350. * @type boolean
  8351. */
  8352. "bSearchable": null,
  8353. /**
  8354. * Flag to indicate if the column is sortable or not.
  8355. * @type boolean
  8356. */
  8357. "bSortable": null,
  8358. /**
  8359. * Flag to indicate if the column is currently visible in the table or not
  8360. * @type boolean
  8361. */
  8362. "bVisible": null,
  8363. /**
  8364. * Store for manual type assignment using the `column.type` option. This
  8365. * is held in store so we can manipulate the column's `sType` property.
  8366. * @type string
  8367. * @default null
  8368. * @private
  8369. */
  8370. "_sManualType": null,
  8371. /**
  8372. * Flag to indicate if HTML5 data attributes should be used as the data
  8373. * source for filtering or sorting. True is either are.
  8374. * @type boolean
  8375. * @default false
  8376. * @private
  8377. */
  8378. "_bAttrSrc": false,
  8379. /**
  8380. * Developer definable function that is called whenever a cell is created (Ajax source,
  8381. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  8382. * allowing you to modify the DOM element (add background colour for example) when the
  8383. * element is available.
  8384. * @type function
  8385. * @param {element} nTd The TD node that has been created
  8386. * @param {*} sData The Data for the cell
  8387. * @param {array|object} oData The data for the whole row
  8388. * @param {int} iRow The row index for the aoData data store
  8389. * @default null
  8390. */
  8391. "fnCreatedCell": null,
  8392. /**
  8393. * Function to get data from a cell in a column. You should <b>never</b>
  8394. * access data directly through _aData internally in DataTables - always use
  8395. * the method attached to this property. It allows mData to function as
  8396. * required. This function is automatically assigned by the column
  8397. * initialisation method
  8398. * @type function
  8399. * @param {array|object} oData The data array/object for the array
  8400. * (i.e. aoData[]._aData)
  8401. * @param {string} sSpecific The specific data type you want to get -
  8402. * 'display', 'type' 'filter' 'sort'
  8403. * @returns {*} The data for the cell from the given row's data
  8404. * @default null
  8405. */
  8406. "fnGetData": null,
  8407. /**
  8408. * Function to set data for a cell in the column. You should <b>never</b>
  8409. * set the data directly to _aData internally in DataTables - always use
  8410. * this method. It allows mData to function as required. This function
  8411. * is automatically assigned by the column initialisation method
  8412. * @type function
  8413. * @param {array|object} oData The data array/object for the array
  8414. * (i.e. aoData[]._aData)
  8415. * @param {*} sValue Value to set
  8416. * @default null
  8417. */
  8418. "fnSetData": null,
  8419. /**
  8420. * Property to read the value for the cells in the column from the data
  8421. * source array / object. If null, then the default content is used, if a
  8422. * function is given then the return from the function is used.
  8423. * @type function|int|string|null
  8424. * @default null
  8425. */
  8426. "mData": null,
  8427. /**
  8428. * Partner property to mData which is used (only when defined) to get
  8429. * the data - i.e. it is basically the same as mData, but without the
  8430. * 'set' option, and also the data fed to it is the result from mData.
  8431. * This is the rendering method to match the data method of mData.
  8432. * @type function|int|string|null
  8433. * @default null
  8434. */
  8435. "mRender": null,
  8436. /**
  8437. * Unique header TH/TD element for this column - this is what the sorting
  8438. * listener is attached to (if sorting is enabled.)
  8439. * @type node
  8440. * @default null
  8441. */
  8442. "nTh": null,
  8443. /**
  8444. * Unique footer TH/TD element for this column (if there is one). Not used
  8445. * in DataTables as such, but can be used for plug-ins to reference the
  8446. * footer for each column.
  8447. * @type node
  8448. * @default null
  8449. */
  8450. "nTf": null,
  8451. /**
  8452. * The class to apply to all TD elements in the table's TBODY for the column
  8453. * @type string
  8454. * @default null
  8455. */
  8456. "sClass": null,
  8457. /**
  8458. * When DataTables calculates the column widths to assign to each column,
  8459. * it finds the longest string in each column and then constructs a
  8460. * temporary table and reads the widths from that. The problem with this
  8461. * is that "mmm" is much wider then "iiii", but the latter is a longer
  8462. * string - thus the calculation can go wrong (doing it properly and putting
  8463. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  8464. * a "work around" we provide this option. It will append its value to the
  8465. * text that is found to be the longest string for the column - i.e. padding.
  8466. * @type string
  8467. */
  8468. "sContentPadding": null,
  8469. /**
  8470. * Allows a default value to be given for a column's data, and will be used
  8471. * whenever a null data source is encountered (this can be because mData
  8472. * is set to null, or because the data source itself is null).
  8473. * @type string
  8474. * @default null
  8475. */
  8476. "sDefaultContent": null,
  8477. /**
  8478. * Name for the column, allowing reference to the column by name as well as
  8479. * by index (needs a lookup to work by name).
  8480. * @type string
  8481. */
  8482. "sName": null,
  8483. /**
  8484. * Custom sorting data type - defines which of the available plug-ins in
  8485. * afnSortData the custom sorting will use - if any is defined.
  8486. * @type string
  8487. * @default std
  8488. */
  8489. "sSortDataType": 'std',
  8490. /**
  8491. * Class to be applied to the header element when sorting on this column
  8492. * @type string
  8493. * @default null
  8494. */
  8495. "sSortingClass": null,
  8496. /**
  8497. * Class to be applied to the header element when sorting on this column -
  8498. * when jQuery UI theming is used.
  8499. * @type string
  8500. * @default null
  8501. */
  8502. "sSortingClassJUI": null,
  8503. /**
  8504. * Title of the column - what is seen in the TH element (nTh).
  8505. * @type string
  8506. */
  8507. "sTitle": null,
  8508. /**
  8509. * Column sorting and filtering type
  8510. * @type string
  8511. * @default null
  8512. */
  8513. "sType": null,
  8514. /**
  8515. * Width of the column
  8516. * @type string
  8517. * @default null
  8518. */
  8519. "sWidth": null,
  8520. /**
  8521. * Width of the column when it was first "encountered"
  8522. * @type string
  8523. * @default null
  8524. */
  8525. "sWidthOrig": null
  8526. };
  8527. /*
  8528. * Developer note: The properties of the object below are given in Hungarian
  8529. * notation, that was used as the interface for DataTables prior to v1.10, however
  8530. * from v1.10 onwards the primary interface is camel case. In order to avoid
  8531. * breaking backwards compatibility utterly with this change, the Hungarian
  8532. * version is still, internally the primary interface, but is is not documented
  8533. * - hence the @name tags in each doc comment. This allows a Javascript function
  8534. * to create a map from Hungarian notation to camel case (going the other direction
  8535. * would require each property to be listed, which would add around 3K to the size
  8536. * of DataTables, while this method is about a 0.5K hit).
  8537. *
  8538. * Ultimately this does pave the way for Hungarian notation to be dropped
  8539. * completely, but that is a massive amount of work and will break current
  8540. * installs (therefore is on-hold until v2).
  8541. */
  8542. /**
  8543. * Initialisation options that can be given to DataTables at initialisation
  8544. * time.
  8545. * @namespace
  8546. */
  8547. DataTable.defaults = {
  8548. /**
  8549. * An array of data to use for the table, passed in at initialisation which
  8550. * will be used in preference to any data which is already in the DOM. This is
  8551. * particularly useful for constructing tables purely in Javascript, for
  8552. * example with a custom Ajax call.
  8553. * @type array
  8554. * @default null
  8555. *
  8556. * @dtopt Option
  8557. * @name DataTable.defaults.data
  8558. *
  8559. * @example
  8560. * // Using a 2D array data source
  8561. * $(document).ready( function () {
  8562. * $('#example').dataTable( {
  8563. * "data": [
  8564. * ['Trident', 'Internet Explorer 4.0', 'Win 95+', 4, 'X'],
  8565. * ['Trident', 'Internet Explorer 5.0', 'Win 95+', 5, 'C'],
  8566. * ],
  8567. * "columns": [
  8568. * { "title": "Engine" },
  8569. * { "title": "Browser" },
  8570. * { "title": "Platform" },
  8571. * { "title": "Version" },
  8572. * { "title": "Grade" }
  8573. * ]
  8574. * } );
  8575. * } );
  8576. *
  8577. * @example
  8578. * // Using an array of objects as a data source (`data`)
  8579. * $(document).ready( function () {
  8580. * $('#example').dataTable( {
  8581. * "data": [
  8582. * {
  8583. * "engine": "Trident",
  8584. * "browser": "Internet Explorer 4.0",
  8585. * "platform": "Win 95+",
  8586. * "version": 4,
  8587. * "grade": "X"
  8588. * },
  8589. * {
  8590. * "engine": "Trident",
  8591. * "browser": "Internet Explorer 5.0",
  8592. * "platform": "Win 95+",
  8593. * "version": 5,
  8594. * "grade": "C"
  8595. * }
  8596. * ],
  8597. * "columns": [
  8598. * { "title": "Engine", "data": "engine" },
  8599. * { "title": "Browser", "data": "browser" },
  8600. * { "title": "Platform", "data": "platform" },
  8601. * { "title": "Version", "data": "version" },
  8602. * { "title": "Grade", "data": "grade" }
  8603. * ]
  8604. * } );
  8605. * } );
  8606. */
  8607. "aaData": null,
  8608. /**
  8609. * If ordering is enabled, then DataTables will perform a first pass sort on
  8610. * initialisation. You can define which column(s) the sort is performed
  8611. * upon, and the sorting direction, with this variable. The `sorting` array
  8612. * should contain an array for each column to be sorted initially containing
  8613. * the column's index and a direction string ('asc' or 'desc').
  8614. * @type array
  8615. * @default [[0,'asc']]
  8616. *
  8617. * @dtopt Option
  8618. * @name DataTable.defaults.order
  8619. *
  8620. * @example
  8621. * // Sort by 3rd column first, and then 4th column
  8622. * $(document).ready( function() {
  8623. * $('#example').dataTable( {
  8624. * "order": [[2,'asc'], [3,'desc']]
  8625. * } );
  8626. * } );
  8627. *
  8628. * // No initial sorting
  8629. * $(document).ready( function() {
  8630. * $('#example').dataTable( {
  8631. * "order": []
  8632. * } );
  8633. * } );
  8634. */
  8635. "aaSorting": [[0,'asc']],
  8636. /**
  8637. * This parameter is basically identical to the `sorting` parameter, but
  8638. * cannot be overridden by user interaction with the table. What this means
  8639. * is that you could have a column (visible or hidden) which the sorting
  8640. * will always be forced on first - any sorting after that (from the user)
  8641. * will then be performed as required. This can be useful for grouping rows
  8642. * together.
  8643. * @type array
  8644. * @default null
  8645. *
  8646. * @dtopt Option
  8647. * @name DataTable.defaults.orderFixed
  8648. *
  8649. * @example
  8650. * $(document).ready( function() {
  8651. * $('#example').dataTable( {
  8652. * "orderFixed": [[0,'asc']]
  8653. * } );
  8654. * } )
  8655. */
  8656. "aaSortingFixed": [],
  8657. /**
  8658. * DataTables can be instructed to load data to display in the table from a
  8659. * Ajax source. This option defines how that Ajax call is made and where to.
  8660. *
  8661. * The `ajax` property has three different modes of operation, depending on
  8662. * how it is defined. These are:
  8663. *
  8664. * * `string` - Set the URL from where the data should be loaded from.
  8665. * * `object` - Define properties for `jQuery.ajax`.
  8666. * * `function` - Custom data get function
  8667. *
  8668. * `string`
  8669. * --------
  8670. *
  8671. * As a string, the `ajax` property simply defines the URL from which
  8672. * DataTables will load data.
  8673. *
  8674. * `object`
  8675. * --------
  8676. *
  8677. * As an object, the parameters in the object are passed to
  8678. * [jQuery.ajax](http://api.jquery.com/jQuery.ajax/) allowing fine control
  8679. * of the Ajax request. DataTables has a number of default parameters which
  8680. * you can override using this option. Please refer to the jQuery
  8681. * documentation for a full description of the options available, although
  8682. * the following parameters provide additional options in DataTables or
  8683. * require special consideration:
  8684. *
  8685. * * `data` - As with jQuery, `data` can be provided as an object, but it
  8686. * can also be used as a function to manipulate the data DataTables sends
  8687. * to the server. The function takes a single parameter, an object of
  8688. * parameters with the values that DataTables has readied for sending. An
  8689. * object may be returned which will be merged into the DataTables
  8690. * defaults, or you can add the items to the object that was passed in and
  8691. * not return anything from the function. This supersedes `fnServerParams`
  8692. * from DataTables 1.9-.
  8693. *
  8694. * * `dataSrc` - By default DataTables will look for the property `data` (or
  8695. * `aaData` for compatibility with DataTables 1.9-) when obtaining data
  8696. * from an Ajax source or for server-side processing - this parameter
  8697. * allows that property to be changed. You can use Javascript dotted
  8698. * object notation to get a data source for multiple levels of nesting, or
  8699. * it my be used as a function. As a function it takes a single parameter,
  8700. * the JSON returned from the server, which can be manipulated as
  8701. * required, with the returned value being that used by DataTables as the
  8702. * data source for the table. This supersedes `sAjaxDataProp` from
  8703. * DataTables 1.9-.
  8704. *
  8705. * * `success` - Should not be overridden it is used internally in
  8706. * DataTables. To manipulate / transform the data returned by the server
  8707. * use `ajax.dataSrc`, or use `ajax` as a function (see below).
  8708. *
  8709. * `function`
  8710. * ----------
  8711. *
  8712. * As a function, making the Ajax call is left up to yourself allowing
  8713. * complete control of the Ajax request. Indeed, if desired, a method other
  8714. * than Ajax could be used to obtain the required data, such as Web storage
  8715. * or an AIR database.
  8716. *
  8717. * The function is given four parameters and no return is required. The
  8718. * parameters are:
  8719. *
  8720. * 1. _object_ - Data to send to the server
  8721. * 2. _function_ - Callback function that must be executed when the required
  8722. * data has been obtained. That data should be passed into the callback
  8723. * as the only parameter
  8724. * 3. _object_ - DataTables settings object for the table
  8725. *
  8726. * Note that this supersedes `fnServerData` from DataTables 1.9-.
  8727. *
  8728. * @type string|object|function
  8729. * @default null
  8730. *
  8731. * @dtopt Option
  8732. * @name DataTable.defaults.ajax
  8733. * @since 1.10.0
  8734. *
  8735. * @example
  8736. * // Get JSON data from a file via Ajax.
  8737. * // Note DataTables expects data in the form `{ data: [ ...data... ] }` by default).
  8738. * $('#example').dataTable( {
  8739. * "ajax": "data.json"
  8740. * } );
  8741. *
  8742. * @example
  8743. * // Get JSON data from a file via Ajax, using `dataSrc` to change
  8744. * // `data` to `tableData` (i.e. `{ tableData: [ ...data... ] }`)
  8745. * $('#example').dataTable( {
  8746. * "ajax": {
  8747. * "url": "data.json",
  8748. * "dataSrc": "tableData"
  8749. * }
  8750. * } );
  8751. *
  8752. * @example
  8753. * // Get JSON data from a file via Ajax, using `dataSrc` to read data
  8754. * // from a plain array rather than an array in an object
  8755. * $('#example').dataTable( {
  8756. * "ajax": {
  8757. * "url": "data.json",
  8758. * "dataSrc": ""
  8759. * }
  8760. * } );
  8761. *
  8762. * @example
  8763. * // Manipulate the data returned from the server - add a link to data
  8764. * // (note this can, should, be done using `render` for the column - this
  8765. * // is just a simple example of how the data can be manipulated).
  8766. * $('#example').dataTable( {
  8767. * "ajax": {
  8768. * "url": "data.json",
  8769. * "dataSrc": function ( json ) {
  8770. * for ( var i=0, ien=json.length ; i<ien ; i++ ) {
  8771. * json[i][0] = '<a href="/message/'+json[i][0]+'>View message</a>';
  8772. * }
  8773. * return json;
  8774. * }
  8775. * }
  8776. * } );
  8777. *
  8778. * @example
  8779. * // Add data to the request
  8780. * $('#example').dataTable( {
  8781. * "ajax": {
  8782. * "url": "data.json",
  8783. * "data": function ( d ) {
  8784. * return {
  8785. * "extra_search": $('#extra').val()
  8786. * };
  8787. * }
  8788. * }
  8789. * } );
  8790. *
  8791. * @example
  8792. * // Send request as POST
  8793. * $('#example').dataTable( {
  8794. * "ajax": {
  8795. * "url": "data.json",
  8796. * "type": "POST"
  8797. * }
  8798. * } );
  8799. *
  8800. * @example
  8801. * // Get the data from localStorage (could interface with a form for
  8802. * // adding, editing and removing rows).
  8803. * $('#example').dataTable( {
  8804. * "ajax": function (data, callback, settings) {
  8805. * callback(
  8806. * JSON.parse( localStorage.getItem('dataTablesData') )
  8807. * );
  8808. * }
  8809. * } );
  8810. */
  8811. "ajax": null,
  8812. /**
  8813. * This parameter allows you to readily specify the entries in the length drop
  8814. * down menu that DataTables shows when pagination is enabled. It can be
  8815. * either a 1D array of options which will be used for both the displayed
  8816. * option and the value, or a 2D array which will use the array in the first
  8817. * position as the value, and the array in the second position as the
  8818. * displayed options (useful for language strings such as 'All').
  8819. *
  8820. * Note that the `pageLength` property will be automatically set to the
  8821. * first value given in this array, unless `pageLength` is also provided.
  8822. * @type array
  8823. * @default [ 10, 25, 50, 100 ]
  8824. *
  8825. * @dtopt Option
  8826. * @name DataTable.defaults.lengthMenu
  8827. *
  8828. * @example
  8829. * $(document).ready( function() {
  8830. * $('#example').dataTable( {
  8831. * "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
  8832. * } );
  8833. * } );
  8834. */
  8835. "aLengthMenu": [ 10, 25, 50, 100 ],
  8836. /**
  8837. * The `columns` option in the initialisation parameter allows you to define
  8838. * details about the way individual columns behave. For a full list of
  8839. * column options that can be set, please see
  8840. * {@link DataTable.defaults.column}. Note that if you use `columns` to
  8841. * define your columns, you must have an entry in the array for every single
  8842. * column that you have in your table (these can be null if you don't which
  8843. * to specify any options).
  8844. * @member
  8845. *
  8846. * @name DataTable.defaults.column
  8847. */
  8848. "aoColumns": null,
  8849. /**
  8850. * Very similar to `columns`, `columnDefs` allows you to target a specific
  8851. * column, multiple columns, or all columns, using the `targets` property of
  8852. * each object in the array. This allows great flexibility when creating
  8853. * tables, as the `columnDefs` arrays can be of any length, targeting the
  8854. * columns you specifically want. `columnDefs` may use any of the column
  8855. * options available: {@link DataTable.defaults.column}, but it _must_
  8856. * have `targets` defined in each object in the array. Values in the `targets`
  8857. * array may be:
  8858. * <ul>
  8859. * <li>a string - class name will be matched on the TH for the column</li>
  8860. * <li>0 or a positive integer - column index counting from the left</li>
  8861. * <li>a negative integer - column index counting from the right</li>
  8862. * <li>the string "_all" - all columns (i.e. assign a default)</li>
  8863. * </ul>
  8864. * @member
  8865. *
  8866. * @name DataTable.defaults.columnDefs
  8867. */
  8868. "aoColumnDefs": null,
  8869. /**
  8870. * Basically the same as `search`, this parameter defines the individual column
  8871. * filtering state at initialisation time. The array must be of the same size
  8872. * as the number of columns, and each element be an object with the parameters
  8873. * `search` and `escapeRegex` (the latter is optional). 'null' is also
  8874. * accepted and the default will be used.
  8875. * @type array
  8876. * @default []
  8877. *
  8878. * @dtopt Option
  8879. * @name DataTable.defaults.searchCols
  8880. *
  8881. * @example
  8882. * $(document).ready( function() {
  8883. * $('#example').dataTable( {
  8884. * "searchCols": [
  8885. * null,
  8886. * { "search": "My filter" },
  8887. * null,
  8888. * { "search": "^[0-9]", "escapeRegex": false }
  8889. * ]
  8890. * } );
  8891. * } )
  8892. */
  8893. "aoSearchCols": [],
  8894. /**
  8895. * An array of CSS classes that should be applied to displayed rows. This
  8896. * array may be of any length, and DataTables will apply each class
  8897. * sequentially, looping when required.
  8898. * @type array
  8899. * @default null <i>Will take the values determined by the `oClasses.stripe*`
  8900. * options</i>
  8901. *
  8902. * @dtopt Option
  8903. * @name DataTable.defaults.stripeClasses
  8904. *
  8905. * @example
  8906. * $(document).ready( function() {
  8907. * $('#example').dataTable( {
  8908. * "stripeClasses": [ 'strip1', 'strip2', 'strip3' ]
  8909. * } );
  8910. * } )
  8911. */
  8912. "asStripeClasses": null,
  8913. /**
  8914. * Enable or disable automatic column width calculation. This can be disabled
  8915. * as an optimisation (it takes some time to calculate the widths) if the
  8916. * tables widths are passed in using `columns`.
  8917. * @type boolean
  8918. * @default true
  8919. *
  8920. * @dtopt Features
  8921. * @name DataTable.defaults.autoWidth
  8922. *
  8923. * @example
  8924. * $(document).ready( function () {
  8925. * $('#example').dataTable( {
  8926. * "autoWidth": false
  8927. * } );
  8928. * } );
  8929. */
  8930. "bAutoWidth": true,
  8931. /**
  8932. * Deferred rendering can provide DataTables with a huge speed boost when you
  8933. * are using an Ajax or JS data source for the table. This option, when set to
  8934. * true, will cause DataTables to defer the creation of the table elements for
  8935. * each row until they are needed for a draw - saving a significant amount of
  8936. * time.
  8937. * @type boolean
  8938. * @default false
  8939. *
  8940. * @dtopt Features
  8941. * @name DataTable.defaults.deferRender
  8942. *
  8943. * @example
  8944. * $(document).ready( function() {
  8945. * $('#example').dataTable( {
  8946. * "ajax": "sources/arrays.txt",
  8947. * "deferRender": true
  8948. * } );
  8949. * } );
  8950. */
  8951. "bDeferRender": false,
  8952. /**
  8953. * Replace a DataTable which matches the given selector and replace it with
  8954. * one which has the properties of the new initialisation object passed. If no
  8955. * table matches the selector, then the new DataTable will be constructed as
  8956. * per normal.
  8957. * @type boolean
  8958. * @default false
  8959. *
  8960. * @dtopt Options
  8961. * @name DataTable.defaults.destroy
  8962. *
  8963. * @example
  8964. * $(document).ready( function() {
  8965. * $('#example').dataTable( {
  8966. * "srollY": "200px",
  8967. * "paginate": false
  8968. * } );
  8969. *
  8970. * // Some time later....
  8971. * $('#example').dataTable( {
  8972. * "filter": false,
  8973. * "destroy": true
  8974. * } );
  8975. * } );
  8976. */
  8977. "bDestroy": false,
  8978. /**
  8979. * Enable or disable filtering of data. Filtering in DataTables is "smart" in
  8980. * that it allows the end user to input multiple words (space separated) and
  8981. * will match a row containing those words, even if not in the order that was
  8982. * specified (this allow matching across multiple columns). Note that if you
  8983. * wish to use filtering in DataTables this must remain 'true' - to remove the
  8984. * default filtering input box and retain filtering abilities, please use
  8985. * {@link DataTable.defaults.dom}.
  8986. * @type boolean
  8987. * @default true
  8988. *
  8989. * @dtopt Features
  8990. * @name DataTable.defaults.searching
  8991. *
  8992. * @example
  8993. * $(document).ready( function () {
  8994. * $('#example').dataTable( {
  8995. * "searching": false
  8996. * } );
  8997. * } );
  8998. */
  8999. "bFilter": true,
  9000. /**
  9001. * Enable or disable the table information display. This shows information
  9002. * about the data that is currently visible on the page, including information
  9003. * about filtered data if that action is being performed.
  9004. * @type boolean
  9005. * @default true
  9006. *
  9007. * @dtopt Features
  9008. * @name DataTable.defaults.info
  9009. *
  9010. * @example
  9011. * $(document).ready( function () {
  9012. * $('#example').dataTable( {
  9013. * "info": false
  9014. * } );
  9015. * } );
  9016. */
  9017. "bInfo": true,
  9018. /**
  9019. * Allows the end user to select the size of a formatted page from a select
  9020. * menu (sizes are 10, 25, 50 and 100). Requires pagination (`paginate`).
  9021. * @type boolean
  9022. * @default true
  9023. *
  9024. * @dtopt Features
  9025. * @name DataTable.defaults.lengthChange
  9026. *
  9027. * @example
  9028. * $(document).ready( function () {
  9029. * $('#example').dataTable( {
  9030. * "lengthChange": false
  9031. * } );
  9032. * } );
  9033. */
  9034. "bLengthChange": true,
  9035. /**
  9036. * Enable or disable pagination.
  9037. * @type boolean
  9038. * @default true
  9039. *
  9040. * @dtopt Features
  9041. * @name DataTable.defaults.paging
  9042. *
  9043. * @example
  9044. * $(document).ready( function () {
  9045. * $('#example').dataTable( {
  9046. * "paging": false
  9047. * } );
  9048. * } );
  9049. */
  9050. "bPaginate": true,
  9051. /**
  9052. * Enable or disable the display of a 'processing' indicator when the table is
  9053. * being processed (e.g. a sort). This is particularly useful for tables with
  9054. * large amounts of data where it can take a noticeable amount of time to sort
  9055. * the entries.
  9056. * @type boolean
  9057. * @default false
  9058. *
  9059. * @dtopt Features
  9060. * @name DataTable.defaults.processing
  9061. *
  9062. * @example
  9063. * $(document).ready( function () {
  9064. * $('#example').dataTable( {
  9065. * "processing": true
  9066. * } );
  9067. * } );
  9068. */
  9069. "bProcessing": false,
  9070. /**
  9071. * Retrieve the DataTables object for the given selector. Note that if the
  9072. * table has already been initialised, this parameter will cause DataTables
  9073. * to simply return the object that has already been set up - it will not take
  9074. * account of any changes you might have made to the initialisation object
  9075. * passed to DataTables (setting this parameter to true is an acknowledgement
  9076. * that you understand this). `destroy` can be used to reinitialise a table if
  9077. * you need.
  9078. * @type boolean
  9079. * @default false
  9080. *
  9081. * @dtopt Options
  9082. * @name DataTable.defaults.retrieve
  9083. *
  9084. * @example
  9085. * $(document).ready( function() {
  9086. * initTable();
  9087. * tableActions();
  9088. * } );
  9089. *
  9090. * function initTable ()
  9091. * {
  9092. * return $('#example').dataTable( {
  9093. * "scrollY": "200px",
  9094. * "paginate": false,
  9095. * "retrieve": true
  9096. * } );
  9097. * }
  9098. *
  9099. * function tableActions ()
  9100. * {
  9101. * var table = initTable();
  9102. * // perform API operations with oTable
  9103. * }
  9104. */
  9105. "bRetrieve": false,
  9106. /**
  9107. * When vertical (y) scrolling is enabled, DataTables will force the height of
  9108. * the table's viewport to the given height at all times (useful for layout).
  9109. * However, this can look odd when filtering data down to a small data set,
  9110. * and the footer is left "floating" further down. This parameter (when
  9111. * enabled) will cause DataTables to collapse the table's viewport down when
  9112. * the result set will fit within the given Y height.
  9113. * @type boolean
  9114. * @default false
  9115. *
  9116. * @dtopt Options
  9117. * @name DataTable.defaults.scrollCollapse
  9118. *
  9119. * @example
  9120. * $(document).ready( function() {
  9121. * $('#example').dataTable( {
  9122. * "scrollY": "200",
  9123. * "scrollCollapse": true
  9124. * } );
  9125. * } );
  9126. */
  9127. "bScrollCollapse": false,
  9128. /**
  9129. * Configure DataTables to use server-side processing. Note that the
  9130. * `ajax` parameter must also be given in order to give DataTables a
  9131. * source to obtain the required data for each draw.
  9132. * @type boolean
  9133. * @default false
  9134. *
  9135. * @dtopt Features
  9136. * @dtopt Server-side
  9137. * @name DataTable.defaults.serverSide
  9138. *
  9139. * @example
  9140. * $(document).ready( function () {
  9141. * $('#example').dataTable( {
  9142. * "serverSide": true,
  9143. * "ajax": "xhr.php"
  9144. * } );
  9145. * } );
  9146. */
  9147. "bServerSide": false,
  9148. /**
  9149. * Enable or disable sorting of columns. Sorting of individual columns can be
  9150. * disabled by the `sortable` option for each column.
  9151. * @type boolean
  9152. * @default true
  9153. *
  9154. * @dtopt Features
  9155. * @name DataTable.defaults.ordering
  9156. *
  9157. * @example
  9158. * $(document).ready( function () {
  9159. * $('#example').dataTable( {
  9160. * "ordering": false
  9161. * } );
  9162. * } );
  9163. */
  9164. "bSort": true,
  9165. /**
  9166. * Enable or display DataTables' ability to sort multiple columns at the
  9167. * same time (activated by shift-click by the user).
  9168. * @type boolean
  9169. * @default true
  9170. *
  9171. * @dtopt Options
  9172. * @name DataTable.defaults.orderMulti
  9173. *
  9174. * @example
  9175. * // Disable multiple column sorting ability
  9176. * $(document).ready( function () {
  9177. * $('#example').dataTable( {
  9178. * "orderMulti": false
  9179. * } );
  9180. * } );
  9181. */
  9182. "bSortMulti": true,
  9183. /**
  9184. * Allows control over whether DataTables should use the top (true) unique
  9185. * cell that is found for a single column, or the bottom (false - default).
  9186. * This is useful when using complex headers.
  9187. * @type boolean
  9188. * @default false
  9189. *
  9190. * @dtopt Options
  9191. * @name DataTable.defaults.orderCellsTop
  9192. *
  9193. * @example
  9194. * $(document).ready( function() {
  9195. * $('#example').dataTable( {
  9196. * "orderCellsTop": true
  9197. * } );
  9198. * } );
  9199. */
  9200. "bSortCellsTop": false,
  9201. /**
  9202. * Enable or disable the addition of the classes `sorting\_1`, `sorting\_2` and
  9203. * `sorting\_3` to the columns which are currently being sorted on. This is
  9204. * presented as a feature switch as it can increase processing time (while
  9205. * classes are removed and added) so for large data sets you might want to
  9206. * turn this off.
  9207. * @type boolean
  9208. * @default true
  9209. *
  9210. * @dtopt Features
  9211. * @name DataTable.defaults.orderClasses
  9212. *
  9213. * @example
  9214. * $(document).ready( function () {
  9215. * $('#example').dataTable( {
  9216. * "orderClasses": false
  9217. * } );
  9218. * } );
  9219. */
  9220. "bSortClasses": true,
  9221. /**
  9222. * Enable or disable state saving. When enabled HTML5 `localStorage` will be
  9223. * used to save table display information such as pagination information,
  9224. * display length, filtering and sorting. As such when the end user reloads
  9225. * the page the display display will match what thy had previously set up.
  9226. *
  9227. * Due to the use of `localStorage` the default state saving is not supported
  9228. * in IE6 or 7. If state saving is required in those browsers, use
  9229. * `stateSaveCallback` to provide a storage solution such as cookies.
  9230. * @type boolean
  9231. * @default false
  9232. *
  9233. * @dtopt Features
  9234. * @name DataTable.defaults.stateSave
  9235. *
  9236. * @example
  9237. * $(document).ready( function () {
  9238. * $('#example').dataTable( {
  9239. * "stateSave": true
  9240. * } );
  9241. * } );
  9242. */
  9243. "bStateSave": false,
  9244. /**
  9245. * This function is called when a TR element is created (and all TD child
  9246. * elements have been inserted), or registered if using a DOM source, allowing
  9247. * manipulation of the TR element (adding classes etc).
  9248. * @type function
  9249. * @param {node} row "TR" element for the current row
  9250. * @param {array} data Raw data array for this row
  9251. * @param {int} dataIndex The index of this row in the internal aoData array
  9252. *
  9253. * @dtopt Callbacks
  9254. * @name DataTable.defaults.createdRow
  9255. *
  9256. * @example
  9257. * $(document).ready( function() {
  9258. * $('#example').dataTable( {
  9259. * "createdRow": function( row, data, dataIndex ) {
  9260. * // Bold the grade for all 'A' grade browsers
  9261. * if ( data[4] == "A" )
  9262. * {
  9263. * $('td:eq(4)', row).html( '<b>A</b>' );
  9264. * }
  9265. * }
  9266. * } );
  9267. * } );
  9268. */
  9269. "fnCreatedRow": null,
  9270. /**
  9271. * This function is called on every 'draw' event, and allows you to
  9272. * dynamically modify any aspect you want about the created DOM.
  9273. * @type function
  9274. * @param {object} settings DataTables settings object
  9275. *
  9276. * @dtopt Callbacks
  9277. * @name DataTable.defaults.drawCallback
  9278. *
  9279. * @example
  9280. * $(document).ready( function() {
  9281. * $('#example').dataTable( {
  9282. * "drawCallback": function( settings ) {
  9283. * alert( 'DataTables has redrawn the table' );
  9284. * }
  9285. * } );
  9286. * } );
  9287. */
  9288. "fnDrawCallback": null,
  9289. /**
  9290. * Identical to fnHeaderCallback() but for the table footer this function
  9291. * allows you to modify the table footer on every 'draw' event.
  9292. * @type function
  9293. * @param {node} foot "TR" element for the footer
  9294. * @param {array} data Full table data (as derived from the original HTML)
  9295. * @param {int} start Index for the current display starting point in the
  9296. * display array
  9297. * @param {int} end Index for the current display ending point in the
  9298. * display array
  9299. * @param {array int} display Index array to translate the visual position
  9300. * to the full data array
  9301. *
  9302. * @dtopt Callbacks
  9303. * @name DataTable.defaults.footerCallback
  9304. *
  9305. * @example
  9306. * $(document).ready( function() {
  9307. * $('#example').dataTable( {
  9308. * "footerCallback": function( tfoot, data, start, end, display ) {
  9309. * tfoot.getElementsByTagName('th')[0].innerHTML = "Starting index is "+start;
  9310. * }
  9311. * } );
  9312. * } )
  9313. */
  9314. "fnFooterCallback": null,
  9315. /**
  9316. * When rendering large numbers in the information element for the table
  9317. * (i.e. "Showing 1 to 10 of 57 entries") DataTables will render large numbers
  9318. * to have a comma separator for the 'thousands' units (e.g. 1 million is
  9319. * rendered as "1,000,000") to help readability for the end user. This
  9320. * function will override the default method DataTables uses.
  9321. * @type function
  9322. * @member
  9323. * @param {int} toFormat number to be formatted
  9324. * @returns {string} formatted string for DataTables to show the number
  9325. *
  9326. * @dtopt Callbacks
  9327. * @name DataTable.defaults.formatNumber
  9328. *
  9329. * @example
  9330. * // Format a number using a single quote for the separator (note that
  9331. * // this can also be done with the language.thousands option)
  9332. * $(document).ready( function() {
  9333. * $('#example').dataTable( {
  9334. * "formatNumber": function ( toFormat ) {
  9335. * return toFormat.toString().replace(
  9336. * /\B(?=(\d{3})+(?!\d))/g, "'"
  9337. * );
  9338. * };
  9339. * } );
  9340. * } );
  9341. */
  9342. "fnFormatNumber": function ( toFormat ) {
  9343. return toFormat.toString().replace(
  9344. /\B(?=(\d{3})+(?!\d))/g,
  9345. this.oLanguage.sThousands
  9346. );
  9347. },
  9348. /**
  9349. * This function is called on every 'draw' event, and allows you to
  9350. * dynamically modify the header row. This can be used to calculate and
  9351. * display useful information about the table.
  9352. * @type function
  9353. * @param {node} head "TR" element for the header
  9354. * @param {array} data Full table data (as derived from the original HTML)
  9355. * @param {int} start Index for the current display starting point in the
  9356. * display array
  9357. * @param {int} end Index for the current display ending point in the
  9358. * display array
  9359. * @param {array int} display Index array to translate the visual position
  9360. * to the full data array
  9361. *
  9362. * @dtopt Callbacks
  9363. * @name DataTable.defaults.headerCallback
  9364. *
  9365. * @example
  9366. * $(document).ready( function() {
  9367. * $('#example').dataTable( {
  9368. * "fheaderCallback": function( head, data, start, end, display ) {
  9369. * head.getElementsByTagName('th')[0].innerHTML = "Displaying "+(end-start)+" records";
  9370. * }
  9371. * } );
  9372. * } )
  9373. */
  9374. "fnHeaderCallback": null,
  9375. /**
  9376. * The information element can be used to convey information about the current
  9377. * state of the table. Although the internationalisation options presented by
  9378. * DataTables are quite capable of dealing with most customisations, there may
  9379. * be times where you wish to customise the string further. This callback
  9380. * allows you to do exactly that.
  9381. * @type function
  9382. * @param {object} oSettings DataTables settings object
  9383. * @param {int} start Starting position in data for the draw
  9384. * @param {int} end End position in data for the draw
  9385. * @param {int} max Total number of rows in the table (regardless of
  9386. * filtering)
  9387. * @param {int} total Total number of rows in the data set, after filtering
  9388. * @param {string} pre The string that DataTables has formatted using it's
  9389. * own rules
  9390. * @returns {string} The string to be displayed in the information element.
  9391. *
  9392. * @dtopt Callbacks
  9393. * @name DataTable.defaults.infoCallback
  9394. *
  9395. * @example
  9396. * $('#example').dataTable( {
  9397. * "infoCallback": function( settings, start, end, max, total, pre ) {
  9398. * return start +" to "+ end;
  9399. * }
  9400. * } );
  9401. */
  9402. "fnInfoCallback": null,
  9403. /**
  9404. * Called when the table has been initialised. Normally DataTables will
  9405. * initialise sequentially and there will be no need for this function,
  9406. * however, this does not hold true when using external language information
  9407. * since that is obtained using an async XHR call.
  9408. * @type function
  9409. * @param {object} settings DataTables settings object
  9410. * @param {object} json The JSON object request from the server - only
  9411. * present if client-side Ajax sourced data is used
  9412. *
  9413. * @dtopt Callbacks
  9414. * @name DataTable.defaults.initComplete
  9415. *
  9416. * @example
  9417. * $(document).ready( function() {
  9418. * $('#example').dataTable( {
  9419. * "initComplete": function(settings, json) {
  9420. * alert( 'DataTables has finished its initialisation.' );
  9421. * }
  9422. * } );
  9423. * } )
  9424. */
  9425. "fnInitComplete": null,
  9426. /**
  9427. * Called at the very start of each table draw and can be used to cancel the
  9428. * draw by returning false, any other return (including undefined) results in
  9429. * the full draw occurring).
  9430. * @type function
  9431. * @param {object} settings DataTables settings object
  9432. * @returns {boolean} False will cancel the draw, anything else (including no
  9433. * return) will allow it to complete.
  9434. *
  9435. * @dtopt Callbacks
  9436. * @name DataTable.defaults.preDrawCallback
  9437. *
  9438. * @example
  9439. * $(document).ready( function() {
  9440. * $('#example').dataTable( {
  9441. * "preDrawCallback": function( settings ) {
  9442. * if ( $('#test').val() == 1 ) {
  9443. * return false;
  9444. * }
  9445. * }
  9446. * } );
  9447. * } );
  9448. */
  9449. "fnPreDrawCallback": null,
  9450. /**
  9451. * This function allows you to 'post process' each row after it have been
  9452. * generated for each table draw, but before it is rendered on screen. This
  9453. * function might be used for setting the row class name etc.
  9454. * @type function
  9455. * @param {node} row "TR" element for the current row
  9456. * @param {array} data Raw data array for this row
  9457. * @param {int} displayIndex The display index for the current table draw
  9458. * @param {int} displayIndexFull The index of the data in the full list of
  9459. * rows (after filtering)
  9460. *
  9461. * @dtopt Callbacks
  9462. * @name DataTable.defaults.rowCallback
  9463. *
  9464. * @example
  9465. * $(document).ready( function() {
  9466. * $('#example').dataTable( {
  9467. * "rowCallback": function( row, data, displayIndex, displayIndexFull ) {
  9468. * // Bold the grade for all 'A' grade browsers
  9469. * if ( data[4] == "A" ) {
  9470. * $('td:eq(4)', row).html( '<b>A</b>' );
  9471. * }
  9472. * }
  9473. * } );
  9474. * } );
  9475. */
  9476. "fnRowCallback": null,
  9477. /**
  9478. * __Deprecated__ The functionality provided by this parameter has now been
  9479. * superseded by that provided through `ajax`, which should be used instead.
  9480. *
  9481. * This parameter allows you to override the default function which obtains
  9482. * the data from the server so something more suitable for your application.
  9483. * For example you could use POST data, or pull information from a Gears or
  9484. * AIR database.
  9485. * @type function
  9486. * @member
  9487. * @param {string} source HTTP source to obtain the data from (`ajax`)
  9488. * @param {array} data A key/value pair object containing the data to send
  9489. * to the server
  9490. * @param {function} callback to be called on completion of the data get
  9491. * process that will draw the data on the page.
  9492. * @param {object} settings DataTables settings object
  9493. *
  9494. * @dtopt Callbacks
  9495. * @dtopt Server-side
  9496. * @name DataTable.defaults.serverData
  9497. *
  9498. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9499. */
  9500. "fnServerData": null,
  9501. /**
  9502. * __Deprecated__ The functionality provided by this parameter has now been
  9503. * superseded by that provided through `ajax`, which should be used instead.
  9504. *
  9505. * It is often useful to send extra data to the server when making an Ajax
  9506. * request - for example custom filtering information, and this callback
  9507. * function makes it trivial to send extra information to the server. The
  9508. * passed in parameter is the data set that has been constructed by
  9509. * DataTables, and you can add to this or modify it as you require.
  9510. * @type function
  9511. * @param {array} data Data array (array of objects which are name/value
  9512. * pairs) that has been constructed by DataTables and will be sent to the
  9513. * server. In the case of Ajax sourced data with server-side processing
  9514. * this will be an empty array, for server-side processing there will be a
  9515. * significant number of parameters!
  9516. * @returns {undefined} Ensure that you modify the data array passed in,
  9517. * as this is passed by reference.
  9518. *
  9519. * @dtopt Callbacks
  9520. * @dtopt Server-side
  9521. * @name DataTable.defaults.serverParams
  9522. *
  9523. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9524. */
  9525. "fnServerParams": null,
  9526. /**
  9527. * Load the table state. With this function you can define from where, and how, the
  9528. * state of a table is loaded. By default DataTables will load from `localStorage`
  9529. * but you might wish to use a server-side database or cookies.
  9530. * @type function
  9531. * @member
  9532. * @param {object} settings DataTables settings object
  9533. * @param {object} callback Callback that can be executed when done. It
  9534. * should be passed the loaded state object.
  9535. * @return {object} The DataTables state object to be loaded
  9536. *
  9537. * @dtopt Callbacks
  9538. * @name DataTable.defaults.stateLoadCallback
  9539. *
  9540. * @example
  9541. * $(document).ready( function() {
  9542. * $('#example').dataTable( {
  9543. * "stateSave": true,
  9544. * "stateLoadCallback": function (settings, callback) {
  9545. * $.ajax( {
  9546. * "url": "/state_load",
  9547. * "dataType": "json",
  9548. * "success": function (json) {
  9549. * callback( json );
  9550. * }
  9551. * } );
  9552. * }
  9553. * } );
  9554. * } );
  9555. */
  9556. "fnStateLoadCallback": function ( settings ) {
  9557. try {
  9558. return JSON.parse(
  9559. (settings.iStateDuration === -1 ? sessionStorage : localStorage).getItem(
  9560. 'DataTables_'+settings.sInstance+'_'+location.pathname
  9561. )
  9562. );
  9563. } catch (e) {
  9564. return {};
  9565. }
  9566. },
  9567. /**
  9568. * Callback which allows modification of the saved state prior to loading that state.
  9569. * This callback is called when the table is loading state from the stored data, but
  9570. * prior to the settings object being modified by the saved state. Note that for
  9571. * plug-in authors, you should use the `stateLoadParams` event to load parameters for
  9572. * a plug-in.
  9573. * @type function
  9574. * @param {object} settings DataTables settings object
  9575. * @param {object} data The state object that is to be loaded
  9576. *
  9577. * @dtopt Callbacks
  9578. * @name DataTable.defaults.stateLoadParams
  9579. *
  9580. * @example
  9581. * // Remove a saved filter, so filtering is never loaded
  9582. * $(document).ready( function() {
  9583. * $('#example').dataTable( {
  9584. * "stateSave": true,
  9585. * "stateLoadParams": function (settings, data) {
  9586. * data.oSearch.sSearch = "";
  9587. * }
  9588. * } );
  9589. * } );
  9590. *
  9591. * @example
  9592. * // Disallow state loading by returning false
  9593. * $(document).ready( function() {
  9594. * $('#example').dataTable( {
  9595. * "stateSave": true,
  9596. * "stateLoadParams": function (settings, data) {
  9597. * return false;
  9598. * }
  9599. * } );
  9600. * } );
  9601. */
  9602. "fnStateLoadParams": null,
  9603. /**
  9604. * Callback that is called when the state has been loaded from the state saving method
  9605. * and the DataTables settings object has been modified as a result of the loaded state.
  9606. * @type function
  9607. * @param {object} settings DataTables settings object
  9608. * @param {object} data The state object that was loaded
  9609. *
  9610. * @dtopt Callbacks
  9611. * @name DataTable.defaults.stateLoaded
  9612. *
  9613. * @example
  9614. * // Show an alert with the filtering value that was saved
  9615. * $(document).ready( function() {
  9616. * $('#example').dataTable( {
  9617. * "stateSave": true,
  9618. * "stateLoaded": function (settings, data) {
  9619. * alert( 'Saved filter was: '+data.oSearch.sSearch );
  9620. * }
  9621. * } );
  9622. * } );
  9623. */
  9624. "fnStateLoaded": null,
  9625. /**
  9626. * Save the table state. This function allows you to define where and how the state
  9627. * information for the table is stored By default DataTables will use `localStorage`
  9628. * but you might wish to use a server-side database or cookies.
  9629. * @type function
  9630. * @member
  9631. * @param {object} settings DataTables settings object
  9632. * @param {object} data The state object to be saved
  9633. *
  9634. * @dtopt Callbacks
  9635. * @name DataTable.defaults.stateSaveCallback
  9636. *
  9637. * @example
  9638. * $(document).ready( function() {
  9639. * $('#example').dataTable( {
  9640. * "stateSave": true,
  9641. * "stateSaveCallback": function (settings, data) {
  9642. * // Send an Ajax request to the server with the state object
  9643. * $.ajax( {
  9644. * "url": "/state_save",
  9645. * "data": data,
  9646. * "dataType": "json",
  9647. * "method": "POST"
  9648. * "success": function () {}
  9649. * } );
  9650. * }
  9651. * } );
  9652. * } );
  9653. */
  9654. "fnStateSaveCallback": function ( settings, data ) {
  9655. try {
  9656. (settings.iStateDuration === -1 ? sessionStorage : localStorage).setItem(
  9657. 'DataTables_'+settings.sInstance+'_'+location.pathname,
  9658. JSON.stringify( data )
  9659. );
  9660. } catch (e) {}
  9661. },
  9662. /**
  9663. * Callback which allows modification of the state to be saved. Called when the table
  9664. * has changed state a new state save is required. This method allows modification of
  9665. * the state saving object prior to actually doing the save, including addition or
  9666. * other state properties or modification. Note that for plug-in authors, you should
  9667. * use the `stateSaveParams` event to save parameters for a plug-in.
  9668. * @type function
  9669. * @param {object} settings DataTables settings object
  9670. * @param {object} data The state object to be saved
  9671. *
  9672. * @dtopt Callbacks
  9673. * @name DataTable.defaults.stateSaveParams
  9674. *
  9675. * @example
  9676. * // Remove a saved filter, so filtering is never saved
  9677. * $(document).ready( function() {
  9678. * $('#example').dataTable( {
  9679. * "stateSave": true,
  9680. * "stateSaveParams": function (settings, data) {
  9681. * data.oSearch.sSearch = "";
  9682. * }
  9683. * } );
  9684. * } );
  9685. */
  9686. "fnStateSaveParams": null,
  9687. /**
  9688. * Duration for which the saved state information is considered valid. After this period
  9689. * has elapsed the state will be returned to the default.
  9690. * Value is given in seconds.
  9691. * @type int
  9692. * @default 7200 <i>(2 hours)</i>
  9693. *
  9694. * @dtopt Options
  9695. * @name DataTable.defaults.stateDuration
  9696. *
  9697. * @example
  9698. * $(document).ready( function() {
  9699. * $('#example').dataTable( {
  9700. * "stateDuration": 60*60*24; // 1 day
  9701. * } );
  9702. * } )
  9703. */
  9704. "iStateDuration": 7200,
  9705. /**
  9706. * When enabled DataTables will not make a request to the server for the first
  9707. * page draw - rather it will use the data already on the page (no sorting etc
  9708. * will be applied to it), thus saving on an XHR at load time. `deferLoading`
  9709. * is used to indicate that deferred loading is required, but it is also used
  9710. * to tell DataTables how many records there are in the full table (allowing
  9711. * the information element and pagination to be displayed correctly). In the case
  9712. * where a filtering is applied to the table on initial load, this can be
  9713. * indicated by giving the parameter as an array, where the first element is
  9714. * the number of records available after filtering and the second element is the
  9715. * number of records without filtering (allowing the table information element
  9716. * to be shown correctly).
  9717. * @type int | array
  9718. * @default null
  9719. *
  9720. * @dtopt Options
  9721. * @name DataTable.defaults.deferLoading
  9722. *
  9723. * @example
  9724. * // 57 records available in the table, no filtering applied
  9725. * $(document).ready( function() {
  9726. * $('#example').dataTable( {
  9727. * "serverSide": true,
  9728. * "ajax": "scripts/server_processing.php",
  9729. * "deferLoading": 57
  9730. * } );
  9731. * } );
  9732. *
  9733. * @example
  9734. * // 57 records after filtering, 100 without filtering (an initial filter applied)
  9735. * $(document).ready( function() {
  9736. * $('#example').dataTable( {
  9737. * "serverSide": true,
  9738. * "ajax": "scripts/server_processing.php",
  9739. * "deferLoading": [ 57, 100 ],
  9740. * "search": {
  9741. * "search": "my_filter"
  9742. * }
  9743. * } );
  9744. * } );
  9745. */
  9746. "iDeferLoading": null,
  9747. /**
  9748. * Number of rows to display on a single page when using pagination. If
  9749. * feature enabled (`lengthChange`) then the end user will be able to override
  9750. * this to a custom setting using a pop-up menu.
  9751. * @type int
  9752. * @default 10
  9753. *
  9754. * @dtopt Options
  9755. * @name DataTable.defaults.pageLength
  9756. *
  9757. * @example
  9758. * $(document).ready( function() {
  9759. * $('#example').dataTable( {
  9760. * "pageLength": 50
  9761. * } );
  9762. * } )
  9763. */
  9764. "iDisplayLength": 10,
  9765. /**
  9766. * Define the starting point for data display when using DataTables with
  9767. * pagination. Note that this parameter is the number of records, rather than
  9768. * the page number, so if you have 10 records per page and want to start on
  9769. * the third page, it should be "20".
  9770. * @type int
  9771. * @default 0
  9772. *
  9773. * @dtopt Options
  9774. * @name DataTable.defaults.displayStart
  9775. *
  9776. * @example
  9777. * $(document).ready( function() {
  9778. * $('#example').dataTable( {
  9779. * "displayStart": 20
  9780. * } );
  9781. * } )
  9782. */
  9783. "iDisplayStart": 0,
  9784. /**
  9785. * By default DataTables allows keyboard navigation of the table (sorting, paging,
  9786. * and filtering) by adding a `tabindex` attribute to the required elements. This
  9787. * allows you to tab through the controls and press the enter key to activate them.
  9788. * The tabindex is default 0, meaning that the tab follows the flow of the document.
  9789. * You can overrule this using this parameter if you wish. Use a value of -1 to
  9790. * disable built-in keyboard navigation.
  9791. * @type int
  9792. * @default 0
  9793. *
  9794. * @dtopt Options
  9795. * @name DataTable.defaults.tabIndex
  9796. *
  9797. * @example
  9798. * $(document).ready( function() {
  9799. * $('#example').dataTable( {
  9800. * "tabIndex": 1
  9801. * } );
  9802. * } );
  9803. */
  9804. "iTabIndex": 0,
  9805. /**
  9806. * Classes that DataTables assigns to the various components and features
  9807. * that it adds to the HTML table. This allows classes to be configured
  9808. * during initialisation in addition to through the static
  9809. * {@link DataTable.ext.oStdClasses} object).
  9810. * @namespace
  9811. * @name DataTable.defaults.classes
  9812. */
  9813. "oClasses": {},
  9814. /**
  9815. * All strings that DataTables uses in the user interface that it creates
  9816. * are defined in this object, allowing you to modified them individually or
  9817. * completely replace them all as required.
  9818. * @namespace
  9819. * @name DataTable.defaults.language
  9820. */
  9821. "oLanguage": {
  9822. /**
  9823. * Strings that are used for WAI-ARIA labels and controls only (these are not
  9824. * actually visible on the page, but will be read by screenreaders, and thus
  9825. * must be internationalised as well).
  9826. * @namespace
  9827. * @name DataTable.defaults.language.aria
  9828. */
  9829. "oAria": {
  9830. /**
  9831. * ARIA label that is added to the table headers when the column may be
  9832. * sorted ascending by activing the column (click or return when focused).
  9833. * Note that the column header is prefixed to this string.
  9834. * @type string
  9835. * @default : activate to sort column ascending
  9836. *
  9837. * @dtopt Language
  9838. * @name DataTable.defaults.language.aria.sortAscending
  9839. *
  9840. * @example
  9841. * $(document).ready( function() {
  9842. * $('#example').dataTable( {
  9843. * "language": {
  9844. * "aria": {
  9845. * "sortAscending": " - click/return to sort ascending"
  9846. * }
  9847. * }
  9848. * } );
  9849. * } );
  9850. */
  9851. "sSortAscending": ": activate to sort column ascending",
  9852. /**
  9853. * ARIA label that is added to the table headers when the column may be
  9854. * sorted descending by activing the column (click or return when focused).
  9855. * Note that the column header is prefixed to this string.
  9856. * @type string
  9857. * @default : activate to sort column ascending
  9858. *
  9859. * @dtopt Language
  9860. * @name DataTable.defaults.language.aria.sortDescending
  9861. *
  9862. * @example
  9863. * $(document).ready( function() {
  9864. * $('#example').dataTable( {
  9865. * "language": {
  9866. * "aria": {
  9867. * "sortDescending": " - click/return to sort descending"
  9868. * }
  9869. * }
  9870. * } );
  9871. * } );
  9872. */
  9873. "sSortDescending": ": activate to sort column descending"
  9874. },
  9875. /**
  9876. * Pagination string used by DataTables for the built-in pagination
  9877. * control types.
  9878. * @namespace
  9879. * @name DataTable.defaults.language.paginate
  9880. */
  9881. "oPaginate": {
  9882. /**
  9883. * Text to use when using the 'full_numbers' type of pagination for the
  9884. * button to take the user to the first page.
  9885. * @type string
  9886. * @default First
  9887. *
  9888. * @dtopt Language
  9889. * @name DataTable.defaults.language.paginate.first
  9890. *
  9891. * @example
  9892. * $(document).ready( function() {
  9893. * $('#example').dataTable( {
  9894. * "language": {
  9895. * "paginate": {
  9896. * "first": "First page"
  9897. * }
  9898. * }
  9899. * } );
  9900. * } );
  9901. */
  9902. "sFirst": "First",
  9903. /**
  9904. * Text to use when using the 'full_numbers' type of pagination for the
  9905. * button to take the user to the last page.
  9906. * @type string
  9907. * @default Last
  9908. *
  9909. * @dtopt Language
  9910. * @name DataTable.defaults.language.paginate.last
  9911. *
  9912. * @example
  9913. * $(document).ready( function() {
  9914. * $('#example').dataTable( {
  9915. * "language": {
  9916. * "paginate": {
  9917. * "last": "Last page"
  9918. * }
  9919. * }
  9920. * } );
  9921. * } );
  9922. */
  9923. "sLast": "Last",
  9924. /**
  9925. * Text to use for the 'next' pagination button (to take the user to the
  9926. * next page).
  9927. * @type string
  9928. * @default Next
  9929. *
  9930. * @dtopt Language
  9931. * @name DataTable.defaults.language.paginate.next
  9932. *
  9933. * @example
  9934. * $(document).ready( function() {
  9935. * $('#example').dataTable( {
  9936. * "language": {
  9937. * "paginate": {
  9938. * "next": "Next page"
  9939. * }
  9940. * }
  9941. * } );
  9942. * } );
  9943. */
  9944. "sNext": "Next",
  9945. /**
  9946. * Text to use for the 'previous' pagination button (to take the user to
  9947. * the previous page).
  9948. * @type string
  9949. * @default Previous
  9950. *
  9951. * @dtopt Language
  9952. * @name DataTable.defaults.language.paginate.previous
  9953. *
  9954. * @example
  9955. * $(document).ready( function() {
  9956. * $('#example').dataTable( {
  9957. * "language": {
  9958. * "paginate": {
  9959. * "previous": "Previous page"
  9960. * }
  9961. * }
  9962. * } );
  9963. * } );
  9964. */
  9965. "sPrevious": "Previous"
  9966. },
  9967. /**
  9968. * This string is shown in preference to `zeroRecords` when the table is
  9969. * empty of data (regardless of filtering). Note that this is an optional
  9970. * parameter - if it is not given, the value of `zeroRecords` will be used
  9971. * instead (either the default or given value).
  9972. * @type string
  9973. * @default No data available in table
  9974. *
  9975. * @dtopt Language
  9976. * @name DataTable.defaults.language.emptyTable
  9977. *
  9978. * @example
  9979. * $(document).ready( function() {
  9980. * $('#example').dataTable( {
  9981. * "language": {
  9982. * "emptyTable": "No data available in table"
  9983. * }
  9984. * } );
  9985. * } );
  9986. */
  9987. "sEmptyTable": "No data available in table",
  9988. /**
  9989. * This string gives information to the end user about the information
  9990. * that is current on display on the page. The following tokens can be
  9991. * used in the string and will be dynamically replaced as the table
  9992. * display updates. This tokens can be placed anywhere in the string, or
  9993. * removed as needed by the language requires:
  9994. *
  9995. * * `\_START\_` - Display index of the first record on the current page
  9996. * * `\_END\_` - Display index of the last record on the current page
  9997. * * `\_TOTAL\_` - Number of records in the table after filtering
  9998. * * `\_MAX\_` - Number of records in the table without filtering
  9999. * * `\_PAGE\_` - Current page number
  10000. * * `\_PAGES\_` - Total number of pages of data in the table
  10001. *
  10002. * @type string
  10003. * @default Showing _START_ to _END_ of _TOTAL_ entries
  10004. *
  10005. * @dtopt Language
  10006. * @name DataTable.defaults.language.info
  10007. *
  10008. * @example
  10009. * $(document).ready( function() {
  10010. * $('#example').dataTable( {
  10011. * "language": {
  10012. * "info": "Showing page _PAGE_ of _PAGES_"
  10013. * }
  10014. * } );
  10015. * } );
  10016. */
  10017. "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
  10018. /**
  10019. * Display information string for when the table is empty. Typically the
  10020. * format of this string should match `info`.
  10021. * @type string
  10022. * @default Showing 0 to 0 of 0 entries
  10023. *
  10024. * @dtopt Language
  10025. * @name DataTable.defaults.language.infoEmpty
  10026. *
  10027. * @example
  10028. * $(document).ready( function() {
  10029. * $('#example').dataTable( {
  10030. * "language": {
  10031. * "infoEmpty": "No entries to show"
  10032. * }
  10033. * } );
  10034. * } );
  10035. */
  10036. "sInfoEmpty": "Showing 0 to 0 of 0 entries",
  10037. /**
  10038. * When a user filters the information in a table, this string is appended
  10039. * to the information (`info`) to give an idea of how strong the filtering
  10040. * is. The variable _MAX_ is dynamically updated.
  10041. * @type string
  10042. * @default (filtered from _MAX_ total entries)
  10043. *
  10044. * @dtopt Language
  10045. * @name DataTable.defaults.language.infoFiltered
  10046. *
  10047. * @example
  10048. * $(document).ready( function() {
  10049. * $('#example').dataTable( {
  10050. * "language": {
  10051. * "infoFiltered": " - filtering from _MAX_ records"
  10052. * }
  10053. * } );
  10054. * } );
  10055. */
  10056. "sInfoFiltered": "(filtered from _MAX_ total entries)",
  10057. /**
  10058. * If can be useful to append extra information to the info string at times,
  10059. * and this variable does exactly that. This information will be appended to
  10060. * the `info` (`infoEmpty` and `infoFiltered` in whatever combination they are
  10061. * being used) at all times.
  10062. * @type string
  10063. * @default <i>Empty string</i>
  10064. *
  10065. * @dtopt Language
  10066. * @name DataTable.defaults.language.infoPostFix
  10067. *
  10068. * @example
  10069. * $(document).ready( function() {
  10070. * $('#example').dataTable( {
  10071. * "language": {
  10072. * "infoPostFix": "All records shown are derived from real information."
  10073. * }
  10074. * } );
  10075. * } );
  10076. */
  10077. "sInfoPostFix": "",
  10078. /**
  10079. * This decimal place operator is a little different from the other
  10080. * language options since DataTables doesn't output floating point
  10081. * numbers, so it won't ever use this for display of a number. Rather,
  10082. * what this parameter does is modify the sort methods of the table so
  10083. * that numbers which are in a format which has a character other than
  10084. * a period (`.`) as a decimal place will be sorted numerically.
  10085. *
  10086. * Note that numbers with different decimal places cannot be shown in
  10087. * the same table and still be sortable, the table must be consistent.
  10088. * However, multiple different tables on the page can use different
  10089. * decimal place characters.
  10090. * @type string
  10091. * @default
  10092. *
  10093. * @dtopt Language
  10094. * @name DataTable.defaults.language.decimal
  10095. *
  10096. * @example
  10097. * $(document).ready( function() {
  10098. * $('#example').dataTable( {
  10099. * "language": {
  10100. * "decimal": ","
  10101. * "thousands": "."
  10102. * }
  10103. * } );
  10104. * } );
  10105. */
  10106. "sDecimal": "",
  10107. /**
  10108. * DataTables has a build in number formatter (`formatNumber`) which is
  10109. * used to format large numbers that are used in the table information.
  10110. * By default a comma is used, but this can be trivially changed to any
  10111. * character you wish with this parameter.
  10112. * @type string
  10113. * @default ,
  10114. *
  10115. * @dtopt Language
  10116. * @name DataTable.defaults.language.thousands
  10117. *
  10118. * @example
  10119. * $(document).ready( function() {
  10120. * $('#example').dataTable( {
  10121. * "language": {
  10122. * "thousands": "'"
  10123. * }
  10124. * } );
  10125. * } );
  10126. */
  10127. "sThousands": ",",
  10128. /**
  10129. * Detail the action that will be taken when the drop down menu for the
  10130. * pagination length option is changed. The '_MENU_' variable is replaced
  10131. * with a default select list of 10, 25, 50 and 100, and can be replaced
  10132. * with a custom select box if required.
  10133. * @type string
  10134. * @default Show _MENU_ entries
  10135. *
  10136. * @dtopt Language
  10137. * @name DataTable.defaults.language.lengthMenu
  10138. *
  10139. * @example
  10140. * // Language change only
  10141. * $(document).ready( function() {
  10142. * $('#example').dataTable( {
  10143. * "language": {
  10144. * "lengthMenu": "Display _MENU_ records"
  10145. * }
  10146. * } );
  10147. * } );
  10148. *
  10149. * @example
  10150. * // Language and options change
  10151. * $(document).ready( function() {
  10152. * $('#example').dataTable( {
  10153. * "language": {
  10154. * "lengthMenu": 'Display <select>'+
  10155. * '<option value="10">10</option>'+
  10156. * '<option value="20">20</option>'+
  10157. * '<option value="30">30</option>'+
  10158. * '<option value="40">40</option>'+
  10159. * '<option value="50">50</option>'+
  10160. * '<option value="-1">All</option>'+
  10161. * '</select> records'
  10162. * }
  10163. * } );
  10164. * } );
  10165. */
  10166. "sLengthMenu": "Show _MENU_ entries",
  10167. /**
  10168. * When using Ajax sourced data and during the first draw when DataTables is
  10169. * gathering the data, this message is shown in an empty row in the table to
  10170. * indicate to the end user the the data is being loaded. Note that this
  10171. * parameter is not used when loading data by server-side processing, just
  10172. * Ajax sourced data with client-side processing.
  10173. * @type string
  10174. * @default Loading...
  10175. *
  10176. * @dtopt Language
  10177. * @name DataTable.defaults.language.loadingRecords
  10178. *
  10179. * @example
  10180. * $(document).ready( function() {
  10181. * $('#example').dataTable( {
  10182. * "language": {
  10183. * "loadingRecords": "Please wait - loading..."
  10184. * }
  10185. * } );
  10186. * } );
  10187. */
  10188. "sLoadingRecords": "Loading...",
  10189. /**
  10190. * Text which is displayed when the table is processing a user action
  10191. * (usually a sort command or similar).
  10192. * @type string
  10193. * @default Processing...
  10194. *
  10195. * @dtopt Language
  10196. * @name DataTable.defaults.language.processing
  10197. *
  10198. * @example
  10199. * $(document).ready( function() {
  10200. * $('#example').dataTable( {
  10201. * "language": {
  10202. * "processing": "DataTables is currently busy"
  10203. * }
  10204. * } );
  10205. * } );
  10206. */
  10207. "sProcessing": "Processing...",
  10208. /**
  10209. * Details the actions that will be taken when the user types into the
  10210. * filtering input text box. The variable "_INPUT_", if used in the string,
  10211. * is replaced with the HTML text box for the filtering input allowing
  10212. * control over where it appears in the string. If "_INPUT_" is not given
  10213. * then the input box is appended to the string automatically.
  10214. * @type string
  10215. * @default Search:
  10216. *
  10217. * @dtopt Language
  10218. * @name DataTable.defaults.language.search
  10219. *
  10220. * @example
  10221. * // Input text box will be appended at the end automatically
  10222. * $(document).ready( function() {
  10223. * $('#example').dataTable( {
  10224. * "language": {
  10225. * "search": "Filter records:"
  10226. * }
  10227. * } );
  10228. * } );
  10229. *
  10230. * @example
  10231. * // Specify where the filter should appear
  10232. * $(document).ready( function() {
  10233. * $('#example').dataTable( {
  10234. * "language": {
  10235. * "search": "Apply filter _INPUT_ to table"
  10236. * }
  10237. * } );
  10238. * } );
  10239. */
  10240. "sSearch": "Search:",
  10241. /**
  10242. * Assign a `placeholder` attribute to the search `input` element
  10243. * @type string
  10244. * @default
  10245. *
  10246. * @dtopt Language
  10247. * @name DataTable.defaults.language.searchPlaceholder
  10248. */
  10249. "sSearchPlaceholder": "",
  10250. /**
  10251. * All of the language information can be stored in a file on the
  10252. * server-side, which DataTables will look up if this parameter is passed.
  10253. * It must store the URL of the language file, which is in a JSON format,
  10254. * and the object has the same properties as the oLanguage object in the
  10255. * initialiser object (i.e. the above parameters). Please refer to one of
  10256. * the example language files to see how this works in action.
  10257. * @type string
  10258. * @default <i>Empty string - i.e. disabled</i>
  10259. *
  10260. * @dtopt Language
  10261. * @name DataTable.defaults.language.url
  10262. *
  10263. * @example
  10264. * $(document).ready( function() {
  10265. * $('#example').dataTable( {
  10266. * "language": {
  10267. * "url": "http://www.sprymedia.co.uk/dataTables/lang.txt"
  10268. * }
  10269. * } );
  10270. * } );
  10271. */
  10272. "sUrl": "",
  10273. /**
  10274. * Text shown inside the table records when the is no information to be
  10275. * displayed after filtering. `emptyTable` is shown when there is simply no
  10276. * information in the table at all (regardless of filtering).
  10277. * @type string
  10278. * @default No matching records found
  10279. *
  10280. * @dtopt Language
  10281. * @name DataTable.defaults.language.zeroRecords
  10282. *
  10283. * @example
  10284. * $(document).ready( function() {
  10285. * $('#example').dataTable( {
  10286. * "language": {
  10287. * "zeroRecords": "No records to display"
  10288. * }
  10289. * } );
  10290. * } );
  10291. */
  10292. "sZeroRecords": "No matching records found"
  10293. },
  10294. /**
  10295. * This parameter allows you to have define the global filtering state at
  10296. * initialisation time. As an object the `search` parameter must be
  10297. * defined, but all other parameters are optional. When `regex` is true,
  10298. * the search string will be treated as a regular expression, when false
  10299. * (default) it will be treated as a straight string. When `smart`
  10300. * DataTables will use it's smart filtering methods (to word match at
  10301. * any point in the data), when false this will not be done.
  10302. * @namespace
  10303. * @extends DataTable.models.oSearch
  10304. *
  10305. * @dtopt Options
  10306. * @name DataTable.defaults.search
  10307. *
  10308. * @example
  10309. * $(document).ready( function() {
  10310. * $('#example').dataTable( {
  10311. * "search": {"search": "Initial search"}
  10312. * } );
  10313. * } )
  10314. */
  10315. "oSearch": $.extend( {}, DataTable.models.oSearch ),
  10316. /**
  10317. * __Deprecated__ The functionality provided by this parameter has now been
  10318. * superseded by that provided through `ajax`, which should be used instead.
  10319. *
  10320. * By default DataTables will look for the property `data` (or `aaData` for
  10321. * compatibility with DataTables 1.9-) when obtaining data from an Ajax
  10322. * source or for server-side processing - this parameter allows that
  10323. * property to be changed. You can use Javascript dotted object notation to
  10324. * get a data source for multiple levels of nesting.
  10325. * @type string
  10326. * @default data
  10327. *
  10328. * @dtopt Options
  10329. * @dtopt Server-side
  10330. * @name DataTable.defaults.ajaxDataProp
  10331. *
  10332. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10333. */
  10334. "sAjaxDataProp": "data",
  10335. /**
  10336. * __Deprecated__ The functionality provided by this parameter has now been
  10337. * superseded by that provided through `ajax`, which should be used instead.
  10338. *
  10339. * You can instruct DataTables to load data from an external
  10340. * source using this parameter (use aData if you want to pass data in you
  10341. * already have). Simply provide a url a JSON object can be obtained from.
  10342. * @type string
  10343. * @default null
  10344. *
  10345. * @dtopt Options
  10346. * @dtopt Server-side
  10347. * @name DataTable.defaults.ajaxSource
  10348. *
  10349. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10350. */
  10351. "sAjaxSource": null,
  10352. /**
  10353. * This initialisation variable allows you to specify exactly where in the
  10354. * DOM you want DataTables to inject the various controls it adds to the page
  10355. * (for example you might want the pagination controls at the top of the
  10356. * table). DIV elements (with or without a custom class) can also be added to
  10357. * aid styling. The follow syntax is used:
  10358. * <ul>
  10359. * <li>The following options are allowed:
  10360. * <ul>
  10361. * <li>'l' - Length changing</li>
  10362. * <li>'f' - Filtering input</li>
  10363. * <li>'t' - The table!</li>
  10364. * <li>'i' - Information</li>
  10365. * <li>'p' - Pagination</li>
  10366. * <li>'r' - pRocessing</li>
  10367. * </ul>
  10368. * </li>
  10369. * <li>The following constants are allowed:
  10370. * <ul>
  10371. * <li>'H' - jQueryUI theme "header" classes ('fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix')</li>
  10372. * <li>'F' - jQueryUI theme "footer" classes ('fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix')</li>
  10373. * </ul>
  10374. * </li>
  10375. * <li>The following syntax is expected:
  10376. * <ul>
  10377. * <li>'&lt;' and '&gt;' - div elements</li>
  10378. * <li>'&lt;"class" and '&gt;' - div with a class</li>
  10379. * <li>'&lt;"#id" and '&gt;' - div with an ID</li>
  10380. * </ul>
  10381. * </li>
  10382. * <li>Examples:
  10383. * <ul>
  10384. * <li>'&lt;"wrapper"flipt&gt;'</li>
  10385. * <li>'&lt;lf&lt;t&gt;ip&gt;'</li>
  10386. * </ul>
  10387. * </li>
  10388. * </ul>
  10389. * @type string
  10390. * @default lfrtip <i>(when `jQueryUI` is false)</i> <b>or</b>
  10391. * <"H"lfr>t<"F"ip> <i>(when `jQueryUI` is true)</i>
  10392. *
  10393. * @dtopt Options
  10394. * @name DataTable.defaults.dom
  10395. *
  10396. * @example
  10397. * $(document).ready( function() {
  10398. * $('#example').dataTable( {
  10399. * "dom": '&lt;"top"i&gt;rt&lt;"bottom"flp&gt;&lt;"clear"&gt;'
  10400. * } );
  10401. * } );
  10402. */
  10403. "sDom": "lfrtip",
  10404. /**
  10405. * Search delay option. This will throttle full table searches that use the
  10406. * DataTables provided search input element (it does not effect calls to
  10407. * `dt-api search()`, providing a delay before the search is made.
  10408. * @type integer
  10409. * @default 0
  10410. *
  10411. * @dtopt Options
  10412. * @name DataTable.defaults.searchDelay
  10413. *
  10414. * @example
  10415. * $(document).ready( function() {
  10416. * $('#example').dataTable( {
  10417. * "searchDelay": 200
  10418. * } );
  10419. * } )
  10420. */
  10421. "searchDelay": null,
  10422. /**
  10423. * DataTables features six different built-in options for the buttons to
  10424. * display for pagination control:
  10425. *
  10426. * * `numbers` - Page number buttons only
  10427. * * `simple` - 'Previous' and 'Next' buttons only
  10428. * * 'simple_numbers` - 'Previous' and 'Next' buttons, plus page numbers
  10429. * * `full` - 'First', 'Previous', 'Next' and 'Last' buttons
  10430. * * `full_numbers` - 'First', 'Previous', 'Next' and 'Last' buttons, plus page numbers
  10431. * * `first_last_numbers` - 'First' and 'Last' buttons, plus page numbers
  10432. *
  10433. * Further methods can be added using {@link DataTable.ext.oPagination}.
  10434. * @type string
  10435. * @default simple_numbers
  10436. *
  10437. * @dtopt Options
  10438. * @name DataTable.defaults.pagingType
  10439. *
  10440. * @example
  10441. * $(document).ready( function() {
  10442. * $('#example').dataTable( {
  10443. * "pagingType": "full_numbers"
  10444. * } );
  10445. * } )
  10446. */
  10447. "sPaginationType": "simple_numbers",
  10448. /**
  10449. * Enable horizontal scrolling. When a table is too wide to fit into a
  10450. * certain layout, or you have a large number of columns in the table, you
  10451. * can enable x-scrolling to show the table in a viewport, which can be
  10452. * scrolled. This property can be `true` which will allow the table to
  10453. * scroll horizontally when needed, or any CSS unit, or a number (in which
  10454. * case it will be treated as a pixel measurement). Setting as simply `true`
  10455. * is recommended.
  10456. * @type boolean|string
  10457. * @default <i>blank string - i.e. disabled</i>
  10458. *
  10459. * @dtopt Features
  10460. * @name DataTable.defaults.scrollX
  10461. *
  10462. * @example
  10463. * $(document).ready( function() {
  10464. * $('#example').dataTable( {
  10465. * "scrollX": true,
  10466. * "scrollCollapse": true
  10467. * } );
  10468. * } );
  10469. */
  10470. "sScrollX": "",
  10471. /**
  10472. * This property can be used to force a DataTable to use more width than it
  10473. * might otherwise do when x-scrolling is enabled. For example if you have a
  10474. * table which requires to be well spaced, this parameter is useful for
  10475. * "over-sizing" the table, and thus forcing scrolling. This property can by
  10476. * any CSS unit, or a number (in which case it will be treated as a pixel
  10477. * measurement).
  10478. * @type string
  10479. * @default <i>blank string - i.e. disabled</i>
  10480. *
  10481. * @dtopt Options
  10482. * @name DataTable.defaults.scrollXInner
  10483. *
  10484. * @example
  10485. * $(document).ready( function() {
  10486. * $('#example').dataTable( {
  10487. * "scrollX": "100%",
  10488. * "scrollXInner": "110%"
  10489. * } );
  10490. * } );
  10491. */
  10492. "sScrollXInner": "",
  10493. /**
  10494. * Enable vertical scrolling. Vertical scrolling will constrain the DataTable
  10495. * to the given height, and enable scrolling for any data which overflows the
  10496. * current viewport. This can be used as an alternative to paging to display
  10497. * a lot of data in a small area (although paging and scrolling can both be
  10498. * enabled at the same time). This property can be any CSS unit, or a number
  10499. * (in which case it will be treated as a pixel measurement).
  10500. * @type string
  10501. * @default <i>blank string - i.e. disabled</i>
  10502. *
  10503. * @dtopt Features
  10504. * @name DataTable.defaults.scrollY
  10505. *
  10506. * @example
  10507. * $(document).ready( function() {
  10508. * $('#example').dataTable( {
  10509. * "scrollY": "200px",
  10510. * "paginate": false
  10511. * } );
  10512. * } );
  10513. */
  10514. "sScrollY": "",
  10515. /**
  10516. * __Deprecated__ The functionality provided by this parameter has now been
  10517. * superseded by that provided through `ajax`, which should be used instead.
  10518. *
  10519. * Set the HTTP method that is used to make the Ajax call for server-side
  10520. * processing or Ajax sourced data.
  10521. * @type string
  10522. * @default GET
  10523. *
  10524. * @dtopt Options
  10525. * @dtopt Server-side
  10526. * @name DataTable.defaults.serverMethod
  10527. *
  10528. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10529. */
  10530. "sServerMethod": "GET",
  10531. /**
  10532. * DataTables makes use of renderers when displaying HTML elements for
  10533. * a table. These renderers can be added or modified by plug-ins to
  10534. * generate suitable mark-up for a site. For example the Bootstrap
  10535. * integration plug-in for DataTables uses a paging button renderer to
  10536. * display pagination buttons in the mark-up required by Bootstrap.
  10537. *
  10538. * For further information about the renderers available see
  10539. * DataTable.ext.renderer
  10540. * @type string|object
  10541. * @default null
  10542. *
  10543. * @name DataTable.defaults.renderer
  10544. *
  10545. */
  10546. "renderer": null,
  10547. /**
  10548. * Set the data property name that DataTables should use to get a row's id
  10549. * to set as the `id` property in the node.
  10550. * @type string
  10551. * @default DT_RowId
  10552. *
  10553. * @name DataTable.defaults.rowId
  10554. */
  10555. "rowId": "DT_RowId"
  10556. };
  10557. _fnHungarianMap( DataTable.defaults );
  10558. /*
  10559. * Developer note - See note in model.defaults.js about the use of Hungarian
  10560. * notation and camel case.
  10561. */
  10562. /**
  10563. * Column options that can be given to DataTables at initialisation time.
  10564. * @namespace
  10565. */
  10566. DataTable.defaults.column = {
  10567. /**
  10568. * Define which column(s) an order will occur on for this column. This
  10569. * allows a column's ordering to take multiple columns into account when
  10570. * doing a sort or use the data from a different column. For example first
  10571. * name / last name columns make sense to do a multi-column sort over the
  10572. * two columns.
  10573. * @type array|int
  10574. * @default null <i>Takes the value of the column index automatically</i>
  10575. *
  10576. * @name DataTable.defaults.column.orderData
  10577. * @dtopt Columns
  10578. *
  10579. * @example
  10580. * // Using `columnDefs`
  10581. * $(document).ready( function() {
  10582. * $('#example').dataTable( {
  10583. * "columnDefs": [
  10584. * { "orderData": [ 0, 1 ], "targets": [ 0 ] },
  10585. * { "orderData": [ 1, 0 ], "targets": [ 1 ] },
  10586. * { "orderData": 2, "targets": [ 2 ] }
  10587. * ]
  10588. * } );
  10589. * } );
  10590. *
  10591. * @example
  10592. * // Using `columns`
  10593. * $(document).ready( function() {
  10594. * $('#example').dataTable( {
  10595. * "columns": [
  10596. * { "orderData": [ 0, 1 ] },
  10597. * { "orderData": [ 1, 0 ] },
  10598. * { "orderData": 2 },
  10599. * null,
  10600. * null
  10601. * ]
  10602. * } );
  10603. * } );
  10604. */
  10605. "aDataSort": null,
  10606. "iDataSort": -1,
  10607. /**
  10608. * You can control the default ordering direction, and even alter the
  10609. * behaviour of the sort handler (i.e. only allow ascending ordering etc)
  10610. * using this parameter.
  10611. * @type array
  10612. * @default [ 'asc', 'desc' ]
  10613. *
  10614. * @name DataTable.defaults.column.orderSequence
  10615. * @dtopt Columns
  10616. *
  10617. * @example
  10618. * // Using `columnDefs`
  10619. * $(document).ready( function() {
  10620. * $('#example').dataTable( {
  10621. * "columnDefs": [
  10622. * { "orderSequence": [ "asc" ], "targets": [ 1 ] },
  10623. * { "orderSequence": [ "desc", "asc", "asc" ], "targets": [ 2 ] },
  10624. * { "orderSequence": [ "desc" ], "targets": [ 3 ] }
  10625. * ]
  10626. * } );
  10627. * } );
  10628. *
  10629. * @example
  10630. * // Using `columns`
  10631. * $(document).ready( function() {
  10632. * $('#example').dataTable( {
  10633. * "columns": [
  10634. * null,
  10635. * { "orderSequence": [ "asc" ] },
  10636. * { "orderSequence": [ "desc", "asc", "asc" ] },
  10637. * { "orderSequence": [ "desc" ] },
  10638. * null
  10639. * ]
  10640. * } );
  10641. * } );
  10642. */
  10643. "asSorting": [ 'asc', 'desc' ],
  10644. /**
  10645. * Enable or disable filtering on the data in this column.
  10646. * @type boolean
  10647. * @default true
  10648. *
  10649. * @name DataTable.defaults.column.searchable
  10650. * @dtopt Columns
  10651. *
  10652. * @example
  10653. * // Using `columnDefs`
  10654. * $(document).ready( function() {
  10655. * $('#example').dataTable( {
  10656. * "columnDefs": [
  10657. * { "searchable": false, "targets": [ 0 ] }
  10658. * ] } );
  10659. * } );
  10660. *
  10661. * @example
  10662. * // Using `columns`
  10663. * $(document).ready( function() {
  10664. * $('#example').dataTable( {
  10665. * "columns": [
  10666. * { "searchable": false },
  10667. * null,
  10668. * null,
  10669. * null,
  10670. * null
  10671. * ] } );
  10672. * } );
  10673. */
  10674. "bSearchable": true,
  10675. /**
  10676. * Enable or disable ordering on this column.
  10677. * @type boolean
  10678. * @default true
  10679. *
  10680. * @name DataTable.defaults.column.orderable
  10681. * @dtopt Columns
  10682. *
  10683. * @example
  10684. * // Using `columnDefs`
  10685. * $(document).ready( function() {
  10686. * $('#example').dataTable( {
  10687. * "columnDefs": [
  10688. * { "orderable": false, "targets": [ 0 ] }
  10689. * ] } );
  10690. * } );
  10691. *
  10692. * @example
  10693. * // Using `columns`
  10694. * $(document).ready( function() {
  10695. * $('#example').dataTable( {
  10696. * "columns": [
  10697. * { "orderable": false },
  10698. * null,
  10699. * null,
  10700. * null,
  10701. * null
  10702. * ] } );
  10703. * } );
  10704. */
  10705. "bSortable": true,
  10706. /**
  10707. * Enable or disable the display of this column.
  10708. * @type boolean
  10709. * @default true
  10710. *
  10711. * @name DataTable.defaults.column.visible
  10712. * @dtopt Columns
  10713. *
  10714. * @example
  10715. * // Using `columnDefs`
  10716. * $(document).ready( function() {
  10717. * $('#example').dataTable( {
  10718. * "columnDefs": [
  10719. * { "visible": false, "targets": [ 0 ] }
  10720. * ] } );
  10721. * } );
  10722. *
  10723. * @example
  10724. * // Using `columns`
  10725. * $(document).ready( function() {
  10726. * $('#example').dataTable( {
  10727. * "columns": [
  10728. * { "visible": false },
  10729. * null,
  10730. * null,
  10731. * null,
  10732. * null
  10733. * ] } );
  10734. * } );
  10735. */
  10736. "bVisible": true,
  10737. /**
  10738. * Developer definable function that is called whenever a cell is created (Ajax source,
  10739. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  10740. * allowing you to modify the DOM element (add background colour for example) when the
  10741. * element is available.
  10742. * @type function
  10743. * @param {element} td The TD node that has been created
  10744. * @param {*} cellData The Data for the cell
  10745. * @param {array|object} rowData The data for the whole row
  10746. * @param {int} row The row index for the aoData data store
  10747. * @param {int} col The column index for aoColumns
  10748. *
  10749. * @name DataTable.defaults.column.createdCell
  10750. * @dtopt Columns
  10751. *
  10752. * @example
  10753. * $(document).ready( function() {
  10754. * $('#example').dataTable( {
  10755. * "columnDefs": [ {
  10756. * "targets": [3],
  10757. * "createdCell": function (td, cellData, rowData, row, col) {
  10758. * if ( cellData == "1.7" ) {
  10759. * $(td).css('color', 'blue')
  10760. * }
  10761. * }
  10762. * } ]
  10763. * });
  10764. * } );
  10765. */
  10766. "fnCreatedCell": null,
  10767. /**
  10768. * This parameter has been replaced by `data` in DataTables to ensure naming
  10769. * consistency. `dataProp` can still be used, as there is backwards
  10770. * compatibility in DataTables for this option, but it is strongly
  10771. * recommended that you use `data` in preference to `dataProp`.
  10772. * @name DataTable.defaults.column.dataProp
  10773. */
  10774. /**
  10775. * This property can be used to read data from any data source property,
  10776. * including deeply nested objects / properties. `data` can be given in a
  10777. * number of different ways which effect its behaviour:
  10778. *
  10779. * * `integer` - treated as an array index for the data source. This is the
  10780. * default that DataTables uses (incrementally increased for each column).
  10781. * * `string` - read an object property from the data source. There are
  10782. * three 'special' options that can be used in the string to alter how
  10783. * DataTables reads the data from the source object:
  10784. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10785. * Javascript to read from nested objects, so to can the options
  10786. * specified in `data`. For example: `browser.version` or
  10787. * `browser.name`. If your object parameter name contains a period, use
  10788. * `\\` to escape it - i.e. `first\\.name`.
  10789. * * `[]` - Array notation. DataTables can automatically combine data
  10790. * from and array source, joining the data with the characters provided
  10791. * between the two brackets. For example: `name[, ]` would provide a
  10792. * comma-space separated list from the source array. If no characters
  10793. * are provided between the brackets, the original array source is
  10794. * returned.
  10795. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10796. * execute a function of the name given. For example: `browser()` for a
  10797. * simple function on the data source, `browser.version()` for a
  10798. * function in a nested property or even `browser().version` to get an
  10799. * object property if the function called returns an object. Note that
  10800. * function notation is recommended for use in `render` rather than
  10801. * `data` as it is much simpler to use as a renderer.
  10802. * * `null` - use the original data source for the row rather than plucking
  10803. * data directly from it. This action has effects on two other
  10804. * initialisation options:
  10805. * * `defaultContent` - When null is given as the `data` option and
  10806. * `defaultContent` is specified for the column, the value defined by
  10807. * `defaultContent` will be used for the cell.
  10808. * * `render` - When null is used for the `data` option and the `render`
  10809. * option is specified for the column, the whole data source for the
  10810. * row is used for the renderer.
  10811. * * `function` - the function given will be executed whenever DataTables
  10812. * needs to set or get the data for a cell in the column. The function
  10813. * takes three parameters:
  10814. * * Parameters:
  10815. * * `{array|object}` The data source for the row
  10816. * * `{string}` The type call data requested - this will be 'set' when
  10817. * setting data or 'filter', 'display', 'type', 'sort' or undefined
  10818. * when gathering data. Note that when `undefined` is given for the
  10819. * type DataTables expects to get the raw data for the object back<
  10820. * * `{*}` Data to set when the second parameter is 'set'.
  10821. * * Return:
  10822. * * The return value from the function is not required when 'set' is
  10823. * the type of call, but otherwise the return is what will be used
  10824. * for the data requested.
  10825. *
  10826. * Note that `data` is a getter and setter option. If you just require
  10827. * formatting of data for output, you will likely want to use `render` which
  10828. * is simply a getter and thus simpler to use.
  10829. *
  10830. * Note that prior to DataTables 1.9.2 `data` was called `mDataProp`. The
  10831. * name change reflects the flexibility of this property and is consistent
  10832. * with the naming of mRender. If 'mDataProp' is given, then it will still
  10833. * be used by DataTables, as it automatically maps the old name to the new
  10834. * if required.
  10835. *
  10836. * @type string|int|function|null
  10837. * @default null <i>Use automatically calculated column index</i>
  10838. *
  10839. * @name DataTable.defaults.column.data
  10840. * @dtopt Columns
  10841. *
  10842. * @example
  10843. * // Read table data from objects
  10844. * // JSON structure for each row:
  10845. * // {
  10846. * // "engine": {value},
  10847. * // "browser": {value},
  10848. * // "platform": {value},
  10849. * // "version": {value},
  10850. * // "grade": {value}
  10851. * // }
  10852. * $(document).ready( function() {
  10853. * $('#example').dataTable( {
  10854. * "ajaxSource": "sources/objects.txt",
  10855. * "columns": [
  10856. * { "data": "engine" },
  10857. * { "data": "browser" },
  10858. * { "data": "platform" },
  10859. * { "data": "version" },
  10860. * { "data": "grade" }
  10861. * ]
  10862. * } );
  10863. * } );
  10864. *
  10865. * @example
  10866. * // Read information from deeply nested objects
  10867. * // JSON structure for each row:
  10868. * // {
  10869. * // "engine": {value},
  10870. * // "browser": {value},
  10871. * // "platform": {
  10872. * // "inner": {value}
  10873. * // },
  10874. * // "details": [
  10875. * // {value}, {value}
  10876. * // ]
  10877. * // }
  10878. * $(document).ready( function() {
  10879. * $('#example').dataTable( {
  10880. * "ajaxSource": "sources/deep.txt",
  10881. * "columns": [
  10882. * { "data": "engine" },
  10883. * { "data": "browser" },
  10884. * { "data": "platform.inner" },
  10885. * { "data": "details.0" },
  10886. * { "data": "details.1" }
  10887. * ]
  10888. * } );
  10889. * } );
  10890. *
  10891. * @example
  10892. * // Using `data` as a function to provide different information for
  10893. * // sorting, filtering and display. In this case, currency (price)
  10894. * $(document).ready( function() {
  10895. * $('#example').dataTable( {
  10896. * "columnDefs": [ {
  10897. * "targets": [ 0 ],
  10898. * "data": function ( source, type, val ) {
  10899. * if (type === 'set') {
  10900. * source.price = val;
  10901. * // Store the computed display and filter values for efficiency
  10902. * source.price_display = val=="" ? "" : "$"+numberFormat(val);
  10903. * source.price_filter = val=="" ? "" : "$"+numberFormat(val)+" "+val;
  10904. * return;
  10905. * }
  10906. * else if (type === 'display') {
  10907. * return source.price_display;
  10908. * }
  10909. * else if (type === 'filter') {
  10910. * return source.price_filter;
  10911. * }
  10912. * // 'sort', 'type' and undefined all just use the integer
  10913. * return source.price;
  10914. * }
  10915. * } ]
  10916. * } );
  10917. * } );
  10918. *
  10919. * @example
  10920. * // Using default content
  10921. * $(document).ready( function() {
  10922. * $('#example').dataTable( {
  10923. * "columnDefs": [ {
  10924. * "targets": [ 0 ],
  10925. * "data": null,
  10926. * "defaultContent": "Click to edit"
  10927. * } ]
  10928. * } );
  10929. * } );
  10930. *
  10931. * @example
  10932. * // Using array notation - outputting a list from an array
  10933. * $(document).ready( function() {
  10934. * $('#example').dataTable( {
  10935. * "columnDefs": [ {
  10936. * "targets": [ 0 ],
  10937. * "data": "name[, ]"
  10938. * } ]
  10939. * } );
  10940. * } );
  10941. *
  10942. */
  10943. "mData": null,
  10944. /**
  10945. * This property is the rendering partner to `data` and it is suggested that
  10946. * when you want to manipulate data for display (including filtering,
  10947. * sorting etc) without altering the underlying data for the table, use this
  10948. * property. `render` can be considered to be the the read only companion to
  10949. * `data` which is read / write (then as such more complex). Like `data`
  10950. * this option can be given in a number of different ways to effect its
  10951. * behaviour:
  10952. *
  10953. * * `integer` - treated as an array index for the data source. This is the
  10954. * default that DataTables uses (incrementally increased for each column).
  10955. * * `string` - read an object property from the data source. There are
  10956. * three 'special' options that can be used in the string to alter how
  10957. * DataTables reads the data from the source object:
  10958. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10959. * Javascript to read from nested objects, so to can the options
  10960. * specified in `data`. For example: `browser.version` or
  10961. * `browser.name`. If your object parameter name contains a period, use
  10962. * `\\` to escape it - i.e. `first\\.name`.
  10963. * * `[]` - Array notation. DataTables can automatically combine data
  10964. * from and array source, joining the data with the characters provided
  10965. * between the two brackets. For example: `name[, ]` would provide a
  10966. * comma-space separated list from the source array. If no characters
  10967. * are provided between the brackets, the original array source is
  10968. * returned.
  10969. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10970. * execute a function of the name given. For example: `browser()` for a
  10971. * simple function on the data source, `browser.version()` for a
  10972. * function in a nested property or even `browser().version` to get an
  10973. * object property if the function called returns an object.
  10974. * * `object` - use different data for the different data types requested by
  10975. * DataTables ('filter', 'display', 'type' or 'sort'). The property names
  10976. * of the object is the data type the property refers to and the value can
  10977. * defined using an integer, string or function using the same rules as
  10978. * `render` normally does. Note that an `_` option _must_ be specified.
  10979. * This is the default value to use if you haven't specified a value for
  10980. * the data type requested by DataTables.
  10981. * * `function` - the function given will be executed whenever DataTables
  10982. * needs to set or get the data for a cell in the column. The function
  10983. * takes three parameters:
  10984. * * Parameters:
  10985. * * {array|object} The data source for the row (based on `data`)
  10986. * * {string} The type call data requested - this will be 'filter',
  10987. * 'display', 'type' or 'sort'.
  10988. * * {array|object} The full data source for the row (not based on
  10989. * `data`)
  10990. * * Return:
  10991. * * The return value from the function is what will be used for the
  10992. * data requested.
  10993. *
  10994. * @type string|int|function|object|null
  10995. * @default null Use the data source value.
  10996. *
  10997. * @name DataTable.defaults.column.render
  10998. * @dtopt Columns
  10999. *
  11000. * @example
  11001. * // Create a comma separated list from an array of objects
  11002. * $(document).ready( function() {
  11003. * $('#example').dataTable( {
  11004. * "ajaxSource": "sources/deep.txt",
  11005. * "columns": [
  11006. * { "data": "engine" },
  11007. * { "data": "browser" },
  11008. * {
  11009. * "data": "platform",
  11010. * "render": "[, ].name"
  11011. * }
  11012. * ]
  11013. * } );
  11014. * } );
  11015. *
  11016. * @example
  11017. * // Execute a function to obtain data
  11018. * $(document).ready( function() {
  11019. * $('#example').dataTable( {
  11020. * "columnDefs": [ {
  11021. * "targets": [ 0 ],
  11022. * "data": null, // Use the full data source object for the renderer's source
  11023. * "render": "browserName()"
  11024. * } ]
  11025. * } );
  11026. * } );
  11027. *
  11028. * @example
  11029. * // As an object, extracting different data for the different types
  11030. * // This would be used with a data source such as:
  11031. * // { "phone": 5552368, "phone_filter": "5552368 555-2368", "phone_display": "555-2368" }
  11032. * // Here the `phone` integer is used for sorting and type detection, while `phone_filter`
  11033. * // (which has both forms) is used for filtering for if a user inputs either format, while
  11034. * // the formatted phone number is the one that is shown in the table.
  11035. * $(document).ready( function() {
  11036. * $('#example').dataTable( {
  11037. * "columnDefs": [ {
  11038. * "targets": [ 0 ],
  11039. * "data": null, // Use the full data source object for the renderer's source
  11040. * "render": {
  11041. * "_": "phone",
  11042. * "filter": "phone_filter",
  11043. * "display": "phone_display"
  11044. * }
  11045. * } ]
  11046. * } );
  11047. * } );
  11048. *
  11049. * @example
  11050. * // Use as a function to create a link from the data source
  11051. * $(document).ready( function() {
  11052. * $('#example').dataTable( {
  11053. * "columnDefs": [ {
  11054. * "targets": [ 0 ],
  11055. * "data": "download_link",
  11056. * "render": function ( data, type, full ) {
  11057. * return '<a href="'+data+'">Download</a>';
  11058. * }
  11059. * } ]
  11060. * } );
  11061. * } );
  11062. */
  11063. "mRender": null,
  11064. /**
  11065. * Change the cell type created for the column - either TD cells or TH cells. This
  11066. * can be useful as TH cells have semantic meaning in the table body, allowing them
  11067. * to act as a header for a row (you may wish to add scope='row' to the TH elements).
  11068. * @type string
  11069. * @default td
  11070. *
  11071. * @name DataTable.defaults.column.cellType
  11072. * @dtopt Columns
  11073. *
  11074. * @example
  11075. * // Make the first column use TH cells
  11076. * $(document).ready( function() {
  11077. * $('#example').dataTable( {
  11078. * "columnDefs": [ {
  11079. * "targets": [ 0 ],
  11080. * "cellType": "th"
  11081. * } ]
  11082. * } );
  11083. * } );
  11084. */
  11085. "sCellType": "td",
  11086. /**
  11087. * Class to give to each cell in this column.
  11088. * @type string
  11089. * @default <i>Empty string</i>
  11090. *
  11091. * @name DataTable.defaults.column.class
  11092. * @dtopt Columns
  11093. *
  11094. * @example
  11095. * // Using `columnDefs`
  11096. * $(document).ready( function() {
  11097. * $('#example').dataTable( {
  11098. * "columnDefs": [
  11099. * { "class": "my_class", "targets": [ 0 ] }
  11100. * ]
  11101. * } );
  11102. * } );
  11103. *
  11104. * @example
  11105. * // Using `columns`
  11106. * $(document).ready( function() {
  11107. * $('#example').dataTable( {
  11108. * "columns": [
  11109. * { "class": "my_class" },
  11110. * null,
  11111. * null,
  11112. * null,
  11113. * null
  11114. * ]
  11115. * } );
  11116. * } );
  11117. */
  11118. "sClass": "",
  11119. /**
  11120. * When DataTables calculates the column widths to assign to each column,
  11121. * it finds the longest string in each column and then constructs a
  11122. * temporary table and reads the widths from that. The problem with this
  11123. * is that "mmm" is much wider then "iiii", but the latter is a longer
  11124. * string - thus the calculation can go wrong (doing it properly and putting
  11125. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  11126. * a "work around" we provide this option. It will append its value to the
  11127. * text that is found to be the longest string for the column - i.e. padding.
  11128. * Generally you shouldn't need this!
  11129. * @type string
  11130. * @default <i>Empty string<i>
  11131. *
  11132. * @name DataTable.defaults.column.contentPadding
  11133. * @dtopt Columns
  11134. *
  11135. * @example
  11136. * // Using `columns`
  11137. * $(document).ready( function() {
  11138. * $('#example').dataTable( {
  11139. * "columns": [
  11140. * null,
  11141. * null,
  11142. * null,
  11143. * {
  11144. * "contentPadding": "mmm"
  11145. * }
  11146. * ]
  11147. * } );
  11148. * } );
  11149. */
  11150. "sContentPadding": "",
  11151. /**
  11152. * Allows a default value to be given for a column's data, and will be used
  11153. * whenever a null data source is encountered (this can be because `data`
  11154. * is set to null, or because the data source itself is null).
  11155. * @type string
  11156. * @default null
  11157. *
  11158. * @name DataTable.defaults.column.defaultContent
  11159. * @dtopt Columns
  11160. *
  11161. * @example
  11162. * // Using `columnDefs`
  11163. * $(document).ready( function() {
  11164. * $('#example').dataTable( {
  11165. * "columnDefs": [
  11166. * {
  11167. * "data": null,
  11168. * "defaultContent": "Edit",
  11169. * "targets": [ -1 ]
  11170. * }
  11171. * ]
  11172. * } );
  11173. * } );
  11174. *
  11175. * @example
  11176. * // Using `columns`
  11177. * $(document).ready( function() {
  11178. * $('#example').dataTable( {
  11179. * "columns": [
  11180. * null,
  11181. * null,
  11182. * null,
  11183. * {
  11184. * "data": null,
  11185. * "defaultContent": "Edit"
  11186. * }
  11187. * ]
  11188. * } );
  11189. * } );
  11190. */
  11191. "sDefaultContent": null,
  11192. /**
  11193. * This parameter is only used in DataTables' server-side processing. It can
  11194. * be exceptionally useful to know what columns are being displayed on the
  11195. * client side, and to map these to database fields. When defined, the names
  11196. * also allow DataTables to reorder information from the server if it comes
  11197. * back in an unexpected order (i.e. if you switch your columns around on the
  11198. * client-side, your server-side code does not also need updating).
  11199. * @type string
  11200. * @default <i>Empty string</i>
  11201. *
  11202. * @name DataTable.defaults.column.name
  11203. * @dtopt Columns
  11204. *
  11205. * @example
  11206. * // Using `columnDefs`
  11207. * $(document).ready( function() {
  11208. * $('#example').dataTable( {
  11209. * "columnDefs": [
  11210. * { "name": "engine", "targets": [ 0 ] },
  11211. * { "name": "browser", "targets": [ 1 ] },
  11212. * { "name": "platform", "targets": [ 2 ] },
  11213. * { "name": "version", "targets": [ 3 ] },
  11214. * { "name": "grade", "targets": [ 4 ] }
  11215. * ]
  11216. * } );
  11217. * } );
  11218. *
  11219. * @example
  11220. * // Using `columns`
  11221. * $(document).ready( function() {
  11222. * $('#example').dataTable( {
  11223. * "columns": [
  11224. * { "name": "engine" },
  11225. * { "name": "browser" },
  11226. * { "name": "platform" },
  11227. * { "name": "version" },
  11228. * { "name": "grade" }
  11229. * ]
  11230. * } );
  11231. * } );
  11232. */
  11233. "sName": "",
  11234. /**
  11235. * Defines a data source type for the ordering which can be used to read
  11236. * real-time information from the table (updating the internally cached
  11237. * version) prior to ordering. This allows ordering to occur on user
  11238. * editable elements such as form inputs.
  11239. * @type string
  11240. * @default std
  11241. *
  11242. * @name DataTable.defaults.column.orderDataType
  11243. * @dtopt Columns
  11244. *
  11245. * @example
  11246. * // Using `columnDefs`
  11247. * $(document).ready( function() {
  11248. * $('#example').dataTable( {
  11249. * "columnDefs": [
  11250. * { "orderDataType": "dom-text", "targets": [ 2, 3 ] },
  11251. * { "type": "numeric", "targets": [ 3 ] },
  11252. * { "orderDataType": "dom-select", "targets": [ 4 ] },
  11253. * { "orderDataType": "dom-checkbox", "targets": [ 5 ] }
  11254. * ]
  11255. * } );
  11256. * } );
  11257. *
  11258. * @example
  11259. * // Using `columns`
  11260. * $(document).ready( function() {
  11261. * $('#example').dataTable( {
  11262. * "columns": [
  11263. * null,
  11264. * null,
  11265. * { "orderDataType": "dom-text" },
  11266. * { "orderDataType": "dom-text", "type": "numeric" },
  11267. * { "orderDataType": "dom-select" },
  11268. * { "orderDataType": "dom-checkbox" }
  11269. * ]
  11270. * } );
  11271. * } );
  11272. */
  11273. "sSortDataType": "std",
  11274. /**
  11275. * The title of this column.
  11276. * @type string
  11277. * @default null <i>Derived from the 'TH' value for this column in the
  11278. * original HTML table.</i>
  11279. *
  11280. * @name DataTable.defaults.column.title
  11281. * @dtopt Columns
  11282. *
  11283. * @example
  11284. * // Using `columnDefs`
  11285. * $(document).ready( function() {
  11286. * $('#example').dataTable( {
  11287. * "columnDefs": [
  11288. * { "title": "My column title", "targets": [ 0 ] }
  11289. * ]
  11290. * } );
  11291. * } );
  11292. *
  11293. * @example
  11294. * // Using `columns`
  11295. * $(document).ready( function() {
  11296. * $('#example').dataTable( {
  11297. * "columns": [
  11298. * { "title": "My column title" },
  11299. * null,
  11300. * null,
  11301. * null,
  11302. * null
  11303. * ]
  11304. * } );
  11305. * } );
  11306. */
  11307. "sTitle": null,
  11308. /**
  11309. * The type allows you to specify how the data for this column will be
  11310. * ordered. Four types (string, numeric, date and html (which will strip
  11311. * HTML tags before ordering)) are currently available. Note that only date
  11312. * formats understood by Javascript's Date() object will be accepted as type
  11313. * date. For example: "Mar 26, 2008 5:03 PM". May take the values: 'string',
  11314. * 'numeric', 'date' or 'html' (by default). Further types can be adding
  11315. * through plug-ins.
  11316. * @type string
  11317. * @default null <i>Auto-detected from raw data</i>
  11318. *
  11319. * @name DataTable.defaults.column.type
  11320. * @dtopt Columns
  11321. *
  11322. * @example
  11323. * // Using `columnDefs`
  11324. * $(document).ready( function() {
  11325. * $('#example').dataTable( {
  11326. * "columnDefs": [
  11327. * { "type": "html", "targets": [ 0 ] }
  11328. * ]
  11329. * } );
  11330. * } );
  11331. *
  11332. * @example
  11333. * // Using `columns`
  11334. * $(document).ready( function() {
  11335. * $('#example').dataTable( {
  11336. * "columns": [
  11337. * { "type": "html" },
  11338. * null,
  11339. * null,
  11340. * null,
  11341. * null
  11342. * ]
  11343. * } );
  11344. * } );
  11345. */
  11346. "sType": null,
  11347. /**
  11348. * Defining the width of the column, this parameter may take any CSS value
  11349. * (3em, 20px etc). DataTables applies 'smart' widths to columns which have not
  11350. * been given a specific width through this interface ensuring that the table
  11351. * remains readable.
  11352. * @type string
  11353. * @default null <i>Automatic</i>
  11354. *
  11355. * @name DataTable.defaults.column.width
  11356. * @dtopt Columns
  11357. *
  11358. * @example
  11359. * // Using `columnDefs`
  11360. * $(document).ready( function() {
  11361. * $('#example').dataTable( {
  11362. * "columnDefs": [
  11363. * { "width": "20%", "targets": [ 0 ] }
  11364. * ]
  11365. * } );
  11366. * } );
  11367. *
  11368. * @example
  11369. * // Using `columns`
  11370. * $(document).ready( function() {
  11371. * $('#example').dataTable( {
  11372. * "columns": [
  11373. * { "width": "20%" },
  11374. * null,
  11375. * null,
  11376. * null,
  11377. * null
  11378. * ]
  11379. * } );
  11380. * } );
  11381. */
  11382. "sWidth": null
  11383. };
  11384. _fnHungarianMap( DataTable.defaults.column );
  11385. /**
  11386. * DataTables settings object - this holds all the information needed for a
  11387. * given table, including configuration, data and current application of the
  11388. * table options. DataTables does not have a single instance for each DataTable
  11389. * with the settings attached to that instance, but rather instances of the
  11390. * DataTable "class" are created on-the-fly as needed (typically by a
  11391. * $().dataTable() call) and the settings object is then applied to that
  11392. * instance.
  11393. *
  11394. * Note that this object is related to {@link DataTable.defaults} but this
  11395. * one is the internal data store for DataTables's cache of columns. It should
  11396. * NOT be manipulated outside of DataTables. Any configuration should be done
  11397. * through the initialisation options.
  11398. * @namespace
  11399. * @todo Really should attach the settings object to individual instances so we
  11400. * don't need to create new instances on each $().dataTable() call (if the
  11401. * table already exists). It would also save passing oSettings around and
  11402. * into every single function. However, this is a very significant
  11403. * architecture change for DataTables and will almost certainly break
  11404. * backwards compatibility with older installations. This is something that
  11405. * will be done in 2.0.
  11406. */
  11407. DataTable.models.oSettings = {
  11408. /**
  11409. * Primary features of DataTables and their enablement state.
  11410. * @namespace
  11411. */
  11412. "oFeatures": {
  11413. /**
  11414. * Flag to say if DataTables should automatically try to calculate the
  11415. * optimum table and columns widths (true) or not (false).
  11416. * Note that this parameter will be set by the initialisation routine. To
  11417. * set a default use {@link DataTable.defaults}.
  11418. * @type boolean
  11419. */
  11420. "bAutoWidth": null,
  11421. /**
  11422. * Delay the creation of TR and TD elements until they are actually
  11423. * needed by a driven page draw. This can give a significant speed
  11424. * increase for Ajax source and Javascript source data, but makes no
  11425. * difference at all for DOM and server-side processing tables.
  11426. * Note that this parameter will be set by the initialisation routine. To
  11427. * set a default use {@link DataTable.defaults}.
  11428. * @type boolean
  11429. */
  11430. "bDeferRender": null,
  11431. /**
  11432. * Enable filtering on the table or not. Note that if this is disabled
  11433. * then there is no filtering at all on the table, including fnFilter.
  11434. * To just remove the filtering input use sDom and remove the 'f' option.
  11435. * Note that this parameter will be set by the initialisation routine. To
  11436. * set a default use {@link DataTable.defaults}.
  11437. * @type boolean
  11438. */
  11439. "bFilter": null,
  11440. /**
  11441. * Table information element (the 'Showing x of y records' div) enable
  11442. * flag.
  11443. * Note that this parameter will be set by the initialisation routine. To
  11444. * set a default use {@link DataTable.defaults}.
  11445. * @type boolean
  11446. */
  11447. "bInfo": null,
  11448. /**
  11449. * Present a user control allowing the end user to change the page size
  11450. * when pagination is enabled.
  11451. * Note that this parameter will be set by the initialisation routine. To
  11452. * set a default use {@link DataTable.defaults}.
  11453. * @type boolean
  11454. */
  11455. "bLengthChange": null,
  11456. /**
  11457. * Pagination enabled or not. Note that if this is disabled then length
  11458. * changing must also be disabled.
  11459. * Note that this parameter will be set by the initialisation routine. To
  11460. * set a default use {@link DataTable.defaults}.
  11461. * @type boolean
  11462. */
  11463. "bPaginate": null,
  11464. /**
  11465. * Processing indicator enable flag whenever DataTables is enacting a
  11466. * user request - typically an Ajax request for server-side processing.
  11467. * Note that this parameter will be set by the initialisation routine. To
  11468. * set a default use {@link DataTable.defaults}.
  11469. * @type boolean
  11470. */
  11471. "bProcessing": null,
  11472. /**
  11473. * Server-side processing enabled flag - when enabled DataTables will
  11474. * get all data from the server for every draw - there is no filtering,
  11475. * sorting or paging done on the client-side.
  11476. * Note that this parameter will be set by the initialisation routine. To
  11477. * set a default use {@link DataTable.defaults}.
  11478. * @type boolean
  11479. */
  11480. "bServerSide": null,
  11481. /**
  11482. * Sorting enablement flag.
  11483. * Note that this parameter will be set by the initialisation routine. To
  11484. * set a default use {@link DataTable.defaults}.
  11485. * @type boolean
  11486. */
  11487. "bSort": null,
  11488. /**
  11489. * Multi-column sorting
  11490. * Note that this parameter will be set by the initialisation routine. To
  11491. * set a default use {@link DataTable.defaults}.
  11492. * @type boolean
  11493. */
  11494. "bSortMulti": null,
  11495. /**
  11496. * Apply a class to the columns which are being sorted to provide a
  11497. * visual highlight or not. This can slow things down when enabled since
  11498. * there is a lot of DOM interaction.
  11499. * Note that this parameter will be set by the initialisation routine. To
  11500. * set a default use {@link DataTable.defaults}.
  11501. * @type boolean
  11502. */
  11503. "bSortClasses": null,
  11504. /**
  11505. * State saving enablement flag.
  11506. * Note that this parameter will be set by the initialisation routine. To
  11507. * set a default use {@link DataTable.defaults}.
  11508. * @type boolean
  11509. */
  11510. "bStateSave": null
  11511. },
  11512. /**
  11513. * Scrolling settings for a table.
  11514. * @namespace
  11515. */
  11516. "oScroll": {
  11517. /**
  11518. * When the table is shorter in height than sScrollY, collapse the
  11519. * table container down to the height of the table (when true).
  11520. * Note that this parameter will be set by the initialisation routine. To
  11521. * set a default use {@link DataTable.defaults}.
  11522. * @type boolean
  11523. */
  11524. "bCollapse": null,
  11525. /**
  11526. * Width of the scrollbar for the web-browser's platform. Calculated
  11527. * during table initialisation.
  11528. * @type int
  11529. * @default 0
  11530. */
  11531. "iBarWidth": 0,
  11532. /**
  11533. * Viewport width for horizontal scrolling. Horizontal scrolling is
  11534. * disabled if an empty string.
  11535. * Note that this parameter will be set by the initialisation routine. To
  11536. * set a default use {@link DataTable.defaults}.
  11537. * @type string
  11538. */
  11539. "sX": null,
  11540. /**
  11541. * Width to expand the table to when using x-scrolling. Typically you
  11542. * should not need to use this.
  11543. * Note that this parameter will be set by the initialisation routine. To
  11544. * set a default use {@link DataTable.defaults}.
  11545. * @type string
  11546. * @deprecated
  11547. */
  11548. "sXInner": null,
  11549. /**
  11550. * Viewport height for vertical scrolling. Vertical scrolling is disabled
  11551. * if an empty string.
  11552. * Note that this parameter will be set by the initialisation routine. To
  11553. * set a default use {@link DataTable.defaults}.
  11554. * @type string
  11555. */
  11556. "sY": null
  11557. },
  11558. /**
  11559. * Language information for the table.
  11560. * @namespace
  11561. * @extends DataTable.defaults.oLanguage
  11562. */
  11563. "oLanguage": {
  11564. /**
  11565. * Information callback function. See
  11566. * {@link DataTable.defaults.fnInfoCallback}
  11567. * @type function
  11568. * @default null
  11569. */
  11570. "fnInfoCallback": null
  11571. },
  11572. /**
  11573. * Browser support parameters
  11574. * @namespace
  11575. */
  11576. "oBrowser": {
  11577. /**
  11578. * Indicate if the browser incorrectly calculates width:100% inside a
  11579. * scrolling element (IE6/7)
  11580. * @type boolean
  11581. * @default false
  11582. */
  11583. "bScrollOversize": false,
  11584. /**
  11585. * Determine if the vertical scrollbar is on the right or left of the
  11586. * scrolling container - needed for rtl language layout, although not
  11587. * all browsers move the scrollbar (Safari).
  11588. * @type boolean
  11589. * @default false
  11590. */
  11591. "bScrollbarLeft": false,
  11592. /**
  11593. * Flag for if `getBoundingClientRect` is fully supported or not
  11594. * @type boolean
  11595. * @default false
  11596. */
  11597. "bBounding": false,
  11598. /**
  11599. * Browser scrollbar width
  11600. * @type integer
  11601. * @default 0
  11602. */
  11603. "barWidth": 0
  11604. },
  11605. "ajax": null,
  11606. /**
  11607. * Array referencing the nodes which are used for the features. The
  11608. * parameters of this object match what is allowed by sDom - i.e.
  11609. * <ul>
  11610. * <li>'l' - Length changing</li>
  11611. * <li>'f' - Filtering input</li>
  11612. * <li>'t' - The table!</li>
  11613. * <li>'i' - Information</li>
  11614. * <li>'p' - Pagination</li>
  11615. * <li>'r' - pRocessing</li>
  11616. * </ul>
  11617. * @type array
  11618. * @default []
  11619. */
  11620. "aanFeatures": [],
  11621. /**
  11622. * Store data information - see {@link DataTable.models.oRow} for detailed
  11623. * information.
  11624. * @type array
  11625. * @default []
  11626. */
  11627. "aoData": [],
  11628. /**
  11629. * Array of indexes which are in the current display (after filtering etc)
  11630. * @type array
  11631. * @default []
  11632. */
  11633. "aiDisplay": [],
  11634. /**
  11635. * Array of indexes for display - no filtering
  11636. * @type array
  11637. * @default []
  11638. */
  11639. "aiDisplayMaster": [],
  11640. /**
  11641. * Map of row ids to data indexes
  11642. * @type object
  11643. * @default {}
  11644. */
  11645. "aIds": {},
  11646. /**
  11647. * Store information about each column that is in use
  11648. * @type array
  11649. * @default []
  11650. */
  11651. "aoColumns": [],
  11652. /**
  11653. * Store information about the table's header
  11654. * @type array
  11655. * @default []
  11656. */
  11657. "aoHeader": [],
  11658. /**
  11659. * Store information about the table's footer
  11660. * @type array
  11661. * @default []
  11662. */
  11663. "aoFooter": [],
  11664. /**
  11665. * Store the applied global search information in case we want to force a
  11666. * research or compare the old search to a new one.
  11667. * Note that this parameter will be set by the initialisation routine. To
  11668. * set a default use {@link DataTable.defaults}.
  11669. * @namespace
  11670. * @extends DataTable.models.oSearch
  11671. */
  11672. "oPreviousSearch": {},
  11673. /**
  11674. * Store the applied search for each column - see
  11675. * {@link DataTable.models.oSearch} for the format that is used for the
  11676. * filtering information for each column.
  11677. * @type array
  11678. * @default []
  11679. */
  11680. "aoPreSearchCols": [],
  11681. /**
  11682. * Sorting that is applied to the table. Note that the inner arrays are
  11683. * used in the following manner:
  11684. * <ul>
  11685. * <li>Index 0 - column number</li>
  11686. * <li>Index 1 - current sorting direction</li>
  11687. * </ul>
  11688. * Note that this parameter will be set by the initialisation routine. To
  11689. * set a default use {@link DataTable.defaults}.
  11690. * @type array
  11691. * @todo These inner arrays should really be objects
  11692. */
  11693. "aaSorting": null,
  11694. /**
  11695. * Sorting that is always applied to the table (i.e. prefixed in front of
  11696. * aaSorting).
  11697. * Note that this parameter will be set by the initialisation routine. To
  11698. * set a default use {@link DataTable.defaults}.
  11699. * @type array
  11700. * @default []
  11701. */
  11702. "aaSortingFixed": [],
  11703. /**
  11704. * Classes to use for the striping of a table.
  11705. * Note that this parameter will be set by the initialisation routine. To
  11706. * set a default use {@link DataTable.defaults}.
  11707. * @type array
  11708. * @default []
  11709. */
  11710. "asStripeClasses": null,
  11711. /**
  11712. * If restoring a table - we should restore its striping classes as well
  11713. * @type array
  11714. * @default []
  11715. */
  11716. "asDestroyStripes": [],
  11717. /**
  11718. * If restoring a table - we should restore its width
  11719. * @type int
  11720. * @default 0
  11721. */
  11722. "sDestroyWidth": 0,
  11723. /**
  11724. * Callback functions array for every time a row is inserted (i.e. on a draw).
  11725. * @type array
  11726. * @default []
  11727. */
  11728. "aoRowCallback": [],
  11729. /**
  11730. * Callback functions for the header on each draw.
  11731. * @type array
  11732. * @default []
  11733. */
  11734. "aoHeaderCallback": [],
  11735. /**
  11736. * Callback function for the footer on each draw.
  11737. * @type array
  11738. * @default []
  11739. */
  11740. "aoFooterCallback": [],
  11741. /**
  11742. * Array of callback functions for draw callback functions
  11743. * @type array
  11744. * @default []
  11745. */
  11746. "aoDrawCallback": [],
  11747. /**
  11748. * Array of callback functions for row created function
  11749. * @type array
  11750. * @default []
  11751. */
  11752. "aoRowCreatedCallback": [],
  11753. /**
  11754. * Callback functions for just before the table is redrawn. A return of
  11755. * false will be used to cancel the draw.
  11756. * @type array
  11757. * @default []
  11758. */
  11759. "aoPreDrawCallback": [],
  11760. /**
  11761. * Callback functions for when the table has been initialised.
  11762. * @type array
  11763. * @default []
  11764. */
  11765. "aoInitComplete": [],
  11766. /**
  11767. * Callbacks for modifying the settings to be stored for state saving, prior to
  11768. * saving state.
  11769. * @type array
  11770. * @default []
  11771. */
  11772. "aoStateSaveParams": [],
  11773. /**
  11774. * Callbacks for modifying the settings that have been stored for state saving
  11775. * prior to using the stored values to restore the state.
  11776. * @type array
  11777. * @default []
  11778. */
  11779. "aoStateLoadParams": [],
  11780. /**
  11781. * Callbacks for operating on the settings object once the saved state has been
  11782. * loaded
  11783. * @type array
  11784. * @default []
  11785. */
  11786. "aoStateLoaded": [],
  11787. /**
  11788. * Cache the table ID for quick access
  11789. * @type string
  11790. * @default <i>Empty string</i>
  11791. */
  11792. "sTableId": "",
  11793. /**
  11794. * The TABLE node for the main table
  11795. * @type node
  11796. * @default null
  11797. */
  11798. "nTable": null,
  11799. /**
  11800. * Permanent ref to the thead element
  11801. * @type node
  11802. * @default null
  11803. */
  11804. "nTHead": null,
  11805. /**
  11806. * Permanent ref to the tfoot element - if it exists
  11807. * @type node
  11808. * @default null
  11809. */
  11810. "nTFoot": null,
  11811. /**
  11812. * Permanent ref to the tbody element
  11813. * @type node
  11814. * @default null
  11815. */
  11816. "nTBody": null,
  11817. /**
  11818. * Cache the wrapper node (contains all DataTables controlled elements)
  11819. * @type node
  11820. * @default null
  11821. */
  11822. "nTableWrapper": null,
  11823. /**
  11824. * Indicate if when using server-side processing the loading of data
  11825. * should be deferred until the second draw.
  11826. * Note that this parameter will be set by the initialisation routine. To
  11827. * set a default use {@link DataTable.defaults}.
  11828. * @type boolean
  11829. * @default false
  11830. */
  11831. "bDeferLoading": false,
  11832. /**
  11833. * Indicate if all required information has been read in
  11834. * @type boolean
  11835. * @default false
  11836. */
  11837. "bInitialised": false,
  11838. /**
  11839. * Information about open rows. Each object in the array has the parameters
  11840. * 'nTr' and 'nParent'
  11841. * @type array
  11842. * @default []
  11843. */
  11844. "aoOpenRows": [],
  11845. /**
  11846. * Dictate the positioning of DataTables' control elements - see
  11847. * {@link DataTable.model.oInit.sDom}.
  11848. * Note that this parameter will be set by the initialisation routine. To
  11849. * set a default use {@link DataTable.defaults}.
  11850. * @type string
  11851. * @default null
  11852. */
  11853. "sDom": null,
  11854. /**
  11855. * Search delay (in mS)
  11856. * @type integer
  11857. * @default null
  11858. */
  11859. "searchDelay": null,
  11860. /**
  11861. * Which type of pagination should be used.
  11862. * Note that this parameter will be set by the initialisation routine. To
  11863. * set a default use {@link DataTable.defaults}.
  11864. * @type string
  11865. * @default two_button
  11866. */
  11867. "sPaginationType": "two_button",
  11868. /**
  11869. * The state duration (for `stateSave`) in seconds.
  11870. * Note that this parameter will be set by the initialisation routine. To
  11871. * set a default use {@link DataTable.defaults}.
  11872. * @type int
  11873. * @default 0
  11874. */
  11875. "iStateDuration": 0,
  11876. /**
  11877. * Array of callback functions for state saving. Each array element is an
  11878. * object with the following parameters:
  11879. * <ul>
  11880. * <li>function:fn - function to call. Takes two parameters, oSettings
  11881. * and the JSON string to save that has been thus far created. Returns
  11882. * a JSON string to be inserted into a json object
  11883. * (i.e. '"param": [ 0, 1, 2]')</li>
  11884. * <li>string:sName - name of callback</li>
  11885. * </ul>
  11886. * @type array
  11887. * @default []
  11888. */
  11889. "aoStateSave": [],
  11890. /**
  11891. * Array of callback functions for state loading. Each array element is an
  11892. * object with the following parameters:
  11893. * <ul>
  11894. * <li>function:fn - function to call. Takes two parameters, oSettings
  11895. * and the object stored. May return false to cancel state loading</li>
  11896. * <li>string:sName - name of callback</li>
  11897. * </ul>
  11898. * @type array
  11899. * @default []
  11900. */
  11901. "aoStateLoad": [],
  11902. /**
  11903. * State that was saved. Useful for back reference
  11904. * @type object
  11905. * @default null
  11906. */
  11907. "oSavedState": null,
  11908. /**
  11909. * State that was loaded. Useful for back reference
  11910. * @type object
  11911. * @default null
  11912. */
  11913. "oLoadedState": null,
  11914. /**
  11915. * Source url for AJAX data for the table.
  11916. * Note that this parameter will be set by the initialisation routine. To
  11917. * set a default use {@link DataTable.defaults}.
  11918. * @type string
  11919. * @default null
  11920. */
  11921. "sAjaxSource": null,
  11922. /**
  11923. * Property from a given object from which to read the table data from. This
  11924. * can be an empty string (when not server-side processing), in which case
  11925. * it is assumed an an array is given directly.
  11926. * Note that this parameter will be set by the initialisation routine. To
  11927. * set a default use {@link DataTable.defaults}.
  11928. * @type string
  11929. */
  11930. "sAjaxDataProp": null,
  11931. /**
  11932. * The last jQuery XHR object that was used for server-side data gathering.
  11933. * This can be used for working with the XHR information in one of the
  11934. * callbacks
  11935. * @type object
  11936. * @default null
  11937. */
  11938. "jqXHR": null,
  11939. /**
  11940. * JSON returned from the server in the last Ajax request
  11941. * @type object
  11942. * @default undefined
  11943. */
  11944. "json": undefined,
  11945. /**
  11946. * Data submitted as part of the last Ajax request
  11947. * @type object
  11948. * @default undefined
  11949. */
  11950. "oAjaxData": undefined,
  11951. /**
  11952. * Function to get the server-side data.
  11953. * Note that this parameter will be set by the initialisation routine. To
  11954. * set a default use {@link DataTable.defaults}.
  11955. * @type function
  11956. */
  11957. "fnServerData": null,
  11958. /**
  11959. * Functions which are called prior to sending an Ajax request so extra
  11960. * parameters can easily be sent to the server
  11961. * @type array
  11962. * @default []
  11963. */
  11964. "aoServerParams": [],
  11965. /**
  11966. * Send the XHR HTTP method - GET or POST (could be PUT or DELETE if
  11967. * required).
  11968. * Note that this parameter will be set by the initialisation routine. To
  11969. * set a default use {@link DataTable.defaults}.
  11970. * @type string
  11971. */
  11972. "sServerMethod": null,
  11973. /**
  11974. * Format numbers for display.
  11975. * Note that this parameter will be set by the initialisation routine. To
  11976. * set a default use {@link DataTable.defaults}.
  11977. * @type function
  11978. */
  11979. "fnFormatNumber": null,
  11980. /**
  11981. * List of options that can be used for the user selectable length menu.
  11982. * Note that this parameter will be set by the initialisation routine. To
  11983. * set a default use {@link DataTable.defaults}.
  11984. * @type array
  11985. * @default []
  11986. */
  11987. "aLengthMenu": null,
  11988. /**
  11989. * Counter for the draws that the table does. Also used as a tracker for
  11990. * server-side processing
  11991. * @type int
  11992. * @default 0
  11993. */
  11994. "iDraw": 0,
  11995. /**
  11996. * Indicate if a redraw is being done - useful for Ajax
  11997. * @type boolean
  11998. * @default false
  11999. */
  12000. "bDrawing": false,
  12001. /**
  12002. * Draw index (iDraw) of the last error when parsing the returned data
  12003. * @type int
  12004. * @default -1
  12005. */
  12006. "iDrawError": -1,
  12007. /**
  12008. * Paging display length
  12009. * @type int
  12010. * @default 10
  12011. */
  12012. "_iDisplayLength": 10,
  12013. /**
  12014. * Paging start point - aiDisplay index
  12015. * @type int
  12016. * @default 0
  12017. */
  12018. "_iDisplayStart": 0,
  12019. /**
  12020. * Server-side processing - number of records in the result set
  12021. * (i.e. before filtering), Use fnRecordsTotal rather than
  12022. * this property to get the value of the number of records, regardless of
  12023. * the server-side processing setting.
  12024. * @type int
  12025. * @default 0
  12026. * @private
  12027. */
  12028. "_iRecordsTotal": 0,
  12029. /**
  12030. * Server-side processing - number of records in the current display set
  12031. * (i.e. after filtering). Use fnRecordsDisplay rather than
  12032. * this property to get the value of the number of records, regardless of
  12033. * the server-side processing setting.
  12034. * @type boolean
  12035. * @default 0
  12036. * @private
  12037. */
  12038. "_iRecordsDisplay": 0,
  12039. /**
  12040. * The classes to use for the table
  12041. * @type object
  12042. * @default {}
  12043. */
  12044. "oClasses": {},
  12045. /**
  12046. * Flag attached to the settings object so you can check in the draw
  12047. * callback if filtering has been done in the draw. Deprecated in favour of
  12048. * events.
  12049. * @type boolean
  12050. * @default false
  12051. * @deprecated
  12052. */
  12053. "bFiltered": false,
  12054. /**
  12055. * Flag attached to the settings object so you can check in the draw
  12056. * callback if sorting has been done in the draw. Deprecated in favour of
  12057. * events.
  12058. * @type boolean
  12059. * @default false
  12060. * @deprecated
  12061. */
  12062. "bSorted": false,
  12063. /**
  12064. * Indicate that if multiple rows are in the header and there is more than
  12065. * one unique cell per column, if the top one (true) or bottom one (false)
  12066. * should be used for sorting / title by DataTables.
  12067. * Note that this parameter will be set by the initialisation routine. To
  12068. * set a default use {@link DataTable.defaults}.
  12069. * @type boolean
  12070. */
  12071. "bSortCellsTop": null,
  12072. /**
  12073. * Initialisation object that is used for the table
  12074. * @type object
  12075. * @default null
  12076. */
  12077. "oInit": null,
  12078. /**
  12079. * Destroy callback functions - for plug-ins to attach themselves to the
  12080. * destroy so they can clean up markup and events.
  12081. * @type array
  12082. * @default []
  12083. */
  12084. "aoDestroyCallback": [],
  12085. /**
  12086. * Get the number of records in the current record set, before filtering
  12087. * @type function
  12088. */
  12089. "fnRecordsTotal": function ()
  12090. {
  12091. return _fnDataSource( this ) == 'ssp' ?
  12092. this._iRecordsTotal * 1 :
  12093. this.aiDisplayMaster.length;
  12094. },
  12095. /**
  12096. * Get the number of records in the current record set, after filtering
  12097. * @type function
  12098. */
  12099. "fnRecordsDisplay": function ()
  12100. {
  12101. return _fnDataSource( this ) == 'ssp' ?
  12102. this._iRecordsDisplay * 1 :
  12103. this.aiDisplay.length;
  12104. },
  12105. /**
  12106. * Get the display end point - aiDisplay index
  12107. * @type function
  12108. */
  12109. "fnDisplayEnd": function ()
  12110. {
  12111. var
  12112. len = this._iDisplayLength,
  12113. start = this._iDisplayStart,
  12114. calc = start + len,
  12115. records = this.aiDisplay.length,
  12116. features = this.oFeatures,
  12117. paginate = features.bPaginate;
  12118. if ( features.bServerSide ) {
  12119. return paginate === false || len === -1 ?
  12120. start + records :
  12121. Math.min( start+len, this._iRecordsDisplay );
  12122. }
  12123. else {
  12124. return ! paginate || calc>records || len===-1 ?
  12125. records :
  12126. calc;
  12127. }
  12128. },
  12129. /**
  12130. * The DataTables object for this table
  12131. * @type object
  12132. * @default null
  12133. */
  12134. "oInstance": null,
  12135. /**
  12136. * Unique identifier for each instance of the DataTables object. If there
  12137. * is an ID on the table node, then it takes that value, otherwise an
  12138. * incrementing internal counter is used.
  12139. * @type string
  12140. * @default null
  12141. */
  12142. "sInstance": null,
  12143. /**
  12144. * tabindex attribute value that is added to DataTables control elements, allowing
  12145. * keyboard navigation of the table and its controls.
  12146. */
  12147. "iTabIndex": 0,
  12148. /**
  12149. * DIV container for the footer scrolling table if scrolling
  12150. */
  12151. "nScrollHead": null,
  12152. /**
  12153. * DIV container for the footer scrolling table if scrolling
  12154. */
  12155. "nScrollFoot": null,
  12156. /**
  12157. * Last applied sort
  12158. * @type array
  12159. * @default []
  12160. */
  12161. "aLastSort": [],
  12162. /**
  12163. * Stored plug-in instances
  12164. * @type object
  12165. * @default {}
  12166. */
  12167. "oPlugins": {},
  12168. /**
  12169. * Function used to get a row's id from the row's data
  12170. * @type function
  12171. * @default null
  12172. */
  12173. "rowIdFn": null,
  12174. /**
  12175. * Data location where to store a row's id
  12176. * @type string
  12177. * @default null
  12178. */
  12179. "rowId": null
  12180. };
  12181. /**
  12182. * Extension object for DataTables that is used to provide all extension
  12183. * options.
  12184. *
  12185. * Note that the `DataTable.ext` object is available through
  12186. * `jQuery.fn.dataTable.ext` where it may be accessed and manipulated. It is
  12187. * also aliased to `jQuery.fn.dataTableExt` for historic reasons.
  12188. * @namespace
  12189. * @extends DataTable.models.ext
  12190. */
  12191. /**
  12192. * DataTables extensions
  12193. *
  12194. * This namespace acts as a collection area for plug-ins that can be used to
  12195. * extend DataTables capabilities. Indeed many of the build in methods
  12196. * use this method to provide their own capabilities (sorting methods for
  12197. * example).
  12198. *
  12199. * Note that this namespace is aliased to `jQuery.fn.dataTableExt` for legacy
  12200. * reasons
  12201. *
  12202. * @namespace
  12203. */
  12204. DataTable.ext = _ext = {
  12205. /**
  12206. * Buttons. For use with the Buttons extension for DataTables. This is
  12207. * defined here so other extensions can define buttons regardless of load
  12208. * order. It is _not_ used by DataTables core.
  12209. *
  12210. * @type object
  12211. * @default {}
  12212. */
  12213. buttons: {},
  12214. /**
  12215. * Element class names
  12216. *
  12217. * @type object
  12218. * @default {}
  12219. */
  12220. classes: {},
  12221. /**
  12222. * DataTables build type (expanded by the download builder)
  12223. *
  12224. * @type string
  12225. */
  12226. builder: "-source-",
  12227. /**
  12228. * Error reporting.
  12229. *
  12230. * How should DataTables report an error. Can take the value 'alert',
  12231. * 'throw', 'none' or a function.
  12232. *
  12233. * @type string|function
  12234. * @default alert
  12235. */
  12236. errMode: "alert",
  12237. /**
  12238. * Feature plug-ins.
  12239. *
  12240. * This is an array of objects which describe the feature plug-ins that are
  12241. * available to DataTables. These feature plug-ins are then available for
  12242. * use through the `dom` initialisation option.
  12243. *
  12244. * Each feature plug-in is described by an object which must have the
  12245. * following properties:
  12246. *
  12247. * * `fnInit` - function that is used to initialise the plug-in,
  12248. * * `cFeature` - a character so the feature can be enabled by the `dom`
  12249. * instillation option. This is case sensitive.
  12250. *
  12251. * The `fnInit` function has the following input parameters:
  12252. *
  12253. * 1. `{object}` DataTables settings object: see
  12254. * {@link DataTable.models.oSettings}
  12255. *
  12256. * And the following return is expected:
  12257. *
  12258. * * {node|null} The element which contains your feature. Note that the
  12259. * return may also be void if your plug-in does not require to inject any
  12260. * DOM elements into DataTables control (`dom`) - for example this might
  12261. * be useful when developing a plug-in which allows table control via
  12262. * keyboard entry
  12263. *
  12264. * @type array
  12265. *
  12266. * @example
  12267. * $.fn.dataTable.ext.features.push( {
  12268. * "fnInit": function( oSettings ) {
  12269. * return new TableTools( { "oDTSettings": oSettings } );
  12270. * },
  12271. * "cFeature": "T"
  12272. * } );
  12273. */
  12274. feature: [],
  12275. /**
  12276. * Row searching.
  12277. *
  12278. * This method of searching is complimentary to the default type based
  12279. * searching, and a lot more comprehensive as it allows you complete control
  12280. * over the searching logic. Each element in this array is a function
  12281. * (parameters described below) that is called for every row in the table,
  12282. * and your logic decides if it should be included in the searching data set
  12283. * or not.
  12284. *
  12285. * Searching functions have the following input parameters:
  12286. *
  12287. * 1. `{object}` DataTables settings object: see
  12288. * {@link DataTable.models.oSettings}
  12289. * 2. `{array|object}` Data for the row to be processed (same as the
  12290. * original format that was passed in as the data source, or an array
  12291. * from a DOM data source
  12292. * 3. `{int}` Row index ({@link DataTable.models.oSettings.aoData}), which
  12293. * can be useful to retrieve the `TR` element if you need DOM interaction.
  12294. *
  12295. * And the following return is expected:
  12296. *
  12297. * * {boolean} Include the row in the searched result set (true) or not
  12298. * (false)
  12299. *
  12300. * Note that as with the main search ability in DataTables, technically this
  12301. * is "filtering", since it is subtractive. However, for consistency in
  12302. * naming we call it searching here.
  12303. *
  12304. * @type array
  12305. * @default []
  12306. *
  12307. * @example
  12308. * // The following example shows custom search being applied to the
  12309. * // fourth column (i.e. the data[3] index) based on two input values
  12310. * // from the end-user, matching the data in a certain range.
  12311. * $.fn.dataTable.ext.search.push(
  12312. * function( settings, data, dataIndex ) {
  12313. * var min = document.getElementById('min').value * 1;
  12314. * var max = document.getElementById('max').value * 1;
  12315. * var version = data[3] == "-" ? 0 : data[3]*1;
  12316. *
  12317. * if ( min == "" && max == "" ) {
  12318. * return true;
  12319. * }
  12320. * else if ( min == "" && version < max ) {
  12321. * return true;
  12322. * }
  12323. * else if ( min < version && "" == max ) {
  12324. * return true;
  12325. * }
  12326. * else if ( min < version && version < max ) {
  12327. * return true;
  12328. * }
  12329. * return false;
  12330. * }
  12331. * );
  12332. */
  12333. search: [],
  12334. /**
  12335. * Selector extensions
  12336. *
  12337. * The `selector` option can be used to extend the options available for the
  12338. * selector modifier options (`selector-modifier` object data type) that
  12339. * each of the three built in selector types offer (row, column and cell +
  12340. * their plural counterparts). For example the Select extension uses this
  12341. * mechanism to provide an option to select only rows, columns and cells
  12342. * that have been marked as selected by the end user (`{selected: true}`),
  12343. * which can be used in conjunction with the existing built in selector
  12344. * options.
  12345. *
  12346. * Each property is an array to which functions can be pushed. The functions
  12347. * take three attributes:
  12348. *
  12349. * * Settings object for the host table
  12350. * * Options object (`selector-modifier` object type)
  12351. * * Array of selected item indexes
  12352. *
  12353. * The return is an array of the resulting item indexes after the custom
  12354. * selector has been applied.
  12355. *
  12356. * @type object
  12357. */
  12358. selector: {
  12359. cell: [],
  12360. column: [],
  12361. row: []
  12362. },
  12363. /**
  12364. * Internal functions, exposed for used in plug-ins.
  12365. *
  12366. * Please note that you should not need to use the internal methods for
  12367. * anything other than a plug-in (and even then, try to avoid if possible).
  12368. * The internal function may change between releases.
  12369. *
  12370. * @type object
  12371. * @default {}
  12372. */
  12373. internal: {},
  12374. /**
  12375. * Legacy configuration options. Enable and disable legacy options that
  12376. * are available in DataTables.
  12377. *
  12378. * @type object
  12379. */
  12380. legacy: {
  12381. /**
  12382. * Enable / disable DataTables 1.9 compatible server-side processing
  12383. * requests
  12384. *
  12385. * @type boolean
  12386. * @default null
  12387. */
  12388. ajax: null
  12389. },
  12390. /**
  12391. * Pagination plug-in methods.
  12392. *
  12393. * Each entry in this object is a function and defines which buttons should
  12394. * be shown by the pagination rendering method that is used for the table:
  12395. * {@link DataTable.ext.renderer.pageButton}. The renderer addresses how the
  12396. * buttons are displayed in the document, while the functions here tell it
  12397. * what buttons to display. This is done by returning an array of button
  12398. * descriptions (what each button will do).
  12399. *
  12400. * Pagination types (the four built in options and any additional plug-in
  12401. * options defined here) can be used through the `paginationType`
  12402. * initialisation parameter.
  12403. *
  12404. * The functions defined take two parameters:
  12405. *
  12406. * 1. `{int} page` The current page index
  12407. * 2. `{int} pages` The number of pages in the table
  12408. *
  12409. * Each function is expected to return an array where each element of the
  12410. * array can be one of:
  12411. *
  12412. * * `first` - Jump to first page when activated
  12413. * * `last` - Jump to last page when activated
  12414. * * `previous` - Show previous page when activated
  12415. * * `next` - Show next page when activated
  12416. * * `{int}` - Show page of the index given
  12417. * * `{array}` - A nested array containing the above elements to add a
  12418. * containing 'DIV' element (might be useful for styling).
  12419. *
  12420. * Note that DataTables v1.9- used this object slightly differently whereby
  12421. * an object with two functions would be defined for each plug-in. That
  12422. * ability is still supported by DataTables 1.10+ to provide backwards
  12423. * compatibility, but this option of use is now decremented and no longer
  12424. * documented in DataTables 1.10+.
  12425. *
  12426. * @type object
  12427. * @default {}
  12428. *
  12429. * @example
  12430. * // Show previous, next and current page buttons only
  12431. * $.fn.dataTableExt.oPagination.current = function ( page, pages ) {
  12432. * return [ 'previous', page, 'next' ];
  12433. * };
  12434. */
  12435. pager: {},
  12436. renderer: {
  12437. pageButton: {},
  12438. header: {}
  12439. },
  12440. /**
  12441. * Ordering plug-ins - custom data source
  12442. *
  12443. * The extension options for ordering of data available here is complimentary
  12444. * to the default type based ordering that DataTables typically uses. It
  12445. * allows much greater control over the the data that is being used to
  12446. * order a column, but is necessarily therefore more complex.
  12447. *
  12448. * This type of ordering is useful if you want to do ordering based on data
  12449. * live from the DOM (for example the contents of an 'input' element) rather
  12450. * than just the static string that DataTables knows of.
  12451. *
  12452. * The way these plug-ins work is that you create an array of the values you
  12453. * wish to be ordering for the column in question and then return that
  12454. * array. The data in the array much be in the index order of the rows in
  12455. * the table (not the currently ordering order!). Which order data gathering
  12456. * function is run here depends on the `dt-init columns.orderDataType`
  12457. * parameter that is used for the column (if any).
  12458. *
  12459. * The functions defined take two parameters:
  12460. *
  12461. * 1. `{object}` DataTables settings object: see
  12462. * {@link DataTable.models.oSettings}
  12463. * 2. `{int}` Target column index
  12464. *
  12465. * Each function is expected to return an array:
  12466. *
  12467. * * `{array}` Data for the column to be ordering upon
  12468. *
  12469. * @type array
  12470. *
  12471. * @example
  12472. * // Ordering using `input` node values
  12473. * $.fn.dataTable.ext.order['dom-text'] = function ( settings, col )
  12474. * {
  12475. * return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
  12476. * return $('input', td).val();
  12477. * } );
  12478. * }
  12479. */
  12480. order: {},
  12481. /**
  12482. * Type based plug-ins.
  12483. *
  12484. * Each column in DataTables has a type assigned to it, either by automatic
  12485. * detection or by direct assignment using the `type` option for the column.
  12486. * The type of a column will effect how it is ordering and search (plug-ins
  12487. * can also make use of the column type if required).
  12488. *
  12489. * @namespace
  12490. */
  12491. type: {
  12492. /**
  12493. * Type detection functions.
  12494. *
  12495. * The functions defined in this object are used to automatically detect
  12496. * a column's type, making initialisation of DataTables super easy, even
  12497. * when complex data is in the table.
  12498. *
  12499. * The functions defined take two parameters:
  12500. *
  12501. * 1. `{*}` Data from the column cell to be analysed
  12502. * 2. `{settings}` DataTables settings object. This can be used to
  12503. * perform context specific type detection - for example detection
  12504. * based on language settings such as using a comma for a decimal
  12505. * place. Generally speaking the options from the settings will not
  12506. * be required
  12507. *
  12508. * Each function is expected to return:
  12509. *
  12510. * * `{string|null}` Data type detected, or null if unknown (and thus
  12511. * pass it on to the other type detection functions.
  12512. *
  12513. * @type array
  12514. *
  12515. * @example
  12516. * // Currency type detection plug-in:
  12517. * $.fn.dataTable.ext.type.detect.push(
  12518. * function ( data, settings ) {
  12519. * // Check the numeric part
  12520. * if ( ! data.substring(1).match(/[0-9]/) ) {
  12521. * return null;
  12522. * }
  12523. *
  12524. * // Check prefixed by currency
  12525. * if ( data.charAt(0) == '$' || data.charAt(0) == '&pound;' ) {
  12526. * return 'currency';
  12527. * }
  12528. * return null;
  12529. * }
  12530. * );
  12531. */
  12532. detect: [],
  12533. /**
  12534. * Type based search formatting.
  12535. *
  12536. * The type based searching functions can be used to pre-format the
  12537. * data to be search on. For example, it can be used to strip HTML
  12538. * tags or to de-format telephone numbers for numeric only searching.
  12539. *
  12540. * Note that is a search is not defined for a column of a given type,
  12541. * no search formatting will be performed.
  12542. *
  12543. * Pre-processing of searching data plug-ins - When you assign the sType
  12544. * for a column (or have it automatically detected for you by DataTables
  12545. * or a type detection plug-in), you will typically be using this for
  12546. * custom sorting, but it can also be used to provide custom searching
  12547. * by allowing you to pre-processing the data and returning the data in
  12548. * the format that should be searched upon. This is done by adding
  12549. * functions this object with a parameter name which matches the sType
  12550. * for that target column. This is the corollary of <i>afnSortData</i>
  12551. * for searching data.
  12552. *
  12553. * The functions defined take a single parameter:
  12554. *
  12555. * 1. `{*}` Data from the column cell to be prepared for searching
  12556. *
  12557. * Each function is expected to return:
  12558. *
  12559. * * `{string|null}` Formatted string that will be used for the searching.
  12560. *
  12561. * @type object
  12562. * @default {}
  12563. *
  12564. * @example
  12565. * $.fn.dataTable.ext.type.search['title-numeric'] = function ( d ) {
  12566. * return d.replace(/\n/g," ").replace( /<.*?>/g, "" );
  12567. * }
  12568. */
  12569. search: {},
  12570. /**
  12571. * Type based ordering.
  12572. *
  12573. * The column type tells DataTables what ordering to apply to the table
  12574. * when a column is sorted upon. The order for each type that is defined,
  12575. * is defined by the functions available in this object.
  12576. *
  12577. * Each ordering option can be described by three properties added to
  12578. * this object:
  12579. *
  12580. * * `{type}-pre` - Pre-formatting function
  12581. * * `{type}-asc` - Ascending order function
  12582. * * `{type}-desc` - Descending order function
  12583. *
  12584. * All three can be used together, only `{type}-pre` or only
  12585. * `{type}-asc` and `{type}-desc` together. It is generally recommended
  12586. * that only `{type}-pre` is used, as this provides the optimal
  12587. * implementation in terms of speed, although the others are provided
  12588. * for compatibility with existing Javascript sort functions.
  12589. *
  12590. * `{type}-pre`: Functions defined take a single parameter:
  12591. *
  12592. * 1. `{*}` Data from the column cell to be prepared for ordering
  12593. *
  12594. * And return:
  12595. *
  12596. * * `{*}` Data to be sorted upon
  12597. *
  12598. * `{type}-asc` and `{type}-desc`: Functions are typical Javascript sort
  12599. * functions, taking two parameters:
  12600. *
  12601. * 1. `{*}` Data to compare to the second parameter
  12602. * 2. `{*}` Data to compare to the first parameter
  12603. *
  12604. * And returning:
  12605. *
  12606. * * `{*}` Ordering match: <0 if first parameter should be sorted lower
  12607. * than the second parameter, ===0 if the two parameters are equal and
  12608. * >0 if the first parameter should be sorted height than the second
  12609. * parameter.
  12610. *
  12611. * @type object
  12612. * @default {}
  12613. *
  12614. * @example
  12615. * // Numeric ordering of formatted numbers with a pre-formatter
  12616. * $.extend( $.fn.dataTable.ext.type.order, {
  12617. * "string-pre": function(x) {
  12618. * a = (a === "-" || a === "") ? 0 : a.replace( /[^\d\-\.]/g, "" );
  12619. * return parseFloat( a );
  12620. * }
  12621. * } );
  12622. *
  12623. * @example
  12624. * // Case-sensitive string ordering, with no pre-formatting method
  12625. * $.extend( $.fn.dataTable.ext.order, {
  12626. * "string-case-asc": function(x,y) {
  12627. * return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12628. * },
  12629. * "string-case-desc": function(x,y) {
  12630. * return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12631. * }
  12632. * } );
  12633. */
  12634. order: {}
  12635. },
  12636. /**
  12637. * Unique DataTables instance counter
  12638. *
  12639. * @type int
  12640. * @private
  12641. */
  12642. _unique: 0,
  12643. //
  12644. // Depreciated
  12645. // The following properties are retained for backwards compatibility only.
  12646. // The should not be used in new projects and will be removed in a future
  12647. // version
  12648. //
  12649. /**
  12650. * Version check function.
  12651. * @type function
  12652. * @depreciated Since 1.10
  12653. */
  12654. fnVersionCheck: DataTable.fnVersionCheck,
  12655. /**
  12656. * Index for what 'this' index API functions should use
  12657. * @type int
  12658. * @deprecated Since v1.10
  12659. */
  12660. iApiIndex: 0,
  12661. /**
  12662. * jQuery UI class container
  12663. * @type object
  12664. * @deprecated Since v1.10
  12665. */
  12666. oJUIClasses: {},
  12667. /**
  12668. * Software version
  12669. * @type string
  12670. * @deprecated Since v1.10
  12671. */
  12672. sVersion: DataTable.version
  12673. };
  12674. //
  12675. // Backwards compatibility. Alias to pre 1.10 Hungarian notation counter parts
  12676. //
  12677. $.extend( _ext, {
  12678. afnFiltering: _ext.search,
  12679. aTypes: _ext.type.detect,
  12680. ofnSearch: _ext.type.search,
  12681. oSort: _ext.type.order,
  12682. afnSortData: _ext.order,
  12683. aoFeatures: _ext.feature,
  12684. oApi: _ext.internal,
  12685. oStdClasses: _ext.classes,
  12686. oPagination: _ext.pager
  12687. } );
  12688. $.extend( DataTable.ext.classes, {
  12689. "sTable": "dataTable",
  12690. "sNoFooter": "no-footer",
  12691. /* Paging buttons */
  12692. "sPageButton": "paginate_button",
  12693. "sPageButtonActive": "current",
  12694. "sPageButtonDisabled": "disabled",
  12695. /* Striping classes */
  12696. "sStripeOdd": "odd",
  12697. "sStripeEven": "even",
  12698. /* Empty row */
  12699. "sRowEmpty": "dataTables_empty",
  12700. /* Features */
  12701. "sWrapper": "dataTables_wrapper",
  12702. "sFilter": "dataTables_filter",
  12703. "sInfo": "dataTables_info",
  12704. "sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */
  12705. "sLength": "dataTables_length",
  12706. "sProcessing": "dataTables_processing",
  12707. /* Sorting */
  12708. "sSortAsc": "sorting_asc",
  12709. "sSortDesc": "sorting_desc",
  12710. "sSortable": "sorting", /* Sortable in both directions */
  12711. "sSortableAsc": "sorting_desc_disabled",
  12712. "sSortableDesc": "sorting_asc_disabled",
  12713. "sSortableNone": "sorting_disabled",
  12714. "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
  12715. /* Filtering */
  12716. "sFilterInput": "",
  12717. /* Page length */
  12718. "sLengthSelect": "",
  12719. /* Scrolling */
  12720. "sScrollWrapper": "dataTables_scroll",
  12721. "sScrollHead": "dataTables_scrollHead",
  12722. "sScrollHeadInner": "dataTables_scrollHeadInner",
  12723. "sScrollBody": "dataTables_scrollBody",
  12724. "sScrollFoot": "dataTables_scrollFoot",
  12725. "sScrollFootInner": "dataTables_scrollFootInner",
  12726. /* Misc */
  12727. "sHeaderTH": "",
  12728. "sFooterTH": "",
  12729. // Deprecated
  12730. "sSortJUIAsc": "",
  12731. "sSortJUIDesc": "",
  12732. "sSortJUI": "",
  12733. "sSortJUIAscAllowed": "",
  12734. "sSortJUIDescAllowed": "",
  12735. "sSortJUIWrapper": "",
  12736. "sSortIcon": "",
  12737. "sJUIHeader": "",
  12738. "sJUIFooter": ""
  12739. } );
  12740. var extPagination = DataTable.ext.pager;
  12741. function _numbers ( page, pages ) {
  12742. var
  12743. numbers = [],
  12744. buttons = extPagination.numbers_length,
  12745. half = Math.floor( buttons / 2 ),
  12746. i = 1;
  12747. if ( pages <= buttons ) {
  12748. numbers = _range( 0, pages );
  12749. }
  12750. else if ( page <= half ) {
  12751. numbers = _range( 0, buttons-2 );
  12752. numbers.push( 'ellipsis' );
  12753. numbers.push( pages-1 );
  12754. }
  12755. else if ( page >= pages - 1 - half ) {
  12756. numbers = _range( pages-(buttons-2), pages );
  12757. numbers.splice( 0, 0, 'ellipsis' ); // no unshift in ie6
  12758. numbers.splice( 0, 0, 0 );
  12759. }
  12760. else {
  12761. numbers = _range( page-half+2, page+half-1 );
  12762. numbers.push( 'ellipsis' );
  12763. numbers.push( pages-1 );
  12764. numbers.splice( 0, 0, 'ellipsis' );
  12765. numbers.splice( 0, 0, 0 );
  12766. }
  12767. numbers.DT_el = 'span';
  12768. return numbers;
  12769. }
  12770. $.extend( extPagination, {
  12771. simple: function ( page, pages ) {
  12772. return [ 'previous', 'next' ];
  12773. },
  12774. full: function ( page, pages ) {
  12775. return [ 'first', 'previous', 'next', 'last' ];
  12776. },
  12777. numbers: function ( page, pages ) {
  12778. return [ _numbers(page, pages) ];
  12779. },
  12780. simple_numbers: function ( page, pages ) {
  12781. return [ 'previous', _numbers(page, pages), 'next' ];
  12782. },
  12783. full_numbers: function ( page, pages ) {
  12784. return [ 'first', 'previous', _numbers(page, pages), 'next', 'last' ];
  12785. },
  12786. first_last_numbers: function (page, pages) {
  12787. return ['first', _numbers(page, pages), 'last'];
  12788. },
  12789. // For testing and plug-ins to use
  12790. _numbers: _numbers,
  12791. // Number of number buttons (including ellipsis) to show. _Must be odd!_
  12792. numbers_length: 7
  12793. } );
  12794. $.extend( true, DataTable.ext.renderer, {
  12795. pageButton: {
  12796. _: function ( settings, host, idx, buttons, page, pages ) {
  12797. var classes = settings.oClasses;
  12798. var lang = settings.oLanguage.oPaginate;
  12799. var aria = settings.oLanguage.oAria.paginate || {};
  12800. var btnDisplay, btnClass, counter=0;
  12801. var attach = function( container, buttons ) {
  12802. var i, ien, node, button, tabIndex;
  12803. var disabledClass = classes.sPageButtonDisabled;
  12804. var clickHandler = function ( e ) {
  12805. _fnPageChange( settings, e.data.action, true );
  12806. };
  12807. for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
  12808. button = buttons[i];
  12809. if ( Array.isArray( button ) ) {
  12810. var inner = $( '<'+(button.DT_el || 'div')+'/>' )
  12811. .appendTo( container );
  12812. attach( inner, button );
  12813. }
  12814. else {
  12815. btnDisplay = null;
  12816. btnClass = button;
  12817. tabIndex = settings.iTabIndex;
  12818. switch ( button ) {
  12819. case 'ellipsis':
  12820. container.append('<span class="ellipsis">&#x2026;</span>');
  12821. break;
  12822. case 'first':
  12823. btnDisplay = lang.sFirst;
  12824. if ( page === 0 ) {
  12825. tabIndex = -1;
  12826. btnClass += ' ' + disabledClass;
  12827. }
  12828. break;
  12829. case 'previous':
  12830. btnDisplay = lang.sPrevious;
  12831. if ( page === 0 ) {
  12832. tabIndex = -1;
  12833. btnClass += ' ' + disabledClass;
  12834. }
  12835. break;
  12836. case 'next':
  12837. btnDisplay = lang.sNext;
  12838. if ( pages === 0 || page === pages-1 ) {
  12839. tabIndex = -1;
  12840. btnClass += ' ' + disabledClass;
  12841. }
  12842. break;
  12843. case 'last':
  12844. btnDisplay = lang.sLast;
  12845. if ( pages === 0 || page === pages-1 ) {
  12846. tabIndex = -1;
  12847. btnClass += ' ' + disabledClass;
  12848. }
  12849. break;
  12850. default:
  12851. btnDisplay = settings.fnFormatNumber( button + 1 );
  12852. btnClass = page === button ?
  12853. classes.sPageButtonActive : '';
  12854. break;
  12855. }
  12856. if ( btnDisplay !== null ) {
  12857. node = $('<a>', {
  12858. 'class': classes.sPageButton+' '+btnClass,
  12859. 'aria-controls': settings.sTableId,
  12860. 'aria-label': aria[ button ],
  12861. 'data-dt-idx': counter,
  12862. 'tabindex': tabIndex,
  12863. 'id': idx === 0 && typeof button === 'string' ?
  12864. settings.sTableId +'_'+ button :
  12865. null
  12866. } )
  12867. .html( btnDisplay )
  12868. .appendTo( container );
  12869. _fnBindAction(
  12870. node, {action: button}, clickHandler
  12871. );
  12872. counter++;
  12873. }
  12874. }
  12875. }
  12876. };
  12877. // IE9 throws an 'unknown error' if document.activeElement is used
  12878. // inside an iframe or frame. Try / catch the error. Not good for
  12879. // accessibility, but neither are frames.
  12880. var activeEl;
  12881. try {
  12882. // Because this approach is destroying and recreating the paging
  12883. // elements, focus is lost on the select button which is bad for
  12884. // accessibility. So we want to restore focus once the draw has
  12885. // completed
  12886. activeEl = $(host).find(document.activeElement).data('dt-idx');
  12887. }
  12888. catch (e) {}
  12889. attach( $(host).empty(), buttons );
  12890. if ( activeEl !== undefined ) {
  12891. $(host).find( '[data-dt-idx='+activeEl+']' ).trigger('focus');
  12892. }
  12893. }
  12894. }
  12895. } );
  12896. // Built in type detection. See model.ext.aTypes for information about
  12897. // what is required from this methods.
  12898. $.extend( DataTable.ext.type.detect, [
  12899. // Plain numbers - first since V8 detects some plain numbers as dates
  12900. // e.g. Date.parse('55') (but not all, e.g. Date.parse('22')...).
  12901. function ( d, settings )
  12902. {
  12903. var decimal = settings.oLanguage.sDecimal;
  12904. return _isNumber( d, decimal ) ? 'num'+decimal : null;
  12905. },
  12906. // Dates (only those recognised by the browser's Date.parse)
  12907. function ( d, settings )
  12908. {
  12909. // V8 tries _very_ hard to make a string passed into `Date.parse()`
  12910. // valid, so we need to use a regex to restrict date formats. Use a
  12911. // plug-in for anything other than ISO8601 style strings
  12912. if ( d && !(d instanceof Date) && ! _re_date.test(d) ) {
  12913. return null;
  12914. }
  12915. var parsed = Date.parse(d);
  12916. return (parsed !== null && !isNaN(parsed)) || _empty(d) ? 'date' : null;
  12917. },
  12918. // Formatted numbers
  12919. function ( d, settings )
  12920. {
  12921. var decimal = settings.oLanguage.sDecimal;
  12922. return _isNumber( d, decimal, true ) ? 'num-fmt'+decimal : null;
  12923. },
  12924. // HTML numeric
  12925. function ( d, settings )
  12926. {
  12927. var decimal = settings.oLanguage.sDecimal;
  12928. return _htmlNumeric( d, decimal ) ? 'html-num'+decimal : null;
  12929. },
  12930. // HTML numeric, formatted
  12931. function ( d, settings )
  12932. {
  12933. var decimal = settings.oLanguage.sDecimal;
  12934. return _htmlNumeric( d, decimal, true ) ? 'html-num-fmt'+decimal : null;
  12935. },
  12936. // HTML (this is strict checking - there must be html)
  12937. function ( d, settings )
  12938. {
  12939. return _empty( d ) || (typeof d === 'string' && d.indexOf('<') !== -1) ?
  12940. 'html' : null;
  12941. }
  12942. ] );
  12943. // Filter formatting functions. See model.ext.ofnSearch for information about
  12944. // what is required from these methods.
  12945. //
  12946. // Note that additional search methods are added for the html numbers and
  12947. // html formatted numbers by `_addNumericSort()` when we know what the decimal
  12948. // place is
  12949. $.extend( DataTable.ext.type.search, {
  12950. html: function ( data ) {
  12951. return _empty(data) ?
  12952. data :
  12953. typeof data === 'string' ?
  12954. data
  12955. .replace( _re_new_lines, " " )
  12956. .replace( _re_html, "" ) :
  12957. '';
  12958. },
  12959. string: function ( data ) {
  12960. return _empty(data) ?
  12961. data :
  12962. typeof data === 'string' ?
  12963. data.replace( _re_new_lines, " " ) :
  12964. data;
  12965. }
  12966. } );
  12967. var __numericReplace = function ( d, decimalPlace, re1, re2 ) {
  12968. if ( d !== 0 && (!d || d === '-') ) {
  12969. return -Infinity;
  12970. }
  12971. // If a decimal place other than `.` is used, it needs to be given to the
  12972. // function so we can detect it and replace with a `.` which is the only
  12973. // decimal place Javascript recognises - it is not locale aware.
  12974. if ( decimalPlace ) {
  12975. d = _numToDecimal( d, decimalPlace );
  12976. }
  12977. if ( d.replace ) {
  12978. if ( re1 ) {
  12979. d = d.replace( re1, '' );
  12980. }
  12981. if ( re2 ) {
  12982. d = d.replace( re2, '' );
  12983. }
  12984. }
  12985. return d * 1;
  12986. };
  12987. // Add the numeric 'deformatting' functions for sorting and search. This is done
  12988. // in a function to provide an easy ability for the language options to add
  12989. // additional methods if a non-period decimal place is used.
  12990. function _addNumericSort ( decimalPlace ) {
  12991. $.each(
  12992. {
  12993. // Plain numbers
  12994. "num": function ( d ) {
  12995. return __numericReplace( d, decimalPlace );
  12996. },
  12997. // Formatted numbers
  12998. "num-fmt": function ( d ) {
  12999. return __numericReplace( d, decimalPlace, _re_formatted_numeric );
  13000. },
  13001. // HTML numeric
  13002. "html-num": function ( d ) {
  13003. return __numericReplace( d, decimalPlace, _re_html );
  13004. },
  13005. // HTML numeric, formatted
  13006. "html-num-fmt": function ( d ) {
  13007. return __numericReplace( d, decimalPlace, _re_html, _re_formatted_numeric );
  13008. }
  13009. },
  13010. function ( key, fn ) {
  13011. // Add the ordering method
  13012. _ext.type.order[ key+decimalPlace+'-pre' ] = fn;
  13013. // For HTML types add a search formatter that will strip the HTML
  13014. if ( key.match(/^html\-/) ) {
  13015. _ext.type.search[ key+decimalPlace ] = _ext.type.search.html;
  13016. }
  13017. }
  13018. );
  13019. }
  13020. // Default sort methods
  13021. $.extend( _ext.type.order, {
  13022. // Dates
  13023. "date-pre": function ( d ) {
  13024. var ts = Date.parse( d );
  13025. return isNaN(ts) ? -Infinity : ts;
  13026. },
  13027. // html
  13028. "html-pre": function ( a ) {
  13029. return _empty(a) ?
  13030. '' :
  13031. a.replace ?
  13032. a.replace( /<.*?>/g, "" ).toLowerCase() :
  13033. a+'';
  13034. },
  13035. // string
  13036. "string-pre": function ( a ) {
  13037. // This is a little complex, but faster than always calling toString,
  13038. // http://jsperf.com/tostring-v-check
  13039. return _empty(a) ?
  13040. '' :
  13041. typeof a === 'string' ?
  13042. a.toLowerCase() :
  13043. ! a.toString ?
  13044. '' :
  13045. a.toString();
  13046. },
  13047. // string-asc and -desc are retained only for compatibility with the old
  13048. // sort methods
  13049. "string-asc": function ( x, y ) {
  13050. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  13051. },
  13052. "string-desc": function ( x, y ) {
  13053. return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  13054. }
  13055. } );
  13056. // Numeric sorting types - order doesn't matter here
  13057. _addNumericSort( '' );
  13058. $.extend( true, DataTable.ext.renderer, {
  13059. header: {
  13060. _: function ( settings, cell, column, classes ) {
  13061. // No additional mark-up required
  13062. // Attach a sort listener to update on sort - note that using the
  13063. // `DT` namespace will allow the event to be removed automatically
  13064. // on destroy, while the `dt` namespaced event is the one we are
  13065. // listening for
  13066. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  13067. if ( settings !== ctx ) { // need to check this this is the host
  13068. return; // table, not a nested one
  13069. }
  13070. var colIdx = column.idx;
  13071. cell
  13072. .removeClass(
  13073. classes.sSortAsc +' '+
  13074. classes.sSortDesc
  13075. )
  13076. .addClass( columns[ colIdx ] == 'asc' ?
  13077. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  13078. classes.sSortDesc :
  13079. column.sSortingClass
  13080. );
  13081. } );
  13082. },
  13083. jqueryui: function ( settings, cell, column, classes ) {
  13084. $('<div/>')
  13085. .addClass( classes.sSortJUIWrapper )
  13086. .append( cell.contents() )
  13087. .append( $('<span/>')
  13088. .addClass( classes.sSortIcon+' '+column.sSortingClassJUI )
  13089. )
  13090. .appendTo( cell );
  13091. // Attach a sort listener to update on sort
  13092. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  13093. if ( settings !== ctx ) {
  13094. return;
  13095. }
  13096. var colIdx = column.idx;
  13097. cell
  13098. .removeClass( classes.sSortAsc +" "+classes.sSortDesc )
  13099. .addClass( columns[ colIdx ] == 'asc' ?
  13100. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  13101. classes.sSortDesc :
  13102. column.sSortingClass
  13103. );
  13104. cell
  13105. .find( 'span.'+classes.sSortIcon )
  13106. .removeClass(
  13107. classes.sSortJUIAsc +" "+
  13108. classes.sSortJUIDesc +" "+
  13109. classes.sSortJUI +" "+
  13110. classes.sSortJUIAscAllowed +" "+
  13111. classes.sSortJUIDescAllowed
  13112. )
  13113. .addClass( columns[ colIdx ] == 'asc' ?
  13114. classes.sSortJUIAsc : columns[ colIdx ] == 'desc' ?
  13115. classes.sSortJUIDesc :
  13116. column.sSortingClassJUI
  13117. );
  13118. } );
  13119. }
  13120. }
  13121. } );
  13122. /*
  13123. * Public helper functions. These aren't used internally by DataTables, or
  13124. * called by any of the options passed into DataTables, but they can be used
  13125. * externally by developers working with DataTables. They are helper functions
  13126. * to make working with DataTables a little bit easier.
  13127. */
  13128. var __htmlEscapeEntities = function ( d ) {
  13129. if (Array.isArray(d)) {
  13130. d = d.join(',');
  13131. }
  13132. return typeof d === 'string' ?
  13133. d
  13134. .replace(/&/g, '&amp;')
  13135. .replace(/</g, '&lt;')
  13136. .replace(/>/g, '&gt;')
  13137. .replace(/"/g, '&quot;') :
  13138. d;
  13139. };
  13140. /**
  13141. * Helpers for `columns.render`.
  13142. *
  13143. * The options defined here can be used with the `columns.render` initialisation
  13144. * option to provide a display renderer. The following functions are defined:
  13145. *
  13146. * * `number` - Will format numeric data (defined by `columns.data`) for
  13147. * display, retaining the original unformatted data for sorting and filtering.
  13148. * It takes 5 parameters:
  13149. * * `string` - Thousands grouping separator
  13150. * * `string` - Decimal point indicator
  13151. * * `integer` - Number of decimal points to show
  13152. * * `string` (optional) - Prefix.
  13153. * * `string` (optional) - Postfix (/suffix).
  13154. * * `text` - Escape HTML to help prevent XSS attacks. It has no optional
  13155. * parameters.
  13156. *
  13157. * @example
  13158. * // Column definition using the number renderer
  13159. * {
  13160. * data: "salary",
  13161. * render: $.fn.dataTable.render.number( '\'', '.', 0, '$' )
  13162. * }
  13163. *
  13164. * @namespace
  13165. */
  13166. DataTable.render = {
  13167. number: function ( thousands, decimal, precision, prefix, postfix ) {
  13168. return {
  13169. display: function ( d ) {
  13170. if ( typeof d !== 'number' && typeof d !== 'string' ) {
  13171. return d;
  13172. }
  13173. var negative = d < 0 ? '-' : '';
  13174. var flo = parseFloat( d );
  13175. // If NaN then there isn't much formatting that we can do - just
  13176. // return immediately, escaping any HTML (this was supposed to
  13177. // be a number after all)
  13178. if ( isNaN( flo ) ) {
  13179. return __htmlEscapeEntities( d );
  13180. }
  13181. flo = flo.toFixed( precision );
  13182. d = Math.abs( flo );
  13183. var intPart = parseInt( d, 10 );
  13184. var floatPart = precision ?
  13185. decimal+(d - intPart).toFixed( precision ).substring( 2 ):
  13186. '';
  13187. // If zero, then can't have a negative prefix
  13188. if (intPart === 0 && parseFloat(floatPart) === 0) {
  13189. negative = '';
  13190. }
  13191. return negative + (prefix||'') +
  13192. intPart.toString().replace(
  13193. /\B(?=(\d{3})+(?!\d))/g, thousands
  13194. ) +
  13195. floatPart +
  13196. (postfix||'');
  13197. }
  13198. };
  13199. },
  13200. text: function () {
  13201. return {
  13202. display: __htmlEscapeEntities,
  13203. filter: __htmlEscapeEntities
  13204. };
  13205. }
  13206. };
  13207. /*
  13208. * This is really a good bit rubbish this method of exposing the internal methods
  13209. * publicly... - To be fixed in 2.0 using methods on the prototype
  13210. */
  13211. /**
  13212. * Create a wrapper function for exporting an internal functions to an external API.
  13213. * @param {string} fn API function name
  13214. * @returns {function} wrapped function
  13215. * @memberof DataTable#internal
  13216. */
  13217. function _fnExternApiFunc (fn)
  13218. {
  13219. return function() {
  13220. var args = [_fnSettingsFromNode( this[DataTable.ext.iApiIndex] )].concat(
  13221. Array.prototype.slice.call(arguments)
  13222. );
  13223. return DataTable.ext.internal[fn].apply( this, args );
  13224. };
  13225. }
  13226. /**
  13227. * Reference to internal functions for use by plug-in developers. Note that
  13228. * these methods are references to internal functions and are considered to be
  13229. * private. If you use these methods, be aware that they are liable to change
  13230. * between versions.
  13231. * @namespace
  13232. */
  13233. $.extend( DataTable.ext.internal, {
  13234. _fnExternApiFunc: _fnExternApiFunc,
  13235. _fnBuildAjax: _fnBuildAjax,
  13236. _fnAjaxUpdate: _fnAjaxUpdate,
  13237. _fnAjaxParameters: _fnAjaxParameters,
  13238. _fnAjaxUpdateDraw: _fnAjaxUpdateDraw,
  13239. _fnAjaxDataSrc: _fnAjaxDataSrc,
  13240. _fnAddColumn: _fnAddColumn,
  13241. _fnColumnOptions: _fnColumnOptions,
  13242. _fnAdjustColumnSizing: _fnAdjustColumnSizing,
  13243. _fnVisibleToColumnIndex: _fnVisibleToColumnIndex,
  13244. _fnColumnIndexToVisible: _fnColumnIndexToVisible,
  13245. _fnVisbleColumns: _fnVisbleColumns,
  13246. _fnGetColumns: _fnGetColumns,
  13247. _fnColumnTypes: _fnColumnTypes,
  13248. _fnApplyColumnDefs: _fnApplyColumnDefs,
  13249. _fnHungarianMap: _fnHungarianMap,
  13250. _fnCamelToHungarian: _fnCamelToHungarian,
  13251. _fnLanguageCompat: _fnLanguageCompat,
  13252. _fnBrowserDetect: _fnBrowserDetect,
  13253. _fnAddData: _fnAddData,
  13254. _fnAddTr: _fnAddTr,
  13255. _fnNodeToDataIndex: _fnNodeToDataIndex,
  13256. _fnNodeToColumnIndex: _fnNodeToColumnIndex,
  13257. _fnGetCellData: _fnGetCellData,
  13258. _fnSetCellData: _fnSetCellData,
  13259. _fnSplitObjNotation: _fnSplitObjNotation,
  13260. _fnGetObjectDataFn: _fnGetObjectDataFn,
  13261. _fnSetObjectDataFn: _fnSetObjectDataFn,
  13262. _fnGetDataMaster: _fnGetDataMaster,
  13263. _fnClearTable: _fnClearTable,
  13264. _fnDeleteIndex: _fnDeleteIndex,
  13265. _fnInvalidate: _fnInvalidate,
  13266. _fnGetRowElements: _fnGetRowElements,
  13267. _fnCreateTr: _fnCreateTr,
  13268. _fnBuildHead: _fnBuildHead,
  13269. _fnDrawHead: _fnDrawHead,
  13270. _fnDraw: _fnDraw,
  13271. _fnReDraw: _fnReDraw,
  13272. _fnAddOptionsHtml: _fnAddOptionsHtml,
  13273. _fnDetectHeader: _fnDetectHeader,
  13274. _fnGetUniqueThs: _fnGetUniqueThs,
  13275. _fnFeatureHtmlFilter: _fnFeatureHtmlFilter,
  13276. _fnFilterComplete: _fnFilterComplete,
  13277. _fnFilterCustom: _fnFilterCustom,
  13278. _fnFilterColumn: _fnFilterColumn,
  13279. _fnFilter: _fnFilter,
  13280. _fnFilterCreateSearch: _fnFilterCreateSearch,
  13281. _fnEscapeRegex: _fnEscapeRegex,
  13282. _fnFilterData: _fnFilterData,
  13283. _fnFeatureHtmlInfo: _fnFeatureHtmlInfo,
  13284. _fnUpdateInfo: _fnUpdateInfo,
  13285. _fnInfoMacros: _fnInfoMacros,
  13286. _fnInitialise: _fnInitialise,
  13287. _fnInitComplete: _fnInitComplete,
  13288. _fnLengthChange: _fnLengthChange,
  13289. _fnFeatureHtmlLength: _fnFeatureHtmlLength,
  13290. _fnFeatureHtmlPaginate: _fnFeatureHtmlPaginate,
  13291. _fnPageChange: _fnPageChange,
  13292. _fnFeatureHtmlProcessing: _fnFeatureHtmlProcessing,
  13293. _fnProcessingDisplay: _fnProcessingDisplay,
  13294. _fnFeatureHtmlTable: _fnFeatureHtmlTable,
  13295. _fnScrollDraw: _fnScrollDraw,
  13296. _fnApplyToChildren: _fnApplyToChildren,
  13297. _fnCalculateColumnWidths: _fnCalculateColumnWidths,
  13298. _fnThrottle: _fnThrottle,
  13299. _fnConvertToWidth: _fnConvertToWidth,
  13300. _fnGetWidestNode: _fnGetWidestNode,
  13301. _fnGetMaxLenString: _fnGetMaxLenString,
  13302. _fnStringToCss: _fnStringToCss,
  13303. _fnSortFlatten: _fnSortFlatten,
  13304. _fnSort: _fnSort,
  13305. _fnSortAria: _fnSortAria,
  13306. _fnSortListener: _fnSortListener,
  13307. _fnSortAttachListener: _fnSortAttachListener,
  13308. _fnSortingClasses: _fnSortingClasses,
  13309. _fnSortData: _fnSortData,
  13310. _fnSaveState: _fnSaveState,
  13311. _fnLoadState: _fnLoadState,
  13312. _fnImplementState: _fnImplementState,
  13313. _fnSettingsFromNode: _fnSettingsFromNode,
  13314. _fnLog: _fnLog,
  13315. _fnMap: _fnMap,
  13316. _fnBindAction: _fnBindAction,
  13317. _fnCallbackReg: _fnCallbackReg,
  13318. _fnCallbackFire: _fnCallbackFire,
  13319. _fnLengthOverflow: _fnLengthOverflow,
  13320. _fnRenderer: _fnRenderer,
  13321. _fnDataSource: _fnDataSource,
  13322. _fnRowAttributes: _fnRowAttributes,
  13323. _fnExtend: _fnExtend,
  13324. _fnCalculateEnd: function () {} // Used by a lot of plug-ins, but redundant
  13325. // in 1.10, so this dead-end function is
  13326. // added to prevent errors
  13327. } );
  13328. // jQuery access
  13329. $.fn.dataTable = DataTable;
  13330. // Provide access to the host jQuery object (circular reference)
  13331. DataTable.$ = $;
  13332. // Legacy aliases
  13333. $.fn.dataTableSettings = DataTable.settings;
  13334. $.fn.dataTableExt = DataTable.ext;
  13335. // With a capital `D` we return a DataTables API instance rather than a
  13336. // jQuery object
  13337. $.fn.DataTable = function ( opts ) {
  13338. return $(this).dataTable( opts ).api();
  13339. };
  13340. // All properties that are available to $.fn.dataTable should also be
  13341. // available on $.fn.DataTable
  13342. $.each( DataTable, function ( prop, val ) {
  13343. $.fn.DataTable[ prop ] = val;
  13344. } );
  13345. return DataTable;
  13346. }));