jquery.dataTables.js 437 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277
  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. }));