jquery.dataTables.js 440 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381
  1. /*! DataTables 1.10.25
  2. * ©2008-2021 SpryMedia Ltd - datatables.net/license
  3. */
  4. /**
  5. * @summary DataTables
  6. * @description Paginate, search and order HTML tables
  7. * @version 1.10.25
  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. factory( jQuery, window, document );
  51. }
  52. }
  53. (function( $, window, document, undefined ) {
  54. "use strict";
  55. /**
  56. * DataTables is a plug-in for the jQuery Javascript library. It is a highly
  57. * flexible tool, based upon the foundations of progressive enhancement,
  58. * which will add advanced interaction controls to any HTML table. For a
  59. * full list of features please refer to
  60. * [DataTables.net](href="http://datatables.net).
  61. *
  62. * Note that the `DataTable` object is not a global variable but is aliased
  63. * to `jQuery.fn.DataTable` and `jQuery.fn.dataTable` through which it may
  64. * be accessed.
  65. *
  66. * @class
  67. * @param {object} [init={}] Configuration object for DataTables. Options
  68. * are defined by {@link DataTable.defaults}
  69. * @requires jQuery 1.7+
  70. *
  71. * @example
  72. * // Basic initialisation
  73. * $(document).ready( function {
  74. * $('#example').dataTable();
  75. * } );
  76. *
  77. * @example
  78. * // Initialisation with configuration options - in this case, disable
  79. * // pagination and sorting.
  80. * $(document).ready( function {
  81. * $('#example').dataTable( {
  82. * "paginate": false,
  83. * "sort": false
  84. * } );
  85. * } );
  86. */
  87. var DataTable = function ( options )
  88. {
  89. /**
  90. * Perform a jQuery selector action on the table's TR elements (from the tbody) and
  91. * return the resulting jQuery object.
  92. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  93. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  94. * @param {string} [oOpts.filter=none] Select TR elements that meet the current filter
  95. * criterion ("applied") or all TR elements (i.e. no filter).
  96. * @param {string} [oOpts.order=current] Order of the TR elements in the processed array.
  97. * Can be either 'current', whereby the current sorting of the table is used, or
  98. * 'original' whereby the original order the data was read into the table is used.
  99. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  100. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  101. * 'current' and filter is 'applied', regardless of what they might be given as.
  102. * @returns {object} jQuery object, filtered by the given selector.
  103. * @dtopt API
  104. * @deprecated Since v1.10
  105. *
  106. * @example
  107. * $(document).ready(function() {
  108. * var oTable = $('#example').dataTable();
  109. *
  110. * // Highlight every second row
  111. * oTable.$('tr:odd').css('backgroundColor', 'blue');
  112. * } );
  113. *
  114. * @example
  115. * $(document).ready(function() {
  116. * var oTable = $('#example').dataTable();
  117. *
  118. * // Filter to rows with 'Webkit' in them, add a background colour and then
  119. * // remove the filter, thus highlighting the 'Webkit' rows only.
  120. * oTable.fnFilter('Webkit');
  121. * oTable.$('tr', {"search": "applied"}).css('backgroundColor', 'blue');
  122. * oTable.fnFilter('');
  123. * } );
  124. */
  125. this.$ = function ( sSelector, oOpts )
  126. {
  127. return this.api(true).$( sSelector, oOpts );
  128. };
  129. /**
  130. * Almost identical to $ in operation, but in this case returns the data for the matched
  131. * rows - as such, the jQuery selector used should match TR row nodes or TD/TH cell nodes
  132. * rather than any descendants, so the data can be obtained for the row/cell. If matching
  133. * rows are found, the data returned is the original data array/object that was used to
  134. * create the row (or a generated array if from a DOM source).
  135. *
  136. * This method is often useful in-combination with $ where both functions are given the
  137. * same parameters and the array indexes will match identically.
  138. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  139. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  140. * @param {string} [oOpts.filter=none] Select elements that meet the current filter
  141. * criterion ("applied") or all elements (i.e. no filter).
  142. * @param {string} [oOpts.order=current] Order of the data in the processed array.
  143. * Can be either 'current', whereby the current sorting of the table is used, or
  144. * 'original' whereby the original order the data was read into the table is used.
  145. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  146. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  147. * 'current' and filter is 'applied', regardless of what they might be given as.
  148. * @returns {array} Data for the matched elements. If any elements, as a result of the
  149. * selector, were not TR, TD or TH elements in the DataTable, they will have a null
  150. * entry in the array.
  151. * @dtopt API
  152. * @deprecated Since v1.10
  153. *
  154. * @example
  155. * $(document).ready(function() {
  156. * var oTable = $('#example').dataTable();
  157. *
  158. * // Get the data from the first row in the table
  159. * var data = oTable._('tr:first');
  160. *
  161. * // Do something useful with the data
  162. * alert( "First cell is: "+data[0] );
  163. * } );
  164. *
  165. * @example
  166. * $(document).ready(function() {
  167. * var oTable = $('#example').dataTable();
  168. *
  169. * // Filter to 'Webkit' and get all data for
  170. * oTable.fnFilter('Webkit');
  171. * var data = oTable._('tr', {"search": "applied"});
  172. *
  173. * // Do something with the data
  174. * alert( data.length+" rows matched the search" );
  175. * } );
  176. */
  177. this._ = function ( sSelector, oOpts )
  178. {
  179. return this.api(true).rows( sSelector, oOpts ).data();
  180. };
  181. /**
  182. * Create a DataTables Api instance, with the currently selected tables for
  183. * the Api's context.
  184. * @param {boolean} [traditional=false] Set the API instance's context to be
  185. * only the table referred to by the `DataTable.ext.iApiIndex` option, as was
  186. * used in the API presented by DataTables 1.9- (i.e. the traditional mode),
  187. * or if all tables captured in the jQuery object should be used.
  188. * @return {DataTables.Api}
  189. */
  190. this.api = function ( traditional )
  191. {
  192. return traditional ?
  193. new _Api(
  194. _fnSettingsFromNode( this[ _ext.iApiIndex ] )
  195. ) :
  196. new _Api( this );
  197. };
  198. /**
  199. * Add a single new row or multiple rows of data to the table. Please note
  200. * that this is suitable for client-side processing only - if you are using
  201. * server-side processing (i.e. "bServerSide": true), then to add data, you
  202. * must add it to the data source, i.e. the server-side, through an Ajax call.
  203. * @param {array|object} data The data to be added to the table. This can be:
  204. * <ul>
  205. * <li>1D array of data - add a single row with the data provided</li>
  206. * <li>2D array of arrays - add multiple rows in a single call</li>
  207. * <li>object - data object when using <i>mData</i></li>
  208. * <li>array of objects - multiple data objects when using <i>mData</i></li>
  209. * </ul>
  210. * @param {bool} [redraw=true] redraw the table or not
  211. * @returns {array} An array of integers, representing the list of indexes in
  212. * <i>aoData</i> ({@link DataTable.models.oSettings}) that have been added to
  213. * the table.
  214. * @dtopt API
  215. * @deprecated Since v1.10
  216. *
  217. * @example
  218. * // Global var for counter
  219. * var giCount = 2;
  220. *
  221. * $(document).ready(function() {
  222. * $('#example').dataTable();
  223. * } );
  224. *
  225. * function fnClickAddRow() {
  226. * $('#example').dataTable().fnAddData( [
  227. * giCount+".1",
  228. * giCount+".2",
  229. * giCount+".3",
  230. * giCount+".4" ]
  231. * );
  232. *
  233. * giCount++;
  234. * }
  235. */
  236. this.fnAddData = function( data, redraw )
  237. {
  238. var api = this.api( true );
  239. /* Check if we want to add multiple rows or not */
  240. var rows = Array.isArray(data) && ( Array.isArray(data[0]) || $.isPlainObject(data[0]) ) ?
  241. api.rows.add( data ) :
  242. api.row.add( data );
  243. if ( redraw === undefined || redraw ) {
  244. api.draw();
  245. }
  246. return rows.flatten().toArray();
  247. };
  248. /**
  249. * This function will make DataTables recalculate the column sizes, based on the data
  250. * contained in the table and the sizes applied to the columns (in the DOM, CSS or
  251. * through the sWidth parameter). This can be useful when the width of the table's
  252. * parent element changes (for example a window resize).
  253. * @param {boolean} [bRedraw=true] Redraw the table or not, you will typically want to
  254. * @dtopt API
  255. * @deprecated Since v1.10
  256. *
  257. * @example
  258. * $(document).ready(function() {
  259. * var oTable = $('#example').dataTable( {
  260. * "sScrollY": "200px",
  261. * "bPaginate": false
  262. * } );
  263. *
  264. * $(window).on('resize', function () {
  265. * oTable.fnAdjustColumnSizing();
  266. * } );
  267. * } );
  268. */
  269. this.fnAdjustColumnSizing = function ( bRedraw )
  270. {
  271. var api = this.api( true ).columns.adjust();
  272. var settings = api.settings()[0];
  273. var scroll = settings.oScroll;
  274. if ( bRedraw === undefined || bRedraw ) {
  275. api.draw( false );
  276. }
  277. else if ( scroll.sX !== "" || scroll.sY !== "" ) {
  278. /* If not redrawing, but scrolling, we want to apply the new column sizes anyway */
  279. _fnScrollDraw( settings );
  280. }
  281. };
  282. /**
  283. * Quickly and simply clear a table
  284. * @param {bool} [bRedraw=true] redraw the table or not
  285. * @dtopt API
  286. * @deprecated Since v1.10
  287. *
  288. * @example
  289. * $(document).ready(function() {
  290. * var oTable = $('#example').dataTable();
  291. *
  292. * // Immediately 'nuke' the current rows (perhaps waiting for an Ajax callback...)
  293. * oTable.fnClearTable();
  294. * } );
  295. */
  296. this.fnClearTable = function( bRedraw )
  297. {
  298. var api = this.api( true ).clear();
  299. if ( bRedraw === undefined || bRedraw ) {
  300. api.draw();
  301. }
  302. };
  303. /**
  304. * The exact opposite of 'opening' a row, this function will close any rows which
  305. * are currently 'open'.
  306. * @param {node} nTr the table row to 'close'
  307. * @returns {int} 0 on success, or 1 if failed (can't find the row)
  308. * @dtopt API
  309. * @deprecated Since v1.10
  310. *
  311. * @example
  312. * $(document).ready(function() {
  313. * var oTable;
  314. *
  315. * // 'open' an information row when a row is clicked on
  316. * $('#example tbody tr').click( function () {
  317. * if ( oTable.fnIsOpen(this) ) {
  318. * oTable.fnClose( this );
  319. * } else {
  320. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  321. * }
  322. * } );
  323. *
  324. * oTable = $('#example').dataTable();
  325. * } );
  326. */
  327. this.fnClose = function( nTr )
  328. {
  329. this.api( true ).row( nTr ).child.hide();
  330. };
  331. /**
  332. * Remove a row for the table
  333. * @param {mixed} target The index of the row from aoData to be deleted, or
  334. * the TR element you want to delete
  335. * @param {function|null} [callBack] Callback function
  336. * @param {bool} [redraw=true] Redraw the table or not
  337. * @returns {array} The row that was deleted
  338. * @dtopt API
  339. * @deprecated Since v1.10
  340. *
  341. * @example
  342. * $(document).ready(function() {
  343. * var oTable = $('#example').dataTable();
  344. *
  345. * // Immediately remove the first row
  346. * oTable.fnDeleteRow( 0 );
  347. * } );
  348. */
  349. this.fnDeleteRow = function( target, callback, redraw )
  350. {
  351. var api = this.api( true );
  352. var rows = api.rows( target );
  353. var settings = rows.settings()[0];
  354. var data = settings.aoData[ rows[0][0] ];
  355. rows.remove();
  356. if ( callback ) {
  357. callback.call( this, settings, data );
  358. }
  359. if ( redraw === undefined || redraw ) {
  360. api.draw();
  361. }
  362. return data;
  363. };
  364. /**
  365. * Restore the table to it's original state in the DOM by removing all of DataTables
  366. * enhancements, alterations to the DOM structure of the table and event listeners.
  367. * @param {boolean} [remove=false] Completely remove the table from the DOM
  368. * @dtopt API
  369. * @deprecated Since v1.10
  370. *
  371. * @example
  372. * $(document).ready(function() {
  373. * // This example is fairly pointless in reality, but shows how fnDestroy can be used
  374. * var oTable = $('#example').dataTable();
  375. * oTable.fnDestroy();
  376. * } );
  377. */
  378. this.fnDestroy = function ( remove )
  379. {
  380. this.api( true ).destroy( remove );
  381. };
  382. /**
  383. * Redraw the table
  384. * @param {bool} [complete=true] Re-filter and resort (if enabled) the table before the draw.
  385. * @dtopt API
  386. * @deprecated Since v1.10
  387. *
  388. * @example
  389. * $(document).ready(function() {
  390. * var oTable = $('#example').dataTable();
  391. *
  392. * // Re-draw the table - you wouldn't want to do it here, but it's an example :-)
  393. * oTable.fnDraw();
  394. * } );
  395. */
  396. this.fnDraw = function( complete )
  397. {
  398. // Note that this isn't an exact match to the old call to _fnDraw - it takes
  399. // into account the new data, but can hold position.
  400. this.api( true ).draw( complete );
  401. };
  402. /**
  403. * Filter the input based on data
  404. * @param {string} sInput String to filter the table on
  405. * @param {int|null} [iColumn] Column to limit filtering to
  406. * @param {bool} [bRegex=false] Treat as regular expression or not
  407. * @param {bool} [bSmart=true] Perform smart filtering or not
  408. * @param {bool} [bShowGlobal=true] Show the input global filter in it's input box(es)
  409. * @param {bool} [bCaseInsensitive=true] Do case-insensitive matching (true) or not (false)
  410. * @dtopt API
  411. * @deprecated Since v1.10
  412. *
  413. * @example
  414. * $(document).ready(function() {
  415. * var oTable = $('#example').dataTable();
  416. *
  417. * // Sometime later - filter...
  418. * oTable.fnFilter( 'test string' );
  419. * } );
  420. */
  421. this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal, bCaseInsensitive )
  422. {
  423. var api = this.api( true );
  424. if ( iColumn === null || iColumn === undefined ) {
  425. api.search( sInput, bRegex, bSmart, bCaseInsensitive );
  426. }
  427. else {
  428. api.column( iColumn ).search( sInput, bRegex, bSmart, bCaseInsensitive );
  429. }
  430. api.draw();
  431. };
  432. /**
  433. * Get the data for the whole table, an individual row or an individual cell based on the
  434. * provided parameters.
  435. * @param {int|node} [src] A TR row node, TD/TH cell node or an integer. If given as
  436. * a TR node then the data source for the whole row will be returned. If given as a
  437. * TD/TH cell node then iCol will be automatically calculated and the data for the
  438. * cell returned. If given as an integer, then this is treated as the aoData internal
  439. * data index for the row (see fnGetPosition) and the data for that row used.
  440. * @param {int} [col] Optional column index that you want the data of.
  441. * @returns {array|object|string} If mRow is undefined, then the data for all rows is
  442. * returned. If mRow is defined, just data for that row, and is iCol is
  443. * defined, only data for the designated cell is returned.
  444. * @dtopt API
  445. * @deprecated Since v1.10
  446. *
  447. * @example
  448. * // Row data
  449. * $(document).ready(function() {
  450. * oTable = $('#example').dataTable();
  451. *
  452. * oTable.$('tr').click( function () {
  453. * var data = oTable.fnGetData( this );
  454. * // ... do something with the array / object of data for the row
  455. * } );
  456. * } );
  457. *
  458. * @example
  459. * // Individual cell data
  460. * $(document).ready(function() {
  461. * oTable = $('#example').dataTable();
  462. *
  463. * oTable.$('td').click( function () {
  464. * var sData = oTable.fnGetData( this );
  465. * alert( 'The cell clicked on had the value of '+sData );
  466. * } );
  467. * } );
  468. */
  469. this.fnGetData = function( src, col )
  470. {
  471. var api = this.api( true );
  472. if ( src !== undefined ) {
  473. var type = src.nodeName ? src.nodeName.toLowerCase() : '';
  474. return col !== undefined || type == 'td' || type == 'th' ?
  475. api.cell( src, col ).data() :
  476. api.row( src ).data() || null;
  477. }
  478. return api.data().toArray();
  479. };
  480. /**
  481. * Get an array of the TR nodes that are used in the table's body. Note that you will
  482. * typically want to use the '$' API method in preference to this as it is more
  483. * flexible.
  484. * @param {int} [iRow] Optional row index for the TR element you want
  485. * @returns {array|node} If iRow is undefined, returns an array of all TR elements
  486. * in the table's body, or iRow is defined, just the TR element requested.
  487. * @dtopt API
  488. * @deprecated Since v1.10
  489. *
  490. * @example
  491. * $(document).ready(function() {
  492. * var oTable = $('#example').dataTable();
  493. *
  494. * // Get the nodes from the table
  495. * var nNodes = oTable.fnGetNodes( );
  496. * } );
  497. */
  498. this.fnGetNodes = function( iRow )
  499. {
  500. var api = this.api( true );
  501. return iRow !== undefined ?
  502. api.row( iRow ).node() :
  503. api.rows().nodes().flatten().toArray();
  504. };
  505. /**
  506. * Get the array indexes of a particular cell from it's DOM element
  507. * and column index including hidden columns
  508. * @param {node} node this can either be a TR, TD or TH in the table's body
  509. * @returns {int} If nNode is given as a TR, then a single index is returned, or
  510. * if given as a cell, an array of [row index, column index (visible),
  511. * column index (all)] is given.
  512. * @dtopt API
  513. * @deprecated Since v1.10
  514. *
  515. * @example
  516. * $(document).ready(function() {
  517. * $('#example tbody td').click( function () {
  518. * // Get the position of the current data from the node
  519. * var aPos = oTable.fnGetPosition( this );
  520. *
  521. * // Get the data array for this row
  522. * var aData = oTable.fnGetData( aPos[0] );
  523. *
  524. * // Update the data array and return the value
  525. * aData[ aPos[1] ] = 'clicked';
  526. * this.innerHTML = 'clicked';
  527. * } );
  528. *
  529. * // Init DataTables
  530. * oTable = $('#example').dataTable();
  531. * } );
  532. */
  533. this.fnGetPosition = function( node )
  534. {
  535. var api = this.api( true );
  536. var nodeName = node.nodeName.toUpperCase();
  537. if ( nodeName == 'TR' ) {
  538. return api.row( node ).index();
  539. }
  540. else if ( nodeName == 'TD' || nodeName == 'TH' ) {
  541. var cell = api.cell( node ).index();
  542. return [
  543. cell.row,
  544. cell.columnVisible,
  545. cell.column
  546. ];
  547. }
  548. return null;
  549. };
  550. /**
  551. * Check to see if a row is 'open' or not.
  552. * @param {node} nTr the table row to check
  553. * @returns {boolean} true if the row is currently open, false otherwise
  554. * @dtopt API
  555. * @deprecated Since v1.10
  556. *
  557. * @example
  558. * $(document).ready(function() {
  559. * var oTable;
  560. *
  561. * // 'open' an information row when a row is clicked on
  562. * $('#example tbody tr').click( function () {
  563. * if ( oTable.fnIsOpen(this) ) {
  564. * oTable.fnClose( this );
  565. * } else {
  566. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  567. * }
  568. * } );
  569. *
  570. * oTable = $('#example').dataTable();
  571. * } );
  572. */
  573. this.fnIsOpen = function( nTr )
  574. {
  575. return this.api( true ).row( nTr ).child.isShown();
  576. };
  577. /**
  578. * This function will place a new row directly after a row which is currently
  579. * on display on the page, with the HTML contents that is passed into the
  580. * function. This can be used, for example, to ask for confirmation that a
  581. * particular record should be deleted.
  582. * @param {node} nTr The table row to 'open'
  583. * @param {string|node|jQuery} mHtml The HTML to put into the row
  584. * @param {string} sClass Class to give the new TD cell
  585. * @returns {node} The row opened. Note that if the table row passed in as the
  586. * first parameter, is not found in the table, this method will silently
  587. * return.
  588. * @dtopt API
  589. * @deprecated Since v1.10
  590. *
  591. * @example
  592. * $(document).ready(function() {
  593. * var oTable;
  594. *
  595. * // 'open' an information row when a row is clicked on
  596. * $('#example tbody tr').click( function () {
  597. * if ( oTable.fnIsOpen(this) ) {
  598. * oTable.fnClose( this );
  599. * } else {
  600. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  601. * }
  602. * } );
  603. *
  604. * oTable = $('#example').dataTable();
  605. * } );
  606. */
  607. this.fnOpen = function( nTr, mHtml, sClass )
  608. {
  609. return this.api( true )
  610. .row( nTr )
  611. .child( mHtml, sClass )
  612. .show()
  613. .child()[0];
  614. };
  615. /**
  616. * Change the pagination - provides the internal logic for pagination in a simple API
  617. * function. With this function you can have a DataTables table go to the next,
  618. * previous, first or last pages.
  619. * @param {string|int} mAction Paging action to take: "first", "previous", "next" or "last"
  620. * or page number to jump to (integer), note that page 0 is the first page.
  621. * @param {bool} [bRedraw=true] Redraw the table or not
  622. * @dtopt API
  623. * @deprecated Since v1.10
  624. *
  625. * @example
  626. * $(document).ready(function() {
  627. * var oTable = $('#example').dataTable();
  628. * oTable.fnPageChange( 'next' );
  629. * } );
  630. */
  631. this.fnPageChange = function ( mAction, bRedraw )
  632. {
  633. var api = this.api( true ).page( mAction );
  634. if ( bRedraw === undefined || bRedraw ) {
  635. api.draw(false);
  636. }
  637. };
  638. /**
  639. * Show a particular column
  640. * @param {int} iCol The column whose display should be changed
  641. * @param {bool} bShow Show (true) or hide (false) the column
  642. * @param {bool} [bRedraw=true] Redraw the table or not
  643. * @dtopt API
  644. * @deprecated Since v1.10
  645. *
  646. * @example
  647. * $(document).ready(function() {
  648. * var oTable = $('#example').dataTable();
  649. *
  650. * // Hide the second column after initialisation
  651. * oTable.fnSetColumnVis( 1, false );
  652. * } );
  653. */
  654. this.fnSetColumnVis = function ( iCol, bShow, bRedraw )
  655. {
  656. var api = this.api( true ).column( iCol ).visible( bShow );
  657. if ( bRedraw === undefined || bRedraw ) {
  658. api.columns.adjust().draw();
  659. }
  660. };
  661. /**
  662. * Get the settings for a particular table for external manipulation
  663. * @returns {object} DataTables settings object. See
  664. * {@link DataTable.models.oSettings}
  665. * @dtopt API
  666. * @deprecated Since v1.10
  667. *
  668. * @example
  669. * $(document).ready(function() {
  670. * var oTable = $('#example').dataTable();
  671. * var oSettings = oTable.fnSettings();
  672. *
  673. * // Show an example parameter from the settings
  674. * alert( oSettings._iDisplayStart );
  675. * } );
  676. */
  677. this.fnSettings = function()
  678. {
  679. return _fnSettingsFromNode( this[_ext.iApiIndex] );
  680. };
  681. /**
  682. * Sort the table by a particular column
  683. * @param {int} iCol the data index to sort on. Note that this will not match the
  684. * 'display index' if you have hidden data entries
  685. * @dtopt API
  686. * @deprecated Since v1.10
  687. *
  688. * @example
  689. * $(document).ready(function() {
  690. * var oTable = $('#example').dataTable();
  691. *
  692. * // Sort immediately with columns 0 and 1
  693. * oTable.fnSort( [ [0,'asc'], [1,'asc'] ] );
  694. * } );
  695. */
  696. this.fnSort = function( aaSort )
  697. {
  698. this.api( true ).order( aaSort ).draw();
  699. };
  700. /**
  701. * Attach a sort listener to an element for a given column
  702. * @param {node} nNode the element to attach the sort listener to
  703. * @param {int} iColumn the column that a click on this node will sort on
  704. * @param {function} [fnCallback] callback function when sort is run
  705. * @dtopt API
  706. * @deprecated Since v1.10
  707. *
  708. * @example
  709. * $(document).ready(function() {
  710. * var oTable = $('#example').dataTable();
  711. *
  712. * // Sort on column 1, when 'sorter' is clicked on
  713. * oTable.fnSortListener( document.getElementById('sorter'), 1 );
  714. * } );
  715. */
  716. this.fnSortListener = function( nNode, iColumn, fnCallback )
  717. {
  718. this.api( true ).order.listener( nNode, iColumn, fnCallback );
  719. };
  720. /**
  721. * Update a table cell or row - this method will accept either a single value to
  722. * update the cell with, an array of values with one element for each column or
  723. * an object in the same format as the original data source. The function is
  724. * self-referencing in order to make the multi column updates easier.
  725. * @param {object|array|string} mData Data to update the cell/row with
  726. * @param {node|int} mRow TR element you want to update or the aoData index
  727. * @param {int} [iColumn] The column to update, give as null or undefined to
  728. * update a whole row.
  729. * @param {bool} [bRedraw=true] Redraw the table or not
  730. * @param {bool} [bAction=true] Perform pre-draw actions or not
  731. * @returns {int} 0 on success, 1 on error
  732. * @dtopt API
  733. * @deprecated Since v1.10
  734. *
  735. * @example
  736. * $(document).ready(function() {
  737. * var oTable = $('#example').dataTable();
  738. * oTable.fnUpdate( 'Example update', 0, 0 ); // Single cell
  739. * oTable.fnUpdate( ['a', 'b', 'c', 'd', 'e'], $('tbody tr')[0] ); // Row
  740. * } );
  741. */
  742. this.fnUpdate = function( mData, mRow, iColumn, bRedraw, bAction )
  743. {
  744. var api = this.api( true );
  745. if ( iColumn === undefined || iColumn === null ) {
  746. api.row( mRow ).data( mData );
  747. }
  748. else {
  749. api.cell( mRow, iColumn ).data( mData );
  750. }
  751. if ( bAction === undefined || bAction ) {
  752. api.columns.adjust();
  753. }
  754. if ( bRedraw === undefined || bRedraw ) {
  755. api.draw();
  756. }
  757. return 0;
  758. };
  759. /**
  760. * Provide a common method for plug-ins to check the version of DataTables being used, in order
  761. * to ensure compatibility.
  762. * @param {string} sVersion Version string to check for, in the format "X.Y.Z". Note that the
  763. * formats "X" and "X.Y" are also acceptable.
  764. * @returns {boolean} true if this version of DataTables is greater or equal to the required
  765. * version, or false if this version of DataTales is not suitable
  766. * @method
  767. * @dtopt API
  768. * @deprecated Since v1.10
  769. *
  770. * @example
  771. * $(document).ready(function() {
  772. * var oTable = $('#example').dataTable();
  773. * alert( oTable.fnVersionCheck( '1.9.0' ) );
  774. * } );
  775. */
  776. this.fnVersionCheck = _ext.fnVersionCheck;
  777. var _that = this;
  778. var emptyInit = options === undefined;
  779. var len = this.length;
  780. if ( emptyInit ) {
  781. options = {};
  782. }
  783. this.oApi = this.internal = _ext.internal;
  784. // Extend with old style plug-in API methods
  785. for ( var fn in DataTable.ext.internal ) {
  786. if ( fn ) {
  787. this[fn] = _fnExternApiFunc(fn);
  788. }
  789. }
  790. this.each(function() {
  791. // For each initialisation we want to give it a clean initialisation
  792. // object that can be bashed around
  793. var o = {};
  794. var oInit = len > 1 ? // optimisation for single table case
  795. _fnExtend( o, options, true ) :
  796. options;
  797. /*global oInit,_that,emptyInit*/
  798. var i=0, iLen, j, jLen, k, kLen;
  799. var sId = this.getAttribute( 'id' );
  800. var bInitHandedOff = false;
  801. var defaults = DataTable.defaults;
  802. var $this = $(this);
  803. /* Sanity check */
  804. if ( this.nodeName.toLowerCase() != 'table' )
  805. {
  806. _fnLog( null, 0, 'Non-table node initialisation ('+this.nodeName+')', 2 );
  807. return;
  808. }
  809. /* Backwards compatibility for the defaults */
  810. _fnCompatOpts( defaults );
  811. _fnCompatCols( defaults.column );
  812. /* Convert the camel-case defaults to Hungarian */
  813. _fnCamelToHungarian( defaults, defaults, true );
  814. _fnCamelToHungarian( defaults.column, defaults.column, true );
  815. /* Setting up the initialisation object */
  816. _fnCamelToHungarian( defaults, $.extend( oInit, $this.data() ), true );
  817. /* Check to see if we are re-initialising a table */
  818. var allSettings = DataTable.settings;
  819. for ( i=0, iLen=allSettings.length ; i<iLen ; i++ )
  820. {
  821. var s = allSettings[i];
  822. /* Base check on table node */
  823. if (
  824. s.nTable == this ||
  825. (s.nTHead && s.nTHead.parentNode == this) ||
  826. (s.nTFoot && s.nTFoot.parentNode == this)
  827. ) {
  828. var bRetrieve = oInit.bRetrieve !== undefined ? oInit.bRetrieve : defaults.bRetrieve;
  829. var bDestroy = oInit.bDestroy !== undefined ? oInit.bDestroy : defaults.bDestroy;
  830. if ( emptyInit || bRetrieve )
  831. {
  832. return s.oInstance;
  833. }
  834. else if ( bDestroy )
  835. {
  836. s.oInstance.fnDestroy();
  837. break;
  838. }
  839. else
  840. {
  841. _fnLog( s, 0, 'Cannot reinitialise DataTable', 3 );
  842. return;
  843. }
  844. }
  845. /* If the element we are initialising has the same ID as a table which was previously
  846. * initialised, but the table nodes don't match (from before) then we destroy the old
  847. * instance by simply deleting it. This is under the assumption that the table has been
  848. * destroyed by other methods. Anyone using non-id selectors will need to do this manually
  849. */
  850. if ( s.sTableId == this.id )
  851. {
  852. allSettings.splice( i, 1 );
  853. break;
  854. }
  855. }
  856. /* Ensure the table has an ID - required for accessibility */
  857. if ( sId === null || sId === "" )
  858. {
  859. sId = "DataTables_Table_"+(DataTable.ext._unique++);
  860. this.id = sId;
  861. }
  862. /* Create the settings object for this table and set some of the default parameters */
  863. var oSettings = $.extend( true, {}, DataTable.models.oSettings, {
  864. "sDestroyWidth": $this[0].style.width,
  865. "sInstance": sId,
  866. "sTableId": sId
  867. } );
  868. oSettings.nTable = this;
  869. oSettings.oApi = _that.internal;
  870. oSettings.oInit = oInit;
  871. allSettings.push( oSettings );
  872. // Need to add the instance after the instance after the settings object has been added
  873. // to the settings array, so we can self reference the table instance if more than one
  874. oSettings.oInstance = (_that.length===1) ? _that : $this.dataTable();
  875. // Backwards compatibility, before we apply all the defaults
  876. _fnCompatOpts( oInit );
  877. _fnLanguageCompat( oInit.oLanguage );
  878. // If the length menu is given, but the init display length is not, use the length menu
  879. if ( oInit.aLengthMenu && ! oInit.iDisplayLength )
  880. {
  881. oInit.iDisplayLength = Array.isArray( oInit.aLengthMenu[0] ) ?
  882. oInit.aLengthMenu[0][0] : oInit.aLengthMenu[0];
  883. }
  884. // Apply the defaults and init options to make a single init object will all
  885. // options defined from defaults and instance options.
  886. oInit = _fnExtend( $.extend( true, {}, defaults ), oInit );
  887. // Map the initialisation options onto the settings object
  888. _fnMap( oSettings.oFeatures, oInit, [
  889. "bPaginate",
  890. "bLengthChange",
  891. "bFilter",
  892. "bSort",
  893. "bSortMulti",
  894. "bInfo",
  895. "bProcessing",
  896. "bAutoWidth",
  897. "bSortClasses",
  898. "bServerSide",
  899. "bDeferRender"
  900. ] );
  901. _fnMap( oSettings, oInit, [
  902. "asStripeClasses",
  903. "ajax",
  904. "fnServerData",
  905. "fnFormatNumber",
  906. "sServerMethod",
  907. "aaSorting",
  908. "aaSortingFixed",
  909. "aLengthMenu",
  910. "sPaginationType",
  911. "sAjaxSource",
  912. "sAjaxDataProp",
  913. "iStateDuration",
  914. "sDom",
  915. "bSortCellsTop",
  916. "iTabIndex",
  917. "fnStateLoadCallback",
  918. "fnStateSaveCallback",
  919. "renderer",
  920. "searchDelay",
  921. "rowId",
  922. [ "iCookieDuration", "iStateDuration" ], // backwards compat
  923. [ "oSearch", "oPreviousSearch" ],
  924. [ "aoSearchCols", "aoPreSearchCols" ],
  925. [ "iDisplayLength", "_iDisplayLength" ]
  926. ] );
  927. _fnMap( oSettings.oScroll, oInit, [
  928. [ "sScrollX", "sX" ],
  929. [ "sScrollXInner", "sXInner" ],
  930. [ "sScrollY", "sY" ],
  931. [ "bScrollCollapse", "bCollapse" ]
  932. ] );
  933. _fnMap( oSettings.oLanguage, oInit, "fnInfoCallback" );
  934. /* Callback functions which are array driven */
  935. _fnCallbackReg( oSettings, 'aoDrawCallback', oInit.fnDrawCallback, 'user' );
  936. _fnCallbackReg( oSettings, 'aoServerParams', oInit.fnServerParams, 'user' );
  937. _fnCallbackReg( oSettings, 'aoStateSaveParams', oInit.fnStateSaveParams, 'user' );
  938. _fnCallbackReg( oSettings, 'aoStateLoadParams', oInit.fnStateLoadParams, 'user' );
  939. _fnCallbackReg( oSettings, 'aoStateLoaded', oInit.fnStateLoaded, 'user' );
  940. _fnCallbackReg( oSettings, 'aoRowCallback', oInit.fnRowCallback, 'user' );
  941. _fnCallbackReg( oSettings, 'aoRowCreatedCallback', oInit.fnCreatedRow, 'user' );
  942. _fnCallbackReg( oSettings, 'aoHeaderCallback', oInit.fnHeaderCallback, 'user' );
  943. _fnCallbackReg( oSettings, 'aoFooterCallback', oInit.fnFooterCallback, 'user' );
  944. _fnCallbackReg( oSettings, 'aoInitComplete', oInit.fnInitComplete, 'user' );
  945. _fnCallbackReg( oSettings, 'aoPreDrawCallback', oInit.fnPreDrawCallback, 'user' );
  946. oSettings.rowIdFn = _fnGetObjectDataFn( oInit.rowId );
  947. /* Browser support detection */
  948. _fnBrowserDetect( oSettings );
  949. var oClasses = oSettings.oClasses;
  950. $.extend( oClasses, DataTable.ext.classes, oInit.oClasses );
  951. $this.addClass( oClasses.sTable );
  952. if ( oSettings.iInitDisplayStart === undefined )
  953. {
  954. /* Display start point, taking into account the save saving */
  955. oSettings.iInitDisplayStart = oInit.iDisplayStart;
  956. oSettings._iDisplayStart = oInit.iDisplayStart;
  957. }
  958. if ( oInit.iDeferLoading !== null )
  959. {
  960. oSettings.bDeferLoading = true;
  961. var tmp = Array.isArray( oInit.iDeferLoading );
  962. oSettings._iRecordsDisplay = tmp ? oInit.iDeferLoading[0] : oInit.iDeferLoading;
  963. oSettings._iRecordsTotal = tmp ? oInit.iDeferLoading[1] : oInit.iDeferLoading;
  964. }
  965. /* Language definitions */
  966. var oLanguage = oSettings.oLanguage;
  967. $.extend( true, oLanguage, oInit.oLanguage );
  968. if ( oLanguage.sUrl )
  969. {
  970. /* Get the language definitions from a file - because this Ajax call makes the language
  971. * get async to the remainder of this function we use bInitHandedOff to indicate that
  972. * _fnInitialise will be fired by the returned Ajax handler, rather than the constructor
  973. */
  974. $.ajax( {
  975. dataType: 'json',
  976. url: oLanguage.sUrl,
  977. success: function ( json ) {
  978. _fnLanguageCompat( json );
  979. _fnCamelToHungarian( defaults.oLanguage, json );
  980. $.extend( true, oLanguage, json );
  981. _fnCallbackFire( oSettings, null, 'i18n', [oSettings]);
  982. _fnInitialise( oSettings );
  983. },
  984. error: function () {
  985. // Error occurred loading language file, continue on as best we can
  986. _fnInitialise( oSettings );
  987. }
  988. } );
  989. bInitHandedOff = true;
  990. }
  991. else {
  992. _fnCallbackFire( oSettings, null, 'i18n', [oSettings]);
  993. }
  994. /*
  995. * Stripes
  996. */
  997. if ( oInit.asStripeClasses === null )
  998. {
  999. oSettings.asStripeClasses =[
  1000. oClasses.sStripeOdd,
  1001. oClasses.sStripeEven
  1002. ];
  1003. }
  1004. /* Remove row stripe classes if they are already on the table row */
  1005. var stripeClasses = oSettings.asStripeClasses;
  1006. var rowOne = $this.children('tbody').find('tr').eq(0);
  1007. if ( $.inArray( true, $.map( stripeClasses, function(el, i) {
  1008. return rowOne.hasClass(el);
  1009. } ) ) !== -1 ) {
  1010. $('tbody tr', this).removeClass( stripeClasses.join(' ') );
  1011. oSettings.asDestroyStripes = stripeClasses.slice();
  1012. }
  1013. /*
  1014. * Columns
  1015. * See if we should load columns automatically or use defined ones
  1016. */
  1017. var anThs = [];
  1018. var aoColumnsInit;
  1019. var nThead = this.getElementsByTagName('thead');
  1020. if ( nThead.length !== 0 )
  1021. {
  1022. _fnDetectHeader( oSettings.aoHeader, nThead[0] );
  1023. anThs = _fnGetUniqueThs( oSettings );
  1024. }
  1025. /* If not given a column array, generate one with nulls */
  1026. if ( oInit.aoColumns === null )
  1027. {
  1028. aoColumnsInit = [];
  1029. for ( i=0, iLen=anThs.length ; i<iLen ; i++ )
  1030. {
  1031. aoColumnsInit.push( null );
  1032. }
  1033. }
  1034. else
  1035. {
  1036. aoColumnsInit = oInit.aoColumns;
  1037. }
  1038. /* Add the columns */
  1039. for ( i=0, iLen=aoColumnsInit.length ; i<iLen ; i++ )
  1040. {
  1041. _fnAddColumn( oSettings, anThs ? anThs[i] : null );
  1042. }
  1043. /* Apply the column definitions */
  1044. _fnApplyColumnDefs( oSettings, oInit.aoColumnDefs, aoColumnsInit, function (iCol, oDef) {
  1045. _fnColumnOptions( oSettings, iCol, oDef );
  1046. } );
  1047. /* HTML5 attribute detection - build an mData object automatically if the
  1048. * attributes are found
  1049. */
  1050. if ( rowOne.length ) {
  1051. var a = function ( cell, name ) {
  1052. return cell.getAttribute( 'data-'+name ) !== null ? name : null;
  1053. };
  1054. $( rowOne[0] ).children('th, td').each( function (i, cell) {
  1055. var col = oSettings.aoColumns[i];
  1056. if ( col.mData === i ) {
  1057. var sort = a( cell, 'sort' ) || a( cell, 'order' );
  1058. var filter = a( cell, 'filter' ) || a( cell, 'search' );
  1059. if ( sort !== null || filter !== null ) {
  1060. col.mData = {
  1061. _: i+'.display',
  1062. sort: sort !== null ? i+'.@data-'+sort : undefined,
  1063. type: sort !== null ? i+'.@data-'+sort : undefined,
  1064. filter: filter !== null ? i+'.@data-'+filter : undefined
  1065. };
  1066. _fnColumnOptions( oSettings, i );
  1067. }
  1068. }
  1069. } );
  1070. }
  1071. var features = oSettings.oFeatures;
  1072. var loadedInit = function () {
  1073. /*
  1074. * Sorting
  1075. * @todo For modularisation (1.11) this needs to do into a sort start up handler
  1076. */
  1077. // If aaSorting is not defined, then we use the first indicator in asSorting
  1078. // in case that has been altered, so the default sort reflects that option
  1079. if ( oInit.aaSorting === undefined ) {
  1080. var sorting = oSettings.aaSorting;
  1081. for ( i=0, iLen=sorting.length ; i<iLen ; i++ ) {
  1082. sorting[i][1] = oSettings.aoColumns[ i ].asSorting[0];
  1083. }
  1084. }
  1085. /* Do a first pass on the sorting classes (allows any size changes to be taken into
  1086. * account, and also will apply sorting disabled classes if disabled
  1087. */
  1088. _fnSortingClasses( oSettings );
  1089. if ( features.bSort ) {
  1090. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  1091. if ( oSettings.bSorted ) {
  1092. var aSort = _fnSortFlatten( oSettings );
  1093. var sortedColumns = {};
  1094. $.each( aSort, function (i, val) {
  1095. sortedColumns[ val.src ] = val.dir;
  1096. } );
  1097. _fnCallbackFire( oSettings, null, 'order', [oSettings, aSort, sortedColumns] );
  1098. _fnSortAria( oSettings );
  1099. }
  1100. } );
  1101. }
  1102. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  1103. if ( oSettings.bSorted || _fnDataSource( oSettings ) === 'ssp' || features.bDeferRender ) {
  1104. _fnSortingClasses( oSettings );
  1105. }
  1106. }, 'sc' );
  1107. /*
  1108. * Final init
  1109. * Cache the header, body and footer as required, creating them if needed
  1110. */
  1111. // Work around for Webkit bug 83867 - store the caption-side before removing from doc
  1112. var captions = $this.children('caption').each( function () {
  1113. this._captionSide = $(this).css('caption-side');
  1114. } );
  1115. var thead = $this.children('thead');
  1116. if ( thead.length === 0 ) {
  1117. thead = $('<thead/>').appendTo($this);
  1118. }
  1119. oSettings.nTHead = thead[0];
  1120. var tbody = $this.children('tbody');
  1121. if ( tbody.length === 0 ) {
  1122. tbody = $('<tbody/>').insertAfter(thead);
  1123. }
  1124. oSettings.nTBody = tbody[0];
  1125. var tfoot = $this.children('tfoot');
  1126. if ( tfoot.length === 0 && captions.length > 0 && (oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "") ) {
  1127. // If we are a scrolling table, and no footer has been given, then we need to create
  1128. // a tfoot element for the caption element to be appended to
  1129. tfoot = $('<tfoot/>').appendTo($this);
  1130. }
  1131. if ( tfoot.length === 0 || tfoot.children().length === 0 ) {
  1132. $this.addClass( oClasses.sNoFooter );
  1133. }
  1134. else if ( tfoot.length > 0 ) {
  1135. oSettings.nTFoot = tfoot[0];
  1136. _fnDetectHeader( oSettings.aoFooter, oSettings.nTFoot );
  1137. }
  1138. /* Check if there is data passing into the constructor */
  1139. if ( oInit.aaData ) {
  1140. for ( i=0 ; i<oInit.aaData.length ; i++ ) {
  1141. _fnAddData( oSettings, oInit.aaData[ i ] );
  1142. }
  1143. }
  1144. else if ( oSettings.bDeferLoading || _fnDataSource( oSettings ) == 'dom' ) {
  1145. /* Grab the data from the page - only do this when deferred loading or no Ajax
  1146. * source since there is no point in reading the DOM data if we are then going
  1147. * to replace it with Ajax data
  1148. */
  1149. _fnAddTr( oSettings, $(oSettings.nTBody).children('tr') );
  1150. }
  1151. /* Copy the data index array */
  1152. oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
  1153. /* Initialisation complete - table can be drawn */
  1154. oSettings.bInitialised = true;
  1155. /* Check if we need to initialise the table (it might not have been handed off to the
  1156. * language processor)
  1157. */
  1158. if ( bInitHandedOff === false ) {
  1159. _fnInitialise( oSettings );
  1160. }
  1161. };
  1162. /* Must be done after everything which can be overridden by the state saving! */
  1163. if ( oInit.bStateSave )
  1164. {
  1165. features.bStateSave = true;
  1166. _fnCallbackReg( oSettings, 'aoDrawCallback', _fnSaveState, 'state_save' );
  1167. _fnLoadState( oSettings, oInit, loadedInit );
  1168. }
  1169. else {
  1170. loadedInit();
  1171. }
  1172. } );
  1173. _that = null;
  1174. return this;
  1175. };
  1176. /*
  1177. * It is useful to have variables which are scoped locally so only the
  1178. * DataTables functions can access them and they don't leak into global space.
  1179. * At the same time these functions are often useful over multiple files in the
  1180. * core and API, so we list, or at least document, all variables which are used
  1181. * by DataTables as private variables here. This also ensures that there is no
  1182. * clashing of variable names and that they can easily referenced for reuse.
  1183. */
  1184. // Defined else where
  1185. // _selector_run
  1186. // _selector_opts
  1187. // _selector_first
  1188. // _selector_row_indexes
  1189. var _ext; // DataTable.ext
  1190. var _Api; // DataTable.Api
  1191. var _api_register; // DataTable.Api.register
  1192. var _api_registerPlural; // DataTable.Api.registerPlural
  1193. var _re_dic = {};
  1194. var _re_new_lines = /[\r\n\u2028]/g;
  1195. var _re_html = /<.*?>/g;
  1196. // This is not strict ISO8601 - Date.parse() is quite lax, although
  1197. // implementations differ between browsers.
  1198. var _re_date = /^\d{2,4}[\.\/\-]\d{1,2}[\.\/\-]\d{1,2}([T ]{1}\d{1,2}[:\.]\d{2}([\.:]\d{2})?)?$/;
  1199. // Escape regular expression special characters
  1200. var _re_escape_regex = new RegExp( '(\\' + [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^', '-' ].join('|\\') + ')', 'g' );
  1201. // http://en.wikipedia.org/wiki/Foreign_exchange_market
  1202. // - \u20BD - Russian ruble.
  1203. // - \u20a9 - South Korean Won
  1204. // - \u20BA - Turkish Lira
  1205. // - \u20B9 - Indian Rupee
  1206. // - R - Brazil (R$) and South Africa
  1207. // - fr - Swiss Franc
  1208. // - kr - Swedish krona, Norwegian krone and Danish krone
  1209. // - \u2009 is thin space and \u202F is narrow no-break space, both used in many
  1210. // - Ƀ - Bitcoin
  1211. // - Ξ - Ethereum
  1212. // standards as thousands separators.
  1213. var _re_formatted_numeric = /['\u00A0,$£€¥%\u2009\u202F\u20BD\u20a9\u20BArfkɃΞ]/gi;
  1214. var _empty = function ( d ) {
  1215. return !d || d === true || d === '-' ? true : false;
  1216. };
  1217. var _intVal = function ( s ) {
  1218. var integer = parseInt( s, 10 );
  1219. return !isNaN(integer) && isFinite(s) ? integer : null;
  1220. };
  1221. // Convert from a formatted number with characters other than `.` as the
  1222. // decimal place, to a Javascript number
  1223. var _numToDecimal = function ( num, decimalPoint ) {
  1224. // Cache created regular expressions for speed as this function is called often
  1225. if ( ! _re_dic[ decimalPoint ] ) {
  1226. _re_dic[ decimalPoint ] = new RegExp( _fnEscapeRegex( decimalPoint ), 'g' );
  1227. }
  1228. return typeof num === 'string' && decimalPoint !== '.' ?
  1229. num.replace( /\./g, '' ).replace( _re_dic[ decimalPoint ], '.' ) :
  1230. num;
  1231. };
  1232. var _isNumber = function ( d, decimalPoint, formatted ) {
  1233. var strType = typeof d === 'string';
  1234. // If empty return immediately so there must be a number if it is a
  1235. // formatted string (this stops the string "k", or "kr", etc being detected
  1236. // as a formatted number for currency
  1237. if ( _empty( d ) ) {
  1238. return true;
  1239. }
  1240. if ( decimalPoint && strType ) {
  1241. d = _numToDecimal( d, decimalPoint );
  1242. }
  1243. if ( formatted && strType ) {
  1244. d = d.replace( _re_formatted_numeric, '' );
  1245. }
  1246. return !isNaN( parseFloat(d) ) && isFinite( d );
  1247. };
  1248. // A string without HTML in it can be considered to be HTML still
  1249. var _isHtml = function ( d ) {
  1250. return _empty( d ) || typeof d === 'string';
  1251. };
  1252. var _htmlNumeric = function ( d, decimalPoint, formatted ) {
  1253. if ( _empty( d ) ) {
  1254. return true;
  1255. }
  1256. var html = _isHtml( d );
  1257. return ! html ?
  1258. null :
  1259. _isNumber( _stripHtml( d ), decimalPoint, formatted ) ?
  1260. true :
  1261. null;
  1262. };
  1263. var _pluck = function ( a, prop, prop2 ) {
  1264. var out = [];
  1265. var i=0, ien=a.length;
  1266. // Could have the test in the loop for slightly smaller code, but speed
  1267. // is essential here
  1268. if ( prop2 !== undefined ) {
  1269. for ( ; i<ien ; i++ ) {
  1270. if ( a[i] && a[i][ prop ] ) {
  1271. out.push( a[i][ prop ][ prop2 ] );
  1272. }
  1273. }
  1274. }
  1275. else {
  1276. for ( ; i<ien ; i++ ) {
  1277. if ( a[i] ) {
  1278. out.push( a[i][ prop ] );
  1279. }
  1280. }
  1281. }
  1282. return out;
  1283. };
  1284. // Basically the same as _pluck, but rather than looping over `a` we use `order`
  1285. // as the indexes to pick from `a`
  1286. var _pluck_order = function ( a, order, prop, prop2 )
  1287. {
  1288. var out = [];
  1289. var i=0, ien=order.length;
  1290. // Could have the test in the loop for slightly smaller code, but speed
  1291. // is essential here
  1292. if ( prop2 !== undefined ) {
  1293. for ( ; i<ien ; i++ ) {
  1294. if ( a[ order[i] ][ prop ] ) {
  1295. out.push( a[ order[i] ][ prop ][ prop2 ] );
  1296. }
  1297. }
  1298. }
  1299. else {
  1300. for ( ; i<ien ; i++ ) {
  1301. out.push( a[ order[i] ][ prop ] );
  1302. }
  1303. }
  1304. return out;
  1305. };
  1306. var _range = function ( len, start )
  1307. {
  1308. var out = [];
  1309. var end;
  1310. if ( start === undefined ) {
  1311. start = 0;
  1312. end = len;
  1313. }
  1314. else {
  1315. end = start;
  1316. start = len;
  1317. }
  1318. for ( var i=start ; i<end ; i++ ) {
  1319. out.push( i );
  1320. }
  1321. return out;
  1322. };
  1323. var _removeEmpty = function ( a )
  1324. {
  1325. var out = [];
  1326. for ( var i=0, ien=a.length ; i<ien ; i++ ) {
  1327. if ( a[i] ) { // careful - will remove all falsy values!
  1328. out.push( a[i] );
  1329. }
  1330. }
  1331. return out;
  1332. };
  1333. var _stripHtml = function ( d ) {
  1334. return d.replace( _re_html, '' );
  1335. };
  1336. /**
  1337. * Determine if all values in the array are unique. This means we can short
  1338. * cut the _unique method at the cost of a single loop. A sorted array is used
  1339. * to easily check the values.
  1340. *
  1341. * @param {array} src Source array
  1342. * @return {boolean} true if all unique, false otherwise
  1343. * @ignore
  1344. */
  1345. var _areAllUnique = function ( src ) {
  1346. if ( src.length < 2 ) {
  1347. return true;
  1348. }
  1349. var sorted = src.slice().sort();
  1350. var last = sorted[0];
  1351. for ( var i=1, ien=sorted.length ; i<ien ; i++ ) {
  1352. if ( sorted[i] === last ) {
  1353. return false;
  1354. }
  1355. last = sorted[i];
  1356. }
  1357. return true;
  1358. };
  1359. /**
  1360. * Find the unique elements in a source array.
  1361. *
  1362. * @param {array} src Source array
  1363. * @return {array} Array of unique items
  1364. * @ignore
  1365. */
  1366. var _unique = function ( src )
  1367. {
  1368. if ( _areAllUnique( src ) ) {
  1369. return src.slice();
  1370. }
  1371. // A faster unique method is to use object keys to identify used values,
  1372. // but this doesn't work with arrays or objects, which we must also
  1373. // consider. See jsperf.com/compare-array-unique-versions/4 for more
  1374. // information.
  1375. var
  1376. out = [],
  1377. val,
  1378. i, ien=src.length,
  1379. j, k=0;
  1380. again: for ( i=0 ; i<ien ; i++ ) {
  1381. val = src[i];
  1382. for ( j=0 ; j<k ; j++ ) {
  1383. if ( out[j] === val ) {
  1384. continue again;
  1385. }
  1386. }
  1387. out.push( val );
  1388. k++;
  1389. }
  1390. return out;
  1391. };
  1392. // Surprisingly this is faster than [].concat.apply
  1393. // https://jsperf.com/flatten-an-array-loop-vs-reduce/2
  1394. var _flatten = function (out, val) {
  1395. if (Array.isArray(val)) {
  1396. for (var i=0 ; i<val.length ; i++) {
  1397. _flatten(out, val[i]);
  1398. }
  1399. }
  1400. else {
  1401. out.push(val);
  1402. }
  1403. return out;
  1404. }
  1405. // Array.isArray polyfill.
  1406. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
  1407. if (! Array.isArray) {
  1408. Array.isArray = function(arg) {
  1409. return Object.prototype.toString.call(arg) === '[object Array]';
  1410. };
  1411. }
  1412. // .trim() polyfill
  1413. // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/trim
  1414. if (!String.prototype.trim) {
  1415. String.prototype.trim = function () {
  1416. return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
  1417. };
  1418. }
  1419. /**
  1420. * DataTables utility methods
  1421. *
  1422. * This namespace provides helper methods that DataTables uses internally to
  1423. * create a DataTable, but which are not exclusively used only for DataTables.
  1424. * These methods can be used by extension authors to save the duplication of
  1425. * code.
  1426. *
  1427. * @namespace
  1428. */
  1429. DataTable.util = {
  1430. /**
  1431. * Throttle the calls to a function. Arguments and context are maintained
  1432. * for the throttled function.
  1433. *
  1434. * @param {function} fn Function to be called
  1435. * @param {integer} freq Call frequency in mS
  1436. * @return {function} Wrapped function
  1437. */
  1438. throttle: function ( fn, freq ) {
  1439. var
  1440. frequency = freq !== undefined ? freq : 200,
  1441. last,
  1442. timer;
  1443. return function () {
  1444. var
  1445. that = this,
  1446. now = +new Date(),
  1447. args = arguments;
  1448. if ( last && now < last + frequency ) {
  1449. clearTimeout( timer );
  1450. timer = setTimeout( function () {
  1451. last = undefined;
  1452. fn.apply( that, args );
  1453. }, frequency );
  1454. }
  1455. else {
  1456. last = now;
  1457. fn.apply( that, args );
  1458. }
  1459. };
  1460. },
  1461. /**
  1462. * Escape a string such that it can be used in a regular expression
  1463. *
  1464. * @param {string} val string to escape
  1465. * @returns {string} escaped string
  1466. */
  1467. escapeRegex: function ( val ) {
  1468. return val.replace( _re_escape_regex, '\\$1' );
  1469. }
  1470. };
  1471. /**
  1472. * Create a mapping object that allows camel case parameters to be looked up
  1473. * for their Hungarian counterparts. The mapping is stored in a private
  1474. * parameter called `_hungarianMap` which can be accessed on the source object.
  1475. * @param {object} o
  1476. * @memberof DataTable#oApi
  1477. */
  1478. function _fnHungarianMap ( o )
  1479. {
  1480. var
  1481. hungarian = 'a aa ai ao as b fn i m o s ',
  1482. match,
  1483. newKey,
  1484. map = {};
  1485. $.each( o, function (key, val) {
  1486. match = key.match(/^([^A-Z]+?)([A-Z])/);
  1487. if ( match && hungarian.indexOf(match[1]+' ') !== -1 )
  1488. {
  1489. newKey = key.replace( match[0], match[2].toLowerCase() );
  1490. map[ newKey ] = key;
  1491. if ( match[1] === 'o' )
  1492. {
  1493. _fnHungarianMap( o[key] );
  1494. }
  1495. }
  1496. } );
  1497. o._hungarianMap = map;
  1498. }
  1499. /**
  1500. * Convert from camel case parameters to Hungarian, based on a Hungarian map
  1501. * created by _fnHungarianMap.
  1502. * @param {object} src The model object which holds all parameters that can be
  1503. * mapped.
  1504. * @param {object} user The object to convert from camel case to Hungarian.
  1505. * @param {boolean} force When set to `true`, properties which already have a
  1506. * Hungarian value in the `user` object will be overwritten. Otherwise they
  1507. * won't be.
  1508. * @memberof DataTable#oApi
  1509. */
  1510. function _fnCamelToHungarian ( src, user, force )
  1511. {
  1512. if ( ! src._hungarianMap ) {
  1513. _fnHungarianMap( src );
  1514. }
  1515. var hungarianKey;
  1516. $.each( user, function (key, val) {
  1517. hungarianKey = src._hungarianMap[ key ];
  1518. if ( hungarianKey !== undefined && (force || user[hungarianKey] === undefined) )
  1519. {
  1520. // For objects, we need to buzz down into the object to copy parameters
  1521. if ( hungarianKey.charAt(0) === 'o' )
  1522. {
  1523. // Copy the camelCase options over to the hungarian
  1524. if ( ! user[ hungarianKey ] ) {
  1525. user[ hungarianKey ] = {};
  1526. }
  1527. $.extend( true, user[hungarianKey], user[key] );
  1528. _fnCamelToHungarian( src[hungarianKey], user[hungarianKey], force );
  1529. }
  1530. else {
  1531. user[hungarianKey] = user[ key ];
  1532. }
  1533. }
  1534. } );
  1535. }
  1536. /**
  1537. * Language compatibility - when certain options are given, and others aren't, we
  1538. * need to duplicate the values over, in order to provide backwards compatibility
  1539. * with older language files.
  1540. * @param {object} oSettings dataTables settings object
  1541. * @memberof DataTable#oApi
  1542. */
  1543. function _fnLanguageCompat( lang )
  1544. {
  1545. // Note the use of the Hungarian notation for the parameters in this method as
  1546. // this is called after the mapping of camelCase to Hungarian
  1547. var defaults = DataTable.defaults.oLanguage;
  1548. // Default mapping
  1549. var defaultDecimal = defaults.sDecimal;
  1550. if ( defaultDecimal ) {
  1551. _addNumericSort( defaultDecimal );
  1552. }
  1553. if ( lang ) {
  1554. var zeroRecords = lang.sZeroRecords;
  1555. // Backwards compatibility - if there is no sEmptyTable given, then use the same as
  1556. // sZeroRecords - assuming that is given.
  1557. if ( ! lang.sEmptyTable && zeroRecords &&
  1558. defaults.sEmptyTable === "No data available in table" )
  1559. {
  1560. _fnMap( lang, lang, 'sZeroRecords', 'sEmptyTable' );
  1561. }
  1562. // Likewise with loading records
  1563. if ( ! lang.sLoadingRecords && zeroRecords &&
  1564. defaults.sLoadingRecords === "Loading..." )
  1565. {
  1566. _fnMap( lang, lang, 'sZeroRecords', 'sLoadingRecords' );
  1567. }
  1568. // Old parameter name of the thousands separator mapped onto the new
  1569. if ( lang.sInfoThousands ) {
  1570. lang.sThousands = lang.sInfoThousands;
  1571. }
  1572. var decimal = lang.sDecimal;
  1573. if ( decimal && defaultDecimal !== decimal ) {
  1574. _addNumericSort( decimal );
  1575. }
  1576. }
  1577. }
  1578. /**
  1579. * Map one parameter onto another
  1580. * @param {object} o Object to map
  1581. * @param {*} knew The new parameter name
  1582. * @param {*} old The old parameter name
  1583. */
  1584. var _fnCompatMap = function ( o, knew, old ) {
  1585. if ( o[ knew ] !== undefined ) {
  1586. o[ old ] = o[ knew ];
  1587. }
  1588. };
  1589. /**
  1590. * Provide backwards compatibility for the main DT options. Note that the new
  1591. * options are mapped onto the old parameters, so this is an external interface
  1592. * change only.
  1593. * @param {object} init Object to map
  1594. */
  1595. function _fnCompatOpts ( init )
  1596. {
  1597. _fnCompatMap( init, 'ordering', 'bSort' );
  1598. _fnCompatMap( init, 'orderMulti', 'bSortMulti' );
  1599. _fnCompatMap( init, 'orderClasses', 'bSortClasses' );
  1600. _fnCompatMap( init, 'orderCellsTop', 'bSortCellsTop' );
  1601. _fnCompatMap( init, 'order', 'aaSorting' );
  1602. _fnCompatMap( init, 'orderFixed', 'aaSortingFixed' );
  1603. _fnCompatMap( init, 'paging', 'bPaginate' );
  1604. _fnCompatMap( init, 'pagingType', 'sPaginationType' );
  1605. _fnCompatMap( init, 'pageLength', 'iDisplayLength' );
  1606. _fnCompatMap( init, 'searching', 'bFilter' );
  1607. // Boolean initialisation of x-scrolling
  1608. if ( typeof init.sScrollX === 'boolean' ) {
  1609. init.sScrollX = init.sScrollX ? '100%' : '';
  1610. }
  1611. if ( typeof init.scrollX === 'boolean' ) {
  1612. init.scrollX = init.scrollX ? '100%' : '';
  1613. }
  1614. // Column search objects are in an array, so it needs to be converted
  1615. // element by element
  1616. var searchCols = init.aoSearchCols;
  1617. if ( searchCols ) {
  1618. for ( var i=0, ien=searchCols.length ; i<ien ; i++ ) {
  1619. if ( searchCols[i] ) {
  1620. _fnCamelToHungarian( DataTable.models.oSearch, searchCols[i] );
  1621. }
  1622. }
  1623. }
  1624. }
  1625. /**
  1626. * Provide backwards compatibility for column options. Note that the new options
  1627. * are mapped onto the old parameters, so this is an external interface change
  1628. * only.
  1629. * @param {object} init Object to map
  1630. */
  1631. function _fnCompatCols ( init )
  1632. {
  1633. _fnCompatMap( init, 'orderable', 'bSortable' );
  1634. _fnCompatMap( init, 'orderData', 'aDataSort' );
  1635. _fnCompatMap( init, 'orderSequence', 'asSorting' );
  1636. _fnCompatMap( init, 'orderDataType', 'sortDataType' );
  1637. // orderData can be given as an integer
  1638. var dataSort = init.aDataSort;
  1639. if ( typeof dataSort === 'number' && ! Array.isArray( dataSort ) ) {
  1640. init.aDataSort = [ dataSort ];
  1641. }
  1642. }
  1643. /**
  1644. * Browser feature detection for capabilities, quirks
  1645. * @param {object} settings dataTables settings object
  1646. * @memberof DataTable#oApi
  1647. */
  1648. function _fnBrowserDetect( settings )
  1649. {
  1650. // We don't need to do this every time DataTables is constructed, the values
  1651. // calculated are specific to the browser and OS configuration which we
  1652. // don't expect to change between initialisations
  1653. if ( ! DataTable.__browser ) {
  1654. var browser = {};
  1655. DataTable.__browser = browser;
  1656. // Scrolling feature / quirks detection
  1657. var n = $('<div/>')
  1658. .css( {
  1659. position: 'fixed',
  1660. top: 0,
  1661. left: $(window).scrollLeft()*-1, // allow for scrolling
  1662. height: 1,
  1663. width: 1,
  1664. overflow: 'hidden'
  1665. } )
  1666. .append(
  1667. $('<div/>')
  1668. .css( {
  1669. position: 'absolute',
  1670. top: 1,
  1671. left: 1,
  1672. width: 100,
  1673. overflow: 'scroll'
  1674. } )
  1675. .append(
  1676. $('<div/>')
  1677. .css( {
  1678. width: '100%',
  1679. height: 10
  1680. } )
  1681. )
  1682. )
  1683. .appendTo( 'body' );
  1684. var outer = n.children();
  1685. var inner = outer.children();
  1686. // Numbers below, in order, are:
  1687. // inner.offsetWidth, inner.clientWidth, outer.offsetWidth, outer.clientWidth
  1688. //
  1689. // IE6 XP: 100 100 100 83
  1690. // IE7 Vista: 100 100 100 83
  1691. // IE 8+ Windows: 83 83 100 83
  1692. // Evergreen Windows: 83 83 100 83
  1693. // Evergreen Mac with scrollbars: 85 85 100 85
  1694. // Evergreen Mac without scrollbars: 100 100 100 100
  1695. // Get scrollbar width
  1696. browser.barWidth = outer[0].offsetWidth - outer[0].clientWidth;
  1697. // IE6/7 will oversize a width 100% element inside a scrolling element, to
  1698. // include the width of the scrollbar, while other browsers ensure the inner
  1699. // element is contained without forcing scrolling
  1700. browser.bScrollOversize = inner[0].offsetWidth === 100 && outer[0].clientWidth !== 100;
  1701. // In rtl text layout, some browsers (most, but not all) will place the
  1702. // scrollbar on the left, rather than the right.
  1703. browser.bScrollbarLeft = Math.round( inner.offset().left ) !== 1;
  1704. // IE8- don't provide height and width for getBoundingClientRect
  1705. browser.bBounding = n[0].getBoundingClientRect().width ? true : false;
  1706. n.remove();
  1707. }
  1708. $.extend( settings.oBrowser, DataTable.__browser );
  1709. settings.oScroll.iBarWidth = DataTable.__browser.barWidth;
  1710. }
  1711. /**
  1712. * Array.prototype reduce[Right] method, used for browsers which don't support
  1713. * JS 1.6. Done this way to reduce code size, since we iterate either way
  1714. * @param {object} settings dataTables settings object
  1715. * @memberof DataTable#oApi
  1716. */
  1717. function _fnReduce ( that, fn, init, start, end, inc )
  1718. {
  1719. var
  1720. i = start,
  1721. value,
  1722. isSet = false;
  1723. if ( init !== undefined ) {
  1724. value = init;
  1725. isSet = true;
  1726. }
  1727. while ( i !== end ) {
  1728. if ( ! that.hasOwnProperty(i) ) {
  1729. continue;
  1730. }
  1731. value = isSet ?
  1732. fn( value, that[i], i, that ) :
  1733. that[i];
  1734. isSet = true;
  1735. i += inc;
  1736. }
  1737. return value;
  1738. }
  1739. /**
  1740. * Add a column to the list used for the table with default values
  1741. * @param {object} oSettings dataTables settings object
  1742. * @param {node} nTh The th element for this column
  1743. * @memberof DataTable#oApi
  1744. */
  1745. function _fnAddColumn( oSettings, nTh )
  1746. {
  1747. // Add column to aoColumns array
  1748. var oDefaults = DataTable.defaults.column;
  1749. var iCol = oSettings.aoColumns.length;
  1750. var oCol = $.extend( {}, DataTable.models.oColumn, oDefaults, {
  1751. "nTh": nTh ? nTh : document.createElement('th'),
  1752. "sTitle": oDefaults.sTitle ? oDefaults.sTitle : nTh ? nTh.innerHTML : '',
  1753. "aDataSort": oDefaults.aDataSort ? oDefaults.aDataSort : [iCol],
  1754. "mData": oDefaults.mData ? oDefaults.mData : iCol,
  1755. idx: iCol
  1756. } );
  1757. oSettings.aoColumns.push( oCol );
  1758. // Add search object for column specific search. Note that the `searchCols[ iCol ]`
  1759. // passed into extend can be undefined. This allows the user to give a default
  1760. // with only some of the parameters defined, and also not give a default
  1761. var searchCols = oSettings.aoPreSearchCols;
  1762. searchCols[ iCol ] = $.extend( {}, DataTable.models.oSearch, searchCols[ iCol ] );
  1763. // Use the default column options function to initialise classes etc
  1764. _fnColumnOptions( oSettings, iCol, $(nTh).data() );
  1765. }
  1766. /**
  1767. * Apply options for a column
  1768. * @param {object} oSettings dataTables settings object
  1769. * @param {int} iCol column index to consider
  1770. * @param {object} oOptions object with sType, bVisible and bSearchable etc
  1771. * @memberof DataTable#oApi
  1772. */
  1773. function _fnColumnOptions( oSettings, iCol, oOptions )
  1774. {
  1775. var oCol = oSettings.aoColumns[ iCol ];
  1776. var oClasses = oSettings.oClasses;
  1777. var th = $(oCol.nTh);
  1778. // Try to get width information from the DOM. We can't get it from CSS
  1779. // as we'd need to parse the CSS stylesheet. `width` option can override
  1780. if ( ! oCol.sWidthOrig ) {
  1781. // Width attribute
  1782. oCol.sWidthOrig = th.attr('width') || null;
  1783. // Style attribute
  1784. var t = (th.attr('style') || '').match(/width:\s*(\d+[pxem%]+)/);
  1785. if ( t ) {
  1786. oCol.sWidthOrig = t[1];
  1787. }
  1788. }
  1789. /* User specified column options */
  1790. if ( oOptions !== undefined && oOptions !== null )
  1791. {
  1792. // Backwards compatibility
  1793. _fnCompatCols( oOptions );
  1794. // Map camel case parameters to their Hungarian counterparts
  1795. _fnCamelToHungarian( DataTable.defaults.column, oOptions, true );
  1796. /* Backwards compatibility for mDataProp */
  1797. if ( oOptions.mDataProp !== undefined && !oOptions.mData )
  1798. {
  1799. oOptions.mData = oOptions.mDataProp;
  1800. }
  1801. if ( oOptions.sType )
  1802. {
  1803. oCol._sManualType = oOptions.sType;
  1804. }
  1805. // `class` is a reserved word in Javascript, so we need to provide
  1806. // the ability to use a valid name for the camel case input
  1807. if ( oOptions.className && ! oOptions.sClass )
  1808. {
  1809. oOptions.sClass = oOptions.className;
  1810. }
  1811. if ( oOptions.sClass ) {
  1812. th.addClass( oOptions.sClass );
  1813. }
  1814. $.extend( oCol, oOptions );
  1815. _fnMap( oCol, oOptions, "sWidth", "sWidthOrig" );
  1816. /* iDataSort to be applied (backwards compatibility), but aDataSort will take
  1817. * priority if defined
  1818. */
  1819. if ( oOptions.iDataSort !== undefined )
  1820. {
  1821. oCol.aDataSort = [ oOptions.iDataSort ];
  1822. }
  1823. _fnMap( oCol, oOptions, "aDataSort" );
  1824. }
  1825. /* Cache the data get and set functions for speed */
  1826. var mDataSrc = oCol.mData;
  1827. var mData = _fnGetObjectDataFn( mDataSrc );
  1828. var mRender = oCol.mRender ? _fnGetObjectDataFn( oCol.mRender ) : null;
  1829. var attrTest = function( src ) {
  1830. return typeof src === 'string' && src.indexOf('@') !== -1;
  1831. };
  1832. oCol._bAttrSrc = $.isPlainObject( mDataSrc ) && (
  1833. attrTest(mDataSrc.sort) || attrTest(mDataSrc.type) || attrTest(mDataSrc.filter)
  1834. );
  1835. oCol._setter = null;
  1836. oCol.fnGetData = function (rowData, type, meta) {
  1837. var innerData = mData( rowData, type, undefined, meta );
  1838. return mRender && type ?
  1839. mRender( innerData, type, rowData, meta ) :
  1840. innerData;
  1841. };
  1842. oCol.fnSetData = function ( rowData, val, meta ) {
  1843. return _fnSetObjectDataFn( mDataSrc )( rowData, val, meta );
  1844. };
  1845. // Indicate if DataTables should read DOM data as an object or array
  1846. // Used in _fnGetRowElements
  1847. if ( typeof mDataSrc !== 'number' ) {
  1848. oSettings._rowReadObject = true;
  1849. }
  1850. /* Feature sorting overrides column specific when off */
  1851. if ( !oSettings.oFeatures.bSort )
  1852. {
  1853. oCol.bSortable = false;
  1854. th.addClass( oClasses.sSortableNone ); // Have to add class here as order event isn't called
  1855. }
  1856. /* Check that the class assignment is correct for sorting */
  1857. var bAsc = $.inArray('asc', oCol.asSorting) !== -1;
  1858. var bDesc = $.inArray('desc', oCol.asSorting) !== -1;
  1859. if ( !oCol.bSortable || (!bAsc && !bDesc) )
  1860. {
  1861. oCol.sSortingClass = oClasses.sSortableNone;
  1862. oCol.sSortingClassJUI = "";
  1863. }
  1864. else if ( bAsc && !bDesc )
  1865. {
  1866. oCol.sSortingClass = oClasses.sSortableAsc;
  1867. oCol.sSortingClassJUI = oClasses.sSortJUIAscAllowed;
  1868. }
  1869. else if ( !bAsc && bDesc )
  1870. {
  1871. oCol.sSortingClass = oClasses.sSortableDesc;
  1872. oCol.sSortingClassJUI = oClasses.sSortJUIDescAllowed;
  1873. }
  1874. else
  1875. {
  1876. oCol.sSortingClass = oClasses.sSortable;
  1877. oCol.sSortingClassJUI = oClasses.sSortJUI;
  1878. }
  1879. }
  1880. /**
  1881. * Adjust the table column widths for new data. Note: you would probably want to
  1882. * do a redraw after calling this function!
  1883. * @param {object} settings dataTables settings object
  1884. * @memberof DataTable#oApi
  1885. */
  1886. function _fnAdjustColumnSizing ( settings )
  1887. {
  1888. /* Not interested in doing column width calculation if auto-width is disabled */
  1889. if ( settings.oFeatures.bAutoWidth !== false )
  1890. {
  1891. var columns = settings.aoColumns;
  1892. _fnCalculateColumnWidths( settings );
  1893. for ( var i=0 , iLen=columns.length ; i<iLen ; i++ )
  1894. {
  1895. columns[i].nTh.style.width = columns[i].sWidth;
  1896. }
  1897. }
  1898. var scroll = settings.oScroll;
  1899. if ( scroll.sY !== '' || scroll.sX !== '')
  1900. {
  1901. _fnScrollDraw( settings );
  1902. }
  1903. _fnCallbackFire( settings, null, 'column-sizing', [settings] );
  1904. }
  1905. /**
  1906. * Covert the index of a visible column to the index in the data array (take account
  1907. * of hidden columns)
  1908. * @param {object} oSettings dataTables settings object
  1909. * @param {int} iMatch Visible column index to lookup
  1910. * @returns {int} i the data index
  1911. * @memberof DataTable#oApi
  1912. */
  1913. function _fnVisibleToColumnIndex( oSettings, iMatch )
  1914. {
  1915. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  1916. return typeof aiVis[iMatch] === 'number' ?
  1917. aiVis[iMatch] :
  1918. null;
  1919. }
  1920. /**
  1921. * Covert the index of an index in the data array and convert it to the visible
  1922. * column index (take account of hidden columns)
  1923. * @param {int} iMatch Column index to lookup
  1924. * @param {object} oSettings dataTables settings object
  1925. * @returns {int} i the data index
  1926. * @memberof DataTable#oApi
  1927. */
  1928. function _fnColumnIndexToVisible( oSettings, iMatch )
  1929. {
  1930. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  1931. var iPos = $.inArray( iMatch, aiVis );
  1932. return iPos !== -1 ? iPos : null;
  1933. }
  1934. /**
  1935. * Get the number of visible columns
  1936. * @param {object} oSettings dataTables settings object
  1937. * @returns {int} i the number of visible columns
  1938. * @memberof DataTable#oApi
  1939. */
  1940. function _fnVisbleColumns( oSettings )
  1941. {
  1942. var vis = 0;
  1943. // No reduce in IE8, use a loop for now
  1944. $.each( oSettings.aoColumns, function ( i, col ) {
  1945. if ( col.bVisible && $(col.nTh).css('display') !== 'none' ) {
  1946. vis++;
  1947. }
  1948. } );
  1949. return vis;
  1950. }
  1951. /**
  1952. * Get an array of column indexes that match a given property
  1953. * @param {object} oSettings dataTables settings object
  1954. * @param {string} sParam Parameter in aoColumns to look for - typically
  1955. * bVisible or bSearchable
  1956. * @returns {array} Array of indexes with matched properties
  1957. * @memberof DataTable#oApi
  1958. */
  1959. function _fnGetColumns( oSettings, sParam )
  1960. {
  1961. var a = [];
  1962. $.map( oSettings.aoColumns, function(val, i) {
  1963. if ( val[sParam] ) {
  1964. a.push( i );
  1965. }
  1966. } );
  1967. return a;
  1968. }
  1969. /**
  1970. * Calculate the 'type' of a column
  1971. * @param {object} settings dataTables settings object
  1972. * @memberof DataTable#oApi
  1973. */
  1974. function _fnColumnTypes ( settings )
  1975. {
  1976. var columns = settings.aoColumns;
  1977. var data = settings.aoData;
  1978. var types = DataTable.ext.type.detect;
  1979. var i, ien, j, jen, k, ken;
  1980. var col, cell, detectedType, cache;
  1981. // For each column, spin over the
  1982. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  1983. col = columns[i];
  1984. cache = [];
  1985. if ( ! col.sType && col._sManualType ) {
  1986. col.sType = col._sManualType;
  1987. }
  1988. else if ( ! col.sType ) {
  1989. for ( j=0, jen=types.length ; j<jen ; j++ ) {
  1990. for ( k=0, ken=data.length ; k<ken ; k++ ) {
  1991. // Use a cache array so we only need to get the type data
  1992. // from the formatter once (when using multiple detectors)
  1993. if ( cache[k] === undefined ) {
  1994. cache[k] = _fnGetCellData( settings, k, i, 'type' );
  1995. }
  1996. detectedType = types[j]( cache[k], settings );
  1997. // If null, then this type can't apply to this column, so
  1998. // rather than testing all cells, break out. There is an
  1999. // exception for the last type which is `html`. We need to
  2000. // scan all rows since it is possible to mix string and HTML
  2001. // types
  2002. if ( ! detectedType && j !== types.length-1 ) {
  2003. break;
  2004. }
  2005. // Only a single match is needed for html type since it is
  2006. // bottom of the pile and very similar to string - but it
  2007. // must not be empty
  2008. if ( detectedType === 'html' && ! _empty(cache[k]) ) {
  2009. break;
  2010. }
  2011. }
  2012. // Type is valid for all data points in the column - use this
  2013. // type
  2014. if ( detectedType ) {
  2015. col.sType = detectedType;
  2016. break;
  2017. }
  2018. }
  2019. // Fall back - if no type was detected, always use string
  2020. if ( ! col.sType ) {
  2021. col.sType = 'string';
  2022. }
  2023. }
  2024. }
  2025. }
  2026. /**
  2027. * Take the column definitions and static columns arrays and calculate how
  2028. * they relate to column indexes. The callback function will then apply the
  2029. * definition found for a column to a suitable configuration object.
  2030. * @param {object} oSettings dataTables settings object
  2031. * @param {array} aoColDefs The aoColumnDefs array that is to be applied
  2032. * @param {array} aoCols The aoColumns array that defines columns individually
  2033. * @param {function} fn Callback function - takes two parameters, the calculated
  2034. * column index and the definition for that column.
  2035. * @memberof DataTable#oApi
  2036. */
  2037. function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, fn )
  2038. {
  2039. var i, iLen, j, jLen, k, kLen, def;
  2040. var columns = oSettings.aoColumns;
  2041. // Column definitions with aTargets
  2042. if ( aoColDefs )
  2043. {
  2044. /* Loop over the definitions array - loop in reverse so first instance has priority */
  2045. for ( i=aoColDefs.length-1 ; i>=0 ; i-- )
  2046. {
  2047. def = aoColDefs[i];
  2048. /* Each definition can target multiple columns, as it is an array */
  2049. var aTargets = def.targets !== undefined ?
  2050. def.targets :
  2051. def.aTargets;
  2052. if ( ! Array.isArray( aTargets ) )
  2053. {
  2054. aTargets = [ aTargets ];
  2055. }
  2056. for ( j=0, jLen=aTargets.length ; j<jLen ; j++ )
  2057. {
  2058. if ( typeof aTargets[j] === 'number' && aTargets[j] >= 0 )
  2059. {
  2060. /* Add columns that we don't yet know about */
  2061. while( columns.length <= aTargets[j] )
  2062. {
  2063. _fnAddColumn( oSettings );
  2064. }
  2065. /* Integer, basic index */
  2066. fn( aTargets[j], def );
  2067. }
  2068. else if ( typeof aTargets[j] === 'number' && aTargets[j] < 0 )
  2069. {
  2070. /* Negative integer, right to left column counting */
  2071. fn( columns.length+aTargets[j], def );
  2072. }
  2073. else if ( typeof aTargets[j] === 'string' )
  2074. {
  2075. /* Class name matching on TH element */
  2076. for ( k=0, kLen=columns.length ; k<kLen ; k++ )
  2077. {
  2078. if ( aTargets[j] == "_all" ||
  2079. $(columns[k].nTh).hasClass( aTargets[j] ) )
  2080. {
  2081. fn( k, def );
  2082. }
  2083. }
  2084. }
  2085. }
  2086. }
  2087. }
  2088. // Statically defined columns array
  2089. if ( aoCols )
  2090. {
  2091. for ( i=0, iLen=aoCols.length ; i<iLen ; i++ )
  2092. {
  2093. fn( i, aoCols[i] );
  2094. }
  2095. }
  2096. }
  2097. /**
  2098. * Add a data array to the table, creating DOM node etc. This is the parallel to
  2099. * _fnGatherData, but for adding rows from a Javascript source, rather than a
  2100. * DOM source.
  2101. * @param {object} oSettings dataTables settings object
  2102. * @param {array} aData data array to be added
  2103. * @param {node} [nTr] TR element to add to the table - optional. If not given,
  2104. * DataTables will create a row automatically
  2105. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  2106. * if nTr is.
  2107. * @returns {int} >=0 if successful (index of new aoData entry), -1 if failed
  2108. * @memberof DataTable#oApi
  2109. */
  2110. function _fnAddData ( oSettings, aDataIn, nTr, anTds )
  2111. {
  2112. /* Create the object for storing information about this new row */
  2113. var iRow = oSettings.aoData.length;
  2114. var oData = $.extend( true, {}, DataTable.models.oRow, {
  2115. src: nTr ? 'dom' : 'data',
  2116. idx: iRow
  2117. } );
  2118. oData._aData = aDataIn;
  2119. oSettings.aoData.push( oData );
  2120. /* Create the cells */
  2121. var nTd, sThisType;
  2122. var columns = oSettings.aoColumns;
  2123. // Invalidate the column types as the new data needs to be revalidated
  2124. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  2125. {
  2126. columns[i].sType = null;
  2127. }
  2128. /* Add to the display array */
  2129. oSettings.aiDisplayMaster.push( iRow );
  2130. var id = oSettings.rowIdFn( aDataIn );
  2131. if ( id !== undefined ) {
  2132. oSettings.aIds[ id ] = oData;
  2133. }
  2134. /* Create the DOM information, or register it if already present */
  2135. if ( nTr || ! oSettings.oFeatures.bDeferRender )
  2136. {
  2137. _fnCreateTr( oSettings, iRow, nTr, anTds );
  2138. }
  2139. return iRow;
  2140. }
  2141. /**
  2142. * Add one or more TR elements to the table. Generally we'd expect to
  2143. * use this for reading data from a DOM sourced table, but it could be
  2144. * used for an TR element. Note that if a TR is given, it is used (i.e.
  2145. * it is not cloned).
  2146. * @param {object} settings dataTables settings object
  2147. * @param {array|node|jQuery} trs The TR element(s) to add to the table
  2148. * @returns {array} Array of indexes for the added rows
  2149. * @memberof DataTable#oApi
  2150. */
  2151. function _fnAddTr( settings, trs )
  2152. {
  2153. var row;
  2154. // Allow an individual node to be passed in
  2155. if ( ! (trs instanceof $) ) {
  2156. trs = $(trs);
  2157. }
  2158. return trs.map( function (i, el) {
  2159. row = _fnGetRowElements( settings, el );
  2160. return _fnAddData( settings, row.data, el, row.cells );
  2161. } );
  2162. }
  2163. /**
  2164. * Take a TR element and convert it to an index in aoData
  2165. * @param {object} oSettings dataTables settings object
  2166. * @param {node} n the TR element to find
  2167. * @returns {int} index if the node is found, null if not
  2168. * @memberof DataTable#oApi
  2169. */
  2170. function _fnNodeToDataIndex( oSettings, n )
  2171. {
  2172. return (n._DT_RowIndex!==undefined) ? n._DT_RowIndex : null;
  2173. }
  2174. /**
  2175. * Take a TD element and convert it into a column data index (not the visible index)
  2176. * @param {object} oSettings dataTables settings object
  2177. * @param {int} iRow The row number the TD/TH can be found in
  2178. * @param {node} n The TD/TH element to find
  2179. * @returns {int} index if the node is found, -1 if not
  2180. * @memberof DataTable#oApi
  2181. */
  2182. function _fnNodeToColumnIndex( oSettings, iRow, n )
  2183. {
  2184. return $.inArray( n, oSettings.aoData[ iRow ].anCells );
  2185. }
  2186. /**
  2187. * Get the data for a given cell from the internal cache, taking into account data mapping
  2188. * @param {object} settings dataTables settings object
  2189. * @param {int} rowIdx aoData row id
  2190. * @param {int} colIdx Column index
  2191. * @param {string} type data get type ('display', 'type' 'filter' 'sort')
  2192. * @returns {*} Cell data
  2193. * @memberof DataTable#oApi
  2194. */
  2195. function _fnGetCellData( settings, rowIdx, colIdx, type )
  2196. {
  2197. var draw = settings.iDraw;
  2198. var col = settings.aoColumns[colIdx];
  2199. var rowData = settings.aoData[rowIdx]._aData;
  2200. var defaultContent = col.sDefaultContent;
  2201. var cellData = col.fnGetData( rowData, type, {
  2202. settings: settings,
  2203. row: rowIdx,
  2204. col: colIdx
  2205. } );
  2206. if ( cellData === undefined ) {
  2207. if ( settings.iDrawError != draw && defaultContent === null ) {
  2208. _fnLog( settings, 0, "Requested unknown parameter "+
  2209. (typeof col.mData=='function' ? '{function}' : "'"+col.mData+"'")+
  2210. " for row "+rowIdx+", column "+colIdx, 4 );
  2211. settings.iDrawError = draw;
  2212. }
  2213. return defaultContent;
  2214. }
  2215. // When the data source is null and a specific data type is requested (i.e.
  2216. // not the original data), we can use default column data
  2217. if ( (cellData === rowData || cellData === null) && defaultContent !== null && type !== undefined ) {
  2218. cellData = defaultContent;
  2219. }
  2220. else if ( typeof cellData === 'function' ) {
  2221. // If the data source is a function, then we run it and use the return,
  2222. // executing in the scope of the data object (for instances)
  2223. return cellData.call( rowData );
  2224. }
  2225. if ( cellData === null && type == 'display' ) {
  2226. return '';
  2227. }
  2228. return cellData;
  2229. }
  2230. /**
  2231. * Set the value for a specific cell, into the internal data cache
  2232. * @param {object} settings dataTables settings object
  2233. * @param {int} rowIdx aoData row id
  2234. * @param {int} colIdx Column index
  2235. * @param {*} val Value to set
  2236. * @memberof DataTable#oApi
  2237. */
  2238. function _fnSetCellData( settings, rowIdx, colIdx, val )
  2239. {
  2240. var col = settings.aoColumns[colIdx];
  2241. var rowData = settings.aoData[rowIdx]._aData;
  2242. col.fnSetData( rowData, val, {
  2243. settings: settings,
  2244. row: rowIdx,
  2245. col: colIdx
  2246. } );
  2247. }
  2248. // Private variable that is used to match action syntax in the data property object
  2249. var __reArray = /\[.*?\]$/;
  2250. var __reFn = /\(\)$/;
  2251. /**
  2252. * Split string on periods, taking into account escaped periods
  2253. * @param {string} str String to split
  2254. * @return {array} Split string
  2255. */
  2256. function _fnSplitObjNotation( str )
  2257. {
  2258. return $.map( str.match(/(\\.|[^\.])+/g) || [''], function ( s ) {
  2259. return s.replace(/\\\./g, '.');
  2260. } );
  2261. }
  2262. /**
  2263. * Return a function that can be used to get data from a source object, taking
  2264. * into account the ability to use nested objects as a source
  2265. * @param {string|int|function} mSource The data source for the object
  2266. * @returns {function} Data get function
  2267. * @memberof DataTable#oApi
  2268. */
  2269. function _fnGetObjectDataFn( mSource )
  2270. {
  2271. if ( $.isPlainObject( mSource ) )
  2272. {
  2273. /* Build an object of get functions, and wrap them in a single call */
  2274. var o = {};
  2275. $.each( mSource, function (key, val) {
  2276. if ( val ) {
  2277. o[key] = _fnGetObjectDataFn( val );
  2278. }
  2279. } );
  2280. return function (data, type, row, meta) {
  2281. var t = o[type] || o._;
  2282. return t !== undefined ?
  2283. t(data, type, row, meta) :
  2284. data;
  2285. };
  2286. }
  2287. else if ( mSource === null )
  2288. {
  2289. /* Give an empty string for rendering / sorting etc */
  2290. return function (data) { // type, row and meta also passed, but not used
  2291. return data;
  2292. };
  2293. }
  2294. else if ( typeof mSource === 'function' )
  2295. {
  2296. return function (data, type, row, meta) {
  2297. return mSource( data, type, row, meta );
  2298. };
  2299. }
  2300. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  2301. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  2302. {
  2303. /* If there is a . in the source string then the data source is in a
  2304. * nested object so we loop over the data for each level to get the next
  2305. * level down. On each loop we test for undefined, and if found immediately
  2306. * return. This allows entire objects to be missing and sDefaultContent to
  2307. * be used if defined, rather than throwing an error
  2308. */
  2309. var fetchData = function (data, type, src) {
  2310. var arrayNotation, funcNotation, out, innerSrc;
  2311. if ( src !== "" )
  2312. {
  2313. var a = _fnSplitObjNotation( src );
  2314. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  2315. {
  2316. // Check if we are dealing with special notation
  2317. arrayNotation = a[i].match(__reArray);
  2318. funcNotation = a[i].match(__reFn);
  2319. if ( arrayNotation )
  2320. {
  2321. // Array notation
  2322. a[i] = a[i].replace(__reArray, '');
  2323. // Condition allows simply [] to be passed in
  2324. if ( a[i] !== "" ) {
  2325. data = data[ a[i] ];
  2326. }
  2327. out = [];
  2328. // Get the remainder of the nested object to get
  2329. a.splice( 0, i+1 );
  2330. innerSrc = a.join('.');
  2331. // Traverse each entry in the array getting the properties requested
  2332. if ( Array.isArray( data ) ) {
  2333. for ( var j=0, jLen=data.length ; j<jLen ; j++ ) {
  2334. out.push( fetchData( data[j], type, innerSrc ) );
  2335. }
  2336. }
  2337. // If a string is given in between the array notation indicators, that
  2338. // is used to join the strings together, otherwise an array is returned
  2339. var join = arrayNotation[0].substring(1, arrayNotation[0].length-1);
  2340. data = (join==="") ? out : out.join(join);
  2341. // The inner call to fetchData has already traversed through the remainder
  2342. // of the source requested, so we exit from the loop
  2343. break;
  2344. }
  2345. else if ( funcNotation )
  2346. {
  2347. // Function call
  2348. a[i] = a[i].replace(__reFn, '');
  2349. data = data[ a[i] ]();
  2350. continue;
  2351. }
  2352. if ( data === null || data[ a[i] ] === undefined )
  2353. {
  2354. return undefined;
  2355. }
  2356. data = data[ a[i] ];
  2357. }
  2358. }
  2359. return data;
  2360. };
  2361. return function (data, type) { // row and meta also passed, but not used
  2362. return fetchData( data, type, mSource );
  2363. };
  2364. }
  2365. else
  2366. {
  2367. /* Array or flat object mapping */
  2368. return function (data, type) { // row and meta also passed, but not used
  2369. return data[mSource];
  2370. };
  2371. }
  2372. }
  2373. /**
  2374. * Return a function that can be used to set data from a source object, taking
  2375. * into account the ability to use nested objects as a source
  2376. * @param {string|int|function} mSource The data source for the object
  2377. * @returns {function} Data set function
  2378. * @memberof DataTable#oApi
  2379. */
  2380. function _fnSetObjectDataFn( mSource )
  2381. {
  2382. if ( $.isPlainObject( mSource ) )
  2383. {
  2384. /* Unlike get, only the underscore (global) option is used for for
  2385. * setting data since we don't know the type here. This is why an object
  2386. * option is not documented for `mData` (which is read/write), but it is
  2387. * for `mRender` which is read only.
  2388. */
  2389. return _fnSetObjectDataFn( mSource._ );
  2390. }
  2391. else if ( mSource === null )
  2392. {
  2393. /* Nothing to do when the data source is null */
  2394. return function () {};
  2395. }
  2396. else if ( typeof mSource === 'function' )
  2397. {
  2398. return function (data, val, meta) {
  2399. mSource( data, 'set', val, meta );
  2400. };
  2401. }
  2402. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  2403. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  2404. {
  2405. /* Like the get, we need to get data from a nested object */
  2406. var setData = function (data, val, src) {
  2407. var a = _fnSplitObjNotation( src ), b;
  2408. var aLast = a[a.length-1];
  2409. var arrayNotation, funcNotation, o, innerSrc;
  2410. for ( var i=0, iLen=a.length-1 ; i<iLen ; i++ )
  2411. {
  2412. // Protect against prototype pollution
  2413. if (a[i] === '__proto__' || a[i] === 'constructor') {
  2414. throw new Error('Cannot set prototype values');
  2415. }
  2416. // Check if we are dealing with an array notation request
  2417. arrayNotation = a[i].match(__reArray);
  2418. funcNotation = a[i].match(__reFn);
  2419. if ( arrayNotation )
  2420. {
  2421. a[i] = a[i].replace(__reArray, '');
  2422. data[ a[i] ] = [];
  2423. // Get the remainder of the nested object to set so we can recurse
  2424. b = a.slice();
  2425. b.splice( 0, i+1 );
  2426. innerSrc = b.join('.');
  2427. // Traverse each entry in the array setting the properties requested
  2428. if ( Array.isArray( val ) )
  2429. {
  2430. for ( var j=0, jLen=val.length ; j<jLen ; j++ )
  2431. {
  2432. o = {};
  2433. setData( o, val[j], innerSrc );
  2434. data[ a[i] ].push( o );
  2435. }
  2436. }
  2437. else
  2438. {
  2439. // We've been asked to save data to an array, but it
  2440. // isn't array data to be saved. Best that can be done
  2441. // is to just save the value.
  2442. data[ a[i] ] = val;
  2443. }
  2444. // The inner call to setData has already traversed through the remainder
  2445. // of the source and has set the data, thus we can exit here
  2446. return;
  2447. }
  2448. else if ( funcNotation )
  2449. {
  2450. // Function call
  2451. a[i] = a[i].replace(__reFn, '');
  2452. data = data[ a[i] ]( val );
  2453. }
  2454. // If the nested object doesn't currently exist - since we are
  2455. // trying to set the value - create it
  2456. if ( data[ a[i] ] === null || data[ a[i] ] === undefined )
  2457. {
  2458. data[ a[i] ] = {};
  2459. }
  2460. data = data[ a[i] ];
  2461. }
  2462. // Last item in the input - i.e, the actual set
  2463. if ( aLast.match(__reFn ) )
  2464. {
  2465. // Function call
  2466. data = data[ aLast.replace(__reFn, '') ]( val );
  2467. }
  2468. else
  2469. {
  2470. // If array notation is used, we just want to strip it and use the property name
  2471. // and assign the value. If it isn't used, then we get the result we want anyway
  2472. data[ aLast.replace(__reArray, '') ] = val;
  2473. }
  2474. };
  2475. return function (data, val) { // meta is also passed in, but not used
  2476. return setData( data, val, mSource );
  2477. };
  2478. }
  2479. else
  2480. {
  2481. /* Array or flat object mapping */
  2482. return function (data, val) { // meta is also passed in, but not used
  2483. data[mSource] = val;
  2484. };
  2485. }
  2486. }
  2487. /**
  2488. * Return an array with the full table data
  2489. * @param {object} oSettings dataTables settings object
  2490. * @returns array {array} aData Master data array
  2491. * @memberof DataTable#oApi
  2492. */
  2493. function _fnGetDataMaster ( settings )
  2494. {
  2495. return _pluck( settings.aoData, '_aData' );
  2496. }
  2497. /**
  2498. * Nuke the table
  2499. * @param {object} oSettings dataTables settings object
  2500. * @memberof DataTable#oApi
  2501. */
  2502. function _fnClearTable( settings )
  2503. {
  2504. settings.aoData.length = 0;
  2505. settings.aiDisplayMaster.length = 0;
  2506. settings.aiDisplay.length = 0;
  2507. settings.aIds = {};
  2508. }
  2509. /**
  2510. * Take an array of integers (index array) and remove a target integer (value - not
  2511. * the key!)
  2512. * @param {array} a Index array to target
  2513. * @param {int} iTarget value to find
  2514. * @memberof DataTable#oApi
  2515. */
  2516. function _fnDeleteIndex( a, iTarget, splice )
  2517. {
  2518. var iTargetIndex = -1;
  2519. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  2520. {
  2521. if ( a[i] == iTarget )
  2522. {
  2523. iTargetIndex = i;
  2524. }
  2525. else if ( a[i] > iTarget )
  2526. {
  2527. a[i]--;
  2528. }
  2529. }
  2530. if ( iTargetIndex != -1 && splice === undefined )
  2531. {
  2532. a.splice( iTargetIndex, 1 );
  2533. }
  2534. }
  2535. /**
  2536. * Mark cached data as invalid such that a re-read of the data will occur when
  2537. * the cached data is next requested. Also update from the data source object.
  2538. *
  2539. * @param {object} settings DataTables settings object
  2540. * @param {int} rowIdx Row index to invalidate
  2541. * @param {string} [src] Source to invalidate from: undefined, 'auto', 'dom'
  2542. * or 'data'
  2543. * @param {int} [colIdx] Column index to invalidate. If undefined the whole
  2544. * row will be invalidated
  2545. * @memberof DataTable#oApi
  2546. *
  2547. * @todo For the modularisation of v1.11 this will need to become a callback, so
  2548. * the sort and filter methods can subscribe to it. That will required
  2549. * initialisation options for sorting, which is why it is not already baked in
  2550. */
  2551. function _fnInvalidate( settings, rowIdx, src, colIdx )
  2552. {
  2553. var row = settings.aoData[ rowIdx ];
  2554. var i, ien;
  2555. var cellWrite = function ( cell, col ) {
  2556. // This is very frustrating, but in IE if you just write directly
  2557. // to innerHTML, and elements that are overwritten are GC'ed,
  2558. // even if there is a reference to them elsewhere
  2559. while ( cell.childNodes.length ) {
  2560. cell.removeChild( cell.firstChild );
  2561. }
  2562. cell.innerHTML = _fnGetCellData( settings, rowIdx, col, 'display' );
  2563. };
  2564. // Are we reading last data from DOM or the data object?
  2565. if ( src === 'dom' || ((! src || src === 'auto') && row.src === 'dom') ) {
  2566. // Read the data from the DOM
  2567. row._aData = _fnGetRowElements(
  2568. settings, row, colIdx, colIdx === undefined ? undefined : row._aData
  2569. )
  2570. .data;
  2571. }
  2572. else {
  2573. // Reading from data object, update the DOM
  2574. var cells = row.anCells;
  2575. if ( cells ) {
  2576. if ( colIdx !== undefined ) {
  2577. cellWrite( cells[colIdx], colIdx );
  2578. }
  2579. else {
  2580. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  2581. cellWrite( cells[i], i );
  2582. }
  2583. }
  2584. }
  2585. }
  2586. // For both row and cell invalidation, the cached data for sorting and
  2587. // filtering is nulled out
  2588. row._aSortData = null;
  2589. row._aFilterData = null;
  2590. // Invalidate the type for a specific column (if given) or all columns since
  2591. // the data might have changed
  2592. var cols = settings.aoColumns;
  2593. if ( colIdx !== undefined ) {
  2594. cols[ colIdx ].sType = null;
  2595. }
  2596. else {
  2597. for ( i=0, ien=cols.length ; i<ien ; i++ ) {
  2598. cols[i].sType = null;
  2599. }
  2600. // Update DataTables special `DT_*` attributes for the row
  2601. _fnRowAttributes( settings, row );
  2602. }
  2603. }
  2604. /**
  2605. * Build a data source object from an HTML row, reading the contents of the
  2606. * cells that are in the row.
  2607. *
  2608. * @param {object} settings DataTables settings object
  2609. * @param {node|object} TR element from which to read data or existing row
  2610. * object from which to re-read the data from the cells
  2611. * @param {int} [colIdx] Optional column index
  2612. * @param {array|object} [d] Data source object. If `colIdx` is given then this
  2613. * parameter should also be given and will be used to write the data into.
  2614. * Only the column in question will be written
  2615. * @returns {object} Object with two parameters: `data` the data read, in
  2616. * document order, and `cells` and array of nodes (they can be useful to the
  2617. * caller, so rather than needing a second traversal to get them, just return
  2618. * them from here).
  2619. * @memberof DataTable#oApi
  2620. */
  2621. function _fnGetRowElements( settings, row, colIdx, d )
  2622. {
  2623. var
  2624. tds = [],
  2625. td = row.firstChild,
  2626. name, col, o, i=0, contents,
  2627. columns = settings.aoColumns,
  2628. objectRead = settings._rowReadObject;
  2629. // Allow the data object to be passed in, or construct
  2630. d = d !== undefined ?
  2631. d :
  2632. objectRead ?
  2633. {} :
  2634. [];
  2635. var attr = function ( str, td ) {
  2636. if ( typeof str === 'string' ) {
  2637. var idx = str.indexOf('@');
  2638. if ( idx !== -1 ) {
  2639. var attr = str.substring( idx+1 );
  2640. var setter = _fnSetObjectDataFn( str );
  2641. setter( d, td.getAttribute( attr ) );
  2642. }
  2643. }
  2644. };
  2645. // Read data from a cell and store into the data object
  2646. var cellProcess = function ( cell ) {
  2647. if ( colIdx === undefined || colIdx === i ) {
  2648. col = columns[i];
  2649. contents = (cell.innerHTML).trim();
  2650. if ( col && col._bAttrSrc ) {
  2651. var setter = _fnSetObjectDataFn( col.mData._ );
  2652. setter( d, contents );
  2653. attr( col.mData.sort, cell );
  2654. attr( col.mData.type, cell );
  2655. attr( col.mData.filter, cell );
  2656. }
  2657. else {
  2658. // Depending on the `data` option for the columns the data can
  2659. // be read to either an object or an array.
  2660. if ( objectRead ) {
  2661. if ( ! col._setter ) {
  2662. // Cache the setter function
  2663. col._setter = _fnSetObjectDataFn( col.mData );
  2664. }
  2665. col._setter( d, contents );
  2666. }
  2667. else {
  2668. d[i] = contents;
  2669. }
  2670. }
  2671. }
  2672. i++;
  2673. };
  2674. if ( td ) {
  2675. // `tr` element was passed in
  2676. while ( td ) {
  2677. name = td.nodeName.toUpperCase();
  2678. if ( name == "TD" || name == "TH" ) {
  2679. cellProcess( td );
  2680. tds.push( td );
  2681. }
  2682. td = td.nextSibling;
  2683. }
  2684. }
  2685. else {
  2686. // Existing row object passed in
  2687. tds = row.anCells;
  2688. for ( var j=0, jen=tds.length ; j<jen ; j++ ) {
  2689. cellProcess( tds[j] );
  2690. }
  2691. }
  2692. // Read the ID from the DOM if present
  2693. var rowNode = row.firstChild ? row : row.nTr;
  2694. if ( rowNode ) {
  2695. var id = rowNode.getAttribute( 'id' );
  2696. if ( id ) {
  2697. _fnSetObjectDataFn( settings.rowId )( d, id );
  2698. }
  2699. }
  2700. return {
  2701. data: d,
  2702. cells: tds
  2703. };
  2704. }
  2705. /**
  2706. * Create a new TR element (and it's TD children) for a row
  2707. * @param {object} oSettings dataTables settings object
  2708. * @param {int} iRow Row to consider
  2709. * @param {node} [nTrIn] TR element to add to the table - optional. If not given,
  2710. * DataTables will create a row automatically
  2711. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  2712. * if nTr is.
  2713. * @memberof DataTable#oApi
  2714. */
  2715. function _fnCreateTr ( oSettings, iRow, nTrIn, anTds )
  2716. {
  2717. var
  2718. row = oSettings.aoData[iRow],
  2719. rowData = row._aData,
  2720. cells = [],
  2721. nTr, nTd, oCol,
  2722. i, iLen, create;
  2723. if ( row.nTr === null )
  2724. {
  2725. nTr = nTrIn || document.createElement('tr');
  2726. row.nTr = nTr;
  2727. row.anCells = cells;
  2728. /* Use a private property on the node to allow reserve mapping from the node
  2729. * to the aoData array for fast look up
  2730. */
  2731. nTr._DT_RowIndex = iRow;
  2732. /* Special parameters can be given by the data source to be used on the row */
  2733. _fnRowAttributes( oSettings, row );
  2734. /* Process each column */
  2735. for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
  2736. {
  2737. oCol = oSettings.aoColumns[i];
  2738. create = nTrIn ? false : true;
  2739. nTd = create ? document.createElement( oCol.sCellType ) : anTds[i];
  2740. nTd._DT_CellIndex = {
  2741. row: iRow,
  2742. column: i
  2743. };
  2744. cells.push( nTd );
  2745. // Need to create the HTML if new, or if a rendering function is defined
  2746. if ( create || ((oCol.mRender || oCol.mData !== i) &&
  2747. (!$.isPlainObject(oCol.mData) || oCol.mData._ !== i+'.display')
  2748. )) {
  2749. nTd.innerHTML = _fnGetCellData( oSettings, iRow, i, 'display' );
  2750. }
  2751. /* Add user defined class */
  2752. if ( oCol.sClass )
  2753. {
  2754. nTd.className += ' '+oCol.sClass;
  2755. }
  2756. // Visibility - add or remove as required
  2757. if ( oCol.bVisible && ! nTrIn )
  2758. {
  2759. nTr.appendChild( nTd );
  2760. }
  2761. else if ( ! oCol.bVisible && nTrIn )
  2762. {
  2763. nTd.parentNode.removeChild( nTd );
  2764. }
  2765. if ( oCol.fnCreatedCell )
  2766. {
  2767. oCol.fnCreatedCell.call( oSettings.oInstance,
  2768. nTd, _fnGetCellData( oSettings, iRow, i ), rowData, iRow, i
  2769. );
  2770. }
  2771. }
  2772. _fnCallbackFire( oSettings, 'aoRowCreatedCallback', null, [nTr, rowData, iRow, cells] );
  2773. }
  2774. }
  2775. /**
  2776. * Add attributes to a row based on the special `DT_*` parameters in a data
  2777. * source object.
  2778. * @param {object} settings DataTables settings object
  2779. * @param {object} DataTables row object for the row to be modified
  2780. * @memberof DataTable#oApi
  2781. */
  2782. function _fnRowAttributes( settings, row )
  2783. {
  2784. var tr = row.nTr;
  2785. var data = row._aData;
  2786. if ( tr ) {
  2787. var id = settings.rowIdFn( data );
  2788. if ( id ) {
  2789. tr.id = id;
  2790. }
  2791. if ( data.DT_RowClass ) {
  2792. // Remove any classes added by DT_RowClass before
  2793. var a = data.DT_RowClass.split(' ');
  2794. row.__rowc = row.__rowc ?
  2795. _unique( row.__rowc.concat( a ) ) :
  2796. a;
  2797. $(tr)
  2798. .removeClass( row.__rowc.join(' ') )
  2799. .addClass( data.DT_RowClass );
  2800. }
  2801. if ( data.DT_RowAttr ) {
  2802. $(tr).attr( data.DT_RowAttr );
  2803. }
  2804. if ( data.DT_RowData ) {
  2805. $(tr).data( data.DT_RowData );
  2806. }
  2807. }
  2808. }
  2809. /**
  2810. * Create the HTML header for the table
  2811. * @param {object} oSettings dataTables settings object
  2812. * @memberof DataTable#oApi
  2813. */
  2814. function _fnBuildHead( oSettings )
  2815. {
  2816. var i, ien, cell, row, column;
  2817. var thead = oSettings.nTHead;
  2818. var tfoot = oSettings.nTFoot;
  2819. var createHeader = $('th, td', thead).length === 0;
  2820. var classes = oSettings.oClasses;
  2821. var columns = oSettings.aoColumns;
  2822. if ( createHeader ) {
  2823. row = $('<tr/>').appendTo( thead );
  2824. }
  2825. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  2826. column = columns[i];
  2827. cell = $( column.nTh ).addClass( column.sClass );
  2828. if ( createHeader ) {
  2829. cell.appendTo( row );
  2830. }
  2831. // 1.11 move into sorting
  2832. if ( oSettings.oFeatures.bSort ) {
  2833. cell.addClass( column.sSortingClass );
  2834. if ( column.bSortable !== false ) {
  2835. cell
  2836. .attr( 'tabindex', oSettings.iTabIndex )
  2837. .attr( 'aria-controls', oSettings.sTableId );
  2838. _fnSortAttachListener( oSettings, column.nTh, i );
  2839. }
  2840. }
  2841. if ( column.sTitle != cell[0].innerHTML ) {
  2842. cell.html( column.sTitle );
  2843. }
  2844. _fnRenderer( oSettings, 'header' )(
  2845. oSettings, cell, column, classes
  2846. );
  2847. }
  2848. if ( createHeader ) {
  2849. _fnDetectHeader( oSettings.aoHeader, thead );
  2850. }
  2851. /* ARIA role for the rows */
  2852. $(thead).children('tr').attr('role', 'row');
  2853. /* Deal with the footer - add classes if required */
  2854. $(thead).children('tr').children('th, td').addClass( classes.sHeaderTH );
  2855. $(tfoot).children('tr').children('th, td').addClass( classes.sFooterTH );
  2856. // Cache the footer cells. Note that we only take the cells from the first
  2857. // row in the footer. If there is more than one row the user wants to
  2858. // interact with, they need to use the table().foot() method. Note also this
  2859. // allows cells to be used for multiple columns using colspan
  2860. if ( tfoot !== null ) {
  2861. var cells = oSettings.aoFooter[0];
  2862. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  2863. column = columns[i];
  2864. column.nTf = cells[i].cell;
  2865. if ( column.sClass ) {
  2866. $(column.nTf).addClass( column.sClass );
  2867. }
  2868. }
  2869. }
  2870. }
  2871. /**
  2872. * Draw the header (or footer) element based on the column visibility states. The
  2873. * methodology here is to use the layout array from _fnDetectHeader, modified for
  2874. * the instantaneous column visibility, to construct the new layout. The grid is
  2875. * traversed over cell at a time in a rows x columns grid fashion, although each
  2876. * cell insert can cover multiple elements in the grid - which is tracks using the
  2877. * aApplied array. Cell inserts in the grid will only occur where there isn't
  2878. * already a cell in that position.
  2879. * @param {object} oSettings dataTables settings object
  2880. * @param array {objects} aoSource Layout array from _fnDetectHeader
  2881. * @param {boolean} [bIncludeHidden=false] If true then include the hidden columns in the calc,
  2882. * @memberof DataTable#oApi
  2883. */
  2884. function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
  2885. {
  2886. var i, iLen, j, jLen, k, kLen, n, nLocalTr;
  2887. var aoLocal = [];
  2888. var aApplied = [];
  2889. var iColumns = oSettings.aoColumns.length;
  2890. var iRowspan, iColspan;
  2891. if ( ! aoSource )
  2892. {
  2893. return;
  2894. }
  2895. if ( bIncludeHidden === undefined )
  2896. {
  2897. bIncludeHidden = false;
  2898. }
  2899. /* Make a copy of the master layout array, but without the visible columns in it */
  2900. for ( i=0, iLen=aoSource.length ; i<iLen ; i++ )
  2901. {
  2902. aoLocal[i] = aoSource[i].slice();
  2903. aoLocal[i].nTr = aoSource[i].nTr;
  2904. /* Remove any columns which are currently hidden */
  2905. for ( j=iColumns-1 ; j>=0 ; j-- )
  2906. {
  2907. if ( !oSettings.aoColumns[j].bVisible && !bIncludeHidden )
  2908. {
  2909. aoLocal[i].splice( j, 1 );
  2910. }
  2911. }
  2912. /* Prep the applied array - it needs an element for each row */
  2913. aApplied.push( [] );
  2914. }
  2915. for ( i=0, iLen=aoLocal.length ; i<iLen ; i++ )
  2916. {
  2917. nLocalTr = aoLocal[i].nTr;
  2918. /* All cells are going to be replaced, so empty out the row */
  2919. if ( nLocalTr )
  2920. {
  2921. while( (n = nLocalTr.firstChild) )
  2922. {
  2923. nLocalTr.removeChild( n );
  2924. }
  2925. }
  2926. for ( j=0, jLen=aoLocal[i].length ; j<jLen ; j++ )
  2927. {
  2928. iRowspan = 1;
  2929. iColspan = 1;
  2930. /* Check to see if there is already a cell (row/colspan) covering our target
  2931. * insert point. If there is, then there is nothing to do.
  2932. */
  2933. if ( aApplied[i][j] === undefined )
  2934. {
  2935. nLocalTr.appendChild( aoLocal[i][j].cell );
  2936. aApplied[i][j] = 1;
  2937. /* Expand the cell to cover as many rows as needed */
  2938. while ( aoLocal[i+iRowspan] !== undefined &&
  2939. aoLocal[i][j].cell == aoLocal[i+iRowspan][j].cell )
  2940. {
  2941. aApplied[i+iRowspan][j] = 1;
  2942. iRowspan++;
  2943. }
  2944. /* Expand the cell to cover as many columns as needed */
  2945. while ( aoLocal[i][j+iColspan] !== undefined &&
  2946. aoLocal[i][j].cell == aoLocal[i][j+iColspan].cell )
  2947. {
  2948. /* Must update the applied array over the rows for the columns */
  2949. for ( k=0 ; k<iRowspan ; k++ )
  2950. {
  2951. aApplied[i+k][j+iColspan] = 1;
  2952. }
  2953. iColspan++;
  2954. }
  2955. /* Do the actual expansion in the DOM */
  2956. $(aoLocal[i][j].cell)
  2957. .attr('rowspan', iRowspan)
  2958. .attr('colspan', iColspan);
  2959. }
  2960. }
  2961. }
  2962. }
  2963. /**
  2964. * Insert the required TR nodes into the table for display
  2965. * @param {object} oSettings dataTables settings object
  2966. * @param ajaxComplete true after ajax call to complete rendering
  2967. * @memberof DataTable#oApi
  2968. */
  2969. function _fnDraw( oSettings, ajaxComplete )
  2970. {
  2971. /* Provide a pre-callback function which can be used to cancel the draw is false is returned */
  2972. var aPreDraw = _fnCallbackFire( oSettings, 'aoPreDrawCallback', 'preDraw', [oSettings] );
  2973. if ( $.inArray( false, aPreDraw ) !== -1 )
  2974. {
  2975. _fnProcessingDisplay( oSettings, false );
  2976. return;
  2977. }
  2978. var i, iLen, n;
  2979. var anRows = [];
  2980. var iRowCount = 0;
  2981. var asStripeClasses = oSettings.asStripeClasses;
  2982. var iStripes = asStripeClasses.length;
  2983. var iOpenRows = oSettings.aoOpenRows.length;
  2984. var oLang = oSettings.oLanguage;
  2985. var iInitDisplayStart = oSettings.iInitDisplayStart;
  2986. var bServerSide = _fnDataSource( oSettings ) == 'ssp';
  2987. var aiDisplay = oSettings.aiDisplay;
  2988. oSettings.bDrawing = true;
  2989. /* Check and see if we have an initial draw position from state saving */
  2990. if ( iInitDisplayStart !== undefined && iInitDisplayStart !== -1 )
  2991. {
  2992. oSettings._iDisplayStart = bServerSide ?
  2993. iInitDisplayStart :
  2994. iInitDisplayStart >= oSettings.fnRecordsDisplay() ?
  2995. 0 :
  2996. iInitDisplayStart;
  2997. oSettings.iInitDisplayStart = -1;
  2998. }
  2999. var iDisplayStart = oSettings._iDisplayStart;
  3000. var iDisplayEnd = oSettings.fnDisplayEnd();
  3001. /* Server-side processing draw intercept */
  3002. if ( oSettings.bDeferLoading )
  3003. {
  3004. oSettings.bDeferLoading = false;
  3005. oSettings.iDraw++;
  3006. _fnProcessingDisplay( oSettings, false );
  3007. }
  3008. else if ( !bServerSide )
  3009. {
  3010. oSettings.iDraw++;
  3011. }
  3012. else if ( !oSettings.bDestroying && !ajaxComplete)
  3013. {
  3014. _fnAjaxUpdate( oSettings );
  3015. return;
  3016. }
  3017. if ( aiDisplay.length !== 0 )
  3018. {
  3019. var iStart = bServerSide ? 0 : iDisplayStart;
  3020. var iEnd = bServerSide ? oSettings.aoData.length : iDisplayEnd;
  3021. for ( var j=iStart ; j<iEnd ; j++ )
  3022. {
  3023. var iDataIndex = aiDisplay[j];
  3024. var aoData = oSettings.aoData[ iDataIndex ];
  3025. if ( aoData.nTr === null )
  3026. {
  3027. _fnCreateTr( oSettings, iDataIndex );
  3028. }
  3029. var nRow = aoData.nTr;
  3030. /* Remove the old striping classes and then add the new one */
  3031. if ( iStripes !== 0 )
  3032. {
  3033. var sStripe = asStripeClasses[ iRowCount % iStripes ];
  3034. if ( aoData._sRowStripe != sStripe )
  3035. {
  3036. $(nRow).removeClass( aoData._sRowStripe ).addClass( sStripe );
  3037. aoData._sRowStripe = sStripe;
  3038. }
  3039. }
  3040. // Row callback functions - might want to manipulate the row
  3041. // iRowCount and j are not currently documented. Are they at all
  3042. // useful?
  3043. _fnCallbackFire( oSettings, 'aoRowCallback', null,
  3044. [nRow, aoData._aData, iRowCount, j, iDataIndex] );
  3045. anRows.push( nRow );
  3046. iRowCount++;
  3047. }
  3048. }
  3049. else
  3050. {
  3051. /* Table is empty - create a row with an empty message in it */
  3052. var sZero = oLang.sZeroRecords;
  3053. if ( oSettings.iDraw == 1 && _fnDataSource( oSettings ) == 'ajax' )
  3054. {
  3055. sZero = oLang.sLoadingRecords;
  3056. }
  3057. else if ( oLang.sEmptyTable && oSettings.fnRecordsTotal() === 0 )
  3058. {
  3059. sZero = oLang.sEmptyTable;
  3060. }
  3061. anRows[ 0 ] = $( '<tr/>', { 'class': iStripes ? asStripeClasses[0] : '' } )
  3062. .append( $('<td />', {
  3063. 'valign': 'top',
  3064. 'colSpan': _fnVisbleColumns( oSettings ),
  3065. 'class': oSettings.oClasses.sRowEmpty
  3066. } ).html( sZero ) )[0];
  3067. }
  3068. /* Header and footer callbacks */
  3069. _fnCallbackFire( oSettings, 'aoHeaderCallback', 'header', [ $(oSettings.nTHead).children('tr')[0],
  3070. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  3071. _fnCallbackFire( oSettings, 'aoFooterCallback', 'footer', [ $(oSettings.nTFoot).children('tr')[0],
  3072. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  3073. var body = $(oSettings.nTBody);
  3074. body.children().detach();
  3075. body.append( $(anRows) );
  3076. /* Call all required callback functions for the end of a draw */
  3077. _fnCallbackFire( oSettings, 'aoDrawCallback', 'draw', [oSettings] );
  3078. /* Draw is complete, sorting and filtering must be as well */
  3079. oSettings.bSorted = false;
  3080. oSettings.bFiltered = false;
  3081. oSettings.bDrawing = false;
  3082. }
  3083. /**
  3084. * Redraw the table - taking account of the various features which are enabled
  3085. * @param {object} oSettings dataTables settings object
  3086. * @param {boolean} [holdPosition] Keep the current paging position. By default
  3087. * the paging is reset to the first page
  3088. * @memberof DataTable#oApi
  3089. */
  3090. function _fnReDraw( settings, holdPosition )
  3091. {
  3092. var
  3093. features = settings.oFeatures,
  3094. sort = features.bSort,
  3095. filter = features.bFilter;
  3096. if ( sort ) {
  3097. _fnSort( settings );
  3098. }
  3099. if ( filter ) {
  3100. _fnFilterComplete( settings, settings.oPreviousSearch );
  3101. }
  3102. else {
  3103. // No filtering, so we want to just use the display master
  3104. settings.aiDisplay = settings.aiDisplayMaster.slice();
  3105. }
  3106. if ( holdPosition !== true ) {
  3107. settings._iDisplayStart = 0;
  3108. }
  3109. // Let any modules know about the draw hold position state (used by
  3110. // scrolling internally)
  3111. settings._drawHold = holdPosition;
  3112. _fnDraw( settings );
  3113. settings._drawHold = false;
  3114. }
  3115. /**
  3116. * Add the options to the page HTML for the table
  3117. * @param {object} oSettings dataTables settings object
  3118. * @memberof DataTable#oApi
  3119. */
  3120. function _fnAddOptionsHtml ( oSettings )
  3121. {
  3122. var classes = oSettings.oClasses;
  3123. var table = $(oSettings.nTable);
  3124. var holding = $('<div/>').insertBefore( table ); // Holding element for speed
  3125. var features = oSettings.oFeatures;
  3126. // All DataTables are wrapped in a div
  3127. var insert = $('<div/>', {
  3128. id: oSettings.sTableId+'_wrapper',
  3129. 'class': classes.sWrapper + (oSettings.nTFoot ? '' : ' '+classes.sNoFooter)
  3130. } );
  3131. oSettings.nHolding = holding[0];
  3132. oSettings.nTableWrapper = insert[0];
  3133. oSettings.nTableReinsertBefore = oSettings.nTable.nextSibling;
  3134. /* Loop over the user set positioning and place the elements as needed */
  3135. var aDom = oSettings.sDom.split('');
  3136. var featureNode, cOption, nNewNode, cNext, sAttr, j;
  3137. for ( var i=0 ; i<aDom.length ; i++ )
  3138. {
  3139. featureNode = null;
  3140. cOption = aDom[i];
  3141. if ( cOption == '<' )
  3142. {
  3143. /* New container div */
  3144. nNewNode = $('<div/>')[0];
  3145. /* Check to see if we should append an id and/or a class name to the container */
  3146. cNext = aDom[i+1];
  3147. if ( cNext == "'" || cNext == '"' )
  3148. {
  3149. sAttr = "";
  3150. j = 2;
  3151. while ( aDom[i+j] != cNext )
  3152. {
  3153. sAttr += aDom[i+j];
  3154. j++;
  3155. }
  3156. /* Replace jQuery UI constants @todo depreciated */
  3157. if ( sAttr == "H" )
  3158. {
  3159. sAttr = classes.sJUIHeader;
  3160. }
  3161. else if ( sAttr == "F" )
  3162. {
  3163. sAttr = classes.sJUIFooter;
  3164. }
  3165. /* The attribute can be in the format of "#id.class", "#id" or "class" This logic
  3166. * breaks the string into parts and applies them as needed
  3167. */
  3168. if ( sAttr.indexOf('.') != -1 )
  3169. {
  3170. var aSplit = sAttr.split('.');
  3171. nNewNode.id = aSplit[0].substr(1, aSplit[0].length-1);
  3172. nNewNode.className = aSplit[1];
  3173. }
  3174. else if ( sAttr.charAt(0) == "#" )
  3175. {
  3176. nNewNode.id = sAttr.substr(1, sAttr.length-1);
  3177. }
  3178. else
  3179. {
  3180. nNewNode.className = sAttr;
  3181. }
  3182. i += j; /* Move along the position array */
  3183. }
  3184. insert.append( nNewNode );
  3185. insert = $(nNewNode);
  3186. }
  3187. else if ( cOption == '>' )
  3188. {
  3189. /* End container div */
  3190. insert = insert.parent();
  3191. }
  3192. // @todo Move options into their own plugins?
  3193. else if ( cOption == 'l' && features.bPaginate && features.bLengthChange )
  3194. {
  3195. /* Length */
  3196. featureNode = _fnFeatureHtmlLength( oSettings );
  3197. }
  3198. else if ( cOption == 'f' && features.bFilter )
  3199. {
  3200. /* Filter */
  3201. featureNode = _fnFeatureHtmlFilter( oSettings );
  3202. }
  3203. else if ( cOption == 'r' && features.bProcessing )
  3204. {
  3205. /* pRocessing */
  3206. featureNode = _fnFeatureHtmlProcessing( oSettings );
  3207. }
  3208. else if ( cOption == 't' )
  3209. {
  3210. /* Table */
  3211. featureNode = _fnFeatureHtmlTable( oSettings );
  3212. }
  3213. else if ( cOption == 'i' && features.bInfo )
  3214. {
  3215. /* Info */
  3216. featureNode = _fnFeatureHtmlInfo( oSettings );
  3217. }
  3218. else if ( cOption == 'p' && features.bPaginate )
  3219. {
  3220. /* Pagination */
  3221. featureNode = _fnFeatureHtmlPaginate( oSettings );
  3222. }
  3223. else if ( DataTable.ext.feature.length !== 0 )
  3224. {
  3225. /* Plug-in features */
  3226. var aoFeatures = DataTable.ext.feature;
  3227. for ( var k=0, kLen=aoFeatures.length ; k<kLen ; k++ )
  3228. {
  3229. if ( cOption == aoFeatures[k].cFeature )
  3230. {
  3231. featureNode = aoFeatures[k].fnInit( oSettings );
  3232. break;
  3233. }
  3234. }
  3235. }
  3236. /* Add to the 2D features array */
  3237. if ( featureNode )
  3238. {
  3239. var aanFeatures = oSettings.aanFeatures;
  3240. if ( ! aanFeatures[cOption] )
  3241. {
  3242. aanFeatures[cOption] = [];
  3243. }
  3244. aanFeatures[cOption].push( featureNode );
  3245. insert.append( featureNode );
  3246. }
  3247. }
  3248. /* Built our DOM structure - replace the holding div with what we want */
  3249. holding.replaceWith( insert );
  3250. oSettings.nHolding = null;
  3251. }
  3252. /**
  3253. * Use the DOM source to create up an array of header cells. The idea here is to
  3254. * create a layout grid (array) of rows x columns, which contains a reference
  3255. * to the cell that that point in the grid (regardless of col/rowspan), such that
  3256. * any column / row could be removed and the new grid constructed
  3257. * @param array {object} aLayout Array to store the calculated layout in
  3258. * @param {node} nThead The header/footer element for the table
  3259. * @memberof DataTable#oApi
  3260. */
  3261. function _fnDetectHeader ( aLayout, nThead )
  3262. {
  3263. var nTrs = $(nThead).children('tr');
  3264. var nTr, nCell;
  3265. var i, k, l, iLen, jLen, iColShifted, iColumn, iColspan, iRowspan;
  3266. var bUnique;
  3267. var fnShiftCol = function ( a, i, j ) {
  3268. var k = a[i];
  3269. while ( k[j] ) {
  3270. j++;
  3271. }
  3272. return j;
  3273. };
  3274. aLayout.splice( 0, aLayout.length );
  3275. /* We know how many rows there are in the layout - so prep it */
  3276. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  3277. {
  3278. aLayout.push( [] );
  3279. }
  3280. /* Calculate a layout array */
  3281. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  3282. {
  3283. nTr = nTrs[i];
  3284. iColumn = 0;
  3285. /* For every cell in the row... */
  3286. nCell = nTr.firstChild;
  3287. while ( nCell ) {
  3288. if ( nCell.nodeName.toUpperCase() == "TD" ||
  3289. nCell.nodeName.toUpperCase() == "TH" )
  3290. {
  3291. /* Get the col and rowspan attributes from the DOM and sanitise them */
  3292. iColspan = nCell.getAttribute('colspan') * 1;
  3293. iRowspan = nCell.getAttribute('rowspan') * 1;
  3294. iColspan = (!iColspan || iColspan===0 || iColspan===1) ? 1 : iColspan;
  3295. iRowspan = (!iRowspan || iRowspan===0 || iRowspan===1) ? 1 : iRowspan;
  3296. /* There might be colspan cells already in this row, so shift our target
  3297. * accordingly
  3298. */
  3299. iColShifted = fnShiftCol( aLayout, i, iColumn );
  3300. /* Cache calculation for unique columns */
  3301. bUnique = iColspan === 1 ? true : false;
  3302. /* If there is col / rowspan, copy the information into the layout grid */
  3303. for ( l=0 ; l<iColspan ; l++ )
  3304. {
  3305. for ( k=0 ; k<iRowspan ; k++ )
  3306. {
  3307. aLayout[i+k][iColShifted+l] = {
  3308. "cell": nCell,
  3309. "unique": bUnique
  3310. };
  3311. aLayout[i+k].nTr = nTr;
  3312. }
  3313. }
  3314. }
  3315. nCell = nCell.nextSibling;
  3316. }
  3317. }
  3318. }
  3319. /**
  3320. * Get an array of unique th elements, one for each column
  3321. * @param {object} oSettings dataTables settings object
  3322. * @param {node} nHeader automatically detect the layout from this node - optional
  3323. * @param {array} aLayout thead/tfoot layout from _fnDetectHeader - optional
  3324. * @returns array {node} aReturn list of unique th's
  3325. * @memberof DataTable#oApi
  3326. */
  3327. function _fnGetUniqueThs ( oSettings, nHeader, aLayout )
  3328. {
  3329. var aReturn = [];
  3330. if ( !aLayout )
  3331. {
  3332. aLayout = oSettings.aoHeader;
  3333. if ( nHeader )
  3334. {
  3335. aLayout = [];
  3336. _fnDetectHeader( aLayout, nHeader );
  3337. }
  3338. }
  3339. for ( var i=0, iLen=aLayout.length ; i<iLen ; i++ )
  3340. {
  3341. for ( var j=0, jLen=aLayout[i].length ; j<jLen ; j++ )
  3342. {
  3343. if ( aLayout[i][j].unique &&
  3344. (!aReturn[j] || !oSettings.bSortCellsTop) )
  3345. {
  3346. aReturn[j] = aLayout[i][j].cell;
  3347. }
  3348. }
  3349. }
  3350. return aReturn;
  3351. }
  3352. /**
  3353. * Create an Ajax call based on the table's settings, taking into account that
  3354. * parameters can have multiple forms, and backwards compatibility.
  3355. *
  3356. * @param {object} oSettings dataTables settings object
  3357. * @param {array} data Data to send to the server, required by
  3358. * DataTables - may be augmented by developer callbacks
  3359. * @param {function} fn Callback function to run when data is obtained
  3360. */
  3361. function _fnBuildAjax( oSettings, data, fn )
  3362. {
  3363. // Compatibility with 1.9-, allow fnServerData and event to manipulate
  3364. _fnCallbackFire( oSettings, 'aoServerParams', 'serverParams', [data] );
  3365. // Convert to object based for 1.10+ if using the old array scheme which can
  3366. // come from server-side processing or serverParams
  3367. if ( data && Array.isArray(data) ) {
  3368. var tmp = {};
  3369. var rbracket = /(.*?)\[\]$/;
  3370. $.each( data, function (key, val) {
  3371. var match = val.name.match(rbracket);
  3372. if ( match ) {
  3373. // Support for arrays
  3374. var name = match[0];
  3375. if ( ! tmp[ name ] ) {
  3376. tmp[ name ] = [];
  3377. }
  3378. tmp[ name ].push( val.value );
  3379. }
  3380. else {
  3381. tmp[val.name] = val.value;
  3382. }
  3383. } );
  3384. data = tmp;
  3385. }
  3386. var ajaxData;
  3387. var ajax = oSettings.ajax;
  3388. var instance = oSettings.oInstance;
  3389. var callback = function ( json ) {
  3390. _fnCallbackFire( oSettings, null, 'xhr', [oSettings, json, oSettings.jqXHR] );
  3391. fn( json );
  3392. };
  3393. if ( $.isPlainObject( ajax ) && ajax.data )
  3394. {
  3395. ajaxData = ajax.data;
  3396. var newData = typeof ajaxData === 'function' ?
  3397. ajaxData( data, oSettings ) : // fn can manipulate data or return
  3398. ajaxData; // an object object or array to merge
  3399. // If the function returned something, use that alone
  3400. data = typeof ajaxData === 'function' && newData ?
  3401. newData :
  3402. $.extend( true, data, newData );
  3403. // Remove the data property as we've resolved it already and don't want
  3404. // jQuery to do it again (it is restored at the end of the function)
  3405. delete ajax.data;
  3406. }
  3407. var baseAjax = {
  3408. "data": data,
  3409. "success": function (json) {
  3410. var error = json.error || json.sError;
  3411. if ( error ) {
  3412. _fnLog( oSettings, 0, error );
  3413. }
  3414. oSettings.json = json;
  3415. callback( json );
  3416. },
  3417. "dataType": "json",
  3418. "cache": false,
  3419. "type": oSettings.sServerMethod,
  3420. "error": function (xhr, error, thrown) {
  3421. var ret = _fnCallbackFire( oSettings, null, 'xhr', [oSettings, null, oSettings.jqXHR] );
  3422. if ( $.inArray( true, ret ) === -1 ) {
  3423. if ( error == "parsererror" ) {
  3424. _fnLog( oSettings, 0, 'Invalid JSON response', 1 );
  3425. }
  3426. else if ( xhr.readyState === 4 ) {
  3427. _fnLog( oSettings, 0, 'Ajax error', 7 );
  3428. }
  3429. }
  3430. _fnProcessingDisplay( oSettings, false );
  3431. }
  3432. };
  3433. // Store the data submitted for the API
  3434. oSettings.oAjaxData = data;
  3435. // Allow plug-ins and external processes to modify the data
  3436. _fnCallbackFire( oSettings, null, 'preXhr', [oSettings, data] );
  3437. if ( oSettings.fnServerData )
  3438. {
  3439. // DataTables 1.9- compatibility
  3440. oSettings.fnServerData.call( instance,
  3441. oSettings.sAjaxSource,
  3442. $.map( data, function (val, key) { // Need to convert back to 1.9 trad format
  3443. return { name: key, value: val };
  3444. } ),
  3445. callback,
  3446. oSettings
  3447. );
  3448. }
  3449. else if ( oSettings.sAjaxSource || typeof ajax === 'string' )
  3450. {
  3451. // DataTables 1.9- compatibility
  3452. oSettings.jqXHR = $.ajax( $.extend( baseAjax, {
  3453. url: ajax || oSettings.sAjaxSource
  3454. } ) );
  3455. }
  3456. else if ( typeof ajax === 'function' )
  3457. {
  3458. // Is a function - let the caller define what needs to be done
  3459. oSettings.jqXHR = ajax.call( instance, data, callback, oSettings );
  3460. }
  3461. else
  3462. {
  3463. // Object to extend the base settings
  3464. oSettings.jqXHR = $.ajax( $.extend( baseAjax, ajax ) );
  3465. // Restore for next time around
  3466. ajax.data = ajaxData;
  3467. }
  3468. }
  3469. /**
  3470. * Update the table using an Ajax call
  3471. * @param {object} settings dataTables settings object
  3472. * @returns {boolean} Block the table drawing or not
  3473. * @memberof DataTable#oApi
  3474. */
  3475. function _fnAjaxUpdate( settings )
  3476. {
  3477. settings.iDraw++;
  3478. _fnProcessingDisplay( settings, true );
  3479. _fnBuildAjax(
  3480. settings,
  3481. _fnAjaxParameters( settings ),
  3482. function(json) {
  3483. _fnAjaxUpdateDraw( settings, json );
  3484. }
  3485. );
  3486. }
  3487. /**
  3488. * Build up the parameters in an object needed for a server-side processing
  3489. * request. Note that this is basically done twice, is different ways - a modern
  3490. * method which is used by default in DataTables 1.10 which uses objects and
  3491. * arrays, or the 1.9- method with is name / value pairs. 1.9 method is used if
  3492. * the sAjaxSource option is used in the initialisation, or the legacyAjax
  3493. * option is set.
  3494. * @param {object} oSettings dataTables settings object
  3495. * @returns {bool} block the table drawing or not
  3496. * @memberof DataTable#oApi
  3497. */
  3498. function _fnAjaxParameters( settings )
  3499. {
  3500. var
  3501. columns = settings.aoColumns,
  3502. columnCount = columns.length,
  3503. features = settings.oFeatures,
  3504. preSearch = settings.oPreviousSearch,
  3505. preColSearch = settings.aoPreSearchCols,
  3506. i, data = [], dataProp, column, columnSearch,
  3507. sort = _fnSortFlatten( settings ),
  3508. displayStart = settings._iDisplayStart,
  3509. displayLength = features.bPaginate !== false ?
  3510. settings._iDisplayLength :
  3511. -1;
  3512. var param = function ( name, value ) {
  3513. data.push( { 'name': name, 'value': value } );
  3514. };
  3515. // DataTables 1.9- compatible method
  3516. param( 'sEcho', settings.iDraw );
  3517. param( 'iColumns', columnCount );
  3518. param( 'sColumns', _pluck( columns, 'sName' ).join(',') );
  3519. param( 'iDisplayStart', displayStart );
  3520. param( 'iDisplayLength', displayLength );
  3521. // DataTables 1.10+ method
  3522. var d = {
  3523. draw: settings.iDraw,
  3524. columns: [],
  3525. order: [],
  3526. start: displayStart,
  3527. length: displayLength,
  3528. search: {
  3529. value: preSearch.sSearch,
  3530. regex: preSearch.bRegex
  3531. }
  3532. };
  3533. for ( i=0 ; i<columnCount ; i++ ) {
  3534. column = columns[i];
  3535. columnSearch = preColSearch[i];
  3536. dataProp = typeof column.mData=="function" ? 'function' : column.mData ;
  3537. d.columns.push( {
  3538. data: dataProp,
  3539. name: column.sName,
  3540. searchable: column.bSearchable,
  3541. orderable: column.bSortable,
  3542. search: {
  3543. value: columnSearch.sSearch,
  3544. regex: columnSearch.bRegex
  3545. }
  3546. } );
  3547. param( "mDataProp_"+i, dataProp );
  3548. if ( features.bFilter ) {
  3549. param( 'sSearch_'+i, columnSearch.sSearch );
  3550. param( 'bRegex_'+i, columnSearch.bRegex );
  3551. param( 'bSearchable_'+i, column.bSearchable );
  3552. }
  3553. if ( features.bSort ) {
  3554. param( 'bSortable_'+i, column.bSortable );
  3555. }
  3556. }
  3557. if ( features.bFilter ) {
  3558. param( 'sSearch', preSearch.sSearch );
  3559. param( 'bRegex', preSearch.bRegex );
  3560. }
  3561. if ( features.bSort ) {
  3562. $.each( sort, function ( i, val ) {
  3563. d.order.push( { column: val.col, dir: val.dir } );
  3564. param( 'iSortCol_'+i, val.col );
  3565. param( 'sSortDir_'+i, val.dir );
  3566. } );
  3567. param( 'iSortingCols', sort.length );
  3568. }
  3569. // If the legacy.ajax parameter is null, then we automatically decide which
  3570. // form to use, based on sAjaxSource
  3571. var legacy = DataTable.ext.legacy.ajax;
  3572. if ( legacy === null ) {
  3573. return settings.sAjaxSource ? data : d;
  3574. }
  3575. // Otherwise, if legacy has been specified then we use that to decide on the
  3576. // form
  3577. return legacy ? data : d;
  3578. }
  3579. /**
  3580. * Data the data from the server (nuking the old) and redraw the table
  3581. * @param {object} oSettings dataTables settings object
  3582. * @param {object} json json data return from the server.
  3583. * @param {string} json.sEcho Tracking flag for DataTables to match requests
  3584. * @param {int} json.iTotalRecords Number of records in the data set, not accounting for filtering
  3585. * @param {int} json.iTotalDisplayRecords Number of records in the data set, accounting for filtering
  3586. * @param {array} json.aaData The data to display on this page
  3587. * @param {string} [json.sColumns] Column ordering (sName, comma separated)
  3588. * @memberof DataTable#oApi
  3589. */
  3590. function _fnAjaxUpdateDraw ( settings, json )
  3591. {
  3592. // v1.10 uses camelCase variables, while 1.9 uses Hungarian notation.
  3593. // Support both
  3594. var compat = function ( old, modern ) {
  3595. return json[old] !== undefined ? json[old] : json[modern];
  3596. };
  3597. var data = _fnAjaxDataSrc( settings, json );
  3598. var draw = compat( 'sEcho', 'draw' );
  3599. var recordsTotal = compat( 'iTotalRecords', 'recordsTotal' );
  3600. var recordsFiltered = compat( 'iTotalDisplayRecords', 'recordsFiltered' );
  3601. if ( draw !== undefined ) {
  3602. // Protect against out of sequence returns
  3603. if ( draw*1 < settings.iDraw ) {
  3604. return;
  3605. }
  3606. settings.iDraw = draw * 1;
  3607. }
  3608. _fnClearTable( settings );
  3609. settings._iRecordsTotal = parseInt(recordsTotal, 10);
  3610. settings._iRecordsDisplay = parseInt(recordsFiltered, 10);
  3611. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  3612. _fnAddData( settings, data[i] );
  3613. }
  3614. settings.aiDisplay = settings.aiDisplayMaster.slice();
  3615. _fnDraw( settings, true );
  3616. if ( ! settings._bInitComplete ) {
  3617. _fnInitComplete( settings, json );
  3618. }
  3619. _fnProcessingDisplay( settings, false );
  3620. }
  3621. /**
  3622. * Get the data from the JSON data source to use for drawing a table. Using
  3623. * `_fnGetObjectDataFn` allows the data to be sourced from a property of the
  3624. * source object, or from a processing function.
  3625. * @param {object} oSettings dataTables settings object
  3626. * @param {object} json Data source object / array from the server
  3627. * @return {array} Array of data to use
  3628. */
  3629. function _fnAjaxDataSrc ( oSettings, json )
  3630. {
  3631. var dataSrc = $.isPlainObject( oSettings.ajax ) && oSettings.ajax.dataSrc !== undefined ?
  3632. oSettings.ajax.dataSrc :
  3633. oSettings.sAjaxDataProp; // Compatibility with 1.9-.
  3634. // Compatibility with 1.9-. In order to read from aaData, check if the
  3635. // default has been changed, if not, check for aaData
  3636. if ( dataSrc === 'data' ) {
  3637. return json.aaData || json[dataSrc];
  3638. }
  3639. return dataSrc !== "" ?
  3640. _fnGetObjectDataFn( dataSrc )( json ) :
  3641. json;
  3642. }
  3643. /**
  3644. * Generate the node required for filtering text
  3645. * @returns {node} Filter control element
  3646. * @param {object} oSettings dataTables settings object
  3647. * @memberof DataTable#oApi
  3648. */
  3649. function _fnFeatureHtmlFilter ( settings )
  3650. {
  3651. var classes = settings.oClasses;
  3652. var tableId = settings.sTableId;
  3653. var language = settings.oLanguage;
  3654. var previousSearch = settings.oPreviousSearch;
  3655. var features = settings.aanFeatures;
  3656. var input = '<input type="search" class="'+classes.sFilterInput+'"/>';
  3657. var str = language.sSearch;
  3658. str = str.match(/_INPUT_/) ?
  3659. str.replace('_INPUT_', input) :
  3660. str+input;
  3661. var filter = $('<div/>', {
  3662. 'id': ! features.f ? tableId+'_filter' : null,
  3663. 'class': classes.sFilter
  3664. } )
  3665. .append( $('<label/>' ).append( str ) );
  3666. var searchFn = function() {
  3667. /* Update all other filter input elements for the new display */
  3668. var n = features.f;
  3669. var val = !this.value ? "" : this.value; // mental IE8 fix :-(
  3670. /* Now do the filter */
  3671. if ( val != previousSearch.sSearch ) {
  3672. _fnFilterComplete( settings, {
  3673. "sSearch": val,
  3674. "bRegex": previousSearch.bRegex,
  3675. "bSmart": previousSearch.bSmart ,
  3676. "bCaseInsensitive": previousSearch.bCaseInsensitive
  3677. } );
  3678. // Need to redraw, without resorting
  3679. settings._iDisplayStart = 0;
  3680. _fnDraw( settings );
  3681. }
  3682. };
  3683. var searchDelay = settings.searchDelay !== null ?
  3684. settings.searchDelay :
  3685. _fnDataSource( settings ) === 'ssp' ?
  3686. 400 :
  3687. 0;
  3688. var jqFilter = $('input', filter)
  3689. .val( previousSearch.sSearch )
  3690. .attr( 'placeholder', language.sSearchPlaceholder )
  3691. .on(
  3692. 'keyup.DT search.DT input.DT paste.DT cut.DT',
  3693. searchDelay ?
  3694. _fnThrottle( searchFn, searchDelay ) :
  3695. searchFn
  3696. )
  3697. .on( 'mouseup', function(e) {
  3698. // Edge fix! Edge 17 does not trigger anything other than mouse events when clicking
  3699. // on the clear icon (Edge bug 17584515). This is safe in other browsers as `searchFn`
  3700. // checks the value to see if it has changed. In other browsers it won't have.
  3701. setTimeout( function () {
  3702. searchFn.call(jqFilter[0]);
  3703. }, 10);
  3704. } )
  3705. .on( 'keypress.DT', function(e) {
  3706. /* Prevent form submission */
  3707. if ( e.keyCode == 13 ) {
  3708. return false;
  3709. }
  3710. } )
  3711. .attr('aria-controls', tableId);
  3712. // Update the input elements whenever the table is filtered
  3713. $(settings.nTable).on( 'search.dt.DT', function ( ev, s ) {
  3714. if ( settings === s ) {
  3715. // IE9 throws an 'unknown error' if document.activeElement is used
  3716. // inside an iframe or frame...
  3717. try {
  3718. if ( jqFilter[0] !== document.activeElement ) {
  3719. jqFilter.val( previousSearch.sSearch );
  3720. }
  3721. }
  3722. catch ( e ) {}
  3723. }
  3724. } );
  3725. return filter[0];
  3726. }
  3727. /**
  3728. * Filter the table using both the global filter and column based filtering
  3729. * @param {object} oSettings dataTables settings object
  3730. * @param {object} oSearch search information
  3731. * @param {int} [iForce] force a research of the master array (1) or not (undefined or 0)
  3732. * @memberof DataTable#oApi
  3733. */
  3734. function _fnFilterComplete ( oSettings, oInput, iForce )
  3735. {
  3736. var oPrevSearch = oSettings.oPreviousSearch;
  3737. var aoPrevSearch = oSettings.aoPreSearchCols;
  3738. var fnSaveFilter = function ( oFilter ) {
  3739. /* Save the filtering values */
  3740. oPrevSearch.sSearch = oFilter.sSearch;
  3741. oPrevSearch.bRegex = oFilter.bRegex;
  3742. oPrevSearch.bSmart = oFilter.bSmart;
  3743. oPrevSearch.bCaseInsensitive = oFilter.bCaseInsensitive;
  3744. };
  3745. var fnRegex = function ( o ) {
  3746. // Backwards compatibility with the bEscapeRegex option
  3747. return o.bEscapeRegex !== undefined ? !o.bEscapeRegex : o.bRegex;
  3748. };
  3749. // Resolve any column types that are unknown due to addition or invalidation
  3750. // @todo As per sort - can this be moved into an event handler?
  3751. _fnColumnTypes( oSettings );
  3752. /* In server-side processing all filtering is done by the server, so no point hanging around here */
  3753. if ( _fnDataSource( oSettings ) != 'ssp' )
  3754. {
  3755. /* Global filter */
  3756. _fnFilter( oSettings, oInput.sSearch, iForce, fnRegex(oInput), oInput.bSmart, oInput.bCaseInsensitive );
  3757. fnSaveFilter( oInput );
  3758. /* Now do the individual column filter */
  3759. for ( var i=0 ; i<aoPrevSearch.length ; i++ )
  3760. {
  3761. _fnFilterColumn( oSettings, aoPrevSearch[i].sSearch, i, fnRegex(aoPrevSearch[i]),
  3762. aoPrevSearch[i].bSmart, aoPrevSearch[i].bCaseInsensitive );
  3763. }
  3764. /* Custom filtering */
  3765. _fnFilterCustom( oSettings );
  3766. }
  3767. else
  3768. {
  3769. fnSaveFilter( oInput );
  3770. }
  3771. /* Tell the draw function we have been filtering */
  3772. oSettings.bFiltered = true;
  3773. _fnCallbackFire( oSettings, null, 'search', [oSettings] );
  3774. }
  3775. /**
  3776. * Apply custom filtering functions
  3777. * @param {object} oSettings dataTables settings object
  3778. * @memberof DataTable#oApi
  3779. */
  3780. function _fnFilterCustom( settings )
  3781. {
  3782. var filters = DataTable.ext.search;
  3783. var displayRows = settings.aiDisplay;
  3784. var row, rowIdx;
  3785. for ( var i=0, ien=filters.length ; i<ien ; i++ ) {
  3786. var rows = [];
  3787. // Loop over each row and see if it should be included
  3788. for ( var j=0, jen=displayRows.length ; j<jen ; j++ ) {
  3789. rowIdx = displayRows[ j ];
  3790. row = settings.aoData[ rowIdx ];
  3791. if ( filters[i]( settings, row._aFilterData, rowIdx, row._aData, j ) ) {
  3792. rows.push( rowIdx );
  3793. }
  3794. }
  3795. // So the array reference doesn't break set the results into the
  3796. // existing array
  3797. displayRows.length = 0;
  3798. $.merge( displayRows, rows );
  3799. }
  3800. }
  3801. /**
  3802. * Filter the table on a per-column basis
  3803. * @param {object} oSettings dataTables settings object
  3804. * @param {string} sInput string to filter on
  3805. * @param {int} iColumn column to filter
  3806. * @param {bool} bRegex treat search string as a regular expression or not
  3807. * @param {bool} bSmart use smart filtering or not
  3808. * @param {bool} bCaseInsensitive Do case insenstive matching or not
  3809. * @memberof DataTable#oApi
  3810. */
  3811. function _fnFilterColumn ( settings, searchStr, colIdx, regex, smart, caseInsensitive )
  3812. {
  3813. if ( searchStr === '' ) {
  3814. return;
  3815. }
  3816. var data;
  3817. var out = [];
  3818. var display = settings.aiDisplay;
  3819. var rpSearch = _fnFilterCreateSearch( searchStr, regex, smart, caseInsensitive );
  3820. for ( var i=0 ; i<display.length ; i++ ) {
  3821. data = settings.aoData[ display[i] ]._aFilterData[ colIdx ];
  3822. if ( rpSearch.test( data ) ) {
  3823. out.push( display[i] );
  3824. }
  3825. }
  3826. settings.aiDisplay = out;
  3827. }
  3828. /**
  3829. * Filter the data table based on user input and draw the table
  3830. * @param {object} settings dataTables settings object
  3831. * @param {string} input string to filter on
  3832. * @param {int} force optional - force a research of the master array (1) or not (undefined or 0)
  3833. * @param {bool} regex treat as a regular expression or not
  3834. * @param {bool} smart perform smart filtering or not
  3835. * @param {bool} caseInsensitive Do case insenstive matching or not
  3836. * @memberof DataTable#oApi
  3837. */
  3838. function _fnFilter( settings, input, force, regex, smart, caseInsensitive )
  3839. {
  3840. var rpSearch = _fnFilterCreateSearch( input, regex, smart, caseInsensitive );
  3841. var prevSearch = settings.oPreviousSearch.sSearch;
  3842. var displayMaster = settings.aiDisplayMaster;
  3843. var display, invalidated, i;
  3844. var filtered = [];
  3845. // Need to take account of custom filtering functions - always filter
  3846. if ( DataTable.ext.search.length !== 0 ) {
  3847. force = true;
  3848. }
  3849. // Check if any of the rows were invalidated
  3850. invalidated = _fnFilterData( settings );
  3851. // If the input is blank - we just want the full data set
  3852. if ( input.length <= 0 ) {
  3853. settings.aiDisplay = displayMaster.slice();
  3854. }
  3855. else {
  3856. // New search - start from the master array
  3857. if ( invalidated ||
  3858. force ||
  3859. regex ||
  3860. prevSearch.length > input.length ||
  3861. input.indexOf(prevSearch) !== 0 ||
  3862. settings.bSorted // On resort, the display master needs to be
  3863. // re-filtered since indexes will have changed
  3864. ) {
  3865. settings.aiDisplay = displayMaster.slice();
  3866. }
  3867. // Search the display array
  3868. display = settings.aiDisplay;
  3869. for ( i=0 ; i<display.length ; i++ ) {
  3870. if ( rpSearch.test( settings.aoData[ display[i] ]._sFilterRow ) ) {
  3871. filtered.push( display[i] );
  3872. }
  3873. }
  3874. settings.aiDisplay = filtered;
  3875. }
  3876. }
  3877. /**
  3878. * Build a regular expression object suitable for searching a table
  3879. * @param {string} sSearch string to search for
  3880. * @param {bool} bRegex treat as a regular expression or not
  3881. * @param {bool} bSmart perform smart filtering or not
  3882. * @param {bool} bCaseInsensitive Do case insensitive matching or not
  3883. * @returns {RegExp} constructed object
  3884. * @memberof DataTable#oApi
  3885. */
  3886. function _fnFilterCreateSearch( search, regex, smart, caseInsensitive )
  3887. {
  3888. search = regex ?
  3889. search :
  3890. _fnEscapeRegex( search );
  3891. if ( smart ) {
  3892. /* For smart filtering we want to allow the search to work regardless of
  3893. * word order. We also want double quoted text to be preserved, so word
  3894. * order is important - a la google. So this is what we want to
  3895. * generate:
  3896. *
  3897. * ^(?=.*?\bone\b)(?=.*?\btwo three\b)(?=.*?\bfour\b).*$
  3898. */
  3899. var a = $.map( search.match( /"[^"]+"|[^ ]+/g ) || [''], function ( word ) {
  3900. if ( word.charAt(0) === '"' ) {
  3901. var m = word.match( /^"(.*)"$/ );
  3902. word = m ? m[1] : word;
  3903. }
  3904. return word.replace('"', '');
  3905. } );
  3906. search = '^(?=.*?'+a.join( ')(?=.*?' )+').*$';
  3907. }
  3908. return new RegExp( search, caseInsensitive ? 'i' : '' );
  3909. }
  3910. /**
  3911. * Escape a string such that it can be used in a regular expression
  3912. * @param {string} sVal string to escape
  3913. * @returns {string} escaped string
  3914. * @memberof DataTable#oApi
  3915. */
  3916. var _fnEscapeRegex = DataTable.util.escapeRegex;
  3917. var __filter_div = $('<div>')[0];
  3918. var __filter_div_textContent = __filter_div.textContent !== undefined;
  3919. // Update the filtering data for each row if needed (by invalidation or first run)
  3920. function _fnFilterData ( settings )
  3921. {
  3922. var columns = settings.aoColumns;
  3923. var column;
  3924. var i, j, ien, jen, filterData, cellData, row;
  3925. var fomatters = DataTable.ext.type.search;
  3926. var wasInvalidated = false;
  3927. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  3928. row = settings.aoData[i];
  3929. if ( ! row._aFilterData ) {
  3930. filterData = [];
  3931. for ( j=0, jen=columns.length ; j<jen ; j++ ) {
  3932. column = columns[j];
  3933. if ( column.bSearchable ) {
  3934. cellData = _fnGetCellData( settings, i, j, 'filter' );
  3935. if ( fomatters[ column.sType ] ) {
  3936. cellData = fomatters[ column.sType ]( cellData );
  3937. }
  3938. // Search in DataTables 1.10 is string based. In 1.11 this
  3939. // should be altered to also allow strict type checking.
  3940. if ( cellData === null ) {
  3941. cellData = '';
  3942. }
  3943. if ( typeof cellData !== 'string' && cellData.toString ) {
  3944. cellData = cellData.toString();
  3945. }
  3946. }
  3947. else {
  3948. cellData = '';
  3949. }
  3950. // If it looks like there is an HTML entity in the string,
  3951. // attempt to decode it so sorting works as expected. Note that
  3952. // we could use a single line of jQuery to do this, but the DOM
  3953. // method used here is much faster http://jsperf.com/html-decode
  3954. if ( cellData.indexOf && cellData.indexOf('&') !== -1 ) {
  3955. __filter_div.innerHTML = cellData;
  3956. cellData = __filter_div_textContent ?
  3957. __filter_div.textContent :
  3958. __filter_div.innerText;
  3959. }
  3960. if ( cellData.replace ) {
  3961. cellData = cellData.replace(/[\r\n\u2028]/g, '');
  3962. }
  3963. filterData.push( cellData );
  3964. }
  3965. row._aFilterData = filterData;
  3966. row._sFilterRow = filterData.join(' ');
  3967. wasInvalidated = true;
  3968. }
  3969. }
  3970. return wasInvalidated;
  3971. }
  3972. /**
  3973. * Convert from the internal Hungarian notation to camelCase for external
  3974. * interaction
  3975. * @param {object} obj Object to convert
  3976. * @returns {object} Inverted object
  3977. * @memberof DataTable#oApi
  3978. */
  3979. function _fnSearchToCamel ( obj )
  3980. {
  3981. return {
  3982. search: obj.sSearch,
  3983. smart: obj.bSmart,
  3984. regex: obj.bRegex,
  3985. caseInsensitive: obj.bCaseInsensitive
  3986. };
  3987. }
  3988. /**
  3989. * Convert from camelCase notation to the internal Hungarian. We could use the
  3990. * Hungarian convert function here, but this is cleaner
  3991. * @param {object} obj Object to convert
  3992. * @returns {object} Inverted object
  3993. * @memberof DataTable#oApi
  3994. */
  3995. function _fnSearchToHung ( obj )
  3996. {
  3997. return {
  3998. sSearch: obj.search,
  3999. bSmart: obj.smart,
  4000. bRegex: obj.regex,
  4001. bCaseInsensitive: obj.caseInsensitive
  4002. };
  4003. }
  4004. /**
  4005. * Generate the node required for the info display
  4006. * @param {object} oSettings dataTables settings object
  4007. * @returns {node} Information element
  4008. * @memberof DataTable#oApi
  4009. */
  4010. function _fnFeatureHtmlInfo ( settings )
  4011. {
  4012. var
  4013. tid = settings.sTableId,
  4014. nodes = settings.aanFeatures.i,
  4015. n = $('<div/>', {
  4016. 'class': settings.oClasses.sInfo,
  4017. 'id': ! nodes ? tid+'_info' : null
  4018. } );
  4019. if ( ! nodes ) {
  4020. // Update display on each draw
  4021. settings.aoDrawCallback.push( {
  4022. "fn": _fnUpdateInfo,
  4023. "sName": "information"
  4024. } );
  4025. n
  4026. .attr( 'role', 'status' )
  4027. .attr( 'aria-live', 'polite' );
  4028. // Table is described by our info div
  4029. $(settings.nTable).attr( 'aria-describedby', tid+'_info' );
  4030. }
  4031. return n[0];
  4032. }
  4033. /**
  4034. * Update the information elements in the display
  4035. * @param {object} settings dataTables settings object
  4036. * @memberof DataTable#oApi
  4037. */
  4038. function _fnUpdateInfo ( settings )
  4039. {
  4040. /* Show information about the table */
  4041. var nodes = settings.aanFeatures.i;
  4042. if ( nodes.length === 0 ) {
  4043. return;
  4044. }
  4045. var
  4046. lang = settings.oLanguage,
  4047. start = settings._iDisplayStart+1,
  4048. end = settings.fnDisplayEnd(),
  4049. max = settings.fnRecordsTotal(),
  4050. total = settings.fnRecordsDisplay(),
  4051. out = total ?
  4052. lang.sInfo :
  4053. lang.sInfoEmpty;
  4054. if ( total !== max ) {
  4055. /* Record set after filtering */
  4056. out += ' ' + lang.sInfoFiltered;
  4057. }
  4058. // Convert the macros
  4059. out += lang.sInfoPostFix;
  4060. out = _fnInfoMacros( settings, out );
  4061. var callback = lang.fnInfoCallback;
  4062. if ( callback !== null ) {
  4063. out = callback.call( settings.oInstance,
  4064. settings, start, end, max, total, out
  4065. );
  4066. }
  4067. $(nodes).html( out );
  4068. }
  4069. function _fnInfoMacros ( settings, str )
  4070. {
  4071. // When infinite scrolling, we are always starting at 1. _iDisplayStart is used only
  4072. // internally
  4073. var
  4074. formatter = settings.fnFormatNumber,
  4075. start = settings._iDisplayStart+1,
  4076. len = settings._iDisplayLength,
  4077. vis = settings.fnRecordsDisplay(),
  4078. all = len === -1;
  4079. return str.
  4080. replace(/_START_/g, formatter.call( settings, start ) ).
  4081. replace(/_END_/g, formatter.call( settings, settings.fnDisplayEnd() ) ).
  4082. replace(/_MAX_/g, formatter.call( settings, settings.fnRecordsTotal() ) ).
  4083. replace(/_TOTAL_/g, formatter.call( settings, vis ) ).
  4084. replace(/_PAGE_/g, formatter.call( settings, all ? 1 : Math.ceil( start / len ) ) ).
  4085. replace(/_PAGES_/g, formatter.call( settings, all ? 1 : Math.ceil( vis / len ) ) );
  4086. }
  4087. /**
  4088. * Draw the table for the first time, adding all required features
  4089. * @param {object} settings dataTables settings object
  4090. * @memberof DataTable#oApi
  4091. */
  4092. function _fnInitialise ( settings )
  4093. {
  4094. var i, iLen, iAjaxStart=settings.iInitDisplayStart;
  4095. var columns = settings.aoColumns, column;
  4096. var features = settings.oFeatures;
  4097. var deferLoading = settings.bDeferLoading; // value modified by the draw
  4098. /* Ensure that the table data is fully initialised */
  4099. if ( ! settings.bInitialised ) {
  4100. setTimeout( function(){ _fnInitialise( settings ); }, 200 );
  4101. return;
  4102. }
  4103. /* Show the display HTML options */
  4104. _fnAddOptionsHtml( settings );
  4105. /* Build and draw the header / footer for the table */
  4106. _fnBuildHead( settings );
  4107. _fnDrawHead( settings, settings.aoHeader );
  4108. _fnDrawHead( settings, settings.aoFooter );
  4109. /* Okay to show that something is going on now */
  4110. _fnProcessingDisplay( settings, true );
  4111. /* Calculate sizes for columns */
  4112. if ( features.bAutoWidth ) {
  4113. _fnCalculateColumnWidths( settings );
  4114. }
  4115. for ( i=0, iLen=columns.length ; i<iLen ; i++ ) {
  4116. column = columns[i];
  4117. if ( column.sWidth ) {
  4118. column.nTh.style.width = _fnStringToCss( column.sWidth );
  4119. }
  4120. }
  4121. _fnCallbackFire( settings, null, 'preInit', [settings] );
  4122. // If there is default sorting required - let's do it. The sort function
  4123. // will do the drawing for us. Otherwise we draw the table regardless of the
  4124. // Ajax source - this allows the table to look initialised for Ajax sourcing
  4125. // data (show 'loading' message possibly)
  4126. _fnReDraw( settings );
  4127. // Server-side processing init complete is done by _fnAjaxUpdateDraw
  4128. var dataSrc = _fnDataSource( settings );
  4129. if ( dataSrc != 'ssp' || deferLoading ) {
  4130. // if there is an ajax source load the data
  4131. if ( dataSrc == 'ajax' ) {
  4132. _fnBuildAjax( settings, [], function(json) {
  4133. var aData = _fnAjaxDataSrc( settings, json );
  4134. // Got the data - add it to the table
  4135. for ( i=0 ; i<aData.length ; i++ ) {
  4136. _fnAddData( settings, aData[i] );
  4137. }
  4138. // Reset the init display for cookie saving. We've already done
  4139. // a filter, and therefore cleared it before. So we need to make
  4140. // it appear 'fresh'
  4141. settings.iInitDisplayStart = iAjaxStart;
  4142. _fnReDraw( settings );
  4143. _fnProcessingDisplay( settings, false );
  4144. _fnInitComplete( settings, json );
  4145. }, settings );
  4146. }
  4147. else {
  4148. _fnProcessingDisplay( settings, false );
  4149. _fnInitComplete( settings );
  4150. }
  4151. }
  4152. }
  4153. /**
  4154. * Draw the table for the first time, adding all required features
  4155. * @param {object} oSettings dataTables settings object
  4156. * @param {object} [json] JSON from the server that completed the table, if using Ajax source
  4157. * with client-side processing (optional)
  4158. * @memberof DataTable#oApi
  4159. */
  4160. function _fnInitComplete ( settings, json )
  4161. {
  4162. settings._bInitComplete = true;
  4163. // When data was added after the initialisation (data or Ajax) we need to
  4164. // calculate the column sizing
  4165. if ( json || settings.oInit.aaData ) {
  4166. _fnAdjustColumnSizing( settings );
  4167. }
  4168. _fnCallbackFire( settings, null, 'plugin-init', [settings, json] );
  4169. _fnCallbackFire( settings, 'aoInitComplete', 'init', [settings, json] );
  4170. }
  4171. function _fnLengthChange ( settings, val )
  4172. {
  4173. var len = parseInt( val, 10 );
  4174. settings._iDisplayLength = len;
  4175. _fnLengthOverflow( settings );
  4176. // Fire length change event
  4177. _fnCallbackFire( settings, null, 'length', [settings, len] );
  4178. }
  4179. /**
  4180. * Generate the node required for user display length changing
  4181. * @param {object} settings dataTables settings object
  4182. * @returns {node} Display length feature node
  4183. * @memberof DataTable#oApi
  4184. */
  4185. function _fnFeatureHtmlLength ( settings )
  4186. {
  4187. var
  4188. classes = settings.oClasses,
  4189. tableId = settings.sTableId,
  4190. menu = settings.aLengthMenu,
  4191. d2 = Array.isArray( menu[0] ),
  4192. lengths = d2 ? menu[0] : menu,
  4193. language = d2 ? menu[1] : menu;
  4194. var select = $('<select/>', {
  4195. 'name': tableId+'_length',
  4196. 'aria-controls': tableId,
  4197. 'class': classes.sLengthSelect
  4198. } );
  4199. for ( var i=0, ien=lengths.length ; i<ien ; i++ ) {
  4200. select[0][ i ] = new Option(
  4201. typeof language[i] === 'number' ?
  4202. settings.fnFormatNumber( language[i] ) :
  4203. language[i],
  4204. lengths[i]
  4205. );
  4206. }
  4207. var div = $('<div><label/></div>').addClass( classes.sLength );
  4208. if ( ! settings.aanFeatures.l ) {
  4209. div[0].id = tableId+'_length';
  4210. }
  4211. div.children().append(
  4212. settings.oLanguage.sLengthMenu.replace( '_MENU_', select[0].outerHTML )
  4213. );
  4214. // Can't use `select` variable as user might provide their own and the
  4215. // reference is broken by the use of outerHTML
  4216. $('select', div)
  4217. .val( settings._iDisplayLength )
  4218. .on( 'change.DT', function(e) {
  4219. _fnLengthChange( settings, $(this).val() );
  4220. _fnDraw( settings );
  4221. } );
  4222. // Update node value whenever anything changes the table's length
  4223. $(settings.nTable).on( 'length.dt.DT', function (e, s, len) {
  4224. if ( settings === s ) {
  4225. $('select', div).val( len );
  4226. }
  4227. } );
  4228. return div[0];
  4229. }
  4230. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  4231. * Note that most of the paging logic is done in
  4232. * DataTable.ext.pager
  4233. */
  4234. /**
  4235. * Generate the node required for default pagination
  4236. * @param {object} oSettings dataTables settings object
  4237. * @returns {node} Pagination feature node
  4238. * @memberof DataTable#oApi
  4239. */
  4240. function _fnFeatureHtmlPaginate ( settings )
  4241. {
  4242. var
  4243. type = settings.sPaginationType,
  4244. plugin = DataTable.ext.pager[ type ],
  4245. modern = typeof plugin === 'function',
  4246. redraw = function( settings ) {
  4247. _fnDraw( settings );
  4248. },
  4249. node = $('<div/>').addClass( settings.oClasses.sPaging + type )[0],
  4250. features = settings.aanFeatures;
  4251. if ( ! modern ) {
  4252. plugin.fnInit( settings, node, redraw );
  4253. }
  4254. /* Add a draw callback for the pagination on first instance, to update the paging display */
  4255. if ( ! features.p )
  4256. {
  4257. node.id = settings.sTableId+'_paginate';
  4258. settings.aoDrawCallback.push( {
  4259. "fn": function( settings ) {
  4260. if ( modern ) {
  4261. var
  4262. start = settings._iDisplayStart,
  4263. len = settings._iDisplayLength,
  4264. visRecords = settings.fnRecordsDisplay(),
  4265. all = len === -1,
  4266. page = all ? 0 : Math.ceil( start / len ),
  4267. pages = all ? 1 : Math.ceil( visRecords / len ),
  4268. buttons = plugin(page, pages),
  4269. i, ien;
  4270. for ( i=0, ien=features.p.length ; i<ien ; i++ ) {
  4271. _fnRenderer( settings, 'pageButton' )(
  4272. settings, features.p[i], i, buttons, page, pages
  4273. );
  4274. }
  4275. }
  4276. else {
  4277. plugin.fnUpdate( settings, redraw );
  4278. }
  4279. },
  4280. "sName": "pagination"
  4281. } );
  4282. }
  4283. return node;
  4284. }
  4285. /**
  4286. * Alter the display settings to change the page
  4287. * @param {object} settings DataTables settings object
  4288. * @param {string|int} action Paging action to take: "first", "previous",
  4289. * "next" or "last" or page number to jump to (integer)
  4290. * @param [bool] redraw Automatically draw the update or not
  4291. * @returns {bool} true page has changed, false - no change
  4292. * @memberof DataTable#oApi
  4293. */
  4294. function _fnPageChange ( settings, action, redraw )
  4295. {
  4296. var
  4297. start = settings._iDisplayStart,
  4298. len = settings._iDisplayLength,
  4299. records = settings.fnRecordsDisplay();
  4300. if ( records === 0 || len === -1 )
  4301. {
  4302. start = 0;
  4303. }
  4304. else if ( typeof action === "number" )
  4305. {
  4306. start = action * len;
  4307. if ( start > records )
  4308. {
  4309. start = 0;
  4310. }
  4311. }
  4312. else if ( action == "first" )
  4313. {
  4314. start = 0;
  4315. }
  4316. else if ( action == "previous" )
  4317. {
  4318. start = len >= 0 ?
  4319. start - len :
  4320. 0;
  4321. if ( start < 0 )
  4322. {
  4323. start = 0;
  4324. }
  4325. }
  4326. else if ( action == "next" )
  4327. {
  4328. if ( start + len < records )
  4329. {
  4330. start += len;
  4331. }
  4332. }
  4333. else if ( action == "last" )
  4334. {
  4335. start = Math.floor( (records-1) / len) * len;
  4336. }
  4337. else
  4338. {
  4339. _fnLog( settings, 0, "Unknown paging action: "+action, 5 );
  4340. }
  4341. var changed = settings._iDisplayStart !== start;
  4342. settings._iDisplayStart = start;
  4343. if ( changed ) {
  4344. _fnCallbackFire( settings, null, 'page', [settings] );
  4345. if ( redraw ) {
  4346. _fnDraw( settings );
  4347. }
  4348. }
  4349. return changed;
  4350. }
  4351. /**
  4352. * Generate the node required for the processing node
  4353. * @param {object} settings dataTables settings object
  4354. * @returns {node} Processing element
  4355. * @memberof DataTable#oApi
  4356. */
  4357. function _fnFeatureHtmlProcessing ( settings )
  4358. {
  4359. return $('<div/>', {
  4360. 'id': ! settings.aanFeatures.r ? settings.sTableId+'_processing' : null,
  4361. 'class': settings.oClasses.sProcessing
  4362. } )
  4363. .html( settings.oLanguage.sProcessing )
  4364. .insertBefore( settings.nTable )[0];
  4365. }
  4366. /**
  4367. * Display or hide the processing indicator
  4368. * @param {object} settings dataTables settings object
  4369. * @param {bool} show Show the processing indicator (true) or not (false)
  4370. * @memberof DataTable#oApi
  4371. */
  4372. function _fnProcessingDisplay ( settings, show )
  4373. {
  4374. if ( settings.oFeatures.bProcessing ) {
  4375. $(settings.aanFeatures.r).css( 'display', show ? 'block' : 'none' );
  4376. }
  4377. _fnCallbackFire( settings, null, 'processing', [settings, show] );
  4378. }
  4379. /**
  4380. * Add any control elements for the table - specifically scrolling
  4381. * @param {object} settings dataTables settings object
  4382. * @returns {node} Node to add to the DOM
  4383. * @memberof DataTable#oApi
  4384. */
  4385. function _fnFeatureHtmlTable ( settings )
  4386. {
  4387. var table = $(settings.nTable);
  4388. // Add the ARIA grid role to the table
  4389. table.attr( 'role', 'grid' );
  4390. // Scrolling from here on in
  4391. var scroll = settings.oScroll;
  4392. if ( scroll.sX === '' && scroll.sY === '' ) {
  4393. return settings.nTable;
  4394. }
  4395. var scrollX = scroll.sX;
  4396. var scrollY = scroll.sY;
  4397. var classes = settings.oClasses;
  4398. var caption = table.children('caption');
  4399. var captionSide = caption.length ? caption[0]._captionSide : null;
  4400. var headerClone = $( table[0].cloneNode(false) );
  4401. var footerClone = $( table[0].cloneNode(false) );
  4402. var footer = table.children('tfoot');
  4403. var _div = '<div/>';
  4404. var size = function ( s ) {
  4405. return !s ? null : _fnStringToCss( s );
  4406. };
  4407. if ( ! footer.length ) {
  4408. footer = null;
  4409. }
  4410. /*
  4411. * The HTML structure that we want to generate in this function is:
  4412. * div - scroller
  4413. * div - scroll head
  4414. * div - scroll head inner
  4415. * table - scroll head table
  4416. * thead - thead
  4417. * div - scroll body
  4418. * table - table (master table)
  4419. * thead - thead clone for sizing
  4420. * tbody - tbody
  4421. * div - scroll foot
  4422. * div - scroll foot inner
  4423. * table - scroll foot table
  4424. * tfoot - tfoot
  4425. */
  4426. var scroller = $( _div, { 'class': classes.sScrollWrapper } )
  4427. .append(
  4428. $(_div, { 'class': classes.sScrollHead } )
  4429. .css( {
  4430. overflow: 'hidden',
  4431. position: 'relative',
  4432. border: 0,
  4433. width: scrollX ? size(scrollX) : '100%'
  4434. } )
  4435. .append(
  4436. $(_div, { 'class': classes.sScrollHeadInner } )
  4437. .css( {
  4438. 'box-sizing': 'content-box',
  4439. width: scroll.sXInner || '100%'
  4440. } )
  4441. .append(
  4442. headerClone
  4443. .removeAttr('id')
  4444. .css( 'margin-left', 0 )
  4445. .append( captionSide === 'top' ? caption : null )
  4446. .append(
  4447. table.children('thead')
  4448. )
  4449. )
  4450. )
  4451. )
  4452. .append(
  4453. $(_div, { 'class': classes.sScrollBody } )
  4454. .css( {
  4455. position: 'relative',
  4456. overflow: 'auto',
  4457. width: size( scrollX )
  4458. } )
  4459. .append( table )
  4460. );
  4461. if ( footer ) {
  4462. scroller.append(
  4463. $(_div, { 'class': classes.sScrollFoot } )
  4464. .css( {
  4465. overflow: 'hidden',
  4466. border: 0,
  4467. width: scrollX ? size(scrollX) : '100%'
  4468. } )
  4469. .append(
  4470. $(_div, { 'class': classes.sScrollFootInner } )
  4471. .append(
  4472. footerClone
  4473. .removeAttr('id')
  4474. .css( 'margin-left', 0 )
  4475. .append( captionSide === 'bottom' ? caption : null )
  4476. .append(
  4477. table.children('tfoot')
  4478. )
  4479. )
  4480. )
  4481. );
  4482. }
  4483. var children = scroller.children();
  4484. var scrollHead = children[0];
  4485. var scrollBody = children[1];
  4486. var scrollFoot = footer ? children[2] : null;
  4487. // When the body is scrolled, then we also want to scroll the headers
  4488. if ( scrollX ) {
  4489. $(scrollBody).on( 'scroll.DT', function (e) {
  4490. var scrollLeft = this.scrollLeft;
  4491. scrollHead.scrollLeft = scrollLeft;
  4492. if ( footer ) {
  4493. scrollFoot.scrollLeft = scrollLeft;
  4494. }
  4495. } );
  4496. }
  4497. $(scrollBody).css('max-height', scrollY);
  4498. if (! scroll.bCollapse) {
  4499. $(scrollBody).css('height', scrollY);
  4500. }
  4501. settings.nScrollHead = scrollHead;
  4502. settings.nScrollBody = scrollBody;
  4503. settings.nScrollFoot = scrollFoot;
  4504. // On redraw - align columns
  4505. settings.aoDrawCallback.push( {
  4506. "fn": _fnScrollDraw,
  4507. "sName": "scrolling"
  4508. } );
  4509. return scroller[0];
  4510. }
  4511. /**
  4512. * Update the header, footer and body tables for resizing - i.e. column
  4513. * alignment.
  4514. *
  4515. * Welcome to the most horrible function DataTables. The process that this
  4516. * function follows is basically:
  4517. * 1. Re-create the table inside the scrolling div
  4518. * 2. Take live measurements from the DOM
  4519. * 3. Apply the measurements to align the columns
  4520. * 4. Clean up
  4521. *
  4522. * @param {object} settings dataTables settings object
  4523. * @memberof DataTable#oApi
  4524. */
  4525. function _fnScrollDraw ( settings )
  4526. {
  4527. // Given that this is such a monster function, a lot of variables are use
  4528. // to try and keep the minimised size as small as possible
  4529. var
  4530. scroll = settings.oScroll,
  4531. scrollX = scroll.sX,
  4532. scrollXInner = scroll.sXInner,
  4533. scrollY = scroll.sY,
  4534. barWidth = scroll.iBarWidth,
  4535. divHeader = $(settings.nScrollHead),
  4536. divHeaderStyle = divHeader[0].style,
  4537. divHeaderInner = divHeader.children('div'),
  4538. divHeaderInnerStyle = divHeaderInner[0].style,
  4539. divHeaderTable = divHeaderInner.children('table'),
  4540. divBodyEl = settings.nScrollBody,
  4541. divBody = $(divBodyEl),
  4542. divBodyStyle = divBodyEl.style,
  4543. divFooter = $(settings.nScrollFoot),
  4544. divFooterInner = divFooter.children('div'),
  4545. divFooterTable = divFooterInner.children('table'),
  4546. header = $(settings.nTHead),
  4547. table = $(settings.nTable),
  4548. tableEl = table[0],
  4549. tableStyle = tableEl.style,
  4550. footer = settings.nTFoot ? $(settings.nTFoot) : null,
  4551. browser = settings.oBrowser,
  4552. ie67 = browser.bScrollOversize,
  4553. dtHeaderCells = _pluck( settings.aoColumns, 'nTh' ),
  4554. headerTrgEls, footerTrgEls,
  4555. headerSrcEls, footerSrcEls,
  4556. headerCopy, footerCopy,
  4557. headerWidths=[], footerWidths=[],
  4558. headerContent=[], footerContent=[],
  4559. idx, correction, sanityWidth,
  4560. zeroOut = function(nSizer) {
  4561. var style = nSizer.style;
  4562. style.paddingTop = "0";
  4563. style.paddingBottom = "0";
  4564. style.borderTopWidth = "0";
  4565. style.borderBottomWidth = "0";
  4566. style.height = 0;
  4567. };
  4568. // If the scrollbar visibility has changed from the last draw, we need to
  4569. // adjust the column sizes as the table width will have changed to account
  4570. // for the scrollbar
  4571. var scrollBarVis = divBodyEl.scrollHeight > divBodyEl.clientHeight;
  4572. if ( settings.scrollBarVis !== scrollBarVis && settings.scrollBarVis !== undefined ) {
  4573. settings.scrollBarVis = scrollBarVis;
  4574. _fnAdjustColumnSizing( settings );
  4575. return; // adjust column sizing will call this function again
  4576. }
  4577. else {
  4578. settings.scrollBarVis = scrollBarVis;
  4579. }
  4580. /*
  4581. * 1. Re-create the table inside the scrolling div
  4582. */
  4583. // Remove the old minimised thead and tfoot elements in the inner table
  4584. table.children('thead, tfoot').remove();
  4585. if ( footer ) {
  4586. footerCopy = footer.clone().prependTo( table );
  4587. footerTrgEls = footer.find('tr'); // the original tfoot is in its own table and must be sized
  4588. footerSrcEls = footerCopy.find('tr');
  4589. }
  4590. // Clone the current header and footer elements and then place it into the inner table
  4591. headerCopy = header.clone().prependTo( table );
  4592. headerTrgEls = header.find('tr'); // original header is in its own table
  4593. headerSrcEls = headerCopy.find('tr');
  4594. headerCopy.find('th, td').removeAttr('tabindex');
  4595. /*
  4596. * 2. Take live measurements from the DOM - do not alter the DOM itself!
  4597. */
  4598. // Remove old sizing and apply the calculated column widths
  4599. // Get the unique column headers in the newly created (cloned) header. We want to apply the
  4600. // calculated sizes to this header
  4601. if ( ! scrollX )
  4602. {
  4603. divBodyStyle.width = '100%';
  4604. divHeader[0].style.width = '100%';
  4605. }
  4606. $.each( _fnGetUniqueThs( settings, headerCopy ), function ( i, el ) {
  4607. idx = _fnVisibleToColumnIndex( settings, i );
  4608. el.style.width = settings.aoColumns[idx].sWidth;
  4609. } );
  4610. if ( footer ) {
  4611. _fnApplyToChildren( function(n) {
  4612. n.style.width = "";
  4613. }, footerSrcEls );
  4614. }
  4615. // Size the table as a whole
  4616. sanityWidth = table.outerWidth();
  4617. if ( scrollX === "" ) {
  4618. // No x scrolling
  4619. tableStyle.width = "100%";
  4620. // IE7 will make the width of the table when 100% include the scrollbar
  4621. // - which is shouldn't. When there is a scrollbar we need to take this
  4622. // into account.
  4623. if ( ie67 && (table.find('tbody').height() > divBodyEl.offsetHeight ||
  4624. divBody.css('overflow-y') == "scroll")
  4625. ) {
  4626. tableStyle.width = _fnStringToCss( table.outerWidth() - barWidth);
  4627. }
  4628. // Recalculate the sanity width
  4629. sanityWidth = table.outerWidth();
  4630. }
  4631. else if ( scrollXInner !== "" ) {
  4632. // legacy x scroll inner has been given - use it
  4633. tableStyle.width = _fnStringToCss(scrollXInner);
  4634. // Recalculate the sanity width
  4635. sanityWidth = table.outerWidth();
  4636. }
  4637. // Hidden header should have zero height, so remove padding and borders. Then
  4638. // set the width based on the real headers
  4639. // Apply all styles in one pass
  4640. _fnApplyToChildren( zeroOut, headerSrcEls );
  4641. // Read all widths in next pass
  4642. _fnApplyToChildren( function(nSizer) {
  4643. headerContent.push( nSizer.innerHTML );
  4644. headerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  4645. }, headerSrcEls );
  4646. // Apply all widths in final pass
  4647. _fnApplyToChildren( function(nToSize, i) {
  4648. // Only apply widths to the DataTables detected header cells - this
  4649. // prevents complex headers from having contradictory sizes applied
  4650. if ( $.inArray( nToSize, dtHeaderCells ) !== -1 ) {
  4651. nToSize.style.width = headerWidths[i];
  4652. }
  4653. }, headerTrgEls );
  4654. $(headerSrcEls).height(0);
  4655. /* Same again with the footer if we have one */
  4656. if ( footer )
  4657. {
  4658. _fnApplyToChildren( zeroOut, footerSrcEls );
  4659. _fnApplyToChildren( function(nSizer) {
  4660. footerContent.push( nSizer.innerHTML );
  4661. footerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  4662. }, footerSrcEls );
  4663. _fnApplyToChildren( function(nToSize, i) {
  4664. nToSize.style.width = footerWidths[i];
  4665. }, footerTrgEls );
  4666. $(footerSrcEls).height(0);
  4667. }
  4668. /*
  4669. * 3. Apply the measurements
  4670. */
  4671. // "Hide" the header and footer that we used for the sizing. We need to keep
  4672. // the content of the cell so that the width applied to the header and body
  4673. // both match, but we want to hide it completely. We want to also fix their
  4674. // width to what they currently are
  4675. _fnApplyToChildren( function(nSizer, i) {
  4676. nSizer.innerHTML = '<div class="dataTables_sizing">'+headerContent[i]+'</div>';
  4677. nSizer.childNodes[0].style.height = "0";
  4678. nSizer.childNodes[0].style.overflow = "hidden";
  4679. nSizer.style.width = headerWidths[i];
  4680. }, headerSrcEls );
  4681. if ( footer )
  4682. {
  4683. _fnApplyToChildren( function(nSizer, i) {
  4684. nSizer.innerHTML = '<div class="dataTables_sizing">'+footerContent[i]+'</div>';
  4685. nSizer.childNodes[0].style.height = "0";
  4686. nSizer.childNodes[0].style.overflow = "hidden";
  4687. nSizer.style.width = footerWidths[i];
  4688. }, footerSrcEls );
  4689. }
  4690. // Sanity check that the table is of a sensible width. If not then we are going to get
  4691. // misalignment - try to prevent this by not allowing the table to shrink below its min width
  4692. if ( table.outerWidth() < sanityWidth )
  4693. {
  4694. // The min width depends upon if we have a vertical scrollbar visible or not */
  4695. correction = ((divBodyEl.scrollHeight > divBodyEl.offsetHeight ||
  4696. divBody.css('overflow-y') == "scroll")) ?
  4697. sanityWidth+barWidth :
  4698. sanityWidth;
  4699. // IE6/7 are a law unto themselves...
  4700. if ( ie67 && (divBodyEl.scrollHeight >
  4701. divBodyEl.offsetHeight || divBody.css('overflow-y') == "scroll")
  4702. ) {
  4703. tableStyle.width = _fnStringToCss( correction-barWidth );
  4704. }
  4705. // And give the user a warning that we've stopped the table getting too small
  4706. if ( scrollX === "" || scrollXInner !== "" ) {
  4707. _fnLog( settings, 1, 'Possible column misalignment', 6 );
  4708. }
  4709. }
  4710. else
  4711. {
  4712. correction = '100%';
  4713. }
  4714. // Apply to the container elements
  4715. divBodyStyle.width = _fnStringToCss( correction );
  4716. divHeaderStyle.width = _fnStringToCss( correction );
  4717. if ( footer ) {
  4718. settings.nScrollFoot.style.width = _fnStringToCss( correction );
  4719. }
  4720. /*
  4721. * 4. Clean up
  4722. */
  4723. if ( ! scrollY ) {
  4724. /* IE7< puts a vertical scrollbar in place (when it shouldn't be) due to subtracting
  4725. * the scrollbar height from the visible display, rather than adding it on. We need to
  4726. * set the height in order to sort this. Don't want to do it in any other browsers.
  4727. */
  4728. if ( ie67 ) {
  4729. divBodyStyle.height = _fnStringToCss( tableEl.offsetHeight+barWidth );
  4730. }
  4731. }
  4732. /* Finally set the width's of the header and footer tables */
  4733. var iOuterWidth = table.outerWidth();
  4734. divHeaderTable[0].style.width = _fnStringToCss( iOuterWidth );
  4735. divHeaderInnerStyle.width = _fnStringToCss( iOuterWidth );
  4736. // Figure out if there are scrollbar present - if so then we need a the header and footer to
  4737. // provide a bit more space to allow "overflow" scrolling (i.e. past the scrollbar)
  4738. var bScrolling = table.height() > divBodyEl.clientHeight || divBody.css('overflow-y') == "scroll";
  4739. var padding = 'padding' + (browser.bScrollbarLeft ? 'Left' : 'Right' );
  4740. divHeaderInnerStyle[ padding ] = bScrolling ? barWidth+"px" : "0px";
  4741. if ( footer ) {
  4742. divFooterTable[0].style.width = _fnStringToCss( iOuterWidth );
  4743. divFooterInner[0].style.width = _fnStringToCss( iOuterWidth );
  4744. divFooterInner[0].style[padding] = bScrolling ? barWidth+"px" : "0px";
  4745. }
  4746. // Correct DOM ordering for colgroup - comes before the thead
  4747. table.children('colgroup').insertBefore( table.children('thead') );
  4748. /* Adjust the position of the header in case we loose the y-scrollbar */
  4749. divBody.trigger('scroll');
  4750. // If sorting or filtering has occurred, jump the scrolling back to the top
  4751. // only if we aren't holding the position
  4752. if ( (settings.bSorted || settings.bFiltered) && ! settings._drawHold ) {
  4753. divBodyEl.scrollTop = 0;
  4754. }
  4755. }
  4756. /**
  4757. * Apply a given function to the display child nodes of an element array (typically
  4758. * TD children of TR rows
  4759. * @param {function} fn Method to apply to the objects
  4760. * @param array {nodes} an1 List of elements to look through for display children
  4761. * @param array {nodes} an2 Another list (identical structure to the first) - optional
  4762. * @memberof DataTable#oApi
  4763. */
  4764. function _fnApplyToChildren( fn, an1, an2 )
  4765. {
  4766. var index=0, i=0, iLen=an1.length;
  4767. var nNode1, nNode2;
  4768. while ( i < iLen ) {
  4769. nNode1 = an1[i].firstChild;
  4770. nNode2 = an2 ? an2[i].firstChild : null;
  4771. while ( nNode1 ) {
  4772. if ( nNode1.nodeType === 1 ) {
  4773. if ( an2 ) {
  4774. fn( nNode1, nNode2, index );
  4775. }
  4776. else {
  4777. fn( nNode1, index );
  4778. }
  4779. index++;
  4780. }
  4781. nNode1 = nNode1.nextSibling;
  4782. nNode2 = an2 ? nNode2.nextSibling : null;
  4783. }
  4784. i++;
  4785. }
  4786. }
  4787. var __re_html_remove = /<.*?>/g;
  4788. /**
  4789. * Calculate the width of columns for the table
  4790. * @param {object} oSettings dataTables settings object
  4791. * @memberof DataTable#oApi
  4792. */
  4793. function _fnCalculateColumnWidths ( oSettings )
  4794. {
  4795. var
  4796. table = oSettings.nTable,
  4797. columns = oSettings.aoColumns,
  4798. scroll = oSettings.oScroll,
  4799. scrollY = scroll.sY,
  4800. scrollX = scroll.sX,
  4801. scrollXInner = scroll.sXInner,
  4802. columnCount = columns.length,
  4803. visibleColumns = _fnGetColumns( oSettings, 'bVisible' ),
  4804. headerCells = $('th', oSettings.nTHead),
  4805. tableWidthAttr = table.getAttribute('width'), // from DOM element
  4806. tableContainer = table.parentNode,
  4807. userInputs = false,
  4808. i, column, columnIdx, width, outerWidth,
  4809. browser = oSettings.oBrowser,
  4810. ie67 = browser.bScrollOversize;
  4811. var styleWidth = table.style.width;
  4812. if ( styleWidth && styleWidth.indexOf('%') !== -1 ) {
  4813. tableWidthAttr = styleWidth;
  4814. }
  4815. /* Convert any user input sizes into pixel sizes */
  4816. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4817. column = columns[ visibleColumns[i] ];
  4818. if ( column.sWidth !== null ) {
  4819. column.sWidth = _fnConvertToWidth( column.sWidthOrig, tableContainer );
  4820. userInputs = true;
  4821. }
  4822. }
  4823. /* If the number of columns in the DOM equals the number that we have to
  4824. * process in DataTables, then we can use the offsets that are created by
  4825. * the web- browser. No custom sizes can be set in order for this to happen,
  4826. * nor scrolling used
  4827. */
  4828. if ( ie67 || ! userInputs && ! scrollX && ! scrollY &&
  4829. columnCount == _fnVisbleColumns( oSettings ) &&
  4830. columnCount == headerCells.length
  4831. ) {
  4832. for ( i=0 ; i<columnCount ; i++ ) {
  4833. var colIdx = _fnVisibleToColumnIndex( oSettings, i );
  4834. if ( colIdx !== null ) {
  4835. columns[ colIdx ].sWidth = _fnStringToCss( headerCells.eq(i).width() );
  4836. }
  4837. }
  4838. }
  4839. else
  4840. {
  4841. // Otherwise construct a single row, worst case, table with the widest
  4842. // node in the data, assign any user defined widths, then insert it into
  4843. // the DOM and allow the browser to do all the hard work of calculating
  4844. // table widths
  4845. var tmpTable = $(table).clone() // don't use cloneNode - IE8 will remove events on the main table
  4846. .css( 'visibility', 'hidden' )
  4847. .removeAttr( 'id' );
  4848. // Clean up the table body
  4849. tmpTable.find('tbody tr').remove();
  4850. var tr = $('<tr/>').appendTo( tmpTable.find('tbody') );
  4851. // Clone the table header and footer - we can't use the header / footer
  4852. // from the cloned table, since if scrolling is active, the table's
  4853. // real header and footer are contained in different table tags
  4854. tmpTable.find('thead, tfoot').remove();
  4855. tmpTable
  4856. .append( $(oSettings.nTHead).clone() )
  4857. .append( $(oSettings.nTFoot).clone() );
  4858. // Remove any assigned widths from the footer (from scrolling)
  4859. tmpTable.find('tfoot th, tfoot td').css('width', '');
  4860. // Apply custom sizing to the cloned header
  4861. headerCells = _fnGetUniqueThs( oSettings, tmpTable.find('thead')[0] );
  4862. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4863. column = columns[ visibleColumns[i] ];
  4864. headerCells[i].style.width = column.sWidthOrig !== null && column.sWidthOrig !== '' ?
  4865. _fnStringToCss( column.sWidthOrig ) :
  4866. '';
  4867. // For scrollX we need to force the column width otherwise the
  4868. // browser will collapse it. If this width is smaller than the
  4869. // width the column requires, then it will have no effect
  4870. if ( column.sWidthOrig && scrollX ) {
  4871. $( headerCells[i] ).append( $('<div/>').css( {
  4872. width: column.sWidthOrig,
  4873. margin: 0,
  4874. padding: 0,
  4875. border: 0,
  4876. height: 1
  4877. } ) );
  4878. }
  4879. }
  4880. // Find the widest cell for each column and put it into the table
  4881. if ( oSettings.aoData.length ) {
  4882. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4883. columnIdx = visibleColumns[i];
  4884. column = columns[ columnIdx ];
  4885. $( _fnGetWidestNode( oSettings, columnIdx ) )
  4886. .clone( false )
  4887. .append( column.sContentPadding )
  4888. .appendTo( tr );
  4889. }
  4890. }
  4891. // Tidy the temporary table - remove name attributes so there aren't
  4892. // duplicated in the dom (radio elements for example)
  4893. $('[name]', tmpTable).removeAttr('name');
  4894. // Table has been built, attach to the document so we can work with it.
  4895. // A holding element is used, positioned at the top of the container
  4896. // with minimal height, so it has no effect on if the container scrolls
  4897. // or not. Otherwise it might trigger scrolling when it actually isn't
  4898. // needed
  4899. var holder = $('<div/>').css( scrollX || scrollY ?
  4900. {
  4901. position: 'absolute',
  4902. top: 0,
  4903. left: 0,
  4904. height: 1,
  4905. right: 0,
  4906. overflow: 'hidden'
  4907. } :
  4908. {}
  4909. )
  4910. .append( tmpTable )
  4911. .appendTo( tableContainer );
  4912. // When scrolling (X or Y) we want to set the width of the table as
  4913. // appropriate. However, when not scrolling leave the table width as it
  4914. // is. This results in slightly different, but I think correct behaviour
  4915. if ( scrollX && scrollXInner ) {
  4916. tmpTable.width( scrollXInner );
  4917. }
  4918. else if ( scrollX ) {
  4919. tmpTable.css( 'width', 'auto' );
  4920. tmpTable.removeAttr('width');
  4921. // If there is no width attribute or style, then allow the table to
  4922. // collapse
  4923. if ( tmpTable.width() < tableContainer.clientWidth && tableWidthAttr ) {
  4924. tmpTable.width( tableContainer.clientWidth );
  4925. }
  4926. }
  4927. else if ( scrollY ) {
  4928. tmpTable.width( tableContainer.clientWidth );
  4929. }
  4930. else if ( tableWidthAttr ) {
  4931. tmpTable.width( tableWidthAttr );
  4932. }
  4933. // Get the width of each column in the constructed table - we need to
  4934. // know the inner width (so it can be assigned to the other table's
  4935. // cells) and the outer width so we can calculate the full width of the
  4936. // table. This is safe since DataTables requires a unique cell for each
  4937. // column, but if ever a header can span multiple columns, this will
  4938. // need to be modified.
  4939. var total = 0;
  4940. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4941. var cell = $(headerCells[i]);
  4942. var border = cell.outerWidth() - cell.width();
  4943. // Use getBounding... where possible (not IE8-) because it can give
  4944. // sub-pixel accuracy, which we then want to round up!
  4945. var bounding = browser.bBounding ?
  4946. Math.ceil( headerCells[i].getBoundingClientRect().width ) :
  4947. cell.outerWidth();
  4948. // Total is tracked to remove any sub-pixel errors as the outerWidth
  4949. // of the table might not equal the total given here (IE!).
  4950. total += bounding;
  4951. // Width for each column to use
  4952. columns[ visibleColumns[i] ].sWidth = _fnStringToCss( bounding - border );
  4953. }
  4954. table.style.width = _fnStringToCss( total );
  4955. // Finished with the table - ditch it
  4956. holder.remove();
  4957. }
  4958. // If there is a width attr, we want to attach an event listener which
  4959. // allows the table sizing to automatically adjust when the window is
  4960. // resized. Use the width attr rather than CSS, since we can't know if the
  4961. // CSS is a relative value or absolute - DOM read is always px.
  4962. if ( tableWidthAttr ) {
  4963. table.style.width = _fnStringToCss( tableWidthAttr );
  4964. }
  4965. if ( (tableWidthAttr || scrollX) && ! oSettings._reszEvt ) {
  4966. var bindResize = function () {
  4967. $(window).on('resize.DT-'+oSettings.sInstance, _fnThrottle( function () {
  4968. _fnAdjustColumnSizing( oSettings );
  4969. } ) );
  4970. };
  4971. // IE6/7 will crash if we bind a resize event handler on page load.
  4972. // To be removed in 1.11 which drops IE6/7 support
  4973. if ( ie67 ) {
  4974. setTimeout( bindResize, 1000 );
  4975. }
  4976. else {
  4977. bindResize();
  4978. }
  4979. oSettings._reszEvt = true;
  4980. }
  4981. }
  4982. /**
  4983. * Throttle the calls to a function. Arguments and context are maintained for
  4984. * the throttled function
  4985. * @param {function} fn Function to be called
  4986. * @param {int} [freq=200] call frequency in mS
  4987. * @returns {function} wrapped function
  4988. * @memberof DataTable#oApi
  4989. */
  4990. var _fnThrottle = DataTable.util.throttle;
  4991. /**
  4992. * Convert a CSS unit width to pixels (e.g. 2em)
  4993. * @param {string} width width to be converted
  4994. * @param {node} parent parent to get the with for (required for relative widths) - optional
  4995. * @returns {int} width in pixels
  4996. * @memberof DataTable#oApi
  4997. */
  4998. function _fnConvertToWidth ( width, parent )
  4999. {
  5000. if ( ! width ) {
  5001. return 0;
  5002. }
  5003. var n = $('<div/>')
  5004. .css( 'width', _fnStringToCss( width ) )
  5005. .appendTo( parent || document.body );
  5006. var val = n[0].offsetWidth;
  5007. n.remove();
  5008. return val;
  5009. }
  5010. /**
  5011. * Get the widest node
  5012. * @param {object} settings dataTables settings object
  5013. * @param {int} colIdx column of interest
  5014. * @returns {node} widest table node
  5015. * @memberof DataTable#oApi
  5016. */
  5017. function _fnGetWidestNode( settings, colIdx )
  5018. {
  5019. var idx = _fnGetMaxLenString( settings, colIdx );
  5020. if ( idx < 0 ) {
  5021. return null;
  5022. }
  5023. var data = settings.aoData[ idx ];
  5024. return ! data.nTr ? // Might not have been created when deferred rendering
  5025. $('<td/>').html( _fnGetCellData( settings, idx, colIdx, 'display' ) )[0] :
  5026. data.anCells[ colIdx ];
  5027. }
  5028. /**
  5029. * Get the maximum strlen for each data column
  5030. * @param {object} settings dataTables settings object
  5031. * @param {int} colIdx column of interest
  5032. * @returns {string} max string length for each column
  5033. * @memberof DataTable#oApi
  5034. */
  5035. function _fnGetMaxLenString( settings, colIdx )
  5036. {
  5037. var s, max=-1, maxIdx = -1;
  5038. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  5039. s = _fnGetCellData( settings, i, colIdx, 'display' )+'';
  5040. s = s.replace( __re_html_remove, '' );
  5041. s = s.replace( /&nbsp;/g, ' ' );
  5042. if ( s.length > max ) {
  5043. max = s.length;
  5044. maxIdx = i;
  5045. }
  5046. }
  5047. return maxIdx;
  5048. }
  5049. /**
  5050. * Append a CSS unit (only if required) to a string
  5051. * @param {string} value to css-ify
  5052. * @returns {string} value with css unit
  5053. * @memberof DataTable#oApi
  5054. */
  5055. function _fnStringToCss( s )
  5056. {
  5057. if ( s === null ) {
  5058. return '0px';
  5059. }
  5060. if ( typeof s == 'number' ) {
  5061. return s < 0 ?
  5062. '0px' :
  5063. s+'px';
  5064. }
  5065. // Check it has a unit character already
  5066. return s.match(/\d$/) ?
  5067. s+'px' :
  5068. s;
  5069. }
  5070. function _fnSortFlatten ( settings )
  5071. {
  5072. var
  5073. i, iLen, k, kLen,
  5074. aSort = [],
  5075. aiOrig = [],
  5076. aoColumns = settings.aoColumns,
  5077. aDataSort, iCol, sType, srcCol,
  5078. fixed = settings.aaSortingFixed,
  5079. fixedObj = $.isPlainObject( fixed ),
  5080. nestedSort = [],
  5081. add = function ( a ) {
  5082. if ( a.length && ! Array.isArray( a[0] ) ) {
  5083. // 1D array
  5084. nestedSort.push( a );
  5085. }
  5086. else {
  5087. // 2D array
  5088. $.merge( nestedSort, a );
  5089. }
  5090. };
  5091. // Build the sort array, with pre-fix and post-fix options if they have been
  5092. // specified
  5093. if ( Array.isArray( fixed ) ) {
  5094. add( fixed );
  5095. }
  5096. if ( fixedObj && fixed.pre ) {
  5097. add( fixed.pre );
  5098. }
  5099. add( settings.aaSorting );
  5100. if (fixedObj && fixed.post ) {
  5101. add( fixed.post );
  5102. }
  5103. for ( i=0 ; i<nestedSort.length ; i++ )
  5104. {
  5105. srcCol = nestedSort[i][0];
  5106. aDataSort = aoColumns[ srcCol ].aDataSort;
  5107. for ( k=0, kLen=aDataSort.length ; k<kLen ; k++ )
  5108. {
  5109. iCol = aDataSort[k];
  5110. sType = aoColumns[ iCol ].sType || 'string';
  5111. if ( nestedSort[i]._idx === undefined ) {
  5112. nestedSort[i]._idx = $.inArray( nestedSort[i][1], aoColumns[iCol].asSorting );
  5113. }
  5114. aSort.push( {
  5115. src: srcCol,
  5116. col: iCol,
  5117. dir: nestedSort[i][1],
  5118. index: nestedSort[i]._idx,
  5119. type: sType,
  5120. formatter: DataTable.ext.type.order[ sType+"-pre" ]
  5121. } );
  5122. }
  5123. }
  5124. return aSort;
  5125. }
  5126. /**
  5127. * Change the order of the table
  5128. * @param {object} oSettings dataTables settings object
  5129. * @memberof DataTable#oApi
  5130. * @todo This really needs split up!
  5131. */
  5132. function _fnSort ( oSettings )
  5133. {
  5134. var
  5135. i, ien, iLen, j, jLen, k, kLen,
  5136. sDataType, nTh,
  5137. aiOrig = [],
  5138. oExtSort = DataTable.ext.type.order,
  5139. aoData = oSettings.aoData,
  5140. aoColumns = oSettings.aoColumns,
  5141. aDataSort, data, iCol, sType, oSort,
  5142. formatters = 0,
  5143. sortCol,
  5144. displayMaster = oSettings.aiDisplayMaster,
  5145. aSort;
  5146. // Resolve any column types that are unknown due to addition or invalidation
  5147. // @todo Can this be moved into a 'data-ready' handler which is called when
  5148. // data is going to be used in the table?
  5149. _fnColumnTypes( oSettings );
  5150. aSort = _fnSortFlatten( oSettings );
  5151. for ( i=0, ien=aSort.length ; i<ien ; i++ ) {
  5152. sortCol = aSort[i];
  5153. // Track if we can use the fast sort algorithm
  5154. if ( sortCol.formatter ) {
  5155. formatters++;
  5156. }
  5157. // Load the data needed for the sort, for each cell
  5158. _fnSortData( oSettings, sortCol.col );
  5159. }
  5160. /* No sorting required if server-side or no sorting array */
  5161. if ( _fnDataSource( oSettings ) != 'ssp' && aSort.length !== 0 )
  5162. {
  5163. // Create a value - key array of the current row positions such that we can use their
  5164. // current position during the sort, if values match, in order to perform stable sorting
  5165. for ( i=0, iLen=displayMaster.length ; i<iLen ; i++ ) {
  5166. aiOrig[ displayMaster[i] ] = i;
  5167. }
  5168. /* Do the sort - here we want multi-column sorting based on a given data source (column)
  5169. * and sorting function (from oSort) in a certain direction. It's reasonably complex to
  5170. * follow on it's own, but this is what we want (example two column sorting):
  5171. * fnLocalSorting = function(a,b){
  5172. * var iTest;
  5173. * iTest = oSort['string-asc']('data11', 'data12');
  5174. * if (iTest !== 0)
  5175. * return iTest;
  5176. * iTest = oSort['numeric-desc']('data21', 'data22');
  5177. * if (iTest !== 0)
  5178. * return iTest;
  5179. * return oSort['numeric-asc']( aiOrig[a], aiOrig[b] );
  5180. * }
  5181. * Basically we have a test for each sorting column, if the data in that column is equal,
  5182. * test the next column. If all columns match, then we use a numeric sort on the row
  5183. * positions in the original data array to provide a stable sort.
  5184. *
  5185. * Note - I know it seems excessive to have two sorting methods, but the first is around
  5186. * 15% faster, so the second is only maintained for backwards compatibility with sorting
  5187. * methods which do not have a pre-sort formatting function.
  5188. */
  5189. if ( formatters === aSort.length ) {
  5190. // All sort types have formatting functions
  5191. displayMaster.sort( function ( a, b ) {
  5192. var
  5193. x, y, k, test, sort,
  5194. len=aSort.length,
  5195. dataA = aoData[a]._aSortData,
  5196. dataB = aoData[b]._aSortData;
  5197. for ( k=0 ; k<len ; k++ ) {
  5198. sort = aSort[k];
  5199. x = dataA[ sort.col ];
  5200. y = dataB[ sort.col ];
  5201. test = x<y ? -1 : x>y ? 1 : 0;
  5202. if ( test !== 0 ) {
  5203. return sort.dir === 'asc' ? test : -test;
  5204. }
  5205. }
  5206. x = aiOrig[a];
  5207. y = aiOrig[b];
  5208. return x<y ? -1 : x>y ? 1 : 0;
  5209. } );
  5210. }
  5211. else {
  5212. // Depreciated - remove in 1.11 (providing a plug-in option)
  5213. // Not all sort types have formatting methods, so we have to call their sorting
  5214. // methods.
  5215. displayMaster.sort( function ( a, b ) {
  5216. var
  5217. x, y, k, l, test, sort, fn,
  5218. len=aSort.length,
  5219. dataA = aoData[a]._aSortData,
  5220. dataB = aoData[b]._aSortData;
  5221. for ( k=0 ; k<len ; k++ ) {
  5222. sort = aSort[k];
  5223. x = dataA[ sort.col ];
  5224. y = dataB[ sort.col ];
  5225. fn = oExtSort[ sort.type+"-"+sort.dir ] || oExtSort[ "string-"+sort.dir ];
  5226. test = fn( x, y );
  5227. if ( test !== 0 ) {
  5228. return test;
  5229. }
  5230. }
  5231. x = aiOrig[a];
  5232. y = aiOrig[b];
  5233. return x<y ? -1 : x>y ? 1 : 0;
  5234. } );
  5235. }
  5236. }
  5237. /* Tell the draw function that we have sorted the data */
  5238. oSettings.bSorted = true;
  5239. }
  5240. function _fnSortAria ( settings )
  5241. {
  5242. var label;
  5243. var nextSort;
  5244. var columns = settings.aoColumns;
  5245. var aSort = _fnSortFlatten( settings );
  5246. var oAria = settings.oLanguage.oAria;
  5247. // ARIA attributes - need to loop all columns, to update all (removing old
  5248. // attributes as needed)
  5249. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  5250. {
  5251. var col = columns[i];
  5252. var asSorting = col.asSorting;
  5253. var sTitle = col.ariaTitle || col.sTitle.replace( /<.*?>/g, "" );
  5254. var th = col.nTh;
  5255. // IE7 is throwing an error when setting these properties with jQuery's
  5256. // attr() and removeAttr() methods...
  5257. th.removeAttribute('aria-sort');
  5258. /* In ARIA only the first sorting column can be marked as sorting - no multi-sort option */
  5259. if ( col.bSortable ) {
  5260. if ( aSort.length > 0 && aSort[0].col == i ) {
  5261. th.setAttribute('aria-sort', aSort[0].dir=="asc" ? "ascending" : "descending" );
  5262. nextSort = asSorting[ aSort[0].index+1 ] || asSorting[0];
  5263. }
  5264. else {
  5265. nextSort = asSorting[0];
  5266. }
  5267. label = sTitle + ( nextSort === "asc" ?
  5268. oAria.sSortAscending :
  5269. oAria.sSortDescending
  5270. );
  5271. }
  5272. else {
  5273. label = sTitle;
  5274. }
  5275. th.setAttribute('aria-label', label);
  5276. }
  5277. }
  5278. /**
  5279. * Function to run on user sort request
  5280. * @param {object} settings dataTables settings object
  5281. * @param {node} attachTo node to attach the handler to
  5282. * @param {int} colIdx column sorting index
  5283. * @param {boolean} [append=false] Append the requested sort to the existing
  5284. * sort if true (i.e. multi-column sort)
  5285. * @param {function} [callback] callback function
  5286. * @memberof DataTable#oApi
  5287. */
  5288. function _fnSortListener ( settings, colIdx, append, callback )
  5289. {
  5290. var col = settings.aoColumns[ colIdx ];
  5291. var sorting = settings.aaSorting;
  5292. var asSorting = col.asSorting;
  5293. var nextSortIdx;
  5294. var next = function ( a, overflow ) {
  5295. var idx = a._idx;
  5296. if ( idx === undefined ) {
  5297. idx = $.inArray( a[1], asSorting );
  5298. }
  5299. return idx+1 < asSorting.length ?
  5300. idx+1 :
  5301. overflow ?
  5302. null :
  5303. 0;
  5304. };
  5305. // Convert to 2D array if needed
  5306. if ( typeof sorting[0] === 'number' ) {
  5307. sorting = settings.aaSorting = [ sorting ];
  5308. }
  5309. // If appending the sort then we are multi-column sorting
  5310. if ( append && settings.oFeatures.bSortMulti ) {
  5311. // Are we already doing some kind of sort on this column?
  5312. var sortIdx = $.inArray( colIdx, _pluck(sorting, '0') );
  5313. if ( sortIdx !== -1 ) {
  5314. // Yes, modify the sort
  5315. nextSortIdx = next( sorting[sortIdx], true );
  5316. if ( nextSortIdx === null && sorting.length === 1 ) {
  5317. nextSortIdx = 0; // can't remove sorting completely
  5318. }
  5319. if ( nextSortIdx === null ) {
  5320. sorting.splice( sortIdx, 1 );
  5321. }
  5322. else {
  5323. sorting[sortIdx][1] = asSorting[ nextSortIdx ];
  5324. sorting[sortIdx]._idx = nextSortIdx;
  5325. }
  5326. }
  5327. else {
  5328. // No sort on this column yet
  5329. sorting.push( [ colIdx, asSorting[0], 0 ] );
  5330. sorting[sorting.length-1]._idx = 0;
  5331. }
  5332. }
  5333. else if ( sorting.length && sorting[0][0] == colIdx ) {
  5334. // Single column - already sorting on this column, modify the sort
  5335. nextSortIdx = next( sorting[0] );
  5336. sorting.length = 1;
  5337. sorting[0][1] = asSorting[ nextSortIdx ];
  5338. sorting[0]._idx = nextSortIdx;
  5339. }
  5340. else {
  5341. // Single column - sort only on this column
  5342. sorting.length = 0;
  5343. sorting.push( [ colIdx, asSorting[0] ] );
  5344. sorting[0]._idx = 0;
  5345. }
  5346. // Run the sort by calling a full redraw
  5347. _fnReDraw( settings );
  5348. // callback used for async user interaction
  5349. if ( typeof callback == 'function' ) {
  5350. callback( settings );
  5351. }
  5352. }
  5353. /**
  5354. * Attach a sort handler (click) to a node
  5355. * @param {object} settings dataTables settings object
  5356. * @param {node} attachTo node to attach the handler to
  5357. * @param {int} colIdx column sorting index
  5358. * @param {function} [callback] callback function
  5359. * @memberof DataTable#oApi
  5360. */
  5361. function _fnSortAttachListener ( settings, attachTo, colIdx, callback )
  5362. {
  5363. var col = settings.aoColumns[ colIdx ];
  5364. _fnBindAction( attachTo, {}, function (e) {
  5365. /* If the column is not sortable - don't to anything */
  5366. if ( col.bSortable === false ) {
  5367. return;
  5368. }
  5369. // If processing is enabled use a timeout to allow the processing
  5370. // display to be shown - otherwise to it synchronously
  5371. if ( settings.oFeatures.bProcessing ) {
  5372. _fnProcessingDisplay( settings, true );
  5373. setTimeout( function() {
  5374. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  5375. // In server-side processing, the draw callback will remove the
  5376. // processing display
  5377. if ( _fnDataSource( settings ) !== 'ssp' ) {
  5378. _fnProcessingDisplay( settings, false );
  5379. }
  5380. }, 0 );
  5381. }
  5382. else {
  5383. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  5384. }
  5385. } );
  5386. }
  5387. /**
  5388. * Set the sorting classes on table's body, Note: it is safe to call this function
  5389. * when bSort and bSortClasses are false
  5390. * @param {object} oSettings dataTables settings object
  5391. * @memberof DataTable#oApi
  5392. */
  5393. function _fnSortingClasses( settings )
  5394. {
  5395. var oldSort = settings.aLastSort;
  5396. var sortClass = settings.oClasses.sSortColumn;
  5397. var sort = _fnSortFlatten( settings );
  5398. var features = settings.oFeatures;
  5399. var i, ien, colIdx;
  5400. if ( features.bSort && features.bSortClasses ) {
  5401. // Remove old sorting classes
  5402. for ( i=0, ien=oldSort.length ; i<ien ; i++ ) {
  5403. colIdx = oldSort[i].src;
  5404. // Remove column sorting
  5405. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  5406. .removeClass( sortClass + (i<2 ? i+1 : 3) );
  5407. }
  5408. // Add new column sorting
  5409. for ( i=0, ien=sort.length ; i<ien ; i++ ) {
  5410. colIdx = sort[i].src;
  5411. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  5412. .addClass( sortClass + (i<2 ? i+1 : 3) );
  5413. }
  5414. }
  5415. settings.aLastSort = sort;
  5416. }
  5417. // Get the data to sort a column, be it from cache, fresh (populating the
  5418. // cache), or from a sort formatter
  5419. function _fnSortData( settings, idx )
  5420. {
  5421. // Custom sorting function - provided by the sort data type
  5422. var column = settings.aoColumns[ idx ];
  5423. var customSort = DataTable.ext.order[ column.sSortDataType ];
  5424. var customData;
  5425. if ( customSort ) {
  5426. customData = customSort.call( settings.oInstance, settings, idx,
  5427. _fnColumnIndexToVisible( settings, idx )
  5428. );
  5429. }
  5430. // Use / populate cache
  5431. var row, cellData;
  5432. var formatter = DataTable.ext.type.order[ column.sType+"-pre" ];
  5433. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  5434. row = settings.aoData[i];
  5435. if ( ! row._aSortData ) {
  5436. row._aSortData = [];
  5437. }
  5438. if ( ! row._aSortData[idx] || customSort ) {
  5439. cellData = customSort ?
  5440. customData[i] : // If there was a custom sort function, use data from there
  5441. _fnGetCellData( settings, i, idx, 'sort' );
  5442. row._aSortData[ idx ] = formatter ?
  5443. formatter( cellData ) :
  5444. cellData;
  5445. }
  5446. }
  5447. }
  5448. /**
  5449. * Save the state of a table
  5450. * @param {object} oSettings dataTables settings object
  5451. * @memberof DataTable#oApi
  5452. */
  5453. function _fnSaveState ( settings )
  5454. {
  5455. if ( !settings.oFeatures.bStateSave || settings.bDestroying )
  5456. {
  5457. return;
  5458. }
  5459. /* Store the interesting variables */
  5460. var state = {
  5461. time: +new Date(),
  5462. start: settings._iDisplayStart,
  5463. length: settings._iDisplayLength,
  5464. order: $.extend( true, [], settings.aaSorting ),
  5465. search: _fnSearchToCamel( settings.oPreviousSearch ),
  5466. columns: $.map( settings.aoColumns, function ( col, i ) {
  5467. return {
  5468. visible: col.bVisible,
  5469. search: _fnSearchToCamel( settings.aoPreSearchCols[i] )
  5470. };
  5471. } )
  5472. };
  5473. _fnCallbackFire( settings, "aoStateSaveParams", 'stateSaveParams', [settings, state] );
  5474. settings.oSavedState = state;
  5475. settings.fnStateSaveCallback.call( settings.oInstance, settings, state );
  5476. }
  5477. /**
  5478. * Attempt to load a saved table state
  5479. * @param {object} oSettings dataTables settings object
  5480. * @param {object} oInit DataTables init object so we can override settings
  5481. * @param {function} callback Callback to execute when the state has been loaded
  5482. * @memberof DataTable#oApi
  5483. */
  5484. function _fnLoadState ( settings, oInit, callback )
  5485. {
  5486. var i, ien;
  5487. var columns = settings.aoColumns;
  5488. var loaded = function ( s ) {
  5489. if ( ! s || ! s.time ) {
  5490. callback();
  5491. return;
  5492. }
  5493. // Allow custom and plug-in manipulation functions to alter the saved data set and
  5494. // cancelling of loading by returning false
  5495. var abStateLoad = _fnCallbackFire( settings, 'aoStateLoadParams', 'stateLoadParams', [settings, s] );
  5496. if ( $.inArray( false, abStateLoad ) !== -1 ) {
  5497. callback();
  5498. return;
  5499. }
  5500. // Reject old data
  5501. var duration = settings.iStateDuration;
  5502. if ( duration > 0 && s.time < +new Date() - (duration*1000) ) {
  5503. callback();
  5504. return;
  5505. }
  5506. // Number of columns have changed - all bets are off, no restore of settings
  5507. if ( s.columns && columns.length !== s.columns.length ) {
  5508. callback();
  5509. return;
  5510. }
  5511. // Store the saved state so it might be accessed at any time
  5512. settings.oLoadedState = $.extend( true, {}, s );
  5513. // Restore key features - todo - for 1.11 this needs to be done by
  5514. // subscribed events
  5515. if ( s.start !== undefined ) {
  5516. settings._iDisplayStart = s.start;
  5517. settings.iInitDisplayStart = s.start;
  5518. }
  5519. if ( s.length !== undefined ) {
  5520. settings._iDisplayLength = s.length;
  5521. }
  5522. // Order
  5523. if ( s.order !== undefined ) {
  5524. settings.aaSorting = [];
  5525. $.each( s.order, function ( i, col ) {
  5526. settings.aaSorting.push( col[0] >= columns.length ?
  5527. [ 0, col[1] ] :
  5528. col
  5529. );
  5530. } );
  5531. }
  5532. // Search
  5533. if ( s.search !== undefined ) {
  5534. $.extend( settings.oPreviousSearch, _fnSearchToHung( s.search ) );
  5535. }
  5536. // Columns
  5537. //
  5538. if ( s.columns ) {
  5539. for ( i=0, ien=s.columns.length ; i<ien ; i++ ) {
  5540. var col = s.columns[i];
  5541. // Visibility
  5542. if ( col.visible !== undefined ) {
  5543. columns[i].bVisible = col.visible;
  5544. }
  5545. // Search
  5546. if ( col.search !== undefined ) {
  5547. $.extend( settings.aoPreSearchCols[i], _fnSearchToHung( col.search ) );
  5548. }
  5549. }
  5550. }
  5551. _fnCallbackFire( settings, 'aoStateLoaded', 'stateLoaded', [settings, s] );
  5552. callback();
  5553. };
  5554. if ( ! settings.oFeatures.bStateSave ) {
  5555. callback();
  5556. return;
  5557. }
  5558. var state = settings.fnStateLoadCallback.call( settings.oInstance, settings, loaded );
  5559. if ( state !== undefined ) {
  5560. loaded( state );
  5561. }
  5562. // otherwise, wait for the loaded callback to be executed
  5563. }
  5564. /**
  5565. * Return the settings object for a particular table
  5566. * @param {node} table table we are using as a dataTable
  5567. * @returns {object} Settings object - or null if not found
  5568. * @memberof DataTable#oApi
  5569. */
  5570. function _fnSettingsFromNode ( table )
  5571. {
  5572. var settings = DataTable.settings;
  5573. var idx = $.inArray( table, _pluck( settings, 'nTable' ) );
  5574. return idx !== -1 ?
  5575. settings[ idx ] :
  5576. null;
  5577. }
  5578. /**
  5579. * Log an error message
  5580. * @param {object} settings dataTables settings object
  5581. * @param {int} level log error messages, or display them to the user
  5582. * @param {string} msg error message
  5583. * @param {int} tn Technical note id to get more information about the error.
  5584. * @memberof DataTable#oApi
  5585. */
  5586. function _fnLog( settings, level, msg, tn )
  5587. {
  5588. msg = 'DataTables warning: '+
  5589. (settings ? 'table id='+settings.sTableId+' - ' : '')+msg;
  5590. if ( tn ) {
  5591. msg += '. For more information about this error, please see '+
  5592. 'http://datatables.net/tn/'+tn;
  5593. }
  5594. if ( ! level ) {
  5595. // Backwards compatibility pre 1.10
  5596. var ext = DataTable.ext;
  5597. var type = ext.sErrMode || ext.errMode;
  5598. if ( settings ) {
  5599. _fnCallbackFire( settings, null, 'error', [ settings, tn, msg ] );
  5600. }
  5601. if ( type == 'alert' ) {
  5602. alert( msg );
  5603. }
  5604. else if ( type == 'throw' ) {
  5605. throw new Error(msg);
  5606. }
  5607. else if ( typeof type == 'function' ) {
  5608. type( settings, tn, msg );
  5609. }
  5610. }
  5611. else if ( window.console && console.log ) {
  5612. console.log( msg );
  5613. }
  5614. }
  5615. /**
  5616. * See if a property is defined on one object, if so assign it to the other object
  5617. * @param {object} ret target object
  5618. * @param {object} src source object
  5619. * @param {string} name property
  5620. * @param {string} [mappedName] name to map too - optional, name used if not given
  5621. * @memberof DataTable#oApi
  5622. */
  5623. function _fnMap( ret, src, name, mappedName )
  5624. {
  5625. if ( Array.isArray( name ) ) {
  5626. $.each( name, function (i, val) {
  5627. if ( Array.isArray( val ) ) {
  5628. _fnMap( ret, src, val[0], val[1] );
  5629. }
  5630. else {
  5631. _fnMap( ret, src, val );
  5632. }
  5633. } );
  5634. return;
  5635. }
  5636. if ( mappedName === undefined ) {
  5637. mappedName = name;
  5638. }
  5639. if ( src[name] !== undefined ) {
  5640. ret[mappedName] = src[name];
  5641. }
  5642. }
  5643. /**
  5644. * Extend objects - very similar to jQuery.extend, but deep copy objects, and
  5645. * shallow copy arrays. The reason we need to do this, is that we don't want to
  5646. * deep copy array init values (such as aaSorting) since the dev wouldn't be
  5647. * able to override them, but we do want to deep copy arrays.
  5648. * @param {object} out Object to extend
  5649. * @param {object} extender Object from which the properties will be applied to
  5650. * out
  5651. * @param {boolean} breakRefs If true, then arrays will be sliced to take an
  5652. * independent copy with the exception of the `data` or `aaData` parameters
  5653. * if they are present. This is so you can pass in a collection to
  5654. * DataTables and have that used as your data source without breaking the
  5655. * references
  5656. * @returns {object} out Reference, just for convenience - out === the return.
  5657. * @memberof DataTable#oApi
  5658. * @todo This doesn't take account of arrays inside the deep copied objects.
  5659. */
  5660. function _fnExtend( out, extender, breakRefs )
  5661. {
  5662. var val;
  5663. for ( var prop in extender ) {
  5664. if ( extender.hasOwnProperty(prop) ) {
  5665. val = extender[prop];
  5666. if ( $.isPlainObject( val ) ) {
  5667. if ( ! $.isPlainObject( out[prop] ) ) {
  5668. out[prop] = {};
  5669. }
  5670. $.extend( true, out[prop], val );
  5671. }
  5672. else if ( breakRefs && prop !== 'data' && prop !== 'aaData' && Array.isArray(val) ) {
  5673. out[prop] = val.slice();
  5674. }
  5675. else {
  5676. out[prop] = val;
  5677. }
  5678. }
  5679. }
  5680. return out;
  5681. }
  5682. /**
  5683. * Bind an event handers to allow a click or return key to activate the callback.
  5684. * This is good for accessibility since a return on the keyboard will have the
  5685. * same effect as a click, if the element has focus.
  5686. * @param {element} n Element to bind the action to
  5687. * @param {object} oData Data object to pass to the triggered function
  5688. * @param {function} fn Callback function for when the event is triggered
  5689. * @memberof DataTable#oApi
  5690. */
  5691. function _fnBindAction( n, oData, fn )
  5692. {
  5693. $(n)
  5694. .on( 'click.DT', oData, function (e) {
  5695. $(n).trigger('blur'); // Remove focus outline for mouse users
  5696. fn(e);
  5697. } )
  5698. .on( 'keypress.DT', oData, function (e){
  5699. if ( e.which === 13 ) {
  5700. e.preventDefault();
  5701. fn(e);
  5702. }
  5703. } )
  5704. .on( 'selectstart.DT', function () {
  5705. /* Take the brutal approach to cancelling text selection */
  5706. return false;
  5707. } );
  5708. }
  5709. /**
  5710. * Register a callback function. Easily allows a callback function to be added to
  5711. * an array store of callback functions that can then all be called together.
  5712. * @param {object} oSettings dataTables settings object
  5713. * @param {string} sStore Name of the array storage for the callbacks in oSettings
  5714. * @param {function} fn Function to be called back
  5715. * @param {string} sName Identifying name for the callback (i.e. a label)
  5716. * @memberof DataTable#oApi
  5717. */
  5718. function _fnCallbackReg( oSettings, sStore, fn, sName )
  5719. {
  5720. if ( fn )
  5721. {
  5722. oSettings[sStore].push( {
  5723. "fn": fn,
  5724. "sName": sName
  5725. } );
  5726. }
  5727. }
  5728. /**
  5729. * Fire callback functions and trigger events. Note that the loop over the
  5730. * callback array store is done backwards! Further note that you do not want to
  5731. * fire off triggers in time sensitive applications (for example cell creation)
  5732. * as its slow.
  5733. * @param {object} settings dataTables settings object
  5734. * @param {string} callbackArr Name of the array storage for the callbacks in
  5735. * oSettings
  5736. * @param {string} eventName Name of the jQuery custom event to trigger. If
  5737. * null no trigger is fired
  5738. * @param {array} args Array of arguments to pass to the callback function /
  5739. * trigger
  5740. * @memberof DataTable#oApi
  5741. */
  5742. function _fnCallbackFire( settings, callbackArr, eventName, args )
  5743. {
  5744. var ret = [];
  5745. if ( callbackArr ) {
  5746. ret = $.map( settings[callbackArr].slice().reverse(), function (val, i) {
  5747. return val.fn.apply( settings.oInstance, args );
  5748. } );
  5749. }
  5750. if ( eventName !== null ) {
  5751. var e = $.Event( eventName+'.dt' );
  5752. $(settings.nTable).trigger( e, args );
  5753. ret.push( e.result );
  5754. }
  5755. return ret;
  5756. }
  5757. function _fnLengthOverflow ( settings )
  5758. {
  5759. var
  5760. start = settings._iDisplayStart,
  5761. end = settings.fnDisplayEnd(),
  5762. len = settings._iDisplayLength;
  5763. /* If we have space to show extra rows (backing up from the end point - then do so */
  5764. if ( start >= end )
  5765. {
  5766. start = end - len;
  5767. }
  5768. // Keep the start record on the current page
  5769. start -= (start % len);
  5770. if ( len === -1 || start < 0 )
  5771. {
  5772. start = 0;
  5773. }
  5774. settings._iDisplayStart = start;
  5775. }
  5776. function _fnRenderer( settings, type )
  5777. {
  5778. var renderer = settings.renderer;
  5779. var host = DataTable.ext.renderer[type];
  5780. if ( $.isPlainObject( renderer ) && renderer[type] ) {
  5781. // Specific renderer for this type. If available use it, otherwise use
  5782. // the default.
  5783. return host[renderer[type]] || host._;
  5784. }
  5785. else if ( typeof renderer === 'string' ) {
  5786. // Common renderer - if there is one available for this type use it,
  5787. // otherwise use the default
  5788. return host[renderer] || host._;
  5789. }
  5790. // Use the default
  5791. return host._;
  5792. }
  5793. /**
  5794. * Detect the data source being used for the table. Used to simplify the code
  5795. * a little (ajax) and to make it compress a little smaller.
  5796. *
  5797. * @param {object} settings dataTables settings object
  5798. * @returns {string} Data source
  5799. * @memberof DataTable#oApi
  5800. */
  5801. function _fnDataSource ( settings )
  5802. {
  5803. if ( settings.oFeatures.bServerSide ) {
  5804. return 'ssp';
  5805. }
  5806. else if ( settings.ajax || settings.sAjaxSource ) {
  5807. return 'ajax';
  5808. }
  5809. return 'dom';
  5810. }
  5811. /**
  5812. * Computed structure of the DataTables API, defined by the options passed to
  5813. * `DataTable.Api.register()` when building the API.
  5814. *
  5815. * The structure is built in order to speed creation and extension of the Api
  5816. * objects since the extensions are effectively pre-parsed.
  5817. *
  5818. * The array is an array of objects with the following structure, where this
  5819. * base array represents the Api prototype base:
  5820. *
  5821. * [
  5822. * {
  5823. * name: 'data' -- string - Property name
  5824. * val: function () {}, -- function - Api method (or undefined if just an object
  5825. * methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  5826. * propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  5827. * },
  5828. * {
  5829. * name: 'row'
  5830. * val: {},
  5831. * methodExt: [ ... ],
  5832. * propExt: [
  5833. * {
  5834. * name: 'data'
  5835. * val: function () {},
  5836. * methodExt: [ ... ],
  5837. * propExt: [ ... ]
  5838. * },
  5839. * ...
  5840. * ]
  5841. * }
  5842. * ]
  5843. *
  5844. * @type {Array}
  5845. * @ignore
  5846. */
  5847. var __apiStruct = [];
  5848. /**
  5849. * `Array.prototype` reference.
  5850. *
  5851. * @type object
  5852. * @ignore
  5853. */
  5854. var __arrayProto = Array.prototype;
  5855. /**
  5856. * Abstraction for `context` parameter of the `Api` constructor to allow it to
  5857. * take several different forms for ease of use.
  5858. *
  5859. * Each of the input parameter types will be converted to a DataTables settings
  5860. * object where possible.
  5861. *
  5862. * @param {string|node|jQuery|object} mixed DataTable identifier. Can be one
  5863. * of:
  5864. *
  5865. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5866. * with be found and used.
  5867. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5868. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5869. * * `object` - DataTables settings object
  5870. * * `DataTables.Api` - API instance
  5871. * @return {array|null} Matching DataTables settings objects. `null` or
  5872. * `undefined` is returned if no matching DataTable is found.
  5873. * @ignore
  5874. */
  5875. var _toSettings = function ( mixed )
  5876. {
  5877. var idx, jq;
  5878. var settings = DataTable.settings;
  5879. var tables = $.map( settings, function (el, i) {
  5880. return el.nTable;
  5881. } );
  5882. if ( ! mixed ) {
  5883. return [];
  5884. }
  5885. else if ( mixed.nTable && mixed.oApi ) {
  5886. // DataTables settings object
  5887. return [ mixed ];
  5888. }
  5889. else if ( mixed.nodeName && mixed.nodeName.toLowerCase() === 'table' ) {
  5890. // Table node
  5891. idx = $.inArray( mixed, tables );
  5892. return idx !== -1 ? [ settings[idx] ] : null;
  5893. }
  5894. else if ( mixed && typeof mixed.settings === 'function' ) {
  5895. return mixed.settings().toArray();
  5896. }
  5897. else if ( typeof mixed === 'string' ) {
  5898. // jQuery selector
  5899. jq = $(mixed);
  5900. }
  5901. else if ( mixed instanceof $ ) {
  5902. // jQuery object (also DataTables instance)
  5903. jq = mixed;
  5904. }
  5905. if ( jq ) {
  5906. return jq.map( function(i) {
  5907. idx = $.inArray( this, tables );
  5908. return idx !== -1 ? settings[idx] : null;
  5909. } ).toArray();
  5910. }
  5911. };
  5912. /**
  5913. * DataTables API class - used to control and interface with one or more
  5914. * DataTables enhanced tables.
  5915. *
  5916. * The API class is heavily based on jQuery, presenting a chainable interface
  5917. * that you can use to interact with tables. Each instance of the API class has
  5918. * a "context" - i.e. the tables that it will operate on. This could be a single
  5919. * table, all tables on a page or a sub-set thereof.
  5920. *
  5921. * Additionally the API is designed to allow you to easily work with the data in
  5922. * the tables, retrieving and manipulating it as required. This is done by
  5923. * presenting the API class as an array like interface. The contents of the
  5924. * array depend upon the actions requested by each method (for example
  5925. * `rows().nodes()` will return an array of nodes, while `rows().data()` will
  5926. * return an array of objects or arrays depending upon your table's
  5927. * configuration). The API object has a number of array like methods (`push`,
  5928. * `pop`, `reverse` etc) as well as additional helper methods (`each`, `pluck`,
  5929. * `unique` etc) to assist your working with the data held in a table.
  5930. *
  5931. * Most methods (those which return an Api instance) are chainable, which means
  5932. * the return from a method call also has all of the methods available that the
  5933. * top level object had. For example, these two calls are equivalent:
  5934. *
  5935. * // Not chained
  5936. * api.row.add( {...} );
  5937. * api.draw();
  5938. *
  5939. * // Chained
  5940. * api.row.add( {...} ).draw();
  5941. *
  5942. * @class DataTable.Api
  5943. * @param {array|object|string|jQuery} context DataTable identifier. This is
  5944. * used to define which DataTables enhanced tables this API will operate on.
  5945. * Can be one of:
  5946. *
  5947. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5948. * with be found and used.
  5949. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5950. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5951. * * `object` - DataTables settings object
  5952. * @param {array} [data] Data to initialise the Api instance with.
  5953. *
  5954. * @example
  5955. * // Direct initialisation during DataTables construction
  5956. * var api = $('#example').DataTable();
  5957. *
  5958. * @example
  5959. * // Initialisation using a DataTables jQuery object
  5960. * var api = $('#example').dataTable().api();
  5961. *
  5962. * @example
  5963. * // Initialisation as a constructor
  5964. * var api = new $.fn.DataTable.Api( 'table.dataTable' );
  5965. */
  5966. _Api = function ( context, data )
  5967. {
  5968. if ( ! (this instanceof _Api) ) {
  5969. return new _Api( context, data );
  5970. }
  5971. var settings = [];
  5972. var ctxSettings = function ( o ) {
  5973. var a = _toSettings( o );
  5974. if ( a ) {
  5975. settings.push.apply( settings, a );
  5976. }
  5977. };
  5978. if ( Array.isArray( context ) ) {
  5979. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  5980. ctxSettings( context[i] );
  5981. }
  5982. }
  5983. else {
  5984. ctxSettings( context );
  5985. }
  5986. // Remove duplicates
  5987. this.context = _unique( settings );
  5988. // Initial data
  5989. if ( data ) {
  5990. $.merge( this, data );
  5991. }
  5992. // selector
  5993. this.selector = {
  5994. rows: null,
  5995. cols: null,
  5996. opts: null
  5997. };
  5998. _Api.extend( this, this, __apiStruct );
  5999. };
  6000. DataTable.Api = _Api;
  6001. // Don't destroy the existing prototype, just extend it. Required for jQuery 2's
  6002. // isPlainObject.
  6003. $.extend( _Api.prototype, {
  6004. any: function ()
  6005. {
  6006. return this.count() !== 0;
  6007. },
  6008. concat: __arrayProto.concat,
  6009. context: [], // array of table settings objects
  6010. count: function ()
  6011. {
  6012. return this.flatten().length;
  6013. },
  6014. each: function ( fn )
  6015. {
  6016. for ( var i=0, ien=this.length ; i<ien; i++ ) {
  6017. fn.call( this, this[i], i, this );
  6018. }
  6019. return this;
  6020. },
  6021. eq: function ( idx )
  6022. {
  6023. var ctx = this.context;
  6024. return ctx.length > idx ?
  6025. new _Api( ctx[idx], this[idx] ) :
  6026. null;
  6027. },
  6028. filter: function ( fn )
  6029. {
  6030. var a = [];
  6031. if ( __arrayProto.filter ) {
  6032. a = __arrayProto.filter.call( this, fn, this );
  6033. }
  6034. else {
  6035. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  6036. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  6037. if ( fn.call( this, this[i], i, this ) ) {
  6038. a.push( this[i] );
  6039. }
  6040. }
  6041. }
  6042. return new _Api( this.context, a );
  6043. },
  6044. flatten: function ()
  6045. {
  6046. var a = [];
  6047. return new _Api( this.context, a.concat.apply( a, this.toArray() ) );
  6048. },
  6049. join: __arrayProto.join,
  6050. indexOf: __arrayProto.indexOf || function (obj, start)
  6051. {
  6052. for ( var i=(start || 0), ien=this.length ; i<ien ; i++ ) {
  6053. if ( this[i] === obj ) {
  6054. return i;
  6055. }
  6056. }
  6057. return -1;
  6058. },
  6059. iterator: function ( flatten, type, fn, alwaysNew ) {
  6060. var
  6061. a = [], ret,
  6062. i, ien, j, jen,
  6063. context = this.context,
  6064. rows, items, item,
  6065. selector = this.selector;
  6066. // Argument shifting
  6067. if ( typeof flatten === 'string' ) {
  6068. alwaysNew = fn;
  6069. fn = type;
  6070. type = flatten;
  6071. flatten = false;
  6072. }
  6073. for ( i=0, ien=context.length ; i<ien ; i++ ) {
  6074. var apiInst = new _Api( context[i] );
  6075. if ( type === 'table' ) {
  6076. ret = fn.call( apiInst, context[i], i );
  6077. if ( ret !== undefined ) {
  6078. a.push( ret );
  6079. }
  6080. }
  6081. else if ( type === 'columns' || type === 'rows' ) {
  6082. // this has same length as context - one entry for each table
  6083. ret = fn.call( apiInst, context[i], this[i], i );
  6084. if ( ret !== undefined ) {
  6085. a.push( ret );
  6086. }
  6087. }
  6088. else if ( type === 'column' || type === 'column-rows' || type === 'row' || type === 'cell' ) {
  6089. // columns and rows share the same structure.
  6090. // 'this' is an array of column indexes for each context
  6091. items = this[i];
  6092. if ( type === 'column-rows' ) {
  6093. rows = _selector_row_indexes( context[i], selector.opts );
  6094. }
  6095. for ( j=0, jen=items.length ; j<jen ; j++ ) {
  6096. item = items[j];
  6097. if ( type === 'cell' ) {
  6098. ret = fn.call( apiInst, context[i], item.row, item.column, i, j );
  6099. }
  6100. else {
  6101. ret = fn.call( apiInst, context[i], item, i, j, rows );
  6102. }
  6103. if ( ret !== undefined ) {
  6104. a.push( ret );
  6105. }
  6106. }
  6107. }
  6108. }
  6109. if ( a.length || alwaysNew ) {
  6110. var api = new _Api( context, flatten ? a.concat.apply( [], a ) : a );
  6111. var apiSelector = api.selector;
  6112. apiSelector.rows = selector.rows;
  6113. apiSelector.cols = selector.cols;
  6114. apiSelector.opts = selector.opts;
  6115. return api;
  6116. }
  6117. return this;
  6118. },
  6119. lastIndexOf: __arrayProto.lastIndexOf || function (obj, start)
  6120. {
  6121. // Bit cheeky...
  6122. return this.indexOf.apply( this.toArray.reverse(), arguments );
  6123. },
  6124. length: 0,
  6125. map: function ( fn )
  6126. {
  6127. var a = [];
  6128. if ( __arrayProto.map ) {
  6129. a = __arrayProto.map.call( this, fn, this );
  6130. }
  6131. else {
  6132. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  6133. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  6134. a.push( fn.call( this, this[i], i ) );
  6135. }
  6136. }
  6137. return new _Api( this.context, a );
  6138. },
  6139. pluck: function ( prop )
  6140. {
  6141. return this.map( function ( el ) {
  6142. return el[ prop ];
  6143. } );
  6144. },
  6145. pop: __arrayProto.pop,
  6146. push: __arrayProto.push,
  6147. // Does not return an API instance
  6148. reduce: __arrayProto.reduce || function ( fn, init )
  6149. {
  6150. return _fnReduce( this, fn, init, 0, this.length, 1 );
  6151. },
  6152. reduceRight: __arrayProto.reduceRight || function ( fn, init )
  6153. {
  6154. return _fnReduce( this, fn, init, this.length-1, -1, -1 );
  6155. },
  6156. reverse: __arrayProto.reverse,
  6157. // Object with rows, columns and opts
  6158. selector: null,
  6159. shift: __arrayProto.shift,
  6160. slice: function () {
  6161. return new _Api( this.context, this );
  6162. },
  6163. sort: __arrayProto.sort, // ? name - order?
  6164. splice: __arrayProto.splice,
  6165. toArray: function ()
  6166. {
  6167. return __arrayProto.slice.call( this );
  6168. },
  6169. to$: function ()
  6170. {
  6171. return $( this );
  6172. },
  6173. toJQuery: function ()
  6174. {
  6175. return $( this );
  6176. },
  6177. unique: function ()
  6178. {
  6179. return new _Api( this.context, _unique(this) );
  6180. },
  6181. unshift: __arrayProto.unshift
  6182. } );
  6183. _Api.extend = function ( scope, obj, ext )
  6184. {
  6185. // Only extend API instances and static properties of the API
  6186. if ( ! ext.length || ! obj || ( ! (obj instanceof _Api) && ! obj.__dt_wrapper ) ) {
  6187. return;
  6188. }
  6189. var
  6190. i, ien,
  6191. struct,
  6192. methodScoping = function ( scope, fn, struc ) {
  6193. return function () {
  6194. var ret = fn.apply( scope, arguments );
  6195. // Method extension
  6196. _Api.extend( ret, ret, struc.methodExt );
  6197. return ret;
  6198. };
  6199. };
  6200. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  6201. struct = ext[i];
  6202. // Value
  6203. obj[ struct.name ] = struct.type === 'function' ?
  6204. methodScoping( scope, struct.val, struct ) :
  6205. struct.type === 'object' ?
  6206. {} :
  6207. struct.val;
  6208. obj[ struct.name ].__dt_wrapper = true;
  6209. // Property extension
  6210. _Api.extend( scope, obj[ struct.name ], struct.propExt );
  6211. }
  6212. };
  6213. // @todo - Is there need for an augment function?
  6214. // _Api.augment = function ( inst, name )
  6215. // {
  6216. // // Find src object in the structure from the name
  6217. // var parts = name.split('.');
  6218. // _Api.extend( inst, obj );
  6219. // };
  6220. // [
  6221. // {
  6222. // name: 'data' -- string - Property name
  6223. // val: function () {}, -- function - Api method (or undefined if just an object
  6224. // methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  6225. // propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  6226. // },
  6227. // {
  6228. // name: 'row'
  6229. // val: {},
  6230. // methodExt: [ ... ],
  6231. // propExt: [
  6232. // {
  6233. // name: 'data'
  6234. // val: function () {},
  6235. // methodExt: [ ... ],
  6236. // propExt: [ ... ]
  6237. // },
  6238. // ...
  6239. // ]
  6240. // }
  6241. // ]
  6242. _Api.register = _api_register = function ( name, val )
  6243. {
  6244. if ( Array.isArray( name ) ) {
  6245. for ( var j=0, jen=name.length ; j<jen ; j++ ) {
  6246. _Api.register( name[j], val );
  6247. }
  6248. return;
  6249. }
  6250. var
  6251. i, ien,
  6252. heir = name.split('.'),
  6253. struct = __apiStruct,
  6254. key, method;
  6255. var find = function ( src, name ) {
  6256. for ( var i=0, ien=src.length ; i<ien ; i++ ) {
  6257. if ( src[i].name === name ) {
  6258. return src[i];
  6259. }
  6260. }
  6261. return null;
  6262. };
  6263. for ( i=0, ien=heir.length ; i<ien ; i++ ) {
  6264. method = heir[i].indexOf('()') !== -1;
  6265. key = method ?
  6266. heir[i].replace('()', '') :
  6267. heir[i];
  6268. var src = find( struct, key );
  6269. if ( ! src ) {
  6270. src = {
  6271. name: key,
  6272. val: {},
  6273. methodExt: [],
  6274. propExt: [],
  6275. type: 'object'
  6276. };
  6277. struct.push( src );
  6278. }
  6279. if ( i === ien-1 ) {
  6280. src.val = val;
  6281. src.type = typeof val === 'function' ?
  6282. 'function' :
  6283. $.isPlainObject( val ) ?
  6284. 'object' :
  6285. 'other';
  6286. }
  6287. else {
  6288. struct = method ?
  6289. src.methodExt :
  6290. src.propExt;
  6291. }
  6292. }
  6293. };
  6294. _Api.registerPlural = _api_registerPlural = function ( pluralName, singularName, val ) {
  6295. _Api.register( pluralName, val );
  6296. _Api.register( singularName, function () {
  6297. var ret = val.apply( this, arguments );
  6298. if ( ret === this ) {
  6299. // Returned item is the API instance that was passed in, return it
  6300. return this;
  6301. }
  6302. else if ( ret instanceof _Api ) {
  6303. // New API instance returned, want the value from the first item
  6304. // in the returned array for the singular result.
  6305. return ret.length ?
  6306. Array.isArray( ret[0] ) ?
  6307. new _Api( ret.context, ret[0] ) : // Array results are 'enhanced'
  6308. ret[0] :
  6309. undefined;
  6310. }
  6311. // Non-API return - just fire it back
  6312. return ret;
  6313. } );
  6314. };
  6315. /**
  6316. * Selector for HTML tables. Apply the given selector to the give array of
  6317. * DataTables settings objects.
  6318. *
  6319. * @param {string|integer} [selector] jQuery selector string or integer
  6320. * @param {array} Array of DataTables settings objects to be filtered
  6321. * @return {array}
  6322. * @ignore
  6323. */
  6324. var __table_selector = function ( selector, a )
  6325. {
  6326. if ( Array.isArray(selector) ) {
  6327. return $.map( selector, function (item) {
  6328. return __table_selector(item, a);
  6329. } );
  6330. }
  6331. // Integer is used to pick out a table by index
  6332. if ( typeof selector === 'number' ) {
  6333. return [ a[ selector ] ];
  6334. }
  6335. // Perform a jQuery selector on the table nodes
  6336. var nodes = $.map( a, function (el, i) {
  6337. return el.nTable;
  6338. } );
  6339. return $(nodes)
  6340. .filter( selector )
  6341. .map( function (i) {
  6342. // Need to translate back from the table node to the settings
  6343. var idx = $.inArray( this, nodes );
  6344. return a[ idx ];
  6345. } )
  6346. .toArray();
  6347. };
  6348. /**
  6349. * Context selector for the API's context (i.e. the tables the API instance
  6350. * refers to.
  6351. *
  6352. * @name DataTable.Api#tables
  6353. * @param {string|integer} [selector] Selector to pick which tables the iterator
  6354. * should operate on. If not given, all tables in the current context are
  6355. * used. This can be given as a jQuery selector (for example `':gt(0)'`) to
  6356. * select multiple tables or as an integer to select a single table.
  6357. * @returns {DataTable.Api} Returns a new API instance if a selector is given.
  6358. */
  6359. _api_register( 'tables()', function ( selector ) {
  6360. // A new instance is created if there was a selector specified
  6361. return selector !== undefined && selector !== null ?
  6362. new _Api( __table_selector( selector, this.context ) ) :
  6363. this;
  6364. } );
  6365. _api_register( 'table()', function ( selector ) {
  6366. var tables = this.tables( selector );
  6367. var ctx = tables.context;
  6368. // Truncate to the first matched table
  6369. return ctx.length ?
  6370. new _Api( ctx[0] ) :
  6371. tables;
  6372. } );
  6373. _api_registerPlural( 'tables().nodes()', 'table().node()' , function () {
  6374. return this.iterator( 'table', function ( ctx ) {
  6375. return ctx.nTable;
  6376. }, 1 );
  6377. } );
  6378. _api_registerPlural( 'tables().body()', 'table().body()' , function () {
  6379. return this.iterator( 'table', function ( ctx ) {
  6380. return ctx.nTBody;
  6381. }, 1 );
  6382. } );
  6383. _api_registerPlural( 'tables().header()', 'table().header()' , function () {
  6384. return this.iterator( 'table', function ( ctx ) {
  6385. return ctx.nTHead;
  6386. }, 1 );
  6387. } );
  6388. _api_registerPlural( 'tables().footer()', 'table().footer()' , function () {
  6389. return this.iterator( 'table', function ( ctx ) {
  6390. return ctx.nTFoot;
  6391. }, 1 );
  6392. } );
  6393. _api_registerPlural( 'tables().containers()', 'table().container()' , function () {
  6394. return this.iterator( 'table', function ( ctx ) {
  6395. return ctx.nTableWrapper;
  6396. }, 1 );
  6397. } );
  6398. /**
  6399. * Redraw the tables in the current context.
  6400. */
  6401. _api_register( 'draw()', function ( paging ) {
  6402. return this.iterator( 'table', function ( settings ) {
  6403. if ( paging === 'page' ) {
  6404. _fnDraw( settings );
  6405. }
  6406. else {
  6407. if ( typeof paging === 'string' ) {
  6408. paging = paging === 'full-hold' ?
  6409. false :
  6410. true;
  6411. }
  6412. _fnReDraw( settings, paging===false );
  6413. }
  6414. } );
  6415. } );
  6416. /**
  6417. * Get the current page index.
  6418. *
  6419. * @return {integer} Current page index (zero based)
  6420. *//**
  6421. * Set the current page.
  6422. *
  6423. * Note that if you attempt to show a page which does not exist, DataTables will
  6424. * not throw an error, but rather reset the paging.
  6425. *
  6426. * @param {integer|string} action The paging action to take. This can be one of:
  6427. * * `integer` - The page index to jump to
  6428. * * `string` - An action to take:
  6429. * * `first` - Jump to first page.
  6430. * * `next` - Jump to the next page
  6431. * * `previous` - Jump to previous page
  6432. * * `last` - Jump to the last page.
  6433. * @returns {DataTables.Api} this
  6434. */
  6435. _api_register( 'page()', function ( action ) {
  6436. if ( action === undefined ) {
  6437. return this.page.info().page; // not an expensive call
  6438. }
  6439. // else, have an action to take on all tables
  6440. return this.iterator( 'table', function ( settings ) {
  6441. _fnPageChange( settings, action );
  6442. } );
  6443. } );
  6444. /**
  6445. * Paging information for the first table in the current context.
  6446. *
  6447. * If you require paging information for another table, use the `table()` method
  6448. * with a suitable selector.
  6449. *
  6450. * @return {object} Object with the following properties set:
  6451. * * `page` - Current page index (zero based - i.e. the first page is `0`)
  6452. * * `pages` - Total number of pages
  6453. * * `start` - Display index for the first record shown on the current page
  6454. * * `end` - Display index for the last record shown on the current page
  6455. * * `length` - Display length (number of records). Note that generally `start
  6456. * + length = end`, but this is not always true, for example if there are
  6457. * only 2 records to show on the final page, with a length of 10.
  6458. * * `recordsTotal` - Full data set length
  6459. * * `recordsDisplay` - Data set length once the current filtering criterion
  6460. * are applied.
  6461. */
  6462. _api_register( 'page.info()', function ( action ) {
  6463. if ( this.context.length === 0 ) {
  6464. return undefined;
  6465. }
  6466. var
  6467. settings = this.context[0],
  6468. start = settings._iDisplayStart,
  6469. len = settings.oFeatures.bPaginate ? settings._iDisplayLength : -1,
  6470. visRecords = settings.fnRecordsDisplay(),
  6471. all = len === -1;
  6472. return {
  6473. "page": all ? 0 : Math.floor( start / len ),
  6474. "pages": all ? 1 : Math.ceil( visRecords / len ),
  6475. "start": start,
  6476. "end": settings.fnDisplayEnd(),
  6477. "length": len,
  6478. "recordsTotal": settings.fnRecordsTotal(),
  6479. "recordsDisplay": visRecords,
  6480. "serverSide": _fnDataSource( settings ) === 'ssp'
  6481. };
  6482. } );
  6483. /**
  6484. * Get the current page length.
  6485. *
  6486. * @return {integer} Current page length. Note `-1` indicates that all records
  6487. * are to be shown.
  6488. *//**
  6489. * Set the current page length.
  6490. *
  6491. * @param {integer} Page length to set. Use `-1` to show all records.
  6492. * @returns {DataTables.Api} this
  6493. */
  6494. _api_register( 'page.len()', function ( len ) {
  6495. // Note that we can't call this function 'length()' because `length`
  6496. // is a Javascript property of functions which defines how many arguments
  6497. // the function expects.
  6498. if ( len === undefined ) {
  6499. return this.context.length !== 0 ?
  6500. this.context[0]._iDisplayLength :
  6501. undefined;
  6502. }
  6503. // else, set the page length
  6504. return this.iterator( 'table', function ( settings ) {
  6505. _fnLengthChange( settings, len );
  6506. } );
  6507. } );
  6508. var __reload = function ( settings, holdPosition, callback ) {
  6509. // Use the draw event to trigger a callback
  6510. if ( callback ) {
  6511. var api = new _Api( settings );
  6512. api.one( 'draw', function () {
  6513. callback( api.ajax.json() );
  6514. } );
  6515. }
  6516. if ( _fnDataSource( settings ) == 'ssp' ) {
  6517. _fnReDraw( settings, holdPosition );
  6518. }
  6519. else {
  6520. _fnProcessingDisplay( settings, true );
  6521. // Cancel an existing request
  6522. var xhr = settings.jqXHR;
  6523. if ( xhr && xhr.readyState !== 4 ) {
  6524. xhr.abort();
  6525. }
  6526. // Trigger xhr
  6527. _fnBuildAjax( settings, [], function( json ) {
  6528. _fnClearTable( settings );
  6529. var data = _fnAjaxDataSrc( settings, json );
  6530. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6531. _fnAddData( settings, data[i] );
  6532. }
  6533. _fnReDraw( settings, holdPosition );
  6534. _fnProcessingDisplay( settings, false );
  6535. } );
  6536. }
  6537. };
  6538. /**
  6539. * Get the JSON response from the last Ajax request that DataTables made to the
  6540. * server. Note that this returns the JSON from the first table in the current
  6541. * context.
  6542. *
  6543. * @return {object} JSON received from the server.
  6544. */
  6545. _api_register( 'ajax.json()', function () {
  6546. var ctx = this.context;
  6547. if ( ctx.length > 0 ) {
  6548. return ctx[0].json;
  6549. }
  6550. // else return undefined;
  6551. } );
  6552. /**
  6553. * Get the data submitted in the last Ajax request
  6554. */
  6555. _api_register( 'ajax.params()', function () {
  6556. var ctx = this.context;
  6557. if ( ctx.length > 0 ) {
  6558. return ctx[0].oAjaxData;
  6559. }
  6560. // else return undefined;
  6561. } );
  6562. /**
  6563. * Reload tables from the Ajax data source. Note that this function will
  6564. * automatically re-draw the table when the remote data has been loaded.
  6565. *
  6566. * @param {boolean} [reset=true] Reset (default) or hold the current paging
  6567. * position. A full re-sort and re-filter is performed when this method is
  6568. * called, which is why the pagination reset is the default action.
  6569. * @returns {DataTables.Api} this
  6570. */
  6571. _api_register( 'ajax.reload()', function ( callback, resetPaging ) {
  6572. return this.iterator( 'table', function (settings) {
  6573. __reload( settings, resetPaging===false, callback );
  6574. } );
  6575. } );
  6576. /**
  6577. * Get the current Ajax URL. Note that this returns the URL from the first
  6578. * table in the current context.
  6579. *
  6580. * @return {string} Current Ajax source URL
  6581. *//**
  6582. * Set the Ajax URL. Note that this will set the URL for all tables in the
  6583. * current context.
  6584. *
  6585. * @param {string} url URL to set.
  6586. * @returns {DataTables.Api} this
  6587. */
  6588. _api_register( 'ajax.url()', function ( url ) {
  6589. var ctx = this.context;
  6590. if ( url === undefined ) {
  6591. // get
  6592. if ( ctx.length === 0 ) {
  6593. return undefined;
  6594. }
  6595. ctx = ctx[0];
  6596. return ctx.ajax ?
  6597. $.isPlainObject( ctx.ajax ) ?
  6598. ctx.ajax.url :
  6599. ctx.ajax :
  6600. ctx.sAjaxSource;
  6601. }
  6602. // set
  6603. return this.iterator( 'table', function ( settings ) {
  6604. if ( $.isPlainObject( settings.ajax ) ) {
  6605. settings.ajax.url = url;
  6606. }
  6607. else {
  6608. settings.ajax = url;
  6609. }
  6610. // No need to consider sAjaxSource here since DataTables gives priority
  6611. // to `ajax` over `sAjaxSource`. So setting `ajax` here, renders any
  6612. // value of `sAjaxSource` redundant.
  6613. } );
  6614. } );
  6615. /**
  6616. * Load data from the newly set Ajax URL. Note that this method is only
  6617. * available when `ajax.url()` is used to set a URL. Additionally, this method
  6618. * has the same effect as calling `ajax.reload()` but is provided for
  6619. * convenience when setting a new URL. Like `ajax.reload()` it will
  6620. * automatically redraw the table once the remote data has been loaded.
  6621. *
  6622. * @returns {DataTables.Api} this
  6623. */
  6624. _api_register( 'ajax.url().load()', function ( callback, resetPaging ) {
  6625. // Same as a reload, but makes sense to present it for easy access after a
  6626. // url change
  6627. return this.iterator( 'table', function ( ctx ) {
  6628. __reload( ctx, resetPaging===false, callback );
  6629. } );
  6630. } );
  6631. var _selector_run = function ( type, selector, selectFn, settings, opts )
  6632. {
  6633. var
  6634. out = [], res,
  6635. a, i, ien, j, jen,
  6636. selectorType = typeof selector;
  6637. // Can't just check for isArray here, as an API or jQuery instance might be
  6638. // given with their array like look
  6639. if ( ! selector || selectorType === 'string' || selectorType === 'function' || selector.length === undefined ) {
  6640. selector = [ selector ];
  6641. }
  6642. for ( i=0, ien=selector.length ; i<ien ; i++ ) {
  6643. // Only split on simple strings - complex expressions will be jQuery selectors
  6644. a = selector[i] && selector[i].split && ! selector[i].match(/[\[\(:]/) ?
  6645. selector[i].split(',') :
  6646. [ selector[i] ];
  6647. for ( j=0, jen=a.length ; j<jen ; j++ ) {
  6648. res = selectFn( typeof a[j] === 'string' ? (a[j]).trim() : a[j] );
  6649. if ( res && res.length ) {
  6650. out = out.concat( res );
  6651. }
  6652. }
  6653. }
  6654. // selector extensions
  6655. var ext = _ext.selector[ type ];
  6656. if ( ext.length ) {
  6657. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  6658. out = ext[i]( settings, opts, out );
  6659. }
  6660. }
  6661. return _unique( out );
  6662. };
  6663. var _selector_opts = function ( opts )
  6664. {
  6665. if ( ! opts ) {
  6666. opts = {};
  6667. }
  6668. // Backwards compatibility for 1.9- which used the terminology filter rather
  6669. // than search
  6670. if ( opts.filter && opts.search === undefined ) {
  6671. opts.search = opts.filter;
  6672. }
  6673. return $.extend( {
  6674. search: 'none',
  6675. order: 'current',
  6676. page: 'all'
  6677. }, opts );
  6678. };
  6679. var _selector_first = function ( inst )
  6680. {
  6681. // Reduce the API instance to the first item found
  6682. for ( var i=0, ien=inst.length ; i<ien ; i++ ) {
  6683. if ( inst[i].length > 0 ) {
  6684. // Assign the first element to the first item in the instance
  6685. // and truncate the instance and context
  6686. inst[0] = inst[i];
  6687. inst[0].length = 1;
  6688. inst.length = 1;
  6689. inst.context = [ inst.context[i] ];
  6690. return inst;
  6691. }
  6692. }
  6693. // Not found - return an empty instance
  6694. inst.length = 0;
  6695. return inst;
  6696. };
  6697. var _selector_row_indexes = function ( settings, opts )
  6698. {
  6699. var
  6700. i, ien, tmp, a=[],
  6701. displayFiltered = settings.aiDisplay,
  6702. displayMaster = settings.aiDisplayMaster;
  6703. var
  6704. search = opts.search, // none, applied, removed
  6705. order = opts.order, // applied, current, index (original - compatibility with 1.9)
  6706. page = opts.page; // all, current
  6707. if ( _fnDataSource( settings ) == 'ssp' ) {
  6708. // In server-side processing mode, most options are irrelevant since
  6709. // rows not shown don't exist and the index order is the applied order
  6710. // Removed is a special case - for consistency just return an empty
  6711. // array
  6712. return search === 'removed' ?
  6713. [] :
  6714. _range( 0, displayMaster.length );
  6715. }
  6716. else if ( page == 'current' ) {
  6717. // Current page implies that order=current and fitler=applied, since it is
  6718. // fairly senseless otherwise, regardless of what order and search actually
  6719. // are
  6720. for ( i=settings._iDisplayStart, ien=settings.fnDisplayEnd() ; i<ien ; i++ ) {
  6721. a.push( displayFiltered[i] );
  6722. }
  6723. }
  6724. else if ( order == 'current' || order == 'applied' ) {
  6725. if ( search == 'none') {
  6726. a = displayMaster.slice();
  6727. }
  6728. else if ( search == 'applied' ) {
  6729. a = displayFiltered.slice();
  6730. }
  6731. else if ( search == 'removed' ) {
  6732. // O(n+m) solution by creating a hash map
  6733. var displayFilteredMap = {};
  6734. for ( var i=0, ien=displayFiltered.length ; i<ien ; i++ ) {
  6735. displayFilteredMap[displayFiltered[i]] = null;
  6736. }
  6737. a = $.map( displayMaster, function (el) {
  6738. return ! displayFilteredMap.hasOwnProperty(el) ?
  6739. el :
  6740. null;
  6741. } );
  6742. }
  6743. }
  6744. else if ( order == 'index' || order == 'original' ) {
  6745. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  6746. if ( search == 'none' ) {
  6747. a.push( i );
  6748. }
  6749. else { // applied | removed
  6750. tmp = $.inArray( i, displayFiltered );
  6751. if ((tmp === -1 && search == 'removed') ||
  6752. (tmp >= 0 && search == 'applied') )
  6753. {
  6754. a.push( i );
  6755. }
  6756. }
  6757. }
  6758. }
  6759. return a;
  6760. };
  6761. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6762. * Rows
  6763. *
  6764. * {} - no selector - use all available rows
  6765. * {integer} - row aoData index
  6766. * {node} - TR node
  6767. * {string} - jQuery selector to apply to the TR elements
  6768. * {array} - jQuery array of nodes, or simply an array of TR nodes
  6769. *
  6770. */
  6771. var __row_selector = function ( settings, selector, opts )
  6772. {
  6773. var rows;
  6774. var run = function ( sel ) {
  6775. var selInt = _intVal( sel );
  6776. var i, ien;
  6777. var aoData = settings.aoData;
  6778. // Short cut - selector is a number and no options provided (default is
  6779. // all records, so no need to check if the index is in there, since it
  6780. // must be - dev error if the index doesn't exist).
  6781. if ( selInt !== null && ! opts ) {
  6782. return [ selInt ];
  6783. }
  6784. if ( ! rows ) {
  6785. rows = _selector_row_indexes( settings, opts );
  6786. }
  6787. if ( selInt !== null && $.inArray( selInt, rows ) !== -1 ) {
  6788. // Selector - integer
  6789. return [ selInt ];
  6790. }
  6791. else if ( sel === null || sel === undefined || sel === '' ) {
  6792. // Selector - none
  6793. return rows;
  6794. }
  6795. // Selector - function
  6796. if ( typeof sel === 'function' ) {
  6797. return $.map( rows, function (idx) {
  6798. var row = aoData[ idx ];
  6799. return sel( idx, row._aData, row.nTr ) ? idx : null;
  6800. } );
  6801. }
  6802. // Selector - node
  6803. if ( sel.nodeName ) {
  6804. var rowIdx = sel._DT_RowIndex; // Property added by DT for fast lookup
  6805. var cellIdx = sel._DT_CellIndex;
  6806. if ( rowIdx !== undefined ) {
  6807. // Make sure that the row is actually still present in the table
  6808. return aoData[ rowIdx ] && aoData[ rowIdx ].nTr === sel ?
  6809. [ rowIdx ] :
  6810. [];
  6811. }
  6812. else if ( cellIdx ) {
  6813. return aoData[ cellIdx.row ] && aoData[ cellIdx.row ].nTr === sel.parentNode ?
  6814. [ cellIdx.row ] :
  6815. [];
  6816. }
  6817. else {
  6818. var host = $(sel).closest('*[data-dt-row]');
  6819. return host.length ?
  6820. [ host.data('dt-row') ] :
  6821. [];
  6822. }
  6823. }
  6824. // ID selector. Want to always be able to select rows by id, regardless
  6825. // of if the tr element has been created or not, so can't rely upon
  6826. // jQuery here - hence a custom implementation. This does not match
  6827. // Sizzle's fast selector or HTML4 - in HTML5 the ID can be anything,
  6828. // but to select it using a CSS selector engine (like Sizzle or
  6829. // querySelect) it would need to need to be escaped for some characters.
  6830. // DataTables simplifies this for row selectors since you can select
  6831. // only a row. A # indicates an id any anything that follows is the id -
  6832. // unescaped.
  6833. if ( typeof sel === 'string' && sel.charAt(0) === '#' ) {
  6834. // get row index from id
  6835. var rowObj = settings.aIds[ sel.replace( /^#/, '' ) ];
  6836. if ( rowObj !== undefined ) {
  6837. return [ rowObj.idx ];
  6838. }
  6839. // need to fall through to jQuery in case there is DOM id that
  6840. // matches
  6841. }
  6842. // Get nodes in the order from the `rows` array with null values removed
  6843. var nodes = _removeEmpty(
  6844. _pluck_order( settings.aoData, rows, 'nTr' )
  6845. );
  6846. // Selector - jQuery selector string, array of nodes or jQuery object/
  6847. // As jQuery's .filter() allows jQuery objects to be passed in filter,
  6848. // it also allows arrays, so this will cope with all three options
  6849. return $(nodes)
  6850. .filter( sel )
  6851. .map( function () {
  6852. return this._DT_RowIndex;
  6853. } )
  6854. .toArray();
  6855. };
  6856. return _selector_run( 'row', selector, run, settings, opts );
  6857. };
  6858. _api_register( 'rows()', function ( selector, opts ) {
  6859. // argument shifting
  6860. if ( selector === undefined ) {
  6861. selector = '';
  6862. }
  6863. else if ( $.isPlainObject( selector ) ) {
  6864. opts = selector;
  6865. selector = '';
  6866. }
  6867. opts = _selector_opts( opts );
  6868. var inst = this.iterator( 'table', function ( settings ) {
  6869. return __row_selector( settings, selector, opts );
  6870. }, 1 );
  6871. // Want argument shifting here and in __row_selector?
  6872. inst.selector.rows = selector;
  6873. inst.selector.opts = opts;
  6874. return inst;
  6875. } );
  6876. _api_register( 'rows().nodes()', function () {
  6877. return this.iterator( 'row', function ( settings, row ) {
  6878. return settings.aoData[ row ].nTr || undefined;
  6879. }, 1 );
  6880. } );
  6881. _api_register( 'rows().data()', function () {
  6882. return this.iterator( true, 'rows', function ( settings, rows ) {
  6883. return _pluck_order( settings.aoData, rows, '_aData' );
  6884. }, 1 );
  6885. } );
  6886. _api_registerPlural( 'rows().cache()', 'row().cache()', function ( type ) {
  6887. return this.iterator( 'row', function ( settings, row ) {
  6888. var r = settings.aoData[ row ];
  6889. return type === 'search' ? r._aFilterData : r._aSortData;
  6890. }, 1 );
  6891. } );
  6892. _api_registerPlural( 'rows().invalidate()', 'row().invalidate()', function ( src ) {
  6893. return this.iterator( 'row', function ( settings, row ) {
  6894. _fnInvalidate( settings, row, src );
  6895. } );
  6896. } );
  6897. _api_registerPlural( 'rows().indexes()', 'row().index()', function () {
  6898. return this.iterator( 'row', function ( settings, row ) {
  6899. return row;
  6900. }, 1 );
  6901. } );
  6902. _api_registerPlural( 'rows().ids()', 'row().id()', function ( hash ) {
  6903. var a = [];
  6904. var context = this.context;
  6905. // `iterator` will drop undefined values, but in this case we want them
  6906. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  6907. for ( var j=0, jen=this[i].length ; j<jen ; j++ ) {
  6908. var id = context[i].rowIdFn( context[i].aoData[ this[i][j] ]._aData );
  6909. a.push( (hash === true ? '#' : '' )+ id );
  6910. }
  6911. }
  6912. return new _Api( context, a );
  6913. } );
  6914. _api_registerPlural( 'rows().remove()', 'row().remove()', function () {
  6915. var that = this;
  6916. this.iterator( 'row', function ( settings, row, thatIdx ) {
  6917. var data = settings.aoData;
  6918. var rowData = data[ row ];
  6919. var i, ien, j, jen;
  6920. var loopRow, loopCells;
  6921. data.splice( row, 1 );
  6922. // Update the cached indexes
  6923. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  6924. loopRow = data[i];
  6925. loopCells = loopRow.anCells;
  6926. // Rows
  6927. if ( loopRow.nTr !== null ) {
  6928. loopRow.nTr._DT_RowIndex = i;
  6929. }
  6930. // Cells
  6931. if ( loopCells !== null ) {
  6932. for ( j=0, jen=loopCells.length ; j<jen ; j++ ) {
  6933. loopCells[j]._DT_CellIndex.row = i;
  6934. }
  6935. }
  6936. }
  6937. // Delete from the display arrays
  6938. _fnDeleteIndex( settings.aiDisplayMaster, row );
  6939. _fnDeleteIndex( settings.aiDisplay, row );
  6940. _fnDeleteIndex( that[ thatIdx ], row, false ); // maintain local indexes
  6941. // For server-side processing tables - subtract the deleted row from the count
  6942. if ( settings._iRecordsDisplay > 0 ) {
  6943. settings._iRecordsDisplay--;
  6944. }
  6945. // Check for an 'overflow' they case for displaying the table
  6946. _fnLengthOverflow( settings );
  6947. // Remove the row's ID reference if there is one
  6948. var id = settings.rowIdFn( rowData._aData );
  6949. if ( id !== undefined ) {
  6950. delete settings.aIds[ id ];
  6951. }
  6952. } );
  6953. this.iterator( 'table', function ( settings ) {
  6954. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  6955. settings.aoData[i].idx = i;
  6956. }
  6957. } );
  6958. return this;
  6959. } );
  6960. _api_register( 'rows.add()', function ( rows ) {
  6961. var newRows = this.iterator( 'table', function ( settings ) {
  6962. var row, i, ien;
  6963. var out = [];
  6964. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  6965. row = rows[i];
  6966. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  6967. out.push( _fnAddTr( settings, row )[0] );
  6968. }
  6969. else {
  6970. out.push( _fnAddData( settings, row ) );
  6971. }
  6972. }
  6973. return out;
  6974. }, 1 );
  6975. // Return an Api.rows() extended instance, so rows().nodes() etc can be used
  6976. var modRows = this.rows( -1 );
  6977. modRows.pop();
  6978. $.merge( modRows, newRows );
  6979. return modRows;
  6980. } );
  6981. /**
  6982. *
  6983. */
  6984. _api_register( 'row()', function ( selector, opts ) {
  6985. return _selector_first( this.rows( selector, opts ) );
  6986. } );
  6987. _api_register( 'row().data()', function ( data ) {
  6988. var ctx = this.context;
  6989. if ( data === undefined ) {
  6990. // Get
  6991. return ctx.length && this.length ?
  6992. ctx[0].aoData[ this[0] ]._aData :
  6993. undefined;
  6994. }
  6995. // Set
  6996. var row = ctx[0].aoData[ this[0] ];
  6997. row._aData = data;
  6998. // If the DOM has an id, and the data source is an array
  6999. if ( Array.isArray( data ) && row.nTr && row.nTr.id ) {
  7000. _fnSetObjectDataFn( ctx[0].rowId )( data, row.nTr.id );
  7001. }
  7002. // Automatically invalidate
  7003. _fnInvalidate( ctx[0], this[0], 'data' );
  7004. return this;
  7005. } );
  7006. _api_register( 'row().node()', function () {
  7007. var ctx = this.context;
  7008. return ctx.length && this.length ?
  7009. ctx[0].aoData[ this[0] ].nTr || null :
  7010. null;
  7011. } );
  7012. _api_register( 'row.add()', function ( row ) {
  7013. // Allow a jQuery object to be passed in - only a single row is added from
  7014. // it though - the first element in the set
  7015. if ( row instanceof $ && row.length ) {
  7016. row = row[0];
  7017. }
  7018. var rows = this.iterator( 'table', function ( settings ) {
  7019. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  7020. return _fnAddTr( settings, row )[0];
  7021. }
  7022. return _fnAddData( settings, row );
  7023. } );
  7024. // Return an Api.rows() extended instance, with the newly added row selected
  7025. return this.row( rows[0] );
  7026. } );
  7027. var __details_add = function ( ctx, row, data, klass )
  7028. {
  7029. // Convert to array of TR elements
  7030. var rows = [];
  7031. var addRow = function ( r, k ) {
  7032. // Recursion to allow for arrays of jQuery objects
  7033. if ( Array.isArray( r ) || r instanceof $ ) {
  7034. for ( var i=0, ien=r.length ; i<ien ; i++ ) {
  7035. addRow( r[i], k );
  7036. }
  7037. return;
  7038. }
  7039. // If we get a TR element, then just add it directly - up to the dev
  7040. // to add the correct number of columns etc
  7041. if ( r.nodeName && r.nodeName.toLowerCase() === 'tr' ) {
  7042. rows.push( r );
  7043. }
  7044. else {
  7045. // Otherwise create a row with a wrapper
  7046. var created = $('<tr><td></td></tr>').addClass( k );
  7047. $('td', created)
  7048. .addClass( k )
  7049. .html( r )
  7050. [0].colSpan = _fnVisbleColumns( ctx );
  7051. rows.push( created[0] );
  7052. }
  7053. };
  7054. addRow( data, klass );
  7055. if ( row._details ) {
  7056. row._details.detach();
  7057. }
  7058. row._details = $(rows);
  7059. // If the children were already shown, that state should be retained
  7060. if ( row._detailsShow ) {
  7061. row._details.insertAfter( row.nTr );
  7062. }
  7063. };
  7064. var __details_remove = function ( api, idx )
  7065. {
  7066. var ctx = api.context;
  7067. if ( ctx.length ) {
  7068. var row = ctx[0].aoData[ idx !== undefined ? idx : api[0] ];
  7069. if ( row && row._details ) {
  7070. row._details.remove();
  7071. row._detailsShow = undefined;
  7072. row._details = undefined;
  7073. }
  7074. }
  7075. };
  7076. var __details_display = function ( api, show ) {
  7077. var ctx = api.context;
  7078. if ( ctx.length && api.length ) {
  7079. var row = ctx[0].aoData[ api[0] ];
  7080. if ( row._details ) {
  7081. row._detailsShow = show;
  7082. if ( show ) {
  7083. row._details.insertAfter( row.nTr );
  7084. }
  7085. else {
  7086. row._details.detach();
  7087. }
  7088. __details_events( ctx[0] );
  7089. }
  7090. }
  7091. };
  7092. var __details_events = function ( settings )
  7093. {
  7094. var api = new _Api( settings );
  7095. var namespace = '.dt.DT_details';
  7096. var drawEvent = 'draw'+namespace;
  7097. var colvisEvent = 'column-visibility'+namespace;
  7098. var destroyEvent = 'destroy'+namespace;
  7099. var data = settings.aoData;
  7100. api.off( drawEvent +' '+ colvisEvent +' '+ destroyEvent );
  7101. if ( _pluck( data, '_details' ).length > 0 ) {
  7102. // On each draw, insert the required elements into the document
  7103. api.on( drawEvent, function ( e, ctx ) {
  7104. if ( settings !== ctx ) {
  7105. return;
  7106. }
  7107. api.rows( {page:'current'} ).eq(0).each( function (idx) {
  7108. // Internal data grab
  7109. var row = data[ idx ];
  7110. if ( row._detailsShow ) {
  7111. row._details.insertAfter( row.nTr );
  7112. }
  7113. } );
  7114. } );
  7115. // Column visibility change - update the colspan
  7116. api.on( colvisEvent, function ( e, ctx, idx, vis ) {
  7117. if ( settings !== ctx ) {
  7118. return;
  7119. }
  7120. // Update the colspan for the details rows (note, only if it already has
  7121. // a colspan)
  7122. var row, visible = _fnVisbleColumns( ctx );
  7123. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  7124. row = data[i];
  7125. if ( row._details ) {
  7126. row._details.children('td[colspan]').attr('colspan', visible );
  7127. }
  7128. }
  7129. } );
  7130. // Table destroyed - nuke any child rows
  7131. api.on( destroyEvent, function ( e, ctx ) {
  7132. if ( settings !== ctx ) {
  7133. return;
  7134. }
  7135. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  7136. if ( data[i]._details ) {
  7137. __details_remove( api, i );
  7138. }
  7139. }
  7140. } );
  7141. }
  7142. };
  7143. // Strings for the method names to help minification
  7144. var _emp = '';
  7145. var _child_obj = _emp+'row().child';
  7146. var _child_mth = _child_obj+'()';
  7147. // data can be:
  7148. // tr
  7149. // string
  7150. // jQuery or array of any of the above
  7151. _api_register( _child_mth, function ( data, klass ) {
  7152. var ctx = this.context;
  7153. if ( data === undefined ) {
  7154. // get
  7155. return ctx.length && this.length ?
  7156. ctx[0].aoData[ this[0] ]._details :
  7157. undefined;
  7158. }
  7159. else if ( data === true ) {
  7160. // show
  7161. this.child.show();
  7162. }
  7163. else if ( data === false ) {
  7164. // remove
  7165. __details_remove( this );
  7166. }
  7167. else if ( ctx.length && this.length ) {
  7168. // set
  7169. __details_add( ctx[0], ctx[0].aoData[ this[0] ], data, klass );
  7170. }
  7171. return this;
  7172. } );
  7173. _api_register( [
  7174. _child_obj+'.show()',
  7175. _child_mth+'.show()' // only when `child()` was called with parameters (without
  7176. ], function ( show ) { // it returns an object and this method is not executed)
  7177. __details_display( this, true );
  7178. return this;
  7179. } );
  7180. _api_register( [
  7181. _child_obj+'.hide()',
  7182. _child_mth+'.hide()' // only when `child()` was called with parameters (without
  7183. ], function () { // it returns an object and this method is not executed)
  7184. __details_display( this, false );
  7185. return this;
  7186. } );
  7187. _api_register( [
  7188. _child_obj+'.remove()',
  7189. _child_mth+'.remove()' // only when `child()` was called with parameters (without
  7190. ], function () { // it returns an object and this method is not executed)
  7191. __details_remove( this );
  7192. return this;
  7193. } );
  7194. _api_register( _child_obj+'.isShown()', function () {
  7195. var ctx = this.context;
  7196. if ( ctx.length && this.length ) {
  7197. // _detailsShown as false or undefined will fall through to return false
  7198. return ctx[0].aoData[ this[0] ]._detailsShow || false;
  7199. }
  7200. return false;
  7201. } );
  7202. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  7203. * Columns
  7204. *
  7205. * {integer} - column index (>=0 count from left, <0 count from right)
  7206. * "{integer}:visIdx" - visible column index (i.e. translate to column index) (>=0 count from left, <0 count from right)
  7207. * "{integer}:visible" - alias for {integer}:visIdx (>=0 count from left, <0 count from right)
  7208. * "{string}:name" - column name
  7209. * "{string}" - jQuery selector on column header nodes
  7210. *
  7211. */
  7212. // can be an array of these items, comma separated list, or an array of comma
  7213. // separated lists
  7214. var __re_column_selector = /^([^:]+):(name|visIdx|visible)$/;
  7215. // r1 and r2 are redundant - but it means that the parameters match for the
  7216. // iterator callback in columns().data()
  7217. var __columnData = function ( settings, column, r1, r2, rows ) {
  7218. var a = [];
  7219. for ( var row=0, ien=rows.length ; row<ien ; row++ ) {
  7220. a.push( _fnGetCellData( settings, rows[row], column ) );
  7221. }
  7222. return a;
  7223. };
  7224. var __column_selector = function ( settings, selector, opts )
  7225. {
  7226. var
  7227. columns = settings.aoColumns,
  7228. names = _pluck( columns, 'sName' ),
  7229. nodes = _pluck( columns, 'nTh' );
  7230. var run = function ( s ) {
  7231. var selInt = _intVal( s );
  7232. // Selector - all
  7233. if ( s === '' ) {
  7234. return _range( columns.length );
  7235. }
  7236. // Selector - index
  7237. if ( selInt !== null ) {
  7238. return [ selInt >= 0 ?
  7239. selInt : // Count from left
  7240. columns.length + selInt // Count from right (+ because its a negative value)
  7241. ];
  7242. }
  7243. // Selector = function
  7244. if ( typeof s === 'function' ) {
  7245. var rows = _selector_row_indexes( settings, opts );
  7246. return $.map( columns, function (col, idx) {
  7247. return s(
  7248. idx,
  7249. __columnData( settings, idx, 0, 0, rows ),
  7250. nodes[ idx ]
  7251. ) ? idx : null;
  7252. } );
  7253. }
  7254. // jQuery or string selector
  7255. var match = typeof s === 'string' ?
  7256. s.match( __re_column_selector ) :
  7257. '';
  7258. if ( match ) {
  7259. switch( match[2] ) {
  7260. case 'visIdx':
  7261. case 'visible':
  7262. var idx = parseInt( match[1], 10 );
  7263. // Visible index given, convert to column index
  7264. if ( idx < 0 ) {
  7265. // Counting from the right
  7266. var visColumns = $.map( columns, function (col,i) {
  7267. return col.bVisible ? i : null;
  7268. } );
  7269. return [ visColumns[ visColumns.length + idx ] ];
  7270. }
  7271. // Counting from the left
  7272. return [ _fnVisibleToColumnIndex( settings, idx ) ];
  7273. case 'name':
  7274. // match by name. `names` is column index complete and in order
  7275. return $.map( names, function (name, i) {
  7276. return name === match[1] ? i : null;
  7277. } );
  7278. default:
  7279. return [];
  7280. }
  7281. }
  7282. // Cell in the table body
  7283. if ( s.nodeName && s._DT_CellIndex ) {
  7284. return [ s._DT_CellIndex.column ];
  7285. }
  7286. // jQuery selector on the TH elements for the columns
  7287. var jqResult = $( nodes )
  7288. .filter( s )
  7289. .map( function () {
  7290. return $.inArray( this, nodes ); // `nodes` is column index complete and in order
  7291. } )
  7292. .toArray();
  7293. if ( jqResult.length || ! s.nodeName ) {
  7294. return jqResult;
  7295. }
  7296. // Otherwise a node which might have a `dt-column` data attribute, or be
  7297. // a child or such an element
  7298. var host = $(s).closest('*[data-dt-column]');
  7299. return host.length ?
  7300. [ host.data('dt-column') ] :
  7301. [];
  7302. };
  7303. return _selector_run( 'column', selector, run, settings, opts );
  7304. };
  7305. var __setColumnVis = function ( settings, column, vis ) {
  7306. var
  7307. cols = settings.aoColumns,
  7308. col = cols[ column ],
  7309. data = settings.aoData,
  7310. row, cells, i, ien, tr;
  7311. // Get
  7312. if ( vis === undefined ) {
  7313. return col.bVisible;
  7314. }
  7315. // Set
  7316. // No change
  7317. if ( col.bVisible === vis ) {
  7318. return;
  7319. }
  7320. if ( vis ) {
  7321. // Insert column
  7322. // Need to decide if we should use appendChild or insertBefore
  7323. var insertBefore = $.inArray( true, _pluck(cols, 'bVisible'), column+1 );
  7324. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  7325. tr = data[i].nTr;
  7326. cells = data[i].anCells;
  7327. if ( tr ) {
  7328. // insertBefore can act like appendChild if 2nd arg is null
  7329. tr.insertBefore( cells[ column ], cells[ insertBefore ] || null );
  7330. }
  7331. }
  7332. }
  7333. else {
  7334. // Remove column
  7335. $( _pluck( settings.aoData, 'anCells', column ) ).detach();
  7336. }
  7337. // Common actions
  7338. col.bVisible = vis;
  7339. };
  7340. _api_register( 'columns()', function ( selector, opts ) {
  7341. // argument shifting
  7342. if ( selector === undefined ) {
  7343. selector = '';
  7344. }
  7345. else if ( $.isPlainObject( selector ) ) {
  7346. opts = selector;
  7347. selector = '';
  7348. }
  7349. opts = _selector_opts( opts );
  7350. var inst = this.iterator( 'table', function ( settings ) {
  7351. return __column_selector( settings, selector, opts );
  7352. }, 1 );
  7353. // Want argument shifting here and in _row_selector?
  7354. inst.selector.cols = selector;
  7355. inst.selector.opts = opts;
  7356. return inst;
  7357. } );
  7358. _api_registerPlural( 'columns().header()', 'column().header()', function ( selector, opts ) {
  7359. return this.iterator( 'column', function ( settings, column ) {
  7360. return settings.aoColumns[column].nTh;
  7361. }, 1 );
  7362. } );
  7363. _api_registerPlural( 'columns().footer()', 'column().footer()', function ( selector, opts ) {
  7364. return this.iterator( 'column', function ( settings, column ) {
  7365. return settings.aoColumns[column].nTf;
  7366. }, 1 );
  7367. } );
  7368. _api_registerPlural( 'columns().data()', 'column().data()', function () {
  7369. return this.iterator( 'column-rows', __columnData, 1 );
  7370. } );
  7371. _api_registerPlural( 'columns().dataSrc()', 'column().dataSrc()', function () {
  7372. return this.iterator( 'column', function ( settings, column ) {
  7373. return settings.aoColumns[column].mData;
  7374. }, 1 );
  7375. } );
  7376. _api_registerPlural( 'columns().cache()', 'column().cache()', function ( type ) {
  7377. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7378. return _pluck_order( settings.aoData, rows,
  7379. type === 'search' ? '_aFilterData' : '_aSortData', column
  7380. );
  7381. }, 1 );
  7382. } );
  7383. _api_registerPlural( 'columns().nodes()', 'column().nodes()', function () {
  7384. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7385. return _pluck_order( settings.aoData, rows, 'anCells', column ) ;
  7386. }, 1 );
  7387. } );
  7388. _api_registerPlural( 'columns().visible()', 'column().visible()', function ( vis, calc ) {
  7389. var that = this;
  7390. var ret = this.iterator( 'column', function ( settings, column ) {
  7391. if ( vis === undefined ) {
  7392. return settings.aoColumns[ column ].bVisible;
  7393. } // else
  7394. __setColumnVis( settings, column, vis );
  7395. } );
  7396. // Group the column visibility changes
  7397. if ( vis !== undefined ) {
  7398. this.iterator( 'table', function ( settings ) {
  7399. // Redraw the header after changes
  7400. _fnDrawHead( settings, settings.aoHeader );
  7401. _fnDrawHead( settings, settings.aoFooter );
  7402. // Update colspan for no records display. Child rows and extensions will use their own
  7403. // listeners to do this - only need to update the empty table item here
  7404. if ( ! settings.aiDisplay.length ) {
  7405. $(settings.nTBody).find('td[colspan]').attr('colspan', _fnVisbleColumns(settings));
  7406. }
  7407. _fnSaveState( settings );
  7408. // Second loop once the first is done for events
  7409. that.iterator( 'column', function ( settings, column ) {
  7410. _fnCallbackFire( settings, null, 'column-visibility', [settings, column, vis, calc] );
  7411. } );
  7412. if ( calc === undefined || calc ) {
  7413. that.columns.adjust();
  7414. }
  7415. });
  7416. }
  7417. return ret;
  7418. } );
  7419. _api_registerPlural( 'columns().indexes()', 'column().index()', function ( type ) {
  7420. return this.iterator( 'column', function ( settings, column ) {
  7421. return type === 'visible' ?
  7422. _fnColumnIndexToVisible( settings, column ) :
  7423. column;
  7424. }, 1 );
  7425. } );
  7426. _api_register( 'columns.adjust()', function () {
  7427. return this.iterator( 'table', function ( settings ) {
  7428. _fnAdjustColumnSizing( settings );
  7429. }, 1 );
  7430. } );
  7431. _api_register( 'column.index()', function ( type, idx ) {
  7432. if ( this.context.length !== 0 ) {
  7433. var ctx = this.context[0];
  7434. if ( type === 'fromVisible' || type === 'toData' ) {
  7435. return _fnVisibleToColumnIndex( ctx, idx );
  7436. }
  7437. else if ( type === 'fromData' || type === 'toVisible' ) {
  7438. return _fnColumnIndexToVisible( ctx, idx );
  7439. }
  7440. }
  7441. } );
  7442. _api_register( 'column()', function ( selector, opts ) {
  7443. return _selector_first( this.columns( selector, opts ) );
  7444. } );
  7445. var __cell_selector = function ( settings, selector, opts )
  7446. {
  7447. var data = settings.aoData;
  7448. var rows = _selector_row_indexes( settings, opts );
  7449. var cells = _removeEmpty( _pluck_order( data, rows, 'anCells' ) );
  7450. var allCells = $(_flatten( [], cells ));
  7451. var row;
  7452. var columns = settings.aoColumns.length;
  7453. var a, i, ien, j, o, host;
  7454. var run = function ( s ) {
  7455. var fnSelector = typeof s === 'function';
  7456. if ( s === null || s === undefined || fnSelector ) {
  7457. // All cells and function selectors
  7458. a = [];
  7459. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  7460. row = rows[i];
  7461. for ( j=0 ; j<columns ; j++ ) {
  7462. o = {
  7463. row: row,
  7464. column: j
  7465. };
  7466. if ( fnSelector ) {
  7467. // Selector - function
  7468. host = data[ row ];
  7469. if ( s( o, _fnGetCellData(settings, row, j), host.anCells ? host.anCells[j] : null ) ) {
  7470. a.push( o );
  7471. }
  7472. }
  7473. else {
  7474. // Selector - all
  7475. a.push( o );
  7476. }
  7477. }
  7478. }
  7479. return a;
  7480. }
  7481. // Selector - index
  7482. if ( $.isPlainObject( s ) ) {
  7483. // Valid cell index and its in the array of selectable rows
  7484. return s.column !== undefined && s.row !== undefined && $.inArray( s.row, rows ) !== -1 ?
  7485. [s] :
  7486. [];
  7487. }
  7488. // Selector - jQuery filtered cells
  7489. var jqResult = allCells
  7490. .filter( s )
  7491. .map( function (i, el) {
  7492. return { // use a new object, in case someone changes the values
  7493. row: el._DT_CellIndex.row,
  7494. column: el._DT_CellIndex.column
  7495. };
  7496. } )
  7497. .toArray();
  7498. if ( jqResult.length || ! s.nodeName ) {
  7499. return jqResult;
  7500. }
  7501. // Otherwise the selector is a node, and there is one last option - the
  7502. // element might be a child of an element which has dt-row and dt-column
  7503. // data attributes
  7504. host = $(s).closest('*[data-dt-row]');
  7505. return host.length ?
  7506. [ {
  7507. row: host.data('dt-row'),
  7508. column: host.data('dt-column')
  7509. } ] :
  7510. [];
  7511. };
  7512. return _selector_run( 'cell', selector, run, settings, opts );
  7513. };
  7514. _api_register( 'cells()', function ( rowSelector, columnSelector, opts ) {
  7515. // Argument shifting
  7516. if ( $.isPlainObject( rowSelector ) ) {
  7517. // Indexes
  7518. if ( rowSelector.row === undefined ) {
  7519. // Selector options in first parameter
  7520. opts = rowSelector;
  7521. rowSelector = null;
  7522. }
  7523. else {
  7524. // Cell index objects in first parameter
  7525. opts = columnSelector;
  7526. columnSelector = null;
  7527. }
  7528. }
  7529. if ( $.isPlainObject( columnSelector ) ) {
  7530. opts = columnSelector;
  7531. columnSelector = null;
  7532. }
  7533. // Cell selector
  7534. if ( columnSelector === null || columnSelector === undefined ) {
  7535. return this.iterator( 'table', function ( settings ) {
  7536. return __cell_selector( settings, rowSelector, _selector_opts( opts ) );
  7537. } );
  7538. }
  7539. // The default built in options need to apply to row and columns
  7540. var internalOpts = opts ? {
  7541. page: opts.page,
  7542. order: opts.order,
  7543. search: opts.search
  7544. } : {};
  7545. // Row + column selector
  7546. var columns = this.columns( columnSelector, internalOpts );
  7547. var rows = this.rows( rowSelector, internalOpts );
  7548. var i, ien, j, jen;
  7549. var cellsNoOpts = this.iterator( 'table', function ( settings, idx ) {
  7550. var a = [];
  7551. for ( i=0, ien=rows[idx].length ; i<ien ; i++ ) {
  7552. for ( j=0, jen=columns[idx].length ; j<jen ; j++ ) {
  7553. a.push( {
  7554. row: rows[idx][i],
  7555. column: columns[idx][j]
  7556. } );
  7557. }
  7558. }
  7559. return a;
  7560. }, 1 );
  7561. // There is currently only one extension which uses a cell selector extension
  7562. // It is a _major_ performance drag to run this if it isn't needed, so this is
  7563. // an extension specific check at the moment
  7564. var cells = opts && opts.selected ?
  7565. this.cells( cellsNoOpts, opts ) :
  7566. cellsNoOpts;
  7567. $.extend( cells.selector, {
  7568. cols: columnSelector,
  7569. rows: rowSelector,
  7570. opts: opts
  7571. } );
  7572. return cells;
  7573. } );
  7574. _api_registerPlural( 'cells().nodes()', 'cell().node()', function () {
  7575. return this.iterator( 'cell', function ( settings, row, column ) {
  7576. var data = settings.aoData[ row ];
  7577. return data && data.anCells ?
  7578. data.anCells[ column ] :
  7579. undefined;
  7580. }, 1 );
  7581. } );
  7582. _api_register( 'cells().data()', function () {
  7583. return this.iterator( 'cell', function ( settings, row, column ) {
  7584. return _fnGetCellData( settings, row, column );
  7585. }, 1 );
  7586. } );
  7587. _api_registerPlural( 'cells().cache()', 'cell().cache()', function ( type ) {
  7588. type = type === 'search' ? '_aFilterData' : '_aSortData';
  7589. return this.iterator( 'cell', function ( settings, row, column ) {
  7590. return settings.aoData[ row ][ type ][ column ];
  7591. }, 1 );
  7592. } );
  7593. _api_registerPlural( 'cells().render()', 'cell().render()', function ( type ) {
  7594. return this.iterator( 'cell', function ( settings, row, column ) {
  7595. return _fnGetCellData( settings, row, column, type );
  7596. }, 1 );
  7597. } );
  7598. _api_registerPlural( 'cells().indexes()', 'cell().index()', function () {
  7599. return this.iterator( 'cell', function ( settings, row, column ) {
  7600. return {
  7601. row: row,
  7602. column: column,
  7603. columnVisible: _fnColumnIndexToVisible( settings, column )
  7604. };
  7605. }, 1 );
  7606. } );
  7607. _api_registerPlural( 'cells().invalidate()', 'cell().invalidate()', function ( src ) {
  7608. return this.iterator( 'cell', function ( settings, row, column ) {
  7609. _fnInvalidate( settings, row, src, column );
  7610. } );
  7611. } );
  7612. _api_register( 'cell()', function ( rowSelector, columnSelector, opts ) {
  7613. return _selector_first( this.cells( rowSelector, columnSelector, opts ) );
  7614. } );
  7615. _api_register( 'cell().data()', function ( data ) {
  7616. var ctx = this.context;
  7617. var cell = this[0];
  7618. if ( data === undefined ) {
  7619. // Get
  7620. return ctx.length && cell.length ?
  7621. _fnGetCellData( ctx[0], cell[0].row, cell[0].column ) :
  7622. undefined;
  7623. }
  7624. // Set
  7625. _fnSetCellData( ctx[0], cell[0].row, cell[0].column, data );
  7626. _fnInvalidate( ctx[0], cell[0].row, 'data', cell[0].column );
  7627. return this;
  7628. } );
  7629. /**
  7630. * Get current ordering (sorting) that has been applied to the table.
  7631. *
  7632. * @returns {array} 2D array containing the sorting information for the first
  7633. * table in the current context. Each element in the parent array represents
  7634. * a column being sorted upon (i.e. multi-sorting with two columns would have
  7635. * 2 inner arrays). The inner arrays may have 2 or 3 elements. The first is
  7636. * the column index that the sorting condition applies to, the second is the
  7637. * direction of the sort (`desc` or `asc`) and, optionally, the third is the
  7638. * index of the sorting order from the `column.sorting` initialisation array.
  7639. *//**
  7640. * Set the ordering for the table.
  7641. *
  7642. * @param {integer} order Column index to sort upon.
  7643. * @param {string} direction Direction of the sort to be applied (`asc` or `desc`)
  7644. * @returns {DataTables.Api} this
  7645. *//**
  7646. * Set the ordering for the table.
  7647. *
  7648. * @param {array} order 1D array of sorting information to be applied.
  7649. * @param {array} [...] Optional additional sorting conditions
  7650. * @returns {DataTables.Api} this
  7651. *//**
  7652. * Set the ordering for the table.
  7653. *
  7654. * @param {array} order 2D array of sorting information to be applied.
  7655. * @returns {DataTables.Api} this
  7656. */
  7657. _api_register( 'order()', function ( order, dir ) {
  7658. var ctx = this.context;
  7659. if ( order === undefined ) {
  7660. // get
  7661. return ctx.length !== 0 ?
  7662. ctx[0].aaSorting :
  7663. undefined;
  7664. }
  7665. // set
  7666. if ( typeof order === 'number' ) {
  7667. // Simple column / direction passed in
  7668. order = [ [ order, dir ] ];
  7669. }
  7670. else if ( order.length && ! Array.isArray( order[0] ) ) {
  7671. // Arguments passed in (list of 1D arrays)
  7672. order = Array.prototype.slice.call( arguments );
  7673. }
  7674. // otherwise a 2D array was passed in
  7675. return this.iterator( 'table', function ( settings ) {
  7676. settings.aaSorting = order.slice();
  7677. } );
  7678. } );
  7679. /**
  7680. * Attach a sort listener to an element for a given column
  7681. *
  7682. * @param {node|jQuery|string} node Identifier for the element(s) to attach the
  7683. * listener to. This can take the form of a single DOM node, a jQuery
  7684. * collection of nodes or a jQuery selector which will identify the node(s).
  7685. * @param {integer} column the column that a click on this node will sort on
  7686. * @param {function} [callback] callback function when sort is run
  7687. * @returns {DataTables.Api} this
  7688. */
  7689. _api_register( 'order.listener()', function ( node, column, callback ) {
  7690. return this.iterator( 'table', function ( settings ) {
  7691. _fnSortAttachListener( settings, node, column, callback );
  7692. } );
  7693. } );
  7694. _api_register( 'order.fixed()', function ( set ) {
  7695. if ( ! set ) {
  7696. var ctx = this.context;
  7697. var fixed = ctx.length ?
  7698. ctx[0].aaSortingFixed :
  7699. undefined;
  7700. return Array.isArray( fixed ) ?
  7701. { pre: fixed } :
  7702. fixed;
  7703. }
  7704. return this.iterator( 'table', function ( settings ) {
  7705. settings.aaSortingFixed = $.extend( true, {}, set );
  7706. } );
  7707. } );
  7708. // Order by the selected column(s)
  7709. _api_register( [
  7710. 'columns().order()',
  7711. 'column().order()'
  7712. ], function ( dir ) {
  7713. var that = this;
  7714. return this.iterator( 'table', function ( settings, i ) {
  7715. var sort = [];
  7716. $.each( that[i], function (j, col) {
  7717. sort.push( [ col, dir ] );
  7718. } );
  7719. settings.aaSorting = sort;
  7720. } );
  7721. } );
  7722. _api_register( 'search()', function ( input, regex, smart, caseInsen ) {
  7723. var ctx = this.context;
  7724. if ( input === undefined ) {
  7725. // get
  7726. return ctx.length !== 0 ?
  7727. ctx[0].oPreviousSearch.sSearch :
  7728. undefined;
  7729. }
  7730. // set
  7731. return this.iterator( 'table', function ( settings ) {
  7732. if ( ! settings.oFeatures.bFilter ) {
  7733. return;
  7734. }
  7735. _fnFilterComplete( settings, $.extend( {}, settings.oPreviousSearch, {
  7736. "sSearch": input+"",
  7737. "bRegex": regex === null ? false : regex,
  7738. "bSmart": smart === null ? true : smart,
  7739. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7740. } ), 1 );
  7741. } );
  7742. } );
  7743. _api_registerPlural(
  7744. 'columns().search()',
  7745. 'column().search()',
  7746. function ( input, regex, smart, caseInsen ) {
  7747. return this.iterator( 'column', function ( settings, column ) {
  7748. var preSearch = settings.aoPreSearchCols;
  7749. if ( input === undefined ) {
  7750. // get
  7751. return preSearch[ column ].sSearch;
  7752. }
  7753. // set
  7754. if ( ! settings.oFeatures.bFilter ) {
  7755. return;
  7756. }
  7757. $.extend( preSearch[ column ], {
  7758. "sSearch": input+"",
  7759. "bRegex": regex === null ? false : regex,
  7760. "bSmart": smart === null ? true : smart,
  7761. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7762. } );
  7763. _fnFilterComplete( settings, settings.oPreviousSearch, 1 );
  7764. } );
  7765. }
  7766. );
  7767. /*
  7768. * State API methods
  7769. */
  7770. _api_register( 'state()', function () {
  7771. return this.context.length ?
  7772. this.context[0].oSavedState :
  7773. null;
  7774. } );
  7775. _api_register( 'state.clear()', function () {
  7776. return this.iterator( 'table', function ( settings ) {
  7777. // Save an empty object
  7778. settings.fnStateSaveCallback.call( settings.oInstance, settings, {} );
  7779. } );
  7780. } );
  7781. _api_register( 'state.loaded()', function () {
  7782. return this.context.length ?
  7783. this.context[0].oLoadedState :
  7784. null;
  7785. } );
  7786. _api_register( 'state.save()', function () {
  7787. return this.iterator( 'table', function ( settings ) {
  7788. _fnSaveState( settings );
  7789. } );
  7790. } );
  7791. /**
  7792. * Provide a common method for plug-ins to check the version of DataTables being
  7793. * used, in order to ensure compatibility.
  7794. *
  7795. * @param {string} version Version string to check for, in the format "X.Y.Z".
  7796. * Note that the formats "X" and "X.Y" are also acceptable.
  7797. * @returns {boolean} true if this version of DataTables is greater or equal to
  7798. * the required version, or false if this version of DataTales is not
  7799. * suitable
  7800. * @static
  7801. * @dtopt API-Static
  7802. *
  7803. * @example
  7804. * alert( $.fn.dataTable.versionCheck( '1.9.0' ) );
  7805. */
  7806. DataTable.versionCheck = DataTable.fnVersionCheck = function( version )
  7807. {
  7808. var aThis = DataTable.version.split('.');
  7809. var aThat = version.split('.');
  7810. var iThis, iThat;
  7811. for ( var i=0, iLen=aThat.length ; i<iLen ; i++ ) {
  7812. iThis = parseInt( aThis[i], 10 ) || 0;
  7813. iThat = parseInt( aThat[i], 10 ) || 0;
  7814. // Parts are the same, keep comparing
  7815. if (iThis === iThat) {
  7816. continue;
  7817. }
  7818. // Parts are different, return immediately
  7819. return iThis > iThat;
  7820. }
  7821. return true;
  7822. };
  7823. /**
  7824. * Check if a `<table>` node is a DataTable table already or not.
  7825. *
  7826. * @param {node|jquery|string} table Table node, jQuery object or jQuery
  7827. * selector for the table to test. Note that if more than more than one
  7828. * table is passed on, only the first will be checked
  7829. * @returns {boolean} true the table given is a DataTable, or false otherwise
  7830. * @static
  7831. * @dtopt API-Static
  7832. *
  7833. * @example
  7834. * if ( ! $.fn.DataTable.isDataTable( '#example' ) ) {
  7835. * $('#example').dataTable();
  7836. * }
  7837. */
  7838. DataTable.isDataTable = DataTable.fnIsDataTable = function ( table )
  7839. {
  7840. var t = $(table).get(0);
  7841. var is = false;
  7842. if ( table instanceof DataTable.Api ) {
  7843. return true;
  7844. }
  7845. $.each( DataTable.settings, function (i, o) {
  7846. var head = o.nScrollHead ? $('table', o.nScrollHead)[0] : null;
  7847. var foot = o.nScrollFoot ? $('table', o.nScrollFoot)[0] : null;
  7848. if ( o.nTable === t || head === t || foot === t ) {
  7849. is = true;
  7850. }
  7851. } );
  7852. return is;
  7853. };
  7854. /**
  7855. * Get all DataTable tables that have been initialised - optionally you can
  7856. * select to get only currently visible tables.
  7857. *
  7858. * @param {boolean} [visible=false] Flag to indicate if you want all (default)
  7859. * or visible tables only.
  7860. * @returns {array} Array of `table` nodes (not DataTable instances) which are
  7861. * DataTables
  7862. * @static
  7863. * @dtopt API-Static
  7864. *
  7865. * @example
  7866. * $.each( $.fn.dataTable.tables(true), function () {
  7867. * $(table).DataTable().columns.adjust();
  7868. * } );
  7869. */
  7870. DataTable.tables = DataTable.fnTables = function ( visible )
  7871. {
  7872. var api = false;
  7873. if ( $.isPlainObject( visible ) ) {
  7874. api = visible.api;
  7875. visible = visible.visible;
  7876. }
  7877. var a = $.map( DataTable.settings, function (o) {
  7878. if ( !visible || (visible && $(o.nTable).is(':visible')) ) {
  7879. return o.nTable;
  7880. }
  7881. } );
  7882. return api ?
  7883. new _Api( a ) :
  7884. a;
  7885. };
  7886. /**
  7887. * Convert from camel case parameters to Hungarian notation. This is made public
  7888. * for the extensions to provide the same ability as DataTables core to accept
  7889. * either the 1.9 style Hungarian notation, or the 1.10+ style camelCase
  7890. * parameters.
  7891. *
  7892. * @param {object} src The model object which holds all parameters that can be
  7893. * mapped.
  7894. * @param {object} user The object to convert from camel case to Hungarian.
  7895. * @param {boolean} force When set to `true`, properties which already have a
  7896. * Hungarian value in the `user` object will be overwritten. Otherwise they
  7897. * won't be.
  7898. */
  7899. DataTable.camelToHungarian = _fnCamelToHungarian;
  7900. /**
  7901. *
  7902. */
  7903. _api_register( '$()', function ( selector, opts ) {
  7904. var
  7905. rows = this.rows( opts ).nodes(), // Get all rows
  7906. jqRows = $(rows);
  7907. return $( [].concat(
  7908. jqRows.filter( selector ).toArray(),
  7909. jqRows.find( selector ).toArray()
  7910. ) );
  7911. } );
  7912. // jQuery functions to operate on the tables
  7913. $.each( [ 'on', 'one', 'off' ], function (i, key) {
  7914. _api_register( key+'()', function ( /* event, handler */ ) {
  7915. var args = Array.prototype.slice.call(arguments);
  7916. // Add the `dt` namespace automatically if it isn't already present
  7917. args[0] = $.map( args[0].split( /\s/ ), function ( e ) {
  7918. return ! e.match(/\.dt\b/) ?
  7919. e+'.dt' :
  7920. e;
  7921. } ).join( ' ' );
  7922. var inst = $( this.tables().nodes() );
  7923. inst[key].apply( inst, args );
  7924. return this;
  7925. } );
  7926. } );
  7927. _api_register( 'clear()', function () {
  7928. return this.iterator( 'table', function ( settings ) {
  7929. _fnClearTable( settings );
  7930. } );
  7931. } );
  7932. _api_register( 'settings()', function () {
  7933. return new _Api( this.context, this.context );
  7934. } );
  7935. _api_register( 'init()', function () {
  7936. var ctx = this.context;
  7937. return ctx.length ? ctx[0].oInit : null;
  7938. } );
  7939. _api_register( 'data()', function () {
  7940. return this.iterator( 'table', function ( settings ) {
  7941. return _pluck( settings.aoData, '_aData' );
  7942. } ).flatten();
  7943. } );
  7944. _api_register( 'destroy()', function ( remove ) {
  7945. remove = remove || false;
  7946. return this.iterator( 'table', function ( settings ) {
  7947. var orig = settings.nTableWrapper.parentNode;
  7948. var classes = settings.oClasses;
  7949. var table = settings.nTable;
  7950. var tbody = settings.nTBody;
  7951. var thead = settings.nTHead;
  7952. var tfoot = settings.nTFoot;
  7953. var jqTable = $(table);
  7954. var jqTbody = $(tbody);
  7955. var jqWrapper = $(settings.nTableWrapper);
  7956. var rows = $.map( settings.aoData, function (r) { return r.nTr; } );
  7957. var i, ien;
  7958. // Flag to note that the table is currently being destroyed - no action
  7959. // should be taken
  7960. settings.bDestroying = true;
  7961. // Fire off the destroy callbacks for plug-ins etc
  7962. _fnCallbackFire( settings, "aoDestroyCallback", "destroy", [settings] );
  7963. // If not being removed from the document, make all columns visible
  7964. if ( ! remove ) {
  7965. new _Api( settings ).columns().visible( true );
  7966. }
  7967. // Blitz all `DT` namespaced events (these are internal events, the
  7968. // lowercase, `dt` events are user subscribed and they are responsible
  7969. // for removing them
  7970. jqWrapper.off('.DT').find(':not(tbody *)').off('.DT');
  7971. $(window).off('.DT-'+settings.sInstance);
  7972. // When scrolling we had to break the table up - restore it
  7973. if ( table != thead.parentNode ) {
  7974. jqTable.children('thead').detach();
  7975. jqTable.append( thead );
  7976. }
  7977. if ( tfoot && table != tfoot.parentNode ) {
  7978. jqTable.children('tfoot').detach();
  7979. jqTable.append( tfoot );
  7980. }
  7981. settings.aaSorting = [];
  7982. settings.aaSortingFixed = [];
  7983. _fnSortingClasses( settings );
  7984. $( rows ).removeClass( settings.asStripeClasses.join(' ') );
  7985. $('th, td', thead).removeClass( classes.sSortable+' '+
  7986. classes.sSortableAsc+' '+classes.sSortableDesc+' '+classes.sSortableNone
  7987. );
  7988. // Add the TR elements back into the table in their original order
  7989. jqTbody.children().detach();
  7990. jqTbody.append( rows );
  7991. // Remove the DataTables generated nodes, events and classes
  7992. var removedMethod = remove ? 'remove' : 'detach';
  7993. jqTable[ removedMethod ]();
  7994. jqWrapper[ removedMethod ]();
  7995. // If we need to reattach the table to the document
  7996. if ( ! remove && orig ) {
  7997. // insertBefore acts like appendChild if !arg[1]
  7998. orig.insertBefore( table, settings.nTableReinsertBefore );
  7999. // Restore the width of the original table - was read from the style property,
  8000. // so we can restore directly to that
  8001. jqTable
  8002. .css( 'width', settings.sDestroyWidth )
  8003. .removeClass( classes.sTable );
  8004. // If the were originally stripe classes - then we add them back here.
  8005. // Note this is not fool proof (for example if not all rows had stripe
  8006. // classes - but it's a good effort without getting carried away
  8007. ien = settings.asDestroyStripes.length;
  8008. if ( ien ) {
  8009. jqTbody.children().each( function (i) {
  8010. $(this).addClass( settings.asDestroyStripes[i % ien] );
  8011. } );
  8012. }
  8013. }
  8014. /* Remove the settings object from the settings array */
  8015. var idx = $.inArray( settings, DataTable.settings );
  8016. if ( idx !== -1 ) {
  8017. DataTable.settings.splice( idx, 1 );
  8018. }
  8019. } );
  8020. } );
  8021. // Add the `every()` method for rows, columns and cells in a compact form
  8022. $.each( [ 'column', 'row', 'cell' ], function ( i, type ) {
  8023. _api_register( type+'s().every()', function ( fn ) {
  8024. var opts = this.selector.opts;
  8025. var api = this;
  8026. return this.iterator( type, function ( settings, arg1, arg2, arg3, arg4 ) {
  8027. // Rows and columns:
  8028. // arg1 - index
  8029. // arg2 - table counter
  8030. // arg3 - loop counter
  8031. // arg4 - undefined
  8032. // Cells:
  8033. // arg1 - row index
  8034. // arg2 - column index
  8035. // arg3 - table counter
  8036. // arg4 - loop counter
  8037. fn.call(
  8038. api[ type ](
  8039. arg1,
  8040. type==='cell' ? arg2 : opts,
  8041. type==='cell' ? opts : undefined
  8042. ),
  8043. arg1, arg2, arg3, arg4
  8044. );
  8045. } );
  8046. } );
  8047. } );
  8048. // i18n method for extensions to be able to use the language object from the
  8049. // DataTable
  8050. _api_register( 'i18n()', function ( token, def, plural ) {
  8051. var ctx = this.context[0];
  8052. var resolved = _fnGetObjectDataFn( token )( ctx.oLanguage );
  8053. if ( resolved === undefined ) {
  8054. resolved = def;
  8055. }
  8056. if ( plural !== undefined && $.isPlainObject( resolved ) ) {
  8057. resolved = resolved[ plural ] !== undefined ?
  8058. resolved[ plural ] :
  8059. resolved._;
  8060. }
  8061. return resolved.replace( '%d', plural ); // nb: plural might be undefined,
  8062. } );
  8063. /**
  8064. * Version string for plug-ins to check compatibility. Allowed format is
  8065. * `a.b.c-d` where: a:int, b:int, c:int, d:string(dev|beta|alpha). `d` is used
  8066. * only for non-release builds. See http://semver.org/ for more information.
  8067. * @member
  8068. * @type string
  8069. * @default Version number
  8070. */
  8071. DataTable.version = "1.10.25";
  8072. /**
  8073. * Private data store, containing all of the settings objects that are
  8074. * created for the tables on a given page.
  8075. *
  8076. * Note that the `DataTable.settings` object is aliased to
  8077. * `jQuery.fn.dataTableExt` through which it may be accessed and
  8078. * manipulated, or `jQuery.fn.dataTable.settings`.
  8079. * @member
  8080. * @type array
  8081. * @default []
  8082. * @private
  8083. */
  8084. DataTable.settings = [];
  8085. /**
  8086. * Object models container, for the various models that DataTables has
  8087. * available to it. These models define the objects that are used to hold
  8088. * the active state and configuration of the table.
  8089. * @namespace
  8090. */
  8091. DataTable.models = {};
  8092. /**
  8093. * Template object for the way in which DataTables holds information about
  8094. * search information for the global filter and individual column filters.
  8095. * @namespace
  8096. */
  8097. DataTable.models.oSearch = {
  8098. /**
  8099. * Flag to indicate if the filtering should be case insensitive or not
  8100. * @type boolean
  8101. * @default true
  8102. */
  8103. "bCaseInsensitive": true,
  8104. /**
  8105. * Applied search term
  8106. * @type string
  8107. * @default <i>Empty string</i>
  8108. */
  8109. "sSearch": "",
  8110. /**
  8111. * Flag to indicate if the search term should be interpreted as a
  8112. * regular expression (true) or not (false) and therefore and special
  8113. * regex characters escaped.
  8114. * @type boolean
  8115. * @default false
  8116. */
  8117. "bRegex": false,
  8118. /**
  8119. * Flag to indicate if DataTables is to use its smart filtering or not.
  8120. * @type boolean
  8121. * @default true
  8122. */
  8123. "bSmart": true
  8124. };
  8125. /**
  8126. * Template object for the way in which DataTables holds information about
  8127. * each individual row. This is the object format used for the settings
  8128. * aoData array.
  8129. * @namespace
  8130. */
  8131. DataTable.models.oRow = {
  8132. /**
  8133. * TR element for the row
  8134. * @type node
  8135. * @default null
  8136. */
  8137. "nTr": null,
  8138. /**
  8139. * Array of TD elements for each row. This is null until the row has been
  8140. * created.
  8141. * @type array nodes
  8142. * @default []
  8143. */
  8144. "anCells": null,
  8145. /**
  8146. * Data object from the original data source for the row. This is either
  8147. * an array if using the traditional form of DataTables, or an object if
  8148. * using mData options. The exact type will depend on the passed in
  8149. * data from the data source, or will be an array if using DOM a data
  8150. * source.
  8151. * @type array|object
  8152. * @default []
  8153. */
  8154. "_aData": [],
  8155. /**
  8156. * Sorting data cache - this array is ostensibly the same length as the
  8157. * number of columns (although each index is generated only as it is
  8158. * needed), and holds the data that is used for sorting each column in the
  8159. * row. We do this cache generation at the start of the sort in order that
  8160. * the formatting of the sort data need be done only once for each cell
  8161. * per sort. This array should not be read from or written to by anything
  8162. * other than the master sorting methods.
  8163. * @type array
  8164. * @default null
  8165. * @private
  8166. */
  8167. "_aSortData": null,
  8168. /**
  8169. * Per cell filtering data cache. As per the sort data cache, used to
  8170. * increase the performance of the filtering in DataTables
  8171. * @type array
  8172. * @default null
  8173. * @private
  8174. */
  8175. "_aFilterData": null,
  8176. /**
  8177. * Filtering data cache. This is the same as the cell filtering cache, but
  8178. * in this case a string rather than an array. This is easily computed with
  8179. * a join on `_aFilterData`, but is provided as a cache so the join isn't
  8180. * needed on every search (memory traded for performance)
  8181. * @type array
  8182. * @default null
  8183. * @private
  8184. */
  8185. "_sFilterRow": null,
  8186. /**
  8187. * Cache of the class name that DataTables has applied to the row, so we
  8188. * can quickly look at this variable rather than needing to do a DOM check
  8189. * on className for the nTr property.
  8190. * @type string
  8191. * @default <i>Empty string</i>
  8192. * @private
  8193. */
  8194. "_sRowStripe": "",
  8195. /**
  8196. * Denote if the original data source was from the DOM, or the data source
  8197. * object. This is used for invalidating data, so DataTables can
  8198. * automatically read data from the original source, unless uninstructed
  8199. * otherwise.
  8200. * @type string
  8201. * @default null
  8202. * @private
  8203. */
  8204. "src": null,
  8205. /**
  8206. * Index in the aoData array. This saves an indexOf lookup when we have the
  8207. * object, but want to know the index
  8208. * @type integer
  8209. * @default -1
  8210. * @private
  8211. */
  8212. "idx": -1
  8213. };
  8214. /**
  8215. * Template object for the column information object in DataTables. This object
  8216. * is held in the settings aoColumns array and contains all the information that
  8217. * DataTables needs about each individual column.
  8218. *
  8219. * Note that this object is related to {@link DataTable.defaults.column}
  8220. * but this one is the internal data store for DataTables's cache of columns.
  8221. * It should NOT be manipulated outside of DataTables. Any configuration should
  8222. * be done through the initialisation options.
  8223. * @namespace
  8224. */
  8225. DataTable.models.oColumn = {
  8226. /**
  8227. * Column index. This could be worked out on-the-fly with $.inArray, but it
  8228. * is faster to just hold it as a variable
  8229. * @type integer
  8230. * @default null
  8231. */
  8232. "idx": null,
  8233. /**
  8234. * A list of the columns that sorting should occur on when this column
  8235. * is sorted. That this property is an array allows multi-column sorting
  8236. * to be defined for a column (for example first name / last name columns
  8237. * would benefit from this). The values are integers pointing to the
  8238. * columns to be sorted on (typically it will be a single integer pointing
  8239. * at itself, but that doesn't need to be the case).
  8240. * @type array
  8241. */
  8242. "aDataSort": null,
  8243. /**
  8244. * Define the sorting directions that are applied to the column, in sequence
  8245. * as the column is repeatedly sorted upon - i.e. the first value is used
  8246. * as the sorting direction when the column if first sorted (clicked on).
  8247. * Sort it again (click again) and it will move on to the next index.
  8248. * Repeat until loop.
  8249. * @type array
  8250. */
  8251. "asSorting": null,
  8252. /**
  8253. * Flag to indicate if the column is searchable, and thus should be included
  8254. * in the filtering or not.
  8255. * @type boolean
  8256. */
  8257. "bSearchable": null,
  8258. /**
  8259. * Flag to indicate if the column is sortable or not.
  8260. * @type boolean
  8261. */
  8262. "bSortable": null,
  8263. /**
  8264. * Flag to indicate if the column is currently visible in the table or not
  8265. * @type boolean
  8266. */
  8267. "bVisible": null,
  8268. /**
  8269. * Store for manual type assignment using the `column.type` option. This
  8270. * is held in store so we can manipulate the column's `sType` property.
  8271. * @type string
  8272. * @default null
  8273. * @private
  8274. */
  8275. "_sManualType": null,
  8276. /**
  8277. * Flag to indicate if HTML5 data attributes should be used as the data
  8278. * source for filtering or sorting. True is either are.
  8279. * @type boolean
  8280. * @default false
  8281. * @private
  8282. */
  8283. "_bAttrSrc": false,
  8284. /**
  8285. * Developer definable function that is called whenever a cell is created (Ajax source,
  8286. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  8287. * allowing you to modify the DOM element (add background colour for example) when the
  8288. * element is available.
  8289. * @type function
  8290. * @param {element} nTd The TD node that has been created
  8291. * @param {*} sData The Data for the cell
  8292. * @param {array|object} oData The data for the whole row
  8293. * @param {int} iRow The row index for the aoData data store
  8294. * @default null
  8295. */
  8296. "fnCreatedCell": null,
  8297. /**
  8298. * Function to get data from a cell in a column. You should <b>never</b>
  8299. * access data directly through _aData internally in DataTables - always use
  8300. * the method attached to this property. It allows mData to function as
  8301. * required. This function is automatically assigned by the column
  8302. * initialisation method
  8303. * @type function
  8304. * @param {array|object} oData The data array/object for the array
  8305. * (i.e. aoData[]._aData)
  8306. * @param {string} sSpecific The specific data type you want to get -
  8307. * 'display', 'type' 'filter' 'sort'
  8308. * @returns {*} The data for the cell from the given row's data
  8309. * @default null
  8310. */
  8311. "fnGetData": null,
  8312. /**
  8313. * Function to set data for a cell in the column. You should <b>never</b>
  8314. * set the data directly to _aData internally in DataTables - always use
  8315. * this method. It allows mData to function as required. This function
  8316. * is automatically assigned by the column initialisation method
  8317. * @type function
  8318. * @param {array|object} oData The data array/object for the array
  8319. * (i.e. aoData[]._aData)
  8320. * @param {*} sValue Value to set
  8321. * @default null
  8322. */
  8323. "fnSetData": null,
  8324. /**
  8325. * Property to read the value for the cells in the column from the data
  8326. * source array / object. If null, then the default content is used, if a
  8327. * function is given then the return from the function is used.
  8328. * @type function|int|string|null
  8329. * @default null
  8330. */
  8331. "mData": null,
  8332. /**
  8333. * Partner property to mData which is used (only when defined) to get
  8334. * the data - i.e. it is basically the same as mData, but without the
  8335. * 'set' option, and also the data fed to it is the result from mData.
  8336. * This is the rendering method to match the data method of mData.
  8337. * @type function|int|string|null
  8338. * @default null
  8339. */
  8340. "mRender": null,
  8341. /**
  8342. * Unique header TH/TD element for this column - this is what the sorting
  8343. * listener is attached to (if sorting is enabled.)
  8344. * @type node
  8345. * @default null
  8346. */
  8347. "nTh": null,
  8348. /**
  8349. * Unique footer TH/TD element for this column (if there is one). Not used
  8350. * in DataTables as such, but can be used for plug-ins to reference the
  8351. * footer for each column.
  8352. * @type node
  8353. * @default null
  8354. */
  8355. "nTf": null,
  8356. /**
  8357. * The class to apply to all TD elements in the table's TBODY for the column
  8358. * @type string
  8359. * @default null
  8360. */
  8361. "sClass": null,
  8362. /**
  8363. * When DataTables calculates the column widths to assign to each column,
  8364. * it finds the longest string in each column and then constructs a
  8365. * temporary table and reads the widths from that. The problem with this
  8366. * is that "mmm" is much wider then "iiii", but the latter is a longer
  8367. * string - thus the calculation can go wrong (doing it properly and putting
  8368. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  8369. * a "work around" we provide this option. It will append its value to the
  8370. * text that is found to be the longest string for the column - i.e. padding.
  8371. * @type string
  8372. */
  8373. "sContentPadding": null,
  8374. /**
  8375. * Allows a default value to be given for a column's data, and will be used
  8376. * whenever a null data source is encountered (this can be because mData
  8377. * is set to null, or because the data source itself is null).
  8378. * @type string
  8379. * @default null
  8380. */
  8381. "sDefaultContent": null,
  8382. /**
  8383. * Name for the column, allowing reference to the column by name as well as
  8384. * by index (needs a lookup to work by name).
  8385. * @type string
  8386. */
  8387. "sName": null,
  8388. /**
  8389. * Custom sorting data type - defines which of the available plug-ins in
  8390. * afnSortData the custom sorting will use - if any is defined.
  8391. * @type string
  8392. * @default std
  8393. */
  8394. "sSortDataType": 'std',
  8395. /**
  8396. * Class to be applied to the header element when sorting on this column
  8397. * @type string
  8398. * @default null
  8399. */
  8400. "sSortingClass": null,
  8401. /**
  8402. * Class to be applied to the header element when sorting on this column -
  8403. * when jQuery UI theming is used.
  8404. * @type string
  8405. * @default null
  8406. */
  8407. "sSortingClassJUI": null,
  8408. /**
  8409. * Title of the column - what is seen in the TH element (nTh).
  8410. * @type string
  8411. */
  8412. "sTitle": null,
  8413. /**
  8414. * Column sorting and filtering type
  8415. * @type string
  8416. * @default null
  8417. */
  8418. "sType": null,
  8419. /**
  8420. * Width of the column
  8421. * @type string
  8422. * @default null
  8423. */
  8424. "sWidth": null,
  8425. /**
  8426. * Width of the column when it was first "encountered"
  8427. * @type string
  8428. * @default null
  8429. */
  8430. "sWidthOrig": null
  8431. };
  8432. /*
  8433. * Developer note: The properties of the object below are given in Hungarian
  8434. * notation, that was used as the interface for DataTables prior to v1.10, however
  8435. * from v1.10 onwards the primary interface is camel case. In order to avoid
  8436. * breaking backwards compatibility utterly with this change, the Hungarian
  8437. * version is still, internally the primary interface, but is is not documented
  8438. * - hence the @name tags in each doc comment. This allows a Javascript function
  8439. * to create a map from Hungarian notation to camel case (going the other direction
  8440. * would require each property to be listed, which would add around 3K to the size
  8441. * of DataTables, while this method is about a 0.5K hit).
  8442. *
  8443. * Ultimately this does pave the way for Hungarian notation to be dropped
  8444. * completely, but that is a massive amount of work and will break current
  8445. * installs (therefore is on-hold until v2).
  8446. */
  8447. /**
  8448. * Initialisation options that can be given to DataTables at initialisation
  8449. * time.
  8450. * @namespace
  8451. */
  8452. DataTable.defaults = {
  8453. /**
  8454. * An array of data to use for the table, passed in at initialisation which
  8455. * will be used in preference to any data which is already in the DOM. This is
  8456. * particularly useful for constructing tables purely in Javascript, for
  8457. * example with a custom Ajax call.
  8458. * @type array
  8459. * @default null
  8460. *
  8461. * @dtopt Option
  8462. * @name DataTable.defaults.data
  8463. *
  8464. * @example
  8465. * // Using a 2D array data source
  8466. * $(document).ready( function () {
  8467. * $('#example').dataTable( {
  8468. * "data": [
  8469. * ['Trident', 'Internet Explorer 4.0', 'Win 95+', 4, 'X'],
  8470. * ['Trident', 'Internet Explorer 5.0', 'Win 95+', 5, 'C'],
  8471. * ],
  8472. * "columns": [
  8473. * { "title": "Engine" },
  8474. * { "title": "Browser" },
  8475. * { "title": "Platform" },
  8476. * { "title": "Version" },
  8477. * { "title": "Grade" }
  8478. * ]
  8479. * } );
  8480. * } );
  8481. *
  8482. * @example
  8483. * // Using an array of objects as a data source (`data`)
  8484. * $(document).ready( function () {
  8485. * $('#example').dataTable( {
  8486. * "data": [
  8487. * {
  8488. * "engine": "Trident",
  8489. * "browser": "Internet Explorer 4.0",
  8490. * "platform": "Win 95+",
  8491. * "version": 4,
  8492. * "grade": "X"
  8493. * },
  8494. * {
  8495. * "engine": "Trident",
  8496. * "browser": "Internet Explorer 5.0",
  8497. * "platform": "Win 95+",
  8498. * "version": 5,
  8499. * "grade": "C"
  8500. * }
  8501. * ],
  8502. * "columns": [
  8503. * { "title": "Engine", "data": "engine" },
  8504. * { "title": "Browser", "data": "browser" },
  8505. * { "title": "Platform", "data": "platform" },
  8506. * { "title": "Version", "data": "version" },
  8507. * { "title": "Grade", "data": "grade" }
  8508. * ]
  8509. * } );
  8510. * } );
  8511. */
  8512. "aaData": null,
  8513. /**
  8514. * If ordering is enabled, then DataTables will perform a first pass sort on
  8515. * initialisation. You can define which column(s) the sort is performed
  8516. * upon, and the sorting direction, with this variable. The `sorting` array
  8517. * should contain an array for each column to be sorted initially containing
  8518. * the column's index and a direction string ('asc' or 'desc').
  8519. * @type array
  8520. * @default [[0,'asc']]
  8521. *
  8522. * @dtopt Option
  8523. * @name DataTable.defaults.order
  8524. *
  8525. * @example
  8526. * // Sort by 3rd column first, and then 4th column
  8527. * $(document).ready( function() {
  8528. * $('#example').dataTable( {
  8529. * "order": [[2,'asc'], [3,'desc']]
  8530. * } );
  8531. * } );
  8532. *
  8533. * // No initial sorting
  8534. * $(document).ready( function() {
  8535. * $('#example').dataTable( {
  8536. * "order": []
  8537. * } );
  8538. * } );
  8539. */
  8540. "aaSorting": [[0,'asc']],
  8541. /**
  8542. * This parameter is basically identical to the `sorting` parameter, but
  8543. * cannot be overridden by user interaction with the table. What this means
  8544. * is that you could have a column (visible or hidden) which the sorting
  8545. * will always be forced on first - any sorting after that (from the user)
  8546. * will then be performed as required. This can be useful for grouping rows
  8547. * together.
  8548. * @type array
  8549. * @default null
  8550. *
  8551. * @dtopt Option
  8552. * @name DataTable.defaults.orderFixed
  8553. *
  8554. * @example
  8555. * $(document).ready( function() {
  8556. * $('#example').dataTable( {
  8557. * "orderFixed": [[0,'asc']]
  8558. * } );
  8559. * } )
  8560. */
  8561. "aaSortingFixed": [],
  8562. /**
  8563. * DataTables can be instructed to load data to display in the table from a
  8564. * Ajax source. This option defines how that Ajax call is made and where to.
  8565. *
  8566. * The `ajax` property has three different modes of operation, depending on
  8567. * how it is defined. These are:
  8568. *
  8569. * * `string` - Set the URL from where the data should be loaded from.
  8570. * * `object` - Define properties for `jQuery.ajax`.
  8571. * * `function` - Custom data get function
  8572. *
  8573. * `string`
  8574. * --------
  8575. *
  8576. * As a string, the `ajax` property simply defines the URL from which
  8577. * DataTables will load data.
  8578. *
  8579. * `object`
  8580. * --------
  8581. *
  8582. * As an object, the parameters in the object are passed to
  8583. * [jQuery.ajax](http://api.jquery.com/jQuery.ajax/) allowing fine control
  8584. * of the Ajax request. DataTables has a number of default parameters which
  8585. * you can override using this option. Please refer to the jQuery
  8586. * documentation for a full description of the options available, although
  8587. * the following parameters provide additional options in DataTables or
  8588. * require special consideration:
  8589. *
  8590. * * `data` - As with jQuery, `data` can be provided as an object, but it
  8591. * can also be used as a function to manipulate the data DataTables sends
  8592. * to the server. The function takes a single parameter, an object of
  8593. * parameters with the values that DataTables has readied for sending. An
  8594. * object may be returned which will be merged into the DataTables
  8595. * defaults, or you can add the items to the object that was passed in and
  8596. * not return anything from the function. This supersedes `fnServerParams`
  8597. * from DataTables 1.9-.
  8598. *
  8599. * * `dataSrc` - By default DataTables will look for the property `data` (or
  8600. * `aaData` for compatibility with DataTables 1.9-) when obtaining data
  8601. * from an Ajax source or for server-side processing - this parameter
  8602. * allows that property to be changed. You can use Javascript dotted
  8603. * object notation to get a data source for multiple levels of nesting, or
  8604. * it my be used as a function. As a function it takes a single parameter,
  8605. * the JSON returned from the server, which can be manipulated as
  8606. * required, with the returned value being that used by DataTables as the
  8607. * data source for the table. This supersedes `sAjaxDataProp` from
  8608. * DataTables 1.9-.
  8609. *
  8610. * * `success` - Should not be overridden it is used internally in
  8611. * DataTables. To manipulate / transform the data returned by the server
  8612. * use `ajax.dataSrc`, or use `ajax` as a function (see below).
  8613. *
  8614. * `function`
  8615. * ----------
  8616. *
  8617. * As a function, making the Ajax call is left up to yourself allowing
  8618. * complete control of the Ajax request. Indeed, if desired, a method other
  8619. * than Ajax could be used to obtain the required data, such as Web storage
  8620. * or an AIR database.
  8621. *
  8622. * The function is given four parameters and no return is required. The
  8623. * parameters are:
  8624. *
  8625. * 1. _object_ - Data to send to the server
  8626. * 2. _function_ - Callback function that must be executed when the required
  8627. * data has been obtained. That data should be passed into the callback
  8628. * as the only parameter
  8629. * 3. _object_ - DataTables settings object for the table
  8630. *
  8631. * Note that this supersedes `fnServerData` from DataTables 1.9-.
  8632. *
  8633. * @type string|object|function
  8634. * @default null
  8635. *
  8636. * @dtopt Option
  8637. * @name DataTable.defaults.ajax
  8638. * @since 1.10.0
  8639. *
  8640. * @example
  8641. * // Get JSON data from a file via Ajax.
  8642. * // Note DataTables expects data in the form `{ data: [ ...data... ] }` by default).
  8643. * $('#example').dataTable( {
  8644. * "ajax": "data.json"
  8645. * } );
  8646. *
  8647. * @example
  8648. * // Get JSON data from a file via Ajax, using `dataSrc` to change
  8649. * // `data` to `tableData` (i.e. `{ tableData: [ ...data... ] }`)
  8650. * $('#example').dataTable( {
  8651. * "ajax": {
  8652. * "url": "data.json",
  8653. * "dataSrc": "tableData"
  8654. * }
  8655. * } );
  8656. *
  8657. * @example
  8658. * // Get JSON data from a file via Ajax, using `dataSrc` to read data
  8659. * // from a plain array rather than an array in an object
  8660. * $('#example').dataTable( {
  8661. * "ajax": {
  8662. * "url": "data.json",
  8663. * "dataSrc": ""
  8664. * }
  8665. * } );
  8666. *
  8667. * @example
  8668. * // Manipulate the data returned from the server - add a link to data
  8669. * // (note this can, should, be done using `render` for the column - this
  8670. * // is just a simple example of how the data can be manipulated).
  8671. * $('#example').dataTable( {
  8672. * "ajax": {
  8673. * "url": "data.json",
  8674. * "dataSrc": function ( json ) {
  8675. * for ( var i=0, ien=json.length ; i<ien ; i++ ) {
  8676. * json[i][0] = '<a href="/message/'+json[i][0]+'>View message</a>';
  8677. * }
  8678. * return json;
  8679. * }
  8680. * }
  8681. * } );
  8682. *
  8683. * @example
  8684. * // Add data to the request
  8685. * $('#example').dataTable( {
  8686. * "ajax": {
  8687. * "url": "data.json",
  8688. * "data": function ( d ) {
  8689. * return {
  8690. * "extra_search": $('#extra').val()
  8691. * };
  8692. * }
  8693. * }
  8694. * } );
  8695. *
  8696. * @example
  8697. * // Send request as POST
  8698. * $('#example').dataTable( {
  8699. * "ajax": {
  8700. * "url": "data.json",
  8701. * "type": "POST"
  8702. * }
  8703. * } );
  8704. *
  8705. * @example
  8706. * // Get the data from localStorage (could interface with a form for
  8707. * // adding, editing and removing rows).
  8708. * $('#example').dataTable( {
  8709. * "ajax": function (data, callback, settings) {
  8710. * callback(
  8711. * JSON.parse( localStorage.getItem('dataTablesData') )
  8712. * );
  8713. * }
  8714. * } );
  8715. */
  8716. "ajax": null,
  8717. /**
  8718. * This parameter allows you to readily specify the entries in the length drop
  8719. * down menu that DataTables shows when pagination is enabled. It can be
  8720. * either a 1D array of options which will be used for both the displayed
  8721. * option and the value, or a 2D array which will use the array in the first
  8722. * position as the value, and the array in the second position as the
  8723. * displayed options (useful for language strings such as 'All').
  8724. *
  8725. * Note that the `pageLength` property will be automatically set to the
  8726. * first value given in this array, unless `pageLength` is also provided.
  8727. * @type array
  8728. * @default [ 10, 25, 50, 100 ]
  8729. *
  8730. * @dtopt Option
  8731. * @name DataTable.defaults.lengthMenu
  8732. *
  8733. * @example
  8734. * $(document).ready( function() {
  8735. * $('#example').dataTable( {
  8736. * "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
  8737. * } );
  8738. * } );
  8739. */
  8740. "aLengthMenu": [ 10, 25, 50, 100 ],
  8741. /**
  8742. * The `columns` option in the initialisation parameter allows you to define
  8743. * details about the way individual columns behave. For a full list of
  8744. * column options that can be set, please see
  8745. * {@link DataTable.defaults.column}. Note that if you use `columns` to
  8746. * define your columns, you must have an entry in the array for every single
  8747. * column that you have in your table (these can be null if you don't which
  8748. * to specify any options).
  8749. * @member
  8750. *
  8751. * @name DataTable.defaults.column
  8752. */
  8753. "aoColumns": null,
  8754. /**
  8755. * Very similar to `columns`, `columnDefs` allows you to target a specific
  8756. * column, multiple columns, or all columns, using the `targets` property of
  8757. * each object in the array. This allows great flexibility when creating
  8758. * tables, as the `columnDefs` arrays can be of any length, targeting the
  8759. * columns you specifically want. `columnDefs` may use any of the column
  8760. * options available: {@link DataTable.defaults.column}, but it _must_
  8761. * have `targets` defined in each object in the array. Values in the `targets`
  8762. * array may be:
  8763. * <ul>
  8764. * <li>a string - class name will be matched on the TH for the column</li>
  8765. * <li>0 or a positive integer - column index counting from the left</li>
  8766. * <li>a negative integer - column index counting from the right</li>
  8767. * <li>the string "_all" - all columns (i.e. assign a default)</li>
  8768. * </ul>
  8769. * @member
  8770. *
  8771. * @name DataTable.defaults.columnDefs
  8772. */
  8773. "aoColumnDefs": null,
  8774. /**
  8775. * Basically the same as `search`, this parameter defines the individual column
  8776. * filtering state at initialisation time. The array must be of the same size
  8777. * as the number of columns, and each element be an object with the parameters
  8778. * `search` and `escapeRegex` (the latter is optional). 'null' is also
  8779. * accepted and the default will be used.
  8780. * @type array
  8781. * @default []
  8782. *
  8783. * @dtopt Option
  8784. * @name DataTable.defaults.searchCols
  8785. *
  8786. * @example
  8787. * $(document).ready( function() {
  8788. * $('#example').dataTable( {
  8789. * "searchCols": [
  8790. * null,
  8791. * { "search": "My filter" },
  8792. * null,
  8793. * { "search": "^[0-9]", "escapeRegex": false }
  8794. * ]
  8795. * } );
  8796. * } )
  8797. */
  8798. "aoSearchCols": [],
  8799. /**
  8800. * An array of CSS classes that should be applied to displayed rows. This
  8801. * array may be of any length, and DataTables will apply each class
  8802. * sequentially, looping when required.
  8803. * @type array
  8804. * @default null <i>Will take the values determined by the `oClasses.stripe*`
  8805. * options</i>
  8806. *
  8807. * @dtopt Option
  8808. * @name DataTable.defaults.stripeClasses
  8809. *
  8810. * @example
  8811. * $(document).ready( function() {
  8812. * $('#example').dataTable( {
  8813. * "stripeClasses": [ 'strip1', 'strip2', 'strip3' ]
  8814. * } );
  8815. * } )
  8816. */
  8817. "asStripeClasses": null,
  8818. /**
  8819. * Enable or disable automatic column width calculation. This can be disabled
  8820. * as an optimisation (it takes some time to calculate the widths) if the
  8821. * tables widths are passed in using `columns`.
  8822. * @type boolean
  8823. * @default true
  8824. *
  8825. * @dtopt Features
  8826. * @name DataTable.defaults.autoWidth
  8827. *
  8828. * @example
  8829. * $(document).ready( function () {
  8830. * $('#example').dataTable( {
  8831. * "autoWidth": false
  8832. * } );
  8833. * } );
  8834. */
  8835. "bAutoWidth": true,
  8836. /**
  8837. * Deferred rendering can provide DataTables with a huge speed boost when you
  8838. * are using an Ajax or JS data source for the table. This option, when set to
  8839. * true, will cause DataTables to defer the creation of the table elements for
  8840. * each row until they are needed for a draw - saving a significant amount of
  8841. * time.
  8842. * @type boolean
  8843. * @default false
  8844. *
  8845. * @dtopt Features
  8846. * @name DataTable.defaults.deferRender
  8847. *
  8848. * @example
  8849. * $(document).ready( function() {
  8850. * $('#example').dataTable( {
  8851. * "ajax": "sources/arrays.txt",
  8852. * "deferRender": true
  8853. * } );
  8854. * } );
  8855. */
  8856. "bDeferRender": false,
  8857. /**
  8858. * Replace a DataTable which matches the given selector and replace it with
  8859. * one which has the properties of the new initialisation object passed. If no
  8860. * table matches the selector, then the new DataTable will be constructed as
  8861. * per normal.
  8862. * @type boolean
  8863. * @default false
  8864. *
  8865. * @dtopt Options
  8866. * @name DataTable.defaults.destroy
  8867. *
  8868. * @example
  8869. * $(document).ready( function() {
  8870. * $('#example').dataTable( {
  8871. * "srollY": "200px",
  8872. * "paginate": false
  8873. * } );
  8874. *
  8875. * // Some time later....
  8876. * $('#example').dataTable( {
  8877. * "filter": false,
  8878. * "destroy": true
  8879. * } );
  8880. * } );
  8881. */
  8882. "bDestroy": false,
  8883. /**
  8884. * Enable or disable filtering of data. Filtering in DataTables is "smart" in
  8885. * that it allows the end user to input multiple words (space separated) and
  8886. * will match a row containing those words, even if not in the order that was
  8887. * specified (this allow matching across multiple columns). Note that if you
  8888. * wish to use filtering in DataTables this must remain 'true' - to remove the
  8889. * default filtering input box and retain filtering abilities, please use
  8890. * {@link DataTable.defaults.dom}.
  8891. * @type boolean
  8892. * @default true
  8893. *
  8894. * @dtopt Features
  8895. * @name DataTable.defaults.searching
  8896. *
  8897. * @example
  8898. * $(document).ready( function () {
  8899. * $('#example').dataTable( {
  8900. * "searching": false
  8901. * } );
  8902. * } );
  8903. */
  8904. "bFilter": true,
  8905. /**
  8906. * Enable or disable the table information display. This shows information
  8907. * about the data that is currently visible on the page, including information
  8908. * about filtered data if that action is being performed.
  8909. * @type boolean
  8910. * @default true
  8911. *
  8912. * @dtopt Features
  8913. * @name DataTable.defaults.info
  8914. *
  8915. * @example
  8916. * $(document).ready( function () {
  8917. * $('#example').dataTable( {
  8918. * "info": false
  8919. * } );
  8920. * } );
  8921. */
  8922. "bInfo": true,
  8923. /**
  8924. * Allows the end user to select the size of a formatted page from a select
  8925. * menu (sizes are 10, 25, 50 and 100). Requires pagination (`paginate`).
  8926. * @type boolean
  8927. * @default true
  8928. *
  8929. * @dtopt Features
  8930. * @name DataTable.defaults.lengthChange
  8931. *
  8932. * @example
  8933. * $(document).ready( function () {
  8934. * $('#example').dataTable( {
  8935. * "lengthChange": false
  8936. * } );
  8937. * } );
  8938. */
  8939. "bLengthChange": true,
  8940. /**
  8941. * Enable or disable pagination.
  8942. * @type boolean
  8943. * @default true
  8944. *
  8945. * @dtopt Features
  8946. * @name DataTable.defaults.paging
  8947. *
  8948. * @example
  8949. * $(document).ready( function () {
  8950. * $('#example').dataTable( {
  8951. * "paging": false
  8952. * } );
  8953. * } );
  8954. */
  8955. "bPaginate": true,
  8956. /**
  8957. * Enable or disable the display of a 'processing' indicator when the table is
  8958. * being processed (e.g. a sort). This is particularly useful for tables with
  8959. * large amounts of data where it can take a noticeable amount of time to sort
  8960. * the entries.
  8961. * @type boolean
  8962. * @default false
  8963. *
  8964. * @dtopt Features
  8965. * @name DataTable.defaults.processing
  8966. *
  8967. * @example
  8968. * $(document).ready( function () {
  8969. * $('#example').dataTable( {
  8970. * "processing": true
  8971. * } );
  8972. * } );
  8973. */
  8974. "bProcessing": false,
  8975. /**
  8976. * Retrieve the DataTables object for the given selector. Note that if the
  8977. * table has already been initialised, this parameter will cause DataTables
  8978. * to simply return the object that has already been set up - it will not take
  8979. * account of any changes you might have made to the initialisation object
  8980. * passed to DataTables (setting this parameter to true is an acknowledgement
  8981. * that you understand this). `destroy` can be used to reinitialise a table if
  8982. * you need.
  8983. * @type boolean
  8984. * @default false
  8985. *
  8986. * @dtopt Options
  8987. * @name DataTable.defaults.retrieve
  8988. *
  8989. * @example
  8990. * $(document).ready( function() {
  8991. * initTable();
  8992. * tableActions();
  8993. * } );
  8994. *
  8995. * function initTable ()
  8996. * {
  8997. * return $('#example').dataTable( {
  8998. * "scrollY": "200px",
  8999. * "paginate": false,
  9000. * "retrieve": true
  9001. * } );
  9002. * }
  9003. *
  9004. * function tableActions ()
  9005. * {
  9006. * var table = initTable();
  9007. * // perform API operations with oTable
  9008. * }
  9009. */
  9010. "bRetrieve": false,
  9011. /**
  9012. * When vertical (y) scrolling is enabled, DataTables will force the height of
  9013. * the table's viewport to the given height at all times (useful for layout).
  9014. * However, this can look odd when filtering data down to a small data set,
  9015. * and the footer is left "floating" further down. This parameter (when
  9016. * enabled) will cause DataTables to collapse the table's viewport down when
  9017. * the result set will fit within the given Y height.
  9018. * @type boolean
  9019. * @default false
  9020. *
  9021. * @dtopt Options
  9022. * @name DataTable.defaults.scrollCollapse
  9023. *
  9024. * @example
  9025. * $(document).ready( function() {
  9026. * $('#example').dataTable( {
  9027. * "scrollY": "200",
  9028. * "scrollCollapse": true
  9029. * } );
  9030. * } );
  9031. */
  9032. "bScrollCollapse": false,
  9033. /**
  9034. * Configure DataTables to use server-side processing. Note that the
  9035. * `ajax` parameter must also be given in order to give DataTables a
  9036. * source to obtain the required data for each draw.
  9037. * @type boolean
  9038. * @default false
  9039. *
  9040. * @dtopt Features
  9041. * @dtopt Server-side
  9042. * @name DataTable.defaults.serverSide
  9043. *
  9044. * @example
  9045. * $(document).ready( function () {
  9046. * $('#example').dataTable( {
  9047. * "serverSide": true,
  9048. * "ajax": "xhr.php"
  9049. * } );
  9050. * } );
  9051. */
  9052. "bServerSide": false,
  9053. /**
  9054. * Enable or disable sorting of columns. Sorting of individual columns can be
  9055. * disabled by the `sortable` option for each column.
  9056. * @type boolean
  9057. * @default true
  9058. *
  9059. * @dtopt Features
  9060. * @name DataTable.defaults.ordering
  9061. *
  9062. * @example
  9063. * $(document).ready( function () {
  9064. * $('#example').dataTable( {
  9065. * "ordering": false
  9066. * } );
  9067. * } );
  9068. */
  9069. "bSort": true,
  9070. /**
  9071. * Enable or display DataTables' ability to sort multiple columns at the
  9072. * same time (activated by shift-click by the user).
  9073. * @type boolean
  9074. * @default true
  9075. *
  9076. * @dtopt Options
  9077. * @name DataTable.defaults.orderMulti
  9078. *
  9079. * @example
  9080. * // Disable multiple column sorting ability
  9081. * $(document).ready( function () {
  9082. * $('#example').dataTable( {
  9083. * "orderMulti": false
  9084. * } );
  9085. * } );
  9086. */
  9087. "bSortMulti": true,
  9088. /**
  9089. * Allows control over whether DataTables should use the top (true) unique
  9090. * cell that is found for a single column, or the bottom (false - default).
  9091. * This is useful when using complex headers.
  9092. * @type boolean
  9093. * @default false
  9094. *
  9095. * @dtopt Options
  9096. * @name DataTable.defaults.orderCellsTop
  9097. *
  9098. * @example
  9099. * $(document).ready( function() {
  9100. * $('#example').dataTable( {
  9101. * "orderCellsTop": true
  9102. * } );
  9103. * } );
  9104. */
  9105. "bSortCellsTop": false,
  9106. /**
  9107. * Enable or disable the addition of the classes `sorting\_1`, `sorting\_2` and
  9108. * `sorting\_3` to the columns which are currently being sorted on. This is
  9109. * presented as a feature switch as it can increase processing time (while
  9110. * classes are removed and added) so for large data sets you might want to
  9111. * turn this off.
  9112. * @type boolean
  9113. * @default true
  9114. *
  9115. * @dtopt Features
  9116. * @name DataTable.defaults.orderClasses
  9117. *
  9118. * @example
  9119. * $(document).ready( function () {
  9120. * $('#example').dataTable( {
  9121. * "orderClasses": false
  9122. * } );
  9123. * } );
  9124. */
  9125. "bSortClasses": true,
  9126. /**
  9127. * Enable or disable state saving. When enabled HTML5 `localStorage` will be
  9128. * used to save table display information such as pagination information,
  9129. * display length, filtering and sorting. As such when the end user reloads
  9130. * the page the display display will match what thy had previously set up.
  9131. *
  9132. * Due to the use of `localStorage` the default state saving is not supported
  9133. * in IE6 or 7. If state saving is required in those browsers, use
  9134. * `stateSaveCallback` to provide a storage solution such as cookies.
  9135. * @type boolean
  9136. * @default false
  9137. *
  9138. * @dtopt Features
  9139. * @name DataTable.defaults.stateSave
  9140. *
  9141. * @example
  9142. * $(document).ready( function () {
  9143. * $('#example').dataTable( {
  9144. * "stateSave": true
  9145. * } );
  9146. * } );
  9147. */
  9148. "bStateSave": false,
  9149. /**
  9150. * This function is called when a TR element is created (and all TD child
  9151. * elements have been inserted), or registered if using a DOM source, allowing
  9152. * manipulation of the TR element (adding classes etc).
  9153. * @type function
  9154. * @param {node} row "TR" element for the current row
  9155. * @param {array} data Raw data array for this row
  9156. * @param {int} dataIndex The index of this row in the internal aoData array
  9157. *
  9158. * @dtopt Callbacks
  9159. * @name DataTable.defaults.createdRow
  9160. *
  9161. * @example
  9162. * $(document).ready( function() {
  9163. * $('#example').dataTable( {
  9164. * "createdRow": function( row, data, dataIndex ) {
  9165. * // Bold the grade for all 'A' grade browsers
  9166. * if ( data[4] == "A" )
  9167. * {
  9168. * $('td:eq(4)', row).html( '<b>A</b>' );
  9169. * }
  9170. * }
  9171. * } );
  9172. * } );
  9173. */
  9174. "fnCreatedRow": null,
  9175. /**
  9176. * This function is called on every 'draw' event, and allows you to
  9177. * dynamically modify any aspect you want about the created DOM.
  9178. * @type function
  9179. * @param {object} settings DataTables settings object
  9180. *
  9181. * @dtopt Callbacks
  9182. * @name DataTable.defaults.drawCallback
  9183. *
  9184. * @example
  9185. * $(document).ready( function() {
  9186. * $('#example').dataTable( {
  9187. * "drawCallback": function( settings ) {
  9188. * alert( 'DataTables has redrawn the table' );
  9189. * }
  9190. * } );
  9191. * } );
  9192. */
  9193. "fnDrawCallback": null,
  9194. /**
  9195. * Identical to fnHeaderCallback() but for the table footer this function
  9196. * allows you to modify the table footer on every 'draw' event.
  9197. * @type function
  9198. * @param {node} foot "TR" element for the footer
  9199. * @param {array} data Full table data (as derived from the original HTML)
  9200. * @param {int} start Index for the current display starting point in the
  9201. * display array
  9202. * @param {int} end Index for the current display ending point in the
  9203. * display array
  9204. * @param {array int} display Index array to translate the visual position
  9205. * to the full data array
  9206. *
  9207. * @dtopt Callbacks
  9208. * @name DataTable.defaults.footerCallback
  9209. *
  9210. * @example
  9211. * $(document).ready( function() {
  9212. * $('#example').dataTable( {
  9213. * "footerCallback": function( tfoot, data, start, end, display ) {
  9214. * tfoot.getElementsByTagName('th')[0].innerHTML = "Starting index is "+start;
  9215. * }
  9216. * } );
  9217. * } )
  9218. */
  9219. "fnFooterCallback": null,
  9220. /**
  9221. * When rendering large numbers in the information element for the table
  9222. * (i.e. "Showing 1 to 10 of 57 entries") DataTables will render large numbers
  9223. * to have a comma separator for the 'thousands' units (e.g. 1 million is
  9224. * rendered as "1,000,000") to help readability for the end user. This
  9225. * function will override the default method DataTables uses.
  9226. * @type function
  9227. * @member
  9228. * @param {int} toFormat number to be formatted
  9229. * @returns {string} formatted string for DataTables to show the number
  9230. *
  9231. * @dtopt Callbacks
  9232. * @name DataTable.defaults.formatNumber
  9233. *
  9234. * @example
  9235. * // Format a number using a single quote for the separator (note that
  9236. * // this can also be done with the language.thousands option)
  9237. * $(document).ready( function() {
  9238. * $('#example').dataTable( {
  9239. * "formatNumber": function ( toFormat ) {
  9240. * return toFormat.toString().replace(
  9241. * /\B(?=(\d{3})+(?!\d))/g, "'"
  9242. * );
  9243. * };
  9244. * } );
  9245. * } );
  9246. */
  9247. "fnFormatNumber": function ( toFormat ) {
  9248. return toFormat.toString().replace(
  9249. /\B(?=(\d{3})+(?!\d))/g,
  9250. this.oLanguage.sThousands
  9251. );
  9252. },
  9253. /**
  9254. * This function is called on every 'draw' event, and allows you to
  9255. * dynamically modify the header row. This can be used to calculate and
  9256. * display useful information about the table.
  9257. * @type function
  9258. * @param {node} head "TR" element for the header
  9259. * @param {array} data Full table data (as derived from the original HTML)
  9260. * @param {int} start Index for the current display starting point in the
  9261. * display array
  9262. * @param {int} end Index for the current display ending point in the
  9263. * display array
  9264. * @param {array int} display Index array to translate the visual position
  9265. * to the full data array
  9266. *
  9267. * @dtopt Callbacks
  9268. * @name DataTable.defaults.headerCallback
  9269. *
  9270. * @example
  9271. * $(document).ready( function() {
  9272. * $('#example').dataTable( {
  9273. * "fheaderCallback": function( head, data, start, end, display ) {
  9274. * head.getElementsByTagName('th')[0].innerHTML = "Displaying "+(end-start)+" records";
  9275. * }
  9276. * } );
  9277. * } )
  9278. */
  9279. "fnHeaderCallback": null,
  9280. /**
  9281. * The information element can be used to convey information about the current
  9282. * state of the table. Although the internationalisation options presented by
  9283. * DataTables are quite capable of dealing with most customisations, there may
  9284. * be times where you wish to customise the string further. This callback
  9285. * allows you to do exactly that.
  9286. * @type function
  9287. * @param {object} oSettings DataTables settings object
  9288. * @param {int} start Starting position in data for the draw
  9289. * @param {int} end End position in data for the draw
  9290. * @param {int} max Total number of rows in the table (regardless of
  9291. * filtering)
  9292. * @param {int} total Total number of rows in the data set, after filtering
  9293. * @param {string} pre The string that DataTables has formatted using it's
  9294. * own rules
  9295. * @returns {string} The string to be displayed in the information element.
  9296. *
  9297. * @dtopt Callbacks
  9298. * @name DataTable.defaults.infoCallback
  9299. *
  9300. * @example
  9301. * $('#example').dataTable( {
  9302. * "infoCallback": function( settings, start, end, max, total, pre ) {
  9303. * return start +" to "+ end;
  9304. * }
  9305. * } );
  9306. */
  9307. "fnInfoCallback": null,
  9308. /**
  9309. * Called when the table has been initialised. Normally DataTables will
  9310. * initialise sequentially and there will be no need for this function,
  9311. * however, this does not hold true when using external language information
  9312. * since that is obtained using an async XHR call.
  9313. * @type function
  9314. * @param {object} settings DataTables settings object
  9315. * @param {object} json The JSON object request from the server - only
  9316. * present if client-side Ajax sourced data is used
  9317. *
  9318. * @dtopt Callbacks
  9319. * @name DataTable.defaults.initComplete
  9320. *
  9321. * @example
  9322. * $(document).ready( function() {
  9323. * $('#example').dataTable( {
  9324. * "initComplete": function(settings, json) {
  9325. * alert( 'DataTables has finished its initialisation.' );
  9326. * }
  9327. * } );
  9328. * } )
  9329. */
  9330. "fnInitComplete": null,
  9331. /**
  9332. * Called at the very start of each table draw and can be used to cancel the
  9333. * draw by returning false, any other return (including undefined) results in
  9334. * the full draw occurring).
  9335. * @type function
  9336. * @param {object} settings DataTables settings object
  9337. * @returns {boolean} False will cancel the draw, anything else (including no
  9338. * return) will allow it to complete.
  9339. *
  9340. * @dtopt Callbacks
  9341. * @name DataTable.defaults.preDrawCallback
  9342. *
  9343. * @example
  9344. * $(document).ready( function() {
  9345. * $('#example').dataTable( {
  9346. * "preDrawCallback": function( settings ) {
  9347. * if ( $('#test').val() == 1 ) {
  9348. * return false;
  9349. * }
  9350. * }
  9351. * } );
  9352. * } );
  9353. */
  9354. "fnPreDrawCallback": null,
  9355. /**
  9356. * This function allows you to 'post process' each row after it have been
  9357. * generated for each table draw, but before it is rendered on screen. This
  9358. * function might be used for setting the row class name etc.
  9359. * @type function
  9360. * @param {node} row "TR" element for the current row
  9361. * @param {array} data Raw data array for this row
  9362. * @param {int} displayIndex The display index for the current table draw
  9363. * @param {int} displayIndexFull The index of the data in the full list of
  9364. * rows (after filtering)
  9365. *
  9366. * @dtopt Callbacks
  9367. * @name DataTable.defaults.rowCallback
  9368. *
  9369. * @example
  9370. * $(document).ready( function() {
  9371. * $('#example').dataTable( {
  9372. * "rowCallback": function( row, data, displayIndex, displayIndexFull ) {
  9373. * // Bold the grade for all 'A' grade browsers
  9374. * if ( data[4] == "A" ) {
  9375. * $('td:eq(4)', row).html( '<b>A</b>' );
  9376. * }
  9377. * }
  9378. * } );
  9379. * } );
  9380. */
  9381. "fnRowCallback": null,
  9382. /**
  9383. * __Deprecated__ The functionality provided by this parameter has now been
  9384. * superseded by that provided through `ajax`, which should be used instead.
  9385. *
  9386. * This parameter allows you to override the default function which obtains
  9387. * the data from the server so something more suitable for your application.
  9388. * For example you could use POST data, or pull information from a Gears or
  9389. * AIR database.
  9390. * @type function
  9391. * @member
  9392. * @param {string} source HTTP source to obtain the data from (`ajax`)
  9393. * @param {array} data A key/value pair object containing the data to send
  9394. * to the server
  9395. * @param {function} callback to be called on completion of the data get
  9396. * process that will draw the data on the page.
  9397. * @param {object} settings DataTables settings object
  9398. *
  9399. * @dtopt Callbacks
  9400. * @dtopt Server-side
  9401. * @name DataTable.defaults.serverData
  9402. *
  9403. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9404. */
  9405. "fnServerData": null,
  9406. /**
  9407. * __Deprecated__ The functionality provided by this parameter has now been
  9408. * superseded by that provided through `ajax`, which should be used instead.
  9409. *
  9410. * It is often useful to send extra data to the server when making an Ajax
  9411. * request - for example custom filtering information, and this callback
  9412. * function makes it trivial to send extra information to the server. The
  9413. * passed in parameter is the data set that has been constructed by
  9414. * DataTables, and you can add to this or modify it as you require.
  9415. * @type function
  9416. * @param {array} data Data array (array of objects which are name/value
  9417. * pairs) that has been constructed by DataTables and will be sent to the
  9418. * server. In the case of Ajax sourced data with server-side processing
  9419. * this will be an empty array, for server-side processing there will be a
  9420. * significant number of parameters!
  9421. * @returns {undefined} Ensure that you modify the data array passed in,
  9422. * as this is passed by reference.
  9423. *
  9424. * @dtopt Callbacks
  9425. * @dtopt Server-side
  9426. * @name DataTable.defaults.serverParams
  9427. *
  9428. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9429. */
  9430. "fnServerParams": null,
  9431. /**
  9432. * Load the table state. With this function you can define from where, and how, the
  9433. * state of a table is loaded. By default DataTables will load from `localStorage`
  9434. * but you might wish to use a server-side database or cookies.
  9435. * @type function
  9436. * @member
  9437. * @param {object} settings DataTables settings object
  9438. * @param {object} callback Callback that can be executed when done. It
  9439. * should be passed the loaded state object.
  9440. * @return {object} The DataTables state object to be loaded
  9441. *
  9442. * @dtopt Callbacks
  9443. * @name DataTable.defaults.stateLoadCallback
  9444. *
  9445. * @example
  9446. * $(document).ready( function() {
  9447. * $('#example').dataTable( {
  9448. * "stateSave": true,
  9449. * "stateLoadCallback": function (settings, callback) {
  9450. * $.ajax( {
  9451. * "url": "/state_load",
  9452. * "dataType": "json",
  9453. * "success": function (json) {
  9454. * callback( json );
  9455. * }
  9456. * } );
  9457. * }
  9458. * } );
  9459. * } );
  9460. */
  9461. "fnStateLoadCallback": function ( settings ) {
  9462. try {
  9463. return JSON.parse(
  9464. (settings.iStateDuration === -1 ? sessionStorage : localStorage).getItem(
  9465. 'DataTables_'+settings.sInstance+'_'+location.pathname
  9466. )
  9467. );
  9468. } catch (e) {
  9469. return {};
  9470. }
  9471. },
  9472. /**
  9473. * Callback which allows modification of the saved state prior to loading that state.
  9474. * This callback is called when the table is loading state from the stored data, but
  9475. * prior to the settings object being modified by the saved state. Note that for
  9476. * plug-in authors, you should use the `stateLoadParams` event to load parameters for
  9477. * a plug-in.
  9478. * @type function
  9479. * @param {object} settings DataTables settings object
  9480. * @param {object} data The state object that is to be loaded
  9481. *
  9482. * @dtopt Callbacks
  9483. * @name DataTable.defaults.stateLoadParams
  9484. *
  9485. * @example
  9486. * // Remove a saved filter, so filtering is never loaded
  9487. * $(document).ready( function() {
  9488. * $('#example').dataTable( {
  9489. * "stateSave": true,
  9490. * "stateLoadParams": function (settings, data) {
  9491. * data.oSearch.sSearch = "";
  9492. * }
  9493. * } );
  9494. * } );
  9495. *
  9496. * @example
  9497. * // Disallow state loading by returning false
  9498. * $(document).ready( function() {
  9499. * $('#example').dataTable( {
  9500. * "stateSave": true,
  9501. * "stateLoadParams": function (settings, data) {
  9502. * return false;
  9503. * }
  9504. * } );
  9505. * } );
  9506. */
  9507. "fnStateLoadParams": null,
  9508. /**
  9509. * Callback that is called when the state has been loaded from the state saving method
  9510. * and the DataTables settings object has been modified as a result of the loaded state.
  9511. * @type function
  9512. * @param {object} settings DataTables settings object
  9513. * @param {object} data The state object that was loaded
  9514. *
  9515. * @dtopt Callbacks
  9516. * @name DataTable.defaults.stateLoaded
  9517. *
  9518. * @example
  9519. * // Show an alert with the filtering value that was saved
  9520. * $(document).ready( function() {
  9521. * $('#example').dataTable( {
  9522. * "stateSave": true,
  9523. * "stateLoaded": function (settings, data) {
  9524. * alert( 'Saved filter was: '+data.oSearch.sSearch );
  9525. * }
  9526. * } );
  9527. * } );
  9528. */
  9529. "fnStateLoaded": null,
  9530. /**
  9531. * Save the table state. This function allows you to define where and how the state
  9532. * information for the table is stored By default DataTables will use `localStorage`
  9533. * but you might wish to use a server-side database or cookies.
  9534. * @type function
  9535. * @member
  9536. * @param {object} settings DataTables settings object
  9537. * @param {object} data The state object to be saved
  9538. *
  9539. * @dtopt Callbacks
  9540. * @name DataTable.defaults.stateSaveCallback
  9541. *
  9542. * @example
  9543. * $(document).ready( function() {
  9544. * $('#example').dataTable( {
  9545. * "stateSave": true,
  9546. * "stateSaveCallback": function (settings, data) {
  9547. * // Send an Ajax request to the server with the state object
  9548. * $.ajax( {
  9549. * "url": "/state_save",
  9550. * "data": data,
  9551. * "dataType": "json",
  9552. * "method": "POST"
  9553. * "success": function () {}
  9554. * } );
  9555. * }
  9556. * } );
  9557. * } );
  9558. */
  9559. "fnStateSaveCallback": function ( settings, data ) {
  9560. try {
  9561. (settings.iStateDuration === -1 ? sessionStorage : localStorage).setItem(
  9562. 'DataTables_'+settings.sInstance+'_'+location.pathname,
  9563. JSON.stringify( data )
  9564. );
  9565. } catch (e) {}
  9566. },
  9567. /**
  9568. * Callback which allows modification of the state to be saved. Called when the table
  9569. * has changed state a new state save is required. This method allows modification of
  9570. * the state saving object prior to actually doing the save, including addition or
  9571. * other state properties or modification. Note that for plug-in authors, you should
  9572. * use the `stateSaveParams` event to save parameters for a plug-in.
  9573. * @type function
  9574. * @param {object} settings DataTables settings object
  9575. * @param {object} data The state object to be saved
  9576. *
  9577. * @dtopt Callbacks
  9578. * @name DataTable.defaults.stateSaveParams
  9579. *
  9580. * @example
  9581. * // Remove a saved filter, so filtering is never saved
  9582. * $(document).ready( function() {
  9583. * $('#example').dataTable( {
  9584. * "stateSave": true,
  9585. * "stateSaveParams": function (settings, data) {
  9586. * data.oSearch.sSearch = "";
  9587. * }
  9588. * } );
  9589. * } );
  9590. */
  9591. "fnStateSaveParams": null,
  9592. /**
  9593. * Duration for which the saved state information is considered valid. After this period
  9594. * has elapsed the state will be returned to the default.
  9595. * Value is given in seconds.
  9596. * @type int
  9597. * @default 7200 <i>(2 hours)</i>
  9598. *
  9599. * @dtopt Options
  9600. * @name DataTable.defaults.stateDuration
  9601. *
  9602. * @example
  9603. * $(document).ready( function() {
  9604. * $('#example').dataTable( {
  9605. * "stateDuration": 60*60*24; // 1 day
  9606. * } );
  9607. * } )
  9608. */
  9609. "iStateDuration": 7200,
  9610. /**
  9611. * When enabled DataTables will not make a request to the server for the first
  9612. * page draw - rather it will use the data already on the page (no sorting etc
  9613. * will be applied to it), thus saving on an XHR at load time. `deferLoading`
  9614. * is used to indicate that deferred loading is required, but it is also used
  9615. * to tell DataTables how many records there are in the full table (allowing
  9616. * the information element and pagination to be displayed correctly). In the case
  9617. * where a filtering is applied to the table on initial load, this can be
  9618. * indicated by giving the parameter as an array, where the first element is
  9619. * the number of records available after filtering and the second element is the
  9620. * number of records without filtering (allowing the table information element
  9621. * to be shown correctly).
  9622. * @type int | array
  9623. * @default null
  9624. *
  9625. * @dtopt Options
  9626. * @name DataTable.defaults.deferLoading
  9627. *
  9628. * @example
  9629. * // 57 records available in the table, no filtering applied
  9630. * $(document).ready( function() {
  9631. * $('#example').dataTable( {
  9632. * "serverSide": true,
  9633. * "ajax": "scripts/server_processing.php",
  9634. * "deferLoading": 57
  9635. * } );
  9636. * } );
  9637. *
  9638. * @example
  9639. * // 57 records after filtering, 100 without filtering (an initial filter applied)
  9640. * $(document).ready( function() {
  9641. * $('#example').dataTable( {
  9642. * "serverSide": true,
  9643. * "ajax": "scripts/server_processing.php",
  9644. * "deferLoading": [ 57, 100 ],
  9645. * "search": {
  9646. * "search": "my_filter"
  9647. * }
  9648. * } );
  9649. * } );
  9650. */
  9651. "iDeferLoading": null,
  9652. /**
  9653. * Number of rows to display on a single page when using pagination. If
  9654. * feature enabled (`lengthChange`) then the end user will be able to override
  9655. * this to a custom setting using a pop-up menu.
  9656. * @type int
  9657. * @default 10
  9658. *
  9659. * @dtopt Options
  9660. * @name DataTable.defaults.pageLength
  9661. *
  9662. * @example
  9663. * $(document).ready( function() {
  9664. * $('#example').dataTable( {
  9665. * "pageLength": 50
  9666. * } );
  9667. * } )
  9668. */
  9669. "iDisplayLength": 10,
  9670. /**
  9671. * Define the starting point for data display when using DataTables with
  9672. * pagination. Note that this parameter is the number of records, rather than
  9673. * the page number, so if you have 10 records per page and want to start on
  9674. * the third page, it should be "20".
  9675. * @type int
  9676. * @default 0
  9677. *
  9678. * @dtopt Options
  9679. * @name DataTable.defaults.displayStart
  9680. *
  9681. * @example
  9682. * $(document).ready( function() {
  9683. * $('#example').dataTable( {
  9684. * "displayStart": 20
  9685. * } );
  9686. * } )
  9687. */
  9688. "iDisplayStart": 0,
  9689. /**
  9690. * By default DataTables allows keyboard navigation of the table (sorting, paging,
  9691. * and filtering) by adding a `tabindex` attribute to the required elements. This
  9692. * allows you to tab through the controls and press the enter key to activate them.
  9693. * The tabindex is default 0, meaning that the tab follows the flow of the document.
  9694. * You can overrule this using this parameter if you wish. Use a value of -1 to
  9695. * disable built-in keyboard navigation.
  9696. * @type int
  9697. * @default 0
  9698. *
  9699. * @dtopt Options
  9700. * @name DataTable.defaults.tabIndex
  9701. *
  9702. * @example
  9703. * $(document).ready( function() {
  9704. * $('#example').dataTable( {
  9705. * "tabIndex": 1
  9706. * } );
  9707. * } );
  9708. */
  9709. "iTabIndex": 0,
  9710. /**
  9711. * Classes that DataTables assigns to the various components and features
  9712. * that it adds to the HTML table. This allows classes to be configured
  9713. * during initialisation in addition to through the static
  9714. * {@link DataTable.ext.oStdClasses} object).
  9715. * @namespace
  9716. * @name DataTable.defaults.classes
  9717. */
  9718. "oClasses": {},
  9719. /**
  9720. * All strings that DataTables uses in the user interface that it creates
  9721. * are defined in this object, allowing you to modified them individually or
  9722. * completely replace them all as required.
  9723. * @namespace
  9724. * @name DataTable.defaults.language
  9725. */
  9726. "oLanguage": {
  9727. /**
  9728. * Strings that are used for WAI-ARIA labels and controls only (these are not
  9729. * actually visible on the page, but will be read by screenreaders, and thus
  9730. * must be internationalised as well).
  9731. * @namespace
  9732. * @name DataTable.defaults.language.aria
  9733. */
  9734. "oAria": {
  9735. /**
  9736. * ARIA label that is added to the table headers when the column may be
  9737. * sorted ascending by activing the column (click or return when focused).
  9738. * Note that the column header is prefixed to this string.
  9739. * @type string
  9740. * @default : activate to sort column ascending
  9741. *
  9742. * @dtopt Language
  9743. * @name DataTable.defaults.language.aria.sortAscending
  9744. *
  9745. * @example
  9746. * $(document).ready( function() {
  9747. * $('#example').dataTable( {
  9748. * "language": {
  9749. * "aria": {
  9750. * "sortAscending": " - click/return to sort ascending"
  9751. * }
  9752. * }
  9753. * } );
  9754. * } );
  9755. */
  9756. "sSortAscending": ": activate to sort column ascending",
  9757. /**
  9758. * ARIA label that is added to the table headers when the column may be
  9759. * sorted descending by activing the column (click or return when focused).
  9760. * Note that the column header is prefixed to this string.
  9761. * @type string
  9762. * @default : activate to sort column ascending
  9763. *
  9764. * @dtopt Language
  9765. * @name DataTable.defaults.language.aria.sortDescending
  9766. *
  9767. * @example
  9768. * $(document).ready( function() {
  9769. * $('#example').dataTable( {
  9770. * "language": {
  9771. * "aria": {
  9772. * "sortDescending": " - click/return to sort descending"
  9773. * }
  9774. * }
  9775. * } );
  9776. * } );
  9777. */
  9778. "sSortDescending": ": activate to sort column descending"
  9779. },
  9780. /**
  9781. * Pagination string used by DataTables for the built-in pagination
  9782. * control types.
  9783. * @namespace
  9784. * @name DataTable.defaults.language.paginate
  9785. */
  9786. "oPaginate": {
  9787. /**
  9788. * Text to use when using the 'full_numbers' type of pagination for the
  9789. * button to take the user to the first page.
  9790. * @type string
  9791. * @default First
  9792. *
  9793. * @dtopt Language
  9794. * @name DataTable.defaults.language.paginate.first
  9795. *
  9796. * @example
  9797. * $(document).ready( function() {
  9798. * $('#example').dataTable( {
  9799. * "language": {
  9800. * "paginate": {
  9801. * "first": "First page"
  9802. * }
  9803. * }
  9804. * } );
  9805. * } );
  9806. */
  9807. "sFirst": "First",
  9808. /**
  9809. * Text to use when using the 'full_numbers' type of pagination for the
  9810. * button to take the user to the last page.
  9811. * @type string
  9812. * @default Last
  9813. *
  9814. * @dtopt Language
  9815. * @name DataTable.defaults.language.paginate.last
  9816. *
  9817. * @example
  9818. * $(document).ready( function() {
  9819. * $('#example').dataTable( {
  9820. * "language": {
  9821. * "paginate": {
  9822. * "last": "Last page"
  9823. * }
  9824. * }
  9825. * } );
  9826. * } );
  9827. */
  9828. "sLast": "Last",
  9829. /**
  9830. * Text to use for the 'next' pagination button (to take the user to the
  9831. * next page).
  9832. * @type string
  9833. * @default Next
  9834. *
  9835. * @dtopt Language
  9836. * @name DataTable.defaults.language.paginate.next
  9837. *
  9838. * @example
  9839. * $(document).ready( function() {
  9840. * $('#example').dataTable( {
  9841. * "language": {
  9842. * "paginate": {
  9843. * "next": "Next page"
  9844. * }
  9845. * }
  9846. * } );
  9847. * } );
  9848. */
  9849. "sNext": "Next",
  9850. /**
  9851. * Text to use for the 'previous' pagination button (to take the user to
  9852. * the previous page).
  9853. * @type string
  9854. * @default Previous
  9855. *
  9856. * @dtopt Language
  9857. * @name DataTable.defaults.language.paginate.previous
  9858. *
  9859. * @example
  9860. * $(document).ready( function() {
  9861. * $('#example').dataTable( {
  9862. * "language": {
  9863. * "paginate": {
  9864. * "previous": "Previous page"
  9865. * }
  9866. * }
  9867. * } );
  9868. * } );
  9869. */
  9870. "sPrevious": "Previous"
  9871. },
  9872. /**
  9873. * This string is shown in preference to `zeroRecords` when the table is
  9874. * empty of data (regardless of filtering). Note that this is an optional
  9875. * parameter - if it is not given, the value of `zeroRecords` will be used
  9876. * instead (either the default or given value).
  9877. * @type string
  9878. * @default No data available in table
  9879. *
  9880. * @dtopt Language
  9881. * @name DataTable.defaults.language.emptyTable
  9882. *
  9883. * @example
  9884. * $(document).ready( function() {
  9885. * $('#example').dataTable( {
  9886. * "language": {
  9887. * "emptyTable": "No data available in table"
  9888. * }
  9889. * } );
  9890. * } );
  9891. */
  9892. "sEmptyTable": "No data available in table",
  9893. /**
  9894. * This string gives information to the end user about the information
  9895. * that is current on display on the page. The following tokens can be
  9896. * used in the string and will be dynamically replaced as the table
  9897. * display updates. This tokens can be placed anywhere in the string, or
  9898. * removed as needed by the language requires:
  9899. *
  9900. * * `\_START\_` - Display index of the first record on the current page
  9901. * * `\_END\_` - Display index of the last record on the current page
  9902. * * `\_TOTAL\_` - Number of records in the table after filtering
  9903. * * `\_MAX\_` - Number of records in the table without filtering
  9904. * * `\_PAGE\_` - Current page number
  9905. * * `\_PAGES\_` - Total number of pages of data in the table
  9906. *
  9907. * @type string
  9908. * @default Showing _START_ to _END_ of _TOTAL_ entries
  9909. *
  9910. * @dtopt Language
  9911. * @name DataTable.defaults.language.info
  9912. *
  9913. * @example
  9914. * $(document).ready( function() {
  9915. * $('#example').dataTable( {
  9916. * "language": {
  9917. * "info": "Showing page _PAGE_ of _PAGES_"
  9918. * }
  9919. * } );
  9920. * } );
  9921. */
  9922. "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
  9923. /**
  9924. * Display information string for when the table is empty. Typically the
  9925. * format of this string should match `info`.
  9926. * @type string
  9927. * @default Showing 0 to 0 of 0 entries
  9928. *
  9929. * @dtopt Language
  9930. * @name DataTable.defaults.language.infoEmpty
  9931. *
  9932. * @example
  9933. * $(document).ready( function() {
  9934. * $('#example').dataTable( {
  9935. * "language": {
  9936. * "infoEmpty": "No entries to show"
  9937. * }
  9938. * } );
  9939. * } );
  9940. */
  9941. "sInfoEmpty": "Showing 0 to 0 of 0 entries",
  9942. /**
  9943. * When a user filters the information in a table, this string is appended
  9944. * to the information (`info`) to give an idea of how strong the filtering
  9945. * is. The variable _MAX_ is dynamically updated.
  9946. * @type string
  9947. * @default (filtered from _MAX_ total entries)
  9948. *
  9949. * @dtopt Language
  9950. * @name DataTable.defaults.language.infoFiltered
  9951. *
  9952. * @example
  9953. * $(document).ready( function() {
  9954. * $('#example').dataTable( {
  9955. * "language": {
  9956. * "infoFiltered": " - filtering from _MAX_ records"
  9957. * }
  9958. * } );
  9959. * } );
  9960. */
  9961. "sInfoFiltered": "(filtered from _MAX_ total entries)",
  9962. /**
  9963. * If can be useful to append extra information to the info string at times,
  9964. * and this variable does exactly that. This information will be appended to
  9965. * the `info` (`infoEmpty` and `infoFiltered` in whatever combination they are
  9966. * being used) at all times.
  9967. * @type string
  9968. * @default <i>Empty string</i>
  9969. *
  9970. * @dtopt Language
  9971. * @name DataTable.defaults.language.infoPostFix
  9972. *
  9973. * @example
  9974. * $(document).ready( function() {
  9975. * $('#example').dataTable( {
  9976. * "language": {
  9977. * "infoPostFix": "All records shown are derived from real information."
  9978. * }
  9979. * } );
  9980. * } );
  9981. */
  9982. "sInfoPostFix": "",
  9983. /**
  9984. * This decimal place operator is a little different from the other
  9985. * language options since DataTables doesn't output floating point
  9986. * numbers, so it won't ever use this for display of a number. Rather,
  9987. * what this parameter does is modify the sort methods of the table so
  9988. * that numbers which are in a format which has a character other than
  9989. * a period (`.`) as a decimal place will be sorted numerically.
  9990. *
  9991. * Note that numbers with different decimal places cannot be shown in
  9992. * the same table and still be sortable, the table must be consistent.
  9993. * However, multiple different tables on the page can use different
  9994. * decimal place characters.
  9995. * @type string
  9996. * @default
  9997. *
  9998. * @dtopt Language
  9999. * @name DataTable.defaults.language.decimal
  10000. *
  10001. * @example
  10002. * $(document).ready( function() {
  10003. * $('#example').dataTable( {
  10004. * "language": {
  10005. * "decimal": ","
  10006. * "thousands": "."
  10007. * }
  10008. * } );
  10009. * } );
  10010. */
  10011. "sDecimal": "",
  10012. /**
  10013. * DataTables has a build in number formatter (`formatNumber`) which is
  10014. * used to format large numbers that are used in the table information.
  10015. * By default a comma is used, but this can be trivially changed to any
  10016. * character you wish with this parameter.
  10017. * @type string
  10018. * @default ,
  10019. *
  10020. * @dtopt Language
  10021. * @name DataTable.defaults.language.thousands
  10022. *
  10023. * @example
  10024. * $(document).ready( function() {
  10025. * $('#example').dataTable( {
  10026. * "language": {
  10027. * "thousands": "'"
  10028. * }
  10029. * } );
  10030. * } );
  10031. */
  10032. "sThousands": ",",
  10033. /**
  10034. * Detail the action that will be taken when the drop down menu for the
  10035. * pagination length option is changed. The '_MENU_' variable is replaced
  10036. * with a default select list of 10, 25, 50 and 100, and can be replaced
  10037. * with a custom select box if required.
  10038. * @type string
  10039. * @default Show _MENU_ entries
  10040. *
  10041. * @dtopt Language
  10042. * @name DataTable.defaults.language.lengthMenu
  10043. *
  10044. * @example
  10045. * // Language change only
  10046. * $(document).ready( function() {
  10047. * $('#example').dataTable( {
  10048. * "language": {
  10049. * "lengthMenu": "Display _MENU_ records"
  10050. * }
  10051. * } );
  10052. * } );
  10053. *
  10054. * @example
  10055. * // Language and options change
  10056. * $(document).ready( function() {
  10057. * $('#example').dataTable( {
  10058. * "language": {
  10059. * "lengthMenu": 'Display <select>'+
  10060. * '<option value="10">10</option>'+
  10061. * '<option value="20">20</option>'+
  10062. * '<option value="30">30</option>'+
  10063. * '<option value="40">40</option>'+
  10064. * '<option value="50">50</option>'+
  10065. * '<option value="-1">All</option>'+
  10066. * '</select> records'
  10067. * }
  10068. * } );
  10069. * } );
  10070. */
  10071. "sLengthMenu": "Show _MENU_ entries",
  10072. /**
  10073. * When using Ajax sourced data and during the first draw when DataTables is
  10074. * gathering the data, this message is shown in an empty row in the table to
  10075. * indicate to the end user the the data is being loaded. Note that this
  10076. * parameter is not used when loading data by server-side processing, just
  10077. * Ajax sourced data with client-side processing.
  10078. * @type string
  10079. * @default Loading...
  10080. *
  10081. * @dtopt Language
  10082. * @name DataTable.defaults.language.loadingRecords
  10083. *
  10084. * @example
  10085. * $(document).ready( function() {
  10086. * $('#example').dataTable( {
  10087. * "language": {
  10088. * "loadingRecords": "Please wait - loading..."
  10089. * }
  10090. * } );
  10091. * } );
  10092. */
  10093. "sLoadingRecords": "Loading...",
  10094. /**
  10095. * Text which is displayed when the table is processing a user action
  10096. * (usually a sort command or similar).
  10097. * @type string
  10098. * @default Processing...
  10099. *
  10100. * @dtopt Language
  10101. * @name DataTable.defaults.language.processing
  10102. *
  10103. * @example
  10104. * $(document).ready( function() {
  10105. * $('#example').dataTable( {
  10106. * "language": {
  10107. * "processing": "DataTables is currently busy"
  10108. * }
  10109. * } );
  10110. * } );
  10111. */
  10112. "sProcessing": "Processing...",
  10113. /**
  10114. * Details the actions that will be taken when the user types into the
  10115. * filtering input text box. The variable "_INPUT_", if used in the string,
  10116. * is replaced with the HTML text box for the filtering input allowing
  10117. * control over where it appears in the string. If "_INPUT_" is not given
  10118. * then the input box is appended to the string automatically.
  10119. * @type string
  10120. * @default Search:
  10121. *
  10122. * @dtopt Language
  10123. * @name DataTable.defaults.language.search
  10124. *
  10125. * @example
  10126. * // Input text box will be appended at the end automatically
  10127. * $(document).ready( function() {
  10128. * $('#example').dataTable( {
  10129. * "language": {
  10130. * "search": "Filter records:"
  10131. * }
  10132. * } );
  10133. * } );
  10134. *
  10135. * @example
  10136. * // Specify where the filter should appear
  10137. * $(document).ready( function() {
  10138. * $('#example').dataTable( {
  10139. * "language": {
  10140. * "search": "Apply filter _INPUT_ to table"
  10141. * }
  10142. * } );
  10143. * } );
  10144. */
  10145. "sSearch": "Search:",
  10146. /**
  10147. * Assign a `placeholder` attribute to the search `input` element
  10148. * @type string
  10149. * @default
  10150. *
  10151. * @dtopt Language
  10152. * @name DataTable.defaults.language.searchPlaceholder
  10153. */
  10154. "sSearchPlaceholder": "",
  10155. /**
  10156. * All of the language information can be stored in a file on the
  10157. * server-side, which DataTables will look up if this parameter is passed.
  10158. * It must store the URL of the language file, which is in a JSON format,
  10159. * and the object has the same properties as the oLanguage object in the
  10160. * initialiser object (i.e. the above parameters). Please refer to one of
  10161. * the example language files to see how this works in action.
  10162. * @type string
  10163. * @default <i>Empty string - i.e. disabled</i>
  10164. *
  10165. * @dtopt Language
  10166. * @name DataTable.defaults.language.url
  10167. *
  10168. * @example
  10169. * $(document).ready( function() {
  10170. * $('#example').dataTable( {
  10171. * "language": {
  10172. * "url": "http://www.sprymedia.co.uk/dataTables/lang.txt"
  10173. * }
  10174. * } );
  10175. * } );
  10176. */
  10177. "sUrl": "",
  10178. /**
  10179. * Text shown inside the table records when the is no information to be
  10180. * displayed after filtering. `emptyTable` is shown when there is simply no
  10181. * information in the table at all (regardless of filtering).
  10182. * @type string
  10183. * @default No matching records found
  10184. *
  10185. * @dtopt Language
  10186. * @name DataTable.defaults.language.zeroRecords
  10187. *
  10188. * @example
  10189. * $(document).ready( function() {
  10190. * $('#example').dataTable( {
  10191. * "language": {
  10192. * "zeroRecords": "No records to display"
  10193. * }
  10194. * } );
  10195. * } );
  10196. */
  10197. "sZeroRecords": "No matching records found"
  10198. },
  10199. /**
  10200. * This parameter allows you to have define the global filtering state at
  10201. * initialisation time. As an object the `search` parameter must be
  10202. * defined, but all other parameters are optional. When `regex` is true,
  10203. * the search string will be treated as a regular expression, when false
  10204. * (default) it will be treated as a straight string. When `smart`
  10205. * DataTables will use it's smart filtering methods (to word match at
  10206. * any point in the data), when false this will not be done.
  10207. * @namespace
  10208. * @extends DataTable.models.oSearch
  10209. *
  10210. * @dtopt Options
  10211. * @name DataTable.defaults.search
  10212. *
  10213. * @example
  10214. * $(document).ready( function() {
  10215. * $('#example').dataTable( {
  10216. * "search": {"search": "Initial search"}
  10217. * } );
  10218. * } )
  10219. */
  10220. "oSearch": $.extend( {}, DataTable.models.oSearch ),
  10221. /**
  10222. * __Deprecated__ The functionality provided by this parameter has now been
  10223. * superseded by that provided through `ajax`, which should be used instead.
  10224. *
  10225. * By default DataTables will look for the property `data` (or `aaData` for
  10226. * compatibility with DataTables 1.9-) when obtaining data from an Ajax
  10227. * source or for server-side processing - this parameter allows that
  10228. * property to be changed. You can use Javascript dotted object notation to
  10229. * get a data source for multiple levels of nesting.
  10230. * @type string
  10231. * @default data
  10232. *
  10233. * @dtopt Options
  10234. * @dtopt Server-side
  10235. * @name DataTable.defaults.ajaxDataProp
  10236. *
  10237. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10238. */
  10239. "sAjaxDataProp": "data",
  10240. /**
  10241. * __Deprecated__ The functionality provided by this parameter has now been
  10242. * superseded by that provided through `ajax`, which should be used instead.
  10243. *
  10244. * You can instruct DataTables to load data from an external
  10245. * source using this parameter (use aData if you want to pass data in you
  10246. * already have). Simply provide a url a JSON object can be obtained from.
  10247. * @type string
  10248. * @default null
  10249. *
  10250. * @dtopt Options
  10251. * @dtopt Server-side
  10252. * @name DataTable.defaults.ajaxSource
  10253. *
  10254. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10255. */
  10256. "sAjaxSource": null,
  10257. /**
  10258. * This initialisation variable allows you to specify exactly where in the
  10259. * DOM you want DataTables to inject the various controls it adds to the page
  10260. * (for example you might want the pagination controls at the top of the
  10261. * table). DIV elements (with or without a custom class) can also be added to
  10262. * aid styling. The follow syntax is used:
  10263. * <ul>
  10264. * <li>The following options are allowed:
  10265. * <ul>
  10266. * <li>'l' - Length changing</li>
  10267. * <li>'f' - Filtering input</li>
  10268. * <li>'t' - The table!</li>
  10269. * <li>'i' - Information</li>
  10270. * <li>'p' - Pagination</li>
  10271. * <li>'r' - pRocessing</li>
  10272. * </ul>
  10273. * </li>
  10274. * <li>The following constants are allowed:
  10275. * <ul>
  10276. * <li>'H' - jQueryUI theme "header" classes ('fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix')</li>
  10277. * <li>'F' - jQueryUI theme "footer" classes ('fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix')</li>
  10278. * </ul>
  10279. * </li>
  10280. * <li>The following syntax is expected:
  10281. * <ul>
  10282. * <li>'&lt;' and '&gt;' - div elements</li>
  10283. * <li>'&lt;"class" and '&gt;' - div with a class</li>
  10284. * <li>'&lt;"#id" and '&gt;' - div with an ID</li>
  10285. * </ul>
  10286. * </li>
  10287. * <li>Examples:
  10288. * <ul>
  10289. * <li>'&lt;"wrapper"flipt&gt;'</li>
  10290. * <li>'&lt;lf&lt;t&gt;ip&gt;'</li>
  10291. * </ul>
  10292. * </li>
  10293. * </ul>
  10294. * @type string
  10295. * @default lfrtip <i>(when `jQueryUI` is false)</i> <b>or</b>
  10296. * <"H"lfr>t<"F"ip> <i>(when `jQueryUI` is true)</i>
  10297. *
  10298. * @dtopt Options
  10299. * @name DataTable.defaults.dom
  10300. *
  10301. * @example
  10302. * $(document).ready( function() {
  10303. * $('#example').dataTable( {
  10304. * "dom": '&lt;"top"i&gt;rt&lt;"bottom"flp&gt;&lt;"clear"&gt;'
  10305. * } );
  10306. * } );
  10307. */
  10308. "sDom": "lfrtip",
  10309. /**
  10310. * Search delay option. This will throttle full table searches that use the
  10311. * DataTables provided search input element (it does not effect calls to
  10312. * `dt-api search()`, providing a delay before the search is made.
  10313. * @type integer
  10314. * @default 0
  10315. *
  10316. * @dtopt Options
  10317. * @name DataTable.defaults.searchDelay
  10318. *
  10319. * @example
  10320. * $(document).ready( function() {
  10321. * $('#example').dataTable( {
  10322. * "searchDelay": 200
  10323. * } );
  10324. * } )
  10325. */
  10326. "searchDelay": null,
  10327. /**
  10328. * DataTables features six different built-in options for the buttons to
  10329. * display for pagination control:
  10330. *
  10331. * * `numbers` - Page number buttons only
  10332. * * `simple` - 'Previous' and 'Next' buttons only
  10333. * * 'simple_numbers` - 'Previous' and 'Next' buttons, plus page numbers
  10334. * * `full` - 'First', 'Previous', 'Next' and 'Last' buttons
  10335. * * `full_numbers` - 'First', 'Previous', 'Next' and 'Last' buttons, plus page numbers
  10336. * * `first_last_numbers` - 'First' and 'Last' buttons, plus page numbers
  10337. *
  10338. * Further methods can be added using {@link DataTable.ext.oPagination}.
  10339. * @type string
  10340. * @default simple_numbers
  10341. *
  10342. * @dtopt Options
  10343. * @name DataTable.defaults.pagingType
  10344. *
  10345. * @example
  10346. * $(document).ready( function() {
  10347. * $('#example').dataTable( {
  10348. * "pagingType": "full_numbers"
  10349. * } );
  10350. * } )
  10351. */
  10352. "sPaginationType": "simple_numbers",
  10353. /**
  10354. * Enable horizontal scrolling. When a table is too wide to fit into a
  10355. * certain layout, or you have a large number of columns in the table, you
  10356. * can enable x-scrolling to show the table in a viewport, which can be
  10357. * scrolled. This property can be `true` which will allow the table to
  10358. * scroll horizontally when needed, or any CSS unit, or a number (in which
  10359. * case it will be treated as a pixel measurement). Setting as simply `true`
  10360. * is recommended.
  10361. * @type boolean|string
  10362. * @default <i>blank string - i.e. disabled</i>
  10363. *
  10364. * @dtopt Features
  10365. * @name DataTable.defaults.scrollX
  10366. *
  10367. * @example
  10368. * $(document).ready( function() {
  10369. * $('#example').dataTable( {
  10370. * "scrollX": true,
  10371. * "scrollCollapse": true
  10372. * } );
  10373. * } );
  10374. */
  10375. "sScrollX": "",
  10376. /**
  10377. * This property can be used to force a DataTable to use more width than it
  10378. * might otherwise do when x-scrolling is enabled. For example if you have a
  10379. * table which requires to be well spaced, this parameter is useful for
  10380. * "over-sizing" the table, and thus forcing scrolling. This property can by
  10381. * any CSS unit, or a number (in which case it will be treated as a pixel
  10382. * measurement).
  10383. * @type string
  10384. * @default <i>blank string - i.e. disabled</i>
  10385. *
  10386. * @dtopt Options
  10387. * @name DataTable.defaults.scrollXInner
  10388. *
  10389. * @example
  10390. * $(document).ready( function() {
  10391. * $('#example').dataTable( {
  10392. * "scrollX": "100%",
  10393. * "scrollXInner": "110%"
  10394. * } );
  10395. * } );
  10396. */
  10397. "sScrollXInner": "",
  10398. /**
  10399. * Enable vertical scrolling. Vertical scrolling will constrain the DataTable
  10400. * to the given height, and enable scrolling for any data which overflows the
  10401. * current viewport. This can be used as an alternative to paging to display
  10402. * a lot of data in a small area (although paging and scrolling can both be
  10403. * enabled at the same time). This property can be any CSS unit, or a number
  10404. * (in which case it will be treated as a pixel measurement).
  10405. * @type string
  10406. * @default <i>blank string - i.e. disabled</i>
  10407. *
  10408. * @dtopt Features
  10409. * @name DataTable.defaults.scrollY
  10410. *
  10411. * @example
  10412. * $(document).ready( function() {
  10413. * $('#example').dataTable( {
  10414. * "scrollY": "200px",
  10415. * "paginate": false
  10416. * } );
  10417. * } );
  10418. */
  10419. "sScrollY": "",
  10420. /**
  10421. * __Deprecated__ The functionality provided by this parameter has now been
  10422. * superseded by that provided through `ajax`, which should be used instead.
  10423. *
  10424. * Set the HTTP method that is used to make the Ajax call for server-side
  10425. * processing or Ajax sourced data.
  10426. * @type string
  10427. * @default GET
  10428. *
  10429. * @dtopt Options
  10430. * @dtopt Server-side
  10431. * @name DataTable.defaults.serverMethod
  10432. *
  10433. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10434. */
  10435. "sServerMethod": "GET",
  10436. /**
  10437. * DataTables makes use of renderers when displaying HTML elements for
  10438. * a table. These renderers can be added or modified by plug-ins to
  10439. * generate suitable mark-up for a site. For example the Bootstrap
  10440. * integration plug-in for DataTables uses a paging button renderer to
  10441. * display pagination buttons in the mark-up required by Bootstrap.
  10442. *
  10443. * For further information about the renderers available see
  10444. * DataTable.ext.renderer
  10445. * @type string|object
  10446. * @default null
  10447. *
  10448. * @name DataTable.defaults.renderer
  10449. *
  10450. */
  10451. "renderer": null,
  10452. /**
  10453. * Set the data property name that DataTables should use to get a row's id
  10454. * to set as the `id` property in the node.
  10455. * @type string
  10456. * @default DT_RowId
  10457. *
  10458. * @name DataTable.defaults.rowId
  10459. */
  10460. "rowId": "DT_RowId"
  10461. };
  10462. _fnHungarianMap( DataTable.defaults );
  10463. /*
  10464. * Developer note - See note in model.defaults.js about the use of Hungarian
  10465. * notation and camel case.
  10466. */
  10467. /**
  10468. * Column options that can be given to DataTables at initialisation time.
  10469. * @namespace
  10470. */
  10471. DataTable.defaults.column = {
  10472. /**
  10473. * Define which column(s) an order will occur on for this column. This
  10474. * allows a column's ordering to take multiple columns into account when
  10475. * doing a sort or use the data from a different column. For example first
  10476. * name / last name columns make sense to do a multi-column sort over the
  10477. * two columns.
  10478. * @type array|int
  10479. * @default null <i>Takes the value of the column index automatically</i>
  10480. *
  10481. * @name DataTable.defaults.column.orderData
  10482. * @dtopt Columns
  10483. *
  10484. * @example
  10485. * // Using `columnDefs`
  10486. * $(document).ready( function() {
  10487. * $('#example').dataTable( {
  10488. * "columnDefs": [
  10489. * { "orderData": [ 0, 1 ], "targets": [ 0 ] },
  10490. * { "orderData": [ 1, 0 ], "targets": [ 1 ] },
  10491. * { "orderData": 2, "targets": [ 2 ] }
  10492. * ]
  10493. * } );
  10494. * } );
  10495. *
  10496. * @example
  10497. * // Using `columns`
  10498. * $(document).ready( function() {
  10499. * $('#example').dataTable( {
  10500. * "columns": [
  10501. * { "orderData": [ 0, 1 ] },
  10502. * { "orderData": [ 1, 0 ] },
  10503. * { "orderData": 2 },
  10504. * null,
  10505. * null
  10506. * ]
  10507. * } );
  10508. * } );
  10509. */
  10510. "aDataSort": null,
  10511. "iDataSort": -1,
  10512. /**
  10513. * You can control the default ordering direction, and even alter the
  10514. * behaviour of the sort handler (i.e. only allow ascending ordering etc)
  10515. * using this parameter.
  10516. * @type array
  10517. * @default [ 'asc', 'desc' ]
  10518. *
  10519. * @name DataTable.defaults.column.orderSequence
  10520. * @dtopt Columns
  10521. *
  10522. * @example
  10523. * // Using `columnDefs`
  10524. * $(document).ready( function() {
  10525. * $('#example').dataTable( {
  10526. * "columnDefs": [
  10527. * { "orderSequence": [ "asc" ], "targets": [ 1 ] },
  10528. * { "orderSequence": [ "desc", "asc", "asc" ], "targets": [ 2 ] },
  10529. * { "orderSequence": [ "desc" ], "targets": [ 3 ] }
  10530. * ]
  10531. * } );
  10532. * } );
  10533. *
  10534. * @example
  10535. * // Using `columns`
  10536. * $(document).ready( function() {
  10537. * $('#example').dataTable( {
  10538. * "columns": [
  10539. * null,
  10540. * { "orderSequence": [ "asc" ] },
  10541. * { "orderSequence": [ "desc", "asc", "asc" ] },
  10542. * { "orderSequence": [ "desc" ] },
  10543. * null
  10544. * ]
  10545. * } );
  10546. * } );
  10547. */
  10548. "asSorting": [ 'asc', 'desc' ],
  10549. /**
  10550. * Enable or disable filtering on the data in this column.
  10551. * @type boolean
  10552. * @default true
  10553. *
  10554. * @name DataTable.defaults.column.searchable
  10555. * @dtopt Columns
  10556. *
  10557. * @example
  10558. * // Using `columnDefs`
  10559. * $(document).ready( function() {
  10560. * $('#example').dataTable( {
  10561. * "columnDefs": [
  10562. * { "searchable": false, "targets": [ 0 ] }
  10563. * ] } );
  10564. * } );
  10565. *
  10566. * @example
  10567. * // Using `columns`
  10568. * $(document).ready( function() {
  10569. * $('#example').dataTable( {
  10570. * "columns": [
  10571. * { "searchable": false },
  10572. * null,
  10573. * null,
  10574. * null,
  10575. * null
  10576. * ] } );
  10577. * } );
  10578. */
  10579. "bSearchable": true,
  10580. /**
  10581. * Enable or disable ordering on this column.
  10582. * @type boolean
  10583. * @default true
  10584. *
  10585. * @name DataTable.defaults.column.orderable
  10586. * @dtopt Columns
  10587. *
  10588. * @example
  10589. * // Using `columnDefs`
  10590. * $(document).ready( function() {
  10591. * $('#example').dataTable( {
  10592. * "columnDefs": [
  10593. * { "orderable": false, "targets": [ 0 ] }
  10594. * ] } );
  10595. * } );
  10596. *
  10597. * @example
  10598. * // Using `columns`
  10599. * $(document).ready( function() {
  10600. * $('#example').dataTable( {
  10601. * "columns": [
  10602. * { "orderable": false },
  10603. * null,
  10604. * null,
  10605. * null,
  10606. * null
  10607. * ] } );
  10608. * } );
  10609. */
  10610. "bSortable": true,
  10611. /**
  10612. * Enable or disable the display of this column.
  10613. * @type boolean
  10614. * @default true
  10615. *
  10616. * @name DataTable.defaults.column.visible
  10617. * @dtopt Columns
  10618. *
  10619. * @example
  10620. * // Using `columnDefs`
  10621. * $(document).ready( function() {
  10622. * $('#example').dataTable( {
  10623. * "columnDefs": [
  10624. * { "visible": false, "targets": [ 0 ] }
  10625. * ] } );
  10626. * } );
  10627. *
  10628. * @example
  10629. * // Using `columns`
  10630. * $(document).ready( function() {
  10631. * $('#example').dataTable( {
  10632. * "columns": [
  10633. * { "visible": false },
  10634. * null,
  10635. * null,
  10636. * null,
  10637. * null
  10638. * ] } );
  10639. * } );
  10640. */
  10641. "bVisible": true,
  10642. /**
  10643. * Developer definable function that is called whenever a cell is created (Ajax source,
  10644. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  10645. * allowing you to modify the DOM element (add background colour for example) when the
  10646. * element is available.
  10647. * @type function
  10648. * @param {element} td The TD node that has been created
  10649. * @param {*} cellData The Data for the cell
  10650. * @param {array|object} rowData The data for the whole row
  10651. * @param {int} row The row index for the aoData data store
  10652. * @param {int} col The column index for aoColumns
  10653. *
  10654. * @name DataTable.defaults.column.createdCell
  10655. * @dtopt Columns
  10656. *
  10657. * @example
  10658. * $(document).ready( function() {
  10659. * $('#example').dataTable( {
  10660. * "columnDefs": [ {
  10661. * "targets": [3],
  10662. * "createdCell": function (td, cellData, rowData, row, col) {
  10663. * if ( cellData == "1.7" ) {
  10664. * $(td).css('color', 'blue')
  10665. * }
  10666. * }
  10667. * } ]
  10668. * });
  10669. * } );
  10670. */
  10671. "fnCreatedCell": null,
  10672. /**
  10673. * This parameter has been replaced by `data` in DataTables to ensure naming
  10674. * consistency. `dataProp` can still be used, as there is backwards
  10675. * compatibility in DataTables for this option, but it is strongly
  10676. * recommended that you use `data` in preference to `dataProp`.
  10677. * @name DataTable.defaults.column.dataProp
  10678. */
  10679. /**
  10680. * This property can be used to read data from any data source property,
  10681. * including deeply nested objects / properties. `data` can be given in a
  10682. * number of different ways which effect its behaviour:
  10683. *
  10684. * * `integer` - treated as an array index for the data source. This is the
  10685. * default that DataTables uses (incrementally increased for each column).
  10686. * * `string` - read an object property from the data source. There are
  10687. * three 'special' options that can be used in the string to alter how
  10688. * DataTables reads the data from the source object:
  10689. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10690. * Javascript to read from nested objects, so to can the options
  10691. * specified in `data`. For example: `browser.version` or
  10692. * `browser.name`. If your object parameter name contains a period, use
  10693. * `\\` to escape it - i.e. `first\\.name`.
  10694. * * `[]` - Array notation. DataTables can automatically combine data
  10695. * from and array source, joining the data with the characters provided
  10696. * between the two brackets. For example: `name[, ]` would provide a
  10697. * comma-space separated list from the source array. If no characters
  10698. * are provided between the brackets, the original array source is
  10699. * returned.
  10700. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10701. * execute a function of the name given. For example: `browser()` for a
  10702. * simple function on the data source, `browser.version()` for a
  10703. * function in a nested property or even `browser().version` to get an
  10704. * object property if the function called returns an object. Note that
  10705. * function notation is recommended for use in `render` rather than
  10706. * `data` as it is much simpler to use as a renderer.
  10707. * * `null` - use the original data source for the row rather than plucking
  10708. * data directly from it. This action has effects on two other
  10709. * initialisation options:
  10710. * * `defaultContent` - When null is given as the `data` option and
  10711. * `defaultContent` is specified for the column, the value defined by
  10712. * `defaultContent` will be used for the cell.
  10713. * * `render` - When null is used for the `data` option and the `render`
  10714. * option is specified for the column, the whole data source for the
  10715. * row is used for the renderer.
  10716. * * `function` - the function given will be executed whenever DataTables
  10717. * needs to set or get the data for a cell in the column. The function
  10718. * takes three parameters:
  10719. * * Parameters:
  10720. * * `{array|object}` The data source for the row
  10721. * * `{string}` The type call data requested - this will be 'set' when
  10722. * setting data or 'filter', 'display', 'type', 'sort' or undefined
  10723. * when gathering data. Note that when `undefined` is given for the
  10724. * type DataTables expects to get the raw data for the object back<
  10725. * * `{*}` Data to set when the second parameter is 'set'.
  10726. * * Return:
  10727. * * The return value from the function is not required when 'set' is
  10728. * the type of call, but otherwise the return is what will be used
  10729. * for the data requested.
  10730. *
  10731. * Note that `data` is a getter and setter option. If you just require
  10732. * formatting of data for output, you will likely want to use `render` which
  10733. * is simply a getter and thus simpler to use.
  10734. *
  10735. * Note that prior to DataTables 1.9.2 `data` was called `mDataProp`. The
  10736. * name change reflects the flexibility of this property and is consistent
  10737. * with the naming of mRender. If 'mDataProp' is given, then it will still
  10738. * be used by DataTables, as it automatically maps the old name to the new
  10739. * if required.
  10740. *
  10741. * @type string|int|function|null
  10742. * @default null <i>Use automatically calculated column index</i>
  10743. *
  10744. * @name DataTable.defaults.column.data
  10745. * @dtopt Columns
  10746. *
  10747. * @example
  10748. * // Read table data from objects
  10749. * // JSON structure for each row:
  10750. * // {
  10751. * // "engine": {value},
  10752. * // "browser": {value},
  10753. * // "platform": {value},
  10754. * // "version": {value},
  10755. * // "grade": {value}
  10756. * // }
  10757. * $(document).ready( function() {
  10758. * $('#example').dataTable( {
  10759. * "ajaxSource": "sources/objects.txt",
  10760. * "columns": [
  10761. * { "data": "engine" },
  10762. * { "data": "browser" },
  10763. * { "data": "platform" },
  10764. * { "data": "version" },
  10765. * { "data": "grade" }
  10766. * ]
  10767. * } );
  10768. * } );
  10769. *
  10770. * @example
  10771. * // Read information from deeply nested objects
  10772. * // JSON structure for each row:
  10773. * // {
  10774. * // "engine": {value},
  10775. * // "browser": {value},
  10776. * // "platform": {
  10777. * // "inner": {value}
  10778. * // },
  10779. * // "details": [
  10780. * // {value}, {value}
  10781. * // ]
  10782. * // }
  10783. * $(document).ready( function() {
  10784. * $('#example').dataTable( {
  10785. * "ajaxSource": "sources/deep.txt",
  10786. * "columns": [
  10787. * { "data": "engine" },
  10788. * { "data": "browser" },
  10789. * { "data": "platform.inner" },
  10790. * { "data": "details.0" },
  10791. * { "data": "details.1" }
  10792. * ]
  10793. * } );
  10794. * } );
  10795. *
  10796. * @example
  10797. * // Using `data` as a function to provide different information for
  10798. * // sorting, filtering and display. In this case, currency (price)
  10799. * $(document).ready( function() {
  10800. * $('#example').dataTable( {
  10801. * "columnDefs": [ {
  10802. * "targets": [ 0 ],
  10803. * "data": function ( source, type, val ) {
  10804. * if (type === 'set') {
  10805. * source.price = val;
  10806. * // Store the computed dislay and filter values for efficiency
  10807. * source.price_display = val=="" ? "" : "$"+numberFormat(val);
  10808. * source.price_filter = val=="" ? "" : "$"+numberFormat(val)+" "+val;
  10809. * return;
  10810. * }
  10811. * else if (type === 'display') {
  10812. * return source.price_display;
  10813. * }
  10814. * else if (type === 'filter') {
  10815. * return source.price_filter;
  10816. * }
  10817. * // 'sort', 'type' and undefined all just use the integer
  10818. * return source.price;
  10819. * }
  10820. * } ]
  10821. * } );
  10822. * } );
  10823. *
  10824. * @example
  10825. * // Using default content
  10826. * $(document).ready( function() {
  10827. * $('#example').dataTable( {
  10828. * "columnDefs": [ {
  10829. * "targets": [ 0 ],
  10830. * "data": null,
  10831. * "defaultContent": "Click to edit"
  10832. * } ]
  10833. * } );
  10834. * } );
  10835. *
  10836. * @example
  10837. * // Using array notation - outputting a list from an array
  10838. * $(document).ready( function() {
  10839. * $('#example').dataTable( {
  10840. * "columnDefs": [ {
  10841. * "targets": [ 0 ],
  10842. * "data": "name[, ]"
  10843. * } ]
  10844. * } );
  10845. * } );
  10846. *
  10847. */
  10848. "mData": null,
  10849. /**
  10850. * This property is the rendering partner to `data` and it is suggested that
  10851. * when you want to manipulate data for display (including filtering,
  10852. * sorting etc) without altering the underlying data for the table, use this
  10853. * property. `render` can be considered to be the the read only companion to
  10854. * `data` which is read / write (then as such more complex). Like `data`
  10855. * this option can be given in a number of different ways to effect its
  10856. * behaviour:
  10857. *
  10858. * * `integer` - treated as an array index for the data source. This is the
  10859. * default that DataTables uses (incrementally increased for each column).
  10860. * * `string` - read an object property from the data source. There are
  10861. * three 'special' options that can be used in the string to alter how
  10862. * DataTables reads the data from the source object:
  10863. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10864. * Javascript to read from nested objects, so to can the options
  10865. * specified in `data`. For example: `browser.version` or
  10866. * `browser.name`. If your object parameter name contains a period, use
  10867. * `\\` to escape it - i.e. `first\\.name`.
  10868. * * `[]` - Array notation. DataTables can automatically combine data
  10869. * from and array source, joining the data with the characters provided
  10870. * between the two brackets. For example: `name[, ]` would provide a
  10871. * comma-space separated list from the source array. If no characters
  10872. * are provided between the brackets, the original array source is
  10873. * returned.
  10874. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10875. * execute a function of the name given. For example: `browser()` for a
  10876. * simple function on the data source, `browser.version()` for a
  10877. * function in a nested property or even `browser().version` to get an
  10878. * object property if the function called returns an object.
  10879. * * `object` - use different data for the different data types requested by
  10880. * DataTables ('filter', 'display', 'type' or 'sort'). The property names
  10881. * of the object is the data type the property refers to and the value can
  10882. * defined using an integer, string or function using the same rules as
  10883. * `render` normally does. Note that an `_` option _must_ be specified.
  10884. * This is the default value to use if you haven't specified a value for
  10885. * the data type requested by DataTables.
  10886. * * `function` - the function given will be executed whenever DataTables
  10887. * needs to set or get the data for a cell in the column. The function
  10888. * takes three parameters:
  10889. * * Parameters:
  10890. * * {array|object} The data source for the row (based on `data`)
  10891. * * {string} The type call data requested - this will be 'filter',
  10892. * 'display', 'type' or 'sort'.
  10893. * * {array|object} The full data source for the row (not based on
  10894. * `data`)
  10895. * * Return:
  10896. * * The return value from the function is what will be used for the
  10897. * data requested.
  10898. *
  10899. * @type string|int|function|object|null
  10900. * @default null Use the data source value.
  10901. *
  10902. * @name DataTable.defaults.column.render
  10903. * @dtopt Columns
  10904. *
  10905. * @example
  10906. * // Create a comma separated list from an array of objects
  10907. * $(document).ready( function() {
  10908. * $('#example').dataTable( {
  10909. * "ajaxSource": "sources/deep.txt",
  10910. * "columns": [
  10911. * { "data": "engine" },
  10912. * { "data": "browser" },
  10913. * {
  10914. * "data": "platform",
  10915. * "render": "[, ].name"
  10916. * }
  10917. * ]
  10918. * } );
  10919. * } );
  10920. *
  10921. * @example
  10922. * // Execute a function to obtain data
  10923. * $(document).ready( function() {
  10924. * $('#example').dataTable( {
  10925. * "columnDefs": [ {
  10926. * "targets": [ 0 ],
  10927. * "data": null, // Use the full data source object for the renderer's source
  10928. * "render": "browserName()"
  10929. * } ]
  10930. * } );
  10931. * } );
  10932. *
  10933. * @example
  10934. * // As an object, extracting different data for the different types
  10935. * // This would be used with a data source such as:
  10936. * // { "phone": 5552368, "phone_filter": "5552368 555-2368", "phone_display": "555-2368" }
  10937. * // Here the `phone` integer is used for sorting and type detection, while `phone_filter`
  10938. * // (which has both forms) is used for filtering for if a user inputs either format, while
  10939. * // the formatted phone number is the one that is shown in the table.
  10940. * $(document).ready( function() {
  10941. * $('#example').dataTable( {
  10942. * "columnDefs": [ {
  10943. * "targets": [ 0 ],
  10944. * "data": null, // Use the full data source object for the renderer's source
  10945. * "render": {
  10946. * "_": "phone",
  10947. * "filter": "phone_filter",
  10948. * "display": "phone_display"
  10949. * }
  10950. * } ]
  10951. * } );
  10952. * } );
  10953. *
  10954. * @example
  10955. * // Use as a function to create a link from the data source
  10956. * $(document).ready( function() {
  10957. * $('#example').dataTable( {
  10958. * "columnDefs": [ {
  10959. * "targets": [ 0 ],
  10960. * "data": "download_link",
  10961. * "render": function ( data, type, full ) {
  10962. * return '<a href="'+data+'">Download</a>';
  10963. * }
  10964. * } ]
  10965. * } );
  10966. * } );
  10967. */
  10968. "mRender": null,
  10969. /**
  10970. * Change the cell type created for the column - either TD cells or TH cells. This
  10971. * can be useful as TH cells have semantic meaning in the table body, allowing them
  10972. * to act as a header for a row (you may wish to add scope='row' to the TH elements).
  10973. * @type string
  10974. * @default td
  10975. *
  10976. * @name DataTable.defaults.column.cellType
  10977. * @dtopt Columns
  10978. *
  10979. * @example
  10980. * // Make the first column use TH cells
  10981. * $(document).ready( function() {
  10982. * $('#example').dataTable( {
  10983. * "columnDefs": [ {
  10984. * "targets": [ 0 ],
  10985. * "cellType": "th"
  10986. * } ]
  10987. * } );
  10988. * } );
  10989. */
  10990. "sCellType": "td",
  10991. /**
  10992. * Class to give to each cell in this column.
  10993. * @type string
  10994. * @default <i>Empty string</i>
  10995. *
  10996. * @name DataTable.defaults.column.class
  10997. * @dtopt Columns
  10998. *
  10999. * @example
  11000. * // Using `columnDefs`
  11001. * $(document).ready( function() {
  11002. * $('#example').dataTable( {
  11003. * "columnDefs": [
  11004. * { "class": "my_class", "targets": [ 0 ] }
  11005. * ]
  11006. * } );
  11007. * } );
  11008. *
  11009. * @example
  11010. * // Using `columns`
  11011. * $(document).ready( function() {
  11012. * $('#example').dataTable( {
  11013. * "columns": [
  11014. * { "class": "my_class" },
  11015. * null,
  11016. * null,
  11017. * null,
  11018. * null
  11019. * ]
  11020. * } );
  11021. * } );
  11022. */
  11023. "sClass": "",
  11024. /**
  11025. * When DataTables calculates the column widths to assign to each column,
  11026. * it finds the longest string in each column and then constructs a
  11027. * temporary table and reads the widths from that. The problem with this
  11028. * is that "mmm" is much wider then "iiii", but the latter is a longer
  11029. * string - thus the calculation can go wrong (doing it properly and putting
  11030. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  11031. * a "work around" we provide this option. It will append its value to the
  11032. * text that is found to be the longest string for the column - i.e. padding.
  11033. * Generally you shouldn't need this!
  11034. * @type string
  11035. * @default <i>Empty string<i>
  11036. *
  11037. * @name DataTable.defaults.column.contentPadding
  11038. * @dtopt Columns
  11039. *
  11040. * @example
  11041. * // Using `columns`
  11042. * $(document).ready( function() {
  11043. * $('#example').dataTable( {
  11044. * "columns": [
  11045. * null,
  11046. * null,
  11047. * null,
  11048. * {
  11049. * "contentPadding": "mmm"
  11050. * }
  11051. * ]
  11052. * } );
  11053. * } );
  11054. */
  11055. "sContentPadding": "",
  11056. /**
  11057. * Allows a default value to be given for a column's data, and will be used
  11058. * whenever a null data source is encountered (this can be because `data`
  11059. * is set to null, or because the data source itself is null).
  11060. * @type string
  11061. * @default null
  11062. *
  11063. * @name DataTable.defaults.column.defaultContent
  11064. * @dtopt Columns
  11065. *
  11066. * @example
  11067. * // Using `columnDefs`
  11068. * $(document).ready( function() {
  11069. * $('#example').dataTable( {
  11070. * "columnDefs": [
  11071. * {
  11072. * "data": null,
  11073. * "defaultContent": "Edit",
  11074. * "targets": [ -1 ]
  11075. * }
  11076. * ]
  11077. * } );
  11078. * } );
  11079. *
  11080. * @example
  11081. * // Using `columns`
  11082. * $(document).ready( function() {
  11083. * $('#example').dataTable( {
  11084. * "columns": [
  11085. * null,
  11086. * null,
  11087. * null,
  11088. * {
  11089. * "data": null,
  11090. * "defaultContent": "Edit"
  11091. * }
  11092. * ]
  11093. * } );
  11094. * } );
  11095. */
  11096. "sDefaultContent": null,
  11097. /**
  11098. * This parameter is only used in DataTables' server-side processing. It can
  11099. * be exceptionally useful to know what columns are being displayed on the
  11100. * client side, and to map these to database fields. When defined, the names
  11101. * also allow DataTables to reorder information from the server if it comes
  11102. * back in an unexpected order (i.e. if you switch your columns around on the
  11103. * client-side, your server-side code does not also need updating).
  11104. * @type string
  11105. * @default <i>Empty string</i>
  11106. *
  11107. * @name DataTable.defaults.column.name
  11108. * @dtopt Columns
  11109. *
  11110. * @example
  11111. * // Using `columnDefs`
  11112. * $(document).ready( function() {
  11113. * $('#example').dataTable( {
  11114. * "columnDefs": [
  11115. * { "name": "engine", "targets": [ 0 ] },
  11116. * { "name": "browser", "targets": [ 1 ] },
  11117. * { "name": "platform", "targets": [ 2 ] },
  11118. * { "name": "version", "targets": [ 3 ] },
  11119. * { "name": "grade", "targets": [ 4 ] }
  11120. * ]
  11121. * } );
  11122. * } );
  11123. *
  11124. * @example
  11125. * // Using `columns`
  11126. * $(document).ready( function() {
  11127. * $('#example').dataTable( {
  11128. * "columns": [
  11129. * { "name": "engine" },
  11130. * { "name": "browser" },
  11131. * { "name": "platform" },
  11132. * { "name": "version" },
  11133. * { "name": "grade" }
  11134. * ]
  11135. * } );
  11136. * } );
  11137. */
  11138. "sName": "",
  11139. /**
  11140. * Defines a data source type for the ordering which can be used to read
  11141. * real-time information from the table (updating the internally cached
  11142. * version) prior to ordering. This allows ordering to occur on user
  11143. * editable elements such as form inputs.
  11144. * @type string
  11145. * @default std
  11146. *
  11147. * @name DataTable.defaults.column.orderDataType
  11148. * @dtopt Columns
  11149. *
  11150. * @example
  11151. * // Using `columnDefs`
  11152. * $(document).ready( function() {
  11153. * $('#example').dataTable( {
  11154. * "columnDefs": [
  11155. * { "orderDataType": "dom-text", "targets": [ 2, 3 ] },
  11156. * { "type": "numeric", "targets": [ 3 ] },
  11157. * { "orderDataType": "dom-select", "targets": [ 4 ] },
  11158. * { "orderDataType": "dom-checkbox", "targets": [ 5 ] }
  11159. * ]
  11160. * } );
  11161. * } );
  11162. *
  11163. * @example
  11164. * // Using `columns`
  11165. * $(document).ready( function() {
  11166. * $('#example').dataTable( {
  11167. * "columns": [
  11168. * null,
  11169. * null,
  11170. * { "orderDataType": "dom-text" },
  11171. * { "orderDataType": "dom-text", "type": "numeric" },
  11172. * { "orderDataType": "dom-select" },
  11173. * { "orderDataType": "dom-checkbox" }
  11174. * ]
  11175. * } );
  11176. * } );
  11177. */
  11178. "sSortDataType": "std",
  11179. /**
  11180. * The title of this column.
  11181. * @type string
  11182. * @default null <i>Derived from the 'TH' value for this column in the
  11183. * original HTML table.</i>
  11184. *
  11185. * @name DataTable.defaults.column.title
  11186. * @dtopt Columns
  11187. *
  11188. * @example
  11189. * // Using `columnDefs`
  11190. * $(document).ready( function() {
  11191. * $('#example').dataTable( {
  11192. * "columnDefs": [
  11193. * { "title": "My column title", "targets": [ 0 ] }
  11194. * ]
  11195. * } );
  11196. * } );
  11197. *
  11198. * @example
  11199. * // Using `columns`
  11200. * $(document).ready( function() {
  11201. * $('#example').dataTable( {
  11202. * "columns": [
  11203. * { "title": "My column title" },
  11204. * null,
  11205. * null,
  11206. * null,
  11207. * null
  11208. * ]
  11209. * } );
  11210. * } );
  11211. */
  11212. "sTitle": null,
  11213. /**
  11214. * The type allows you to specify how the data for this column will be
  11215. * ordered. Four types (string, numeric, date and html (which will strip
  11216. * HTML tags before ordering)) are currently available. Note that only date
  11217. * formats understood by Javascript's Date() object will be accepted as type
  11218. * date. For example: "Mar 26, 2008 5:03 PM". May take the values: 'string',
  11219. * 'numeric', 'date' or 'html' (by default). Further types can be adding
  11220. * through plug-ins.
  11221. * @type string
  11222. * @default null <i>Auto-detected from raw data</i>
  11223. *
  11224. * @name DataTable.defaults.column.type
  11225. * @dtopt Columns
  11226. *
  11227. * @example
  11228. * // Using `columnDefs`
  11229. * $(document).ready( function() {
  11230. * $('#example').dataTable( {
  11231. * "columnDefs": [
  11232. * { "type": "html", "targets": [ 0 ] }
  11233. * ]
  11234. * } );
  11235. * } );
  11236. *
  11237. * @example
  11238. * // Using `columns`
  11239. * $(document).ready( function() {
  11240. * $('#example').dataTable( {
  11241. * "columns": [
  11242. * { "type": "html" },
  11243. * null,
  11244. * null,
  11245. * null,
  11246. * null
  11247. * ]
  11248. * } );
  11249. * } );
  11250. */
  11251. "sType": null,
  11252. /**
  11253. * Defining the width of the column, this parameter may take any CSS value
  11254. * (3em, 20px etc). DataTables applies 'smart' widths to columns which have not
  11255. * been given a specific width through this interface ensuring that the table
  11256. * remains readable.
  11257. * @type string
  11258. * @default null <i>Automatic</i>
  11259. *
  11260. * @name DataTable.defaults.column.width
  11261. * @dtopt Columns
  11262. *
  11263. * @example
  11264. * // Using `columnDefs`
  11265. * $(document).ready( function() {
  11266. * $('#example').dataTable( {
  11267. * "columnDefs": [
  11268. * { "width": "20%", "targets": [ 0 ] }
  11269. * ]
  11270. * } );
  11271. * } );
  11272. *
  11273. * @example
  11274. * // Using `columns`
  11275. * $(document).ready( function() {
  11276. * $('#example').dataTable( {
  11277. * "columns": [
  11278. * { "width": "20%" },
  11279. * null,
  11280. * null,
  11281. * null,
  11282. * null
  11283. * ]
  11284. * } );
  11285. * } );
  11286. */
  11287. "sWidth": null
  11288. };
  11289. _fnHungarianMap( DataTable.defaults.column );
  11290. /**
  11291. * DataTables settings object - this holds all the information needed for a
  11292. * given table, including configuration, data and current application of the
  11293. * table options. DataTables does not have a single instance for each DataTable
  11294. * with the settings attached to that instance, but rather instances of the
  11295. * DataTable "class" are created on-the-fly as needed (typically by a
  11296. * $().dataTable() call) and the settings object is then applied to that
  11297. * instance.
  11298. *
  11299. * Note that this object is related to {@link DataTable.defaults} but this
  11300. * one is the internal data store for DataTables's cache of columns. It should
  11301. * NOT be manipulated outside of DataTables. Any configuration should be done
  11302. * through the initialisation options.
  11303. * @namespace
  11304. * @todo Really should attach the settings object to individual instances so we
  11305. * don't need to create new instances on each $().dataTable() call (if the
  11306. * table already exists). It would also save passing oSettings around and
  11307. * into every single function. However, this is a very significant
  11308. * architecture change for DataTables and will almost certainly break
  11309. * backwards compatibility with older installations. This is something that
  11310. * will be done in 2.0.
  11311. */
  11312. DataTable.models.oSettings = {
  11313. /**
  11314. * Primary features of DataTables and their enablement state.
  11315. * @namespace
  11316. */
  11317. "oFeatures": {
  11318. /**
  11319. * Flag to say if DataTables should automatically try to calculate the
  11320. * optimum table and columns widths (true) or not (false).
  11321. * Note that this parameter will be set by the initialisation routine. To
  11322. * set a default use {@link DataTable.defaults}.
  11323. * @type boolean
  11324. */
  11325. "bAutoWidth": null,
  11326. /**
  11327. * Delay the creation of TR and TD elements until they are actually
  11328. * needed by a driven page draw. This can give a significant speed
  11329. * increase for Ajax source and Javascript source data, but makes no
  11330. * difference at all fro DOM and server-side processing tables.
  11331. * Note that this parameter will be set by the initialisation routine. To
  11332. * set a default use {@link DataTable.defaults}.
  11333. * @type boolean
  11334. */
  11335. "bDeferRender": null,
  11336. /**
  11337. * Enable filtering on the table or not. Note that if this is disabled
  11338. * then there is no filtering at all on the table, including fnFilter.
  11339. * To just remove the filtering input use sDom and remove the 'f' option.
  11340. * Note that this parameter will be set by the initialisation routine. To
  11341. * set a default use {@link DataTable.defaults}.
  11342. * @type boolean
  11343. */
  11344. "bFilter": null,
  11345. /**
  11346. * Table information element (the 'Showing x of y records' div) enable
  11347. * flag.
  11348. * Note that this parameter will be set by the initialisation routine. To
  11349. * set a default use {@link DataTable.defaults}.
  11350. * @type boolean
  11351. */
  11352. "bInfo": null,
  11353. /**
  11354. * Present a user control allowing the end user to change the page size
  11355. * when pagination is enabled.
  11356. * Note that this parameter will be set by the initialisation routine. To
  11357. * set a default use {@link DataTable.defaults}.
  11358. * @type boolean
  11359. */
  11360. "bLengthChange": null,
  11361. /**
  11362. * Pagination enabled or not. Note that if this is disabled then length
  11363. * changing must also be disabled.
  11364. * Note that this parameter will be set by the initialisation routine. To
  11365. * set a default use {@link DataTable.defaults}.
  11366. * @type boolean
  11367. */
  11368. "bPaginate": null,
  11369. /**
  11370. * Processing indicator enable flag whenever DataTables is enacting a
  11371. * user request - typically an Ajax request for server-side processing.
  11372. * Note that this parameter will be set by the initialisation routine. To
  11373. * set a default use {@link DataTable.defaults}.
  11374. * @type boolean
  11375. */
  11376. "bProcessing": null,
  11377. /**
  11378. * Server-side processing enabled flag - when enabled DataTables will
  11379. * get all data from the server for every draw - there is no filtering,
  11380. * sorting or paging done on the client-side.
  11381. * Note that this parameter will be set by the initialisation routine. To
  11382. * set a default use {@link DataTable.defaults}.
  11383. * @type boolean
  11384. */
  11385. "bServerSide": null,
  11386. /**
  11387. * Sorting enablement flag.
  11388. * Note that this parameter will be set by the initialisation routine. To
  11389. * set a default use {@link DataTable.defaults}.
  11390. * @type boolean
  11391. */
  11392. "bSort": null,
  11393. /**
  11394. * Multi-column sorting
  11395. * Note that this parameter will be set by the initialisation routine. To
  11396. * set a default use {@link DataTable.defaults}.
  11397. * @type boolean
  11398. */
  11399. "bSortMulti": null,
  11400. /**
  11401. * Apply a class to the columns which are being sorted to provide a
  11402. * visual highlight or not. This can slow things down when enabled since
  11403. * there is a lot of DOM interaction.
  11404. * Note that this parameter will be set by the initialisation routine. To
  11405. * set a default use {@link DataTable.defaults}.
  11406. * @type boolean
  11407. */
  11408. "bSortClasses": null,
  11409. /**
  11410. * State saving enablement flag.
  11411. * Note that this parameter will be set by the initialisation routine. To
  11412. * set a default use {@link DataTable.defaults}.
  11413. * @type boolean
  11414. */
  11415. "bStateSave": null
  11416. },
  11417. /**
  11418. * Scrolling settings for a table.
  11419. * @namespace
  11420. */
  11421. "oScroll": {
  11422. /**
  11423. * When the table is shorter in height than sScrollY, collapse the
  11424. * table container down to the height of the table (when true).
  11425. * Note that this parameter will be set by the initialisation routine. To
  11426. * set a default use {@link DataTable.defaults}.
  11427. * @type boolean
  11428. */
  11429. "bCollapse": null,
  11430. /**
  11431. * Width of the scrollbar for the web-browser's platform. Calculated
  11432. * during table initialisation.
  11433. * @type int
  11434. * @default 0
  11435. */
  11436. "iBarWidth": 0,
  11437. /**
  11438. * Viewport width for horizontal scrolling. Horizontal scrolling is
  11439. * disabled if an empty string.
  11440. * Note that this parameter will be set by the initialisation routine. To
  11441. * set a default use {@link DataTable.defaults}.
  11442. * @type string
  11443. */
  11444. "sX": null,
  11445. /**
  11446. * Width to expand the table to when using x-scrolling. Typically you
  11447. * should not need to use this.
  11448. * Note that this parameter will be set by the initialisation routine. To
  11449. * set a default use {@link DataTable.defaults}.
  11450. * @type string
  11451. * @deprecated
  11452. */
  11453. "sXInner": null,
  11454. /**
  11455. * Viewport height for vertical scrolling. Vertical scrolling is disabled
  11456. * if an empty string.
  11457. * Note that this parameter will be set by the initialisation routine. To
  11458. * set a default use {@link DataTable.defaults}.
  11459. * @type string
  11460. */
  11461. "sY": null
  11462. },
  11463. /**
  11464. * Language information for the table.
  11465. * @namespace
  11466. * @extends DataTable.defaults.oLanguage
  11467. */
  11468. "oLanguage": {
  11469. /**
  11470. * Information callback function. See
  11471. * {@link DataTable.defaults.fnInfoCallback}
  11472. * @type function
  11473. * @default null
  11474. */
  11475. "fnInfoCallback": null
  11476. },
  11477. /**
  11478. * Browser support parameters
  11479. * @namespace
  11480. */
  11481. "oBrowser": {
  11482. /**
  11483. * Indicate if the browser incorrectly calculates width:100% inside a
  11484. * scrolling element (IE6/7)
  11485. * @type boolean
  11486. * @default false
  11487. */
  11488. "bScrollOversize": false,
  11489. /**
  11490. * Determine if the vertical scrollbar is on the right or left of the
  11491. * scrolling container - needed for rtl language layout, although not
  11492. * all browsers move the scrollbar (Safari).
  11493. * @type boolean
  11494. * @default false
  11495. */
  11496. "bScrollbarLeft": false,
  11497. /**
  11498. * Flag for if `getBoundingClientRect` is fully supported or not
  11499. * @type boolean
  11500. * @default false
  11501. */
  11502. "bBounding": false,
  11503. /**
  11504. * Browser scrollbar width
  11505. * @type integer
  11506. * @default 0
  11507. */
  11508. "barWidth": 0
  11509. },
  11510. "ajax": null,
  11511. /**
  11512. * Array referencing the nodes which are used for the features. The
  11513. * parameters of this object match what is allowed by sDom - i.e.
  11514. * <ul>
  11515. * <li>'l' - Length changing</li>
  11516. * <li>'f' - Filtering input</li>
  11517. * <li>'t' - The table!</li>
  11518. * <li>'i' - Information</li>
  11519. * <li>'p' - Pagination</li>
  11520. * <li>'r' - pRocessing</li>
  11521. * </ul>
  11522. * @type array
  11523. * @default []
  11524. */
  11525. "aanFeatures": [],
  11526. /**
  11527. * Store data information - see {@link DataTable.models.oRow} for detailed
  11528. * information.
  11529. * @type array
  11530. * @default []
  11531. */
  11532. "aoData": [],
  11533. /**
  11534. * Array of indexes which are in the current display (after filtering etc)
  11535. * @type array
  11536. * @default []
  11537. */
  11538. "aiDisplay": [],
  11539. /**
  11540. * Array of indexes for display - no filtering
  11541. * @type array
  11542. * @default []
  11543. */
  11544. "aiDisplayMaster": [],
  11545. /**
  11546. * Map of row ids to data indexes
  11547. * @type object
  11548. * @default {}
  11549. */
  11550. "aIds": {},
  11551. /**
  11552. * Store information about each column that is in use
  11553. * @type array
  11554. * @default []
  11555. */
  11556. "aoColumns": [],
  11557. /**
  11558. * Store information about the table's header
  11559. * @type array
  11560. * @default []
  11561. */
  11562. "aoHeader": [],
  11563. /**
  11564. * Store information about the table's footer
  11565. * @type array
  11566. * @default []
  11567. */
  11568. "aoFooter": [],
  11569. /**
  11570. * Store the applied global search information in case we want to force a
  11571. * research or compare the old search to a new one.
  11572. * Note that this parameter will be set by the initialisation routine. To
  11573. * set a default use {@link DataTable.defaults}.
  11574. * @namespace
  11575. * @extends DataTable.models.oSearch
  11576. */
  11577. "oPreviousSearch": {},
  11578. /**
  11579. * Store the applied search for each column - see
  11580. * {@link DataTable.models.oSearch} for the format that is used for the
  11581. * filtering information for each column.
  11582. * @type array
  11583. * @default []
  11584. */
  11585. "aoPreSearchCols": [],
  11586. /**
  11587. * Sorting that is applied to the table. Note that the inner arrays are
  11588. * used in the following manner:
  11589. * <ul>
  11590. * <li>Index 0 - column number</li>
  11591. * <li>Index 1 - current sorting direction</li>
  11592. * </ul>
  11593. * Note that this parameter will be set by the initialisation routine. To
  11594. * set a default use {@link DataTable.defaults}.
  11595. * @type array
  11596. * @todo These inner arrays should really be objects
  11597. */
  11598. "aaSorting": null,
  11599. /**
  11600. * Sorting that is always applied to the table (i.e. prefixed in front of
  11601. * aaSorting).
  11602. * Note that this parameter will be set by the initialisation routine. To
  11603. * set a default use {@link DataTable.defaults}.
  11604. * @type array
  11605. * @default []
  11606. */
  11607. "aaSortingFixed": [],
  11608. /**
  11609. * Classes to use for the striping of a table.
  11610. * Note that this parameter will be set by the initialisation routine. To
  11611. * set a default use {@link DataTable.defaults}.
  11612. * @type array
  11613. * @default []
  11614. */
  11615. "asStripeClasses": null,
  11616. /**
  11617. * If restoring a table - we should restore its striping classes as well
  11618. * @type array
  11619. * @default []
  11620. */
  11621. "asDestroyStripes": [],
  11622. /**
  11623. * If restoring a table - we should restore its width
  11624. * @type int
  11625. * @default 0
  11626. */
  11627. "sDestroyWidth": 0,
  11628. /**
  11629. * Callback functions array for every time a row is inserted (i.e. on a draw).
  11630. * @type array
  11631. * @default []
  11632. */
  11633. "aoRowCallback": [],
  11634. /**
  11635. * Callback functions for the header on each draw.
  11636. * @type array
  11637. * @default []
  11638. */
  11639. "aoHeaderCallback": [],
  11640. /**
  11641. * Callback function for the footer on each draw.
  11642. * @type array
  11643. * @default []
  11644. */
  11645. "aoFooterCallback": [],
  11646. /**
  11647. * Array of callback functions for draw callback functions
  11648. * @type array
  11649. * @default []
  11650. */
  11651. "aoDrawCallback": [],
  11652. /**
  11653. * Array of callback functions for row created function
  11654. * @type array
  11655. * @default []
  11656. */
  11657. "aoRowCreatedCallback": [],
  11658. /**
  11659. * Callback functions for just before the table is redrawn. A return of
  11660. * false will be used to cancel the draw.
  11661. * @type array
  11662. * @default []
  11663. */
  11664. "aoPreDrawCallback": [],
  11665. /**
  11666. * Callback functions for when the table has been initialised.
  11667. * @type array
  11668. * @default []
  11669. */
  11670. "aoInitComplete": [],
  11671. /**
  11672. * Callbacks for modifying the settings to be stored for state saving, prior to
  11673. * saving state.
  11674. * @type array
  11675. * @default []
  11676. */
  11677. "aoStateSaveParams": [],
  11678. /**
  11679. * Callbacks for modifying the settings that have been stored for state saving
  11680. * prior to using the stored values to restore the state.
  11681. * @type array
  11682. * @default []
  11683. */
  11684. "aoStateLoadParams": [],
  11685. /**
  11686. * Callbacks for operating on the settings object once the saved state has been
  11687. * loaded
  11688. * @type array
  11689. * @default []
  11690. */
  11691. "aoStateLoaded": [],
  11692. /**
  11693. * Cache the table ID for quick access
  11694. * @type string
  11695. * @default <i>Empty string</i>
  11696. */
  11697. "sTableId": "",
  11698. /**
  11699. * The TABLE node for the main table
  11700. * @type node
  11701. * @default null
  11702. */
  11703. "nTable": null,
  11704. /**
  11705. * Permanent ref to the thead element
  11706. * @type node
  11707. * @default null
  11708. */
  11709. "nTHead": null,
  11710. /**
  11711. * Permanent ref to the tfoot element - if it exists
  11712. * @type node
  11713. * @default null
  11714. */
  11715. "nTFoot": null,
  11716. /**
  11717. * Permanent ref to the tbody element
  11718. * @type node
  11719. * @default null
  11720. */
  11721. "nTBody": null,
  11722. /**
  11723. * Cache the wrapper node (contains all DataTables controlled elements)
  11724. * @type node
  11725. * @default null
  11726. */
  11727. "nTableWrapper": null,
  11728. /**
  11729. * Indicate if when using server-side processing the loading of data
  11730. * should be deferred until the second draw.
  11731. * Note that this parameter will be set by the initialisation routine. To
  11732. * set a default use {@link DataTable.defaults}.
  11733. * @type boolean
  11734. * @default false
  11735. */
  11736. "bDeferLoading": false,
  11737. /**
  11738. * Indicate if all required information has been read in
  11739. * @type boolean
  11740. * @default false
  11741. */
  11742. "bInitialised": false,
  11743. /**
  11744. * Information about open rows. Each object in the array has the parameters
  11745. * 'nTr' and 'nParent'
  11746. * @type array
  11747. * @default []
  11748. */
  11749. "aoOpenRows": [],
  11750. /**
  11751. * Dictate the positioning of DataTables' control elements - see
  11752. * {@link DataTable.model.oInit.sDom}.
  11753. * Note that this parameter will be set by the initialisation routine. To
  11754. * set a default use {@link DataTable.defaults}.
  11755. * @type string
  11756. * @default null
  11757. */
  11758. "sDom": null,
  11759. /**
  11760. * Search delay (in mS)
  11761. * @type integer
  11762. * @default null
  11763. */
  11764. "searchDelay": null,
  11765. /**
  11766. * Which type of pagination should be used.
  11767. * Note that this parameter will be set by the initialisation routine. To
  11768. * set a default use {@link DataTable.defaults}.
  11769. * @type string
  11770. * @default two_button
  11771. */
  11772. "sPaginationType": "two_button",
  11773. /**
  11774. * The state duration (for `stateSave`) in seconds.
  11775. * Note that this parameter will be set by the initialisation routine. To
  11776. * set a default use {@link DataTable.defaults}.
  11777. * @type int
  11778. * @default 0
  11779. */
  11780. "iStateDuration": 0,
  11781. /**
  11782. * Array of callback functions for state saving. Each array element is an
  11783. * object with the following parameters:
  11784. * <ul>
  11785. * <li>function:fn - function to call. Takes two parameters, oSettings
  11786. * and the JSON string to save that has been thus far created. Returns
  11787. * a JSON string to be inserted into a json object
  11788. * (i.e. '"param": [ 0, 1, 2]')</li>
  11789. * <li>string:sName - name of callback</li>
  11790. * </ul>
  11791. * @type array
  11792. * @default []
  11793. */
  11794. "aoStateSave": [],
  11795. /**
  11796. * Array of callback functions for state loading. Each array element is an
  11797. * object with the following parameters:
  11798. * <ul>
  11799. * <li>function:fn - function to call. Takes two parameters, oSettings
  11800. * and the object stored. May return false to cancel state loading</li>
  11801. * <li>string:sName - name of callback</li>
  11802. * </ul>
  11803. * @type array
  11804. * @default []
  11805. */
  11806. "aoStateLoad": [],
  11807. /**
  11808. * State that was saved. Useful for back reference
  11809. * @type object
  11810. * @default null
  11811. */
  11812. "oSavedState": null,
  11813. /**
  11814. * State that was loaded. Useful for back reference
  11815. * @type object
  11816. * @default null
  11817. */
  11818. "oLoadedState": null,
  11819. /**
  11820. * Source url for AJAX data for the table.
  11821. * Note that this parameter will be set by the initialisation routine. To
  11822. * set a default use {@link DataTable.defaults}.
  11823. * @type string
  11824. * @default null
  11825. */
  11826. "sAjaxSource": null,
  11827. /**
  11828. * Property from a given object from which to read the table data from. This
  11829. * can be an empty string (when not server-side processing), in which case
  11830. * it is assumed an an array is given directly.
  11831. * Note that this parameter will be set by the initialisation routine. To
  11832. * set a default use {@link DataTable.defaults}.
  11833. * @type string
  11834. */
  11835. "sAjaxDataProp": null,
  11836. /**
  11837. * The last jQuery XHR object that was used for server-side data gathering.
  11838. * This can be used for working with the XHR information in one of the
  11839. * callbacks
  11840. * @type object
  11841. * @default null
  11842. */
  11843. "jqXHR": null,
  11844. /**
  11845. * JSON returned from the server in the last Ajax request
  11846. * @type object
  11847. * @default undefined
  11848. */
  11849. "json": undefined,
  11850. /**
  11851. * Data submitted as part of the last Ajax request
  11852. * @type object
  11853. * @default undefined
  11854. */
  11855. "oAjaxData": undefined,
  11856. /**
  11857. * Function to get the server-side data.
  11858. * Note that this parameter will be set by the initialisation routine. To
  11859. * set a default use {@link DataTable.defaults}.
  11860. * @type function
  11861. */
  11862. "fnServerData": null,
  11863. /**
  11864. * Functions which are called prior to sending an Ajax request so extra
  11865. * parameters can easily be sent to the server
  11866. * @type array
  11867. * @default []
  11868. */
  11869. "aoServerParams": [],
  11870. /**
  11871. * Send the XHR HTTP method - GET or POST (could be PUT or DELETE if
  11872. * required).
  11873. * Note that this parameter will be set by the initialisation routine. To
  11874. * set a default use {@link DataTable.defaults}.
  11875. * @type string
  11876. */
  11877. "sServerMethod": null,
  11878. /**
  11879. * Format numbers for display.
  11880. * Note that this parameter will be set by the initialisation routine. To
  11881. * set a default use {@link DataTable.defaults}.
  11882. * @type function
  11883. */
  11884. "fnFormatNumber": null,
  11885. /**
  11886. * List of options that can be used for the user selectable length menu.
  11887. * Note that this parameter will be set by the initialisation routine. To
  11888. * set a default use {@link DataTable.defaults}.
  11889. * @type array
  11890. * @default []
  11891. */
  11892. "aLengthMenu": null,
  11893. /**
  11894. * Counter for the draws that the table does. Also used as a tracker for
  11895. * server-side processing
  11896. * @type int
  11897. * @default 0
  11898. */
  11899. "iDraw": 0,
  11900. /**
  11901. * Indicate if a redraw is being done - useful for Ajax
  11902. * @type boolean
  11903. * @default false
  11904. */
  11905. "bDrawing": false,
  11906. /**
  11907. * Draw index (iDraw) of the last error when parsing the returned data
  11908. * @type int
  11909. * @default -1
  11910. */
  11911. "iDrawError": -1,
  11912. /**
  11913. * Paging display length
  11914. * @type int
  11915. * @default 10
  11916. */
  11917. "_iDisplayLength": 10,
  11918. /**
  11919. * Paging start point - aiDisplay index
  11920. * @type int
  11921. * @default 0
  11922. */
  11923. "_iDisplayStart": 0,
  11924. /**
  11925. * Server-side processing - number of records in the result set
  11926. * (i.e. before filtering), Use fnRecordsTotal rather than
  11927. * this property to get the value of the number of records, regardless of
  11928. * the server-side processing setting.
  11929. * @type int
  11930. * @default 0
  11931. * @private
  11932. */
  11933. "_iRecordsTotal": 0,
  11934. /**
  11935. * Server-side processing - number of records in the current display set
  11936. * (i.e. after filtering). Use fnRecordsDisplay rather than
  11937. * this property to get the value of the number of records, regardless of
  11938. * the server-side processing setting.
  11939. * @type boolean
  11940. * @default 0
  11941. * @private
  11942. */
  11943. "_iRecordsDisplay": 0,
  11944. /**
  11945. * The classes to use for the table
  11946. * @type object
  11947. * @default {}
  11948. */
  11949. "oClasses": {},
  11950. /**
  11951. * Flag attached to the settings object so you can check in the draw
  11952. * callback if filtering has been done in the draw. Deprecated in favour of
  11953. * events.
  11954. * @type boolean
  11955. * @default false
  11956. * @deprecated
  11957. */
  11958. "bFiltered": false,
  11959. /**
  11960. * Flag attached to the settings object so you can check in the draw
  11961. * callback if sorting has been done in the draw. Deprecated in favour of
  11962. * events.
  11963. * @type boolean
  11964. * @default false
  11965. * @deprecated
  11966. */
  11967. "bSorted": false,
  11968. /**
  11969. * Indicate that if multiple rows are in the header and there is more than
  11970. * one unique cell per column, if the top one (true) or bottom one (false)
  11971. * should be used for sorting / title by DataTables.
  11972. * Note that this parameter will be set by the initialisation routine. To
  11973. * set a default use {@link DataTable.defaults}.
  11974. * @type boolean
  11975. */
  11976. "bSortCellsTop": null,
  11977. /**
  11978. * Initialisation object that is used for the table
  11979. * @type object
  11980. * @default null
  11981. */
  11982. "oInit": null,
  11983. /**
  11984. * Destroy callback functions - for plug-ins to attach themselves to the
  11985. * destroy so they can clean up markup and events.
  11986. * @type array
  11987. * @default []
  11988. */
  11989. "aoDestroyCallback": [],
  11990. /**
  11991. * Get the number of records in the current record set, before filtering
  11992. * @type function
  11993. */
  11994. "fnRecordsTotal": function ()
  11995. {
  11996. return _fnDataSource( this ) == 'ssp' ?
  11997. this._iRecordsTotal * 1 :
  11998. this.aiDisplayMaster.length;
  11999. },
  12000. /**
  12001. * Get the number of records in the current record set, after filtering
  12002. * @type function
  12003. */
  12004. "fnRecordsDisplay": function ()
  12005. {
  12006. return _fnDataSource( this ) == 'ssp' ?
  12007. this._iRecordsDisplay * 1 :
  12008. this.aiDisplay.length;
  12009. },
  12010. /**
  12011. * Get the display end point - aiDisplay index
  12012. * @type function
  12013. */
  12014. "fnDisplayEnd": function ()
  12015. {
  12016. var
  12017. len = this._iDisplayLength,
  12018. start = this._iDisplayStart,
  12019. calc = start + len,
  12020. records = this.aiDisplay.length,
  12021. features = this.oFeatures,
  12022. paginate = features.bPaginate;
  12023. if ( features.bServerSide ) {
  12024. return paginate === false || len === -1 ?
  12025. start + records :
  12026. Math.min( start+len, this._iRecordsDisplay );
  12027. }
  12028. else {
  12029. return ! paginate || calc>records || len===-1 ?
  12030. records :
  12031. calc;
  12032. }
  12033. },
  12034. /**
  12035. * The DataTables object for this table
  12036. * @type object
  12037. * @default null
  12038. */
  12039. "oInstance": null,
  12040. /**
  12041. * Unique identifier for each instance of the DataTables object. If there
  12042. * is an ID on the table node, then it takes that value, otherwise an
  12043. * incrementing internal counter is used.
  12044. * @type string
  12045. * @default null
  12046. */
  12047. "sInstance": null,
  12048. /**
  12049. * tabindex attribute value that is added to DataTables control elements, allowing
  12050. * keyboard navigation of the table and its controls.
  12051. */
  12052. "iTabIndex": 0,
  12053. /**
  12054. * DIV container for the footer scrolling table if scrolling
  12055. */
  12056. "nScrollHead": null,
  12057. /**
  12058. * DIV container for the footer scrolling table if scrolling
  12059. */
  12060. "nScrollFoot": null,
  12061. /**
  12062. * Last applied sort
  12063. * @type array
  12064. * @default []
  12065. */
  12066. "aLastSort": [],
  12067. /**
  12068. * Stored plug-in instances
  12069. * @type object
  12070. * @default {}
  12071. */
  12072. "oPlugins": {},
  12073. /**
  12074. * Function used to get a row's id from the row's data
  12075. * @type function
  12076. * @default null
  12077. */
  12078. "rowIdFn": null,
  12079. /**
  12080. * Data location where to store a row's id
  12081. * @type string
  12082. * @default null
  12083. */
  12084. "rowId": null
  12085. };
  12086. /**
  12087. * Extension object for DataTables that is used to provide all extension
  12088. * options.
  12089. *
  12090. * Note that the `DataTable.ext` object is available through
  12091. * `jQuery.fn.dataTable.ext` where it may be accessed and manipulated. It is
  12092. * also aliased to `jQuery.fn.dataTableExt` for historic reasons.
  12093. * @namespace
  12094. * @extends DataTable.models.ext
  12095. */
  12096. /**
  12097. * DataTables extensions
  12098. *
  12099. * This namespace acts as a collection area for plug-ins that can be used to
  12100. * extend DataTables capabilities. Indeed many of the build in methods
  12101. * use this method to provide their own capabilities (sorting methods for
  12102. * example).
  12103. *
  12104. * Note that this namespace is aliased to `jQuery.fn.dataTableExt` for legacy
  12105. * reasons
  12106. *
  12107. * @namespace
  12108. */
  12109. DataTable.ext = _ext = {
  12110. /**
  12111. * Buttons. For use with the Buttons extension for DataTables. This is
  12112. * defined here so other extensions can define buttons regardless of load
  12113. * order. It is _not_ used by DataTables core.
  12114. *
  12115. * @type object
  12116. * @default {}
  12117. */
  12118. buttons: {},
  12119. /**
  12120. * Element class names
  12121. *
  12122. * @type object
  12123. * @default {}
  12124. */
  12125. classes: {},
  12126. /**
  12127. * DataTables build type (expanded by the download builder)
  12128. *
  12129. * @type string
  12130. */
  12131. builder: "-source-",
  12132. /**
  12133. * Error reporting.
  12134. *
  12135. * How should DataTables report an error. Can take the value 'alert',
  12136. * 'throw', 'none' or a function.
  12137. *
  12138. * @type string|function
  12139. * @default alert
  12140. */
  12141. errMode: "alert",
  12142. /**
  12143. * Feature plug-ins.
  12144. *
  12145. * This is an array of objects which describe the feature plug-ins that are
  12146. * available to DataTables. These feature plug-ins are then available for
  12147. * use through the `dom` initialisation option.
  12148. *
  12149. * Each feature plug-in is described by an object which must have the
  12150. * following properties:
  12151. *
  12152. * * `fnInit` - function that is used to initialise the plug-in,
  12153. * * `cFeature` - a character so the feature can be enabled by the `dom`
  12154. * instillation option. This is case sensitive.
  12155. *
  12156. * The `fnInit` function has the following input parameters:
  12157. *
  12158. * 1. `{object}` DataTables settings object: see
  12159. * {@link DataTable.models.oSettings}
  12160. *
  12161. * And the following return is expected:
  12162. *
  12163. * * {node|null} The element which contains your feature. Note that the
  12164. * return may also be void if your plug-in does not require to inject any
  12165. * DOM elements into DataTables control (`dom`) - for example this might
  12166. * be useful when developing a plug-in which allows table control via
  12167. * keyboard entry
  12168. *
  12169. * @type array
  12170. *
  12171. * @example
  12172. * $.fn.dataTable.ext.features.push( {
  12173. * "fnInit": function( oSettings ) {
  12174. * return new TableTools( { "oDTSettings": oSettings } );
  12175. * },
  12176. * "cFeature": "T"
  12177. * } );
  12178. */
  12179. feature: [],
  12180. /**
  12181. * Row searching.
  12182. *
  12183. * This method of searching is complimentary to the default type based
  12184. * searching, and a lot more comprehensive as it allows you complete control
  12185. * over the searching logic. Each element in this array is a function
  12186. * (parameters described below) that is called for every row in the table,
  12187. * and your logic decides if it should be included in the searching data set
  12188. * or not.
  12189. *
  12190. * Searching functions have the following input parameters:
  12191. *
  12192. * 1. `{object}` DataTables settings object: see
  12193. * {@link DataTable.models.oSettings}
  12194. * 2. `{array|object}` Data for the row to be processed (same as the
  12195. * original format that was passed in as the data source, or an array
  12196. * from a DOM data source
  12197. * 3. `{int}` Row index ({@link DataTable.models.oSettings.aoData}), which
  12198. * can be useful to retrieve the `TR` element if you need DOM interaction.
  12199. *
  12200. * And the following return is expected:
  12201. *
  12202. * * {boolean} Include the row in the searched result set (true) or not
  12203. * (false)
  12204. *
  12205. * Note that as with the main search ability in DataTables, technically this
  12206. * is "filtering", since it is subtractive. However, for consistency in
  12207. * naming we call it searching here.
  12208. *
  12209. * @type array
  12210. * @default []
  12211. *
  12212. * @example
  12213. * // The following example shows custom search being applied to the
  12214. * // fourth column (i.e. the data[3] index) based on two input values
  12215. * // from the end-user, matching the data in a certain range.
  12216. * $.fn.dataTable.ext.search.push(
  12217. * function( settings, data, dataIndex ) {
  12218. * var min = document.getElementById('min').value * 1;
  12219. * var max = document.getElementById('max').value * 1;
  12220. * var version = data[3] == "-" ? 0 : data[3]*1;
  12221. *
  12222. * if ( min == "" && max == "" ) {
  12223. * return true;
  12224. * }
  12225. * else if ( min == "" && version < max ) {
  12226. * return true;
  12227. * }
  12228. * else if ( min < version && "" == max ) {
  12229. * return true;
  12230. * }
  12231. * else if ( min < version && version < max ) {
  12232. * return true;
  12233. * }
  12234. * return false;
  12235. * }
  12236. * );
  12237. */
  12238. search: [],
  12239. /**
  12240. * Selector extensions
  12241. *
  12242. * The `selector` option can be used to extend the options available for the
  12243. * selector modifier options (`selector-modifier` object data type) that
  12244. * each of the three built in selector types offer (row, column and cell +
  12245. * their plural counterparts). For example the Select extension uses this
  12246. * mechanism to provide an option to select only rows, columns and cells
  12247. * that have been marked as selected by the end user (`{selected: true}`),
  12248. * which can be used in conjunction with the existing built in selector
  12249. * options.
  12250. *
  12251. * Each property is an array to which functions can be pushed. The functions
  12252. * take three attributes:
  12253. *
  12254. * * Settings object for the host table
  12255. * * Options object (`selector-modifier` object type)
  12256. * * Array of selected item indexes
  12257. *
  12258. * The return is an array of the resulting item indexes after the custom
  12259. * selector has been applied.
  12260. *
  12261. * @type object
  12262. */
  12263. selector: {
  12264. cell: [],
  12265. column: [],
  12266. row: []
  12267. },
  12268. /**
  12269. * Internal functions, exposed for used in plug-ins.
  12270. *
  12271. * Please note that you should not need to use the internal methods for
  12272. * anything other than a plug-in (and even then, try to avoid if possible).
  12273. * The internal function may change between releases.
  12274. *
  12275. * @type object
  12276. * @default {}
  12277. */
  12278. internal: {},
  12279. /**
  12280. * Legacy configuration options. Enable and disable legacy options that
  12281. * are available in DataTables.
  12282. *
  12283. * @type object
  12284. */
  12285. legacy: {
  12286. /**
  12287. * Enable / disable DataTables 1.9 compatible server-side processing
  12288. * requests
  12289. *
  12290. * @type boolean
  12291. * @default null
  12292. */
  12293. ajax: null
  12294. },
  12295. /**
  12296. * Pagination plug-in methods.
  12297. *
  12298. * Each entry in this object is a function and defines which buttons should
  12299. * be shown by the pagination rendering method that is used for the table:
  12300. * {@link DataTable.ext.renderer.pageButton}. The renderer addresses how the
  12301. * buttons are displayed in the document, while the functions here tell it
  12302. * what buttons to display. This is done by returning an array of button
  12303. * descriptions (what each button will do).
  12304. *
  12305. * Pagination types (the four built in options and any additional plug-in
  12306. * options defined here) can be used through the `paginationType`
  12307. * initialisation parameter.
  12308. *
  12309. * The functions defined take two parameters:
  12310. *
  12311. * 1. `{int} page` The current page index
  12312. * 2. `{int} pages` The number of pages in the table
  12313. *
  12314. * Each function is expected to return an array where each element of the
  12315. * array can be one of:
  12316. *
  12317. * * `first` - Jump to first page when activated
  12318. * * `last` - Jump to last page when activated
  12319. * * `previous` - Show previous page when activated
  12320. * * `next` - Show next page when activated
  12321. * * `{int}` - Show page of the index given
  12322. * * `{array}` - A nested array containing the above elements to add a
  12323. * containing 'DIV' element (might be useful for styling).
  12324. *
  12325. * Note that DataTables v1.9- used this object slightly differently whereby
  12326. * an object with two functions would be defined for each plug-in. That
  12327. * ability is still supported by DataTables 1.10+ to provide backwards
  12328. * compatibility, but this option of use is now decremented and no longer
  12329. * documented in DataTables 1.10+.
  12330. *
  12331. * @type object
  12332. * @default {}
  12333. *
  12334. * @example
  12335. * // Show previous, next and current page buttons only
  12336. * $.fn.dataTableExt.oPagination.current = function ( page, pages ) {
  12337. * return [ 'previous', page, 'next' ];
  12338. * };
  12339. */
  12340. pager: {},
  12341. renderer: {
  12342. pageButton: {},
  12343. header: {}
  12344. },
  12345. /**
  12346. * Ordering plug-ins - custom data source
  12347. *
  12348. * The extension options for ordering of data available here is complimentary
  12349. * to the default type based ordering that DataTables typically uses. It
  12350. * allows much greater control over the the data that is being used to
  12351. * order a column, but is necessarily therefore more complex.
  12352. *
  12353. * This type of ordering is useful if you want to do ordering based on data
  12354. * live from the DOM (for example the contents of an 'input' element) rather
  12355. * than just the static string that DataTables knows of.
  12356. *
  12357. * The way these plug-ins work is that you create an array of the values you
  12358. * wish to be ordering for the column in question and then return that
  12359. * array. The data in the array much be in the index order of the rows in
  12360. * the table (not the currently ordering order!). Which order data gathering
  12361. * function is run here depends on the `dt-init columns.orderDataType`
  12362. * parameter that is used for the column (if any).
  12363. *
  12364. * The functions defined take two parameters:
  12365. *
  12366. * 1. `{object}` DataTables settings object: see
  12367. * {@link DataTable.models.oSettings}
  12368. * 2. `{int}` Target column index
  12369. *
  12370. * Each function is expected to return an array:
  12371. *
  12372. * * `{array}` Data for the column to be ordering upon
  12373. *
  12374. * @type array
  12375. *
  12376. * @example
  12377. * // Ordering using `input` node values
  12378. * $.fn.dataTable.ext.order['dom-text'] = function ( settings, col )
  12379. * {
  12380. * return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
  12381. * return $('input', td).val();
  12382. * } );
  12383. * }
  12384. */
  12385. order: {},
  12386. /**
  12387. * Type based plug-ins.
  12388. *
  12389. * Each column in DataTables has a type assigned to it, either by automatic
  12390. * detection or by direct assignment using the `type` option for the column.
  12391. * The type of a column will effect how it is ordering and search (plug-ins
  12392. * can also make use of the column type if required).
  12393. *
  12394. * @namespace
  12395. */
  12396. type: {
  12397. /**
  12398. * Type detection functions.
  12399. *
  12400. * The functions defined in this object are used to automatically detect
  12401. * a column's type, making initialisation of DataTables super easy, even
  12402. * when complex data is in the table.
  12403. *
  12404. * The functions defined take two parameters:
  12405. *
  12406. * 1. `{*}` Data from the column cell to be analysed
  12407. * 2. `{settings}` DataTables settings object. This can be used to
  12408. * perform context specific type detection - for example detection
  12409. * based on language settings such as using a comma for a decimal
  12410. * place. Generally speaking the options from the settings will not
  12411. * be required
  12412. *
  12413. * Each function is expected to return:
  12414. *
  12415. * * `{string|null}` Data type detected, or null if unknown (and thus
  12416. * pass it on to the other type detection functions.
  12417. *
  12418. * @type array
  12419. *
  12420. * @example
  12421. * // Currency type detection plug-in:
  12422. * $.fn.dataTable.ext.type.detect.push(
  12423. * function ( data, settings ) {
  12424. * // Check the numeric part
  12425. * if ( ! data.substring(1).match(/[0-9]/) ) {
  12426. * return null;
  12427. * }
  12428. *
  12429. * // Check prefixed by currency
  12430. * if ( data.charAt(0) == '$' || data.charAt(0) == '&pound;' ) {
  12431. * return 'currency';
  12432. * }
  12433. * return null;
  12434. * }
  12435. * );
  12436. */
  12437. detect: [],
  12438. /**
  12439. * Type based search formatting.
  12440. *
  12441. * The type based searching functions can be used to pre-format the
  12442. * data to be search on. For example, it can be used to strip HTML
  12443. * tags or to de-format telephone numbers for numeric only searching.
  12444. *
  12445. * Note that is a search is not defined for a column of a given type,
  12446. * no search formatting will be performed.
  12447. *
  12448. * Pre-processing of searching data plug-ins - When you assign the sType
  12449. * for a column (or have it automatically detected for you by DataTables
  12450. * or a type detection plug-in), you will typically be using this for
  12451. * custom sorting, but it can also be used to provide custom searching
  12452. * by allowing you to pre-processing the data and returning the data in
  12453. * the format that should be searched upon. This is done by adding
  12454. * functions this object with a parameter name which matches the sType
  12455. * for that target column. This is the corollary of <i>afnSortData</i>
  12456. * for searching data.
  12457. *
  12458. * The functions defined take a single parameter:
  12459. *
  12460. * 1. `{*}` Data from the column cell to be prepared for searching
  12461. *
  12462. * Each function is expected to return:
  12463. *
  12464. * * `{string|null}` Formatted string that will be used for the searching.
  12465. *
  12466. * @type object
  12467. * @default {}
  12468. *
  12469. * @example
  12470. * $.fn.dataTable.ext.type.search['title-numeric'] = function ( d ) {
  12471. * return d.replace(/\n/g," ").replace( /<.*?>/g, "" );
  12472. * }
  12473. */
  12474. search: {},
  12475. /**
  12476. * Type based ordering.
  12477. *
  12478. * The column type tells DataTables what ordering to apply to the table
  12479. * when a column is sorted upon. The order for each type that is defined,
  12480. * is defined by the functions available in this object.
  12481. *
  12482. * Each ordering option can be described by three properties added to
  12483. * this object:
  12484. *
  12485. * * `{type}-pre` - Pre-formatting function
  12486. * * `{type}-asc` - Ascending order function
  12487. * * `{type}-desc` - Descending order function
  12488. *
  12489. * All three can be used together, only `{type}-pre` or only
  12490. * `{type}-asc` and `{type}-desc` together. It is generally recommended
  12491. * that only `{type}-pre` is used, as this provides the optimal
  12492. * implementation in terms of speed, although the others are provided
  12493. * for compatibility with existing Javascript sort functions.
  12494. *
  12495. * `{type}-pre`: Functions defined take a single parameter:
  12496. *
  12497. * 1. `{*}` Data from the column cell to be prepared for ordering
  12498. *
  12499. * And return:
  12500. *
  12501. * * `{*}` Data to be sorted upon
  12502. *
  12503. * `{type}-asc` and `{type}-desc`: Functions are typical Javascript sort
  12504. * functions, taking two parameters:
  12505. *
  12506. * 1. `{*}` Data to compare to the second parameter
  12507. * 2. `{*}` Data to compare to the first parameter
  12508. *
  12509. * And returning:
  12510. *
  12511. * * `{*}` Ordering match: <0 if first parameter should be sorted lower
  12512. * than the second parameter, ===0 if the two parameters are equal and
  12513. * >0 if the first parameter should be sorted height than the second
  12514. * parameter.
  12515. *
  12516. * @type object
  12517. * @default {}
  12518. *
  12519. * @example
  12520. * // Numeric ordering of formatted numbers with a pre-formatter
  12521. * $.extend( $.fn.dataTable.ext.type.order, {
  12522. * "string-pre": function(x) {
  12523. * a = (a === "-" || a === "") ? 0 : a.replace( /[^\d\-\.]/g, "" );
  12524. * return parseFloat( a );
  12525. * }
  12526. * } );
  12527. *
  12528. * @example
  12529. * // Case-sensitive string ordering, with no pre-formatting method
  12530. * $.extend( $.fn.dataTable.ext.order, {
  12531. * "string-case-asc": function(x,y) {
  12532. * return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12533. * },
  12534. * "string-case-desc": function(x,y) {
  12535. * return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12536. * }
  12537. * } );
  12538. */
  12539. order: {}
  12540. },
  12541. /**
  12542. * Unique DataTables instance counter
  12543. *
  12544. * @type int
  12545. * @private
  12546. */
  12547. _unique: 0,
  12548. //
  12549. // Depreciated
  12550. // The following properties are retained for backwards compatiblity only.
  12551. // The should not be used in new projects and will be removed in a future
  12552. // version
  12553. //
  12554. /**
  12555. * Version check function.
  12556. * @type function
  12557. * @depreciated Since 1.10
  12558. */
  12559. fnVersionCheck: DataTable.fnVersionCheck,
  12560. /**
  12561. * Index for what 'this' index API functions should use
  12562. * @type int
  12563. * @deprecated Since v1.10
  12564. */
  12565. iApiIndex: 0,
  12566. /**
  12567. * jQuery UI class container
  12568. * @type object
  12569. * @deprecated Since v1.10
  12570. */
  12571. oJUIClasses: {},
  12572. /**
  12573. * Software version
  12574. * @type string
  12575. * @deprecated Since v1.10
  12576. */
  12577. sVersion: DataTable.version
  12578. };
  12579. //
  12580. // Backwards compatibility. Alias to pre 1.10 Hungarian notation counter parts
  12581. //
  12582. $.extend( _ext, {
  12583. afnFiltering: _ext.search,
  12584. aTypes: _ext.type.detect,
  12585. ofnSearch: _ext.type.search,
  12586. oSort: _ext.type.order,
  12587. afnSortData: _ext.order,
  12588. aoFeatures: _ext.feature,
  12589. oApi: _ext.internal,
  12590. oStdClasses: _ext.classes,
  12591. oPagination: _ext.pager
  12592. } );
  12593. $.extend( DataTable.ext.classes, {
  12594. "sTable": "dataTable",
  12595. "sNoFooter": "no-footer",
  12596. /* Paging buttons */
  12597. "sPageButton": "paginate_button",
  12598. "sPageButtonActive": "current",
  12599. "sPageButtonDisabled": "disabled",
  12600. /* Striping classes */
  12601. "sStripeOdd": "odd",
  12602. "sStripeEven": "even",
  12603. /* Empty row */
  12604. "sRowEmpty": "dataTables_empty",
  12605. /* Features */
  12606. "sWrapper": "dataTables_wrapper",
  12607. "sFilter": "dataTables_filter",
  12608. "sInfo": "dataTables_info",
  12609. "sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */
  12610. "sLength": "dataTables_length",
  12611. "sProcessing": "dataTables_processing",
  12612. /* Sorting */
  12613. "sSortAsc": "sorting_asc",
  12614. "sSortDesc": "sorting_desc",
  12615. "sSortable": "sorting", /* Sortable in both directions */
  12616. "sSortableAsc": "sorting_desc_disabled",
  12617. "sSortableDesc": "sorting_asc_disabled",
  12618. "sSortableNone": "sorting_disabled",
  12619. "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
  12620. /* Filtering */
  12621. "sFilterInput": "",
  12622. /* Page length */
  12623. "sLengthSelect": "",
  12624. /* Scrolling */
  12625. "sScrollWrapper": "dataTables_scroll",
  12626. "sScrollHead": "dataTables_scrollHead",
  12627. "sScrollHeadInner": "dataTables_scrollHeadInner",
  12628. "sScrollBody": "dataTables_scrollBody",
  12629. "sScrollFoot": "dataTables_scrollFoot",
  12630. "sScrollFootInner": "dataTables_scrollFootInner",
  12631. /* Misc */
  12632. "sHeaderTH": "",
  12633. "sFooterTH": "",
  12634. // Deprecated
  12635. "sSortJUIAsc": "",
  12636. "sSortJUIDesc": "",
  12637. "sSortJUI": "",
  12638. "sSortJUIAscAllowed": "",
  12639. "sSortJUIDescAllowed": "",
  12640. "sSortJUIWrapper": "",
  12641. "sSortIcon": "",
  12642. "sJUIHeader": "",
  12643. "sJUIFooter": ""
  12644. } );
  12645. var extPagination = DataTable.ext.pager;
  12646. function _numbers ( page, pages ) {
  12647. var
  12648. numbers = [],
  12649. buttons = extPagination.numbers_length,
  12650. half = Math.floor( buttons / 2 ),
  12651. i = 1;
  12652. if ( pages <= buttons ) {
  12653. numbers = _range( 0, pages );
  12654. }
  12655. else if ( page <= half ) {
  12656. numbers = _range( 0, buttons-2 );
  12657. numbers.push( 'ellipsis' );
  12658. numbers.push( pages-1 );
  12659. }
  12660. else if ( page >= pages - 1 - half ) {
  12661. numbers = _range( pages-(buttons-2), pages );
  12662. numbers.splice( 0, 0, 'ellipsis' ); // no unshift in ie6
  12663. numbers.splice( 0, 0, 0 );
  12664. }
  12665. else {
  12666. numbers = _range( page-half+2, page+half-1 );
  12667. numbers.push( 'ellipsis' );
  12668. numbers.push( pages-1 );
  12669. numbers.splice( 0, 0, 'ellipsis' );
  12670. numbers.splice( 0, 0, 0 );
  12671. }
  12672. numbers.DT_el = 'span';
  12673. return numbers;
  12674. }
  12675. $.extend( extPagination, {
  12676. simple: function ( page, pages ) {
  12677. return [ 'previous', 'next' ];
  12678. },
  12679. full: function ( page, pages ) {
  12680. return [ 'first', 'previous', 'next', 'last' ];
  12681. },
  12682. numbers: function ( page, pages ) {
  12683. return [ _numbers(page, pages) ];
  12684. },
  12685. simple_numbers: function ( page, pages ) {
  12686. return [ 'previous', _numbers(page, pages), 'next' ];
  12687. },
  12688. full_numbers: function ( page, pages ) {
  12689. return [ 'first', 'previous', _numbers(page, pages), 'next', 'last' ];
  12690. },
  12691. first_last_numbers: function (page, pages) {
  12692. return ['first', _numbers(page, pages), 'last'];
  12693. },
  12694. // For testing and plug-ins to use
  12695. _numbers: _numbers,
  12696. // Number of number buttons (including ellipsis) to show. _Must be odd!_
  12697. numbers_length: 7
  12698. } );
  12699. $.extend( true, DataTable.ext.renderer, {
  12700. pageButton: {
  12701. _: function ( settings, host, idx, buttons, page, pages ) {
  12702. var classes = settings.oClasses;
  12703. var lang = settings.oLanguage.oPaginate;
  12704. var aria = settings.oLanguage.oAria.paginate || {};
  12705. var btnDisplay, btnClass, counter=0;
  12706. var attach = function( container, buttons ) {
  12707. var i, ien, node, button, tabIndex;
  12708. var disabledClass = classes.sPageButtonDisabled;
  12709. var clickHandler = function ( e ) {
  12710. _fnPageChange( settings, e.data.action, true );
  12711. };
  12712. for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
  12713. button = buttons[i];
  12714. if ( Array.isArray( button ) ) {
  12715. var inner = $( '<'+(button.DT_el || 'div')+'/>' )
  12716. .appendTo( container );
  12717. attach( inner, button );
  12718. }
  12719. else {
  12720. btnDisplay = null;
  12721. btnClass = button;
  12722. tabIndex = settings.iTabIndex;
  12723. switch ( button ) {
  12724. case 'ellipsis':
  12725. container.append('<span class="ellipsis">&#x2026;</span>');
  12726. break;
  12727. case 'first':
  12728. btnDisplay = lang.sFirst;
  12729. if ( page === 0 ) {
  12730. tabIndex = -1;
  12731. btnClass += ' ' + disabledClass;
  12732. }
  12733. break;
  12734. case 'previous':
  12735. btnDisplay = lang.sPrevious;
  12736. if ( page === 0 ) {
  12737. tabIndex = -1;
  12738. btnClass += ' ' + disabledClass;
  12739. }
  12740. break;
  12741. case 'next':
  12742. btnDisplay = lang.sNext;
  12743. if ( pages === 0 || page === pages-1 ) {
  12744. tabIndex = -1;
  12745. btnClass += ' ' + disabledClass;
  12746. }
  12747. break;
  12748. case 'last':
  12749. btnDisplay = lang.sLast;
  12750. if ( pages === 0 || page === pages-1 ) {
  12751. tabIndex = -1;
  12752. btnClass += ' ' + disabledClass;
  12753. }
  12754. break;
  12755. default:
  12756. btnDisplay = settings.fnFormatNumber( button + 1 );
  12757. btnClass = page === button ?
  12758. classes.sPageButtonActive : '';
  12759. break;
  12760. }
  12761. if ( btnDisplay !== null ) {
  12762. node = $('<a>', {
  12763. 'class': classes.sPageButton+' '+btnClass,
  12764. 'aria-controls': settings.sTableId,
  12765. 'aria-label': aria[ button ],
  12766. 'data-dt-idx': counter,
  12767. 'tabindex': tabIndex,
  12768. 'id': idx === 0 && typeof button === 'string' ?
  12769. settings.sTableId +'_'+ button :
  12770. null
  12771. } )
  12772. .html( btnDisplay )
  12773. .appendTo( container );
  12774. _fnBindAction(
  12775. node, {action: button}, clickHandler
  12776. );
  12777. counter++;
  12778. }
  12779. }
  12780. }
  12781. };
  12782. // IE9 throws an 'unknown error' if document.activeElement is used
  12783. // inside an iframe or frame. Try / catch the error. Not good for
  12784. // accessibility, but neither are frames.
  12785. var activeEl;
  12786. try {
  12787. // Because this approach is destroying and recreating the paging
  12788. // elements, focus is lost on the select button which is bad for
  12789. // accessibility. So we want to restore focus once the draw has
  12790. // completed
  12791. activeEl = $(host).find(document.activeElement).data('dt-idx');
  12792. }
  12793. catch (e) {}
  12794. attach( $(host).empty(), buttons );
  12795. if ( activeEl !== undefined ) {
  12796. $(host).find( '[data-dt-idx='+activeEl+']' ).trigger('focus');
  12797. }
  12798. }
  12799. }
  12800. } );
  12801. // Built in type detection. See model.ext.aTypes for information about
  12802. // what is required from this methods.
  12803. $.extend( DataTable.ext.type.detect, [
  12804. // Plain numbers - first since V8 detects some plain numbers as dates
  12805. // e.g. Date.parse('55') (but not all, e.g. Date.parse('22')...).
  12806. function ( d, settings )
  12807. {
  12808. var decimal = settings.oLanguage.sDecimal;
  12809. return _isNumber( d, decimal ) ? 'num'+decimal : null;
  12810. },
  12811. // Dates (only those recognised by the browser's Date.parse)
  12812. function ( d, settings )
  12813. {
  12814. // V8 tries _very_ hard to make a string passed into `Date.parse()`
  12815. // valid, so we need to use a regex to restrict date formats. Use a
  12816. // plug-in for anything other than ISO8601 style strings
  12817. if ( d && !(d instanceof Date) && ! _re_date.test(d) ) {
  12818. return null;
  12819. }
  12820. var parsed = Date.parse(d);
  12821. return (parsed !== null && !isNaN(parsed)) || _empty(d) ? 'date' : null;
  12822. },
  12823. // Formatted numbers
  12824. function ( d, settings )
  12825. {
  12826. var decimal = settings.oLanguage.sDecimal;
  12827. return _isNumber( d, decimal, true ) ? 'num-fmt'+decimal : null;
  12828. },
  12829. // HTML numeric
  12830. function ( d, settings )
  12831. {
  12832. var decimal = settings.oLanguage.sDecimal;
  12833. return _htmlNumeric( d, decimal ) ? 'html-num'+decimal : null;
  12834. },
  12835. // HTML numeric, formatted
  12836. function ( d, settings )
  12837. {
  12838. var decimal = settings.oLanguage.sDecimal;
  12839. return _htmlNumeric( d, decimal, true ) ? 'html-num-fmt'+decimal : null;
  12840. },
  12841. // HTML (this is strict checking - there must be html)
  12842. function ( d, settings )
  12843. {
  12844. return _empty( d ) || (typeof d === 'string' && d.indexOf('<') !== -1) ?
  12845. 'html' : null;
  12846. }
  12847. ] );
  12848. // Filter formatting functions. See model.ext.ofnSearch for information about
  12849. // what is required from these methods.
  12850. //
  12851. // Note that additional search methods are added for the html numbers and
  12852. // html formatted numbers by `_addNumericSort()` when we know what the decimal
  12853. // place is
  12854. $.extend( DataTable.ext.type.search, {
  12855. html: function ( data ) {
  12856. return _empty(data) ?
  12857. data :
  12858. typeof data === 'string' ?
  12859. data
  12860. .replace( _re_new_lines, " " )
  12861. .replace( _re_html, "" ) :
  12862. '';
  12863. },
  12864. string: function ( data ) {
  12865. return _empty(data) ?
  12866. data :
  12867. typeof data === 'string' ?
  12868. data.replace( _re_new_lines, " " ) :
  12869. data;
  12870. }
  12871. } );
  12872. var __numericReplace = function ( d, decimalPlace, re1, re2 ) {
  12873. if ( d !== 0 && (!d || d === '-') ) {
  12874. return -Infinity;
  12875. }
  12876. // If a decimal place other than `.` is used, it needs to be given to the
  12877. // function so we can detect it and replace with a `.` which is the only
  12878. // decimal place Javascript recognises - it is not locale aware.
  12879. if ( decimalPlace ) {
  12880. d = _numToDecimal( d, decimalPlace );
  12881. }
  12882. if ( d.replace ) {
  12883. if ( re1 ) {
  12884. d = d.replace( re1, '' );
  12885. }
  12886. if ( re2 ) {
  12887. d = d.replace( re2, '' );
  12888. }
  12889. }
  12890. return d * 1;
  12891. };
  12892. // Add the numeric 'deformatting' functions for sorting and search. This is done
  12893. // in a function to provide an easy ability for the language options to add
  12894. // additional methods if a non-period decimal place is used.
  12895. function _addNumericSort ( decimalPlace ) {
  12896. $.each(
  12897. {
  12898. // Plain numbers
  12899. "num": function ( d ) {
  12900. return __numericReplace( d, decimalPlace );
  12901. },
  12902. // Formatted numbers
  12903. "num-fmt": function ( d ) {
  12904. return __numericReplace( d, decimalPlace, _re_formatted_numeric );
  12905. },
  12906. // HTML numeric
  12907. "html-num": function ( d ) {
  12908. return __numericReplace( d, decimalPlace, _re_html );
  12909. },
  12910. // HTML numeric, formatted
  12911. "html-num-fmt": function ( d ) {
  12912. return __numericReplace( d, decimalPlace, _re_html, _re_formatted_numeric );
  12913. }
  12914. },
  12915. function ( key, fn ) {
  12916. // Add the ordering method
  12917. _ext.type.order[ key+decimalPlace+'-pre' ] = fn;
  12918. // For HTML types add a search formatter that will strip the HTML
  12919. if ( key.match(/^html\-/) ) {
  12920. _ext.type.search[ key+decimalPlace ] = _ext.type.search.html;
  12921. }
  12922. }
  12923. );
  12924. }
  12925. // Default sort methods
  12926. $.extend( _ext.type.order, {
  12927. // Dates
  12928. "date-pre": function ( d ) {
  12929. var ts = Date.parse( d );
  12930. return isNaN(ts) ? -Infinity : ts;
  12931. },
  12932. // html
  12933. "html-pre": function ( a ) {
  12934. return _empty(a) ?
  12935. '' :
  12936. a.replace ?
  12937. a.replace( /<.*?>/g, "" ).toLowerCase() :
  12938. a+'';
  12939. },
  12940. // string
  12941. "string-pre": function ( a ) {
  12942. // This is a little complex, but faster than always calling toString,
  12943. // http://jsperf.com/tostring-v-check
  12944. return _empty(a) ?
  12945. '' :
  12946. typeof a === 'string' ?
  12947. a.toLowerCase() :
  12948. ! a.toString ?
  12949. '' :
  12950. a.toString();
  12951. },
  12952. // string-asc and -desc are retained only for compatibility with the old
  12953. // sort methods
  12954. "string-asc": function ( x, y ) {
  12955. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12956. },
  12957. "string-desc": function ( x, y ) {
  12958. return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12959. }
  12960. } );
  12961. // Numeric sorting types - order doesn't matter here
  12962. _addNumericSort( '' );
  12963. $.extend( true, DataTable.ext.renderer, {
  12964. header: {
  12965. _: function ( settings, cell, column, classes ) {
  12966. // No additional mark-up required
  12967. // Attach a sort listener to update on sort - note that using the
  12968. // `DT` namespace will allow the event to be removed automatically
  12969. // on destroy, while the `dt` namespaced event is the one we are
  12970. // listening for
  12971. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  12972. if ( settings !== ctx ) { // need to check this this is the host
  12973. return; // table, not a nested one
  12974. }
  12975. var colIdx = column.idx;
  12976. cell
  12977. .removeClass(
  12978. classes.sSortAsc +' '+
  12979. classes.sSortDesc
  12980. )
  12981. .addClass( columns[ colIdx ] == 'asc' ?
  12982. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  12983. classes.sSortDesc :
  12984. column.sSortingClass
  12985. );
  12986. } );
  12987. },
  12988. jqueryui: function ( settings, cell, column, classes ) {
  12989. $('<div/>')
  12990. .addClass( classes.sSortJUIWrapper )
  12991. .append( cell.contents() )
  12992. .append( $('<span/>')
  12993. .addClass( classes.sSortIcon+' '+column.sSortingClassJUI )
  12994. )
  12995. .appendTo( cell );
  12996. // Attach a sort listener to update on sort
  12997. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  12998. if ( settings !== ctx ) {
  12999. return;
  13000. }
  13001. var colIdx = column.idx;
  13002. cell
  13003. .removeClass( classes.sSortAsc +" "+classes.sSortDesc )
  13004. .addClass( columns[ colIdx ] == 'asc' ?
  13005. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  13006. classes.sSortDesc :
  13007. column.sSortingClass
  13008. );
  13009. cell
  13010. .find( 'span.'+classes.sSortIcon )
  13011. .removeClass(
  13012. classes.sSortJUIAsc +" "+
  13013. classes.sSortJUIDesc +" "+
  13014. classes.sSortJUI +" "+
  13015. classes.sSortJUIAscAllowed +" "+
  13016. classes.sSortJUIDescAllowed
  13017. )
  13018. .addClass( columns[ colIdx ] == 'asc' ?
  13019. classes.sSortJUIAsc : columns[ colIdx ] == 'desc' ?
  13020. classes.sSortJUIDesc :
  13021. column.sSortingClassJUI
  13022. );
  13023. } );
  13024. }
  13025. }
  13026. } );
  13027. /*
  13028. * Public helper functions. These aren't used internally by DataTables, or
  13029. * called by any of the options passed into DataTables, but they can be used
  13030. * externally by developers working with DataTables. They are helper functions
  13031. * to make working with DataTables a little bit easier.
  13032. */
  13033. var __htmlEscapeEntities = function ( d ) {
  13034. return typeof d === 'string' ?
  13035. d
  13036. .replace(/&/g, '&amp;')
  13037. .replace(/</g, '&lt;')
  13038. .replace(/>/g, '&gt;')
  13039. .replace(/"/g, '&quot;') :
  13040. d;
  13041. };
  13042. /**
  13043. * Helpers for `columns.render`.
  13044. *
  13045. * The options defined here can be used with the `columns.render` initialisation
  13046. * option to provide a display renderer. The following functions are defined:
  13047. *
  13048. * * `number` - Will format numeric data (defined by `columns.data`) for
  13049. * display, retaining the original unformatted data for sorting and filtering.
  13050. * It takes 5 parameters:
  13051. * * `string` - Thousands grouping separator
  13052. * * `string` - Decimal point indicator
  13053. * * `integer` - Number of decimal points to show
  13054. * * `string` (optional) - Prefix.
  13055. * * `string` (optional) - Postfix (/suffix).
  13056. * * `text` - Escape HTML to help prevent XSS attacks. It has no optional
  13057. * parameters.
  13058. *
  13059. * @example
  13060. * // Column definition using the number renderer
  13061. * {
  13062. * data: "salary",
  13063. * render: $.fn.dataTable.render.number( '\'', '.', 0, '$' )
  13064. * }
  13065. *
  13066. * @namespace
  13067. */
  13068. DataTable.render = {
  13069. number: function ( thousands, decimal, precision, prefix, postfix ) {
  13070. return {
  13071. display: function ( d ) {
  13072. if ( typeof d !== 'number' && typeof d !== 'string' ) {
  13073. return d;
  13074. }
  13075. var negative = d < 0 ? '-' : '';
  13076. var flo = parseFloat( d );
  13077. // If NaN then there isn't much formatting that we can do - just
  13078. // return immediately, escaping any HTML (this was supposed to
  13079. // be a number after all)
  13080. if ( isNaN( flo ) ) {
  13081. return __htmlEscapeEntities( d );
  13082. }
  13083. flo = flo.toFixed( precision );
  13084. d = Math.abs( flo );
  13085. var intPart = parseInt( d, 10 );
  13086. var floatPart = precision ?
  13087. decimal+(d - intPart).toFixed( precision ).substring( 2 ):
  13088. '';
  13089. // If zero, then can't have a negative prefix
  13090. if (intPart === 0 && parseFloat(floatPart) === 0) {
  13091. negative = '';
  13092. }
  13093. return negative + (prefix||'') +
  13094. intPart.toString().replace(
  13095. /\B(?=(\d{3})+(?!\d))/g, thousands
  13096. ) +
  13097. floatPart +
  13098. (postfix||'');
  13099. }
  13100. };
  13101. },
  13102. text: function () {
  13103. return {
  13104. display: __htmlEscapeEntities,
  13105. filter: __htmlEscapeEntities
  13106. };
  13107. }
  13108. };
  13109. /*
  13110. * This is really a good bit rubbish this method of exposing the internal methods
  13111. * publicly... - To be fixed in 2.0 using methods on the prototype
  13112. */
  13113. /**
  13114. * Create a wrapper function for exporting an internal functions to an external API.
  13115. * @param {string} fn API function name
  13116. * @returns {function} wrapped function
  13117. * @memberof DataTable#internal
  13118. */
  13119. function _fnExternApiFunc (fn)
  13120. {
  13121. return function() {
  13122. var args = [_fnSettingsFromNode( this[DataTable.ext.iApiIndex] )].concat(
  13123. Array.prototype.slice.call(arguments)
  13124. );
  13125. return DataTable.ext.internal[fn].apply( this, args );
  13126. };
  13127. }
  13128. /**
  13129. * Reference to internal functions for use by plug-in developers. Note that
  13130. * these methods are references to internal functions and are considered to be
  13131. * private. If you use these methods, be aware that they are liable to change
  13132. * between versions.
  13133. * @namespace
  13134. */
  13135. $.extend( DataTable.ext.internal, {
  13136. _fnExternApiFunc: _fnExternApiFunc,
  13137. _fnBuildAjax: _fnBuildAjax,
  13138. _fnAjaxUpdate: _fnAjaxUpdate,
  13139. _fnAjaxParameters: _fnAjaxParameters,
  13140. _fnAjaxUpdateDraw: _fnAjaxUpdateDraw,
  13141. _fnAjaxDataSrc: _fnAjaxDataSrc,
  13142. _fnAddColumn: _fnAddColumn,
  13143. _fnColumnOptions: _fnColumnOptions,
  13144. _fnAdjustColumnSizing: _fnAdjustColumnSizing,
  13145. _fnVisibleToColumnIndex: _fnVisibleToColumnIndex,
  13146. _fnColumnIndexToVisible: _fnColumnIndexToVisible,
  13147. _fnVisbleColumns: _fnVisbleColumns,
  13148. _fnGetColumns: _fnGetColumns,
  13149. _fnColumnTypes: _fnColumnTypes,
  13150. _fnApplyColumnDefs: _fnApplyColumnDefs,
  13151. _fnHungarianMap: _fnHungarianMap,
  13152. _fnCamelToHungarian: _fnCamelToHungarian,
  13153. _fnLanguageCompat: _fnLanguageCompat,
  13154. _fnBrowserDetect: _fnBrowserDetect,
  13155. _fnAddData: _fnAddData,
  13156. _fnAddTr: _fnAddTr,
  13157. _fnNodeToDataIndex: _fnNodeToDataIndex,
  13158. _fnNodeToColumnIndex: _fnNodeToColumnIndex,
  13159. _fnGetCellData: _fnGetCellData,
  13160. _fnSetCellData: _fnSetCellData,
  13161. _fnSplitObjNotation: _fnSplitObjNotation,
  13162. _fnGetObjectDataFn: _fnGetObjectDataFn,
  13163. _fnSetObjectDataFn: _fnSetObjectDataFn,
  13164. _fnGetDataMaster: _fnGetDataMaster,
  13165. _fnClearTable: _fnClearTable,
  13166. _fnDeleteIndex: _fnDeleteIndex,
  13167. _fnInvalidate: _fnInvalidate,
  13168. _fnGetRowElements: _fnGetRowElements,
  13169. _fnCreateTr: _fnCreateTr,
  13170. _fnBuildHead: _fnBuildHead,
  13171. _fnDrawHead: _fnDrawHead,
  13172. _fnDraw: _fnDraw,
  13173. _fnReDraw: _fnReDraw,
  13174. _fnAddOptionsHtml: _fnAddOptionsHtml,
  13175. _fnDetectHeader: _fnDetectHeader,
  13176. _fnGetUniqueThs: _fnGetUniqueThs,
  13177. _fnFeatureHtmlFilter: _fnFeatureHtmlFilter,
  13178. _fnFilterComplete: _fnFilterComplete,
  13179. _fnFilterCustom: _fnFilterCustom,
  13180. _fnFilterColumn: _fnFilterColumn,
  13181. _fnFilter: _fnFilter,
  13182. _fnFilterCreateSearch: _fnFilterCreateSearch,
  13183. _fnEscapeRegex: _fnEscapeRegex,
  13184. _fnFilterData: _fnFilterData,
  13185. _fnFeatureHtmlInfo: _fnFeatureHtmlInfo,
  13186. _fnUpdateInfo: _fnUpdateInfo,
  13187. _fnInfoMacros: _fnInfoMacros,
  13188. _fnInitialise: _fnInitialise,
  13189. _fnInitComplete: _fnInitComplete,
  13190. _fnLengthChange: _fnLengthChange,
  13191. _fnFeatureHtmlLength: _fnFeatureHtmlLength,
  13192. _fnFeatureHtmlPaginate: _fnFeatureHtmlPaginate,
  13193. _fnPageChange: _fnPageChange,
  13194. _fnFeatureHtmlProcessing: _fnFeatureHtmlProcessing,
  13195. _fnProcessingDisplay: _fnProcessingDisplay,
  13196. _fnFeatureHtmlTable: _fnFeatureHtmlTable,
  13197. _fnScrollDraw: _fnScrollDraw,
  13198. _fnApplyToChildren: _fnApplyToChildren,
  13199. _fnCalculateColumnWidths: _fnCalculateColumnWidths,
  13200. _fnThrottle: _fnThrottle,
  13201. _fnConvertToWidth: _fnConvertToWidth,
  13202. _fnGetWidestNode: _fnGetWidestNode,
  13203. _fnGetMaxLenString: _fnGetMaxLenString,
  13204. _fnStringToCss: _fnStringToCss,
  13205. _fnSortFlatten: _fnSortFlatten,
  13206. _fnSort: _fnSort,
  13207. _fnSortAria: _fnSortAria,
  13208. _fnSortListener: _fnSortListener,
  13209. _fnSortAttachListener: _fnSortAttachListener,
  13210. _fnSortingClasses: _fnSortingClasses,
  13211. _fnSortData: _fnSortData,
  13212. _fnSaveState: _fnSaveState,
  13213. _fnLoadState: _fnLoadState,
  13214. _fnSettingsFromNode: _fnSettingsFromNode,
  13215. _fnLog: _fnLog,
  13216. _fnMap: _fnMap,
  13217. _fnBindAction: _fnBindAction,
  13218. _fnCallbackReg: _fnCallbackReg,
  13219. _fnCallbackFire: _fnCallbackFire,
  13220. _fnLengthOverflow: _fnLengthOverflow,
  13221. _fnRenderer: _fnRenderer,
  13222. _fnDataSource: _fnDataSource,
  13223. _fnRowAttributes: _fnRowAttributes,
  13224. _fnExtend: _fnExtend,
  13225. _fnCalculateEnd: function () {} // Used by a lot of plug-ins, but redundant
  13226. // in 1.10, so this dead-end function is
  13227. // added to prevent errors
  13228. } );
  13229. // jQuery access
  13230. $.fn.dataTable = DataTable;
  13231. // Provide access to the host jQuery object (circular reference)
  13232. DataTable.$ = $;
  13233. // Legacy aliases
  13234. $.fn.dataTableSettings = DataTable.settings;
  13235. $.fn.dataTableExt = DataTable.ext;
  13236. // With a capital `D` we return a DataTables API instance rather than a
  13237. // jQuery object
  13238. $.fn.DataTable = function ( opts ) {
  13239. return $(this).dataTable( opts ).api();
  13240. };
  13241. // All properties that are available to $.fn.dataTable should also be
  13242. // available on $.fn.DataTable
  13243. $.each( DataTable, function ( prop, val ) {
  13244. $.fn.DataTable[ prop ] = val;
  13245. } );
  13246. // Information about events fired by DataTables - for documentation.
  13247. /**
  13248. * Draw event, fired whenever the table is redrawn on the page, at the same
  13249. * point as fnDrawCallback. This may be useful for binding events or
  13250. * performing calculations when the table is altered at all.
  13251. * @name DataTable#draw.dt
  13252. * @event
  13253. * @param {event} e jQuery event object
  13254. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13255. */
  13256. /**
  13257. * Search event, fired when the searching applied to the table (using the
  13258. * built-in global search, or column filters) is altered.
  13259. * @name DataTable#search.dt
  13260. * @event
  13261. * @param {event} e jQuery event object
  13262. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13263. */
  13264. /**
  13265. * Page change event, fired when the paging of the table is altered.
  13266. * @name DataTable#page.dt
  13267. * @event
  13268. * @param {event} e jQuery event object
  13269. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13270. */
  13271. /**
  13272. * Order event, fired when the ordering applied to the table is altered.
  13273. * @name DataTable#order.dt
  13274. * @event
  13275. * @param {event} e jQuery event object
  13276. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13277. */
  13278. /**
  13279. * DataTables initialisation complete event, fired when the table is fully
  13280. * drawn, including Ajax data loaded, if Ajax data is required.
  13281. * @name DataTable#init.dt
  13282. * @event
  13283. * @param {event} e jQuery event object
  13284. * @param {object} oSettings DataTables settings object
  13285. * @param {object} json The JSON object request from the server - only
  13286. * present if client-side Ajax sourced data is used</li></ol>
  13287. */
  13288. /**
  13289. * State save event, fired when the table has changed state a new state save
  13290. * is required. This event allows modification of the state saving object
  13291. * prior to actually doing the save, including addition or other state
  13292. * properties (for plug-ins) or modification of a DataTables core property.
  13293. * @name DataTable#stateSaveParams.dt
  13294. * @event
  13295. * @param {event} e jQuery event object
  13296. * @param {object} oSettings DataTables settings object
  13297. * @param {object} json The state information to be saved
  13298. */
  13299. /**
  13300. * State load event, fired when the table is loading state from the stored
  13301. * data, but prior to the settings object being modified by the saved state
  13302. * - allowing modification of the saved state is required or loading of
  13303. * state for a plug-in.
  13304. * @name DataTable#stateLoadParams.dt
  13305. * @event
  13306. * @param {event} e jQuery event object
  13307. * @param {object} oSettings DataTables settings object
  13308. * @param {object} json The saved state information
  13309. */
  13310. /**
  13311. * State loaded event, fired when state has been loaded from stored data and
  13312. * the settings object has been modified by the loaded data.
  13313. * @name DataTable#stateLoaded.dt
  13314. * @event
  13315. * @param {event} e jQuery event object
  13316. * @param {object} oSettings DataTables settings object
  13317. * @param {object} json The saved state information
  13318. */
  13319. /**
  13320. * Processing event, fired when DataTables is doing some kind of processing
  13321. * (be it, order, search or anything else). It can be used to indicate to
  13322. * the end user that there is something happening, or that something has
  13323. * finished.
  13324. * @name DataTable#processing.dt
  13325. * @event
  13326. * @param {event} e jQuery event object
  13327. * @param {object} oSettings DataTables settings object
  13328. * @param {boolean} bShow Flag for if DataTables is doing processing or not
  13329. */
  13330. /**
  13331. * Ajax (XHR) event, fired whenever an Ajax request is completed from a
  13332. * request to made to the server for new data. This event is called before
  13333. * DataTables processed the returned data, so it can also be used to pre-
  13334. * process the data returned from the server, if needed.
  13335. *
  13336. * Note that this trigger is called in `fnServerData`, if you override
  13337. * `fnServerData` and which to use this event, you need to trigger it in you
  13338. * success function.
  13339. * @name DataTable#xhr.dt
  13340. * @event
  13341. * @param {event} e jQuery event object
  13342. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13343. * @param {object} json JSON returned from the server
  13344. *
  13345. * @example
  13346. * // Use a custom property returned from the server in another DOM element
  13347. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  13348. * $('#status').html( json.status );
  13349. * } );
  13350. *
  13351. * @example
  13352. * // Pre-process the data returned from the server
  13353. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  13354. * for ( var i=0, ien=json.aaData.length ; i<ien ; i++ ) {
  13355. * json.aaData[i].sum = json.aaData[i].one + json.aaData[i].two;
  13356. * }
  13357. * // Note no return - manipulate the data directly in the JSON object.
  13358. * } );
  13359. */
  13360. /**
  13361. * Destroy event, fired when the DataTable is destroyed by calling fnDestroy
  13362. * or passing the bDestroy:true parameter in the initialisation object. This
  13363. * can be used to remove bound events, added DOM nodes, etc.
  13364. * @name DataTable#destroy.dt
  13365. * @event
  13366. * @param {event} e jQuery event object
  13367. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13368. */
  13369. /**
  13370. * Page length change event, fired when number of records to show on each
  13371. * page (the length) is changed.
  13372. * @name DataTable#length.dt
  13373. * @event
  13374. * @param {event} e jQuery event object
  13375. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13376. * @param {integer} len New length
  13377. */
  13378. /**
  13379. * Column sizing has changed.
  13380. * @name DataTable#column-sizing.dt
  13381. * @event
  13382. * @param {event} e jQuery event object
  13383. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13384. */
  13385. /**
  13386. * Column visibility has changed.
  13387. * @name DataTable#column-visibility.dt
  13388. * @event
  13389. * @param {event} e jQuery event object
  13390. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13391. * @param {int} column Column index
  13392. * @param {bool} vis `false` if column now hidden, or `true` if visible
  13393. */
  13394. return $.fn.dataTable;
  13395. }));