jquery.dataTables.js 437 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278
  1. /*! DataTables 1.10.12
  2. * ©2008-2015 SpryMedia Ltd - datatables.net/license
  3. */
  4. /**
  5. * @summary DataTables
  6. * @description Paginate, search and order HTML tables
  7. * @version 1.10.12
  8. * @file jquery.dataTables.js
  9. * @author SpryMedia Ltd (www.sprymedia.co.uk)
  10. * @contact www.sprymedia.co.uk/contact
  11. * @copyright Copyright 2008-2015 SpryMedia Ltd.
  12. *
  13. * This source file is free software, available under the following license:
  14. * MIT license - http://datatables.net/license
  15. *
  16. * This source file is distributed in the hope that it will be useful, but
  17. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  18. * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
  19. *
  20. * For details please refer to: http://www.datatables.net
  21. */
  22. /*jslint evil: true, undef: true, browser: true */
  23. /*globals $,require,jQuery,define,_selector_run,_selector_opts,_selector_first,_selector_row_indexes,_ext,_Api,_api_register,_api_registerPlural,_re_new_lines,_re_html,_re_formatted_numeric,_re_escape_regex,_empty,_intVal,_numToDecimal,_isNumber,_isHtml,_htmlNumeric,_pluck,_pluck_order,_range,_stripHtml,_unique,_fnBuildAjax,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnAjaxDataSrc,_fnAddColumn,_fnColumnOptions,_fnAdjustColumnSizing,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnVisbleColumns,_fnGetColumns,_fnColumnTypes,_fnApplyColumnDefs,_fnHungarianMap,_fnCamelToHungarian,_fnLanguageCompat,_fnBrowserDetect,_fnAddData,_fnAddTr,_fnNodeToDataIndex,_fnNodeToColumnIndex,_fnGetCellData,_fnSetCellData,_fnSplitObjNotation,_fnGetObjectDataFn,_fnSetObjectDataFn,_fnGetDataMaster,_fnClearTable,_fnDeleteIndex,_fnInvalidate,_fnGetRowElements,_fnCreateTr,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAddOptionsHtml,_fnDetectHeader,_fnGetUniqueThs,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnFilterCreateSearch,_fnEscapeRegex,_fnFilterData,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnInfoMacros,_fnInitialise,_fnInitComplete,_fnLengthChange,_fnFeatureHtmlLength,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnFeatureHtmlTable,_fnScrollDraw,_fnApplyToChildren,_fnCalculateColumnWidths,_fnThrottle,_fnConvertToWidth,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnSortFlatten,_fnSort,_fnSortAria,_fnSortListener,_fnSortAttachListener,_fnSortingClasses,_fnSortData,_fnSaveState,_fnLoadState,_fnSettingsFromNode,_fnLog,_fnMap,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnLengthOverflow,_fnRenderer,_fnDataSource,_fnRowAttributes*/
  24. (function( factory ) {
  25. "use strict";
  26. if ( typeof define === 'function' && define.amd ) {
  27. // AMD
  28. define( ['jquery'], function ( $ ) {
  29. return factory( $, window, document );
  30. } );
  31. }
  32. else if ( typeof exports === 'object' ) {
  33. // CommonJS
  34. module.exports = function (root, $) {
  35. if ( ! root ) {
  36. // CommonJS environments without a window global must pass a
  37. // root. This will give an error otherwise
  38. root = window;
  39. }
  40. if ( ! $ ) {
  41. $ = typeof window !== 'undefined' ? // jQuery's factory checks for a global window
  42. require('jquery') :
  43. require('jquery')( root );
  44. }
  45. return factory( $, root, root.document );
  46. };
  47. }
  48. else {
  49. // Browser
  50. factory( jQuery, window, document );
  51. }
  52. }
  53. (function( $, window, document, undefined ) {
  54. "use strict";
  55. /**
  56. * DataTables is a plug-in for the jQuery Javascript library. It is a highly
  57. * flexible tool, based upon the foundations of progressive enhancement,
  58. * which will add advanced interaction controls to any HTML table. For a
  59. * full list of features please refer to
  60. * [DataTables.net](href="http://datatables.net).
  61. *
  62. * Note that the `DataTable` object is not a global variable but is aliased
  63. * to `jQuery.fn.DataTable` and `jQuery.fn.dataTable` through which it may
  64. * be accessed.
  65. *
  66. * @class
  67. * @param {object} [init={}] Configuration object for DataTables. Options
  68. * are defined by {@link DataTable.defaults}
  69. * @requires jQuery 1.7+
  70. *
  71. * @example
  72. * // Basic initialisation
  73. * $(document).ready( function {
  74. * $('#example').dataTable();
  75. * } );
  76. *
  77. * @example
  78. * // Initialisation with configuration options - in this case, disable
  79. * // pagination and sorting.
  80. * $(document).ready( function {
  81. * $('#example').dataTable( {
  82. * "paginate": false,
  83. * "sort": false
  84. * } );
  85. * } );
  86. */
  87. var DataTable = function ( options )
  88. {
  89. /**
  90. * Perform a jQuery selector action on the table's TR elements (from the tbody) and
  91. * return the resulting jQuery object.
  92. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  93. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  94. * @param {string} [oOpts.filter=none] Select TR elements that meet the current filter
  95. * criterion ("applied") or all TR elements (i.e. no filter).
  96. * @param {string} [oOpts.order=current] Order of the TR elements in the processed array.
  97. * Can be either 'current', whereby the current sorting of the table is used, or
  98. * 'original' whereby the original order the data was read into the table is used.
  99. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  100. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  101. * 'current' and filter is 'applied', regardless of what they might be given as.
  102. * @returns {object} jQuery object, filtered by the given selector.
  103. * @dtopt API
  104. * @deprecated Since v1.10
  105. *
  106. * @example
  107. * $(document).ready(function() {
  108. * var oTable = $('#example').dataTable();
  109. *
  110. * // Highlight every second row
  111. * oTable.$('tr:odd').css('backgroundColor', 'blue');
  112. * } );
  113. *
  114. * @example
  115. * $(document).ready(function() {
  116. * var oTable = $('#example').dataTable();
  117. *
  118. * // Filter to rows with 'Webkit' in them, add a background colour and then
  119. * // remove the filter, thus highlighting the 'Webkit' rows only.
  120. * oTable.fnFilter('Webkit');
  121. * oTable.$('tr', {"search": "applied"}).css('backgroundColor', 'blue');
  122. * oTable.fnFilter('');
  123. * } );
  124. */
  125. this.$ = function ( sSelector, oOpts )
  126. {
  127. return this.api(true).$( sSelector, oOpts );
  128. };
  129. /**
  130. * Almost identical to $ in operation, but in this case returns the data for the matched
  131. * rows - as such, the jQuery selector used should match TR row nodes or TD/TH cell nodes
  132. * rather than any descendants, so the data can be obtained for the row/cell. If matching
  133. * rows are found, the data returned is the original data array/object that was used to
  134. * create the row (or a generated array if from a DOM source).
  135. *
  136. * This method is often useful in-combination with $ where both functions are given the
  137. * same parameters and the array indexes will match identically.
  138. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  139. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  140. * @param {string} [oOpts.filter=none] Select elements that meet the current filter
  141. * criterion ("applied") or all elements (i.e. no filter).
  142. * @param {string} [oOpts.order=current] Order of the data in the processed array.
  143. * Can be either 'current', whereby the current sorting of the table is used, or
  144. * 'original' whereby the original order the data was read into the table is used.
  145. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  146. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  147. * 'current' and filter is 'applied', regardless of what they might be given as.
  148. * @returns {array} Data for the matched elements. If any elements, as a result of the
  149. * selector, were not TR, TD or TH elements in the DataTable, they will have a null
  150. * entry in the array.
  151. * @dtopt API
  152. * @deprecated Since v1.10
  153. *
  154. * @example
  155. * $(document).ready(function() {
  156. * var oTable = $('#example').dataTable();
  157. *
  158. * // Get the data from the first row in the table
  159. * var data = oTable._('tr:first');
  160. *
  161. * // Do something useful with the data
  162. * alert( "First cell is: "+data[0] );
  163. * } );
  164. *
  165. * @example
  166. * $(document).ready(function() {
  167. * var oTable = $('#example').dataTable();
  168. *
  169. * // Filter to 'Webkit' and get all data for
  170. * oTable.fnFilter('Webkit');
  171. * var data = oTable._('tr', {"search": "applied"});
  172. *
  173. * // Do something with the data
  174. * alert( data.length+" rows matched the search" );
  175. * } );
  176. */
  177. this._ = function ( sSelector, oOpts )
  178. {
  179. return this.api(true).rows( sSelector, oOpts ).data();
  180. };
  181. /**
  182. * Create a DataTables Api instance, with the currently selected tables for
  183. * the Api's context.
  184. * @param {boolean} [traditional=false] Set the API instance's context to be
  185. * only the table referred to by the `DataTable.ext.iApiIndex` option, as was
  186. * used in the API presented by DataTables 1.9- (i.e. the traditional mode),
  187. * or if all tables captured in the jQuery object should be used.
  188. * @return {DataTables.Api}
  189. */
  190. this.api = function ( traditional )
  191. {
  192. return traditional ?
  193. new _Api(
  194. _fnSettingsFromNode( this[ _ext.iApiIndex ] )
  195. ) :
  196. new _Api( this );
  197. };
  198. /**
  199. * Add a single new row or multiple rows of data to the table. Please note
  200. * that this is suitable for client-side processing only - if you are using
  201. * server-side processing (i.e. "bServerSide": true), then to add data, you
  202. * must add it to the data source, i.e. the server-side, through an Ajax call.
  203. * @param {array|object} data The data to be added to the table. This can be:
  204. * <ul>
  205. * <li>1D array of data - add a single row with the data provided</li>
  206. * <li>2D array of arrays - add multiple rows in a single call</li>
  207. * <li>object - data object when using <i>mData</i></li>
  208. * <li>array of objects - multiple data objects when using <i>mData</i></li>
  209. * </ul>
  210. * @param {bool} [redraw=true] redraw the table or not
  211. * @returns {array} An array of integers, representing the list of indexes in
  212. * <i>aoData</i> ({@link DataTable.models.oSettings}) that have been added to
  213. * the table.
  214. * @dtopt API
  215. * @deprecated Since v1.10
  216. *
  217. * @example
  218. * // Global var for counter
  219. * var giCount = 2;
  220. *
  221. * $(document).ready(function() {
  222. * $('#example').dataTable();
  223. * } );
  224. *
  225. * function fnClickAddRow() {
  226. * $('#example').dataTable().fnAddData( [
  227. * giCount+".1",
  228. * giCount+".2",
  229. * giCount+".3",
  230. * giCount+".4" ]
  231. * );
  232. *
  233. * giCount++;
  234. * }
  235. */
  236. this.fnAddData = function( data, redraw )
  237. {
  238. var api = this.api( true );
  239. /* Check if we want to add multiple rows or not */
  240. var rows = $.isArray(data) && ( $.isArray(data[0]) || $.isPlainObject(data[0]) ) ?
  241. api.rows.add( data ) :
  242. api.row.add( data );
  243. if ( redraw === undefined || redraw ) {
  244. api.draw();
  245. }
  246. return rows.flatten().toArray();
  247. };
  248. /**
  249. * This function will make DataTables recalculate the column sizes, based on the data
  250. * contained in the table and the sizes applied to the columns (in the DOM, CSS or
  251. * through the sWidth parameter). This can be useful when the width of the table's
  252. * parent element changes (for example a window resize).
  253. * @param {boolean} [bRedraw=true] Redraw the table or not, you will typically want to
  254. * @dtopt API
  255. * @deprecated Since v1.10
  256. *
  257. * @example
  258. * $(document).ready(function() {
  259. * var oTable = $('#example').dataTable( {
  260. * "sScrollY": "200px",
  261. * "bPaginate": false
  262. * } );
  263. *
  264. * $(window).bind('resize', function () {
  265. * oTable.fnAdjustColumnSizing();
  266. * } );
  267. * } );
  268. */
  269. this.fnAdjustColumnSizing = function ( bRedraw )
  270. {
  271. var api = this.api( true ).columns.adjust();
  272. var settings = api.settings()[0];
  273. var scroll = settings.oScroll;
  274. if ( bRedraw === undefined || bRedraw ) {
  275. api.draw( false );
  276. }
  277. else if ( scroll.sX !== "" || scroll.sY !== "" ) {
  278. /* If not redrawing, but scrolling, we want to apply the new column sizes anyway */
  279. _fnScrollDraw( settings );
  280. }
  281. };
  282. /**
  283. * Quickly and simply clear a table
  284. * @param {bool} [bRedraw=true] redraw the table or not
  285. * @dtopt API
  286. * @deprecated Since v1.10
  287. *
  288. * @example
  289. * $(document).ready(function() {
  290. * var oTable = $('#example').dataTable();
  291. *
  292. * // Immediately 'nuke' the current rows (perhaps waiting for an Ajax callback...)
  293. * oTable.fnClearTable();
  294. * } );
  295. */
  296. this.fnClearTable = function( bRedraw )
  297. {
  298. var api = this.api( true ).clear();
  299. if ( bRedraw === undefined || bRedraw ) {
  300. api.draw();
  301. }
  302. };
  303. /**
  304. * The exact opposite of 'opening' a row, this function will close any rows which
  305. * are currently 'open'.
  306. * @param {node} nTr the table row to 'close'
  307. * @returns {int} 0 on success, or 1 if failed (can't find the row)
  308. * @dtopt API
  309. * @deprecated Since v1.10
  310. *
  311. * @example
  312. * $(document).ready(function() {
  313. * var oTable;
  314. *
  315. * // 'open' an information row when a row is clicked on
  316. * $('#example tbody tr').click( function () {
  317. * if ( oTable.fnIsOpen(this) ) {
  318. * oTable.fnClose( this );
  319. * } else {
  320. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  321. * }
  322. * } );
  323. *
  324. * oTable = $('#example').dataTable();
  325. * } );
  326. */
  327. this.fnClose = function( nTr )
  328. {
  329. this.api( true ).row( nTr ).child.hide();
  330. };
  331. /**
  332. * Remove a row for the table
  333. * @param {mixed} target The index of the row from aoData to be deleted, or
  334. * the TR element you want to delete
  335. * @param {function|null} [callBack] Callback function
  336. * @param {bool} [redraw=true] Redraw the table or not
  337. * @returns {array} The row that was deleted
  338. * @dtopt API
  339. * @deprecated Since v1.10
  340. *
  341. * @example
  342. * $(document).ready(function() {
  343. * var oTable = $('#example').dataTable();
  344. *
  345. * // Immediately remove the first row
  346. * oTable.fnDeleteRow( 0 );
  347. * } );
  348. */
  349. this.fnDeleteRow = function( target, callback, redraw )
  350. {
  351. var api = this.api( true );
  352. var rows = api.rows( target );
  353. var settings = rows.settings()[0];
  354. var data = settings.aoData[ rows[0][0] ];
  355. rows.remove();
  356. if ( callback ) {
  357. callback.call( this, settings, data );
  358. }
  359. if ( redraw === undefined || redraw ) {
  360. api.draw();
  361. }
  362. return data;
  363. };
  364. /**
  365. * Restore the table to it's original state in the DOM by removing all of DataTables
  366. * enhancements, alterations to the DOM structure of the table and event listeners.
  367. * @param {boolean} [remove=false] Completely remove the table from the DOM
  368. * @dtopt API
  369. * @deprecated Since v1.10
  370. *
  371. * @example
  372. * $(document).ready(function() {
  373. * // This example is fairly pointless in reality, but shows how fnDestroy can be used
  374. * var oTable = $('#example').dataTable();
  375. * oTable.fnDestroy();
  376. * } );
  377. */
  378. this.fnDestroy = function ( remove )
  379. {
  380. this.api( true ).destroy( remove );
  381. };
  382. /**
  383. * Redraw the table
  384. * @param {bool} [complete=true] Re-filter and resort (if enabled) the table before the draw.
  385. * @dtopt API
  386. * @deprecated Since v1.10
  387. *
  388. * @example
  389. * $(document).ready(function() {
  390. * var oTable = $('#example').dataTable();
  391. *
  392. * // Re-draw the table - you wouldn't want to do it here, but it's an example :-)
  393. * oTable.fnDraw();
  394. * } );
  395. */
  396. this.fnDraw = function( complete )
  397. {
  398. // Note that this isn't an exact match to the old call to _fnDraw - it takes
  399. // into account the new data, but can hold position.
  400. this.api( true ).draw( complete );
  401. };
  402. /**
  403. * Filter the input based on data
  404. * @param {string} sInput String to filter the table on
  405. * @param {int|null} [iColumn] Column to limit filtering to
  406. * @param {bool} [bRegex=false] Treat as regular expression or not
  407. * @param {bool} [bSmart=true] Perform smart filtering or not
  408. * @param {bool} [bShowGlobal=true] Show the input global filter in it's input box(es)
  409. * @param {bool} [bCaseInsensitive=true] Do case-insensitive matching (true) or not (false)
  410. * @dtopt API
  411. * @deprecated Since v1.10
  412. *
  413. * @example
  414. * $(document).ready(function() {
  415. * var oTable = $('#example').dataTable();
  416. *
  417. * // Sometime later - filter...
  418. * oTable.fnFilter( 'test string' );
  419. * } );
  420. */
  421. this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal, bCaseInsensitive )
  422. {
  423. var api = this.api( true );
  424. if ( iColumn === null || iColumn === undefined ) {
  425. api.search( sInput, bRegex, bSmart, bCaseInsensitive );
  426. }
  427. else {
  428. api.column( iColumn ).search( sInput, bRegex, bSmart, bCaseInsensitive );
  429. }
  430. api.draw();
  431. };
  432. /**
  433. * Get the data for the whole table, an individual row or an individual cell based on the
  434. * provided parameters.
  435. * @param {int|node} [src] A TR row node, TD/TH cell node or an integer. If given as
  436. * a TR node then the data source for the whole row will be returned. If given as a
  437. * TD/TH cell node then iCol will be automatically calculated and the data for the
  438. * cell returned. If given as an integer, then this is treated as the aoData internal
  439. * data index for the row (see fnGetPosition) and the data for that row used.
  440. * @param {int} [col] Optional column index that you want the data of.
  441. * @returns {array|object|string} If mRow is undefined, then the data for all rows is
  442. * returned. If mRow is defined, just data for that row, and is iCol is
  443. * defined, only data for the designated cell is returned.
  444. * @dtopt API
  445. * @deprecated Since v1.10
  446. *
  447. * @example
  448. * // Row data
  449. * $(document).ready(function() {
  450. * oTable = $('#example').dataTable();
  451. *
  452. * oTable.$('tr').click( function () {
  453. * var data = oTable.fnGetData( this );
  454. * // ... do something with the array / object of data for the row
  455. * } );
  456. * } );
  457. *
  458. * @example
  459. * // Individual cell data
  460. * $(document).ready(function() {
  461. * oTable = $('#example').dataTable();
  462. *
  463. * oTable.$('td').click( function () {
  464. * var sData = oTable.fnGetData( this );
  465. * alert( 'The cell clicked on had the value of '+sData );
  466. * } );
  467. * } );
  468. */
  469. this.fnGetData = function( src, col )
  470. {
  471. var api = this.api( true );
  472. if ( src !== undefined ) {
  473. var type = src.nodeName ? src.nodeName.toLowerCase() : '';
  474. return col !== undefined || type == 'td' || type == 'th' ?
  475. api.cell( src, col ).data() :
  476. api.row( src ).data() || null;
  477. }
  478. return api.data().toArray();
  479. };
  480. /**
  481. * Get an array of the TR nodes that are used in the table's body. Note that you will
  482. * typically want to use the '$' API method in preference to this as it is more
  483. * flexible.
  484. * @param {int} [iRow] Optional row index for the TR element you want
  485. * @returns {array|node} If iRow is undefined, returns an array of all TR elements
  486. * in the table's body, or iRow is defined, just the TR element requested.
  487. * @dtopt API
  488. * @deprecated Since v1.10
  489. *
  490. * @example
  491. * $(document).ready(function() {
  492. * var oTable = $('#example').dataTable();
  493. *
  494. * // Get the nodes from the table
  495. * var nNodes = oTable.fnGetNodes( );
  496. * } );
  497. */
  498. this.fnGetNodes = function( iRow )
  499. {
  500. var api = this.api( true );
  501. return iRow !== undefined ?
  502. api.row( iRow ).node() :
  503. api.rows().nodes().flatten().toArray();
  504. };
  505. /**
  506. * Get the array indexes of a particular cell from it's DOM element
  507. * and column index including hidden columns
  508. * @param {node} node this can either be a TR, TD or TH in the table's body
  509. * @returns {int} If nNode is given as a TR, then a single index is returned, or
  510. * if given as a cell, an array of [row index, column index (visible),
  511. * column index (all)] is given.
  512. * @dtopt API
  513. * @deprecated Since v1.10
  514. *
  515. * @example
  516. * $(document).ready(function() {
  517. * $('#example tbody td').click( function () {
  518. * // Get the position of the current data from the node
  519. * var aPos = oTable.fnGetPosition( this );
  520. *
  521. * // Get the data array for this row
  522. * var aData = oTable.fnGetData( aPos[0] );
  523. *
  524. * // Update the data array and return the value
  525. * aData[ aPos[1] ] = 'clicked';
  526. * this.innerHTML = 'clicked';
  527. * } );
  528. *
  529. * // Init DataTables
  530. * oTable = $('#example').dataTable();
  531. * } );
  532. */
  533. this.fnGetPosition = function( node )
  534. {
  535. var api = this.api( true );
  536. var nodeName = node.nodeName.toUpperCase();
  537. if ( nodeName == 'TR' ) {
  538. return api.row( node ).index();
  539. }
  540. else if ( nodeName == 'TD' || nodeName == 'TH' ) {
  541. var cell = api.cell( node ).index();
  542. return [
  543. cell.row,
  544. cell.columnVisible,
  545. cell.column
  546. ];
  547. }
  548. return null;
  549. };
  550. /**
  551. * Check to see if a row is 'open' or not.
  552. * @param {node} nTr the table row to check
  553. * @returns {boolean} true if the row is currently open, false otherwise
  554. * @dtopt API
  555. * @deprecated Since v1.10
  556. *
  557. * @example
  558. * $(document).ready(function() {
  559. * var oTable;
  560. *
  561. * // 'open' an information row when a row is clicked on
  562. * $('#example tbody tr').click( function () {
  563. * if ( oTable.fnIsOpen(this) ) {
  564. * oTable.fnClose( this );
  565. * } else {
  566. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  567. * }
  568. * } );
  569. *
  570. * oTable = $('#example').dataTable();
  571. * } );
  572. */
  573. this.fnIsOpen = function( nTr )
  574. {
  575. return this.api( true ).row( nTr ).child.isShown();
  576. };
  577. /**
  578. * This function will place a new row directly after a row which is currently
  579. * on display on the page, with the HTML contents that is passed into the
  580. * function. This can be used, for example, to ask for confirmation that a
  581. * particular record should be deleted.
  582. * @param {node} nTr The table row to 'open'
  583. * @param {string|node|jQuery} mHtml The HTML to put into the row
  584. * @param {string} sClass Class to give the new TD cell
  585. * @returns {node} The row opened. Note that if the table row passed in as the
  586. * first parameter, is not found in the table, this method will silently
  587. * return.
  588. * @dtopt API
  589. * @deprecated Since v1.10
  590. *
  591. * @example
  592. * $(document).ready(function() {
  593. * var oTable;
  594. *
  595. * // 'open' an information row when a row is clicked on
  596. * $('#example tbody tr').click( function () {
  597. * if ( oTable.fnIsOpen(this) ) {
  598. * oTable.fnClose( this );
  599. * } else {
  600. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  601. * }
  602. * } );
  603. *
  604. * oTable = $('#example').dataTable();
  605. * } );
  606. */
  607. this.fnOpen = function( nTr, mHtml, sClass )
  608. {
  609. return this.api( true )
  610. .row( nTr )
  611. .child( mHtml, sClass )
  612. .show()
  613. .child()[0];
  614. };
  615. /**
  616. * Change the pagination - provides the internal logic for pagination in a simple API
  617. * function. With this function you can have a DataTables table go to the next,
  618. * previous, first or last pages.
  619. * @param {string|int} mAction Paging action to take: "first", "previous", "next" or "last"
  620. * or page number to jump to (integer), note that page 0 is the first page.
  621. * @param {bool} [bRedraw=true] Redraw the table or not
  622. * @dtopt API
  623. * @deprecated Since v1.10
  624. *
  625. * @example
  626. * $(document).ready(function() {
  627. * var oTable = $('#example').dataTable();
  628. * oTable.fnPageChange( 'next' );
  629. * } );
  630. */
  631. this.fnPageChange = function ( mAction, bRedraw )
  632. {
  633. var api = this.api( true ).page( mAction );
  634. if ( bRedraw === undefined || bRedraw ) {
  635. api.draw(false);
  636. }
  637. };
  638. /**
  639. * Show a particular column
  640. * @param {int} iCol The column whose display should be changed
  641. * @param {bool} bShow Show (true) or hide (false) the column
  642. * @param {bool} [bRedraw=true] Redraw the table or not
  643. * @dtopt API
  644. * @deprecated Since v1.10
  645. *
  646. * @example
  647. * $(document).ready(function() {
  648. * var oTable = $('#example').dataTable();
  649. *
  650. * // Hide the second column after initialisation
  651. * oTable.fnSetColumnVis( 1, false );
  652. * } );
  653. */
  654. this.fnSetColumnVis = function ( iCol, bShow, bRedraw )
  655. {
  656. var api = this.api( true ).column( iCol ).visible( bShow );
  657. if ( bRedraw === undefined || bRedraw ) {
  658. api.columns.adjust().draw();
  659. }
  660. };
  661. /**
  662. * Get the settings for a particular table for external manipulation
  663. * @returns {object} DataTables settings object. See
  664. * {@link DataTable.models.oSettings}
  665. * @dtopt API
  666. * @deprecated Since v1.10
  667. *
  668. * @example
  669. * $(document).ready(function() {
  670. * var oTable = $('#example').dataTable();
  671. * var oSettings = oTable.fnSettings();
  672. *
  673. * // Show an example parameter from the settings
  674. * alert( oSettings._iDisplayStart );
  675. * } );
  676. */
  677. this.fnSettings = function()
  678. {
  679. return _fnSettingsFromNode( this[_ext.iApiIndex] );
  680. };
  681. /**
  682. * Sort the table by a particular column
  683. * @param {int} iCol the data index to sort on. Note that this will not match the
  684. * 'display index' if you have hidden data entries
  685. * @dtopt API
  686. * @deprecated Since v1.10
  687. *
  688. * @example
  689. * $(document).ready(function() {
  690. * var oTable = $('#example').dataTable();
  691. *
  692. * // Sort immediately with columns 0 and 1
  693. * oTable.fnSort( [ [0,'asc'], [1,'asc'] ] );
  694. * } );
  695. */
  696. this.fnSort = function( aaSort )
  697. {
  698. this.api( true ).order( aaSort ).draw();
  699. };
  700. /**
  701. * Attach a sort listener to an element for a given column
  702. * @param {node} nNode the element to attach the sort listener to
  703. * @param {int} iColumn the column that a click on this node will sort on
  704. * @param {function} [fnCallback] callback function when sort is run
  705. * @dtopt API
  706. * @deprecated Since v1.10
  707. *
  708. * @example
  709. * $(document).ready(function() {
  710. * var oTable = $('#example').dataTable();
  711. *
  712. * // Sort on column 1, when 'sorter' is clicked on
  713. * oTable.fnSortListener( document.getElementById('sorter'), 1 );
  714. * } );
  715. */
  716. this.fnSortListener = function( nNode, iColumn, fnCallback )
  717. {
  718. this.api( true ).order.listener( nNode, iColumn, fnCallback );
  719. };
  720. /**
  721. * Update a table cell or row - this method will accept either a single value to
  722. * update the cell with, an array of values with one element for each column or
  723. * an object in the same format as the original data source. The function is
  724. * self-referencing in order to make the multi column updates easier.
  725. * @param {object|array|string} mData Data to update the cell/row with
  726. * @param {node|int} mRow TR element you want to update or the aoData index
  727. * @param {int} [iColumn] The column to update, give as null or undefined to
  728. * update a whole row.
  729. * @param {bool} [bRedraw=true] Redraw the table or not
  730. * @param {bool} [bAction=true] Perform pre-draw actions or not
  731. * @returns {int} 0 on success, 1 on error
  732. * @dtopt API
  733. * @deprecated Since v1.10
  734. *
  735. * @example
  736. * $(document).ready(function() {
  737. * var oTable = $('#example').dataTable();
  738. * oTable.fnUpdate( 'Example update', 0, 0 ); // Single cell
  739. * oTable.fnUpdate( ['a', 'b', 'c', 'd', 'e'], $('tbody tr')[0] ); // Row
  740. * } );
  741. */
  742. this.fnUpdate = function( mData, mRow, iColumn, bRedraw, bAction )
  743. {
  744. var api = this.api( true );
  745. if ( iColumn === undefined || iColumn === null ) {
  746. api.row( mRow ).data( mData );
  747. }
  748. else {
  749. api.cell( mRow, iColumn ).data( mData );
  750. }
  751. if ( bAction === undefined || bAction ) {
  752. api.columns.adjust();
  753. }
  754. if ( bRedraw === undefined || bRedraw ) {
  755. api.draw();
  756. }
  757. return 0;
  758. };
  759. /**
  760. * Provide a common method for plug-ins to check the version of DataTables being used, in order
  761. * to ensure compatibility.
  762. * @param {string} sVersion Version string to check for, in the format "X.Y.Z". Note that the
  763. * formats "X" and "X.Y" are also acceptable.
  764. * @returns {boolean} true if this version of DataTables is greater or equal to the required
  765. * version, or false if this version of DataTales is not suitable
  766. * @method
  767. * @dtopt API
  768. * @deprecated Since v1.10
  769. *
  770. * @example
  771. * $(document).ready(function() {
  772. * var oTable = $('#example').dataTable();
  773. * alert( oTable.fnVersionCheck( '1.9.0' ) );
  774. * } );
  775. */
  776. this.fnVersionCheck = _ext.fnVersionCheck;
  777. var _that = this;
  778. var emptyInit = options === undefined;
  779. var len = this.length;
  780. if ( emptyInit ) {
  781. options = {};
  782. }
  783. this.oApi = this.internal = _ext.internal;
  784. // Extend with old style plug-in API methods
  785. for ( var fn in DataTable.ext.internal ) {
  786. if ( fn ) {
  787. this[fn] = _fnExternApiFunc(fn);
  788. }
  789. }
  790. this.each(function() {
  791. // For each initialisation we want to give it a clean initialisation
  792. // object that can be bashed around
  793. var o = {};
  794. var oInit = len > 1 ? // optimisation for single table case
  795. _fnExtend( o, options, true ) :
  796. options;
  797. /*global oInit,_that,emptyInit*/
  798. var i=0, iLen, j, jLen, k, kLen;
  799. var sId = this.getAttribute( 'id' );
  800. var bInitHandedOff = false;
  801. var defaults = DataTable.defaults;
  802. var $this = $(this);
  803. /* Sanity check */
  804. if ( this.nodeName.toLowerCase() != 'table' )
  805. {
  806. _fnLog( null, 0, 'Non-table node initialisation ('+this.nodeName+')', 2 );
  807. return;
  808. }
  809. /* Backwards compatibility for the defaults */
  810. _fnCompatOpts( defaults );
  811. _fnCompatCols( defaults.column );
  812. /* Convert the camel-case defaults to Hungarian */
  813. _fnCamelToHungarian( defaults, defaults, true );
  814. _fnCamelToHungarian( defaults.column, defaults.column, true );
  815. /* Setting up the initialisation object */
  816. _fnCamelToHungarian( defaults, $.extend( oInit, $this.data() ) );
  817. /* Check to see if we are re-initialising a table */
  818. var allSettings = DataTable.settings;
  819. for ( i=0, iLen=allSettings.length ; i<iLen ; i++ )
  820. {
  821. var s = allSettings[i];
  822. /* Base check on table node */
  823. if ( s.nTable == this || s.nTHead.parentNode == this || (s.nTFoot && s.nTFoot.parentNode == this) )
  824. {
  825. var bRetrieve = oInit.bRetrieve !== undefined ? oInit.bRetrieve : defaults.bRetrieve;
  826. var bDestroy = oInit.bDestroy !== undefined ? oInit.bDestroy : defaults.bDestroy;
  827. if ( emptyInit || bRetrieve )
  828. {
  829. return s.oInstance;
  830. }
  831. else if ( bDestroy )
  832. {
  833. s.oInstance.fnDestroy();
  834. break;
  835. }
  836. else
  837. {
  838. _fnLog( s, 0, 'Cannot reinitialise DataTable', 3 );
  839. return;
  840. }
  841. }
  842. /* If the element we are initialising has the same ID as a table which was previously
  843. * initialised, but the table nodes don't match (from before) then we destroy the old
  844. * instance by simply deleting it. This is under the assumption that the table has been
  845. * destroyed by other methods. Anyone using non-id selectors will need to do this manually
  846. */
  847. if ( s.sTableId == this.id )
  848. {
  849. allSettings.splice( i, 1 );
  850. break;
  851. }
  852. }
  853. /* Ensure the table has an ID - required for accessibility */
  854. if ( sId === null || sId === "" )
  855. {
  856. sId = "DataTables_Table_"+(DataTable.ext._unique++);
  857. this.id = sId;
  858. }
  859. /* Create the settings object for this table and set some of the default parameters */
  860. var oSettings = $.extend( true, {}, DataTable.models.oSettings, {
  861. "sDestroyWidth": $this[0].style.width,
  862. "sInstance": sId,
  863. "sTableId": sId
  864. } );
  865. oSettings.nTable = this;
  866. oSettings.oApi = _that.internal;
  867. oSettings.oInit = oInit;
  868. allSettings.push( oSettings );
  869. // Need to add the instance after the instance after the settings object has been added
  870. // to the settings array, so we can self reference the table instance if more than one
  871. oSettings.oInstance = (_that.length===1) ? _that : $this.dataTable();
  872. // Backwards compatibility, before we apply all the defaults
  873. _fnCompatOpts( oInit );
  874. if ( oInit.oLanguage )
  875. {
  876. _fnLanguageCompat( oInit.oLanguage );
  877. }
  878. // If the length menu is given, but the init display length is not, use the length menu
  879. if ( oInit.aLengthMenu && ! oInit.iDisplayLength )
  880. {
  881. oInit.iDisplayLength = $.isArray( oInit.aLengthMenu[0] ) ?
  882. oInit.aLengthMenu[0][0] : oInit.aLengthMenu[0];
  883. }
  884. // Apply the defaults and init options to make a single init object will all
  885. // options defined from defaults and instance options.
  886. oInit = _fnExtend( $.extend( true, {}, defaults ), oInit );
  887. // Map the initialisation options onto the settings object
  888. _fnMap( oSettings.oFeatures, oInit, [
  889. "bPaginate",
  890. "bLengthChange",
  891. "bFilter",
  892. "bSort",
  893. "bSortMulti",
  894. "bInfo",
  895. "bProcessing",
  896. "bAutoWidth",
  897. "bSortClasses",
  898. "bServerSide",
  899. "bDeferRender"
  900. ] );
  901. _fnMap( oSettings, oInit, [
  902. "asStripeClasses",
  903. "ajax",
  904. "fnServerData",
  905. "fnFormatNumber",
  906. "sServerMethod",
  907. "aaSorting",
  908. "aaSortingFixed",
  909. "aLengthMenu",
  910. "sPaginationType",
  911. "sAjaxSource",
  912. "sAjaxDataProp",
  913. "iStateDuration",
  914. "sDom",
  915. "bSortCellsTop",
  916. "iTabIndex",
  917. "fnStateLoadCallback",
  918. "fnStateSaveCallback",
  919. "renderer",
  920. "searchDelay",
  921. "rowId",
  922. [ "iCookieDuration", "iStateDuration" ], // backwards compat
  923. [ "oSearch", "oPreviousSearch" ],
  924. [ "aoSearchCols", "aoPreSearchCols" ],
  925. [ "iDisplayLength", "_iDisplayLength" ],
  926. [ "bJQueryUI", "bJUI" ]
  927. ] );
  928. _fnMap( oSettings.oScroll, oInit, [
  929. [ "sScrollX", "sX" ],
  930. [ "sScrollXInner", "sXInner" ],
  931. [ "sScrollY", "sY" ],
  932. [ "bScrollCollapse", "bCollapse" ]
  933. ] );
  934. _fnMap( oSettings.oLanguage, oInit, "fnInfoCallback" );
  935. /* Callback functions which are array driven */
  936. _fnCallbackReg( oSettings, 'aoDrawCallback', oInit.fnDrawCallback, 'user' );
  937. _fnCallbackReg( oSettings, 'aoServerParams', oInit.fnServerParams, 'user' );
  938. _fnCallbackReg( oSettings, 'aoStateSaveParams', oInit.fnStateSaveParams, 'user' );
  939. _fnCallbackReg( oSettings, 'aoStateLoadParams', oInit.fnStateLoadParams, 'user' );
  940. _fnCallbackReg( oSettings, 'aoStateLoaded', oInit.fnStateLoaded, 'user' );
  941. _fnCallbackReg( oSettings, 'aoRowCallback', oInit.fnRowCallback, 'user' );
  942. _fnCallbackReg( oSettings, 'aoRowCreatedCallback', oInit.fnCreatedRow, 'user' );
  943. _fnCallbackReg( oSettings, 'aoHeaderCallback', oInit.fnHeaderCallback, 'user' );
  944. _fnCallbackReg( oSettings, 'aoFooterCallback', oInit.fnFooterCallback, 'user' );
  945. _fnCallbackReg( oSettings, 'aoInitComplete', oInit.fnInitComplete, 'user' );
  946. _fnCallbackReg( oSettings, 'aoPreDrawCallback', oInit.fnPreDrawCallback, 'user' );
  947. oSettings.rowIdFn = _fnGetObjectDataFn( oInit.rowId );
  948. /* Browser support detection */
  949. _fnBrowserDetect( oSettings );
  950. var oClasses = oSettings.oClasses;
  951. // @todo Remove in 1.11
  952. if ( oInit.bJQueryUI )
  953. {
  954. /* Use the JUI classes object for display. You could clone the oStdClasses object if
  955. * you want to have multiple tables with multiple independent classes
  956. */
  957. $.extend( oClasses, DataTable.ext.oJUIClasses, oInit.oClasses );
  958. if ( oInit.sDom === defaults.sDom && defaults.sDom === "lfrtip" )
  959. {
  960. /* Set the DOM to use a layout suitable for jQuery UI's theming */
  961. oSettings.sDom = '<"H"lfr>t<"F"ip>';
  962. }
  963. if ( ! oSettings.renderer ) {
  964. oSettings.renderer = 'jqueryui';
  965. }
  966. else if ( $.isPlainObject( oSettings.renderer ) && ! oSettings.renderer.header ) {
  967. oSettings.renderer.header = 'jqueryui';
  968. }
  969. }
  970. else
  971. {
  972. $.extend( oClasses, DataTable.ext.classes, oInit.oClasses );
  973. }
  974. $this.addClass( oClasses.sTable );
  975. if ( oSettings.iInitDisplayStart === undefined )
  976. {
  977. /* Display start point, taking into account the save saving */
  978. oSettings.iInitDisplayStart = oInit.iDisplayStart;
  979. oSettings._iDisplayStart = oInit.iDisplayStart;
  980. }
  981. if ( oInit.iDeferLoading !== null )
  982. {
  983. oSettings.bDeferLoading = true;
  984. var tmp = $.isArray( oInit.iDeferLoading );
  985. oSettings._iRecordsDisplay = tmp ? oInit.iDeferLoading[0] : oInit.iDeferLoading;
  986. oSettings._iRecordsTotal = tmp ? oInit.iDeferLoading[1] : oInit.iDeferLoading;
  987. }
  988. /* Language definitions */
  989. var oLanguage = oSettings.oLanguage;
  990. $.extend( true, oLanguage, oInit.oLanguage );
  991. if ( oLanguage.sUrl !== "" )
  992. {
  993. /* Get the language definitions from a file - because this Ajax call makes the language
  994. * get async to the remainder of this function we use bInitHandedOff to indicate that
  995. * _fnInitialise will be fired by the returned Ajax handler, rather than the constructor
  996. */
  997. $.ajax( {
  998. dataType: 'json',
  999. url: oLanguage.sUrl,
  1000. success: function ( json ) {
  1001. _fnLanguageCompat( json );
  1002. _fnCamelToHungarian( defaults.oLanguage, json );
  1003. $.extend( true, oLanguage, json );
  1004. _fnInitialise( oSettings );
  1005. },
  1006. error: function () {
  1007. // Error occurred loading language file, continue on as best we can
  1008. _fnInitialise( oSettings );
  1009. }
  1010. } );
  1011. bInitHandedOff = true;
  1012. }
  1013. /*
  1014. * Stripes
  1015. */
  1016. if ( oInit.asStripeClasses === null )
  1017. {
  1018. oSettings.asStripeClasses =[
  1019. oClasses.sStripeOdd,
  1020. oClasses.sStripeEven
  1021. ];
  1022. }
  1023. /* Remove row stripe classes if they are already on the table row */
  1024. var stripeClasses = oSettings.asStripeClasses;
  1025. var rowOne = $this.children('tbody').find('tr').eq(0);
  1026. if ( $.inArray( true, $.map( stripeClasses, function(el, i) {
  1027. return rowOne.hasClass(el);
  1028. } ) ) !== -1 ) {
  1029. $('tbody tr', this).removeClass( stripeClasses.join(' ') );
  1030. oSettings.asDestroyStripes = stripeClasses.slice();
  1031. }
  1032. /*
  1033. * Columns
  1034. * See if we should load columns automatically or use defined ones
  1035. */
  1036. var anThs = [];
  1037. var aoColumnsInit;
  1038. var nThead = this.getElementsByTagName('thead');
  1039. if ( nThead.length !== 0 )
  1040. {
  1041. _fnDetectHeader( oSettings.aoHeader, nThead[0] );
  1042. anThs = _fnGetUniqueThs( oSettings );
  1043. }
  1044. /* If not given a column array, generate one with nulls */
  1045. if ( oInit.aoColumns === null )
  1046. {
  1047. aoColumnsInit = [];
  1048. for ( i=0, iLen=anThs.length ; i<iLen ; i++ )
  1049. {
  1050. aoColumnsInit.push( null );
  1051. }
  1052. }
  1053. else
  1054. {
  1055. aoColumnsInit = oInit.aoColumns;
  1056. }
  1057. /* Add the columns */
  1058. for ( i=0, iLen=aoColumnsInit.length ; i<iLen ; i++ )
  1059. {
  1060. _fnAddColumn( oSettings, anThs ? anThs[i] : null );
  1061. }
  1062. /* Apply the column definitions */
  1063. _fnApplyColumnDefs( oSettings, oInit.aoColumnDefs, aoColumnsInit, function (iCol, oDef) {
  1064. _fnColumnOptions( oSettings, iCol, oDef );
  1065. } );
  1066. /* HTML5 attribute detection - build an mData object automatically if the
  1067. * attributes are found
  1068. */
  1069. if ( rowOne.length ) {
  1070. var a = function ( cell, name ) {
  1071. return cell.getAttribute( 'data-'+name ) !== null ? name : null;
  1072. };
  1073. $( rowOne[0] ).children('th, td').each( function (i, cell) {
  1074. var col = oSettings.aoColumns[i];
  1075. if ( col.mData === i ) {
  1076. var sort = a( cell, 'sort' ) || a( cell, 'order' );
  1077. var filter = a( cell, 'filter' ) || a( cell, 'search' );
  1078. if ( sort !== null || filter !== null ) {
  1079. col.mData = {
  1080. _: i+'.display',
  1081. sort: sort !== null ? i+'.@data-'+sort : undefined,
  1082. type: sort !== null ? i+'.@data-'+sort : undefined,
  1083. filter: filter !== null ? i+'.@data-'+filter : undefined
  1084. };
  1085. _fnColumnOptions( oSettings, i );
  1086. }
  1087. }
  1088. } );
  1089. }
  1090. var features = oSettings.oFeatures;
  1091. /* Must be done after everything which can be overridden by the state saving! */
  1092. if ( oInit.bStateSave )
  1093. {
  1094. features.bStateSave = true;
  1095. _fnLoadState( oSettings, oInit );
  1096. _fnCallbackReg( oSettings, 'aoDrawCallback', _fnSaveState, 'state_save' );
  1097. }
  1098. /*
  1099. * Sorting
  1100. * @todo For modularisation (1.11) this needs to do into a sort start up handler
  1101. */
  1102. // If aaSorting is not defined, then we use the first indicator in asSorting
  1103. // in case that has been altered, so the default sort reflects that option
  1104. if ( oInit.aaSorting === undefined )
  1105. {
  1106. var sorting = oSettings.aaSorting;
  1107. for ( i=0, iLen=sorting.length ; i<iLen ; i++ )
  1108. {
  1109. sorting[i][1] = oSettings.aoColumns[ i ].asSorting[0];
  1110. }
  1111. }
  1112. /* Do a first pass on the sorting classes (allows any size changes to be taken into
  1113. * account, and also will apply sorting disabled classes if disabled
  1114. */
  1115. _fnSortingClasses( oSettings );
  1116. if ( features.bSort )
  1117. {
  1118. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  1119. if ( oSettings.bSorted ) {
  1120. var aSort = _fnSortFlatten( oSettings );
  1121. var sortedColumns = {};
  1122. $.each( aSort, function (i, val) {
  1123. sortedColumns[ val.src ] = val.dir;
  1124. } );
  1125. _fnCallbackFire( oSettings, null, 'order', [oSettings, aSort, sortedColumns] );
  1126. _fnSortAria( oSettings );
  1127. }
  1128. } );
  1129. }
  1130. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  1131. if ( oSettings.bSorted || _fnDataSource( oSettings ) === 'ssp' || features.bDeferRender ) {
  1132. _fnSortingClasses( oSettings );
  1133. }
  1134. }, 'sc' );
  1135. /*
  1136. * Final init
  1137. * Cache the header, body and footer as required, creating them if needed
  1138. */
  1139. // Work around for Webkit bug 83867 - store the caption-side before removing from doc
  1140. var captions = $this.children('caption').each( function () {
  1141. this._captionSide = $this.css('caption-side');
  1142. } );
  1143. var thead = $this.children('thead');
  1144. if ( thead.length === 0 )
  1145. {
  1146. thead = $('<thead/>').appendTo(this);
  1147. }
  1148. oSettings.nTHead = thead[0];
  1149. var tbody = $this.children('tbody');
  1150. if ( tbody.length === 0 )
  1151. {
  1152. tbody = $('<tbody/>').appendTo(this);
  1153. }
  1154. oSettings.nTBody = tbody[0];
  1155. var tfoot = $this.children('tfoot');
  1156. if ( tfoot.length === 0 && captions.length > 0 && (oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "") )
  1157. {
  1158. // If we are a scrolling table, and no footer has been given, then we need to create
  1159. // a tfoot element for the caption element to be appended to
  1160. tfoot = $('<tfoot/>').appendTo(this);
  1161. }
  1162. if ( tfoot.length === 0 || tfoot.children().length === 0 ) {
  1163. $this.addClass( oClasses.sNoFooter );
  1164. }
  1165. else if ( tfoot.length > 0 ) {
  1166. oSettings.nTFoot = tfoot[0];
  1167. _fnDetectHeader( oSettings.aoFooter, oSettings.nTFoot );
  1168. }
  1169. /* Check if there is data passing into the constructor */
  1170. if ( oInit.aaData )
  1171. {
  1172. for ( i=0 ; i<oInit.aaData.length ; i++ )
  1173. {
  1174. _fnAddData( oSettings, oInit.aaData[ i ] );
  1175. }
  1176. }
  1177. else if ( oSettings.bDeferLoading || _fnDataSource( oSettings ) == 'dom' )
  1178. {
  1179. /* Grab the data from the page - only do this when deferred loading or no Ajax
  1180. * source since there is no point in reading the DOM data if we are then going
  1181. * to replace it with Ajax data
  1182. */
  1183. _fnAddTr( oSettings, $(oSettings.nTBody).children('tr') );
  1184. }
  1185. /* Copy the data index array */
  1186. oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
  1187. /* Initialisation complete - table can be drawn */
  1188. oSettings.bInitialised = true;
  1189. /* Check if we need to initialise the table (it might not have been handed off to the
  1190. * language processor)
  1191. */
  1192. if ( bInitHandedOff === false )
  1193. {
  1194. _fnInitialise( oSettings );
  1195. }
  1196. } );
  1197. _that = null;
  1198. return this;
  1199. };
  1200. /*
  1201. * It is useful to have variables which are scoped locally so only the
  1202. * DataTables functions can access them and they don't leak into global space.
  1203. * At the same time these functions are often useful over multiple files in the
  1204. * core and API, so we list, or at least document, all variables which are used
  1205. * by DataTables as private variables here. This also ensures that there is no
  1206. * clashing of variable names and that they can easily referenced for reuse.
  1207. */
  1208. // Defined else where
  1209. // _selector_run
  1210. // _selector_opts
  1211. // _selector_first
  1212. // _selector_row_indexes
  1213. var _ext; // DataTable.ext
  1214. var _Api; // DataTable.Api
  1215. var _api_register; // DataTable.Api.register
  1216. var _api_registerPlural; // DataTable.Api.registerPlural
  1217. var _re_dic = {};
  1218. var _re_new_lines = /[\r\n]/g;
  1219. var _re_html = /<.*?>/g;
  1220. var _re_date_start = /^[\w\+\-]/;
  1221. var _re_date_end = /[\w\+\-]$/;
  1222. // Escape regular expression special characters
  1223. var _re_escape_regex = new RegExp( '(\\' + [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^', '-' ].join('|\\') + ')', 'g' );
  1224. // http://en.wikipedia.org/wiki/Foreign_exchange_market
  1225. // - \u20BD - Russian ruble.
  1226. // - \u20a9 - South Korean Won
  1227. // - \u20BA - Turkish Lira
  1228. // - \u20B9 - Indian Rupee
  1229. // - R - Brazil (R$) and South Africa
  1230. // - fr - Swiss Franc
  1231. // - kr - Swedish krona, Norwegian krone and Danish krone
  1232. // - \u2009 is thin space and \u202F is narrow no-break space, both used in many
  1233. // standards as thousands separators.
  1234. var _re_formatted_numeric = /[',$£€¥%\u2009\u202F\u20BD\u20a9\u20BArfk]/gi;
  1235. var _empty = function ( d ) {
  1236. return !d || d === true || d === '-' ? true : false;
  1237. };
  1238. var _intVal = function ( s ) {
  1239. var integer = parseInt( s, 10 );
  1240. return !isNaN(integer) && isFinite(s) ? integer : null;
  1241. };
  1242. // Convert from a formatted number with characters other than `.` as the
  1243. // decimal place, to a Javascript number
  1244. var _numToDecimal = function ( num, decimalPoint ) {
  1245. // Cache created regular expressions for speed as this function is called often
  1246. if ( ! _re_dic[ decimalPoint ] ) {
  1247. _re_dic[ decimalPoint ] = new RegExp( _fnEscapeRegex( decimalPoint ), 'g' );
  1248. }
  1249. return typeof num === 'string' && decimalPoint !== '.' ?
  1250. num.replace( /\./g, '' ).replace( _re_dic[ decimalPoint ], '.' ) :
  1251. num;
  1252. };
  1253. var _isNumber = function ( d, decimalPoint, formatted ) {
  1254. var strType = typeof d === 'string';
  1255. // If empty return immediately so there must be a number if it is a
  1256. // formatted string (this stops the string "k", or "kr", etc being detected
  1257. // as a formatted number for currency
  1258. if ( _empty( d ) ) {
  1259. return true;
  1260. }
  1261. if ( decimalPoint && strType ) {
  1262. d = _numToDecimal( d, decimalPoint );
  1263. }
  1264. if ( formatted && strType ) {
  1265. d = d.replace( _re_formatted_numeric, '' );
  1266. }
  1267. return !isNaN( parseFloat(d) ) && isFinite( d );
  1268. };
  1269. // A string without HTML in it can be considered to be HTML still
  1270. var _isHtml = function ( d ) {
  1271. return _empty( d ) || typeof d === 'string';
  1272. };
  1273. var _htmlNumeric = function ( d, decimalPoint, formatted ) {
  1274. if ( _empty( d ) ) {
  1275. return true;
  1276. }
  1277. var html = _isHtml( d );
  1278. return ! html ?
  1279. null :
  1280. _isNumber( _stripHtml( d ), decimalPoint, formatted ) ?
  1281. true :
  1282. null;
  1283. };
  1284. var _pluck = function ( a, prop, prop2 ) {
  1285. var out = [];
  1286. var i=0, ien=a.length;
  1287. // Could have the test in the loop for slightly smaller code, but speed
  1288. // is essential here
  1289. if ( prop2 !== undefined ) {
  1290. for ( ; i<ien ; i++ ) {
  1291. if ( a[i] && a[i][ prop ] ) {
  1292. out.push( a[i][ prop ][ prop2 ] );
  1293. }
  1294. }
  1295. }
  1296. else {
  1297. for ( ; i<ien ; i++ ) {
  1298. if ( a[i] ) {
  1299. out.push( a[i][ prop ] );
  1300. }
  1301. }
  1302. }
  1303. return out;
  1304. };
  1305. // Basically the same as _pluck, but rather than looping over `a` we use `order`
  1306. // as the indexes to pick from `a`
  1307. var _pluck_order = function ( a, order, prop, prop2 )
  1308. {
  1309. var out = [];
  1310. var i=0, ien=order.length;
  1311. // Could have the test in the loop for slightly smaller code, but speed
  1312. // is essential here
  1313. if ( prop2 !== undefined ) {
  1314. for ( ; i<ien ; i++ ) {
  1315. if ( a[ order[i] ][ prop ] ) {
  1316. out.push( a[ order[i] ][ prop ][ prop2 ] );
  1317. }
  1318. }
  1319. }
  1320. else {
  1321. for ( ; i<ien ; i++ ) {
  1322. out.push( a[ order[i] ][ prop ] );
  1323. }
  1324. }
  1325. return out;
  1326. };
  1327. var _range = function ( len, start )
  1328. {
  1329. var out = [];
  1330. var end;
  1331. if ( start === undefined ) {
  1332. start = 0;
  1333. end = len;
  1334. }
  1335. else {
  1336. end = start;
  1337. start = len;
  1338. }
  1339. for ( var i=start ; i<end ; i++ ) {
  1340. out.push( i );
  1341. }
  1342. return out;
  1343. };
  1344. var _removeEmpty = function ( a )
  1345. {
  1346. var out = [];
  1347. for ( var i=0, ien=a.length ; i<ien ; i++ ) {
  1348. if ( a[i] ) { // careful - will remove all falsy values!
  1349. out.push( a[i] );
  1350. }
  1351. }
  1352. return out;
  1353. };
  1354. var _stripHtml = function ( d ) {
  1355. return d.replace( _re_html, '' );
  1356. };
  1357. /**
  1358. * Find the unique elements in a source array.
  1359. *
  1360. * @param {array} src Source array
  1361. * @return {array} Array of unique items
  1362. * @ignore
  1363. */
  1364. var _unique = function ( src )
  1365. {
  1366. // A faster unique method is to use object keys to identify used values,
  1367. // but this doesn't work with arrays or objects, which we must also
  1368. // consider. See jsperf.com/compare-array-unique-versions/4 for more
  1369. // information.
  1370. var
  1371. out = [],
  1372. val,
  1373. i, ien=src.length,
  1374. j, k=0;
  1375. again: for ( i=0 ; i<ien ; i++ ) {
  1376. val = src[i];
  1377. for ( j=0 ; j<k ; j++ ) {
  1378. if ( out[j] === val ) {
  1379. continue again;
  1380. }
  1381. }
  1382. out.push( val );
  1383. k++;
  1384. }
  1385. return out;
  1386. };
  1387. /**
  1388. * DataTables utility methods
  1389. *
  1390. * This namespace provides helper methods that DataTables uses internally to
  1391. * create a DataTable, but which are not exclusively used only for DataTables.
  1392. * These methods can be used by extension authors to save the duplication of
  1393. * code.
  1394. *
  1395. * @namespace
  1396. */
  1397. DataTable.util = {
  1398. /**
  1399. * Throttle the calls to a function. Arguments and context are maintained
  1400. * for the throttled function.
  1401. *
  1402. * @param {function} fn Function to be called
  1403. * @param {integer} freq Call frequency in mS
  1404. * @return {function} Wrapped function
  1405. */
  1406. throttle: function ( fn, freq ) {
  1407. var
  1408. frequency = freq !== undefined ? freq : 200,
  1409. last,
  1410. timer;
  1411. return function () {
  1412. var
  1413. that = this,
  1414. now = +new Date(),
  1415. args = arguments;
  1416. if ( last && now < last + frequency ) {
  1417. clearTimeout( timer );
  1418. timer = setTimeout( function () {
  1419. last = undefined;
  1420. fn.apply( that, args );
  1421. }, frequency );
  1422. }
  1423. else {
  1424. last = now;
  1425. fn.apply( that, args );
  1426. }
  1427. };
  1428. },
  1429. /**
  1430. * Escape a string such that it can be used in a regular expression
  1431. *
  1432. * @param {string} val string to escape
  1433. * @returns {string} escaped string
  1434. */
  1435. escapeRegex: function ( val ) {
  1436. return val.replace( _re_escape_regex, '\\$1' );
  1437. }
  1438. };
  1439. /**
  1440. * Create a mapping object that allows camel case parameters to be looked up
  1441. * for their Hungarian counterparts. The mapping is stored in a private
  1442. * parameter called `_hungarianMap` which can be accessed on the source object.
  1443. * @param {object} o
  1444. * @memberof DataTable#oApi
  1445. */
  1446. function _fnHungarianMap ( o )
  1447. {
  1448. var
  1449. hungarian = 'a aa ai ao as b fn i m o s ',
  1450. match,
  1451. newKey,
  1452. map = {};
  1453. $.each( o, function (key, val) {
  1454. match = key.match(/^([^A-Z]+?)([A-Z])/);
  1455. if ( match && hungarian.indexOf(match[1]+' ') !== -1 )
  1456. {
  1457. newKey = key.replace( match[0], match[2].toLowerCase() );
  1458. map[ newKey ] = key;
  1459. if ( match[1] === 'o' )
  1460. {
  1461. _fnHungarianMap( o[key] );
  1462. }
  1463. }
  1464. } );
  1465. o._hungarianMap = map;
  1466. }
  1467. /**
  1468. * Convert from camel case parameters to Hungarian, based on a Hungarian map
  1469. * created by _fnHungarianMap.
  1470. * @param {object} src The model object which holds all parameters that can be
  1471. * mapped.
  1472. * @param {object} user The object to convert from camel case to Hungarian.
  1473. * @param {boolean} force When set to `true`, properties which already have a
  1474. * Hungarian value in the `user` object will be overwritten. Otherwise they
  1475. * won't be.
  1476. * @memberof DataTable#oApi
  1477. */
  1478. function _fnCamelToHungarian ( src, user, force )
  1479. {
  1480. if ( ! src._hungarianMap ) {
  1481. _fnHungarianMap( src );
  1482. }
  1483. var hungarianKey;
  1484. $.each( user, function (key, val) {
  1485. hungarianKey = src._hungarianMap[ key ];
  1486. if ( hungarianKey !== undefined && (force || user[hungarianKey] === undefined) )
  1487. {
  1488. // For objects, we need to buzz down into the object to copy parameters
  1489. if ( hungarianKey.charAt(0) === 'o' )
  1490. {
  1491. // Copy the camelCase options over to the hungarian
  1492. if ( ! user[ hungarianKey ] ) {
  1493. user[ hungarianKey ] = {};
  1494. }
  1495. $.extend( true, user[hungarianKey], user[key] );
  1496. _fnCamelToHungarian( src[hungarianKey], user[hungarianKey], force );
  1497. }
  1498. else {
  1499. user[hungarianKey] = user[ key ];
  1500. }
  1501. }
  1502. } );
  1503. }
  1504. /**
  1505. * Language compatibility - when certain options are given, and others aren't, we
  1506. * need to duplicate the values over, in order to provide backwards compatibility
  1507. * with older language files.
  1508. * @param {object} oSettings dataTables settings object
  1509. * @memberof DataTable#oApi
  1510. */
  1511. function _fnLanguageCompat( lang )
  1512. {
  1513. var defaults = DataTable.defaults.oLanguage;
  1514. var zeroRecords = lang.sZeroRecords;
  1515. /* Backwards compatibility - if there is no sEmptyTable given, then use the same as
  1516. * sZeroRecords - assuming that is given.
  1517. */
  1518. if ( ! lang.sEmptyTable && zeroRecords &&
  1519. defaults.sEmptyTable === "No data available in table" )
  1520. {
  1521. _fnMap( lang, lang, 'sZeroRecords', 'sEmptyTable' );
  1522. }
  1523. /* Likewise with loading records */
  1524. if ( ! lang.sLoadingRecords && zeroRecords &&
  1525. defaults.sLoadingRecords === "Loading..." )
  1526. {
  1527. _fnMap( lang, lang, 'sZeroRecords', 'sLoadingRecords' );
  1528. }
  1529. // Old parameter name of the thousands separator mapped onto the new
  1530. if ( lang.sInfoThousands ) {
  1531. lang.sThousands = lang.sInfoThousands;
  1532. }
  1533. var decimal = lang.sDecimal;
  1534. if ( decimal ) {
  1535. _addNumericSort( decimal );
  1536. }
  1537. }
  1538. /**
  1539. * Map one parameter onto another
  1540. * @param {object} o Object to map
  1541. * @param {*} knew The new parameter name
  1542. * @param {*} old The old parameter name
  1543. */
  1544. var _fnCompatMap = function ( o, knew, old ) {
  1545. if ( o[ knew ] !== undefined ) {
  1546. o[ old ] = o[ knew ];
  1547. }
  1548. };
  1549. /**
  1550. * Provide backwards compatibility for the main DT options. Note that the new
  1551. * options are mapped onto the old parameters, so this is an external interface
  1552. * change only.
  1553. * @param {object} init Object to map
  1554. */
  1555. function _fnCompatOpts ( init )
  1556. {
  1557. _fnCompatMap( init, 'ordering', 'bSort' );
  1558. _fnCompatMap( init, 'orderMulti', 'bSortMulti' );
  1559. _fnCompatMap( init, 'orderClasses', 'bSortClasses' );
  1560. _fnCompatMap( init, 'orderCellsTop', 'bSortCellsTop' );
  1561. _fnCompatMap( init, 'order', 'aaSorting' );
  1562. _fnCompatMap( init, 'orderFixed', 'aaSortingFixed' );
  1563. _fnCompatMap( init, 'paging', 'bPaginate' );
  1564. _fnCompatMap( init, 'pagingType', 'sPaginationType' );
  1565. _fnCompatMap( init, 'pageLength', 'iDisplayLength' );
  1566. _fnCompatMap( init, 'searching', 'bFilter' );
  1567. // Boolean initialisation of x-scrolling
  1568. if ( typeof init.sScrollX === 'boolean' ) {
  1569. init.sScrollX = init.sScrollX ? '100%' : '';
  1570. }
  1571. if ( typeof init.scrollX === 'boolean' ) {
  1572. init.scrollX = init.scrollX ? '100%' : '';
  1573. }
  1574. // Column search objects are in an array, so it needs to be converted
  1575. // element by element
  1576. var searchCols = init.aoSearchCols;
  1577. if ( searchCols ) {
  1578. for ( var i=0, ien=searchCols.length ; i<ien ; i++ ) {
  1579. if ( searchCols[i] ) {
  1580. _fnCamelToHungarian( DataTable.models.oSearch, searchCols[i] );
  1581. }
  1582. }
  1583. }
  1584. }
  1585. /**
  1586. * Provide backwards compatibility for column options. Note that the new options
  1587. * are mapped onto the old parameters, so this is an external interface change
  1588. * only.
  1589. * @param {object} init Object to map
  1590. */
  1591. function _fnCompatCols ( init )
  1592. {
  1593. _fnCompatMap( init, 'orderable', 'bSortable' );
  1594. _fnCompatMap( init, 'orderData', 'aDataSort' );
  1595. _fnCompatMap( init, 'orderSequence', 'asSorting' );
  1596. _fnCompatMap( init, 'orderDataType', 'sortDataType' );
  1597. // orderData can be given as an integer
  1598. var dataSort = init.aDataSort;
  1599. if ( dataSort && ! $.isArray( dataSort ) ) {
  1600. init.aDataSort = [ dataSort ];
  1601. }
  1602. }
  1603. /**
  1604. * Browser feature detection for capabilities, quirks
  1605. * @param {object} settings dataTables settings object
  1606. * @memberof DataTable#oApi
  1607. */
  1608. function _fnBrowserDetect( settings )
  1609. {
  1610. // We don't need to do this every time DataTables is constructed, the values
  1611. // calculated are specific to the browser and OS configuration which we
  1612. // don't expect to change between initialisations
  1613. if ( ! DataTable.__browser ) {
  1614. var browser = {};
  1615. DataTable.__browser = browser;
  1616. // Scrolling feature / quirks detection
  1617. var n = $('<div/>')
  1618. .css( {
  1619. position: 'fixed',
  1620. top: 0,
  1621. left: 0,
  1622. height: 1,
  1623. width: 1,
  1624. overflow: 'hidden'
  1625. } )
  1626. .append(
  1627. $('<div/>')
  1628. .css( {
  1629. position: 'absolute',
  1630. top: 1,
  1631. left: 1,
  1632. width: 100,
  1633. overflow: 'scroll'
  1634. } )
  1635. .append(
  1636. $('<div/>')
  1637. .css( {
  1638. width: '100%',
  1639. height: 10
  1640. } )
  1641. )
  1642. )
  1643. .appendTo( 'body' );
  1644. var outer = n.children();
  1645. var inner = outer.children();
  1646. // Numbers below, in order, are:
  1647. // inner.offsetWidth, inner.clientWidth, outer.offsetWidth, outer.clientWidth
  1648. //
  1649. // IE6 XP: 100 100 100 83
  1650. // IE7 Vista: 100 100 100 83
  1651. // IE 8+ Windows: 83 83 100 83
  1652. // Evergreen Windows: 83 83 100 83
  1653. // Evergreen Mac with scrollbars: 85 85 100 85
  1654. // Evergreen Mac without scrollbars: 100 100 100 100
  1655. // Get scrollbar width
  1656. browser.barWidth = outer[0].offsetWidth - outer[0].clientWidth;
  1657. // IE6/7 will oversize a width 100% element inside a scrolling element, to
  1658. // include the width of the scrollbar, while other browsers ensure the inner
  1659. // element is contained without forcing scrolling
  1660. browser.bScrollOversize = inner[0].offsetWidth === 100 && outer[0].clientWidth !== 100;
  1661. // In rtl text layout, some browsers (most, but not all) will place the
  1662. // scrollbar on the left, rather than the right.
  1663. browser.bScrollbarLeft = Math.round( inner.offset().left ) !== 1;
  1664. // IE8- don't provide height and width for getBoundingClientRect
  1665. browser.bBounding = n[0].getBoundingClientRect().width ? true : false;
  1666. n.remove();
  1667. }
  1668. $.extend( settings.oBrowser, DataTable.__browser );
  1669. settings.oScroll.iBarWidth = DataTable.__browser.barWidth;
  1670. }
  1671. /**
  1672. * Array.prototype reduce[Right] method, used for browsers which don't support
  1673. * JS 1.6. Done this way to reduce code size, since we iterate either way
  1674. * @param {object} settings dataTables settings object
  1675. * @memberof DataTable#oApi
  1676. */
  1677. function _fnReduce ( that, fn, init, start, end, inc )
  1678. {
  1679. var
  1680. i = start,
  1681. value,
  1682. isSet = false;
  1683. if ( init !== undefined ) {
  1684. value = init;
  1685. isSet = true;
  1686. }
  1687. while ( i !== end ) {
  1688. if ( ! that.hasOwnProperty(i) ) {
  1689. continue;
  1690. }
  1691. value = isSet ?
  1692. fn( value, that[i], i, that ) :
  1693. that[i];
  1694. isSet = true;
  1695. i += inc;
  1696. }
  1697. return value;
  1698. }
  1699. /**
  1700. * Add a column to the list used for the table with default values
  1701. * @param {object} oSettings dataTables settings object
  1702. * @param {node} nTh The th element for this column
  1703. * @memberof DataTable#oApi
  1704. */
  1705. function _fnAddColumn( oSettings, nTh )
  1706. {
  1707. // Add column to aoColumns array
  1708. var oDefaults = DataTable.defaults.column;
  1709. var iCol = oSettings.aoColumns.length;
  1710. var oCol = $.extend( {}, DataTable.models.oColumn, oDefaults, {
  1711. "nTh": nTh ? nTh : document.createElement('th'),
  1712. "sTitle": oDefaults.sTitle ? oDefaults.sTitle : nTh ? nTh.innerHTML : '',
  1713. "aDataSort": oDefaults.aDataSort ? oDefaults.aDataSort : [iCol],
  1714. "mData": oDefaults.mData ? oDefaults.mData : iCol,
  1715. idx: iCol
  1716. } );
  1717. oSettings.aoColumns.push( oCol );
  1718. // Add search object for column specific search. Note that the `searchCols[ iCol ]`
  1719. // passed into extend can be undefined. This allows the user to give a default
  1720. // with only some of the parameters defined, and also not give a default
  1721. var searchCols = oSettings.aoPreSearchCols;
  1722. searchCols[ iCol ] = $.extend( {}, DataTable.models.oSearch, searchCols[ iCol ] );
  1723. // Use the default column options function to initialise classes etc
  1724. _fnColumnOptions( oSettings, iCol, $(nTh).data() );
  1725. }
  1726. /**
  1727. * Apply options for a column
  1728. * @param {object} oSettings dataTables settings object
  1729. * @param {int} iCol column index to consider
  1730. * @param {object} oOptions object with sType, bVisible and bSearchable etc
  1731. * @memberof DataTable#oApi
  1732. */
  1733. function _fnColumnOptions( oSettings, iCol, oOptions )
  1734. {
  1735. var oCol = oSettings.aoColumns[ iCol ];
  1736. var oClasses = oSettings.oClasses;
  1737. var th = $(oCol.nTh);
  1738. // Try to get width information from the DOM. We can't get it from CSS
  1739. // as we'd need to parse the CSS stylesheet. `width` option can override
  1740. if ( ! oCol.sWidthOrig ) {
  1741. // Width attribute
  1742. oCol.sWidthOrig = th.attr('width') || null;
  1743. // Style attribute
  1744. var t = (th.attr('style') || '').match(/width:\s*(\d+[pxem%]+)/);
  1745. if ( t ) {
  1746. oCol.sWidthOrig = t[1];
  1747. }
  1748. }
  1749. /* User specified column options */
  1750. if ( oOptions !== undefined && oOptions !== null )
  1751. {
  1752. // Backwards compatibility
  1753. _fnCompatCols( oOptions );
  1754. // Map camel case parameters to their Hungarian counterparts
  1755. _fnCamelToHungarian( DataTable.defaults.column, oOptions );
  1756. /* Backwards compatibility for mDataProp */
  1757. if ( oOptions.mDataProp !== undefined && !oOptions.mData )
  1758. {
  1759. oOptions.mData = oOptions.mDataProp;
  1760. }
  1761. if ( oOptions.sType )
  1762. {
  1763. oCol._sManualType = oOptions.sType;
  1764. }
  1765. // `class` is a reserved word in Javascript, so we need to provide
  1766. // the ability to use a valid name for the camel case input
  1767. if ( oOptions.className && ! oOptions.sClass )
  1768. {
  1769. oOptions.sClass = oOptions.className;
  1770. }
  1771. $.extend( oCol, oOptions );
  1772. _fnMap( oCol, oOptions, "sWidth", "sWidthOrig" );
  1773. /* iDataSort to be applied (backwards compatibility), but aDataSort will take
  1774. * priority if defined
  1775. */
  1776. if ( oOptions.iDataSort !== undefined )
  1777. {
  1778. oCol.aDataSort = [ oOptions.iDataSort ];
  1779. }
  1780. _fnMap( oCol, oOptions, "aDataSort" );
  1781. }
  1782. /* Cache the data get and set functions for speed */
  1783. var mDataSrc = oCol.mData;
  1784. var mData = _fnGetObjectDataFn( mDataSrc );
  1785. var mRender = oCol.mRender ? _fnGetObjectDataFn( oCol.mRender ) : null;
  1786. var attrTest = function( src ) {
  1787. return typeof src === 'string' && src.indexOf('@') !== -1;
  1788. };
  1789. oCol._bAttrSrc = $.isPlainObject( mDataSrc ) && (
  1790. attrTest(mDataSrc.sort) || attrTest(mDataSrc.type) || attrTest(mDataSrc.filter)
  1791. );
  1792. oCol._setter = null;
  1793. oCol.fnGetData = function (rowData, type, meta) {
  1794. var innerData = mData( rowData, type, undefined, meta );
  1795. return mRender && type ?
  1796. mRender( innerData, type, rowData, meta ) :
  1797. innerData;
  1798. };
  1799. oCol.fnSetData = function ( rowData, val, meta ) {
  1800. return _fnSetObjectDataFn( mDataSrc )( rowData, val, meta );
  1801. };
  1802. // Indicate if DataTables should read DOM data as an object or array
  1803. // Used in _fnGetRowElements
  1804. if ( typeof mDataSrc !== 'number' ) {
  1805. oSettings._rowReadObject = true;
  1806. }
  1807. /* Feature sorting overrides column specific when off */
  1808. if ( !oSettings.oFeatures.bSort )
  1809. {
  1810. oCol.bSortable = false;
  1811. th.addClass( oClasses.sSortableNone ); // Have to add class here as order event isn't called
  1812. }
  1813. /* Check that the class assignment is correct for sorting */
  1814. var bAsc = $.inArray('asc', oCol.asSorting) !== -1;
  1815. var bDesc = $.inArray('desc', oCol.asSorting) !== -1;
  1816. if ( !oCol.bSortable || (!bAsc && !bDesc) )
  1817. {
  1818. oCol.sSortingClass = oClasses.sSortableNone;
  1819. oCol.sSortingClassJUI = "";
  1820. }
  1821. else if ( bAsc && !bDesc )
  1822. {
  1823. oCol.sSortingClass = oClasses.sSortableAsc;
  1824. oCol.sSortingClassJUI = oClasses.sSortJUIAscAllowed;
  1825. }
  1826. else if ( !bAsc && bDesc )
  1827. {
  1828. oCol.sSortingClass = oClasses.sSortableDesc;
  1829. oCol.sSortingClassJUI = oClasses.sSortJUIDescAllowed;
  1830. }
  1831. else
  1832. {
  1833. oCol.sSortingClass = oClasses.sSortable;
  1834. oCol.sSortingClassJUI = oClasses.sSortJUI;
  1835. }
  1836. }
  1837. /**
  1838. * Adjust the table column widths for new data. Note: you would probably want to
  1839. * do a redraw after calling this function!
  1840. * @param {object} settings dataTables settings object
  1841. * @memberof DataTable#oApi
  1842. */
  1843. function _fnAdjustColumnSizing ( settings )
  1844. {
  1845. /* Not interested in doing column width calculation if auto-width is disabled */
  1846. if ( settings.oFeatures.bAutoWidth !== false )
  1847. {
  1848. var columns = settings.aoColumns;
  1849. _fnCalculateColumnWidths( settings );
  1850. for ( var i=0 , iLen=columns.length ; i<iLen ; i++ )
  1851. {
  1852. columns[i].nTh.style.width = columns[i].sWidth;
  1853. }
  1854. }
  1855. var scroll = settings.oScroll;
  1856. if ( scroll.sY !== '' || scroll.sX !== '')
  1857. {
  1858. _fnScrollDraw( settings );
  1859. }
  1860. _fnCallbackFire( settings, null, 'column-sizing', [settings] );
  1861. }
  1862. /**
  1863. * Covert the index of a visible column to the index in the data array (take account
  1864. * of hidden columns)
  1865. * @param {object} oSettings dataTables settings object
  1866. * @param {int} iMatch Visible column index to lookup
  1867. * @returns {int} i the data index
  1868. * @memberof DataTable#oApi
  1869. */
  1870. function _fnVisibleToColumnIndex( oSettings, iMatch )
  1871. {
  1872. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  1873. return typeof aiVis[iMatch] === 'number' ?
  1874. aiVis[iMatch] :
  1875. null;
  1876. }
  1877. /**
  1878. * Covert the index of an index in the data array and convert it to the visible
  1879. * column index (take account of hidden columns)
  1880. * @param {int} iMatch Column index to lookup
  1881. * @param {object} oSettings dataTables settings object
  1882. * @returns {int} i the data index
  1883. * @memberof DataTable#oApi
  1884. */
  1885. function _fnColumnIndexToVisible( oSettings, iMatch )
  1886. {
  1887. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  1888. var iPos = $.inArray( iMatch, aiVis );
  1889. return iPos !== -1 ? iPos : null;
  1890. }
  1891. /**
  1892. * Get the number of visible columns
  1893. * @param {object} oSettings dataTables settings object
  1894. * @returns {int} i the number of visible columns
  1895. * @memberof DataTable#oApi
  1896. */
  1897. function _fnVisbleColumns( oSettings )
  1898. {
  1899. var vis = 0;
  1900. // No reduce in IE8, use a loop for now
  1901. $.each( oSettings.aoColumns, function ( i, col ) {
  1902. if ( col.bVisible && $(col.nTh).css('display') !== 'none' ) {
  1903. vis++;
  1904. }
  1905. } );
  1906. return vis;
  1907. }
  1908. /**
  1909. * Get an array of column indexes that match a given property
  1910. * @param {object} oSettings dataTables settings object
  1911. * @param {string} sParam Parameter in aoColumns to look for - typically
  1912. * bVisible or bSearchable
  1913. * @returns {array} Array of indexes with matched properties
  1914. * @memberof DataTable#oApi
  1915. */
  1916. function _fnGetColumns( oSettings, sParam )
  1917. {
  1918. var a = [];
  1919. $.map( oSettings.aoColumns, function(val, i) {
  1920. if ( val[sParam] ) {
  1921. a.push( i );
  1922. }
  1923. } );
  1924. return a;
  1925. }
  1926. /**
  1927. * Calculate the 'type' of a column
  1928. * @param {object} settings dataTables settings object
  1929. * @memberof DataTable#oApi
  1930. */
  1931. function _fnColumnTypes ( settings )
  1932. {
  1933. var columns = settings.aoColumns;
  1934. var data = settings.aoData;
  1935. var types = DataTable.ext.type.detect;
  1936. var i, ien, j, jen, k, ken;
  1937. var col, cell, detectedType, cache;
  1938. // For each column, spin over the
  1939. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  1940. col = columns[i];
  1941. cache = [];
  1942. if ( ! col.sType && col._sManualType ) {
  1943. col.sType = col._sManualType;
  1944. }
  1945. else if ( ! col.sType ) {
  1946. for ( j=0, jen=types.length ; j<jen ; j++ ) {
  1947. for ( k=0, ken=data.length ; k<ken ; k++ ) {
  1948. // Use a cache array so we only need to get the type data
  1949. // from the formatter once (when using multiple detectors)
  1950. if ( cache[k] === undefined ) {
  1951. cache[k] = _fnGetCellData( settings, k, i, 'type' );
  1952. }
  1953. detectedType = types[j]( cache[k], settings );
  1954. // If null, then this type can't apply to this column, so
  1955. // rather than testing all cells, break out. There is an
  1956. // exception for the last type which is `html`. We need to
  1957. // scan all rows since it is possible to mix string and HTML
  1958. // types
  1959. if ( ! detectedType && j !== types.length-1 ) {
  1960. break;
  1961. }
  1962. // Only a single match is needed for html type since it is
  1963. // bottom of the pile and very similar to string
  1964. if ( detectedType === 'html' ) {
  1965. break;
  1966. }
  1967. }
  1968. // Type is valid for all data points in the column - use this
  1969. // type
  1970. if ( detectedType ) {
  1971. col.sType = detectedType;
  1972. break;
  1973. }
  1974. }
  1975. // Fall back - if no type was detected, always use string
  1976. if ( ! col.sType ) {
  1977. col.sType = 'string';
  1978. }
  1979. }
  1980. }
  1981. }
  1982. /**
  1983. * Take the column definitions and static columns arrays and calculate how
  1984. * they relate to column indexes. The callback function will then apply the
  1985. * definition found for a column to a suitable configuration object.
  1986. * @param {object} oSettings dataTables settings object
  1987. * @param {array} aoColDefs The aoColumnDefs array that is to be applied
  1988. * @param {array} aoCols The aoColumns array that defines columns individually
  1989. * @param {function} fn Callback function - takes two parameters, the calculated
  1990. * column index and the definition for that column.
  1991. * @memberof DataTable#oApi
  1992. */
  1993. function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, fn )
  1994. {
  1995. var i, iLen, j, jLen, k, kLen, def;
  1996. var columns = oSettings.aoColumns;
  1997. // Column definitions with aTargets
  1998. if ( aoColDefs )
  1999. {
  2000. /* Loop over the definitions array - loop in reverse so first instance has priority */
  2001. for ( i=aoColDefs.length-1 ; i>=0 ; i-- )
  2002. {
  2003. def = aoColDefs[i];
  2004. /* Each definition can target multiple columns, as it is an array */
  2005. var aTargets = def.targets !== undefined ?
  2006. def.targets :
  2007. def.aTargets;
  2008. if ( ! $.isArray( aTargets ) )
  2009. {
  2010. aTargets = [ aTargets ];
  2011. }
  2012. for ( j=0, jLen=aTargets.length ; j<jLen ; j++ )
  2013. {
  2014. if ( typeof aTargets[j] === 'number' && aTargets[j] >= 0 )
  2015. {
  2016. /* Add columns that we don't yet know about */
  2017. while( columns.length <= aTargets[j] )
  2018. {
  2019. _fnAddColumn( oSettings );
  2020. }
  2021. /* Integer, basic index */
  2022. fn( aTargets[j], def );
  2023. }
  2024. else if ( typeof aTargets[j] === 'number' && aTargets[j] < 0 )
  2025. {
  2026. /* Negative integer, right to left column counting */
  2027. fn( columns.length+aTargets[j], def );
  2028. }
  2029. else if ( typeof aTargets[j] === 'string' )
  2030. {
  2031. /* Class name matching on TH element */
  2032. for ( k=0, kLen=columns.length ; k<kLen ; k++ )
  2033. {
  2034. if ( aTargets[j] == "_all" ||
  2035. $(columns[k].nTh).hasClass( aTargets[j] ) )
  2036. {
  2037. fn( k, def );
  2038. }
  2039. }
  2040. }
  2041. }
  2042. }
  2043. }
  2044. // Statically defined columns array
  2045. if ( aoCols )
  2046. {
  2047. for ( i=0, iLen=aoCols.length ; i<iLen ; i++ )
  2048. {
  2049. fn( i, aoCols[i] );
  2050. }
  2051. }
  2052. }
  2053. /**
  2054. * Add a data array to the table, creating DOM node etc. This is the parallel to
  2055. * _fnGatherData, but for adding rows from a Javascript source, rather than a
  2056. * DOM source.
  2057. * @param {object} oSettings dataTables settings object
  2058. * @param {array} aData data array to be added
  2059. * @param {node} [nTr] TR element to add to the table - optional. If not given,
  2060. * DataTables will create a row automatically
  2061. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  2062. * if nTr is.
  2063. * @returns {int} >=0 if successful (index of new aoData entry), -1 if failed
  2064. * @memberof DataTable#oApi
  2065. */
  2066. function _fnAddData ( oSettings, aDataIn, nTr, anTds )
  2067. {
  2068. /* Create the object for storing information about this new row */
  2069. var iRow = oSettings.aoData.length;
  2070. var oData = $.extend( true, {}, DataTable.models.oRow, {
  2071. src: nTr ? 'dom' : 'data',
  2072. idx: iRow
  2073. } );
  2074. oData._aData = aDataIn;
  2075. oSettings.aoData.push( oData );
  2076. /* Create the cells */
  2077. var nTd, sThisType;
  2078. var columns = oSettings.aoColumns;
  2079. // Invalidate the column types as the new data needs to be revalidated
  2080. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  2081. {
  2082. columns[i].sType = null;
  2083. }
  2084. /* Add to the display array */
  2085. oSettings.aiDisplayMaster.push( iRow );
  2086. var id = oSettings.rowIdFn( aDataIn );
  2087. if ( id !== undefined ) {
  2088. oSettings.aIds[ id ] = oData;
  2089. }
  2090. /* Create the DOM information, or register it if already present */
  2091. if ( nTr || ! oSettings.oFeatures.bDeferRender )
  2092. {
  2093. _fnCreateTr( oSettings, iRow, nTr, anTds );
  2094. }
  2095. return iRow;
  2096. }
  2097. /**
  2098. * Add one or more TR elements to the table. Generally we'd expect to
  2099. * use this for reading data from a DOM sourced table, but it could be
  2100. * used for an TR element. Note that if a TR is given, it is used (i.e.
  2101. * it is not cloned).
  2102. * @param {object} settings dataTables settings object
  2103. * @param {array|node|jQuery} trs The TR element(s) to add to the table
  2104. * @returns {array} Array of indexes for the added rows
  2105. * @memberof DataTable#oApi
  2106. */
  2107. function _fnAddTr( settings, trs )
  2108. {
  2109. var row;
  2110. // Allow an individual node to be passed in
  2111. if ( ! (trs instanceof $) ) {
  2112. trs = $(trs);
  2113. }
  2114. return trs.map( function (i, el) {
  2115. row = _fnGetRowElements( settings, el );
  2116. return _fnAddData( settings, row.data, el, row.cells );
  2117. } );
  2118. }
  2119. /**
  2120. * Take a TR element and convert it to an index in aoData
  2121. * @param {object} oSettings dataTables settings object
  2122. * @param {node} n the TR element to find
  2123. * @returns {int} index if the node is found, null if not
  2124. * @memberof DataTable#oApi
  2125. */
  2126. function _fnNodeToDataIndex( oSettings, n )
  2127. {
  2128. return (n._DT_RowIndex!==undefined) ? n._DT_RowIndex : null;
  2129. }
  2130. /**
  2131. * Take a TD element and convert it into a column data index (not the visible index)
  2132. * @param {object} oSettings dataTables settings object
  2133. * @param {int} iRow The row number the TD/TH can be found in
  2134. * @param {node} n The TD/TH element to find
  2135. * @returns {int} index if the node is found, -1 if not
  2136. * @memberof DataTable#oApi
  2137. */
  2138. function _fnNodeToColumnIndex( oSettings, iRow, n )
  2139. {
  2140. return $.inArray( n, oSettings.aoData[ iRow ].anCells );
  2141. }
  2142. /**
  2143. * Get the data for a given cell from the internal cache, taking into account data mapping
  2144. * @param {object} settings dataTables settings object
  2145. * @param {int} rowIdx aoData row id
  2146. * @param {int} colIdx Column index
  2147. * @param {string} type data get type ('display', 'type' 'filter' 'sort')
  2148. * @returns {*} Cell data
  2149. * @memberof DataTable#oApi
  2150. */
  2151. function _fnGetCellData( settings, rowIdx, colIdx, type )
  2152. {
  2153. var draw = settings.iDraw;
  2154. var col = settings.aoColumns[colIdx];
  2155. var rowData = settings.aoData[rowIdx]._aData;
  2156. var defaultContent = col.sDefaultContent;
  2157. var cellData = col.fnGetData( rowData, type, {
  2158. settings: settings,
  2159. row: rowIdx,
  2160. col: colIdx
  2161. } );
  2162. if ( cellData === undefined ) {
  2163. if ( settings.iDrawError != draw && defaultContent === null ) {
  2164. _fnLog( settings, 0, "Requested unknown parameter "+
  2165. (typeof col.mData=='function' ? '{function}' : "'"+col.mData+"'")+
  2166. " for row "+rowIdx+", column "+colIdx, 4 );
  2167. settings.iDrawError = draw;
  2168. }
  2169. return defaultContent;
  2170. }
  2171. // When the data source is null and a specific data type is requested (i.e.
  2172. // not the original data), we can use default column data
  2173. if ( (cellData === rowData || cellData === null) && defaultContent !== null && type !== undefined ) {
  2174. cellData = defaultContent;
  2175. }
  2176. else if ( typeof cellData === 'function' ) {
  2177. // If the data source is a function, then we run it and use the return,
  2178. // executing in the scope of the data object (for instances)
  2179. return cellData.call( rowData );
  2180. }
  2181. if ( cellData === null && type == 'display' ) {
  2182. return '';
  2183. }
  2184. return cellData;
  2185. }
  2186. /**
  2187. * Set the value for a specific cell, into the internal data cache
  2188. * @param {object} settings dataTables settings object
  2189. * @param {int} rowIdx aoData row id
  2190. * @param {int} colIdx Column index
  2191. * @param {*} val Value to set
  2192. * @memberof DataTable#oApi
  2193. */
  2194. function _fnSetCellData( settings, rowIdx, colIdx, val )
  2195. {
  2196. var col = settings.aoColumns[colIdx];
  2197. var rowData = settings.aoData[rowIdx]._aData;
  2198. col.fnSetData( rowData, val, {
  2199. settings: settings,
  2200. row: rowIdx,
  2201. col: colIdx
  2202. } );
  2203. }
  2204. // Private variable that is used to match action syntax in the data property object
  2205. var __reArray = /\[.*?\]$/;
  2206. var __reFn = /\(\)$/;
  2207. /**
  2208. * Split string on periods, taking into account escaped periods
  2209. * @param {string} str String to split
  2210. * @return {array} Split string
  2211. */
  2212. function _fnSplitObjNotation( str )
  2213. {
  2214. return $.map( str.match(/(\\.|[^\.])+/g) || [''], function ( s ) {
  2215. return s.replace(/\\./g, '.');
  2216. } );
  2217. }
  2218. /**
  2219. * Return a function that can be used to get data from a source object, taking
  2220. * into account the ability to use nested objects as a source
  2221. * @param {string|int|function} mSource The data source for the object
  2222. * @returns {function} Data get function
  2223. * @memberof DataTable#oApi
  2224. */
  2225. function _fnGetObjectDataFn( mSource )
  2226. {
  2227. if ( $.isPlainObject( mSource ) )
  2228. {
  2229. /* Build an object of get functions, and wrap them in a single call */
  2230. var o = {};
  2231. $.each( mSource, function (key, val) {
  2232. if ( val ) {
  2233. o[key] = _fnGetObjectDataFn( val );
  2234. }
  2235. } );
  2236. return function (data, type, row, meta) {
  2237. var t = o[type] || o._;
  2238. return t !== undefined ?
  2239. t(data, type, row, meta) :
  2240. data;
  2241. };
  2242. }
  2243. else if ( mSource === null )
  2244. {
  2245. /* Give an empty string for rendering / sorting etc */
  2246. return function (data) { // type, row and meta also passed, but not used
  2247. return data;
  2248. };
  2249. }
  2250. else if ( typeof mSource === 'function' )
  2251. {
  2252. return function (data, type, row, meta) {
  2253. return mSource( data, type, row, meta );
  2254. };
  2255. }
  2256. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  2257. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  2258. {
  2259. /* If there is a . in the source string then the data source is in a
  2260. * nested object so we loop over the data for each level to get the next
  2261. * level down. On each loop we test for undefined, and if found immediately
  2262. * return. This allows entire objects to be missing and sDefaultContent to
  2263. * be used if defined, rather than throwing an error
  2264. */
  2265. var fetchData = function (data, type, src) {
  2266. var arrayNotation, funcNotation, out, innerSrc;
  2267. if ( src !== "" )
  2268. {
  2269. var a = _fnSplitObjNotation( src );
  2270. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  2271. {
  2272. // Check if we are dealing with special notation
  2273. arrayNotation = a[i].match(__reArray);
  2274. funcNotation = a[i].match(__reFn);
  2275. if ( arrayNotation )
  2276. {
  2277. // Array notation
  2278. a[i] = a[i].replace(__reArray, '');
  2279. // Condition allows simply [] to be passed in
  2280. if ( a[i] !== "" ) {
  2281. data = data[ a[i] ];
  2282. }
  2283. out = [];
  2284. // Get the remainder of the nested object to get
  2285. a.splice( 0, i+1 );
  2286. innerSrc = a.join('.');
  2287. // Traverse each entry in the array getting the properties requested
  2288. if ( $.isArray( data ) ) {
  2289. for ( var j=0, jLen=data.length ; j<jLen ; j++ ) {
  2290. out.push( fetchData( data[j], type, innerSrc ) );
  2291. }
  2292. }
  2293. // If a string is given in between the array notation indicators, that
  2294. // is used to join the strings together, otherwise an array is returned
  2295. var join = arrayNotation[0].substring(1, arrayNotation[0].length-1);
  2296. data = (join==="") ? out : out.join(join);
  2297. // The inner call to fetchData has already traversed through the remainder
  2298. // of the source requested, so we exit from the loop
  2299. break;
  2300. }
  2301. else if ( funcNotation )
  2302. {
  2303. // Function call
  2304. a[i] = a[i].replace(__reFn, '');
  2305. data = data[ a[i] ]();
  2306. continue;
  2307. }
  2308. if ( data === null || data[ a[i] ] === undefined )
  2309. {
  2310. return undefined;
  2311. }
  2312. data = data[ a[i] ];
  2313. }
  2314. }
  2315. return data;
  2316. };
  2317. return function (data, type) { // row and meta also passed, but not used
  2318. return fetchData( data, type, mSource );
  2319. };
  2320. }
  2321. else
  2322. {
  2323. /* Array or flat object mapping */
  2324. return function (data, type) { // row and meta also passed, but not used
  2325. return data[mSource];
  2326. };
  2327. }
  2328. }
  2329. /**
  2330. * Return a function that can be used to set data from a source object, taking
  2331. * into account the ability to use nested objects as a source
  2332. * @param {string|int|function} mSource The data source for the object
  2333. * @returns {function} Data set function
  2334. * @memberof DataTable#oApi
  2335. */
  2336. function _fnSetObjectDataFn( mSource )
  2337. {
  2338. if ( $.isPlainObject( mSource ) )
  2339. {
  2340. /* Unlike get, only the underscore (global) option is used for for
  2341. * setting data since we don't know the type here. This is why an object
  2342. * option is not documented for `mData` (which is read/write), but it is
  2343. * for `mRender` which is read only.
  2344. */
  2345. return _fnSetObjectDataFn( mSource._ );
  2346. }
  2347. else if ( mSource === null )
  2348. {
  2349. /* Nothing to do when the data source is null */
  2350. return function () {};
  2351. }
  2352. else if ( typeof mSource === 'function' )
  2353. {
  2354. return function (data, val, meta) {
  2355. mSource( data, 'set', val, meta );
  2356. };
  2357. }
  2358. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  2359. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  2360. {
  2361. /* Like the get, we need to get data from a nested object */
  2362. var setData = function (data, val, src) {
  2363. var a = _fnSplitObjNotation( src ), b;
  2364. var aLast = a[a.length-1];
  2365. var arrayNotation, funcNotation, o, innerSrc;
  2366. for ( var i=0, iLen=a.length-1 ; i<iLen ; i++ )
  2367. {
  2368. // Check if we are dealing with an array notation request
  2369. arrayNotation = a[i].match(__reArray);
  2370. funcNotation = a[i].match(__reFn);
  2371. if ( arrayNotation )
  2372. {
  2373. a[i] = a[i].replace(__reArray, '');
  2374. data[ a[i] ] = [];
  2375. // Get the remainder of the nested object to set so we can recurse
  2376. b = a.slice();
  2377. b.splice( 0, i+1 );
  2378. innerSrc = b.join('.');
  2379. // Traverse each entry in the array setting the properties requested
  2380. if ( $.isArray( val ) )
  2381. {
  2382. for ( var j=0, jLen=val.length ; j<jLen ; j++ )
  2383. {
  2384. o = {};
  2385. setData( o, val[j], innerSrc );
  2386. data[ a[i] ].push( o );
  2387. }
  2388. }
  2389. else
  2390. {
  2391. // We've been asked to save data to an array, but it
  2392. // isn't array data to be saved. Best that can be done
  2393. // is to just save the value.
  2394. data[ a[i] ] = val;
  2395. }
  2396. // The inner call to setData has already traversed through the remainder
  2397. // of the source and has set the data, thus we can exit here
  2398. return;
  2399. }
  2400. else if ( funcNotation )
  2401. {
  2402. // Function call
  2403. a[i] = a[i].replace(__reFn, '');
  2404. data = data[ a[i] ]( val );
  2405. }
  2406. // If the nested object doesn't currently exist - since we are
  2407. // trying to set the value - create it
  2408. if ( data[ a[i] ] === null || data[ a[i] ] === undefined )
  2409. {
  2410. data[ a[i] ] = {};
  2411. }
  2412. data = data[ a[i] ];
  2413. }
  2414. // Last item in the input - i.e, the actual set
  2415. if ( aLast.match(__reFn ) )
  2416. {
  2417. // Function call
  2418. data = data[ aLast.replace(__reFn, '') ]( val );
  2419. }
  2420. else
  2421. {
  2422. // If array notation is used, we just want to strip it and use the property name
  2423. // and assign the value. If it isn't used, then we get the result we want anyway
  2424. data[ aLast.replace(__reArray, '') ] = val;
  2425. }
  2426. };
  2427. return function (data, val) { // meta is also passed in, but not used
  2428. return setData( data, val, mSource );
  2429. };
  2430. }
  2431. else
  2432. {
  2433. /* Array or flat object mapping */
  2434. return function (data, val) { // meta is also passed in, but not used
  2435. data[mSource] = val;
  2436. };
  2437. }
  2438. }
  2439. /**
  2440. * Return an array with the full table data
  2441. * @param {object} oSettings dataTables settings object
  2442. * @returns array {array} aData Master data array
  2443. * @memberof DataTable#oApi
  2444. */
  2445. function _fnGetDataMaster ( settings )
  2446. {
  2447. return _pluck( settings.aoData, '_aData' );
  2448. }
  2449. /**
  2450. * Nuke the table
  2451. * @param {object} oSettings dataTables settings object
  2452. * @memberof DataTable#oApi
  2453. */
  2454. function _fnClearTable( settings )
  2455. {
  2456. settings.aoData.length = 0;
  2457. settings.aiDisplayMaster.length = 0;
  2458. settings.aiDisplay.length = 0;
  2459. settings.aIds = {};
  2460. }
  2461. /**
  2462. * Take an array of integers (index array) and remove a target integer (value - not
  2463. * the key!)
  2464. * @param {array} a Index array to target
  2465. * @param {int} iTarget value to find
  2466. * @memberof DataTable#oApi
  2467. */
  2468. function _fnDeleteIndex( a, iTarget, splice )
  2469. {
  2470. var iTargetIndex = -1;
  2471. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  2472. {
  2473. if ( a[i] == iTarget )
  2474. {
  2475. iTargetIndex = i;
  2476. }
  2477. else if ( a[i] > iTarget )
  2478. {
  2479. a[i]--;
  2480. }
  2481. }
  2482. if ( iTargetIndex != -1 && splice === undefined )
  2483. {
  2484. a.splice( iTargetIndex, 1 );
  2485. }
  2486. }
  2487. /**
  2488. * Mark cached data as invalid such that a re-read of the data will occur when
  2489. * the cached data is next requested. Also update from the data source object.
  2490. *
  2491. * @param {object} settings DataTables settings object
  2492. * @param {int} rowIdx Row index to invalidate
  2493. * @param {string} [src] Source to invalidate from: undefined, 'auto', 'dom'
  2494. * or 'data'
  2495. * @param {int} [colIdx] Column index to invalidate. If undefined the whole
  2496. * row will be invalidated
  2497. * @memberof DataTable#oApi
  2498. *
  2499. * @todo For the modularisation of v1.11 this will need to become a callback, so
  2500. * the sort and filter methods can subscribe to it. That will required
  2501. * initialisation options for sorting, which is why it is not already baked in
  2502. */
  2503. function _fnInvalidate( settings, rowIdx, src, colIdx )
  2504. {
  2505. var row = settings.aoData[ rowIdx ];
  2506. var i, ien;
  2507. var cellWrite = function ( cell, col ) {
  2508. // This is very frustrating, but in IE if you just write directly
  2509. // to innerHTML, and elements that are overwritten are GC'ed,
  2510. // even if there is a reference to them elsewhere
  2511. while ( cell.childNodes.length ) {
  2512. cell.removeChild( cell.firstChild );
  2513. }
  2514. cell.innerHTML = _fnGetCellData( settings, rowIdx, col, 'display' );
  2515. };
  2516. // Are we reading last data from DOM or the data object?
  2517. if ( src === 'dom' || ((! src || src === 'auto') && row.src === 'dom') ) {
  2518. // Read the data from the DOM
  2519. row._aData = _fnGetRowElements(
  2520. settings, row, colIdx, colIdx === undefined ? undefined : row._aData
  2521. )
  2522. .data;
  2523. }
  2524. else {
  2525. // Reading from data object, update the DOM
  2526. var cells = row.anCells;
  2527. if ( cells ) {
  2528. if ( colIdx !== undefined ) {
  2529. cellWrite( cells[colIdx], colIdx );
  2530. }
  2531. else {
  2532. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  2533. cellWrite( cells[i], i );
  2534. }
  2535. }
  2536. }
  2537. }
  2538. // For both row and cell invalidation, the cached data for sorting and
  2539. // filtering is nulled out
  2540. row._aSortData = null;
  2541. row._aFilterData = null;
  2542. // Invalidate the type for a specific column (if given) or all columns since
  2543. // the data might have changed
  2544. var cols = settings.aoColumns;
  2545. if ( colIdx !== undefined ) {
  2546. cols[ colIdx ].sType = null;
  2547. }
  2548. else {
  2549. for ( i=0, ien=cols.length ; i<ien ; i++ ) {
  2550. cols[i].sType = null;
  2551. }
  2552. // Update DataTables special `DT_*` attributes for the row
  2553. _fnRowAttributes( settings, row );
  2554. }
  2555. }
  2556. /**
  2557. * Build a data source object from an HTML row, reading the contents of the
  2558. * cells that are in the row.
  2559. *
  2560. * @param {object} settings DataTables settings object
  2561. * @param {node|object} TR element from which to read data or existing row
  2562. * object from which to re-read the data from the cells
  2563. * @param {int} [colIdx] Optional column index
  2564. * @param {array|object} [d] Data source object. If `colIdx` is given then this
  2565. * parameter should also be given and will be used to write the data into.
  2566. * Only the column in question will be written
  2567. * @returns {object} Object with two parameters: `data` the data read, in
  2568. * document order, and `cells` and array of nodes (they can be useful to the
  2569. * caller, so rather than needing a second traversal to get them, just return
  2570. * them from here).
  2571. * @memberof DataTable#oApi
  2572. */
  2573. function _fnGetRowElements( settings, row, colIdx, d )
  2574. {
  2575. var
  2576. tds = [],
  2577. td = row.firstChild,
  2578. name, col, o, i=0, contents,
  2579. columns = settings.aoColumns,
  2580. objectRead = settings._rowReadObject;
  2581. // Allow the data object to be passed in, or construct
  2582. d = d !== undefined ?
  2583. d :
  2584. objectRead ?
  2585. {} :
  2586. [];
  2587. var attr = function ( str, td ) {
  2588. if ( typeof str === 'string' ) {
  2589. var idx = str.indexOf('@');
  2590. if ( idx !== -1 ) {
  2591. var attr = str.substring( idx+1 );
  2592. var setter = _fnSetObjectDataFn( str );
  2593. setter( d, td.getAttribute( attr ) );
  2594. }
  2595. }
  2596. };
  2597. // Read data from a cell and store into the data object
  2598. var cellProcess = function ( cell ) {
  2599. if ( colIdx === undefined || colIdx === i ) {
  2600. col = columns[i];
  2601. contents = $.trim(cell.innerHTML);
  2602. if ( col && col._bAttrSrc ) {
  2603. var setter = _fnSetObjectDataFn( col.mData._ );
  2604. setter( d, contents );
  2605. attr( col.mData.sort, cell );
  2606. attr( col.mData.type, cell );
  2607. attr( col.mData.filter, cell );
  2608. }
  2609. else {
  2610. // Depending on the `data` option for the columns the data can
  2611. // be read to either an object or an array.
  2612. if ( objectRead ) {
  2613. if ( ! col._setter ) {
  2614. // Cache the setter function
  2615. col._setter = _fnSetObjectDataFn( col.mData );
  2616. }
  2617. col._setter( d, contents );
  2618. }
  2619. else {
  2620. d[i] = contents;
  2621. }
  2622. }
  2623. }
  2624. i++;
  2625. };
  2626. if ( td ) {
  2627. // `tr` element was passed in
  2628. while ( td ) {
  2629. name = td.nodeName.toUpperCase();
  2630. if ( name == "TD" || name == "TH" ) {
  2631. cellProcess( td );
  2632. tds.push( td );
  2633. }
  2634. td = td.nextSibling;
  2635. }
  2636. }
  2637. else {
  2638. // Existing row object passed in
  2639. tds = row.anCells;
  2640. for ( var j=0, jen=tds.length ; j<jen ; j++ ) {
  2641. cellProcess( tds[j] );
  2642. }
  2643. }
  2644. // Read the ID from the DOM if present
  2645. var rowNode = row.firstChild ? row : row.nTr;
  2646. if ( rowNode ) {
  2647. var id = rowNode.getAttribute( 'id' );
  2648. if ( id ) {
  2649. _fnSetObjectDataFn( settings.rowId )( d, id );
  2650. }
  2651. }
  2652. return {
  2653. data: d,
  2654. cells: tds
  2655. };
  2656. }
  2657. /**
  2658. * Create a new TR element (and it's TD children) for a row
  2659. * @param {object} oSettings dataTables settings object
  2660. * @param {int} iRow Row to consider
  2661. * @param {node} [nTrIn] TR element to add to the table - optional. If not given,
  2662. * DataTables will create a row automatically
  2663. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  2664. * if nTr is.
  2665. * @memberof DataTable#oApi
  2666. */
  2667. function _fnCreateTr ( oSettings, iRow, nTrIn, anTds )
  2668. {
  2669. var
  2670. row = oSettings.aoData[iRow],
  2671. rowData = row._aData,
  2672. cells = [],
  2673. nTr, nTd, oCol,
  2674. i, iLen;
  2675. if ( row.nTr === null )
  2676. {
  2677. nTr = nTrIn || document.createElement('tr');
  2678. row.nTr = nTr;
  2679. row.anCells = cells;
  2680. /* Use a private property on the node to allow reserve mapping from the node
  2681. * to the aoData array for fast look up
  2682. */
  2683. nTr._DT_RowIndex = iRow;
  2684. /* Special parameters can be given by the data source to be used on the row */
  2685. _fnRowAttributes( oSettings, row );
  2686. /* Process each column */
  2687. for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
  2688. {
  2689. oCol = oSettings.aoColumns[i];
  2690. nTd = nTrIn ? anTds[i] : document.createElement( oCol.sCellType );
  2691. nTd._DT_CellIndex = {
  2692. row: iRow,
  2693. column: i
  2694. };
  2695. cells.push( nTd );
  2696. // Need to create the HTML if new, or if a rendering function is defined
  2697. if ( (!nTrIn || oCol.mRender || oCol.mData !== i) &&
  2698. (!$.isPlainObject(oCol.mData) || oCol.mData._ !== i+'.display')
  2699. ) {
  2700. nTd.innerHTML = _fnGetCellData( oSettings, iRow, i, 'display' );
  2701. }
  2702. /* Add user defined class */
  2703. if ( oCol.sClass )
  2704. {
  2705. nTd.className += ' '+oCol.sClass;
  2706. }
  2707. // Visibility - add or remove as required
  2708. if ( oCol.bVisible && ! nTrIn )
  2709. {
  2710. nTr.appendChild( nTd );
  2711. }
  2712. else if ( ! oCol.bVisible && nTrIn )
  2713. {
  2714. nTd.parentNode.removeChild( nTd );
  2715. }
  2716. if ( oCol.fnCreatedCell )
  2717. {
  2718. oCol.fnCreatedCell.call( oSettings.oInstance,
  2719. nTd, _fnGetCellData( oSettings, iRow, i ), rowData, iRow, i
  2720. );
  2721. }
  2722. }
  2723. _fnCallbackFire( oSettings, 'aoRowCreatedCallback', null, [nTr, rowData, iRow] );
  2724. }
  2725. // Remove once webkit bug 131819 and Chromium bug 365619 have been resolved
  2726. // and deployed
  2727. row.nTr.setAttribute( 'role', 'row' );
  2728. }
  2729. /**
  2730. * Add attributes to a row based on the special `DT_*` parameters in a data
  2731. * source object.
  2732. * @param {object} settings DataTables settings object
  2733. * @param {object} DataTables row object for the row to be modified
  2734. * @memberof DataTable#oApi
  2735. */
  2736. function _fnRowAttributes( settings, row )
  2737. {
  2738. var tr = row.nTr;
  2739. var data = row._aData;
  2740. if ( tr ) {
  2741. var id = settings.rowIdFn( data );
  2742. if ( id ) {
  2743. tr.id = id;
  2744. }
  2745. if ( data.DT_RowClass ) {
  2746. // Remove any classes added by DT_RowClass before
  2747. var a = data.DT_RowClass.split(' ');
  2748. row.__rowc = row.__rowc ?
  2749. _unique( row.__rowc.concat( a ) ) :
  2750. a;
  2751. $(tr)
  2752. .removeClass( row.__rowc.join(' ') )
  2753. .addClass( data.DT_RowClass );
  2754. }
  2755. if ( data.DT_RowAttr ) {
  2756. $(tr).attr( data.DT_RowAttr );
  2757. }
  2758. if ( data.DT_RowData ) {
  2759. $(tr).data( data.DT_RowData );
  2760. }
  2761. }
  2762. }
  2763. /**
  2764. * Create the HTML header for the table
  2765. * @param {object} oSettings dataTables settings object
  2766. * @memberof DataTable#oApi
  2767. */
  2768. function _fnBuildHead( oSettings )
  2769. {
  2770. var i, ien, cell, row, column;
  2771. var thead = oSettings.nTHead;
  2772. var tfoot = oSettings.nTFoot;
  2773. var createHeader = $('th, td', thead).length === 0;
  2774. var classes = oSettings.oClasses;
  2775. var columns = oSettings.aoColumns;
  2776. if ( createHeader ) {
  2777. row = $('<tr/>').appendTo( thead );
  2778. }
  2779. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  2780. column = columns[i];
  2781. cell = $( column.nTh ).addClass( column.sClass );
  2782. if ( createHeader ) {
  2783. cell.appendTo( row );
  2784. }
  2785. // 1.11 move into sorting
  2786. if ( oSettings.oFeatures.bSort ) {
  2787. cell.addClass( column.sSortingClass );
  2788. if ( column.bSortable !== false ) {
  2789. cell
  2790. .attr( 'tabindex', oSettings.iTabIndex )
  2791. .attr( 'aria-controls', oSettings.sTableId );
  2792. _fnSortAttachListener( oSettings, column.nTh, i );
  2793. }
  2794. }
  2795. if ( column.sTitle != cell[0].innerHTML ) {
  2796. cell.html( column.sTitle );
  2797. }
  2798. _fnRenderer( oSettings, 'header' )(
  2799. oSettings, cell, column, classes
  2800. );
  2801. }
  2802. if ( createHeader ) {
  2803. _fnDetectHeader( oSettings.aoHeader, thead );
  2804. }
  2805. /* ARIA role for the rows */
  2806. $(thead).find('>tr').attr('role', 'row');
  2807. /* Deal with the footer - add classes if required */
  2808. $(thead).find('>tr>th, >tr>td').addClass( classes.sHeaderTH );
  2809. $(tfoot).find('>tr>th, >tr>td').addClass( classes.sFooterTH );
  2810. // Cache the footer cells. Note that we only take the cells from the first
  2811. // row in the footer. If there is more than one row the user wants to
  2812. // interact with, they need to use the table().foot() method. Note also this
  2813. // allows cells to be used for multiple columns using colspan
  2814. if ( tfoot !== null ) {
  2815. var cells = oSettings.aoFooter[0];
  2816. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  2817. column = columns[i];
  2818. column.nTf = cells[i].cell;
  2819. if ( column.sClass ) {
  2820. $(column.nTf).addClass( column.sClass );
  2821. }
  2822. }
  2823. }
  2824. }
  2825. /**
  2826. * Draw the header (or footer) element based on the column visibility states. The
  2827. * methodology here is to use the layout array from _fnDetectHeader, modified for
  2828. * the instantaneous column visibility, to construct the new layout. The grid is
  2829. * traversed over cell at a time in a rows x columns grid fashion, although each
  2830. * cell insert can cover multiple elements in the grid - which is tracks using the
  2831. * aApplied array. Cell inserts in the grid will only occur where there isn't
  2832. * already a cell in that position.
  2833. * @param {object} oSettings dataTables settings object
  2834. * @param array {objects} aoSource Layout array from _fnDetectHeader
  2835. * @param {boolean} [bIncludeHidden=false] If true then include the hidden columns in the calc,
  2836. * @memberof DataTable#oApi
  2837. */
  2838. function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
  2839. {
  2840. var i, iLen, j, jLen, k, kLen, n, nLocalTr;
  2841. var aoLocal = [];
  2842. var aApplied = [];
  2843. var iColumns = oSettings.aoColumns.length;
  2844. var iRowspan, iColspan;
  2845. if ( ! aoSource )
  2846. {
  2847. return;
  2848. }
  2849. if ( bIncludeHidden === undefined )
  2850. {
  2851. bIncludeHidden = false;
  2852. }
  2853. /* Make a copy of the master layout array, but without the visible columns in it */
  2854. for ( i=0, iLen=aoSource.length ; i<iLen ; i++ )
  2855. {
  2856. aoLocal[i] = aoSource[i].slice();
  2857. aoLocal[i].nTr = aoSource[i].nTr;
  2858. /* Remove any columns which are currently hidden */
  2859. for ( j=iColumns-1 ; j>=0 ; j-- )
  2860. {
  2861. if ( !oSettings.aoColumns[j].bVisible && !bIncludeHidden )
  2862. {
  2863. aoLocal[i].splice( j, 1 );
  2864. }
  2865. }
  2866. /* Prep the applied array - it needs an element for each row */
  2867. aApplied.push( [] );
  2868. }
  2869. for ( i=0, iLen=aoLocal.length ; i<iLen ; i++ )
  2870. {
  2871. nLocalTr = aoLocal[i].nTr;
  2872. /* All cells are going to be replaced, so empty out the row */
  2873. if ( nLocalTr )
  2874. {
  2875. while( (n = nLocalTr.firstChild) )
  2876. {
  2877. nLocalTr.removeChild( n );
  2878. }
  2879. }
  2880. for ( j=0, jLen=aoLocal[i].length ; j<jLen ; j++ )
  2881. {
  2882. iRowspan = 1;
  2883. iColspan = 1;
  2884. /* Check to see if there is already a cell (row/colspan) covering our target
  2885. * insert point. If there is, then there is nothing to do.
  2886. */
  2887. if ( aApplied[i][j] === undefined )
  2888. {
  2889. nLocalTr.appendChild( aoLocal[i][j].cell );
  2890. aApplied[i][j] = 1;
  2891. /* Expand the cell to cover as many rows as needed */
  2892. while ( aoLocal[i+iRowspan] !== undefined &&
  2893. aoLocal[i][j].cell == aoLocal[i+iRowspan][j].cell )
  2894. {
  2895. aApplied[i+iRowspan][j] = 1;
  2896. iRowspan++;
  2897. }
  2898. /* Expand the cell to cover as many columns as needed */
  2899. while ( aoLocal[i][j+iColspan] !== undefined &&
  2900. aoLocal[i][j].cell == aoLocal[i][j+iColspan].cell )
  2901. {
  2902. /* Must update the applied array over the rows for the columns */
  2903. for ( k=0 ; k<iRowspan ; k++ )
  2904. {
  2905. aApplied[i+k][j+iColspan] = 1;
  2906. }
  2907. iColspan++;
  2908. }
  2909. /* Do the actual expansion in the DOM */
  2910. $(aoLocal[i][j].cell)
  2911. .attr('rowspan', iRowspan)
  2912. .attr('colspan', iColspan);
  2913. }
  2914. }
  2915. }
  2916. }
  2917. /**
  2918. * Insert the required TR nodes into the table for display
  2919. * @param {object} oSettings dataTables settings object
  2920. * @memberof DataTable#oApi
  2921. */
  2922. function _fnDraw( oSettings )
  2923. {
  2924. /* Provide a pre-callback function which can be used to cancel the draw is false is returned */
  2925. var aPreDraw = _fnCallbackFire( oSettings, 'aoPreDrawCallback', 'preDraw', [oSettings] );
  2926. if ( $.inArray( false, aPreDraw ) !== -1 )
  2927. {
  2928. _fnProcessingDisplay( oSettings, false );
  2929. return;
  2930. }
  2931. var i, iLen, n;
  2932. var anRows = [];
  2933. var iRowCount = 0;
  2934. var asStripeClasses = oSettings.asStripeClasses;
  2935. var iStripes = asStripeClasses.length;
  2936. var iOpenRows = oSettings.aoOpenRows.length;
  2937. var oLang = oSettings.oLanguage;
  2938. var iInitDisplayStart = oSettings.iInitDisplayStart;
  2939. var bServerSide = _fnDataSource( oSettings ) == 'ssp';
  2940. var aiDisplay = oSettings.aiDisplay;
  2941. oSettings.bDrawing = true;
  2942. /* Check and see if we have an initial draw position from state saving */
  2943. if ( iInitDisplayStart !== undefined && iInitDisplayStart !== -1 )
  2944. {
  2945. oSettings._iDisplayStart = bServerSide ?
  2946. iInitDisplayStart :
  2947. iInitDisplayStart >= oSettings.fnRecordsDisplay() ?
  2948. 0 :
  2949. iInitDisplayStart;
  2950. oSettings.iInitDisplayStart = -1;
  2951. }
  2952. var iDisplayStart = oSettings._iDisplayStart;
  2953. var iDisplayEnd = oSettings.fnDisplayEnd();
  2954. /* Server-side processing draw intercept */
  2955. if ( oSettings.bDeferLoading )
  2956. {
  2957. oSettings.bDeferLoading = false;
  2958. oSettings.iDraw++;
  2959. _fnProcessingDisplay( oSettings, false );
  2960. }
  2961. else if ( !bServerSide )
  2962. {
  2963. oSettings.iDraw++;
  2964. }
  2965. else if ( !oSettings.bDestroying && !_fnAjaxUpdate( oSettings ) )
  2966. {
  2967. return;
  2968. }
  2969. if ( aiDisplay.length !== 0 )
  2970. {
  2971. var iStart = bServerSide ? 0 : iDisplayStart;
  2972. var iEnd = bServerSide ? oSettings.aoData.length : iDisplayEnd;
  2973. for ( var j=iStart ; j<iEnd ; j++ )
  2974. {
  2975. var iDataIndex = aiDisplay[j];
  2976. var aoData = oSettings.aoData[ iDataIndex ];
  2977. if ( aoData.nTr === null )
  2978. {
  2979. _fnCreateTr( oSettings, iDataIndex );
  2980. }
  2981. var nRow = aoData.nTr;
  2982. /* Remove the old striping classes and then add the new one */
  2983. if ( iStripes !== 0 )
  2984. {
  2985. var sStripe = asStripeClasses[ iRowCount % iStripes ];
  2986. if ( aoData._sRowStripe != sStripe )
  2987. {
  2988. $(nRow).removeClass( aoData._sRowStripe ).addClass( sStripe );
  2989. aoData._sRowStripe = sStripe;
  2990. }
  2991. }
  2992. // Row callback functions - might want to manipulate the row
  2993. // iRowCount and j are not currently documented. Are they at all
  2994. // useful?
  2995. _fnCallbackFire( oSettings, 'aoRowCallback', null,
  2996. [nRow, aoData._aData, iRowCount, j] );
  2997. anRows.push( nRow );
  2998. iRowCount++;
  2999. }
  3000. }
  3001. else
  3002. {
  3003. /* Table is empty - create a row with an empty message in it */
  3004. var sZero = oLang.sZeroRecords;
  3005. if ( oSettings.iDraw == 1 && _fnDataSource( oSettings ) == 'ajax' )
  3006. {
  3007. sZero = oLang.sLoadingRecords;
  3008. }
  3009. else if ( oLang.sEmptyTable && oSettings.fnRecordsTotal() === 0 )
  3010. {
  3011. sZero = oLang.sEmptyTable;
  3012. }
  3013. anRows[ 0 ] = $( '<tr/>', { 'class': iStripes ? asStripeClasses[0] : '' } )
  3014. .append( $('<td />', {
  3015. 'valign': 'top',
  3016. 'colSpan': _fnVisbleColumns( oSettings ),
  3017. 'class': oSettings.oClasses.sRowEmpty
  3018. } ).html( sZero ) )[0];
  3019. }
  3020. /* Header and footer callbacks */
  3021. _fnCallbackFire( oSettings, 'aoHeaderCallback', 'header', [ $(oSettings.nTHead).children('tr')[0],
  3022. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  3023. _fnCallbackFire( oSettings, 'aoFooterCallback', 'footer', [ $(oSettings.nTFoot).children('tr')[0],
  3024. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  3025. var body = $(oSettings.nTBody);
  3026. body.children().detach();
  3027. body.append( $(anRows) );
  3028. /* Call all required callback functions for the end of a draw */
  3029. _fnCallbackFire( oSettings, 'aoDrawCallback', 'draw', [oSettings] );
  3030. /* Draw is complete, sorting and filtering must be as well */
  3031. oSettings.bSorted = false;
  3032. oSettings.bFiltered = false;
  3033. oSettings.bDrawing = false;
  3034. }
  3035. /**
  3036. * Redraw the table - taking account of the various features which are enabled
  3037. * @param {object} oSettings dataTables settings object
  3038. * @param {boolean} [holdPosition] Keep the current paging position. By default
  3039. * the paging is reset to the first page
  3040. * @memberof DataTable#oApi
  3041. */
  3042. function _fnReDraw( settings, holdPosition )
  3043. {
  3044. var
  3045. features = settings.oFeatures,
  3046. sort = features.bSort,
  3047. filter = features.bFilter;
  3048. if ( sort ) {
  3049. _fnSort( settings );
  3050. }
  3051. if ( filter ) {
  3052. _fnFilterComplete( settings, settings.oPreviousSearch );
  3053. }
  3054. else {
  3055. // No filtering, so we want to just use the display master
  3056. settings.aiDisplay = settings.aiDisplayMaster.slice();
  3057. }
  3058. if ( holdPosition !== true ) {
  3059. settings._iDisplayStart = 0;
  3060. }
  3061. // Let any modules know about the draw hold position state (used by
  3062. // scrolling internally)
  3063. settings._drawHold = holdPosition;
  3064. _fnDraw( settings );
  3065. settings._drawHold = false;
  3066. }
  3067. /**
  3068. * Add the options to the page HTML for the table
  3069. * @param {object} oSettings dataTables settings object
  3070. * @memberof DataTable#oApi
  3071. */
  3072. function _fnAddOptionsHtml ( oSettings )
  3073. {
  3074. var classes = oSettings.oClasses;
  3075. var table = $(oSettings.nTable);
  3076. var holding = $('<div/>').insertBefore( table ); // Holding element for speed
  3077. var features = oSettings.oFeatures;
  3078. // All DataTables are wrapped in a div
  3079. var insert = $('<div/>', {
  3080. id: oSettings.sTableId+'_wrapper',
  3081. 'class': classes.sWrapper + (oSettings.nTFoot ? '' : ' '+classes.sNoFooter)
  3082. } );
  3083. oSettings.nHolding = holding[0];
  3084. oSettings.nTableWrapper = insert[0];
  3085. oSettings.nTableReinsertBefore = oSettings.nTable.nextSibling;
  3086. /* Loop over the user set positioning and place the elements as needed */
  3087. var aDom = oSettings.sDom.split('');
  3088. var featureNode, cOption, nNewNode, cNext, sAttr, j;
  3089. for ( var i=0 ; i<aDom.length ; i++ )
  3090. {
  3091. featureNode = null;
  3092. cOption = aDom[i];
  3093. if ( cOption == '<' )
  3094. {
  3095. /* New container div */
  3096. nNewNode = $('<div/>')[0];
  3097. /* Check to see if we should append an id and/or a class name to the container */
  3098. cNext = aDom[i+1];
  3099. if ( cNext == "'" || cNext == '"' )
  3100. {
  3101. sAttr = "";
  3102. j = 2;
  3103. while ( aDom[i+j] != cNext )
  3104. {
  3105. sAttr += aDom[i+j];
  3106. j++;
  3107. }
  3108. /* Replace jQuery UI constants @todo depreciated */
  3109. if ( sAttr == "H" )
  3110. {
  3111. sAttr = classes.sJUIHeader;
  3112. }
  3113. else if ( sAttr == "F" )
  3114. {
  3115. sAttr = classes.sJUIFooter;
  3116. }
  3117. /* The attribute can be in the format of "#id.class", "#id" or "class" This logic
  3118. * breaks the string into parts and applies them as needed
  3119. */
  3120. if ( sAttr.indexOf('.') != -1 )
  3121. {
  3122. var aSplit = sAttr.split('.');
  3123. nNewNode.id = aSplit[0].substr(1, aSplit[0].length-1);
  3124. nNewNode.className = aSplit[1];
  3125. }
  3126. else if ( sAttr.charAt(0) == "#" )
  3127. {
  3128. nNewNode.id = sAttr.substr(1, sAttr.length-1);
  3129. }
  3130. else
  3131. {
  3132. nNewNode.className = sAttr;
  3133. }
  3134. i += j; /* Move along the position array */
  3135. }
  3136. insert.append( nNewNode );
  3137. insert = $(nNewNode);
  3138. }
  3139. else if ( cOption == '>' )
  3140. {
  3141. /* End container div */
  3142. insert = insert.parent();
  3143. }
  3144. // @todo Move options into their own plugins?
  3145. else if ( cOption == 'l' && features.bPaginate && features.bLengthChange )
  3146. {
  3147. /* Length */
  3148. featureNode = _fnFeatureHtmlLength( oSettings );
  3149. }
  3150. else if ( cOption == 'f' && features.bFilter )
  3151. {
  3152. /* Filter */
  3153. featureNode = _fnFeatureHtmlFilter( oSettings );
  3154. }
  3155. else if ( cOption == 'r' && features.bProcessing )
  3156. {
  3157. /* pRocessing */
  3158. featureNode = _fnFeatureHtmlProcessing( oSettings );
  3159. }
  3160. else if ( cOption == 't' )
  3161. {
  3162. /* Table */
  3163. featureNode = _fnFeatureHtmlTable( oSettings );
  3164. }
  3165. else if ( cOption == 'i' && features.bInfo )
  3166. {
  3167. /* Info */
  3168. featureNode = _fnFeatureHtmlInfo( oSettings );
  3169. }
  3170. else if ( cOption == 'p' && features.bPaginate )
  3171. {
  3172. /* Pagination */
  3173. featureNode = _fnFeatureHtmlPaginate( oSettings );
  3174. }
  3175. else if ( DataTable.ext.feature.length !== 0 )
  3176. {
  3177. /* Plug-in features */
  3178. var aoFeatures = DataTable.ext.feature;
  3179. for ( var k=0, kLen=aoFeatures.length ; k<kLen ; k++ )
  3180. {
  3181. if ( cOption == aoFeatures[k].cFeature )
  3182. {
  3183. featureNode = aoFeatures[k].fnInit( oSettings );
  3184. break;
  3185. }
  3186. }
  3187. }
  3188. /* Add to the 2D features array */
  3189. if ( featureNode )
  3190. {
  3191. var aanFeatures = oSettings.aanFeatures;
  3192. if ( ! aanFeatures[cOption] )
  3193. {
  3194. aanFeatures[cOption] = [];
  3195. }
  3196. aanFeatures[cOption].push( featureNode );
  3197. insert.append( featureNode );
  3198. }
  3199. }
  3200. /* Built our DOM structure - replace the holding div with what we want */
  3201. holding.replaceWith( insert );
  3202. oSettings.nHolding = null;
  3203. }
  3204. /**
  3205. * Use the DOM source to create up an array of header cells. The idea here is to
  3206. * create a layout grid (array) of rows x columns, which contains a reference
  3207. * to the cell that that point in the grid (regardless of col/rowspan), such that
  3208. * any column / row could be removed and the new grid constructed
  3209. * @param array {object} aLayout Array to store the calculated layout in
  3210. * @param {node} nThead The header/footer element for the table
  3211. * @memberof DataTable#oApi
  3212. */
  3213. function _fnDetectHeader ( aLayout, nThead )
  3214. {
  3215. var nTrs = $(nThead).children('tr');
  3216. var nTr, nCell;
  3217. var i, k, l, iLen, jLen, iColShifted, iColumn, iColspan, iRowspan;
  3218. var bUnique;
  3219. var fnShiftCol = function ( a, i, j ) {
  3220. var k = a[i];
  3221. while ( k[j] ) {
  3222. j++;
  3223. }
  3224. return j;
  3225. };
  3226. aLayout.splice( 0, aLayout.length );
  3227. /* We know how many rows there are in the layout - so prep it */
  3228. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  3229. {
  3230. aLayout.push( [] );
  3231. }
  3232. /* Calculate a layout array */
  3233. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  3234. {
  3235. nTr = nTrs[i];
  3236. iColumn = 0;
  3237. /* For every cell in the row... */
  3238. nCell = nTr.firstChild;
  3239. while ( nCell ) {
  3240. if ( nCell.nodeName.toUpperCase() == "TD" ||
  3241. nCell.nodeName.toUpperCase() == "TH" )
  3242. {
  3243. /* Get the col and rowspan attributes from the DOM and sanitise them */
  3244. iColspan = nCell.getAttribute('colspan') * 1;
  3245. iRowspan = nCell.getAttribute('rowspan') * 1;
  3246. iColspan = (!iColspan || iColspan===0 || iColspan===1) ? 1 : iColspan;
  3247. iRowspan = (!iRowspan || iRowspan===0 || iRowspan===1) ? 1 : iRowspan;
  3248. /* There might be colspan cells already in this row, so shift our target
  3249. * accordingly
  3250. */
  3251. iColShifted = fnShiftCol( aLayout, i, iColumn );
  3252. /* Cache calculation for unique columns */
  3253. bUnique = iColspan === 1 ? true : false;
  3254. /* If there is col / rowspan, copy the information into the layout grid */
  3255. for ( l=0 ; l<iColspan ; l++ )
  3256. {
  3257. for ( k=0 ; k<iRowspan ; k++ )
  3258. {
  3259. aLayout[i+k][iColShifted+l] = {
  3260. "cell": nCell,
  3261. "unique": bUnique
  3262. };
  3263. aLayout[i+k].nTr = nTr;
  3264. }
  3265. }
  3266. }
  3267. nCell = nCell.nextSibling;
  3268. }
  3269. }
  3270. }
  3271. /**
  3272. * Get an array of unique th elements, one for each column
  3273. * @param {object} oSettings dataTables settings object
  3274. * @param {node} nHeader automatically detect the layout from this node - optional
  3275. * @param {array} aLayout thead/tfoot layout from _fnDetectHeader - optional
  3276. * @returns array {node} aReturn list of unique th's
  3277. * @memberof DataTable#oApi
  3278. */
  3279. function _fnGetUniqueThs ( oSettings, nHeader, aLayout )
  3280. {
  3281. var aReturn = [];
  3282. if ( !aLayout )
  3283. {
  3284. aLayout = oSettings.aoHeader;
  3285. if ( nHeader )
  3286. {
  3287. aLayout = [];
  3288. _fnDetectHeader( aLayout, nHeader );
  3289. }
  3290. }
  3291. for ( var i=0, iLen=aLayout.length ; i<iLen ; i++ )
  3292. {
  3293. for ( var j=0, jLen=aLayout[i].length ; j<jLen ; j++ )
  3294. {
  3295. if ( aLayout[i][j].unique &&
  3296. (!aReturn[j] || !oSettings.bSortCellsTop) )
  3297. {
  3298. aReturn[j] = aLayout[i][j].cell;
  3299. }
  3300. }
  3301. }
  3302. return aReturn;
  3303. }
  3304. /**
  3305. * Create an Ajax call based on the table's settings, taking into account that
  3306. * parameters can have multiple forms, and backwards compatibility.
  3307. *
  3308. * @param {object} oSettings dataTables settings object
  3309. * @param {array} data Data to send to the server, required by
  3310. * DataTables - may be augmented by developer callbacks
  3311. * @param {function} fn Callback function to run when data is obtained
  3312. */
  3313. function _fnBuildAjax( oSettings, data, fn )
  3314. {
  3315. // Compatibility with 1.9-, allow fnServerData and event to manipulate
  3316. _fnCallbackFire( oSettings, 'aoServerParams', 'serverParams', [data] );
  3317. // Convert to object based for 1.10+ if using the old array scheme which can
  3318. // come from server-side processing or serverParams
  3319. if ( data && $.isArray(data) ) {
  3320. var tmp = {};
  3321. var rbracket = /(.*?)\[\]$/;
  3322. $.each( data, function (key, val) {
  3323. var match = val.name.match(rbracket);
  3324. if ( match ) {
  3325. // Support for arrays
  3326. var name = match[0];
  3327. if ( ! tmp[ name ] ) {
  3328. tmp[ name ] = [];
  3329. }
  3330. tmp[ name ].push( val.value );
  3331. }
  3332. else {
  3333. tmp[val.name] = val.value;
  3334. }
  3335. } );
  3336. data = tmp;
  3337. }
  3338. var ajaxData;
  3339. var ajax = oSettings.ajax;
  3340. var instance = oSettings.oInstance;
  3341. var callback = function ( json ) {
  3342. _fnCallbackFire( oSettings, null, 'xhr', [oSettings, json, oSettings.jqXHR] );
  3343. fn( json );
  3344. };
  3345. if ( $.isPlainObject( ajax ) && ajax.data )
  3346. {
  3347. ajaxData = ajax.data;
  3348. var newData = $.isFunction( ajaxData ) ?
  3349. ajaxData( data, oSettings ) : // fn can manipulate data or return
  3350. ajaxData; // an object object or array to merge
  3351. // If the function returned something, use that alone
  3352. data = $.isFunction( ajaxData ) && newData ?
  3353. newData :
  3354. $.extend( true, data, newData );
  3355. // Remove the data property as we've resolved it already and don't want
  3356. // jQuery to do it again (it is restored at the end of the function)
  3357. delete ajax.data;
  3358. }
  3359. var baseAjax = {
  3360. "data": data,
  3361. "success": function (json) {
  3362. var error = json.error || json.sError;
  3363. if ( error ) {
  3364. _fnLog( oSettings, 0, error );
  3365. }
  3366. oSettings.json = json;
  3367. callback( json );
  3368. },
  3369. "dataType": "json",
  3370. "cache": false,
  3371. "type": oSettings.sServerMethod,
  3372. "error": function (xhr, error, thrown) {
  3373. var ret = _fnCallbackFire( oSettings, null, 'xhr', [oSettings, null, oSettings.jqXHR] );
  3374. if ( $.inArray( true, ret ) === -1 ) {
  3375. if ( error == "parsererror" ) {
  3376. _fnLog( oSettings, 0, 'Invalid JSON response', 1 );
  3377. }
  3378. else if ( xhr.readyState === 4 ) {
  3379. _fnLog( oSettings, 0, 'Ajax error', 7 );
  3380. }
  3381. }
  3382. _fnProcessingDisplay( oSettings, false );
  3383. }
  3384. };
  3385. // Store the data submitted for the API
  3386. oSettings.oAjaxData = data;
  3387. // Allow plug-ins and external processes to modify the data
  3388. _fnCallbackFire( oSettings, null, 'preXhr', [oSettings, data] );
  3389. if ( oSettings.fnServerData )
  3390. {
  3391. // DataTables 1.9- compatibility
  3392. oSettings.fnServerData.call( instance,
  3393. oSettings.sAjaxSource,
  3394. $.map( data, function (val, key) { // Need to convert back to 1.9 trad format
  3395. return { name: key, value: val };
  3396. } ),
  3397. callback,
  3398. oSettings
  3399. );
  3400. }
  3401. else if ( oSettings.sAjaxSource || typeof ajax === 'string' )
  3402. {
  3403. // DataTables 1.9- compatibility
  3404. oSettings.jqXHR = $.ajax( $.extend( baseAjax, {
  3405. url: ajax || oSettings.sAjaxSource
  3406. } ) );
  3407. }
  3408. else if ( $.isFunction( ajax ) )
  3409. {
  3410. // Is a function - let the caller define what needs to be done
  3411. oSettings.jqXHR = ajax.call( instance, data, callback, oSettings );
  3412. }
  3413. else
  3414. {
  3415. // Object to extend the base settings
  3416. oSettings.jqXHR = $.ajax( $.extend( baseAjax, ajax ) );
  3417. // Restore for next time around
  3418. ajax.data = ajaxData;
  3419. }
  3420. }
  3421. /**
  3422. * Update the table using an Ajax call
  3423. * @param {object} settings dataTables settings object
  3424. * @returns {boolean} Block the table drawing or not
  3425. * @memberof DataTable#oApi
  3426. */
  3427. function _fnAjaxUpdate( settings )
  3428. {
  3429. if ( settings.bAjaxDataGet ) {
  3430. settings.iDraw++;
  3431. _fnProcessingDisplay( settings, true );
  3432. _fnBuildAjax(
  3433. settings,
  3434. _fnAjaxParameters( settings ),
  3435. function(json) {
  3436. _fnAjaxUpdateDraw( settings, json );
  3437. }
  3438. );
  3439. return false;
  3440. }
  3441. return true;
  3442. }
  3443. /**
  3444. * Build up the parameters in an object needed for a server-side processing
  3445. * request. Note that this is basically done twice, is different ways - a modern
  3446. * method which is used by default in DataTables 1.10 which uses objects and
  3447. * arrays, or the 1.9- method with is name / value pairs. 1.9 method is used if
  3448. * the sAjaxSource option is used in the initialisation, or the legacyAjax
  3449. * option is set.
  3450. * @param {object} oSettings dataTables settings object
  3451. * @returns {bool} block the table drawing or not
  3452. * @memberof DataTable#oApi
  3453. */
  3454. function _fnAjaxParameters( settings )
  3455. {
  3456. var
  3457. columns = settings.aoColumns,
  3458. columnCount = columns.length,
  3459. features = settings.oFeatures,
  3460. preSearch = settings.oPreviousSearch,
  3461. preColSearch = settings.aoPreSearchCols,
  3462. i, data = [], dataProp, column, columnSearch,
  3463. sort = _fnSortFlatten( settings ),
  3464. displayStart = settings._iDisplayStart,
  3465. displayLength = features.bPaginate !== false ?
  3466. settings._iDisplayLength :
  3467. -1;
  3468. var param = function ( name, value ) {
  3469. data.push( { 'name': name, 'value': value } );
  3470. };
  3471. // DataTables 1.9- compatible method
  3472. param( 'sEcho', settings.iDraw );
  3473. param( 'iColumns', columnCount );
  3474. param( 'sColumns', _pluck( columns, 'sName' ).join(',') );
  3475. param( 'iDisplayStart', displayStart );
  3476. param( 'iDisplayLength', displayLength );
  3477. // DataTables 1.10+ method
  3478. var d = {
  3479. draw: settings.iDraw,
  3480. columns: [],
  3481. order: [],
  3482. start: displayStart,
  3483. length: displayLength,
  3484. search: {
  3485. value: preSearch.sSearch,
  3486. regex: preSearch.bRegex
  3487. }
  3488. };
  3489. for ( i=0 ; i<columnCount ; i++ ) {
  3490. column = columns[i];
  3491. columnSearch = preColSearch[i];
  3492. dataProp = typeof column.mData=="function" ? 'function' : column.mData ;
  3493. d.columns.push( {
  3494. data: dataProp,
  3495. name: column.sName,
  3496. searchable: column.bSearchable,
  3497. orderable: column.bSortable,
  3498. search: {
  3499. value: columnSearch.sSearch,
  3500. regex: columnSearch.bRegex
  3501. }
  3502. } );
  3503. param( "mDataProp_"+i, dataProp );
  3504. if ( features.bFilter ) {
  3505. param( 'sSearch_'+i, columnSearch.sSearch );
  3506. param( 'bRegex_'+i, columnSearch.bRegex );
  3507. param( 'bSearchable_'+i, column.bSearchable );
  3508. }
  3509. if ( features.bSort ) {
  3510. param( 'bSortable_'+i, column.bSortable );
  3511. }
  3512. }
  3513. if ( features.bFilter ) {
  3514. param( 'sSearch', preSearch.sSearch );
  3515. param( 'bRegex', preSearch.bRegex );
  3516. }
  3517. if ( features.bSort ) {
  3518. $.each( sort, function ( i, val ) {
  3519. d.order.push( { column: val.col, dir: val.dir } );
  3520. param( 'iSortCol_'+i, val.col );
  3521. param( 'sSortDir_'+i, val.dir );
  3522. } );
  3523. param( 'iSortingCols', sort.length );
  3524. }
  3525. // If the legacy.ajax parameter is null, then we automatically decide which
  3526. // form to use, based on sAjaxSource
  3527. var legacy = DataTable.ext.legacy.ajax;
  3528. if ( legacy === null ) {
  3529. return settings.sAjaxSource ? data : d;
  3530. }
  3531. // Otherwise, if legacy has been specified then we use that to decide on the
  3532. // form
  3533. return legacy ? data : d;
  3534. }
  3535. /**
  3536. * Data the data from the server (nuking the old) and redraw the table
  3537. * @param {object} oSettings dataTables settings object
  3538. * @param {object} json json data return from the server.
  3539. * @param {string} json.sEcho Tracking flag for DataTables to match requests
  3540. * @param {int} json.iTotalRecords Number of records in the data set, not accounting for filtering
  3541. * @param {int} json.iTotalDisplayRecords Number of records in the data set, accounting for filtering
  3542. * @param {array} json.aaData The data to display on this page
  3543. * @param {string} [json.sColumns] Column ordering (sName, comma separated)
  3544. * @memberof DataTable#oApi
  3545. */
  3546. function _fnAjaxUpdateDraw ( settings, json )
  3547. {
  3548. // v1.10 uses camelCase variables, while 1.9 uses Hungarian notation.
  3549. // Support both
  3550. var compat = function ( old, modern ) {
  3551. return json[old] !== undefined ? json[old] : json[modern];
  3552. };
  3553. var data = _fnAjaxDataSrc( settings, json );
  3554. var draw = compat( 'sEcho', 'draw' );
  3555. var recordsTotal = compat( 'iTotalRecords', 'recordsTotal' );
  3556. var recordsFiltered = compat( 'iTotalDisplayRecords', 'recordsFiltered' );
  3557. if ( draw ) {
  3558. // Protect against out of sequence returns
  3559. if ( draw*1 < settings.iDraw ) {
  3560. return;
  3561. }
  3562. settings.iDraw = draw * 1;
  3563. }
  3564. _fnClearTable( settings );
  3565. settings._iRecordsTotal = parseInt(recordsTotal, 10);
  3566. settings._iRecordsDisplay = parseInt(recordsFiltered, 10);
  3567. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  3568. _fnAddData( settings, data[i] );
  3569. }
  3570. settings.aiDisplay = settings.aiDisplayMaster.slice();
  3571. settings.bAjaxDataGet = false;
  3572. _fnDraw( settings );
  3573. if ( ! settings._bInitComplete ) {
  3574. _fnInitComplete( settings, json );
  3575. }
  3576. settings.bAjaxDataGet = true;
  3577. _fnProcessingDisplay( settings, false );
  3578. }
  3579. /**
  3580. * Get the data from the JSON data source to use for drawing a table. Using
  3581. * `_fnGetObjectDataFn` allows the data to be sourced from a property of the
  3582. * source object, or from a processing function.
  3583. * @param {object} oSettings dataTables settings object
  3584. * @param {object} json Data source object / array from the server
  3585. * @return {array} Array of data to use
  3586. */
  3587. function _fnAjaxDataSrc ( oSettings, json )
  3588. {
  3589. var dataSrc = $.isPlainObject( oSettings.ajax ) && oSettings.ajax.dataSrc !== undefined ?
  3590. oSettings.ajax.dataSrc :
  3591. oSettings.sAjaxDataProp; // Compatibility with 1.9-.
  3592. // Compatibility with 1.9-. In order to read from aaData, check if the
  3593. // default has been changed, if not, check for aaData
  3594. if ( dataSrc === 'data' ) {
  3595. return json.aaData || json[dataSrc];
  3596. }
  3597. return dataSrc !== "" ?
  3598. _fnGetObjectDataFn( dataSrc )( json ) :
  3599. json;
  3600. }
  3601. /**
  3602. * Generate the node required for filtering text
  3603. * @returns {node} Filter control element
  3604. * @param {object} oSettings dataTables settings object
  3605. * @memberof DataTable#oApi
  3606. */
  3607. function _fnFeatureHtmlFilter ( settings )
  3608. {
  3609. var classes = settings.oClasses;
  3610. var tableId = settings.sTableId;
  3611. var language = settings.oLanguage;
  3612. var previousSearch = settings.oPreviousSearch;
  3613. var features = settings.aanFeatures;
  3614. var input = '<input type="search" class="'+classes.sFilterInput+'"/>';
  3615. var str = language.sSearch;
  3616. str = str.match(/_INPUT_/) ?
  3617. str.replace('_INPUT_', input) :
  3618. str+input;
  3619. var filter = $('<div/>', {
  3620. 'id': ! features.f ? tableId+'_filter' : null,
  3621. 'class': classes.sFilter
  3622. } )
  3623. .append( $('<label/>' ).append( str ) );
  3624. var searchFn = function() {
  3625. /* Update all other filter input elements for the new display */
  3626. var n = features.f;
  3627. var val = !this.value ? "" : this.value; // mental IE8 fix :-(
  3628. /* Now do the filter */
  3629. if ( val != previousSearch.sSearch ) {
  3630. _fnFilterComplete( settings, {
  3631. "sSearch": val,
  3632. "bRegex": previousSearch.bRegex,
  3633. "bSmart": previousSearch.bSmart ,
  3634. "bCaseInsensitive": previousSearch.bCaseInsensitive
  3635. } );
  3636. // Need to redraw, without resorting
  3637. settings._iDisplayStart = 0;
  3638. _fnDraw( settings );
  3639. }
  3640. };
  3641. var searchDelay = settings.searchDelay !== null ?
  3642. settings.searchDelay :
  3643. _fnDataSource( settings ) === 'ssp' ?
  3644. 400 :
  3645. 0;
  3646. var jqFilter = $('input', filter)
  3647. .val( previousSearch.sSearch )
  3648. .attr( 'placeholder', language.sSearchPlaceholder )
  3649. .bind(
  3650. 'keyup.DT search.DT input.DT paste.DT cut.DT',
  3651. searchDelay ?
  3652. _fnThrottle( searchFn, searchDelay ) :
  3653. searchFn
  3654. )
  3655. .bind( 'keypress.DT', function(e) {
  3656. /* Prevent form submission */
  3657. if ( e.keyCode == 13 ) {
  3658. return false;
  3659. }
  3660. } )
  3661. .attr('aria-controls', tableId);
  3662. // Update the input elements whenever the table is filtered
  3663. $(settings.nTable).on( 'search.dt.DT', function ( ev, s ) {
  3664. if ( settings === s ) {
  3665. // IE9 throws an 'unknown error' if document.activeElement is used
  3666. // inside an iframe or frame...
  3667. try {
  3668. if ( jqFilter[0] !== document.activeElement ) {
  3669. jqFilter.val( previousSearch.sSearch );
  3670. }
  3671. }
  3672. catch ( e ) {}
  3673. }
  3674. } );
  3675. return filter[0];
  3676. }
  3677. /**
  3678. * Filter the table using both the global filter and column based filtering
  3679. * @param {object} oSettings dataTables settings object
  3680. * @param {object} oSearch search information
  3681. * @param {int} [iForce] force a research of the master array (1) or not (undefined or 0)
  3682. * @memberof DataTable#oApi
  3683. */
  3684. function _fnFilterComplete ( oSettings, oInput, iForce )
  3685. {
  3686. var oPrevSearch = oSettings.oPreviousSearch;
  3687. var aoPrevSearch = oSettings.aoPreSearchCols;
  3688. var fnSaveFilter = function ( oFilter ) {
  3689. /* Save the filtering values */
  3690. oPrevSearch.sSearch = oFilter.sSearch;
  3691. oPrevSearch.bRegex = oFilter.bRegex;
  3692. oPrevSearch.bSmart = oFilter.bSmart;
  3693. oPrevSearch.bCaseInsensitive = oFilter.bCaseInsensitive;
  3694. };
  3695. var fnRegex = function ( o ) {
  3696. // Backwards compatibility with the bEscapeRegex option
  3697. return o.bEscapeRegex !== undefined ? !o.bEscapeRegex : o.bRegex;
  3698. };
  3699. // Resolve any column types that are unknown due to addition or invalidation
  3700. // @todo As per sort - can this be moved into an event handler?
  3701. _fnColumnTypes( oSettings );
  3702. /* In server-side processing all filtering is done by the server, so no point hanging around here */
  3703. if ( _fnDataSource( oSettings ) != 'ssp' )
  3704. {
  3705. /* Global filter */
  3706. _fnFilter( oSettings, oInput.sSearch, iForce, fnRegex(oInput), oInput.bSmart, oInput.bCaseInsensitive );
  3707. fnSaveFilter( oInput );
  3708. /* Now do the individual column filter */
  3709. for ( var i=0 ; i<aoPrevSearch.length ; i++ )
  3710. {
  3711. _fnFilterColumn( oSettings, aoPrevSearch[i].sSearch, i, fnRegex(aoPrevSearch[i]),
  3712. aoPrevSearch[i].bSmart, aoPrevSearch[i].bCaseInsensitive );
  3713. }
  3714. /* Custom filtering */
  3715. _fnFilterCustom( oSettings );
  3716. }
  3717. else
  3718. {
  3719. fnSaveFilter( oInput );
  3720. }
  3721. /* Tell the draw function we have been filtering */
  3722. oSettings.bFiltered = true;
  3723. _fnCallbackFire( oSettings, null, 'search', [oSettings] );
  3724. }
  3725. /**
  3726. * Apply custom filtering functions
  3727. * @param {object} oSettings dataTables settings object
  3728. * @memberof DataTable#oApi
  3729. */
  3730. function _fnFilterCustom( settings )
  3731. {
  3732. var filters = DataTable.ext.search;
  3733. var displayRows = settings.aiDisplay;
  3734. var row, rowIdx;
  3735. for ( var i=0, ien=filters.length ; i<ien ; i++ ) {
  3736. var rows = [];
  3737. // Loop over each row and see if it should be included
  3738. for ( var j=0, jen=displayRows.length ; j<jen ; j++ ) {
  3739. rowIdx = displayRows[ j ];
  3740. row = settings.aoData[ rowIdx ];
  3741. if ( filters[i]( settings, row._aFilterData, rowIdx, row._aData, j ) ) {
  3742. rows.push( rowIdx );
  3743. }
  3744. }
  3745. // So the array reference doesn't break set the results into the
  3746. // existing array
  3747. displayRows.length = 0;
  3748. $.merge( displayRows, rows );
  3749. }
  3750. }
  3751. /**
  3752. * Filter the table on a per-column basis
  3753. * @param {object} oSettings dataTables settings object
  3754. * @param {string} sInput string to filter on
  3755. * @param {int} iColumn column to filter
  3756. * @param {bool} bRegex treat search string as a regular expression or not
  3757. * @param {bool} bSmart use smart filtering or not
  3758. * @param {bool} bCaseInsensitive Do case insenstive matching or not
  3759. * @memberof DataTable#oApi
  3760. */
  3761. function _fnFilterColumn ( settings, searchStr, colIdx, regex, smart, caseInsensitive )
  3762. {
  3763. if ( searchStr === '' ) {
  3764. return;
  3765. }
  3766. var data;
  3767. var display = settings.aiDisplay;
  3768. var rpSearch = _fnFilterCreateSearch( searchStr, regex, smart, caseInsensitive );
  3769. for ( var i=display.length-1 ; i>=0 ; i-- ) {
  3770. data = settings.aoData[ display[i] ]._aFilterData[ colIdx ];
  3771. if ( ! rpSearch.test( data ) ) {
  3772. display.splice( i, 1 );
  3773. }
  3774. }
  3775. }
  3776. /**
  3777. * Filter the data table based on user input and draw the table
  3778. * @param {object} settings dataTables settings object
  3779. * @param {string} input string to filter on
  3780. * @param {int} force optional - force a research of the master array (1) or not (undefined or 0)
  3781. * @param {bool} regex treat as a regular expression or not
  3782. * @param {bool} smart perform smart filtering or not
  3783. * @param {bool} caseInsensitive Do case insenstive matching or not
  3784. * @memberof DataTable#oApi
  3785. */
  3786. function _fnFilter( settings, input, force, regex, smart, caseInsensitive )
  3787. {
  3788. var rpSearch = _fnFilterCreateSearch( input, regex, smart, caseInsensitive );
  3789. var prevSearch = settings.oPreviousSearch.sSearch;
  3790. var displayMaster = settings.aiDisplayMaster;
  3791. var display, invalidated, i;
  3792. // Need to take account of custom filtering functions - always filter
  3793. if ( DataTable.ext.search.length !== 0 ) {
  3794. force = true;
  3795. }
  3796. // Check if any of the rows were invalidated
  3797. invalidated = _fnFilterData( settings );
  3798. // If the input is blank - we just want the full data set
  3799. if ( input.length <= 0 ) {
  3800. settings.aiDisplay = displayMaster.slice();
  3801. }
  3802. else {
  3803. // New search - start from the master array
  3804. if ( invalidated ||
  3805. force ||
  3806. prevSearch.length > input.length ||
  3807. input.indexOf(prevSearch) !== 0 ||
  3808. settings.bSorted // On resort, the display master needs to be
  3809. // re-filtered since indexes will have changed
  3810. ) {
  3811. settings.aiDisplay = displayMaster.slice();
  3812. }
  3813. // Search the display array
  3814. display = settings.aiDisplay;
  3815. for ( i=display.length-1 ; i>=0 ; i-- ) {
  3816. if ( ! rpSearch.test( settings.aoData[ display[i] ]._sFilterRow ) ) {
  3817. display.splice( i, 1 );
  3818. }
  3819. }
  3820. }
  3821. }
  3822. /**
  3823. * Build a regular expression object suitable for searching a table
  3824. * @param {string} sSearch string to search for
  3825. * @param {bool} bRegex treat as a regular expression or not
  3826. * @param {bool} bSmart perform smart filtering or not
  3827. * @param {bool} bCaseInsensitive Do case insensitive matching or not
  3828. * @returns {RegExp} constructed object
  3829. * @memberof DataTable#oApi
  3830. */
  3831. function _fnFilterCreateSearch( search, regex, smart, caseInsensitive )
  3832. {
  3833. search = regex ?
  3834. search :
  3835. _fnEscapeRegex( search );
  3836. if ( smart ) {
  3837. /* For smart filtering we want to allow the search to work regardless of
  3838. * word order. We also want double quoted text to be preserved, so word
  3839. * order is important - a la google. So this is what we want to
  3840. * generate:
  3841. *
  3842. * ^(?=.*?\bone\b)(?=.*?\btwo three\b)(?=.*?\bfour\b).*$
  3843. */
  3844. var a = $.map( search.match( /"[^"]+"|[^ ]+/g ) || [''], function ( word ) {
  3845. if ( word.charAt(0) === '"' ) {
  3846. var m = word.match( /^"(.*)"$/ );
  3847. word = m ? m[1] : word;
  3848. }
  3849. return word.replace('"', '');
  3850. } );
  3851. search = '^(?=.*?'+a.join( ')(?=.*?' )+').*$';
  3852. }
  3853. return new RegExp( search, caseInsensitive ? 'i' : '' );
  3854. }
  3855. /**
  3856. * Escape a string such that it can be used in a regular expression
  3857. * @param {string} sVal string to escape
  3858. * @returns {string} escaped string
  3859. * @memberof DataTable#oApi
  3860. */
  3861. var _fnEscapeRegex = DataTable.util.escapeRegex;
  3862. var __filter_div = $('<div>')[0];
  3863. var __filter_div_textContent = __filter_div.textContent !== undefined;
  3864. // Update the filtering data for each row if needed (by invalidation or first run)
  3865. function _fnFilterData ( settings )
  3866. {
  3867. var columns = settings.aoColumns;
  3868. var column;
  3869. var i, j, ien, jen, filterData, cellData, row;
  3870. var fomatters = DataTable.ext.type.search;
  3871. var wasInvalidated = false;
  3872. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  3873. row = settings.aoData[i];
  3874. if ( ! row._aFilterData ) {
  3875. filterData = [];
  3876. for ( j=0, jen=columns.length ; j<jen ; j++ ) {
  3877. column = columns[j];
  3878. if ( column.bSearchable ) {
  3879. cellData = _fnGetCellData( settings, i, j, 'filter' );
  3880. if ( fomatters[ column.sType ] ) {
  3881. cellData = fomatters[ column.sType ]( cellData );
  3882. }
  3883. // Search in DataTables 1.10 is string based. In 1.11 this
  3884. // should be altered to also allow strict type checking.
  3885. if ( cellData === null ) {
  3886. cellData = '';
  3887. }
  3888. if ( typeof cellData !== 'string' && cellData.toString ) {
  3889. cellData = cellData.toString();
  3890. }
  3891. }
  3892. else {
  3893. cellData = '';
  3894. }
  3895. // If it looks like there is an HTML entity in the string,
  3896. // attempt to decode it so sorting works as expected. Note that
  3897. // we could use a single line of jQuery to do this, but the DOM
  3898. // method used here is much faster http://jsperf.com/html-decode
  3899. if ( cellData.indexOf && cellData.indexOf('&') !== -1 ) {
  3900. __filter_div.innerHTML = cellData;
  3901. cellData = __filter_div_textContent ?
  3902. __filter_div.textContent :
  3903. __filter_div.innerText;
  3904. }
  3905. if ( cellData.replace ) {
  3906. cellData = cellData.replace(/[\r\n]/g, '');
  3907. }
  3908. filterData.push( cellData );
  3909. }
  3910. row._aFilterData = filterData;
  3911. row._sFilterRow = filterData.join(' ');
  3912. wasInvalidated = true;
  3913. }
  3914. }
  3915. return wasInvalidated;
  3916. }
  3917. /**
  3918. * Convert from the internal Hungarian notation to camelCase for external
  3919. * interaction
  3920. * @param {object} obj Object to convert
  3921. * @returns {object} Inverted object
  3922. * @memberof DataTable#oApi
  3923. */
  3924. function _fnSearchToCamel ( obj )
  3925. {
  3926. return {
  3927. search: obj.sSearch,
  3928. smart: obj.bSmart,
  3929. regex: obj.bRegex,
  3930. caseInsensitive: obj.bCaseInsensitive
  3931. };
  3932. }
  3933. /**
  3934. * Convert from camelCase notation to the internal Hungarian. We could use the
  3935. * Hungarian convert function here, but this is cleaner
  3936. * @param {object} obj Object to convert
  3937. * @returns {object} Inverted object
  3938. * @memberof DataTable#oApi
  3939. */
  3940. function _fnSearchToHung ( obj )
  3941. {
  3942. return {
  3943. sSearch: obj.search,
  3944. bSmart: obj.smart,
  3945. bRegex: obj.regex,
  3946. bCaseInsensitive: obj.caseInsensitive
  3947. };
  3948. }
  3949. /**
  3950. * Generate the node required for the info display
  3951. * @param {object} oSettings dataTables settings object
  3952. * @returns {node} Information element
  3953. * @memberof DataTable#oApi
  3954. */
  3955. function _fnFeatureHtmlInfo ( settings )
  3956. {
  3957. var
  3958. tid = settings.sTableId,
  3959. nodes = settings.aanFeatures.i,
  3960. n = $('<div/>', {
  3961. 'class': settings.oClasses.sInfo,
  3962. 'id': ! nodes ? tid+'_info' : null
  3963. } );
  3964. if ( ! nodes ) {
  3965. // Update display on each draw
  3966. settings.aoDrawCallback.push( {
  3967. "fn": _fnUpdateInfo,
  3968. "sName": "information"
  3969. } );
  3970. n
  3971. .attr( 'role', 'status' )
  3972. .attr( 'aria-live', 'polite' );
  3973. // Table is described by our info div
  3974. $(settings.nTable).attr( 'aria-describedby', tid+'_info' );
  3975. }
  3976. return n[0];
  3977. }
  3978. /**
  3979. * Update the information elements in the display
  3980. * @param {object} settings dataTables settings object
  3981. * @memberof DataTable#oApi
  3982. */
  3983. function _fnUpdateInfo ( settings )
  3984. {
  3985. /* Show information about the table */
  3986. var nodes = settings.aanFeatures.i;
  3987. if ( nodes.length === 0 ) {
  3988. return;
  3989. }
  3990. var
  3991. lang = settings.oLanguage,
  3992. start = settings._iDisplayStart+1,
  3993. end = settings.fnDisplayEnd(),
  3994. max = settings.fnRecordsTotal(),
  3995. total = settings.fnRecordsDisplay(),
  3996. out = total ?
  3997. lang.sInfo :
  3998. lang.sInfoEmpty;
  3999. if ( total !== max ) {
  4000. /* Record set after filtering */
  4001. out += ' ' + lang.sInfoFiltered;
  4002. }
  4003. // Convert the macros
  4004. out += lang.sInfoPostFix;
  4005. out = _fnInfoMacros( settings, out );
  4006. var callback = lang.fnInfoCallback;
  4007. if ( callback !== null ) {
  4008. out = callback.call( settings.oInstance,
  4009. settings, start, end, max, total, out
  4010. );
  4011. }
  4012. $(nodes).html( out );
  4013. }
  4014. function _fnInfoMacros ( settings, str )
  4015. {
  4016. // When infinite scrolling, we are always starting at 1. _iDisplayStart is used only
  4017. // internally
  4018. var
  4019. formatter = settings.fnFormatNumber,
  4020. start = settings._iDisplayStart+1,
  4021. len = settings._iDisplayLength,
  4022. vis = settings.fnRecordsDisplay(),
  4023. all = len === -1;
  4024. return str.
  4025. replace(/_START_/g, formatter.call( settings, start ) ).
  4026. replace(/_END_/g, formatter.call( settings, settings.fnDisplayEnd() ) ).
  4027. replace(/_MAX_/g, formatter.call( settings, settings.fnRecordsTotal() ) ).
  4028. replace(/_TOTAL_/g, formatter.call( settings, vis ) ).
  4029. replace(/_PAGE_/g, formatter.call( settings, all ? 1 : Math.ceil( start / len ) ) ).
  4030. replace(/_PAGES_/g, formatter.call( settings, all ? 1 : Math.ceil( vis / len ) ) );
  4031. }
  4032. /**
  4033. * Draw the table for the first time, adding all required features
  4034. * @param {object} settings dataTables settings object
  4035. * @memberof DataTable#oApi
  4036. */
  4037. function _fnInitialise ( settings )
  4038. {
  4039. var i, iLen, iAjaxStart=settings.iInitDisplayStart;
  4040. var columns = settings.aoColumns, column;
  4041. var features = settings.oFeatures;
  4042. var deferLoading = settings.bDeferLoading; // value modified by the draw
  4043. /* Ensure that the table data is fully initialised */
  4044. if ( ! settings.bInitialised ) {
  4045. setTimeout( function(){ _fnInitialise( settings ); }, 200 );
  4046. return;
  4047. }
  4048. /* Show the display HTML options */
  4049. _fnAddOptionsHtml( settings );
  4050. /* Build and draw the header / footer for the table */
  4051. _fnBuildHead( settings );
  4052. _fnDrawHead( settings, settings.aoHeader );
  4053. _fnDrawHead( settings, settings.aoFooter );
  4054. /* Okay to show that something is going on now */
  4055. _fnProcessingDisplay( settings, true );
  4056. /* Calculate sizes for columns */
  4057. if ( features.bAutoWidth ) {
  4058. _fnCalculateColumnWidths( settings );
  4059. }
  4060. for ( i=0, iLen=columns.length ; i<iLen ; i++ ) {
  4061. column = columns[i];
  4062. if ( column.sWidth ) {
  4063. column.nTh.style.width = _fnStringToCss( column.sWidth );
  4064. }
  4065. }
  4066. _fnCallbackFire( settings, null, 'preInit', [settings] );
  4067. // If there is default sorting required - let's do it. The sort function
  4068. // will do the drawing for us. Otherwise we draw the table regardless of the
  4069. // Ajax source - this allows the table to look initialised for Ajax sourcing
  4070. // data (show 'loading' message possibly)
  4071. _fnReDraw( settings );
  4072. // Server-side processing init complete is done by _fnAjaxUpdateDraw
  4073. var dataSrc = _fnDataSource( settings );
  4074. if ( dataSrc != 'ssp' || deferLoading ) {
  4075. // if there is an ajax source load the data
  4076. if ( dataSrc == 'ajax' ) {
  4077. _fnBuildAjax( settings, [], function(json) {
  4078. var aData = _fnAjaxDataSrc( settings, json );
  4079. // Got the data - add it to the table
  4080. for ( i=0 ; i<aData.length ; i++ ) {
  4081. _fnAddData( settings, aData[i] );
  4082. }
  4083. // Reset the init display for cookie saving. We've already done
  4084. // a filter, and therefore cleared it before. So we need to make
  4085. // it appear 'fresh'
  4086. settings.iInitDisplayStart = iAjaxStart;
  4087. _fnReDraw( settings );
  4088. _fnProcessingDisplay( settings, false );
  4089. _fnInitComplete( settings, json );
  4090. }, settings );
  4091. }
  4092. else {
  4093. _fnProcessingDisplay( settings, false );
  4094. _fnInitComplete( settings );
  4095. }
  4096. }
  4097. }
  4098. /**
  4099. * Draw the table for the first time, adding all required features
  4100. * @param {object} oSettings dataTables settings object
  4101. * @param {object} [json] JSON from the server that completed the table, if using Ajax source
  4102. * with client-side processing (optional)
  4103. * @memberof DataTable#oApi
  4104. */
  4105. function _fnInitComplete ( settings, json )
  4106. {
  4107. settings._bInitComplete = true;
  4108. // When data was added after the initialisation (data or Ajax) we need to
  4109. // calculate the column sizing
  4110. if ( json || settings.oInit.aaData ) {
  4111. _fnAdjustColumnSizing( settings );
  4112. }
  4113. _fnCallbackFire( settings, null, 'plugin-init', [settings, json] );
  4114. _fnCallbackFire( settings, 'aoInitComplete', 'init', [settings, json] );
  4115. }
  4116. function _fnLengthChange ( settings, val )
  4117. {
  4118. var len = parseInt( val, 10 );
  4119. settings._iDisplayLength = len;
  4120. _fnLengthOverflow( settings );
  4121. // Fire length change event
  4122. _fnCallbackFire( settings, null, 'length', [settings, len] );
  4123. }
  4124. /**
  4125. * Generate the node required for user display length changing
  4126. * @param {object} settings dataTables settings object
  4127. * @returns {node} Display length feature node
  4128. * @memberof DataTable#oApi
  4129. */
  4130. function _fnFeatureHtmlLength ( settings )
  4131. {
  4132. var
  4133. classes = settings.oClasses,
  4134. tableId = settings.sTableId,
  4135. menu = settings.aLengthMenu,
  4136. d2 = $.isArray( menu[0] ),
  4137. lengths = d2 ? menu[0] : menu,
  4138. language = d2 ? menu[1] : menu;
  4139. var select = $('<select/>', {
  4140. 'name': tableId+'_length',
  4141. 'aria-controls': tableId,
  4142. 'class': classes.sLengthSelect
  4143. } );
  4144. for ( var i=0, ien=lengths.length ; i<ien ; i++ ) {
  4145. select[0][ i ] = new Option( language[i], lengths[i] );
  4146. }
  4147. var div = $('<div><label/></div>').addClass( classes.sLength );
  4148. if ( ! settings.aanFeatures.l ) {
  4149. div[0].id = tableId+'_length';
  4150. }
  4151. div.children().append(
  4152. settings.oLanguage.sLengthMenu.replace( '_MENU_', select[0].outerHTML )
  4153. );
  4154. // Can't use `select` variable as user might provide their own and the
  4155. // reference is broken by the use of outerHTML
  4156. $('select', div)
  4157. .val( settings._iDisplayLength )
  4158. .bind( 'change.DT', function(e) {
  4159. _fnLengthChange( settings, $(this).val() );
  4160. _fnDraw( settings );
  4161. } );
  4162. // Update node value whenever anything changes the table's length
  4163. $(settings.nTable).bind( 'length.dt.DT', function (e, s, len) {
  4164. if ( settings === s ) {
  4165. $('select', div).val( len );
  4166. }
  4167. } );
  4168. return div[0];
  4169. }
  4170. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  4171. * Note that most of the paging logic is done in
  4172. * DataTable.ext.pager
  4173. */
  4174. /**
  4175. * Generate the node required for default pagination
  4176. * @param {object} oSettings dataTables settings object
  4177. * @returns {node} Pagination feature node
  4178. * @memberof DataTable#oApi
  4179. */
  4180. function _fnFeatureHtmlPaginate ( settings )
  4181. {
  4182. var
  4183. type = settings.sPaginationType,
  4184. plugin = DataTable.ext.pager[ type ],
  4185. modern = typeof plugin === 'function',
  4186. redraw = function( settings ) {
  4187. _fnDraw( settings );
  4188. },
  4189. node = $('<div/>').addClass( settings.oClasses.sPaging + type )[0],
  4190. features = settings.aanFeatures;
  4191. if ( ! modern ) {
  4192. plugin.fnInit( settings, node, redraw );
  4193. }
  4194. /* Add a draw callback for the pagination on first instance, to update the paging display */
  4195. if ( ! features.p )
  4196. {
  4197. node.id = settings.sTableId+'_paginate';
  4198. settings.aoDrawCallback.push( {
  4199. "fn": function( settings ) {
  4200. if ( modern ) {
  4201. var
  4202. start = settings._iDisplayStart,
  4203. len = settings._iDisplayLength,
  4204. visRecords = settings.fnRecordsDisplay(),
  4205. all = len === -1,
  4206. page = all ? 0 : Math.ceil( start / len ),
  4207. pages = all ? 1 : Math.ceil( visRecords / len ),
  4208. buttons = plugin(page, pages),
  4209. i, ien;
  4210. for ( i=0, ien=features.p.length ; i<ien ; i++ ) {
  4211. _fnRenderer( settings, 'pageButton' )(
  4212. settings, features.p[i], i, buttons, page, pages
  4213. );
  4214. }
  4215. }
  4216. else {
  4217. plugin.fnUpdate( settings, redraw );
  4218. }
  4219. },
  4220. "sName": "pagination"
  4221. } );
  4222. }
  4223. return node;
  4224. }
  4225. /**
  4226. * Alter the display settings to change the page
  4227. * @param {object} settings DataTables settings object
  4228. * @param {string|int} action Paging action to take: "first", "previous",
  4229. * "next" or "last" or page number to jump to (integer)
  4230. * @param [bool] redraw Automatically draw the update or not
  4231. * @returns {bool} true page has changed, false - no change
  4232. * @memberof DataTable#oApi
  4233. */
  4234. function _fnPageChange ( settings, action, redraw )
  4235. {
  4236. var
  4237. start = settings._iDisplayStart,
  4238. len = settings._iDisplayLength,
  4239. records = settings.fnRecordsDisplay();
  4240. if ( records === 0 || len === -1 )
  4241. {
  4242. start = 0;
  4243. }
  4244. else if ( typeof action === "number" )
  4245. {
  4246. start = action * len;
  4247. if ( start > records )
  4248. {
  4249. start = 0;
  4250. }
  4251. }
  4252. else if ( action == "first" )
  4253. {
  4254. start = 0;
  4255. }
  4256. else if ( action == "previous" )
  4257. {
  4258. start = len >= 0 ?
  4259. start - len :
  4260. 0;
  4261. if ( start < 0 )
  4262. {
  4263. start = 0;
  4264. }
  4265. }
  4266. else if ( action == "next" )
  4267. {
  4268. if ( start + len < records )
  4269. {
  4270. start += len;
  4271. }
  4272. }
  4273. else if ( action == "last" )
  4274. {
  4275. start = Math.floor( (records-1) / len) * len;
  4276. }
  4277. else
  4278. {
  4279. _fnLog( settings, 0, "Unknown paging action: "+action, 5 );
  4280. }
  4281. var changed = settings._iDisplayStart !== start;
  4282. settings._iDisplayStart = start;
  4283. if ( changed ) {
  4284. _fnCallbackFire( settings, null, 'page', [settings] );
  4285. if ( redraw ) {
  4286. _fnDraw( settings );
  4287. }
  4288. }
  4289. return changed;
  4290. }
  4291. /**
  4292. * Generate the node required for the processing node
  4293. * @param {object} settings dataTables settings object
  4294. * @returns {node} Processing element
  4295. * @memberof DataTable#oApi
  4296. */
  4297. function _fnFeatureHtmlProcessing ( settings )
  4298. {
  4299. return $('<div/>', {
  4300. 'id': ! settings.aanFeatures.r ? settings.sTableId+'_processing' : null,
  4301. 'class': settings.oClasses.sProcessing
  4302. } )
  4303. .html( settings.oLanguage.sProcessing )
  4304. .insertBefore( settings.nTable )[0];
  4305. }
  4306. /**
  4307. * Display or hide the processing indicator
  4308. * @param {object} settings dataTables settings object
  4309. * @param {bool} show Show the processing indicator (true) or not (false)
  4310. * @memberof DataTable#oApi
  4311. */
  4312. function _fnProcessingDisplay ( settings, show )
  4313. {
  4314. if ( settings.oFeatures.bProcessing ) {
  4315. $(settings.aanFeatures.r).css( 'display', show ? 'block' : 'none' );
  4316. }
  4317. _fnCallbackFire( settings, null, 'processing', [settings, show] );
  4318. }
  4319. /**
  4320. * Add any control elements for the table - specifically scrolling
  4321. * @param {object} settings dataTables settings object
  4322. * @returns {node} Node to add to the DOM
  4323. * @memberof DataTable#oApi
  4324. */
  4325. function _fnFeatureHtmlTable ( settings )
  4326. {
  4327. var table = $(settings.nTable);
  4328. // Add the ARIA grid role to the table
  4329. table.attr( 'role', 'grid' );
  4330. // Scrolling from here on in
  4331. var scroll = settings.oScroll;
  4332. if ( scroll.sX === '' && scroll.sY === '' ) {
  4333. return settings.nTable;
  4334. }
  4335. var scrollX = scroll.sX;
  4336. var scrollY = scroll.sY;
  4337. var classes = settings.oClasses;
  4338. var caption = table.children('caption');
  4339. var captionSide = caption.length ? caption[0]._captionSide : null;
  4340. var headerClone = $( table[0].cloneNode(false) );
  4341. var footerClone = $( table[0].cloneNode(false) );
  4342. var footer = table.children('tfoot');
  4343. var _div = '<div/>';
  4344. var size = function ( s ) {
  4345. return !s ? null : _fnStringToCss( s );
  4346. };
  4347. if ( ! footer.length ) {
  4348. footer = null;
  4349. }
  4350. /*
  4351. * The HTML structure that we want to generate in this function is:
  4352. * div - scroller
  4353. * div - scroll head
  4354. * div - scroll head inner
  4355. * table - scroll head table
  4356. * thead - thead
  4357. * div - scroll body
  4358. * table - table (master table)
  4359. * thead - thead clone for sizing
  4360. * tbody - tbody
  4361. * div - scroll foot
  4362. * div - scroll foot inner
  4363. * table - scroll foot table
  4364. * tfoot - tfoot
  4365. */
  4366. var scroller = $( _div, { 'class': classes.sScrollWrapper } )
  4367. .append(
  4368. $(_div, { 'class': classes.sScrollHead } )
  4369. .css( {
  4370. overflow: 'hidden',
  4371. position: 'relative',
  4372. border: 0,
  4373. width: scrollX ? size(scrollX) : '100%'
  4374. } )
  4375. .append(
  4376. $(_div, { 'class': classes.sScrollHeadInner } )
  4377. .css( {
  4378. 'box-sizing': 'content-box',
  4379. width: scroll.sXInner || '100%'
  4380. } )
  4381. .append(
  4382. headerClone
  4383. .removeAttr('id')
  4384. .css( 'margin-left', 0 )
  4385. .append( captionSide === 'top' ? caption : null )
  4386. .append(
  4387. table.children('thead')
  4388. )
  4389. )
  4390. )
  4391. )
  4392. .append(
  4393. $(_div, { 'class': classes.sScrollBody } )
  4394. .css( {
  4395. position: 'relative',
  4396. overflow: 'auto',
  4397. width: size( scrollX )
  4398. } )
  4399. .append( table )
  4400. );
  4401. if ( footer ) {
  4402. scroller.append(
  4403. $(_div, { 'class': classes.sScrollFoot } )
  4404. .css( {
  4405. overflow: 'hidden',
  4406. border: 0,
  4407. width: scrollX ? size(scrollX) : '100%'
  4408. } )
  4409. .append(
  4410. $(_div, { 'class': classes.sScrollFootInner } )
  4411. .append(
  4412. footerClone
  4413. .removeAttr('id')
  4414. .css( 'margin-left', 0 )
  4415. .append( captionSide === 'bottom' ? caption : null )
  4416. .append(
  4417. table.children('tfoot')
  4418. )
  4419. )
  4420. )
  4421. );
  4422. }
  4423. var children = scroller.children();
  4424. var scrollHead = children[0];
  4425. var scrollBody = children[1];
  4426. var scrollFoot = footer ? children[2] : null;
  4427. // When the body is scrolled, then we also want to scroll the headers
  4428. if ( scrollX ) {
  4429. $(scrollBody).on( 'scroll.DT', function (e) {
  4430. var scrollLeft = this.scrollLeft;
  4431. scrollHead.scrollLeft = scrollLeft;
  4432. if ( footer ) {
  4433. scrollFoot.scrollLeft = scrollLeft;
  4434. }
  4435. } );
  4436. }
  4437. $(scrollBody).css(
  4438. scrollY && scroll.bCollapse ? 'max-height' : 'height',
  4439. scrollY
  4440. );
  4441. settings.nScrollHead = scrollHead;
  4442. settings.nScrollBody = scrollBody;
  4443. settings.nScrollFoot = scrollFoot;
  4444. // On redraw - align columns
  4445. settings.aoDrawCallback.push( {
  4446. "fn": _fnScrollDraw,
  4447. "sName": "scrolling"
  4448. } );
  4449. return scroller[0];
  4450. }
  4451. /**
  4452. * Update the header, footer and body tables for resizing - i.e. column
  4453. * alignment.
  4454. *
  4455. * Welcome to the most horrible function DataTables. The process that this
  4456. * function follows is basically:
  4457. * 1. Re-create the table inside the scrolling div
  4458. * 2. Take live measurements from the DOM
  4459. * 3. Apply the measurements to align the columns
  4460. * 4. Clean up
  4461. *
  4462. * @param {object} settings dataTables settings object
  4463. * @memberof DataTable#oApi
  4464. */
  4465. function _fnScrollDraw ( settings )
  4466. {
  4467. // Given that this is such a monster function, a lot of variables are use
  4468. // to try and keep the minimised size as small as possible
  4469. var
  4470. scroll = settings.oScroll,
  4471. scrollX = scroll.sX,
  4472. scrollXInner = scroll.sXInner,
  4473. scrollY = scroll.sY,
  4474. barWidth = scroll.iBarWidth,
  4475. divHeader = $(settings.nScrollHead),
  4476. divHeaderStyle = divHeader[0].style,
  4477. divHeaderInner = divHeader.children('div'),
  4478. divHeaderInnerStyle = divHeaderInner[0].style,
  4479. divHeaderTable = divHeaderInner.children('table'),
  4480. divBodyEl = settings.nScrollBody,
  4481. divBody = $(divBodyEl),
  4482. divBodyStyle = divBodyEl.style,
  4483. divFooter = $(settings.nScrollFoot),
  4484. divFooterInner = divFooter.children('div'),
  4485. divFooterTable = divFooterInner.children('table'),
  4486. header = $(settings.nTHead),
  4487. table = $(settings.nTable),
  4488. tableEl = table[0],
  4489. tableStyle = tableEl.style,
  4490. footer = settings.nTFoot ? $(settings.nTFoot) : null,
  4491. browser = settings.oBrowser,
  4492. ie67 = browser.bScrollOversize,
  4493. dtHeaderCells = _pluck( settings.aoColumns, 'nTh' ),
  4494. headerTrgEls, footerTrgEls,
  4495. headerSrcEls, footerSrcEls,
  4496. headerCopy, footerCopy,
  4497. headerWidths=[], footerWidths=[],
  4498. headerContent=[], footerContent=[],
  4499. idx, correction, sanityWidth,
  4500. zeroOut = function(nSizer) {
  4501. var style = nSizer.style;
  4502. style.paddingTop = "0";
  4503. style.paddingBottom = "0";
  4504. style.borderTopWidth = "0";
  4505. style.borderBottomWidth = "0";
  4506. style.height = 0;
  4507. };
  4508. // If the scrollbar visibility has changed from the last draw, we need to
  4509. // adjust the column sizes as the table width will have changed to account
  4510. // for the scrollbar
  4511. var scrollBarVis = divBodyEl.scrollHeight > divBodyEl.clientHeight;
  4512. if ( settings.scrollBarVis !== scrollBarVis && settings.scrollBarVis !== undefined ) {
  4513. settings.scrollBarVis = scrollBarVis;
  4514. _fnAdjustColumnSizing( settings );
  4515. return; // adjust column sizing will call this function again
  4516. }
  4517. else {
  4518. settings.scrollBarVis = scrollBarVis;
  4519. }
  4520. /*
  4521. * 1. Re-create the table inside the scrolling div
  4522. */
  4523. // Remove the old minimised thead and tfoot elements in the inner table
  4524. table.children('thead, tfoot').remove();
  4525. if ( footer ) {
  4526. footerCopy = footer.clone().prependTo( table );
  4527. footerTrgEls = footer.find('tr'); // the original tfoot is in its own table and must be sized
  4528. footerSrcEls = footerCopy.find('tr');
  4529. }
  4530. // Clone the current header and footer elements and then place it into the inner table
  4531. headerCopy = header.clone().prependTo( table );
  4532. headerTrgEls = header.find('tr'); // original header is in its own table
  4533. headerSrcEls = headerCopy.find('tr');
  4534. headerCopy.find('th, td').removeAttr('tabindex');
  4535. /*
  4536. * 2. Take live measurements from the DOM - do not alter the DOM itself!
  4537. */
  4538. // Remove old sizing and apply the calculated column widths
  4539. // Get the unique column headers in the newly created (cloned) header. We want to apply the
  4540. // calculated sizes to this header
  4541. if ( ! scrollX )
  4542. {
  4543. divBodyStyle.width = '100%';
  4544. divHeader[0].style.width = '100%';
  4545. }
  4546. $.each( _fnGetUniqueThs( settings, headerCopy ), function ( i, el ) {
  4547. idx = _fnVisibleToColumnIndex( settings, i );
  4548. el.style.width = settings.aoColumns[idx].sWidth;
  4549. } );
  4550. if ( footer ) {
  4551. _fnApplyToChildren( function(n) {
  4552. n.style.width = "";
  4553. }, footerSrcEls );
  4554. }
  4555. // Size the table as a whole
  4556. sanityWidth = table.outerWidth();
  4557. if ( scrollX === "" ) {
  4558. // No x scrolling
  4559. tableStyle.width = "100%";
  4560. // IE7 will make the width of the table when 100% include the scrollbar
  4561. // - which is shouldn't. When there is a scrollbar we need to take this
  4562. // into account.
  4563. if ( ie67 && (table.find('tbody').height() > divBodyEl.offsetHeight ||
  4564. divBody.css('overflow-y') == "scroll")
  4565. ) {
  4566. tableStyle.width = _fnStringToCss( table.outerWidth() - barWidth);
  4567. }
  4568. // Recalculate the sanity width
  4569. sanityWidth = table.outerWidth();
  4570. }
  4571. else if ( scrollXInner !== "" ) {
  4572. // legacy x scroll inner has been given - use it
  4573. tableStyle.width = _fnStringToCss(scrollXInner);
  4574. // Recalculate the sanity width
  4575. sanityWidth = table.outerWidth();
  4576. }
  4577. // Hidden header should have zero height, so remove padding and borders. Then
  4578. // set the width based on the real headers
  4579. // Apply all styles in one pass
  4580. _fnApplyToChildren( zeroOut, headerSrcEls );
  4581. // Read all widths in next pass
  4582. _fnApplyToChildren( function(nSizer) {
  4583. headerContent.push( nSizer.innerHTML );
  4584. headerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  4585. }, headerSrcEls );
  4586. // Apply all widths in final pass
  4587. _fnApplyToChildren( function(nToSize, i) {
  4588. // Only apply widths to the DataTables detected header cells - this
  4589. // prevents complex headers from having contradictory sizes applied
  4590. if ( $.inArray( nToSize, dtHeaderCells ) !== -1 ) {
  4591. nToSize.style.width = headerWidths[i];
  4592. }
  4593. }, headerTrgEls );
  4594. $(headerSrcEls).height(0);
  4595. /* Same again with the footer if we have one */
  4596. if ( footer )
  4597. {
  4598. _fnApplyToChildren( zeroOut, footerSrcEls );
  4599. _fnApplyToChildren( function(nSizer) {
  4600. footerContent.push( nSizer.innerHTML );
  4601. footerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  4602. }, footerSrcEls );
  4603. _fnApplyToChildren( function(nToSize, i) {
  4604. nToSize.style.width = footerWidths[i];
  4605. }, footerTrgEls );
  4606. $(footerSrcEls).height(0);
  4607. }
  4608. /*
  4609. * 3. Apply the measurements
  4610. */
  4611. // "Hide" the header and footer that we used for the sizing. We need to keep
  4612. // the content of the cell so that the width applied to the header and body
  4613. // both match, but we want to hide it completely. We want to also fix their
  4614. // width to what they currently are
  4615. _fnApplyToChildren( function(nSizer, i) {
  4616. nSizer.innerHTML = '<div class="dataTables_sizing" style="height:0;overflow:hidden;">'+headerContent[i]+'</div>';
  4617. nSizer.style.width = headerWidths[i];
  4618. }, headerSrcEls );
  4619. if ( footer )
  4620. {
  4621. _fnApplyToChildren( function(nSizer, i) {
  4622. nSizer.innerHTML = '<div class="dataTables_sizing" style="height:0;overflow:hidden;">'+footerContent[i]+'</div>';
  4623. nSizer.style.width = footerWidths[i];
  4624. }, footerSrcEls );
  4625. }
  4626. // Sanity check that the table is of a sensible width. If not then we are going to get
  4627. // misalignment - try to prevent this by not allowing the table to shrink below its min width
  4628. if ( table.outerWidth() < sanityWidth )
  4629. {
  4630. // The min width depends upon if we have a vertical scrollbar visible or not */
  4631. correction = ((divBodyEl.scrollHeight > divBodyEl.offsetHeight ||
  4632. divBody.css('overflow-y') == "scroll")) ?
  4633. sanityWidth+barWidth :
  4634. sanityWidth;
  4635. // IE6/7 are a law unto themselves...
  4636. if ( ie67 && (divBodyEl.scrollHeight >
  4637. divBodyEl.offsetHeight || divBody.css('overflow-y') == "scroll")
  4638. ) {
  4639. tableStyle.width = _fnStringToCss( correction-barWidth );
  4640. }
  4641. // And give the user a warning that we've stopped the table getting too small
  4642. if ( scrollX === "" || scrollXInner !== "" ) {
  4643. _fnLog( settings, 1, 'Possible column misalignment', 6 );
  4644. }
  4645. }
  4646. else
  4647. {
  4648. correction = '100%';
  4649. }
  4650. // Apply to the container elements
  4651. divBodyStyle.width = _fnStringToCss( correction );
  4652. divHeaderStyle.width = _fnStringToCss( correction );
  4653. if ( footer ) {
  4654. settings.nScrollFoot.style.width = _fnStringToCss( correction );
  4655. }
  4656. /*
  4657. * 4. Clean up
  4658. */
  4659. if ( ! scrollY ) {
  4660. /* IE7< puts a vertical scrollbar in place (when it shouldn't be) due to subtracting
  4661. * the scrollbar height from the visible display, rather than adding it on. We need to
  4662. * set the height in order to sort this. Don't want to do it in any other browsers.
  4663. */
  4664. if ( ie67 ) {
  4665. divBodyStyle.height = _fnStringToCss( tableEl.offsetHeight+barWidth );
  4666. }
  4667. }
  4668. /* Finally set the width's of the header and footer tables */
  4669. var iOuterWidth = table.outerWidth();
  4670. divHeaderTable[0].style.width = _fnStringToCss( iOuterWidth );
  4671. divHeaderInnerStyle.width = _fnStringToCss( iOuterWidth );
  4672. // Figure out if there are scrollbar present - if so then we need a the header and footer to
  4673. // provide a bit more space to allow "overflow" scrolling (i.e. past the scrollbar)
  4674. var bScrolling = table.height() > divBodyEl.clientHeight || divBody.css('overflow-y') == "scroll";
  4675. var padding = 'padding' + (browser.bScrollbarLeft ? 'Left' : 'Right' );
  4676. divHeaderInnerStyle[ padding ] = bScrolling ? barWidth+"px" : "0px";
  4677. if ( footer ) {
  4678. divFooterTable[0].style.width = _fnStringToCss( iOuterWidth );
  4679. divFooterInner[0].style.width = _fnStringToCss( iOuterWidth );
  4680. divFooterInner[0].style[padding] = bScrolling ? barWidth+"px" : "0px";
  4681. }
  4682. // Correct DOM ordering for colgroup - comes before the thead
  4683. table.children('colgroup').insertBefore( table.children('thead') );
  4684. /* Adjust the position of the header in case we loose the y-scrollbar */
  4685. divBody.scroll();
  4686. // If sorting or filtering has occurred, jump the scrolling back to the top
  4687. // only if we aren't holding the position
  4688. if ( (settings.bSorted || settings.bFiltered) && ! settings._drawHold ) {
  4689. divBodyEl.scrollTop = 0;
  4690. }
  4691. }
  4692. /**
  4693. * Apply a given function to the display child nodes of an element array (typically
  4694. * TD children of TR rows
  4695. * @param {function} fn Method to apply to the objects
  4696. * @param array {nodes} an1 List of elements to look through for display children
  4697. * @param array {nodes} an2 Another list (identical structure to the first) - optional
  4698. * @memberof DataTable#oApi
  4699. */
  4700. function _fnApplyToChildren( fn, an1, an2 )
  4701. {
  4702. var index=0, i=0, iLen=an1.length;
  4703. var nNode1, nNode2;
  4704. while ( i < iLen ) {
  4705. nNode1 = an1[i].firstChild;
  4706. nNode2 = an2 ? an2[i].firstChild : null;
  4707. while ( nNode1 ) {
  4708. if ( nNode1.nodeType === 1 ) {
  4709. if ( an2 ) {
  4710. fn( nNode1, nNode2, index );
  4711. }
  4712. else {
  4713. fn( nNode1, index );
  4714. }
  4715. index++;
  4716. }
  4717. nNode1 = nNode1.nextSibling;
  4718. nNode2 = an2 ? nNode2.nextSibling : null;
  4719. }
  4720. i++;
  4721. }
  4722. }
  4723. var __re_html_remove = /<.*?>/g;
  4724. /**
  4725. * Calculate the width of columns for the table
  4726. * @param {object} oSettings dataTables settings object
  4727. * @memberof DataTable#oApi
  4728. */
  4729. function _fnCalculateColumnWidths ( oSettings )
  4730. {
  4731. var
  4732. table = oSettings.nTable,
  4733. columns = oSettings.aoColumns,
  4734. scroll = oSettings.oScroll,
  4735. scrollY = scroll.sY,
  4736. scrollX = scroll.sX,
  4737. scrollXInner = scroll.sXInner,
  4738. columnCount = columns.length,
  4739. visibleColumns = _fnGetColumns( oSettings, 'bVisible' ),
  4740. headerCells = $('th', oSettings.nTHead),
  4741. tableWidthAttr = table.getAttribute('width'), // from DOM element
  4742. tableContainer = table.parentNode,
  4743. userInputs = false,
  4744. i, column, columnIdx, width, outerWidth,
  4745. browser = oSettings.oBrowser,
  4746. ie67 = browser.bScrollOversize;
  4747. var styleWidth = table.style.width;
  4748. if ( styleWidth && styleWidth.indexOf('%') !== -1 ) {
  4749. tableWidthAttr = styleWidth;
  4750. }
  4751. /* Convert any user input sizes into pixel sizes */
  4752. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4753. column = columns[ visibleColumns[i] ];
  4754. if ( column.sWidth !== null ) {
  4755. column.sWidth = _fnConvertToWidth( column.sWidthOrig, tableContainer );
  4756. userInputs = true;
  4757. }
  4758. }
  4759. /* If the number of columns in the DOM equals the number that we have to
  4760. * process in DataTables, then we can use the offsets that are created by
  4761. * the web- browser. No custom sizes can be set in order for this to happen,
  4762. * nor scrolling used
  4763. */
  4764. if ( ie67 || ! userInputs && ! scrollX && ! scrollY &&
  4765. columnCount == _fnVisbleColumns( oSettings ) &&
  4766. columnCount == headerCells.length
  4767. ) {
  4768. for ( i=0 ; i<columnCount ; i++ ) {
  4769. var colIdx = _fnVisibleToColumnIndex( oSettings, i );
  4770. if ( colIdx !== null ) {
  4771. columns[ colIdx ].sWidth = _fnStringToCss( headerCells.eq(i).width() );
  4772. }
  4773. }
  4774. }
  4775. else
  4776. {
  4777. // Otherwise construct a single row, worst case, table with the widest
  4778. // node in the data, assign any user defined widths, then insert it into
  4779. // the DOM and allow the browser to do all the hard work of calculating
  4780. // table widths
  4781. var tmpTable = $(table).clone() // don't use cloneNode - IE8 will remove events on the main table
  4782. .css( 'visibility', 'hidden' )
  4783. .removeAttr( 'id' );
  4784. // Clean up the table body
  4785. tmpTable.find('tbody tr').remove();
  4786. var tr = $('<tr/>').appendTo( tmpTable.find('tbody') );
  4787. // Clone the table header and footer - we can't use the header / footer
  4788. // from the cloned table, since if scrolling is active, the table's
  4789. // real header and footer are contained in different table tags
  4790. tmpTable.find('thead, tfoot').remove();
  4791. tmpTable
  4792. .append( $(oSettings.nTHead).clone() )
  4793. .append( $(oSettings.nTFoot).clone() );
  4794. // Remove any assigned widths from the footer (from scrolling)
  4795. tmpTable.find('tfoot th, tfoot td').css('width', '');
  4796. // Apply custom sizing to the cloned header
  4797. headerCells = _fnGetUniqueThs( oSettings, tmpTable.find('thead')[0] );
  4798. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4799. column = columns[ visibleColumns[i] ];
  4800. headerCells[i].style.width = column.sWidthOrig !== null && column.sWidthOrig !== '' ?
  4801. _fnStringToCss( column.sWidthOrig ) :
  4802. '';
  4803. // For scrollX we need to force the column width otherwise the
  4804. // browser will collapse it. If this width is smaller than the
  4805. // width the column requires, then it will have no effect
  4806. if ( column.sWidthOrig && scrollX ) {
  4807. $( headerCells[i] ).append( $('<div/>').css( {
  4808. width: column.sWidthOrig,
  4809. margin: 0,
  4810. padding: 0,
  4811. border: 0,
  4812. height: 1
  4813. } ) );
  4814. }
  4815. }
  4816. // Find the widest cell for each column and put it into the table
  4817. if ( oSettings.aoData.length ) {
  4818. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4819. columnIdx = visibleColumns[i];
  4820. column = columns[ columnIdx ];
  4821. $( _fnGetWidestNode( oSettings, columnIdx ) )
  4822. .clone( false )
  4823. .append( column.sContentPadding )
  4824. .appendTo( tr );
  4825. }
  4826. }
  4827. // Tidy the temporary table - remove name attributes so there aren't
  4828. // duplicated in the dom (radio elements for example)
  4829. $('[name]', tmpTable).removeAttr('name');
  4830. // Table has been built, attach to the document so we can work with it.
  4831. // A holding element is used, positioned at the top of the container
  4832. // with minimal height, so it has no effect on if the container scrolls
  4833. // or not. Otherwise it might trigger scrolling when it actually isn't
  4834. // needed
  4835. var holder = $('<div/>').css( scrollX || scrollY ?
  4836. {
  4837. position: 'absolute',
  4838. top: 0,
  4839. left: 0,
  4840. height: 1,
  4841. right: 0,
  4842. overflow: 'hidden'
  4843. } :
  4844. {}
  4845. )
  4846. .append( tmpTable )
  4847. .appendTo( tableContainer );
  4848. // When scrolling (X or Y) we want to set the width of the table as
  4849. // appropriate. However, when not scrolling leave the table width as it
  4850. // is. This results in slightly different, but I think correct behaviour
  4851. if ( scrollX && scrollXInner ) {
  4852. tmpTable.width( scrollXInner );
  4853. }
  4854. else if ( scrollX ) {
  4855. tmpTable.css( 'width', 'auto' );
  4856. tmpTable.removeAttr('width');
  4857. // If there is no width attribute or style, then allow the table to
  4858. // collapse
  4859. if ( tmpTable.width() < tableContainer.clientWidth && tableWidthAttr ) {
  4860. tmpTable.width( tableContainer.clientWidth );
  4861. }
  4862. }
  4863. else if ( scrollY ) {
  4864. tmpTable.width( tableContainer.clientWidth );
  4865. }
  4866. else if ( tableWidthAttr ) {
  4867. tmpTable.width( tableWidthAttr );
  4868. }
  4869. // Get the width of each column in the constructed table - we need to
  4870. // know the inner width (so it can be assigned to the other table's
  4871. // cells) and the outer width so we can calculate the full width of the
  4872. // table. This is safe since DataTables requires a unique cell for each
  4873. // column, but if ever a header can span multiple columns, this will
  4874. // need to be modified.
  4875. var total = 0;
  4876. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4877. var cell = $(headerCells[i]);
  4878. var border = cell.outerWidth() - cell.width();
  4879. // Use getBounding... where possible (not IE8-) because it can give
  4880. // sub-pixel accuracy, which we then want to round up!
  4881. var bounding = browser.bBounding ?
  4882. Math.ceil( headerCells[i].getBoundingClientRect().width ) :
  4883. cell.outerWidth();
  4884. // Total is tracked to remove any sub-pixel errors as the outerWidth
  4885. // of the table might not equal the total given here (IE!).
  4886. total += bounding;
  4887. // Width for each column to use
  4888. columns[ visibleColumns[i] ].sWidth = _fnStringToCss( bounding - border );
  4889. }
  4890. table.style.width = _fnStringToCss( total );
  4891. // Finished with the table - ditch it
  4892. holder.remove();
  4893. }
  4894. // If there is a width attr, we want to attach an event listener which
  4895. // allows the table sizing to automatically adjust when the window is
  4896. // resized. Use the width attr rather than CSS, since we can't know if the
  4897. // CSS is a relative value or absolute - DOM read is always px.
  4898. if ( tableWidthAttr ) {
  4899. table.style.width = _fnStringToCss( tableWidthAttr );
  4900. }
  4901. if ( (tableWidthAttr || scrollX) && ! oSettings._reszEvt ) {
  4902. var bindResize = function () {
  4903. $(window).bind('resize.DT-'+oSettings.sInstance, _fnThrottle( function () {
  4904. _fnAdjustColumnSizing( oSettings );
  4905. } ) );
  4906. };
  4907. // IE6/7 will crash if we bind a resize event handler on page load.
  4908. // To be removed in 1.11 which drops IE6/7 support
  4909. if ( ie67 ) {
  4910. setTimeout( bindResize, 1000 );
  4911. }
  4912. else {
  4913. bindResize();
  4914. }
  4915. oSettings._reszEvt = true;
  4916. }
  4917. }
  4918. /**
  4919. * Throttle the calls to a function. Arguments and context are maintained for
  4920. * the throttled function
  4921. * @param {function} fn Function to be called
  4922. * @param {int} [freq=200] call frequency in mS
  4923. * @returns {function} wrapped function
  4924. * @memberof DataTable#oApi
  4925. */
  4926. var _fnThrottle = DataTable.util.throttle;
  4927. /**
  4928. * Convert a CSS unit width to pixels (e.g. 2em)
  4929. * @param {string} width width to be converted
  4930. * @param {node} parent parent to get the with for (required for relative widths) - optional
  4931. * @returns {int} width in pixels
  4932. * @memberof DataTable#oApi
  4933. */
  4934. function _fnConvertToWidth ( width, parent )
  4935. {
  4936. if ( ! width ) {
  4937. return 0;
  4938. }
  4939. var n = $('<div/>')
  4940. .css( 'width', _fnStringToCss( width ) )
  4941. .appendTo( parent || document.body );
  4942. var val = n[0].offsetWidth;
  4943. n.remove();
  4944. return val;
  4945. }
  4946. /**
  4947. * Get the widest node
  4948. * @param {object} settings dataTables settings object
  4949. * @param {int} colIdx column of interest
  4950. * @returns {node} widest table node
  4951. * @memberof DataTable#oApi
  4952. */
  4953. function _fnGetWidestNode( settings, colIdx )
  4954. {
  4955. var idx = _fnGetMaxLenString( settings, colIdx );
  4956. if ( idx < 0 ) {
  4957. return null;
  4958. }
  4959. var data = settings.aoData[ idx ];
  4960. return ! data.nTr ? // Might not have been created when deferred rendering
  4961. $('<td/>').html( _fnGetCellData( settings, idx, colIdx, 'display' ) )[0] :
  4962. data.anCells[ colIdx ];
  4963. }
  4964. /**
  4965. * Get the maximum strlen for each data column
  4966. * @param {object} settings dataTables settings object
  4967. * @param {int} colIdx column of interest
  4968. * @returns {string} max string length for each column
  4969. * @memberof DataTable#oApi
  4970. */
  4971. function _fnGetMaxLenString( settings, colIdx )
  4972. {
  4973. var s, max=-1, maxIdx = -1;
  4974. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  4975. s = _fnGetCellData( settings, i, colIdx, 'display' )+'';
  4976. s = s.replace( __re_html_remove, '' );
  4977. s = s.replace( /&nbsp;/g, ' ' );
  4978. if ( s.length > max ) {
  4979. max = s.length;
  4980. maxIdx = i;
  4981. }
  4982. }
  4983. return maxIdx;
  4984. }
  4985. /**
  4986. * Append a CSS unit (only if required) to a string
  4987. * @param {string} value to css-ify
  4988. * @returns {string} value with css unit
  4989. * @memberof DataTable#oApi
  4990. */
  4991. function _fnStringToCss( s )
  4992. {
  4993. if ( s === null ) {
  4994. return '0px';
  4995. }
  4996. if ( typeof s == 'number' ) {
  4997. return s < 0 ?
  4998. '0px' :
  4999. s+'px';
  5000. }
  5001. // Check it has a unit character already
  5002. return s.match(/\d$/) ?
  5003. s+'px' :
  5004. s;
  5005. }
  5006. function _fnSortFlatten ( settings )
  5007. {
  5008. var
  5009. i, iLen, k, kLen,
  5010. aSort = [],
  5011. aiOrig = [],
  5012. aoColumns = settings.aoColumns,
  5013. aDataSort, iCol, sType, srcCol,
  5014. fixed = settings.aaSortingFixed,
  5015. fixedObj = $.isPlainObject( fixed ),
  5016. nestedSort = [],
  5017. add = function ( a ) {
  5018. if ( a.length && ! $.isArray( a[0] ) ) {
  5019. // 1D array
  5020. nestedSort.push( a );
  5021. }
  5022. else {
  5023. // 2D array
  5024. $.merge( nestedSort, a );
  5025. }
  5026. };
  5027. // Build the sort array, with pre-fix and post-fix options if they have been
  5028. // specified
  5029. if ( $.isArray( fixed ) ) {
  5030. add( fixed );
  5031. }
  5032. if ( fixedObj && fixed.pre ) {
  5033. add( fixed.pre );
  5034. }
  5035. add( settings.aaSorting );
  5036. if (fixedObj && fixed.post ) {
  5037. add( fixed.post );
  5038. }
  5039. for ( i=0 ; i<nestedSort.length ; i++ )
  5040. {
  5041. srcCol = nestedSort[i][0];
  5042. aDataSort = aoColumns[ srcCol ].aDataSort;
  5043. for ( k=0, kLen=aDataSort.length ; k<kLen ; k++ )
  5044. {
  5045. iCol = aDataSort[k];
  5046. sType = aoColumns[ iCol ].sType || 'string';
  5047. if ( nestedSort[i]._idx === undefined ) {
  5048. nestedSort[i]._idx = $.inArray( nestedSort[i][1], aoColumns[iCol].asSorting );
  5049. }
  5050. aSort.push( {
  5051. src: srcCol,
  5052. col: iCol,
  5053. dir: nestedSort[i][1],
  5054. index: nestedSort[i]._idx,
  5055. type: sType,
  5056. formatter: DataTable.ext.type.order[ sType+"-pre" ]
  5057. } );
  5058. }
  5059. }
  5060. return aSort;
  5061. }
  5062. /**
  5063. * Change the order of the table
  5064. * @param {object} oSettings dataTables settings object
  5065. * @memberof DataTable#oApi
  5066. * @todo This really needs split up!
  5067. */
  5068. function _fnSort ( oSettings )
  5069. {
  5070. var
  5071. i, ien, iLen, j, jLen, k, kLen,
  5072. sDataType, nTh,
  5073. aiOrig = [],
  5074. oExtSort = DataTable.ext.type.order,
  5075. aoData = oSettings.aoData,
  5076. aoColumns = oSettings.aoColumns,
  5077. aDataSort, data, iCol, sType, oSort,
  5078. formatters = 0,
  5079. sortCol,
  5080. displayMaster = oSettings.aiDisplayMaster,
  5081. aSort;
  5082. // Resolve any column types that are unknown due to addition or invalidation
  5083. // @todo Can this be moved into a 'data-ready' handler which is called when
  5084. // data is going to be used in the table?
  5085. _fnColumnTypes( oSettings );
  5086. aSort = _fnSortFlatten( oSettings );
  5087. for ( i=0, ien=aSort.length ; i<ien ; i++ ) {
  5088. sortCol = aSort[i];
  5089. // Track if we can use the fast sort algorithm
  5090. if ( sortCol.formatter ) {
  5091. formatters++;
  5092. }
  5093. // Load the data needed for the sort, for each cell
  5094. _fnSortData( oSettings, sortCol.col );
  5095. }
  5096. /* No sorting required if server-side or no sorting array */
  5097. if ( _fnDataSource( oSettings ) != 'ssp' && aSort.length !== 0 )
  5098. {
  5099. // Create a value - key array of the current row positions such that we can use their
  5100. // current position during the sort, if values match, in order to perform stable sorting
  5101. for ( i=0, iLen=displayMaster.length ; i<iLen ; i++ ) {
  5102. aiOrig[ displayMaster[i] ] = i;
  5103. }
  5104. /* Do the sort - here we want multi-column sorting based on a given data source (column)
  5105. * and sorting function (from oSort) in a certain direction. It's reasonably complex to
  5106. * follow on it's own, but this is what we want (example two column sorting):
  5107. * fnLocalSorting = function(a,b){
  5108. * var iTest;
  5109. * iTest = oSort['string-asc']('data11', 'data12');
  5110. * if (iTest !== 0)
  5111. * return iTest;
  5112. * iTest = oSort['numeric-desc']('data21', 'data22');
  5113. * if (iTest !== 0)
  5114. * return iTest;
  5115. * return oSort['numeric-asc']( aiOrig[a], aiOrig[b] );
  5116. * }
  5117. * Basically we have a test for each sorting column, if the data in that column is equal,
  5118. * test the next column. If all columns match, then we use a numeric sort on the row
  5119. * positions in the original data array to provide a stable sort.
  5120. *
  5121. * Note - I know it seems excessive to have two sorting methods, but the first is around
  5122. * 15% faster, so the second is only maintained for backwards compatibility with sorting
  5123. * methods which do not have a pre-sort formatting function.
  5124. */
  5125. if ( formatters === aSort.length ) {
  5126. // All sort types have formatting functions
  5127. displayMaster.sort( function ( a, b ) {
  5128. var
  5129. x, y, k, test, sort,
  5130. len=aSort.length,
  5131. dataA = aoData[a]._aSortData,
  5132. dataB = aoData[b]._aSortData;
  5133. for ( k=0 ; k<len ; k++ ) {
  5134. sort = aSort[k];
  5135. x = dataA[ sort.col ];
  5136. y = dataB[ sort.col ];
  5137. test = x<y ? -1 : x>y ? 1 : 0;
  5138. if ( test !== 0 ) {
  5139. return sort.dir === 'asc' ? test : -test;
  5140. }
  5141. }
  5142. x = aiOrig[a];
  5143. y = aiOrig[b];
  5144. return x<y ? -1 : x>y ? 1 : 0;
  5145. } );
  5146. }
  5147. else {
  5148. // Depreciated - remove in 1.11 (providing a plug-in option)
  5149. // Not all sort types have formatting methods, so we have to call their sorting
  5150. // methods.
  5151. displayMaster.sort( function ( a, b ) {
  5152. var
  5153. x, y, k, l, test, sort, fn,
  5154. len=aSort.length,
  5155. dataA = aoData[a]._aSortData,
  5156. dataB = aoData[b]._aSortData;
  5157. for ( k=0 ; k<len ; k++ ) {
  5158. sort = aSort[k];
  5159. x = dataA[ sort.col ];
  5160. y = dataB[ sort.col ];
  5161. fn = oExtSort[ sort.type+"-"+sort.dir ] || oExtSort[ "string-"+sort.dir ];
  5162. test = fn( x, y );
  5163. if ( test !== 0 ) {
  5164. return test;
  5165. }
  5166. }
  5167. x = aiOrig[a];
  5168. y = aiOrig[b];
  5169. return x<y ? -1 : x>y ? 1 : 0;
  5170. } );
  5171. }
  5172. }
  5173. /* Tell the draw function that we have sorted the data */
  5174. oSettings.bSorted = true;
  5175. }
  5176. function _fnSortAria ( settings )
  5177. {
  5178. var label;
  5179. var nextSort;
  5180. var columns = settings.aoColumns;
  5181. var aSort = _fnSortFlatten( settings );
  5182. var oAria = settings.oLanguage.oAria;
  5183. // ARIA attributes - need to loop all columns, to update all (removing old
  5184. // attributes as needed)
  5185. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  5186. {
  5187. var col = columns[i];
  5188. var asSorting = col.asSorting;
  5189. var sTitle = col.sTitle.replace( /<.*?>/g, "" );
  5190. var th = col.nTh;
  5191. // IE7 is throwing an error when setting these properties with jQuery's
  5192. // attr() and removeAttr() methods...
  5193. th.removeAttribute('aria-sort');
  5194. /* In ARIA only the first sorting column can be marked as sorting - no multi-sort option */
  5195. if ( col.bSortable ) {
  5196. if ( aSort.length > 0 && aSort[0].col == i ) {
  5197. th.setAttribute('aria-sort', aSort[0].dir=="asc" ? "ascending" : "descending" );
  5198. nextSort = asSorting[ aSort[0].index+1 ] || asSorting[0];
  5199. }
  5200. else {
  5201. nextSort = asSorting[0];
  5202. }
  5203. label = sTitle + ( nextSort === "asc" ?
  5204. oAria.sSortAscending :
  5205. oAria.sSortDescending
  5206. );
  5207. }
  5208. else {
  5209. label = sTitle;
  5210. }
  5211. th.setAttribute('aria-label', label);
  5212. }
  5213. }
  5214. /**
  5215. * Function to run on user sort request
  5216. * @param {object} settings dataTables settings object
  5217. * @param {node} attachTo node to attach the handler to
  5218. * @param {int} colIdx column sorting index
  5219. * @param {boolean} [append=false] Append the requested sort to the existing
  5220. * sort if true (i.e. multi-column sort)
  5221. * @param {function} [callback] callback function
  5222. * @memberof DataTable#oApi
  5223. */
  5224. function _fnSortListener ( settings, colIdx, append, callback )
  5225. {
  5226. var col = settings.aoColumns[ colIdx ];
  5227. var sorting = settings.aaSorting;
  5228. var asSorting = col.asSorting;
  5229. var nextSortIdx;
  5230. var next = function ( a, overflow ) {
  5231. var idx = a._idx;
  5232. if ( idx === undefined ) {
  5233. idx = $.inArray( a[1], asSorting );
  5234. }
  5235. return idx+1 < asSorting.length ?
  5236. idx+1 :
  5237. overflow ?
  5238. null :
  5239. 0;
  5240. };
  5241. // Convert to 2D array if needed
  5242. if ( typeof sorting[0] === 'number' ) {
  5243. sorting = settings.aaSorting = [ sorting ];
  5244. }
  5245. // If appending the sort then we are multi-column sorting
  5246. if ( append && settings.oFeatures.bSortMulti ) {
  5247. // Are we already doing some kind of sort on this column?
  5248. var sortIdx = $.inArray( colIdx, _pluck(sorting, '0') );
  5249. if ( sortIdx !== -1 ) {
  5250. // Yes, modify the sort
  5251. nextSortIdx = next( sorting[sortIdx], true );
  5252. if ( nextSortIdx === null && sorting.length === 1 ) {
  5253. nextSortIdx = 0; // can't remove sorting completely
  5254. }
  5255. if ( nextSortIdx === null ) {
  5256. sorting.splice( sortIdx, 1 );
  5257. }
  5258. else {
  5259. sorting[sortIdx][1] = asSorting[ nextSortIdx ];
  5260. sorting[sortIdx]._idx = nextSortIdx;
  5261. }
  5262. }
  5263. else {
  5264. // No sort on this column yet
  5265. sorting.push( [ colIdx, asSorting[0], 0 ] );
  5266. sorting[sorting.length-1]._idx = 0;
  5267. }
  5268. }
  5269. else if ( sorting.length && sorting[0][0] == colIdx ) {
  5270. // Single column - already sorting on this column, modify the sort
  5271. nextSortIdx = next( sorting[0] );
  5272. sorting.length = 1;
  5273. sorting[0][1] = asSorting[ nextSortIdx ];
  5274. sorting[0]._idx = nextSortIdx;
  5275. }
  5276. else {
  5277. // Single column - sort only on this column
  5278. sorting.length = 0;
  5279. sorting.push( [ colIdx, asSorting[0] ] );
  5280. sorting[0]._idx = 0;
  5281. }
  5282. // Run the sort by calling a full redraw
  5283. _fnReDraw( settings );
  5284. // callback used for async user interaction
  5285. if ( typeof callback == 'function' ) {
  5286. callback( settings );
  5287. }
  5288. }
  5289. /**
  5290. * Attach a sort handler (click) to a node
  5291. * @param {object} settings dataTables settings object
  5292. * @param {node} attachTo node to attach the handler to
  5293. * @param {int} colIdx column sorting index
  5294. * @param {function} [callback] callback function
  5295. * @memberof DataTable#oApi
  5296. */
  5297. function _fnSortAttachListener ( settings, attachTo, colIdx, callback )
  5298. {
  5299. var col = settings.aoColumns[ colIdx ];
  5300. _fnBindAction( attachTo, {}, function (e) {
  5301. /* If the column is not sortable - don't to anything */
  5302. if ( col.bSortable === false ) {
  5303. return;
  5304. }
  5305. // If processing is enabled use a timeout to allow the processing
  5306. // display to be shown - otherwise to it synchronously
  5307. if ( settings.oFeatures.bProcessing ) {
  5308. _fnProcessingDisplay( settings, true );
  5309. setTimeout( function() {
  5310. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  5311. // In server-side processing, the draw callback will remove the
  5312. // processing display
  5313. if ( _fnDataSource( settings ) !== 'ssp' ) {
  5314. _fnProcessingDisplay( settings, false );
  5315. }
  5316. }, 0 );
  5317. }
  5318. else {
  5319. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  5320. }
  5321. } );
  5322. }
  5323. /**
  5324. * Set the sorting classes on table's body, Note: it is safe to call this function
  5325. * when bSort and bSortClasses are false
  5326. * @param {object} oSettings dataTables settings object
  5327. * @memberof DataTable#oApi
  5328. */
  5329. function _fnSortingClasses( settings )
  5330. {
  5331. var oldSort = settings.aLastSort;
  5332. var sortClass = settings.oClasses.sSortColumn;
  5333. var sort = _fnSortFlatten( settings );
  5334. var features = settings.oFeatures;
  5335. var i, ien, colIdx;
  5336. if ( features.bSort && features.bSortClasses ) {
  5337. // Remove old sorting classes
  5338. for ( i=0, ien=oldSort.length ; i<ien ; i++ ) {
  5339. colIdx = oldSort[i].src;
  5340. // Remove column sorting
  5341. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  5342. .removeClass( sortClass + (i<2 ? i+1 : 3) );
  5343. }
  5344. // Add new column sorting
  5345. for ( i=0, ien=sort.length ; i<ien ; i++ ) {
  5346. colIdx = sort[i].src;
  5347. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  5348. .addClass( sortClass + (i<2 ? i+1 : 3) );
  5349. }
  5350. }
  5351. settings.aLastSort = sort;
  5352. }
  5353. // Get the data to sort a column, be it from cache, fresh (populating the
  5354. // cache), or from a sort formatter
  5355. function _fnSortData( settings, idx )
  5356. {
  5357. // Custom sorting function - provided by the sort data type
  5358. var column = settings.aoColumns[ idx ];
  5359. var customSort = DataTable.ext.order[ column.sSortDataType ];
  5360. var customData;
  5361. if ( customSort ) {
  5362. customData = customSort.call( settings.oInstance, settings, idx,
  5363. _fnColumnIndexToVisible( settings, idx )
  5364. );
  5365. }
  5366. // Use / populate cache
  5367. var row, cellData;
  5368. var formatter = DataTable.ext.type.order[ column.sType+"-pre" ];
  5369. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  5370. row = settings.aoData[i];
  5371. if ( ! row._aSortData ) {
  5372. row._aSortData = [];
  5373. }
  5374. if ( ! row._aSortData[idx] || customSort ) {
  5375. cellData = customSort ?
  5376. customData[i] : // If there was a custom sort function, use data from there
  5377. _fnGetCellData( settings, i, idx, 'sort' );
  5378. row._aSortData[ idx ] = formatter ?
  5379. formatter( cellData ) :
  5380. cellData;
  5381. }
  5382. }
  5383. }
  5384. /**
  5385. * Save the state of a table
  5386. * @param {object} oSettings dataTables settings object
  5387. * @memberof DataTable#oApi
  5388. */
  5389. function _fnSaveState ( settings )
  5390. {
  5391. if ( !settings.oFeatures.bStateSave || settings.bDestroying )
  5392. {
  5393. return;
  5394. }
  5395. /* Store the interesting variables */
  5396. var state = {
  5397. time: +new Date(),
  5398. start: settings._iDisplayStart,
  5399. length: settings._iDisplayLength,
  5400. order: $.extend( true, [], settings.aaSorting ),
  5401. search: _fnSearchToCamel( settings.oPreviousSearch ),
  5402. columns: $.map( settings.aoColumns, function ( col, i ) {
  5403. return {
  5404. visible: col.bVisible,
  5405. search: _fnSearchToCamel( settings.aoPreSearchCols[i] )
  5406. };
  5407. } )
  5408. };
  5409. _fnCallbackFire( settings, "aoStateSaveParams", 'stateSaveParams', [settings, state] );
  5410. settings.oSavedState = state;
  5411. settings.fnStateSaveCallback.call( settings.oInstance, settings, state );
  5412. }
  5413. /**
  5414. * Attempt to load a saved table state
  5415. * @param {object} oSettings dataTables settings object
  5416. * @param {object} oInit DataTables init object so we can override settings
  5417. * @memberof DataTable#oApi
  5418. */
  5419. function _fnLoadState ( settings, oInit )
  5420. {
  5421. var i, ien;
  5422. var columns = settings.aoColumns;
  5423. if ( ! settings.oFeatures.bStateSave ) {
  5424. return;
  5425. }
  5426. var state = settings.fnStateLoadCallback.call( settings.oInstance, settings );
  5427. if ( ! state || ! state.time ) {
  5428. return;
  5429. }
  5430. /* Allow custom and plug-in manipulation functions to alter the saved data set and
  5431. * cancelling of loading by returning false
  5432. */
  5433. var abStateLoad = _fnCallbackFire( settings, 'aoStateLoadParams', 'stateLoadParams', [settings, state] );
  5434. if ( $.inArray( false, abStateLoad ) !== -1 ) {
  5435. return;
  5436. }
  5437. /* Reject old data */
  5438. var duration = settings.iStateDuration;
  5439. if ( duration > 0 && state.time < +new Date() - (duration*1000) ) {
  5440. return;
  5441. }
  5442. // Number of columns have changed - all bets are off, no restore of settings
  5443. if ( columns.length !== state.columns.length ) {
  5444. return;
  5445. }
  5446. // Store the saved state so it might be accessed at any time
  5447. settings.oLoadedState = $.extend( true, {}, state );
  5448. // Restore key features - todo - for 1.11 this needs to be done by
  5449. // subscribed events
  5450. if ( state.start !== undefined ) {
  5451. settings._iDisplayStart = state.start;
  5452. settings.iInitDisplayStart = state.start;
  5453. }
  5454. if ( state.length !== undefined ) {
  5455. settings._iDisplayLength = state.length;
  5456. }
  5457. // Order
  5458. if ( state.order !== undefined ) {
  5459. settings.aaSorting = [];
  5460. $.each( state.order, function ( i, col ) {
  5461. settings.aaSorting.push( col[0] >= columns.length ?
  5462. [ 0, col[1] ] :
  5463. col
  5464. );
  5465. } );
  5466. }
  5467. // Search
  5468. if ( state.search !== undefined ) {
  5469. $.extend( settings.oPreviousSearch, _fnSearchToHung( state.search ) );
  5470. }
  5471. // Columns
  5472. for ( i=0, ien=state.columns.length ; i<ien ; i++ ) {
  5473. var col = state.columns[i];
  5474. // Visibility
  5475. if ( col.visible !== undefined ) {
  5476. columns[i].bVisible = col.visible;
  5477. }
  5478. // Search
  5479. if ( col.search !== undefined ) {
  5480. $.extend( settings.aoPreSearchCols[i], _fnSearchToHung( col.search ) );
  5481. }
  5482. }
  5483. _fnCallbackFire( settings, 'aoStateLoaded', 'stateLoaded', [settings, state] );
  5484. }
  5485. /**
  5486. * Return the settings object for a particular table
  5487. * @param {node} table table we are using as a dataTable
  5488. * @returns {object} Settings object - or null if not found
  5489. * @memberof DataTable#oApi
  5490. */
  5491. function _fnSettingsFromNode ( table )
  5492. {
  5493. var settings = DataTable.settings;
  5494. var idx = $.inArray( table, _pluck( settings, 'nTable' ) );
  5495. return idx !== -1 ?
  5496. settings[ idx ] :
  5497. null;
  5498. }
  5499. /**
  5500. * Log an error message
  5501. * @param {object} settings dataTables settings object
  5502. * @param {int} level log error messages, or display them to the user
  5503. * @param {string} msg error message
  5504. * @param {int} tn Technical note id to get more information about the error.
  5505. * @memberof DataTable#oApi
  5506. */
  5507. function _fnLog( settings, level, msg, tn )
  5508. {
  5509. msg = 'DataTables warning: '+
  5510. (settings ? 'table id='+settings.sTableId+' - ' : '')+msg;
  5511. if ( tn ) {
  5512. msg += '. For more information about this error, please see '+
  5513. 'http://datatables.net/tn/'+tn;
  5514. }
  5515. if ( ! level ) {
  5516. // Backwards compatibility pre 1.10
  5517. var ext = DataTable.ext;
  5518. var type = ext.sErrMode || ext.errMode;
  5519. if ( settings ) {
  5520. _fnCallbackFire( settings, null, 'error', [ settings, tn, msg ] );
  5521. }
  5522. if ( type == 'alert' ) {
  5523. alert( msg );
  5524. }
  5525. else if ( type == 'throw' ) {
  5526. throw new Error(msg);
  5527. }
  5528. else if ( typeof type == 'function' ) {
  5529. type( settings, tn, msg );
  5530. }
  5531. }
  5532. else if ( window.console && console.log ) {
  5533. console.log( msg );
  5534. }
  5535. }
  5536. /**
  5537. * See if a property is defined on one object, if so assign it to the other object
  5538. * @param {object} ret target object
  5539. * @param {object} src source object
  5540. * @param {string} name property
  5541. * @param {string} [mappedName] name to map too - optional, name used if not given
  5542. * @memberof DataTable#oApi
  5543. */
  5544. function _fnMap( ret, src, name, mappedName )
  5545. {
  5546. if ( $.isArray( name ) ) {
  5547. $.each( name, function (i, val) {
  5548. if ( $.isArray( val ) ) {
  5549. _fnMap( ret, src, val[0], val[1] );
  5550. }
  5551. else {
  5552. _fnMap( ret, src, val );
  5553. }
  5554. } );
  5555. return;
  5556. }
  5557. if ( mappedName === undefined ) {
  5558. mappedName = name;
  5559. }
  5560. if ( src[name] !== undefined ) {
  5561. ret[mappedName] = src[name];
  5562. }
  5563. }
  5564. /**
  5565. * Extend objects - very similar to jQuery.extend, but deep copy objects, and
  5566. * shallow copy arrays. The reason we need to do this, is that we don't want to
  5567. * deep copy array init values (such as aaSorting) since the dev wouldn't be
  5568. * able to override them, but we do want to deep copy arrays.
  5569. * @param {object} out Object to extend
  5570. * @param {object} extender Object from which the properties will be applied to
  5571. * out
  5572. * @param {boolean} breakRefs If true, then arrays will be sliced to take an
  5573. * independent copy with the exception of the `data` or `aaData` parameters
  5574. * if they are present. This is so you can pass in a collection to
  5575. * DataTables and have that used as your data source without breaking the
  5576. * references
  5577. * @returns {object} out Reference, just for convenience - out === the return.
  5578. * @memberof DataTable#oApi
  5579. * @todo This doesn't take account of arrays inside the deep copied objects.
  5580. */
  5581. function _fnExtend( out, extender, breakRefs )
  5582. {
  5583. var val;
  5584. for ( var prop in extender ) {
  5585. if ( extender.hasOwnProperty(prop) ) {
  5586. val = extender[prop];
  5587. if ( $.isPlainObject( val ) ) {
  5588. if ( ! $.isPlainObject( out[prop] ) ) {
  5589. out[prop] = {};
  5590. }
  5591. $.extend( true, out[prop], val );
  5592. }
  5593. else if ( breakRefs && prop !== 'data' && prop !== 'aaData' && $.isArray(val) ) {
  5594. out[prop] = val.slice();
  5595. }
  5596. else {
  5597. out[prop] = val;
  5598. }
  5599. }
  5600. }
  5601. return out;
  5602. }
  5603. /**
  5604. * Bind an event handers to allow a click or return key to activate the callback.
  5605. * This is good for accessibility since a return on the keyboard will have the
  5606. * same effect as a click, if the element has focus.
  5607. * @param {element} n Element to bind the action to
  5608. * @param {object} oData Data object to pass to the triggered function
  5609. * @param {function} fn Callback function for when the event is triggered
  5610. * @memberof DataTable#oApi
  5611. */
  5612. function _fnBindAction( n, oData, fn )
  5613. {
  5614. $(n)
  5615. .bind( 'click.DT', oData, function (e) {
  5616. n.blur(); // Remove focus outline for mouse users
  5617. fn(e);
  5618. } )
  5619. .bind( 'keypress.DT', oData, function (e){
  5620. if ( e.which === 13 ) {
  5621. e.preventDefault();
  5622. fn(e);
  5623. }
  5624. } )
  5625. .bind( 'selectstart.DT', function () {
  5626. /* Take the brutal approach to cancelling text selection */
  5627. return false;
  5628. } );
  5629. }
  5630. /**
  5631. * Register a callback function. Easily allows a callback function to be added to
  5632. * an array store of callback functions that can then all be called together.
  5633. * @param {object} oSettings dataTables settings object
  5634. * @param {string} sStore Name of the array storage for the callbacks in oSettings
  5635. * @param {function} fn Function to be called back
  5636. * @param {string} sName Identifying name for the callback (i.e. a label)
  5637. * @memberof DataTable#oApi
  5638. */
  5639. function _fnCallbackReg( oSettings, sStore, fn, sName )
  5640. {
  5641. if ( fn )
  5642. {
  5643. oSettings[sStore].push( {
  5644. "fn": fn,
  5645. "sName": sName
  5646. } );
  5647. }
  5648. }
  5649. /**
  5650. * Fire callback functions and trigger events. Note that the loop over the
  5651. * callback array store is done backwards! Further note that you do not want to
  5652. * fire off triggers in time sensitive applications (for example cell creation)
  5653. * as its slow.
  5654. * @param {object} settings dataTables settings object
  5655. * @param {string} callbackArr Name of the array storage for the callbacks in
  5656. * oSettings
  5657. * @param {string} eventName Name of the jQuery custom event to trigger. If
  5658. * null no trigger is fired
  5659. * @param {array} args Array of arguments to pass to the callback function /
  5660. * trigger
  5661. * @memberof DataTable#oApi
  5662. */
  5663. function _fnCallbackFire( settings, callbackArr, eventName, args )
  5664. {
  5665. var ret = [];
  5666. if ( callbackArr ) {
  5667. ret = $.map( settings[callbackArr].slice().reverse(), function (val, i) {
  5668. return val.fn.apply( settings.oInstance, args );
  5669. } );
  5670. }
  5671. if ( eventName !== null ) {
  5672. var e = $.Event( eventName+'.dt' );
  5673. $(settings.nTable).trigger( e, args );
  5674. ret.push( e.result );
  5675. }
  5676. return ret;
  5677. }
  5678. function _fnLengthOverflow ( settings )
  5679. {
  5680. var
  5681. start = settings._iDisplayStart,
  5682. end = settings.fnDisplayEnd(),
  5683. len = settings._iDisplayLength;
  5684. /* If we have space to show extra rows (backing up from the end point - then do so */
  5685. if ( start >= end )
  5686. {
  5687. start = end - len;
  5688. }
  5689. // Keep the start record on the current page
  5690. start -= (start % len);
  5691. if ( len === -1 || start < 0 )
  5692. {
  5693. start = 0;
  5694. }
  5695. settings._iDisplayStart = start;
  5696. }
  5697. function _fnRenderer( settings, type )
  5698. {
  5699. var renderer = settings.renderer;
  5700. var host = DataTable.ext.renderer[type];
  5701. if ( $.isPlainObject( renderer ) && renderer[type] ) {
  5702. // Specific renderer for this type. If available use it, otherwise use
  5703. // the default.
  5704. return host[renderer[type]] || host._;
  5705. }
  5706. else if ( typeof renderer === 'string' ) {
  5707. // Common renderer - if there is one available for this type use it,
  5708. // otherwise use the default
  5709. return host[renderer] || host._;
  5710. }
  5711. // Use the default
  5712. return host._;
  5713. }
  5714. /**
  5715. * Detect the data source being used for the table. Used to simplify the code
  5716. * a little (ajax) and to make it compress a little smaller.
  5717. *
  5718. * @param {object} settings dataTables settings object
  5719. * @returns {string} Data source
  5720. * @memberof DataTable#oApi
  5721. */
  5722. function _fnDataSource ( settings )
  5723. {
  5724. if ( settings.oFeatures.bServerSide ) {
  5725. return 'ssp';
  5726. }
  5727. else if ( settings.ajax || settings.sAjaxSource ) {
  5728. return 'ajax';
  5729. }
  5730. return 'dom';
  5731. }
  5732. /**
  5733. * Computed structure of the DataTables API, defined by the options passed to
  5734. * `DataTable.Api.register()` when building the API.
  5735. *
  5736. * The structure is built in order to speed creation and extension of the Api
  5737. * objects since the extensions are effectively pre-parsed.
  5738. *
  5739. * The array is an array of objects with the following structure, where this
  5740. * base array represents the Api prototype base:
  5741. *
  5742. * [
  5743. * {
  5744. * name: 'data' -- string - Property name
  5745. * val: function () {}, -- function - Api method (or undefined if just an object
  5746. * methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  5747. * propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  5748. * },
  5749. * {
  5750. * name: 'row'
  5751. * val: {},
  5752. * methodExt: [ ... ],
  5753. * propExt: [
  5754. * {
  5755. * name: 'data'
  5756. * val: function () {},
  5757. * methodExt: [ ... ],
  5758. * propExt: [ ... ]
  5759. * },
  5760. * ...
  5761. * ]
  5762. * }
  5763. * ]
  5764. *
  5765. * @type {Array}
  5766. * @ignore
  5767. */
  5768. var __apiStruct = [];
  5769. /**
  5770. * `Array.prototype` reference.
  5771. *
  5772. * @type object
  5773. * @ignore
  5774. */
  5775. var __arrayProto = Array.prototype;
  5776. /**
  5777. * Abstraction for `context` parameter of the `Api` constructor to allow it to
  5778. * take several different forms for ease of use.
  5779. *
  5780. * Each of the input parameter types will be converted to a DataTables settings
  5781. * object where possible.
  5782. *
  5783. * @param {string|node|jQuery|object} mixed DataTable identifier. Can be one
  5784. * of:
  5785. *
  5786. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5787. * with be found and used.
  5788. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5789. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5790. * * `object` - DataTables settings object
  5791. * * `DataTables.Api` - API instance
  5792. * @return {array|null} Matching DataTables settings objects. `null` or
  5793. * `undefined` is returned if no matching DataTable is found.
  5794. * @ignore
  5795. */
  5796. var _toSettings = function ( mixed )
  5797. {
  5798. var idx, jq;
  5799. var settings = DataTable.settings;
  5800. var tables = $.map( settings, function (el, i) {
  5801. return el.nTable;
  5802. } );
  5803. if ( ! mixed ) {
  5804. return [];
  5805. }
  5806. else if ( mixed.nTable && mixed.oApi ) {
  5807. // DataTables settings object
  5808. return [ mixed ];
  5809. }
  5810. else if ( mixed.nodeName && mixed.nodeName.toLowerCase() === 'table' ) {
  5811. // Table node
  5812. idx = $.inArray( mixed, tables );
  5813. return idx !== -1 ? [ settings[idx] ] : null;
  5814. }
  5815. else if ( mixed && typeof mixed.settings === 'function' ) {
  5816. return mixed.settings().toArray();
  5817. }
  5818. else if ( typeof mixed === 'string' ) {
  5819. // jQuery selector
  5820. jq = $(mixed);
  5821. }
  5822. else if ( mixed instanceof $ ) {
  5823. // jQuery object (also DataTables instance)
  5824. jq = mixed;
  5825. }
  5826. if ( jq ) {
  5827. return jq.map( function(i) {
  5828. idx = $.inArray( this, tables );
  5829. return idx !== -1 ? settings[idx] : null;
  5830. } ).toArray();
  5831. }
  5832. };
  5833. /**
  5834. * DataTables API class - used to control and interface with one or more
  5835. * DataTables enhanced tables.
  5836. *
  5837. * The API class is heavily based on jQuery, presenting a chainable interface
  5838. * that you can use to interact with tables. Each instance of the API class has
  5839. * a "context" - i.e. the tables that it will operate on. This could be a single
  5840. * table, all tables on a page or a sub-set thereof.
  5841. *
  5842. * Additionally the API is designed to allow you to easily work with the data in
  5843. * the tables, retrieving and manipulating it as required. This is done by
  5844. * presenting the API class as an array like interface. The contents of the
  5845. * array depend upon the actions requested by each method (for example
  5846. * `rows().nodes()` will return an array of nodes, while `rows().data()` will
  5847. * return an array of objects or arrays depending upon your table's
  5848. * configuration). The API object has a number of array like methods (`push`,
  5849. * `pop`, `reverse` etc) as well as additional helper methods (`each`, `pluck`,
  5850. * `unique` etc) to assist your working with the data held in a table.
  5851. *
  5852. * Most methods (those which return an Api instance) are chainable, which means
  5853. * the return from a method call also has all of the methods available that the
  5854. * top level object had. For example, these two calls are equivalent:
  5855. *
  5856. * // Not chained
  5857. * api.row.add( {...} );
  5858. * api.draw();
  5859. *
  5860. * // Chained
  5861. * api.row.add( {...} ).draw();
  5862. *
  5863. * @class DataTable.Api
  5864. * @param {array|object|string|jQuery} context DataTable identifier. This is
  5865. * used to define which DataTables enhanced tables this API will operate on.
  5866. * Can be one of:
  5867. *
  5868. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5869. * with be found and used.
  5870. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5871. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5872. * * `object` - DataTables settings object
  5873. * @param {array} [data] Data to initialise the Api instance with.
  5874. *
  5875. * @example
  5876. * // Direct initialisation during DataTables construction
  5877. * var api = $('#example').DataTable();
  5878. *
  5879. * @example
  5880. * // Initialisation using a DataTables jQuery object
  5881. * var api = $('#example').dataTable().api();
  5882. *
  5883. * @example
  5884. * // Initialisation as a constructor
  5885. * var api = new $.fn.DataTable.Api( 'table.dataTable' );
  5886. */
  5887. _Api = function ( context, data )
  5888. {
  5889. if ( ! (this instanceof _Api) ) {
  5890. return new _Api( context, data );
  5891. }
  5892. var settings = [];
  5893. var ctxSettings = function ( o ) {
  5894. var a = _toSettings( o );
  5895. if ( a ) {
  5896. settings = settings.concat( a );
  5897. }
  5898. };
  5899. if ( $.isArray( context ) ) {
  5900. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  5901. ctxSettings( context[i] );
  5902. }
  5903. }
  5904. else {
  5905. ctxSettings( context );
  5906. }
  5907. // Remove duplicates
  5908. this.context = _unique( settings );
  5909. // Initial data
  5910. if ( data ) {
  5911. $.merge( this, data );
  5912. }
  5913. // selector
  5914. this.selector = {
  5915. rows: null,
  5916. cols: null,
  5917. opts: null
  5918. };
  5919. _Api.extend( this, this, __apiStruct );
  5920. };
  5921. DataTable.Api = _Api;
  5922. // Don't destroy the existing prototype, just extend it. Required for jQuery 2's
  5923. // isPlainObject.
  5924. $.extend( _Api.prototype, {
  5925. any: function ()
  5926. {
  5927. return this.count() !== 0;
  5928. },
  5929. concat: __arrayProto.concat,
  5930. context: [], // array of table settings objects
  5931. count: function ()
  5932. {
  5933. return this.flatten().length;
  5934. },
  5935. each: function ( fn )
  5936. {
  5937. for ( var i=0, ien=this.length ; i<ien; i++ ) {
  5938. fn.call( this, this[i], i, this );
  5939. }
  5940. return this;
  5941. },
  5942. eq: function ( idx )
  5943. {
  5944. var ctx = this.context;
  5945. return ctx.length > idx ?
  5946. new _Api( ctx[idx], this[idx] ) :
  5947. null;
  5948. },
  5949. filter: function ( fn )
  5950. {
  5951. var a = [];
  5952. if ( __arrayProto.filter ) {
  5953. a = __arrayProto.filter.call( this, fn, this );
  5954. }
  5955. else {
  5956. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  5957. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  5958. if ( fn.call( this, this[i], i, this ) ) {
  5959. a.push( this[i] );
  5960. }
  5961. }
  5962. }
  5963. return new _Api( this.context, a );
  5964. },
  5965. flatten: function ()
  5966. {
  5967. var a = [];
  5968. return new _Api( this.context, a.concat.apply( a, this.toArray() ) );
  5969. },
  5970. join: __arrayProto.join,
  5971. indexOf: __arrayProto.indexOf || function (obj, start)
  5972. {
  5973. for ( var i=(start || 0), ien=this.length ; i<ien ; i++ ) {
  5974. if ( this[i] === obj ) {
  5975. return i;
  5976. }
  5977. }
  5978. return -1;
  5979. },
  5980. iterator: function ( flatten, type, fn, alwaysNew ) {
  5981. var
  5982. a = [], ret,
  5983. i, ien, j, jen,
  5984. context = this.context,
  5985. rows, items, item,
  5986. selector = this.selector;
  5987. // Argument shifting
  5988. if ( typeof flatten === 'string' ) {
  5989. alwaysNew = fn;
  5990. fn = type;
  5991. type = flatten;
  5992. flatten = false;
  5993. }
  5994. for ( i=0, ien=context.length ; i<ien ; i++ ) {
  5995. var apiInst = new _Api( context[i] );
  5996. if ( type === 'table' ) {
  5997. ret = fn.call( apiInst, context[i], i );
  5998. if ( ret !== undefined ) {
  5999. a.push( ret );
  6000. }
  6001. }
  6002. else if ( type === 'columns' || type === 'rows' ) {
  6003. // this has same length as context - one entry for each table
  6004. ret = fn.call( apiInst, context[i], this[i], i );
  6005. if ( ret !== undefined ) {
  6006. a.push( ret );
  6007. }
  6008. }
  6009. else if ( type === 'column' || type === 'column-rows' || type === 'row' || type === 'cell' ) {
  6010. // columns and rows share the same structure.
  6011. // 'this' is an array of column indexes for each context
  6012. items = this[i];
  6013. if ( type === 'column-rows' ) {
  6014. rows = _selector_row_indexes( context[i], selector.opts );
  6015. }
  6016. for ( j=0, jen=items.length ; j<jen ; j++ ) {
  6017. item = items[j];
  6018. if ( type === 'cell' ) {
  6019. ret = fn.call( apiInst, context[i], item.row, item.column, i, j );
  6020. }
  6021. else {
  6022. ret = fn.call( apiInst, context[i], item, i, j, rows );
  6023. }
  6024. if ( ret !== undefined ) {
  6025. a.push( ret );
  6026. }
  6027. }
  6028. }
  6029. }
  6030. if ( a.length || alwaysNew ) {
  6031. var api = new _Api( context, flatten ? a.concat.apply( [], a ) : a );
  6032. var apiSelector = api.selector;
  6033. apiSelector.rows = selector.rows;
  6034. apiSelector.cols = selector.cols;
  6035. apiSelector.opts = selector.opts;
  6036. return api;
  6037. }
  6038. return this;
  6039. },
  6040. lastIndexOf: __arrayProto.lastIndexOf || function (obj, start)
  6041. {
  6042. // Bit cheeky...
  6043. return this.indexOf.apply( this.toArray.reverse(), arguments );
  6044. },
  6045. length: 0,
  6046. map: function ( fn )
  6047. {
  6048. var a = [];
  6049. if ( __arrayProto.map ) {
  6050. a = __arrayProto.map.call( this, fn, this );
  6051. }
  6052. else {
  6053. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  6054. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  6055. a.push( fn.call( this, this[i], i ) );
  6056. }
  6057. }
  6058. return new _Api( this.context, a );
  6059. },
  6060. pluck: function ( prop )
  6061. {
  6062. return this.map( function ( el ) {
  6063. return el[ prop ];
  6064. } );
  6065. },
  6066. pop: __arrayProto.pop,
  6067. push: __arrayProto.push,
  6068. // Does not return an API instance
  6069. reduce: __arrayProto.reduce || function ( fn, init )
  6070. {
  6071. return _fnReduce( this, fn, init, 0, this.length, 1 );
  6072. },
  6073. reduceRight: __arrayProto.reduceRight || function ( fn, init )
  6074. {
  6075. return _fnReduce( this, fn, init, this.length-1, -1, -1 );
  6076. },
  6077. reverse: __arrayProto.reverse,
  6078. // Object with rows, columns and opts
  6079. selector: null,
  6080. shift: __arrayProto.shift,
  6081. sort: __arrayProto.sort, // ? name - order?
  6082. splice: __arrayProto.splice,
  6083. toArray: function ()
  6084. {
  6085. return __arrayProto.slice.call( this );
  6086. },
  6087. to$: function ()
  6088. {
  6089. return $( this );
  6090. },
  6091. toJQuery: function ()
  6092. {
  6093. return $( this );
  6094. },
  6095. unique: function ()
  6096. {
  6097. return new _Api( this.context, _unique(this) );
  6098. },
  6099. unshift: __arrayProto.unshift
  6100. } );
  6101. _Api.extend = function ( scope, obj, ext )
  6102. {
  6103. // Only extend API instances and static properties of the API
  6104. if ( ! ext.length || ! obj || ( ! (obj instanceof _Api) && ! obj.__dt_wrapper ) ) {
  6105. return;
  6106. }
  6107. var
  6108. i, ien,
  6109. j, jen,
  6110. struct, inner,
  6111. methodScoping = function ( scope, fn, struc ) {
  6112. return function () {
  6113. var ret = fn.apply( scope, arguments );
  6114. // Method extension
  6115. _Api.extend( ret, ret, struc.methodExt );
  6116. return ret;
  6117. };
  6118. };
  6119. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  6120. struct = ext[i];
  6121. // Value
  6122. obj[ struct.name ] = typeof struct.val === 'function' ?
  6123. methodScoping( scope, struct.val, struct ) :
  6124. $.isPlainObject( struct.val ) ?
  6125. {} :
  6126. struct.val;
  6127. obj[ struct.name ].__dt_wrapper = true;
  6128. // Property extension
  6129. _Api.extend( scope, obj[ struct.name ], struct.propExt );
  6130. }
  6131. };
  6132. // @todo - Is there need for an augment function?
  6133. // _Api.augment = function ( inst, name )
  6134. // {
  6135. // // Find src object in the structure from the name
  6136. // var parts = name.split('.');
  6137. // _Api.extend( inst, obj );
  6138. // };
  6139. // [
  6140. // {
  6141. // name: 'data' -- string - Property name
  6142. // val: function () {}, -- function - Api method (or undefined if just an object
  6143. // methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  6144. // propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  6145. // },
  6146. // {
  6147. // name: 'row'
  6148. // val: {},
  6149. // methodExt: [ ... ],
  6150. // propExt: [
  6151. // {
  6152. // name: 'data'
  6153. // val: function () {},
  6154. // methodExt: [ ... ],
  6155. // propExt: [ ... ]
  6156. // },
  6157. // ...
  6158. // ]
  6159. // }
  6160. // ]
  6161. _Api.register = _api_register = function ( name, val )
  6162. {
  6163. if ( $.isArray( name ) ) {
  6164. for ( var j=0, jen=name.length ; j<jen ; j++ ) {
  6165. _Api.register( name[j], val );
  6166. }
  6167. return;
  6168. }
  6169. var
  6170. i, ien,
  6171. heir = name.split('.'),
  6172. struct = __apiStruct,
  6173. key, method;
  6174. var find = function ( src, name ) {
  6175. for ( var i=0, ien=src.length ; i<ien ; i++ ) {
  6176. if ( src[i].name === name ) {
  6177. return src[i];
  6178. }
  6179. }
  6180. return null;
  6181. };
  6182. for ( i=0, ien=heir.length ; i<ien ; i++ ) {
  6183. method = heir[i].indexOf('()') !== -1;
  6184. key = method ?
  6185. heir[i].replace('()', '') :
  6186. heir[i];
  6187. var src = find( struct, key );
  6188. if ( ! src ) {
  6189. src = {
  6190. name: key,
  6191. val: {},
  6192. methodExt: [],
  6193. propExt: []
  6194. };
  6195. struct.push( src );
  6196. }
  6197. if ( i === ien-1 ) {
  6198. src.val = val;
  6199. }
  6200. else {
  6201. struct = method ?
  6202. src.methodExt :
  6203. src.propExt;
  6204. }
  6205. }
  6206. };
  6207. _Api.registerPlural = _api_registerPlural = function ( pluralName, singularName, val ) {
  6208. _Api.register( pluralName, val );
  6209. _Api.register( singularName, function () {
  6210. var ret = val.apply( this, arguments );
  6211. if ( ret === this ) {
  6212. // Returned item is the API instance that was passed in, return it
  6213. return this;
  6214. }
  6215. else if ( ret instanceof _Api ) {
  6216. // New API instance returned, want the value from the first item
  6217. // in the returned array for the singular result.
  6218. return ret.length ?
  6219. $.isArray( ret[0] ) ?
  6220. new _Api( ret.context, ret[0] ) : // Array results are 'enhanced'
  6221. ret[0] :
  6222. undefined;
  6223. }
  6224. // Non-API return - just fire it back
  6225. return ret;
  6226. } );
  6227. };
  6228. /**
  6229. * Selector for HTML tables. Apply the given selector to the give array of
  6230. * DataTables settings objects.
  6231. *
  6232. * @param {string|integer} [selector] jQuery selector string or integer
  6233. * @param {array} Array of DataTables settings objects to be filtered
  6234. * @return {array}
  6235. * @ignore
  6236. */
  6237. var __table_selector = function ( selector, a )
  6238. {
  6239. // Integer is used to pick out a table by index
  6240. if ( typeof selector === 'number' ) {
  6241. return [ a[ selector ] ];
  6242. }
  6243. // Perform a jQuery selector on the table nodes
  6244. var nodes = $.map( a, function (el, i) {
  6245. return el.nTable;
  6246. } );
  6247. return $(nodes)
  6248. .filter( selector )
  6249. .map( function (i) {
  6250. // Need to translate back from the table node to the settings
  6251. var idx = $.inArray( this, nodes );
  6252. return a[ idx ];
  6253. } )
  6254. .toArray();
  6255. };
  6256. /**
  6257. * Context selector for the API's context (i.e. the tables the API instance
  6258. * refers to.
  6259. *
  6260. * @name DataTable.Api#tables
  6261. * @param {string|integer} [selector] Selector to pick which tables the iterator
  6262. * should operate on. If not given, all tables in the current context are
  6263. * used. This can be given as a jQuery selector (for example `':gt(0)'`) to
  6264. * select multiple tables or as an integer to select a single table.
  6265. * @returns {DataTable.Api} Returns a new API instance if a selector is given.
  6266. */
  6267. _api_register( 'tables()', function ( selector ) {
  6268. // A new instance is created if there was a selector specified
  6269. return selector ?
  6270. new _Api( __table_selector( selector, this.context ) ) :
  6271. this;
  6272. } );
  6273. _api_register( 'table()', function ( selector ) {
  6274. var tables = this.tables( selector );
  6275. var ctx = tables.context;
  6276. // Truncate to the first matched table
  6277. return ctx.length ?
  6278. new _Api( ctx[0] ) :
  6279. tables;
  6280. } );
  6281. _api_registerPlural( 'tables().nodes()', 'table().node()' , function () {
  6282. return this.iterator( 'table', function ( ctx ) {
  6283. return ctx.nTable;
  6284. }, 1 );
  6285. } );
  6286. _api_registerPlural( 'tables().body()', 'table().body()' , function () {
  6287. return this.iterator( 'table', function ( ctx ) {
  6288. return ctx.nTBody;
  6289. }, 1 );
  6290. } );
  6291. _api_registerPlural( 'tables().header()', 'table().header()' , function () {
  6292. return this.iterator( 'table', function ( ctx ) {
  6293. return ctx.nTHead;
  6294. }, 1 );
  6295. } );
  6296. _api_registerPlural( 'tables().footer()', 'table().footer()' , function () {
  6297. return this.iterator( 'table', function ( ctx ) {
  6298. return ctx.nTFoot;
  6299. }, 1 );
  6300. } );
  6301. _api_registerPlural( 'tables().containers()', 'table().container()' , function () {
  6302. return this.iterator( 'table', function ( ctx ) {
  6303. return ctx.nTableWrapper;
  6304. }, 1 );
  6305. } );
  6306. /**
  6307. * Redraw the tables in the current context.
  6308. */
  6309. _api_register( 'draw()', function ( paging ) {
  6310. return this.iterator( 'table', function ( settings ) {
  6311. if ( paging === 'page' ) {
  6312. _fnDraw( settings );
  6313. }
  6314. else {
  6315. if ( typeof paging === 'string' ) {
  6316. paging = paging === 'full-hold' ?
  6317. false :
  6318. true;
  6319. }
  6320. _fnReDraw( settings, paging===false );
  6321. }
  6322. } );
  6323. } );
  6324. /**
  6325. * Get the current page index.
  6326. *
  6327. * @return {integer} Current page index (zero based)
  6328. *//**
  6329. * Set the current page.
  6330. *
  6331. * Note that if you attempt to show a page which does not exist, DataTables will
  6332. * not throw an error, but rather reset the paging.
  6333. *
  6334. * @param {integer|string} action The paging action to take. This can be one of:
  6335. * * `integer` - The page index to jump to
  6336. * * `string` - An action to take:
  6337. * * `first` - Jump to first page.
  6338. * * `next` - Jump to the next page
  6339. * * `previous` - Jump to previous page
  6340. * * `last` - Jump to the last page.
  6341. * @returns {DataTables.Api} this
  6342. */
  6343. _api_register( 'page()', function ( action ) {
  6344. if ( action === undefined ) {
  6345. return this.page.info().page; // not an expensive call
  6346. }
  6347. // else, have an action to take on all tables
  6348. return this.iterator( 'table', function ( settings ) {
  6349. _fnPageChange( settings, action );
  6350. } );
  6351. } );
  6352. /**
  6353. * Paging information for the first table in the current context.
  6354. *
  6355. * If you require paging information for another table, use the `table()` method
  6356. * with a suitable selector.
  6357. *
  6358. * @return {object} Object with the following properties set:
  6359. * * `page` - Current page index (zero based - i.e. the first page is `0`)
  6360. * * `pages` - Total number of pages
  6361. * * `start` - Display index for the first record shown on the current page
  6362. * * `end` - Display index for the last record shown on the current page
  6363. * * `length` - Display length (number of records). Note that generally `start
  6364. * + length = end`, but this is not always true, for example if there are
  6365. * only 2 records to show on the final page, with a length of 10.
  6366. * * `recordsTotal` - Full data set length
  6367. * * `recordsDisplay` - Data set length once the current filtering criterion
  6368. * are applied.
  6369. */
  6370. _api_register( 'page.info()', function ( action ) {
  6371. if ( this.context.length === 0 ) {
  6372. return undefined;
  6373. }
  6374. var
  6375. settings = this.context[0],
  6376. start = settings._iDisplayStart,
  6377. len = settings.oFeatures.bPaginate ? settings._iDisplayLength : -1,
  6378. visRecords = settings.fnRecordsDisplay(),
  6379. all = len === -1;
  6380. return {
  6381. "page": all ? 0 : Math.floor( start / len ),
  6382. "pages": all ? 1 : Math.ceil( visRecords / len ),
  6383. "start": start,
  6384. "end": settings.fnDisplayEnd(),
  6385. "length": len,
  6386. "recordsTotal": settings.fnRecordsTotal(),
  6387. "recordsDisplay": visRecords,
  6388. "serverSide": _fnDataSource( settings ) === 'ssp'
  6389. };
  6390. } );
  6391. /**
  6392. * Get the current page length.
  6393. *
  6394. * @return {integer} Current page length. Note `-1` indicates that all records
  6395. * are to be shown.
  6396. *//**
  6397. * Set the current page length.
  6398. *
  6399. * @param {integer} Page length to set. Use `-1` to show all records.
  6400. * @returns {DataTables.Api} this
  6401. */
  6402. _api_register( 'page.len()', function ( len ) {
  6403. // Note that we can't call this function 'length()' because `length`
  6404. // is a Javascript property of functions which defines how many arguments
  6405. // the function expects.
  6406. if ( len === undefined ) {
  6407. return this.context.length !== 0 ?
  6408. this.context[0]._iDisplayLength :
  6409. undefined;
  6410. }
  6411. // else, set the page length
  6412. return this.iterator( 'table', function ( settings ) {
  6413. _fnLengthChange( settings, len );
  6414. } );
  6415. } );
  6416. var __reload = function ( settings, holdPosition, callback ) {
  6417. // Use the draw event to trigger a callback
  6418. if ( callback ) {
  6419. var api = new _Api( settings );
  6420. api.one( 'draw', function () {
  6421. callback( api.ajax.json() );
  6422. } );
  6423. }
  6424. if ( _fnDataSource( settings ) == 'ssp' ) {
  6425. _fnReDraw( settings, holdPosition );
  6426. }
  6427. else {
  6428. _fnProcessingDisplay( settings, true );
  6429. // Cancel an existing request
  6430. var xhr = settings.jqXHR;
  6431. if ( xhr && xhr.readyState !== 4 ) {
  6432. xhr.abort();
  6433. }
  6434. // Trigger xhr
  6435. _fnBuildAjax( settings, [], function( json ) {
  6436. _fnClearTable( settings );
  6437. var data = _fnAjaxDataSrc( settings, json );
  6438. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6439. _fnAddData( settings, data[i] );
  6440. }
  6441. _fnReDraw( settings, holdPosition );
  6442. _fnProcessingDisplay( settings, false );
  6443. } );
  6444. }
  6445. };
  6446. /**
  6447. * Get the JSON response from the last Ajax request that DataTables made to the
  6448. * server. Note that this returns the JSON from the first table in the current
  6449. * context.
  6450. *
  6451. * @return {object} JSON received from the server.
  6452. */
  6453. _api_register( 'ajax.json()', function () {
  6454. var ctx = this.context;
  6455. if ( ctx.length > 0 ) {
  6456. return ctx[0].json;
  6457. }
  6458. // else return undefined;
  6459. } );
  6460. /**
  6461. * Get the data submitted in the last Ajax request
  6462. */
  6463. _api_register( 'ajax.params()', function () {
  6464. var ctx = this.context;
  6465. if ( ctx.length > 0 ) {
  6466. return ctx[0].oAjaxData;
  6467. }
  6468. // else return undefined;
  6469. } );
  6470. /**
  6471. * Reload tables from the Ajax data source. Note that this function will
  6472. * automatically re-draw the table when the remote data has been loaded.
  6473. *
  6474. * @param {boolean} [reset=true] Reset (default) or hold the current paging
  6475. * position. A full re-sort and re-filter is performed when this method is
  6476. * called, which is why the pagination reset is the default action.
  6477. * @returns {DataTables.Api} this
  6478. */
  6479. _api_register( 'ajax.reload()', function ( callback, resetPaging ) {
  6480. return this.iterator( 'table', function (settings) {
  6481. __reload( settings, resetPaging===false, callback );
  6482. } );
  6483. } );
  6484. /**
  6485. * Get the current Ajax URL. Note that this returns the URL from the first
  6486. * table in the current context.
  6487. *
  6488. * @return {string} Current Ajax source URL
  6489. *//**
  6490. * Set the Ajax URL. Note that this will set the URL for all tables in the
  6491. * current context.
  6492. *
  6493. * @param {string} url URL to set.
  6494. * @returns {DataTables.Api} this
  6495. */
  6496. _api_register( 'ajax.url()', function ( url ) {
  6497. var ctx = this.context;
  6498. if ( url === undefined ) {
  6499. // get
  6500. if ( ctx.length === 0 ) {
  6501. return undefined;
  6502. }
  6503. ctx = ctx[0];
  6504. return ctx.ajax ?
  6505. $.isPlainObject( ctx.ajax ) ?
  6506. ctx.ajax.url :
  6507. ctx.ajax :
  6508. ctx.sAjaxSource;
  6509. }
  6510. // set
  6511. return this.iterator( 'table', function ( settings ) {
  6512. if ( $.isPlainObject( settings.ajax ) ) {
  6513. settings.ajax.url = url;
  6514. }
  6515. else {
  6516. settings.ajax = url;
  6517. }
  6518. // No need to consider sAjaxSource here since DataTables gives priority
  6519. // to `ajax` over `sAjaxSource`. So setting `ajax` here, renders any
  6520. // value of `sAjaxSource` redundant.
  6521. } );
  6522. } );
  6523. /**
  6524. * Load data from the newly set Ajax URL. Note that this method is only
  6525. * available when `ajax.url()` is used to set a URL. Additionally, this method
  6526. * has the same effect as calling `ajax.reload()` but is provided for
  6527. * convenience when setting a new URL. Like `ajax.reload()` it will
  6528. * automatically redraw the table once the remote data has been loaded.
  6529. *
  6530. * @returns {DataTables.Api} this
  6531. */
  6532. _api_register( 'ajax.url().load()', function ( callback, resetPaging ) {
  6533. // Same as a reload, but makes sense to present it for easy access after a
  6534. // url change
  6535. return this.iterator( 'table', function ( ctx ) {
  6536. __reload( ctx, resetPaging===false, callback );
  6537. } );
  6538. } );
  6539. var _selector_run = function ( type, selector, selectFn, settings, opts )
  6540. {
  6541. var
  6542. out = [], res,
  6543. a, i, ien, j, jen,
  6544. selectorType = typeof selector;
  6545. // Can't just check for isArray here, as an API or jQuery instance might be
  6546. // given with their array like look
  6547. if ( ! selector || selectorType === 'string' || selectorType === 'function' || selector.length === undefined ) {
  6548. selector = [ selector ];
  6549. }
  6550. for ( i=0, ien=selector.length ; i<ien ; i++ ) {
  6551. a = selector[i] && selector[i].split ?
  6552. selector[i].split(',') :
  6553. [ selector[i] ];
  6554. for ( j=0, jen=a.length ; j<jen ; j++ ) {
  6555. res = selectFn( typeof a[j] === 'string' ? $.trim(a[j]) : a[j] );
  6556. if ( res && res.length ) {
  6557. out = out.concat( res );
  6558. }
  6559. }
  6560. }
  6561. // selector extensions
  6562. var ext = _ext.selector[ type ];
  6563. if ( ext.length ) {
  6564. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  6565. out = ext[i]( settings, opts, out );
  6566. }
  6567. }
  6568. return _unique( out );
  6569. };
  6570. var _selector_opts = function ( opts )
  6571. {
  6572. if ( ! opts ) {
  6573. opts = {};
  6574. }
  6575. // Backwards compatibility for 1.9- which used the terminology filter rather
  6576. // than search
  6577. if ( opts.filter && opts.search === undefined ) {
  6578. opts.search = opts.filter;
  6579. }
  6580. return $.extend( {
  6581. search: 'none',
  6582. order: 'current',
  6583. page: 'all'
  6584. }, opts );
  6585. };
  6586. var _selector_first = function ( inst )
  6587. {
  6588. // Reduce the API instance to the first item found
  6589. for ( var i=0, ien=inst.length ; i<ien ; i++ ) {
  6590. if ( inst[i].length > 0 ) {
  6591. // Assign the first element to the first item in the instance
  6592. // and truncate the instance and context
  6593. inst[0] = inst[i];
  6594. inst[0].length = 1;
  6595. inst.length = 1;
  6596. inst.context = [ inst.context[i] ];
  6597. return inst;
  6598. }
  6599. }
  6600. // Not found - return an empty instance
  6601. inst.length = 0;
  6602. return inst;
  6603. };
  6604. var _selector_row_indexes = function ( settings, opts )
  6605. {
  6606. var
  6607. i, ien, tmp, a=[],
  6608. displayFiltered = settings.aiDisplay,
  6609. displayMaster = settings.aiDisplayMaster;
  6610. var
  6611. search = opts.search, // none, applied, removed
  6612. order = opts.order, // applied, current, index (original - compatibility with 1.9)
  6613. page = opts.page; // all, current
  6614. if ( _fnDataSource( settings ) == 'ssp' ) {
  6615. // In server-side processing mode, most options are irrelevant since
  6616. // rows not shown don't exist and the index order is the applied order
  6617. // Removed is a special case - for consistency just return an empty
  6618. // array
  6619. return search === 'removed' ?
  6620. [] :
  6621. _range( 0, displayMaster.length );
  6622. }
  6623. else if ( page == 'current' ) {
  6624. // Current page implies that order=current and fitler=applied, since it is
  6625. // fairly senseless otherwise, regardless of what order and search actually
  6626. // are
  6627. for ( i=settings._iDisplayStart, ien=settings.fnDisplayEnd() ; i<ien ; i++ ) {
  6628. a.push( displayFiltered[i] );
  6629. }
  6630. }
  6631. else if ( order == 'current' || order == 'applied' ) {
  6632. a = search == 'none' ?
  6633. displayMaster.slice() : // no search
  6634. search == 'applied' ?
  6635. displayFiltered.slice() : // applied search
  6636. $.map( displayMaster, function (el, i) { // removed search
  6637. return $.inArray( el, displayFiltered ) === -1 ? el : null;
  6638. } );
  6639. }
  6640. else if ( order == 'index' || order == 'original' ) {
  6641. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  6642. if ( search == 'none' ) {
  6643. a.push( i );
  6644. }
  6645. else { // applied | removed
  6646. tmp = $.inArray( i, displayFiltered );
  6647. if ((tmp === -1 && search == 'removed') ||
  6648. (tmp >= 0 && search == 'applied') )
  6649. {
  6650. a.push( i );
  6651. }
  6652. }
  6653. }
  6654. }
  6655. return a;
  6656. };
  6657. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6658. * Rows
  6659. *
  6660. * {} - no selector - use all available rows
  6661. * {integer} - row aoData index
  6662. * {node} - TR node
  6663. * {string} - jQuery selector to apply to the TR elements
  6664. * {array} - jQuery array of nodes, or simply an array of TR nodes
  6665. *
  6666. */
  6667. var __row_selector = function ( settings, selector, opts )
  6668. {
  6669. var run = function ( sel ) {
  6670. var selInt = _intVal( sel );
  6671. var i, ien;
  6672. // Short cut - selector is a number and no options provided (default is
  6673. // all records, so no need to check if the index is in there, since it
  6674. // must be - dev error if the index doesn't exist).
  6675. if ( selInt !== null && ! opts ) {
  6676. return [ selInt ];
  6677. }
  6678. var rows = _selector_row_indexes( settings, opts );
  6679. if ( selInt !== null && $.inArray( selInt, rows ) !== -1 ) {
  6680. // Selector - integer
  6681. return [ selInt ];
  6682. }
  6683. else if ( ! sel ) {
  6684. // Selector - none
  6685. return rows;
  6686. }
  6687. // Selector - function
  6688. if ( typeof sel === 'function' ) {
  6689. return $.map( rows, function (idx) {
  6690. var row = settings.aoData[ idx ];
  6691. return sel( idx, row._aData, row.nTr ) ? idx : null;
  6692. } );
  6693. }
  6694. // Get nodes in the order from the `rows` array with null values removed
  6695. var nodes = _removeEmpty(
  6696. _pluck_order( settings.aoData, rows, 'nTr' )
  6697. );
  6698. // Selector - node
  6699. if ( sel.nodeName ) {
  6700. if ( sel._DT_RowIndex !== undefined ) {
  6701. return [ sel._DT_RowIndex ]; // Property added by DT for fast lookup
  6702. }
  6703. else if ( sel._DT_CellIndex ) {
  6704. return [ sel._DT_CellIndex.row ];
  6705. }
  6706. else {
  6707. var host = $(sel).closest('*[data-dt-row]');
  6708. return host.length ?
  6709. [ host.data('dt-row') ] :
  6710. [];
  6711. }
  6712. }
  6713. // ID selector. Want to always be able to select rows by id, regardless
  6714. // of if the tr element has been created or not, so can't rely upon
  6715. // jQuery here - hence a custom implementation. This does not match
  6716. // Sizzle's fast selector or HTML4 - in HTML5 the ID can be anything,
  6717. // but to select it using a CSS selector engine (like Sizzle or
  6718. // querySelect) it would need to need to be escaped for some characters.
  6719. // DataTables simplifies this for row selectors since you can select
  6720. // only a row. A # indicates an id any anything that follows is the id -
  6721. // unescaped.
  6722. if ( typeof sel === 'string' && sel.charAt(0) === '#' ) {
  6723. // get row index from id
  6724. var rowObj = settings.aIds[ sel.replace( /^#/, '' ) ];
  6725. if ( rowObj !== undefined ) {
  6726. return [ rowObj.idx ];
  6727. }
  6728. // need to fall through to jQuery in case there is DOM id that
  6729. // matches
  6730. }
  6731. // Selector - jQuery selector string, array of nodes or jQuery object/
  6732. // As jQuery's .filter() allows jQuery objects to be passed in filter,
  6733. // it also allows arrays, so this will cope with all three options
  6734. return $(nodes)
  6735. .filter( sel )
  6736. .map( function () {
  6737. return this._DT_RowIndex;
  6738. } )
  6739. .toArray();
  6740. };
  6741. return _selector_run( 'row', selector, run, settings, opts );
  6742. };
  6743. _api_register( 'rows()', function ( selector, opts ) {
  6744. // argument shifting
  6745. if ( selector === undefined ) {
  6746. selector = '';
  6747. }
  6748. else if ( $.isPlainObject( selector ) ) {
  6749. opts = selector;
  6750. selector = '';
  6751. }
  6752. opts = _selector_opts( opts );
  6753. var inst = this.iterator( 'table', function ( settings ) {
  6754. return __row_selector( settings, selector, opts );
  6755. }, 1 );
  6756. // Want argument shifting here and in __row_selector?
  6757. inst.selector.rows = selector;
  6758. inst.selector.opts = opts;
  6759. return inst;
  6760. } );
  6761. _api_register( 'rows().nodes()', function () {
  6762. return this.iterator( 'row', function ( settings, row ) {
  6763. return settings.aoData[ row ].nTr || undefined;
  6764. }, 1 );
  6765. } );
  6766. _api_register( 'rows().data()', function () {
  6767. return this.iterator( true, 'rows', function ( settings, rows ) {
  6768. return _pluck_order( settings.aoData, rows, '_aData' );
  6769. }, 1 );
  6770. } );
  6771. _api_registerPlural( 'rows().cache()', 'row().cache()', function ( type ) {
  6772. return this.iterator( 'row', function ( settings, row ) {
  6773. var r = settings.aoData[ row ];
  6774. return type === 'search' ? r._aFilterData : r._aSortData;
  6775. }, 1 );
  6776. } );
  6777. _api_registerPlural( 'rows().invalidate()', 'row().invalidate()', function ( src ) {
  6778. return this.iterator( 'row', function ( settings, row ) {
  6779. _fnInvalidate( settings, row, src );
  6780. } );
  6781. } );
  6782. _api_registerPlural( 'rows().indexes()', 'row().index()', function () {
  6783. return this.iterator( 'row', function ( settings, row ) {
  6784. return row;
  6785. }, 1 );
  6786. } );
  6787. _api_registerPlural( 'rows().ids()', 'row().id()', function ( hash ) {
  6788. var a = [];
  6789. var context = this.context;
  6790. // `iterator` will drop undefined values, but in this case we want them
  6791. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  6792. for ( var j=0, jen=this[i].length ; j<jen ; j++ ) {
  6793. var id = context[i].rowIdFn( context[i].aoData[ this[i][j] ]._aData );
  6794. a.push( (hash === true ? '#' : '' )+ id );
  6795. }
  6796. }
  6797. return new _Api( context, a );
  6798. } );
  6799. _api_registerPlural( 'rows().remove()', 'row().remove()', function () {
  6800. var that = this;
  6801. this.iterator( 'row', function ( settings, row, thatIdx ) {
  6802. var data = settings.aoData;
  6803. var rowData = data[ row ];
  6804. var i, ien, j, jen;
  6805. var loopRow, loopCells;
  6806. data.splice( row, 1 );
  6807. // Update the cached indexes
  6808. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  6809. loopRow = data[i];
  6810. loopCells = loopRow.anCells;
  6811. // Rows
  6812. if ( loopRow.nTr !== null ) {
  6813. loopRow.nTr._DT_RowIndex = i;
  6814. }
  6815. // Cells
  6816. if ( loopCells !== null ) {
  6817. for ( j=0, jen=loopCells.length ; j<jen ; j++ ) {
  6818. loopCells[j]._DT_CellIndex.row = i;
  6819. }
  6820. }
  6821. }
  6822. // Delete from the display arrays
  6823. _fnDeleteIndex( settings.aiDisplayMaster, row );
  6824. _fnDeleteIndex( settings.aiDisplay, row );
  6825. _fnDeleteIndex( that[ thatIdx ], row, false ); // maintain local indexes
  6826. // Check for an 'overflow' they case for displaying the table
  6827. _fnLengthOverflow( settings );
  6828. // Remove the row's ID reference if there is one
  6829. var id = settings.rowIdFn( rowData._aData );
  6830. if ( id !== undefined ) {
  6831. delete settings.aIds[ id ];
  6832. }
  6833. } );
  6834. this.iterator( 'table', function ( settings ) {
  6835. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  6836. settings.aoData[i].idx = i;
  6837. }
  6838. } );
  6839. return this;
  6840. } );
  6841. _api_register( 'rows.add()', function ( rows ) {
  6842. var newRows = this.iterator( 'table', function ( settings ) {
  6843. var row, i, ien;
  6844. var out = [];
  6845. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  6846. row = rows[i];
  6847. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  6848. out.push( _fnAddTr( settings, row )[0] );
  6849. }
  6850. else {
  6851. out.push( _fnAddData( settings, row ) );
  6852. }
  6853. }
  6854. return out;
  6855. }, 1 );
  6856. // Return an Api.rows() extended instance, so rows().nodes() etc can be used
  6857. var modRows = this.rows( -1 );
  6858. modRows.pop();
  6859. $.merge( modRows, newRows );
  6860. return modRows;
  6861. } );
  6862. /**
  6863. *
  6864. */
  6865. _api_register( 'row()', function ( selector, opts ) {
  6866. return _selector_first( this.rows( selector, opts ) );
  6867. } );
  6868. _api_register( 'row().data()', function ( data ) {
  6869. var ctx = this.context;
  6870. if ( data === undefined ) {
  6871. // Get
  6872. return ctx.length && this.length ?
  6873. ctx[0].aoData[ this[0] ]._aData :
  6874. undefined;
  6875. }
  6876. // Set
  6877. ctx[0].aoData[ this[0] ]._aData = data;
  6878. // Automatically invalidate
  6879. _fnInvalidate( ctx[0], this[0], 'data' );
  6880. return this;
  6881. } );
  6882. _api_register( 'row().node()', function () {
  6883. var ctx = this.context;
  6884. return ctx.length && this.length ?
  6885. ctx[0].aoData[ this[0] ].nTr || null :
  6886. null;
  6887. } );
  6888. _api_register( 'row.add()', function ( row ) {
  6889. // Allow a jQuery object to be passed in - only a single row is added from
  6890. // it though - the first element in the set
  6891. if ( row instanceof $ && row.length ) {
  6892. row = row[0];
  6893. }
  6894. var rows = this.iterator( 'table', function ( settings ) {
  6895. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  6896. return _fnAddTr( settings, row )[0];
  6897. }
  6898. return _fnAddData( settings, row );
  6899. } );
  6900. // Return an Api.rows() extended instance, with the newly added row selected
  6901. return this.row( rows[0] );
  6902. } );
  6903. var __details_add = function ( ctx, row, data, klass )
  6904. {
  6905. // Convert to array of TR elements
  6906. var rows = [];
  6907. var addRow = function ( r, k ) {
  6908. // Recursion to allow for arrays of jQuery objects
  6909. if ( $.isArray( r ) || r instanceof $ ) {
  6910. for ( var i=0, ien=r.length ; i<ien ; i++ ) {
  6911. addRow( r[i], k );
  6912. }
  6913. return;
  6914. }
  6915. // If we get a TR element, then just add it directly - up to the dev
  6916. // to add the correct number of columns etc
  6917. if ( r.nodeName && r.nodeName.toLowerCase() === 'tr' ) {
  6918. rows.push( r );
  6919. }
  6920. else {
  6921. // Otherwise create a row with a wrapper
  6922. var created = $('<tr><td/></tr>').addClass( k );
  6923. $('td', created)
  6924. .addClass( k )
  6925. .html( r )
  6926. [0].colSpan = _fnVisbleColumns( ctx );
  6927. rows.push( created[0] );
  6928. }
  6929. };
  6930. addRow( data, klass );
  6931. if ( row._details ) {
  6932. row._details.remove();
  6933. }
  6934. row._details = $(rows);
  6935. // If the children were already shown, that state should be retained
  6936. if ( row._detailsShow ) {
  6937. row._details.insertAfter( row.nTr );
  6938. }
  6939. };
  6940. var __details_remove = function ( api, idx )
  6941. {
  6942. var ctx = api.context;
  6943. if ( ctx.length ) {
  6944. var row = ctx[0].aoData[ idx !== undefined ? idx : api[0] ];
  6945. if ( row && row._details ) {
  6946. row._details.remove();
  6947. row._detailsShow = undefined;
  6948. row._details = undefined;
  6949. }
  6950. }
  6951. };
  6952. var __details_display = function ( api, show ) {
  6953. var ctx = api.context;
  6954. if ( ctx.length && api.length ) {
  6955. var row = ctx[0].aoData[ api[0] ];
  6956. if ( row._details ) {
  6957. row._detailsShow = show;
  6958. if ( show ) {
  6959. row._details.insertAfter( row.nTr );
  6960. }
  6961. else {
  6962. row._details.detach();
  6963. }
  6964. __details_events( ctx[0] );
  6965. }
  6966. }
  6967. };
  6968. var __details_events = function ( settings )
  6969. {
  6970. var api = new _Api( settings );
  6971. var namespace = '.dt.DT_details';
  6972. var drawEvent = 'draw'+namespace;
  6973. var colvisEvent = 'column-visibility'+namespace;
  6974. var destroyEvent = 'destroy'+namespace;
  6975. var data = settings.aoData;
  6976. api.off( drawEvent +' '+ colvisEvent +' '+ destroyEvent );
  6977. if ( _pluck( data, '_details' ).length > 0 ) {
  6978. // On each draw, insert the required elements into the document
  6979. api.on( drawEvent, function ( e, ctx ) {
  6980. if ( settings !== ctx ) {
  6981. return;
  6982. }
  6983. api.rows( {page:'current'} ).eq(0).each( function (idx) {
  6984. // Internal data grab
  6985. var row = data[ idx ];
  6986. if ( row._detailsShow ) {
  6987. row._details.insertAfter( row.nTr );
  6988. }
  6989. } );
  6990. } );
  6991. // Column visibility change - update the colspan
  6992. api.on( colvisEvent, function ( e, ctx, idx, vis ) {
  6993. if ( settings !== ctx ) {
  6994. return;
  6995. }
  6996. // Update the colspan for the details rows (note, only if it already has
  6997. // a colspan)
  6998. var row, visible = _fnVisbleColumns( ctx );
  6999. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  7000. row = data[i];
  7001. if ( row._details ) {
  7002. row._details.children('td[colspan]').attr('colspan', visible );
  7003. }
  7004. }
  7005. } );
  7006. // Table destroyed - nuke any child rows
  7007. api.on( destroyEvent, function ( e, ctx ) {
  7008. if ( settings !== ctx ) {
  7009. return;
  7010. }
  7011. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  7012. if ( data[i]._details ) {
  7013. __details_remove( api, i );
  7014. }
  7015. }
  7016. } );
  7017. }
  7018. };
  7019. // Strings for the method names to help minification
  7020. var _emp = '';
  7021. var _child_obj = _emp+'row().child';
  7022. var _child_mth = _child_obj+'()';
  7023. // data can be:
  7024. // tr
  7025. // string
  7026. // jQuery or array of any of the above
  7027. _api_register( _child_mth, function ( data, klass ) {
  7028. var ctx = this.context;
  7029. if ( data === undefined ) {
  7030. // get
  7031. return ctx.length && this.length ?
  7032. ctx[0].aoData[ this[0] ]._details :
  7033. undefined;
  7034. }
  7035. else if ( data === true ) {
  7036. // show
  7037. this.child.show();
  7038. }
  7039. else if ( data === false ) {
  7040. // remove
  7041. __details_remove( this );
  7042. }
  7043. else if ( ctx.length && this.length ) {
  7044. // set
  7045. __details_add( ctx[0], ctx[0].aoData[ this[0] ], data, klass );
  7046. }
  7047. return this;
  7048. } );
  7049. _api_register( [
  7050. _child_obj+'.show()',
  7051. _child_mth+'.show()' // only when `child()` was called with parameters (without
  7052. ], function ( show ) { // it returns an object and this method is not executed)
  7053. __details_display( this, true );
  7054. return this;
  7055. } );
  7056. _api_register( [
  7057. _child_obj+'.hide()',
  7058. _child_mth+'.hide()' // only when `child()` was called with parameters (without
  7059. ], function () { // it returns an object and this method is not executed)
  7060. __details_display( this, false );
  7061. return this;
  7062. } );
  7063. _api_register( [
  7064. _child_obj+'.remove()',
  7065. _child_mth+'.remove()' // only when `child()` was called with parameters (without
  7066. ], function () { // it returns an object and this method is not executed)
  7067. __details_remove( this );
  7068. return this;
  7069. } );
  7070. _api_register( _child_obj+'.isShown()', function () {
  7071. var ctx = this.context;
  7072. if ( ctx.length && this.length ) {
  7073. // _detailsShown as false or undefined will fall through to return false
  7074. return ctx[0].aoData[ this[0] ]._detailsShow || false;
  7075. }
  7076. return false;
  7077. } );
  7078. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  7079. * Columns
  7080. *
  7081. * {integer} - column index (>=0 count from left, <0 count from right)
  7082. * "{integer}:visIdx" - visible column index (i.e. translate to column index) (>=0 count from left, <0 count from right)
  7083. * "{integer}:visible" - alias for {integer}:visIdx (>=0 count from left, <0 count from right)
  7084. * "{string}:name" - column name
  7085. * "{string}" - jQuery selector on column header nodes
  7086. *
  7087. */
  7088. // can be an array of these items, comma separated list, or an array of comma
  7089. // separated lists
  7090. var __re_column_selector = /^(.+):(name|visIdx|visible)$/;
  7091. // r1 and r2 are redundant - but it means that the parameters match for the
  7092. // iterator callback in columns().data()
  7093. var __columnData = function ( settings, column, r1, r2, rows ) {
  7094. var a = [];
  7095. for ( var row=0, ien=rows.length ; row<ien ; row++ ) {
  7096. a.push( _fnGetCellData( settings, rows[row], column ) );
  7097. }
  7098. return a;
  7099. };
  7100. var __column_selector = function ( settings, selector, opts )
  7101. {
  7102. var
  7103. columns = settings.aoColumns,
  7104. names = _pluck( columns, 'sName' ),
  7105. nodes = _pluck( columns, 'nTh' );
  7106. var run = function ( s ) {
  7107. var selInt = _intVal( s );
  7108. // Selector - all
  7109. if ( s === '' ) {
  7110. return _range( columns.length );
  7111. }
  7112. // Selector - index
  7113. if ( selInt !== null ) {
  7114. return [ selInt >= 0 ?
  7115. selInt : // Count from left
  7116. columns.length + selInt // Count from right (+ because its a negative value)
  7117. ];
  7118. }
  7119. // Selector = function
  7120. if ( typeof s === 'function' ) {
  7121. var rows = _selector_row_indexes( settings, opts );
  7122. return $.map( columns, function (col, idx) {
  7123. return s(
  7124. idx,
  7125. __columnData( settings, idx, 0, 0, rows ),
  7126. nodes[ idx ]
  7127. ) ? idx : null;
  7128. } );
  7129. }
  7130. // jQuery or string selector
  7131. var match = typeof s === 'string' ?
  7132. s.match( __re_column_selector ) :
  7133. '';
  7134. if ( match ) {
  7135. switch( match[2] ) {
  7136. case 'visIdx':
  7137. case 'visible':
  7138. var idx = parseInt( match[1], 10 );
  7139. // Visible index given, convert to column index
  7140. if ( idx < 0 ) {
  7141. // Counting from the right
  7142. var visColumns = $.map( columns, function (col,i) {
  7143. return col.bVisible ? i : null;
  7144. } );
  7145. return [ visColumns[ visColumns.length + idx ] ];
  7146. }
  7147. // Counting from the left
  7148. return [ _fnVisibleToColumnIndex( settings, idx ) ];
  7149. case 'name':
  7150. // match by name. `names` is column index complete and in order
  7151. return $.map( names, function (name, i) {
  7152. return name === match[1] ? i : null;
  7153. } );
  7154. default:
  7155. return [];
  7156. }
  7157. }
  7158. // Cell in the table body
  7159. if ( s.nodeName && s._DT_CellIndex ) {
  7160. return [ s._DT_CellIndex.column ];
  7161. }
  7162. // jQuery selector on the TH elements for the columns
  7163. var jqResult = $( nodes )
  7164. .filter( s )
  7165. .map( function () {
  7166. return $.inArray( this, nodes ); // `nodes` is column index complete and in order
  7167. } )
  7168. .toArray();
  7169. if ( jqResult.length || ! s.nodeName ) {
  7170. return jqResult;
  7171. }
  7172. // Otherwise a node which might have a `dt-column` data attribute, or be
  7173. // a child or such an element
  7174. var host = $(s).closest('*[data-dt-column]');
  7175. return host.length ?
  7176. [ host.data('dt-column') ] :
  7177. [];
  7178. };
  7179. return _selector_run( 'column', selector, run, settings, opts );
  7180. };
  7181. var __setColumnVis = function ( settings, column, vis ) {
  7182. var
  7183. cols = settings.aoColumns,
  7184. col = cols[ column ],
  7185. data = settings.aoData,
  7186. row, cells, i, ien, tr;
  7187. // Get
  7188. if ( vis === undefined ) {
  7189. return col.bVisible;
  7190. }
  7191. // Set
  7192. // No change
  7193. if ( col.bVisible === vis ) {
  7194. return;
  7195. }
  7196. if ( vis ) {
  7197. // Insert column
  7198. // Need to decide if we should use appendChild or insertBefore
  7199. var insertBefore = $.inArray( true, _pluck(cols, 'bVisible'), column+1 );
  7200. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  7201. tr = data[i].nTr;
  7202. cells = data[i].anCells;
  7203. if ( tr ) {
  7204. // insertBefore can act like appendChild if 2nd arg is null
  7205. tr.insertBefore( cells[ column ], cells[ insertBefore ] || null );
  7206. }
  7207. }
  7208. }
  7209. else {
  7210. // Remove column
  7211. $( _pluck( settings.aoData, 'anCells', column ) ).detach();
  7212. }
  7213. // Common actions
  7214. col.bVisible = vis;
  7215. _fnDrawHead( settings, settings.aoHeader );
  7216. _fnDrawHead( settings, settings.aoFooter );
  7217. _fnSaveState( settings );
  7218. };
  7219. _api_register( 'columns()', function ( selector, opts ) {
  7220. // argument shifting
  7221. if ( selector === undefined ) {
  7222. selector = '';
  7223. }
  7224. else if ( $.isPlainObject( selector ) ) {
  7225. opts = selector;
  7226. selector = '';
  7227. }
  7228. opts = _selector_opts( opts );
  7229. var inst = this.iterator( 'table', function ( settings ) {
  7230. return __column_selector( settings, selector, opts );
  7231. }, 1 );
  7232. // Want argument shifting here and in _row_selector?
  7233. inst.selector.cols = selector;
  7234. inst.selector.opts = opts;
  7235. return inst;
  7236. } );
  7237. _api_registerPlural( 'columns().header()', 'column().header()', function ( selector, opts ) {
  7238. return this.iterator( 'column', function ( settings, column ) {
  7239. return settings.aoColumns[column].nTh;
  7240. }, 1 );
  7241. } );
  7242. _api_registerPlural( 'columns().footer()', 'column().footer()', function ( selector, opts ) {
  7243. return this.iterator( 'column', function ( settings, column ) {
  7244. return settings.aoColumns[column].nTf;
  7245. }, 1 );
  7246. } );
  7247. _api_registerPlural( 'columns().data()', 'column().data()', function () {
  7248. return this.iterator( 'column-rows', __columnData, 1 );
  7249. } );
  7250. _api_registerPlural( 'columns().dataSrc()', 'column().dataSrc()', function () {
  7251. return this.iterator( 'column', function ( settings, column ) {
  7252. return settings.aoColumns[column].mData;
  7253. }, 1 );
  7254. } );
  7255. _api_registerPlural( 'columns().cache()', 'column().cache()', function ( type ) {
  7256. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7257. return _pluck_order( settings.aoData, rows,
  7258. type === 'search' ? '_aFilterData' : '_aSortData', column
  7259. );
  7260. }, 1 );
  7261. } );
  7262. _api_registerPlural( 'columns().nodes()', 'column().nodes()', function () {
  7263. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7264. return _pluck_order( settings.aoData, rows, 'anCells', column ) ;
  7265. }, 1 );
  7266. } );
  7267. _api_registerPlural( 'columns().visible()', 'column().visible()', function ( vis, calc ) {
  7268. var ret = this.iterator( 'column', function ( settings, column ) {
  7269. if ( vis === undefined ) {
  7270. return settings.aoColumns[ column ].bVisible;
  7271. } // else
  7272. __setColumnVis( settings, column, vis );
  7273. } );
  7274. // Group the column visibility changes
  7275. if ( vis !== undefined ) {
  7276. // Second loop once the first is done for events
  7277. this.iterator( 'column', function ( settings, column ) {
  7278. _fnCallbackFire( settings, null, 'column-visibility', [settings, column, vis, calc] );
  7279. } );
  7280. if ( calc === undefined || calc ) {
  7281. this.columns.adjust();
  7282. }
  7283. }
  7284. return ret;
  7285. } );
  7286. _api_registerPlural( 'columns().indexes()', 'column().index()', function ( type ) {
  7287. return this.iterator( 'column', function ( settings, column ) {
  7288. return type === 'visible' ?
  7289. _fnColumnIndexToVisible( settings, column ) :
  7290. column;
  7291. }, 1 );
  7292. } );
  7293. _api_register( 'columns.adjust()', function () {
  7294. return this.iterator( 'table', function ( settings ) {
  7295. _fnAdjustColumnSizing( settings );
  7296. }, 1 );
  7297. } );
  7298. _api_register( 'column.index()', function ( type, idx ) {
  7299. if ( this.context.length !== 0 ) {
  7300. var ctx = this.context[0];
  7301. if ( type === 'fromVisible' || type === 'toData' ) {
  7302. return _fnVisibleToColumnIndex( ctx, idx );
  7303. }
  7304. else if ( type === 'fromData' || type === 'toVisible' ) {
  7305. return _fnColumnIndexToVisible( ctx, idx );
  7306. }
  7307. }
  7308. } );
  7309. _api_register( 'column()', function ( selector, opts ) {
  7310. return _selector_first( this.columns( selector, opts ) );
  7311. } );
  7312. var __cell_selector = function ( settings, selector, opts )
  7313. {
  7314. var data = settings.aoData;
  7315. var rows = _selector_row_indexes( settings, opts );
  7316. var cells = _removeEmpty( _pluck_order( data, rows, 'anCells' ) );
  7317. var allCells = $( [].concat.apply([], cells) );
  7318. var row;
  7319. var columns = settings.aoColumns.length;
  7320. var a, i, ien, j, o, host;
  7321. var run = function ( s ) {
  7322. var fnSelector = typeof s === 'function';
  7323. if ( s === null || s === undefined || fnSelector ) {
  7324. // All cells and function selectors
  7325. a = [];
  7326. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  7327. row = rows[i];
  7328. for ( j=0 ; j<columns ; j++ ) {
  7329. o = {
  7330. row: row,
  7331. column: j
  7332. };
  7333. if ( fnSelector ) {
  7334. // Selector - function
  7335. host = data[ row ];
  7336. if ( s( o, _fnGetCellData(settings, row, j), host.anCells ? host.anCells[j] : null ) ) {
  7337. a.push( o );
  7338. }
  7339. }
  7340. else {
  7341. // Selector - all
  7342. a.push( o );
  7343. }
  7344. }
  7345. }
  7346. return a;
  7347. }
  7348. // Selector - index
  7349. if ( $.isPlainObject( s ) ) {
  7350. return [s];
  7351. }
  7352. // Selector - jQuery filtered cells
  7353. var jqResult = allCells
  7354. .filter( s )
  7355. .map( function (i, el) {
  7356. return { // use a new object, in case someone changes the values
  7357. row: el._DT_CellIndex.row,
  7358. column: el._DT_CellIndex.column
  7359. };
  7360. } )
  7361. .toArray();
  7362. if ( jqResult.length || ! s.nodeName ) {
  7363. return jqResult;
  7364. }
  7365. // Otherwise the selector is a node, and there is one last option - the
  7366. // element might be a child of an element which has dt-row and dt-column
  7367. // data attributes
  7368. host = $(s).closest('*[data-dt-row]');
  7369. return host.length ?
  7370. [ {
  7371. row: host.data('dt-row'),
  7372. column: host.data('dt-column')
  7373. } ] :
  7374. [];
  7375. };
  7376. return _selector_run( 'cell', selector, run, settings, opts );
  7377. };
  7378. _api_register( 'cells()', function ( rowSelector, columnSelector, opts ) {
  7379. // Argument shifting
  7380. if ( $.isPlainObject( rowSelector ) ) {
  7381. // Indexes
  7382. if ( rowSelector.row === undefined ) {
  7383. // Selector options in first parameter
  7384. opts = rowSelector;
  7385. rowSelector = null;
  7386. }
  7387. else {
  7388. // Cell index objects in first parameter
  7389. opts = columnSelector;
  7390. columnSelector = null;
  7391. }
  7392. }
  7393. if ( $.isPlainObject( columnSelector ) ) {
  7394. opts = columnSelector;
  7395. columnSelector = null;
  7396. }
  7397. // Cell selector
  7398. if ( columnSelector === null || columnSelector === undefined ) {
  7399. return this.iterator( 'table', function ( settings ) {
  7400. return __cell_selector( settings, rowSelector, _selector_opts( opts ) );
  7401. } );
  7402. }
  7403. // Row + column selector
  7404. var columns = this.columns( columnSelector, opts );
  7405. var rows = this.rows( rowSelector, opts );
  7406. var a, i, ien, j, jen;
  7407. var cells = this.iterator( 'table', function ( settings, idx ) {
  7408. a = [];
  7409. for ( i=0, ien=rows[idx].length ; i<ien ; i++ ) {
  7410. for ( j=0, jen=columns[idx].length ; j<jen ; j++ ) {
  7411. a.push( {
  7412. row: rows[idx][i],
  7413. column: columns[idx][j]
  7414. } );
  7415. }
  7416. }
  7417. return a;
  7418. }, 1 );
  7419. $.extend( cells.selector, {
  7420. cols: columnSelector,
  7421. rows: rowSelector,
  7422. opts: opts
  7423. } );
  7424. return cells;
  7425. } );
  7426. _api_registerPlural( 'cells().nodes()', 'cell().node()', function () {
  7427. return this.iterator( 'cell', function ( settings, row, column ) {
  7428. var data = settings.aoData[ row ];
  7429. return data && data.anCells ?
  7430. data.anCells[ column ] :
  7431. undefined;
  7432. }, 1 );
  7433. } );
  7434. _api_register( 'cells().data()', function () {
  7435. return this.iterator( 'cell', function ( settings, row, column ) {
  7436. return _fnGetCellData( settings, row, column );
  7437. }, 1 );
  7438. } );
  7439. _api_registerPlural( 'cells().cache()', 'cell().cache()', function ( type ) {
  7440. type = type === 'search' ? '_aFilterData' : '_aSortData';
  7441. return this.iterator( 'cell', function ( settings, row, column ) {
  7442. return settings.aoData[ row ][ type ][ column ];
  7443. }, 1 );
  7444. } );
  7445. _api_registerPlural( 'cells().render()', 'cell().render()', function ( type ) {
  7446. return this.iterator( 'cell', function ( settings, row, column ) {
  7447. return _fnGetCellData( settings, row, column, type );
  7448. }, 1 );
  7449. } );
  7450. _api_registerPlural( 'cells().indexes()', 'cell().index()', function () {
  7451. return this.iterator( 'cell', function ( settings, row, column ) {
  7452. return {
  7453. row: row,
  7454. column: column,
  7455. columnVisible: _fnColumnIndexToVisible( settings, column )
  7456. };
  7457. }, 1 );
  7458. } );
  7459. _api_registerPlural( 'cells().invalidate()', 'cell().invalidate()', function ( src ) {
  7460. return this.iterator( 'cell', function ( settings, row, column ) {
  7461. _fnInvalidate( settings, row, src, column );
  7462. } );
  7463. } );
  7464. _api_register( 'cell()', function ( rowSelector, columnSelector, opts ) {
  7465. return _selector_first( this.cells( rowSelector, columnSelector, opts ) );
  7466. } );
  7467. _api_register( 'cell().data()', function ( data ) {
  7468. var ctx = this.context;
  7469. var cell = this[0];
  7470. if ( data === undefined ) {
  7471. // Get
  7472. return ctx.length && cell.length ?
  7473. _fnGetCellData( ctx[0], cell[0].row, cell[0].column ) :
  7474. undefined;
  7475. }
  7476. // Set
  7477. _fnSetCellData( ctx[0], cell[0].row, cell[0].column, data );
  7478. _fnInvalidate( ctx[0], cell[0].row, 'data', cell[0].column );
  7479. return this;
  7480. } );
  7481. /**
  7482. * Get current ordering (sorting) that has been applied to the table.
  7483. *
  7484. * @returns {array} 2D array containing the sorting information for the first
  7485. * table in the current context. Each element in the parent array represents
  7486. * a column being sorted upon (i.e. multi-sorting with two columns would have
  7487. * 2 inner arrays). The inner arrays may have 2 or 3 elements. The first is
  7488. * the column index that the sorting condition applies to, the second is the
  7489. * direction of the sort (`desc` or `asc`) and, optionally, the third is the
  7490. * index of the sorting order from the `column.sorting` initialisation array.
  7491. *//**
  7492. * Set the ordering for the table.
  7493. *
  7494. * @param {integer} order Column index to sort upon.
  7495. * @param {string} direction Direction of the sort to be applied (`asc` or `desc`)
  7496. * @returns {DataTables.Api} this
  7497. *//**
  7498. * Set the ordering for the table.
  7499. *
  7500. * @param {array} order 1D array of sorting information to be applied.
  7501. * @param {array} [...] Optional additional sorting conditions
  7502. * @returns {DataTables.Api} this
  7503. *//**
  7504. * Set the ordering for the table.
  7505. *
  7506. * @param {array} order 2D array of sorting information to be applied.
  7507. * @returns {DataTables.Api} this
  7508. */
  7509. _api_register( 'order()', function ( order, dir ) {
  7510. var ctx = this.context;
  7511. if ( order === undefined ) {
  7512. // get
  7513. return ctx.length !== 0 ?
  7514. ctx[0].aaSorting :
  7515. undefined;
  7516. }
  7517. // set
  7518. if ( typeof order === 'number' ) {
  7519. // Simple column / direction passed in
  7520. order = [ [ order, dir ] ];
  7521. }
  7522. else if ( order.length && ! $.isArray( order[0] ) ) {
  7523. // Arguments passed in (list of 1D arrays)
  7524. order = Array.prototype.slice.call( arguments );
  7525. }
  7526. // otherwise a 2D array was passed in
  7527. return this.iterator( 'table', function ( settings ) {
  7528. settings.aaSorting = order.slice();
  7529. } );
  7530. } );
  7531. /**
  7532. * Attach a sort listener to an element for a given column
  7533. *
  7534. * @param {node|jQuery|string} node Identifier for the element(s) to attach the
  7535. * listener to. This can take the form of a single DOM node, a jQuery
  7536. * collection of nodes or a jQuery selector which will identify the node(s).
  7537. * @param {integer} column the column that a click on this node will sort on
  7538. * @param {function} [callback] callback function when sort is run
  7539. * @returns {DataTables.Api} this
  7540. */
  7541. _api_register( 'order.listener()', function ( node, column, callback ) {
  7542. return this.iterator( 'table', function ( settings ) {
  7543. _fnSortAttachListener( settings, node, column, callback );
  7544. } );
  7545. } );
  7546. _api_register( 'order.fixed()', function ( set ) {
  7547. if ( ! set ) {
  7548. var ctx = this.context;
  7549. var fixed = ctx.length ?
  7550. ctx[0].aaSortingFixed :
  7551. undefined;
  7552. return $.isArray( fixed ) ?
  7553. { pre: fixed } :
  7554. fixed;
  7555. }
  7556. return this.iterator( 'table', function ( settings ) {
  7557. settings.aaSortingFixed = $.extend( true, {}, set );
  7558. } );
  7559. } );
  7560. // Order by the selected column(s)
  7561. _api_register( [
  7562. 'columns().order()',
  7563. 'column().order()'
  7564. ], function ( dir ) {
  7565. var that = this;
  7566. return this.iterator( 'table', function ( settings, i ) {
  7567. var sort = [];
  7568. $.each( that[i], function (j, col) {
  7569. sort.push( [ col, dir ] );
  7570. } );
  7571. settings.aaSorting = sort;
  7572. } );
  7573. } );
  7574. _api_register( 'search()', function ( input, regex, smart, caseInsen ) {
  7575. var ctx = this.context;
  7576. if ( input === undefined ) {
  7577. // get
  7578. return ctx.length !== 0 ?
  7579. ctx[0].oPreviousSearch.sSearch :
  7580. undefined;
  7581. }
  7582. // set
  7583. return this.iterator( 'table', function ( settings ) {
  7584. if ( ! settings.oFeatures.bFilter ) {
  7585. return;
  7586. }
  7587. _fnFilterComplete( settings, $.extend( {}, settings.oPreviousSearch, {
  7588. "sSearch": input+"",
  7589. "bRegex": regex === null ? false : regex,
  7590. "bSmart": smart === null ? true : smart,
  7591. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7592. } ), 1 );
  7593. } );
  7594. } );
  7595. _api_registerPlural(
  7596. 'columns().search()',
  7597. 'column().search()',
  7598. function ( input, regex, smart, caseInsen ) {
  7599. return this.iterator( 'column', function ( settings, column ) {
  7600. var preSearch = settings.aoPreSearchCols;
  7601. if ( input === undefined ) {
  7602. // get
  7603. return preSearch[ column ].sSearch;
  7604. }
  7605. // set
  7606. if ( ! settings.oFeatures.bFilter ) {
  7607. return;
  7608. }
  7609. $.extend( preSearch[ column ], {
  7610. "sSearch": input+"",
  7611. "bRegex": regex === null ? false : regex,
  7612. "bSmart": smart === null ? true : smart,
  7613. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7614. } );
  7615. _fnFilterComplete( settings, settings.oPreviousSearch, 1 );
  7616. } );
  7617. }
  7618. );
  7619. /*
  7620. * State API methods
  7621. */
  7622. _api_register( 'state()', function () {
  7623. return this.context.length ?
  7624. this.context[0].oSavedState :
  7625. null;
  7626. } );
  7627. _api_register( 'state.clear()', function () {
  7628. return this.iterator( 'table', function ( settings ) {
  7629. // Save an empty object
  7630. settings.fnStateSaveCallback.call( settings.oInstance, settings, {} );
  7631. } );
  7632. } );
  7633. _api_register( 'state.loaded()', function () {
  7634. return this.context.length ?
  7635. this.context[0].oLoadedState :
  7636. null;
  7637. } );
  7638. _api_register( 'state.save()', function () {
  7639. return this.iterator( 'table', function ( settings ) {
  7640. _fnSaveState( settings );
  7641. } );
  7642. } );
  7643. /**
  7644. * Provide a common method for plug-ins to check the version of DataTables being
  7645. * used, in order to ensure compatibility.
  7646. *
  7647. * @param {string} version Version string to check for, in the format "X.Y.Z".
  7648. * Note that the formats "X" and "X.Y" are also acceptable.
  7649. * @returns {boolean} true if this version of DataTables is greater or equal to
  7650. * the required version, or false if this version of DataTales is not
  7651. * suitable
  7652. * @static
  7653. * @dtopt API-Static
  7654. *
  7655. * @example
  7656. * alert( $.fn.dataTable.versionCheck( '1.9.0' ) );
  7657. */
  7658. DataTable.versionCheck = DataTable.fnVersionCheck = function( version )
  7659. {
  7660. var aThis = DataTable.version.split('.');
  7661. var aThat = version.split('.');
  7662. var iThis, iThat;
  7663. for ( var i=0, iLen=aThat.length ; i<iLen ; i++ ) {
  7664. iThis = parseInt( aThis[i], 10 ) || 0;
  7665. iThat = parseInt( aThat[i], 10 ) || 0;
  7666. // Parts are the same, keep comparing
  7667. if (iThis === iThat) {
  7668. continue;
  7669. }
  7670. // Parts are different, return immediately
  7671. return iThis > iThat;
  7672. }
  7673. return true;
  7674. };
  7675. /**
  7676. * Check if a `<table>` node is a DataTable table already or not.
  7677. *
  7678. * @param {node|jquery|string} table Table node, jQuery object or jQuery
  7679. * selector for the table to test. Note that if more than more than one
  7680. * table is passed on, only the first will be checked
  7681. * @returns {boolean} true the table given is a DataTable, or false otherwise
  7682. * @static
  7683. * @dtopt API-Static
  7684. *
  7685. * @example
  7686. * if ( ! $.fn.DataTable.isDataTable( '#example' ) ) {
  7687. * $('#example').dataTable();
  7688. * }
  7689. */
  7690. DataTable.isDataTable = DataTable.fnIsDataTable = function ( table )
  7691. {
  7692. var t = $(table).get(0);
  7693. var is = false;
  7694. $.each( DataTable.settings, function (i, o) {
  7695. var head = o.nScrollHead ? $('table', o.nScrollHead)[0] : null;
  7696. var foot = o.nScrollFoot ? $('table', o.nScrollFoot)[0] : null;
  7697. if ( o.nTable === t || head === t || foot === t ) {
  7698. is = true;
  7699. }
  7700. } );
  7701. return is;
  7702. };
  7703. /**
  7704. * Get all DataTable tables that have been initialised - optionally you can
  7705. * select to get only currently visible tables.
  7706. *
  7707. * @param {boolean} [visible=false] Flag to indicate if you want all (default)
  7708. * or visible tables only.
  7709. * @returns {array} Array of `table` nodes (not DataTable instances) which are
  7710. * DataTables
  7711. * @static
  7712. * @dtopt API-Static
  7713. *
  7714. * @example
  7715. * $.each( $.fn.dataTable.tables(true), function () {
  7716. * $(table).DataTable().columns.adjust();
  7717. * } );
  7718. */
  7719. DataTable.tables = DataTable.fnTables = function ( visible )
  7720. {
  7721. var api = false;
  7722. if ( $.isPlainObject( visible ) ) {
  7723. api = visible.api;
  7724. visible = visible.visible;
  7725. }
  7726. var a = $.map( DataTable.settings, function (o) {
  7727. if ( !visible || (visible && $(o.nTable).is(':visible')) ) {
  7728. return o.nTable;
  7729. }
  7730. } );
  7731. return api ?
  7732. new _Api( a ) :
  7733. a;
  7734. };
  7735. /**
  7736. * Convert from camel case parameters to Hungarian notation. This is made public
  7737. * for the extensions to provide the same ability as DataTables core to accept
  7738. * either the 1.9 style Hungarian notation, or the 1.10+ style camelCase
  7739. * parameters.
  7740. *
  7741. * @param {object} src The model object which holds all parameters that can be
  7742. * mapped.
  7743. * @param {object} user The object to convert from camel case to Hungarian.
  7744. * @param {boolean} force When set to `true`, properties which already have a
  7745. * Hungarian value in the `user` object will be overwritten. Otherwise they
  7746. * won't be.
  7747. */
  7748. DataTable.camelToHungarian = _fnCamelToHungarian;
  7749. /**
  7750. *
  7751. */
  7752. _api_register( '$()', function ( selector, opts ) {
  7753. var
  7754. rows = this.rows( opts ).nodes(), // Get all rows
  7755. jqRows = $(rows);
  7756. return $( [].concat(
  7757. jqRows.filter( selector ).toArray(),
  7758. jqRows.find( selector ).toArray()
  7759. ) );
  7760. } );
  7761. // jQuery functions to operate on the tables
  7762. $.each( [ 'on', 'one', 'off' ], function (i, key) {
  7763. _api_register( key+'()', function ( /* event, handler */ ) {
  7764. var args = Array.prototype.slice.call(arguments);
  7765. // Add the `dt` namespace automatically if it isn't already present
  7766. if ( ! args[0].match(/\.dt\b/) ) {
  7767. args[0] += '.dt';
  7768. }
  7769. var inst = $( this.tables().nodes() );
  7770. inst[key].apply( inst, args );
  7771. return this;
  7772. } );
  7773. } );
  7774. _api_register( 'clear()', function () {
  7775. return this.iterator( 'table', function ( settings ) {
  7776. _fnClearTable( settings );
  7777. } );
  7778. } );
  7779. _api_register( 'settings()', function () {
  7780. return new _Api( this.context, this.context );
  7781. } );
  7782. _api_register( 'init()', function () {
  7783. var ctx = this.context;
  7784. return ctx.length ? ctx[0].oInit : null;
  7785. } );
  7786. _api_register( 'data()', function () {
  7787. return this.iterator( 'table', function ( settings ) {
  7788. return _pluck( settings.aoData, '_aData' );
  7789. } ).flatten();
  7790. } );
  7791. _api_register( 'destroy()', function ( remove ) {
  7792. remove = remove || false;
  7793. return this.iterator( 'table', function ( settings ) {
  7794. var orig = settings.nTableWrapper.parentNode;
  7795. var classes = settings.oClasses;
  7796. var table = settings.nTable;
  7797. var tbody = settings.nTBody;
  7798. var thead = settings.nTHead;
  7799. var tfoot = settings.nTFoot;
  7800. var jqTable = $(table);
  7801. var jqTbody = $(tbody);
  7802. var jqWrapper = $(settings.nTableWrapper);
  7803. var rows = $.map( settings.aoData, function (r) { return r.nTr; } );
  7804. var i, ien;
  7805. // Flag to note that the table is currently being destroyed - no action
  7806. // should be taken
  7807. settings.bDestroying = true;
  7808. // Fire off the destroy callbacks for plug-ins etc
  7809. _fnCallbackFire( settings, "aoDestroyCallback", "destroy", [settings] );
  7810. // If not being removed from the document, make all columns visible
  7811. if ( ! remove ) {
  7812. new _Api( settings ).columns().visible( true );
  7813. }
  7814. // Blitz all `DT` namespaced events (these are internal events, the
  7815. // lowercase, `dt` events are user subscribed and they are responsible
  7816. // for removing them
  7817. jqWrapper.unbind('.DT').find(':not(tbody *)').unbind('.DT');
  7818. $(window).unbind('.DT-'+settings.sInstance);
  7819. // When scrolling we had to break the table up - restore it
  7820. if ( table != thead.parentNode ) {
  7821. jqTable.children('thead').detach();
  7822. jqTable.append( thead );
  7823. }
  7824. if ( tfoot && table != tfoot.parentNode ) {
  7825. jqTable.children('tfoot').detach();
  7826. jqTable.append( tfoot );
  7827. }
  7828. settings.aaSorting = [];
  7829. settings.aaSortingFixed = [];
  7830. _fnSortingClasses( settings );
  7831. $( rows ).removeClass( settings.asStripeClasses.join(' ') );
  7832. $('th, td', thead).removeClass( classes.sSortable+' '+
  7833. classes.sSortableAsc+' '+classes.sSortableDesc+' '+classes.sSortableNone
  7834. );
  7835. if ( settings.bJUI ) {
  7836. $('th span.'+classes.sSortIcon+ ', td span.'+classes.sSortIcon, thead).detach();
  7837. $('th, td', thead).each( function () {
  7838. var wrapper = $('div.'+classes.sSortJUIWrapper, this);
  7839. $(this).append( wrapper.contents() );
  7840. wrapper.detach();
  7841. } );
  7842. }
  7843. // Add the TR elements back into the table in their original order
  7844. jqTbody.children().detach();
  7845. jqTbody.append( rows );
  7846. // Remove the DataTables generated nodes, events and classes
  7847. var removedMethod = remove ? 'remove' : 'detach';
  7848. jqTable[ removedMethod ]();
  7849. jqWrapper[ removedMethod ]();
  7850. // If we need to reattach the table to the document
  7851. if ( ! remove && orig ) {
  7852. // insertBefore acts like appendChild if !arg[1]
  7853. orig.insertBefore( table, settings.nTableReinsertBefore );
  7854. // Restore the width of the original table - was read from the style property,
  7855. // so we can restore directly to that
  7856. jqTable
  7857. .css( 'width', settings.sDestroyWidth )
  7858. .removeClass( classes.sTable );
  7859. // If the were originally stripe classes - then we add them back here.
  7860. // Note this is not fool proof (for example if not all rows had stripe
  7861. // classes - but it's a good effort without getting carried away
  7862. ien = settings.asDestroyStripes.length;
  7863. if ( ien ) {
  7864. jqTbody.children().each( function (i) {
  7865. $(this).addClass( settings.asDestroyStripes[i % ien] );
  7866. } );
  7867. }
  7868. }
  7869. /* Remove the settings object from the settings array */
  7870. var idx = $.inArray( settings, DataTable.settings );
  7871. if ( idx !== -1 ) {
  7872. DataTable.settings.splice( idx, 1 );
  7873. }
  7874. } );
  7875. } );
  7876. // Add the `every()` method for rows, columns and cells in a compact form
  7877. $.each( [ 'column', 'row', 'cell' ], function ( i, type ) {
  7878. _api_register( type+'s().every()', function ( fn ) {
  7879. var opts = this.selector.opts;
  7880. var api = this;
  7881. return this.iterator( type, function ( settings, arg1, arg2, arg3, arg4 ) {
  7882. // Rows and columns:
  7883. // arg1 - index
  7884. // arg2 - table counter
  7885. // arg3 - loop counter
  7886. // arg4 - undefined
  7887. // Cells:
  7888. // arg1 - row index
  7889. // arg2 - column index
  7890. // arg3 - table counter
  7891. // arg4 - loop counter
  7892. fn.call(
  7893. api[ type ](
  7894. arg1,
  7895. type==='cell' ? arg2 : opts,
  7896. type==='cell' ? opts : undefined
  7897. ),
  7898. arg1, arg2, arg3, arg4
  7899. );
  7900. } );
  7901. } );
  7902. } );
  7903. // i18n method for extensions to be able to use the language object from the
  7904. // DataTable
  7905. _api_register( 'i18n()', function ( token, def, plural ) {
  7906. var ctx = this.context[0];
  7907. var resolved = _fnGetObjectDataFn( token )( ctx.oLanguage );
  7908. if ( resolved === undefined ) {
  7909. resolved = def;
  7910. }
  7911. if ( plural !== undefined && $.isPlainObject( resolved ) ) {
  7912. resolved = resolved[ plural ] !== undefined ?
  7913. resolved[ plural ] :
  7914. resolved._;
  7915. }
  7916. return resolved.replace( '%d', plural ); // nb: plural might be undefined,
  7917. } );
  7918. /**
  7919. * Version string for plug-ins to check compatibility. Allowed format is
  7920. * `a.b.c-d` where: a:int, b:int, c:int, d:string(dev|beta|alpha). `d` is used
  7921. * only for non-release builds. See http://semver.org/ for more information.
  7922. * @member
  7923. * @type string
  7924. * @default Version number
  7925. */
  7926. DataTable.version = "1.10.12";
  7927. /**
  7928. * Private data store, containing all of the settings objects that are
  7929. * created for the tables on a given page.
  7930. *
  7931. * Note that the `DataTable.settings` object is aliased to
  7932. * `jQuery.fn.dataTableExt` through which it may be accessed and
  7933. * manipulated, or `jQuery.fn.dataTable.settings`.
  7934. * @member
  7935. * @type array
  7936. * @default []
  7937. * @private
  7938. */
  7939. DataTable.settings = [];
  7940. /**
  7941. * Object models container, for the various models that DataTables has
  7942. * available to it. These models define the objects that are used to hold
  7943. * the active state and configuration of the table.
  7944. * @namespace
  7945. */
  7946. DataTable.models = {};
  7947. /**
  7948. * Template object for the way in which DataTables holds information about
  7949. * search information for the global filter and individual column filters.
  7950. * @namespace
  7951. */
  7952. DataTable.models.oSearch = {
  7953. /**
  7954. * Flag to indicate if the filtering should be case insensitive or not
  7955. * @type boolean
  7956. * @default true
  7957. */
  7958. "bCaseInsensitive": true,
  7959. /**
  7960. * Applied search term
  7961. * @type string
  7962. * @default <i>Empty string</i>
  7963. */
  7964. "sSearch": "",
  7965. /**
  7966. * Flag to indicate if the search term should be interpreted as a
  7967. * regular expression (true) or not (false) and therefore and special
  7968. * regex characters escaped.
  7969. * @type boolean
  7970. * @default false
  7971. */
  7972. "bRegex": false,
  7973. /**
  7974. * Flag to indicate if DataTables is to use its smart filtering or not.
  7975. * @type boolean
  7976. * @default true
  7977. */
  7978. "bSmart": true
  7979. };
  7980. /**
  7981. * Template object for the way in which DataTables holds information about
  7982. * each individual row. This is the object format used for the settings
  7983. * aoData array.
  7984. * @namespace
  7985. */
  7986. DataTable.models.oRow = {
  7987. /**
  7988. * TR element for the row
  7989. * @type node
  7990. * @default null
  7991. */
  7992. "nTr": null,
  7993. /**
  7994. * Array of TD elements for each row. This is null until the row has been
  7995. * created.
  7996. * @type array nodes
  7997. * @default []
  7998. */
  7999. "anCells": null,
  8000. /**
  8001. * Data object from the original data source for the row. This is either
  8002. * an array if using the traditional form of DataTables, or an object if
  8003. * using mData options. The exact type will depend on the passed in
  8004. * data from the data source, or will be an array if using DOM a data
  8005. * source.
  8006. * @type array|object
  8007. * @default []
  8008. */
  8009. "_aData": [],
  8010. /**
  8011. * Sorting data cache - this array is ostensibly the same length as the
  8012. * number of columns (although each index is generated only as it is
  8013. * needed), and holds the data that is used for sorting each column in the
  8014. * row. We do this cache generation at the start of the sort in order that
  8015. * the formatting of the sort data need be done only once for each cell
  8016. * per sort. This array should not be read from or written to by anything
  8017. * other than the master sorting methods.
  8018. * @type array
  8019. * @default null
  8020. * @private
  8021. */
  8022. "_aSortData": null,
  8023. /**
  8024. * Per cell filtering data cache. As per the sort data cache, used to
  8025. * increase the performance of the filtering in DataTables
  8026. * @type array
  8027. * @default null
  8028. * @private
  8029. */
  8030. "_aFilterData": null,
  8031. /**
  8032. * Filtering data cache. This is the same as the cell filtering cache, but
  8033. * in this case a string rather than an array. This is easily computed with
  8034. * a join on `_aFilterData`, but is provided as a cache so the join isn't
  8035. * needed on every search (memory traded for performance)
  8036. * @type array
  8037. * @default null
  8038. * @private
  8039. */
  8040. "_sFilterRow": null,
  8041. /**
  8042. * Cache of the class name that DataTables has applied to the row, so we
  8043. * can quickly look at this variable rather than needing to do a DOM check
  8044. * on className for the nTr property.
  8045. * @type string
  8046. * @default <i>Empty string</i>
  8047. * @private
  8048. */
  8049. "_sRowStripe": "",
  8050. /**
  8051. * Denote if the original data source was from the DOM, or the data source
  8052. * object. This is used for invalidating data, so DataTables can
  8053. * automatically read data from the original source, unless uninstructed
  8054. * otherwise.
  8055. * @type string
  8056. * @default null
  8057. * @private
  8058. */
  8059. "src": null,
  8060. /**
  8061. * Index in the aoData array. This saves an indexOf lookup when we have the
  8062. * object, but want to know the index
  8063. * @type integer
  8064. * @default -1
  8065. * @private
  8066. */
  8067. "idx": -1
  8068. };
  8069. /**
  8070. * Template object for the column information object in DataTables. This object
  8071. * is held in the settings aoColumns array and contains all the information that
  8072. * DataTables needs about each individual column.
  8073. *
  8074. * Note that this object is related to {@link DataTable.defaults.column}
  8075. * but this one is the internal data store for DataTables's cache of columns.
  8076. * It should NOT be manipulated outside of DataTables. Any configuration should
  8077. * be done through the initialisation options.
  8078. * @namespace
  8079. */
  8080. DataTable.models.oColumn = {
  8081. /**
  8082. * Column index. This could be worked out on-the-fly with $.inArray, but it
  8083. * is faster to just hold it as a variable
  8084. * @type integer
  8085. * @default null
  8086. */
  8087. "idx": null,
  8088. /**
  8089. * A list of the columns that sorting should occur on when this column
  8090. * is sorted. That this property is an array allows multi-column sorting
  8091. * to be defined for a column (for example first name / last name columns
  8092. * would benefit from this). The values are integers pointing to the
  8093. * columns to be sorted on (typically it will be a single integer pointing
  8094. * at itself, but that doesn't need to be the case).
  8095. * @type array
  8096. */
  8097. "aDataSort": null,
  8098. /**
  8099. * Define the sorting directions that are applied to the column, in sequence
  8100. * as the column is repeatedly sorted upon - i.e. the first value is used
  8101. * as the sorting direction when the column if first sorted (clicked on).
  8102. * Sort it again (click again) and it will move on to the next index.
  8103. * Repeat until loop.
  8104. * @type array
  8105. */
  8106. "asSorting": null,
  8107. /**
  8108. * Flag to indicate if the column is searchable, and thus should be included
  8109. * in the filtering or not.
  8110. * @type boolean
  8111. */
  8112. "bSearchable": null,
  8113. /**
  8114. * Flag to indicate if the column is sortable or not.
  8115. * @type boolean
  8116. */
  8117. "bSortable": null,
  8118. /**
  8119. * Flag to indicate if the column is currently visible in the table or not
  8120. * @type boolean
  8121. */
  8122. "bVisible": null,
  8123. /**
  8124. * Store for manual type assignment using the `column.type` option. This
  8125. * is held in store so we can manipulate the column's `sType` property.
  8126. * @type string
  8127. * @default null
  8128. * @private
  8129. */
  8130. "_sManualType": null,
  8131. /**
  8132. * Flag to indicate if HTML5 data attributes should be used as the data
  8133. * source for filtering or sorting. True is either are.
  8134. * @type boolean
  8135. * @default false
  8136. * @private
  8137. */
  8138. "_bAttrSrc": false,
  8139. /**
  8140. * Developer definable function that is called whenever a cell is created (Ajax source,
  8141. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  8142. * allowing you to modify the DOM element (add background colour for example) when the
  8143. * element is available.
  8144. * @type function
  8145. * @param {element} nTd The TD node that has been created
  8146. * @param {*} sData The Data for the cell
  8147. * @param {array|object} oData The data for the whole row
  8148. * @param {int} iRow The row index for the aoData data store
  8149. * @default null
  8150. */
  8151. "fnCreatedCell": null,
  8152. /**
  8153. * Function to get data from a cell in a column. You should <b>never</b>
  8154. * access data directly through _aData internally in DataTables - always use
  8155. * the method attached to this property. It allows mData to function as
  8156. * required. This function is automatically assigned by the column
  8157. * initialisation method
  8158. * @type function
  8159. * @param {array|object} oData The data array/object for the array
  8160. * (i.e. aoData[]._aData)
  8161. * @param {string} sSpecific The specific data type you want to get -
  8162. * 'display', 'type' 'filter' 'sort'
  8163. * @returns {*} The data for the cell from the given row's data
  8164. * @default null
  8165. */
  8166. "fnGetData": null,
  8167. /**
  8168. * Function to set data for a cell in the column. You should <b>never</b>
  8169. * set the data directly to _aData internally in DataTables - always use
  8170. * this method. It allows mData to function as required. This function
  8171. * is automatically assigned by the column initialisation method
  8172. * @type function
  8173. * @param {array|object} oData The data array/object for the array
  8174. * (i.e. aoData[]._aData)
  8175. * @param {*} sValue Value to set
  8176. * @default null
  8177. */
  8178. "fnSetData": null,
  8179. /**
  8180. * Property to read the value for the cells in the column from the data
  8181. * source array / object. If null, then the default content is used, if a
  8182. * function is given then the return from the function is used.
  8183. * @type function|int|string|null
  8184. * @default null
  8185. */
  8186. "mData": null,
  8187. /**
  8188. * Partner property to mData which is used (only when defined) to get
  8189. * the data - i.e. it is basically the same as mData, but without the
  8190. * 'set' option, and also the data fed to it is the result from mData.
  8191. * This is the rendering method to match the data method of mData.
  8192. * @type function|int|string|null
  8193. * @default null
  8194. */
  8195. "mRender": null,
  8196. /**
  8197. * Unique header TH/TD element for this column - this is what the sorting
  8198. * listener is attached to (if sorting is enabled.)
  8199. * @type node
  8200. * @default null
  8201. */
  8202. "nTh": null,
  8203. /**
  8204. * Unique footer TH/TD element for this column (if there is one). Not used
  8205. * in DataTables as such, but can be used for plug-ins to reference the
  8206. * footer for each column.
  8207. * @type node
  8208. * @default null
  8209. */
  8210. "nTf": null,
  8211. /**
  8212. * The class to apply to all TD elements in the table's TBODY for the column
  8213. * @type string
  8214. * @default null
  8215. */
  8216. "sClass": null,
  8217. /**
  8218. * When DataTables calculates the column widths to assign to each column,
  8219. * it finds the longest string in each column and then constructs a
  8220. * temporary table and reads the widths from that. The problem with this
  8221. * is that "mmm" is much wider then "iiii", but the latter is a longer
  8222. * string - thus the calculation can go wrong (doing it properly and putting
  8223. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  8224. * a "work around" we provide this option. It will append its value to the
  8225. * text that is found to be the longest string for the column - i.e. padding.
  8226. * @type string
  8227. */
  8228. "sContentPadding": null,
  8229. /**
  8230. * Allows a default value to be given for a column's data, and will be used
  8231. * whenever a null data source is encountered (this can be because mData
  8232. * is set to null, or because the data source itself is null).
  8233. * @type string
  8234. * @default null
  8235. */
  8236. "sDefaultContent": null,
  8237. /**
  8238. * Name for the column, allowing reference to the column by name as well as
  8239. * by index (needs a lookup to work by name).
  8240. * @type string
  8241. */
  8242. "sName": null,
  8243. /**
  8244. * Custom sorting data type - defines which of the available plug-ins in
  8245. * afnSortData the custom sorting will use - if any is defined.
  8246. * @type string
  8247. * @default std
  8248. */
  8249. "sSortDataType": 'std',
  8250. /**
  8251. * Class to be applied to the header element when sorting on this column
  8252. * @type string
  8253. * @default null
  8254. */
  8255. "sSortingClass": null,
  8256. /**
  8257. * Class to be applied to the header element when sorting on this column -
  8258. * when jQuery UI theming is used.
  8259. * @type string
  8260. * @default null
  8261. */
  8262. "sSortingClassJUI": null,
  8263. /**
  8264. * Title of the column - what is seen in the TH element (nTh).
  8265. * @type string
  8266. */
  8267. "sTitle": null,
  8268. /**
  8269. * Column sorting and filtering type
  8270. * @type string
  8271. * @default null
  8272. */
  8273. "sType": null,
  8274. /**
  8275. * Width of the column
  8276. * @type string
  8277. * @default null
  8278. */
  8279. "sWidth": null,
  8280. /**
  8281. * Width of the column when it was first "encountered"
  8282. * @type string
  8283. * @default null
  8284. */
  8285. "sWidthOrig": null
  8286. };
  8287. /*
  8288. * Developer note: The properties of the object below are given in Hungarian
  8289. * notation, that was used as the interface for DataTables prior to v1.10, however
  8290. * from v1.10 onwards the primary interface is camel case. In order to avoid
  8291. * breaking backwards compatibility utterly with this change, the Hungarian
  8292. * version is still, internally the primary interface, but is is not documented
  8293. * - hence the @name tags in each doc comment. This allows a Javascript function
  8294. * to create a map from Hungarian notation to camel case (going the other direction
  8295. * would require each property to be listed, which would at around 3K to the size
  8296. * of DataTables, while this method is about a 0.5K hit.
  8297. *
  8298. * Ultimately this does pave the way for Hungarian notation to be dropped
  8299. * completely, but that is a massive amount of work and will break current
  8300. * installs (therefore is on-hold until v2).
  8301. */
  8302. /**
  8303. * Initialisation options that can be given to DataTables at initialisation
  8304. * time.
  8305. * @namespace
  8306. */
  8307. DataTable.defaults = {
  8308. /**
  8309. * An array of data to use for the table, passed in at initialisation which
  8310. * will be used in preference to any data which is already in the DOM. This is
  8311. * particularly useful for constructing tables purely in Javascript, for
  8312. * example with a custom Ajax call.
  8313. * @type array
  8314. * @default null
  8315. *
  8316. * @dtopt Option
  8317. * @name DataTable.defaults.data
  8318. *
  8319. * @example
  8320. * // Using a 2D array data source
  8321. * $(document).ready( function () {
  8322. * $('#example').dataTable( {
  8323. * "data": [
  8324. * ['Trident', 'Internet Explorer 4.0', 'Win 95+', 4, 'X'],
  8325. * ['Trident', 'Internet Explorer 5.0', 'Win 95+', 5, 'C'],
  8326. * ],
  8327. * "columns": [
  8328. * { "title": "Engine" },
  8329. * { "title": "Browser" },
  8330. * { "title": "Platform" },
  8331. * { "title": "Version" },
  8332. * { "title": "Grade" }
  8333. * ]
  8334. * } );
  8335. * } );
  8336. *
  8337. * @example
  8338. * // Using an array of objects as a data source (`data`)
  8339. * $(document).ready( function () {
  8340. * $('#example').dataTable( {
  8341. * "data": [
  8342. * {
  8343. * "engine": "Trident",
  8344. * "browser": "Internet Explorer 4.0",
  8345. * "platform": "Win 95+",
  8346. * "version": 4,
  8347. * "grade": "X"
  8348. * },
  8349. * {
  8350. * "engine": "Trident",
  8351. * "browser": "Internet Explorer 5.0",
  8352. * "platform": "Win 95+",
  8353. * "version": 5,
  8354. * "grade": "C"
  8355. * }
  8356. * ],
  8357. * "columns": [
  8358. * { "title": "Engine", "data": "engine" },
  8359. * { "title": "Browser", "data": "browser" },
  8360. * { "title": "Platform", "data": "platform" },
  8361. * { "title": "Version", "data": "version" },
  8362. * { "title": "Grade", "data": "grade" }
  8363. * ]
  8364. * } );
  8365. * } );
  8366. */
  8367. "aaData": null,
  8368. /**
  8369. * If ordering is enabled, then DataTables will perform a first pass sort on
  8370. * initialisation. You can define which column(s) the sort is performed
  8371. * upon, and the sorting direction, with this variable. The `sorting` array
  8372. * should contain an array for each column to be sorted initially containing
  8373. * the column's index and a direction string ('asc' or 'desc').
  8374. * @type array
  8375. * @default [[0,'asc']]
  8376. *
  8377. * @dtopt Option
  8378. * @name DataTable.defaults.order
  8379. *
  8380. * @example
  8381. * // Sort by 3rd column first, and then 4th column
  8382. * $(document).ready( function() {
  8383. * $('#example').dataTable( {
  8384. * "order": [[2,'asc'], [3,'desc']]
  8385. * } );
  8386. * } );
  8387. *
  8388. * // No initial sorting
  8389. * $(document).ready( function() {
  8390. * $('#example').dataTable( {
  8391. * "order": []
  8392. * } );
  8393. * } );
  8394. */
  8395. "aaSorting": [[0,'asc']],
  8396. /**
  8397. * This parameter is basically identical to the `sorting` parameter, but
  8398. * cannot be overridden by user interaction with the table. What this means
  8399. * is that you could have a column (visible or hidden) which the sorting
  8400. * will always be forced on first - any sorting after that (from the user)
  8401. * will then be performed as required. This can be useful for grouping rows
  8402. * together.
  8403. * @type array
  8404. * @default null
  8405. *
  8406. * @dtopt Option
  8407. * @name DataTable.defaults.orderFixed
  8408. *
  8409. * @example
  8410. * $(document).ready( function() {
  8411. * $('#example').dataTable( {
  8412. * "orderFixed": [[0,'asc']]
  8413. * } );
  8414. * } )
  8415. */
  8416. "aaSortingFixed": [],
  8417. /**
  8418. * DataTables can be instructed to load data to display in the table from a
  8419. * Ajax source. This option defines how that Ajax call is made and where to.
  8420. *
  8421. * The `ajax` property has three different modes of operation, depending on
  8422. * how it is defined. These are:
  8423. *
  8424. * * `string` - Set the URL from where the data should be loaded from.
  8425. * * `object` - Define properties for `jQuery.ajax`.
  8426. * * `function` - Custom data get function
  8427. *
  8428. * `string`
  8429. * --------
  8430. *
  8431. * As a string, the `ajax` property simply defines the URL from which
  8432. * DataTables will load data.
  8433. *
  8434. * `object`
  8435. * --------
  8436. *
  8437. * As an object, the parameters in the object are passed to
  8438. * [jQuery.ajax](http://api.jquery.com/jQuery.ajax/) allowing fine control
  8439. * of the Ajax request. DataTables has a number of default parameters which
  8440. * you can override using this option. Please refer to the jQuery
  8441. * documentation for a full description of the options available, although
  8442. * the following parameters provide additional options in DataTables or
  8443. * require special consideration:
  8444. *
  8445. * * `data` - As with jQuery, `data` can be provided as an object, but it
  8446. * can also be used as a function to manipulate the data DataTables sends
  8447. * to the server. The function takes a single parameter, an object of
  8448. * parameters with the values that DataTables has readied for sending. An
  8449. * object may be returned which will be merged into the DataTables
  8450. * defaults, or you can add the items to the object that was passed in and
  8451. * not return anything from the function. This supersedes `fnServerParams`
  8452. * from DataTables 1.9-.
  8453. *
  8454. * * `dataSrc` - By default DataTables will look for the property `data` (or
  8455. * `aaData` for compatibility with DataTables 1.9-) when obtaining data
  8456. * from an Ajax source or for server-side processing - this parameter
  8457. * allows that property to be changed. You can use Javascript dotted
  8458. * object notation to get a data source for multiple levels of nesting, or
  8459. * it my be used as a function. As a function it takes a single parameter,
  8460. * the JSON returned from the server, which can be manipulated as
  8461. * required, with the returned value being that used by DataTables as the
  8462. * data source for the table. This supersedes `sAjaxDataProp` from
  8463. * DataTables 1.9-.
  8464. *
  8465. * * `success` - Should not be overridden it is used internally in
  8466. * DataTables. To manipulate / transform the data returned by the server
  8467. * use `ajax.dataSrc`, or use `ajax` as a function (see below).
  8468. *
  8469. * `function`
  8470. * ----------
  8471. *
  8472. * As a function, making the Ajax call is left up to yourself allowing
  8473. * complete control of the Ajax request. Indeed, if desired, a method other
  8474. * than Ajax could be used to obtain the required data, such as Web storage
  8475. * or an AIR database.
  8476. *
  8477. * The function is given four parameters and no return is required. The
  8478. * parameters are:
  8479. *
  8480. * 1. _object_ - Data to send to the server
  8481. * 2. _function_ - Callback function that must be executed when the required
  8482. * data has been obtained. That data should be passed into the callback
  8483. * as the only parameter
  8484. * 3. _object_ - DataTables settings object for the table
  8485. *
  8486. * Note that this supersedes `fnServerData` from DataTables 1.9-.
  8487. *
  8488. * @type string|object|function
  8489. * @default null
  8490. *
  8491. * @dtopt Option
  8492. * @name DataTable.defaults.ajax
  8493. * @since 1.10.0
  8494. *
  8495. * @example
  8496. * // Get JSON data from a file via Ajax.
  8497. * // Note DataTables expects data in the form `{ data: [ ...data... ] }` by default).
  8498. * $('#example').dataTable( {
  8499. * "ajax": "data.json"
  8500. * } );
  8501. *
  8502. * @example
  8503. * // Get JSON data from a file via Ajax, using `dataSrc` to change
  8504. * // `data` to `tableData` (i.e. `{ tableData: [ ...data... ] }`)
  8505. * $('#example').dataTable( {
  8506. * "ajax": {
  8507. * "url": "data.json",
  8508. * "dataSrc": "tableData"
  8509. * }
  8510. * } );
  8511. *
  8512. * @example
  8513. * // Get JSON data from a file via Ajax, using `dataSrc` to read data
  8514. * // from a plain array rather than an array in an object
  8515. * $('#example').dataTable( {
  8516. * "ajax": {
  8517. * "url": "data.json",
  8518. * "dataSrc": ""
  8519. * }
  8520. * } );
  8521. *
  8522. * @example
  8523. * // Manipulate the data returned from the server - add a link to data
  8524. * // (note this can, should, be done using `render` for the column - this
  8525. * // is just a simple example of how the data can be manipulated).
  8526. * $('#example').dataTable( {
  8527. * "ajax": {
  8528. * "url": "data.json",
  8529. * "dataSrc": function ( json ) {
  8530. * for ( var i=0, ien=json.length ; i<ien ; i++ ) {
  8531. * json[i][0] = '<a href="/message/'+json[i][0]+'>View message</a>';
  8532. * }
  8533. * return json;
  8534. * }
  8535. * }
  8536. * } );
  8537. *
  8538. * @example
  8539. * // Add data to the request
  8540. * $('#example').dataTable( {
  8541. * "ajax": {
  8542. * "url": "data.json",
  8543. * "data": function ( d ) {
  8544. * return {
  8545. * "extra_search": $('#extra').val()
  8546. * };
  8547. * }
  8548. * }
  8549. * } );
  8550. *
  8551. * @example
  8552. * // Send request as POST
  8553. * $('#example').dataTable( {
  8554. * "ajax": {
  8555. * "url": "data.json",
  8556. * "type": "POST"
  8557. * }
  8558. * } );
  8559. *
  8560. * @example
  8561. * // Get the data from localStorage (could interface with a form for
  8562. * // adding, editing and removing rows).
  8563. * $('#example').dataTable( {
  8564. * "ajax": function (data, callback, settings) {
  8565. * callback(
  8566. * JSON.parse( localStorage.getItem('dataTablesData') )
  8567. * );
  8568. * }
  8569. * } );
  8570. */
  8571. "ajax": null,
  8572. /**
  8573. * This parameter allows you to readily specify the entries in the length drop
  8574. * down menu that DataTables shows when pagination is enabled. It can be
  8575. * either a 1D array of options which will be used for both the displayed
  8576. * option and the value, or a 2D array which will use the array in the first
  8577. * position as the value, and the array in the second position as the
  8578. * displayed options (useful for language strings such as 'All').
  8579. *
  8580. * Note that the `pageLength` property will be automatically set to the
  8581. * first value given in this array, unless `pageLength` is also provided.
  8582. * @type array
  8583. * @default [ 10, 25, 50, 100 ]
  8584. *
  8585. * @dtopt Option
  8586. * @name DataTable.defaults.lengthMenu
  8587. *
  8588. * @example
  8589. * $(document).ready( function() {
  8590. * $('#example').dataTable( {
  8591. * "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
  8592. * } );
  8593. * } );
  8594. */
  8595. "aLengthMenu": [ 10, 25, 50, 100 ],
  8596. /**
  8597. * The `columns` option in the initialisation parameter allows you to define
  8598. * details about the way individual columns behave. For a full list of
  8599. * column options that can be set, please see
  8600. * {@link DataTable.defaults.column}. Note that if you use `columns` to
  8601. * define your columns, you must have an entry in the array for every single
  8602. * column that you have in your table (these can be null if you don't which
  8603. * to specify any options).
  8604. * @member
  8605. *
  8606. * @name DataTable.defaults.column
  8607. */
  8608. "aoColumns": null,
  8609. /**
  8610. * Very similar to `columns`, `columnDefs` allows you to target a specific
  8611. * column, multiple columns, or all columns, using the `targets` property of
  8612. * each object in the array. This allows great flexibility when creating
  8613. * tables, as the `columnDefs` arrays can be of any length, targeting the
  8614. * columns you specifically want. `columnDefs` may use any of the column
  8615. * options available: {@link DataTable.defaults.column}, but it _must_
  8616. * have `targets` defined in each object in the array. Values in the `targets`
  8617. * array may be:
  8618. * <ul>
  8619. * <li>a string - class name will be matched on the TH for the column</li>
  8620. * <li>0 or a positive integer - column index counting from the left</li>
  8621. * <li>a negative integer - column index counting from the right</li>
  8622. * <li>the string "_all" - all columns (i.e. assign a default)</li>
  8623. * </ul>
  8624. * @member
  8625. *
  8626. * @name DataTable.defaults.columnDefs
  8627. */
  8628. "aoColumnDefs": null,
  8629. /**
  8630. * Basically the same as `search`, this parameter defines the individual column
  8631. * filtering state at initialisation time. The array must be of the same size
  8632. * as the number of columns, and each element be an object with the parameters
  8633. * `search` and `escapeRegex` (the latter is optional). 'null' is also
  8634. * accepted and the default will be used.
  8635. * @type array
  8636. * @default []
  8637. *
  8638. * @dtopt Option
  8639. * @name DataTable.defaults.searchCols
  8640. *
  8641. * @example
  8642. * $(document).ready( function() {
  8643. * $('#example').dataTable( {
  8644. * "searchCols": [
  8645. * null,
  8646. * { "search": "My filter" },
  8647. * null,
  8648. * { "search": "^[0-9]", "escapeRegex": false }
  8649. * ]
  8650. * } );
  8651. * } )
  8652. */
  8653. "aoSearchCols": [],
  8654. /**
  8655. * An array of CSS classes that should be applied to displayed rows. This
  8656. * array may be of any length, and DataTables will apply each class
  8657. * sequentially, looping when required.
  8658. * @type array
  8659. * @default null <i>Will take the values determined by the `oClasses.stripe*`
  8660. * options</i>
  8661. *
  8662. * @dtopt Option
  8663. * @name DataTable.defaults.stripeClasses
  8664. *
  8665. * @example
  8666. * $(document).ready( function() {
  8667. * $('#example').dataTable( {
  8668. * "stripeClasses": [ 'strip1', 'strip2', 'strip3' ]
  8669. * } );
  8670. * } )
  8671. */
  8672. "asStripeClasses": null,
  8673. /**
  8674. * Enable or disable automatic column width calculation. This can be disabled
  8675. * as an optimisation (it takes some time to calculate the widths) if the
  8676. * tables widths are passed in using `columns`.
  8677. * @type boolean
  8678. * @default true
  8679. *
  8680. * @dtopt Features
  8681. * @name DataTable.defaults.autoWidth
  8682. *
  8683. * @example
  8684. * $(document).ready( function () {
  8685. * $('#example').dataTable( {
  8686. * "autoWidth": false
  8687. * } );
  8688. * } );
  8689. */
  8690. "bAutoWidth": true,
  8691. /**
  8692. * Deferred rendering can provide DataTables with a huge speed boost when you
  8693. * are using an Ajax or JS data source for the table. This option, when set to
  8694. * true, will cause DataTables to defer the creation of the table elements for
  8695. * each row until they are needed for a draw - saving a significant amount of
  8696. * time.
  8697. * @type boolean
  8698. * @default false
  8699. *
  8700. * @dtopt Features
  8701. * @name DataTable.defaults.deferRender
  8702. *
  8703. * @example
  8704. * $(document).ready( function() {
  8705. * $('#example').dataTable( {
  8706. * "ajax": "sources/arrays.txt",
  8707. * "deferRender": true
  8708. * } );
  8709. * } );
  8710. */
  8711. "bDeferRender": false,
  8712. /**
  8713. * Replace a DataTable which matches the given selector and replace it with
  8714. * one which has the properties of the new initialisation object passed. If no
  8715. * table matches the selector, then the new DataTable will be constructed as
  8716. * per normal.
  8717. * @type boolean
  8718. * @default false
  8719. *
  8720. * @dtopt Options
  8721. * @name DataTable.defaults.destroy
  8722. *
  8723. * @example
  8724. * $(document).ready( function() {
  8725. * $('#example').dataTable( {
  8726. * "srollY": "200px",
  8727. * "paginate": false
  8728. * } );
  8729. *
  8730. * // Some time later....
  8731. * $('#example').dataTable( {
  8732. * "filter": false,
  8733. * "destroy": true
  8734. * } );
  8735. * } );
  8736. */
  8737. "bDestroy": false,
  8738. /**
  8739. * Enable or disable filtering of data. Filtering in DataTables is "smart" in
  8740. * that it allows the end user to input multiple words (space separated) and
  8741. * will match a row containing those words, even if not in the order that was
  8742. * specified (this allow matching across multiple columns). Note that if you
  8743. * wish to use filtering in DataTables this must remain 'true' - to remove the
  8744. * default filtering input box and retain filtering abilities, please use
  8745. * {@link DataTable.defaults.dom}.
  8746. * @type boolean
  8747. * @default true
  8748. *
  8749. * @dtopt Features
  8750. * @name DataTable.defaults.searching
  8751. *
  8752. * @example
  8753. * $(document).ready( function () {
  8754. * $('#example').dataTable( {
  8755. * "searching": false
  8756. * } );
  8757. * } );
  8758. */
  8759. "bFilter": true,
  8760. /**
  8761. * Enable or disable the table information display. This shows information
  8762. * about the data that is currently visible on the page, including information
  8763. * about filtered data if that action is being performed.
  8764. * @type boolean
  8765. * @default true
  8766. *
  8767. * @dtopt Features
  8768. * @name DataTable.defaults.info
  8769. *
  8770. * @example
  8771. * $(document).ready( function () {
  8772. * $('#example').dataTable( {
  8773. * "info": false
  8774. * } );
  8775. * } );
  8776. */
  8777. "bInfo": true,
  8778. /**
  8779. * Enable jQuery UI ThemeRoller support (required as ThemeRoller requires some
  8780. * slightly different and additional mark-up from what DataTables has
  8781. * traditionally used).
  8782. * @type boolean
  8783. * @default false
  8784. *
  8785. * @dtopt Features
  8786. * @name DataTable.defaults.jQueryUI
  8787. *
  8788. * @example
  8789. * $(document).ready( function() {
  8790. * $('#example').dataTable( {
  8791. * "jQueryUI": true
  8792. * } );
  8793. * } );
  8794. */
  8795. "bJQueryUI": false,
  8796. /**
  8797. * Allows the end user to select the size of a formatted page from a select
  8798. * menu (sizes are 10, 25, 50 and 100). Requires pagination (`paginate`).
  8799. * @type boolean
  8800. * @default true
  8801. *
  8802. * @dtopt Features
  8803. * @name DataTable.defaults.lengthChange
  8804. *
  8805. * @example
  8806. * $(document).ready( function () {
  8807. * $('#example').dataTable( {
  8808. * "lengthChange": false
  8809. * } );
  8810. * } );
  8811. */
  8812. "bLengthChange": true,
  8813. /**
  8814. * Enable or disable pagination.
  8815. * @type boolean
  8816. * @default true
  8817. *
  8818. * @dtopt Features
  8819. * @name DataTable.defaults.paging
  8820. *
  8821. * @example
  8822. * $(document).ready( function () {
  8823. * $('#example').dataTable( {
  8824. * "paging": false
  8825. * } );
  8826. * } );
  8827. */
  8828. "bPaginate": true,
  8829. /**
  8830. * Enable or disable the display of a 'processing' indicator when the table is
  8831. * being processed (e.g. a sort). This is particularly useful for tables with
  8832. * large amounts of data where it can take a noticeable amount of time to sort
  8833. * the entries.
  8834. * @type boolean
  8835. * @default false
  8836. *
  8837. * @dtopt Features
  8838. * @name DataTable.defaults.processing
  8839. *
  8840. * @example
  8841. * $(document).ready( function () {
  8842. * $('#example').dataTable( {
  8843. * "processing": true
  8844. * } );
  8845. * } );
  8846. */
  8847. "bProcessing": false,
  8848. /**
  8849. * Retrieve the DataTables object for the given selector. Note that if the
  8850. * table has already been initialised, this parameter will cause DataTables
  8851. * to simply return the object that has already been set up - it will not take
  8852. * account of any changes you might have made to the initialisation object
  8853. * passed to DataTables (setting this parameter to true is an acknowledgement
  8854. * that you understand this). `destroy` can be used to reinitialise a table if
  8855. * you need.
  8856. * @type boolean
  8857. * @default false
  8858. *
  8859. * @dtopt Options
  8860. * @name DataTable.defaults.retrieve
  8861. *
  8862. * @example
  8863. * $(document).ready( function() {
  8864. * initTable();
  8865. * tableActions();
  8866. * } );
  8867. *
  8868. * function initTable ()
  8869. * {
  8870. * return $('#example').dataTable( {
  8871. * "scrollY": "200px",
  8872. * "paginate": false,
  8873. * "retrieve": true
  8874. * } );
  8875. * }
  8876. *
  8877. * function tableActions ()
  8878. * {
  8879. * var table = initTable();
  8880. * // perform API operations with oTable
  8881. * }
  8882. */
  8883. "bRetrieve": false,
  8884. /**
  8885. * When vertical (y) scrolling is enabled, DataTables will force the height of
  8886. * the table's viewport to the given height at all times (useful for layout).
  8887. * However, this can look odd when filtering data down to a small data set,
  8888. * and the footer is left "floating" further down. This parameter (when
  8889. * enabled) will cause DataTables to collapse the table's viewport down when
  8890. * the result set will fit within the given Y height.
  8891. * @type boolean
  8892. * @default false
  8893. *
  8894. * @dtopt Options
  8895. * @name DataTable.defaults.scrollCollapse
  8896. *
  8897. * @example
  8898. * $(document).ready( function() {
  8899. * $('#example').dataTable( {
  8900. * "scrollY": "200",
  8901. * "scrollCollapse": true
  8902. * } );
  8903. * } );
  8904. */
  8905. "bScrollCollapse": false,
  8906. /**
  8907. * Configure DataTables to use server-side processing. Note that the
  8908. * `ajax` parameter must also be given in order to give DataTables a
  8909. * source to obtain the required data for each draw.
  8910. * @type boolean
  8911. * @default false
  8912. *
  8913. * @dtopt Features
  8914. * @dtopt Server-side
  8915. * @name DataTable.defaults.serverSide
  8916. *
  8917. * @example
  8918. * $(document).ready( function () {
  8919. * $('#example').dataTable( {
  8920. * "serverSide": true,
  8921. * "ajax": "xhr.php"
  8922. * } );
  8923. * } );
  8924. */
  8925. "bServerSide": false,
  8926. /**
  8927. * Enable or disable sorting of columns. Sorting of individual columns can be
  8928. * disabled by the `sortable` option for each column.
  8929. * @type boolean
  8930. * @default true
  8931. *
  8932. * @dtopt Features
  8933. * @name DataTable.defaults.ordering
  8934. *
  8935. * @example
  8936. * $(document).ready( function () {
  8937. * $('#example').dataTable( {
  8938. * "ordering": false
  8939. * } );
  8940. * } );
  8941. */
  8942. "bSort": true,
  8943. /**
  8944. * Enable or display DataTables' ability to sort multiple columns at the
  8945. * same time (activated by shift-click by the user).
  8946. * @type boolean
  8947. * @default true
  8948. *
  8949. * @dtopt Options
  8950. * @name DataTable.defaults.orderMulti
  8951. *
  8952. * @example
  8953. * // Disable multiple column sorting ability
  8954. * $(document).ready( function () {
  8955. * $('#example').dataTable( {
  8956. * "orderMulti": false
  8957. * } );
  8958. * } );
  8959. */
  8960. "bSortMulti": true,
  8961. /**
  8962. * Allows control over whether DataTables should use the top (true) unique
  8963. * cell that is found for a single column, or the bottom (false - default).
  8964. * This is useful when using complex headers.
  8965. * @type boolean
  8966. * @default false
  8967. *
  8968. * @dtopt Options
  8969. * @name DataTable.defaults.orderCellsTop
  8970. *
  8971. * @example
  8972. * $(document).ready( function() {
  8973. * $('#example').dataTable( {
  8974. * "orderCellsTop": true
  8975. * } );
  8976. * } );
  8977. */
  8978. "bSortCellsTop": false,
  8979. /**
  8980. * Enable or disable the addition of the classes `sorting\_1`, `sorting\_2` and
  8981. * `sorting\_3` to the columns which are currently being sorted on. This is
  8982. * presented as a feature switch as it can increase processing time (while
  8983. * classes are removed and added) so for large data sets you might want to
  8984. * turn this off.
  8985. * @type boolean
  8986. * @default true
  8987. *
  8988. * @dtopt Features
  8989. * @name DataTable.defaults.orderClasses
  8990. *
  8991. * @example
  8992. * $(document).ready( function () {
  8993. * $('#example').dataTable( {
  8994. * "orderClasses": false
  8995. * } );
  8996. * } );
  8997. */
  8998. "bSortClasses": true,
  8999. /**
  9000. * Enable or disable state saving. When enabled HTML5 `localStorage` will be
  9001. * used to save table display information such as pagination information,
  9002. * display length, filtering and sorting. As such when the end user reloads
  9003. * the page the display display will match what thy had previously set up.
  9004. *
  9005. * Due to the use of `localStorage` the default state saving is not supported
  9006. * in IE6 or 7. If state saving is required in those browsers, use
  9007. * `stateSaveCallback` to provide a storage solution such as cookies.
  9008. * @type boolean
  9009. * @default false
  9010. *
  9011. * @dtopt Features
  9012. * @name DataTable.defaults.stateSave
  9013. *
  9014. * @example
  9015. * $(document).ready( function () {
  9016. * $('#example').dataTable( {
  9017. * "stateSave": true
  9018. * } );
  9019. * } );
  9020. */
  9021. "bStateSave": false,
  9022. /**
  9023. * This function is called when a TR element is created (and all TD child
  9024. * elements have been inserted), or registered if using a DOM source, allowing
  9025. * manipulation of the TR element (adding classes etc).
  9026. * @type function
  9027. * @param {node} row "TR" element for the current row
  9028. * @param {array} data Raw data array for this row
  9029. * @param {int} dataIndex The index of this row in the internal aoData array
  9030. *
  9031. * @dtopt Callbacks
  9032. * @name DataTable.defaults.createdRow
  9033. *
  9034. * @example
  9035. * $(document).ready( function() {
  9036. * $('#example').dataTable( {
  9037. * "createdRow": function( row, data, dataIndex ) {
  9038. * // Bold the grade for all 'A' grade browsers
  9039. * if ( data[4] == "A" )
  9040. * {
  9041. * $('td:eq(4)', row).html( '<b>A</b>' );
  9042. * }
  9043. * }
  9044. * } );
  9045. * } );
  9046. */
  9047. "fnCreatedRow": null,
  9048. /**
  9049. * This function is called on every 'draw' event, and allows you to
  9050. * dynamically modify any aspect you want about the created DOM.
  9051. * @type function
  9052. * @param {object} settings DataTables settings object
  9053. *
  9054. * @dtopt Callbacks
  9055. * @name DataTable.defaults.drawCallback
  9056. *
  9057. * @example
  9058. * $(document).ready( function() {
  9059. * $('#example').dataTable( {
  9060. * "drawCallback": function( settings ) {
  9061. * alert( 'DataTables has redrawn the table' );
  9062. * }
  9063. * } );
  9064. * } );
  9065. */
  9066. "fnDrawCallback": null,
  9067. /**
  9068. * Identical to fnHeaderCallback() but for the table footer this function
  9069. * allows you to modify the table footer on every 'draw' event.
  9070. * @type function
  9071. * @param {node} foot "TR" element for the footer
  9072. * @param {array} data Full table data (as derived from the original HTML)
  9073. * @param {int} start Index for the current display starting point in the
  9074. * display array
  9075. * @param {int} end Index for the current display ending point in the
  9076. * display array
  9077. * @param {array int} display Index array to translate the visual position
  9078. * to the full data array
  9079. *
  9080. * @dtopt Callbacks
  9081. * @name DataTable.defaults.footerCallback
  9082. *
  9083. * @example
  9084. * $(document).ready( function() {
  9085. * $('#example').dataTable( {
  9086. * "footerCallback": function( tfoot, data, start, end, display ) {
  9087. * tfoot.getElementsByTagName('th')[0].innerHTML = "Starting index is "+start;
  9088. * }
  9089. * } );
  9090. * } )
  9091. */
  9092. "fnFooterCallback": null,
  9093. /**
  9094. * When rendering large numbers in the information element for the table
  9095. * (i.e. "Showing 1 to 10 of 57 entries") DataTables will render large numbers
  9096. * to have a comma separator for the 'thousands' units (e.g. 1 million is
  9097. * rendered as "1,000,000") to help readability for the end user. This
  9098. * function will override the default method DataTables uses.
  9099. * @type function
  9100. * @member
  9101. * @param {int} toFormat number to be formatted
  9102. * @returns {string} formatted string for DataTables to show the number
  9103. *
  9104. * @dtopt Callbacks
  9105. * @name DataTable.defaults.formatNumber
  9106. *
  9107. * @example
  9108. * // Format a number using a single quote for the separator (note that
  9109. * // this can also be done with the language.thousands option)
  9110. * $(document).ready( function() {
  9111. * $('#example').dataTable( {
  9112. * "formatNumber": function ( toFormat ) {
  9113. * return toFormat.toString().replace(
  9114. * /\B(?=(\d{3})+(?!\d))/g, "'"
  9115. * );
  9116. * };
  9117. * } );
  9118. * } );
  9119. */
  9120. "fnFormatNumber": function ( toFormat ) {
  9121. return toFormat.toString().replace(
  9122. /\B(?=(\d{3})+(?!\d))/g,
  9123. this.oLanguage.sThousands
  9124. );
  9125. },
  9126. /**
  9127. * This function is called on every 'draw' event, and allows you to
  9128. * dynamically modify the header row. This can be used to calculate and
  9129. * display useful information about the table.
  9130. * @type function
  9131. * @param {node} head "TR" element for the header
  9132. * @param {array} data Full table data (as derived from the original HTML)
  9133. * @param {int} start Index for the current display starting point in the
  9134. * display array
  9135. * @param {int} end Index for the current display ending point in the
  9136. * display array
  9137. * @param {array int} display Index array to translate the visual position
  9138. * to the full data array
  9139. *
  9140. * @dtopt Callbacks
  9141. * @name DataTable.defaults.headerCallback
  9142. *
  9143. * @example
  9144. * $(document).ready( function() {
  9145. * $('#example').dataTable( {
  9146. * "fheaderCallback": function( head, data, start, end, display ) {
  9147. * head.getElementsByTagName('th')[0].innerHTML = "Displaying "+(end-start)+" records";
  9148. * }
  9149. * } );
  9150. * } )
  9151. */
  9152. "fnHeaderCallback": null,
  9153. /**
  9154. * The information element can be used to convey information about the current
  9155. * state of the table. Although the internationalisation options presented by
  9156. * DataTables are quite capable of dealing with most customisations, there may
  9157. * be times where you wish to customise the string further. This callback
  9158. * allows you to do exactly that.
  9159. * @type function
  9160. * @param {object} oSettings DataTables settings object
  9161. * @param {int} start Starting position in data for the draw
  9162. * @param {int} end End position in data for the draw
  9163. * @param {int} max Total number of rows in the table (regardless of
  9164. * filtering)
  9165. * @param {int} total Total number of rows in the data set, after filtering
  9166. * @param {string} pre The string that DataTables has formatted using it's
  9167. * own rules
  9168. * @returns {string} The string to be displayed in the information element.
  9169. *
  9170. * @dtopt Callbacks
  9171. * @name DataTable.defaults.infoCallback
  9172. *
  9173. * @example
  9174. * $('#example').dataTable( {
  9175. * "infoCallback": function( settings, start, end, max, total, pre ) {
  9176. * return start +" to "+ end;
  9177. * }
  9178. * } );
  9179. */
  9180. "fnInfoCallback": null,
  9181. /**
  9182. * Called when the table has been initialised. Normally DataTables will
  9183. * initialise sequentially and there will be no need for this function,
  9184. * however, this does not hold true when using external language information
  9185. * since that is obtained using an async XHR call.
  9186. * @type function
  9187. * @param {object} settings DataTables settings object
  9188. * @param {object} json The JSON object request from the server - only
  9189. * present if client-side Ajax sourced data is used
  9190. *
  9191. * @dtopt Callbacks
  9192. * @name DataTable.defaults.initComplete
  9193. *
  9194. * @example
  9195. * $(document).ready( function() {
  9196. * $('#example').dataTable( {
  9197. * "initComplete": function(settings, json) {
  9198. * alert( 'DataTables has finished its initialisation.' );
  9199. * }
  9200. * } );
  9201. * } )
  9202. */
  9203. "fnInitComplete": null,
  9204. /**
  9205. * Called at the very start of each table draw and can be used to cancel the
  9206. * draw by returning false, any other return (including undefined) results in
  9207. * the full draw occurring).
  9208. * @type function
  9209. * @param {object} settings DataTables settings object
  9210. * @returns {boolean} False will cancel the draw, anything else (including no
  9211. * return) will allow it to complete.
  9212. *
  9213. * @dtopt Callbacks
  9214. * @name DataTable.defaults.preDrawCallback
  9215. *
  9216. * @example
  9217. * $(document).ready( function() {
  9218. * $('#example').dataTable( {
  9219. * "preDrawCallback": function( settings ) {
  9220. * if ( $('#test').val() == 1 ) {
  9221. * return false;
  9222. * }
  9223. * }
  9224. * } );
  9225. * } );
  9226. */
  9227. "fnPreDrawCallback": null,
  9228. /**
  9229. * This function allows you to 'post process' each row after it have been
  9230. * generated for each table draw, but before it is rendered on screen. This
  9231. * function might be used for setting the row class name etc.
  9232. * @type function
  9233. * @param {node} row "TR" element for the current row
  9234. * @param {array} data Raw data array for this row
  9235. * @param {int} displayIndex The display index for the current table draw
  9236. * @param {int} displayIndexFull The index of the data in the full list of
  9237. * rows (after filtering)
  9238. *
  9239. * @dtopt Callbacks
  9240. * @name DataTable.defaults.rowCallback
  9241. *
  9242. * @example
  9243. * $(document).ready( function() {
  9244. * $('#example').dataTable( {
  9245. * "rowCallback": function( row, data, displayIndex, displayIndexFull ) {
  9246. * // Bold the grade for all 'A' grade browsers
  9247. * if ( data[4] == "A" ) {
  9248. * $('td:eq(4)', row).html( '<b>A</b>' );
  9249. * }
  9250. * }
  9251. * } );
  9252. * } );
  9253. */
  9254. "fnRowCallback": null,
  9255. /**
  9256. * __Deprecated__ The functionality provided by this parameter has now been
  9257. * superseded by that provided through `ajax`, which should be used instead.
  9258. *
  9259. * This parameter allows you to override the default function which obtains
  9260. * the data from the server so something more suitable for your application.
  9261. * For example you could use POST data, or pull information from a Gears or
  9262. * AIR database.
  9263. * @type function
  9264. * @member
  9265. * @param {string} source HTTP source to obtain the data from (`ajax`)
  9266. * @param {array} data A key/value pair object containing the data to send
  9267. * to the server
  9268. * @param {function} callback to be called on completion of the data get
  9269. * process that will draw the data on the page.
  9270. * @param {object} settings DataTables settings object
  9271. *
  9272. * @dtopt Callbacks
  9273. * @dtopt Server-side
  9274. * @name DataTable.defaults.serverData
  9275. *
  9276. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9277. */
  9278. "fnServerData": null,
  9279. /**
  9280. * __Deprecated__ The functionality provided by this parameter has now been
  9281. * superseded by that provided through `ajax`, which should be used instead.
  9282. *
  9283. * It is often useful to send extra data to the server when making an Ajax
  9284. * request - for example custom filtering information, and this callback
  9285. * function makes it trivial to send extra information to the server. The
  9286. * passed in parameter is the data set that has been constructed by
  9287. * DataTables, and you can add to this or modify it as you require.
  9288. * @type function
  9289. * @param {array} data Data array (array of objects which are name/value
  9290. * pairs) that has been constructed by DataTables and will be sent to the
  9291. * server. In the case of Ajax sourced data with server-side processing
  9292. * this will be an empty array, for server-side processing there will be a
  9293. * significant number of parameters!
  9294. * @returns {undefined} Ensure that you modify the data array passed in,
  9295. * as this is passed by reference.
  9296. *
  9297. * @dtopt Callbacks
  9298. * @dtopt Server-side
  9299. * @name DataTable.defaults.serverParams
  9300. *
  9301. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9302. */
  9303. "fnServerParams": null,
  9304. /**
  9305. * Load the table state. With this function you can define from where, and how, the
  9306. * state of a table is loaded. By default DataTables will load from `localStorage`
  9307. * but you might wish to use a server-side database or cookies.
  9308. * @type function
  9309. * @member
  9310. * @param {object} settings DataTables settings object
  9311. * @return {object} The DataTables state object to be loaded
  9312. *
  9313. * @dtopt Callbacks
  9314. * @name DataTable.defaults.stateLoadCallback
  9315. *
  9316. * @example
  9317. * $(document).ready( function() {
  9318. * $('#example').dataTable( {
  9319. * "stateSave": true,
  9320. * "stateLoadCallback": function (settings) {
  9321. * var o;
  9322. *
  9323. * // Send an Ajax request to the server to get the data. Note that
  9324. * // this is a synchronous request.
  9325. * $.ajax( {
  9326. * "url": "/state_load",
  9327. * "async": false,
  9328. * "dataType": "json",
  9329. * "success": function (json) {
  9330. * o = json;
  9331. * }
  9332. * } );
  9333. *
  9334. * return o;
  9335. * }
  9336. * } );
  9337. * } );
  9338. */
  9339. "fnStateLoadCallback": function ( settings ) {
  9340. try {
  9341. return JSON.parse(
  9342. (settings.iStateDuration === -1 ? sessionStorage : localStorage).getItem(
  9343. 'DataTables_'+settings.sInstance+'_'+location.pathname
  9344. )
  9345. );
  9346. } catch (e) {}
  9347. },
  9348. /**
  9349. * Callback which allows modification of the saved state prior to loading that state.
  9350. * This callback is called when the table is loading state from the stored data, but
  9351. * prior to the settings object being modified by the saved state. Note that for
  9352. * plug-in authors, you should use the `stateLoadParams` event to load parameters for
  9353. * a plug-in.
  9354. * @type function
  9355. * @param {object} settings DataTables settings object
  9356. * @param {object} data The state object that is to be loaded
  9357. *
  9358. * @dtopt Callbacks
  9359. * @name DataTable.defaults.stateLoadParams
  9360. *
  9361. * @example
  9362. * // Remove a saved filter, so filtering is never loaded
  9363. * $(document).ready( function() {
  9364. * $('#example').dataTable( {
  9365. * "stateSave": true,
  9366. * "stateLoadParams": function (settings, data) {
  9367. * data.oSearch.sSearch = "";
  9368. * }
  9369. * } );
  9370. * } );
  9371. *
  9372. * @example
  9373. * // Disallow state loading by returning false
  9374. * $(document).ready( function() {
  9375. * $('#example').dataTable( {
  9376. * "stateSave": true,
  9377. * "stateLoadParams": function (settings, data) {
  9378. * return false;
  9379. * }
  9380. * } );
  9381. * } );
  9382. */
  9383. "fnStateLoadParams": null,
  9384. /**
  9385. * Callback that is called when the state has been loaded from the state saving method
  9386. * and the DataTables settings object has been modified as a result of the loaded state.
  9387. * @type function
  9388. * @param {object} settings DataTables settings object
  9389. * @param {object} data The state object that was loaded
  9390. *
  9391. * @dtopt Callbacks
  9392. * @name DataTable.defaults.stateLoaded
  9393. *
  9394. * @example
  9395. * // Show an alert with the filtering value that was saved
  9396. * $(document).ready( function() {
  9397. * $('#example').dataTable( {
  9398. * "stateSave": true,
  9399. * "stateLoaded": function (settings, data) {
  9400. * alert( 'Saved filter was: '+data.oSearch.sSearch );
  9401. * }
  9402. * } );
  9403. * } );
  9404. */
  9405. "fnStateLoaded": null,
  9406. /**
  9407. * Save the table state. This function allows you to define where and how the state
  9408. * information for the table is stored By default DataTables will use `localStorage`
  9409. * but you might wish to use a server-side database or cookies.
  9410. * @type function
  9411. * @member
  9412. * @param {object} settings DataTables settings object
  9413. * @param {object} data The state object to be saved
  9414. *
  9415. * @dtopt Callbacks
  9416. * @name DataTable.defaults.stateSaveCallback
  9417. *
  9418. * @example
  9419. * $(document).ready( function() {
  9420. * $('#example').dataTable( {
  9421. * "stateSave": true,
  9422. * "stateSaveCallback": function (settings, data) {
  9423. * // Send an Ajax request to the server with the state object
  9424. * $.ajax( {
  9425. * "url": "/state_save",
  9426. * "data": data,
  9427. * "dataType": "json",
  9428. * "method": "POST"
  9429. * "success": function () {}
  9430. * } );
  9431. * }
  9432. * } );
  9433. * } );
  9434. */
  9435. "fnStateSaveCallback": function ( settings, data ) {
  9436. try {
  9437. (settings.iStateDuration === -1 ? sessionStorage : localStorage).setItem(
  9438. 'DataTables_'+settings.sInstance+'_'+location.pathname,
  9439. JSON.stringify( data )
  9440. );
  9441. } catch (e) {}
  9442. },
  9443. /**
  9444. * Callback which allows modification of the state to be saved. Called when the table
  9445. * has changed state a new state save is required. This method allows modification of
  9446. * the state saving object prior to actually doing the save, including addition or
  9447. * other state properties or modification. Note that for plug-in authors, you should
  9448. * use the `stateSaveParams` event to save parameters for a plug-in.
  9449. * @type function
  9450. * @param {object} settings DataTables settings object
  9451. * @param {object} data The state object to be saved
  9452. *
  9453. * @dtopt Callbacks
  9454. * @name DataTable.defaults.stateSaveParams
  9455. *
  9456. * @example
  9457. * // Remove a saved filter, so filtering is never saved
  9458. * $(document).ready( function() {
  9459. * $('#example').dataTable( {
  9460. * "stateSave": true,
  9461. * "stateSaveParams": function (settings, data) {
  9462. * data.oSearch.sSearch = "";
  9463. * }
  9464. * } );
  9465. * } );
  9466. */
  9467. "fnStateSaveParams": null,
  9468. /**
  9469. * Duration for which the saved state information is considered valid. After this period
  9470. * has elapsed the state will be returned to the default.
  9471. * Value is given in seconds.
  9472. * @type int
  9473. * @default 7200 <i>(2 hours)</i>
  9474. *
  9475. * @dtopt Options
  9476. * @name DataTable.defaults.stateDuration
  9477. *
  9478. * @example
  9479. * $(document).ready( function() {
  9480. * $('#example').dataTable( {
  9481. * "stateDuration": 60*60*24; // 1 day
  9482. * } );
  9483. * } )
  9484. */
  9485. "iStateDuration": 7200,
  9486. /**
  9487. * When enabled DataTables will not make a request to the server for the first
  9488. * page draw - rather it will use the data already on the page (no sorting etc
  9489. * will be applied to it), thus saving on an XHR at load time. `deferLoading`
  9490. * is used to indicate that deferred loading is required, but it is also used
  9491. * to tell DataTables how many records there are in the full table (allowing
  9492. * the information element and pagination to be displayed correctly). In the case
  9493. * where a filtering is applied to the table on initial load, this can be
  9494. * indicated by giving the parameter as an array, where the first element is
  9495. * the number of records available after filtering and the second element is the
  9496. * number of records without filtering (allowing the table information element
  9497. * to be shown correctly).
  9498. * @type int | array
  9499. * @default null
  9500. *
  9501. * @dtopt Options
  9502. * @name DataTable.defaults.deferLoading
  9503. *
  9504. * @example
  9505. * // 57 records available in the table, no filtering applied
  9506. * $(document).ready( function() {
  9507. * $('#example').dataTable( {
  9508. * "serverSide": true,
  9509. * "ajax": "scripts/server_processing.php",
  9510. * "deferLoading": 57
  9511. * } );
  9512. * } );
  9513. *
  9514. * @example
  9515. * // 57 records after filtering, 100 without filtering (an initial filter applied)
  9516. * $(document).ready( function() {
  9517. * $('#example').dataTable( {
  9518. * "serverSide": true,
  9519. * "ajax": "scripts/server_processing.php",
  9520. * "deferLoading": [ 57, 100 ],
  9521. * "search": {
  9522. * "search": "my_filter"
  9523. * }
  9524. * } );
  9525. * } );
  9526. */
  9527. "iDeferLoading": null,
  9528. /**
  9529. * Number of rows to display on a single page when using pagination. If
  9530. * feature enabled (`lengthChange`) then the end user will be able to override
  9531. * this to a custom setting using a pop-up menu.
  9532. * @type int
  9533. * @default 10
  9534. *
  9535. * @dtopt Options
  9536. * @name DataTable.defaults.pageLength
  9537. *
  9538. * @example
  9539. * $(document).ready( function() {
  9540. * $('#example').dataTable( {
  9541. * "pageLength": 50
  9542. * } );
  9543. * } )
  9544. */
  9545. "iDisplayLength": 10,
  9546. /**
  9547. * Define the starting point for data display when using DataTables with
  9548. * pagination. Note that this parameter is the number of records, rather than
  9549. * the page number, so if you have 10 records per page and want to start on
  9550. * the third page, it should be "20".
  9551. * @type int
  9552. * @default 0
  9553. *
  9554. * @dtopt Options
  9555. * @name DataTable.defaults.displayStart
  9556. *
  9557. * @example
  9558. * $(document).ready( function() {
  9559. * $('#example').dataTable( {
  9560. * "displayStart": 20
  9561. * } );
  9562. * } )
  9563. */
  9564. "iDisplayStart": 0,
  9565. /**
  9566. * By default DataTables allows keyboard navigation of the table (sorting, paging,
  9567. * and filtering) by adding a `tabindex` attribute to the required elements. This
  9568. * allows you to tab through the controls and press the enter key to activate them.
  9569. * The tabindex is default 0, meaning that the tab follows the flow of the document.
  9570. * You can overrule this using this parameter if you wish. Use a value of -1 to
  9571. * disable built-in keyboard navigation.
  9572. * @type int
  9573. * @default 0
  9574. *
  9575. * @dtopt Options
  9576. * @name DataTable.defaults.tabIndex
  9577. *
  9578. * @example
  9579. * $(document).ready( function() {
  9580. * $('#example').dataTable( {
  9581. * "tabIndex": 1
  9582. * } );
  9583. * } );
  9584. */
  9585. "iTabIndex": 0,
  9586. /**
  9587. * Classes that DataTables assigns to the various components and features
  9588. * that it adds to the HTML table. This allows classes to be configured
  9589. * during initialisation in addition to through the static
  9590. * {@link DataTable.ext.oStdClasses} object).
  9591. * @namespace
  9592. * @name DataTable.defaults.classes
  9593. */
  9594. "oClasses": {},
  9595. /**
  9596. * All strings that DataTables uses in the user interface that it creates
  9597. * are defined in this object, allowing you to modified them individually or
  9598. * completely replace them all as required.
  9599. * @namespace
  9600. * @name DataTable.defaults.language
  9601. */
  9602. "oLanguage": {
  9603. /**
  9604. * Strings that are used for WAI-ARIA labels and controls only (these are not
  9605. * actually visible on the page, but will be read by screenreaders, and thus
  9606. * must be internationalised as well).
  9607. * @namespace
  9608. * @name DataTable.defaults.language.aria
  9609. */
  9610. "oAria": {
  9611. /**
  9612. * ARIA label that is added to the table headers when the column may be
  9613. * sorted ascending by activing the column (click or return when focused).
  9614. * Note that the column header is prefixed to this string.
  9615. * @type string
  9616. * @default : activate to sort column ascending
  9617. *
  9618. * @dtopt Language
  9619. * @name DataTable.defaults.language.aria.sortAscending
  9620. *
  9621. * @example
  9622. * $(document).ready( function() {
  9623. * $('#example').dataTable( {
  9624. * "language": {
  9625. * "aria": {
  9626. * "sortAscending": " - click/return to sort ascending"
  9627. * }
  9628. * }
  9629. * } );
  9630. * } );
  9631. */
  9632. "sSortAscending": ": activate to sort column ascending",
  9633. /**
  9634. * ARIA label that is added to the table headers when the column may be
  9635. * sorted descending by activing the column (click or return when focused).
  9636. * Note that the column header is prefixed to this string.
  9637. * @type string
  9638. * @default : activate to sort column ascending
  9639. *
  9640. * @dtopt Language
  9641. * @name DataTable.defaults.language.aria.sortDescending
  9642. *
  9643. * @example
  9644. * $(document).ready( function() {
  9645. * $('#example').dataTable( {
  9646. * "language": {
  9647. * "aria": {
  9648. * "sortDescending": " - click/return to sort descending"
  9649. * }
  9650. * }
  9651. * } );
  9652. * } );
  9653. */
  9654. "sSortDescending": ": activate to sort column descending"
  9655. },
  9656. /**
  9657. * Pagination string used by DataTables for the built-in pagination
  9658. * control types.
  9659. * @namespace
  9660. * @name DataTable.defaults.language.paginate
  9661. */
  9662. "oPaginate": {
  9663. /**
  9664. * Text to use when using the 'full_numbers' type of pagination for the
  9665. * button to take the user to the first page.
  9666. * @type string
  9667. * @default First
  9668. *
  9669. * @dtopt Language
  9670. * @name DataTable.defaults.language.paginate.first
  9671. *
  9672. * @example
  9673. * $(document).ready( function() {
  9674. * $('#example').dataTable( {
  9675. * "language": {
  9676. * "paginate": {
  9677. * "first": "First page"
  9678. * }
  9679. * }
  9680. * } );
  9681. * } );
  9682. */
  9683. "sFirst": "First",
  9684. /**
  9685. * Text to use when using the 'full_numbers' type of pagination for the
  9686. * button to take the user to the last page.
  9687. * @type string
  9688. * @default Last
  9689. *
  9690. * @dtopt Language
  9691. * @name DataTable.defaults.language.paginate.last
  9692. *
  9693. * @example
  9694. * $(document).ready( function() {
  9695. * $('#example').dataTable( {
  9696. * "language": {
  9697. * "paginate": {
  9698. * "last": "Last page"
  9699. * }
  9700. * }
  9701. * } );
  9702. * } );
  9703. */
  9704. "sLast": "Last",
  9705. /**
  9706. * Text to use for the 'next' pagination button (to take the user to the
  9707. * next page).
  9708. * @type string
  9709. * @default Next
  9710. *
  9711. * @dtopt Language
  9712. * @name DataTable.defaults.language.paginate.next
  9713. *
  9714. * @example
  9715. * $(document).ready( function() {
  9716. * $('#example').dataTable( {
  9717. * "language": {
  9718. * "paginate": {
  9719. * "next": "Next page"
  9720. * }
  9721. * }
  9722. * } );
  9723. * } );
  9724. */
  9725. "sNext": "Next",
  9726. /**
  9727. * Text to use for the 'previous' pagination button (to take the user to
  9728. * the previous page).
  9729. * @type string
  9730. * @default Previous
  9731. *
  9732. * @dtopt Language
  9733. * @name DataTable.defaults.language.paginate.previous
  9734. *
  9735. * @example
  9736. * $(document).ready( function() {
  9737. * $('#example').dataTable( {
  9738. * "language": {
  9739. * "paginate": {
  9740. * "previous": "Previous page"
  9741. * }
  9742. * }
  9743. * } );
  9744. * } );
  9745. */
  9746. "sPrevious": "Previous"
  9747. },
  9748. /**
  9749. * This string is shown in preference to `zeroRecords` when the table is
  9750. * empty of data (regardless of filtering). Note that this is an optional
  9751. * parameter - if it is not given, the value of `zeroRecords` will be used
  9752. * instead (either the default or given value).
  9753. * @type string
  9754. * @default No data available in table
  9755. *
  9756. * @dtopt Language
  9757. * @name DataTable.defaults.language.emptyTable
  9758. *
  9759. * @example
  9760. * $(document).ready( function() {
  9761. * $('#example').dataTable( {
  9762. * "language": {
  9763. * "emptyTable": "No data available in table"
  9764. * }
  9765. * } );
  9766. * } );
  9767. */
  9768. "sEmptyTable": "No data available in table",
  9769. /**
  9770. * This string gives information to the end user about the information
  9771. * that is current on display on the page. The following tokens can be
  9772. * used in the string and will be dynamically replaced as the table
  9773. * display updates. This tokens can be placed anywhere in the string, or
  9774. * removed as needed by the language requires:
  9775. *
  9776. * * `\_START\_` - Display index of the first record on the current page
  9777. * * `\_END\_` - Display index of the last record on the current page
  9778. * * `\_TOTAL\_` - Number of records in the table after filtering
  9779. * * `\_MAX\_` - Number of records in the table without filtering
  9780. * * `\_PAGE\_` - Current page number
  9781. * * `\_PAGES\_` - Total number of pages of data in the table
  9782. *
  9783. * @type string
  9784. * @default Showing _START_ to _END_ of _TOTAL_ entries
  9785. *
  9786. * @dtopt Language
  9787. * @name DataTable.defaults.language.info
  9788. *
  9789. * @example
  9790. * $(document).ready( function() {
  9791. * $('#example').dataTable( {
  9792. * "language": {
  9793. * "info": "Showing page _PAGE_ of _PAGES_"
  9794. * }
  9795. * } );
  9796. * } );
  9797. */
  9798. "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
  9799. /**
  9800. * Display information string for when the table is empty. Typically the
  9801. * format of this string should match `info`.
  9802. * @type string
  9803. * @default Showing 0 to 0 of 0 entries
  9804. *
  9805. * @dtopt Language
  9806. * @name DataTable.defaults.language.infoEmpty
  9807. *
  9808. * @example
  9809. * $(document).ready( function() {
  9810. * $('#example').dataTable( {
  9811. * "language": {
  9812. * "infoEmpty": "No entries to show"
  9813. * }
  9814. * } );
  9815. * } );
  9816. */
  9817. "sInfoEmpty": "Showing 0 to 0 of 0 entries",
  9818. /**
  9819. * When a user filters the information in a table, this string is appended
  9820. * to the information (`info`) to give an idea of how strong the filtering
  9821. * is. The variable _MAX_ is dynamically updated.
  9822. * @type string
  9823. * @default (filtered from _MAX_ total entries)
  9824. *
  9825. * @dtopt Language
  9826. * @name DataTable.defaults.language.infoFiltered
  9827. *
  9828. * @example
  9829. * $(document).ready( function() {
  9830. * $('#example').dataTable( {
  9831. * "language": {
  9832. * "infoFiltered": " - filtering from _MAX_ records"
  9833. * }
  9834. * } );
  9835. * } );
  9836. */
  9837. "sInfoFiltered": "(filtered from _MAX_ total entries)",
  9838. /**
  9839. * If can be useful to append extra information to the info string at times,
  9840. * and this variable does exactly that. This information will be appended to
  9841. * the `info` (`infoEmpty` and `infoFiltered` in whatever combination they are
  9842. * being used) at all times.
  9843. * @type string
  9844. * @default <i>Empty string</i>
  9845. *
  9846. * @dtopt Language
  9847. * @name DataTable.defaults.language.infoPostFix
  9848. *
  9849. * @example
  9850. * $(document).ready( function() {
  9851. * $('#example').dataTable( {
  9852. * "language": {
  9853. * "infoPostFix": "All records shown are derived from real information."
  9854. * }
  9855. * } );
  9856. * } );
  9857. */
  9858. "sInfoPostFix": "",
  9859. /**
  9860. * This decimal place operator is a little different from the other
  9861. * language options since DataTables doesn't output floating point
  9862. * numbers, so it won't ever use this for display of a number. Rather,
  9863. * what this parameter does is modify the sort methods of the table so
  9864. * that numbers which are in a format which has a character other than
  9865. * a period (`.`) as a decimal place will be sorted numerically.
  9866. *
  9867. * Note that numbers with different decimal places cannot be shown in
  9868. * the same table and still be sortable, the table must be consistent.
  9869. * However, multiple different tables on the page can use different
  9870. * decimal place characters.
  9871. * @type string
  9872. * @default
  9873. *
  9874. * @dtopt Language
  9875. * @name DataTable.defaults.language.decimal
  9876. *
  9877. * @example
  9878. * $(document).ready( function() {
  9879. * $('#example').dataTable( {
  9880. * "language": {
  9881. * "decimal": ","
  9882. * "thousands": "."
  9883. * }
  9884. * } );
  9885. * } );
  9886. */
  9887. "sDecimal": "",
  9888. /**
  9889. * DataTables has a build in number formatter (`formatNumber`) which is
  9890. * used to format large numbers that are used in the table information.
  9891. * By default a comma is used, but this can be trivially changed to any
  9892. * character you wish with this parameter.
  9893. * @type string
  9894. * @default ,
  9895. *
  9896. * @dtopt Language
  9897. * @name DataTable.defaults.language.thousands
  9898. *
  9899. * @example
  9900. * $(document).ready( function() {
  9901. * $('#example').dataTable( {
  9902. * "language": {
  9903. * "thousands": "'"
  9904. * }
  9905. * } );
  9906. * } );
  9907. */
  9908. "sThousands": ",",
  9909. /**
  9910. * Detail the action that will be taken when the drop down menu for the
  9911. * pagination length option is changed. The '_MENU_' variable is replaced
  9912. * with a default select list of 10, 25, 50 and 100, and can be replaced
  9913. * with a custom select box if required.
  9914. * @type string
  9915. * @default Show _MENU_ entries
  9916. *
  9917. * @dtopt Language
  9918. * @name DataTable.defaults.language.lengthMenu
  9919. *
  9920. * @example
  9921. * // Language change only
  9922. * $(document).ready( function() {
  9923. * $('#example').dataTable( {
  9924. * "language": {
  9925. * "lengthMenu": "Display _MENU_ records"
  9926. * }
  9927. * } );
  9928. * } );
  9929. *
  9930. * @example
  9931. * // Language and options change
  9932. * $(document).ready( function() {
  9933. * $('#example').dataTable( {
  9934. * "language": {
  9935. * "lengthMenu": 'Display <select>'+
  9936. * '<option value="10">10</option>'+
  9937. * '<option value="20">20</option>'+
  9938. * '<option value="30">30</option>'+
  9939. * '<option value="40">40</option>'+
  9940. * '<option value="50">50</option>'+
  9941. * '<option value="-1">All</option>'+
  9942. * '</select> records'
  9943. * }
  9944. * } );
  9945. * } );
  9946. */
  9947. "sLengthMenu": "Show _MENU_ entries",
  9948. /**
  9949. * When using Ajax sourced data and during the first draw when DataTables is
  9950. * gathering the data, this message is shown in an empty row in the table to
  9951. * indicate to the end user the the data is being loaded. Note that this
  9952. * parameter is not used when loading data by server-side processing, just
  9953. * Ajax sourced data with client-side processing.
  9954. * @type string
  9955. * @default Loading...
  9956. *
  9957. * @dtopt Language
  9958. * @name DataTable.defaults.language.loadingRecords
  9959. *
  9960. * @example
  9961. * $(document).ready( function() {
  9962. * $('#example').dataTable( {
  9963. * "language": {
  9964. * "loadingRecords": "Please wait - loading..."
  9965. * }
  9966. * } );
  9967. * } );
  9968. */
  9969. "sLoadingRecords": "Loading...",
  9970. /**
  9971. * Text which is displayed when the table is processing a user action
  9972. * (usually a sort command or similar).
  9973. * @type string
  9974. * @default Processing...
  9975. *
  9976. * @dtopt Language
  9977. * @name DataTable.defaults.language.processing
  9978. *
  9979. * @example
  9980. * $(document).ready( function() {
  9981. * $('#example').dataTable( {
  9982. * "language": {
  9983. * "processing": "DataTables is currently busy"
  9984. * }
  9985. * } );
  9986. * } );
  9987. */
  9988. "sProcessing": "Processing...",
  9989. /**
  9990. * Details the actions that will be taken when the user types into the
  9991. * filtering input text box. The variable "_INPUT_", if used in the string,
  9992. * is replaced with the HTML text box for the filtering input allowing
  9993. * control over where it appears in the string. If "_INPUT_" is not given
  9994. * then the input box is appended to the string automatically.
  9995. * @type string
  9996. * @default Search:
  9997. *
  9998. * @dtopt Language
  9999. * @name DataTable.defaults.language.search
  10000. *
  10001. * @example
  10002. * // Input text box will be appended at the end automatically
  10003. * $(document).ready( function() {
  10004. * $('#example').dataTable( {
  10005. * "language": {
  10006. * "search": "Filter records:"
  10007. * }
  10008. * } );
  10009. * } );
  10010. *
  10011. * @example
  10012. * // Specify where the filter should appear
  10013. * $(document).ready( function() {
  10014. * $('#example').dataTable( {
  10015. * "language": {
  10016. * "search": "Apply filter _INPUT_ to table"
  10017. * }
  10018. * } );
  10019. * } );
  10020. */
  10021. "sSearch": "Search:",
  10022. /**
  10023. * Assign a `placeholder` attribute to the search `input` element
  10024. * @type string
  10025. * @default
  10026. *
  10027. * @dtopt Language
  10028. * @name DataTable.defaults.language.searchPlaceholder
  10029. */
  10030. "sSearchPlaceholder": "",
  10031. /**
  10032. * All of the language information can be stored in a file on the
  10033. * server-side, which DataTables will look up if this parameter is passed.
  10034. * It must store the URL of the language file, which is in a JSON format,
  10035. * and the object has the same properties as the oLanguage object in the
  10036. * initialiser object (i.e. the above parameters). Please refer to one of
  10037. * the example language files to see how this works in action.
  10038. * @type string
  10039. * @default <i>Empty string - i.e. disabled</i>
  10040. *
  10041. * @dtopt Language
  10042. * @name DataTable.defaults.language.url
  10043. *
  10044. * @example
  10045. * $(document).ready( function() {
  10046. * $('#example').dataTable( {
  10047. * "language": {
  10048. * "url": "http://www.sprymedia.co.uk/dataTables/lang.txt"
  10049. * }
  10050. * } );
  10051. * } );
  10052. */
  10053. "sUrl": "",
  10054. /**
  10055. * Text shown inside the table records when the is no information to be
  10056. * displayed after filtering. `emptyTable` is shown when there is simply no
  10057. * information in the table at all (regardless of filtering).
  10058. * @type string
  10059. * @default No matching records found
  10060. *
  10061. * @dtopt Language
  10062. * @name DataTable.defaults.language.zeroRecords
  10063. *
  10064. * @example
  10065. * $(document).ready( function() {
  10066. * $('#example').dataTable( {
  10067. * "language": {
  10068. * "zeroRecords": "No records to display"
  10069. * }
  10070. * } );
  10071. * } );
  10072. */
  10073. "sZeroRecords": "No matching records found"
  10074. },
  10075. /**
  10076. * This parameter allows you to have define the global filtering state at
  10077. * initialisation time. As an object the `search` parameter must be
  10078. * defined, but all other parameters are optional. When `regex` is true,
  10079. * the search string will be treated as a regular expression, when false
  10080. * (default) it will be treated as a straight string. When `smart`
  10081. * DataTables will use it's smart filtering methods (to word match at
  10082. * any point in the data), when false this will not be done.
  10083. * @namespace
  10084. * @extends DataTable.models.oSearch
  10085. *
  10086. * @dtopt Options
  10087. * @name DataTable.defaults.search
  10088. *
  10089. * @example
  10090. * $(document).ready( function() {
  10091. * $('#example').dataTable( {
  10092. * "search": {"search": "Initial search"}
  10093. * } );
  10094. * } )
  10095. */
  10096. "oSearch": $.extend( {}, DataTable.models.oSearch ),
  10097. /**
  10098. * __Deprecated__ The functionality provided by this parameter has now been
  10099. * superseded by that provided through `ajax`, which should be used instead.
  10100. *
  10101. * By default DataTables will look for the property `data` (or `aaData` for
  10102. * compatibility with DataTables 1.9-) when obtaining data from an Ajax
  10103. * source or for server-side processing - this parameter allows that
  10104. * property to be changed. You can use Javascript dotted object notation to
  10105. * get a data source for multiple levels of nesting.
  10106. * @type string
  10107. * @default data
  10108. *
  10109. * @dtopt Options
  10110. * @dtopt Server-side
  10111. * @name DataTable.defaults.ajaxDataProp
  10112. *
  10113. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10114. */
  10115. "sAjaxDataProp": "data",
  10116. /**
  10117. * __Deprecated__ The functionality provided by this parameter has now been
  10118. * superseded by that provided through `ajax`, which should be used instead.
  10119. *
  10120. * You can instruct DataTables to load data from an external
  10121. * source using this parameter (use aData if you want to pass data in you
  10122. * already have). Simply provide a url a JSON object can be obtained from.
  10123. * @type string
  10124. * @default null
  10125. *
  10126. * @dtopt Options
  10127. * @dtopt Server-side
  10128. * @name DataTable.defaults.ajaxSource
  10129. *
  10130. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10131. */
  10132. "sAjaxSource": null,
  10133. /**
  10134. * This initialisation variable allows you to specify exactly where in the
  10135. * DOM you want DataTables to inject the various controls it adds to the page
  10136. * (for example you might want the pagination controls at the top of the
  10137. * table). DIV elements (with or without a custom class) can also be added to
  10138. * aid styling. The follow syntax is used:
  10139. * <ul>
  10140. * <li>The following options are allowed:
  10141. * <ul>
  10142. * <li>'l' - Length changing</li>
  10143. * <li>'f' - Filtering input</li>
  10144. * <li>'t' - The table!</li>
  10145. * <li>'i' - Information</li>
  10146. * <li>'p' - Pagination</li>
  10147. * <li>'r' - pRocessing</li>
  10148. * </ul>
  10149. * </li>
  10150. * <li>The following constants are allowed:
  10151. * <ul>
  10152. * <li>'H' - jQueryUI theme "header" classes ('fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix')</li>
  10153. * <li>'F' - jQueryUI theme "footer" classes ('fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix')</li>
  10154. * </ul>
  10155. * </li>
  10156. * <li>The following syntax is expected:
  10157. * <ul>
  10158. * <li>'&lt;' and '&gt;' - div elements</li>
  10159. * <li>'&lt;"class" and '&gt;' - div with a class</li>
  10160. * <li>'&lt;"#id" and '&gt;' - div with an ID</li>
  10161. * </ul>
  10162. * </li>
  10163. * <li>Examples:
  10164. * <ul>
  10165. * <li>'&lt;"wrapper"flipt&gt;'</li>
  10166. * <li>'&lt;lf&lt;t&gt;ip&gt;'</li>
  10167. * </ul>
  10168. * </li>
  10169. * </ul>
  10170. * @type string
  10171. * @default lfrtip <i>(when `jQueryUI` is false)</i> <b>or</b>
  10172. * <"H"lfr>t<"F"ip> <i>(when `jQueryUI` is true)</i>
  10173. *
  10174. * @dtopt Options
  10175. * @name DataTable.defaults.dom
  10176. *
  10177. * @example
  10178. * $(document).ready( function() {
  10179. * $('#example').dataTable( {
  10180. * "dom": '&lt;"top"i&gt;rt&lt;"bottom"flp&gt;&lt;"clear"&gt;'
  10181. * } );
  10182. * } );
  10183. */
  10184. "sDom": "lfrtip",
  10185. /**
  10186. * Search delay option. This will throttle full table searches that use the
  10187. * DataTables provided search input element (it does not effect calls to
  10188. * `dt-api search()`, providing a delay before the search is made.
  10189. * @type integer
  10190. * @default 0
  10191. *
  10192. * @dtopt Options
  10193. * @name DataTable.defaults.searchDelay
  10194. *
  10195. * @example
  10196. * $(document).ready( function() {
  10197. * $('#example').dataTable( {
  10198. * "searchDelay": 200
  10199. * } );
  10200. * } )
  10201. */
  10202. "searchDelay": null,
  10203. /**
  10204. * DataTables features four different built-in options for the buttons to
  10205. * display for pagination control:
  10206. *
  10207. * * `simple` - 'Previous' and 'Next' buttons only
  10208. * * 'simple_numbers` - 'Previous' and 'Next' buttons, plus page numbers
  10209. * * `full` - 'First', 'Previous', 'Next' and 'Last' buttons
  10210. * * `full_numbers` - 'First', 'Previous', 'Next' and 'Last' buttons, plus
  10211. * page numbers
  10212. *
  10213. * Further methods can be added using {@link DataTable.ext.oPagination}.
  10214. * @type string
  10215. * @default simple_numbers
  10216. *
  10217. * @dtopt Options
  10218. * @name DataTable.defaults.pagingType
  10219. *
  10220. * @example
  10221. * $(document).ready( function() {
  10222. * $('#example').dataTable( {
  10223. * "pagingType": "full_numbers"
  10224. * } );
  10225. * } )
  10226. */
  10227. "sPaginationType": "simple_numbers",
  10228. /**
  10229. * Enable horizontal scrolling. When a table is too wide to fit into a
  10230. * certain layout, or you have a large number of columns in the table, you
  10231. * can enable x-scrolling to show the table in a viewport, which can be
  10232. * scrolled. This property can be `true` which will allow the table to
  10233. * scroll horizontally when needed, or any CSS unit, or a number (in which
  10234. * case it will be treated as a pixel measurement). Setting as simply `true`
  10235. * is recommended.
  10236. * @type boolean|string
  10237. * @default <i>blank string - i.e. disabled</i>
  10238. *
  10239. * @dtopt Features
  10240. * @name DataTable.defaults.scrollX
  10241. *
  10242. * @example
  10243. * $(document).ready( function() {
  10244. * $('#example').dataTable( {
  10245. * "scrollX": true,
  10246. * "scrollCollapse": true
  10247. * } );
  10248. * } );
  10249. */
  10250. "sScrollX": "",
  10251. /**
  10252. * This property can be used to force a DataTable to use more width than it
  10253. * might otherwise do when x-scrolling is enabled. For example if you have a
  10254. * table which requires to be well spaced, this parameter is useful for
  10255. * "over-sizing" the table, and thus forcing scrolling. This property can by
  10256. * any CSS unit, or a number (in which case it will be treated as a pixel
  10257. * measurement).
  10258. * @type string
  10259. * @default <i>blank string - i.e. disabled</i>
  10260. *
  10261. * @dtopt Options
  10262. * @name DataTable.defaults.scrollXInner
  10263. *
  10264. * @example
  10265. * $(document).ready( function() {
  10266. * $('#example').dataTable( {
  10267. * "scrollX": "100%",
  10268. * "scrollXInner": "110%"
  10269. * } );
  10270. * } );
  10271. */
  10272. "sScrollXInner": "",
  10273. /**
  10274. * Enable vertical scrolling. Vertical scrolling will constrain the DataTable
  10275. * to the given height, and enable scrolling for any data which overflows the
  10276. * current viewport. This can be used as an alternative to paging to display
  10277. * a lot of data in a small area (although paging and scrolling can both be
  10278. * enabled at the same time). This property can be any CSS unit, or a number
  10279. * (in which case it will be treated as a pixel measurement).
  10280. * @type string
  10281. * @default <i>blank string - i.e. disabled</i>
  10282. *
  10283. * @dtopt Features
  10284. * @name DataTable.defaults.scrollY
  10285. *
  10286. * @example
  10287. * $(document).ready( function() {
  10288. * $('#example').dataTable( {
  10289. * "scrollY": "200px",
  10290. * "paginate": false
  10291. * } );
  10292. * } );
  10293. */
  10294. "sScrollY": "",
  10295. /**
  10296. * __Deprecated__ The functionality provided by this parameter has now been
  10297. * superseded by that provided through `ajax`, which should be used instead.
  10298. *
  10299. * Set the HTTP method that is used to make the Ajax call for server-side
  10300. * processing or Ajax sourced data.
  10301. * @type string
  10302. * @default GET
  10303. *
  10304. * @dtopt Options
  10305. * @dtopt Server-side
  10306. * @name DataTable.defaults.serverMethod
  10307. *
  10308. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10309. */
  10310. "sServerMethod": "GET",
  10311. /**
  10312. * DataTables makes use of renderers when displaying HTML elements for
  10313. * a table. These renderers can be added or modified by plug-ins to
  10314. * generate suitable mark-up for a site. For example the Bootstrap
  10315. * integration plug-in for DataTables uses a paging button renderer to
  10316. * display pagination buttons in the mark-up required by Bootstrap.
  10317. *
  10318. * For further information about the renderers available see
  10319. * DataTable.ext.renderer
  10320. * @type string|object
  10321. * @default null
  10322. *
  10323. * @name DataTable.defaults.renderer
  10324. *
  10325. */
  10326. "renderer": null,
  10327. /**
  10328. * Set the data property name that DataTables should use to get a row's id
  10329. * to set as the `id` property in the node.
  10330. * @type string
  10331. * @default DT_RowId
  10332. *
  10333. * @name DataTable.defaults.rowId
  10334. */
  10335. "rowId": "DT_RowId"
  10336. };
  10337. _fnHungarianMap( DataTable.defaults );
  10338. /*
  10339. * Developer note - See note in model.defaults.js about the use of Hungarian
  10340. * notation and camel case.
  10341. */
  10342. /**
  10343. * Column options that can be given to DataTables at initialisation time.
  10344. * @namespace
  10345. */
  10346. DataTable.defaults.column = {
  10347. /**
  10348. * Define which column(s) an order will occur on for this column. This
  10349. * allows a column's ordering to take multiple columns into account when
  10350. * doing a sort or use the data from a different column. For example first
  10351. * name / last name columns make sense to do a multi-column sort over the
  10352. * two columns.
  10353. * @type array|int
  10354. * @default null <i>Takes the value of the column index automatically</i>
  10355. *
  10356. * @name DataTable.defaults.column.orderData
  10357. * @dtopt Columns
  10358. *
  10359. * @example
  10360. * // Using `columnDefs`
  10361. * $(document).ready( function() {
  10362. * $('#example').dataTable( {
  10363. * "columnDefs": [
  10364. * { "orderData": [ 0, 1 ], "targets": [ 0 ] },
  10365. * { "orderData": [ 1, 0 ], "targets": [ 1 ] },
  10366. * { "orderData": 2, "targets": [ 2 ] }
  10367. * ]
  10368. * } );
  10369. * } );
  10370. *
  10371. * @example
  10372. * // Using `columns`
  10373. * $(document).ready( function() {
  10374. * $('#example').dataTable( {
  10375. * "columns": [
  10376. * { "orderData": [ 0, 1 ] },
  10377. * { "orderData": [ 1, 0 ] },
  10378. * { "orderData": 2 },
  10379. * null,
  10380. * null
  10381. * ]
  10382. * } );
  10383. * } );
  10384. */
  10385. "aDataSort": null,
  10386. "iDataSort": -1,
  10387. /**
  10388. * You can control the default ordering direction, and even alter the
  10389. * behaviour of the sort handler (i.e. only allow ascending ordering etc)
  10390. * using this parameter.
  10391. * @type array
  10392. * @default [ 'asc', 'desc' ]
  10393. *
  10394. * @name DataTable.defaults.column.orderSequence
  10395. * @dtopt Columns
  10396. *
  10397. * @example
  10398. * // Using `columnDefs`
  10399. * $(document).ready( function() {
  10400. * $('#example').dataTable( {
  10401. * "columnDefs": [
  10402. * { "orderSequence": [ "asc" ], "targets": [ 1 ] },
  10403. * { "orderSequence": [ "desc", "asc", "asc" ], "targets": [ 2 ] },
  10404. * { "orderSequence": [ "desc" ], "targets": [ 3 ] }
  10405. * ]
  10406. * } );
  10407. * } );
  10408. *
  10409. * @example
  10410. * // Using `columns`
  10411. * $(document).ready( function() {
  10412. * $('#example').dataTable( {
  10413. * "columns": [
  10414. * null,
  10415. * { "orderSequence": [ "asc" ] },
  10416. * { "orderSequence": [ "desc", "asc", "asc" ] },
  10417. * { "orderSequence": [ "desc" ] },
  10418. * null
  10419. * ]
  10420. * } );
  10421. * } );
  10422. */
  10423. "asSorting": [ 'asc', 'desc' ],
  10424. /**
  10425. * Enable or disable filtering on the data in this column.
  10426. * @type boolean
  10427. * @default true
  10428. *
  10429. * @name DataTable.defaults.column.searchable
  10430. * @dtopt Columns
  10431. *
  10432. * @example
  10433. * // Using `columnDefs`
  10434. * $(document).ready( function() {
  10435. * $('#example').dataTable( {
  10436. * "columnDefs": [
  10437. * { "searchable": false, "targets": [ 0 ] }
  10438. * ] } );
  10439. * } );
  10440. *
  10441. * @example
  10442. * // Using `columns`
  10443. * $(document).ready( function() {
  10444. * $('#example').dataTable( {
  10445. * "columns": [
  10446. * { "searchable": false },
  10447. * null,
  10448. * null,
  10449. * null,
  10450. * null
  10451. * ] } );
  10452. * } );
  10453. */
  10454. "bSearchable": true,
  10455. /**
  10456. * Enable or disable ordering on this column.
  10457. * @type boolean
  10458. * @default true
  10459. *
  10460. * @name DataTable.defaults.column.orderable
  10461. * @dtopt Columns
  10462. *
  10463. * @example
  10464. * // Using `columnDefs`
  10465. * $(document).ready( function() {
  10466. * $('#example').dataTable( {
  10467. * "columnDefs": [
  10468. * { "orderable": false, "targets": [ 0 ] }
  10469. * ] } );
  10470. * } );
  10471. *
  10472. * @example
  10473. * // Using `columns`
  10474. * $(document).ready( function() {
  10475. * $('#example').dataTable( {
  10476. * "columns": [
  10477. * { "orderable": false },
  10478. * null,
  10479. * null,
  10480. * null,
  10481. * null
  10482. * ] } );
  10483. * } );
  10484. */
  10485. "bSortable": true,
  10486. /**
  10487. * Enable or disable the display of this column.
  10488. * @type boolean
  10489. * @default true
  10490. *
  10491. * @name DataTable.defaults.column.visible
  10492. * @dtopt Columns
  10493. *
  10494. * @example
  10495. * // Using `columnDefs`
  10496. * $(document).ready( function() {
  10497. * $('#example').dataTable( {
  10498. * "columnDefs": [
  10499. * { "visible": false, "targets": [ 0 ] }
  10500. * ] } );
  10501. * } );
  10502. *
  10503. * @example
  10504. * // Using `columns`
  10505. * $(document).ready( function() {
  10506. * $('#example').dataTable( {
  10507. * "columns": [
  10508. * { "visible": false },
  10509. * null,
  10510. * null,
  10511. * null,
  10512. * null
  10513. * ] } );
  10514. * } );
  10515. */
  10516. "bVisible": true,
  10517. /**
  10518. * Developer definable function that is called whenever a cell is created (Ajax source,
  10519. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  10520. * allowing you to modify the DOM element (add background colour for example) when the
  10521. * element is available.
  10522. * @type function
  10523. * @param {element} td The TD node that has been created
  10524. * @param {*} cellData The Data for the cell
  10525. * @param {array|object} rowData The data for the whole row
  10526. * @param {int} row The row index for the aoData data store
  10527. * @param {int} col The column index for aoColumns
  10528. *
  10529. * @name DataTable.defaults.column.createdCell
  10530. * @dtopt Columns
  10531. *
  10532. * @example
  10533. * $(document).ready( function() {
  10534. * $('#example').dataTable( {
  10535. * "columnDefs": [ {
  10536. * "targets": [3],
  10537. * "createdCell": function (td, cellData, rowData, row, col) {
  10538. * if ( cellData == "1.7" ) {
  10539. * $(td).css('color', 'blue')
  10540. * }
  10541. * }
  10542. * } ]
  10543. * });
  10544. * } );
  10545. */
  10546. "fnCreatedCell": null,
  10547. /**
  10548. * This parameter has been replaced by `data` in DataTables to ensure naming
  10549. * consistency. `dataProp` can still be used, as there is backwards
  10550. * compatibility in DataTables for this option, but it is strongly
  10551. * recommended that you use `data` in preference to `dataProp`.
  10552. * @name DataTable.defaults.column.dataProp
  10553. */
  10554. /**
  10555. * This property can be used to read data from any data source property,
  10556. * including deeply nested objects / properties. `data` can be given in a
  10557. * number of different ways which effect its behaviour:
  10558. *
  10559. * * `integer` - treated as an array index for the data source. This is the
  10560. * default that DataTables uses (incrementally increased for each column).
  10561. * * `string` - read an object property from the data source. There are
  10562. * three 'special' options that can be used in the string to alter how
  10563. * DataTables reads the data from the source object:
  10564. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10565. * Javascript to read from nested objects, so to can the options
  10566. * specified in `data`. For example: `browser.version` or
  10567. * `browser.name`. If your object parameter name contains a period, use
  10568. * `\\` to escape it - i.e. `first\\.name`.
  10569. * * `[]` - Array notation. DataTables can automatically combine data
  10570. * from and array source, joining the data with the characters provided
  10571. * between the two brackets. For example: `name[, ]` would provide a
  10572. * comma-space separated list from the source array. If no characters
  10573. * are provided between the brackets, the original array source is
  10574. * returned.
  10575. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10576. * execute a function of the name given. For example: `browser()` for a
  10577. * simple function on the data source, `browser.version()` for a
  10578. * function in a nested property or even `browser().version` to get an
  10579. * object property if the function called returns an object. Note that
  10580. * function notation is recommended for use in `render` rather than
  10581. * `data` as it is much simpler to use as a renderer.
  10582. * * `null` - use the original data source for the row rather than plucking
  10583. * data directly from it. This action has effects on two other
  10584. * initialisation options:
  10585. * * `defaultContent` - When null is given as the `data` option and
  10586. * `defaultContent` is specified for the column, the value defined by
  10587. * `defaultContent` will be used for the cell.
  10588. * * `render` - When null is used for the `data` option and the `render`
  10589. * option is specified for the column, the whole data source for the
  10590. * row is used for the renderer.
  10591. * * `function` - the function given will be executed whenever DataTables
  10592. * needs to set or get the data for a cell in the column. The function
  10593. * takes three parameters:
  10594. * * Parameters:
  10595. * * `{array|object}` The data source for the row
  10596. * * `{string}` The type call data requested - this will be 'set' when
  10597. * setting data or 'filter', 'display', 'type', 'sort' or undefined
  10598. * when gathering data. Note that when `undefined` is given for the
  10599. * type DataTables expects to get the raw data for the object back<
  10600. * * `{*}` Data to set when the second parameter is 'set'.
  10601. * * Return:
  10602. * * The return value from the function is not required when 'set' is
  10603. * the type of call, but otherwise the return is what will be used
  10604. * for the data requested.
  10605. *
  10606. * Note that `data` is a getter and setter option. If you just require
  10607. * formatting of data for output, you will likely want to use `render` which
  10608. * is simply a getter and thus simpler to use.
  10609. *
  10610. * Note that prior to DataTables 1.9.2 `data` was called `mDataProp`. The
  10611. * name change reflects the flexibility of this property and is consistent
  10612. * with the naming of mRender. If 'mDataProp' is given, then it will still
  10613. * be used by DataTables, as it automatically maps the old name to the new
  10614. * if required.
  10615. *
  10616. * @type string|int|function|null
  10617. * @default null <i>Use automatically calculated column index</i>
  10618. *
  10619. * @name DataTable.defaults.column.data
  10620. * @dtopt Columns
  10621. *
  10622. * @example
  10623. * // Read table data from objects
  10624. * // JSON structure for each row:
  10625. * // {
  10626. * // "engine": {value},
  10627. * // "browser": {value},
  10628. * // "platform": {value},
  10629. * // "version": {value},
  10630. * // "grade": {value}
  10631. * // }
  10632. * $(document).ready( function() {
  10633. * $('#example').dataTable( {
  10634. * "ajaxSource": "sources/objects.txt",
  10635. * "columns": [
  10636. * { "data": "engine" },
  10637. * { "data": "browser" },
  10638. * { "data": "platform" },
  10639. * { "data": "version" },
  10640. * { "data": "grade" }
  10641. * ]
  10642. * } );
  10643. * } );
  10644. *
  10645. * @example
  10646. * // Read information from deeply nested objects
  10647. * // JSON structure for each row:
  10648. * // {
  10649. * // "engine": {value},
  10650. * // "browser": {value},
  10651. * // "platform": {
  10652. * // "inner": {value}
  10653. * // },
  10654. * // "details": [
  10655. * // {value}, {value}
  10656. * // ]
  10657. * // }
  10658. * $(document).ready( function() {
  10659. * $('#example').dataTable( {
  10660. * "ajaxSource": "sources/deep.txt",
  10661. * "columns": [
  10662. * { "data": "engine" },
  10663. * { "data": "browser" },
  10664. * { "data": "platform.inner" },
  10665. * { "data": "platform.details.0" },
  10666. * { "data": "platform.details.1" }
  10667. * ]
  10668. * } );
  10669. * } );
  10670. *
  10671. * @example
  10672. * // Using `data` as a function to provide different information for
  10673. * // sorting, filtering and display. In this case, currency (price)
  10674. * $(document).ready( function() {
  10675. * $('#example').dataTable( {
  10676. * "columnDefs": [ {
  10677. * "targets": [ 0 ],
  10678. * "data": function ( source, type, val ) {
  10679. * if (type === 'set') {
  10680. * source.price = val;
  10681. * // Store the computed dislay and filter values for efficiency
  10682. * source.price_display = val=="" ? "" : "$"+numberFormat(val);
  10683. * source.price_filter = val=="" ? "" : "$"+numberFormat(val)+" "+val;
  10684. * return;
  10685. * }
  10686. * else if (type === 'display') {
  10687. * return source.price_display;
  10688. * }
  10689. * else if (type === 'filter') {
  10690. * return source.price_filter;
  10691. * }
  10692. * // 'sort', 'type' and undefined all just use the integer
  10693. * return source.price;
  10694. * }
  10695. * } ]
  10696. * } );
  10697. * } );
  10698. *
  10699. * @example
  10700. * // Using default content
  10701. * $(document).ready( function() {
  10702. * $('#example').dataTable( {
  10703. * "columnDefs": [ {
  10704. * "targets": [ 0 ],
  10705. * "data": null,
  10706. * "defaultContent": "Click to edit"
  10707. * } ]
  10708. * } );
  10709. * } );
  10710. *
  10711. * @example
  10712. * // Using array notation - outputting a list from an array
  10713. * $(document).ready( function() {
  10714. * $('#example').dataTable( {
  10715. * "columnDefs": [ {
  10716. * "targets": [ 0 ],
  10717. * "data": "name[, ]"
  10718. * } ]
  10719. * } );
  10720. * } );
  10721. *
  10722. */
  10723. "mData": null,
  10724. /**
  10725. * This property is the rendering partner to `data` and it is suggested that
  10726. * when you want to manipulate data for display (including filtering,
  10727. * sorting etc) without altering the underlying data for the table, use this
  10728. * property. `render` can be considered to be the the read only companion to
  10729. * `data` which is read / write (then as such more complex). Like `data`
  10730. * this option can be given in a number of different ways to effect its
  10731. * behaviour:
  10732. *
  10733. * * `integer` - treated as an array index for the data source. This is the
  10734. * default that DataTables uses (incrementally increased for each column).
  10735. * * `string` - read an object property from the data source. There are
  10736. * three 'special' options that can be used in the string to alter how
  10737. * DataTables reads the data from the source object:
  10738. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10739. * Javascript to read from nested objects, so to can the options
  10740. * specified in `data`. For example: `browser.version` or
  10741. * `browser.name`. If your object parameter name contains a period, use
  10742. * `\\` to escape it - i.e. `first\\.name`.
  10743. * * `[]` - Array notation. DataTables can automatically combine data
  10744. * from and array source, joining the data with the characters provided
  10745. * between the two brackets. For example: `name[, ]` would provide a
  10746. * comma-space separated list from the source array. If no characters
  10747. * are provided between the brackets, the original array source is
  10748. * returned.
  10749. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10750. * execute a function of the name given. For example: `browser()` for a
  10751. * simple function on the data source, `browser.version()` for a
  10752. * function in a nested property or even `browser().version` to get an
  10753. * object property if the function called returns an object.
  10754. * * `object` - use different data for the different data types requested by
  10755. * DataTables ('filter', 'display', 'type' or 'sort'). The property names
  10756. * of the object is the data type the property refers to and the value can
  10757. * defined using an integer, string or function using the same rules as
  10758. * `render` normally does. Note that an `_` option _must_ be specified.
  10759. * This is the default value to use if you haven't specified a value for
  10760. * the data type requested by DataTables.
  10761. * * `function` - the function given will be executed whenever DataTables
  10762. * needs to set or get the data for a cell in the column. The function
  10763. * takes three parameters:
  10764. * * Parameters:
  10765. * * {array|object} The data source for the row (based on `data`)
  10766. * * {string} The type call data requested - this will be 'filter',
  10767. * 'display', 'type' or 'sort'.
  10768. * * {array|object} The full data source for the row (not based on
  10769. * `data`)
  10770. * * Return:
  10771. * * The return value from the function is what will be used for the
  10772. * data requested.
  10773. *
  10774. * @type string|int|function|object|null
  10775. * @default null Use the data source value.
  10776. *
  10777. * @name DataTable.defaults.column.render
  10778. * @dtopt Columns
  10779. *
  10780. * @example
  10781. * // Create a comma separated list from an array of objects
  10782. * $(document).ready( function() {
  10783. * $('#example').dataTable( {
  10784. * "ajaxSource": "sources/deep.txt",
  10785. * "columns": [
  10786. * { "data": "engine" },
  10787. * { "data": "browser" },
  10788. * {
  10789. * "data": "platform",
  10790. * "render": "[, ].name"
  10791. * }
  10792. * ]
  10793. * } );
  10794. * } );
  10795. *
  10796. * @example
  10797. * // Execute a function to obtain data
  10798. * $(document).ready( function() {
  10799. * $('#example').dataTable( {
  10800. * "columnDefs": [ {
  10801. * "targets": [ 0 ],
  10802. * "data": null, // Use the full data source object for the renderer's source
  10803. * "render": "browserName()"
  10804. * } ]
  10805. * } );
  10806. * } );
  10807. *
  10808. * @example
  10809. * // As an object, extracting different data for the different types
  10810. * // This would be used with a data source such as:
  10811. * // { "phone": 5552368, "phone_filter": "5552368 555-2368", "phone_display": "555-2368" }
  10812. * // Here the `phone` integer is used for sorting and type detection, while `phone_filter`
  10813. * // (which has both forms) is used for filtering for if a user inputs either format, while
  10814. * // the formatted phone number is the one that is shown in the table.
  10815. * $(document).ready( function() {
  10816. * $('#example').dataTable( {
  10817. * "columnDefs": [ {
  10818. * "targets": [ 0 ],
  10819. * "data": null, // Use the full data source object for the renderer's source
  10820. * "render": {
  10821. * "_": "phone",
  10822. * "filter": "phone_filter",
  10823. * "display": "phone_display"
  10824. * }
  10825. * } ]
  10826. * } );
  10827. * } );
  10828. *
  10829. * @example
  10830. * // Use as a function to create a link from the data source
  10831. * $(document).ready( function() {
  10832. * $('#example').dataTable( {
  10833. * "columnDefs": [ {
  10834. * "targets": [ 0 ],
  10835. * "data": "download_link",
  10836. * "render": function ( data, type, full ) {
  10837. * return '<a href="'+data+'">Download</a>';
  10838. * }
  10839. * } ]
  10840. * } );
  10841. * } );
  10842. */
  10843. "mRender": null,
  10844. /**
  10845. * Change the cell type created for the column - either TD cells or TH cells. This
  10846. * can be useful as TH cells have semantic meaning in the table body, allowing them
  10847. * to act as a header for a row (you may wish to add scope='row' to the TH elements).
  10848. * @type string
  10849. * @default td
  10850. *
  10851. * @name DataTable.defaults.column.cellType
  10852. * @dtopt Columns
  10853. *
  10854. * @example
  10855. * // Make the first column use TH cells
  10856. * $(document).ready( function() {
  10857. * $('#example').dataTable( {
  10858. * "columnDefs": [ {
  10859. * "targets": [ 0 ],
  10860. * "cellType": "th"
  10861. * } ]
  10862. * } );
  10863. * } );
  10864. */
  10865. "sCellType": "td",
  10866. /**
  10867. * Class to give to each cell in this column.
  10868. * @type string
  10869. * @default <i>Empty string</i>
  10870. *
  10871. * @name DataTable.defaults.column.class
  10872. * @dtopt Columns
  10873. *
  10874. * @example
  10875. * // Using `columnDefs`
  10876. * $(document).ready( function() {
  10877. * $('#example').dataTable( {
  10878. * "columnDefs": [
  10879. * { "class": "my_class", "targets": [ 0 ] }
  10880. * ]
  10881. * } );
  10882. * } );
  10883. *
  10884. * @example
  10885. * // Using `columns`
  10886. * $(document).ready( function() {
  10887. * $('#example').dataTable( {
  10888. * "columns": [
  10889. * { "class": "my_class" },
  10890. * null,
  10891. * null,
  10892. * null,
  10893. * null
  10894. * ]
  10895. * } );
  10896. * } );
  10897. */
  10898. "sClass": "",
  10899. /**
  10900. * When DataTables calculates the column widths to assign to each column,
  10901. * it finds the longest string in each column and then constructs a
  10902. * temporary table and reads the widths from that. The problem with this
  10903. * is that "mmm" is much wider then "iiii", but the latter is a longer
  10904. * string - thus the calculation can go wrong (doing it properly and putting
  10905. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  10906. * a "work around" we provide this option. It will append its value to the
  10907. * text that is found to be the longest string for the column - i.e. padding.
  10908. * Generally you shouldn't need this!
  10909. * @type string
  10910. * @default <i>Empty string<i>
  10911. *
  10912. * @name DataTable.defaults.column.contentPadding
  10913. * @dtopt Columns
  10914. *
  10915. * @example
  10916. * // Using `columns`
  10917. * $(document).ready( function() {
  10918. * $('#example').dataTable( {
  10919. * "columns": [
  10920. * null,
  10921. * null,
  10922. * null,
  10923. * {
  10924. * "contentPadding": "mmm"
  10925. * }
  10926. * ]
  10927. * } );
  10928. * } );
  10929. */
  10930. "sContentPadding": "",
  10931. /**
  10932. * Allows a default value to be given for a column's data, and will be used
  10933. * whenever a null data source is encountered (this can be because `data`
  10934. * is set to null, or because the data source itself is null).
  10935. * @type string
  10936. * @default null
  10937. *
  10938. * @name DataTable.defaults.column.defaultContent
  10939. * @dtopt Columns
  10940. *
  10941. * @example
  10942. * // Using `columnDefs`
  10943. * $(document).ready( function() {
  10944. * $('#example').dataTable( {
  10945. * "columnDefs": [
  10946. * {
  10947. * "data": null,
  10948. * "defaultContent": "Edit",
  10949. * "targets": [ -1 ]
  10950. * }
  10951. * ]
  10952. * } );
  10953. * } );
  10954. *
  10955. * @example
  10956. * // Using `columns`
  10957. * $(document).ready( function() {
  10958. * $('#example').dataTable( {
  10959. * "columns": [
  10960. * null,
  10961. * null,
  10962. * null,
  10963. * {
  10964. * "data": null,
  10965. * "defaultContent": "Edit"
  10966. * }
  10967. * ]
  10968. * } );
  10969. * } );
  10970. */
  10971. "sDefaultContent": null,
  10972. /**
  10973. * This parameter is only used in DataTables' server-side processing. It can
  10974. * be exceptionally useful to know what columns are being displayed on the
  10975. * client side, and to map these to database fields. When defined, the names
  10976. * also allow DataTables to reorder information from the server if it comes
  10977. * back in an unexpected order (i.e. if you switch your columns around on the
  10978. * client-side, your server-side code does not also need updating).
  10979. * @type string
  10980. * @default <i>Empty string</i>
  10981. *
  10982. * @name DataTable.defaults.column.name
  10983. * @dtopt Columns
  10984. *
  10985. * @example
  10986. * // Using `columnDefs`
  10987. * $(document).ready( function() {
  10988. * $('#example').dataTable( {
  10989. * "columnDefs": [
  10990. * { "name": "engine", "targets": [ 0 ] },
  10991. * { "name": "browser", "targets": [ 1 ] },
  10992. * { "name": "platform", "targets": [ 2 ] },
  10993. * { "name": "version", "targets": [ 3 ] },
  10994. * { "name": "grade", "targets": [ 4 ] }
  10995. * ]
  10996. * } );
  10997. * } );
  10998. *
  10999. * @example
  11000. * // Using `columns`
  11001. * $(document).ready( function() {
  11002. * $('#example').dataTable( {
  11003. * "columns": [
  11004. * { "name": "engine" },
  11005. * { "name": "browser" },
  11006. * { "name": "platform" },
  11007. * { "name": "version" },
  11008. * { "name": "grade" }
  11009. * ]
  11010. * } );
  11011. * } );
  11012. */
  11013. "sName": "",
  11014. /**
  11015. * Defines a data source type for the ordering which can be used to read
  11016. * real-time information from the table (updating the internally cached
  11017. * version) prior to ordering. This allows ordering to occur on user
  11018. * editable elements such as form inputs.
  11019. * @type string
  11020. * @default std
  11021. *
  11022. * @name DataTable.defaults.column.orderDataType
  11023. * @dtopt Columns
  11024. *
  11025. * @example
  11026. * // Using `columnDefs`
  11027. * $(document).ready( function() {
  11028. * $('#example').dataTable( {
  11029. * "columnDefs": [
  11030. * { "orderDataType": "dom-text", "targets": [ 2, 3 ] },
  11031. * { "type": "numeric", "targets": [ 3 ] },
  11032. * { "orderDataType": "dom-select", "targets": [ 4 ] },
  11033. * { "orderDataType": "dom-checkbox", "targets": [ 5 ] }
  11034. * ]
  11035. * } );
  11036. * } );
  11037. *
  11038. * @example
  11039. * // Using `columns`
  11040. * $(document).ready( function() {
  11041. * $('#example').dataTable( {
  11042. * "columns": [
  11043. * null,
  11044. * null,
  11045. * { "orderDataType": "dom-text" },
  11046. * { "orderDataType": "dom-text", "type": "numeric" },
  11047. * { "orderDataType": "dom-select" },
  11048. * { "orderDataType": "dom-checkbox" }
  11049. * ]
  11050. * } );
  11051. * } );
  11052. */
  11053. "sSortDataType": "std",
  11054. /**
  11055. * The title of this column.
  11056. * @type string
  11057. * @default null <i>Derived from the 'TH' value for this column in the
  11058. * original HTML table.</i>
  11059. *
  11060. * @name DataTable.defaults.column.title
  11061. * @dtopt Columns
  11062. *
  11063. * @example
  11064. * // Using `columnDefs`
  11065. * $(document).ready( function() {
  11066. * $('#example').dataTable( {
  11067. * "columnDefs": [
  11068. * { "title": "My column title", "targets": [ 0 ] }
  11069. * ]
  11070. * } );
  11071. * } );
  11072. *
  11073. * @example
  11074. * // Using `columns`
  11075. * $(document).ready( function() {
  11076. * $('#example').dataTable( {
  11077. * "columns": [
  11078. * { "title": "My column title" },
  11079. * null,
  11080. * null,
  11081. * null,
  11082. * null
  11083. * ]
  11084. * } );
  11085. * } );
  11086. */
  11087. "sTitle": null,
  11088. /**
  11089. * The type allows you to specify how the data for this column will be
  11090. * ordered. Four types (string, numeric, date and html (which will strip
  11091. * HTML tags before ordering)) are currently available. Note that only date
  11092. * formats understood by Javascript's Date() object will be accepted as type
  11093. * date. For example: "Mar 26, 2008 5:03 PM". May take the values: 'string',
  11094. * 'numeric', 'date' or 'html' (by default). Further types can be adding
  11095. * through plug-ins.
  11096. * @type string
  11097. * @default null <i>Auto-detected from raw data</i>
  11098. *
  11099. * @name DataTable.defaults.column.type
  11100. * @dtopt Columns
  11101. *
  11102. * @example
  11103. * // Using `columnDefs`
  11104. * $(document).ready( function() {
  11105. * $('#example').dataTable( {
  11106. * "columnDefs": [
  11107. * { "type": "html", "targets": [ 0 ] }
  11108. * ]
  11109. * } );
  11110. * } );
  11111. *
  11112. * @example
  11113. * // Using `columns`
  11114. * $(document).ready( function() {
  11115. * $('#example').dataTable( {
  11116. * "columns": [
  11117. * { "type": "html" },
  11118. * null,
  11119. * null,
  11120. * null,
  11121. * null
  11122. * ]
  11123. * } );
  11124. * } );
  11125. */
  11126. "sType": null,
  11127. /**
  11128. * Defining the width of the column, this parameter may take any CSS value
  11129. * (3em, 20px etc). DataTables applies 'smart' widths to columns which have not
  11130. * been given a specific width through this interface ensuring that the table
  11131. * remains readable.
  11132. * @type string
  11133. * @default null <i>Automatic</i>
  11134. *
  11135. * @name DataTable.defaults.column.width
  11136. * @dtopt Columns
  11137. *
  11138. * @example
  11139. * // Using `columnDefs`
  11140. * $(document).ready( function() {
  11141. * $('#example').dataTable( {
  11142. * "columnDefs": [
  11143. * { "width": "20%", "targets": [ 0 ] }
  11144. * ]
  11145. * } );
  11146. * } );
  11147. *
  11148. * @example
  11149. * // Using `columns`
  11150. * $(document).ready( function() {
  11151. * $('#example').dataTable( {
  11152. * "columns": [
  11153. * { "width": "20%" },
  11154. * null,
  11155. * null,
  11156. * null,
  11157. * null
  11158. * ]
  11159. * } );
  11160. * } );
  11161. */
  11162. "sWidth": null
  11163. };
  11164. _fnHungarianMap( DataTable.defaults.column );
  11165. /**
  11166. * DataTables settings object - this holds all the information needed for a
  11167. * given table, including configuration, data and current application of the
  11168. * table options. DataTables does not have a single instance for each DataTable
  11169. * with the settings attached to that instance, but rather instances of the
  11170. * DataTable "class" are created on-the-fly as needed (typically by a
  11171. * $().dataTable() call) and the settings object is then applied to that
  11172. * instance.
  11173. *
  11174. * Note that this object is related to {@link DataTable.defaults} but this
  11175. * one is the internal data store for DataTables's cache of columns. It should
  11176. * NOT be manipulated outside of DataTables. Any configuration should be done
  11177. * through the initialisation options.
  11178. * @namespace
  11179. * @todo Really should attach the settings object to individual instances so we
  11180. * don't need to create new instances on each $().dataTable() call (if the
  11181. * table already exists). It would also save passing oSettings around and
  11182. * into every single function. However, this is a very significant
  11183. * architecture change for DataTables and will almost certainly break
  11184. * backwards compatibility with older installations. This is something that
  11185. * will be done in 2.0.
  11186. */
  11187. DataTable.models.oSettings = {
  11188. /**
  11189. * Primary features of DataTables and their enablement state.
  11190. * @namespace
  11191. */
  11192. "oFeatures": {
  11193. /**
  11194. * Flag to say if DataTables should automatically try to calculate the
  11195. * optimum table and columns widths (true) or not (false).
  11196. * Note that this parameter will be set by the initialisation routine. To
  11197. * set a default use {@link DataTable.defaults}.
  11198. * @type boolean
  11199. */
  11200. "bAutoWidth": null,
  11201. /**
  11202. * Delay the creation of TR and TD elements until they are actually
  11203. * needed by a driven page draw. This can give a significant speed
  11204. * increase for Ajax source and Javascript source data, but makes no
  11205. * difference at all fro DOM and server-side processing tables.
  11206. * Note that this parameter will be set by the initialisation routine. To
  11207. * set a default use {@link DataTable.defaults}.
  11208. * @type boolean
  11209. */
  11210. "bDeferRender": null,
  11211. /**
  11212. * Enable filtering on the table or not. Note that if this is disabled
  11213. * then there is no filtering at all on the table, including fnFilter.
  11214. * To just remove the filtering input use sDom and remove the 'f' option.
  11215. * Note that this parameter will be set by the initialisation routine. To
  11216. * set a default use {@link DataTable.defaults}.
  11217. * @type boolean
  11218. */
  11219. "bFilter": null,
  11220. /**
  11221. * Table information element (the 'Showing x of y records' div) enable
  11222. * flag.
  11223. * Note that this parameter will be set by the initialisation routine. To
  11224. * set a default use {@link DataTable.defaults}.
  11225. * @type boolean
  11226. */
  11227. "bInfo": null,
  11228. /**
  11229. * Present a user control allowing the end user to change the page size
  11230. * when pagination is enabled.
  11231. * Note that this parameter will be set by the initialisation routine. To
  11232. * set a default use {@link DataTable.defaults}.
  11233. * @type boolean
  11234. */
  11235. "bLengthChange": null,
  11236. /**
  11237. * Pagination enabled or not. Note that if this is disabled then length
  11238. * changing must also be disabled.
  11239. * Note that this parameter will be set by the initialisation routine. To
  11240. * set a default use {@link DataTable.defaults}.
  11241. * @type boolean
  11242. */
  11243. "bPaginate": null,
  11244. /**
  11245. * Processing indicator enable flag whenever DataTables is enacting a
  11246. * user request - typically an Ajax request for server-side processing.
  11247. * Note that this parameter will be set by the initialisation routine. To
  11248. * set a default use {@link DataTable.defaults}.
  11249. * @type boolean
  11250. */
  11251. "bProcessing": null,
  11252. /**
  11253. * Server-side processing enabled flag - when enabled DataTables will
  11254. * get all data from the server for every draw - there is no filtering,
  11255. * sorting or paging done on the client-side.
  11256. * Note that this parameter will be set by the initialisation routine. To
  11257. * set a default use {@link DataTable.defaults}.
  11258. * @type boolean
  11259. */
  11260. "bServerSide": null,
  11261. /**
  11262. * Sorting enablement flag.
  11263. * Note that this parameter will be set by the initialisation routine. To
  11264. * set a default use {@link DataTable.defaults}.
  11265. * @type boolean
  11266. */
  11267. "bSort": null,
  11268. /**
  11269. * Multi-column sorting
  11270. * Note that this parameter will be set by the initialisation routine. To
  11271. * set a default use {@link DataTable.defaults}.
  11272. * @type boolean
  11273. */
  11274. "bSortMulti": null,
  11275. /**
  11276. * Apply a class to the columns which are being sorted to provide a
  11277. * visual highlight or not. This can slow things down when enabled since
  11278. * there is a lot of DOM interaction.
  11279. * Note that this parameter will be set by the initialisation routine. To
  11280. * set a default use {@link DataTable.defaults}.
  11281. * @type boolean
  11282. */
  11283. "bSortClasses": null,
  11284. /**
  11285. * State saving enablement flag.
  11286. * Note that this parameter will be set by the initialisation routine. To
  11287. * set a default use {@link DataTable.defaults}.
  11288. * @type boolean
  11289. */
  11290. "bStateSave": null
  11291. },
  11292. /**
  11293. * Scrolling settings for a table.
  11294. * @namespace
  11295. */
  11296. "oScroll": {
  11297. /**
  11298. * When the table is shorter in height than sScrollY, collapse the
  11299. * table container down to the height of the table (when true).
  11300. * Note that this parameter will be set by the initialisation routine. To
  11301. * set a default use {@link DataTable.defaults}.
  11302. * @type boolean
  11303. */
  11304. "bCollapse": null,
  11305. /**
  11306. * Width of the scrollbar for the web-browser's platform. Calculated
  11307. * during table initialisation.
  11308. * @type int
  11309. * @default 0
  11310. */
  11311. "iBarWidth": 0,
  11312. /**
  11313. * Viewport width for horizontal scrolling. Horizontal scrolling is
  11314. * disabled if an empty string.
  11315. * Note that this parameter will be set by the initialisation routine. To
  11316. * set a default use {@link DataTable.defaults}.
  11317. * @type string
  11318. */
  11319. "sX": null,
  11320. /**
  11321. * Width to expand the table to when using x-scrolling. Typically you
  11322. * should not need to use this.
  11323. * Note that this parameter will be set by the initialisation routine. To
  11324. * set a default use {@link DataTable.defaults}.
  11325. * @type string
  11326. * @deprecated
  11327. */
  11328. "sXInner": null,
  11329. /**
  11330. * Viewport height for vertical scrolling. Vertical scrolling is disabled
  11331. * if an empty string.
  11332. * Note that this parameter will be set by the initialisation routine. To
  11333. * set a default use {@link DataTable.defaults}.
  11334. * @type string
  11335. */
  11336. "sY": null
  11337. },
  11338. /**
  11339. * Language information for the table.
  11340. * @namespace
  11341. * @extends DataTable.defaults.oLanguage
  11342. */
  11343. "oLanguage": {
  11344. /**
  11345. * Information callback function. See
  11346. * {@link DataTable.defaults.fnInfoCallback}
  11347. * @type function
  11348. * @default null
  11349. */
  11350. "fnInfoCallback": null
  11351. },
  11352. /**
  11353. * Browser support parameters
  11354. * @namespace
  11355. */
  11356. "oBrowser": {
  11357. /**
  11358. * Indicate if the browser incorrectly calculates width:100% inside a
  11359. * scrolling element (IE6/7)
  11360. * @type boolean
  11361. * @default false
  11362. */
  11363. "bScrollOversize": false,
  11364. /**
  11365. * Determine if the vertical scrollbar is on the right or left of the
  11366. * scrolling container - needed for rtl language layout, although not
  11367. * all browsers move the scrollbar (Safari).
  11368. * @type boolean
  11369. * @default false
  11370. */
  11371. "bScrollbarLeft": false,
  11372. /**
  11373. * Flag for if `getBoundingClientRect` is fully supported or not
  11374. * @type boolean
  11375. * @default false
  11376. */
  11377. "bBounding": false,
  11378. /**
  11379. * Browser scrollbar width
  11380. * @type integer
  11381. * @default 0
  11382. */
  11383. "barWidth": 0
  11384. },
  11385. "ajax": null,
  11386. /**
  11387. * Array referencing the nodes which are used for the features. The
  11388. * parameters of this object match what is allowed by sDom - i.e.
  11389. * <ul>
  11390. * <li>'l' - Length changing</li>
  11391. * <li>'f' - Filtering input</li>
  11392. * <li>'t' - The table!</li>
  11393. * <li>'i' - Information</li>
  11394. * <li>'p' - Pagination</li>
  11395. * <li>'r' - pRocessing</li>
  11396. * </ul>
  11397. * @type array
  11398. * @default []
  11399. */
  11400. "aanFeatures": [],
  11401. /**
  11402. * Store data information - see {@link DataTable.models.oRow} for detailed
  11403. * information.
  11404. * @type array
  11405. * @default []
  11406. */
  11407. "aoData": [],
  11408. /**
  11409. * Array of indexes which are in the current display (after filtering etc)
  11410. * @type array
  11411. * @default []
  11412. */
  11413. "aiDisplay": [],
  11414. /**
  11415. * Array of indexes for display - no filtering
  11416. * @type array
  11417. * @default []
  11418. */
  11419. "aiDisplayMaster": [],
  11420. /**
  11421. * Map of row ids to data indexes
  11422. * @type object
  11423. * @default {}
  11424. */
  11425. "aIds": {},
  11426. /**
  11427. * Store information about each column that is in use
  11428. * @type array
  11429. * @default []
  11430. */
  11431. "aoColumns": [],
  11432. /**
  11433. * Store information about the table's header
  11434. * @type array
  11435. * @default []
  11436. */
  11437. "aoHeader": [],
  11438. /**
  11439. * Store information about the table's footer
  11440. * @type array
  11441. * @default []
  11442. */
  11443. "aoFooter": [],
  11444. /**
  11445. * Store the applied global search information in case we want to force a
  11446. * research or compare the old search to a new one.
  11447. * Note that this parameter will be set by the initialisation routine. To
  11448. * set a default use {@link DataTable.defaults}.
  11449. * @namespace
  11450. * @extends DataTable.models.oSearch
  11451. */
  11452. "oPreviousSearch": {},
  11453. /**
  11454. * Store the applied search for each column - see
  11455. * {@link DataTable.models.oSearch} for the format that is used for the
  11456. * filtering information for each column.
  11457. * @type array
  11458. * @default []
  11459. */
  11460. "aoPreSearchCols": [],
  11461. /**
  11462. * Sorting that is applied to the table. Note that the inner arrays are
  11463. * used in the following manner:
  11464. * <ul>
  11465. * <li>Index 0 - column number</li>
  11466. * <li>Index 1 - current sorting direction</li>
  11467. * </ul>
  11468. * Note that this parameter will be set by the initialisation routine. To
  11469. * set a default use {@link DataTable.defaults}.
  11470. * @type array
  11471. * @todo These inner arrays should really be objects
  11472. */
  11473. "aaSorting": null,
  11474. /**
  11475. * Sorting that is always applied to the table (i.e. prefixed in front of
  11476. * aaSorting).
  11477. * Note that this parameter will be set by the initialisation routine. To
  11478. * set a default use {@link DataTable.defaults}.
  11479. * @type array
  11480. * @default []
  11481. */
  11482. "aaSortingFixed": [],
  11483. /**
  11484. * Classes to use for the striping of a table.
  11485. * Note that this parameter will be set by the initialisation routine. To
  11486. * set a default use {@link DataTable.defaults}.
  11487. * @type array
  11488. * @default []
  11489. */
  11490. "asStripeClasses": null,
  11491. /**
  11492. * If restoring a table - we should restore its striping classes as well
  11493. * @type array
  11494. * @default []
  11495. */
  11496. "asDestroyStripes": [],
  11497. /**
  11498. * If restoring a table - we should restore its width
  11499. * @type int
  11500. * @default 0
  11501. */
  11502. "sDestroyWidth": 0,
  11503. /**
  11504. * Callback functions array for every time a row is inserted (i.e. on a draw).
  11505. * @type array
  11506. * @default []
  11507. */
  11508. "aoRowCallback": [],
  11509. /**
  11510. * Callback functions for the header on each draw.
  11511. * @type array
  11512. * @default []
  11513. */
  11514. "aoHeaderCallback": [],
  11515. /**
  11516. * Callback function for the footer on each draw.
  11517. * @type array
  11518. * @default []
  11519. */
  11520. "aoFooterCallback": [],
  11521. /**
  11522. * Array of callback functions for draw callback functions
  11523. * @type array
  11524. * @default []
  11525. */
  11526. "aoDrawCallback": [],
  11527. /**
  11528. * Array of callback functions for row created function
  11529. * @type array
  11530. * @default []
  11531. */
  11532. "aoRowCreatedCallback": [],
  11533. /**
  11534. * Callback functions for just before the table is redrawn. A return of
  11535. * false will be used to cancel the draw.
  11536. * @type array
  11537. * @default []
  11538. */
  11539. "aoPreDrawCallback": [],
  11540. /**
  11541. * Callback functions for when the table has been initialised.
  11542. * @type array
  11543. * @default []
  11544. */
  11545. "aoInitComplete": [],
  11546. /**
  11547. * Callbacks for modifying the settings to be stored for state saving, prior to
  11548. * saving state.
  11549. * @type array
  11550. * @default []
  11551. */
  11552. "aoStateSaveParams": [],
  11553. /**
  11554. * Callbacks for modifying the settings that have been stored for state saving
  11555. * prior to using the stored values to restore the state.
  11556. * @type array
  11557. * @default []
  11558. */
  11559. "aoStateLoadParams": [],
  11560. /**
  11561. * Callbacks for operating on the settings object once the saved state has been
  11562. * loaded
  11563. * @type array
  11564. * @default []
  11565. */
  11566. "aoStateLoaded": [],
  11567. /**
  11568. * Cache the table ID for quick access
  11569. * @type string
  11570. * @default <i>Empty string</i>
  11571. */
  11572. "sTableId": "",
  11573. /**
  11574. * The TABLE node for the main table
  11575. * @type node
  11576. * @default null
  11577. */
  11578. "nTable": null,
  11579. /**
  11580. * Permanent ref to the thead element
  11581. * @type node
  11582. * @default null
  11583. */
  11584. "nTHead": null,
  11585. /**
  11586. * Permanent ref to the tfoot element - if it exists
  11587. * @type node
  11588. * @default null
  11589. */
  11590. "nTFoot": null,
  11591. /**
  11592. * Permanent ref to the tbody element
  11593. * @type node
  11594. * @default null
  11595. */
  11596. "nTBody": null,
  11597. /**
  11598. * Cache the wrapper node (contains all DataTables controlled elements)
  11599. * @type node
  11600. * @default null
  11601. */
  11602. "nTableWrapper": null,
  11603. /**
  11604. * Indicate if when using server-side processing the loading of data
  11605. * should be deferred until the second draw.
  11606. * Note that this parameter will be set by the initialisation routine. To
  11607. * set a default use {@link DataTable.defaults}.
  11608. * @type boolean
  11609. * @default false
  11610. */
  11611. "bDeferLoading": false,
  11612. /**
  11613. * Indicate if all required information has been read in
  11614. * @type boolean
  11615. * @default false
  11616. */
  11617. "bInitialised": false,
  11618. /**
  11619. * Information about open rows. Each object in the array has the parameters
  11620. * 'nTr' and 'nParent'
  11621. * @type array
  11622. * @default []
  11623. */
  11624. "aoOpenRows": [],
  11625. /**
  11626. * Dictate the positioning of DataTables' control elements - see
  11627. * {@link DataTable.model.oInit.sDom}.
  11628. * Note that this parameter will be set by the initialisation routine. To
  11629. * set a default use {@link DataTable.defaults}.
  11630. * @type string
  11631. * @default null
  11632. */
  11633. "sDom": null,
  11634. /**
  11635. * Search delay (in mS)
  11636. * @type integer
  11637. * @default null
  11638. */
  11639. "searchDelay": null,
  11640. /**
  11641. * Which type of pagination should be used.
  11642. * Note that this parameter will be set by the initialisation routine. To
  11643. * set a default use {@link DataTable.defaults}.
  11644. * @type string
  11645. * @default two_button
  11646. */
  11647. "sPaginationType": "two_button",
  11648. /**
  11649. * The state duration (for `stateSave`) in seconds.
  11650. * Note that this parameter will be set by the initialisation routine. To
  11651. * set a default use {@link DataTable.defaults}.
  11652. * @type int
  11653. * @default 0
  11654. */
  11655. "iStateDuration": 0,
  11656. /**
  11657. * Array of callback functions for state saving. Each array element is an
  11658. * object with the following parameters:
  11659. * <ul>
  11660. * <li>function:fn - function to call. Takes two parameters, oSettings
  11661. * and the JSON string to save that has been thus far created. Returns
  11662. * a JSON string to be inserted into a json object
  11663. * (i.e. '"param": [ 0, 1, 2]')</li>
  11664. * <li>string:sName - name of callback</li>
  11665. * </ul>
  11666. * @type array
  11667. * @default []
  11668. */
  11669. "aoStateSave": [],
  11670. /**
  11671. * Array of callback functions for state loading. Each array element is an
  11672. * object with the following parameters:
  11673. * <ul>
  11674. * <li>function:fn - function to call. Takes two parameters, oSettings
  11675. * and the object stored. May return false to cancel state loading</li>
  11676. * <li>string:sName - name of callback</li>
  11677. * </ul>
  11678. * @type array
  11679. * @default []
  11680. */
  11681. "aoStateLoad": [],
  11682. /**
  11683. * State that was saved. Useful for back reference
  11684. * @type object
  11685. * @default null
  11686. */
  11687. "oSavedState": null,
  11688. /**
  11689. * State that was loaded. Useful for back reference
  11690. * @type object
  11691. * @default null
  11692. */
  11693. "oLoadedState": null,
  11694. /**
  11695. * Source url for AJAX data for the table.
  11696. * Note that this parameter will be set by the initialisation routine. To
  11697. * set a default use {@link DataTable.defaults}.
  11698. * @type string
  11699. * @default null
  11700. */
  11701. "sAjaxSource": null,
  11702. /**
  11703. * Property from a given object from which to read the table data from. This
  11704. * can be an empty string (when not server-side processing), in which case
  11705. * it is assumed an an array is given directly.
  11706. * Note that this parameter will be set by the initialisation routine. To
  11707. * set a default use {@link DataTable.defaults}.
  11708. * @type string
  11709. */
  11710. "sAjaxDataProp": null,
  11711. /**
  11712. * Note if draw should be blocked while getting data
  11713. * @type boolean
  11714. * @default true
  11715. */
  11716. "bAjaxDataGet": true,
  11717. /**
  11718. * The last jQuery XHR object that was used for server-side data gathering.
  11719. * This can be used for working with the XHR information in one of the
  11720. * callbacks
  11721. * @type object
  11722. * @default null
  11723. */
  11724. "jqXHR": null,
  11725. /**
  11726. * JSON returned from the server in the last Ajax request
  11727. * @type object
  11728. * @default undefined
  11729. */
  11730. "json": undefined,
  11731. /**
  11732. * Data submitted as part of the last Ajax request
  11733. * @type object
  11734. * @default undefined
  11735. */
  11736. "oAjaxData": undefined,
  11737. /**
  11738. * Function to get the server-side data.
  11739. * Note that this parameter will be set by the initialisation routine. To
  11740. * set a default use {@link DataTable.defaults}.
  11741. * @type function
  11742. */
  11743. "fnServerData": null,
  11744. /**
  11745. * Functions which are called prior to sending an Ajax request so extra
  11746. * parameters can easily be sent to the server
  11747. * @type array
  11748. * @default []
  11749. */
  11750. "aoServerParams": [],
  11751. /**
  11752. * Send the XHR HTTP method - GET or POST (could be PUT or DELETE if
  11753. * required).
  11754. * Note that this parameter will be set by the initialisation routine. To
  11755. * set a default use {@link DataTable.defaults}.
  11756. * @type string
  11757. */
  11758. "sServerMethod": null,
  11759. /**
  11760. * Format numbers for display.
  11761. * Note that this parameter will be set by the initialisation routine. To
  11762. * set a default use {@link DataTable.defaults}.
  11763. * @type function
  11764. */
  11765. "fnFormatNumber": null,
  11766. /**
  11767. * List of options that can be used for the user selectable length menu.
  11768. * Note that this parameter will be set by the initialisation routine. To
  11769. * set a default use {@link DataTable.defaults}.
  11770. * @type array
  11771. * @default []
  11772. */
  11773. "aLengthMenu": null,
  11774. /**
  11775. * Counter for the draws that the table does. Also used as a tracker for
  11776. * server-side processing
  11777. * @type int
  11778. * @default 0
  11779. */
  11780. "iDraw": 0,
  11781. /**
  11782. * Indicate if a redraw is being done - useful for Ajax
  11783. * @type boolean
  11784. * @default false
  11785. */
  11786. "bDrawing": false,
  11787. /**
  11788. * Draw index (iDraw) of the last error when parsing the returned data
  11789. * @type int
  11790. * @default -1
  11791. */
  11792. "iDrawError": -1,
  11793. /**
  11794. * Paging display length
  11795. * @type int
  11796. * @default 10
  11797. */
  11798. "_iDisplayLength": 10,
  11799. /**
  11800. * Paging start point - aiDisplay index
  11801. * @type int
  11802. * @default 0
  11803. */
  11804. "_iDisplayStart": 0,
  11805. /**
  11806. * Server-side processing - number of records in the result set
  11807. * (i.e. before filtering), Use fnRecordsTotal rather than
  11808. * this property to get the value of the number of records, regardless of
  11809. * the server-side processing setting.
  11810. * @type int
  11811. * @default 0
  11812. * @private
  11813. */
  11814. "_iRecordsTotal": 0,
  11815. /**
  11816. * Server-side processing - number of records in the current display set
  11817. * (i.e. after filtering). Use fnRecordsDisplay rather than
  11818. * this property to get the value of the number of records, regardless of
  11819. * the server-side processing setting.
  11820. * @type boolean
  11821. * @default 0
  11822. * @private
  11823. */
  11824. "_iRecordsDisplay": 0,
  11825. /**
  11826. * Flag to indicate if jQuery UI marking and classes should be used.
  11827. * Note that this parameter will be set by the initialisation routine. To
  11828. * set a default use {@link DataTable.defaults}.
  11829. * @type boolean
  11830. */
  11831. "bJUI": null,
  11832. /**
  11833. * The classes to use for the table
  11834. * @type object
  11835. * @default {}
  11836. */
  11837. "oClasses": {},
  11838. /**
  11839. * Flag attached to the settings object so you can check in the draw
  11840. * callback if filtering has been done in the draw. Deprecated in favour of
  11841. * events.
  11842. * @type boolean
  11843. * @default false
  11844. * @deprecated
  11845. */
  11846. "bFiltered": false,
  11847. /**
  11848. * Flag attached to the settings object so you can check in the draw
  11849. * callback if sorting has been done in the draw. Deprecated in favour of
  11850. * events.
  11851. * @type boolean
  11852. * @default false
  11853. * @deprecated
  11854. */
  11855. "bSorted": false,
  11856. /**
  11857. * Indicate that if multiple rows are in the header and there is more than
  11858. * one unique cell per column, if the top one (true) or bottom one (false)
  11859. * should be used for sorting / title by DataTables.
  11860. * Note that this parameter will be set by the initialisation routine. To
  11861. * set a default use {@link DataTable.defaults}.
  11862. * @type boolean
  11863. */
  11864. "bSortCellsTop": null,
  11865. /**
  11866. * Initialisation object that is used for the table
  11867. * @type object
  11868. * @default null
  11869. */
  11870. "oInit": null,
  11871. /**
  11872. * Destroy callback functions - for plug-ins to attach themselves to the
  11873. * destroy so they can clean up markup and events.
  11874. * @type array
  11875. * @default []
  11876. */
  11877. "aoDestroyCallback": [],
  11878. /**
  11879. * Get the number of records in the current record set, before filtering
  11880. * @type function
  11881. */
  11882. "fnRecordsTotal": function ()
  11883. {
  11884. return _fnDataSource( this ) == 'ssp' ?
  11885. this._iRecordsTotal * 1 :
  11886. this.aiDisplayMaster.length;
  11887. },
  11888. /**
  11889. * Get the number of records in the current record set, after filtering
  11890. * @type function
  11891. */
  11892. "fnRecordsDisplay": function ()
  11893. {
  11894. return _fnDataSource( this ) == 'ssp' ?
  11895. this._iRecordsDisplay * 1 :
  11896. this.aiDisplay.length;
  11897. },
  11898. /**
  11899. * Get the display end point - aiDisplay index
  11900. * @type function
  11901. */
  11902. "fnDisplayEnd": function ()
  11903. {
  11904. var
  11905. len = this._iDisplayLength,
  11906. start = this._iDisplayStart,
  11907. calc = start + len,
  11908. records = this.aiDisplay.length,
  11909. features = this.oFeatures,
  11910. paginate = features.bPaginate;
  11911. if ( features.bServerSide ) {
  11912. return paginate === false || len === -1 ?
  11913. start + records :
  11914. Math.min( start+len, this._iRecordsDisplay );
  11915. }
  11916. else {
  11917. return ! paginate || calc>records || len===-1 ?
  11918. records :
  11919. calc;
  11920. }
  11921. },
  11922. /**
  11923. * The DataTables object for this table
  11924. * @type object
  11925. * @default null
  11926. */
  11927. "oInstance": null,
  11928. /**
  11929. * Unique identifier for each instance of the DataTables object. If there
  11930. * is an ID on the table node, then it takes that value, otherwise an
  11931. * incrementing internal counter is used.
  11932. * @type string
  11933. * @default null
  11934. */
  11935. "sInstance": null,
  11936. /**
  11937. * tabindex attribute value that is added to DataTables control elements, allowing
  11938. * keyboard navigation of the table and its controls.
  11939. */
  11940. "iTabIndex": 0,
  11941. /**
  11942. * DIV container for the footer scrolling table if scrolling
  11943. */
  11944. "nScrollHead": null,
  11945. /**
  11946. * DIV container for the footer scrolling table if scrolling
  11947. */
  11948. "nScrollFoot": null,
  11949. /**
  11950. * Last applied sort
  11951. * @type array
  11952. * @default []
  11953. */
  11954. "aLastSort": [],
  11955. /**
  11956. * Stored plug-in instances
  11957. * @type object
  11958. * @default {}
  11959. */
  11960. "oPlugins": {},
  11961. /**
  11962. * Function used to get a row's id from the row's data
  11963. * @type function
  11964. * @default null
  11965. */
  11966. "rowIdFn": null,
  11967. /**
  11968. * Data location where to store a row's id
  11969. * @type string
  11970. * @default null
  11971. */
  11972. "rowId": null
  11973. };
  11974. /**
  11975. * Extension object for DataTables that is used to provide all extension
  11976. * options.
  11977. *
  11978. * Note that the `DataTable.ext` object is available through
  11979. * `jQuery.fn.dataTable.ext` where it may be accessed and manipulated. It is
  11980. * also aliased to `jQuery.fn.dataTableExt` for historic reasons.
  11981. * @namespace
  11982. * @extends DataTable.models.ext
  11983. */
  11984. /**
  11985. * DataTables extensions
  11986. *
  11987. * This namespace acts as a collection area for plug-ins that can be used to
  11988. * extend DataTables capabilities. Indeed many of the build in methods
  11989. * use this method to provide their own capabilities (sorting methods for
  11990. * example).
  11991. *
  11992. * Note that this namespace is aliased to `jQuery.fn.dataTableExt` for legacy
  11993. * reasons
  11994. *
  11995. * @namespace
  11996. */
  11997. DataTable.ext = _ext = {
  11998. /**
  11999. * Buttons. For use with the Buttons extension for DataTables. This is
  12000. * defined here so other extensions can define buttons regardless of load
  12001. * order. It is _not_ used by DataTables core.
  12002. *
  12003. * @type object
  12004. * @default {}
  12005. */
  12006. buttons: {},
  12007. /**
  12008. * Element class names
  12009. *
  12010. * @type object
  12011. * @default {}
  12012. */
  12013. classes: {},
  12014. /**
  12015. * DataTables build type (expanded by the download builder)
  12016. *
  12017. * @type string
  12018. */
  12019. builder: "-source-",
  12020. /**
  12021. * Error reporting.
  12022. *
  12023. * How should DataTables report an error. Can take the value 'alert',
  12024. * 'throw', 'none' or a function.
  12025. *
  12026. * @type string|function
  12027. * @default alert
  12028. */
  12029. errMode: "alert",
  12030. /**
  12031. * Feature plug-ins.
  12032. *
  12033. * This is an array of objects which describe the feature plug-ins that are
  12034. * available to DataTables. These feature plug-ins are then available for
  12035. * use through the `dom` initialisation option.
  12036. *
  12037. * Each feature plug-in is described by an object which must have the
  12038. * following properties:
  12039. *
  12040. * * `fnInit` - function that is used to initialise the plug-in,
  12041. * * `cFeature` - a character so the feature can be enabled by the `dom`
  12042. * instillation option. This is case sensitive.
  12043. *
  12044. * The `fnInit` function has the following input parameters:
  12045. *
  12046. * 1. `{object}` DataTables settings object: see
  12047. * {@link DataTable.models.oSettings}
  12048. *
  12049. * And the following return is expected:
  12050. *
  12051. * * {node|null} The element which contains your feature. Note that the
  12052. * return may also be void if your plug-in does not require to inject any
  12053. * DOM elements into DataTables control (`dom`) - for example this might
  12054. * be useful when developing a plug-in which allows table control via
  12055. * keyboard entry
  12056. *
  12057. * @type array
  12058. *
  12059. * @example
  12060. * $.fn.dataTable.ext.features.push( {
  12061. * "fnInit": function( oSettings ) {
  12062. * return new TableTools( { "oDTSettings": oSettings } );
  12063. * },
  12064. * "cFeature": "T"
  12065. * } );
  12066. */
  12067. feature: [],
  12068. /**
  12069. * Row searching.
  12070. *
  12071. * This method of searching is complimentary to the default type based
  12072. * searching, and a lot more comprehensive as it allows you complete control
  12073. * over the searching logic. Each element in this array is a function
  12074. * (parameters described below) that is called for every row in the table,
  12075. * and your logic decides if it should be included in the searching data set
  12076. * or not.
  12077. *
  12078. * Searching functions have the following input parameters:
  12079. *
  12080. * 1. `{object}` DataTables settings object: see
  12081. * {@link DataTable.models.oSettings}
  12082. * 2. `{array|object}` Data for the row to be processed (same as the
  12083. * original format that was passed in as the data source, or an array
  12084. * from a DOM data source
  12085. * 3. `{int}` Row index ({@link DataTable.models.oSettings.aoData}), which
  12086. * can be useful to retrieve the `TR` element if you need DOM interaction.
  12087. *
  12088. * And the following return is expected:
  12089. *
  12090. * * {boolean} Include the row in the searched result set (true) or not
  12091. * (false)
  12092. *
  12093. * Note that as with the main search ability in DataTables, technically this
  12094. * is "filtering", since it is subtractive. However, for consistency in
  12095. * naming we call it searching here.
  12096. *
  12097. * @type array
  12098. * @default []
  12099. *
  12100. * @example
  12101. * // The following example shows custom search being applied to the
  12102. * // fourth column (i.e. the data[3] index) based on two input values
  12103. * // from the end-user, matching the data in a certain range.
  12104. * $.fn.dataTable.ext.search.push(
  12105. * function( settings, data, dataIndex ) {
  12106. * var min = document.getElementById('min').value * 1;
  12107. * var max = document.getElementById('max').value * 1;
  12108. * var version = data[3] == "-" ? 0 : data[3]*1;
  12109. *
  12110. * if ( min == "" && max == "" ) {
  12111. * return true;
  12112. * }
  12113. * else if ( min == "" && version < max ) {
  12114. * return true;
  12115. * }
  12116. * else if ( min < version && "" == max ) {
  12117. * return true;
  12118. * }
  12119. * else if ( min < version && version < max ) {
  12120. * return true;
  12121. * }
  12122. * return false;
  12123. * }
  12124. * );
  12125. */
  12126. search: [],
  12127. /**
  12128. * Selector extensions
  12129. *
  12130. * The `selector` option can be used to extend the options available for the
  12131. * selector modifier options (`selector-modifier` object data type) that
  12132. * each of the three built in selector types offer (row, column and cell +
  12133. * their plural counterparts). For example the Select extension uses this
  12134. * mechanism to provide an option to select only rows, columns and cells
  12135. * that have been marked as selected by the end user (`{selected: true}`),
  12136. * which can be used in conjunction with the existing built in selector
  12137. * options.
  12138. *
  12139. * Each property is an array to which functions can be pushed. The functions
  12140. * take three attributes:
  12141. *
  12142. * * Settings object for the host table
  12143. * * Options object (`selector-modifier` object type)
  12144. * * Array of selected item indexes
  12145. *
  12146. * The return is an array of the resulting item indexes after the custom
  12147. * selector has been applied.
  12148. *
  12149. * @type object
  12150. */
  12151. selector: {
  12152. cell: [],
  12153. column: [],
  12154. row: []
  12155. },
  12156. /**
  12157. * Internal functions, exposed for used in plug-ins.
  12158. *
  12159. * Please note that you should not need to use the internal methods for
  12160. * anything other than a plug-in (and even then, try to avoid if possible).
  12161. * The internal function may change between releases.
  12162. *
  12163. * @type object
  12164. * @default {}
  12165. */
  12166. internal: {},
  12167. /**
  12168. * Legacy configuration options. Enable and disable legacy options that
  12169. * are available in DataTables.
  12170. *
  12171. * @type object
  12172. */
  12173. legacy: {
  12174. /**
  12175. * Enable / disable DataTables 1.9 compatible server-side processing
  12176. * requests
  12177. *
  12178. * @type boolean
  12179. * @default null
  12180. */
  12181. ajax: null
  12182. },
  12183. /**
  12184. * Pagination plug-in methods.
  12185. *
  12186. * Each entry in this object is a function and defines which buttons should
  12187. * be shown by the pagination rendering method that is used for the table:
  12188. * {@link DataTable.ext.renderer.pageButton}. The renderer addresses how the
  12189. * buttons are displayed in the document, while the functions here tell it
  12190. * what buttons to display. This is done by returning an array of button
  12191. * descriptions (what each button will do).
  12192. *
  12193. * Pagination types (the four built in options and any additional plug-in
  12194. * options defined here) can be used through the `paginationType`
  12195. * initialisation parameter.
  12196. *
  12197. * The functions defined take two parameters:
  12198. *
  12199. * 1. `{int} page` The current page index
  12200. * 2. `{int} pages` The number of pages in the table
  12201. *
  12202. * Each function is expected to return an array where each element of the
  12203. * array can be one of:
  12204. *
  12205. * * `first` - Jump to first page when activated
  12206. * * `last` - Jump to last page when activated
  12207. * * `previous` - Show previous page when activated
  12208. * * `next` - Show next page when activated
  12209. * * `{int}` - Show page of the index given
  12210. * * `{array}` - A nested array containing the above elements to add a
  12211. * containing 'DIV' element (might be useful for styling).
  12212. *
  12213. * Note that DataTables v1.9- used this object slightly differently whereby
  12214. * an object with two functions would be defined for each plug-in. That
  12215. * ability is still supported by DataTables 1.10+ to provide backwards
  12216. * compatibility, but this option of use is now decremented and no longer
  12217. * documented in DataTables 1.10+.
  12218. *
  12219. * @type object
  12220. * @default {}
  12221. *
  12222. * @example
  12223. * // Show previous, next and current page buttons only
  12224. * $.fn.dataTableExt.oPagination.current = function ( page, pages ) {
  12225. * return [ 'previous', page, 'next' ];
  12226. * };
  12227. */
  12228. pager: {},
  12229. renderer: {
  12230. pageButton: {},
  12231. header: {}
  12232. },
  12233. /**
  12234. * Ordering plug-ins - custom data source
  12235. *
  12236. * The extension options for ordering of data available here is complimentary
  12237. * to the default type based ordering that DataTables typically uses. It
  12238. * allows much greater control over the the data that is being used to
  12239. * order a column, but is necessarily therefore more complex.
  12240. *
  12241. * This type of ordering is useful if you want to do ordering based on data
  12242. * live from the DOM (for example the contents of an 'input' element) rather
  12243. * than just the static string that DataTables knows of.
  12244. *
  12245. * The way these plug-ins work is that you create an array of the values you
  12246. * wish to be ordering for the column in question and then return that
  12247. * array. The data in the array much be in the index order of the rows in
  12248. * the table (not the currently ordering order!). Which order data gathering
  12249. * function is run here depends on the `dt-init columns.orderDataType`
  12250. * parameter that is used for the column (if any).
  12251. *
  12252. * The functions defined take two parameters:
  12253. *
  12254. * 1. `{object}` DataTables settings object: see
  12255. * {@link DataTable.models.oSettings}
  12256. * 2. `{int}` Target column index
  12257. *
  12258. * Each function is expected to return an array:
  12259. *
  12260. * * `{array}` Data for the column to be ordering upon
  12261. *
  12262. * @type array
  12263. *
  12264. * @example
  12265. * // Ordering using `input` node values
  12266. * $.fn.dataTable.ext.order['dom-text'] = function ( settings, col )
  12267. * {
  12268. * return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
  12269. * return $('input', td).val();
  12270. * } );
  12271. * }
  12272. */
  12273. order: {},
  12274. /**
  12275. * Type based plug-ins.
  12276. *
  12277. * Each column in DataTables has a type assigned to it, either by automatic
  12278. * detection or by direct assignment using the `type` option for the column.
  12279. * The type of a column will effect how it is ordering and search (plug-ins
  12280. * can also make use of the column type if required).
  12281. *
  12282. * @namespace
  12283. */
  12284. type: {
  12285. /**
  12286. * Type detection functions.
  12287. *
  12288. * The functions defined in this object are used to automatically detect
  12289. * a column's type, making initialisation of DataTables super easy, even
  12290. * when complex data is in the table.
  12291. *
  12292. * The functions defined take two parameters:
  12293. *
  12294. * 1. `{*}` Data from the column cell to be analysed
  12295. * 2. `{settings}` DataTables settings object. This can be used to
  12296. * perform context specific type detection - for example detection
  12297. * based on language settings such as using a comma for a decimal
  12298. * place. Generally speaking the options from the settings will not
  12299. * be required
  12300. *
  12301. * Each function is expected to return:
  12302. *
  12303. * * `{string|null}` Data type detected, or null if unknown (and thus
  12304. * pass it on to the other type detection functions.
  12305. *
  12306. * @type array
  12307. *
  12308. * @example
  12309. * // Currency type detection plug-in:
  12310. * $.fn.dataTable.ext.type.detect.push(
  12311. * function ( data, settings ) {
  12312. * // Check the numeric part
  12313. * if ( ! $.isNumeric( data.substring(1) ) ) {
  12314. * return null;
  12315. * }
  12316. *
  12317. * // Check prefixed by currency
  12318. * if ( data.charAt(0) == '$' || data.charAt(0) == '&pound;' ) {
  12319. * return 'currency';
  12320. * }
  12321. * return null;
  12322. * }
  12323. * );
  12324. */
  12325. detect: [],
  12326. /**
  12327. * Type based search formatting.
  12328. *
  12329. * The type based searching functions can be used to pre-format the
  12330. * data to be search on. For example, it can be used to strip HTML
  12331. * tags or to de-format telephone numbers for numeric only searching.
  12332. *
  12333. * Note that is a search is not defined for a column of a given type,
  12334. * no search formatting will be performed.
  12335. *
  12336. * Pre-processing of searching data plug-ins - When you assign the sType
  12337. * for a column (or have it automatically detected for you by DataTables
  12338. * or a type detection plug-in), you will typically be using this for
  12339. * custom sorting, but it can also be used to provide custom searching
  12340. * by allowing you to pre-processing the data and returning the data in
  12341. * the format that should be searched upon. This is done by adding
  12342. * functions this object with a parameter name which matches the sType
  12343. * for that target column. This is the corollary of <i>afnSortData</i>
  12344. * for searching data.
  12345. *
  12346. * The functions defined take a single parameter:
  12347. *
  12348. * 1. `{*}` Data from the column cell to be prepared for searching
  12349. *
  12350. * Each function is expected to return:
  12351. *
  12352. * * `{string|null}` Formatted string that will be used for the searching.
  12353. *
  12354. * @type object
  12355. * @default {}
  12356. *
  12357. * @example
  12358. * $.fn.dataTable.ext.type.search['title-numeric'] = function ( d ) {
  12359. * return d.replace(/\n/g," ").replace( /<.*?>/g, "" );
  12360. * }
  12361. */
  12362. search: {},
  12363. /**
  12364. * Type based ordering.
  12365. *
  12366. * The column type tells DataTables what ordering to apply to the table
  12367. * when a column is sorted upon. The order for each type that is defined,
  12368. * is defined by the functions available in this object.
  12369. *
  12370. * Each ordering option can be described by three properties added to
  12371. * this object:
  12372. *
  12373. * * `{type}-pre` - Pre-formatting function
  12374. * * `{type}-asc` - Ascending order function
  12375. * * `{type}-desc` - Descending order function
  12376. *
  12377. * All three can be used together, only `{type}-pre` or only
  12378. * `{type}-asc` and `{type}-desc` together. It is generally recommended
  12379. * that only `{type}-pre` is used, as this provides the optimal
  12380. * implementation in terms of speed, although the others are provided
  12381. * for compatibility with existing Javascript sort functions.
  12382. *
  12383. * `{type}-pre`: Functions defined take a single parameter:
  12384. *
  12385. * 1. `{*}` Data from the column cell to be prepared for ordering
  12386. *
  12387. * And return:
  12388. *
  12389. * * `{*}` Data to be sorted upon
  12390. *
  12391. * `{type}-asc` and `{type}-desc`: Functions are typical Javascript sort
  12392. * functions, taking two parameters:
  12393. *
  12394. * 1. `{*}` Data to compare to the second parameter
  12395. * 2. `{*}` Data to compare to the first parameter
  12396. *
  12397. * And returning:
  12398. *
  12399. * * `{*}` Ordering match: <0 if first parameter should be sorted lower
  12400. * than the second parameter, ===0 if the two parameters are equal and
  12401. * >0 if the first parameter should be sorted height than the second
  12402. * parameter.
  12403. *
  12404. * @type object
  12405. * @default {}
  12406. *
  12407. * @example
  12408. * // Numeric ordering of formatted numbers with a pre-formatter
  12409. * $.extend( $.fn.dataTable.ext.type.order, {
  12410. * "string-pre": function(x) {
  12411. * a = (a === "-" || a === "") ? 0 : a.replace( /[^\d\-\.]/g, "" );
  12412. * return parseFloat( a );
  12413. * }
  12414. * } );
  12415. *
  12416. * @example
  12417. * // Case-sensitive string ordering, with no pre-formatting method
  12418. * $.extend( $.fn.dataTable.ext.order, {
  12419. * "string-case-asc": function(x,y) {
  12420. * return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12421. * },
  12422. * "string-case-desc": function(x,y) {
  12423. * return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12424. * }
  12425. * } );
  12426. */
  12427. order: {}
  12428. },
  12429. /**
  12430. * Unique DataTables instance counter
  12431. *
  12432. * @type int
  12433. * @private
  12434. */
  12435. _unique: 0,
  12436. //
  12437. // Depreciated
  12438. // The following properties are retained for backwards compatiblity only.
  12439. // The should not be used in new projects and will be removed in a future
  12440. // version
  12441. //
  12442. /**
  12443. * Version check function.
  12444. * @type function
  12445. * @depreciated Since 1.10
  12446. */
  12447. fnVersionCheck: DataTable.fnVersionCheck,
  12448. /**
  12449. * Index for what 'this' index API functions should use
  12450. * @type int
  12451. * @deprecated Since v1.10
  12452. */
  12453. iApiIndex: 0,
  12454. /**
  12455. * jQuery UI class container
  12456. * @type object
  12457. * @deprecated Since v1.10
  12458. */
  12459. oJUIClasses: {},
  12460. /**
  12461. * Software version
  12462. * @type string
  12463. * @deprecated Since v1.10
  12464. */
  12465. sVersion: DataTable.version
  12466. };
  12467. //
  12468. // Backwards compatibility. Alias to pre 1.10 Hungarian notation counter parts
  12469. //
  12470. $.extend( _ext, {
  12471. afnFiltering: _ext.search,
  12472. aTypes: _ext.type.detect,
  12473. ofnSearch: _ext.type.search,
  12474. oSort: _ext.type.order,
  12475. afnSortData: _ext.order,
  12476. aoFeatures: _ext.feature,
  12477. oApi: _ext.internal,
  12478. oStdClasses: _ext.classes,
  12479. oPagination: _ext.pager
  12480. } );
  12481. $.extend( DataTable.ext.classes, {
  12482. "sTable": "dataTable",
  12483. "sNoFooter": "no-footer",
  12484. /* Paging buttons */
  12485. "sPageButton": "paginate_button",
  12486. "sPageButtonActive": "current",
  12487. "sPageButtonDisabled": "disabled",
  12488. /* Striping classes */
  12489. "sStripeOdd": "odd",
  12490. "sStripeEven": "even",
  12491. /* Empty row */
  12492. "sRowEmpty": "dataTables_empty",
  12493. /* Features */
  12494. "sWrapper": "dataTables_wrapper",
  12495. "sFilter": "dataTables_filter",
  12496. "sInfo": "dataTables_info",
  12497. "sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */
  12498. "sLength": "dataTables_length",
  12499. "sProcessing": "dataTables_processing",
  12500. /* Sorting */
  12501. "sSortAsc": "sorting_asc",
  12502. "sSortDesc": "sorting_desc",
  12503. "sSortable": "sorting", /* Sortable in both directions */
  12504. "sSortableAsc": "sorting_asc_disabled",
  12505. "sSortableDesc": "sorting_desc_disabled",
  12506. "sSortableNone": "sorting_disabled",
  12507. "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
  12508. /* Filtering */
  12509. "sFilterInput": "",
  12510. /* Page length */
  12511. "sLengthSelect": "",
  12512. /* Scrolling */
  12513. "sScrollWrapper": "dataTables_scroll",
  12514. "sScrollHead": "dataTables_scrollHead",
  12515. "sScrollHeadInner": "dataTables_scrollHeadInner",
  12516. "sScrollBody": "dataTables_scrollBody",
  12517. "sScrollFoot": "dataTables_scrollFoot",
  12518. "sScrollFootInner": "dataTables_scrollFootInner",
  12519. /* Misc */
  12520. "sHeaderTH": "",
  12521. "sFooterTH": "",
  12522. // Deprecated
  12523. "sSortJUIAsc": "",
  12524. "sSortJUIDesc": "",
  12525. "sSortJUI": "",
  12526. "sSortJUIAscAllowed": "",
  12527. "sSortJUIDescAllowed": "",
  12528. "sSortJUIWrapper": "",
  12529. "sSortIcon": "",
  12530. "sJUIHeader": "",
  12531. "sJUIFooter": ""
  12532. } );
  12533. (function() {
  12534. // Reused strings for better compression. Closure compiler appears to have a
  12535. // weird edge case where it is trying to expand strings rather than use the
  12536. // variable version. This results in about 200 bytes being added, for very
  12537. // little preference benefit since it this run on script load only.
  12538. var _empty = '';
  12539. _empty = '';
  12540. var _stateDefault = _empty + 'ui-state-default';
  12541. var _sortIcon = _empty + 'css_right ui-icon ui-icon-';
  12542. var _headerFooter = _empty + 'fg-toolbar ui-toolbar ui-widget-header ui-helper-clearfix';
  12543. $.extend( DataTable.ext.oJUIClasses, DataTable.ext.classes, {
  12544. /* Full numbers paging buttons */
  12545. "sPageButton": "fg-button ui-button "+_stateDefault,
  12546. "sPageButtonActive": "ui-state-disabled",
  12547. "sPageButtonDisabled": "ui-state-disabled",
  12548. /* Features */
  12549. "sPaging": "dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi "+
  12550. "ui-buttonset-multi paging_", /* Note that the type is postfixed */
  12551. /* Sorting */
  12552. "sSortAsc": _stateDefault+" sorting_asc",
  12553. "sSortDesc": _stateDefault+" sorting_desc",
  12554. "sSortable": _stateDefault+" sorting",
  12555. "sSortableAsc": _stateDefault+" sorting_asc_disabled",
  12556. "sSortableDesc": _stateDefault+" sorting_desc_disabled",
  12557. "sSortableNone": _stateDefault+" sorting_disabled",
  12558. "sSortJUIAsc": _sortIcon+"triangle-1-n",
  12559. "sSortJUIDesc": _sortIcon+"triangle-1-s",
  12560. "sSortJUI": _sortIcon+"carat-2-n-s",
  12561. "sSortJUIAscAllowed": _sortIcon+"carat-1-n",
  12562. "sSortJUIDescAllowed": _sortIcon+"carat-1-s",
  12563. "sSortJUIWrapper": "DataTables_sort_wrapper",
  12564. "sSortIcon": "DataTables_sort_icon",
  12565. /* Scrolling */
  12566. "sScrollHead": "dataTables_scrollHead "+_stateDefault,
  12567. "sScrollFoot": "dataTables_scrollFoot "+_stateDefault,
  12568. /* Misc */
  12569. "sHeaderTH": _stateDefault,
  12570. "sFooterTH": _stateDefault,
  12571. "sJUIHeader": _headerFooter+" ui-corner-tl ui-corner-tr",
  12572. "sJUIFooter": _headerFooter+" ui-corner-bl ui-corner-br"
  12573. } );
  12574. }());
  12575. var extPagination = DataTable.ext.pager;
  12576. function _numbers ( page, pages ) {
  12577. var
  12578. numbers = [],
  12579. buttons = extPagination.numbers_length,
  12580. half = Math.floor( buttons / 2 ),
  12581. i = 1;
  12582. if ( pages <= buttons ) {
  12583. numbers = _range( 0, pages );
  12584. }
  12585. else if ( page <= half ) {
  12586. numbers = _range( 0, buttons-2 );
  12587. numbers.push( 'ellipsis' );
  12588. numbers.push( pages-1 );
  12589. }
  12590. else if ( page >= pages - 1 - half ) {
  12591. numbers = _range( pages-(buttons-2), pages );
  12592. numbers.splice( 0, 0, 'ellipsis' ); // no unshift in ie6
  12593. numbers.splice( 0, 0, 0 );
  12594. }
  12595. else {
  12596. numbers = _range( page-half+2, page+half-1 );
  12597. numbers.push( 'ellipsis' );
  12598. numbers.push( pages-1 );
  12599. numbers.splice( 0, 0, 'ellipsis' );
  12600. numbers.splice( 0, 0, 0 );
  12601. }
  12602. numbers.DT_el = 'span';
  12603. return numbers;
  12604. }
  12605. $.extend( extPagination, {
  12606. simple: function ( page, pages ) {
  12607. return [ 'previous', 'next' ];
  12608. },
  12609. full: function ( page, pages ) {
  12610. return [ 'first', 'previous', 'next', 'last' ];
  12611. },
  12612. numbers: function ( page, pages ) {
  12613. return [ _numbers(page, pages) ];
  12614. },
  12615. simple_numbers: function ( page, pages ) {
  12616. return [ 'previous', _numbers(page, pages), 'next' ];
  12617. },
  12618. full_numbers: function ( page, pages ) {
  12619. return [ 'first', 'previous', _numbers(page, pages), 'next', 'last' ];
  12620. },
  12621. // For testing and plug-ins to use
  12622. _numbers: _numbers,
  12623. // Number of number buttons (including ellipsis) to show. _Must be odd!_
  12624. numbers_length: 7
  12625. } );
  12626. $.extend( true, DataTable.ext.renderer, {
  12627. pageButton: {
  12628. _: function ( settings, host, idx, buttons, page, pages ) {
  12629. var classes = settings.oClasses;
  12630. var lang = settings.oLanguage.oPaginate;
  12631. var aria = settings.oLanguage.oAria.paginate || {};
  12632. var btnDisplay, btnClass, counter=0;
  12633. var attach = function( container, buttons ) {
  12634. var i, ien, node, button;
  12635. var clickHandler = function ( e ) {
  12636. _fnPageChange( settings, e.data.action, true );
  12637. };
  12638. for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
  12639. button = buttons[i];
  12640. if ( $.isArray( button ) ) {
  12641. var inner = $( '<'+(button.DT_el || 'div')+'/>' )
  12642. .appendTo( container );
  12643. attach( inner, button );
  12644. }
  12645. else {
  12646. btnDisplay = null;
  12647. btnClass = '';
  12648. switch ( button ) {
  12649. case 'ellipsis':
  12650. container.append('<span class="ellipsis">&#x2026;</span>');
  12651. break;
  12652. case 'first':
  12653. btnDisplay = lang.sFirst;
  12654. btnClass = button + (page > 0 ?
  12655. '' : ' '+classes.sPageButtonDisabled);
  12656. break;
  12657. case 'previous':
  12658. btnDisplay = lang.sPrevious;
  12659. btnClass = button + (page > 0 ?
  12660. '' : ' '+classes.sPageButtonDisabled);
  12661. break;
  12662. case 'next':
  12663. btnDisplay = lang.sNext;
  12664. btnClass = button + (page < pages-1 ?
  12665. '' : ' '+classes.sPageButtonDisabled);
  12666. break;
  12667. case 'last':
  12668. btnDisplay = lang.sLast;
  12669. btnClass = button + (page < pages-1 ?
  12670. '' : ' '+classes.sPageButtonDisabled);
  12671. break;
  12672. default:
  12673. btnDisplay = button + 1;
  12674. btnClass = page === button ?
  12675. classes.sPageButtonActive : '';
  12676. break;
  12677. }
  12678. if ( btnDisplay !== null ) {
  12679. node = $('<a>', {
  12680. 'class': classes.sPageButton+' '+btnClass,
  12681. 'aria-controls': settings.sTableId,
  12682. 'aria-label': aria[ button ],
  12683. 'data-dt-idx': counter,
  12684. 'tabindex': settings.iTabIndex,
  12685. 'id': idx === 0 && typeof button === 'string' ?
  12686. settings.sTableId +'_'+ button :
  12687. null
  12688. } )
  12689. .html( btnDisplay )
  12690. .appendTo( container );
  12691. _fnBindAction(
  12692. node, {action: button}, clickHandler
  12693. );
  12694. counter++;
  12695. }
  12696. }
  12697. }
  12698. };
  12699. // IE9 throws an 'unknown error' if document.activeElement is used
  12700. // inside an iframe or frame. Try / catch the error. Not good for
  12701. // accessibility, but neither are frames.
  12702. var activeEl;
  12703. try {
  12704. // Because this approach is destroying and recreating the paging
  12705. // elements, focus is lost on the select button which is bad for
  12706. // accessibility. So we want to restore focus once the draw has
  12707. // completed
  12708. activeEl = $(host).find(document.activeElement).data('dt-idx');
  12709. }
  12710. catch (e) {}
  12711. attach( $(host).empty(), buttons );
  12712. if ( activeEl ) {
  12713. $(host).find( '[data-dt-idx='+activeEl+']' ).focus();
  12714. }
  12715. }
  12716. }
  12717. } );
  12718. // Built in type detection. See model.ext.aTypes for information about
  12719. // what is required from this methods.
  12720. $.extend( DataTable.ext.type.detect, [
  12721. // Plain numbers - first since V8 detects some plain numbers as dates
  12722. // e.g. Date.parse('55') (but not all, e.g. Date.parse('22')...).
  12723. function ( d, settings )
  12724. {
  12725. var decimal = settings.oLanguage.sDecimal;
  12726. return _isNumber( d, decimal ) ? 'num'+decimal : null;
  12727. },
  12728. // Dates (only those recognised by the browser's Date.parse)
  12729. function ( d, settings )
  12730. {
  12731. // V8 will remove any unknown characters at the start and end of the
  12732. // expression, leading to false matches such as `$245.12` or `10%` being
  12733. // a valid date. See forum thread 18941 for detail.
  12734. if ( d && !(d instanceof Date) && ( ! _re_date_start.test(d) || ! _re_date_end.test(d) ) ) {
  12735. return null;
  12736. }
  12737. var parsed = Date.parse(d);
  12738. return (parsed !== null && !isNaN(parsed)) || _empty(d) ? 'date' : null;
  12739. },
  12740. // Formatted numbers
  12741. function ( d, settings )
  12742. {
  12743. var decimal = settings.oLanguage.sDecimal;
  12744. return _isNumber( d, decimal, true ) ? 'num-fmt'+decimal : null;
  12745. },
  12746. // HTML numeric
  12747. function ( d, settings )
  12748. {
  12749. var decimal = settings.oLanguage.sDecimal;
  12750. return _htmlNumeric( d, decimal ) ? 'html-num'+decimal : null;
  12751. },
  12752. // HTML numeric, formatted
  12753. function ( d, settings )
  12754. {
  12755. var decimal = settings.oLanguage.sDecimal;
  12756. return _htmlNumeric( d, decimal, true ) ? 'html-num-fmt'+decimal : null;
  12757. },
  12758. // HTML (this is strict checking - there must be html)
  12759. function ( d, settings )
  12760. {
  12761. return _empty( d ) || (typeof d === 'string' && d.indexOf('<') !== -1) ?
  12762. 'html' : null;
  12763. }
  12764. ] );
  12765. // Filter formatting functions. See model.ext.ofnSearch for information about
  12766. // what is required from these methods.
  12767. //
  12768. // Note that additional search methods are added for the html numbers and
  12769. // html formatted numbers by `_addNumericSort()` when we know what the decimal
  12770. // place is
  12771. $.extend( DataTable.ext.type.search, {
  12772. html: function ( data ) {
  12773. return _empty(data) ?
  12774. data :
  12775. typeof data === 'string' ?
  12776. data
  12777. .replace( _re_new_lines, " " )
  12778. .replace( _re_html, "" ) :
  12779. '';
  12780. },
  12781. string: function ( data ) {
  12782. return _empty(data) ?
  12783. data :
  12784. typeof data === 'string' ?
  12785. data.replace( _re_new_lines, " " ) :
  12786. data;
  12787. }
  12788. } );
  12789. var __numericReplace = function ( d, decimalPlace, re1, re2 ) {
  12790. if ( d !== 0 && (!d || d === '-') ) {
  12791. return -Infinity;
  12792. }
  12793. // If a decimal place other than `.` is used, it needs to be given to the
  12794. // function so we can detect it and replace with a `.` which is the only
  12795. // decimal place Javascript recognises - it is not locale aware.
  12796. if ( decimalPlace ) {
  12797. d = _numToDecimal( d, decimalPlace );
  12798. }
  12799. if ( d.replace ) {
  12800. if ( re1 ) {
  12801. d = d.replace( re1, '' );
  12802. }
  12803. if ( re2 ) {
  12804. d = d.replace( re2, '' );
  12805. }
  12806. }
  12807. return d * 1;
  12808. };
  12809. // Add the numeric 'deformatting' functions for sorting and search. This is done
  12810. // in a function to provide an easy ability for the language options to add
  12811. // additional methods if a non-period decimal place is used.
  12812. function _addNumericSort ( decimalPlace ) {
  12813. $.each(
  12814. {
  12815. // Plain numbers
  12816. "num": function ( d ) {
  12817. return __numericReplace( d, decimalPlace );
  12818. },
  12819. // Formatted numbers
  12820. "num-fmt": function ( d ) {
  12821. return __numericReplace( d, decimalPlace, _re_formatted_numeric );
  12822. },
  12823. // HTML numeric
  12824. "html-num": function ( d ) {
  12825. return __numericReplace( d, decimalPlace, _re_html );
  12826. },
  12827. // HTML numeric, formatted
  12828. "html-num-fmt": function ( d ) {
  12829. return __numericReplace( d, decimalPlace, _re_html, _re_formatted_numeric );
  12830. }
  12831. },
  12832. function ( key, fn ) {
  12833. // Add the ordering method
  12834. _ext.type.order[ key+decimalPlace+'-pre' ] = fn;
  12835. // For HTML types add a search formatter that will strip the HTML
  12836. if ( key.match(/^html\-/) ) {
  12837. _ext.type.search[ key+decimalPlace ] = _ext.type.search.html;
  12838. }
  12839. }
  12840. );
  12841. }
  12842. // Default sort methods
  12843. $.extend( _ext.type.order, {
  12844. // Dates
  12845. "date-pre": function ( d ) {
  12846. return Date.parse( d ) || 0;
  12847. },
  12848. // html
  12849. "html-pre": function ( a ) {
  12850. return _empty(a) ?
  12851. '' :
  12852. a.replace ?
  12853. a.replace( /<.*?>/g, "" ).toLowerCase() :
  12854. a+'';
  12855. },
  12856. // string
  12857. "string-pre": function ( a ) {
  12858. // This is a little complex, but faster than always calling toString,
  12859. // http://jsperf.com/tostring-v-check
  12860. return _empty(a) ?
  12861. '' :
  12862. typeof a === 'string' ?
  12863. a.toLowerCase() :
  12864. ! a.toString ?
  12865. '' :
  12866. a.toString();
  12867. },
  12868. // string-asc and -desc are retained only for compatibility with the old
  12869. // sort methods
  12870. "string-asc": function ( x, y ) {
  12871. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12872. },
  12873. "string-desc": function ( x, y ) {
  12874. return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12875. }
  12876. } );
  12877. // Numeric sorting types - order doesn't matter here
  12878. _addNumericSort( '' );
  12879. $.extend( true, DataTable.ext.renderer, {
  12880. header: {
  12881. _: function ( settings, cell, column, classes ) {
  12882. // No additional mark-up required
  12883. // Attach a sort listener to update on sort - note that using the
  12884. // `DT` namespace will allow the event to be removed automatically
  12885. // on destroy, while the `dt` namespaced event is the one we are
  12886. // listening for
  12887. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  12888. if ( settings !== ctx ) { // need to check this this is the host
  12889. return; // table, not a nested one
  12890. }
  12891. var colIdx = column.idx;
  12892. cell
  12893. .removeClass(
  12894. column.sSortingClass +' '+
  12895. classes.sSortAsc +' '+
  12896. classes.sSortDesc
  12897. )
  12898. .addClass( columns[ colIdx ] == 'asc' ?
  12899. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  12900. classes.sSortDesc :
  12901. column.sSortingClass
  12902. );
  12903. } );
  12904. },
  12905. jqueryui: function ( settings, cell, column, classes ) {
  12906. $('<div/>')
  12907. .addClass( classes.sSortJUIWrapper )
  12908. .append( cell.contents() )
  12909. .append( $('<span/>')
  12910. .addClass( classes.sSortIcon+' '+column.sSortingClassJUI )
  12911. )
  12912. .appendTo( cell );
  12913. // Attach a sort listener to update on sort
  12914. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  12915. if ( settings !== ctx ) {
  12916. return;
  12917. }
  12918. var colIdx = column.idx;
  12919. cell
  12920. .removeClass( classes.sSortAsc +" "+classes.sSortDesc )
  12921. .addClass( columns[ colIdx ] == 'asc' ?
  12922. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  12923. classes.sSortDesc :
  12924. column.sSortingClass
  12925. );
  12926. cell
  12927. .find( 'span.'+classes.sSortIcon )
  12928. .removeClass(
  12929. classes.sSortJUIAsc +" "+
  12930. classes.sSortJUIDesc +" "+
  12931. classes.sSortJUI +" "+
  12932. classes.sSortJUIAscAllowed +" "+
  12933. classes.sSortJUIDescAllowed
  12934. )
  12935. .addClass( columns[ colIdx ] == 'asc' ?
  12936. classes.sSortJUIAsc : columns[ colIdx ] == 'desc' ?
  12937. classes.sSortJUIDesc :
  12938. column.sSortingClassJUI
  12939. );
  12940. } );
  12941. }
  12942. }
  12943. } );
  12944. /*
  12945. * Public helper functions. These aren't used internally by DataTables, or
  12946. * called by any of the options passed into DataTables, but they can be used
  12947. * externally by developers working with DataTables. They are helper functions
  12948. * to make working with DataTables a little bit easier.
  12949. */
  12950. var __htmlEscapeEntities = function ( d ) {
  12951. return typeof d === 'string' ?
  12952. d.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;') :
  12953. d;
  12954. };
  12955. /**
  12956. * Helpers for `columns.render`.
  12957. *
  12958. * The options defined here can be used with the `columns.render` initialisation
  12959. * option to provide a display renderer. The following functions are defined:
  12960. *
  12961. * * `number` - Will format numeric data (defined by `columns.data`) for
  12962. * display, retaining the original unformatted data for sorting and filtering.
  12963. * It takes 5 parameters:
  12964. * * `string` - Thousands grouping separator
  12965. * * `string` - Decimal point indicator
  12966. * * `integer` - Number of decimal points to show
  12967. * * `string` (optional) - Prefix.
  12968. * * `string` (optional) - Postfix (/suffix).
  12969. * * `text` - Escape HTML to help prevent XSS attacks. It has no optional
  12970. * parameters.
  12971. *
  12972. * @example
  12973. * // Column definition using the number renderer
  12974. * {
  12975. * data: "salary",
  12976. * render: $.fn.dataTable.render.number( '\'', '.', 0, '$' )
  12977. * }
  12978. *
  12979. * @namespace
  12980. */
  12981. DataTable.render = {
  12982. number: function ( thousands, decimal, precision, prefix, postfix ) {
  12983. return {
  12984. display: function ( d ) {
  12985. if ( typeof d !== 'number' && typeof d !== 'string' ) {
  12986. return d;
  12987. }
  12988. var negative = d < 0 ? '-' : '';
  12989. var flo = parseFloat( d );
  12990. // If NaN then there isn't much formatting that we can do - just
  12991. // return immediately, escaping any HTML (this was supposed to
  12992. // be a number after all)
  12993. if ( isNaN( flo ) ) {
  12994. return __htmlEscapeEntities( d );
  12995. }
  12996. d = Math.abs( flo );
  12997. var intPart = parseInt( d, 10 );
  12998. var floatPart = precision ?
  12999. decimal+(d - intPart).toFixed( precision ).substring( 2 ):
  13000. '';
  13001. return negative + (prefix||'') +
  13002. intPart.toString().replace(
  13003. /\B(?=(\d{3})+(?!\d))/g, thousands
  13004. ) +
  13005. floatPart +
  13006. (postfix||'');
  13007. }
  13008. };
  13009. },
  13010. text: function () {
  13011. return {
  13012. display: __htmlEscapeEntities
  13013. };
  13014. }
  13015. };
  13016. /*
  13017. * This is really a good bit rubbish this method of exposing the internal methods
  13018. * publicly... - To be fixed in 2.0 using methods on the prototype
  13019. */
  13020. /**
  13021. * Create a wrapper function for exporting an internal functions to an external API.
  13022. * @param {string} fn API function name
  13023. * @returns {function} wrapped function
  13024. * @memberof DataTable#internal
  13025. */
  13026. function _fnExternApiFunc (fn)
  13027. {
  13028. return function() {
  13029. var args = [_fnSettingsFromNode( this[DataTable.ext.iApiIndex] )].concat(
  13030. Array.prototype.slice.call(arguments)
  13031. );
  13032. return DataTable.ext.internal[fn].apply( this, args );
  13033. };
  13034. }
  13035. /**
  13036. * Reference to internal functions for use by plug-in developers. Note that
  13037. * these methods are references to internal functions and are considered to be
  13038. * private. If you use these methods, be aware that they are liable to change
  13039. * between versions.
  13040. * @namespace
  13041. */
  13042. $.extend( DataTable.ext.internal, {
  13043. _fnExternApiFunc: _fnExternApiFunc,
  13044. _fnBuildAjax: _fnBuildAjax,
  13045. _fnAjaxUpdate: _fnAjaxUpdate,
  13046. _fnAjaxParameters: _fnAjaxParameters,
  13047. _fnAjaxUpdateDraw: _fnAjaxUpdateDraw,
  13048. _fnAjaxDataSrc: _fnAjaxDataSrc,
  13049. _fnAddColumn: _fnAddColumn,
  13050. _fnColumnOptions: _fnColumnOptions,
  13051. _fnAdjustColumnSizing: _fnAdjustColumnSizing,
  13052. _fnVisibleToColumnIndex: _fnVisibleToColumnIndex,
  13053. _fnColumnIndexToVisible: _fnColumnIndexToVisible,
  13054. _fnVisbleColumns: _fnVisbleColumns,
  13055. _fnGetColumns: _fnGetColumns,
  13056. _fnColumnTypes: _fnColumnTypes,
  13057. _fnApplyColumnDefs: _fnApplyColumnDefs,
  13058. _fnHungarianMap: _fnHungarianMap,
  13059. _fnCamelToHungarian: _fnCamelToHungarian,
  13060. _fnLanguageCompat: _fnLanguageCompat,
  13061. _fnBrowserDetect: _fnBrowserDetect,
  13062. _fnAddData: _fnAddData,
  13063. _fnAddTr: _fnAddTr,
  13064. _fnNodeToDataIndex: _fnNodeToDataIndex,
  13065. _fnNodeToColumnIndex: _fnNodeToColumnIndex,
  13066. _fnGetCellData: _fnGetCellData,
  13067. _fnSetCellData: _fnSetCellData,
  13068. _fnSplitObjNotation: _fnSplitObjNotation,
  13069. _fnGetObjectDataFn: _fnGetObjectDataFn,
  13070. _fnSetObjectDataFn: _fnSetObjectDataFn,
  13071. _fnGetDataMaster: _fnGetDataMaster,
  13072. _fnClearTable: _fnClearTable,
  13073. _fnDeleteIndex: _fnDeleteIndex,
  13074. _fnInvalidate: _fnInvalidate,
  13075. _fnGetRowElements: _fnGetRowElements,
  13076. _fnCreateTr: _fnCreateTr,
  13077. _fnBuildHead: _fnBuildHead,
  13078. _fnDrawHead: _fnDrawHead,
  13079. _fnDraw: _fnDraw,
  13080. _fnReDraw: _fnReDraw,
  13081. _fnAddOptionsHtml: _fnAddOptionsHtml,
  13082. _fnDetectHeader: _fnDetectHeader,
  13083. _fnGetUniqueThs: _fnGetUniqueThs,
  13084. _fnFeatureHtmlFilter: _fnFeatureHtmlFilter,
  13085. _fnFilterComplete: _fnFilterComplete,
  13086. _fnFilterCustom: _fnFilterCustom,
  13087. _fnFilterColumn: _fnFilterColumn,
  13088. _fnFilter: _fnFilter,
  13089. _fnFilterCreateSearch: _fnFilterCreateSearch,
  13090. _fnEscapeRegex: _fnEscapeRegex,
  13091. _fnFilterData: _fnFilterData,
  13092. _fnFeatureHtmlInfo: _fnFeatureHtmlInfo,
  13093. _fnUpdateInfo: _fnUpdateInfo,
  13094. _fnInfoMacros: _fnInfoMacros,
  13095. _fnInitialise: _fnInitialise,
  13096. _fnInitComplete: _fnInitComplete,
  13097. _fnLengthChange: _fnLengthChange,
  13098. _fnFeatureHtmlLength: _fnFeatureHtmlLength,
  13099. _fnFeatureHtmlPaginate: _fnFeatureHtmlPaginate,
  13100. _fnPageChange: _fnPageChange,
  13101. _fnFeatureHtmlProcessing: _fnFeatureHtmlProcessing,
  13102. _fnProcessingDisplay: _fnProcessingDisplay,
  13103. _fnFeatureHtmlTable: _fnFeatureHtmlTable,
  13104. _fnScrollDraw: _fnScrollDraw,
  13105. _fnApplyToChildren: _fnApplyToChildren,
  13106. _fnCalculateColumnWidths: _fnCalculateColumnWidths,
  13107. _fnThrottle: _fnThrottle,
  13108. _fnConvertToWidth: _fnConvertToWidth,
  13109. _fnGetWidestNode: _fnGetWidestNode,
  13110. _fnGetMaxLenString: _fnGetMaxLenString,
  13111. _fnStringToCss: _fnStringToCss,
  13112. _fnSortFlatten: _fnSortFlatten,
  13113. _fnSort: _fnSort,
  13114. _fnSortAria: _fnSortAria,
  13115. _fnSortListener: _fnSortListener,
  13116. _fnSortAttachListener: _fnSortAttachListener,
  13117. _fnSortingClasses: _fnSortingClasses,
  13118. _fnSortData: _fnSortData,
  13119. _fnSaveState: _fnSaveState,
  13120. _fnLoadState: _fnLoadState,
  13121. _fnSettingsFromNode: _fnSettingsFromNode,
  13122. _fnLog: _fnLog,
  13123. _fnMap: _fnMap,
  13124. _fnBindAction: _fnBindAction,
  13125. _fnCallbackReg: _fnCallbackReg,
  13126. _fnCallbackFire: _fnCallbackFire,
  13127. _fnLengthOverflow: _fnLengthOverflow,
  13128. _fnRenderer: _fnRenderer,
  13129. _fnDataSource: _fnDataSource,
  13130. _fnRowAttributes: _fnRowAttributes,
  13131. _fnCalculateEnd: function () {} // Used by a lot of plug-ins, but redundant
  13132. // in 1.10, so this dead-end function is
  13133. // added to prevent errors
  13134. } );
  13135. // jQuery access
  13136. $.fn.dataTable = DataTable;
  13137. // Provide access to the host jQuery object (circular reference)
  13138. DataTable.$ = $;
  13139. // Legacy aliases
  13140. $.fn.dataTableSettings = DataTable.settings;
  13141. $.fn.dataTableExt = DataTable.ext;
  13142. // With a capital `D` we return a DataTables API instance rather than a
  13143. // jQuery object
  13144. $.fn.DataTable = function ( opts ) {
  13145. return $(this).dataTable( opts ).api();
  13146. };
  13147. // All properties that are available to $.fn.dataTable should also be
  13148. // available on $.fn.DataTable
  13149. $.each( DataTable, function ( prop, val ) {
  13150. $.fn.DataTable[ prop ] = val;
  13151. } );
  13152. // Information about events fired by DataTables - for documentation.
  13153. /**
  13154. * Draw event, fired whenever the table is redrawn on the page, at the same
  13155. * point as fnDrawCallback. This may be useful for binding events or
  13156. * performing calculations when the table is altered at all.
  13157. * @name DataTable#draw.dt
  13158. * @event
  13159. * @param {event} e jQuery event object
  13160. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13161. */
  13162. /**
  13163. * Search event, fired when the searching applied to the table (using the
  13164. * built-in global search, or column filters) is altered.
  13165. * @name DataTable#search.dt
  13166. * @event
  13167. * @param {event} e jQuery event object
  13168. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13169. */
  13170. /**
  13171. * Page change event, fired when the paging of the table is altered.
  13172. * @name DataTable#page.dt
  13173. * @event
  13174. * @param {event} e jQuery event object
  13175. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13176. */
  13177. /**
  13178. * Order event, fired when the ordering applied to the table is altered.
  13179. * @name DataTable#order.dt
  13180. * @event
  13181. * @param {event} e jQuery event object
  13182. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13183. */
  13184. /**
  13185. * DataTables initialisation complete event, fired when the table is fully
  13186. * drawn, including Ajax data loaded, if Ajax data is required.
  13187. * @name DataTable#init.dt
  13188. * @event
  13189. * @param {event} e jQuery event object
  13190. * @param {object} oSettings DataTables settings object
  13191. * @param {object} json The JSON object request from the server - only
  13192. * present if client-side Ajax sourced data is used</li></ol>
  13193. */
  13194. /**
  13195. * State save event, fired when the table has changed state a new state save
  13196. * is required. This event allows modification of the state saving object
  13197. * prior to actually doing the save, including addition or other state
  13198. * properties (for plug-ins) or modification of a DataTables core property.
  13199. * @name DataTable#stateSaveParams.dt
  13200. * @event
  13201. * @param {event} e jQuery event object
  13202. * @param {object} oSettings DataTables settings object
  13203. * @param {object} json The state information to be saved
  13204. */
  13205. /**
  13206. * State load event, fired when the table is loading state from the stored
  13207. * data, but prior to the settings object being modified by the saved state
  13208. * - allowing modification of the saved state is required or loading of
  13209. * state for a plug-in.
  13210. * @name DataTable#stateLoadParams.dt
  13211. * @event
  13212. * @param {event} e jQuery event object
  13213. * @param {object} oSettings DataTables settings object
  13214. * @param {object} json The saved state information
  13215. */
  13216. /**
  13217. * State loaded event, fired when state has been loaded from stored data and
  13218. * the settings object has been modified by the loaded data.
  13219. * @name DataTable#stateLoaded.dt
  13220. * @event
  13221. * @param {event} e jQuery event object
  13222. * @param {object} oSettings DataTables settings object
  13223. * @param {object} json The saved state information
  13224. */
  13225. /**
  13226. * Processing event, fired when DataTables is doing some kind of processing
  13227. * (be it, order, searcg or anything else). It can be used to indicate to
  13228. * the end user that there is something happening, or that something has
  13229. * finished.
  13230. * @name DataTable#processing.dt
  13231. * @event
  13232. * @param {event} e jQuery event object
  13233. * @param {object} oSettings DataTables settings object
  13234. * @param {boolean} bShow Flag for if DataTables is doing processing or not
  13235. */
  13236. /**
  13237. * Ajax (XHR) event, fired whenever an Ajax request is completed from a
  13238. * request to made to the server for new data. This event is called before
  13239. * DataTables processed the returned data, so it can also be used to pre-
  13240. * process the data returned from the server, if needed.
  13241. *
  13242. * Note that this trigger is called in `fnServerData`, if you override
  13243. * `fnServerData` and which to use this event, you need to trigger it in you
  13244. * success function.
  13245. * @name DataTable#xhr.dt
  13246. * @event
  13247. * @param {event} e jQuery event object
  13248. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13249. * @param {object} json JSON returned from the server
  13250. *
  13251. * @example
  13252. * // Use a custom property returned from the server in another DOM element
  13253. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  13254. * $('#status').html( json.status );
  13255. * } );
  13256. *
  13257. * @example
  13258. * // Pre-process the data returned from the server
  13259. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  13260. * for ( var i=0, ien=json.aaData.length ; i<ien ; i++ ) {
  13261. * json.aaData[i].sum = json.aaData[i].one + json.aaData[i].two;
  13262. * }
  13263. * // Note no return - manipulate the data directly in the JSON object.
  13264. * } );
  13265. */
  13266. /**
  13267. * Destroy event, fired when the DataTable is destroyed by calling fnDestroy
  13268. * or passing the bDestroy:true parameter in the initialisation object. This
  13269. * can be used to remove bound events, added DOM nodes, etc.
  13270. * @name DataTable#destroy.dt
  13271. * @event
  13272. * @param {event} e jQuery event object
  13273. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13274. */
  13275. /**
  13276. * Page length change event, fired when number of records to show on each
  13277. * page (the length) is changed.
  13278. * @name DataTable#length.dt
  13279. * @event
  13280. * @param {event} e jQuery event object
  13281. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13282. * @param {integer} len New length
  13283. */
  13284. /**
  13285. * Column sizing has changed.
  13286. * @name DataTable#column-sizing.dt
  13287. * @event
  13288. * @param {event} e jQuery event object
  13289. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13290. */
  13291. /**
  13292. * Column visibility has changed.
  13293. * @name DataTable#column-visibility.dt
  13294. * @event
  13295. * @param {event} e jQuery event object
  13296. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13297. * @param {int} column Column index
  13298. * @param {bool} vis `false` if column now hidden, or `true` if visible
  13299. */
  13300. return $.fn.dataTable;
  13301. }));