jquery.dataTables.js 436 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268
  1. /*! DataTables 1.10.11
  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.11
  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;
  88. /*
  89. * It is useful to have variables which are scoped locally so only the
  90. * DataTables functions can access them and they don't leak into global space.
  91. * At the same time these functions are often useful over multiple files in the
  92. * core and API, so we list, or at least document, all variables which are used
  93. * by DataTables as private variables here. This also ensures that there is no
  94. * clashing of variable names and that they can easily referenced for reuse.
  95. */
  96. // Defined else where
  97. // _selector_run
  98. // _selector_opts
  99. // _selector_first
  100. // _selector_row_indexes
  101. var _ext; // DataTable.ext
  102. var _Api; // DataTable.Api
  103. var _api_register; // DataTable.Api.register
  104. var _api_registerPlural; // DataTable.Api.registerPlural
  105. var _re_dic = {};
  106. var _re_new_lines = /[\r\n]/g;
  107. var _re_html = /<.*?>/g;
  108. var _re_date_start = /^[\w\+\-]/;
  109. var _re_date_end = /[\w\+\-]$/;
  110. // Escape regular expression special characters
  111. var _re_escape_regex = new RegExp( '(\\' + [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^', '-' ].join('|\\') + ')', 'g' );
  112. // http://en.wikipedia.org/wiki/Foreign_exchange_market
  113. // - \u20BD - Russian ruble.
  114. // - \u20a9 - South Korean Won
  115. // - \u20BA - Turkish Lira
  116. // - \u20B9 - Indian Rupee
  117. // - R - Brazil (R$) and South Africa
  118. // - fr - Swiss Franc
  119. // - kr - Swedish krona, Norwegian krone and Danish krone
  120. // - \u2009 is thin space and \u202F is narrow no-break space, both used in many
  121. // standards as thousands separators.
  122. var _re_formatted_numeric = /[',$£€¥%\u2009\u202F\u20BD\u20a9\u20BArfk]/gi;
  123. var _empty = function ( d ) {
  124. return !d || d === true || d === '-' ? true : false;
  125. };
  126. var _intVal = function ( s ) {
  127. var integer = parseInt( s, 10 );
  128. return !isNaN(integer) && isFinite(s) ? integer : null;
  129. };
  130. // Convert from a formatted number with characters other than `.` as the
  131. // decimal place, to a Javascript number
  132. var _numToDecimal = function ( num, decimalPoint ) {
  133. // Cache created regular expressions for speed as this function is called often
  134. if ( ! _re_dic[ decimalPoint ] ) {
  135. _re_dic[ decimalPoint ] = new RegExp( _fnEscapeRegex( decimalPoint ), 'g' );
  136. }
  137. return typeof num === 'string' && decimalPoint !== '.' ?
  138. num.replace( /\./g, '' ).replace( _re_dic[ decimalPoint ], '.' ) :
  139. num;
  140. };
  141. var _isNumber = function ( d, decimalPoint, formatted ) {
  142. var strType = typeof d === 'string';
  143. // If empty return immediately so there must be a number if it is a
  144. // formatted string (this stops the string "k", or "kr", etc being detected
  145. // as a formatted number for currency
  146. if ( _empty( d ) ) {
  147. return true;
  148. }
  149. if ( decimalPoint && strType ) {
  150. d = _numToDecimal( d, decimalPoint );
  151. }
  152. if ( formatted && strType ) {
  153. d = d.replace( _re_formatted_numeric, '' );
  154. }
  155. return !isNaN( parseFloat(d) ) && isFinite( d );
  156. };
  157. // A string without HTML in it can be considered to be HTML still
  158. var _isHtml = function ( d ) {
  159. return _empty( d ) || typeof d === 'string';
  160. };
  161. var _htmlNumeric = function ( d, decimalPoint, formatted ) {
  162. if ( _empty( d ) ) {
  163. return true;
  164. }
  165. var html = _isHtml( d );
  166. return ! html ?
  167. null :
  168. _isNumber( _stripHtml( d ), decimalPoint, formatted ) ?
  169. true :
  170. null;
  171. };
  172. var _pluck = function ( a, prop, prop2 ) {
  173. var out = [];
  174. var i=0, ien=a.length;
  175. // Could have the test in the loop for slightly smaller code, but speed
  176. // is essential here
  177. if ( prop2 !== undefined ) {
  178. for ( ; i<ien ; i++ ) {
  179. if ( a[i] && a[i][ prop ] ) {
  180. out.push( a[i][ prop ][ prop2 ] );
  181. }
  182. }
  183. }
  184. else {
  185. for ( ; i<ien ; i++ ) {
  186. if ( a[i] ) {
  187. out.push( a[i][ prop ] );
  188. }
  189. }
  190. }
  191. return out;
  192. };
  193. // Basically the same as _pluck, but rather than looping over `a` we use `order`
  194. // as the indexes to pick from `a`
  195. var _pluck_order = function ( a, order, prop, prop2 )
  196. {
  197. var out = [];
  198. var i=0, ien=order.length;
  199. // Could have the test in the loop for slightly smaller code, but speed
  200. // is essential here
  201. if ( prop2 !== undefined ) {
  202. for ( ; i<ien ; i++ ) {
  203. if ( a[ order[i] ][ prop ] ) {
  204. out.push( a[ order[i] ][ prop ][ prop2 ] );
  205. }
  206. }
  207. }
  208. else {
  209. for ( ; i<ien ; i++ ) {
  210. out.push( a[ order[i] ][ prop ] );
  211. }
  212. }
  213. return out;
  214. };
  215. var _range = function ( len, start )
  216. {
  217. var out = [];
  218. var end;
  219. if ( start === undefined ) {
  220. start = 0;
  221. end = len;
  222. }
  223. else {
  224. end = start;
  225. start = len;
  226. }
  227. for ( var i=start ; i<end ; i++ ) {
  228. out.push( i );
  229. }
  230. return out;
  231. };
  232. var _removeEmpty = function ( a )
  233. {
  234. var out = [];
  235. for ( var i=0, ien=a.length ; i<ien ; i++ ) {
  236. if ( a[i] ) { // careful - will remove all falsy values!
  237. out.push( a[i] );
  238. }
  239. }
  240. return out;
  241. };
  242. var _stripHtml = function ( d ) {
  243. return d.replace( _re_html, '' );
  244. };
  245. /**
  246. * Find the unique elements in a source array.
  247. *
  248. * @param {array} src Source array
  249. * @return {array} Array of unique items
  250. * @ignore
  251. */
  252. var _unique = function ( src )
  253. {
  254. // A faster unique method is to use object keys to identify used values,
  255. // but this doesn't work with arrays or objects, which we must also
  256. // consider. See jsperf.com/compare-array-unique-versions/4 for more
  257. // information.
  258. var
  259. out = [],
  260. val,
  261. i, ien=src.length,
  262. j, k=0;
  263. again: for ( i=0 ; i<ien ; i++ ) {
  264. val = src[i];
  265. for ( j=0 ; j<k ; j++ ) {
  266. if ( out[j] === val ) {
  267. continue again;
  268. }
  269. }
  270. out.push( val );
  271. k++;
  272. }
  273. return out;
  274. };
  275. /**
  276. * Create a mapping object that allows camel case parameters to be looked up
  277. * for their Hungarian counterparts. The mapping is stored in a private
  278. * parameter called `_hungarianMap` which can be accessed on the source object.
  279. * @param {object} o
  280. * @memberof DataTable#oApi
  281. */
  282. function _fnHungarianMap ( o )
  283. {
  284. var
  285. hungarian = 'a aa ai ao as b fn i m o s ',
  286. match,
  287. newKey,
  288. map = {};
  289. $.each( o, function (key, val) {
  290. match = key.match(/^([^A-Z]+?)([A-Z])/);
  291. if ( match && hungarian.indexOf(match[1]+' ') !== -1 )
  292. {
  293. newKey = key.replace( match[0], match[2].toLowerCase() );
  294. map[ newKey ] = key;
  295. if ( match[1] === 'o' )
  296. {
  297. _fnHungarianMap( o[key] );
  298. }
  299. }
  300. } );
  301. o._hungarianMap = map;
  302. }
  303. /**
  304. * Convert from camel case parameters to Hungarian, based on a Hungarian map
  305. * created by _fnHungarianMap.
  306. * @param {object} src The model object which holds all parameters that can be
  307. * mapped.
  308. * @param {object} user The object to convert from camel case to Hungarian.
  309. * @param {boolean} force When set to `true`, properties which already have a
  310. * Hungarian value in the `user` object will be overwritten. Otherwise they
  311. * won't be.
  312. * @memberof DataTable#oApi
  313. */
  314. function _fnCamelToHungarian ( src, user, force )
  315. {
  316. if ( ! src._hungarianMap ) {
  317. _fnHungarianMap( src );
  318. }
  319. var hungarianKey;
  320. $.each( user, function (key, val) {
  321. hungarianKey = src._hungarianMap[ key ];
  322. if ( hungarianKey !== undefined && (force || user[hungarianKey] === undefined) )
  323. {
  324. // For objects, we need to buzz down into the object to copy parameters
  325. if ( hungarianKey.charAt(0) === 'o' )
  326. {
  327. // Copy the camelCase options over to the hungarian
  328. if ( ! user[ hungarianKey ] ) {
  329. user[ hungarianKey ] = {};
  330. }
  331. $.extend( true, user[hungarianKey], user[key] );
  332. _fnCamelToHungarian( src[hungarianKey], user[hungarianKey], force );
  333. }
  334. else {
  335. user[hungarianKey] = user[ key ];
  336. }
  337. }
  338. } );
  339. }
  340. /**
  341. * Language compatibility - when certain options are given, and others aren't, we
  342. * need to duplicate the values over, in order to provide backwards compatibility
  343. * with older language files.
  344. * @param {object} oSettings dataTables settings object
  345. * @memberof DataTable#oApi
  346. */
  347. function _fnLanguageCompat( lang )
  348. {
  349. var defaults = DataTable.defaults.oLanguage;
  350. var zeroRecords = lang.sZeroRecords;
  351. /* Backwards compatibility - if there is no sEmptyTable given, then use the same as
  352. * sZeroRecords - assuming that is given.
  353. */
  354. if ( ! lang.sEmptyTable && zeroRecords &&
  355. defaults.sEmptyTable === "No data available in table" )
  356. {
  357. _fnMap( lang, lang, 'sZeroRecords', 'sEmptyTable' );
  358. }
  359. /* Likewise with loading records */
  360. if ( ! lang.sLoadingRecords && zeroRecords &&
  361. defaults.sLoadingRecords === "Loading..." )
  362. {
  363. _fnMap( lang, lang, 'sZeroRecords', 'sLoadingRecords' );
  364. }
  365. // Old parameter name of the thousands separator mapped onto the new
  366. if ( lang.sInfoThousands ) {
  367. lang.sThousands = lang.sInfoThousands;
  368. }
  369. var decimal = lang.sDecimal;
  370. if ( decimal ) {
  371. _addNumericSort( decimal );
  372. }
  373. }
  374. /**
  375. * Map one parameter onto another
  376. * @param {object} o Object to map
  377. * @param {*} knew The new parameter name
  378. * @param {*} old The old parameter name
  379. */
  380. var _fnCompatMap = function ( o, knew, old ) {
  381. if ( o[ knew ] !== undefined ) {
  382. o[ old ] = o[ knew ];
  383. }
  384. };
  385. /**
  386. * Provide backwards compatibility for the main DT options. Note that the new
  387. * options are mapped onto the old parameters, so this is an external interface
  388. * change only.
  389. * @param {object} init Object to map
  390. */
  391. function _fnCompatOpts ( init )
  392. {
  393. _fnCompatMap( init, 'ordering', 'bSort' );
  394. _fnCompatMap( init, 'orderMulti', 'bSortMulti' );
  395. _fnCompatMap( init, 'orderClasses', 'bSortClasses' );
  396. _fnCompatMap( init, 'orderCellsTop', 'bSortCellsTop' );
  397. _fnCompatMap( init, 'order', 'aaSorting' );
  398. _fnCompatMap( init, 'orderFixed', 'aaSortingFixed' );
  399. _fnCompatMap( init, 'paging', 'bPaginate' );
  400. _fnCompatMap( init, 'pagingType', 'sPaginationType' );
  401. _fnCompatMap( init, 'pageLength', 'iDisplayLength' );
  402. _fnCompatMap( init, 'searching', 'bFilter' );
  403. // Boolean initialisation of x-scrolling
  404. if ( typeof init.sScrollX === 'boolean' ) {
  405. init.sScrollX = init.sScrollX ? '100%' : '';
  406. }
  407. if ( typeof init.scrollX === 'boolean' ) {
  408. init.scrollX = init.scrollX ? '100%' : '';
  409. }
  410. // Column search objects are in an array, so it needs to be converted
  411. // element by element
  412. var searchCols = init.aoSearchCols;
  413. if ( searchCols ) {
  414. for ( var i=0, ien=searchCols.length ; i<ien ; i++ ) {
  415. if ( searchCols[i] ) {
  416. _fnCamelToHungarian( DataTable.models.oSearch, searchCols[i] );
  417. }
  418. }
  419. }
  420. }
  421. /**
  422. * Provide backwards compatibility for column options. Note that the new options
  423. * are mapped onto the old parameters, so this is an external interface change
  424. * only.
  425. * @param {object} init Object to map
  426. */
  427. function _fnCompatCols ( init )
  428. {
  429. _fnCompatMap( init, 'orderable', 'bSortable' );
  430. _fnCompatMap( init, 'orderData', 'aDataSort' );
  431. _fnCompatMap( init, 'orderSequence', 'asSorting' );
  432. _fnCompatMap( init, 'orderDataType', 'sortDataType' );
  433. // orderData can be given as an integer
  434. var dataSort = init.aDataSort;
  435. if ( dataSort && ! $.isArray( dataSort ) ) {
  436. init.aDataSort = [ dataSort ];
  437. }
  438. }
  439. /**
  440. * Browser feature detection for capabilities, quirks
  441. * @param {object} settings dataTables settings object
  442. * @memberof DataTable#oApi
  443. */
  444. function _fnBrowserDetect( settings )
  445. {
  446. // We don't need to do this every time DataTables is constructed, the values
  447. // calculated are specific to the browser and OS configuration which we
  448. // don't expect to change between initialisations
  449. if ( ! DataTable.__browser ) {
  450. var browser = {};
  451. DataTable.__browser = browser;
  452. // Scrolling feature / quirks detection
  453. var n = $('<div/>')
  454. .css( {
  455. position: 'fixed',
  456. top: 0,
  457. left: 0,
  458. height: 1,
  459. width: 1,
  460. overflow: 'hidden'
  461. } )
  462. .append(
  463. $('<div/>')
  464. .css( {
  465. position: 'absolute',
  466. top: 1,
  467. left: 1,
  468. width: 100,
  469. overflow: 'scroll'
  470. } )
  471. .append(
  472. $('<div/>')
  473. .css( {
  474. width: '100%',
  475. height: 10
  476. } )
  477. )
  478. )
  479. .appendTo( 'body' );
  480. var outer = n.children();
  481. var inner = outer.children();
  482. // Numbers below, in order, are:
  483. // inner.offsetWidth, inner.clientWidth, outer.offsetWidth, outer.clientWidth
  484. //
  485. // IE6 XP: 100 100 100 83
  486. // IE7 Vista: 100 100 100 83
  487. // IE 8+ Windows: 83 83 100 83
  488. // Evergreen Windows: 83 83 100 83
  489. // Evergreen Mac with scrollbars: 85 85 100 85
  490. // Evergreen Mac without scrollbars: 100 100 100 100
  491. // Get scrollbar width
  492. browser.barWidth = outer[0].offsetWidth - outer[0].clientWidth;
  493. // IE6/7 will oversize a width 100% element inside a scrolling element, to
  494. // include the width of the scrollbar, while other browsers ensure the inner
  495. // element is contained without forcing scrolling
  496. browser.bScrollOversize = inner[0].offsetWidth === 100 && outer[0].clientWidth !== 100;
  497. // In rtl text layout, some browsers (most, but not all) will place the
  498. // scrollbar on the left, rather than the right.
  499. browser.bScrollbarLeft = Math.round( inner.offset().left ) !== 1;
  500. // IE8- don't provide height and width for getBoundingClientRect
  501. browser.bBounding = n[0].getBoundingClientRect().width ? true : false;
  502. n.remove();
  503. }
  504. $.extend( settings.oBrowser, DataTable.__browser );
  505. settings.oScroll.iBarWidth = DataTable.__browser.barWidth;
  506. }
  507. /**
  508. * Array.prototype reduce[Right] method, used for browsers which don't support
  509. * JS 1.6. Done this way to reduce code size, since we iterate either way
  510. * @param {object} settings dataTables settings object
  511. * @memberof DataTable#oApi
  512. */
  513. function _fnReduce ( that, fn, init, start, end, inc )
  514. {
  515. var
  516. i = start,
  517. value,
  518. isSet = false;
  519. if ( init !== undefined ) {
  520. value = init;
  521. isSet = true;
  522. }
  523. while ( i !== end ) {
  524. if ( ! that.hasOwnProperty(i) ) {
  525. continue;
  526. }
  527. value = isSet ?
  528. fn( value, that[i], i, that ) :
  529. that[i];
  530. isSet = true;
  531. i += inc;
  532. }
  533. return value;
  534. }
  535. /**
  536. * Add a column to the list used for the table with default values
  537. * @param {object} oSettings dataTables settings object
  538. * @param {node} nTh The th element for this column
  539. * @memberof DataTable#oApi
  540. */
  541. function _fnAddColumn( oSettings, nTh )
  542. {
  543. // Add column to aoColumns array
  544. var oDefaults = DataTable.defaults.column;
  545. var iCol = oSettings.aoColumns.length;
  546. var oCol = $.extend( {}, DataTable.models.oColumn, oDefaults, {
  547. "nTh": nTh ? nTh : document.createElement('th'),
  548. "sTitle": oDefaults.sTitle ? oDefaults.sTitle : nTh ? nTh.innerHTML : '',
  549. "aDataSort": oDefaults.aDataSort ? oDefaults.aDataSort : [iCol],
  550. "mData": oDefaults.mData ? oDefaults.mData : iCol,
  551. idx: iCol
  552. } );
  553. oSettings.aoColumns.push( oCol );
  554. // Add search object for column specific search. Note that the `searchCols[ iCol ]`
  555. // passed into extend can be undefined. This allows the user to give a default
  556. // with only some of the parameters defined, and also not give a default
  557. var searchCols = oSettings.aoPreSearchCols;
  558. searchCols[ iCol ] = $.extend( {}, DataTable.models.oSearch, searchCols[ iCol ] );
  559. // Use the default column options function to initialise classes etc
  560. _fnColumnOptions( oSettings, iCol, $(nTh).data() );
  561. }
  562. /**
  563. * Apply options for a column
  564. * @param {object} oSettings dataTables settings object
  565. * @param {int} iCol column index to consider
  566. * @param {object} oOptions object with sType, bVisible and bSearchable etc
  567. * @memberof DataTable#oApi
  568. */
  569. function _fnColumnOptions( oSettings, iCol, oOptions )
  570. {
  571. var oCol = oSettings.aoColumns[ iCol ];
  572. var oClasses = oSettings.oClasses;
  573. var th = $(oCol.nTh);
  574. // Try to get width information from the DOM. We can't get it from CSS
  575. // as we'd need to parse the CSS stylesheet. `width` option can override
  576. if ( ! oCol.sWidthOrig ) {
  577. // Width attribute
  578. oCol.sWidthOrig = th.attr('width') || null;
  579. // Style attribute
  580. var t = (th.attr('style') || '').match(/width:\s*(\d+[pxem%]+)/);
  581. if ( t ) {
  582. oCol.sWidthOrig = t[1];
  583. }
  584. }
  585. /* User specified column options */
  586. if ( oOptions !== undefined && oOptions !== null )
  587. {
  588. // Backwards compatibility
  589. _fnCompatCols( oOptions );
  590. // Map camel case parameters to their Hungarian counterparts
  591. _fnCamelToHungarian( DataTable.defaults.column, oOptions );
  592. /* Backwards compatibility for mDataProp */
  593. if ( oOptions.mDataProp !== undefined && !oOptions.mData )
  594. {
  595. oOptions.mData = oOptions.mDataProp;
  596. }
  597. if ( oOptions.sType )
  598. {
  599. oCol._sManualType = oOptions.sType;
  600. }
  601. // `class` is a reserved word in Javascript, so we need to provide
  602. // the ability to use a valid name for the camel case input
  603. if ( oOptions.className && ! oOptions.sClass )
  604. {
  605. oOptions.sClass = oOptions.className;
  606. }
  607. $.extend( oCol, oOptions );
  608. _fnMap( oCol, oOptions, "sWidth", "sWidthOrig" );
  609. /* iDataSort to be applied (backwards compatibility), but aDataSort will take
  610. * priority if defined
  611. */
  612. if ( oOptions.iDataSort !== undefined )
  613. {
  614. oCol.aDataSort = [ oOptions.iDataSort ];
  615. }
  616. _fnMap( oCol, oOptions, "aDataSort" );
  617. }
  618. /* Cache the data get and set functions for speed */
  619. var mDataSrc = oCol.mData;
  620. var mData = _fnGetObjectDataFn( mDataSrc );
  621. var mRender = oCol.mRender ? _fnGetObjectDataFn( oCol.mRender ) : null;
  622. var attrTest = function( src ) {
  623. return typeof src === 'string' && src.indexOf('@') !== -1;
  624. };
  625. oCol._bAttrSrc = $.isPlainObject( mDataSrc ) && (
  626. attrTest(mDataSrc.sort) || attrTest(mDataSrc.type) || attrTest(mDataSrc.filter)
  627. );
  628. oCol._setter = null;
  629. oCol.fnGetData = function (rowData, type, meta) {
  630. var innerData = mData( rowData, type, undefined, meta );
  631. return mRender && type ?
  632. mRender( innerData, type, rowData, meta ) :
  633. innerData;
  634. };
  635. oCol.fnSetData = function ( rowData, val, meta ) {
  636. return _fnSetObjectDataFn( mDataSrc )( rowData, val, meta );
  637. };
  638. // Indicate if DataTables should read DOM data as an object or array
  639. // Used in _fnGetRowElements
  640. if ( typeof mDataSrc !== 'number' ) {
  641. oSettings._rowReadObject = true;
  642. }
  643. /* Feature sorting overrides column specific when off */
  644. if ( !oSettings.oFeatures.bSort )
  645. {
  646. oCol.bSortable = false;
  647. th.addClass( oClasses.sSortableNone ); // Have to add class here as order event isn't called
  648. }
  649. /* Check that the class assignment is correct for sorting */
  650. var bAsc = $.inArray('asc', oCol.asSorting) !== -1;
  651. var bDesc = $.inArray('desc', oCol.asSorting) !== -1;
  652. if ( !oCol.bSortable || (!bAsc && !bDesc) )
  653. {
  654. oCol.sSortingClass = oClasses.sSortableNone;
  655. oCol.sSortingClassJUI = "";
  656. }
  657. else if ( bAsc && !bDesc )
  658. {
  659. oCol.sSortingClass = oClasses.sSortableAsc;
  660. oCol.sSortingClassJUI = oClasses.sSortJUIAscAllowed;
  661. }
  662. else if ( !bAsc && bDesc )
  663. {
  664. oCol.sSortingClass = oClasses.sSortableDesc;
  665. oCol.sSortingClassJUI = oClasses.sSortJUIDescAllowed;
  666. }
  667. else
  668. {
  669. oCol.sSortingClass = oClasses.sSortable;
  670. oCol.sSortingClassJUI = oClasses.sSortJUI;
  671. }
  672. }
  673. /**
  674. * Adjust the table column widths for new data. Note: you would probably want to
  675. * do a redraw after calling this function!
  676. * @param {object} settings dataTables settings object
  677. * @memberof DataTable#oApi
  678. */
  679. function _fnAdjustColumnSizing ( settings )
  680. {
  681. /* Not interested in doing column width calculation if auto-width is disabled */
  682. if ( settings.oFeatures.bAutoWidth !== false )
  683. {
  684. var columns = settings.aoColumns;
  685. _fnCalculateColumnWidths( settings );
  686. for ( var i=0 , iLen=columns.length ; i<iLen ; i++ )
  687. {
  688. columns[i].nTh.style.width = columns[i].sWidth;
  689. }
  690. }
  691. var scroll = settings.oScroll;
  692. if ( scroll.sY !== '' || scroll.sX !== '')
  693. {
  694. _fnScrollDraw( settings );
  695. }
  696. _fnCallbackFire( settings, null, 'column-sizing', [settings] );
  697. }
  698. /**
  699. * Covert the index of a visible column to the index in the data array (take account
  700. * of hidden columns)
  701. * @param {object} oSettings dataTables settings object
  702. * @param {int} iMatch Visible column index to lookup
  703. * @returns {int} i the data index
  704. * @memberof DataTable#oApi
  705. */
  706. function _fnVisibleToColumnIndex( oSettings, iMatch )
  707. {
  708. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  709. return typeof aiVis[iMatch] === 'number' ?
  710. aiVis[iMatch] :
  711. null;
  712. }
  713. /**
  714. * Covert the index of an index in the data array and convert it to the visible
  715. * column index (take account of hidden columns)
  716. * @param {int} iMatch Column index to lookup
  717. * @param {object} oSettings dataTables settings object
  718. * @returns {int} i the data index
  719. * @memberof DataTable#oApi
  720. */
  721. function _fnColumnIndexToVisible( oSettings, iMatch )
  722. {
  723. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  724. var iPos = $.inArray( iMatch, aiVis );
  725. return iPos !== -1 ? iPos : null;
  726. }
  727. /**
  728. * Get the number of visible columns
  729. * @param {object} oSettings dataTables settings object
  730. * @returns {int} i the number of visible columns
  731. * @memberof DataTable#oApi
  732. */
  733. function _fnVisbleColumns( oSettings )
  734. {
  735. return $( _pluck( oSettings.aoColumns, 'nTh' ) ).filter(':visible').length;
  736. }
  737. /**
  738. * Get an array of column indexes that match a given property
  739. * @param {object} oSettings dataTables settings object
  740. * @param {string} sParam Parameter in aoColumns to look for - typically
  741. * bVisible or bSearchable
  742. * @returns {array} Array of indexes with matched properties
  743. * @memberof DataTable#oApi
  744. */
  745. function _fnGetColumns( oSettings, sParam )
  746. {
  747. var a = [];
  748. $.map( oSettings.aoColumns, function(val, i) {
  749. if ( val[sParam] ) {
  750. a.push( i );
  751. }
  752. } );
  753. return a;
  754. }
  755. /**
  756. * Calculate the 'type' of a column
  757. * @param {object} settings dataTables settings object
  758. * @memberof DataTable#oApi
  759. */
  760. function _fnColumnTypes ( settings )
  761. {
  762. var columns = settings.aoColumns;
  763. var data = settings.aoData;
  764. var types = DataTable.ext.type.detect;
  765. var i, ien, j, jen, k, ken;
  766. var col, cell, detectedType, cache;
  767. // For each column, spin over the
  768. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  769. col = columns[i];
  770. cache = [];
  771. if ( ! col.sType && col._sManualType ) {
  772. col.sType = col._sManualType;
  773. }
  774. else if ( ! col.sType ) {
  775. for ( j=0, jen=types.length ; j<jen ; j++ ) {
  776. for ( k=0, ken=data.length ; k<ken ; k++ ) {
  777. // Use a cache array so we only need to get the type data
  778. // from the formatter once (when using multiple detectors)
  779. if ( cache[k] === undefined ) {
  780. cache[k] = _fnGetCellData( settings, k, i, 'type' );
  781. }
  782. detectedType = types[j]( cache[k], settings );
  783. // If null, then this type can't apply to this column, so
  784. // rather than testing all cells, break out. There is an
  785. // exception for the last type which is `html`. We need to
  786. // scan all rows since it is possible to mix string and HTML
  787. // types
  788. if ( ! detectedType && j !== types.length-1 ) {
  789. break;
  790. }
  791. // Only a single match is needed for html type since it is
  792. // bottom of the pile and very similar to string
  793. if ( detectedType === 'html' ) {
  794. break;
  795. }
  796. }
  797. // Type is valid for all data points in the column - use this
  798. // type
  799. if ( detectedType ) {
  800. col.sType = detectedType;
  801. break;
  802. }
  803. }
  804. // Fall back - if no type was detected, always use string
  805. if ( ! col.sType ) {
  806. col.sType = 'string';
  807. }
  808. }
  809. }
  810. }
  811. /**
  812. * Take the column definitions and static columns arrays and calculate how
  813. * they relate to column indexes. The callback function will then apply the
  814. * definition found for a column to a suitable configuration object.
  815. * @param {object} oSettings dataTables settings object
  816. * @param {array} aoColDefs The aoColumnDefs array that is to be applied
  817. * @param {array} aoCols The aoColumns array that defines columns individually
  818. * @param {function} fn Callback function - takes two parameters, the calculated
  819. * column index and the definition for that column.
  820. * @memberof DataTable#oApi
  821. */
  822. function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, fn )
  823. {
  824. var i, iLen, j, jLen, k, kLen, def;
  825. var columns = oSettings.aoColumns;
  826. // Column definitions with aTargets
  827. if ( aoColDefs )
  828. {
  829. /* Loop over the definitions array - loop in reverse so first instance has priority */
  830. for ( i=aoColDefs.length-1 ; i>=0 ; i-- )
  831. {
  832. def = aoColDefs[i];
  833. /* Each definition can target multiple columns, as it is an array */
  834. var aTargets = def.targets !== undefined ?
  835. def.targets :
  836. def.aTargets;
  837. if ( ! $.isArray( aTargets ) )
  838. {
  839. aTargets = [ aTargets ];
  840. }
  841. for ( j=0, jLen=aTargets.length ; j<jLen ; j++ )
  842. {
  843. if ( typeof aTargets[j] === 'number' && aTargets[j] >= 0 )
  844. {
  845. /* Add columns that we don't yet know about */
  846. while( columns.length <= aTargets[j] )
  847. {
  848. _fnAddColumn( oSettings );
  849. }
  850. /* Integer, basic index */
  851. fn( aTargets[j], def );
  852. }
  853. else if ( typeof aTargets[j] === 'number' && aTargets[j] < 0 )
  854. {
  855. /* Negative integer, right to left column counting */
  856. fn( columns.length+aTargets[j], def );
  857. }
  858. else if ( typeof aTargets[j] === 'string' )
  859. {
  860. /* Class name matching on TH element */
  861. for ( k=0, kLen=columns.length ; k<kLen ; k++ )
  862. {
  863. if ( aTargets[j] == "_all" ||
  864. $(columns[k].nTh).hasClass( aTargets[j] ) )
  865. {
  866. fn( k, def );
  867. }
  868. }
  869. }
  870. }
  871. }
  872. }
  873. // Statically defined columns array
  874. if ( aoCols )
  875. {
  876. for ( i=0, iLen=aoCols.length ; i<iLen ; i++ )
  877. {
  878. fn( i, aoCols[i] );
  879. }
  880. }
  881. }
  882. /**
  883. * Add a data array to the table, creating DOM node etc. This is the parallel to
  884. * _fnGatherData, but for adding rows from a Javascript source, rather than a
  885. * DOM source.
  886. * @param {object} oSettings dataTables settings object
  887. * @param {array} aData data array to be added
  888. * @param {node} [nTr] TR element to add to the table - optional. If not given,
  889. * DataTables will create a row automatically
  890. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  891. * if nTr is.
  892. * @returns {int} >=0 if successful (index of new aoData entry), -1 if failed
  893. * @memberof DataTable#oApi
  894. */
  895. function _fnAddData ( oSettings, aDataIn, nTr, anTds )
  896. {
  897. /* Create the object for storing information about this new row */
  898. var iRow = oSettings.aoData.length;
  899. var oData = $.extend( true, {}, DataTable.models.oRow, {
  900. src: nTr ? 'dom' : 'data',
  901. idx: iRow
  902. } );
  903. oData._aData = aDataIn;
  904. oSettings.aoData.push( oData );
  905. /* Create the cells */
  906. var nTd, sThisType;
  907. var columns = oSettings.aoColumns;
  908. // Invalidate the column types as the new data needs to be revalidated
  909. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  910. {
  911. columns[i].sType = null;
  912. }
  913. /* Add to the display array */
  914. oSettings.aiDisplayMaster.push( iRow );
  915. var id = oSettings.rowIdFn( aDataIn );
  916. if ( id !== undefined ) {
  917. oSettings.aIds[ id ] = oData;
  918. }
  919. /* Create the DOM information, or register it if already present */
  920. if ( nTr || ! oSettings.oFeatures.bDeferRender )
  921. {
  922. _fnCreateTr( oSettings, iRow, nTr, anTds );
  923. }
  924. return iRow;
  925. }
  926. /**
  927. * Add one or more TR elements to the table. Generally we'd expect to
  928. * use this for reading data from a DOM sourced table, but it could be
  929. * used for an TR element. Note that if a TR is given, it is used (i.e.
  930. * it is not cloned).
  931. * @param {object} settings dataTables settings object
  932. * @param {array|node|jQuery} trs The TR element(s) to add to the table
  933. * @returns {array} Array of indexes for the added rows
  934. * @memberof DataTable#oApi
  935. */
  936. function _fnAddTr( settings, trs )
  937. {
  938. var row;
  939. // Allow an individual node to be passed in
  940. if ( ! (trs instanceof $) ) {
  941. trs = $(trs);
  942. }
  943. return trs.map( function (i, el) {
  944. row = _fnGetRowElements( settings, el );
  945. return _fnAddData( settings, row.data, el, row.cells );
  946. } );
  947. }
  948. /**
  949. * Take a TR element and convert it to an index in aoData
  950. * @param {object} oSettings dataTables settings object
  951. * @param {node} n the TR element to find
  952. * @returns {int} index if the node is found, null if not
  953. * @memberof DataTable#oApi
  954. */
  955. function _fnNodeToDataIndex( oSettings, n )
  956. {
  957. return (n._DT_RowIndex!==undefined) ? n._DT_RowIndex : null;
  958. }
  959. /**
  960. * Take a TD element and convert it into a column data index (not the visible index)
  961. * @param {object} oSettings dataTables settings object
  962. * @param {int} iRow The row number the TD/TH can be found in
  963. * @param {node} n The TD/TH element to find
  964. * @returns {int} index if the node is found, -1 if not
  965. * @memberof DataTable#oApi
  966. */
  967. function _fnNodeToColumnIndex( oSettings, iRow, n )
  968. {
  969. return $.inArray( n, oSettings.aoData[ iRow ].anCells );
  970. }
  971. /**
  972. * Get the data for a given cell from the internal cache, taking into account data mapping
  973. * @param {object} settings dataTables settings object
  974. * @param {int} rowIdx aoData row id
  975. * @param {int} colIdx Column index
  976. * @param {string} type data get type ('display', 'type' 'filter' 'sort')
  977. * @returns {*} Cell data
  978. * @memberof DataTable#oApi
  979. */
  980. function _fnGetCellData( settings, rowIdx, colIdx, type )
  981. {
  982. var draw = settings.iDraw;
  983. var col = settings.aoColumns[colIdx];
  984. var rowData = settings.aoData[rowIdx]._aData;
  985. var defaultContent = col.sDefaultContent;
  986. var cellData = col.fnGetData( rowData, type, {
  987. settings: settings,
  988. row: rowIdx,
  989. col: colIdx
  990. } );
  991. if ( cellData === undefined ) {
  992. if ( settings.iDrawError != draw && defaultContent === null ) {
  993. _fnLog( settings, 0, "Requested unknown parameter "+
  994. (typeof col.mData=='function' ? '{function}' : "'"+col.mData+"'")+
  995. " for row "+rowIdx+", column "+colIdx, 4 );
  996. settings.iDrawError = draw;
  997. }
  998. return defaultContent;
  999. }
  1000. // When the data source is null and a specific data type is requested (i.e.
  1001. // not the original data), we can use default column data
  1002. if ( (cellData === rowData || cellData === null) && defaultContent !== null && type !== undefined ) {
  1003. cellData = defaultContent;
  1004. }
  1005. else if ( typeof cellData === 'function' ) {
  1006. // If the data source is a function, then we run it and use the return,
  1007. // executing in the scope of the data object (for instances)
  1008. return cellData.call( rowData );
  1009. }
  1010. if ( cellData === null && type == 'display' ) {
  1011. return '';
  1012. }
  1013. return cellData;
  1014. }
  1015. /**
  1016. * Set the value for a specific cell, into the internal data cache
  1017. * @param {object} settings dataTables settings object
  1018. * @param {int} rowIdx aoData row id
  1019. * @param {int} colIdx Column index
  1020. * @param {*} val Value to set
  1021. * @memberof DataTable#oApi
  1022. */
  1023. function _fnSetCellData( settings, rowIdx, colIdx, val )
  1024. {
  1025. var col = settings.aoColumns[colIdx];
  1026. var rowData = settings.aoData[rowIdx]._aData;
  1027. col.fnSetData( rowData, val, {
  1028. settings: settings,
  1029. row: rowIdx,
  1030. col: colIdx
  1031. } );
  1032. }
  1033. // Private variable that is used to match action syntax in the data property object
  1034. var __reArray = /\[.*?\]$/;
  1035. var __reFn = /\(\)$/;
  1036. /**
  1037. * Split string on periods, taking into account escaped periods
  1038. * @param {string} str String to split
  1039. * @return {array} Split string
  1040. */
  1041. function _fnSplitObjNotation( str )
  1042. {
  1043. return $.map( str.match(/(\\.|[^\.])+/g) || [''], function ( s ) {
  1044. return s.replace(/\\./g, '.');
  1045. } );
  1046. }
  1047. /**
  1048. * Return a function that can be used to get data from a source object, taking
  1049. * into account the ability to use nested objects as a source
  1050. * @param {string|int|function} mSource The data source for the object
  1051. * @returns {function} Data get function
  1052. * @memberof DataTable#oApi
  1053. */
  1054. function _fnGetObjectDataFn( mSource )
  1055. {
  1056. if ( $.isPlainObject( mSource ) )
  1057. {
  1058. /* Build an object of get functions, and wrap them in a single call */
  1059. var o = {};
  1060. $.each( mSource, function (key, val) {
  1061. if ( val ) {
  1062. o[key] = _fnGetObjectDataFn( val );
  1063. }
  1064. } );
  1065. return function (data, type, row, meta) {
  1066. var t = o[type] || o._;
  1067. return t !== undefined ?
  1068. t(data, type, row, meta) :
  1069. data;
  1070. };
  1071. }
  1072. else if ( mSource === null )
  1073. {
  1074. /* Give an empty string for rendering / sorting etc */
  1075. return function (data) { // type, row and meta also passed, but not used
  1076. return data;
  1077. };
  1078. }
  1079. else if ( typeof mSource === 'function' )
  1080. {
  1081. return function (data, type, row, meta) {
  1082. return mSource( data, type, row, meta );
  1083. };
  1084. }
  1085. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  1086. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  1087. {
  1088. /* If there is a . in the source string then the data source is in a
  1089. * nested object so we loop over the data for each level to get the next
  1090. * level down. On each loop we test for undefined, and if found immediately
  1091. * return. This allows entire objects to be missing and sDefaultContent to
  1092. * be used if defined, rather than throwing an error
  1093. */
  1094. var fetchData = function (data, type, src) {
  1095. var arrayNotation, funcNotation, out, innerSrc;
  1096. if ( src !== "" )
  1097. {
  1098. var a = _fnSplitObjNotation( src );
  1099. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  1100. {
  1101. // Check if we are dealing with special notation
  1102. arrayNotation = a[i].match(__reArray);
  1103. funcNotation = a[i].match(__reFn);
  1104. if ( arrayNotation )
  1105. {
  1106. // Array notation
  1107. a[i] = a[i].replace(__reArray, '');
  1108. // Condition allows simply [] to be passed in
  1109. if ( a[i] !== "" ) {
  1110. data = data[ a[i] ];
  1111. }
  1112. out = [];
  1113. // Get the remainder of the nested object to get
  1114. a.splice( 0, i+1 );
  1115. innerSrc = a.join('.');
  1116. // Traverse each entry in the array getting the properties requested
  1117. if ( $.isArray( data ) ) {
  1118. for ( var j=0, jLen=data.length ; j<jLen ; j++ ) {
  1119. out.push( fetchData( data[j], type, innerSrc ) );
  1120. }
  1121. }
  1122. // If a string is given in between the array notation indicators, that
  1123. // is used to join the strings together, otherwise an array is returned
  1124. var join = arrayNotation[0].substring(1, arrayNotation[0].length-1);
  1125. data = (join==="") ? out : out.join(join);
  1126. // The inner call to fetchData has already traversed through the remainder
  1127. // of the source requested, so we exit from the loop
  1128. break;
  1129. }
  1130. else if ( funcNotation )
  1131. {
  1132. // Function call
  1133. a[i] = a[i].replace(__reFn, '');
  1134. data = data[ a[i] ]();
  1135. continue;
  1136. }
  1137. if ( data === null || data[ a[i] ] === undefined )
  1138. {
  1139. return undefined;
  1140. }
  1141. data = data[ a[i] ];
  1142. }
  1143. }
  1144. return data;
  1145. };
  1146. return function (data, type) { // row and meta also passed, but not used
  1147. return fetchData( data, type, mSource );
  1148. };
  1149. }
  1150. else
  1151. {
  1152. /* Array or flat object mapping */
  1153. return function (data, type) { // row and meta also passed, but not used
  1154. return data[mSource];
  1155. };
  1156. }
  1157. }
  1158. /**
  1159. * Return a function that can be used to set data from a source object, taking
  1160. * into account the ability to use nested objects as a source
  1161. * @param {string|int|function} mSource The data source for the object
  1162. * @returns {function} Data set function
  1163. * @memberof DataTable#oApi
  1164. */
  1165. function _fnSetObjectDataFn( mSource )
  1166. {
  1167. if ( $.isPlainObject( mSource ) )
  1168. {
  1169. /* Unlike get, only the underscore (global) option is used for for
  1170. * setting data since we don't know the type here. This is why an object
  1171. * option is not documented for `mData` (which is read/write), but it is
  1172. * for `mRender` which is read only.
  1173. */
  1174. return _fnSetObjectDataFn( mSource._ );
  1175. }
  1176. else if ( mSource === null )
  1177. {
  1178. /* Nothing to do when the data source is null */
  1179. return function () {};
  1180. }
  1181. else if ( typeof mSource === 'function' )
  1182. {
  1183. return function (data, val, meta) {
  1184. mSource( data, 'set', val, meta );
  1185. };
  1186. }
  1187. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  1188. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  1189. {
  1190. /* Like the get, we need to get data from a nested object */
  1191. var setData = function (data, val, src) {
  1192. var a = _fnSplitObjNotation( src ), b;
  1193. var aLast = a[a.length-1];
  1194. var arrayNotation, funcNotation, o, innerSrc;
  1195. for ( var i=0, iLen=a.length-1 ; i<iLen ; i++ )
  1196. {
  1197. // Check if we are dealing with an array notation request
  1198. arrayNotation = a[i].match(__reArray);
  1199. funcNotation = a[i].match(__reFn);
  1200. if ( arrayNotation )
  1201. {
  1202. a[i] = a[i].replace(__reArray, '');
  1203. data[ a[i] ] = [];
  1204. // Get the remainder of the nested object to set so we can recurse
  1205. b = a.slice();
  1206. b.splice( 0, i+1 );
  1207. innerSrc = b.join('.');
  1208. // Traverse each entry in the array setting the properties requested
  1209. if ( $.isArray( val ) )
  1210. {
  1211. for ( var j=0, jLen=val.length ; j<jLen ; j++ )
  1212. {
  1213. o = {};
  1214. setData( o, val[j], innerSrc );
  1215. data[ a[i] ].push( o );
  1216. }
  1217. }
  1218. else
  1219. {
  1220. // We've been asked to save data to an array, but it
  1221. // isn't array data to be saved. Best that can be done
  1222. // is to just save the value.
  1223. data[ a[i] ] = val;
  1224. }
  1225. // The inner call to setData has already traversed through the remainder
  1226. // of the source and has set the data, thus we can exit here
  1227. return;
  1228. }
  1229. else if ( funcNotation )
  1230. {
  1231. // Function call
  1232. a[i] = a[i].replace(__reFn, '');
  1233. data = data[ a[i] ]( val );
  1234. }
  1235. // If the nested object doesn't currently exist - since we are
  1236. // trying to set the value - create it
  1237. if ( data[ a[i] ] === null || data[ a[i] ] === undefined )
  1238. {
  1239. data[ a[i] ] = {};
  1240. }
  1241. data = data[ a[i] ];
  1242. }
  1243. // Last item in the input - i.e, the actual set
  1244. if ( aLast.match(__reFn ) )
  1245. {
  1246. // Function call
  1247. data = data[ aLast.replace(__reFn, '') ]( val );
  1248. }
  1249. else
  1250. {
  1251. // If array notation is used, we just want to strip it and use the property name
  1252. // and assign the value. If it isn't used, then we get the result we want anyway
  1253. data[ aLast.replace(__reArray, '') ] = val;
  1254. }
  1255. };
  1256. return function (data, val) { // meta is also passed in, but not used
  1257. return setData( data, val, mSource );
  1258. };
  1259. }
  1260. else
  1261. {
  1262. /* Array or flat object mapping */
  1263. return function (data, val) { // meta is also passed in, but not used
  1264. data[mSource] = val;
  1265. };
  1266. }
  1267. }
  1268. /**
  1269. * Return an array with the full table data
  1270. * @param {object} oSettings dataTables settings object
  1271. * @returns array {array} aData Master data array
  1272. * @memberof DataTable#oApi
  1273. */
  1274. function _fnGetDataMaster ( settings )
  1275. {
  1276. return _pluck( settings.aoData, '_aData' );
  1277. }
  1278. /**
  1279. * Nuke the table
  1280. * @param {object} oSettings dataTables settings object
  1281. * @memberof DataTable#oApi
  1282. */
  1283. function _fnClearTable( settings )
  1284. {
  1285. settings.aoData.length = 0;
  1286. settings.aiDisplayMaster.length = 0;
  1287. settings.aiDisplay.length = 0;
  1288. settings.aIds = {};
  1289. }
  1290. /**
  1291. * Take an array of integers (index array) and remove a target integer (value - not
  1292. * the key!)
  1293. * @param {array} a Index array to target
  1294. * @param {int} iTarget value to find
  1295. * @memberof DataTable#oApi
  1296. */
  1297. function _fnDeleteIndex( a, iTarget, splice )
  1298. {
  1299. var iTargetIndex = -1;
  1300. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  1301. {
  1302. if ( a[i] == iTarget )
  1303. {
  1304. iTargetIndex = i;
  1305. }
  1306. else if ( a[i] > iTarget )
  1307. {
  1308. a[i]--;
  1309. }
  1310. }
  1311. if ( iTargetIndex != -1 && splice === undefined )
  1312. {
  1313. a.splice( iTargetIndex, 1 );
  1314. }
  1315. }
  1316. /**
  1317. * Mark cached data as invalid such that a re-read of the data will occur when
  1318. * the cached data is next requested. Also update from the data source object.
  1319. *
  1320. * @param {object} settings DataTables settings object
  1321. * @param {int} rowIdx Row index to invalidate
  1322. * @param {string} [src] Source to invalidate from: undefined, 'auto', 'dom'
  1323. * or 'data'
  1324. * @param {int} [colIdx] Column index to invalidate. If undefined the whole
  1325. * row will be invalidated
  1326. * @memberof DataTable#oApi
  1327. *
  1328. * @todo For the modularisation of v1.11 this will need to become a callback, so
  1329. * the sort and filter methods can subscribe to it. That will required
  1330. * initialisation options for sorting, which is why it is not already baked in
  1331. */
  1332. function _fnInvalidate( settings, rowIdx, src, colIdx )
  1333. {
  1334. var row = settings.aoData[ rowIdx ];
  1335. var i, ien;
  1336. var cellWrite = function ( cell, col ) {
  1337. // This is very frustrating, but in IE if you just write directly
  1338. // to innerHTML, and elements that are overwritten are GC'ed,
  1339. // even if there is a reference to them elsewhere
  1340. while ( cell.childNodes.length ) {
  1341. cell.removeChild( cell.firstChild );
  1342. }
  1343. cell.innerHTML = _fnGetCellData( settings, rowIdx, col, 'display' );
  1344. };
  1345. // Are we reading last data from DOM or the data object?
  1346. if ( src === 'dom' || ((! src || src === 'auto') && row.src === 'dom') ) {
  1347. // Read the data from the DOM
  1348. row._aData = _fnGetRowElements(
  1349. settings, row, colIdx, colIdx === undefined ? undefined : row._aData
  1350. )
  1351. .data;
  1352. }
  1353. else {
  1354. // Reading from data object, update the DOM
  1355. var cells = row.anCells;
  1356. if ( cells ) {
  1357. if ( colIdx !== undefined ) {
  1358. cellWrite( cells[colIdx], colIdx );
  1359. }
  1360. else {
  1361. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  1362. cellWrite( cells[i], i );
  1363. }
  1364. }
  1365. }
  1366. }
  1367. // For both row and cell invalidation, the cached data for sorting and
  1368. // filtering is nulled out
  1369. row._aSortData = null;
  1370. row._aFilterData = null;
  1371. // Invalidate the type for a specific column (if given) or all columns since
  1372. // the data might have changed
  1373. var cols = settings.aoColumns;
  1374. if ( colIdx !== undefined ) {
  1375. cols[ colIdx ].sType = null;
  1376. }
  1377. else {
  1378. for ( i=0, ien=cols.length ; i<ien ; i++ ) {
  1379. cols[i].sType = null;
  1380. }
  1381. // Update DataTables special `DT_*` attributes for the row
  1382. _fnRowAttributes( settings, row );
  1383. }
  1384. }
  1385. /**
  1386. * Build a data source object from an HTML row, reading the contents of the
  1387. * cells that are in the row.
  1388. *
  1389. * @param {object} settings DataTables settings object
  1390. * @param {node|object} TR element from which to read data or existing row
  1391. * object from which to re-read the data from the cells
  1392. * @param {int} [colIdx] Optional column index
  1393. * @param {array|object} [d] Data source object. If `colIdx` is given then this
  1394. * parameter should also be given and will be used to write the data into.
  1395. * Only the column in question will be written
  1396. * @returns {object} Object with two parameters: `data` the data read, in
  1397. * document order, and `cells` and array of nodes (they can be useful to the
  1398. * caller, so rather than needing a second traversal to get them, just return
  1399. * them from here).
  1400. * @memberof DataTable#oApi
  1401. */
  1402. function _fnGetRowElements( settings, row, colIdx, d )
  1403. {
  1404. var
  1405. tds = [],
  1406. td = row.firstChild,
  1407. name, col, o, i=0, contents,
  1408. columns = settings.aoColumns,
  1409. objectRead = settings._rowReadObject;
  1410. // Allow the data object to be passed in, or construct
  1411. d = d !== undefined ?
  1412. d :
  1413. objectRead ?
  1414. {} :
  1415. [];
  1416. var attr = function ( str, td ) {
  1417. if ( typeof str === 'string' ) {
  1418. var idx = str.indexOf('@');
  1419. if ( idx !== -1 ) {
  1420. var attr = str.substring( idx+1 );
  1421. var setter = _fnSetObjectDataFn( str );
  1422. setter( d, td.getAttribute( attr ) );
  1423. }
  1424. }
  1425. };
  1426. // Read data from a cell and store into the data object
  1427. var cellProcess = function ( cell ) {
  1428. if ( colIdx === undefined || colIdx === i ) {
  1429. col = columns[i];
  1430. contents = $.trim(cell.innerHTML);
  1431. if ( col && col._bAttrSrc ) {
  1432. var setter = _fnSetObjectDataFn( col.mData._ );
  1433. setter( d, contents );
  1434. attr( col.mData.sort, cell );
  1435. attr( col.mData.type, cell );
  1436. attr( col.mData.filter, cell );
  1437. }
  1438. else {
  1439. // Depending on the `data` option for the columns the data can
  1440. // be read to either an object or an array.
  1441. if ( objectRead ) {
  1442. if ( ! col._setter ) {
  1443. // Cache the setter function
  1444. col._setter = _fnSetObjectDataFn( col.mData );
  1445. }
  1446. col._setter( d, contents );
  1447. }
  1448. else {
  1449. d[i] = contents;
  1450. }
  1451. }
  1452. }
  1453. i++;
  1454. };
  1455. if ( td ) {
  1456. // `tr` element was passed in
  1457. while ( td ) {
  1458. name = td.nodeName.toUpperCase();
  1459. if ( name == "TD" || name == "TH" ) {
  1460. cellProcess( td );
  1461. tds.push( td );
  1462. }
  1463. td = td.nextSibling;
  1464. }
  1465. }
  1466. else {
  1467. // Existing row object passed in
  1468. tds = row.anCells;
  1469. for ( var j=0, jen=tds.length ; j<jen ; j++ ) {
  1470. cellProcess( tds[j] );
  1471. }
  1472. }
  1473. // Read the ID from the DOM if present
  1474. var rowNode = row.firstChild ? row : row.nTr;
  1475. if ( rowNode ) {
  1476. var id = rowNode.getAttribute( 'id' );
  1477. if ( id ) {
  1478. _fnSetObjectDataFn( settings.rowId )( d, id );
  1479. }
  1480. }
  1481. return {
  1482. data: d,
  1483. cells: tds
  1484. };
  1485. }
  1486. /**
  1487. * Create a new TR element (and it's TD children) for a row
  1488. * @param {object} oSettings dataTables settings object
  1489. * @param {int} iRow Row to consider
  1490. * @param {node} [nTrIn] TR element to add to the table - optional. If not given,
  1491. * DataTables will create a row automatically
  1492. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  1493. * if nTr is.
  1494. * @memberof DataTable#oApi
  1495. */
  1496. function _fnCreateTr ( oSettings, iRow, nTrIn, anTds )
  1497. {
  1498. var
  1499. row = oSettings.aoData[iRow],
  1500. rowData = row._aData,
  1501. cells = [],
  1502. nTr, nTd, oCol,
  1503. i, iLen;
  1504. if ( row.nTr === null )
  1505. {
  1506. nTr = nTrIn || document.createElement('tr');
  1507. row.nTr = nTr;
  1508. row.anCells = cells;
  1509. /* Use a private property on the node to allow reserve mapping from the node
  1510. * to the aoData array for fast look up
  1511. */
  1512. nTr._DT_RowIndex = iRow;
  1513. /* Special parameters can be given by the data source to be used on the row */
  1514. _fnRowAttributes( oSettings, row );
  1515. /* Process each column */
  1516. for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
  1517. {
  1518. oCol = oSettings.aoColumns[i];
  1519. nTd = nTrIn ? anTds[i] : document.createElement( oCol.sCellType );
  1520. nTd._DT_CellIndex = {
  1521. row: iRow,
  1522. column: i
  1523. };
  1524. cells.push( nTd );
  1525. // Need to create the HTML if new, or if a rendering function is defined
  1526. if ( (!nTrIn || oCol.mRender || oCol.mData !== i) &&
  1527. (!$.isPlainObject(oCol.mData) || oCol.mData._ !== i+'.display')
  1528. ) {
  1529. nTd.innerHTML = _fnGetCellData( oSettings, iRow, i, 'display' );
  1530. }
  1531. /* Add user defined class */
  1532. if ( oCol.sClass )
  1533. {
  1534. nTd.className += ' '+oCol.sClass;
  1535. }
  1536. // Visibility - add or remove as required
  1537. if ( oCol.bVisible && ! nTrIn )
  1538. {
  1539. nTr.appendChild( nTd );
  1540. }
  1541. else if ( ! oCol.bVisible && nTrIn )
  1542. {
  1543. nTd.parentNode.removeChild( nTd );
  1544. }
  1545. if ( oCol.fnCreatedCell )
  1546. {
  1547. oCol.fnCreatedCell.call( oSettings.oInstance,
  1548. nTd, _fnGetCellData( oSettings, iRow, i ), rowData, iRow, i
  1549. );
  1550. }
  1551. }
  1552. _fnCallbackFire( oSettings, 'aoRowCreatedCallback', null, [nTr, rowData, iRow] );
  1553. }
  1554. // Remove once webkit bug 131819 and Chromium bug 365619 have been resolved
  1555. // and deployed
  1556. row.nTr.setAttribute( 'role', 'row' );
  1557. }
  1558. /**
  1559. * Add attributes to a row based on the special `DT_*` parameters in a data
  1560. * source object.
  1561. * @param {object} settings DataTables settings object
  1562. * @param {object} DataTables row object for the row to be modified
  1563. * @memberof DataTable#oApi
  1564. */
  1565. function _fnRowAttributes( settings, row )
  1566. {
  1567. var tr = row.nTr;
  1568. var data = row._aData;
  1569. if ( tr ) {
  1570. var id = settings.rowIdFn( data );
  1571. if ( id ) {
  1572. tr.id = id;
  1573. }
  1574. if ( data.DT_RowClass ) {
  1575. // Remove any classes added by DT_RowClass before
  1576. var a = data.DT_RowClass.split(' ');
  1577. row.__rowc = row.__rowc ?
  1578. _unique( row.__rowc.concat( a ) ) :
  1579. a;
  1580. $(tr)
  1581. .removeClass( row.__rowc.join(' ') )
  1582. .addClass( data.DT_RowClass );
  1583. }
  1584. if ( data.DT_RowAttr ) {
  1585. $(tr).attr( data.DT_RowAttr );
  1586. }
  1587. if ( data.DT_RowData ) {
  1588. $(tr).data( data.DT_RowData );
  1589. }
  1590. }
  1591. }
  1592. /**
  1593. * Create the HTML header for the table
  1594. * @param {object} oSettings dataTables settings object
  1595. * @memberof DataTable#oApi
  1596. */
  1597. function _fnBuildHead( oSettings )
  1598. {
  1599. var i, ien, cell, row, column;
  1600. var thead = oSettings.nTHead;
  1601. var tfoot = oSettings.nTFoot;
  1602. var createHeader = $('th, td', thead).length === 0;
  1603. var classes = oSettings.oClasses;
  1604. var columns = oSettings.aoColumns;
  1605. if ( createHeader ) {
  1606. row = $('<tr/>').appendTo( thead );
  1607. }
  1608. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  1609. column = columns[i];
  1610. cell = $( column.nTh ).addClass( column.sClass );
  1611. if ( createHeader ) {
  1612. cell.appendTo( row );
  1613. }
  1614. // 1.11 move into sorting
  1615. if ( oSettings.oFeatures.bSort ) {
  1616. cell.addClass( column.sSortingClass );
  1617. if ( column.bSortable !== false ) {
  1618. cell
  1619. .attr( 'tabindex', oSettings.iTabIndex )
  1620. .attr( 'aria-controls', oSettings.sTableId );
  1621. _fnSortAttachListener( oSettings, column.nTh, i );
  1622. }
  1623. }
  1624. if ( column.sTitle != cell[0].innerHTML ) {
  1625. cell.html( column.sTitle );
  1626. }
  1627. _fnRenderer( oSettings, 'header' )(
  1628. oSettings, cell, column, classes
  1629. );
  1630. }
  1631. if ( createHeader ) {
  1632. _fnDetectHeader( oSettings.aoHeader, thead );
  1633. }
  1634. /* ARIA role for the rows */
  1635. $(thead).find('>tr').attr('role', 'row');
  1636. /* Deal with the footer - add classes if required */
  1637. $(thead).find('>tr>th, >tr>td').addClass( classes.sHeaderTH );
  1638. $(tfoot).find('>tr>th, >tr>td').addClass( classes.sFooterTH );
  1639. // Cache the footer cells. Note that we only take the cells from the first
  1640. // row in the footer. If there is more than one row the user wants to
  1641. // interact with, they need to use the table().foot() method. Note also this
  1642. // allows cells to be used for multiple columns using colspan
  1643. if ( tfoot !== null ) {
  1644. var cells = oSettings.aoFooter[0];
  1645. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  1646. column = columns[i];
  1647. column.nTf = cells[i].cell;
  1648. if ( column.sClass ) {
  1649. $(column.nTf).addClass( column.sClass );
  1650. }
  1651. }
  1652. }
  1653. }
  1654. /**
  1655. * Draw the header (or footer) element based on the column visibility states. The
  1656. * methodology here is to use the layout array from _fnDetectHeader, modified for
  1657. * the instantaneous column visibility, to construct the new layout. The grid is
  1658. * traversed over cell at a time in a rows x columns grid fashion, although each
  1659. * cell insert can cover multiple elements in the grid - which is tracks using the
  1660. * aApplied array. Cell inserts in the grid will only occur where there isn't
  1661. * already a cell in that position.
  1662. * @param {object} oSettings dataTables settings object
  1663. * @param array {objects} aoSource Layout array from _fnDetectHeader
  1664. * @param {boolean} [bIncludeHidden=false] If true then include the hidden columns in the calc,
  1665. * @memberof DataTable#oApi
  1666. */
  1667. function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
  1668. {
  1669. var i, iLen, j, jLen, k, kLen, n, nLocalTr;
  1670. var aoLocal = [];
  1671. var aApplied = [];
  1672. var iColumns = oSettings.aoColumns.length;
  1673. var iRowspan, iColspan;
  1674. if ( ! aoSource )
  1675. {
  1676. return;
  1677. }
  1678. if ( bIncludeHidden === undefined )
  1679. {
  1680. bIncludeHidden = false;
  1681. }
  1682. /* Make a copy of the master layout array, but without the visible columns in it */
  1683. for ( i=0, iLen=aoSource.length ; i<iLen ; i++ )
  1684. {
  1685. aoLocal[i] = aoSource[i].slice();
  1686. aoLocal[i].nTr = aoSource[i].nTr;
  1687. /* Remove any columns which are currently hidden */
  1688. for ( j=iColumns-1 ; j>=0 ; j-- )
  1689. {
  1690. if ( !oSettings.aoColumns[j].bVisible && !bIncludeHidden )
  1691. {
  1692. aoLocal[i].splice( j, 1 );
  1693. }
  1694. }
  1695. /* Prep the applied array - it needs an element for each row */
  1696. aApplied.push( [] );
  1697. }
  1698. for ( i=0, iLen=aoLocal.length ; i<iLen ; i++ )
  1699. {
  1700. nLocalTr = aoLocal[i].nTr;
  1701. /* All cells are going to be replaced, so empty out the row */
  1702. if ( nLocalTr )
  1703. {
  1704. while( (n = nLocalTr.firstChild) )
  1705. {
  1706. nLocalTr.removeChild( n );
  1707. }
  1708. }
  1709. for ( j=0, jLen=aoLocal[i].length ; j<jLen ; j++ )
  1710. {
  1711. iRowspan = 1;
  1712. iColspan = 1;
  1713. /* Check to see if there is already a cell (row/colspan) covering our target
  1714. * insert point. If there is, then there is nothing to do.
  1715. */
  1716. if ( aApplied[i][j] === undefined )
  1717. {
  1718. nLocalTr.appendChild( aoLocal[i][j].cell );
  1719. aApplied[i][j] = 1;
  1720. /* Expand the cell to cover as many rows as needed */
  1721. while ( aoLocal[i+iRowspan] !== undefined &&
  1722. aoLocal[i][j].cell == aoLocal[i+iRowspan][j].cell )
  1723. {
  1724. aApplied[i+iRowspan][j] = 1;
  1725. iRowspan++;
  1726. }
  1727. /* Expand the cell to cover as many columns as needed */
  1728. while ( aoLocal[i][j+iColspan] !== undefined &&
  1729. aoLocal[i][j].cell == aoLocal[i][j+iColspan].cell )
  1730. {
  1731. /* Must update the applied array over the rows for the columns */
  1732. for ( k=0 ; k<iRowspan ; k++ )
  1733. {
  1734. aApplied[i+k][j+iColspan] = 1;
  1735. }
  1736. iColspan++;
  1737. }
  1738. /* Do the actual expansion in the DOM */
  1739. $(aoLocal[i][j].cell)
  1740. .attr('rowspan', iRowspan)
  1741. .attr('colspan', iColspan);
  1742. }
  1743. }
  1744. }
  1745. }
  1746. /**
  1747. * Insert the required TR nodes into the table for display
  1748. * @param {object} oSettings dataTables settings object
  1749. * @memberof DataTable#oApi
  1750. */
  1751. function _fnDraw( oSettings )
  1752. {
  1753. /* Provide a pre-callback function which can be used to cancel the draw is false is returned */
  1754. var aPreDraw = _fnCallbackFire( oSettings, 'aoPreDrawCallback', 'preDraw', [oSettings] );
  1755. if ( $.inArray( false, aPreDraw ) !== -1 )
  1756. {
  1757. _fnProcessingDisplay( oSettings, false );
  1758. return;
  1759. }
  1760. var i, iLen, n;
  1761. var anRows = [];
  1762. var iRowCount = 0;
  1763. var asStripeClasses = oSettings.asStripeClasses;
  1764. var iStripes = asStripeClasses.length;
  1765. var iOpenRows = oSettings.aoOpenRows.length;
  1766. var oLang = oSettings.oLanguage;
  1767. var iInitDisplayStart = oSettings.iInitDisplayStart;
  1768. var bServerSide = _fnDataSource( oSettings ) == 'ssp';
  1769. var aiDisplay = oSettings.aiDisplay;
  1770. oSettings.bDrawing = true;
  1771. /* Check and see if we have an initial draw position from state saving */
  1772. if ( iInitDisplayStart !== undefined && iInitDisplayStart !== -1 )
  1773. {
  1774. oSettings._iDisplayStart = bServerSide ?
  1775. iInitDisplayStart :
  1776. iInitDisplayStart >= oSettings.fnRecordsDisplay() ?
  1777. 0 :
  1778. iInitDisplayStart;
  1779. oSettings.iInitDisplayStart = -1;
  1780. }
  1781. var iDisplayStart = oSettings._iDisplayStart;
  1782. var iDisplayEnd = oSettings.fnDisplayEnd();
  1783. /* Server-side processing draw intercept */
  1784. if ( oSettings.bDeferLoading )
  1785. {
  1786. oSettings.bDeferLoading = false;
  1787. oSettings.iDraw++;
  1788. _fnProcessingDisplay( oSettings, false );
  1789. }
  1790. else if ( !bServerSide )
  1791. {
  1792. oSettings.iDraw++;
  1793. }
  1794. else if ( !oSettings.bDestroying && !_fnAjaxUpdate( oSettings ) )
  1795. {
  1796. return;
  1797. }
  1798. if ( aiDisplay.length !== 0 )
  1799. {
  1800. var iStart = bServerSide ? 0 : iDisplayStart;
  1801. var iEnd = bServerSide ? oSettings.aoData.length : iDisplayEnd;
  1802. for ( var j=iStart ; j<iEnd ; j++ )
  1803. {
  1804. var iDataIndex = aiDisplay[j];
  1805. var aoData = oSettings.aoData[ iDataIndex ];
  1806. if ( aoData.nTr === null )
  1807. {
  1808. _fnCreateTr( oSettings, iDataIndex );
  1809. }
  1810. var nRow = aoData.nTr;
  1811. /* Remove the old striping classes and then add the new one */
  1812. if ( iStripes !== 0 )
  1813. {
  1814. var sStripe = asStripeClasses[ iRowCount % iStripes ];
  1815. if ( aoData._sRowStripe != sStripe )
  1816. {
  1817. $(nRow).removeClass( aoData._sRowStripe ).addClass( sStripe );
  1818. aoData._sRowStripe = sStripe;
  1819. }
  1820. }
  1821. // Row callback functions - might want to manipulate the row
  1822. // iRowCount and j are not currently documented. Are they at all
  1823. // useful?
  1824. _fnCallbackFire( oSettings, 'aoRowCallback', null,
  1825. [nRow, aoData._aData, iRowCount, j] );
  1826. anRows.push( nRow );
  1827. iRowCount++;
  1828. }
  1829. }
  1830. else
  1831. {
  1832. /* Table is empty - create a row with an empty message in it */
  1833. var sZero = oLang.sZeroRecords;
  1834. if ( oSettings.iDraw == 1 && _fnDataSource( oSettings ) == 'ajax' )
  1835. {
  1836. sZero = oLang.sLoadingRecords;
  1837. }
  1838. else if ( oLang.sEmptyTable && oSettings.fnRecordsTotal() === 0 )
  1839. {
  1840. sZero = oLang.sEmptyTable;
  1841. }
  1842. anRows[ 0 ] = $( '<tr/>', { 'class': iStripes ? asStripeClasses[0] : '' } )
  1843. .append( $('<td />', {
  1844. 'valign': 'top',
  1845. 'colSpan': _fnVisbleColumns( oSettings ),
  1846. 'class': oSettings.oClasses.sRowEmpty
  1847. } ).html( sZero ) )[0];
  1848. }
  1849. /* Header and footer callbacks */
  1850. _fnCallbackFire( oSettings, 'aoHeaderCallback', 'header', [ $(oSettings.nTHead).children('tr')[0],
  1851. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  1852. _fnCallbackFire( oSettings, 'aoFooterCallback', 'footer', [ $(oSettings.nTFoot).children('tr')[0],
  1853. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  1854. var body = $(oSettings.nTBody);
  1855. body.children().detach();
  1856. body.append( $(anRows) );
  1857. /* Call all required callback functions for the end of a draw */
  1858. _fnCallbackFire( oSettings, 'aoDrawCallback', 'draw', [oSettings] );
  1859. /* Draw is complete, sorting and filtering must be as well */
  1860. oSettings.bSorted = false;
  1861. oSettings.bFiltered = false;
  1862. oSettings.bDrawing = false;
  1863. }
  1864. /**
  1865. * Redraw the table - taking account of the various features which are enabled
  1866. * @param {object} oSettings dataTables settings object
  1867. * @param {boolean} [holdPosition] Keep the current paging position. By default
  1868. * the paging is reset to the first page
  1869. * @memberof DataTable#oApi
  1870. */
  1871. function _fnReDraw( settings, holdPosition )
  1872. {
  1873. var
  1874. features = settings.oFeatures,
  1875. sort = features.bSort,
  1876. filter = features.bFilter;
  1877. if ( sort ) {
  1878. _fnSort( settings );
  1879. }
  1880. if ( filter ) {
  1881. _fnFilterComplete( settings, settings.oPreviousSearch );
  1882. }
  1883. else {
  1884. // No filtering, so we want to just use the display master
  1885. settings.aiDisplay = settings.aiDisplayMaster.slice();
  1886. }
  1887. if ( holdPosition !== true ) {
  1888. settings._iDisplayStart = 0;
  1889. }
  1890. // Let any modules know about the draw hold position state (used by
  1891. // scrolling internally)
  1892. settings._drawHold = holdPosition;
  1893. _fnDraw( settings );
  1894. settings._drawHold = false;
  1895. }
  1896. /**
  1897. * Add the options to the page HTML for the table
  1898. * @param {object} oSettings dataTables settings object
  1899. * @memberof DataTable#oApi
  1900. */
  1901. function _fnAddOptionsHtml ( oSettings )
  1902. {
  1903. var classes = oSettings.oClasses;
  1904. var table = $(oSettings.nTable);
  1905. var holding = $('<div/>').insertBefore( table ); // Holding element for speed
  1906. var features = oSettings.oFeatures;
  1907. // All DataTables are wrapped in a div
  1908. var insert = $('<div/>', {
  1909. id: oSettings.sTableId+'_wrapper',
  1910. 'class': classes.sWrapper + (oSettings.nTFoot ? '' : ' '+classes.sNoFooter)
  1911. } );
  1912. oSettings.nHolding = holding[0];
  1913. oSettings.nTableWrapper = insert[0];
  1914. oSettings.nTableReinsertBefore = oSettings.nTable.nextSibling;
  1915. /* Loop over the user set positioning and place the elements as needed */
  1916. var aDom = oSettings.sDom.split('');
  1917. var featureNode, cOption, nNewNode, cNext, sAttr, j;
  1918. for ( var i=0 ; i<aDom.length ; i++ )
  1919. {
  1920. featureNode = null;
  1921. cOption = aDom[i];
  1922. if ( cOption == '<' )
  1923. {
  1924. /* New container div */
  1925. nNewNode = $('<div/>')[0];
  1926. /* Check to see if we should append an id and/or a class name to the container */
  1927. cNext = aDom[i+1];
  1928. if ( cNext == "'" || cNext == '"' )
  1929. {
  1930. sAttr = "";
  1931. j = 2;
  1932. while ( aDom[i+j] != cNext )
  1933. {
  1934. sAttr += aDom[i+j];
  1935. j++;
  1936. }
  1937. /* Replace jQuery UI constants @todo depreciated */
  1938. if ( sAttr == "H" )
  1939. {
  1940. sAttr = classes.sJUIHeader;
  1941. }
  1942. else if ( sAttr == "F" )
  1943. {
  1944. sAttr = classes.sJUIFooter;
  1945. }
  1946. /* The attribute can be in the format of "#id.class", "#id" or "class" This logic
  1947. * breaks the string into parts and applies them as needed
  1948. */
  1949. if ( sAttr.indexOf('.') != -1 )
  1950. {
  1951. var aSplit = sAttr.split('.');
  1952. nNewNode.id = aSplit[0].substr(1, aSplit[0].length-1);
  1953. nNewNode.className = aSplit[1];
  1954. }
  1955. else if ( sAttr.charAt(0) == "#" )
  1956. {
  1957. nNewNode.id = sAttr.substr(1, sAttr.length-1);
  1958. }
  1959. else
  1960. {
  1961. nNewNode.className = sAttr;
  1962. }
  1963. i += j; /* Move along the position array */
  1964. }
  1965. insert.append( nNewNode );
  1966. insert = $(nNewNode);
  1967. }
  1968. else if ( cOption == '>' )
  1969. {
  1970. /* End container div */
  1971. insert = insert.parent();
  1972. }
  1973. // @todo Move options into their own plugins?
  1974. else if ( cOption == 'l' && features.bPaginate && features.bLengthChange )
  1975. {
  1976. /* Length */
  1977. featureNode = _fnFeatureHtmlLength( oSettings );
  1978. }
  1979. else if ( cOption == 'f' && features.bFilter )
  1980. {
  1981. /* Filter */
  1982. featureNode = _fnFeatureHtmlFilter( oSettings );
  1983. }
  1984. else if ( cOption == 'r' && features.bProcessing )
  1985. {
  1986. /* pRocessing */
  1987. featureNode = _fnFeatureHtmlProcessing( oSettings );
  1988. }
  1989. else if ( cOption == 't' )
  1990. {
  1991. /* Table */
  1992. featureNode = _fnFeatureHtmlTable( oSettings );
  1993. }
  1994. else if ( cOption == 'i' && features.bInfo )
  1995. {
  1996. /* Info */
  1997. featureNode = _fnFeatureHtmlInfo( oSettings );
  1998. }
  1999. else if ( cOption == 'p' && features.bPaginate )
  2000. {
  2001. /* Pagination */
  2002. featureNode = _fnFeatureHtmlPaginate( oSettings );
  2003. }
  2004. else if ( DataTable.ext.feature.length !== 0 )
  2005. {
  2006. /* Plug-in features */
  2007. var aoFeatures = DataTable.ext.feature;
  2008. for ( var k=0, kLen=aoFeatures.length ; k<kLen ; k++ )
  2009. {
  2010. if ( cOption == aoFeatures[k].cFeature )
  2011. {
  2012. featureNode = aoFeatures[k].fnInit( oSettings );
  2013. break;
  2014. }
  2015. }
  2016. }
  2017. /* Add to the 2D features array */
  2018. if ( featureNode )
  2019. {
  2020. var aanFeatures = oSettings.aanFeatures;
  2021. if ( ! aanFeatures[cOption] )
  2022. {
  2023. aanFeatures[cOption] = [];
  2024. }
  2025. aanFeatures[cOption].push( featureNode );
  2026. insert.append( featureNode );
  2027. }
  2028. }
  2029. /* Built our DOM structure - replace the holding div with what we want */
  2030. holding.replaceWith( insert );
  2031. oSettings.nHolding = null;
  2032. }
  2033. /**
  2034. * Use the DOM source to create up an array of header cells. The idea here is to
  2035. * create a layout grid (array) of rows x columns, which contains a reference
  2036. * to the cell that that point in the grid (regardless of col/rowspan), such that
  2037. * any column / row could be removed and the new grid constructed
  2038. * @param array {object} aLayout Array to store the calculated layout in
  2039. * @param {node} nThead The header/footer element for the table
  2040. * @memberof DataTable#oApi
  2041. */
  2042. function _fnDetectHeader ( aLayout, nThead )
  2043. {
  2044. var nTrs = $(nThead).children('tr');
  2045. var nTr, nCell;
  2046. var i, k, l, iLen, jLen, iColShifted, iColumn, iColspan, iRowspan;
  2047. var bUnique;
  2048. var fnShiftCol = function ( a, i, j ) {
  2049. var k = a[i];
  2050. while ( k[j] ) {
  2051. j++;
  2052. }
  2053. return j;
  2054. };
  2055. aLayout.splice( 0, aLayout.length );
  2056. /* We know how many rows there are in the layout - so prep it */
  2057. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  2058. {
  2059. aLayout.push( [] );
  2060. }
  2061. /* Calculate a layout array */
  2062. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  2063. {
  2064. nTr = nTrs[i];
  2065. iColumn = 0;
  2066. /* For every cell in the row... */
  2067. nCell = nTr.firstChild;
  2068. while ( nCell ) {
  2069. if ( nCell.nodeName.toUpperCase() == "TD" ||
  2070. nCell.nodeName.toUpperCase() == "TH" )
  2071. {
  2072. /* Get the col and rowspan attributes from the DOM and sanitise them */
  2073. iColspan = nCell.getAttribute('colspan') * 1;
  2074. iRowspan = nCell.getAttribute('rowspan') * 1;
  2075. iColspan = (!iColspan || iColspan===0 || iColspan===1) ? 1 : iColspan;
  2076. iRowspan = (!iRowspan || iRowspan===0 || iRowspan===1) ? 1 : iRowspan;
  2077. /* There might be colspan cells already in this row, so shift our target
  2078. * accordingly
  2079. */
  2080. iColShifted = fnShiftCol( aLayout, i, iColumn );
  2081. /* Cache calculation for unique columns */
  2082. bUnique = iColspan === 1 ? true : false;
  2083. /* If there is col / rowspan, copy the information into the layout grid */
  2084. for ( l=0 ; l<iColspan ; l++ )
  2085. {
  2086. for ( k=0 ; k<iRowspan ; k++ )
  2087. {
  2088. aLayout[i+k][iColShifted+l] = {
  2089. "cell": nCell,
  2090. "unique": bUnique
  2091. };
  2092. aLayout[i+k].nTr = nTr;
  2093. }
  2094. }
  2095. }
  2096. nCell = nCell.nextSibling;
  2097. }
  2098. }
  2099. }
  2100. /**
  2101. * Get an array of unique th elements, one for each column
  2102. * @param {object} oSettings dataTables settings object
  2103. * @param {node} nHeader automatically detect the layout from this node - optional
  2104. * @param {array} aLayout thead/tfoot layout from _fnDetectHeader - optional
  2105. * @returns array {node} aReturn list of unique th's
  2106. * @memberof DataTable#oApi
  2107. */
  2108. function _fnGetUniqueThs ( oSettings, nHeader, aLayout )
  2109. {
  2110. var aReturn = [];
  2111. if ( !aLayout )
  2112. {
  2113. aLayout = oSettings.aoHeader;
  2114. if ( nHeader )
  2115. {
  2116. aLayout = [];
  2117. _fnDetectHeader( aLayout, nHeader );
  2118. }
  2119. }
  2120. for ( var i=0, iLen=aLayout.length ; i<iLen ; i++ )
  2121. {
  2122. for ( var j=0, jLen=aLayout[i].length ; j<jLen ; j++ )
  2123. {
  2124. if ( aLayout[i][j].unique &&
  2125. (!aReturn[j] || !oSettings.bSortCellsTop) )
  2126. {
  2127. aReturn[j] = aLayout[i][j].cell;
  2128. }
  2129. }
  2130. }
  2131. return aReturn;
  2132. }
  2133. /**
  2134. * Create an Ajax call based on the table's settings, taking into account that
  2135. * parameters can have multiple forms, and backwards compatibility.
  2136. *
  2137. * @param {object} oSettings dataTables settings object
  2138. * @param {array} data Data to send to the server, required by
  2139. * DataTables - may be augmented by developer callbacks
  2140. * @param {function} fn Callback function to run when data is obtained
  2141. */
  2142. function _fnBuildAjax( oSettings, data, fn )
  2143. {
  2144. // Compatibility with 1.9-, allow fnServerData and event to manipulate
  2145. _fnCallbackFire( oSettings, 'aoServerParams', 'serverParams', [data] );
  2146. // Convert to object based for 1.10+ if using the old array scheme which can
  2147. // come from server-side processing or serverParams
  2148. if ( data && $.isArray(data) ) {
  2149. var tmp = {};
  2150. var rbracket = /(.*?)\[\]$/;
  2151. $.each( data, function (key, val) {
  2152. var match = val.name.match(rbracket);
  2153. if ( match ) {
  2154. // Support for arrays
  2155. var name = match[0];
  2156. if ( ! tmp[ name ] ) {
  2157. tmp[ name ] = [];
  2158. }
  2159. tmp[ name ].push( val.value );
  2160. }
  2161. else {
  2162. tmp[val.name] = val.value;
  2163. }
  2164. } );
  2165. data = tmp;
  2166. }
  2167. var ajaxData;
  2168. var ajax = oSettings.ajax;
  2169. var instance = oSettings.oInstance;
  2170. var callback = function ( json ) {
  2171. _fnCallbackFire( oSettings, null, 'xhr', [oSettings, json, oSettings.jqXHR] );
  2172. fn( json );
  2173. };
  2174. if ( $.isPlainObject( ajax ) && ajax.data )
  2175. {
  2176. ajaxData = ajax.data;
  2177. var newData = $.isFunction( ajaxData ) ?
  2178. ajaxData( data, oSettings ) : // fn can manipulate data or return
  2179. ajaxData; // an object object or array to merge
  2180. // If the function returned something, use that alone
  2181. data = $.isFunction( ajaxData ) && newData ?
  2182. newData :
  2183. $.extend( true, data, newData );
  2184. // Remove the data property as we've resolved it already and don't want
  2185. // jQuery to do it again (it is restored at the end of the function)
  2186. delete ajax.data;
  2187. }
  2188. var baseAjax = {
  2189. "data": data,
  2190. "success": function (json) {
  2191. var error = json.error || json.sError;
  2192. if ( error ) {
  2193. _fnLog( oSettings, 0, error );
  2194. }
  2195. oSettings.json = json;
  2196. callback( json );
  2197. },
  2198. "dataType": "json",
  2199. "cache": false,
  2200. "type": oSettings.sServerMethod,
  2201. "error": function (xhr, error, thrown) {
  2202. var ret = _fnCallbackFire( oSettings, null, 'xhr', [oSettings, null, oSettings.jqXHR] );
  2203. if ( $.inArray( true, ret ) === -1 ) {
  2204. if ( error == "parsererror" ) {
  2205. _fnLog( oSettings, 0, 'Invalid JSON response', 1 );
  2206. }
  2207. else if ( xhr.readyState === 4 ) {
  2208. _fnLog( oSettings, 0, 'Ajax error', 7 );
  2209. }
  2210. }
  2211. _fnProcessingDisplay( oSettings, false );
  2212. }
  2213. };
  2214. // Store the data submitted for the API
  2215. oSettings.oAjaxData = data;
  2216. // Allow plug-ins and external processes to modify the data
  2217. _fnCallbackFire( oSettings, null, 'preXhr', [oSettings, data] );
  2218. if ( oSettings.fnServerData )
  2219. {
  2220. // DataTables 1.9- compatibility
  2221. oSettings.fnServerData.call( instance,
  2222. oSettings.sAjaxSource,
  2223. $.map( data, function (val, key) { // Need to convert back to 1.9 trad format
  2224. return { name: key, value: val };
  2225. } ),
  2226. callback,
  2227. oSettings
  2228. );
  2229. }
  2230. else if ( oSettings.sAjaxSource || typeof ajax === 'string' )
  2231. {
  2232. // DataTables 1.9- compatibility
  2233. oSettings.jqXHR = $.ajax( $.extend( baseAjax, {
  2234. url: ajax || oSettings.sAjaxSource
  2235. } ) );
  2236. }
  2237. else if ( $.isFunction( ajax ) )
  2238. {
  2239. // Is a function - let the caller define what needs to be done
  2240. oSettings.jqXHR = ajax.call( instance, data, callback, oSettings );
  2241. }
  2242. else
  2243. {
  2244. // Object to extend the base settings
  2245. oSettings.jqXHR = $.ajax( $.extend( baseAjax, ajax ) );
  2246. // Restore for next time around
  2247. ajax.data = ajaxData;
  2248. }
  2249. }
  2250. /**
  2251. * Update the table using an Ajax call
  2252. * @param {object} settings dataTables settings object
  2253. * @returns {boolean} Block the table drawing or not
  2254. * @memberof DataTable#oApi
  2255. */
  2256. function _fnAjaxUpdate( settings )
  2257. {
  2258. if ( settings.bAjaxDataGet ) {
  2259. settings.iDraw++;
  2260. _fnProcessingDisplay( settings, true );
  2261. _fnBuildAjax(
  2262. settings,
  2263. _fnAjaxParameters( settings ),
  2264. function(json) {
  2265. _fnAjaxUpdateDraw( settings, json );
  2266. }
  2267. );
  2268. return false;
  2269. }
  2270. return true;
  2271. }
  2272. /**
  2273. * Build up the parameters in an object needed for a server-side processing
  2274. * request. Note that this is basically done twice, is different ways - a modern
  2275. * method which is used by default in DataTables 1.10 which uses objects and
  2276. * arrays, or the 1.9- method with is name / value pairs. 1.9 method is used if
  2277. * the sAjaxSource option is used in the initialisation, or the legacyAjax
  2278. * option is set.
  2279. * @param {object} oSettings dataTables settings object
  2280. * @returns {bool} block the table drawing or not
  2281. * @memberof DataTable#oApi
  2282. */
  2283. function _fnAjaxParameters( settings )
  2284. {
  2285. var
  2286. columns = settings.aoColumns,
  2287. columnCount = columns.length,
  2288. features = settings.oFeatures,
  2289. preSearch = settings.oPreviousSearch,
  2290. preColSearch = settings.aoPreSearchCols,
  2291. i, data = [], dataProp, column, columnSearch,
  2292. sort = _fnSortFlatten( settings ),
  2293. displayStart = settings._iDisplayStart,
  2294. displayLength = features.bPaginate !== false ?
  2295. settings._iDisplayLength :
  2296. -1;
  2297. var param = function ( name, value ) {
  2298. data.push( { 'name': name, 'value': value } );
  2299. };
  2300. // DataTables 1.9- compatible method
  2301. param( 'sEcho', settings.iDraw );
  2302. param( 'iColumns', columnCount );
  2303. param( 'sColumns', _pluck( columns, 'sName' ).join(',') );
  2304. param( 'iDisplayStart', displayStart );
  2305. param( 'iDisplayLength', displayLength );
  2306. // DataTables 1.10+ method
  2307. var d = {
  2308. draw: settings.iDraw,
  2309. columns: [],
  2310. order: [],
  2311. start: displayStart,
  2312. length: displayLength,
  2313. search: {
  2314. value: preSearch.sSearch,
  2315. regex: preSearch.bRegex
  2316. }
  2317. };
  2318. for ( i=0 ; i<columnCount ; i++ ) {
  2319. column = columns[i];
  2320. columnSearch = preColSearch[i];
  2321. dataProp = typeof column.mData=="function" ? 'function' : column.mData ;
  2322. d.columns.push( {
  2323. data: dataProp,
  2324. name: column.sName,
  2325. searchable: column.bSearchable,
  2326. orderable: column.bSortable,
  2327. search: {
  2328. value: columnSearch.sSearch,
  2329. regex: columnSearch.bRegex
  2330. }
  2331. } );
  2332. param( "mDataProp_"+i, dataProp );
  2333. if ( features.bFilter ) {
  2334. param( 'sSearch_'+i, columnSearch.sSearch );
  2335. param( 'bRegex_'+i, columnSearch.bRegex );
  2336. param( 'bSearchable_'+i, column.bSearchable );
  2337. }
  2338. if ( features.bSort ) {
  2339. param( 'bSortable_'+i, column.bSortable );
  2340. }
  2341. }
  2342. if ( features.bFilter ) {
  2343. param( 'sSearch', preSearch.sSearch );
  2344. param( 'bRegex', preSearch.bRegex );
  2345. }
  2346. if ( features.bSort ) {
  2347. $.each( sort, function ( i, val ) {
  2348. d.order.push( { column: val.col, dir: val.dir } );
  2349. param( 'iSortCol_'+i, val.col );
  2350. param( 'sSortDir_'+i, val.dir );
  2351. } );
  2352. param( 'iSortingCols', sort.length );
  2353. }
  2354. // If the legacy.ajax parameter is null, then we automatically decide which
  2355. // form to use, based on sAjaxSource
  2356. var legacy = DataTable.ext.legacy.ajax;
  2357. if ( legacy === null ) {
  2358. return settings.sAjaxSource ? data : d;
  2359. }
  2360. // Otherwise, if legacy has been specified then we use that to decide on the
  2361. // form
  2362. return legacy ? data : d;
  2363. }
  2364. /**
  2365. * Data the data from the server (nuking the old) and redraw the table
  2366. * @param {object} oSettings dataTables settings object
  2367. * @param {object} json json data return from the server.
  2368. * @param {string} json.sEcho Tracking flag for DataTables to match requests
  2369. * @param {int} json.iTotalRecords Number of records in the data set, not accounting for filtering
  2370. * @param {int} json.iTotalDisplayRecords Number of records in the data set, accounting for filtering
  2371. * @param {array} json.aaData The data to display on this page
  2372. * @param {string} [json.sColumns] Column ordering (sName, comma separated)
  2373. * @memberof DataTable#oApi
  2374. */
  2375. function _fnAjaxUpdateDraw ( settings, json )
  2376. {
  2377. // v1.10 uses camelCase variables, while 1.9 uses Hungarian notation.
  2378. // Support both
  2379. var compat = function ( old, modern ) {
  2380. return json[old] !== undefined ? json[old] : json[modern];
  2381. };
  2382. var data = _fnAjaxDataSrc( settings, json );
  2383. var draw = compat( 'sEcho', 'draw' );
  2384. var recordsTotal = compat( 'iTotalRecords', 'recordsTotal' );
  2385. var recordsFiltered = compat( 'iTotalDisplayRecords', 'recordsFiltered' );
  2386. if ( draw ) {
  2387. // Protect against out of sequence returns
  2388. if ( draw*1 < settings.iDraw ) {
  2389. return;
  2390. }
  2391. settings.iDraw = draw * 1;
  2392. }
  2393. _fnClearTable( settings );
  2394. settings._iRecordsTotal = parseInt(recordsTotal, 10);
  2395. settings._iRecordsDisplay = parseInt(recordsFiltered, 10);
  2396. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  2397. _fnAddData( settings, data[i] );
  2398. }
  2399. settings.aiDisplay = settings.aiDisplayMaster.slice();
  2400. settings.bAjaxDataGet = false;
  2401. _fnDraw( settings );
  2402. if ( ! settings._bInitComplete ) {
  2403. _fnInitComplete( settings, json );
  2404. }
  2405. settings.bAjaxDataGet = true;
  2406. _fnProcessingDisplay( settings, false );
  2407. }
  2408. /**
  2409. * Get the data from the JSON data source to use for drawing a table. Using
  2410. * `_fnGetObjectDataFn` allows the data to be sourced from a property of the
  2411. * source object, or from a processing function.
  2412. * @param {object} oSettings dataTables settings object
  2413. * @param {object} json Data source object / array from the server
  2414. * @return {array} Array of data to use
  2415. */
  2416. function _fnAjaxDataSrc ( oSettings, json )
  2417. {
  2418. var dataSrc = $.isPlainObject( oSettings.ajax ) && oSettings.ajax.dataSrc !== undefined ?
  2419. oSettings.ajax.dataSrc :
  2420. oSettings.sAjaxDataProp; // Compatibility with 1.9-.
  2421. // Compatibility with 1.9-. In order to read from aaData, check if the
  2422. // default has been changed, if not, check for aaData
  2423. if ( dataSrc === 'data' ) {
  2424. return json.aaData || json[dataSrc];
  2425. }
  2426. return dataSrc !== "" ?
  2427. _fnGetObjectDataFn( dataSrc )( json ) :
  2428. json;
  2429. }
  2430. /**
  2431. * Generate the node required for filtering text
  2432. * @returns {node} Filter control element
  2433. * @param {object} oSettings dataTables settings object
  2434. * @memberof DataTable#oApi
  2435. */
  2436. function _fnFeatureHtmlFilter ( settings )
  2437. {
  2438. var classes = settings.oClasses;
  2439. var tableId = settings.sTableId;
  2440. var language = settings.oLanguage;
  2441. var previousSearch = settings.oPreviousSearch;
  2442. var features = settings.aanFeatures;
  2443. var input = '<input type="search" class="'+classes.sFilterInput+'"/>';
  2444. var str = language.sSearch;
  2445. str = str.match(/_INPUT_/) ?
  2446. str.replace('_INPUT_', input) :
  2447. str+input;
  2448. var filter = $('<div/>', {
  2449. 'id': ! features.f ? tableId+'_filter' : null,
  2450. 'class': classes.sFilter
  2451. } )
  2452. .append( $('<label/>' ).append( str ) );
  2453. var searchFn = function() {
  2454. /* Update all other filter input elements for the new display */
  2455. var n = features.f;
  2456. var val = !this.value ? "" : this.value; // mental IE8 fix :-(
  2457. /* Now do the filter */
  2458. if ( val != previousSearch.sSearch ) {
  2459. _fnFilterComplete( settings, {
  2460. "sSearch": val,
  2461. "bRegex": previousSearch.bRegex,
  2462. "bSmart": previousSearch.bSmart ,
  2463. "bCaseInsensitive": previousSearch.bCaseInsensitive
  2464. } );
  2465. // Need to redraw, without resorting
  2466. settings._iDisplayStart = 0;
  2467. _fnDraw( settings );
  2468. }
  2469. };
  2470. var searchDelay = settings.searchDelay !== null ?
  2471. settings.searchDelay :
  2472. _fnDataSource( settings ) === 'ssp' ?
  2473. 400 :
  2474. 0;
  2475. var jqFilter = $('input', filter)
  2476. .val( previousSearch.sSearch )
  2477. .attr( 'placeholder', language.sSearchPlaceholder )
  2478. .bind(
  2479. 'keyup.DT search.DT input.DT paste.DT cut.DT',
  2480. searchDelay ?
  2481. _fnThrottle( searchFn, searchDelay ) :
  2482. searchFn
  2483. )
  2484. .bind( 'keypress.DT', function(e) {
  2485. /* Prevent form submission */
  2486. if ( e.keyCode == 13 ) {
  2487. return false;
  2488. }
  2489. } )
  2490. .attr('aria-controls', tableId);
  2491. // Update the input elements whenever the table is filtered
  2492. $(settings.nTable).on( 'search.dt.DT', function ( ev, s ) {
  2493. if ( settings === s ) {
  2494. // IE9 throws an 'unknown error' if document.activeElement is used
  2495. // inside an iframe or frame...
  2496. try {
  2497. if ( jqFilter[0] !== document.activeElement ) {
  2498. jqFilter.val( previousSearch.sSearch );
  2499. }
  2500. }
  2501. catch ( e ) {}
  2502. }
  2503. } );
  2504. return filter[0];
  2505. }
  2506. /**
  2507. * Filter the table using both the global filter and column based filtering
  2508. * @param {object} oSettings dataTables settings object
  2509. * @param {object} oSearch search information
  2510. * @param {int} [iForce] force a research of the master array (1) or not (undefined or 0)
  2511. * @memberof DataTable#oApi
  2512. */
  2513. function _fnFilterComplete ( oSettings, oInput, iForce )
  2514. {
  2515. var oPrevSearch = oSettings.oPreviousSearch;
  2516. var aoPrevSearch = oSettings.aoPreSearchCols;
  2517. var fnSaveFilter = function ( oFilter ) {
  2518. /* Save the filtering values */
  2519. oPrevSearch.sSearch = oFilter.sSearch;
  2520. oPrevSearch.bRegex = oFilter.bRegex;
  2521. oPrevSearch.bSmart = oFilter.bSmart;
  2522. oPrevSearch.bCaseInsensitive = oFilter.bCaseInsensitive;
  2523. };
  2524. var fnRegex = function ( o ) {
  2525. // Backwards compatibility with the bEscapeRegex option
  2526. return o.bEscapeRegex !== undefined ? !o.bEscapeRegex : o.bRegex;
  2527. };
  2528. // Resolve any column types that are unknown due to addition or invalidation
  2529. // @todo As per sort - can this be moved into an event handler?
  2530. _fnColumnTypes( oSettings );
  2531. /* In server-side processing all filtering is done by the server, so no point hanging around here */
  2532. if ( _fnDataSource( oSettings ) != 'ssp' )
  2533. {
  2534. /* Global filter */
  2535. _fnFilter( oSettings, oInput.sSearch, iForce, fnRegex(oInput), oInput.bSmart, oInput.bCaseInsensitive );
  2536. fnSaveFilter( oInput );
  2537. /* Now do the individual column filter */
  2538. for ( var i=0 ; i<aoPrevSearch.length ; i++ )
  2539. {
  2540. _fnFilterColumn( oSettings, aoPrevSearch[i].sSearch, i, fnRegex(aoPrevSearch[i]),
  2541. aoPrevSearch[i].bSmart, aoPrevSearch[i].bCaseInsensitive );
  2542. }
  2543. /* Custom filtering */
  2544. _fnFilterCustom( oSettings );
  2545. }
  2546. else
  2547. {
  2548. fnSaveFilter( oInput );
  2549. }
  2550. /* Tell the draw function we have been filtering */
  2551. oSettings.bFiltered = true;
  2552. _fnCallbackFire( oSettings, null, 'search', [oSettings] );
  2553. }
  2554. /**
  2555. * Apply custom filtering functions
  2556. * @param {object} oSettings dataTables settings object
  2557. * @memberof DataTable#oApi
  2558. */
  2559. function _fnFilterCustom( settings )
  2560. {
  2561. var filters = DataTable.ext.search;
  2562. var displayRows = settings.aiDisplay;
  2563. var row, rowIdx;
  2564. for ( var i=0, ien=filters.length ; i<ien ; i++ ) {
  2565. var rows = [];
  2566. // Loop over each row and see if it should be included
  2567. for ( var j=0, jen=displayRows.length ; j<jen ; j++ ) {
  2568. rowIdx = displayRows[ j ];
  2569. row = settings.aoData[ rowIdx ];
  2570. if ( filters[i]( settings, row._aFilterData, rowIdx, row._aData, j ) ) {
  2571. rows.push( rowIdx );
  2572. }
  2573. }
  2574. // So the array reference doesn't break set the results into the
  2575. // existing array
  2576. displayRows.length = 0;
  2577. $.merge( displayRows, rows );
  2578. }
  2579. }
  2580. /**
  2581. * Filter the table on a per-column basis
  2582. * @param {object} oSettings dataTables settings object
  2583. * @param {string} sInput string to filter on
  2584. * @param {int} iColumn column to filter
  2585. * @param {bool} bRegex treat search string as a regular expression or not
  2586. * @param {bool} bSmart use smart filtering or not
  2587. * @param {bool} bCaseInsensitive Do case insenstive matching or not
  2588. * @memberof DataTable#oApi
  2589. */
  2590. function _fnFilterColumn ( settings, searchStr, colIdx, regex, smart, caseInsensitive )
  2591. {
  2592. if ( searchStr === '' ) {
  2593. return;
  2594. }
  2595. var data;
  2596. var display = settings.aiDisplay;
  2597. var rpSearch = _fnFilterCreateSearch( searchStr, regex, smart, caseInsensitive );
  2598. for ( var i=display.length-1 ; i>=0 ; i-- ) {
  2599. data = settings.aoData[ display[i] ]._aFilterData[ colIdx ];
  2600. if ( ! rpSearch.test( data ) ) {
  2601. display.splice( i, 1 );
  2602. }
  2603. }
  2604. }
  2605. /**
  2606. * Filter the data table based on user input and draw the table
  2607. * @param {object} settings dataTables settings object
  2608. * @param {string} input string to filter on
  2609. * @param {int} force optional - force a research of the master array (1) or not (undefined or 0)
  2610. * @param {bool} regex treat as a regular expression or not
  2611. * @param {bool} smart perform smart filtering or not
  2612. * @param {bool} caseInsensitive Do case insenstive matching or not
  2613. * @memberof DataTable#oApi
  2614. */
  2615. function _fnFilter( settings, input, force, regex, smart, caseInsensitive )
  2616. {
  2617. var rpSearch = _fnFilterCreateSearch( input, regex, smart, caseInsensitive );
  2618. var prevSearch = settings.oPreviousSearch.sSearch;
  2619. var displayMaster = settings.aiDisplayMaster;
  2620. var display, invalidated, i;
  2621. // Need to take account of custom filtering functions - always filter
  2622. if ( DataTable.ext.search.length !== 0 ) {
  2623. force = true;
  2624. }
  2625. // Check if any of the rows were invalidated
  2626. invalidated = _fnFilterData( settings );
  2627. // If the input is blank - we just want the full data set
  2628. if ( input.length <= 0 ) {
  2629. settings.aiDisplay = displayMaster.slice();
  2630. }
  2631. else {
  2632. // New search - start from the master array
  2633. if ( invalidated ||
  2634. force ||
  2635. prevSearch.length > input.length ||
  2636. input.indexOf(prevSearch) !== 0 ||
  2637. settings.bSorted // On resort, the display master needs to be
  2638. // re-filtered since indexes will have changed
  2639. ) {
  2640. settings.aiDisplay = displayMaster.slice();
  2641. }
  2642. // Search the display array
  2643. display = settings.aiDisplay;
  2644. for ( i=display.length-1 ; i>=0 ; i-- ) {
  2645. if ( ! rpSearch.test( settings.aoData[ display[i] ]._sFilterRow ) ) {
  2646. display.splice( i, 1 );
  2647. }
  2648. }
  2649. }
  2650. }
  2651. /**
  2652. * Build a regular expression object suitable for searching a table
  2653. * @param {string} sSearch string to search for
  2654. * @param {bool} bRegex treat as a regular expression or not
  2655. * @param {bool} bSmart perform smart filtering or not
  2656. * @param {bool} bCaseInsensitive Do case insensitive matching or not
  2657. * @returns {RegExp} constructed object
  2658. * @memberof DataTable#oApi
  2659. */
  2660. function _fnFilterCreateSearch( search, regex, smart, caseInsensitive )
  2661. {
  2662. search = regex ?
  2663. search :
  2664. _fnEscapeRegex( search );
  2665. if ( smart ) {
  2666. /* For smart filtering we want to allow the search to work regardless of
  2667. * word order. We also want double quoted text to be preserved, so word
  2668. * order is important - a la google. So this is what we want to
  2669. * generate:
  2670. *
  2671. * ^(?=.*?\bone\b)(?=.*?\btwo three\b)(?=.*?\bfour\b).*$
  2672. */
  2673. var a = $.map( search.match( /"[^"]+"|[^ ]+/g ) || [''], function ( word ) {
  2674. if ( word.charAt(0) === '"' ) {
  2675. var m = word.match( /^"(.*)"$/ );
  2676. word = m ? m[1] : word;
  2677. }
  2678. return word.replace('"', '');
  2679. } );
  2680. search = '^(?=.*?'+a.join( ')(?=.*?' )+').*$';
  2681. }
  2682. return new RegExp( search, caseInsensitive ? 'i' : '' );
  2683. }
  2684. /**
  2685. * Escape a string such that it can be used in a regular expression
  2686. * @param {string} sVal string to escape
  2687. * @returns {string} escaped string
  2688. * @memberof DataTable#oApi
  2689. */
  2690. function _fnEscapeRegex ( sVal )
  2691. {
  2692. return sVal.replace( _re_escape_regex, '\\$1' );
  2693. }
  2694. var __filter_div = $('<div>')[0];
  2695. var __filter_div_textContent = __filter_div.textContent !== undefined;
  2696. // Update the filtering data for each row if needed (by invalidation or first run)
  2697. function _fnFilterData ( settings )
  2698. {
  2699. var columns = settings.aoColumns;
  2700. var column;
  2701. var i, j, ien, jen, filterData, cellData, row;
  2702. var fomatters = DataTable.ext.type.search;
  2703. var wasInvalidated = false;
  2704. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  2705. row = settings.aoData[i];
  2706. if ( ! row._aFilterData ) {
  2707. filterData = [];
  2708. for ( j=0, jen=columns.length ; j<jen ; j++ ) {
  2709. column = columns[j];
  2710. if ( column.bSearchable ) {
  2711. cellData = _fnGetCellData( settings, i, j, 'filter' );
  2712. if ( fomatters[ column.sType ] ) {
  2713. cellData = fomatters[ column.sType ]( cellData );
  2714. }
  2715. // Search in DataTables 1.10 is string based. In 1.11 this
  2716. // should be altered to also allow strict type checking.
  2717. if ( cellData === null ) {
  2718. cellData = '';
  2719. }
  2720. if ( typeof cellData !== 'string' && cellData.toString ) {
  2721. cellData = cellData.toString();
  2722. }
  2723. }
  2724. else {
  2725. cellData = '';
  2726. }
  2727. // If it looks like there is an HTML entity in the string,
  2728. // attempt to decode it so sorting works as expected. Note that
  2729. // we could use a single line of jQuery to do this, but the DOM
  2730. // method used here is much faster http://jsperf.com/html-decode
  2731. if ( cellData.indexOf && cellData.indexOf('&') !== -1 ) {
  2732. __filter_div.innerHTML = cellData;
  2733. cellData = __filter_div_textContent ?
  2734. __filter_div.textContent :
  2735. __filter_div.innerText;
  2736. }
  2737. if ( cellData.replace ) {
  2738. cellData = cellData.replace(/[\r\n]/g, '');
  2739. }
  2740. filterData.push( cellData );
  2741. }
  2742. row._aFilterData = filterData;
  2743. row._sFilterRow = filterData.join(' ');
  2744. wasInvalidated = true;
  2745. }
  2746. }
  2747. return wasInvalidated;
  2748. }
  2749. /**
  2750. * Convert from the internal Hungarian notation to camelCase for external
  2751. * interaction
  2752. * @param {object} obj Object to convert
  2753. * @returns {object} Inverted object
  2754. * @memberof DataTable#oApi
  2755. */
  2756. function _fnSearchToCamel ( obj )
  2757. {
  2758. return {
  2759. search: obj.sSearch,
  2760. smart: obj.bSmart,
  2761. regex: obj.bRegex,
  2762. caseInsensitive: obj.bCaseInsensitive
  2763. };
  2764. }
  2765. /**
  2766. * Convert from camelCase notation to the internal Hungarian. We could use the
  2767. * Hungarian convert function here, but this is cleaner
  2768. * @param {object} obj Object to convert
  2769. * @returns {object} Inverted object
  2770. * @memberof DataTable#oApi
  2771. */
  2772. function _fnSearchToHung ( obj )
  2773. {
  2774. return {
  2775. sSearch: obj.search,
  2776. bSmart: obj.smart,
  2777. bRegex: obj.regex,
  2778. bCaseInsensitive: obj.caseInsensitive
  2779. };
  2780. }
  2781. /**
  2782. * Generate the node required for the info display
  2783. * @param {object} oSettings dataTables settings object
  2784. * @returns {node} Information element
  2785. * @memberof DataTable#oApi
  2786. */
  2787. function _fnFeatureHtmlInfo ( settings )
  2788. {
  2789. var
  2790. tid = settings.sTableId,
  2791. nodes = settings.aanFeatures.i,
  2792. n = $('<div/>', {
  2793. 'class': settings.oClasses.sInfo,
  2794. 'id': ! nodes ? tid+'_info' : null
  2795. } );
  2796. if ( ! nodes ) {
  2797. // Update display on each draw
  2798. settings.aoDrawCallback.push( {
  2799. "fn": _fnUpdateInfo,
  2800. "sName": "information"
  2801. } );
  2802. n
  2803. .attr( 'role', 'status' )
  2804. .attr( 'aria-live', 'polite' );
  2805. // Table is described by our info div
  2806. $(settings.nTable).attr( 'aria-describedby', tid+'_info' );
  2807. }
  2808. return n[0];
  2809. }
  2810. /**
  2811. * Update the information elements in the display
  2812. * @param {object} settings dataTables settings object
  2813. * @memberof DataTable#oApi
  2814. */
  2815. function _fnUpdateInfo ( settings )
  2816. {
  2817. /* Show information about the table */
  2818. var nodes = settings.aanFeatures.i;
  2819. if ( nodes.length === 0 ) {
  2820. return;
  2821. }
  2822. var
  2823. lang = settings.oLanguage,
  2824. start = settings._iDisplayStart+1,
  2825. end = settings.fnDisplayEnd(),
  2826. max = settings.fnRecordsTotal(),
  2827. total = settings.fnRecordsDisplay(),
  2828. out = total ?
  2829. lang.sInfo :
  2830. lang.sInfoEmpty;
  2831. if ( total !== max ) {
  2832. /* Record set after filtering */
  2833. out += ' ' + lang.sInfoFiltered;
  2834. }
  2835. // Convert the macros
  2836. out += lang.sInfoPostFix;
  2837. out = _fnInfoMacros( settings, out );
  2838. var callback = lang.fnInfoCallback;
  2839. if ( callback !== null ) {
  2840. out = callback.call( settings.oInstance,
  2841. settings, start, end, max, total, out
  2842. );
  2843. }
  2844. $(nodes).html( out );
  2845. }
  2846. function _fnInfoMacros ( settings, str )
  2847. {
  2848. // When infinite scrolling, we are always starting at 1. _iDisplayStart is used only
  2849. // internally
  2850. var
  2851. formatter = settings.fnFormatNumber,
  2852. start = settings._iDisplayStart+1,
  2853. len = settings._iDisplayLength,
  2854. vis = settings.fnRecordsDisplay(),
  2855. all = len === -1;
  2856. return str.
  2857. replace(/_START_/g, formatter.call( settings, start ) ).
  2858. replace(/_END_/g, formatter.call( settings, settings.fnDisplayEnd() ) ).
  2859. replace(/_MAX_/g, formatter.call( settings, settings.fnRecordsTotal() ) ).
  2860. replace(/_TOTAL_/g, formatter.call( settings, vis ) ).
  2861. replace(/_PAGE_/g, formatter.call( settings, all ? 1 : Math.ceil( start / len ) ) ).
  2862. replace(/_PAGES_/g, formatter.call( settings, all ? 1 : Math.ceil( vis / len ) ) );
  2863. }
  2864. /**
  2865. * Draw the table for the first time, adding all required features
  2866. * @param {object} settings dataTables settings object
  2867. * @memberof DataTable#oApi
  2868. */
  2869. function _fnInitialise ( settings )
  2870. {
  2871. var i, iLen, iAjaxStart=settings.iInitDisplayStart;
  2872. var columns = settings.aoColumns, column;
  2873. var features = settings.oFeatures;
  2874. var deferLoading = settings.bDeferLoading; // value modified by the draw
  2875. /* Ensure that the table data is fully initialised */
  2876. if ( ! settings.bInitialised ) {
  2877. setTimeout( function(){ _fnInitialise( settings ); }, 200 );
  2878. return;
  2879. }
  2880. /* Show the display HTML options */
  2881. _fnAddOptionsHtml( settings );
  2882. /* Build and draw the header / footer for the table */
  2883. _fnBuildHead( settings );
  2884. _fnDrawHead( settings, settings.aoHeader );
  2885. _fnDrawHead( settings, settings.aoFooter );
  2886. /* Okay to show that something is going on now */
  2887. _fnProcessingDisplay( settings, true );
  2888. /* Calculate sizes for columns */
  2889. if ( features.bAutoWidth ) {
  2890. _fnCalculateColumnWidths( settings );
  2891. }
  2892. for ( i=0, iLen=columns.length ; i<iLen ; i++ ) {
  2893. column = columns[i];
  2894. if ( column.sWidth ) {
  2895. column.nTh.style.width = _fnStringToCss( column.sWidth );
  2896. }
  2897. }
  2898. _fnCallbackFire( settings, null, 'preInit', [settings] );
  2899. // If there is default sorting required - let's do it. The sort function
  2900. // will do the drawing for us. Otherwise we draw the table regardless of the
  2901. // Ajax source - this allows the table to look initialised for Ajax sourcing
  2902. // data (show 'loading' message possibly)
  2903. _fnReDraw( settings );
  2904. // Server-side processing init complete is done by _fnAjaxUpdateDraw
  2905. var dataSrc = _fnDataSource( settings );
  2906. if ( dataSrc != 'ssp' || deferLoading ) {
  2907. // if there is an ajax source load the data
  2908. if ( dataSrc == 'ajax' ) {
  2909. _fnBuildAjax( settings, [], function(json) {
  2910. var aData = _fnAjaxDataSrc( settings, json );
  2911. // Got the data - add it to the table
  2912. for ( i=0 ; i<aData.length ; i++ ) {
  2913. _fnAddData( settings, aData[i] );
  2914. }
  2915. // Reset the init display for cookie saving. We've already done
  2916. // a filter, and therefore cleared it before. So we need to make
  2917. // it appear 'fresh'
  2918. settings.iInitDisplayStart = iAjaxStart;
  2919. _fnReDraw( settings );
  2920. _fnProcessingDisplay( settings, false );
  2921. _fnInitComplete( settings, json );
  2922. }, settings );
  2923. }
  2924. else {
  2925. _fnProcessingDisplay( settings, false );
  2926. _fnInitComplete( settings );
  2927. }
  2928. }
  2929. }
  2930. /**
  2931. * Draw the table for the first time, adding all required features
  2932. * @param {object} oSettings dataTables settings object
  2933. * @param {object} [json] JSON from the server that completed the table, if using Ajax source
  2934. * with client-side processing (optional)
  2935. * @memberof DataTable#oApi
  2936. */
  2937. function _fnInitComplete ( settings, json )
  2938. {
  2939. settings._bInitComplete = true;
  2940. // When data was added after the initialisation (data or Ajax) we need to
  2941. // calculate the column sizing
  2942. if ( json || settings.oInit.aaData ) {
  2943. _fnAdjustColumnSizing( settings );
  2944. }
  2945. _fnCallbackFire( settings, null, 'plugin-init', [settings, json] );
  2946. _fnCallbackFire( settings, 'aoInitComplete', 'init', [settings, json] );
  2947. }
  2948. function _fnLengthChange ( settings, val )
  2949. {
  2950. var len = parseInt( val, 10 );
  2951. settings._iDisplayLength = len;
  2952. _fnLengthOverflow( settings );
  2953. // Fire length change event
  2954. _fnCallbackFire( settings, null, 'length', [settings, len] );
  2955. }
  2956. /**
  2957. * Generate the node required for user display length changing
  2958. * @param {object} settings dataTables settings object
  2959. * @returns {node} Display length feature node
  2960. * @memberof DataTable#oApi
  2961. */
  2962. function _fnFeatureHtmlLength ( settings )
  2963. {
  2964. var
  2965. classes = settings.oClasses,
  2966. tableId = settings.sTableId,
  2967. menu = settings.aLengthMenu,
  2968. d2 = $.isArray( menu[0] ),
  2969. lengths = d2 ? menu[0] : menu,
  2970. language = d2 ? menu[1] : menu;
  2971. var select = $('<select/>', {
  2972. 'name': tableId+'_length',
  2973. 'aria-controls': tableId,
  2974. 'class': classes.sLengthSelect
  2975. } );
  2976. for ( var i=0, ien=lengths.length ; i<ien ; i++ ) {
  2977. select[0][ i ] = new Option( language[i], lengths[i] );
  2978. }
  2979. var div = $('<div><label/></div>').addClass( classes.sLength );
  2980. if ( ! settings.aanFeatures.l ) {
  2981. div[0].id = tableId+'_length';
  2982. }
  2983. div.children().append(
  2984. settings.oLanguage.sLengthMenu.replace( '_MENU_', select[0].outerHTML )
  2985. );
  2986. // Can't use `select` variable as user might provide their own and the
  2987. // reference is broken by the use of outerHTML
  2988. $('select', div)
  2989. .val( settings._iDisplayLength )
  2990. .bind( 'change.DT', function(e) {
  2991. _fnLengthChange( settings, $(this).val() );
  2992. _fnDraw( settings );
  2993. } );
  2994. // Update node value whenever anything changes the table's length
  2995. $(settings.nTable).bind( 'length.dt.DT', function (e, s, len) {
  2996. if ( settings === s ) {
  2997. $('select', div).val( len );
  2998. }
  2999. } );
  3000. return div[0];
  3001. }
  3002. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  3003. * Note that most of the paging logic is done in
  3004. * DataTable.ext.pager
  3005. */
  3006. /**
  3007. * Generate the node required for default pagination
  3008. * @param {object} oSettings dataTables settings object
  3009. * @returns {node} Pagination feature node
  3010. * @memberof DataTable#oApi
  3011. */
  3012. function _fnFeatureHtmlPaginate ( settings )
  3013. {
  3014. var
  3015. type = settings.sPaginationType,
  3016. plugin = DataTable.ext.pager[ type ],
  3017. modern = typeof plugin === 'function',
  3018. redraw = function( settings ) {
  3019. _fnDraw( settings );
  3020. },
  3021. node = $('<div/>').addClass( settings.oClasses.sPaging + type )[0],
  3022. features = settings.aanFeatures;
  3023. if ( ! modern ) {
  3024. plugin.fnInit( settings, node, redraw );
  3025. }
  3026. /* Add a draw callback for the pagination on first instance, to update the paging display */
  3027. if ( ! features.p )
  3028. {
  3029. node.id = settings.sTableId+'_paginate';
  3030. settings.aoDrawCallback.push( {
  3031. "fn": function( settings ) {
  3032. if ( modern ) {
  3033. var
  3034. start = settings._iDisplayStart,
  3035. len = settings._iDisplayLength,
  3036. visRecords = settings.fnRecordsDisplay(),
  3037. all = len === -1,
  3038. page = all ? 0 : Math.ceil( start / len ),
  3039. pages = all ? 1 : Math.ceil( visRecords / len ),
  3040. buttons = plugin(page, pages),
  3041. i, ien;
  3042. for ( i=0, ien=features.p.length ; i<ien ; i++ ) {
  3043. _fnRenderer( settings, 'pageButton' )(
  3044. settings, features.p[i], i, buttons, page, pages
  3045. );
  3046. }
  3047. }
  3048. else {
  3049. plugin.fnUpdate( settings, redraw );
  3050. }
  3051. },
  3052. "sName": "pagination"
  3053. } );
  3054. }
  3055. return node;
  3056. }
  3057. /**
  3058. * Alter the display settings to change the page
  3059. * @param {object} settings DataTables settings object
  3060. * @param {string|int} action Paging action to take: "first", "previous",
  3061. * "next" or "last" or page number to jump to (integer)
  3062. * @param [bool] redraw Automatically draw the update or not
  3063. * @returns {bool} true page has changed, false - no change
  3064. * @memberof DataTable#oApi
  3065. */
  3066. function _fnPageChange ( settings, action, redraw )
  3067. {
  3068. var
  3069. start = settings._iDisplayStart,
  3070. len = settings._iDisplayLength,
  3071. records = settings.fnRecordsDisplay();
  3072. if ( records === 0 || len === -1 )
  3073. {
  3074. start = 0;
  3075. }
  3076. else if ( typeof action === "number" )
  3077. {
  3078. start = action * len;
  3079. if ( start > records )
  3080. {
  3081. start = 0;
  3082. }
  3083. }
  3084. else if ( action == "first" )
  3085. {
  3086. start = 0;
  3087. }
  3088. else if ( action == "previous" )
  3089. {
  3090. start = len >= 0 ?
  3091. start - len :
  3092. 0;
  3093. if ( start < 0 )
  3094. {
  3095. start = 0;
  3096. }
  3097. }
  3098. else if ( action == "next" )
  3099. {
  3100. if ( start + len < records )
  3101. {
  3102. start += len;
  3103. }
  3104. }
  3105. else if ( action == "last" )
  3106. {
  3107. start = Math.floor( (records-1) / len) * len;
  3108. }
  3109. else
  3110. {
  3111. _fnLog( settings, 0, "Unknown paging action: "+action, 5 );
  3112. }
  3113. var changed = settings._iDisplayStart !== start;
  3114. settings._iDisplayStart = start;
  3115. if ( changed ) {
  3116. _fnCallbackFire( settings, null, 'page', [settings] );
  3117. if ( redraw ) {
  3118. _fnDraw( settings );
  3119. }
  3120. }
  3121. return changed;
  3122. }
  3123. /**
  3124. * Generate the node required for the processing node
  3125. * @param {object} settings dataTables settings object
  3126. * @returns {node} Processing element
  3127. * @memberof DataTable#oApi
  3128. */
  3129. function _fnFeatureHtmlProcessing ( settings )
  3130. {
  3131. return $('<div/>', {
  3132. 'id': ! settings.aanFeatures.r ? settings.sTableId+'_processing' : null,
  3133. 'class': settings.oClasses.sProcessing
  3134. } )
  3135. .html( settings.oLanguage.sProcessing )
  3136. .insertBefore( settings.nTable )[0];
  3137. }
  3138. /**
  3139. * Display or hide the processing indicator
  3140. * @param {object} settings dataTables settings object
  3141. * @param {bool} show Show the processing indicator (true) or not (false)
  3142. * @memberof DataTable#oApi
  3143. */
  3144. function _fnProcessingDisplay ( settings, show )
  3145. {
  3146. if ( settings.oFeatures.bProcessing ) {
  3147. $(settings.aanFeatures.r).css( 'display', show ? 'block' : 'none' );
  3148. }
  3149. _fnCallbackFire( settings, null, 'processing', [settings, show] );
  3150. }
  3151. /**
  3152. * Add any control elements for the table - specifically scrolling
  3153. * @param {object} settings dataTables settings object
  3154. * @returns {node} Node to add to the DOM
  3155. * @memberof DataTable#oApi
  3156. */
  3157. function _fnFeatureHtmlTable ( settings )
  3158. {
  3159. var table = $(settings.nTable);
  3160. // Add the ARIA grid role to the table
  3161. table.attr( 'role', 'grid' );
  3162. // Scrolling from here on in
  3163. var scroll = settings.oScroll;
  3164. if ( scroll.sX === '' && scroll.sY === '' ) {
  3165. return settings.nTable;
  3166. }
  3167. var scrollX = scroll.sX;
  3168. var scrollY = scroll.sY;
  3169. var classes = settings.oClasses;
  3170. var caption = table.children('caption');
  3171. var captionSide = caption.length ? caption[0]._captionSide : null;
  3172. var headerClone = $( table[0].cloneNode(false) );
  3173. var footerClone = $( table[0].cloneNode(false) );
  3174. var footer = table.children('tfoot');
  3175. var _div = '<div/>';
  3176. var size = function ( s ) {
  3177. return !s ? null : _fnStringToCss( s );
  3178. };
  3179. if ( ! footer.length ) {
  3180. footer = null;
  3181. }
  3182. /*
  3183. * The HTML structure that we want to generate in this function is:
  3184. * div - scroller
  3185. * div - scroll head
  3186. * div - scroll head inner
  3187. * table - scroll head table
  3188. * thead - thead
  3189. * div - scroll body
  3190. * table - table (master table)
  3191. * thead - thead clone for sizing
  3192. * tbody - tbody
  3193. * div - scroll foot
  3194. * div - scroll foot inner
  3195. * table - scroll foot table
  3196. * tfoot - tfoot
  3197. */
  3198. var scroller = $( _div, { 'class': classes.sScrollWrapper } )
  3199. .append(
  3200. $(_div, { 'class': classes.sScrollHead } )
  3201. .css( {
  3202. overflow: 'hidden',
  3203. position: 'relative',
  3204. border: 0,
  3205. width: scrollX ? size(scrollX) : '100%'
  3206. } )
  3207. .append(
  3208. $(_div, { 'class': classes.sScrollHeadInner } )
  3209. .css( {
  3210. 'box-sizing': 'content-box',
  3211. width: scroll.sXInner || '100%'
  3212. } )
  3213. .append(
  3214. headerClone
  3215. .removeAttr('id')
  3216. .css( 'margin-left', 0 )
  3217. .append( captionSide === 'top' ? caption : null )
  3218. .append(
  3219. table.children('thead')
  3220. )
  3221. )
  3222. )
  3223. )
  3224. .append(
  3225. $(_div, { 'class': classes.sScrollBody } )
  3226. .css( {
  3227. position: 'relative',
  3228. overflow: 'auto',
  3229. width: size( scrollX )
  3230. } )
  3231. .append( table )
  3232. );
  3233. if ( footer ) {
  3234. scroller.append(
  3235. $(_div, { 'class': classes.sScrollFoot } )
  3236. .css( {
  3237. overflow: 'hidden',
  3238. border: 0,
  3239. width: scrollX ? size(scrollX) : '100%'
  3240. } )
  3241. .append(
  3242. $(_div, { 'class': classes.sScrollFootInner } )
  3243. .append(
  3244. footerClone
  3245. .removeAttr('id')
  3246. .css( 'margin-left', 0 )
  3247. .append( captionSide === 'bottom' ? caption : null )
  3248. .append(
  3249. table.children('tfoot')
  3250. )
  3251. )
  3252. )
  3253. );
  3254. }
  3255. var children = scroller.children();
  3256. var scrollHead = children[0];
  3257. var scrollBody = children[1];
  3258. var scrollFoot = footer ? children[2] : null;
  3259. // When the body is scrolled, then we also want to scroll the headers
  3260. if ( scrollX ) {
  3261. $(scrollBody).on( 'scroll.DT', function (e) {
  3262. var scrollLeft = this.scrollLeft;
  3263. scrollHead.scrollLeft = scrollLeft;
  3264. if ( footer ) {
  3265. scrollFoot.scrollLeft = scrollLeft;
  3266. }
  3267. } );
  3268. }
  3269. $(scrollBody).css(
  3270. scrollY && scroll.bCollapse ? 'max-height' : 'height',
  3271. scrollY
  3272. );
  3273. settings.nScrollHead = scrollHead;
  3274. settings.nScrollBody = scrollBody;
  3275. settings.nScrollFoot = scrollFoot;
  3276. // On redraw - align columns
  3277. settings.aoDrawCallback.push( {
  3278. "fn": _fnScrollDraw,
  3279. "sName": "scrolling"
  3280. } );
  3281. return scroller[0];
  3282. }
  3283. /**
  3284. * Update the header, footer and body tables for resizing - i.e. column
  3285. * alignment.
  3286. *
  3287. * Welcome to the most horrible function DataTables. The process that this
  3288. * function follows is basically:
  3289. * 1. Re-create the table inside the scrolling div
  3290. * 2. Take live measurements from the DOM
  3291. * 3. Apply the measurements to align the columns
  3292. * 4. Clean up
  3293. *
  3294. * @param {object} settings dataTables settings object
  3295. * @memberof DataTable#oApi
  3296. */
  3297. function _fnScrollDraw ( settings )
  3298. {
  3299. // Given that this is such a monster function, a lot of variables are use
  3300. // to try and keep the minimised size as small as possible
  3301. var
  3302. scroll = settings.oScroll,
  3303. scrollX = scroll.sX,
  3304. scrollXInner = scroll.sXInner,
  3305. scrollY = scroll.sY,
  3306. barWidth = scroll.iBarWidth,
  3307. divHeader = $(settings.nScrollHead),
  3308. divHeaderStyle = divHeader[0].style,
  3309. divHeaderInner = divHeader.children('div'),
  3310. divHeaderInnerStyle = divHeaderInner[0].style,
  3311. divHeaderTable = divHeaderInner.children('table'),
  3312. divBodyEl = settings.nScrollBody,
  3313. divBody = $(divBodyEl),
  3314. divBodyStyle = divBodyEl.style,
  3315. divFooter = $(settings.nScrollFoot),
  3316. divFooterInner = divFooter.children('div'),
  3317. divFooterTable = divFooterInner.children('table'),
  3318. header = $(settings.nTHead),
  3319. table = $(settings.nTable),
  3320. tableEl = table[0],
  3321. tableStyle = tableEl.style,
  3322. footer = settings.nTFoot ? $(settings.nTFoot) : null,
  3323. browser = settings.oBrowser,
  3324. ie67 = browser.bScrollOversize,
  3325. dtHeaderCells = _pluck( settings.aoColumns, 'nTh' ),
  3326. headerTrgEls, footerTrgEls,
  3327. headerSrcEls, footerSrcEls,
  3328. headerCopy, footerCopy,
  3329. headerWidths=[], footerWidths=[],
  3330. headerContent=[], footerContent=[],
  3331. idx, correction, sanityWidth,
  3332. zeroOut = function(nSizer) {
  3333. var style = nSizer.style;
  3334. style.paddingTop = "0";
  3335. style.paddingBottom = "0";
  3336. style.borderTopWidth = "0";
  3337. style.borderBottomWidth = "0";
  3338. style.height = 0;
  3339. };
  3340. // If the scrollbar visibility has changed from the last draw, we need to
  3341. // adjust the column sizes as the table width will have changed to account
  3342. // for the scrollbar
  3343. var scrollBarVis = divBodyEl.scrollHeight > divBodyEl.clientHeight;
  3344. if ( settings.scrollBarVis !== scrollBarVis && settings.scrollBarVis !== undefined ) {
  3345. settings.scrollBarVis = scrollBarVis;
  3346. _fnAdjustColumnSizing( settings );
  3347. return; // adjust column sizing will call this function again
  3348. }
  3349. else {
  3350. settings.scrollBarVis = scrollBarVis;
  3351. }
  3352. /*
  3353. * 1. Re-create the table inside the scrolling div
  3354. */
  3355. // Remove the old minimised thead and tfoot elements in the inner table
  3356. table.children('thead, tfoot').remove();
  3357. if ( footer ) {
  3358. footerCopy = footer.clone().prependTo( table );
  3359. footerTrgEls = footer.find('tr'); // the original tfoot is in its own table and must be sized
  3360. footerSrcEls = footerCopy.find('tr');
  3361. }
  3362. // Clone the current header and footer elements and then place it into the inner table
  3363. headerCopy = header.clone().prependTo( table );
  3364. headerTrgEls = header.find('tr'); // original header is in its own table
  3365. headerSrcEls = headerCopy.find('tr');
  3366. headerCopy.find('th, td').removeAttr('tabindex');
  3367. /*
  3368. * 2. Take live measurements from the DOM - do not alter the DOM itself!
  3369. */
  3370. // Remove old sizing and apply the calculated column widths
  3371. // Get the unique column headers in the newly created (cloned) header. We want to apply the
  3372. // calculated sizes to this header
  3373. if ( ! scrollX )
  3374. {
  3375. divBodyStyle.width = '100%';
  3376. divHeader[0].style.width = '100%';
  3377. }
  3378. $.each( _fnGetUniqueThs( settings, headerCopy ), function ( i, el ) {
  3379. idx = _fnVisibleToColumnIndex( settings, i );
  3380. el.style.width = settings.aoColumns[idx].sWidth;
  3381. } );
  3382. if ( footer ) {
  3383. _fnApplyToChildren( function(n) {
  3384. n.style.width = "";
  3385. }, footerSrcEls );
  3386. }
  3387. // Size the table as a whole
  3388. sanityWidth = table.outerWidth();
  3389. if ( scrollX === "" ) {
  3390. // No x scrolling
  3391. tableStyle.width = "100%";
  3392. // IE7 will make the width of the table when 100% include the scrollbar
  3393. // - which is shouldn't. When there is a scrollbar we need to take this
  3394. // into account.
  3395. if ( ie67 && (table.find('tbody').height() > divBodyEl.offsetHeight ||
  3396. divBody.css('overflow-y') == "scroll")
  3397. ) {
  3398. tableStyle.width = _fnStringToCss( table.outerWidth() - barWidth);
  3399. }
  3400. // Recalculate the sanity width
  3401. sanityWidth = table.outerWidth();
  3402. }
  3403. else if ( scrollXInner !== "" ) {
  3404. // legacy x scroll inner has been given - use it
  3405. tableStyle.width = _fnStringToCss(scrollXInner);
  3406. // Recalculate the sanity width
  3407. sanityWidth = table.outerWidth();
  3408. }
  3409. // Hidden header should have zero height, so remove padding and borders. Then
  3410. // set the width based on the real headers
  3411. // Apply all styles in one pass
  3412. _fnApplyToChildren( zeroOut, headerSrcEls );
  3413. // Read all widths in next pass
  3414. _fnApplyToChildren( function(nSizer) {
  3415. headerContent.push( nSizer.innerHTML );
  3416. headerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  3417. }, headerSrcEls );
  3418. // Apply all widths in final pass
  3419. _fnApplyToChildren( function(nToSize, i) {
  3420. // Only apply widths to the DataTables detected header cells - this
  3421. // prevents complex headers from having contradictory sizes applied
  3422. if ( $.inArray( nToSize, dtHeaderCells ) !== -1 ) {
  3423. nToSize.style.width = headerWidths[i];
  3424. }
  3425. }, headerTrgEls );
  3426. $(headerSrcEls).height(0);
  3427. /* Same again with the footer if we have one */
  3428. if ( footer )
  3429. {
  3430. _fnApplyToChildren( zeroOut, footerSrcEls );
  3431. _fnApplyToChildren( function(nSizer) {
  3432. footerContent.push( nSizer.innerHTML );
  3433. footerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  3434. }, footerSrcEls );
  3435. _fnApplyToChildren( function(nToSize, i) {
  3436. nToSize.style.width = footerWidths[i];
  3437. }, footerTrgEls );
  3438. $(footerSrcEls).height(0);
  3439. }
  3440. /*
  3441. * 3. Apply the measurements
  3442. */
  3443. // "Hide" the header and footer that we used for the sizing. We need to keep
  3444. // the content of the cell so that the width applied to the header and body
  3445. // both match, but we want to hide it completely. We want to also fix their
  3446. // width to what they currently are
  3447. _fnApplyToChildren( function(nSizer, i) {
  3448. nSizer.innerHTML = '<div class="dataTables_sizing" style="height:0;overflow:hidden;">'+headerContent[i]+'</div>';
  3449. nSizer.style.width = headerWidths[i];
  3450. }, headerSrcEls );
  3451. if ( footer )
  3452. {
  3453. _fnApplyToChildren( function(nSizer, i) {
  3454. nSizer.innerHTML = '<div class="dataTables_sizing" style="height:0;overflow:hidden;">'+footerContent[i]+'</div>';
  3455. nSizer.style.width = footerWidths[i];
  3456. }, footerSrcEls );
  3457. }
  3458. // Sanity check that the table is of a sensible width. If not then we are going to get
  3459. // misalignment - try to prevent this by not allowing the table to shrink below its min width
  3460. if ( table.outerWidth() < sanityWidth )
  3461. {
  3462. // The min width depends upon if we have a vertical scrollbar visible or not */
  3463. correction = ((divBodyEl.scrollHeight > divBodyEl.offsetHeight ||
  3464. divBody.css('overflow-y') == "scroll")) ?
  3465. sanityWidth+barWidth :
  3466. sanityWidth;
  3467. // IE6/7 are a law unto themselves...
  3468. if ( ie67 && (divBodyEl.scrollHeight >
  3469. divBodyEl.offsetHeight || divBody.css('overflow-y') == "scroll")
  3470. ) {
  3471. tableStyle.width = _fnStringToCss( correction-barWidth );
  3472. }
  3473. // And give the user a warning that we've stopped the table getting too small
  3474. if ( scrollX === "" || scrollXInner !== "" ) {
  3475. _fnLog( settings, 1, 'Possible column misalignment', 6 );
  3476. }
  3477. }
  3478. else
  3479. {
  3480. correction = '100%';
  3481. }
  3482. // Apply to the container elements
  3483. divBodyStyle.width = _fnStringToCss( correction );
  3484. divHeaderStyle.width = _fnStringToCss( correction );
  3485. if ( footer ) {
  3486. settings.nScrollFoot.style.width = _fnStringToCss( correction );
  3487. }
  3488. /*
  3489. * 4. Clean up
  3490. */
  3491. if ( ! scrollY ) {
  3492. /* IE7< puts a vertical scrollbar in place (when it shouldn't be) due to subtracting
  3493. * the scrollbar height from the visible display, rather than adding it on. We need to
  3494. * set the height in order to sort this. Don't want to do it in any other browsers.
  3495. */
  3496. if ( ie67 ) {
  3497. divBodyStyle.height = _fnStringToCss( tableEl.offsetHeight+barWidth );
  3498. }
  3499. }
  3500. /* Finally set the width's of the header and footer tables */
  3501. var iOuterWidth = table.outerWidth();
  3502. divHeaderTable[0].style.width = _fnStringToCss( iOuterWidth );
  3503. divHeaderInnerStyle.width = _fnStringToCss( iOuterWidth );
  3504. // Figure out if there are scrollbar present - if so then we need a the header and footer to
  3505. // provide a bit more space to allow "overflow" scrolling (i.e. past the scrollbar)
  3506. var bScrolling = table.height() > divBodyEl.clientHeight || divBody.css('overflow-y') == "scroll";
  3507. var padding = 'padding' + (browser.bScrollbarLeft ? 'Left' : 'Right' );
  3508. divHeaderInnerStyle[ padding ] = bScrolling ? barWidth+"px" : "0px";
  3509. if ( footer ) {
  3510. divFooterTable[0].style.width = _fnStringToCss( iOuterWidth );
  3511. divFooterInner[0].style.width = _fnStringToCss( iOuterWidth );
  3512. divFooterInner[0].style[padding] = bScrolling ? barWidth+"px" : "0px";
  3513. }
  3514. // Correct DOM ordering for colgroup - comes before the thead
  3515. table.children('colgroup').insertBefore( table.children('thead') );
  3516. /* Adjust the position of the header in case we loose the y-scrollbar */
  3517. divBody.scroll();
  3518. // If sorting or filtering has occurred, jump the scrolling back to the top
  3519. // only if we aren't holding the position
  3520. if ( (settings.bSorted || settings.bFiltered) && ! settings._drawHold ) {
  3521. divBodyEl.scrollTop = 0;
  3522. }
  3523. }
  3524. /**
  3525. * Apply a given function to the display child nodes of an element array (typically
  3526. * TD children of TR rows
  3527. * @param {function} fn Method to apply to the objects
  3528. * @param array {nodes} an1 List of elements to look through for display children
  3529. * @param array {nodes} an2 Another list (identical structure to the first) - optional
  3530. * @memberof DataTable#oApi
  3531. */
  3532. function _fnApplyToChildren( fn, an1, an2 )
  3533. {
  3534. var index=0, i=0, iLen=an1.length;
  3535. var nNode1, nNode2;
  3536. while ( i < iLen ) {
  3537. nNode1 = an1[i].firstChild;
  3538. nNode2 = an2 ? an2[i].firstChild : null;
  3539. while ( nNode1 ) {
  3540. if ( nNode1.nodeType === 1 ) {
  3541. if ( an2 ) {
  3542. fn( nNode1, nNode2, index );
  3543. }
  3544. else {
  3545. fn( nNode1, index );
  3546. }
  3547. index++;
  3548. }
  3549. nNode1 = nNode1.nextSibling;
  3550. nNode2 = an2 ? nNode2.nextSibling : null;
  3551. }
  3552. i++;
  3553. }
  3554. }
  3555. var __re_html_remove = /<.*?>/g;
  3556. /**
  3557. * Calculate the width of columns for the table
  3558. * @param {object} oSettings dataTables settings object
  3559. * @memberof DataTable#oApi
  3560. */
  3561. function _fnCalculateColumnWidths ( oSettings )
  3562. {
  3563. var
  3564. table = oSettings.nTable,
  3565. columns = oSettings.aoColumns,
  3566. scroll = oSettings.oScroll,
  3567. scrollY = scroll.sY,
  3568. scrollX = scroll.sX,
  3569. scrollXInner = scroll.sXInner,
  3570. columnCount = columns.length,
  3571. visibleColumns = _fnGetColumns( oSettings, 'bVisible' ),
  3572. headerCells = $('th', oSettings.nTHead),
  3573. tableWidthAttr = table.getAttribute('width'), // from DOM element
  3574. tableContainer = table.parentNode,
  3575. userInputs = false,
  3576. i, column, columnIdx, width, outerWidth,
  3577. browser = oSettings.oBrowser,
  3578. ie67 = browser.bScrollOversize;
  3579. var styleWidth = table.style.width;
  3580. if ( styleWidth && styleWidth.indexOf('%') !== -1 ) {
  3581. tableWidthAttr = styleWidth;
  3582. }
  3583. /* Convert any user input sizes into pixel sizes */
  3584. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3585. column = columns[ visibleColumns[i] ];
  3586. if ( column.sWidth !== null ) {
  3587. column.sWidth = _fnConvertToWidth( column.sWidthOrig, tableContainer );
  3588. userInputs = true;
  3589. }
  3590. }
  3591. /* If the number of columns in the DOM equals the number that we have to
  3592. * process in DataTables, then we can use the offsets that are created by
  3593. * the web- browser. No custom sizes can be set in order for this to happen,
  3594. * nor scrolling used
  3595. */
  3596. if ( ie67 || ! userInputs && ! scrollX && ! scrollY &&
  3597. columnCount == _fnVisbleColumns( oSettings ) &&
  3598. columnCount == headerCells.length
  3599. ) {
  3600. for ( i=0 ; i<columnCount ; i++ ) {
  3601. var colIdx = _fnVisibleToColumnIndex( oSettings, i );
  3602. if ( colIdx !== null ) {
  3603. columns[ colIdx ].sWidth = _fnStringToCss( headerCells.eq(i).width() );
  3604. }
  3605. }
  3606. }
  3607. else
  3608. {
  3609. // Otherwise construct a single row, worst case, table with the widest
  3610. // node in the data, assign any user defined widths, then insert it into
  3611. // the DOM and allow the browser to do all the hard work of calculating
  3612. // table widths
  3613. var tmpTable = $(table).clone() // don't use cloneNode - IE8 will remove events on the main table
  3614. .css( 'visibility', 'hidden' )
  3615. .removeAttr( 'id' );
  3616. // Clean up the table body
  3617. tmpTable.find('tbody tr').remove();
  3618. var tr = $('<tr/>').appendTo( tmpTable.find('tbody') );
  3619. // Clone the table header and footer - we can't use the header / footer
  3620. // from the cloned table, since if scrolling is active, the table's
  3621. // real header and footer are contained in different table tags
  3622. tmpTable.find('thead, tfoot').remove();
  3623. tmpTable
  3624. .append( $(oSettings.nTHead).clone() )
  3625. .append( $(oSettings.nTFoot).clone() );
  3626. // Remove any assigned widths from the footer (from scrolling)
  3627. tmpTable.find('tfoot th, tfoot td').css('width', '');
  3628. // Apply custom sizing to the cloned header
  3629. headerCells = _fnGetUniqueThs( oSettings, tmpTable.find('thead')[0] );
  3630. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3631. column = columns[ visibleColumns[i] ];
  3632. headerCells[i].style.width = column.sWidthOrig !== null && column.sWidthOrig !== '' ?
  3633. _fnStringToCss( column.sWidthOrig ) :
  3634. '';
  3635. // For scrollX we need to force the column width otherwise the
  3636. // browser will collapse it. If this width is smaller than the
  3637. // width the column requires, then it will have no effect
  3638. if ( column.sWidthOrig && scrollX ) {
  3639. $( headerCells[i] ).append( $('<div/>').css( {
  3640. width: column.sWidthOrig,
  3641. margin: 0,
  3642. padding: 0,
  3643. border: 0,
  3644. height: 1
  3645. } ) );
  3646. }
  3647. }
  3648. // Find the widest cell for each column and put it into the table
  3649. if ( oSettings.aoData.length ) {
  3650. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3651. columnIdx = visibleColumns[i];
  3652. column = columns[ columnIdx ];
  3653. $( _fnGetWidestNode( oSettings, columnIdx ) )
  3654. .clone( false )
  3655. .append( column.sContentPadding )
  3656. .appendTo( tr );
  3657. }
  3658. }
  3659. // Tidy the temporary table - remove name attributes so there aren't
  3660. // duplicated in the dom (radio elements for example)
  3661. $('[name]', tmpTable).removeAttr('name');
  3662. // Table has been built, attach to the document so we can work with it.
  3663. // A holding element is used, positioned at the top of the container
  3664. // with minimal height, so it has no effect on if the container scrolls
  3665. // or not. Otherwise it might trigger scrolling when it actually isn't
  3666. // needed
  3667. var holder = $('<div/>').css( scrollX || scrollY ?
  3668. {
  3669. position: 'absolute',
  3670. top: 0,
  3671. left: 0,
  3672. height: 1,
  3673. right: 0,
  3674. overflow: 'hidden'
  3675. } :
  3676. {}
  3677. )
  3678. .append( tmpTable )
  3679. .appendTo( tableContainer );
  3680. // When scrolling (X or Y) we want to set the width of the table as
  3681. // appropriate. However, when not scrolling leave the table width as it
  3682. // is. This results in slightly different, but I think correct behaviour
  3683. if ( scrollX && scrollXInner ) {
  3684. tmpTable.width( scrollXInner );
  3685. }
  3686. else if ( scrollX ) {
  3687. tmpTable.css( 'width', 'auto' );
  3688. tmpTable.removeAttr('width');
  3689. // If there is no width attribute or style, then allow the table to
  3690. // collapse
  3691. if ( tmpTable.width() < tableContainer.clientWidth && tableWidthAttr ) {
  3692. tmpTable.width( tableContainer.clientWidth );
  3693. }
  3694. }
  3695. else if ( scrollY ) {
  3696. tmpTable.width( tableContainer.clientWidth );
  3697. }
  3698. else if ( tableWidthAttr ) {
  3699. tmpTable.width( tableWidthAttr );
  3700. }
  3701. // Get the width of each column in the constructed table - we need to
  3702. // know the inner width (so it can be assigned to the other table's
  3703. // cells) and the outer width so we can calculate the full width of the
  3704. // table. This is safe since DataTables requires a unique cell for each
  3705. // column, but if ever a header can span multiple columns, this will
  3706. // need to be modified.
  3707. var total = 0;
  3708. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3709. var cell = $(headerCells[i]);
  3710. var border = cell.outerWidth() - cell.width();
  3711. // Use getBounding... where possible (not IE8-) because it can give
  3712. // sub-pixel accuracy, which we then want to round up!
  3713. var bounding = browser.bBounding ?
  3714. Math.ceil( headerCells[i].getBoundingClientRect().width ) :
  3715. cell.outerWidth();
  3716. // Total is tracked to remove any sub-pixel errors as the outerWidth
  3717. // of the table might not equal the total given here (IE!).
  3718. total += bounding;
  3719. // Width for each column to use
  3720. columns[ visibleColumns[i] ].sWidth = _fnStringToCss( bounding - border );
  3721. }
  3722. table.style.width = _fnStringToCss( total );
  3723. // Finished with the table - ditch it
  3724. holder.remove();
  3725. }
  3726. // If there is a width attr, we want to attach an event listener which
  3727. // allows the table sizing to automatically adjust when the window is
  3728. // resized. Use the width attr rather than CSS, since we can't know if the
  3729. // CSS is a relative value or absolute - DOM read is always px.
  3730. if ( tableWidthAttr ) {
  3731. table.style.width = _fnStringToCss( tableWidthAttr );
  3732. }
  3733. if ( (tableWidthAttr || scrollX) && ! oSettings._reszEvt ) {
  3734. var bindResize = function () {
  3735. $(window).bind('resize.DT-'+oSettings.sInstance, _fnThrottle( function () {
  3736. _fnAdjustColumnSizing( oSettings );
  3737. } ) );
  3738. };
  3739. // IE6/7 will crash if we bind a resize event handler on page load.
  3740. // To be removed in 1.11 which drops IE6/7 support
  3741. if ( ie67 ) {
  3742. setTimeout( bindResize, 1000 );
  3743. }
  3744. else {
  3745. bindResize();
  3746. }
  3747. oSettings._reszEvt = true;
  3748. }
  3749. }
  3750. /**
  3751. * Throttle the calls to a function. Arguments and context are maintained for
  3752. * the throttled function
  3753. * @param {function} fn Function to be called
  3754. * @param {int} [freq=200] call frequency in mS
  3755. * @returns {function} wrapped function
  3756. * @memberof DataTable#oApi
  3757. */
  3758. function _fnThrottle( fn, freq ) {
  3759. var
  3760. frequency = freq !== undefined ? freq : 200,
  3761. last,
  3762. timer;
  3763. return function () {
  3764. var
  3765. that = this,
  3766. now = +new Date(),
  3767. args = arguments;
  3768. if ( last && now < last + frequency ) {
  3769. clearTimeout( timer );
  3770. timer = setTimeout( function () {
  3771. last = undefined;
  3772. fn.apply( that, args );
  3773. }, frequency );
  3774. }
  3775. else {
  3776. last = now;
  3777. fn.apply( that, args );
  3778. }
  3779. };
  3780. }
  3781. /**
  3782. * Convert a CSS unit width to pixels (e.g. 2em)
  3783. * @param {string} width width to be converted
  3784. * @param {node} parent parent to get the with for (required for relative widths) - optional
  3785. * @returns {int} width in pixels
  3786. * @memberof DataTable#oApi
  3787. */
  3788. function _fnConvertToWidth ( width, parent )
  3789. {
  3790. if ( ! width ) {
  3791. return 0;
  3792. }
  3793. var n = $('<div/>')
  3794. .css( 'width', _fnStringToCss( width ) )
  3795. .appendTo( parent || document.body );
  3796. var val = n[0].offsetWidth;
  3797. n.remove();
  3798. return val;
  3799. }
  3800. /**
  3801. * Get the widest node
  3802. * @param {object} settings dataTables settings object
  3803. * @param {int} colIdx column of interest
  3804. * @returns {node} widest table node
  3805. * @memberof DataTable#oApi
  3806. */
  3807. function _fnGetWidestNode( settings, colIdx )
  3808. {
  3809. var idx = _fnGetMaxLenString( settings, colIdx );
  3810. if ( idx < 0 ) {
  3811. return null;
  3812. }
  3813. var data = settings.aoData[ idx ];
  3814. return ! data.nTr ? // Might not have been created when deferred rendering
  3815. $('<td/>').html( _fnGetCellData( settings, idx, colIdx, 'display' ) )[0] :
  3816. data.anCells[ colIdx ];
  3817. }
  3818. /**
  3819. * Get the maximum strlen for each data column
  3820. * @param {object} settings dataTables settings object
  3821. * @param {int} colIdx column of interest
  3822. * @returns {string} max string length for each column
  3823. * @memberof DataTable#oApi
  3824. */
  3825. function _fnGetMaxLenString( settings, colIdx )
  3826. {
  3827. var s, max=-1, maxIdx = -1;
  3828. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  3829. s = _fnGetCellData( settings, i, colIdx, 'display' )+'';
  3830. s = s.replace( __re_html_remove, '' );
  3831. s = s.replace( /&nbsp;/g, ' ' );
  3832. if ( s.length > max ) {
  3833. max = s.length;
  3834. maxIdx = i;
  3835. }
  3836. }
  3837. return maxIdx;
  3838. }
  3839. /**
  3840. * Append a CSS unit (only if required) to a string
  3841. * @param {string} value to css-ify
  3842. * @returns {string} value with css unit
  3843. * @memberof DataTable#oApi
  3844. */
  3845. function _fnStringToCss( s )
  3846. {
  3847. if ( s === null ) {
  3848. return '0px';
  3849. }
  3850. if ( typeof s == 'number' ) {
  3851. return s < 0 ?
  3852. '0px' :
  3853. s+'px';
  3854. }
  3855. // Check it has a unit character already
  3856. return s.match(/\d$/) ?
  3857. s+'px' :
  3858. s;
  3859. }
  3860. function _fnSortFlatten ( settings )
  3861. {
  3862. var
  3863. i, iLen, k, kLen,
  3864. aSort = [],
  3865. aiOrig = [],
  3866. aoColumns = settings.aoColumns,
  3867. aDataSort, iCol, sType, srcCol,
  3868. fixed = settings.aaSortingFixed,
  3869. fixedObj = $.isPlainObject( fixed ),
  3870. nestedSort = [],
  3871. add = function ( a ) {
  3872. if ( a.length && ! $.isArray( a[0] ) ) {
  3873. // 1D array
  3874. nestedSort.push( a );
  3875. }
  3876. else {
  3877. // 2D array
  3878. $.merge( nestedSort, a );
  3879. }
  3880. };
  3881. // Build the sort array, with pre-fix and post-fix options if they have been
  3882. // specified
  3883. if ( $.isArray( fixed ) ) {
  3884. add( fixed );
  3885. }
  3886. if ( fixedObj && fixed.pre ) {
  3887. add( fixed.pre );
  3888. }
  3889. add( settings.aaSorting );
  3890. if (fixedObj && fixed.post ) {
  3891. add( fixed.post );
  3892. }
  3893. for ( i=0 ; i<nestedSort.length ; i++ )
  3894. {
  3895. srcCol = nestedSort[i][0];
  3896. aDataSort = aoColumns[ srcCol ].aDataSort;
  3897. for ( k=0, kLen=aDataSort.length ; k<kLen ; k++ )
  3898. {
  3899. iCol = aDataSort[k];
  3900. sType = aoColumns[ iCol ].sType || 'string';
  3901. if ( nestedSort[i]._idx === undefined ) {
  3902. nestedSort[i]._idx = $.inArray( nestedSort[i][1], aoColumns[iCol].asSorting );
  3903. }
  3904. aSort.push( {
  3905. src: srcCol,
  3906. col: iCol,
  3907. dir: nestedSort[i][1],
  3908. index: nestedSort[i]._idx,
  3909. type: sType,
  3910. formatter: DataTable.ext.type.order[ sType+"-pre" ]
  3911. } );
  3912. }
  3913. }
  3914. return aSort;
  3915. }
  3916. /**
  3917. * Change the order of the table
  3918. * @param {object} oSettings dataTables settings object
  3919. * @memberof DataTable#oApi
  3920. * @todo This really needs split up!
  3921. */
  3922. function _fnSort ( oSettings )
  3923. {
  3924. var
  3925. i, ien, iLen, j, jLen, k, kLen,
  3926. sDataType, nTh,
  3927. aiOrig = [],
  3928. oExtSort = DataTable.ext.type.order,
  3929. aoData = oSettings.aoData,
  3930. aoColumns = oSettings.aoColumns,
  3931. aDataSort, data, iCol, sType, oSort,
  3932. formatters = 0,
  3933. sortCol,
  3934. displayMaster = oSettings.aiDisplayMaster,
  3935. aSort;
  3936. // Resolve any column types that are unknown due to addition or invalidation
  3937. // @todo Can this be moved into a 'data-ready' handler which is called when
  3938. // data is going to be used in the table?
  3939. _fnColumnTypes( oSettings );
  3940. aSort = _fnSortFlatten( oSettings );
  3941. for ( i=0, ien=aSort.length ; i<ien ; i++ ) {
  3942. sortCol = aSort[i];
  3943. // Track if we can use the fast sort algorithm
  3944. if ( sortCol.formatter ) {
  3945. formatters++;
  3946. }
  3947. // Load the data needed for the sort, for each cell
  3948. _fnSortData( oSettings, sortCol.col );
  3949. }
  3950. /* No sorting required if server-side or no sorting array */
  3951. if ( _fnDataSource( oSettings ) != 'ssp' && aSort.length !== 0 )
  3952. {
  3953. // Create a value - key array of the current row positions such that we can use their
  3954. // current position during the sort, if values match, in order to perform stable sorting
  3955. for ( i=0, iLen=displayMaster.length ; i<iLen ; i++ ) {
  3956. aiOrig[ displayMaster[i] ] = i;
  3957. }
  3958. /* Do the sort - here we want multi-column sorting based on a given data source (column)
  3959. * and sorting function (from oSort) in a certain direction. It's reasonably complex to
  3960. * follow on it's own, but this is what we want (example two column sorting):
  3961. * fnLocalSorting = function(a,b){
  3962. * var iTest;
  3963. * iTest = oSort['string-asc']('data11', 'data12');
  3964. * if (iTest !== 0)
  3965. * return iTest;
  3966. * iTest = oSort['numeric-desc']('data21', 'data22');
  3967. * if (iTest !== 0)
  3968. * return iTest;
  3969. * return oSort['numeric-asc']( aiOrig[a], aiOrig[b] );
  3970. * }
  3971. * Basically we have a test for each sorting column, if the data in that column is equal,
  3972. * test the next column. If all columns match, then we use a numeric sort on the row
  3973. * positions in the original data array to provide a stable sort.
  3974. *
  3975. * Note - I know it seems excessive to have two sorting methods, but the first is around
  3976. * 15% faster, so the second is only maintained for backwards compatibility with sorting
  3977. * methods which do not have a pre-sort formatting function.
  3978. */
  3979. if ( formatters === aSort.length ) {
  3980. // All sort types have formatting functions
  3981. displayMaster.sort( function ( a, b ) {
  3982. var
  3983. x, y, k, test, sort,
  3984. len=aSort.length,
  3985. dataA = aoData[a]._aSortData,
  3986. dataB = aoData[b]._aSortData;
  3987. for ( k=0 ; k<len ; k++ ) {
  3988. sort = aSort[k];
  3989. x = dataA[ sort.col ];
  3990. y = dataB[ sort.col ];
  3991. test = x<y ? -1 : x>y ? 1 : 0;
  3992. if ( test !== 0 ) {
  3993. return sort.dir === 'asc' ? test : -test;
  3994. }
  3995. }
  3996. x = aiOrig[a];
  3997. y = aiOrig[b];
  3998. return x<y ? -1 : x>y ? 1 : 0;
  3999. } );
  4000. }
  4001. else {
  4002. // Depreciated - remove in 1.11 (providing a plug-in option)
  4003. // Not all sort types have formatting methods, so we have to call their sorting
  4004. // methods.
  4005. displayMaster.sort( function ( a, b ) {
  4006. var
  4007. x, y, k, l, test, sort, fn,
  4008. len=aSort.length,
  4009. dataA = aoData[a]._aSortData,
  4010. dataB = aoData[b]._aSortData;
  4011. for ( k=0 ; k<len ; k++ ) {
  4012. sort = aSort[k];
  4013. x = dataA[ sort.col ];
  4014. y = dataB[ sort.col ];
  4015. fn = oExtSort[ sort.type+"-"+sort.dir ] || oExtSort[ "string-"+sort.dir ];
  4016. test = fn( x, y );
  4017. if ( test !== 0 ) {
  4018. return test;
  4019. }
  4020. }
  4021. x = aiOrig[a];
  4022. y = aiOrig[b];
  4023. return x<y ? -1 : x>y ? 1 : 0;
  4024. } );
  4025. }
  4026. }
  4027. /* Tell the draw function that we have sorted the data */
  4028. oSettings.bSorted = true;
  4029. }
  4030. function _fnSortAria ( settings )
  4031. {
  4032. var label;
  4033. var nextSort;
  4034. var columns = settings.aoColumns;
  4035. var aSort = _fnSortFlatten( settings );
  4036. var oAria = settings.oLanguage.oAria;
  4037. // ARIA attributes - need to loop all columns, to update all (removing old
  4038. // attributes as needed)
  4039. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  4040. {
  4041. var col = columns[i];
  4042. var asSorting = col.asSorting;
  4043. var sTitle = col.sTitle.replace( /<.*?>/g, "" );
  4044. var th = col.nTh;
  4045. // IE7 is throwing an error when setting these properties with jQuery's
  4046. // attr() and removeAttr() methods...
  4047. th.removeAttribute('aria-sort');
  4048. /* In ARIA only the first sorting column can be marked as sorting - no multi-sort option */
  4049. if ( col.bSortable ) {
  4050. if ( aSort.length > 0 && aSort[0].col == i ) {
  4051. th.setAttribute('aria-sort', aSort[0].dir=="asc" ? "ascending" : "descending" );
  4052. nextSort = asSorting[ aSort[0].index+1 ] || asSorting[0];
  4053. }
  4054. else {
  4055. nextSort = asSorting[0];
  4056. }
  4057. label = sTitle + ( nextSort === "asc" ?
  4058. oAria.sSortAscending :
  4059. oAria.sSortDescending
  4060. );
  4061. }
  4062. else {
  4063. label = sTitle;
  4064. }
  4065. th.setAttribute('aria-label', label);
  4066. }
  4067. }
  4068. /**
  4069. * Function to run on user sort request
  4070. * @param {object} settings dataTables settings object
  4071. * @param {node} attachTo node to attach the handler to
  4072. * @param {int} colIdx column sorting index
  4073. * @param {boolean} [append=false] Append the requested sort to the existing
  4074. * sort if true (i.e. multi-column sort)
  4075. * @param {function} [callback] callback function
  4076. * @memberof DataTable#oApi
  4077. */
  4078. function _fnSortListener ( settings, colIdx, append, callback )
  4079. {
  4080. var col = settings.aoColumns[ colIdx ];
  4081. var sorting = settings.aaSorting;
  4082. var asSorting = col.asSorting;
  4083. var nextSortIdx;
  4084. var next = function ( a, overflow ) {
  4085. var idx = a._idx;
  4086. if ( idx === undefined ) {
  4087. idx = $.inArray( a[1], asSorting );
  4088. }
  4089. return idx+1 < asSorting.length ?
  4090. idx+1 :
  4091. overflow ?
  4092. null :
  4093. 0;
  4094. };
  4095. // Convert to 2D array if needed
  4096. if ( typeof sorting[0] === 'number' ) {
  4097. sorting = settings.aaSorting = [ sorting ];
  4098. }
  4099. // If appending the sort then we are multi-column sorting
  4100. if ( append && settings.oFeatures.bSortMulti ) {
  4101. // Are we already doing some kind of sort on this column?
  4102. var sortIdx = $.inArray( colIdx, _pluck(sorting, '0') );
  4103. if ( sortIdx !== -1 ) {
  4104. // Yes, modify the sort
  4105. nextSortIdx = next( sorting[sortIdx], true );
  4106. if ( nextSortIdx === null && sorting.length === 1 ) {
  4107. nextSortIdx = 0; // can't remove sorting completely
  4108. }
  4109. if ( nextSortIdx === null ) {
  4110. sorting.splice( sortIdx, 1 );
  4111. }
  4112. else {
  4113. sorting[sortIdx][1] = asSorting[ nextSortIdx ];
  4114. sorting[sortIdx]._idx = nextSortIdx;
  4115. }
  4116. }
  4117. else {
  4118. // No sort on this column yet
  4119. sorting.push( [ colIdx, asSorting[0], 0 ] );
  4120. sorting[sorting.length-1]._idx = 0;
  4121. }
  4122. }
  4123. else if ( sorting.length && sorting[0][0] == colIdx ) {
  4124. // Single column - already sorting on this column, modify the sort
  4125. nextSortIdx = next( sorting[0] );
  4126. sorting.length = 1;
  4127. sorting[0][1] = asSorting[ nextSortIdx ];
  4128. sorting[0]._idx = nextSortIdx;
  4129. }
  4130. else {
  4131. // Single column - sort only on this column
  4132. sorting.length = 0;
  4133. sorting.push( [ colIdx, asSorting[0] ] );
  4134. sorting[0]._idx = 0;
  4135. }
  4136. // Run the sort by calling a full redraw
  4137. _fnReDraw( settings );
  4138. // callback used for async user interaction
  4139. if ( typeof callback == 'function' ) {
  4140. callback( settings );
  4141. }
  4142. }
  4143. /**
  4144. * Attach a sort handler (click) to a node
  4145. * @param {object} settings dataTables settings object
  4146. * @param {node} attachTo node to attach the handler to
  4147. * @param {int} colIdx column sorting index
  4148. * @param {function} [callback] callback function
  4149. * @memberof DataTable#oApi
  4150. */
  4151. function _fnSortAttachListener ( settings, attachTo, colIdx, callback )
  4152. {
  4153. var col = settings.aoColumns[ colIdx ];
  4154. _fnBindAction( attachTo, {}, function (e) {
  4155. /* If the column is not sortable - don't to anything */
  4156. if ( col.bSortable === false ) {
  4157. return;
  4158. }
  4159. // If processing is enabled use a timeout to allow the processing
  4160. // display to be shown - otherwise to it synchronously
  4161. if ( settings.oFeatures.bProcessing ) {
  4162. _fnProcessingDisplay( settings, true );
  4163. setTimeout( function() {
  4164. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  4165. // In server-side processing, the draw callback will remove the
  4166. // processing display
  4167. if ( _fnDataSource( settings ) !== 'ssp' ) {
  4168. _fnProcessingDisplay( settings, false );
  4169. }
  4170. }, 0 );
  4171. }
  4172. else {
  4173. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  4174. }
  4175. } );
  4176. }
  4177. /**
  4178. * Set the sorting classes on table's body, Note: it is safe to call this function
  4179. * when bSort and bSortClasses are false
  4180. * @param {object} oSettings dataTables settings object
  4181. * @memberof DataTable#oApi
  4182. */
  4183. function _fnSortingClasses( settings )
  4184. {
  4185. var oldSort = settings.aLastSort;
  4186. var sortClass = settings.oClasses.sSortColumn;
  4187. var sort = _fnSortFlatten( settings );
  4188. var features = settings.oFeatures;
  4189. var i, ien, colIdx;
  4190. if ( features.bSort && features.bSortClasses ) {
  4191. // Remove old sorting classes
  4192. for ( i=0, ien=oldSort.length ; i<ien ; i++ ) {
  4193. colIdx = oldSort[i].src;
  4194. // Remove column sorting
  4195. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  4196. .removeClass( sortClass + (i<2 ? i+1 : 3) );
  4197. }
  4198. // Add new column sorting
  4199. for ( i=0, ien=sort.length ; i<ien ; i++ ) {
  4200. colIdx = sort[i].src;
  4201. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  4202. .addClass( sortClass + (i<2 ? i+1 : 3) );
  4203. }
  4204. }
  4205. settings.aLastSort = sort;
  4206. }
  4207. // Get the data to sort a column, be it from cache, fresh (populating the
  4208. // cache), or from a sort formatter
  4209. function _fnSortData( settings, idx )
  4210. {
  4211. // Custom sorting function - provided by the sort data type
  4212. var column = settings.aoColumns[ idx ];
  4213. var customSort = DataTable.ext.order[ column.sSortDataType ];
  4214. var customData;
  4215. if ( customSort ) {
  4216. customData = customSort.call( settings.oInstance, settings, idx,
  4217. _fnColumnIndexToVisible( settings, idx )
  4218. );
  4219. }
  4220. // Use / populate cache
  4221. var row, cellData;
  4222. var formatter = DataTable.ext.type.order[ column.sType+"-pre" ];
  4223. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  4224. row = settings.aoData[i];
  4225. if ( ! row._aSortData ) {
  4226. row._aSortData = [];
  4227. }
  4228. if ( ! row._aSortData[idx] || customSort ) {
  4229. cellData = customSort ?
  4230. customData[i] : // If there was a custom sort function, use data from there
  4231. _fnGetCellData( settings, i, idx, 'sort' );
  4232. row._aSortData[ idx ] = formatter ?
  4233. formatter( cellData ) :
  4234. cellData;
  4235. }
  4236. }
  4237. }
  4238. /**
  4239. * Save the state of a table
  4240. * @param {object} oSettings dataTables settings object
  4241. * @memberof DataTable#oApi
  4242. */
  4243. function _fnSaveState ( settings )
  4244. {
  4245. if ( !settings.oFeatures.bStateSave || settings.bDestroying )
  4246. {
  4247. return;
  4248. }
  4249. /* Store the interesting variables */
  4250. var state = {
  4251. time: +new Date(),
  4252. start: settings._iDisplayStart,
  4253. length: settings._iDisplayLength,
  4254. order: $.extend( true, [], settings.aaSorting ),
  4255. search: _fnSearchToCamel( settings.oPreviousSearch ),
  4256. columns: $.map( settings.aoColumns, function ( col, i ) {
  4257. return {
  4258. visible: col.bVisible,
  4259. search: _fnSearchToCamel( settings.aoPreSearchCols[i] )
  4260. };
  4261. } )
  4262. };
  4263. _fnCallbackFire( settings, "aoStateSaveParams", 'stateSaveParams', [settings, state] );
  4264. settings.oSavedState = state;
  4265. settings.fnStateSaveCallback.call( settings.oInstance, settings, state );
  4266. }
  4267. /**
  4268. * Attempt to load a saved table state
  4269. * @param {object} oSettings dataTables settings object
  4270. * @param {object} oInit DataTables init object so we can override settings
  4271. * @memberof DataTable#oApi
  4272. */
  4273. function _fnLoadState ( settings, oInit )
  4274. {
  4275. var i, ien;
  4276. var columns = settings.aoColumns;
  4277. if ( ! settings.oFeatures.bStateSave ) {
  4278. return;
  4279. }
  4280. var state = settings.fnStateLoadCallback.call( settings.oInstance, settings );
  4281. if ( ! state || ! state.time ) {
  4282. return;
  4283. }
  4284. /* Allow custom and plug-in manipulation functions to alter the saved data set and
  4285. * cancelling of loading by returning false
  4286. */
  4287. var abStateLoad = _fnCallbackFire( settings, 'aoStateLoadParams', 'stateLoadParams', [settings, state] );
  4288. if ( $.inArray( false, abStateLoad ) !== -1 ) {
  4289. return;
  4290. }
  4291. /* Reject old data */
  4292. var duration = settings.iStateDuration;
  4293. if ( duration > 0 && state.time < +new Date() - (duration*1000) ) {
  4294. return;
  4295. }
  4296. // Number of columns have changed - all bets are off, no restore of settings
  4297. if ( columns.length !== state.columns.length ) {
  4298. return;
  4299. }
  4300. // Store the saved state so it might be accessed at any time
  4301. settings.oLoadedState = $.extend( true, {}, state );
  4302. // Restore key features - todo - for 1.11 this needs to be done by
  4303. // subscribed events
  4304. if ( state.start !== undefined ) {
  4305. settings._iDisplayStart = state.start;
  4306. settings.iInitDisplayStart = state.start;
  4307. }
  4308. if ( state.length !== undefined ) {
  4309. settings._iDisplayLength = state.length;
  4310. }
  4311. // Order
  4312. if ( state.order !== undefined ) {
  4313. settings.aaSorting = [];
  4314. $.each( state.order, function ( i, col ) {
  4315. settings.aaSorting.push( col[0] >= columns.length ?
  4316. [ 0, col[1] ] :
  4317. col
  4318. );
  4319. } );
  4320. }
  4321. // Search
  4322. if ( state.search !== undefined ) {
  4323. $.extend( settings.oPreviousSearch, _fnSearchToHung( state.search ) );
  4324. }
  4325. // Columns
  4326. for ( i=0, ien=state.columns.length ; i<ien ; i++ ) {
  4327. var col = state.columns[i];
  4328. // Visibility
  4329. if ( col.visible !== undefined ) {
  4330. columns[i].bVisible = col.visible;
  4331. }
  4332. // Search
  4333. if ( col.search !== undefined ) {
  4334. $.extend( settings.aoPreSearchCols[i], _fnSearchToHung( col.search ) );
  4335. }
  4336. }
  4337. _fnCallbackFire( settings, 'aoStateLoaded', 'stateLoaded', [settings, state] );
  4338. }
  4339. /**
  4340. * Return the settings object for a particular table
  4341. * @param {node} table table we are using as a dataTable
  4342. * @returns {object} Settings object - or null if not found
  4343. * @memberof DataTable#oApi
  4344. */
  4345. function _fnSettingsFromNode ( table )
  4346. {
  4347. var settings = DataTable.settings;
  4348. var idx = $.inArray( table, _pluck( settings, 'nTable' ) );
  4349. return idx !== -1 ?
  4350. settings[ idx ] :
  4351. null;
  4352. }
  4353. /**
  4354. * Log an error message
  4355. * @param {object} settings dataTables settings object
  4356. * @param {int} level log error messages, or display them to the user
  4357. * @param {string} msg error message
  4358. * @param {int} tn Technical note id to get more information about the error.
  4359. * @memberof DataTable#oApi
  4360. */
  4361. function _fnLog( settings, level, msg, tn )
  4362. {
  4363. msg = 'DataTables warning: '+
  4364. (settings ? 'table id='+settings.sTableId+' - ' : '')+msg;
  4365. if ( tn ) {
  4366. msg += '. For more information about this error, please see '+
  4367. 'http://datatables.net/tn/'+tn;
  4368. }
  4369. if ( ! level ) {
  4370. // Backwards compatibility pre 1.10
  4371. var ext = DataTable.ext;
  4372. var type = ext.sErrMode || ext.errMode;
  4373. if ( settings ) {
  4374. _fnCallbackFire( settings, null, 'error', [ settings, tn, msg ] );
  4375. }
  4376. if ( type == 'alert' ) {
  4377. alert( msg );
  4378. }
  4379. else if ( type == 'throw' ) {
  4380. throw new Error(msg);
  4381. }
  4382. else if ( typeof type == 'function' ) {
  4383. type( settings, tn, msg );
  4384. }
  4385. }
  4386. else if ( window.console && console.log ) {
  4387. console.log( msg );
  4388. }
  4389. }
  4390. /**
  4391. * See if a property is defined on one object, if so assign it to the other object
  4392. * @param {object} ret target object
  4393. * @param {object} src source object
  4394. * @param {string} name property
  4395. * @param {string} [mappedName] name to map too - optional, name used if not given
  4396. * @memberof DataTable#oApi
  4397. */
  4398. function _fnMap( ret, src, name, mappedName )
  4399. {
  4400. if ( $.isArray( name ) ) {
  4401. $.each( name, function (i, val) {
  4402. if ( $.isArray( val ) ) {
  4403. _fnMap( ret, src, val[0], val[1] );
  4404. }
  4405. else {
  4406. _fnMap( ret, src, val );
  4407. }
  4408. } );
  4409. return;
  4410. }
  4411. if ( mappedName === undefined ) {
  4412. mappedName = name;
  4413. }
  4414. if ( src[name] !== undefined ) {
  4415. ret[mappedName] = src[name];
  4416. }
  4417. }
  4418. /**
  4419. * Extend objects - very similar to jQuery.extend, but deep copy objects, and
  4420. * shallow copy arrays. The reason we need to do this, is that we don't want to
  4421. * deep copy array init values (such as aaSorting) since the dev wouldn't be
  4422. * able to override them, but we do want to deep copy arrays.
  4423. * @param {object} out Object to extend
  4424. * @param {object} extender Object from which the properties will be applied to
  4425. * out
  4426. * @param {boolean} breakRefs If true, then arrays will be sliced to take an
  4427. * independent copy with the exception of the `data` or `aaData` parameters
  4428. * if they are present. This is so you can pass in a collection to
  4429. * DataTables and have that used as your data source without breaking the
  4430. * references
  4431. * @returns {object} out Reference, just for convenience - out === the return.
  4432. * @memberof DataTable#oApi
  4433. * @todo This doesn't take account of arrays inside the deep copied objects.
  4434. */
  4435. function _fnExtend( out, extender, breakRefs )
  4436. {
  4437. var val;
  4438. for ( var prop in extender ) {
  4439. if ( extender.hasOwnProperty(prop) ) {
  4440. val = extender[prop];
  4441. if ( $.isPlainObject( val ) ) {
  4442. if ( ! $.isPlainObject( out[prop] ) ) {
  4443. out[prop] = {};
  4444. }
  4445. $.extend( true, out[prop], val );
  4446. }
  4447. else if ( breakRefs && prop !== 'data' && prop !== 'aaData' && $.isArray(val) ) {
  4448. out[prop] = val.slice();
  4449. }
  4450. else {
  4451. out[prop] = val;
  4452. }
  4453. }
  4454. }
  4455. return out;
  4456. }
  4457. /**
  4458. * Bind an event handers to allow a click or return key to activate the callback.
  4459. * This is good for accessibility since a return on the keyboard will have the
  4460. * same effect as a click, if the element has focus.
  4461. * @param {element} n Element to bind the action to
  4462. * @param {object} oData Data object to pass to the triggered function
  4463. * @param {function} fn Callback function for when the event is triggered
  4464. * @memberof DataTable#oApi
  4465. */
  4466. function _fnBindAction( n, oData, fn )
  4467. {
  4468. $(n)
  4469. .bind( 'click.DT', oData, function (e) {
  4470. n.blur(); // Remove focus outline for mouse users
  4471. fn(e);
  4472. } )
  4473. .bind( 'keypress.DT', oData, function (e){
  4474. if ( e.which === 13 ) {
  4475. e.preventDefault();
  4476. fn(e);
  4477. }
  4478. } )
  4479. .bind( 'selectstart.DT', function () {
  4480. /* Take the brutal approach to cancelling text selection */
  4481. return false;
  4482. } );
  4483. }
  4484. /**
  4485. * Register a callback function. Easily allows a callback function to be added to
  4486. * an array store of callback functions that can then all be called together.
  4487. * @param {object} oSettings dataTables settings object
  4488. * @param {string} sStore Name of the array storage for the callbacks in oSettings
  4489. * @param {function} fn Function to be called back
  4490. * @param {string} sName Identifying name for the callback (i.e. a label)
  4491. * @memberof DataTable#oApi
  4492. */
  4493. function _fnCallbackReg( oSettings, sStore, fn, sName )
  4494. {
  4495. if ( fn )
  4496. {
  4497. oSettings[sStore].push( {
  4498. "fn": fn,
  4499. "sName": sName
  4500. } );
  4501. }
  4502. }
  4503. /**
  4504. * Fire callback functions and trigger events. Note that the loop over the
  4505. * callback array store is done backwards! Further note that you do not want to
  4506. * fire off triggers in time sensitive applications (for example cell creation)
  4507. * as its slow.
  4508. * @param {object} settings dataTables settings object
  4509. * @param {string} callbackArr Name of the array storage for the callbacks in
  4510. * oSettings
  4511. * @param {string} eventName Name of the jQuery custom event to trigger. If
  4512. * null no trigger is fired
  4513. * @param {array} args Array of arguments to pass to the callback function /
  4514. * trigger
  4515. * @memberof DataTable#oApi
  4516. */
  4517. function _fnCallbackFire( settings, callbackArr, eventName, args )
  4518. {
  4519. var ret = [];
  4520. if ( callbackArr ) {
  4521. ret = $.map( settings[callbackArr].slice().reverse(), function (val, i) {
  4522. return val.fn.apply( settings.oInstance, args );
  4523. } );
  4524. }
  4525. if ( eventName !== null ) {
  4526. var e = $.Event( eventName+'.dt' );
  4527. $(settings.nTable).trigger( e, args );
  4528. ret.push( e.result );
  4529. }
  4530. return ret;
  4531. }
  4532. function _fnLengthOverflow ( settings )
  4533. {
  4534. var
  4535. start = settings._iDisplayStart,
  4536. end = settings.fnDisplayEnd(),
  4537. len = settings._iDisplayLength;
  4538. /* If we have space to show extra rows (backing up from the end point - then do so */
  4539. if ( start >= end )
  4540. {
  4541. start = end - len;
  4542. }
  4543. // Keep the start record on the current page
  4544. start -= (start % len);
  4545. if ( len === -1 || start < 0 )
  4546. {
  4547. start = 0;
  4548. }
  4549. settings._iDisplayStart = start;
  4550. }
  4551. function _fnRenderer( settings, type )
  4552. {
  4553. var renderer = settings.renderer;
  4554. var host = DataTable.ext.renderer[type];
  4555. if ( $.isPlainObject( renderer ) && renderer[type] ) {
  4556. // Specific renderer for this type. If available use it, otherwise use
  4557. // the default.
  4558. return host[renderer[type]] || host._;
  4559. }
  4560. else if ( typeof renderer === 'string' ) {
  4561. // Common renderer - if there is one available for this type use it,
  4562. // otherwise use the default
  4563. return host[renderer] || host._;
  4564. }
  4565. // Use the default
  4566. return host._;
  4567. }
  4568. /**
  4569. * Detect the data source being used for the table. Used to simplify the code
  4570. * a little (ajax) and to make it compress a little smaller.
  4571. *
  4572. * @param {object} settings dataTables settings object
  4573. * @returns {string} Data source
  4574. * @memberof DataTable#oApi
  4575. */
  4576. function _fnDataSource ( settings )
  4577. {
  4578. if ( settings.oFeatures.bServerSide ) {
  4579. return 'ssp';
  4580. }
  4581. else if ( settings.ajax || settings.sAjaxSource ) {
  4582. return 'ajax';
  4583. }
  4584. return 'dom';
  4585. }
  4586. DataTable = function( options )
  4587. {
  4588. /**
  4589. * Perform a jQuery selector action on the table's TR elements (from the tbody) and
  4590. * return the resulting jQuery object.
  4591. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  4592. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  4593. * @param {string} [oOpts.filter=none] Select TR elements that meet the current filter
  4594. * criterion ("applied") or all TR elements (i.e. no filter).
  4595. * @param {string} [oOpts.order=current] Order of the TR elements in the processed array.
  4596. * Can be either 'current', whereby the current sorting of the table is used, or
  4597. * 'original' whereby the original order the data was read into the table is used.
  4598. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  4599. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  4600. * 'current' and filter is 'applied', regardless of what they might be given as.
  4601. * @returns {object} jQuery object, filtered by the given selector.
  4602. * @dtopt API
  4603. * @deprecated Since v1.10
  4604. *
  4605. * @example
  4606. * $(document).ready(function() {
  4607. * var oTable = $('#example').dataTable();
  4608. *
  4609. * // Highlight every second row
  4610. * oTable.$('tr:odd').css('backgroundColor', 'blue');
  4611. * } );
  4612. *
  4613. * @example
  4614. * $(document).ready(function() {
  4615. * var oTable = $('#example').dataTable();
  4616. *
  4617. * // Filter to rows with 'Webkit' in them, add a background colour and then
  4618. * // remove the filter, thus highlighting the 'Webkit' rows only.
  4619. * oTable.fnFilter('Webkit');
  4620. * oTable.$('tr', {"search": "applied"}).css('backgroundColor', 'blue');
  4621. * oTable.fnFilter('');
  4622. * } );
  4623. */
  4624. this.$ = function ( sSelector, oOpts )
  4625. {
  4626. return this.api(true).$( sSelector, oOpts );
  4627. };
  4628. /**
  4629. * Almost identical to $ in operation, but in this case returns the data for the matched
  4630. * rows - as such, the jQuery selector used should match TR row nodes or TD/TH cell nodes
  4631. * rather than any descendants, so the data can be obtained for the row/cell. If matching
  4632. * rows are found, the data returned is the original data array/object that was used to
  4633. * create the row (or a generated array if from a DOM source).
  4634. *
  4635. * This method is often useful in-combination with $ where both functions are given the
  4636. * same parameters and the array indexes will match identically.
  4637. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  4638. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  4639. * @param {string} [oOpts.filter=none] Select elements that meet the current filter
  4640. * criterion ("applied") or all elements (i.e. no filter).
  4641. * @param {string} [oOpts.order=current] Order of the data in the processed array.
  4642. * Can be either 'current', whereby the current sorting of the table is used, or
  4643. * 'original' whereby the original order the data was read into the table is used.
  4644. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  4645. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  4646. * 'current' and filter is 'applied', regardless of what they might be given as.
  4647. * @returns {array} Data for the matched elements. If any elements, as a result of the
  4648. * selector, were not TR, TD or TH elements in the DataTable, they will have a null
  4649. * entry in the array.
  4650. * @dtopt API
  4651. * @deprecated Since v1.10
  4652. *
  4653. * @example
  4654. * $(document).ready(function() {
  4655. * var oTable = $('#example').dataTable();
  4656. *
  4657. * // Get the data from the first row in the table
  4658. * var data = oTable._('tr:first');
  4659. *
  4660. * // Do something useful with the data
  4661. * alert( "First cell is: "+data[0] );
  4662. * } );
  4663. *
  4664. * @example
  4665. * $(document).ready(function() {
  4666. * var oTable = $('#example').dataTable();
  4667. *
  4668. * // Filter to 'Webkit' and get all data for
  4669. * oTable.fnFilter('Webkit');
  4670. * var data = oTable._('tr', {"search": "applied"});
  4671. *
  4672. * // Do something with the data
  4673. * alert( data.length+" rows matched the search" );
  4674. * } );
  4675. */
  4676. this._ = function ( sSelector, oOpts )
  4677. {
  4678. return this.api(true).rows( sSelector, oOpts ).data();
  4679. };
  4680. /**
  4681. * Create a DataTables Api instance, with the currently selected tables for
  4682. * the Api's context.
  4683. * @param {boolean} [traditional=false] Set the API instance's context to be
  4684. * only the table referred to by the `DataTable.ext.iApiIndex` option, as was
  4685. * used in the API presented by DataTables 1.9- (i.e. the traditional mode),
  4686. * or if all tables captured in the jQuery object should be used.
  4687. * @return {DataTables.Api}
  4688. */
  4689. this.api = function ( traditional )
  4690. {
  4691. return traditional ?
  4692. new _Api(
  4693. _fnSettingsFromNode( this[ _ext.iApiIndex ] )
  4694. ) :
  4695. new _Api( this );
  4696. };
  4697. /**
  4698. * Add a single new row or multiple rows of data to the table. Please note
  4699. * that this is suitable for client-side processing only - if you are using
  4700. * server-side processing (i.e. "bServerSide": true), then to add data, you
  4701. * must add it to the data source, i.e. the server-side, through an Ajax call.
  4702. * @param {array|object} data The data to be added to the table. This can be:
  4703. * <ul>
  4704. * <li>1D array of data - add a single row with the data provided</li>
  4705. * <li>2D array of arrays - add multiple rows in a single call</li>
  4706. * <li>object - data object when using <i>mData</i></li>
  4707. * <li>array of objects - multiple data objects when using <i>mData</i></li>
  4708. * </ul>
  4709. * @param {bool} [redraw=true] redraw the table or not
  4710. * @returns {array} An array of integers, representing the list of indexes in
  4711. * <i>aoData</i> ({@link DataTable.models.oSettings}) that have been added to
  4712. * the table.
  4713. * @dtopt API
  4714. * @deprecated Since v1.10
  4715. *
  4716. * @example
  4717. * // Global var for counter
  4718. * var giCount = 2;
  4719. *
  4720. * $(document).ready(function() {
  4721. * $('#example').dataTable();
  4722. * } );
  4723. *
  4724. * function fnClickAddRow() {
  4725. * $('#example').dataTable().fnAddData( [
  4726. * giCount+".1",
  4727. * giCount+".2",
  4728. * giCount+".3",
  4729. * giCount+".4" ]
  4730. * );
  4731. *
  4732. * giCount++;
  4733. * }
  4734. */
  4735. this.fnAddData = function( data, redraw )
  4736. {
  4737. var api = this.api( true );
  4738. /* Check if we want to add multiple rows or not */
  4739. var rows = $.isArray(data) && ( $.isArray(data[0]) || $.isPlainObject(data[0]) ) ?
  4740. api.rows.add( data ) :
  4741. api.row.add( data );
  4742. if ( redraw === undefined || redraw ) {
  4743. api.draw();
  4744. }
  4745. return rows.flatten().toArray();
  4746. };
  4747. /**
  4748. * This function will make DataTables recalculate the column sizes, based on the data
  4749. * contained in the table and the sizes applied to the columns (in the DOM, CSS or
  4750. * through the sWidth parameter). This can be useful when the width of the table's
  4751. * parent element changes (for example a window resize).
  4752. * @param {boolean} [bRedraw=true] Redraw the table or not, you will typically want to
  4753. * @dtopt API
  4754. * @deprecated Since v1.10
  4755. *
  4756. * @example
  4757. * $(document).ready(function() {
  4758. * var oTable = $('#example').dataTable( {
  4759. * "sScrollY": "200px",
  4760. * "bPaginate": false
  4761. * } );
  4762. *
  4763. * $(window).bind('resize', function () {
  4764. * oTable.fnAdjustColumnSizing();
  4765. * } );
  4766. * } );
  4767. */
  4768. this.fnAdjustColumnSizing = function ( bRedraw )
  4769. {
  4770. var api = this.api( true ).columns.adjust();
  4771. var settings = api.settings()[0];
  4772. var scroll = settings.oScroll;
  4773. if ( bRedraw === undefined || bRedraw ) {
  4774. api.draw( false );
  4775. }
  4776. else if ( scroll.sX !== "" || scroll.sY !== "" ) {
  4777. /* If not redrawing, but scrolling, we want to apply the new column sizes anyway */
  4778. _fnScrollDraw( settings );
  4779. }
  4780. };
  4781. /**
  4782. * Quickly and simply clear a table
  4783. * @param {bool} [bRedraw=true] redraw the table or not
  4784. * @dtopt API
  4785. * @deprecated Since v1.10
  4786. *
  4787. * @example
  4788. * $(document).ready(function() {
  4789. * var oTable = $('#example').dataTable();
  4790. *
  4791. * // Immediately 'nuke' the current rows (perhaps waiting for an Ajax callback...)
  4792. * oTable.fnClearTable();
  4793. * } );
  4794. */
  4795. this.fnClearTable = function( bRedraw )
  4796. {
  4797. var api = this.api( true ).clear();
  4798. if ( bRedraw === undefined || bRedraw ) {
  4799. api.draw();
  4800. }
  4801. };
  4802. /**
  4803. * The exact opposite of 'opening' a row, this function will close any rows which
  4804. * are currently 'open'.
  4805. * @param {node} nTr the table row to 'close'
  4806. * @returns {int} 0 on success, or 1 if failed (can't find the row)
  4807. * @dtopt API
  4808. * @deprecated Since v1.10
  4809. *
  4810. * @example
  4811. * $(document).ready(function() {
  4812. * var oTable;
  4813. *
  4814. * // 'open' an information row when a row is clicked on
  4815. * $('#example tbody tr').click( function () {
  4816. * if ( oTable.fnIsOpen(this) ) {
  4817. * oTable.fnClose( this );
  4818. * } else {
  4819. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  4820. * }
  4821. * } );
  4822. *
  4823. * oTable = $('#example').dataTable();
  4824. * } );
  4825. */
  4826. this.fnClose = function( nTr )
  4827. {
  4828. this.api( true ).row( nTr ).child.hide();
  4829. };
  4830. /**
  4831. * Remove a row for the table
  4832. * @param {mixed} target The index of the row from aoData to be deleted, or
  4833. * the TR element you want to delete
  4834. * @param {function|null} [callBack] Callback function
  4835. * @param {bool} [redraw=true] Redraw the table or not
  4836. * @returns {array} The row that was deleted
  4837. * @dtopt API
  4838. * @deprecated Since v1.10
  4839. *
  4840. * @example
  4841. * $(document).ready(function() {
  4842. * var oTable = $('#example').dataTable();
  4843. *
  4844. * // Immediately remove the first row
  4845. * oTable.fnDeleteRow( 0 );
  4846. * } );
  4847. */
  4848. this.fnDeleteRow = function( target, callback, redraw )
  4849. {
  4850. var api = this.api( true );
  4851. var rows = api.rows( target );
  4852. var settings = rows.settings()[0];
  4853. var data = settings.aoData[ rows[0][0] ];
  4854. rows.remove();
  4855. if ( callback ) {
  4856. callback.call( this, settings, data );
  4857. }
  4858. if ( redraw === undefined || redraw ) {
  4859. api.draw();
  4860. }
  4861. return data;
  4862. };
  4863. /**
  4864. * Restore the table to it's original state in the DOM by removing all of DataTables
  4865. * enhancements, alterations to the DOM structure of the table and event listeners.
  4866. * @param {boolean} [remove=false] Completely remove the table from the DOM
  4867. * @dtopt API
  4868. * @deprecated Since v1.10
  4869. *
  4870. * @example
  4871. * $(document).ready(function() {
  4872. * // This example is fairly pointless in reality, but shows how fnDestroy can be used
  4873. * var oTable = $('#example').dataTable();
  4874. * oTable.fnDestroy();
  4875. * } );
  4876. */
  4877. this.fnDestroy = function ( remove )
  4878. {
  4879. this.api( true ).destroy( remove );
  4880. };
  4881. /**
  4882. * Redraw the table
  4883. * @param {bool} [complete=true] Re-filter and resort (if enabled) the table before the draw.
  4884. * @dtopt API
  4885. * @deprecated Since v1.10
  4886. *
  4887. * @example
  4888. * $(document).ready(function() {
  4889. * var oTable = $('#example').dataTable();
  4890. *
  4891. * // Re-draw the table - you wouldn't want to do it here, but it's an example :-)
  4892. * oTable.fnDraw();
  4893. * } );
  4894. */
  4895. this.fnDraw = function( complete )
  4896. {
  4897. // Note that this isn't an exact match to the old call to _fnDraw - it takes
  4898. // into account the new data, but can hold position.
  4899. this.api( true ).draw( complete );
  4900. };
  4901. /**
  4902. * Filter the input based on data
  4903. * @param {string} sInput String to filter the table on
  4904. * @param {int|null} [iColumn] Column to limit filtering to
  4905. * @param {bool} [bRegex=false] Treat as regular expression or not
  4906. * @param {bool} [bSmart=true] Perform smart filtering or not
  4907. * @param {bool} [bShowGlobal=true] Show the input global filter in it's input box(es)
  4908. * @param {bool} [bCaseInsensitive=true] Do case-insensitive matching (true) or not (false)
  4909. * @dtopt API
  4910. * @deprecated Since v1.10
  4911. *
  4912. * @example
  4913. * $(document).ready(function() {
  4914. * var oTable = $('#example').dataTable();
  4915. *
  4916. * // Sometime later - filter...
  4917. * oTable.fnFilter( 'test string' );
  4918. * } );
  4919. */
  4920. this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal, bCaseInsensitive )
  4921. {
  4922. var api = this.api( true );
  4923. if ( iColumn === null || iColumn === undefined ) {
  4924. api.search( sInput, bRegex, bSmart, bCaseInsensitive );
  4925. }
  4926. else {
  4927. api.column( iColumn ).search( sInput, bRegex, bSmart, bCaseInsensitive );
  4928. }
  4929. api.draw();
  4930. };
  4931. /**
  4932. * Get the data for the whole table, an individual row or an individual cell based on the
  4933. * provided parameters.
  4934. * @param {int|node} [src] A TR row node, TD/TH cell node or an integer. If given as
  4935. * a TR node then the data source for the whole row will be returned. If given as a
  4936. * TD/TH cell node then iCol will be automatically calculated and the data for the
  4937. * cell returned. If given as an integer, then this is treated as the aoData internal
  4938. * data index for the row (see fnGetPosition) and the data for that row used.
  4939. * @param {int} [col] Optional column index that you want the data of.
  4940. * @returns {array|object|string} If mRow is undefined, then the data for all rows is
  4941. * returned. If mRow is defined, just data for that row, and is iCol is
  4942. * defined, only data for the designated cell is returned.
  4943. * @dtopt API
  4944. * @deprecated Since v1.10
  4945. *
  4946. * @example
  4947. * // Row data
  4948. * $(document).ready(function() {
  4949. * oTable = $('#example').dataTable();
  4950. *
  4951. * oTable.$('tr').click( function () {
  4952. * var data = oTable.fnGetData( this );
  4953. * // ... do something with the array / object of data for the row
  4954. * } );
  4955. * } );
  4956. *
  4957. * @example
  4958. * // Individual cell data
  4959. * $(document).ready(function() {
  4960. * oTable = $('#example').dataTable();
  4961. *
  4962. * oTable.$('td').click( function () {
  4963. * var sData = oTable.fnGetData( this );
  4964. * alert( 'The cell clicked on had the value of '+sData );
  4965. * } );
  4966. * } );
  4967. */
  4968. this.fnGetData = function( src, col )
  4969. {
  4970. var api = this.api( true );
  4971. if ( src !== undefined ) {
  4972. var type = src.nodeName ? src.nodeName.toLowerCase() : '';
  4973. return col !== undefined || type == 'td' || type == 'th' ?
  4974. api.cell( src, col ).data() :
  4975. api.row( src ).data() || null;
  4976. }
  4977. return api.data().toArray();
  4978. };
  4979. /**
  4980. * Get an array of the TR nodes that are used in the table's body. Note that you will
  4981. * typically want to use the '$' API method in preference to this as it is more
  4982. * flexible.
  4983. * @param {int} [iRow] Optional row index for the TR element you want
  4984. * @returns {array|node} If iRow is undefined, returns an array of all TR elements
  4985. * in the table's body, or iRow is defined, just the TR element requested.
  4986. * @dtopt API
  4987. * @deprecated Since v1.10
  4988. *
  4989. * @example
  4990. * $(document).ready(function() {
  4991. * var oTable = $('#example').dataTable();
  4992. *
  4993. * // Get the nodes from the table
  4994. * var nNodes = oTable.fnGetNodes( );
  4995. * } );
  4996. */
  4997. this.fnGetNodes = function( iRow )
  4998. {
  4999. var api = this.api( true );
  5000. return iRow !== undefined ?
  5001. api.row( iRow ).node() :
  5002. api.rows().nodes().flatten().toArray();
  5003. };
  5004. /**
  5005. * Get the array indexes of a particular cell from it's DOM element
  5006. * and column index including hidden columns
  5007. * @param {node} node this can either be a TR, TD or TH in the table's body
  5008. * @returns {int} If nNode is given as a TR, then a single index is returned, or
  5009. * if given as a cell, an array of [row index, column index (visible),
  5010. * column index (all)] is given.
  5011. * @dtopt API
  5012. * @deprecated Since v1.10
  5013. *
  5014. * @example
  5015. * $(document).ready(function() {
  5016. * $('#example tbody td').click( function () {
  5017. * // Get the position of the current data from the node
  5018. * var aPos = oTable.fnGetPosition( this );
  5019. *
  5020. * // Get the data array for this row
  5021. * var aData = oTable.fnGetData( aPos[0] );
  5022. *
  5023. * // Update the data array and return the value
  5024. * aData[ aPos[1] ] = 'clicked';
  5025. * this.innerHTML = 'clicked';
  5026. * } );
  5027. *
  5028. * // Init DataTables
  5029. * oTable = $('#example').dataTable();
  5030. * } );
  5031. */
  5032. this.fnGetPosition = function( node )
  5033. {
  5034. var api = this.api( true );
  5035. var nodeName = node.nodeName.toUpperCase();
  5036. if ( nodeName == 'TR' ) {
  5037. return api.row( node ).index();
  5038. }
  5039. else if ( nodeName == 'TD' || nodeName == 'TH' ) {
  5040. var cell = api.cell( node ).index();
  5041. return [
  5042. cell.row,
  5043. cell.columnVisible,
  5044. cell.column
  5045. ];
  5046. }
  5047. return null;
  5048. };
  5049. /**
  5050. * Check to see if a row is 'open' or not.
  5051. * @param {node} nTr the table row to check
  5052. * @returns {boolean} true if the row is currently open, false otherwise
  5053. * @dtopt API
  5054. * @deprecated Since v1.10
  5055. *
  5056. * @example
  5057. * $(document).ready(function() {
  5058. * var oTable;
  5059. *
  5060. * // 'open' an information row when a row is clicked on
  5061. * $('#example tbody tr').click( function () {
  5062. * if ( oTable.fnIsOpen(this) ) {
  5063. * oTable.fnClose( this );
  5064. * } else {
  5065. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  5066. * }
  5067. * } );
  5068. *
  5069. * oTable = $('#example').dataTable();
  5070. * } );
  5071. */
  5072. this.fnIsOpen = function( nTr )
  5073. {
  5074. return this.api( true ).row( nTr ).child.isShown();
  5075. };
  5076. /**
  5077. * This function will place a new row directly after a row which is currently
  5078. * on display on the page, with the HTML contents that is passed into the
  5079. * function. This can be used, for example, to ask for confirmation that a
  5080. * particular record should be deleted.
  5081. * @param {node} nTr The table row to 'open'
  5082. * @param {string|node|jQuery} mHtml The HTML to put into the row
  5083. * @param {string} sClass Class to give the new TD cell
  5084. * @returns {node} The row opened. Note that if the table row passed in as the
  5085. * first parameter, is not found in the table, this method will silently
  5086. * return.
  5087. * @dtopt API
  5088. * @deprecated Since v1.10
  5089. *
  5090. * @example
  5091. * $(document).ready(function() {
  5092. * var oTable;
  5093. *
  5094. * // 'open' an information row when a row is clicked on
  5095. * $('#example tbody tr').click( function () {
  5096. * if ( oTable.fnIsOpen(this) ) {
  5097. * oTable.fnClose( this );
  5098. * } else {
  5099. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  5100. * }
  5101. * } );
  5102. *
  5103. * oTable = $('#example').dataTable();
  5104. * } );
  5105. */
  5106. this.fnOpen = function( nTr, mHtml, sClass )
  5107. {
  5108. return this.api( true )
  5109. .row( nTr )
  5110. .child( mHtml, sClass )
  5111. .show()
  5112. .child()[0];
  5113. };
  5114. /**
  5115. * Change the pagination - provides the internal logic for pagination in a simple API
  5116. * function. With this function you can have a DataTables table go to the next,
  5117. * previous, first or last pages.
  5118. * @param {string|int} mAction Paging action to take: "first", "previous", "next" or "last"
  5119. * or page number to jump to (integer), note that page 0 is the first page.
  5120. * @param {bool} [bRedraw=true] Redraw the table or not
  5121. * @dtopt API
  5122. * @deprecated Since v1.10
  5123. *
  5124. * @example
  5125. * $(document).ready(function() {
  5126. * var oTable = $('#example').dataTable();
  5127. * oTable.fnPageChange( 'next' );
  5128. * } );
  5129. */
  5130. this.fnPageChange = function ( mAction, bRedraw )
  5131. {
  5132. var api = this.api( true ).page( mAction );
  5133. if ( bRedraw === undefined || bRedraw ) {
  5134. api.draw(false);
  5135. }
  5136. };
  5137. /**
  5138. * Show a particular column
  5139. * @param {int} iCol The column whose display should be changed
  5140. * @param {bool} bShow Show (true) or hide (false) the column
  5141. * @param {bool} [bRedraw=true] Redraw the table or not
  5142. * @dtopt API
  5143. * @deprecated Since v1.10
  5144. *
  5145. * @example
  5146. * $(document).ready(function() {
  5147. * var oTable = $('#example').dataTable();
  5148. *
  5149. * // Hide the second column after initialisation
  5150. * oTable.fnSetColumnVis( 1, false );
  5151. * } );
  5152. */
  5153. this.fnSetColumnVis = function ( iCol, bShow, bRedraw )
  5154. {
  5155. var api = this.api( true ).column( iCol ).visible( bShow );
  5156. if ( bRedraw === undefined || bRedraw ) {
  5157. api.columns.adjust().draw();
  5158. }
  5159. };
  5160. /**
  5161. * Get the settings for a particular table for external manipulation
  5162. * @returns {object} DataTables settings object. See
  5163. * {@link DataTable.models.oSettings}
  5164. * @dtopt API
  5165. * @deprecated Since v1.10
  5166. *
  5167. * @example
  5168. * $(document).ready(function() {
  5169. * var oTable = $('#example').dataTable();
  5170. * var oSettings = oTable.fnSettings();
  5171. *
  5172. * // Show an example parameter from the settings
  5173. * alert( oSettings._iDisplayStart );
  5174. * } );
  5175. */
  5176. this.fnSettings = function()
  5177. {
  5178. return _fnSettingsFromNode( this[_ext.iApiIndex] );
  5179. };
  5180. /**
  5181. * Sort the table by a particular column
  5182. * @param {int} iCol the data index to sort on. Note that this will not match the
  5183. * 'display index' if you have hidden data entries
  5184. * @dtopt API
  5185. * @deprecated Since v1.10
  5186. *
  5187. * @example
  5188. * $(document).ready(function() {
  5189. * var oTable = $('#example').dataTable();
  5190. *
  5191. * // Sort immediately with columns 0 and 1
  5192. * oTable.fnSort( [ [0,'asc'], [1,'asc'] ] );
  5193. * } );
  5194. */
  5195. this.fnSort = function( aaSort )
  5196. {
  5197. this.api( true ).order( aaSort ).draw();
  5198. };
  5199. /**
  5200. * Attach a sort listener to an element for a given column
  5201. * @param {node} nNode the element to attach the sort listener to
  5202. * @param {int} iColumn the column that a click on this node will sort on
  5203. * @param {function} [fnCallback] callback function when sort is run
  5204. * @dtopt API
  5205. * @deprecated Since v1.10
  5206. *
  5207. * @example
  5208. * $(document).ready(function() {
  5209. * var oTable = $('#example').dataTable();
  5210. *
  5211. * // Sort on column 1, when 'sorter' is clicked on
  5212. * oTable.fnSortListener( document.getElementById('sorter'), 1 );
  5213. * } );
  5214. */
  5215. this.fnSortListener = function( nNode, iColumn, fnCallback )
  5216. {
  5217. this.api( true ).order.listener( nNode, iColumn, fnCallback );
  5218. };
  5219. /**
  5220. * Update a table cell or row - this method will accept either a single value to
  5221. * update the cell with, an array of values with one element for each column or
  5222. * an object in the same format as the original data source. The function is
  5223. * self-referencing in order to make the multi column updates easier.
  5224. * @param {object|array|string} mData Data to update the cell/row with
  5225. * @param {node|int} mRow TR element you want to update or the aoData index
  5226. * @param {int} [iColumn] The column to update, give as null or undefined to
  5227. * update a whole row.
  5228. * @param {bool} [bRedraw=true] Redraw the table or not
  5229. * @param {bool} [bAction=true] Perform pre-draw actions or not
  5230. * @returns {int} 0 on success, 1 on error
  5231. * @dtopt API
  5232. * @deprecated Since v1.10
  5233. *
  5234. * @example
  5235. * $(document).ready(function() {
  5236. * var oTable = $('#example').dataTable();
  5237. * oTable.fnUpdate( 'Example update', 0, 0 ); // Single cell
  5238. * oTable.fnUpdate( ['a', 'b', 'c', 'd', 'e'], $('tbody tr')[0] ); // Row
  5239. * } );
  5240. */
  5241. this.fnUpdate = function( mData, mRow, iColumn, bRedraw, bAction )
  5242. {
  5243. var api = this.api( true );
  5244. if ( iColumn === undefined || iColumn === null ) {
  5245. api.row( mRow ).data( mData );
  5246. }
  5247. else {
  5248. api.cell( mRow, iColumn ).data( mData );
  5249. }
  5250. if ( bAction === undefined || bAction ) {
  5251. api.columns.adjust();
  5252. }
  5253. if ( bRedraw === undefined || bRedraw ) {
  5254. api.draw();
  5255. }
  5256. return 0;
  5257. };
  5258. /**
  5259. * Provide a common method for plug-ins to check the version of DataTables being used, in order
  5260. * to ensure compatibility.
  5261. * @param {string} sVersion Version string to check for, in the format "X.Y.Z". Note that the
  5262. * formats "X" and "X.Y" are also acceptable.
  5263. * @returns {boolean} true if this version of DataTables is greater or equal to the required
  5264. * version, or false if this version of DataTales is not suitable
  5265. * @method
  5266. * @dtopt API
  5267. * @deprecated Since v1.10
  5268. *
  5269. * @example
  5270. * $(document).ready(function() {
  5271. * var oTable = $('#example').dataTable();
  5272. * alert( oTable.fnVersionCheck( '1.9.0' ) );
  5273. * } );
  5274. */
  5275. this.fnVersionCheck = _ext.fnVersionCheck;
  5276. var _that = this;
  5277. var emptyInit = options === undefined;
  5278. var len = this.length;
  5279. if ( emptyInit ) {
  5280. options = {};
  5281. }
  5282. this.oApi = this.internal = _ext.internal;
  5283. // Extend with old style plug-in API methods
  5284. for ( var fn in DataTable.ext.internal ) {
  5285. if ( fn ) {
  5286. this[fn] = _fnExternApiFunc(fn);
  5287. }
  5288. }
  5289. this.each(function() {
  5290. // For each initialisation we want to give it a clean initialisation
  5291. // object that can be bashed around
  5292. var o = {};
  5293. var oInit = len > 1 ? // optimisation for single table case
  5294. _fnExtend( o, options, true ) :
  5295. options;
  5296. /*global oInit,_that,emptyInit*/
  5297. var i=0, iLen, j, jLen, k, kLen;
  5298. var sId = this.getAttribute( 'id' );
  5299. var bInitHandedOff = false;
  5300. var defaults = DataTable.defaults;
  5301. var $this = $(this);
  5302. /* Sanity check */
  5303. if ( this.nodeName.toLowerCase() != 'table' )
  5304. {
  5305. _fnLog( null, 0, 'Non-table node initialisation ('+this.nodeName+')', 2 );
  5306. return;
  5307. }
  5308. /* Backwards compatibility for the defaults */
  5309. _fnCompatOpts( defaults );
  5310. _fnCompatCols( defaults.column );
  5311. /* Convert the camel-case defaults to Hungarian */
  5312. _fnCamelToHungarian( defaults, defaults, true );
  5313. _fnCamelToHungarian( defaults.column, defaults.column, true );
  5314. /* Setting up the initialisation object */
  5315. _fnCamelToHungarian( defaults, $.extend( oInit, $this.data() ) );
  5316. /* Check to see if we are re-initialising a table */
  5317. var allSettings = DataTable.settings;
  5318. for ( i=0, iLen=allSettings.length ; i<iLen ; i++ )
  5319. {
  5320. var s = allSettings[i];
  5321. /* Base check on table node */
  5322. if ( s.nTable == this || s.nTHead.parentNode == this || (s.nTFoot && s.nTFoot.parentNode == this) )
  5323. {
  5324. var bRetrieve = oInit.bRetrieve !== undefined ? oInit.bRetrieve : defaults.bRetrieve;
  5325. var bDestroy = oInit.bDestroy !== undefined ? oInit.bDestroy : defaults.bDestroy;
  5326. if ( emptyInit || bRetrieve )
  5327. {
  5328. return s.oInstance;
  5329. }
  5330. else if ( bDestroy )
  5331. {
  5332. s.oInstance.fnDestroy();
  5333. break;
  5334. }
  5335. else
  5336. {
  5337. _fnLog( s, 0, 'Cannot reinitialise DataTable', 3 );
  5338. return;
  5339. }
  5340. }
  5341. /* If the element we are initialising has the same ID as a table which was previously
  5342. * initialised, but the table nodes don't match (from before) then we destroy the old
  5343. * instance by simply deleting it. This is under the assumption that the table has been
  5344. * destroyed by other methods. Anyone using non-id selectors will need to do this manually
  5345. */
  5346. if ( s.sTableId == this.id )
  5347. {
  5348. allSettings.splice( i, 1 );
  5349. break;
  5350. }
  5351. }
  5352. /* Ensure the table has an ID - required for accessibility */
  5353. if ( sId === null || sId === "" )
  5354. {
  5355. sId = "DataTables_Table_"+(DataTable.ext._unique++);
  5356. this.id = sId;
  5357. }
  5358. /* Create the settings object for this table and set some of the default parameters */
  5359. var oSettings = $.extend( true, {}, DataTable.models.oSettings, {
  5360. "sDestroyWidth": $this[0].style.width,
  5361. "sInstance": sId,
  5362. "sTableId": sId
  5363. } );
  5364. oSettings.nTable = this;
  5365. oSettings.oApi = _that.internal;
  5366. oSettings.oInit = oInit;
  5367. allSettings.push( oSettings );
  5368. // Need to add the instance after the instance after the settings object has been added
  5369. // to the settings array, so we can self reference the table instance if more than one
  5370. oSettings.oInstance = (_that.length===1) ? _that : $this.dataTable();
  5371. // Backwards compatibility, before we apply all the defaults
  5372. _fnCompatOpts( oInit );
  5373. if ( oInit.oLanguage )
  5374. {
  5375. _fnLanguageCompat( oInit.oLanguage );
  5376. }
  5377. // If the length menu is given, but the init display length is not, use the length menu
  5378. if ( oInit.aLengthMenu && ! oInit.iDisplayLength )
  5379. {
  5380. oInit.iDisplayLength = $.isArray( oInit.aLengthMenu[0] ) ?
  5381. oInit.aLengthMenu[0][0] : oInit.aLengthMenu[0];
  5382. }
  5383. // Apply the defaults and init options to make a single init object will all
  5384. // options defined from defaults and instance options.
  5385. oInit = _fnExtend( $.extend( true, {}, defaults ), oInit );
  5386. // Map the initialisation options onto the settings object
  5387. _fnMap( oSettings.oFeatures, oInit, [
  5388. "bPaginate",
  5389. "bLengthChange",
  5390. "bFilter",
  5391. "bSort",
  5392. "bSortMulti",
  5393. "bInfo",
  5394. "bProcessing",
  5395. "bAutoWidth",
  5396. "bSortClasses",
  5397. "bServerSide",
  5398. "bDeferRender"
  5399. ] );
  5400. _fnMap( oSettings, oInit, [
  5401. "asStripeClasses",
  5402. "ajax",
  5403. "fnServerData",
  5404. "fnFormatNumber",
  5405. "sServerMethod",
  5406. "aaSorting",
  5407. "aaSortingFixed",
  5408. "aLengthMenu",
  5409. "sPaginationType",
  5410. "sAjaxSource",
  5411. "sAjaxDataProp",
  5412. "iStateDuration",
  5413. "sDom",
  5414. "bSortCellsTop",
  5415. "iTabIndex",
  5416. "fnStateLoadCallback",
  5417. "fnStateSaveCallback",
  5418. "renderer",
  5419. "searchDelay",
  5420. "rowId",
  5421. [ "iCookieDuration", "iStateDuration" ], // backwards compat
  5422. [ "oSearch", "oPreviousSearch" ],
  5423. [ "aoSearchCols", "aoPreSearchCols" ],
  5424. [ "iDisplayLength", "_iDisplayLength" ],
  5425. [ "bJQueryUI", "bJUI" ]
  5426. ] );
  5427. _fnMap( oSettings.oScroll, oInit, [
  5428. [ "sScrollX", "sX" ],
  5429. [ "sScrollXInner", "sXInner" ],
  5430. [ "sScrollY", "sY" ],
  5431. [ "bScrollCollapse", "bCollapse" ]
  5432. ] );
  5433. _fnMap( oSettings.oLanguage, oInit, "fnInfoCallback" );
  5434. /* Callback functions which are array driven */
  5435. _fnCallbackReg( oSettings, 'aoDrawCallback', oInit.fnDrawCallback, 'user' );
  5436. _fnCallbackReg( oSettings, 'aoServerParams', oInit.fnServerParams, 'user' );
  5437. _fnCallbackReg( oSettings, 'aoStateSaveParams', oInit.fnStateSaveParams, 'user' );
  5438. _fnCallbackReg( oSettings, 'aoStateLoadParams', oInit.fnStateLoadParams, 'user' );
  5439. _fnCallbackReg( oSettings, 'aoStateLoaded', oInit.fnStateLoaded, 'user' );
  5440. _fnCallbackReg( oSettings, 'aoRowCallback', oInit.fnRowCallback, 'user' );
  5441. _fnCallbackReg( oSettings, 'aoRowCreatedCallback', oInit.fnCreatedRow, 'user' );
  5442. _fnCallbackReg( oSettings, 'aoHeaderCallback', oInit.fnHeaderCallback, 'user' );
  5443. _fnCallbackReg( oSettings, 'aoFooterCallback', oInit.fnFooterCallback, 'user' );
  5444. _fnCallbackReg( oSettings, 'aoInitComplete', oInit.fnInitComplete, 'user' );
  5445. _fnCallbackReg( oSettings, 'aoPreDrawCallback', oInit.fnPreDrawCallback, 'user' );
  5446. oSettings.rowIdFn = _fnGetObjectDataFn( oInit.rowId );
  5447. /* Browser support detection */
  5448. _fnBrowserDetect( oSettings );
  5449. var oClasses = oSettings.oClasses;
  5450. // @todo Remove in 1.11
  5451. if ( oInit.bJQueryUI )
  5452. {
  5453. /* Use the JUI classes object for display. You could clone the oStdClasses object if
  5454. * you want to have multiple tables with multiple independent classes
  5455. */
  5456. $.extend( oClasses, DataTable.ext.oJUIClasses, oInit.oClasses );
  5457. if ( oInit.sDom === defaults.sDom && defaults.sDom === "lfrtip" )
  5458. {
  5459. /* Set the DOM to use a layout suitable for jQuery UI's theming */
  5460. oSettings.sDom = '<"H"lfr>t<"F"ip>';
  5461. }
  5462. if ( ! oSettings.renderer ) {
  5463. oSettings.renderer = 'jqueryui';
  5464. }
  5465. else if ( $.isPlainObject( oSettings.renderer ) && ! oSettings.renderer.header ) {
  5466. oSettings.renderer.header = 'jqueryui';
  5467. }
  5468. }
  5469. else
  5470. {
  5471. $.extend( oClasses, DataTable.ext.classes, oInit.oClasses );
  5472. }
  5473. $this.addClass( oClasses.sTable );
  5474. if ( oSettings.iInitDisplayStart === undefined )
  5475. {
  5476. /* Display start point, taking into account the save saving */
  5477. oSettings.iInitDisplayStart = oInit.iDisplayStart;
  5478. oSettings._iDisplayStart = oInit.iDisplayStart;
  5479. }
  5480. if ( oInit.iDeferLoading !== null )
  5481. {
  5482. oSettings.bDeferLoading = true;
  5483. var tmp = $.isArray( oInit.iDeferLoading );
  5484. oSettings._iRecordsDisplay = tmp ? oInit.iDeferLoading[0] : oInit.iDeferLoading;
  5485. oSettings._iRecordsTotal = tmp ? oInit.iDeferLoading[1] : oInit.iDeferLoading;
  5486. }
  5487. /* Language definitions */
  5488. var oLanguage = oSettings.oLanguage;
  5489. $.extend( true, oLanguage, oInit.oLanguage );
  5490. if ( oLanguage.sUrl !== "" )
  5491. {
  5492. /* Get the language definitions from a file - because this Ajax call makes the language
  5493. * get async to the remainder of this function we use bInitHandedOff to indicate that
  5494. * _fnInitialise will be fired by the returned Ajax handler, rather than the constructor
  5495. */
  5496. $.ajax( {
  5497. dataType: 'json',
  5498. url: oLanguage.sUrl,
  5499. success: function ( json ) {
  5500. _fnLanguageCompat( json );
  5501. _fnCamelToHungarian( defaults.oLanguage, json );
  5502. $.extend( true, oLanguage, json );
  5503. _fnInitialise( oSettings );
  5504. },
  5505. error: function () {
  5506. // Error occurred loading language file, continue on as best we can
  5507. _fnInitialise( oSettings );
  5508. }
  5509. } );
  5510. bInitHandedOff = true;
  5511. }
  5512. /*
  5513. * Stripes
  5514. */
  5515. if ( oInit.asStripeClasses === null )
  5516. {
  5517. oSettings.asStripeClasses =[
  5518. oClasses.sStripeOdd,
  5519. oClasses.sStripeEven
  5520. ];
  5521. }
  5522. /* Remove row stripe classes if they are already on the table row */
  5523. var stripeClasses = oSettings.asStripeClasses;
  5524. var rowOne = $this.children('tbody').find('tr').eq(0);
  5525. if ( $.inArray( true, $.map( stripeClasses, function(el, i) {
  5526. return rowOne.hasClass(el);
  5527. } ) ) !== -1 ) {
  5528. $('tbody tr', this).removeClass( stripeClasses.join(' ') );
  5529. oSettings.asDestroyStripes = stripeClasses.slice();
  5530. }
  5531. /*
  5532. * Columns
  5533. * See if we should load columns automatically or use defined ones
  5534. */
  5535. var anThs = [];
  5536. var aoColumnsInit;
  5537. var nThead = this.getElementsByTagName('thead');
  5538. if ( nThead.length !== 0 )
  5539. {
  5540. _fnDetectHeader( oSettings.aoHeader, nThead[0] );
  5541. anThs = _fnGetUniqueThs( oSettings );
  5542. }
  5543. /* If not given a column array, generate one with nulls */
  5544. if ( oInit.aoColumns === null )
  5545. {
  5546. aoColumnsInit = [];
  5547. for ( i=0, iLen=anThs.length ; i<iLen ; i++ )
  5548. {
  5549. aoColumnsInit.push( null );
  5550. }
  5551. }
  5552. else
  5553. {
  5554. aoColumnsInit = oInit.aoColumns;
  5555. }
  5556. /* Add the columns */
  5557. for ( i=0, iLen=aoColumnsInit.length ; i<iLen ; i++ )
  5558. {
  5559. _fnAddColumn( oSettings, anThs ? anThs[i] : null );
  5560. }
  5561. /* Apply the column definitions */
  5562. _fnApplyColumnDefs( oSettings, oInit.aoColumnDefs, aoColumnsInit, function (iCol, oDef) {
  5563. _fnColumnOptions( oSettings, iCol, oDef );
  5564. } );
  5565. /* HTML5 attribute detection - build an mData object automatically if the
  5566. * attributes are found
  5567. */
  5568. if ( rowOne.length ) {
  5569. var a = function ( cell, name ) {
  5570. return cell.getAttribute( 'data-'+name ) !== null ? name : null;
  5571. };
  5572. $( rowOne[0] ).children('th, td').each( function (i, cell) {
  5573. var col = oSettings.aoColumns[i];
  5574. if ( col.mData === i ) {
  5575. var sort = a( cell, 'sort' ) || a( cell, 'order' );
  5576. var filter = a( cell, 'filter' ) || a( cell, 'search' );
  5577. if ( sort !== null || filter !== null ) {
  5578. col.mData = {
  5579. _: i+'.display',
  5580. sort: sort !== null ? i+'.@data-'+sort : undefined,
  5581. type: sort !== null ? i+'.@data-'+sort : undefined,
  5582. filter: filter !== null ? i+'.@data-'+filter : undefined
  5583. };
  5584. _fnColumnOptions( oSettings, i );
  5585. }
  5586. }
  5587. } );
  5588. }
  5589. var features = oSettings.oFeatures;
  5590. /* Must be done after everything which can be overridden by the state saving! */
  5591. if ( oInit.bStateSave )
  5592. {
  5593. features.bStateSave = true;
  5594. _fnLoadState( oSettings, oInit );
  5595. _fnCallbackReg( oSettings, 'aoDrawCallback', _fnSaveState, 'state_save' );
  5596. }
  5597. /*
  5598. * Sorting
  5599. * @todo For modularisation (1.11) this needs to do into a sort start up handler
  5600. */
  5601. // If aaSorting is not defined, then we use the first indicator in asSorting
  5602. // in case that has been altered, so the default sort reflects that option
  5603. if ( oInit.aaSorting === undefined )
  5604. {
  5605. var sorting = oSettings.aaSorting;
  5606. for ( i=0, iLen=sorting.length ; i<iLen ; i++ )
  5607. {
  5608. sorting[i][1] = oSettings.aoColumns[ i ].asSorting[0];
  5609. }
  5610. }
  5611. /* Do a first pass on the sorting classes (allows any size changes to be taken into
  5612. * account, and also will apply sorting disabled classes if disabled
  5613. */
  5614. _fnSortingClasses( oSettings );
  5615. if ( features.bSort )
  5616. {
  5617. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  5618. if ( oSettings.bSorted ) {
  5619. var aSort = _fnSortFlatten( oSettings );
  5620. var sortedColumns = {};
  5621. $.each( aSort, function (i, val) {
  5622. sortedColumns[ val.src ] = val.dir;
  5623. } );
  5624. _fnCallbackFire( oSettings, null, 'order', [oSettings, aSort, sortedColumns] );
  5625. _fnSortAria( oSettings );
  5626. }
  5627. } );
  5628. }
  5629. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  5630. if ( oSettings.bSorted || _fnDataSource( oSettings ) === 'ssp' || features.bDeferRender ) {
  5631. _fnSortingClasses( oSettings );
  5632. }
  5633. }, 'sc' );
  5634. /*
  5635. * Final init
  5636. * Cache the header, body and footer as required, creating them if needed
  5637. */
  5638. // Work around for Webkit bug 83867 - store the caption-side before removing from doc
  5639. var captions = $this.children('caption').each( function () {
  5640. this._captionSide = $this.css('caption-side');
  5641. } );
  5642. var thead = $this.children('thead');
  5643. if ( thead.length === 0 )
  5644. {
  5645. thead = $('<thead/>').appendTo(this);
  5646. }
  5647. oSettings.nTHead = thead[0];
  5648. var tbody = $this.children('tbody');
  5649. if ( tbody.length === 0 )
  5650. {
  5651. tbody = $('<tbody/>').appendTo(this);
  5652. }
  5653. oSettings.nTBody = tbody[0];
  5654. var tfoot = $this.children('tfoot');
  5655. if ( tfoot.length === 0 && captions.length > 0 && (oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "") )
  5656. {
  5657. // If we are a scrolling table, and no footer has been given, then we need to create
  5658. // a tfoot element for the caption element to be appended to
  5659. tfoot = $('<tfoot/>').appendTo(this);
  5660. }
  5661. if ( tfoot.length === 0 || tfoot.children().length === 0 ) {
  5662. $this.addClass( oClasses.sNoFooter );
  5663. }
  5664. else if ( tfoot.length > 0 ) {
  5665. oSettings.nTFoot = tfoot[0];
  5666. _fnDetectHeader( oSettings.aoFooter, oSettings.nTFoot );
  5667. }
  5668. /* Check if there is data passing into the constructor */
  5669. if ( oInit.aaData )
  5670. {
  5671. for ( i=0 ; i<oInit.aaData.length ; i++ )
  5672. {
  5673. _fnAddData( oSettings, oInit.aaData[ i ] );
  5674. }
  5675. }
  5676. else if ( oSettings.bDeferLoading || _fnDataSource( oSettings ) == 'dom' )
  5677. {
  5678. /* Grab the data from the page - only do this when deferred loading or no Ajax
  5679. * source since there is no point in reading the DOM data if we are then going
  5680. * to replace it with Ajax data
  5681. */
  5682. _fnAddTr( oSettings, $(oSettings.nTBody).children('tr') );
  5683. }
  5684. /* Copy the data index array */
  5685. oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
  5686. /* Initialisation complete - table can be drawn */
  5687. oSettings.bInitialised = true;
  5688. /* Check if we need to initialise the table (it might not have been handed off to the
  5689. * language processor)
  5690. */
  5691. if ( bInitHandedOff === false )
  5692. {
  5693. _fnInitialise( oSettings );
  5694. }
  5695. } );
  5696. _that = null;
  5697. return this;
  5698. };
  5699. /**
  5700. * Computed structure of the DataTables API, defined by the options passed to
  5701. * `DataTable.Api.register()` when building the API.
  5702. *
  5703. * The structure is built in order to speed creation and extension of the Api
  5704. * objects since the extensions are effectively pre-parsed.
  5705. *
  5706. * The array is an array of objects with the following structure, where this
  5707. * base array represents the Api prototype base:
  5708. *
  5709. * [
  5710. * {
  5711. * name: 'data' -- string - Property name
  5712. * val: function () {}, -- function - Api method (or undefined if just an object
  5713. * methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  5714. * propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  5715. * },
  5716. * {
  5717. * name: 'row'
  5718. * val: {},
  5719. * methodExt: [ ... ],
  5720. * propExt: [
  5721. * {
  5722. * name: 'data'
  5723. * val: function () {},
  5724. * methodExt: [ ... ],
  5725. * propExt: [ ... ]
  5726. * },
  5727. * ...
  5728. * ]
  5729. * }
  5730. * ]
  5731. *
  5732. * @type {Array}
  5733. * @ignore
  5734. */
  5735. var __apiStruct = [];
  5736. /**
  5737. * `Array.prototype` reference.
  5738. *
  5739. * @type object
  5740. * @ignore
  5741. */
  5742. var __arrayProto = Array.prototype;
  5743. /**
  5744. * Abstraction for `context` parameter of the `Api` constructor to allow it to
  5745. * take several different forms for ease of use.
  5746. *
  5747. * Each of the input parameter types will be converted to a DataTables settings
  5748. * object where possible.
  5749. *
  5750. * @param {string|node|jQuery|object} mixed DataTable identifier. Can be one
  5751. * of:
  5752. *
  5753. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5754. * with be found and used.
  5755. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5756. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5757. * * `object` - DataTables settings object
  5758. * * `DataTables.Api` - API instance
  5759. * @return {array|null} Matching DataTables settings objects. `null` or
  5760. * `undefined` is returned if no matching DataTable is found.
  5761. * @ignore
  5762. */
  5763. var _toSettings = function ( mixed )
  5764. {
  5765. var idx, jq;
  5766. var settings = DataTable.settings;
  5767. var tables = $.map( settings, function (el, i) {
  5768. return el.nTable;
  5769. } );
  5770. if ( ! mixed ) {
  5771. return [];
  5772. }
  5773. else if ( mixed.nTable && mixed.oApi ) {
  5774. // DataTables settings object
  5775. return [ mixed ];
  5776. }
  5777. else if ( mixed.nodeName && mixed.nodeName.toLowerCase() === 'table' ) {
  5778. // Table node
  5779. idx = $.inArray( mixed, tables );
  5780. return idx !== -1 ? [ settings[idx] ] : null;
  5781. }
  5782. else if ( mixed && typeof mixed.settings === 'function' ) {
  5783. return mixed.settings().toArray();
  5784. }
  5785. else if ( typeof mixed === 'string' ) {
  5786. // jQuery selector
  5787. jq = $(mixed);
  5788. }
  5789. else if ( mixed instanceof $ ) {
  5790. // jQuery object (also DataTables instance)
  5791. jq = mixed;
  5792. }
  5793. if ( jq ) {
  5794. return jq.map( function(i) {
  5795. idx = $.inArray( this, tables );
  5796. return idx !== -1 ? settings[idx] : null;
  5797. } ).toArray();
  5798. }
  5799. };
  5800. /**
  5801. * DataTables API class - used to control and interface with one or more
  5802. * DataTables enhanced tables.
  5803. *
  5804. * The API class is heavily based on jQuery, presenting a chainable interface
  5805. * that you can use to interact with tables. Each instance of the API class has
  5806. * a "context" - i.e. the tables that it will operate on. This could be a single
  5807. * table, all tables on a page or a sub-set thereof.
  5808. *
  5809. * Additionally the API is designed to allow you to easily work with the data in
  5810. * the tables, retrieving and manipulating it as required. This is done by
  5811. * presenting the API class as an array like interface. The contents of the
  5812. * array depend upon the actions requested by each method (for example
  5813. * `rows().nodes()` will return an array of nodes, while `rows().data()` will
  5814. * return an array of objects or arrays depending upon your table's
  5815. * configuration). The API object has a number of array like methods (`push`,
  5816. * `pop`, `reverse` etc) as well as additional helper methods (`each`, `pluck`,
  5817. * `unique` etc) to assist your working with the data held in a table.
  5818. *
  5819. * Most methods (those which return an Api instance) are chainable, which means
  5820. * the return from a method call also has all of the methods available that the
  5821. * top level object had. For example, these two calls are equivalent:
  5822. *
  5823. * // Not chained
  5824. * api.row.add( {...} );
  5825. * api.draw();
  5826. *
  5827. * // Chained
  5828. * api.row.add( {...} ).draw();
  5829. *
  5830. * @class DataTable.Api
  5831. * @param {array|object|string|jQuery} context DataTable identifier. This is
  5832. * used to define which DataTables enhanced tables this API will operate on.
  5833. * Can be one of:
  5834. *
  5835. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5836. * with be found and used.
  5837. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5838. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5839. * * `object` - DataTables settings object
  5840. * @param {array} [data] Data to initialise the Api instance with.
  5841. *
  5842. * @example
  5843. * // Direct initialisation during DataTables construction
  5844. * var api = $('#example').DataTable();
  5845. *
  5846. * @example
  5847. * // Initialisation using a DataTables jQuery object
  5848. * var api = $('#example').dataTable().api();
  5849. *
  5850. * @example
  5851. * // Initialisation as a constructor
  5852. * var api = new $.fn.DataTable.Api( 'table.dataTable' );
  5853. */
  5854. _Api = function ( context, data )
  5855. {
  5856. if ( ! (this instanceof _Api) ) {
  5857. return new _Api( context, data );
  5858. }
  5859. var settings = [];
  5860. var ctxSettings = function ( o ) {
  5861. var a = _toSettings( o );
  5862. if ( a ) {
  5863. settings = settings.concat( a );
  5864. }
  5865. };
  5866. if ( $.isArray( context ) ) {
  5867. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  5868. ctxSettings( context[i] );
  5869. }
  5870. }
  5871. else {
  5872. ctxSettings( context );
  5873. }
  5874. // Remove duplicates
  5875. this.context = _unique( settings );
  5876. // Initial data
  5877. if ( data ) {
  5878. $.merge( this, data );
  5879. }
  5880. // selector
  5881. this.selector = {
  5882. rows: null,
  5883. cols: null,
  5884. opts: null
  5885. };
  5886. _Api.extend( this, this, __apiStruct );
  5887. };
  5888. DataTable.Api = _Api;
  5889. // Don't destroy the existing prototype, just extend it. Required for jQuery 2's
  5890. // isPlainObject.
  5891. $.extend( _Api.prototype, {
  5892. any: function ()
  5893. {
  5894. return this.count() !== 0;
  5895. },
  5896. concat: __arrayProto.concat,
  5897. context: [], // array of table settings objects
  5898. count: function ()
  5899. {
  5900. return this.flatten().length;
  5901. },
  5902. each: function ( fn )
  5903. {
  5904. for ( var i=0, ien=this.length ; i<ien; i++ ) {
  5905. fn.call( this, this[i], i, this );
  5906. }
  5907. return this;
  5908. },
  5909. eq: function ( idx )
  5910. {
  5911. var ctx = this.context;
  5912. return ctx.length > idx ?
  5913. new _Api( ctx[idx], this[idx] ) :
  5914. null;
  5915. },
  5916. filter: function ( fn )
  5917. {
  5918. var a = [];
  5919. if ( __arrayProto.filter ) {
  5920. a = __arrayProto.filter.call( this, fn, this );
  5921. }
  5922. else {
  5923. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  5924. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  5925. if ( fn.call( this, this[i], i, this ) ) {
  5926. a.push( this[i] );
  5927. }
  5928. }
  5929. }
  5930. return new _Api( this.context, a );
  5931. },
  5932. flatten: function ()
  5933. {
  5934. var a = [];
  5935. return new _Api( this.context, a.concat.apply( a, this.toArray() ) );
  5936. },
  5937. join: __arrayProto.join,
  5938. indexOf: __arrayProto.indexOf || function (obj, start)
  5939. {
  5940. for ( var i=(start || 0), ien=this.length ; i<ien ; i++ ) {
  5941. if ( this[i] === obj ) {
  5942. return i;
  5943. }
  5944. }
  5945. return -1;
  5946. },
  5947. iterator: function ( flatten, type, fn, alwaysNew ) {
  5948. var
  5949. a = [], ret,
  5950. i, ien, j, jen,
  5951. context = this.context,
  5952. rows, items, item,
  5953. selector = this.selector;
  5954. // Argument shifting
  5955. if ( typeof flatten === 'string' ) {
  5956. alwaysNew = fn;
  5957. fn = type;
  5958. type = flatten;
  5959. flatten = false;
  5960. }
  5961. for ( i=0, ien=context.length ; i<ien ; i++ ) {
  5962. var apiInst = new _Api( context[i] );
  5963. if ( type === 'table' ) {
  5964. ret = fn.call( apiInst, context[i], i );
  5965. if ( ret !== undefined ) {
  5966. a.push( ret );
  5967. }
  5968. }
  5969. else if ( type === 'columns' || type === 'rows' ) {
  5970. // this has same length as context - one entry for each table
  5971. ret = fn.call( apiInst, context[i], this[i], i );
  5972. if ( ret !== undefined ) {
  5973. a.push( ret );
  5974. }
  5975. }
  5976. else if ( type === 'column' || type === 'column-rows' || type === 'row' || type === 'cell' ) {
  5977. // columns and rows share the same structure.
  5978. // 'this' is an array of column indexes for each context
  5979. items = this[i];
  5980. if ( type === 'column-rows' ) {
  5981. rows = _selector_row_indexes( context[i], selector.opts );
  5982. }
  5983. for ( j=0, jen=items.length ; j<jen ; j++ ) {
  5984. item = items[j];
  5985. if ( type === 'cell' ) {
  5986. ret = fn.call( apiInst, context[i], item.row, item.column, i, j );
  5987. }
  5988. else {
  5989. ret = fn.call( apiInst, context[i], item, i, j, rows );
  5990. }
  5991. if ( ret !== undefined ) {
  5992. a.push( ret );
  5993. }
  5994. }
  5995. }
  5996. }
  5997. if ( a.length || alwaysNew ) {
  5998. var api = new _Api( context, flatten ? a.concat.apply( [], a ) : a );
  5999. var apiSelector = api.selector;
  6000. apiSelector.rows = selector.rows;
  6001. apiSelector.cols = selector.cols;
  6002. apiSelector.opts = selector.opts;
  6003. return api;
  6004. }
  6005. return this;
  6006. },
  6007. lastIndexOf: __arrayProto.lastIndexOf || function (obj, start)
  6008. {
  6009. // Bit cheeky...
  6010. return this.indexOf.apply( this.toArray.reverse(), arguments );
  6011. },
  6012. length: 0,
  6013. map: function ( fn )
  6014. {
  6015. var a = [];
  6016. if ( __arrayProto.map ) {
  6017. a = __arrayProto.map.call( this, fn, this );
  6018. }
  6019. else {
  6020. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  6021. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  6022. a.push( fn.call( this, this[i], i ) );
  6023. }
  6024. }
  6025. return new _Api( this.context, a );
  6026. },
  6027. pluck: function ( prop )
  6028. {
  6029. return this.map( function ( el ) {
  6030. return el[ prop ];
  6031. } );
  6032. },
  6033. pop: __arrayProto.pop,
  6034. push: __arrayProto.push,
  6035. // Does not return an API instance
  6036. reduce: __arrayProto.reduce || function ( fn, init )
  6037. {
  6038. return _fnReduce( this, fn, init, 0, this.length, 1 );
  6039. },
  6040. reduceRight: __arrayProto.reduceRight || function ( fn, init )
  6041. {
  6042. return _fnReduce( this, fn, init, this.length-1, -1, -1 );
  6043. },
  6044. reverse: __arrayProto.reverse,
  6045. // Object with rows, columns and opts
  6046. selector: null,
  6047. shift: __arrayProto.shift,
  6048. sort: __arrayProto.sort, // ? name - order?
  6049. splice: __arrayProto.splice,
  6050. toArray: function ()
  6051. {
  6052. return __arrayProto.slice.call( this );
  6053. },
  6054. to$: function ()
  6055. {
  6056. return $( this );
  6057. },
  6058. toJQuery: function ()
  6059. {
  6060. return $( this );
  6061. },
  6062. unique: function ()
  6063. {
  6064. return new _Api( this.context, _unique(this) );
  6065. },
  6066. unshift: __arrayProto.unshift
  6067. } );
  6068. _Api.extend = function ( scope, obj, ext )
  6069. {
  6070. // Only extend API instances and static properties of the API
  6071. if ( ! ext.length || ! obj || ( ! (obj instanceof _Api) && ! obj.__dt_wrapper ) ) {
  6072. return;
  6073. }
  6074. var
  6075. i, ien,
  6076. j, jen,
  6077. struct, inner,
  6078. methodScoping = function ( scope, fn, struc ) {
  6079. return function () {
  6080. var ret = fn.apply( scope, arguments );
  6081. // Method extension
  6082. _Api.extend( ret, ret, struc.methodExt );
  6083. return ret;
  6084. };
  6085. };
  6086. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  6087. struct = ext[i];
  6088. // Value
  6089. obj[ struct.name ] = typeof struct.val === 'function' ?
  6090. methodScoping( scope, struct.val, struct ) :
  6091. $.isPlainObject( struct.val ) ?
  6092. {} :
  6093. struct.val;
  6094. obj[ struct.name ].__dt_wrapper = true;
  6095. // Property extension
  6096. _Api.extend( scope, obj[ struct.name ], struct.propExt );
  6097. }
  6098. };
  6099. // @todo - Is there need for an augment function?
  6100. // _Api.augment = function ( inst, name )
  6101. // {
  6102. // // Find src object in the structure from the name
  6103. // var parts = name.split('.');
  6104. // _Api.extend( inst, obj );
  6105. // };
  6106. // [
  6107. // {
  6108. // name: 'data' -- string - Property name
  6109. // val: function () {}, -- function - Api method (or undefined if just an object
  6110. // methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  6111. // propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  6112. // },
  6113. // {
  6114. // name: 'row'
  6115. // val: {},
  6116. // methodExt: [ ... ],
  6117. // propExt: [
  6118. // {
  6119. // name: 'data'
  6120. // val: function () {},
  6121. // methodExt: [ ... ],
  6122. // propExt: [ ... ]
  6123. // },
  6124. // ...
  6125. // ]
  6126. // }
  6127. // ]
  6128. _Api.register = _api_register = function ( name, val )
  6129. {
  6130. if ( $.isArray( name ) ) {
  6131. for ( var j=0, jen=name.length ; j<jen ; j++ ) {
  6132. _Api.register( name[j], val );
  6133. }
  6134. return;
  6135. }
  6136. var
  6137. i, ien,
  6138. heir = name.split('.'),
  6139. struct = __apiStruct,
  6140. key, method;
  6141. var find = function ( src, name ) {
  6142. for ( var i=0, ien=src.length ; i<ien ; i++ ) {
  6143. if ( src[i].name === name ) {
  6144. return src[i];
  6145. }
  6146. }
  6147. return null;
  6148. };
  6149. for ( i=0, ien=heir.length ; i<ien ; i++ ) {
  6150. method = heir[i].indexOf('()') !== -1;
  6151. key = method ?
  6152. heir[i].replace('()', '') :
  6153. heir[i];
  6154. var src = find( struct, key );
  6155. if ( ! src ) {
  6156. src = {
  6157. name: key,
  6158. val: {},
  6159. methodExt: [],
  6160. propExt: []
  6161. };
  6162. struct.push( src );
  6163. }
  6164. if ( i === ien-1 ) {
  6165. src.val = val;
  6166. }
  6167. else {
  6168. struct = method ?
  6169. src.methodExt :
  6170. src.propExt;
  6171. }
  6172. }
  6173. };
  6174. _Api.registerPlural = _api_registerPlural = function ( pluralName, singularName, val ) {
  6175. _Api.register( pluralName, val );
  6176. _Api.register( singularName, function () {
  6177. var ret = val.apply( this, arguments );
  6178. if ( ret === this ) {
  6179. // Returned item is the API instance that was passed in, return it
  6180. return this;
  6181. }
  6182. else if ( ret instanceof _Api ) {
  6183. // New API instance returned, want the value from the first item
  6184. // in the returned array for the singular result.
  6185. return ret.length ?
  6186. $.isArray( ret[0] ) ?
  6187. new _Api( ret.context, ret[0] ) : // Array results are 'enhanced'
  6188. ret[0] :
  6189. undefined;
  6190. }
  6191. // Non-API return - just fire it back
  6192. return ret;
  6193. } );
  6194. };
  6195. /**
  6196. * Selector for HTML tables. Apply the given selector to the give array of
  6197. * DataTables settings objects.
  6198. *
  6199. * @param {string|integer} [selector] jQuery selector string or integer
  6200. * @param {array} Array of DataTables settings objects to be filtered
  6201. * @return {array}
  6202. * @ignore
  6203. */
  6204. var __table_selector = function ( selector, a )
  6205. {
  6206. // Integer is used to pick out a table by index
  6207. if ( typeof selector === 'number' ) {
  6208. return [ a[ selector ] ];
  6209. }
  6210. // Perform a jQuery selector on the table nodes
  6211. var nodes = $.map( a, function (el, i) {
  6212. return el.nTable;
  6213. } );
  6214. return $(nodes)
  6215. .filter( selector )
  6216. .map( function (i) {
  6217. // Need to translate back from the table node to the settings
  6218. var idx = $.inArray( this, nodes );
  6219. return a[ idx ];
  6220. } )
  6221. .toArray();
  6222. };
  6223. /**
  6224. * Context selector for the API's context (i.e. the tables the API instance
  6225. * refers to.
  6226. *
  6227. * @name DataTable.Api#tables
  6228. * @param {string|integer} [selector] Selector to pick which tables the iterator
  6229. * should operate on. If not given, all tables in the current context are
  6230. * used. This can be given as a jQuery selector (for example `':gt(0)'`) to
  6231. * select multiple tables or as an integer to select a single table.
  6232. * @returns {DataTable.Api} Returns a new API instance if a selector is given.
  6233. */
  6234. _api_register( 'tables()', function ( selector ) {
  6235. // A new instance is created if there was a selector specified
  6236. return selector ?
  6237. new _Api( __table_selector( selector, this.context ) ) :
  6238. this;
  6239. } );
  6240. _api_register( 'table()', function ( selector ) {
  6241. var tables = this.tables( selector );
  6242. var ctx = tables.context;
  6243. // Truncate to the first matched table
  6244. return ctx.length ?
  6245. new _Api( ctx[0] ) :
  6246. tables;
  6247. } );
  6248. _api_registerPlural( 'tables().nodes()', 'table().node()' , function () {
  6249. return this.iterator( 'table', function ( ctx ) {
  6250. return ctx.nTable;
  6251. }, 1 );
  6252. } );
  6253. _api_registerPlural( 'tables().body()', 'table().body()' , function () {
  6254. return this.iterator( 'table', function ( ctx ) {
  6255. return ctx.nTBody;
  6256. }, 1 );
  6257. } );
  6258. _api_registerPlural( 'tables().header()', 'table().header()' , function () {
  6259. return this.iterator( 'table', function ( ctx ) {
  6260. return ctx.nTHead;
  6261. }, 1 );
  6262. } );
  6263. _api_registerPlural( 'tables().footer()', 'table().footer()' , function () {
  6264. return this.iterator( 'table', function ( ctx ) {
  6265. return ctx.nTFoot;
  6266. }, 1 );
  6267. } );
  6268. _api_registerPlural( 'tables().containers()', 'table().container()' , function () {
  6269. return this.iterator( 'table', function ( ctx ) {
  6270. return ctx.nTableWrapper;
  6271. }, 1 );
  6272. } );
  6273. /**
  6274. * Redraw the tables in the current context.
  6275. */
  6276. _api_register( 'draw()', function ( paging ) {
  6277. return this.iterator( 'table', function ( settings ) {
  6278. if ( paging === 'page' ) {
  6279. _fnDraw( settings );
  6280. }
  6281. else {
  6282. if ( typeof paging === 'string' ) {
  6283. paging = paging === 'full-hold' ?
  6284. false :
  6285. true;
  6286. }
  6287. _fnReDraw( settings, paging===false );
  6288. }
  6289. } );
  6290. } );
  6291. /**
  6292. * Get the current page index.
  6293. *
  6294. * @return {integer} Current page index (zero based)
  6295. *//**
  6296. * Set the current page.
  6297. *
  6298. * Note that if you attempt to show a page which does not exist, DataTables will
  6299. * not throw an error, but rather reset the paging.
  6300. *
  6301. * @param {integer|string} action The paging action to take. This can be one of:
  6302. * * `integer` - The page index to jump to
  6303. * * `string` - An action to take:
  6304. * * `first` - Jump to first page.
  6305. * * `next` - Jump to the next page
  6306. * * `previous` - Jump to previous page
  6307. * * `last` - Jump to the last page.
  6308. * @returns {DataTables.Api} this
  6309. */
  6310. _api_register( 'page()', function ( action ) {
  6311. if ( action === undefined ) {
  6312. return this.page.info().page; // not an expensive call
  6313. }
  6314. // else, have an action to take on all tables
  6315. return this.iterator( 'table', function ( settings ) {
  6316. _fnPageChange( settings, action );
  6317. } );
  6318. } );
  6319. /**
  6320. * Paging information for the first table in the current context.
  6321. *
  6322. * If you require paging information for another table, use the `table()` method
  6323. * with a suitable selector.
  6324. *
  6325. * @return {object} Object with the following properties set:
  6326. * * `page` - Current page index (zero based - i.e. the first page is `0`)
  6327. * * `pages` - Total number of pages
  6328. * * `start` - Display index for the first record shown on the current page
  6329. * * `end` - Display index for the last record shown on the current page
  6330. * * `length` - Display length (number of records). Note that generally `start
  6331. * + length = end`, but this is not always true, for example if there are
  6332. * only 2 records to show on the final page, with a length of 10.
  6333. * * `recordsTotal` - Full data set length
  6334. * * `recordsDisplay` - Data set length once the current filtering criterion
  6335. * are applied.
  6336. */
  6337. _api_register( 'page.info()', function ( action ) {
  6338. if ( this.context.length === 0 ) {
  6339. return undefined;
  6340. }
  6341. var
  6342. settings = this.context[0],
  6343. start = settings._iDisplayStart,
  6344. len = settings.oFeatures.bPaginate ? settings._iDisplayLength : -1,
  6345. visRecords = settings.fnRecordsDisplay(),
  6346. all = len === -1;
  6347. return {
  6348. "page": all ? 0 : Math.floor( start / len ),
  6349. "pages": all ? 1 : Math.ceil( visRecords / len ),
  6350. "start": start,
  6351. "end": settings.fnDisplayEnd(),
  6352. "length": len,
  6353. "recordsTotal": settings.fnRecordsTotal(),
  6354. "recordsDisplay": visRecords,
  6355. "serverSide": _fnDataSource( settings ) === 'ssp'
  6356. };
  6357. } );
  6358. /**
  6359. * Get the current page length.
  6360. *
  6361. * @return {integer} Current page length. Note `-1` indicates that all records
  6362. * are to be shown.
  6363. *//**
  6364. * Set the current page length.
  6365. *
  6366. * @param {integer} Page length to set. Use `-1` to show all records.
  6367. * @returns {DataTables.Api} this
  6368. */
  6369. _api_register( 'page.len()', function ( len ) {
  6370. // Note that we can't call this function 'length()' because `length`
  6371. // is a Javascript property of functions which defines how many arguments
  6372. // the function expects.
  6373. if ( len === undefined ) {
  6374. return this.context.length !== 0 ?
  6375. this.context[0]._iDisplayLength :
  6376. undefined;
  6377. }
  6378. // else, set the page length
  6379. return this.iterator( 'table', function ( settings ) {
  6380. _fnLengthChange( settings, len );
  6381. } );
  6382. } );
  6383. var __reload = function ( settings, holdPosition, callback ) {
  6384. // Use the draw event to trigger a callback
  6385. if ( callback ) {
  6386. var api = new _Api( settings );
  6387. api.one( 'draw', function () {
  6388. callback( api.ajax.json() );
  6389. } );
  6390. }
  6391. if ( _fnDataSource( settings ) == 'ssp' ) {
  6392. _fnReDraw( settings, holdPosition );
  6393. }
  6394. else {
  6395. _fnProcessingDisplay( settings, true );
  6396. // Cancel an existing request
  6397. var xhr = settings.jqXHR;
  6398. if ( xhr && xhr.readyState !== 4 ) {
  6399. xhr.abort();
  6400. }
  6401. // Trigger xhr
  6402. _fnBuildAjax( settings, [], function( json ) {
  6403. _fnClearTable( settings );
  6404. var data = _fnAjaxDataSrc( settings, json );
  6405. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6406. _fnAddData( settings, data[i] );
  6407. }
  6408. _fnReDraw( settings, holdPosition );
  6409. _fnProcessingDisplay( settings, false );
  6410. } );
  6411. }
  6412. };
  6413. /**
  6414. * Get the JSON response from the last Ajax request that DataTables made to the
  6415. * server. Note that this returns the JSON from the first table in the current
  6416. * context.
  6417. *
  6418. * @return {object} JSON received from the server.
  6419. */
  6420. _api_register( 'ajax.json()', function () {
  6421. var ctx = this.context;
  6422. if ( ctx.length > 0 ) {
  6423. return ctx[0].json;
  6424. }
  6425. // else return undefined;
  6426. } );
  6427. /**
  6428. * Get the data submitted in the last Ajax request
  6429. */
  6430. _api_register( 'ajax.params()', function () {
  6431. var ctx = this.context;
  6432. if ( ctx.length > 0 ) {
  6433. return ctx[0].oAjaxData;
  6434. }
  6435. // else return undefined;
  6436. } );
  6437. /**
  6438. * Reload tables from the Ajax data source. Note that this function will
  6439. * automatically re-draw the table when the remote data has been loaded.
  6440. *
  6441. * @param {boolean} [reset=true] Reset (default) or hold the current paging
  6442. * position. A full re-sort and re-filter is performed when this method is
  6443. * called, which is why the pagination reset is the default action.
  6444. * @returns {DataTables.Api} this
  6445. */
  6446. _api_register( 'ajax.reload()', function ( callback, resetPaging ) {
  6447. return this.iterator( 'table', function (settings) {
  6448. __reload( settings, resetPaging===false, callback );
  6449. } );
  6450. } );
  6451. /**
  6452. * Get the current Ajax URL. Note that this returns the URL from the first
  6453. * table in the current context.
  6454. *
  6455. * @return {string} Current Ajax source URL
  6456. *//**
  6457. * Set the Ajax URL. Note that this will set the URL for all tables in the
  6458. * current context.
  6459. *
  6460. * @param {string} url URL to set.
  6461. * @returns {DataTables.Api} this
  6462. */
  6463. _api_register( 'ajax.url()', function ( url ) {
  6464. var ctx = this.context;
  6465. if ( url === undefined ) {
  6466. // get
  6467. if ( ctx.length === 0 ) {
  6468. return undefined;
  6469. }
  6470. ctx = ctx[0];
  6471. return ctx.ajax ?
  6472. $.isPlainObject( ctx.ajax ) ?
  6473. ctx.ajax.url :
  6474. ctx.ajax :
  6475. ctx.sAjaxSource;
  6476. }
  6477. // set
  6478. return this.iterator( 'table', function ( settings ) {
  6479. if ( $.isPlainObject( settings.ajax ) ) {
  6480. settings.ajax.url = url;
  6481. }
  6482. else {
  6483. settings.ajax = url;
  6484. }
  6485. // No need to consider sAjaxSource here since DataTables gives priority
  6486. // to `ajax` over `sAjaxSource`. So setting `ajax` here, renders any
  6487. // value of `sAjaxSource` redundant.
  6488. } );
  6489. } );
  6490. /**
  6491. * Load data from the newly set Ajax URL. Note that this method is only
  6492. * available when `ajax.url()` is used to set a URL. Additionally, this method
  6493. * has the same effect as calling `ajax.reload()` but is provided for
  6494. * convenience when setting a new URL. Like `ajax.reload()` it will
  6495. * automatically redraw the table once the remote data has been loaded.
  6496. *
  6497. * @returns {DataTables.Api} this
  6498. */
  6499. _api_register( 'ajax.url().load()', function ( callback, resetPaging ) {
  6500. // Same as a reload, but makes sense to present it for easy access after a
  6501. // url change
  6502. return this.iterator( 'table', function ( ctx ) {
  6503. __reload( ctx, resetPaging===false, callback );
  6504. } );
  6505. } );
  6506. var _selector_run = function ( type, selector, selectFn, settings, opts )
  6507. {
  6508. var
  6509. out = [], res,
  6510. a, i, ien, j, jen,
  6511. selectorType = typeof selector;
  6512. // Can't just check for isArray here, as an API or jQuery instance might be
  6513. // given with their array like look
  6514. if ( ! selector || selectorType === 'string' || selectorType === 'function' || selector.length === undefined ) {
  6515. selector = [ selector ];
  6516. }
  6517. for ( i=0, ien=selector.length ; i<ien ; i++ ) {
  6518. a = selector[i] && selector[i].split ?
  6519. selector[i].split(',') :
  6520. [ selector[i] ];
  6521. for ( j=0, jen=a.length ; j<jen ; j++ ) {
  6522. res = selectFn( typeof a[j] === 'string' ? $.trim(a[j]) : a[j] );
  6523. if ( res && res.length ) {
  6524. out = out.concat( res );
  6525. }
  6526. }
  6527. }
  6528. // selector extensions
  6529. var ext = _ext.selector[ type ];
  6530. if ( ext.length ) {
  6531. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  6532. out = ext[i]( settings, opts, out );
  6533. }
  6534. }
  6535. return _unique( out );
  6536. };
  6537. var _selector_opts = function ( opts )
  6538. {
  6539. if ( ! opts ) {
  6540. opts = {};
  6541. }
  6542. // Backwards compatibility for 1.9- which used the terminology filter rather
  6543. // than search
  6544. if ( opts.filter && opts.search === undefined ) {
  6545. opts.search = opts.filter;
  6546. }
  6547. return $.extend( {
  6548. search: 'none',
  6549. order: 'current',
  6550. page: 'all'
  6551. }, opts );
  6552. };
  6553. var _selector_first = function ( inst )
  6554. {
  6555. // Reduce the API instance to the first item found
  6556. for ( var i=0, ien=inst.length ; i<ien ; i++ ) {
  6557. if ( inst[i].length > 0 ) {
  6558. // Assign the first element to the first item in the instance
  6559. // and truncate the instance and context
  6560. inst[0] = inst[i];
  6561. inst[0].length = 1;
  6562. inst.length = 1;
  6563. inst.context = [ inst.context[i] ];
  6564. return inst;
  6565. }
  6566. }
  6567. // Not found - return an empty instance
  6568. inst.length = 0;
  6569. return inst;
  6570. };
  6571. var _selector_row_indexes = function ( settings, opts )
  6572. {
  6573. var
  6574. i, ien, tmp, a=[],
  6575. displayFiltered = settings.aiDisplay,
  6576. displayMaster = settings.aiDisplayMaster;
  6577. var
  6578. search = opts.search, // none, applied, removed
  6579. order = opts.order, // applied, current, index (original - compatibility with 1.9)
  6580. page = opts.page; // all, current
  6581. if ( _fnDataSource( settings ) == 'ssp' ) {
  6582. // In server-side processing mode, most options are irrelevant since
  6583. // rows not shown don't exist and the index order is the applied order
  6584. // Removed is a special case - for consistency just return an empty
  6585. // array
  6586. return search === 'removed' ?
  6587. [] :
  6588. _range( 0, displayMaster.length );
  6589. }
  6590. else if ( page == 'current' ) {
  6591. // Current page implies that order=current and fitler=applied, since it is
  6592. // fairly senseless otherwise, regardless of what order and search actually
  6593. // are
  6594. for ( i=settings._iDisplayStart, ien=settings.fnDisplayEnd() ; i<ien ; i++ ) {
  6595. a.push( displayFiltered[i] );
  6596. }
  6597. }
  6598. else if ( order == 'current' || order == 'applied' ) {
  6599. a = search == 'none' ?
  6600. displayMaster.slice() : // no search
  6601. search == 'applied' ?
  6602. displayFiltered.slice() : // applied search
  6603. $.map( displayMaster, function (el, i) { // removed search
  6604. return $.inArray( el, displayFiltered ) === -1 ? el : null;
  6605. } );
  6606. }
  6607. else if ( order == 'index' || order == 'original' ) {
  6608. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  6609. if ( search == 'none' ) {
  6610. a.push( i );
  6611. }
  6612. else { // applied | removed
  6613. tmp = $.inArray( i, displayFiltered );
  6614. if ((tmp === -1 && search == 'removed') ||
  6615. (tmp >= 0 && search == 'applied') )
  6616. {
  6617. a.push( i );
  6618. }
  6619. }
  6620. }
  6621. }
  6622. return a;
  6623. };
  6624. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6625. * Rows
  6626. *
  6627. * {} - no selector - use all available rows
  6628. * {integer} - row aoData index
  6629. * {node} - TR node
  6630. * {string} - jQuery selector to apply to the TR elements
  6631. * {array} - jQuery array of nodes, or simply an array of TR nodes
  6632. *
  6633. */
  6634. var __row_selector = function ( settings, selector, opts )
  6635. {
  6636. var run = function ( sel ) {
  6637. var selInt = _intVal( sel );
  6638. var i, ien;
  6639. // Short cut - selector is a number and no options provided (default is
  6640. // all records, so no need to check if the index is in there, since it
  6641. // must be - dev error if the index doesn't exist).
  6642. if ( selInt !== null && ! opts ) {
  6643. return [ selInt ];
  6644. }
  6645. var rows = _selector_row_indexes( settings, opts );
  6646. if ( selInt !== null && $.inArray( selInt, rows ) !== -1 ) {
  6647. // Selector - integer
  6648. return [ selInt ];
  6649. }
  6650. else if ( ! sel ) {
  6651. // Selector - none
  6652. return rows;
  6653. }
  6654. // Selector - function
  6655. if ( typeof sel === 'function' ) {
  6656. return $.map( rows, function (idx) {
  6657. var row = settings.aoData[ idx ];
  6658. return sel( idx, row._aData, row.nTr ) ? idx : null;
  6659. } );
  6660. }
  6661. // Get nodes in the order from the `rows` array with null values removed
  6662. var nodes = _removeEmpty(
  6663. _pluck_order( settings.aoData, rows, 'nTr' )
  6664. );
  6665. // Selector - node
  6666. if ( sel.nodeName ) {
  6667. if ( sel._DT_RowIndex !== undefined ) {
  6668. return [ sel._DT_RowIndex ]; // Property added by DT for fast lookup
  6669. }
  6670. else if ( sel._DT_CellIndex ) {
  6671. return [ sel._DT_CellIndex.row ];
  6672. }
  6673. else {
  6674. var host = $(sel).closest('*[data-dt-row]');
  6675. return host.length ?
  6676. [ host.data('dt-row') ] :
  6677. [];
  6678. }
  6679. }
  6680. // ID selector. Want to always be able to select rows by id, regardless
  6681. // of if the tr element has been created or not, so can't rely upon
  6682. // jQuery here - hence a custom implementation. This does not match
  6683. // Sizzle's fast selector or HTML4 - in HTML5 the ID can be anything,
  6684. // but to select it using a CSS selector engine (like Sizzle or
  6685. // querySelect) it would need to need to be escaped for some characters.
  6686. // DataTables simplifies this for row selectors since you can select
  6687. // only a row. A # indicates an id any anything that follows is the id -
  6688. // unescaped.
  6689. if ( typeof sel === 'string' && sel.charAt(0) === '#' ) {
  6690. // get row index from id
  6691. var rowObj = settings.aIds[ sel.replace( /^#/, '' ) ];
  6692. if ( rowObj !== undefined ) {
  6693. return [ rowObj.idx ];
  6694. }
  6695. // need to fall through to jQuery in case there is DOM id that
  6696. // matches
  6697. }
  6698. // Selector - jQuery selector string, array of nodes or jQuery object/
  6699. // As jQuery's .filter() allows jQuery objects to be passed in filter,
  6700. // it also allows arrays, so this will cope with all three options
  6701. return $(nodes)
  6702. .filter( sel )
  6703. .map( function () {
  6704. return this._DT_RowIndex;
  6705. } )
  6706. .toArray();
  6707. };
  6708. return _selector_run( 'row', selector, run, settings, opts );
  6709. };
  6710. _api_register( 'rows()', function ( selector, opts ) {
  6711. // argument shifting
  6712. if ( selector === undefined ) {
  6713. selector = '';
  6714. }
  6715. else if ( $.isPlainObject( selector ) ) {
  6716. opts = selector;
  6717. selector = '';
  6718. }
  6719. opts = _selector_opts( opts );
  6720. var inst = this.iterator( 'table', function ( settings ) {
  6721. return __row_selector( settings, selector, opts );
  6722. }, 1 );
  6723. // Want argument shifting here and in __row_selector?
  6724. inst.selector.rows = selector;
  6725. inst.selector.opts = opts;
  6726. return inst;
  6727. } );
  6728. _api_register( 'rows().nodes()', function () {
  6729. return this.iterator( 'row', function ( settings, row ) {
  6730. return settings.aoData[ row ].nTr || undefined;
  6731. }, 1 );
  6732. } );
  6733. _api_register( 'rows().data()', function () {
  6734. return this.iterator( true, 'rows', function ( settings, rows ) {
  6735. return _pluck_order( settings.aoData, rows, '_aData' );
  6736. }, 1 );
  6737. } );
  6738. _api_registerPlural( 'rows().cache()', 'row().cache()', function ( type ) {
  6739. return this.iterator( 'row', function ( settings, row ) {
  6740. var r = settings.aoData[ row ];
  6741. return type === 'search' ? r._aFilterData : r._aSortData;
  6742. }, 1 );
  6743. } );
  6744. _api_registerPlural( 'rows().invalidate()', 'row().invalidate()', function ( src ) {
  6745. return this.iterator( 'row', function ( settings, row ) {
  6746. _fnInvalidate( settings, row, src );
  6747. } );
  6748. } );
  6749. _api_registerPlural( 'rows().indexes()', 'row().index()', function () {
  6750. return this.iterator( 'row', function ( settings, row ) {
  6751. return row;
  6752. }, 1 );
  6753. } );
  6754. _api_registerPlural( 'rows().ids()', 'row().id()', function ( hash ) {
  6755. var a = [];
  6756. var context = this.context;
  6757. // `iterator` will drop undefined values, but in this case we want them
  6758. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  6759. for ( var j=0, jen=this[i].length ; j<jen ; j++ ) {
  6760. var id = context[i].rowIdFn( context[i].aoData[ this[i][j] ]._aData );
  6761. a.push( (hash === true ? '#' : '' )+ id );
  6762. }
  6763. }
  6764. return new _Api( context, a );
  6765. } );
  6766. _api_registerPlural( 'rows().remove()', 'row().remove()', function () {
  6767. var that = this;
  6768. this.iterator( 'row', function ( settings, row, thatIdx ) {
  6769. var data = settings.aoData;
  6770. var rowData = data[ row ];
  6771. var i, ien, j, jen;
  6772. var loopRow, loopCells;
  6773. data.splice( row, 1 );
  6774. // Update the cached indexes
  6775. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  6776. loopRow = data[i];
  6777. loopCells = loopRow.anCells;
  6778. // Rows
  6779. if ( loopRow.nTr !== null ) {
  6780. loopRow.nTr._DT_RowIndex = i;
  6781. }
  6782. // Cells
  6783. if ( loopCells !== null ) {
  6784. for ( j=0, jen=loopCells.length ; j<jen ; j++ ) {
  6785. loopCells[j]._DT_CellIndex.row = i;
  6786. }
  6787. }
  6788. }
  6789. // Delete from the display arrays
  6790. _fnDeleteIndex( settings.aiDisplayMaster, row );
  6791. _fnDeleteIndex( settings.aiDisplay, row );
  6792. _fnDeleteIndex( that[ thatIdx ], row, false ); // maintain local indexes
  6793. // Check for an 'overflow' they case for displaying the table
  6794. _fnLengthOverflow( settings );
  6795. // Remove the row's ID reference if there is one
  6796. var id = settings.rowIdFn( rowData._aData );
  6797. if ( id !== undefined ) {
  6798. delete settings.aIds[ id ];
  6799. }
  6800. } );
  6801. this.iterator( 'table', function ( settings ) {
  6802. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  6803. settings.aoData[i].idx = i;
  6804. }
  6805. } );
  6806. return this;
  6807. } );
  6808. _api_register( 'rows.add()', function ( rows ) {
  6809. var newRows = this.iterator( 'table', function ( settings ) {
  6810. var row, i, ien;
  6811. var out = [];
  6812. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  6813. row = rows[i];
  6814. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  6815. out.push( _fnAddTr( settings, row )[0] );
  6816. }
  6817. else {
  6818. out.push( _fnAddData( settings, row ) );
  6819. }
  6820. }
  6821. return out;
  6822. }, 1 );
  6823. // Return an Api.rows() extended instance, so rows().nodes() etc can be used
  6824. var modRows = this.rows( -1 );
  6825. modRows.pop();
  6826. $.merge( modRows, newRows );
  6827. return modRows;
  6828. } );
  6829. /**
  6830. *
  6831. */
  6832. _api_register( 'row()', function ( selector, opts ) {
  6833. return _selector_first( this.rows( selector, opts ) );
  6834. } );
  6835. _api_register( 'row().data()', function ( data ) {
  6836. var ctx = this.context;
  6837. if ( data === undefined ) {
  6838. // Get
  6839. return ctx.length && this.length ?
  6840. ctx[0].aoData[ this[0] ]._aData :
  6841. undefined;
  6842. }
  6843. // Set
  6844. ctx[0].aoData[ this[0] ]._aData = data;
  6845. // Automatically invalidate
  6846. _fnInvalidate( ctx[0], this[0], 'data' );
  6847. return this;
  6848. } );
  6849. _api_register( 'row().node()', function () {
  6850. var ctx = this.context;
  6851. return ctx.length && this.length ?
  6852. ctx[0].aoData[ this[0] ].nTr || null :
  6853. null;
  6854. } );
  6855. _api_register( 'row.add()', function ( row ) {
  6856. // Allow a jQuery object to be passed in - only a single row is added from
  6857. // it though - the first element in the set
  6858. if ( row instanceof $ && row.length ) {
  6859. row = row[0];
  6860. }
  6861. var rows = this.iterator( 'table', function ( settings ) {
  6862. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  6863. return _fnAddTr( settings, row )[0];
  6864. }
  6865. return _fnAddData( settings, row );
  6866. } );
  6867. // Return an Api.rows() extended instance, with the newly added row selected
  6868. return this.row( rows[0] );
  6869. } );
  6870. var __details_add = function ( ctx, row, data, klass )
  6871. {
  6872. // Convert to array of TR elements
  6873. var rows = [];
  6874. var addRow = function ( r, k ) {
  6875. // Recursion to allow for arrays of jQuery objects
  6876. if ( $.isArray( r ) || r instanceof $ ) {
  6877. for ( var i=0, ien=r.length ; i<ien ; i++ ) {
  6878. addRow( r[i], k );
  6879. }
  6880. return;
  6881. }
  6882. // If we get a TR element, then just add it directly - up to the dev
  6883. // to add the correct number of columns etc
  6884. if ( r.nodeName && r.nodeName.toLowerCase() === 'tr' ) {
  6885. rows.push( r );
  6886. }
  6887. else {
  6888. // Otherwise create a row with a wrapper
  6889. var created = $('<tr><td/></tr>').addClass( k );
  6890. $('td', created)
  6891. .addClass( k )
  6892. .html( r )
  6893. [0].colSpan = _fnVisbleColumns( ctx );
  6894. rows.push( created[0] );
  6895. }
  6896. };
  6897. addRow( data, klass );
  6898. if ( row._details ) {
  6899. row._details.remove();
  6900. }
  6901. row._details = $(rows);
  6902. // If the children were already shown, that state should be retained
  6903. if ( row._detailsShow ) {
  6904. row._details.insertAfter( row.nTr );
  6905. }
  6906. };
  6907. var __details_remove = function ( api, idx )
  6908. {
  6909. var ctx = api.context;
  6910. if ( ctx.length ) {
  6911. var row = ctx[0].aoData[ idx !== undefined ? idx : api[0] ];
  6912. if ( row && row._details ) {
  6913. row._details.remove();
  6914. row._detailsShow = undefined;
  6915. row._details = undefined;
  6916. }
  6917. }
  6918. };
  6919. var __details_display = function ( api, show ) {
  6920. var ctx = api.context;
  6921. if ( ctx.length && api.length ) {
  6922. var row = ctx[0].aoData[ api[0] ];
  6923. if ( row._details ) {
  6924. row._detailsShow = show;
  6925. if ( show ) {
  6926. row._details.insertAfter( row.nTr );
  6927. }
  6928. else {
  6929. row._details.detach();
  6930. }
  6931. __details_events( ctx[0] );
  6932. }
  6933. }
  6934. };
  6935. var __details_events = function ( settings )
  6936. {
  6937. var api = new _Api( settings );
  6938. var namespace = '.dt.DT_details';
  6939. var drawEvent = 'draw'+namespace;
  6940. var colvisEvent = 'column-visibility'+namespace;
  6941. var destroyEvent = 'destroy'+namespace;
  6942. var data = settings.aoData;
  6943. api.off( drawEvent +' '+ colvisEvent +' '+ destroyEvent );
  6944. if ( _pluck( data, '_details' ).length > 0 ) {
  6945. // On each draw, insert the required elements into the document
  6946. api.on( drawEvent, function ( e, ctx ) {
  6947. if ( settings !== ctx ) {
  6948. return;
  6949. }
  6950. api.rows( {page:'current'} ).eq(0).each( function (idx) {
  6951. // Internal data grab
  6952. var row = data[ idx ];
  6953. if ( row._detailsShow ) {
  6954. row._details.insertAfter( row.nTr );
  6955. }
  6956. } );
  6957. } );
  6958. // Column visibility change - update the colspan
  6959. api.on( colvisEvent, function ( e, ctx, idx, vis ) {
  6960. if ( settings !== ctx ) {
  6961. return;
  6962. }
  6963. // Update the colspan for the details rows (note, only if it already has
  6964. // a colspan)
  6965. var row, visible = _fnVisbleColumns( ctx );
  6966. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6967. row = data[i];
  6968. if ( row._details ) {
  6969. row._details.children('td[colspan]').attr('colspan', visible );
  6970. }
  6971. }
  6972. } );
  6973. // Table destroyed - nuke any child rows
  6974. api.on( destroyEvent, function ( e, ctx ) {
  6975. if ( settings !== ctx ) {
  6976. return;
  6977. }
  6978. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6979. if ( data[i]._details ) {
  6980. __details_remove( api, i );
  6981. }
  6982. }
  6983. } );
  6984. }
  6985. };
  6986. // Strings for the method names to help minification
  6987. var _emp = '';
  6988. var _child_obj = _emp+'row().child';
  6989. var _child_mth = _child_obj+'()';
  6990. // data can be:
  6991. // tr
  6992. // string
  6993. // jQuery or array of any of the above
  6994. _api_register( _child_mth, function ( data, klass ) {
  6995. var ctx = this.context;
  6996. if ( data === undefined ) {
  6997. // get
  6998. return ctx.length && this.length ?
  6999. ctx[0].aoData[ this[0] ]._details :
  7000. undefined;
  7001. }
  7002. else if ( data === true ) {
  7003. // show
  7004. this.child.show();
  7005. }
  7006. else if ( data === false ) {
  7007. // remove
  7008. __details_remove( this );
  7009. }
  7010. else if ( ctx.length && this.length ) {
  7011. // set
  7012. __details_add( ctx[0], ctx[0].aoData[ this[0] ], data, klass );
  7013. }
  7014. return this;
  7015. } );
  7016. _api_register( [
  7017. _child_obj+'.show()',
  7018. _child_mth+'.show()' // only when `child()` was called with parameters (without
  7019. ], function ( show ) { // it returns an object and this method is not executed)
  7020. __details_display( this, true );
  7021. return this;
  7022. } );
  7023. _api_register( [
  7024. _child_obj+'.hide()',
  7025. _child_mth+'.hide()' // only when `child()` was called with parameters (without
  7026. ], function () { // it returns an object and this method is not executed)
  7027. __details_display( this, false );
  7028. return this;
  7029. } );
  7030. _api_register( [
  7031. _child_obj+'.remove()',
  7032. _child_mth+'.remove()' // only when `child()` was called with parameters (without
  7033. ], function () { // it returns an object and this method is not executed)
  7034. __details_remove( this );
  7035. return this;
  7036. } );
  7037. _api_register( _child_obj+'.isShown()', function () {
  7038. var ctx = this.context;
  7039. if ( ctx.length && this.length ) {
  7040. // _detailsShown as false or undefined will fall through to return false
  7041. return ctx[0].aoData[ this[0] ]._detailsShow || false;
  7042. }
  7043. return false;
  7044. } );
  7045. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  7046. * Columns
  7047. *
  7048. * {integer} - column index (>=0 count from left, <0 count from right)
  7049. * "{integer}:visIdx" - visible column index (i.e. translate to column index) (>=0 count from left, <0 count from right)
  7050. * "{integer}:visible" - alias for {integer}:visIdx (>=0 count from left, <0 count from right)
  7051. * "{string}:name" - column name
  7052. * "{string}" - jQuery selector on column header nodes
  7053. *
  7054. */
  7055. // can be an array of these items, comma separated list, or an array of comma
  7056. // separated lists
  7057. var __re_column_selector = /^(.+):(name|visIdx|visible)$/;
  7058. // r1 and r2 are redundant - but it means that the parameters match for the
  7059. // iterator callback in columns().data()
  7060. var __columnData = function ( settings, column, r1, r2, rows ) {
  7061. var a = [];
  7062. for ( var row=0, ien=rows.length ; row<ien ; row++ ) {
  7063. a.push( _fnGetCellData( settings, rows[row], column ) );
  7064. }
  7065. return a;
  7066. };
  7067. var __column_selector = function ( settings, selector, opts )
  7068. {
  7069. var
  7070. columns = settings.aoColumns,
  7071. names = _pluck( columns, 'sName' ),
  7072. nodes = _pluck( columns, 'nTh' );
  7073. var run = function ( s ) {
  7074. var selInt = _intVal( s );
  7075. // Selector - all
  7076. if ( s === '' ) {
  7077. return _range( columns.length );
  7078. }
  7079. // Selector - index
  7080. if ( selInt !== null ) {
  7081. return [ selInt >= 0 ?
  7082. selInt : // Count from left
  7083. columns.length + selInt // Count from right (+ because its a negative value)
  7084. ];
  7085. }
  7086. // Selector = function
  7087. if ( typeof s === 'function' ) {
  7088. var rows = _selector_row_indexes( settings, opts );
  7089. return $.map( columns, function (col, idx) {
  7090. return s(
  7091. idx,
  7092. __columnData( settings, idx, 0, 0, rows ),
  7093. nodes[ idx ]
  7094. ) ? idx : null;
  7095. } );
  7096. }
  7097. // jQuery or string selector
  7098. var match = typeof s === 'string' ?
  7099. s.match( __re_column_selector ) :
  7100. '';
  7101. if ( match ) {
  7102. switch( match[2] ) {
  7103. case 'visIdx':
  7104. case 'visible':
  7105. var idx = parseInt( match[1], 10 );
  7106. // Visible index given, convert to column index
  7107. if ( idx < 0 ) {
  7108. // Counting from the right
  7109. var visColumns = $.map( columns, function (col,i) {
  7110. return col.bVisible ? i : null;
  7111. } );
  7112. return [ visColumns[ visColumns.length + idx ] ];
  7113. }
  7114. // Counting from the left
  7115. return [ _fnVisibleToColumnIndex( settings, idx ) ];
  7116. case 'name':
  7117. // match by name. `names` is column index complete and in order
  7118. return $.map( names, function (name, i) {
  7119. return name === match[1] ? i : null;
  7120. } );
  7121. default:
  7122. return [];
  7123. }
  7124. }
  7125. // Cell in the table body
  7126. if ( s.nodeName && s._DT_CellIndex ) {
  7127. return [ s._DT_CellIndex.column ];
  7128. }
  7129. // jQuery selector on the TH elements for the columns
  7130. var jqResult = $( nodes )
  7131. .filter( s )
  7132. .map( function () {
  7133. return $.inArray( this, nodes ); // `nodes` is column index complete and in order
  7134. } )
  7135. .toArray();
  7136. if ( jqResult.length || ! s.nodeName ) {
  7137. return jqResult;
  7138. }
  7139. // Otherwise a node which might have a `dt-column` data attribute, or be
  7140. // a child or such an element
  7141. var host = $(s).closest('*[data-dt-column]');
  7142. return host.length ?
  7143. [ host.data('dt-column') ] :
  7144. [];
  7145. };
  7146. return _selector_run( 'column', selector, run, settings, opts );
  7147. };
  7148. var __setColumnVis = function ( settings, column, vis, recalc ) {
  7149. var
  7150. cols = settings.aoColumns,
  7151. col = cols[ column ],
  7152. data = settings.aoData,
  7153. row, cells, i, ien, tr;
  7154. // Get
  7155. if ( vis === undefined ) {
  7156. return col.bVisible;
  7157. }
  7158. // Set
  7159. // No change
  7160. if ( col.bVisible === vis ) {
  7161. return;
  7162. }
  7163. if ( vis ) {
  7164. // Insert column
  7165. // Need to decide if we should use appendChild or insertBefore
  7166. var insertBefore = $.inArray( true, _pluck(cols, 'bVisible'), column+1 );
  7167. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  7168. tr = data[i].nTr;
  7169. cells = data[i].anCells;
  7170. if ( tr ) {
  7171. // insertBefore can act like appendChild if 2nd arg is null
  7172. tr.insertBefore( cells[ column ], cells[ insertBefore ] || null );
  7173. }
  7174. }
  7175. }
  7176. else {
  7177. // Remove column
  7178. $( _pluck( settings.aoData, 'anCells', column ) ).detach();
  7179. }
  7180. // Common actions
  7181. col.bVisible = vis;
  7182. _fnDrawHead( settings, settings.aoHeader );
  7183. _fnDrawHead( settings, settings.aoFooter );
  7184. if ( recalc === undefined || recalc ) {
  7185. // Automatically adjust column sizing
  7186. _fnAdjustColumnSizing( settings );
  7187. }
  7188. _fnCallbackFire( settings, null, 'column-visibility', [settings, column, vis, recalc] );
  7189. _fnSaveState( settings );
  7190. };
  7191. _api_register( 'columns()', function ( selector, opts ) {
  7192. // argument shifting
  7193. if ( selector === undefined ) {
  7194. selector = '';
  7195. }
  7196. else if ( $.isPlainObject( selector ) ) {
  7197. opts = selector;
  7198. selector = '';
  7199. }
  7200. opts = _selector_opts( opts );
  7201. var inst = this.iterator( 'table', function ( settings ) {
  7202. return __column_selector( settings, selector, opts );
  7203. }, 1 );
  7204. // Want argument shifting here and in _row_selector?
  7205. inst.selector.cols = selector;
  7206. inst.selector.opts = opts;
  7207. return inst;
  7208. } );
  7209. _api_registerPlural( 'columns().header()', 'column().header()', function ( selector, opts ) {
  7210. return this.iterator( 'column', function ( settings, column ) {
  7211. return settings.aoColumns[column].nTh;
  7212. }, 1 );
  7213. } );
  7214. _api_registerPlural( 'columns().footer()', 'column().footer()', function ( selector, opts ) {
  7215. return this.iterator( 'column', function ( settings, column ) {
  7216. return settings.aoColumns[column].nTf;
  7217. }, 1 );
  7218. } );
  7219. _api_registerPlural( 'columns().data()', 'column().data()', function () {
  7220. return this.iterator( 'column-rows', __columnData, 1 );
  7221. } );
  7222. _api_registerPlural( 'columns().dataSrc()', 'column().dataSrc()', function () {
  7223. return this.iterator( 'column', function ( settings, column ) {
  7224. return settings.aoColumns[column].mData;
  7225. }, 1 );
  7226. } );
  7227. _api_registerPlural( 'columns().cache()', 'column().cache()', function ( type ) {
  7228. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7229. return _pluck_order( settings.aoData, rows,
  7230. type === 'search' ? '_aFilterData' : '_aSortData', column
  7231. );
  7232. }, 1 );
  7233. } );
  7234. _api_registerPlural( 'columns().nodes()', 'column().nodes()', function () {
  7235. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7236. return _pluck_order( settings.aoData, rows, 'anCells', column ) ;
  7237. }, 1 );
  7238. } );
  7239. _api_registerPlural( 'columns().visible()', 'column().visible()', function ( vis, calc ) {
  7240. return this.iterator( 'column', function ( settings, column ) {
  7241. if ( vis === undefined ) {
  7242. return settings.aoColumns[ column ].bVisible;
  7243. } // else
  7244. __setColumnVis( settings, column, vis, calc );
  7245. } );
  7246. } );
  7247. _api_registerPlural( 'columns().indexes()', 'column().index()', function ( type ) {
  7248. return this.iterator( 'column', function ( settings, column ) {
  7249. return type === 'visible' ?
  7250. _fnColumnIndexToVisible( settings, column ) :
  7251. column;
  7252. }, 1 );
  7253. } );
  7254. _api_register( 'columns.adjust()', function () {
  7255. return this.iterator( 'table', function ( settings ) {
  7256. _fnAdjustColumnSizing( settings );
  7257. }, 1 );
  7258. } );
  7259. _api_register( 'column.index()', function ( type, idx ) {
  7260. if ( this.context.length !== 0 ) {
  7261. var ctx = this.context[0];
  7262. if ( type === 'fromVisible' || type === 'toData' ) {
  7263. return _fnVisibleToColumnIndex( ctx, idx );
  7264. }
  7265. else if ( type === 'fromData' || type === 'toVisible' ) {
  7266. return _fnColumnIndexToVisible( ctx, idx );
  7267. }
  7268. }
  7269. } );
  7270. _api_register( 'column()', function ( selector, opts ) {
  7271. return _selector_first( this.columns( selector, opts ) );
  7272. } );
  7273. var __cell_selector = function ( settings, selector, opts )
  7274. {
  7275. var data = settings.aoData;
  7276. var rows = _selector_row_indexes( settings, opts );
  7277. var cells = _removeEmpty( _pluck_order( data, rows, 'anCells' ) );
  7278. var allCells = $( [].concat.apply([], cells) );
  7279. var row;
  7280. var columns = settings.aoColumns.length;
  7281. var a, i, ien, j, o, host;
  7282. var run = function ( s ) {
  7283. var fnSelector = typeof s === 'function';
  7284. if ( s === null || s === undefined || fnSelector ) {
  7285. // All cells and function selectors
  7286. a = [];
  7287. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  7288. row = rows[i];
  7289. for ( j=0 ; j<columns ; j++ ) {
  7290. o = {
  7291. row: row,
  7292. column: j
  7293. };
  7294. if ( fnSelector ) {
  7295. // Selector - function
  7296. host = data[ row ];
  7297. if ( s( o, _fnGetCellData(settings, row, j), host.anCells ? host.anCells[j] : null ) ) {
  7298. a.push( o );
  7299. }
  7300. }
  7301. else {
  7302. // Selector - all
  7303. a.push( o );
  7304. }
  7305. }
  7306. }
  7307. return a;
  7308. }
  7309. // Selector - index
  7310. if ( $.isPlainObject( s ) ) {
  7311. return [s];
  7312. }
  7313. // Selector - jQuery filtered cells
  7314. var jqResult = allCells
  7315. .filter( s )
  7316. .map( function (i, el) {
  7317. return { // use a new object, in case someone changes the values
  7318. row: el._DT_CellIndex.row,
  7319. column: el._DT_CellIndex.column
  7320. };
  7321. } )
  7322. .toArray();
  7323. if ( jqResult.length || ! s.nodeName ) {
  7324. return jqResult;
  7325. }
  7326. // Otherwise the selector is a node, and there is one last option - the
  7327. // element might be a child of an element which has dt-row and dt-column
  7328. // data attributes
  7329. host = $(s).closest('*[data-dt-row]');
  7330. return host.length ?
  7331. [ {
  7332. row: host.data('dt-row'),
  7333. column: host.data('dt-column')
  7334. } ] :
  7335. [];
  7336. };
  7337. return _selector_run( 'cell', selector, run, settings, opts );
  7338. };
  7339. _api_register( 'cells()', function ( rowSelector, columnSelector, opts ) {
  7340. // Argument shifting
  7341. if ( $.isPlainObject( rowSelector ) ) {
  7342. // Indexes
  7343. if ( rowSelector.row === undefined ) {
  7344. // Selector options in first parameter
  7345. opts = rowSelector;
  7346. rowSelector = null;
  7347. }
  7348. else {
  7349. // Cell index objects in first parameter
  7350. opts = columnSelector;
  7351. columnSelector = null;
  7352. }
  7353. }
  7354. if ( $.isPlainObject( columnSelector ) ) {
  7355. opts = columnSelector;
  7356. columnSelector = null;
  7357. }
  7358. // Cell selector
  7359. if ( columnSelector === null || columnSelector === undefined ) {
  7360. return this.iterator( 'table', function ( settings ) {
  7361. return __cell_selector( settings, rowSelector, _selector_opts( opts ) );
  7362. } );
  7363. }
  7364. // Row + column selector
  7365. var columns = this.columns( columnSelector, opts );
  7366. var rows = this.rows( rowSelector, opts );
  7367. var a, i, ien, j, jen;
  7368. var cells = this.iterator( 'table', function ( settings, idx ) {
  7369. a = [];
  7370. for ( i=0, ien=rows[idx].length ; i<ien ; i++ ) {
  7371. for ( j=0, jen=columns[idx].length ; j<jen ; j++ ) {
  7372. a.push( {
  7373. row: rows[idx][i],
  7374. column: columns[idx][j]
  7375. } );
  7376. }
  7377. }
  7378. return a;
  7379. }, 1 );
  7380. $.extend( cells.selector, {
  7381. cols: columnSelector,
  7382. rows: rowSelector,
  7383. opts: opts
  7384. } );
  7385. return cells;
  7386. } );
  7387. _api_registerPlural( 'cells().nodes()', 'cell().node()', function () {
  7388. return this.iterator( 'cell', function ( settings, row, column ) {
  7389. var data = settings.aoData[ row ];
  7390. return data && data.anCells ?
  7391. data.anCells[ column ] :
  7392. undefined;
  7393. }, 1 );
  7394. } );
  7395. _api_register( 'cells().data()', function () {
  7396. return this.iterator( 'cell', function ( settings, row, column ) {
  7397. return _fnGetCellData( settings, row, column );
  7398. }, 1 );
  7399. } );
  7400. _api_registerPlural( 'cells().cache()', 'cell().cache()', function ( type ) {
  7401. type = type === 'search' ? '_aFilterData' : '_aSortData';
  7402. return this.iterator( 'cell', function ( settings, row, column ) {
  7403. return settings.aoData[ row ][ type ][ column ];
  7404. }, 1 );
  7405. } );
  7406. _api_registerPlural( 'cells().render()', 'cell().render()', function ( type ) {
  7407. return this.iterator( 'cell', function ( settings, row, column ) {
  7408. return _fnGetCellData( settings, row, column, type );
  7409. }, 1 );
  7410. } );
  7411. _api_registerPlural( 'cells().indexes()', 'cell().index()', function () {
  7412. return this.iterator( 'cell', function ( settings, row, column ) {
  7413. return {
  7414. row: row,
  7415. column: column,
  7416. columnVisible: _fnColumnIndexToVisible( settings, column )
  7417. };
  7418. }, 1 );
  7419. } );
  7420. _api_registerPlural( 'cells().invalidate()', 'cell().invalidate()', function ( src ) {
  7421. return this.iterator( 'cell', function ( settings, row, column ) {
  7422. _fnInvalidate( settings, row, src, column );
  7423. } );
  7424. } );
  7425. _api_register( 'cell()', function ( rowSelector, columnSelector, opts ) {
  7426. return _selector_first( this.cells( rowSelector, columnSelector, opts ) );
  7427. } );
  7428. _api_register( 'cell().data()', function ( data ) {
  7429. var ctx = this.context;
  7430. var cell = this[0];
  7431. if ( data === undefined ) {
  7432. // Get
  7433. return ctx.length && cell.length ?
  7434. _fnGetCellData( ctx[0], cell[0].row, cell[0].column ) :
  7435. undefined;
  7436. }
  7437. // Set
  7438. _fnSetCellData( ctx[0], cell[0].row, cell[0].column, data );
  7439. _fnInvalidate( ctx[0], cell[0].row, 'data', cell[0].column );
  7440. return this;
  7441. } );
  7442. /**
  7443. * Get current ordering (sorting) that has been applied to the table.
  7444. *
  7445. * @returns {array} 2D array containing the sorting information for the first
  7446. * table in the current context. Each element in the parent array represents
  7447. * a column being sorted upon (i.e. multi-sorting with two columns would have
  7448. * 2 inner arrays). The inner arrays may have 2 or 3 elements. The first is
  7449. * the column index that the sorting condition applies to, the second is the
  7450. * direction of the sort (`desc` or `asc`) and, optionally, the third is the
  7451. * index of the sorting order from the `column.sorting` initialisation array.
  7452. *//**
  7453. * Set the ordering for the table.
  7454. *
  7455. * @param {integer} order Column index to sort upon.
  7456. * @param {string} direction Direction of the sort to be applied (`asc` or `desc`)
  7457. * @returns {DataTables.Api} this
  7458. *//**
  7459. * Set the ordering for the table.
  7460. *
  7461. * @param {array} order 1D array of sorting information to be applied.
  7462. * @param {array} [...] Optional additional sorting conditions
  7463. * @returns {DataTables.Api} this
  7464. *//**
  7465. * Set the ordering for the table.
  7466. *
  7467. * @param {array} order 2D array of sorting information to be applied.
  7468. * @returns {DataTables.Api} this
  7469. */
  7470. _api_register( 'order()', function ( order, dir ) {
  7471. var ctx = this.context;
  7472. if ( order === undefined ) {
  7473. // get
  7474. return ctx.length !== 0 ?
  7475. ctx[0].aaSorting :
  7476. undefined;
  7477. }
  7478. // set
  7479. if ( typeof order === 'number' ) {
  7480. // Simple column / direction passed in
  7481. order = [ [ order, dir ] ];
  7482. }
  7483. else if ( ! $.isArray( order[0] ) ) {
  7484. // Arguments passed in (list of 1D arrays)
  7485. order = Array.prototype.slice.call( arguments );
  7486. }
  7487. // otherwise a 2D array was passed in
  7488. return this.iterator( 'table', function ( settings ) {
  7489. settings.aaSorting = order.slice();
  7490. } );
  7491. } );
  7492. /**
  7493. * Attach a sort listener to an element for a given column
  7494. *
  7495. * @param {node|jQuery|string} node Identifier for the element(s) to attach the
  7496. * listener to. This can take the form of a single DOM node, a jQuery
  7497. * collection of nodes or a jQuery selector which will identify the node(s).
  7498. * @param {integer} column the column that a click on this node will sort on
  7499. * @param {function} [callback] callback function when sort is run
  7500. * @returns {DataTables.Api} this
  7501. */
  7502. _api_register( 'order.listener()', function ( node, column, callback ) {
  7503. return this.iterator( 'table', function ( settings ) {
  7504. _fnSortAttachListener( settings, node, column, callback );
  7505. } );
  7506. } );
  7507. _api_register( 'order.fixed()', function ( set ) {
  7508. if ( ! set ) {
  7509. var ctx = this.context;
  7510. var fixed = ctx.length ?
  7511. ctx[0].aaSortingFixed :
  7512. undefined;
  7513. return $.isArray( fixed ) ?
  7514. { pre: fixed } :
  7515. fixed;
  7516. }
  7517. return this.iterator( 'table', function ( settings ) {
  7518. settings.aaSortingFixed = $.extend( true, {}, set );
  7519. } );
  7520. } );
  7521. // Order by the selected column(s)
  7522. _api_register( [
  7523. 'columns().order()',
  7524. 'column().order()'
  7525. ], function ( dir ) {
  7526. var that = this;
  7527. return this.iterator( 'table', function ( settings, i ) {
  7528. var sort = [];
  7529. $.each( that[i], function (j, col) {
  7530. sort.push( [ col, dir ] );
  7531. } );
  7532. settings.aaSorting = sort;
  7533. } );
  7534. } );
  7535. _api_register( 'search()', function ( input, regex, smart, caseInsen ) {
  7536. var ctx = this.context;
  7537. if ( input === undefined ) {
  7538. // get
  7539. return ctx.length !== 0 ?
  7540. ctx[0].oPreviousSearch.sSearch :
  7541. undefined;
  7542. }
  7543. // set
  7544. return this.iterator( 'table', function ( settings ) {
  7545. if ( ! settings.oFeatures.bFilter ) {
  7546. return;
  7547. }
  7548. _fnFilterComplete( settings, $.extend( {}, settings.oPreviousSearch, {
  7549. "sSearch": input+"",
  7550. "bRegex": regex === null ? false : regex,
  7551. "bSmart": smart === null ? true : smart,
  7552. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7553. } ), 1 );
  7554. } );
  7555. } );
  7556. _api_registerPlural(
  7557. 'columns().search()',
  7558. 'column().search()',
  7559. function ( input, regex, smart, caseInsen ) {
  7560. return this.iterator( 'column', function ( settings, column ) {
  7561. var preSearch = settings.aoPreSearchCols;
  7562. if ( input === undefined ) {
  7563. // get
  7564. return preSearch[ column ].sSearch;
  7565. }
  7566. // set
  7567. if ( ! settings.oFeatures.bFilter ) {
  7568. return;
  7569. }
  7570. $.extend( preSearch[ column ], {
  7571. "sSearch": input+"",
  7572. "bRegex": regex === null ? false : regex,
  7573. "bSmart": smart === null ? true : smart,
  7574. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7575. } );
  7576. _fnFilterComplete( settings, settings.oPreviousSearch, 1 );
  7577. } );
  7578. }
  7579. );
  7580. /*
  7581. * State API methods
  7582. */
  7583. _api_register( 'state()', function () {
  7584. return this.context.length ?
  7585. this.context[0].oSavedState :
  7586. null;
  7587. } );
  7588. _api_register( 'state.clear()', function () {
  7589. return this.iterator( 'table', function ( settings ) {
  7590. // Save an empty object
  7591. settings.fnStateSaveCallback.call( settings.oInstance, settings, {} );
  7592. } );
  7593. } );
  7594. _api_register( 'state.loaded()', function () {
  7595. return this.context.length ?
  7596. this.context[0].oLoadedState :
  7597. null;
  7598. } );
  7599. _api_register( 'state.save()', function () {
  7600. return this.iterator( 'table', function ( settings ) {
  7601. _fnSaveState( settings );
  7602. } );
  7603. } );
  7604. /**
  7605. * Provide a common method for plug-ins to check the version of DataTables being
  7606. * used, in order to ensure compatibility.
  7607. *
  7608. * @param {string} version Version string to check for, in the format "X.Y.Z".
  7609. * Note that the formats "X" and "X.Y" are also acceptable.
  7610. * @returns {boolean} true if this version of DataTables is greater or equal to
  7611. * the required version, or false if this version of DataTales is not
  7612. * suitable
  7613. * @static
  7614. * @dtopt API-Static
  7615. *
  7616. * @example
  7617. * alert( $.fn.dataTable.versionCheck( '1.9.0' ) );
  7618. */
  7619. DataTable.versionCheck = DataTable.fnVersionCheck = function( version )
  7620. {
  7621. var aThis = DataTable.version.split('.');
  7622. var aThat = version.split('.');
  7623. var iThis, iThat;
  7624. for ( var i=0, iLen=aThat.length ; i<iLen ; i++ ) {
  7625. iThis = parseInt( aThis[i], 10 ) || 0;
  7626. iThat = parseInt( aThat[i], 10 ) || 0;
  7627. // Parts are the same, keep comparing
  7628. if (iThis === iThat) {
  7629. continue;
  7630. }
  7631. // Parts are different, return immediately
  7632. return iThis > iThat;
  7633. }
  7634. return true;
  7635. };
  7636. /**
  7637. * Check if a `<table>` node is a DataTable table already or not.
  7638. *
  7639. * @param {node|jquery|string} table Table node, jQuery object or jQuery
  7640. * selector for the table to test. Note that if more than more than one
  7641. * table is passed on, only the first will be checked
  7642. * @returns {boolean} true the table given is a DataTable, or false otherwise
  7643. * @static
  7644. * @dtopt API-Static
  7645. *
  7646. * @example
  7647. * if ( ! $.fn.DataTable.isDataTable( '#example' ) ) {
  7648. * $('#example').dataTable();
  7649. * }
  7650. */
  7651. DataTable.isDataTable = DataTable.fnIsDataTable = function ( table )
  7652. {
  7653. var t = $(table).get(0);
  7654. var is = false;
  7655. $.each( DataTable.settings, function (i, o) {
  7656. var head = o.nScrollHead ? $('table', o.nScrollHead)[0] : null;
  7657. var foot = o.nScrollFoot ? $('table', o.nScrollFoot)[0] : null;
  7658. if ( o.nTable === t || head === t || foot === t ) {
  7659. is = true;
  7660. }
  7661. } );
  7662. return is;
  7663. };
  7664. /**
  7665. * Get all DataTable tables that have been initialised - optionally you can
  7666. * select to get only currently visible tables.
  7667. *
  7668. * @param {boolean} [visible=false] Flag to indicate if you want all (default)
  7669. * or visible tables only.
  7670. * @returns {array} Array of `table` nodes (not DataTable instances) which are
  7671. * DataTables
  7672. * @static
  7673. * @dtopt API-Static
  7674. *
  7675. * @example
  7676. * $.each( $.fn.dataTable.tables(true), function () {
  7677. * $(table).DataTable().columns.adjust();
  7678. * } );
  7679. */
  7680. DataTable.tables = DataTable.fnTables = function ( visible )
  7681. {
  7682. var api = false;
  7683. if ( $.isPlainObject( visible ) ) {
  7684. api = visible.api;
  7685. visible = visible.visible;
  7686. }
  7687. var a = $.map( DataTable.settings, function (o) {
  7688. if ( !visible || (visible && $(o.nTable).is(':visible')) ) {
  7689. return o.nTable;
  7690. }
  7691. } );
  7692. return api ?
  7693. new _Api( a ) :
  7694. a;
  7695. };
  7696. /**
  7697. * DataTables utility methods
  7698. *
  7699. * This namespace provides helper methods that DataTables uses internally to
  7700. * create a DataTable, but which are not exclusively used only for DataTables.
  7701. * These methods can be used by extension authors to save the duplication of
  7702. * code.
  7703. *
  7704. * @namespace
  7705. */
  7706. DataTable.util = {
  7707. /**
  7708. * Throttle the calls to a function. Arguments and context are maintained
  7709. * for the throttled function.
  7710. *
  7711. * @param {function} fn Function to be called
  7712. * @param {integer} freq Call frequency in mS
  7713. * @return {function} Wrapped function
  7714. */
  7715. throttle: _fnThrottle,
  7716. /**
  7717. * Escape a string such that it can be used in a regular expression
  7718. *
  7719. * @param {string} sVal string to escape
  7720. * @returns {string} escaped string
  7721. */
  7722. escapeRegex: _fnEscapeRegex
  7723. };
  7724. /**
  7725. * Convert from camel case parameters to Hungarian notation. This is made public
  7726. * for the extensions to provide the same ability as DataTables core to accept
  7727. * either the 1.9 style Hungarian notation, or the 1.10+ style camelCase
  7728. * parameters.
  7729. *
  7730. * @param {object} src The model object which holds all parameters that can be
  7731. * mapped.
  7732. * @param {object} user The object to convert from camel case to Hungarian.
  7733. * @param {boolean} force When set to `true`, properties which already have a
  7734. * Hungarian value in the `user` object will be overwritten. Otherwise they
  7735. * won't be.
  7736. */
  7737. DataTable.camelToHungarian = _fnCamelToHungarian;
  7738. /**
  7739. *
  7740. */
  7741. _api_register( '$()', function ( selector, opts ) {
  7742. var
  7743. rows = this.rows( opts ).nodes(), // Get all rows
  7744. jqRows = $(rows);
  7745. return $( [].concat(
  7746. jqRows.filter( selector ).toArray(),
  7747. jqRows.find( selector ).toArray()
  7748. ) );
  7749. } );
  7750. // jQuery functions to operate on the tables
  7751. $.each( [ 'on', 'one', 'off' ], function (i, key) {
  7752. _api_register( key+'()', function ( /* event, handler */ ) {
  7753. var args = Array.prototype.slice.call(arguments);
  7754. // Add the `dt` namespace automatically if it isn't already present
  7755. if ( ! args[0].match(/\.dt\b/) ) {
  7756. args[0] += '.dt';
  7757. }
  7758. var inst = $( this.tables().nodes() );
  7759. inst[key].apply( inst, args );
  7760. return this;
  7761. } );
  7762. } );
  7763. _api_register( 'clear()', function () {
  7764. return this.iterator( 'table', function ( settings ) {
  7765. _fnClearTable( settings );
  7766. } );
  7767. } );
  7768. _api_register( 'settings()', function () {
  7769. return new _Api( this.context, this.context );
  7770. } );
  7771. _api_register( 'init()', function () {
  7772. var ctx = this.context;
  7773. return ctx.length ? ctx[0].oInit : null;
  7774. } );
  7775. _api_register( 'data()', function () {
  7776. return this.iterator( 'table', function ( settings ) {
  7777. return _pluck( settings.aoData, '_aData' );
  7778. } ).flatten();
  7779. } );
  7780. _api_register( 'destroy()', function ( remove ) {
  7781. remove = remove || false;
  7782. return this.iterator( 'table', function ( settings ) {
  7783. var orig = settings.nTableWrapper.parentNode;
  7784. var classes = settings.oClasses;
  7785. var table = settings.nTable;
  7786. var tbody = settings.nTBody;
  7787. var thead = settings.nTHead;
  7788. var tfoot = settings.nTFoot;
  7789. var jqTable = $(table);
  7790. var jqTbody = $(tbody);
  7791. var jqWrapper = $(settings.nTableWrapper);
  7792. var rows = $.map( settings.aoData, function (r) { return r.nTr; } );
  7793. var i, ien;
  7794. // Flag to note that the table is currently being destroyed - no action
  7795. // should be taken
  7796. settings.bDestroying = true;
  7797. // Fire off the destroy callbacks for plug-ins etc
  7798. _fnCallbackFire( settings, "aoDestroyCallback", "destroy", [settings] );
  7799. // If not being removed from the document, make all columns visible
  7800. if ( ! remove ) {
  7801. new _Api( settings ).columns().visible( true );
  7802. }
  7803. // Blitz all `DT` namespaced events (these are internal events, the
  7804. // lowercase, `dt` events are user subscribed and they are responsible
  7805. // for removing them
  7806. jqWrapper.unbind('.DT').find(':not(tbody *)').unbind('.DT');
  7807. $(window).unbind('.DT-'+settings.sInstance);
  7808. // When scrolling we had to break the table up - restore it
  7809. if ( table != thead.parentNode ) {
  7810. jqTable.children('thead').detach();
  7811. jqTable.append( thead );
  7812. }
  7813. if ( tfoot && table != tfoot.parentNode ) {
  7814. jqTable.children('tfoot').detach();
  7815. jqTable.append( tfoot );
  7816. }
  7817. settings.aaSorting = [];
  7818. settings.aaSortingFixed = [];
  7819. _fnSortingClasses( settings );
  7820. $( rows ).removeClass( settings.asStripeClasses.join(' ') );
  7821. $('th, td', thead).removeClass( classes.sSortable+' '+
  7822. classes.sSortableAsc+' '+classes.sSortableDesc+' '+classes.sSortableNone
  7823. );
  7824. if ( settings.bJUI ) {
  7825. $('th span.'+classes.sSortIcon+ ', td span.'+classes.sSortIcon, thead).detach();
  7826. $('th, td', thead).each( function () {
  7827. var wrapper = $('div.'+classes.sSortJUIWrapper, this);
  7828. $(this).append( wrapper.contents() );
  7829. wrapper.detach();
  7830. } );
  7831. }
  7832. // Add the TR elements back into the table in their original order
  7833. jqTbody.children().detach();
  7834. jqTbody.append( rows );
  7835. // Remove the DataTables generated nodes, events and classes
  7836. var removedMethod = remove ? 'remove' : 'detach';
  7837. jqTable[ removedMethod ]();
  7838. jqWrapper[ removedMethod ]();
  7839. // If we need to reattach the table to the document
  7840. if ( ! remove && orig ) {
  7841. // insertBefore acts like appendChild if !arg[1]
  7842. orig.insertBefore( table, settings.nTableReinsertBefore );
  7843. // Restore the width of the original table - was read from the style property,
  7844. // so we can restore directly to that
  7845. jqTable
  7846. .css( 'width', settings.sDestroyWidth )
  7847. .removeClass( classes.sTable );
  7848. // If the were originally stripe classes - then we add them back here.
  7849. // Note this is not fool proof (for example if not all rows had stripe
  7850. // classes - but it's a good effort without getting carried away
  7851. ien = settings.asDestroyStripes.length;
  7852. if ( ien ) {
  7853. jqTbody.children().each( function (i) {
  7854. $(this).addClass( settings.asDestroyStripes[i % ien] );
  7855. } );
  7856. }
  7857. }
  7858. /* Remove the settings object from the settings array */
  7859. var idx = $.inArray( settings, DataTable.settings );
  7860. if ( idx !== -1 ) {
  7861. DataTable.settings.splice( idx, 1 );
  7862. }
  7863. } );
  7864. } );
  7865. // Add the `every()` method for rows, columns and cells in a compact form
  7866. $.each( [ 'column', 'row', 'cell' ], function ( i, type ) {
  7867. _api_register( type+'s().every()', function ( fn ) {
  7868. var opts = this.selector.opts;
  7869. var api = this;
  7870. return this.iterator( type, function ( settings, arg1, arg2, arg3, arg4 ) {
  7871. // Rows and columns:
  7872. // arg1 - index
  7873. // arg2 - table counter
  7874. // arg3 - loop counter
  7875. // arg4 - undefined
  7876. // Cells:
  7877. // arg1 - row index
  7878. // arg2 - column index
  7879. // arg3 - table counter
  7880. // arg4 - loop counter
  7881. fn.call(
  7882. api[ type ](
  7883. arg1,
  7884. type==='cell' ? arg2 : opts,
  7885. type==='cell' ? opts : undefined
  7886. ),
  7887. arg1, arg2, arg3, arg4
  7888. );
  7889. } );
  7890. } );
  7891. } );
  7892. // i18n method for extensions to be able to use the language object from the
  7893. // DataTable
  7894. _api_register( 'i18n()', function ( token, def, plural ) {
  7895. var ctx = this.context[0];
  7896. var resolved = _fnGetObjectDataFn( token )( ctx.oLanguage );
  7897. if ( resolved === undefined ) {
  7898. resolved = def;
  7899. }
  7900. if ( plural !== undefined && $.isPlainObject( resolved ) ) {
  7901. resolved = resolved[ plural ] !== undefined ?
  7902. resolved[ plural ] :
  7903. resolved._;
  7904. }
  7905. return resolved.replace( '%d', plural ); // nb: plural might be undefined,
  7906. } );
  7907. /**
  7908. * Version string for plug-ins to check compatibility. Allowed format is
  7909. * `a.b.c-d` where: a:int, b:int, c:int, d:string(dev|beta|alpha). `d` is used
  7910. * only for non-release builds. See http://semver.org/ for more information.
  7911. * @member
  7912. * @type string
  7913. * @default Version number
  7914. */
  7915. DataTable.version = "1.10.11";
  7916. /**
  7917. * Private data store, containing all of the settings objects that are
  7918. * created for the tables on a given page.
  7919. *
  7920. * Note that the `DataTable.settings` object is aliased to
  7921. * `jQuery.fn.dataTableExt` through which it may be accessed and
  7922. * manipulated, or `jQuery.fn.dataTable.settings`.
  7923. * @member
  7924. * @type array
  7925. * @default []
  7926. * @private
  7927. */
  7928. DataTable.settings = [];
  7929. /**
  7930. * Object models container, for the various models that DataTables has
  7931. * available to it. These models define the objects that are used to hold
  7932. * the active state and configuration of the table.
  7933. * @namespace
  7934. */
  7935. DataTable.models = {};
  7936. /**
  7937. * Template object for the way in which DataTables holds information about
  7938. * search information for the global filter and individual column filters.
  7939. * @namespace
  7940. */
  7941. DataTable.models.oSearch = {
  7942. /**
  7943. * Flag to indicate if the filtering should be case insensitive or not
  7944. * @type boolean
  7945. * @default true
  7946. */
  7947. "bCaseInsensitive": true,
  7948. /**
  7949. * Applied search term
  7950. * @type string
  7951. * @default <i>Empty string</i>
  7952. */
  7953. "sSearch": "",
  7954. /**
  7955. * Flag to indicate if the search term should be interpreted as a
  7956. * regular expression (true) or not (false) and therefore and special
  7957. * regex characters escaped.
  7958. * @type boolean
  7959. * @default false
  7960. */
  7961. "bRegex": false,
  7962. /**
  7963. * Flag to indicate if DataTables is to use its smart filtering or not.
  7964. * @type boolean
  7965. * @default true
  7966. */
  7967. "bSmart": true
  7968. };
  7969. /**
  7970. * Template object for the way in which DataTables holds information about
  7971. * each individual row. This is the object format used for the settings
  7972. * aoData array.
  7973. * @namespace
  7974. */
  7975. DataTable.models.oRow = {
  7976. /**
  7977. * TR element for the row
  7978. * @type node
  7979. * @default null
  7980. */
  7981. "nTr": null,
  7982. /**
  7983. * Array of TD elements for each row. This is null until the row has been
  7984. * created.
  7985. * @type array nodes
  7986. * @default []
  7987. */
  7988. "anCells": null,
  7989. /**
  7990. * Data object from the original data source for the row. This is either
  7991. * an array if using the traditional form of DataTables, or an object if
  7992. * using mData options. The exact type will depend on the passed in
  7993. * data from the data source, or will be an array if using DOM a data
  7994. * source.
  7995. * @type array|object
  7996. * @default []
  7997. */
  7998. "_aData": [],
  7999. /**
  8000. * Sorting data cache - this array is ostensibly the same length as the
  8001. * number of columns (although each index is generated only as it is
  8002. * needed), and holds the data that is used for sorting each column in the
  8003. * row. We do this cache generation at the start of the sort in order that
  8004. * the formatting of the sort data need be done only once for each cell
  8005. * per sort. This array should not be read from or written to by anything
  8006. * other than the master sorting methods.
  8007. * @type array
  8008. * @default null
  8009. * @private
  8010. */
  8011. "_aSortData": null,
  8012. /**
  8013. * Per cell filtering data cache. As per the sort data cache, used to
  8014. * increase the performance of the filtering in DataTables
  8015. * @type array
  8016. * @default null
  8017. * @private
  8018. */
  8019. "_aFilterData": null,
  8020. /**
  8021. * Filtering data cache. This is the same as the cell filtering cache, but
  8022. * in this case a string rather than an array. This is easily computed with
  8023. * a join on `_aFilterData`, but is provided as a cache so the join isn't
  8024. * needed on every search (memory traded for performance)
  8025. * @type array
  8026. * @default null
  8027. * @private
  8028. */
  8029. "_sFilterRow": null,
  8030. /**
  8031. * Cache of the class name that DataTables has applied to the row, so we
  8032. * can quickly look at this variable rather than needing to do a DOM check
  8033. * on className for the nTr property.
  8034. * @type string
  8035. * @default <i>Empty string</i>
  8036. * @private
  8037. */
  8038. "_sRowStripe": "",
  8039. /**
  8040. * Denote if the original data source was from the DOM, or the data source
  8041. * object. This is used for invalidating data, so DataTables can
  8042. * automatically read data from the original source, unless uninstructed
  8043. * otherwise.
  8044. * @type string
  8045. * @default null
  8046. * @private
  8047. */
  8048. "src": null,
  8049. /**
  8050. * Index in the aoData array. This saves an indexOf lookup when we have the
  8051. * object, but want to know the index
  8052. * @type integer
  8053. * @default -1
  8054. * @private
  8055. */
  8056. "idx": -1
  8057. };
  8058. /**
  8059. * Template object for the column information object in DataTables. This object
  8060. * is held in the settings aoColumns array and contains all the information that
  8061. * DataTables needs about each individual column.
  8062. *
  8063. * Note that this object is related to {@link DataTable.defaults.column}
  8064. * but this one is the internal data store for DataTables's cache of columns.
  8065. * It should NOT be manipulated outside of DataTables. Any configuration should
  8066. * be done through the initialisation options.
  8067. * @namespace
  8068. */
  8069. DataTable.models.oColumn = {
  8070. /**
  8071. * Column index. This could be worked out on-the-fly with $.inArray, but it
  8072. * is faster to just hold it as a variable
  8073. * @type integer
  8074. * @default null
  8075. */
  8076. "idx": null,
  8077. /**
  8078. * A list of the columns that sorting should occur on when this column
  8079. * is sorted. That this property is an array allows multi-column sorting
  8080. * to be defined for a column (for example first name / last name columns
  8081. * would benefit from this). The values are integers pointing to the
  8082. * columns to be sorted on (typically it will be a single integer pointing
  8083. * at itself, but that doesn't need to be the case).
  8084. * @type array
  8085. */
  8086. "aDataSort": null,
  8087. /**
  8088. * Define the sorting directions that are applied to the column, in sequence
  8089. * as the column is repeatedly sorted upon - i.e. the first value is used
  8090. * as the sorting direction when the column if first sorted (clicked on).
  8091. * Sort it again (click again) and it will move on to the next index.
  8092. * Repeat until loop.
  8093. * @type array
  8094. */
  8095. "asSorting": null,
  8096. /**
  8097. * Flag to indicate if the column is searchable, and thus should be included
  8098. * in the filtering or not.
  8099. * @type boolean
  8100. */
  8101. "bSearchable": null,
  8102. /**
  8103. * Flag to indicate if the column is sortable or not.
  8104. * @type boolean
  8105. */
  8106. "bSortable": null,
  8107. /**
  8108. * Flag to indicate if the column is currently visible in the table or not
  8109. * @type boolean
  8110. */
  8111. "bVisible": null,
  8112. /**
  8113. * Store for manual type assignment using the `column.type` option. This
  8114. * is held in store so we can manipulate the column's `sType` property.
  8115. * @type string
  8116. * @default null
  8117. * @private
  8118. */
  8119. "_sManualType": null,
  8120. /**
  8121. * Flag to indicate if HTML5 data attributes should be used as the data
  8122. * source for filtering or sorting. True is either are.
  8123. * @type boolean
  8124. * @default false
  8125. * @private
  8126. */
  8127. "_bAttrSrc": false,
  8128. /**
  8129. * Developer definable function that is called whenever a cell is created (Ajax source,
  8130. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  8131. * allowing you to modify the DOM element (add background colour for example) when the
  8132. * element is available.
  8133. * @type function
  8134. * @param {element} nTd The TD node that has been created
  8135. * @param {*} sData The Data for the cell
  8136. * @param {array|object} oData The data for the whole row
  8137. * @param {int} iRow The row index for the aoData data store
  8138. * @default null
  8139. */
  8140. "fnCreatedCell": null,
  8141. /**
  8142. * Function to get data from a cell in a column. You should <b>never</b>
  8143. * access data directly through _aData internally in DataTables - always use
  8144. * the method attached to this property. It allows mData to function as
  8145. * required. This function is automatically assigned by the column
  8146. * initialisation method
  8147. * @type function
  8148. * @param {array|object} oData The data array/object for the array
  8149. * (i.e. aoData[]._aData)
  8150. * @param {string} sSpecific The specific data type you want to get -
  8151. * 'display', 'type' 'filter' 'sort'
  8152. * @returns {*} The data for the cell from the given row's data
  8153. * @default null
  8154. */
  8155. "fnGetData": null,
  8156. /**
  8157. * Function to set data for a cell in the column. You should <b>never</b>
  8158. * set the data directly to _aData internally in DataTables - always use
  8159. * this method. It allows mData to function as required. This function
  8160. * is automatically assigned by the column initialisation method
  8161. * @type function
  8162. * @param {array|object} oData The data array/object for the array
  8163. * (i.e. aoData[]._aData)
  8164. * @param {*} sValue Value to set
  8165. * @default null
  8166. */
  8167. "fnSetData": null,
  8168. /**
  8169. * Property to read the value for the cells in the column from the data
  8170. * source array / object. If null, then the default content is used, if a
  8171. * function is given then the return from the function is used.
  8172. * @type function|int|string|null
  8173. * @default null
  8174. */
  8175. "mData": null,
  8176. /**
  8177. * Partner property to mData which is used (only when defined) to get
  8178. * the data - i.e. it is basically the same as mData, but without the
  8179. * 'set' option, and also the data fed to it is the result from mData.
  8180. * This is the rendering method to match the data method of mData.
  8181. * @type function|int|string|null
  8182. * @default null
  8183. */
  8184. "mRender": null,
  8185. /**
  8186. * Unique header TH/TD element for this column - this is what the sorting
  8187. * listener is attached to (if sorting is enabled.)
  8188. * @type node
  8189. * @default null
  8190. */
  8191. "nTh": null,
  8192. /**
  8193. * Unique footer TH/TD element for this column (if there is one). Not used
  8194. * in DataTables as such, but can be used for plug-ins to reference the
  8195. * footer for each column.
  8196. * @type node
  8197. * @default null
  8198. */
  8199. "nTf": null,
  8200. /**
  8201. * The class to apply to all TD elements in the table's TBODY for the column
  8202. * @type string
  8203. * @default null
  8204. */
  8205. "sClass": null,
  8206. /**
  8207. * When DataTables calculates the column widths to assign to each column,
  8208. * it finds the longest string in each column and then constructs a
  8209. * temporary table and reads the widths from that. The problem with this
  8210. * is that "mmm" is much wider then "iiii", but the latter is a longer
  8211. * string - thus the calculation can go wrong (doing it properly and putting
  8212. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  8213. * a "work around" we provide this option. It will append its value to the
  8214. * text that is found to be the longest string for the column - i.e. padding.
  8215. * @type string
  8216. */
  8217. "sContentPadding": null,
  8218. /**
  8219. * Allows a default value to be given for a column's data, and will be used
  8220. * whenever a null data source is encountered (this can be because mData
  8221. * is set to null, or because the data source itself is null).
  8222. * @type string
  8223. * @default null
  8224. */
  8225. "sDefaultContent": null,
  8226. /**
  8227. * Name for the column, allowing reference to the column by name as well as
  8228. * by index (needs a lookup to work by name).
  8229. * @type string
  8230. */
  8231. "sName": null,
  8232. /**
  8233. * Custom sorting data type - defines which of the available plug-ins in
  8234. * afnSortData the custom sorting will use - if any is defined.
  8235. * @type string
  8236. * @default std
  8237. */
  8238. "sSortDataType": 'std',
  8239. /**
  8240. * Class to be applied to the header element when sorting on this column
  8241. * @type string
  8242. * @default null
  8243. */
  8244. "sSortingClass": null,
  8245. /**
  8246. * Class to be applied to the header element when sorting on this column -
  8247. * when jQuery UI theming is used.
  8248. * @type string
  8249. * @default null
  8250. */
  8251. "sSortingClassJUI": null,
  8252. /**
  8253. * Title of the column - what is seen in the TH element (nTh).
  8254. * @type string
  8255. */
  8256. "sTitle": null,
  8257. /**
  8258. * Column sorting and filtering type
  8259. * @type string
  8260. * @default null
  8261. */
  8262. "sType": null,
  8263. /**
  8264. * Width of the column
  8265. * @type string
  8266. * @default null
  8267. */
  8268. "sWidth": null,
  8269. /**
  8270. * Width of the column when it was first "encountered"
  8271. * @type string
  8272. * @default null
  8273. */
  8274. "sWidthOrig": null
  8275. };
  8276. /*
  8277. * Developer note: The properties of the object below are given in Hungarian
  8278. * notation, that was used as the interface for DataTables prior to v1.10, however
  8279. * from v1.10 onwards the primary interface is camel case. In order to avoid
  8280. * breaking backwards compatibility utterly with this change, the Hungarian
  8281. * version is still, internally the primary interface, but is is not documented
  8282. * - hence the @name tags in each doc comment. This allows a Javascript function
  8283. * to create a map from Hungarian notation to camel case (going the other direction
  8284. * would require each property to be listed, which would at around 3K to the size
  8285. * of DataTables, while this method is about a 0.5K hit.
  8286. *
  8287. * Ultimately this does pave the way for Hungarian notation to be dropped
  8288. * completely, but that is a massive amount of work and will break current
  8289. * installs (therefore is on-hold until v2).
  8290. */
  8291. /**
  8292. * Initialisation options that can be given to DataTables at initialisation
  8293. * time.
  8294. * @namespace
  8295. */
  8296. DataTable.defaults = {
  8297. /**
  8298. * An array of data to use for the table, passed in at initialisation which
  8299. * will be used in preference to any data which is already in the DOM. This is
  8300. * particularly useful for constructing tables purely in Javascript, for
  8301. * example with a custom Ajax call.
  8302. * @type array
  8303. * @default null
  8304. *
  8305. * @dtopt Option
  8306. * @name DataTable.defaults.data
  8307. *
  8308. * @example
  8309. * // Using a 2D array data source
  8310. * $(document).ready( function () {
  8311. * $('#example').dataTable( {
  8312. * "data": [
  8313. * ['Trident', 'Internet Explorer 4.0', 'Win 95+', 4, 'X'],
  8314. * ['Trident', 'Internet Explorer 5.0', 'Win 95+', 5, 'C'],
  8315. * ],
  8316. * "columns": [
  8317. * { "title": "Engine" },
  8318. * { "title": "Browser" },
  8319. * { "title": "Platform" },
  8320. * { "title": "Version" },
  8321. * { "title": "Grade" }
  8322. * ]
  8323. * } );
  8324. * } );
  8325. *
  8326. * @example
  8327. * // Using an array of objects as a data source (`data`)
  8328. * $(document).ready( function () {
  8329. * $('#example').dataTable( {
  8330. * "data": [
  8331. * {
  8332. * "engine": "Trident",
  8333. * "browser": "Internet Explorer 4.0",
  8334. * "platform": "Win 95+",
  8335. * "version": 4,
  8336. * "grade": "X"
  8337. * },
  8338. * {
  8339. * "engine": "Trident",
  8340. * "browser": "Internet Explorer 5.0",
  8341. * "platform": "Win 95+",
  8342. * "version": 5,
  8343. * "grade": "C"
  8344. * }
  8345. * ],
  8346. * "columns": [
  8347. * { "title": "Engine", "data": "engine" },
  8348. * { "title": "Browser", "data": "browser" },
  8349. * { "title": "Platform", "data": "platform" },
  8350. * { "title": "Version", "data": "version" },
  8351. * { "title": "Grade", "data": "grade" }
  8352. * ]
  8353. * } );
  8354. * } );
  8355. */
  8356. "aaData": null,
  8357. /**
  8358. * If ordering is enabled, then DataTables will perform a first pass sort on
  8359. * initialisation. You can define which column(s) the sort is performed
  8360. * upon, and the sorting direction, with this variable. The `sorting` array
  8361. * should contain an array for each column to be sorted initially containing
  8362. * the column's index and a direction string ('asc' or 'desc').
  8363. * @type array
  8364. * @default [[0,'asc']]
  8365. *
  8366. * @dtopt Option
  8367. * @name DataTable.defaults.order
  8368. *
  8369. * @example
  8370. * // Sort by 3rd column first, and then 4th column
  8371. * $(document).ready( function() {
  8372. * $('#example').dataTable( {
  8373. * "order": [[2,'asc'], [3,'desc']]
  8374. * } );
  8375. * } );
  8376. *
  8377. * // No initial sorting
  8378. * $(document).ready( function() {
  8379. * $('#example').dataTable( {
  8380. * "order": []
  8381. * } );
  8382. * } );
  8383. */
  8384. "aaSorting": [[0,'asc']],
  8385. /**
  8386. * This parameter is basically identical to the `sorting` parameter, but
  8387. * cannot be overridden by user interaction with the table. What this means
  8388. * is that you could have a column (visible or hidden) which the sorting
  8389. * will always be forced on first - any sorting after that (from the user)
  8390. * will then be performed as required. This can be useful for grouping rows
  8391. * together.
  8392. * @type array
  8393. * @default null
  8394. *
  8395. * @dtopt Option
  8396. * @name DataTable.defaults.orderFixed
  8397. *
  8398. * @example
  8399. * $(document).ready( function() {
  8400. * $('#example').dataTable( {
  8401. * "orderFixed": [[0,'asc']]
  8402. * } );
  8403. * } )
  8404. */
  8405. "aaSortingFixed": [],
  8406. /**
  8407. * DataTables can be instructed to load data to display in the table from a
  8408. * Ajax source. This option defines how that Ajax call is made and where to.
  8409. *
  8410. * The `ajax` property has three different modes of operation, depending on
  8411. * how it is defined. These are:
  8412. *
  8413. * * `string` - Set the URL from where the data should be loaded from.
  8414. * * `object` - Define properties for `jQuery.ajax`.
  8415. * * `function` - Custom data get function
  8416. *
  8417. * `string`
  8418. * --------
  8419. *
  8420. * As a string, the `ajax` property simply defines the URL from which
  8421. * DataTables will load data.
  8422. *
  8423. * `object`
  8424. * --------
  8425. *
  8426. * As an object, the parameters in the object are passed to
  8427. * [jQuery.ajax](http://api.jquery.com/jQuery.ajax/) allowing fine control
  8428. * of the Ajax request. DataTables has a number of default parameters which
  8429. * you can override using this option. Please refer to the jQuery
  8430. * documentation for a full description of the options available, although
  8431. * the following parameters provide additional options in DataTables or
  8432. * require special consideration:
  8433. *
  8434. * * `data` - As with jQuery, `data` can be provided as an object, but it
  8435. * can also be used as a function to manipulate the data DataTables sends
  8436. * to the server. The function takes a single parameter, an object of
  8437. * parameters with the values that DataTables has readied for sending. An
  8438. * object may be returned which will be merged into the DataTables
  8439. * defaults, or you can add the items to the object that was passed in and
  8440. * not return anything from the function. This supersedes `fnServerParams`
  8441. * from DataTables 1.9-.
  8442. *
  8443. * * `dataSrc` - By default DataTables will look for the property `data` (or
  8444. * `aaData` for compatibility with DataTables 1.9-) when obtaining data
  8445. * from an Ajax source or for server-side processing - this parameter
  8446. * allows that property to be changed. You can use Javascript dotted
  8447. * object notation to get a data source for multiple levels of nesting, or
  8448. * it my be used as a function. As a function it takes a single parameter,
  8449. * the JSON returned from the server, which can be manipulated as
  8450. * required, with the returned value being that used by DataTables as the
  8451. * data source for the table. This supersedes `sAjaxDataProp` from
  8452. * DataTables 1.9-.
  8453. *
  8454. * * `success` - Should not be overridden it is used internally in
  8455. * DataTables. To manipulate / transform the data returned by the server
  8456. * use `ajax.dataSrc`, or use `ajax` as a function (see below).
  8457. *
  8458. * `function`
  8459. * ----------
  8460. *
  8461. * As a function, making the Ajax call is left up to yourself allowing
  8462. * complete control of the Ajax request. Indeed, if desired, a method other
  8463. * than Ajax could be used to obtain the required data, such as Web storage
  8464. * or an AIR database.
  8465. *
  8466. * The function is given four parameters and no return is required. The
  8467. * parameters are:
  8468. *
  8469. * 1. _object_ - Data to send to the server
  8470. * 2. _function_ - Callback function that must be executed when the required
  8471. * data has been obtained. That data should be passed into the callback
  8472. * as the only parameter
  8473. * 3. _object_ - DataTables settings object for the table
  8474. *
  8475. * Note that this supersedes `fnServerData` from DataTables 1.9-.
  8476. *
  8477. * @type string|object|function
  8478. * @default null
  8479. *
  8480. * @dtopt Option
  8481. * @name DataTable.defaults.ajax
  8482. * @since 1.10.0
  8483. *
  8484. * @example
  8485. * // Get JSON data from a file via Ajax.
  8486. * // Note DataTables expects data in the form `{ data: [ ...data... ] }` by default).
  8487. * $('#example').dataTable( {
  8488. * "ajax": "data.json"
  8489. * } );
  8490. *
  8491. * @example
  8492. * // Get JSON data from a file via Ajax, using `dataSrc` to change
  8493. * // `data` to `tableData` (i.e. `{ tableData: [ ...data... ] }`)
  8494. * $('#example').dataTable( {
  8495. * "ajax": {
  8496. * "url": "data.json",
  8497. * "dataSrc": "tableData"
  8498. * }
  8499. * } );
  8500. *
  8501. * @example
  8502. * // Get JSON data from a file via Ajax, using `dataSrc` to read data
  8503. * // from a plain array rather than an array in an object
  8504. * $('#example').dataTable( {
  8505. * "ajax": {
  8506. * "url": "data.json",
  8507. * "dataSrc": ""
  8508. * }
  8509. * } );
  8510. *
  8511. * @example
  8512. * // Manipulate the data returned from the server - add a link to data
  8513. * // (note this can, should, be done using `render` for the column - this
  8514. * // is just a simple example of how the data can be manipulated).
  8515. * $('#example').dataTable( {
  8516. * "ajax": {
  8517. * "url": "data.json",
  8518. * "dataSrc": function ( json ) {
  8519. * for ( var i=0, ien=json.length ; i<ien ; i++ ) {
  8520. * json[i][0] = '<a href="/message/'+json[i][0]+'>View message</a>';
  8521. * }
  8522. * return json;
  8523. * }
  8524. * }
  8525. * } );
  8526. *
  8527. * @example
  8528. * // Add data to the request
  8529. * $('#example').dataTable( {
  8530. * "ajax": {
  8531. * "url": "data.json",
  8532. * "data": function ( d ) {
  8533. * return {
  8534. * "extra_search": $('#extra').val()
  8535. * };
  8536. * }
  8537. * }
  8538. * } );
  8539. *
  8540. * @example
  8541. * // Send request as POST
  8542. * $('#example').dataTable( {
  8543. * "ajax": {
  8544. * "url": "data.json",
  8545. * "type": "POST"
  8546. * }
  8547. * } );
  8548. *
  8549. * @example
  8550. * // Get the data from localStorage (could interface with a form for
  8551. * // adding, editing and removing rows).
  8552. * $('#example').dataTable( {
  8553. * "ajax": function (data, callback, settings) {
  8554. * callback(
  8555. * JSON.parse( localStorage.getItem('dataTablesData') )
  8556. * );
  8557. * }
  8558. * } );
  8559. */
  8560. "ajax": null,
  8561. /**
  8562. * This parameter allows you to readily specify the entries in the length drop
  8563. * down menu that DataTables shows when pagination is enabled. It can be
  8564. * either a 1D array of options which will be used for both the displayed
  8565. * option and the value, or a 2D array which will use the array in the first
  8566. * position as the value, and the array in the second position as the
  8567. * displayed options (useful for language strings such as 'All').
  8568. *
  8569. * Note that the `pageLength` property will be automatically set to the
  8570. * first value given in this array, unless `pageLength` is also provided.
  8571. * @type array
  8572. * @default [ 10, 25, 50, 100 ]
  8573. *
  8574. * @dtopt Option
  8575. * @name DataTable.defaults.lengthMenu
  8576. *
  8577. * @example
  8578. * $(document).ready( function() {
  8579. * $('#example').dataTable( {
  8580. * "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
  8581. * } );
  8582. * } );
  8583. */
  8584. "aLengthMenu": [ 10, 25, 50, 100 ],
  8585. /**
  8586. * The `columns` option in the initialisation parameter allows you to define
  8587. * details about the way individual columns behave. For a full list of
  8588. * column options that can be set, please see
  8589. * {@link DataTable.defaults.column}. Note that if you use `columns` to
  8590. * define your columns, you must have an entry in the array for every single
  8591. * column that you have in your table (these can be null if you don't which
  8592. * to specify any options).
  8593. * @member
  8594. *
  8595. * @name DataTable.defaults.column
  8596. */
  8597. "aoColumns": null,
  8598. /**
  8599. * Very similar to `columns`, `columnDefs` allows you to target a specific
  8600. * column, multiple columns, or all columns, using the `targets` property of
  8601. * each object in the array. This allows great flexibility when creating
  8602. * tables, as the `columnDefs` arrays can be of any length, targeting the
  8603. * columns you specifically want. `columnDefs` may use any of the column
  8604. * options available: {@link DataTable.defaults.column}, but it _must_
  8605. * have `targets` defined in each object in the array. Values in the `targets`
  8606. * array may be:
  8607. * <ul>
  8608. * <li>a string - class name will be matched on the TH for the column</li>
  8609. * <li>0 or a positive integer - column index counting from the left</li>
  8610. * <li>a negative integer - column index counting from the right</li>
  8611. * <li>the string "_all" - all columns (i.e. assign a default)</li>
  8612. * </ul>
  8613. * @member
  8614. *
  8615. * @name DataTable.defaults.columnDefs
  8616. */
  8617. "aoColumnDefs": null,
  8618. /**
  8619. * Basically the same as `search`, this parameter defines the individual column
  8620. * filtering state at initialisation time. The array must be of the same size
  8621. * as the number of columns, and each element be an object with the parameters
  8622. * `search` and `escapeRegex` (the latter is optional). 'null' is also
  8623. * accepted and the default will be used.
  8624. * @type array
  8625. * @default []
  8626. *
  8627. * @dtopt Option
  8628. * @name DataTable.defaults.searchCols
  8629. *
  8630. * @example
  8631. * $(document).ready( function() {
  8632. * $('#example').dataTable( {
  8633. * "searchCols": [
  8634. * null,
  8635. * { "search": "My filter" },
  8636. * null,
  8637. * { "search": "^[0-9]", "escapeRegex": false }
  8638. * ]
  8639. * } );
  8640. * } )
  8641. */
  8642. "aoSearchCols": [],
  8643. /**
  8644. * An array of CSS classes that should be applied to displayed rows. This
  8645. * array may be of any length, and DataTables will apply each class
  8646. * sequentially, looping when required.
  8647. * @type array
  8648. * @default null <i>Will take the values determined by the `oClasses.stripe*`
  8649. * options</i>
  8650. *
  8651. * @dtopt Option
  8652. * @name DataTable.defaults.stripeClasses
  8653. *
  8654. * @example
  8655. * $(document).ready( function() {
  8656. * $('#example').dataTable( {
  8657. * "stripeClasses": [ 'strip1', 'strip2', 'strip3' ]
  8658. * } );
  8659. * } )
  8660. */
  8661. "asStripeClasses": null,
  8662. /**
  8663. * Enable or disable automatic column width calculation. This can be disabled
  8664. * as an optimisation (it takes some time to calculate the widths) if the
  8665. * tables widths are passed in using `columns`.
  8666. * @type boolean
  8667. * @default true
  8668. *
  8669. * @dtopt Features
  8670. * @name DataTable.defaults.autoWidth
  8671. *
  8672. * @example
  8673. * $(document).ready( function () {
  8674. * $('#example').dataTable( {
  8675. * "autoWidth": false
  8676. * } );
  8677. * } );
  8678. */
  8679. "bAutoWidth": true,
  8680. /**
  8681. * Deferred rendering can provide DataTables with a huge speed boost when you
  8682. * are using an Ajax or JS data source for the table. This option, when set to
  8683. * true, will cause DataTables to defer the creation of the table elements for
  8684. * each row until they are needed for a draw - saving a significant amount of
  8685. * time.
  8686. * @type boolean
  8687. * @default false
  8688. *
  8689. * @dtopt Features
  8690. * @name DataTable.defaults.deferRender
  8691. *
  8692. * @example
  8693. * $(document).ready( function() {
  8694. * $('#example').dataTable( {
  8695. * "ajax": "sources/arrays.txt",
  8696. * "deferRender": true
  8697. * } );
  8698. * } );
  8699. */
  8700. "bDeferRender": false,
  8701. /**
  8702. * Replace a DataTable which matches the given selector and replace it with
  8703. * one which has the properties of the new initialisation object passed. If no
  8704. * table matches the selector, then the new DataTable will be constructed as
  8705. * per normal.
  8706. * @type boolean
  8707. * @default false
  8708. *
  8709. * @dtopt Options
  8710. * @name DataTable.defaults.destroy
  8711. *
  8712. * @example
  8713. * $(document).ready( function() {
  8714. * $('#example').dataTable( {
  8715. * "srollY": "200px",
  8716. * "paginate": false
  8717. * } );
  8718. *
  8719. * // Some time later....
  8720. * $('#example').dataTable( {
  8721. * "filter": false,
  8722. * "destroy": true
  8723. * } );
  8724. * } );
  8725. */
  8726. "bDestroy": false,
  8727. /**
  8728. * Enable or disable filtering of data. Filtering in DataTables is "smart" in
  8729. * that it allows the end user to input multiple words (space separated) and
  8730. * will match a row containing those words, even if not in the order that was
  8731. * specified (this allow matching across multiple columns). Note that if you
  8732. * wish to use filtering in DataTables this must remain 'true' - to remove the
  8733. * default filtering input box and retain filtering abilities, please use
  8734. * {@link DataTable.defaults.dom}.
  8735. * @type boolean
  8736. * @default true
  8737. *
  8738. * @dtopt Features
  8739. * @name DataTable.defaults.searching
  8740. *
  8741. * @example
  8742. * $(document).ready( function () {
  8743. * $('#example').dataTable( {
  8744. * "searching": false
  8745. * } );
  8746. * } );
  8747. */
  8748. "bFilter": true,
  8749. /**
  8750. * Enable or disable the table information display. This shows information
  8751. * about the data that is currently visible on the page, including information
  8752. * about filtered data if that action is being performed.
  8753. * @type boolean
  8754. * @default true
  8755. *
  8756. * @dtopt Features
  8757. * @name DataTable.defaults.info
  8758. *
  8759. * @example
  8760. * $(document).ready( function () {
  8761. * $('#example').dataTable( {
  8762. * "info": false
  8763. * } );
  8764. * } );
  8765. */
  8766. "bInfo": true,
  8767. /**
  8768. * Enable jQuery UI ThemeRoller support (required as ThemeRoller requires some
  8769. * slightly different and additional mark-up from what DataTables has
  8770. * traditionally used).
  8771. * @type boolean
  8772. * @default false
  8773. *
  8774. * @dtopt Features
  8775. * @name DataTable.defaults.jQueryUI
  8776. *
  8777. * @example
  8778. * $(document).ready( function() {
  8779. * $('#example').dataTable( {
  8780. * "jQueryUI": true
  8781. * } );
  8782. * } );
  8783. */
  8784. "bJQueryUI": false,
  8785. /**
  8786. * Allows the end user to select the size of a formatted page from a select
  8787. * menu (sizes are 10, 25, 50 and 100). Requires pagination (`paginate`).
  8788. * @type boolean
  8789. * @default true
  8790. *
  8791. * @dtopt Features
  8792. * @name DataTable.defaults.lengthChange
  8793. *
  8794. * @example
  8795. * $(document).ready( function () {
  8796. * $('#example').dataTable( {
  8797. * "lengthChange": false
  8798. * } );
  8799. * } );
  8800. */
  8801. "bLengthChange": true,
  8802. /**
  8803. * Enable or disable pagination.
  8804. * @type boolean
  8805. * @default true
  8806. *
  8807. * @dtopt Features
  8808. * @name DataTable.defaults.paging
  8809. *
  8810. * @example
  8811. * $(document).ready( function () {
  8812. * $('#example').dataTable( {
  8813. * "paging": false
  8814. * } );
  8815. * } );
  8816. */
  8817. "bPaginate": true,
  8818. /**
  8819. * Enable or disable the display of a 'processing' indicator when the table is
  8820. * being processed (e.g. a sort). This is particularly useful for tables with
  8821. * large amounts of data where it can take a noticeable amount of time to sort
  8822. * the entries.
  8823. * @type boolean
  8824. * @default false
  8825. *
  8826. * @dtopt Features
  8827. * @name DataTable.defaults.processing
  8828. *
  8829. * @example
  8830. * $(document).ready( function () {
  8831. * $('#example').dataTable( {
  8832. * "processing": true
  8833. * } );
  8834. * } );
  8835. */
  8836. "bProcessing": false,
  8837. /**
  8838. * Retrieve the DataTables object for the given selector. Note that if the
  8839. * table has already been initialised, this parameter will cause DataTables
  8840. * to simply return the object that has already been set up - it will not take
  8841. * account of any changes you might have made to the initialisation object
  8842. * passed to DataTables (setting this parameter to true is an acknowledgement
  8843. * that you understand this). `destroy` can be used to reinitialise a table if
  8844. * you need.
  8845. * @type boolean
  8846. * @default false
  8847. *
  8848. * @dtopt Options
  8849. * @name DataTable.defaults.retrieve
  8850. *
  8851. * @example
  8852. * $(document).ready( function() {
  8853. * initTable();
  8854. * tableActions();
  8855. * } );
  8856. *
  8857. * function initTable ()
  8858. * {
  8859. * return $('#example').dataTable( {
  8860. * "scrollY": "200px",
  8861. * "paginate": false,
  8862. * "retrieve": true
  8863. * } );
  8864. * }
  8865. *
  8866. * function tableActions ()
  8867. * {
  8868. * var table = initTable();
  8869. * // perform API operations with oTable
  8870. * }
  8871. */
  8872. "bRetrieve": false,
  8873. /**
  8874. * When vertical (y) scrolling is enabled, DataTables will force the height of
  8875. * the table's viewport to the given height at all times (useful for layout).
  8876. * However, this can look odd when filtering data down to a small data set,
  8877. * and the footer is left "floating" further down. This parameter (when
  8878. * enabled) will cause DataTables to collapse the table's viewport down when
  8879. * the result set will fit within the given Y height.
  8880. * @type boolean
  8881. * @default false
  8882. *
  8883. * @dtopt Options
  8884. * @name DataTable.defaults.scrollCollapse
  8885. *
  8886. * @example
  8887. * $(document).ready( function() {
  8888. * $('#example').dataTable( {
  8889. * "scrollY": "200",
  8890. * "scrollCollapse": true
  8891. * } );
  8892. * } );
  8893. */
  8894. "bScrollCollapse": false,
  8895. /**
  8896. * Configure DataTables to use server-side processing. Note that the
  8897. * `ajax` parameter must also be given in order to give DataTables a
  8898. * source to obtain the required data for each draw.
  8899. * @type boolean
  8900. * @default false
  8901. *
  8902. * @dtopt Features
  8903. * @dtopt Server-side
  8904. * @name DataTable.defaults.serverSide
  8905. *
  8906. * @example
  8907. * $(document).ready( function () {
  8908. * $('#example').dataTable( {
  8909. * "serverSide": true,
  8910. * "ajax": "xhr.php"
  8911. * } );
  8912. * } );
  8913. */
  8914. "bServerSide": false,
  8915. /**
  8916. * Enable or disable sorting of columns. Sorting of individual columns can be
  8917. * disabled by the `sortable` option for each column.
  8918. * @type boolean
  8919. * @default true
  8920. *
  8921. * @dtopt Features
  8922. * @name DataTable.defaults.ordering
  8923. *
  8924. * @example
  8925. * $(document).ready( function () {
  8926. * $('#example').dataTable( {
  8927. * "ordering": false
  8928. * } );
  8929. * } );
  8930. */
  8931. "bSort": true,
  8932. /**
  8933. * Enable or display DataTables' ability to sort multiple columns at the
  8934. * same time (activated by shift-click by the user).
  8935. * @type boolean
  8936. * @default true
  8937. *
  8938. * @dtopt Options
  8939. * @name DataTable.defaults.orderMulti
  8940. *
  8941. * @example
  8942. * // Disable multiple column sorting ability
  8943. * $(document).ready( function () {
  8944. * $('#example').dataTable( {
  8945. * "orderMulti": false
  8946. * } );
  8947. * } );
  8948. */
  8949. "bSortMulti": true,
  8950. /**
  8951. * Allows control over whether DataTables should use the top (true) unique
  8952. * cell that is found for a single column, or the bottom (false - default).
  8953. * This is useful when using complex headers.
  8954. * @type boolean
  8955. * @default false
  8956. *
  8957. * @dtopt Options
  8958. * @name DataTable.defaults.orderCellsTop
  8959. *
  8960. * @example
  8961. * $(document).ready( function() {
  8962. * $('#example').dataTable( {
  8963. * "orderCellsTop": true
  8964. * } );
  8965. * } );
  8966. */
  8967. "bSortCellsTop": false,
  8968. /**
  8969. * Enable or disable the addition of the classes `sorting\_1`, `sorting\_2` and
  8970. * `sorting\_3` to the columns which are currently being sorted on. This is
  8971. * presented as a feature switch as it can increase processing time (while
  8972. * classes are removed and added) so for large data sets you might want to
  8973. * turn this off.
  8974. * @type boolean
  8975. * @default true
  8976. *
  8977. * @dtopt Features
  8978. * @name DataTable.defaults.orderClasses
  8979. *
  8980. * @example
  8981. * $(document).ready( function () {
  8982. * $('#example').dataTable( {
  8983. * "orderClasses": false
  8984. * } );
  8985. * } );
  8986. */
  8987. "bSortClasses": true,
  8988. /**
  8989. * Enable or disable state saving. When enabled HTML5 `localStorage` will be
  8990. * used to save table display information such as pagination information,
  8991. * display length, filtering and sorting. As such when the end user reloads
  8992. * the page the display display will match what thy had previously set up.
  8993. *
  8994. * Due to the use of `localStorage` the default state saving is not supported
  8995. * in IE6 or 7. If state saving is required in those browsers, use
  8996. * `stateSaveCallback` to provide a storage solution such as cookies.
  8997. * @type boolean
  8998. * @default false
  8999. *
  9000. * @dtopt Features
  9001. * @name DataTable.defaults.stateSave
  9002. *
  9003. * @example
  9004. * $(document).ready( function () {
  9005. * $('#example').dataTable( {
  9006. * "stateSave": true
  9007. * } );
  9008. * } );
  9009. */
  9010. "bStateSave": false,
  9011. /**
  9012. * This function is called when a TR element is created (and all TD child
  9013. * elements have been inserted), or registered if using a DOM source, allowing
  9014. * manipulation of the TR element (adding classes etc).
  9015. * @type function
  9016. * @param {node} row "TR" element for the current row
  9017. * @param {array} data Raw data array for this row
  9018. * @param {int} dataIndex The index of this row in the internal aoData array
  9019. *
  9020. * @dtopt Callbacks
  9021. * @name DataTable.defaults.createdRow
  9022. *
  9023. * @example
  9024. * $(document).ready( function() {
  9025. * $('#example').dataTable( {
  9026. * "createdRow": function( row, data, dataIndex ) {
  9027. * // Bold the grade for all 'A' grade browsers
  9028. * if ( data[4] == "A" )
  9029. * {
  9030. * $('td:eq(4)', row).html( '<b>A</b>' );
  9031. * }
  9032. * }
  9033. * } );
  9034. * } );
  9035. */
  9036. "fnCreatedRow": null,
  9037. /**
  9038. * This function is called on every 'draw' event, and allows you to
  9039. * dynamically modify any aspect you want about the created DOM.
  9040. * @type function
  9041. * @param {object} settings DataTables settings object
  9042. *
  9043. * @dtopt Callbacks
  9044. * @name DataTable.defaults.drawCallback
  9045. *
  9046. * @example
  9047. * $(document).ready( function() {
  9048. * $('#example').dataTable( {
  9049. * "drawCallback": function( settings ) {
  9050. * alert( 'DataTables has redrawn the table' );
  9051. * }
  9052. * } );
  9053. * } );
  9054. */
  9055. "fnDrawCallback": null,
  9056. /**
  9057. * Identical to fnHeaderCallback() but for the table footer this function
  9058. * allows you to modify the table footer on every 'draw' event.
  9059. * @type function
  9060. * @param {node} foot "TR" element for the footer
  9061. * @param {array} data Full table data (as derived from the original HTML)
  9062. * @param {int} start Index for the current display starting point in the
  9063. * display array
  9064. * @param {int} end Index for the current display ending point in the
  9065. * display array
  9066. * @param {array int} display Index array to translate the visual position
  9067. * to the full data array
  9068. *
  9069. * @dtopt Callbacks
  9070. * @name DataTable.defaults.footerCallback
  9071. *
  9072. * @example
  9073. * $(document).ready( function() {
  9074. * $('#example').dataTable( {
  9075. * "footerCallback": function( tfoot, data, start, end, display ) {
  9076. * tfoot.getElementsByTagName('th')[0].innerHTML = "Starting index is "+start;
  9077. * }
  9078. * } );
  9079. * } )
  9080. */
  9081. "fnFooterCallback": null,
  9082. /**
  9083. * When rendering large numbers in the information element for the table
  9084. * (i.e. "Showing 1 to 10 of 57 entries") DataTables will render large numbers
  9085. * to have a comma separator for the 'thousands' units (e.g. 1 million is
  9086. * rendered as "1,000,000") to help readability for the end user. This
  9087. * function will override the default method DataTables uses.
  9088. * @type function
  9089. * @member
  9090. * @param {int} toFormat number to be formatted
  9091. * @returns {string} formatted string for DataTables to show the number
  9092. *
  9093. * @dtopt Callbacks
  9094. * @name DataTable.defaults.formatNumber
  9095. *
  9096. * @example
  9097. * // Format a number using a single quote for the separator (note that
  9098. * // this can also be done with the language.thousands option)
  9099. * $(document).ready( function() {
  9100. * $('#example').dataTable( {
  9101. * "formatNumber": function ( toFormat ) {
  9102. * return toFormat.toString().replace(
  9103. * /\B(?=(\d{3})+(?!\d))/g, "'"
  9104. * );
  9105. * };
  9106. * } );
  9107. * } );
  9108. */
  9109. "fnFormatNumber": function ( toFormat ) {
  9110. return toFormat.toString().replace(
  9111. /\B(?=(\d{3})+(?!\d))/g,
  9112. this.oLanguage.sThousands
  9113. );
  9114. },
  9115. /**
  9116. * This function is called on every 'draw' event, and allows you to
  9117. * dynamically modify the header row. This can be used to calculate and
  9118. * display useful information about the table.
  9119. * @type function
  9120. * @param {node} head "TR" element for the header
  9121. * @param {array} data Full table data (as derived from the original HTML)
  9122. * @param {int} start Index for the current display starting point in the
  9123. * display array
  9124. * @param {int} end Index for the current display ending point in the
  9125. * display array
  9126. * @param {array int} display Index array to translate the visual position
  9127. * to the full data array
  9128. *
  9129. * @dtopt Callbacks
  9130. * @name DataTable.defaults.headerCallback
  9131. *
  9132. * @example
  9133. * $(document).ready( function() {
  9134. * $('#example').dataTable( {
  9135. * "fheaderCallback": function( head, data, start, end, display ) {
  9136. * head.getElementsByTagName('th')[0].innerHTML = "Displaying "+(end-start)+" records";
  9137. * }
  9138. * } );
  9139. * } )
  9140. */
  9141. "fnHeaderCallback": null,
  9142. /**
  9143. * The information element can be used to convey information about the current
  9144. * state of the table. Although the internationalisation options presented by
  9145. * DataTables are quite capable of dealing with most customisations, there may
  9146. * be times where you wish to customise the string further. This callback
  9147. * allows you to do exactly that.
  9148. * @type function
  9149. * @param {object} oSettings DataTables settings object
  9150. * @param {int} start Starting position in data for the draw
  9151. * @param {int} end End position in data for the draw
  9152. * @param {int} max Total number of rows in the table (regardless of
  9153. * filtering)
  9154. * @param {int} total Total number of rows in the data set, after filtering
  9155. * @param {string} pre The string that DataTables has formatted using it's
  9156. * own rules
  9157. * @returns {string} The string to be displayed in the information element.
  9158. *
  9159. * @dtopt Callbacks
  9160. * @name DataTable.defaults.infoCallback
  9161. *
  9162. * @example
  9163. * $('#example').dataTable( {
  9164. * "infoCallback": function( settings, start, end, max, total, pre ) {
  9165. * return start +" to "+ end;
  9166. * }
  9167. * } );
  9168. */
  9169. "fnInfoCallback": null,
  9170. /**
  9171. * Called when the table has been initialised. Normally DataTables will
  9172. * initialise sequentially and there will be no need for this function,
  9173. * however, this does not hold true when using external language information
  9174. * since that is obtained using an async XHR call.
  9175. * @type function
  9176. * @param {object} settings DataTables settings object
  9177. * @param {object} json The JSON object request from the server - only
  9178. * present if client-side Ajax sourced data is used
  9179. *
  9180. * @dtopt Callbacks
  9181. * @name DataTable.defaults.initComplete
  9182. *
  9183. * @example
  9184. * $(document).ready( function() {
  9185. * $('#example').dataTable( {
  9186. * "initComplete": function(settings, json) {
  9187. * alert( 'DataTables has finished its initialisation.' );
  9188. * }
  9189. * } );
  9190. * } )
  9191. */
  9192. "fnInitComplete": null,
  9193. /**
  9194. * Called at the very start of each table draw and can be used to cancel the
  9195. * draw by returning false, any other return (including undefined) results in
  9196. * the full draw occurring).
  9197. * @type function
  9198. * @param {object} settings DataTables settings object
  9199. * @returns {boolean} False will cancel the draw, anything else (including no
  9200. * return) will allow it to complete.
  9201. *
  9202. * @dtopt Callbacks
  9203. * @name DataTable.defaults.preDrawCallback
  9204. *
  9205. * @example
  9206. * $(document).ready( function() {
  9207. * $('#example').dataTable( {
  9208. * "preDrawCallback": function( settings ) {
  9209. * if ( $('#test').val() == 1 ) {
  9210. * return false;
  9211. * }
  9212. * }
  9213. * } );
  9214. * } );
  9215. */
  9216. "fnPreDrawCallback": null,
  9217. /**
  9218. * This function allows you to 'post process' each row after it have been
  9219. * generated for each table draw, but before it is rendered on screen. This
  9220. * function might be used for setting the row class name etc.
  9221. * @type function
  9222. * @param {node} row "TR" element for the current row
  9223. * @param {array} data Raw data array for this row
  9224. * @param {int} displayIndex The display index for the current table draw
  9225. * @param {int} displayIndexFull The index of the data in the full list of
  9226. * rows (after filtering)
  9227. *
  9228. * @dtopt Callbacks
  9229. * @name DataTable.defaults.rowCallback
  9230. *
  9231. * @example
  9232. * $(document).ready( function() {
  9233. * $('#example').dataTable( {
  9234. * "rowCallback": function( row, data, displayIndex, displayIndexFull ) {
  9235. * // Bold the grade for all 'A' grade browsers
  9236. * if ( data[4] == "A" ) {
  9237. * $('td:eq(4)', row).html( '<b>A</b>' );
  9238. * }
  9239. * }
  9240. * } );
  9241. * } );
  9242. */
  9243. "fnRowCallback": null,
  9244. /**
  9245. * __Deprecated__ The functionality provided by this parameter has now been
  9246. * superseded by that provided through `ajax`, which should be used instead.
  9247. *
  9248. * This parameter allows you to override the default function which obtains
  9249. * the data from the server so something more suitable for your application.
  9250. * For example you could use POST data, or pull information from a Gears or
  9251. * AIR database.
  9252. * @type function
  9253. * @member
  9254. * @param {string} source HTTP source to obtain the data from (`ajax`)
  9255. * @param {array} data A key/value pair object containing the data to send
  9256. * to the server
  9257. * @param {function} callback to be called on completion of the data get
  9258. * process that will draw the data on the page.
  9259. * @param {object} settings DataTables settings object
  9260. *
  9261. * @dtopt Callbacks
  9262. * @dtopt Server-side
  9263. * @name DataTable.defaults.serverData
  9264. *
  9265. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9266. */
  9267. "fnServerData": null,
  9268. /**
  9269. * __Deprecated__ The functionality provided by this parameter has now been
  9270. * superseded by that provided through `ajax`, which should be used instead.
  9271. *
  9272. * It is often useful to send extra data to the server when making an Ajax
  9273. * request - for example custom filtering information, and this callback
  9274. * function makes it trivial to send extra information to the server. The
  9275. * passed in parameter is the data set that has been constructed by
  9276. * DataTables, and you can add to this or modify it as you require.
  9277. * @type function
  9278. * @param {array} data Data array (array of objects which are name/value
  9279. * pairs) that has been constructed by DataTables and will be sent to the
  9280. * server. In the case of Ajax sourced data with server-side processing
  9281. * this will be an empty array, for server-side processing there will be a
  9282. * significant number of parameters!
  9283. * @returns {undefined} Ensure that you modify the data array passed in,
  9284. * as this is passed by reference.
  9285. *
  9286. * @dtopt Callbacks
  9287. * @dtopt Server-side
  9288. * @name DataTable.defaults.serverParams
  9289. *
  9290. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9291. */
  9292. "fnServerParams": null,
  9293. /**
  9294. * Load the table state. With this function you can define from where, and how, the
  9295. * state of a table is loaded. By default DataTables will load from `localStorage`
  9296. * but you might wish to use a server-side database or cookies.
  9297. * @type function
  9298. * @member
  9299. * @param {object} settings DataTables settings object
  9300. * @return {object} The DataTables state object to be loaded
  9301. *
  9302. * @dtopt Callbacks
  9303. * @name DataTable.defaults.stateLoadCallback
  9304. *
  9305. * @example
  9306. * $(document).ready( function() {
  9307. * $('#example').dataTable( {
  9308. * "stateSave": true,
  9309. * "stateLoadCallback": function (settings) {
  9310. * var o;
  9311. *
  9312. * // Send an Ajax request to the server to get the data. Note that
  9313. * // this is a synchronous request.
  9314. * $.ajax( {
  9315. * "url": "/state_load",
  9316. * "async": false,
  9317. * "dataType": "json",
  9318. * "success": function (json) {
  9319. * o = json;
  9320. * }
  9321. * } );
  9322. *
  9323. * return o;
  9324. * }
  9325. * } );
  9326. * } );
  9327. */
  9328. "fnStateLoadCallback": function ( settings ) {
  9329. try {
  9330. return JSON.parse(
  9331. (settings.iStateDuration === -1 ? sessionStorage : localStorage).getItem(
  9332. 'DataTables_'+settings.sInstance+'_'+location.pathname
  9333. )
  9334. );
  9335. } catch (e) {}
  9336. },
  9337. /**
  9338. * Callback which allows modification of the saved state prior to loading that state.
  9339. * This callback is called when the table is loading state from the stored data, but
  9340. * prior to the settings object being modified by the saved state. Note that for
  9341. * plug-in authors, you should use the `stateLoadParams` event to load parameters for
  9342. * a plug-in.
  9343. * @type function
  9344. * @param {object} settings DataTables settings object
  9345. * @param {object} data The state object that is to be loaded
  9346. *
  9347. * @dtopt Callbacks
  9348. * @name DataTable.defaults.stateLoadParams
  9349. *
  9350. * @example
  9351. * // Remove a saved filter, so filtering is never loaded
  9352. * $(document).ready( function() {
  9353. * $('#example').dataTable( {
  9354. * "stateSave": true,
  9355. * "stateLoadParams": function (settings, data) {
  9356. * data.oSearch.sSearch = "";
  9357. * }
  9358. * } );
  9359. * } );
  9360. *
  9361. * @example
  9362. * // Disallow state loading by returning false
  9363. * $(document).ready( function() {
  9364. * $('#example').dataTable( {
  9365. * "stateSave": true,
  9366. * "stateLoadParams": function (settings, data) {
  9367. * return false;
  9368. * }
  9369. * } );
  9370. * } );
  9371. */
  9372. "fnStateLoadParams": null,
  9373. /**
  9374. * Callback that is called when the state has been loaded from the state saving method
  9375. * and the DataTables settings object has been modified as a result of the loaded state.
  9376. * @type function
  9377. * @param {object} settings DataTables settings object
  9378. * @param {object} data The state object that was loaded
  9379. *
  9380. * @dtopt Callbacks
  9381. * @name DataTable.defaults.stateLoaded
  9382. *
  9383. * @example
  9384. * // Show an alert with the filtering value that was saved
  9385. * $(document).ready( function() {
  9386. * $('#example').dataTable( {
  9387. * "stateSave": true,
  9388. * "stateLoaded": function (settings, data) {
  9389. * alert( 'Saved filter was: '+data.oSearch.sSearch );
  9390. * }
  9391. * } );
  9392. * } );
  9393. */
  9394. "fnStateLoaded": null,
  9395. /**
  9396. * Save the table state. This function allows you to define where and how the state
  9397. * information for the table is stored By default DataTables will use `localStorage`
  9398. * but you might wish to use a server-side database or cookies.
  9399. * @type function
  9400. * @member
  9401. * @param {object} settings DataTables settings object
  9402. * @param {object} data The state object to be saved
  9403. *
  9404. * @dtopt Callbacks
  9405. * @name DataTable.defaults.stateSaveCallback
  9406. *
  9407. * @example
  9408. * $(document).ready( function() {
  9409. * $('#example').dataTable( {
  9410. * "stateSave": true,
  9411. * "stateSaveCallback": function (settings, data) {
  9412. * // Send an Ajax request to the server with the state object
  9413. * $.ajax( {
  9414. * "url": "/state_save",
  9415. * "data": data,
  9416. * "dataType": "json",
  9417. * "method": "POST"
  9418. * "success": function () {}
  9419. * } );
  9420. * }
  9421. * } );
  9422. * } );
  9423. */
  9424. "fnStateSaveCallback": function ( settings, data ) {
  9425. try {
  9426. (settings.iStateDuration === -1 ? sessionStorage : localStorage).setItem(
  9427. 'DataTables_'+settings.sInstance+'_'+location.pathname,
  9428. JSON.stringify( data )
  9429. );
  9430. } catch (e) {}
  9431. },
  9432. /**
  9433. * Callback which allows modification of the state to be saved. Called when the table
  9434. * has changed state a new state save is required. This method allows modification of
  9435. * the state saving object prior to actually doing the save, including addition or
  9436. * other state properties or modification. Note that for plug-in authors, you should
  9437. * use the `stateSaveParams` event to save parameters for a plug-in.
  9438. * @type function
  9439. * @param {object} settings DataTables settings object
  9440. * @param {object} data The state object to be saved
  9441. *
  9442. * @dtopt Callbacks
  9443. * @name DataTable.defaults.stateSaveParams
  9444. *
  9445. * @example
  9446. * // Remove a saved filter, so filtering is never saved
  9447. * $(document).ready( function() {
  9448. * $('#example').dataTable( {
  9449. * "stateSave": true,
  9450. * "stateSaveParams": function (settings, data) {
  9451. * data.oSearch.sSearch = "";
  9452. * }
  9453. * } );
  9454. * } );
  9455. */
  9456. "fnStateSaveParams": null,
  9457. /**
  9458. * Duration for which the saved state information is considered valid. After this period
  9459. * has elapsed the state will be returned to the default.
  9460. * Value is given in seconds.
  9461. * @type int
  9462. * @default 7200 <i>(2 hours)</i>
  9463. *
  9464. * @dtopt Options
  9465. * @name DataTable.defaults.stateDuration
  9466. *
  9467. * @example
  9468. * $(document).ready( function() {
  9469. * $('#example').dataTable( {
  9470. * "stateDuration": 60*60*24; // 1 day
  9471. * } );
  9472. * } )
  9473. */
  9474. "iStateDuration": 7200,
  9475. /**
  9476. * When enabled DataTables will not make a request to the server for the first
  9477. * page draw - rather it will use the data already on the page (no sorting etc
  9478. * will be applied to it), thus saving on an XHR at load time. `deferLoading`
  9479. * is used to indicate that deferred loading is required, but it is also used
  9480. * to tell DataTables how many records there are in the full table (allowing
  9481. * the information element and pagination to be displayed correctly). In the case
  9482. * where a filtering is applied to the table on initial load, this can be
  9483. * indicated by giving the parameter as an array, where the first element is
  9484. * the number of records available after filtering and the second element is the
  9485. * number of records without filtering (allowing the table information element
  9486. * to be shown correctly).
  9487. * @type int | array
  9488. * @default null
  9489. *
  9490. * @dtopt Options
  9491. * @name DataTable.defaults.deferLoading
  9492. *
  9493. * @example
  9494. * // 57 records available in the table, no filtering applied
  9495. * $(document).ready( function() {
  9496. * $('#example').dataTable( {
  9497. * "serverSide": true,
  9498. * "ajax": "scripts/server_processing.php",
  9499. * "deferLoading": 57
  9500. * } );
  9501. * } );
  9502. *
  9503. * @example
  9504. * // 57 records after filtering, 100 without filtering (an initial filter applied)
  9505. * $(document).ready( function() {
  9506. * $('#example').dataTable( {
  9507. * "serverSide": true,
  9508. * "ajax": "scripts/server_processing.php",
  9509. * "deferLoading": [ 57, 100 ],
  9510. * "search": {
  9511. * "search": "my_filter"
  9512. * }
  9513. * } );
  9514. * } );
  9515. */
  9516. "iDeferLoading": null,
  9517. /**
  9518. * Number of rows to display on a single page when using pagination. If
  9519. * feature enabled (`lengthChange`) then the end user will be able to override
  9520. * this to a custom setting using a pop-up menu.
  9521. * @type int
  9522. * @default 10
  9523. *
  9524. * @dtopt Options
  9525. * @name DataTable.defaults.pageLength
  9526. *
  9527. * @example
  9528. * $(document).ready( function() {
  9529. * $('#example').dataTable( {
  9530. * "pageLength": 50
  9531. * } );
  9532. * } )
  9533. */
  9534. "iDisplayLength": 10,
  9535. /**
  9536. * Define the starting point for data display when using DataTables with
  9537. * pagination. Note that this parameter is the number of records, rather than
  9538. * the page number, so if you have 10 records per page and want to start on
  9539. * the third page, it should be "20".
  9540. * @type int
  9541. * @default 0
  9542. *
  9543. * @dtopt Options
  9544. * @name DataTable.defaults.displayStart
  9545. *
  9546. * @example
  9547. * $(document).ready( function() {
  9548. * $('#example').dataTable( {
  9549. * "displayStart": 20
  9550. * } );
  9551. * } )
  9552. */
  9553. "iDisplayStart": 0,
  9554. /**
  9555. * By default DataTables allows keyboard navigation of the table (sorting, paging,
  9556. * and filtering) by adding a `tabindex` attribute to the required elements. This
  9557. * allows you to tab through the controls and press the enter key to activate them.
  9558. * The tabindex is default 0, meaning that the tab follows the flow of the document.
  9559. * You can overrule this using this parameter if you wish. Use a value of -1 to
  9560. * disable built-in keyboard navigation.
  9561. * @type int
  9562. * @default 0
  9563. *
  9564. * @dtopt Options
  9565. * @name DataTable.defaults.tabIndex
  9566. *
  9567. * @example
  9568. * $(document).ready( function() {
  9569. * $('#example').dataTable( {
  9570. * "tabIndex": 1
  9571. * } );
  9572. * } );
  9573. */
  9574. "iTabIndex": 0,
  9575. /**
  9576. * Classes that DataTables assigns to the various components and features
  9577. * that it adds to the HTML table. This allows classes to be configured
  9578. * during initialisation in addition to through the static
  9579. * {@link DataTable.ext.oStdClasses} object).
  9580. * @namespace
  9581. * @name DataTable.defaults.classes
  9582. */
  9583. "oClasses": {},
  9584. /**
  9585. * All strings that DataTables uses in the user interface that it creates
  9586. * are defined in this object, allowing you to modified them individually or
  9587. * completely replace them all as required.
  9588. * @namespace
  9589. * @name DataTable.defaults.language
  9590. */
  9591. "oLanguage": {
  9592. /**
  9593. * Strings that are used for WAI-ARIA labels and controls only (these are not
  9594. * actually visible on the page, but will be read by screenreaders, and thus
  9595. * must be internationalised as well).
  9596. * @namespace
  9597. * @name DataTable.defaults.language.aria
  9598. */
  9599. "oAria": {
  9600. /**
  9601. * ARIA label that is added to the table headers when the column may be
  9602. * sorted ascending by activing the column (click or return when focused).
  9603. * Note that the column header is prefixed to this string.
  9604. * @type string
  9605. * @default : activate to sort column ascending
  9606. *
  9607. * @dtopt Language
  9608. * @name DataTable.defaults.language.aria.sortAscending
  9609. *
  9610. * @example
  9611. * $(document).ready( function() {
  9612. * $('#example').dataTable( {
  9613. * "language": {
  9614. * "aria": {
  9615. * "sortAscending": " - click/return to sort ascending"
  9616. * }
  9617. * }
  9618. * } );
  9619. * } );
  9620. */
  9621. "sSortAscending": ": activate to sort column ascending",
  9622. /**
  9623. * ARIA label that is added to the table headers when the column may be
  9624. * sorted descending by activing the column (click or return when focused).
  9625. * Note that the column header is prefixed to this string.
  9626. * @type string
  9627. * @default : activate to sort column ascending
  9628. *
  9629. * @dtopt Language
  9630. * @name DataTable.defaults.language.aria.sortDescending
  9631. *
  9632. * @example
  9633. * $(document).ready( function() {
  9634. * $('#example').dataTable( {
  9635. * "language": {
  9636. * "aria": {
  9637. * "sortDescending": " - click/return to sort descending"
  9638. * }
  9639. * }
  9640. * } );
  9641. * } );
  9642. */
  9643. "sSortDescending": ": activate to sort column descending"
  9644. },
  9645. /**
  9646. * Pagination string used by DataTables for the built-in pagination
  9647. * control types.
  9648. * @namespace
  9649. * @name DataTable.defaults.language.paginate
  9650. */
  9651. "oPaginate": {
  9652. /**
  9653. * Text to use when using the 'full_numbers' type of pagination for the
  9654. * button to take the user to the first page.
  9655. * @type string
  9656. * @default First
  9657. *
  9658. * @dtopt Language
  9659. * @name DataTable.defaults.language.paginate.first
  9660. *
  9661. * @example
  9662. * $(document).ready( function() {
  9663. * $('#example').dataTable( {
  9664. * "language": {
  9665. * "paginate": {
  9666. * "first": "First page"
  9667. * }
  9668. * }
  9669. * } );
  9670. * } );
  9671. */
  9672. "sFirst": "First",
  9673. /**
  9674. * Text to use when using the 'full_numbers' type of pagination for the
  9675. * button to take the user to the last page.
  9676. * @type string
  9677. * @default Last
  9678. *
  9679. * @dtopt Language
  9680. * @name DataTable.defaults.language.paginate.last
  9681. *
  9682. * @example
  9683. * $(document).ready( function() {
  9684. * $('#example').dataTable( {
  9685. * "language": {
  9686. * "paginate": {
  9687. * "last": "Last page"
  9688. * }
  9689. * }
  9690. * } );
  9691. * } );
  9692. */
  9693. "sLast": "Last",
  9694. /**
  9695. * Text to use for the 'next' pagination button (to take the user to the
  9696. * next page).
  9697. * @type string
  9698. * @default Next
  9699. *
  9700. * @dtopt Language
  9701. * @name DataTable.defaults.language.paginate.next
  9702. *
  9703. * @example
  9704. * $(document).ready( function() {
  9705. * $('#example').dataTable( {
  9706. * "language": {
  9707. * "paginate": {
  9708. * "next": "Next page"
  9709. * }
  9710. * }
  9711. * } );
  9712. * } );
  9713. */
  9714. "sNext": "Next",
  9715. /**
  9716. * Text to use for the 'previous' pagination button (to take the user to
  9717. * the previous page).
  9718. * @type string
  9719. * @default Previous
  9720. *
  9721. * @dtopt Language
  9722. * @name DataTable.defaults.language.paginate.previous
  9723. *
  9724. * @example
  9725. * $(document).ready( function() {
  9726. * $('#example').dataTable( {
  9727. * "language": {
  9728. * "paginate": {
  9729. * "previous": "Previous page"
  9730. * }
  9731. * }
  9732. * } );
  9733. * } );
  9734. */
  9735. "sPrevious": "Previous"
  9736. },
  9737. /**
  9738. * This string is shown in preference to `zeroRecords` when the table is
  9739. * empty of data (regardless of filtering). Note that this is an optional
  9740. * parameter - if it is not given, the value of `zeroRecords` will be used
  9741. * instead (either the default or given value).
  9742. * @type string
  9743. * @default No data available in table
  9744. *
  9745. * @dtopt Language
  9746. * @name DataTable.defaults.language.emptyTable
  9747. *
  9748. * @example
  9749. * $(document).ready( function() {
  9750. * $('#example').dataTable( {
  9751. * "language": {
  9752. * "emptyTable": "No data available in table"
  9753. * }
  9754. * } );
  9755. * } );
  9756. */
  9757. "sEmptyTable": "No data available in table",
  9758. /**
  9759. * This string gives information to the end user about the information
  9760. * that is current on display on the page. The following tokens can be
  9761. * used in the string and will be dynamically replaced as the table
  9762. * display updates. This tokens can be placed anywhere in the string, or
  9763. * removed as needed by the language requires:
  9764. *
  9765. * * `\_START\_` - Display index of the first record on the current page
  9766. * * `\_END\_` - Display index of the last record on the current page
  9767. * * `\_TOTAL\_` - Number of records in the table after filtering
  9768. * * `\_MAX\_` - Number of records in the table without filtering
  9769. * * `\_PAGE\_` - Current page number
  9770. * * `\_PAGES\_` - Total number of pages of data in the table
  9771. *
  9772. * @type string
  9773. * @default Showing _START_ to _END_ of _TOTAL_ entries
  9774. *
  9775. * @dtopt Language
  9776. * @name DataTable.defaults.language.info
  9777. *
  9778. * @example
  9779. * $(document).ready( function() {
  9780. * $('#example').dataTable( {
  9781. * "language": {
  9782. * "info": "Showing page _PAGE_ of _PAGES_"
  9783. * }
  9784. * } );
  9785. * } );
  9786. */
  9787. "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
  9788. /**
  9789. * Display information string for when the table is empty. Typically the
  9790. * format of this string should match `info`.
  9791. * @type string
  9792. * @default Showing 0 to 0 of 0 entries
  9793. *
  9794. * @dtopt Language
  9795. * @name DataTable.defaults.language.infoEmpty
  9796. *
  9797. * @example
  9798. * $(document).ready( function() {
  9799. * $('#example').dataTable( {
  9800. * "language": {
  9801. * "infoEmpty": "No entries to show"
  9802. * }
  9803. * } );
  9804. * } );
  9805. */
  9806. "sInfoEmpty": "Showing 0 to 0 of 0 entries",
  9807. /**
  9808. * When a user filters the information in a table, this string is appended
  9809. * to the information (`info`) to give an idea of how strong the filtering
  9810. * is. The variable _MAX_ is dynamically updated.
  9811. * @type string
  9812. * @default (filtered from _MAX_ total entries)
  9813. *
  9814. * @dtopt Language
  9815. * @name DataTable.defaults.language.infoFiltered
  9816. *
  9817. * @example
  9818. * $(document).ready( function() {
  9819. * $('#example').dataTable( {
  9820. * "language": {
  9821. * "infoFiltered": " - filtering from _MAX_ records"
  9822. * }
  9823. * } );
  9824. * } );
  9825. */
  9826. "sInfoFiltered": "(filtered from _MAX_ total entries)",
  9827. /**
  9828. * If can be useful to append extra information to the info string at times,
  9829. * and this variable does exactly that. This information will be appended to
  9830. * the `info` (`infoEmpty` and `infoFiltered` in whatever combination they are
  9831. * being used) at all times.
  9832. * @type string
  9833. * @default <i>Empty string</i>
  9834. *
  9835. * @dtopt Language
  9836. * @name DataTable.defaults.language.infoPostFix
  9837. *
  9838. * @example
  9839. * $(document).ready( function() {
  9840. * $('#example').dataTable( {
  9841. * "language": {
  9842. * "infoPostFix": "All records shown are derived from real information."
  9843. * }
  9844. * } );
  9845. * } );
  9846. */
  9847. "sInfoPostFix": "",
  9848. /**
  9849. * This decimal place operator is a little different from the other
  9850. * language options since DataTables doesn't output floating point
  9851. * numbers, so it won't ever use this for display of a number. Rather,
  9852. * what this parameter does is modify the sort methods of the table so
  9853. * that numbers which are in a format which has a character other than
  9854. * a period (`.`) as a decimal place will be sorted numerically.
  9855. *
  9856. * Note that numbers with different decimal places cannot be shown in
  9857. * the same table and still be sortable, the table must be consistent.
  9858. * However, multiple different tables on the page can use different
  9859. * decimal place characters.
  9860. * @type string
  9861. * @default
  9862. *
  9863. * @dtopt Language
  9864. * @name DataTable.defaults.language.decimal
  9865. *
  9866. * @example
  9867. * $(document).ready( function() {
  9868. * $('#example').dataTable( {
  9869. * "language": {
  9870. * "decimal": ","
  9871. * "thousands": "."
  9872. * }
  9873. * } );
  9874. * } );
  9875. */
  9876. "sDecimal": "",
  9877. /**
  9878. * DataTables has a build in number formatter (`formatNumber`) which is
  9879. * used to format large numbers that are used in the table information.
  9880. * By default a comma is used, but this can be trivially changed to any
  9881. * character you wish with this parameter.
  9882. * @type string
  9883. * @default ,
  9884. *
  9885. * @dtopt Language
  9886. * @name DataTable.defaults.language.thousands
  9887. *
  9888. * @example
  9889. * $(document).ready( function() {
  9890. * $('#example').dataTable( {
  9891. * "language": {
  9892. * "thousands": "'"
  9893. * }
  9894. * } );
  9895. * } );
  9896. */
  9897. "sThousands": ",",
  9898. /**
  9899. * Detail the action that will be taken when the drop down menu for the
  9900. * pagination length option is changed. The '_MENU_' variable is replaced
  9901. * with a default select list of 10, 25, 50 and 100, and can be replaced
  9902. * with a custom select box if required.
  9903. * @type string
  9904. * @default Show _MENU_ entries
  9905. *
  9906. * @dtopt Language
  9907. * @name DataTable.defaults.language.lengthMenu
  9908. *
  9909. * @example
  9910. * // Language change only
  9911. * $(document).ready( function() {
  9912. * $('#example').dataTable( {
  9913. * "language": {
  9914. * "lengthMenu": "Display _MENU_ records"
  9915. * }
  9916. * } );
  9917. * } );
  9918. *
  9919. * @example
  9920. * // Language and options change
  9921. * $(document).ready( function() {
  9922. * $('#example').dataTable( {
  9923. * "language": {
  9924. * "lengthMenu": 'Display <select>'+
  9925. * '<option value="10">10</option>'+
  9926. * '<option value="20">20</option>'+
  9927. * '<option value="30">30</option>'+
  9928. * '<option value="40">40</option>'+
  9929. * '<option value="50">50</option>'+
  9930. * '<option value="-1">All</option>'+
  9931. * '</select> records'
  9932. * }
  9933. * } );
  9934. * } );
  9935. */
  9936. "sLengthMenu": "Show _MENU_ entries",
  9937. /**
  9938. * When using Ajax sourced data and during the first draw when DataTables is
  9939. * gathering the data, this message is shown in an empty row in the table to
  9940. * indicate to the end user the the data is being loaded. Note that this
  9941. * parameter is not used when loading data by server-side processing, just
  9942. * Ajax sourced data with client-side processing.
  9943. * @type string
  9944. * @default Loading...
  9945. *
  9946. * @dtopt Language
  9947. * @name DataTable.defaults.language.loadingRecords
  9948. *
  9949. * @example
  9950. * $(document).ready( function() {
  9951. * $('#example').dataTable( {
  9952. * "language": {
  9953. * "loadingRecords": "Please wait - loading..."
  9954. * }
  9955. * } );
  9956. * } );
  9957. */
  9958. "sLoadingRecords": "Loading...",
  9959. /**
  9960. * Text which is displayed when the table is processing a user action
  9961. * (usually a sort command or similar).
  9962. * @type string
  9963. * @default Processing...
  9964. *
  9965. * @dtopt Language
  9966. * @name DataTable.defaults.language.processing
  9967. *
  9968. * @example
  9969. * $(document).ready( function() {
  9970. * $('#example').dataTable( {
  9971. * "language": {
  9972. * "processing": "DataTables is currently busy"
  9973. * }
  9974. * } );
  9975. * } );
  9976. */
  9977. "sProcessing": "Processing...",
  9978. /**
  9979. * Details the actions that will be taken when the user types into the
  9980. * filtering input text box. The variable "_INPUT_", if used in the string,
  9981. * is replaced with the HTML text box for the filtering input allowing
  9982. * control over where it appears in the string. If "_INPUT_" is not given
  9983. * then the input box is appended to the string automatically.
  9984. * @type string
  9985. * @default Search:
  9986. *
  9987. * @dtopt Language
  9988. * @name DataTable.defaults.language.search
  9989. *
  9990. * @example
  9991. * // Input text box will be appended at the end automatically
  9992. * $(document).ready( function() {
  9993. * $('#example').dataTable( {
  9994. * "language": {
  9995. * "search": "Filter records:"
  9996. * }
  9997. * } );
  9998. * } );
  9999. *
  10000. * @example
  10001. * // Specify where the filter should appear
  10002. * $(document).ready( function() {
  10003. * $('#example').dataTable( {
  10004. * "language": {
  10005. * "search": "Apply filter _INPUT_ to table"
  10006. * }
  10007. * } );
  10008. * } );
  10009. */
  10010. "sSearch": "Search:",
  10011. /**
  10012. * Assign a `placeholder` attribute to the search `input` element
  10013. * @type string
  10014. * @default
  10015. *
  10016. * @dtopt Language
  10017. * @name DataTable.defaults.language.searchPlaceholder
  10018. */
  10019. "sSearchPlaceholder": "",
  10020. /**
  10021. * All of the language information can be stored in a file on the
  10022. * server-side, which DataTables will look up if this parameter is passed.
  10023. * It must store the URL of the language file, which is in a JSON format,
  10024. * and the object has the same properties as the oLanguage object in the
  10025. * initialiser object (i.e. the above parameters). Please refer to one of
  10026. * the example language files to see how this works in action.
  10027. * @type string
  10028. * @default <i>Empty string - i.e. disabled</i>
  10029. *
  10030. * @dtopt Language
  10031. * @name DataTable.defaults.language.url
  10032. *
  10033. * @example
  10034. * $(document).ready( function() {
  10035. * $('#example').dataTable( {
  10036. * "language": {
  10037. * "url": "http://www.sprymedia.co.uk/dataTables/lang.txt"
  10038. * }
  10039. * } );
  10040. * } );
  10041. */
  10042. "sUrl": "",
  10043. /**
  10044. * Text shown inside the table records when the is no information to be
  10045. * displayed after filtering. `emptyTable` is shown when there is simply no
  10046. * information in the table at all (regardless of filtering).
  10047. * @type string
  10048. * @default No matching records found
  10049. *
  10050. * @dtopt Language
  10051. * @name DataTable.defaults.language.zeroRecords
  10052. *
  10053. * @example
  10054. * $(document).ready( function() {
  10055. * $('#example').dataTable( {
  10056. * "language": {
  10057. * "zeroRecords": "No records to display"
  10058. * }
  10059. * } );
  10060. * } );
  10061. */
  10062. "sZeroRecords": "No matching records found"
  10063. },
  10064. /**
  10065. * This parameter allows you to have define the global filtering state at
  10066. * initialisation time. As an object the `search` parameter must be
  10067. * defined, but all other parameters are optional. When `regex` is true,
  10068. * the search string will be treated as a regular expression, when false
  10069. * (default) it will be treated as a straight string. When `smart`
  10070. * DataTables will use it's smart filtering methods (to word match at
  10071. * any point in the data), when false this will not be done.
  10072. * @namespace
  10073. * @extends DataTable.models.oSearch
  10074. *
  10075. * @dtopt Options
  10076. * @name DataTable.defaults.search
  10077. *
  10078. * @example
  10079. * $(document).ready( function() {
  10080. * $('#example').dataTable( {
  10081. * "search": {"search": "Initial search"}
  10082. * } );
  10083. * } )
  10084. */
  10085. "oSearch": $.extend( {}, DataTable.models.oSearch ),
  10086. /**
  10087. * __Deprecated__ The functionality provided by this parameter has now been
  10088. * superseded by that provided through `ajax`, which should be used instead.
  10089. *
  10090. * By default DataTables will look for the property `data` (or `aaData` for
  10091. * compatibility with DataTables 1.9-) when obtaining data from an Ajax
  10092. * source or for server-side processing - this parameter allows that
  10093. * property to be changed. You can use Javascript dotted object notation to
  10094. * get a data source for multiple levels of nesting.
  10095. * @type string
  10096. * @default data
  10097. *
  10098. * @dtopt Options
  10099. * @dtopt Server-side
  10100. * @name DataTable.defaults.ajaxDataProp
  10101. *
  10102. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10103. */
  10104. "sAjaxDataProp": "data",
  10105. /**
  10106. * __Deprecated__ The functionality provided by this parameter has now been
  10107. * superseded by that provided through `ajax`, which should be used instead.
  10108. *
  10109. * You can instruct DataTables to load data from an external
  10110. * source using this parameter (use aData if you want to pass data in you
  10111. * already have). Simply provide a url a JSON object can be obtained from.
  10112. * @type string
  10113. * @default null
  10114. *
  10115. * @dtopt Options
  10116. * @dtopt Server-side
  10117. * @name DataTable.defaults.ajaxSource
  10118. *
  10119. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10120. */
  10121. "sAjaxSource": null,
  10122. /**
  10123. * This initialisation variable allows you to specify exactly where in the
  10124. * DOM you want DataTables to inject the various controls it adds to the page
  10125. * (for example you might want the pagination controls at the top of the
  10126. * table). DIV elements (with or without a custom class) can also be added to
  10127. * aid styling. The follow syntax is used:
  10128. * <ul>
  10129. * <li>The following options are allowed:
  10130. * <ul>
  10131. * <li>'l' - Length changing</li>
  10132. * <li>'f' - Filtering input</li>
  10133. * <li>'t' - The table!</li>
  10134. * <li>'i' - Information</li>
  10135. * <li>'p' - Pagination</li>
  10136. * <li>'r' - pRocessing</li>
  10137. * </ul>
  10138. * </li>
  10139. * <li>The following constants are allowed:
  10140. * <ul>
  10141. * <li>'H' - jQueryUI theme "header" classes ('fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix')</li>
  10142. * <li>'F' - jQueryUI theme "footer" classes ('fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix')</li>
  10143. * </ul>
  10144. * </li>
  10145. * <li>The following syntax is expected:
  10146. * <ul>
  10147. * <li>'&lt;' and '&gt;' - div elements</li>
  10148. * <li>'&lt;"class" and '&gt;' - div with a class</li>
  10149. * <li>'&lt;"#id" and '&gt;' - div with an ID</li>
  10150. * </ul>
  10151. * </li>
  10152. * <li>Examples:
  10153. * <ul>
  10154. * <li>'&lt;"wrapper"flipt&gt;'</li>
  10155. * <li>'&lt;lf&lt;t&gt;ip&gt;'</li>
  10156. * </ul>
  10157. * </li>
  10158. * </ul>
  10159. * @type string
  10160. * @default lfrtip <i>(when `jQueryUI` is false)</i> <b>or</b>
  10161. * <"H"lfr>t<"F"ip> <i>(when `jQueryUI` is true)</i>
  10162. *
  10163. * @dtopt Options
  10164. * @name DataTable.defaults.dom
  10165. *
  10166. * @example
  10167. * $(document).ready( function() {
  10168. * $('#example').dataTable( {
  10169. * "dom": '&lt;"top"i&gt;rt&lt;"bottom"flp&gt;&lt;"clear"&gt;'
  10170. * } );
  10171. * } );
  10172. */
  10173. "sDom": "lfrtip",
  10174. /**
  10175. * Search delay option. This will throttle full table searches that use the
  10176. * DataTables provided search input element (it does not effect calls to
  10177. * `dt-api search()`, providing a delay before the search is made.
  10178. * @type integer
  10179. * @default 0
  10180. *
  10181. * @dtopt Options
  10182. * @name DataTable.defaults.searchDelay
  10183. *
  10184. * @example
  10185. * $(document).ready( function() {
  10186. * $('#example').dataTable( {
  10187. * "searchDelay": 200
  10188. * } );
  10189. * } )
  10190. */
  10191. "searchDelay": null,
  10192. /**
  10193. * DataTables features four different built-in options for the buttons to
  10194. * display for pagination control:
  10195. *
  10196. * * `simple` - 'Previous' and 'Next' buttons only
  10197. * * 'simple_numbers` - 'Previous' and 'Next' buttons, plus page numbers
  10198. * * `full` - 'First', 'Previous', 'Next' and 'Last' buttons
  10199. * * `full_numbers` - 'First', 'Previous', 'Next' and 'Last' buttons, plus
  10200. * page numbers
  10201. *
  10202. * Further methods can be added using {@link DataTable.ext.oPagination}.
  10203. * @type string
  10204. * @default simple_numbers
  10205. *
  10206. * @dtopt Options
  10207. * @name DataTable.defaults.pagingType
  10208. *
  10209. * @example
  10210. * $(document).ready( function() {
  10211. * $('#example').dataTable( {
  10212. * "pagingType": "full_numbers"
  10213. * } );
  10214. * } )
  10215. */
  10216. "sPaginationType": "simple_numbers",
  10217. /**
  10218. * Enable horizontal scrolling. When a table is too wide to fit into a
  10219. * certain layout, or you have a large number of columns in the table, you
  10220. * can enable x-scrolling to show the table in a viewport, which can be
  10221. * scrolled. This property can be `true` which will allow the table to
  10222. * scroll horizontally when needed, or any CSS unit, or a number (in which
  10223. * case it will be treated as a pixel measurement). Setting as simply `true`
  10224. * is recommended.
  10225. * @type boolean|string
  10226. * @default <i>blank string - i.e. disabled</i>
  10227. *
  10228. * @dtopt Features
  10229. * @name DataTable.defaults.scrollX
  10230. *
  10231. * @example
  10232. * $(document).ready( function() {
  10233. * $('#example').dataTable( {
  10234. * "scrollX": true,
  10235. * "scrollCollapse": true
  10236. * } );
  10237. * } );
  10238. */
  10239. "sScrollX": "",
  10240. /**
  10241. * This property can be used to force a DataTable to use more width than it
  10242. * might otherwise do when x-scrolling is enabled. For example if you have a
  10243. * table which requires to be well spaced, this parameter is useful for
  10244. * "over-sizing" the table, and thus forcing scrolling. This property can by
  10245. * any CSS unit, or a number (in which case it will be treated as a pixel
  10246. * measurement).
  10247. * @type string
  10248. * @default <i>blank string - i.e. disabled</i>
  10249. *
  10250. * @dtopt Options
  10251. * @name DataTable.defaults.scrollXInner
  10252. *
  10253. * @example
  10254. * $(document).ready( function() {
  10255. * $('#example').dataTable( {
  10256. * "scrollX": "100%",
  10257. * "scrollXInner": "110%"
  10258. * } );
  10259. * } );
  10260. */
  10261. "sScrollXInner": "",
  10262. /**
  10263. * Enable vertical scrolling. Vertical scrolling will constrain the DataTable
  10264. * to the given height, and enable scrolling for any data which overflows the
  10265. * current viewport. This can be used as an alternative to paging to display
  10266. * a lot of data in a small area (although paging and scrolling can both be
  10267. * enabled at the same time). This property can be any CSS unit, or a number
  10268. * (in which case it will be treated as a pixel measurement).
  10269. * @type string
  10270. * @default <i>blank string - i.e. disabled</i>
  10271. *
  10272. * @dtopt Features
  10273. * @name DataTable.defaults.scrollY
  10274. *
  10275. * @example
  10276. * $(document).ready( function() {
  10277. * $('#example').dataTable( {
  10278. * "scrollY": "200px",
  10279. * "paginate": false
  10280. * } );
  10281. * } );
  10282. */
  10283. "sScrollY": "",
  10284. /**
  10285. * __Deprecated__ The functionality provided by this parameter has now been
  10286. * superseded by that provided through `ajax`, which should be used instead.
  10287. *
  10288. * Set the HTTP method that is used to make the Ajax call for server-side
  10289. * processing or Ajax sourced data.
  10290. * @type string
  10291. * @default GET
  10292. *
  10293. * @dtopt Options
  10294. * @dtopt Server-side
  10295. * @name DataTable.defaults.serverMethod
  10296. *
  10297. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10298. */
  10299. "sServerMethod": "GET",
  10300. /**
  10301. * DataTables makes use of renderers when displaying HTML elements for
  10302. * a table. These renderers can be added or modified by plug-ins to
  10303. * generate suitable mark-up for a site. For example the Bootstrap
  10304. * integration plug-in for DataTables uses a paging button renderer to
  10305. * display pagination buttons in the mark-up required by Bootstrap.
  10306. *
  10307. * For further information about the renderers available see
  10308. * DataTable.ext.renderer
  10309. * @type string|object
  10310. * @default null
  10311. *
  10312. * @name DataTable.defaults.renderer
  10313. *
  10314. */
  10315. "renderer": null,
  10316. /**
  10317. * Set the data property name that DataTables should use to get a row's id
  10318. * to set as the `id` property in the node.
  10319. * @type string
  10320. * @default DT_RowId
  10321. *
  10322. * @name DataTable.defaults.rowId
  10323. */
  10324. "rowId": "DT_RowId"
  10325. };
  10326. _fnHungarianMap( DataTable.defaults );
  10327. /*
  10328. * Developer note - See note in model.defaults.js about the use of Hungarian
  10329. * notation and camel case.
  10330. */
  10331. /**
  10332. * Column options that can be given to DataTables at initialisation time.
  10333. * @namespace
  10334. */
  10335. DataTable.defaults.column = {
  10336. /**
  10337. * Define which column(s) an order will occur on for this column. This
  10338. * allows a column's ordering to take multiple columns into account when
  10339. * doing a sort or use the data from a different column. For example first
  10340. * name / last name columns make sense to do a multi-column sort over the
  10341. * two columns.
  10342. * @type array|int
  10343. * @default null <i>Takes the value of the column index automatically</i>
  10344. *
  10345. * @name DataTable.defaults.column.orderData
  10346. * @dtopt Columns
  10347. *
  10348. * @example
  10349. * // Using `columnDefs`
  10350. * $(document).ready( function() {
  10351. * $('#example').dataTable( {
  10352. * "columnDefs": [
  10353. * { "orderData": [ 0, 1 ], "targets": [ 0 ] },
  10354. * { "orderData": [ 1, 0 ], "targets": [ 1 ] },
  10355. * { "orderData": 2, "targets": [ 2 ] }
  10356. * ]
  10357. * } );
  10358. * } );
  10359. *
  10360. * @example
  10361. * // Using `columns`
  10362. * $(document).ready( function() {
  10363. * $('#example').dataTable( {
  10364. * "columns": [
  10365. * { "orderData": [ 0, 1 ] },
  10366. * { "orderData": [ 1, 0 ] },
  10367. * { "orderData": 2 },
  10368. * null,
  10369. * null
  10370. * ]
  10371. * } );
  10372. * } );
  10373. */
  10374. "aDataSort": null,
  10375. "iDataSort": -1,
  10376. /**
  10377. * You can control the default ordering direction, and even alter the
  10378. * behaviour of the sort handler (i.e. only allow ascending ordering etc)
  10379. * using this parameter.
  10380. * @type array
  10381. * @default [ 'asc', 'desc' ]
  10382. *
  10383. * @name DataTable.defaults.column.orderSequence
  10384. * @dtopt Columns
  10385. *
  10386. * @example
  10387. * // Using `columnDefs`
  10388. * $(document).ready( function() {
  10389. * $('#example').dataTable( {
  10390. * "columnDefs": [
  10391. * { "orderSequence": [ "asc" ], "targets": [ 1 ] },
  10392. * { "orderSequence": [ "desc", "asc", "asc" ], "targets": [ 2 ] },
  10393. * { "orderSequence": [ "desc" ], "targets": [ 3 ] }
  10394. * ]
  10395. * } );
  10396. * } );
  10397. *
  10398. * @example
  10399. * // Using `columns`
  10400. * $(document).ready( function() {
  10401. * $('#example').dataTable( {
  10402. * "columns": [
  10403. * null,
  10404. * { "orderSequence": [ "asc" ] },
  10405. * { "orderSequence": [ "desc", "asc", "asc" ] },
  10406. * { "orderSequence": [ "desc" ] },
  10407. * null
  10408. * ]
  10409. * } );
  10410. * } );
  10411. */
  10412. "asSorting": [ 'asc', 'desc' ],
  10413. /**
  10414. * Enable or disable filtering on the data in this column.
  10415. * @type boolean
  10416. * @default true
  10417. *
  10418. * @name DataTable.defaults.column.searchable
  10419. * @dtopt Columns
  10420. *
  10421. * @example
  10422. * // Using `columnDefs`
  10423. * $(document).ready( function() {
  10424. * $('#example').dataTable( {
  10425. * "columnDefs": [
  10426. * { "searchable": false, "targets": [ 0 ] }
  10427. * ] } );
  10428. * } );
  10429. *
  10430. * @example
  10431. * // Using `columns`
  10432. * $(document).ready( function() {
  10433. * $('#example').dataTable( {
  10434. * "columns": [
  10435. * { "searchable": false },
  10436. * null,
  10437. * null,
  10438. * null,
  10439. * null
  10440. * ] } );
  10441. * } );
  10442. */
  10443. "bSearchable": true,
  10444. /**
  10445. * Enable or disable ordering on this column.
  10446. * @type boolean
  10447. * @default true
  10448. *
  10449. * @name DataTable.defaults.column.orderable
  10450. * @dtopt Columns
  10451. *
  10452. * @example
  10453. * // Using `columnDefs`
  10454. * $(document).ready( function() {
  10455. * $('#example').dataTable( {
  10456. * "columnDefs": [
  10457. * { "orderable": false, "targets": [ 0 ] }
  10458. * ] } );
  10459. * } );
  10460. *
  10461. * @example
  10462. * // Using `columns`
  10463. * $(document).ready( function() {
  10464. * $('#example').dataTable( {
  10465. * "columns": [
  10466. * { "orderable": false },
  10467. * null,
  10468. * null,
  10469. * null,
  10470. * null
  10471. * ] } );
  10472. * } );
  10473. */
  10474. "bSortable": true,
  10475. /**
  10476. * Enable or disable the display of this column.
  10477. * @type boolean
  10478. * @default true
  10479. *
  10480. * @name DataTable.defaults.column.visible
  10481. * @dtopt Columns
  10482. *
  10483. * @example
  10484. * // Using `columnDefs`
  10485. * $(document).ready( function() {
  10486. * $('#example').dataTable( {
  10487. * "columnDefs": [
  10488. * { "visible": false, "targets": [ 0 ] }
  10489. * ] } );
  10490. * } );
  10491. *
  10492. * @example
  10493. * // Using `columns`
  10494. * $(document).ready( function() {
  10495. * $('#example').dataTable( {
  10496. * "columns": [
  10497. * { "visible": false },
  10498. * null,
  10499. * null,
  10500. * null,
  10501. * null
  10502. * ] } );
  10503. * } );
  10504. */
  10505. "bVisible": true,
  10506. /**
  10507. * Developer definable function that is called whenever a cell is created (Ajax source,
  10508. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  10509. * allowing you to modify the DOM element (add background colour for example) when the
  10510. * element is available.
  10511. * @type function
  10512. * @param {element} td The TD node that has been created
  10513. * @param {*} cellData The Data for the cell
  10514. * @param {array|object} rowData The data for the whole row
  10515. * @param {int} row The row index for the aoData data store
  10516. * @param {int} col The column index for aoColumns
  10517. *
  10518. * @name DataTable.defaults.column.createdCell
  10519. * @dtopt Columns
  10520. *
  10521. * @example
  10522. * $(document).ready( function() {
  10523. * $('#example').dataTable( {
  10524. * "columnDefs": [ {
  10525. * "targets": [3],
  10526. * "createdCell": function (td, cellData, rowData, row, col) {
  10527. * if ( cellData == "1.7" ) {
  10528. * $(td).css('color', 'blue')
  10529. * }
  10530. * }
  10531. * } ]
  10532. * });
  10533. * } );
  10534. */
  10535. "fnCreatedCell": null,
  10536. /**
  10537. * This parameter has been replaced by `data` in DataTables to ensure naming
  10538. * consistency. `dataProp` can still be used, as there is backwards
  10539. * compatibility in DataTables for this option, but it is strongly
  10540. * recommended that you use `data` in preference to `dataProp`.
  10541. * @name DataTable.defaults.column.dataProp
  10542. */
  10543. /**
  10544. * This property can be used to read data from any data source property,
  10545. * including deeply nested objects / properties. `data` can be given in a
  10546. * number of different ways which effect its behaviour:
  10547. *
  10548. * * `integer` - treated as an array index for the data source. This is the
  10549. * default that DataTables uses (incrementally increased for each column).
  10550. * * `string` - read an object property from the data source. There are
  10551. * three 'special' options that can be used in the string to alter how
  10552. * DataTables reads the data from the source object:
  10553. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10554. * Javascript to read from nested objects, so to can the options
  10555. * specified in `data`. For example: `browser.version` or
  10556. * `browser.name`. If your object parameter name contains a period, use
  10557. * `\\` to escape it - i.e. `first\\.name`.
  10558. * * `[]` - Array notation. DataTables can automatically combine data
  10559. * from and array source, joining the data with the characters provided
  10560. * between the two brackets. For example: `name[, ]` would provide a
  10561. * comma-space separated list from the source array. If no characters
  10562. * are provided between the brackets, the original array source is
  10563. * returned.
  10564. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10565. * execute a function of the name given. For example: `browser()` for a
  10566. * simple function on the data source, `browser.version()` for a
  10567. * function in a nested property or even `browser().version` to get an
  10568. * object property if the function called returns an object. Note that
  10569. * function notation is recommended for use in `render` rather than
  10570. * `data` as it is much simpler to use as a renderer.
  10571. * * `null` - use the original data source for the row rather than plucking
  10572. * data directly from it. This action has effects on two other
  10573. * initialisation options:
  10574. * * `defaultContent` - When null is given as the `data` option and
  10575. * `defaultContent` is specified for the column, the value defined by
  10576. * `defaultContent` will be used for the cell.
  10577. * * `render` - When null is used for the `data` option and the `render`
  10578. * option is specified for the column, the whole data source for the
  10579. * row is used for the renderer.
  10580. * * `function` - the function given will be executed whenever DataTables
  10581. * needs to set or get the data for a cell in the column. The function
  10582. * takes three parameters:
  10583. * * Parameters:
  10584. * * `{array|object}` The data source for the row
  10585. * * `{string}` The type call data requested - this will be 'set' when
  10586. * setting data or 'filter', 'display', 'type', 'sort' or undefined
  10587. * when gathering data. Note that when `undefined` is given for the
  10588. * type DataTables expects to get the raw data for the object back<
  10589. * * `{*}` Data to set when the second parameter is 'set'.
  10590. * * Return:
  10591. * * The return value from the function is not required when 'set' is
  10592. * the type of call, but otherwise the return is what will be used
  10593. * for the data requested.
  10594. *
  10595. * Note that `data` is a getter and setter option. If you just require
  10596. * formatting of data for output, you will likely want to use `render` which
  10597. * is simply a getter and thus simpler to use.
  10598. *
  10599. * Note that prior to DataTables 1.9.2 `data` was called `mDataProp`. The
  10600. * name change reflects the flexibility of this property and is consistent
  10601. * with the naming of mRender. If 'mDataProp' is given, then it will still
  10602. * be used by DataTables, as it automatically maps the old name to the new
  10603. * if required.
  10604. *
  10605. * @type string|int|function|null
  10606. * @default null <i>Use automatically calculated column index</i>
  10607. *
  10608. * @name DataTable.defaults.column.data
  10609. * @dtopt Columns
  10610. *
  10611. * @example
  10612. * // Read table data from objects
  10613. * // JSON structure for each row:
  10614. * // {
  10615. * // "engine": {value},
  10616. * // "browser": {value},
  10617. * // "platform": {value},
  10618. * // "version": {value},
  10619. * // "grade": {value}
  10620. * // }
  10621. * $(document).ready( function() {
  10622. * $('#example').dataTable( {
  10623. * "ajaxSource": "sources/objects.txt",
  10624. * "columns": [
  10625. * { "data": "engine" },
  10626. * { "data": "browser" },
  10627. * { "data": "platform" },
  10628. * { "data": "version" },
  10629. * { "data": "grade" }
  10630. * ]
  10631. * } );
  10632. * } );
  10633. *
  10634. * @example
  10635. * // Read information from deeply nested objects
  10636. * // JSON structure for each row:
  10637. * // {
  10638. * // "engine": {value},
  10639. * // "browser": {value},
  10640. * // "platform": {
  10641. * // "inner": {value}
  10642. * // },
  10643. * // "details": [
  10644. * // {value}, {value}
  10645. * // ]
  10646. * // }
  10647. * $(document).ready( function() {
  10648. * $('#example').dataTable( {
  10649. * "ajaxSource": "sources/deep.txt",
  10650. * "columns": [
  10651. * { "data": "engine" },
  10652. * { "data": "browser" },
  10653. * { "data": "platform.inner" },
  10654. * { "data": "platform.details.0" },
  10655. * { "data": "platform.details.1" }
  10656. * ]
  10657. * } );
  10658. * } );
  10659. *
  10660. * @example
  10661. * // Using `data` as a function to provide different information for
  10662. * // sorting, filtering and display. In this case, currency (price)
  10663. * $(document).ready( function() {
  10664. * $('#example').dataTable( {
  10665. * "columnDefs": [ {
  10666. * "targets": [ 0 ],
  10667. * "data": function ( source, type, val ) {
  10668. * if (type === 'set') {
  10669. * source.price = val;
  10670. * // Store the computed dislay and filter values for efficiency
  10671. * source.price_display = val=="" ? "" : "$"+numberFormat(val);
  10672. * source.price_filter = val=="" ? "" : "$"+numberFormat(val)+" "+val;
  10673. * return;
  10674. * }
  10675. * else if (type === 'display') {
  10676. * return source.price_display;
  10677. * }
  10678. * else if (type === 'filter') {
  10679. * return source.price_filter;
  10680. * }
  10681. * // 'sort', 'type' and undefined all just use the integer
  10682. * return source.price;
  10683. * }
  10684. * } ]
  10685. * } );
  10686. * } );
  10687. *
  10688. * @example
  10689. * // Using default content
  10690. * $(document).ready( function() {
  10691. * $('#example').dataTable( {
  10692. * "columnDefs": [ {
  10693. * "targets": [ 0 ],
  10694. * "data": null,
  10695. * "defaultContent": "Click to edit"
  10696. * } ]
  10697. * } );
  10698. * } );
  10699. *
  10700. * @example
  10701. * // Using array notation - outputting a list from an array
  10702. * $(document).ready( function() {
  10703. * $('#example').dataTable( {
  10704. * "columnDefs": [ {
  10705. * "targets": [ 0 ],
  10706. * "data": "name[, ]"
  10707. * } ]
  10708. * } );
  10709. * } );
  10710. *
  10711. */
  10712. "mData": null,
  10713. /**
  10714. * This property is the rendering partner to `data` and it is suggested that
  10715. * when you want to manipulate data for display (including filtering,
  10716. * sorting etc) without altering the underlying data for the table, use this
  10717. * property. `render` can be considered to be the the read only companion to
  10718. * `data` which is read / write (then as such more complex). Like `data`
  10719. * this option can be given in a number of different ways to effect its
  10720. * behaviour:
  10721. *
  10722. * * `integer` - treated as an array index for the data source. This is the
  10723. * default that DataTables uses (incrementally increased for each column).
  10724. * * `string` - read an object property from the data source. There are
  10725. * three 'special' options that can be used in the string to alter how
  10726. * DataTables reads the data from the source object:
  10727. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10728. * Javascript to read from nested objects, so to can the options
  10729. * specified in `data`. For example: `browser.version` or
  10730. * `browser.name`. If your object parameter name contains a period, use
  10731. * `\\` to escape it - i.e. `first\\.name`.
  10732. * * `[]` - Array notation. DataTables can automatically combine data
  10733. * from and array source, joining the data with the characters provided
  10734. * between the two brackets. For example: `name[, ]` would provide a
  10735. * comma-space separated list from the source array. If no characters
  10736. * are provided between the brackets, the original array source is
  10737. * returned.
  10738. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10739. * execute a function of the name given. For example: `browser()` for a
  10740. * simple function on the data source, `browser.version()` for a
  10741. * function in a nested property or even `browser().version` to get an
  10742. * object property if the function called returns an object.
  10743. * * `object` - use different data for the different data types requested by
  10744. * DataTables ('filter', 'display', 'type' or 'sort'). The property names
  10745. * of the object is the data type the property refers to and the value can
  10746. * defined using an integer, string or function using the same rules as
  10747. * `render` normally does. Note that an `_` option _must_ be specified.
  10748. * This is the default value to use if you haven't specified a value for
  10749. * the data type requested by DataTables.
  10750. * * `function` - the function given will be executed whenever DataTables
  10751. * needs to set or get the data for a cell in the column. The function
  10752. * takes three parameters:
  10753. * * Parameters:
  10754. * * {array|object} The data source for the row (based on `data`)
  10755. * * {string} The type call data requested - this will be 'filter',
  10756. * 'display', 'type' or 'sort'.
  10757. * * {array|object} The full data source for the row (not based on
  10758. * `data`)
  10759. * * Return:
  10760. * * The return value from the function is what will be used for the
  10761. * data requested.
  10762. *
  10763. * @type string|int|function|object|null
  10764. * @default null Use the data source value.
  10765. *
  10766. * @name DataTable.defaults.column.render
  10767. * @dtopt Columns
  10768. *
  10769. * @example
  10770. * // Create a comma separated list from an array of objects
  10771. * $(document).ready( function() {
  10772. * $('#example').dataTable( {
  10773. * "ajaxSource": "sources/deep.txt",
  10774. * "columns": [
  10775. * { "data": "engine" },
  10776. * { "data": "browser" },
  10777. * {
  10778. * "data": "platform",
  10779. * "render": "[, ].name"
  10780. * }
  10781. * ]
  10782. * } );
  10783. * } );
  10784. *
  10785. * @example
  10786. * // Execute a function to obtain data
  10787. * $(document).ready( function() {
  10788. * $('#example').dataTable( {
  10789. * "columnDefs": [ {
  10790. * "targets": [ 0 ],
  10791. * "data": null, // Use the full data source object for the renderer's source
  10792. * "render": "browserName()"
  10793. * } ]
  10794. * } );
  10795. * } );
  10796. *
  10797. * @example
  10798. * // As an object, extracting different data for the different types
  10799. * // This would be used with a data source such as:
  10800. * // { "phone": 5552368, "phone_filter": "5552368 555-2368", "phone_display": "555-2368" }
  10801. * // Here the `phone` integer is used for sorting and type detection, while `phone_filter`
  10802. * // (which has both forms) is used for filtering for if a user inputs either format, while
  10803. * // the formatted phone number is the one that is shown in the table.
  10804. * $(document).ready( function() {
  10805. * $('#example').dataTable( {
  10806. * "columnDefs": [ {
  10807. * "targets": [ 0 ],
  10808. * "data": null, // Use the full data source object for the renderer's source
  10809. * "render": {
  10810. * "_": "phone",
  10811. * "filter": "phone_filter",
  10812. * "display": "phone_display"
  10813. * }
  10814. * } ]
  10815. * } );
  10816. * } );
  10817. *
  10818. * @example
  10819. * // Use as a function to create a link from the data source
  10820. * $(document).ready( function() {
  10821. * $('#example').dataTable( {
  10822. * "columnDefs": [ {
  10823. * "targets": [ 0 ],
  10824. * "data": "download_link",
  10825. * "render": function ( data, type, full ) {
  10826. * return '<a href="'+data+'">Download</a>';
  10827. * }
  10828. * } ]
  10829. * } );
  10830. * } );
  10831. */
  10832. "mRender": null,
  10833. /**
  10834. * Change the cell type created for the column - either TD cells or TH cells. This
  10835. * can be useful as TH cells have semantic meaning in the table body, allowing them
  10836. * to act as a header for a row (you may wish to add scope='row' to the TH elements).
  10837. * @type string
  10838. * @default td
  10839. *
  10840. * @name DataTable.defaults.column.cellType
  10841. * @dtopt Columns
  10842. *
  10843. * @example
  10844. * // Make the first column use TH cells
  10845. * $(document).ready( function() {
  10846. * $('#example').dataTable( {
  10847. * "columnDefs": [ {
  10848. * "targets": [ 0 ],
  10849. * "cellType": "th"
  10850. * } ]
  10851. * } );
  10852. * } );
  10853. */
  10854. "sCellType": "td",
  10855. /**
  10856. * Class to give to each cell in this column.
  10857. * @type string
  10858. * @default <i>Empty string</i>
  10859. *
  10860. * @name DataTable.defaults.column.class
  10861. * @dtopt Columns
  10862. *
  10863. * @example
  10864. * // Using `columnDefs`
  10865. * $(document).ready( function() {
  10866. * $('#example').dataTable( {
  10867. * "columnDefs": [
  10868. * { "class": "my_class", "targets": [ 0 ] }
  10869. * ]
  10870. * } );
  10871. * } );
  10872. *
  10873. * @example
  10874. * // Using `columns`
  10875. * $(document).ready( function() {
  10876. * $('#example').dataTable( {
  10877. * "columns": [
  10878. * { "class": "my_class" },
  10879. * null,
  10880. * null,
  10881. * null,
  10882. * null
  10883. * ]
  10884. * } );
  10885. * } );
  10886. */
  10887. "sClass": "",
  10888. /**
  10889. * When DataTables calculates the column widths to assign to each column,
  10890. * it finds the longest string in each column and then constructs a
  10891. * temporary table and reads the widths from that. The problem with this
  10892. * is that "mmm" is much wider then "iiii", but the latter is a longer
  10893. * string - thus the calculation can go wrong (doing it properly and putting
  10894. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  10895. * a "work around" we provide this option. It will append its value to the
  10896. * text that is found to be the longest string for the column - i.e. padding.
  10897. * Generally you shouldn't need this!
  10898. * @type string
  10899. * @default <i>Empty string<i>
  10900. *
  10901. * @name DataTable.defaults.column.contentPadding
  10902. * @dtopt Columns
  10903. *
  10904. * @example
  10905. * // Using `columns`
  10906. * $(document).ready( function() {
  10907. * $('#example').dataTable( {
  10908. * "columns": [
  10909. * null,
  10910. * null,
  10911. * null,
  10912. * {
  10913. * "contentPadding": "mmm"
  10914. * }
  10915. * ]
  10916. * } );
  10917. * } );
  10918. */
  10919. "sContentPadding": "",
  10920. /**
  10921. * Allows a default value to be given for a column's data, and will be used
  10922. * whenever a null data source is encountered (this can be because `data`
  10923. * is set to null, or because the data source itself is null).
  10924. * @type string
  10925. * @default null
  10926. *
  10927. * @name DataTable.defaults.column.defaultContent
  10928. * @dtopt Columns
  10929. *
  10930. * @example
  10931. * // Using `columnDefs`
  10932. * $(document).ready( function() {
  10933. * $('#example').dataTable( {
  10934. * "columnDefs": [
  10935. * {
  10936. * "data": null,
  10937. * "defaultContent": "Edit",
  10938. * "targets": [ -1 ]
  10939. * }
  10940. * ]
  10941. * } );
  10942. * } );
  10943. *
  10944. * @example
  10945. * // Using `columns`
  10946. * $(document).ready( function() {
  10947. * $('#example').dataTable( {
  10948. * "columns": [
  10949. * null,
  10950. * null,
  10951. * null,
  10952. * {
  10953. * "data": null,
  10954. * "defaultContent": "Edit"
  10955. * }
  10956. * ]
  10957. * } );
  10958. * } );
  10959. */
  10960. "sDefaultContent": null,
  10961. /**
  10962. * This parameter is only used in DataTables' server-side processing. It can
  10963. * be exceptionally useful to know what columns are being displayed on the
  10964. * client side, and to map these to database fields. When defined, the names
  10965. * also allow DataTables to reorder information from the server if it comes
  10966. * back in an unexpected order (i.e. if you switch your columns around on the
  10967. * client-side, your server-side code does not also need updating).
  10968. * @type string
  10969. * @default <i>Empty string</i>
  10970. *
  10971. * @name DataTable.defaults.column.name
  10972. * @dtopt Columns
  10973. *
  10974. * @example
  10975. * // Using `columnDefs`
  10976. * $(document).ready( function() {
  10977. * $('#example').dataTable( {
  10978. * "columnDefs": [
  10979. * { "name": "engine", "targets": [ 0 ] },
  10980. * { "name": "browser", "targets": [ 1 ] },
  10981. * { "name": "platform", "targets": [ 2 ] },
  10982. * { "name": "version", "targets": [ 3 ] },
  10983. * { "name": "grade", "targets": [ 4 ] }
  10984. * ]
  10985. * } );
  10986. * } );
  10987. *
  10988. * @example
  10989. * // Using `columns`
  10990. * $(document).ready( function() {
  10991. * $('#example').dataTable( {
  10992. * "columns": [
  10993. * { "name": "engine" },
  10994. * { "name": "browser" },
  10995. * { "name": "platform" },
  10996. * { "name": "version" },
  10997. * { "name": "grade" }
  10998. * ]
  10999. * } );
  11000. * } );
  11001. */
  11002. "sName": "",
  11003. /**
  11004. * Defines a data source type for the ordering which can be used to read
  11005. * real-time information from the table (updating the internally cached
  11006. * version) prior to ordering. This allows ordering to occur on user
  11007. * editable elements such as form inputs.
  11008. * @type string
  11009. * @default std
  11010. *
  11011. * @name DataTable.defaults.column.orderDataType
  11012. * @dtopt Columns
  11013. *
  11014. * @example
  11015. * // Using `columnDefs`
  11016. * $(document).ready( function() {
  11017. * $('#example').dataTable( {
  11018. * "columnDefs": [
  11019. * { "orderDataType": "dom-text", "targets": [ 2, 3 ] },
  11020. * { "type": "numeric", "targets": [ 3 ] },
  11021. * { "orderDataType": "dom-select", "targets": [ 4 ] },
  11022. * { "orderDataType": "dom-checkbox", "targets": [ 5 ] }
  11023. * ]
  11024. * } );
  11025. * } );
  11026. *
  11027. * @example
  11028. * // Using `columns`
  11029. * $(document).ready( function() {
  11030. * $('#example').dataTable( {
  11031. * "columns": [
  11032. * null,
  11033. * null,
  11034. * { "orderDataType": "dom-text" },
  11035. * { "orderDataType": "dom-text", "type": "numeric" },
  11036. * { "orderDataType": "dom-select" },
  11037. * { "orderDataType": "dom-checkbox" }
  11038. * ]
  11039. * } );
  11040. * } );
  11041. */
  11042. "sSortDataType": "std",
  11043. /**
  11044. * The title of this column.
  11045. * @type string
  11046. * @default null <i>Derived from the 'TH' value for this column in the
  11047. * original HTML table.</i>
  11048. *
  11049. * @name DataTable.defaults.column.title
  11050. * @dtopt Columns
  11051. *
  11052. * @example
  11053. * // Using `columnDefs`
  11054. * $(document).ready( function() {
  11055. * $('#example').dataTable( {
  11056. * "columnDefs": [
  11057. * { "title": "My column title", "targets": [ 0 ] }
  11058. * ]
  11059. * } );
  11060. * } );
  11061. *
  11062. * @example
  11063. * // Using `columns`
  11064. * $(document).ready( function() {
  11065. * $('#example').dataTable( {
  11066. * "columns": [
  11067. * { "title": "My column title" },
  11068. * null,
  11069. * null,
  11070. * null,
  11071. * null
  11072. * ]
  11073. * } );
  11074. * } );
  11075. */
  11076. "sTitle": null,
  11077. /**
  11078. * The type allows you to specify how the data for this column will be
  11079. * ordered. Four types (string, numeric, date and html (which will strip
  11080. * HTML tags before ordering)) are currently available. Note that only date
  11081. * formats understood by Javascript's Date() object will be accepted as type
  11082. * date. For example: "Mar 26, 2008 5:03 PM". May take the values: 'string',
  11083. * 'numeric', 'date' or 'html' (by default). Further types can be adding
  11084. * through plug-ins.
  11085. * @type string
  11086. * @default null <i>Auto-detected from raw data</i>
  11087. *
  11088. * @name DataTable.defaults.column.type
  11089. * @dtopt Columns
  11090. *
  11091. * @example
  11092. * // Using `columnDefs`
  11093. * $(document).ready( function() {
  11094. * $('#example').dataTable( {
  11095. * "columnDefs": [
  11096. * { "type": "html", "targets": [ 0 ] }
  11097. * ]
  11098. * } );
  11099. * } );
  11100. *
  11101. * @example
  11102. * // Using `columns`
  11103. * $(document).ready( function() {
  11104. * $('#example').dataTable( {
  11105. * "columns": [
  11106. * { "type": "html" },
  11107. * null,
  11108. * null,
  11109. * null,
  11110. * null
  11111. * ]
  11112. * } );
  11113. * } );
  11114. */
  11115. "sType": null,
  11116. /**
  11117. * Defining the width of the column, this parameter may take any CSS value
  11118. * (3em, 20px etc). DataTables applies 'smart' widths to columns which have not
  11119. * been given a specific width through this interface ensuring that the table
  11120. * remains readable.
  11121. * @type string
  11122. * @default null <i>Automatic</i>
  11123. *
  11124. * @name DataTable.defaults.column.width
  11125. * @dtopt Columns
  11126. *
  11127. * @example
  11128. * // Using `columnDefs`
  11129. * $(document).ready( function() {
  11130. * $('#example').dataTable( {
  11131. * "columnDefs": [
  11132. * { "width": "20%", "targets": [ 0 ] }
  11133. * ]
  11134. * } );
  11135. * } );
  11136. *
  11137. * @example
  11138. * // Using `columns`
  11139. * $(document).ready( function() {
  11140. * $('#example').dataTable( {
  11141. * "columns": [
  11142. * { "width": "20%" },
  11143. * null,
  11144. * null,
  11145. * null,
  11146. * null
  11147. * ]
  11148. * } );
  11149. * } );
  11150. */
  11151. "sWidth": null
  11152. };
  11153. _fnHungarianMap( DataTable.defaults.column );
  11154. /**
  11155. * DataTables settings object - this holds all the information needed for a
  11156. * given table, including configuration, data and current application of the
  11157. * table options. DataTables does not have a single instance for each DataTable
  11158. * with the settings attached to that instance, but rather instances of the
  11159. * DataTable "class" are created on-the-fly as needed (typically by a
  11160. * $().dataTable() call) and the settings object is then applied to that
  11161. * instance.
  11162. *
  11163. * Note that this object is related to {@link DataTable.defaults} but this
  11164. * one is the internal data store for DataTables's cache of columns. It should
  11165. * NOT be manipulated outside of DataTables. Any configuration should be done
  11166. * through the initialisation options.
  11167. * @namespace
  11168. * @todo Really should attach the settings object to individual instances so we
  11169. * don't need to create new instances on each $().dataTable() call (if the
  11170. * table already exists). It would also save passing oSettings around and
  11171. * into every single function. However, this is a very significant
  11172. * architecture change for DataTables and will almost certainly break
  11173. * backwards compatibility with older installations. This is something that
  11174. * will be done in 2.0.
  11175. */
  11176. DataTable.models.oSettings = {
  11177. /**
  11178. * Primary features of DataTables and their enablement state.
  11179. * @namespace
  11180. */
  11181. "oFeatures": {
  11182. /**
  11183. * Flag to say if DataTables should automatically try to calculate the
  11184. * optimum table and columns widths (true) or not (false).
  11185. * Note that this parameter will be set by the initialisation routine. To
  11186. * set a default use {@link DataTable.defaults}.
  11187. * @type boolean
  11188. */
  11189. "bAutoWidth": null,
  11190. /**
  11191. * Delay the creation of TR and TD elements until they are actually
  11192. * needed by a driven page draw. This can give a significant speed
  11193. * increase for Ajax source and Javascript source data, but makes no
  11194. * difference at all fro DOM and server-side processing tables.
  11195. * Note that this parameter will be set by the initialisation routine. To
  11196. * set a default use {@link DataTable.defaults}.
  11197. * @type boolean
  11198. */
  11199. "bDeferRender": null,
  11200. /**
  11201. * Enable filtering on the table or not. Note that if this is disabled
  11202. * then there is no filtering at all on the table, including fnFilter.
  11203. * To just remove the filtering input use sDom and remove the 'f' option.
  11204. * Note that this parameter will be set by the initialisation routine. To
  11205. * set a default use {@link DataTable.defaults}.
  11206. * @type boolean
  11207. */
  11208. "bFilter": null,
  11209. /**
  11210. * Table information element (the 'Showing x of y records' div) enable
  11211. * flag.
  11212. * Note that this parameter will be set by the initialisation routine. To
  11213. * set a default use {@link DataTable.defaults}.
  11214. * @type boolean
  11215. */
  11216. "bInfo": null,
  11217. /**
  11218. * Present a user control allowing the end user to change the page size
  11219. * when pagination is enabled.
  11220. * Note that this parameter will be set by the initialisation routine. To
  11221. * set a default use {@link DataTable.defaults}.
  11222. * @type boolean
  11223. */
  11224. "bLengthChange": null,
  11225. /**
  11226. * Pagination enabled or not. Note that if this is disabled then length
  11227. * changing must also be disabled.
  11228. * Note that this parameter will be set by the initialisation routine. To
  11229. * set a default use {@link DataTable.defaults}.
  11230. * @type boolean
  11231. */
  11232. "bPaginate": null,
  11233. /**
  11234. * Processing indicator enable flag whenever DataTables is enacting a
  11235. * user request - typically an Ajax request for server-side processing.
  11236. * Note that this parameter will be set by the initialisation routine. To
  11237. * set a default use {@link DataTable.defaults}.
  11238. * @type boolean
  11239. */
  11240. "bProcessing": null,
  11241. /**
  11242. * Server-side processing enabled flag - when enabled DataTables will
  11243. * get all data from the server for every draw - there is no filtering,
  11244. * sorting or paging done on the client-side.
  11245. * Note that this parameter will be set by the initialisation routine. To
  11246. * set a default use {@link DataTable.defaults}.
  11247. * @type boolean
  11248. */
  11249. "bServerSide": null,
  11250. /**
  11251. * Sorting enablement flag.
  11252. * Note that this parameter will be set by the initialisation routine. To
  11253. * set a default use {@link DataTable.defaults}.
  11254. * @type boolean
  11255. */
  11256. "bSort": null,
  11257. /**
  11258. * Multi-column sorting
  11259. * Note that this parameter will be set by the initialisation routine. To
  11260. * set a default use {@link DataTable.defaults}.
  11261. * @type boolean
  11262. */
  11263. "bSortMulti": null,
  11264. /**
  11265. * Apply a class to the columns which are being sorted to provide a
  11266. * visual highlight or not. This can slow things down when enabled since
  11267. * there is a lot of DOM interaction.
  11268. * Note that this parameter will be set by the initialisation routine. To
  11269. * set a default use {@link DataTable.defaults}.
  11270. * @type boolean
  11271. */
  11272. "bSortClasses": null,
  11273. /**
  11274. * State saving enablement flag.
  11275. * Note that this parameter will be set by the initialisation routine. To
  11276. * set a default use {@link DataTable.defaults}.
  11277. * @type boolean
  11278. */
  11279. "bStateSave": null
  11280. },
  11281. /**
  11282. * Scrolling settings for a table.
  11283. * @namespace
  11284. */
  11285. "oScroll": {
  11286. /**
  11287. * When the table is shorter in height than sScrollY, collapse the
  11288. * table container down to the height of the table (when true).
  11289. * Note that this parameter will be set by the initialisation routine. To
  11290. * set a default use {@link DataTable.defaults}.
  11291. * @type boolean
  11292. */
  11293. "bCollapse": null,
  11294. /**
  11295. * Width of the scrollbar for the web-browser's platform. Calculated
  11296. * during table initialisation.
  11297. * @type int
  11298. * @default 0
  11299. */
  11300. "iBarWidth": 0,
  11301. /**
  11302. * Viewport width for horizontal scrolling. Horizontal scrolling is
  11303. * disabled if an empty string.
  11304. * Note that this parameter will be set by the initialisation routine. To
  11305. * set a default use {@link DataTable.defaults}.
  11306. * @type string
  11307. */
  11308. "sX": null,
  11309. /**
  11310. * Width to expand the table to when using x-scrolling. Typically you
  11311. * should not need to use this.
  11312. * Note that this parameter will be set by the initialisation routine. To
  11313. * set a default use {@link DataTable.defaults}.
  11314. * @type string
  11315. * @deprecated
  11316. */
  11317. "sXInner": null,
  11318. /**
  11319. * Viewport height for vertical scrolling. Vertical scrolling is disabled
  11320. * if an empty string.
  11321. * Note that this parameter will be set by the initialisation routine. To
  11322. * set a default use {@link DataTable.defaults}.
  11323. * @type string
  11324. */
  11325. "sY": null
  11326. },
  11327. /**
  11328. * Language information for the table.
  11329. * @namespace
  11330. * @extends DataTable.defaults.oLanguage
  11331. */
  11332. "oLanguage": {
  11333. /**
  11334. * Information callback function. See
  11335. * {@link DataTable.defaults.fnInfoCallback}
  11336. * @type function
  11337. * @default null
  11338. */
  11339. "fnInfoCallback": null
  11340. },
  11341. /**
  11342. * Browser support parameters
  11343. * @namespace
  11344. */
  11345. "oBrowser": {
  11346. /**
  11347. * Indicate if the browser incorrectly calculates width:100% inside a
  11348. * scrolling element (IE6/7)
  11349. * @type boolean
  11350. * @default false
  11351. */
  11352. "bScrollOversize": false,
  11353. /**
  11354. * Determine if the vertical scrollbar is on the right or left of the
  11355. * scrolling container - needed for rtl language layout, although not
  11356. * all browsers move the scrollbar (Safari).
  11357. * @type boolean
  11358. * @default false
  11359. */
  11360. "bScrollbarLeft": false,
  11361. /**
  11362. * Flag for if `getBoundingClientRect` is fully supported or not
  11363. * @type boolean
  11364. * @default false
  11365. */
  11366. "bBounding": false,
  11367. /**
  11368. * Browser scrollbar width
  11369. * @type integer
  11370. * @default 0
  11371. */
  11372. "barWidth": 0
  11373. },
  11374. "ajax": null,
  11375. /**
  11376. * Array referencing the nodes which are used for the features. The
  11377. * parameters of this object match what is allowed by sDom - i.e.
  11378. * <ul>
  11379. * <li>'l' - Length changing</li>
  11380. * <li>'f' - Filtering input</li>
  11381. * <li>'t' - The table!</li>
  11382. * <li>'i' - Information</li>
  11383. * <li>'p' - Pagination</li>
  11384. * <li>'r' - pRocessing</li>
  11385. * </ul>
  11386. * @type array
  11387. * @default []
  11388. */
  11389. "aanFeatures": [],
  11390. /**
  11391. * Store data information - see {@link DataTable.models.oRow} for detailed
  11392. * information.
  11393. * @type array
  11394. * @default []
  11395. */
  11396. "aoData": [],
  11397. /**
  11398. * Array of indexes which are in the current display (after filtering etc)
  11399. * @type array
  11400. * @default []
  11401. */
  11402. "aiDisplay": [],
  11403. /**
  11404. * Array of indexes for display - no filtering
  11405. * @type array
  11406. * @default []
  11407. */
  11408. "aiDisplayMaster": [],
  11409. /**
  11410. * Map of row ids to data indexes
  11411. * @type object
  11412. * @default {}
  11413. */
  11414. "aIds": {},
  11415. /**
  11416. * Store information about each column that is in use
  11417. * @type array
  11418. * @default []
  11419. */
  11420. "aoColumns": [],
  11421. /**
  11422. * Store information about the table's header
  11423. * @type array
  11424. * @default []
  11425. */
  11426. "aoHeader": [],
  11427. /**
  11428. * Store information about the table's footer
  11429. * @type array
  11430. * @default []
  11431. */
  11432. "aoFooter": [],
  11433. /**
  11434. * Store the applied global search information in case we want to force a
  11435. * research or compare the old search to a new one.
  11436. * Note that this parameter will be set by the initialisation routine. To
  11437. * set a default use {@link DataTable.defaults}.
  11438. * @namespace
  11439. * @extends DataTable.models.oSearch
  11440. */
  11441. "oPreviousSearch": {},
  11442. /**
  11443. * Store the applied search for each column - see
  11444. * {@link DataTable.models.oSearch} for the format that is used for the
  11445. * filtering information for each column.
  11446. * @type array
  11447. * @default []
  11448. */
  11449. "aoPreSearchCols": [],
  11450. /**
  11451. * Sorting that is applied to the table. Note that the inner arrays are
  11452. * used in the following manner:
  11453. * <ul>
  11454. * <li>Index 0 - column number</li>
  11455. * <li>Index 1 - current sorting direction</li>
  11456. * </ul>
  11457. * Note that this parameter will be set by the initialisation routine. To
  11458. * set a default use {@link DataTable.defaults}.
  11459. * @type array
  11460. * @todo These inner arrays should really be objects
  11461. */
  11462. "aaSorting": null,
  11463. /**
  11464. * Sorting that is always applied to the table (i.e. prefixed in front of
  11465. * aaSorting).
  11466. * Note that this parameter will be set by the initialisation routine. To
  11467. * set a default use {@link DataTable.defaults}.
  11468. * @type array
  11469. * @default []
  11470. */
  11471. "aaSortingFixed": [],
  11472. /**
  11473. * Classes to use for the striping of a table.
  11474. * Note that this parameter will be set by the initialisation routine. To
  11475. * set a default use {@link DataTable.defaults}.
  11476. * @type array
  11477. * @default []
  11478. */
  11479. "asStripeClasses": null,
  11480. /**
  11481. * If restoring a table - we should restore its striping classes as well
  11482. * @type array
  11483. * @default []
  11484. */
  11485. "asDestroyStripes": [],
  11486. /**
  11487. * If restoring a table - we should restore its width
  11488. * @type int
  11489. * @default 0
  11490. */
  11491. "sDestroyWidth": 0,
  11492. /**
  11493. * Callback functions array for every time a row is inserted (i.e. on a draw).
  11494. * @type array
  11495. * @default []
  11496. */
  11497. "aoRowCallback": [],
  11498. /**
  11499. * Callback functions for the header on each draw.
  11500. * @type array
  11501. * @default []
  11502. */
  11503. "aoHeaderCallback": [],
  11504. /**
  11505. * Callback function for the footer on each draw.
  11506. * @type array
  11507. * @default []
  11508. */
  11509. "aoFooterCallback": [],
  11510. /**
  11511. * Array of callback functions for draw callback functions
  11512. * @type array
  11513. * @default []
  11514. */
  11515. "aoDrawCallback": [],
  11516. /**
  11517. * Array of callback functions for row created function
  11518. * @type array
  11519. * @default []
  11520. */
  11521. "aoRowCreatedCallback": [],
  11522. /**
  11523. * Callback functions for just before the table is redrawn. A return of
  11524. * false will be used to cancel the draw.
  11525. * @type array
  11526. * @default []
  11527. */
  11528. "aoPreDrawCallback": [],
  11529. /**
  11530. * Callback functions for when the table has been initialised.
  11531. * @type array
  11532. * @default []
  11533. */
  11534. "aoInitComplete": [],
  11535. /**
  11536. * Callbacks for modifying the settings to be stored for state saving, prior to
  11537. * saving state.
  11538. * @type array
  11539. * @default []
  11540. */
  11541. "aoStateSaveParams": [],
  11542. /**
  11543. * Callbacks for modifying the settings that have been stored for state saving
  11544. * prior to using the stored values to restore the state.
  11545. * @type array
  11546. * @default []
  11547. */
  11548. "aoStateLoadParams": [],
  11549. /**
  11550. * Callbacks for operating on the settings object once the saved state has been
  11551. * loaded
  11552. * @type array
  11553. * @default []
  11554. */
  11555. "aoStateLoaded": [],
  11556. /**
  11557. * Cache the table ID for quick access
  11558. * @type string
  11559. * @default <i>Empty string</i>
  11560. */
  11561. "sTableId": "",
  11562. /**
  11563. * The TABLE node for the main table
  11564. * @type node
  11565. * @default null
  11566. */
  11567. "nTable": null,
  11568. /**
  11569. * Permanent ref to the thead element
  11570. * @type node
  11571. * @default null
  11572. */
  11573. "nTHead": null,
  11574. /**
  11575. * Permanent ref to the tfoot element - if it exists
  11576. * @type node
  11577. * @default null
  11578. */
  11579. "nTFoot": null,
  11580. /**
  11581. * Permanent ref to the tbody element
  11582. * @type node
  11583. * @default null
  11584. */
  11585. "nTBody": null,
  11586. /**
  11587. * Cache the wrapper node (contains all DataTables controlled elements)
  11588. * @type node
  11589. * @default null
  11590. */
  11591. "nTableWrapper": null,
  11592. /**
  11593. * Indicate if when using server-side processing the loading of data
  11594. * should be deferred until the second draw.
  11595. * Note that this parameter will be set by the initialisation routine. To
  11596. * set a default use {@link DataTable.defaults}.
  11597. * @type boolean
  11598. * @default false
  11599. */
  11600. "bDeferLoading": false,
  11601. /**
  11602. * Indicate if all required information has been read in
  11603. * @type boolean
  11604. * @default false
  11605. */
  11606. "bInitialised": false,
  11607. /**
  11608. * Information about open rows. Each object in the array has the parameters
  11609. * 'nTr' and 'nParent'
  11610. * @type array
  11611. * @default []
  11612. */
  11613. "aoOpenRows": [],
  11614. /**
  11615. * Dictate the positioning of DataTables' control elements - see
  11616. * {@link DataTable.model.oInit.sDom}.
  11617. * Note that this parameter will be set by the initialisation routine. To
  11618. * set a default use {@link DataTable.defaults}.
  11619. * @type string
  11620. * @default null
  11621. */
  11622. "sDom": null,
  11623. /**
  11624. * Search delay (in mS)
  11625. * @type integer
  11626. * @default null
  11627. */
  11628. "searchDelay": null,
  11629. /**
  11630. * Which type of pagination should be used.
  11631. * Note that this parameter will be set by the initialisation routine. To
  11632. * set a default use {@link DataTable.defaults}.
  11633. * @type string
  11634. * @default two_button
  11635. */
  11636. "sPaginationType": "two_button",
  11637. /**
  11638. * The state duration (for `stateSave`) in seconds.
  11639. * Note that this parameter will be set by the initialisation routine. To
  11640. * set a default use {@link DataTable.defaults}.
  11641. * @type int
  11642. * @default 0
  11643. */
  11644. "iStateDuration": 0,
  11645. /**
  11646. * Array of callback functions for state saving. Each array element is an
  11647. * object with the following parameters:
  11648. * <ul>
  11649. * <li>function:fn - function to call. Takes two parameters, oSettings
  11650. * and the JSON string to save that has been thus far created. Returns
  11651. * a JSON string to be inserted into a json object
  11652. * (i.e. '"param": [ 0, 1, 2]')</li>
  11653. * <li>string:sName - name of callback</li>
  11654. * </ul>
  11655. * @type array
  11656. * @default []
  11657. */
  11658. "aoStateSave": [],
  11659. /**
  11660. * Array of callback functions for state loading. Each array element is an
  11661. * object with the following parameters:
  11662. * <ul>
  11663. * <li>function:fn - function to call. Takes two parameters, oSettings
  11664. * and the object stored. May return false to cancel state loading</li>
  11665. * <li>string:sName - name of callback</li>
  11666. * </ul>
  11667. * @type array
  11668. * @default []
  11669. */
  11670. "aoStateLoad": [],
  11671. /**
  11672. * State that was saved. Useful for back reference
  11673. * @type object
  11674. * @default null
  11675. */
  11676. "oSavedState": null,
  11677. /**
  11678. * State that was loaded. Useful for back reference
  11679. * @type object
  11680. * @default null
  11681. */
  11682. "oLoadedState": null,
  11683. /**
  11684. * Source url for AJAX data for the table.
  11685. * Note that this parameter will be set by the initialisation routine. To
  11686. * set a default use {@link DataTable.defaults}.
  11687. * @type string
  11688. * @default null
  11689. */
  11690. "sAjaxSource": null,
  11691. /**
  11692. * Property from a given object from which to read the table data from. This
  11693. * can be an empty string (when not server-side processing), in which case
  11694. * it is assumed an an array is given directly.
  11695. * Note that this parameter will be set by the initialisation routine. To
  11696. * set a default use {@link DataTable.defaults}.
  11697. * @type string
  11698. */
  11699. "sAjaxDataProp": null,
  11700. /**
  11701. * Note if draw should be blocked while getting data
  11702. * @type boolean
  11703. * @default true
  11704. */
  11705. "bAjaxDataGet": true,
  11706. /**
  11707. * The last jQuery XHR object that was used for server-side data gathering.
  11708. * This can be used for working with the XHR information in one of the
  11709. * callbacks
  11710. * @type object
  11711. * @default null
  11712. */
  11713. "jqXHR": null,
  11714. /**
  11715. * JSON returned from the server in the last Ajax request
  11716. * @type object
  11717. * @default undefined
  11718. */
  11719. "json": undefined,
  11720. /**
  11721. * Data submitted as part of the last Ajax request
  11722. * @type object
  11723. * @default undefined
  11724. */
  11725. "oAjaxData": undefined,
  11726. /**
  11727. * Function to get the server-side data.
  11728. * Note that this parameter will be set by the initialisation routine. To
  11729. * set a default use {@link DataTable.defaults}.
  11730. * @type function
  11731. */
  11732. "fnServerData": null,
  11733. /**
  11734. * Functions which are called prior to sending an Ajax request so extra
  11735. * parameters can easily be sent to the server
  11736. * @type array
  11737. * @default []
  11738. */
  11739. "aoServerParams": [],
  11740. /**
  11741. * Send the XHR HTTP method - GET or POST (could be PUT or DELETE if
  11742. * required).
  11743. * Note that this parameter will be set by the initialisation routine. To
  11744. * set a default use {@link DataTable.defaults}.
  11745. * @type string
  11746. */
  11747. "sServerMethod": null,
  11748. /**
  11749. * Format numbers for display.
  11750. * Note that this parameter will be set by the initialisation routine. To
  11751. * set a default use {@link DataTable.defaults}.
  11752. * @type function
  11753. */
  11754. "fnFormatNumber": null,
  11755. /**
  11756. * List of options that can be used for the user selectable length menu.
  11757. * Note that this parameter will be set by the initialisation routine. To
  11758. * set a default use {@link DataTable.defaults}.
  11759. * @type array
  11760. * @default []
  11761. */
  11762. "aLengthMenu": null,
  11763. /**
  11764. * Counter for the draws that the table does. Also used as a tracker for
  11765. * server-side processing
  11766. * @type int
  11767. * @default 0
  11768. */
  11769. "iDraw": 0,
  11770. /**
  11771. * Indicate if a redraw is being done - useful for Ajax
  11772. * @type boolean
  11773. * @default false
  11774. */
  11775. "bDrawing": false,
  11776. /**
  11777. * Draw index (iDraw) of the last error when parsing the returned data
  11778. * @type int
  11779. * @default -1
  11780. */
  11781. "iDrawError": -1,
  11782. /**
  11783. * Paging display length
  11784. * @type int
  11785. * @default 10
  11786. */
  11787. "_iDisplayLength": 10,
  11788. /**
  11789. * Paging start point - aiDisplay index
  11790. * @type int
  11791. * @default 0
  11792. */
  11793. "_iDisplayStart": 0,
  11794. /**
  11795. * Server-side processing - number of records in the result set
  11796. * (i.e. before filtering), Use fnRecordsTotal rather than
  11797. * this property to get the value of the number of records, regardless of
  11798. * the server-side processing setting.
  11799. * @type int
  11800. * @default 0
  11801. * @private
  11802. */
  11803. "_iRecordsTotal": 0,
  11804. /**
  11805. * Server-side processing - number of records in the current display set
  11806. * (i.e. after filtering). Use fnRecordsDisplay rather than
  11807. * this property to get the value of the number of records, regardless of
  11808. * the server-side processing setting.
  11809. * @type boolean
  11810. * @default 0
  11811. * @private
  11812. */
  11813. "_iRecordsDisplay": 0,
  11814. /**
  11815. * Flag to indicate if jQuery UI marking and classes should be used.
  11816. * Note that this parameter will be set by the initialisation routine. To
  11817. * set a default use {@link DataTable.defaults}.
  11818. * @type boolean
  11819. */
  11820. "bJUI": null,
  11821. /**
  11822. * The classes to use for the table
  11823. * @type object
  11824. * @default {}
  11825. */
  11826. "oClasses": {},
  11827. /**
  11828. * Flag attached to the settings object so you can check in the draw
  11829. * callback if filtering has been done in the draw. Deprecated in favour of
  11830. * events.
  11831. * @type boolean
  11832. * @default false
  11833. * @deprecated
  11834. */
  11835. "bFiltered": false,
  11836. /**
  11837. * Flag attached to the settings object so you can check in the draw
  11838. * callback if sorting has been done in the draw. Deprecated in favour of
  11839. * events.
  11840. * @type boolean
  11841. * @default false
  11842. * @deprecated
  11843. */
  11844. "bSorted": false,
  11845. /**
  11846. * Indicate that if multiple rows are in the header and there is more than
  11847. * one unique cell per column, if the top one (true) or bottom one (false)
  11848. * should be used for sorting / title by DataTables.
  11849. * Note that this parameter will be set by the initialisation routine. To
  11850. * set a default use {@link DataTable.defaults}.
  11851. * @type boolean
  11852. */
  11853. "bSortCellsTop": null,
  11854. /**
  11855. * Initialisation object that is used for the table
  11856. * @type object
  11857. * @default null
  11858. */
  11859. "oInit": null,
  11860. /**
  11861. * Destroy callback functions - for plug-ins to attach themselves to the
  11862. * destroy so they can clean up markup and events.
  11863. * @type array
  11864. * @default []
  11865. */
  11866. "aoDestroyCallback": [],
  11867. /**
  11868. * Get the number of records in the current record set, before filtering
  11869. * @type function
  11870. */
  11871. "fnRecordsTotal": function ()
  11872. {
  11873. return _fnDataSource( this ) == 'ssp' ?
  11874. this._iRecordsTotal * 1 :
  11875. this.aiDisplayMaster.length;
  11876. },
  11877. /**
  11878. * Get the number of records in the current record set, after filtering
  11879. * @type function
  11880. */
  11881. "fnRecordsDisplay": function ()
  11882. {
  11883. return _fnDataSource( this ) == 'ssp' ?
  11884. this._iRecordsDisplay * 1 :
  11885. this.aiDisplay.length;
  11886. },
  11887. /**
  11888. * Get the display end point - aiDisplay index
  11889. * @type function
  11890. */
  11891. "fnDisplayEnd": function ()
  11892. {
  11893. var
  11894. len = this._iDisplayLength,
  11895. start = this._iDisplayStart,
  11896. calc = start + len,
  11897. records = this.aiDisplay.length,
  11898. features = this.oFeatures,
  11899. paginate = features.bPaginate;
  11900. if ( features.bServerSide ) {
  11901. return paginate === false || len === -1 ?
  11902. start + records :
  11903. Math.min( start+len, this._iRecordsDisplay );
  11904. }
  11905. else {
  11906. return ! paginate || calc>records || len===-1 ?
  11907. records :
  11908. calc;
  11909. }
  11910. },
  11911. /**
  11912. * The DataTables object for this table
  11913. * @type object
  11914. * @default null
  11915. */
  11916. "oInstance": null,
  11917. /**
  11918. * Unique identifier for each instance of the DataTables object. If there
  11919. * is an ID on the table node, then it takes that value, otherwise an
  11920. * incrementing internal counter is used.
  11921. * @type string
  11922. * @default null
  11923. */
  11924. "sInstance": null,
  11925. /**
  11926. * tabindex attribute value that is added to DataTables control elements, allowing
  11927. * keyboard navigation of the table and its controls.
  11928. */
  11929. "iTabIndex": 0,
  11930. /**
  11931. * DIV container for the footer scrolling table if scrolling
  11932. */
  11933. "nScrollHead": null,
  11934. /**
  11935. * DIV container for the footer scrolling table if scrolling
  11936. */
  11937. "nScrollFoot": null,
  11938. /**
  11939. * Last applied sort
  11940. * @type array
  11941. * @default []
  11942. */
  11943. "aLastSort": [],
  11944. /**
  11945. * Stored plug-in instances
  11946. * @type object
  11947. * @default {}
  11948. */
  11949. "oPlugins": {},
  11950. /**
  11951. * Function used to get a row's id from the row's data
  11952. * @type function
  11953. * @default null
  11954. */
  11955. "rowIdFn": null,
  11956. /**
  11957. * Data location where to store a row's id
  11958. * @type string
  11959. * @default null
  11960. */
  11961. "rowId": null
  11962. };
  11963. /**
  11964. * Extension object for DataTables that is used to provide all extension
  11965. * options.
  11966. *
  11967. * Note that the `DataTable.ext` object is available through
  11968. * `jQuery.fn.dataTable.ext` where it may be accessed and manipulated. It is
  11969. * also aliased to `jQuery.fn.dataTableExt` for historic reasons.
  11970. * @namespace
  11971. * @extends DataTable.models.ext
  11972. */
  11973. /**
  11974. * DataTables extensions
  11975. *
  11976. * This namespace acts as a collection area for plug-ins that can be used to
  11977. * extend DataTables capabilities. Indeed many of the build in methods
  11978. * use this method to provide their own capabilities (sorting methods for
  11979. * example).
  11980. *
  11981. * Note that this namespace is aliased to `jQuery.fn.dataTableExt` for legacy
  11982. * reasons
  11983. *
  11984. * @namespace
  11985. */
  11986. DataTable.ext = _ext = {
  11987. /**
  11988. * Buttons. For use with the Buttons extension for DataTables. This is
  11989. * defined here so other extensions can define buttons regardless of load
  11990. * order. It is _not_ used by DataTables core.
  11991. *
  11992. * @type object
  11993. * @default {}
  11994. */
  11995. buttons: {},
  11996. /**
  11997. * Element class names
  11998. *
  11999. * @type object
  12000. * @default {}
  12001. */
  12002. classes: {},
  12003. /**
  12004. * DataTables build type (expanded by the download builder)
  12005. *
  12006. * @type string
  12007. */
  12008. builder: "-source-",
  12009. /**
  12010. * Error reporting.
  12011. *
  12012. * How should DataTables report an error. Can take the value 'alert',
  12013. * 'throw', 'none' or a function.
  12014. *
  12015. * @type string|function
  12016. * @default alert
  12017. */
  12018. errMode: "alert",
  12019. /**
  12020. * Feature plug-ins.
  12021. *
  12022. * This is an array of objects which describe the feature plug-ins that are
  12023. * available to DataTables. These feature plug-ins are then available for
  12024. * use through the `dom` initialisation option.
  12025. *
  12026. * Each feature plug-in is described by an object which must have the
  12027. * following properties:
  12028. *
  12029. * * `fnInit` - function that is used to initialise the plug-in,
  12030. * * `cFeature` - a character so the feature can be enabled by the `dom`
  12031. * instillation option. This is case sensitive.
  12032. *
  12033. * The `fnInit` function has the following input parameters:
  12034. *
  12035. * 1. `{object}` DataTables settings object: see
  12036. * {@link DataTable.models.oSettings}
  12037. *
  12038. * And the following return is expected:
  12039. *
  12040. * * {node|null} The element which contains your feature. Note that the
  12041. * return may also be void if your plug-in does not require to inject any
  12042. * DOM elements into DataTables control (`dom`) - for example this might
  12043. * be useful when developing a plug-in which allows table control via
  12044. * keyboard entry
  12045. *
  12046. * @type array
  12047. *
  12048. * @example
  12049. * $.fn.dataTable.ext.features.push( {
  12050. * "fnInit": function( oSettings ) {
  12051. * return new TableTools( { "oDTSettings": oSettings } );
  12052. * },
  12053. * "cFeature": "T"
  12054. * } );
  12055. */
  12056. feature: [],
  12057. /**
  12058. * Row searching.
  12059. *
  12060. * This method of searching is complimentary to the default type based
  12061. * searching, and a lot more comprehensive as it allows you complete control
  12062. * over the searching logic. Each element in this array is a function
  12063. * (parameters described below) that is called for every row in the table,
  12064. * and your logic decides if it should be included in the searching data set
  12065. * or not.
  12066. *
  12067. * Searching functions have the following input parameters:
  12068. *
  12069. * 1. `{object}` DataTables settings object: see
  12070. * {@link DataTable.models.oSettings}
  12071. * 2. `{array|object}` Data for the row to be processed (same as the
  12072. * original format that was passed in as the data source, or an array
  12073. * from a DOM data source
  12074. * 3. `{int}` Row index ({@link DataTable.models.oSettings.aoData}), which
  12075. * can be useful to retrieve the `TR` element if you need DOM interaction.
  12076. *
  12077. * And the following return is expected:
  12078. *
  12079. * * {boolean} Include the row in the searched result set (true) or not
  12080. * (false)
  12081. *
  12082. * Note that as with the main search ability in DataTables, technically this
  12083. * is "filtering", since it is subtractive. However, for consistency in
  12084. * naming we call it searching here.
  12085. *
  12086. * @type array
  12087. * @default []
  12088. *
  12089. * @example
  12090. * // The following example shows custom search being applied to the
  12091. * // fourth column (i.e. the data[3] index) based on two input values
  12092. * // from the end-user, matching the data in a certain range.
  12093. * $.fn.dataTable.ext.search.push(
  12094. * function( settings, data, dataIndex ) {
  12095. * var min = document.getElementById('min').value * 1;
  12096. * var max = document.getElementById('max').value * 1;
  12097. * var version = data[3] == "-" ? 0 : data[3]*1;
  12098. *
  12099. * if ( min == "" && max == "" ) {
  12100. * return true;
  12101. * }
  12102. * else if ( min == "" && version < max ) {
  12103. * return true;
  12104. * }
  12105. * else if ( min < version && "" == max ) {
  12106. * return true;
  12107. * }
  12108. * else if ( min < version && version < max ) {
  12109. * return true;
  12110. * }
  12111. * return false;
  12112. * }
  12113. * );
  12114. */
  12115. search: [],
  12116. /**
  12117. * Selector extensions
  12118. *
  12119. * The `selector` option can be used to extend the options available for the
  12120. * selector modifier options (`selector-modifier` object data type) that
  12121. * each of the three built in selector types offer (row, column and cell +
  12122. * their plural counterparts). For example the Select extension uses this
  12123. * mechanism to provide an option to select only rows, columns and cells
  12124. * that have been marked as selected by the end user (`{selected: true}`),
  12125. * which can be used in conjunction with the existing built in selector
  12126. * options.
  12127. *
  12128. * Each property is an array to which functions can be pushed. The functions
  12129. * take three attributes:
  12130. *
  12131. * * Settings object for the host table
  12132. * * Options object (`selector-modifier` object type)
  12133. * * Array of selected item indexes
  12134. *
  12135. * The return is an array of the resulting item indexes after the custom
  12136. * selector has been applied.
  12137. *
  12138. * @type object
  12139. */
  12140. selector: {
  12141. cell: [],
  12142. column: [],
  12143. row: []
  12144. },
  12145. /**
  12146. * Internal functions, exposed for used in plug-ins.
  12147. *
  12148. * Please note that you should not need to use the internal methods for
  12149. * anything other than a plug-in (and even then, try to avoid if possible).
  12150. * The internal function may change between releases.
  12151. *
  12152. * @type object
  12153. * @default {}
  12154. */
  12155. internal: {},
  12156. /**
  12157. * Legacy configuration options. Enable and disable legacy options that
  12158. * are available in DataTables.
  12159. *
  12160. * @type object
  12161. */
  12162. legacy: {
  12163. /**
  12164. * Enable / disable DataTables 1.9 compatible server-side processing
  12165. * requests
  12166. *
  12167. * @type boolean
  12168. * @default null
  12169. */
  12170. ajax: null
  12171. },
  12172. /**
  12173. * Pagination plug-in methods.
  12174. *
  12175. * Each entry in this object is a function and defines which buttons should
  12176. * be shown by the pagination rendering method that is used for the table:
  12177. * {@link DataTable.ext.renderer.pageButton}. The renderer addresses how the
  12178. * buttons are displayed in the document, while the functions here tell it
  12179. * what buttons to display. This is done by returning an array of button
  12180. * descriptions (what each button will do).
  12181. *
  12182. * Pagination types (the four built in options and any additional plug-in
  12183. * options defined here) can be used through the `paginationType`
  12184. * initialisation parameter.
  12185. *
  12186. * The functions defined take two parameters:
  12187. *
  12188. * 1. `{int} page` The current page index
  12189. * 2. `{int} pages` The number of pages in the table
  12190. *
  12191. * Each function is expected to return an array where each element of the
  12192. * array can be one of:
  12193. *
  12194. * * `first` - Jump to first page when activated
  12195. * * `last` - Jump to last page when activated
  12196. * * `previous` - Show previous page when activated
  12197. * * `next` - Show next page when activated
  12198. * * `{int}` - Show page of the index given
  12199. * * `{array}` - A nested array containing the above elements to add a
  12200. * containing 'DIV' element (might be useful for styling).
  12201. *
  12202. * Note that DataTables v1.9- used this object slightly differently whereby
  12203. * an object with two functions would be defined for each plug-in. That
  12204. * ability is still supported by DataTables 1.10+ to provide backwards
  12205. * compatibility, but this option of use is now decremented and no longer
  12206. * documented in DataTables 1.10+.
  12207. *
  12208. * @type object
  12209. * @default {}
  12210. *
  12211. * @example
  12212. * // Show previous, next and current page buttons only
  12213. * $.fn.dataTableExt.oPagination.current = function ( page, pages ) {
  12214. * return [ 'previous', page, 'next' ];
  12215. * };
  12216. */
  12217. pager: {},
  12218. renderer: {
  12219. pageButton: {},
  12220. header: {}
  12221. },
  12222. /**
  12223. * Ordering plug-ins - custom data source
  12224. *
  12225. * The extension options for ordering of data available here is complimentary
  12226. * to the default type based ordering that DataTables typically uses. It
  12227. * allows much greater control over the the data that is being used to
  12228. * order a column, but is necessarily therefore more complex.
  12229. *
  12230. * This type of ordering is useful if you want to do ordering based on data
  12231. * live from the DOM (for example the contents of an 'input' element) rather
  12232. * than just the static string that DataTables knows of.
  12233. *
  12234. * The way these plug-ins work is that you create an array of the values you
  12235. * wish to be ordering for the column in question and then return that
  12236. * array. The data in the array much be in the index order of the rows in
  12237. * the table (not the currently ordering order!). Which order data gathering
  12238. * function is run here depends on the `dt-init columns.orderDataType`
  12239. * parameter that is used for the column (if any).
  12240. *
  12241. * The functions defined take two parameters:
  12242. *
  12243. * 1. `{object}` DataTables settings object: see
  12244. * {@link DataTable.models.oSettings}
  12245. * 2. `{int}` Target column index
  12246. *
  12247. * Each function is expected to return an array:
  12248. *
  12249. * * `{array}` Data for the column to be ordering upon
  12250. *
  12251. * @type array
  12252. *
  12253. * @example
  12254. * // Ordering using `input` node values
  12255. * $.fn.dataTable.ext.order['dom-text'] = function ( settings, col )
  12256. * {
  12257. * return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
  12258. * return $('input', td).val();
  12259. * } );
  12260. * }
  12261. */
  12262. order: {},
  12263. /**
  12264. * Type based plug-ins.
  12265. *
  12266. * Each column in DataTables has a type assigned to it, either by automatic
  12267. * detection or by direct assignment using the `type` option for the column.
  12268. * The type of a column will effect how it is ordering and search (plug-ins
  12269. * can also make use of the column type if required).
  12270. *
  12271. * @namespace
  12272. */
  12273. type: {
  12274. /**
  12275. * Type detection functions.
  12276. *
  12277. * The functions defined in this object are used to automatically detect
  12278. * a column's type, making initialisation of DataTables super easy, even
  12279. * when complex data is in the table.
  12280. *
  12281. * The functions defined take two parameters:
  12282. *
  12283. * 1. `{*}` Data from the column cell to be analysed
  12284. * 2. `{settings}` DataTables settings object. This can be used to
  12285. * perform context specific type detection - for example detection
  12286. * based on language settings such as using a comma for a decimal
  12287. * place. Generally speaking the options from the settings will not
  12288. * be required
  12289. *
  12290. * Each function is expected to return:
  12291. *
  12292. * * `{string|null}` Data type detected, or null if unknown (and thus
  12293. * pass it on to the other type detection functions.
  12294. *
  12295. * @type array
  12296. *
  12297. * @example
  12298. * // Currency type detection plug-in:
  12299. * $.fn.dataTable.ext.type.detect.push(
  12300. * function ( data, settings ) {
  12301. * // Check the numeric part
  12302. * if ( ! $.isNumeric( data.substring(1) ) ) {
  12303. * return null;
  12304. * }
  12305. *
  12306. * // Check prefixed by currency
  12307. * if ( data.charAt(0) == '$' || data.charAt(0) == '&pound;' ) {
  12308. * return 'currency';
  12309. * }
  12310. * return null;
  12311. * }
  12312. * );
  12313. */
  12314. detect: [],
  12315. /**
  12316. * Type based search formatting.
  12317. *
  12318. * The type based searching functions can be used to pre-format the
  12319. * data to be search on. For example, it can be used to strip HTML
  12320. * tags or to de-format telephone numbers for numeric only searching.
  12321. *
  12322. * Note that is a search is not defined for a column of a given type,
  12323. * no search formatting will be performed.
  12324. *
  12325. * Pre-processing of searching data plug-ins - When you assign the sType
  12326. * for a column (or have it automatically detected for you by DataTables
  12327. * or a type detection plug-in), you will typically be using this for
  12328. * custom sorting, but it can also be used to provide custom searching
  12329. * by allowing you to pre-processing the data and returning the data in
  12330. * the format that should be searched upon. This is done by adding
  12331. * functions this object with a parameter name which matches the sType
  12332. * for that target column. This is the corollary of <i>afnSortData</i>
  12333. * for searching data.
  12334. *
  12335. * The functions defined take a single parameter:
  12336. *
  12337. * 1. `{*}` Data from the column cell to be prepared for searching
  12338. *
  12339. * Each function is expected to return:
  12340. *
  12341. * * `{string|null}` Formatted string that will be used for the searching.
  12342. *
  12343. * @type object
  12344. * @default {}
  12345. *
  12346. * @example
  12347. * $.fn.dataTable.ext.type.search['title-numeric'] = function ( d ) {
  12348. * return d.replace(/\n/g," ").replace( /<.*?>/g, "" );
  12349. * }
  12350. */
  12351. search: {},
  12352. /**
  12353. * Type based ordering.
  12354. *
  12355. * The column type tells DataTables what ordering to apply to the table
  12356. * when a column is sorted upon. The order for each type that is defined,
  12357. * is defined by the functions available in this object.
  12358. *
  12359. * Each ordering option can be described by three properties added to
  12360. * this object:
  12361. *
  12362. * * `{type}-pre` - Pre-formatting function
  12363. * * `{type}-asc` - Ascending order function
  12364. * * `{type}-desc` - Descending order function
  12365. *
  12366. * All three can be used together, only `{type}-pre` or only
  12367. * `{type}-asc` and `{type}-desc` together. It is generally recommended
  12368. * that only `{type}-pre` is used, as this provides the optimal
  12369. * implementation in terms of speed, although the others are provided
  12370. * for compatibility with existing Javascript sort functions.
  12371. *
  12372. * `{type}-pre`: Functions defined take a single parameter:
  12373. *
  12374. * 1. `{*}` Data from the column cell to be prepared for ordering
  12375. *
  12376. * And return:
  12377. *
  12378. * * `{*}` Data to be sorted upon
  12379. *
  12380. * `{type}-asc` and `{type}-desc`: Functions are typical Javascript sort
  12381. * functions, taking two parameters:
  12382. *
  12383. * 1. `{*}` Data to compare to the second parameter
  12384. * 2. `{*}` Data to compare to the first parameter
  12385. *
  12386. * And returning:
  12387. *
  12388. * * `{*}` Ordering match: <0 if first parameter should be sorted lower
  12389. * than the second parameter, ===0 if the two parameters are equal and
  12390. * >0 if the first parameter should be sorted height than the second
  12391. * parameter.
  12392. *
  12393. * @type object
  12394. * @default {}
  12395. *
  12396. * @example
  12397. * // Numeric ordering of formatted numbers with a pre-formatter
  12398. * $.extend( $.fn.dataTable.ext.type.order, {
  12399. * "string-pre": function(x) {
  12400. * a = (a === "-" || a === "") ? 0 : a.replace( /[^\d\-\.]/g, "" );
  12401. * return parseFloat( a );
  12402. * }
  12403. * } );
  12404. *
  12405. * @example
  12406. * // Case-sensitive string ordering, with no pre-formatting method
  12407. * $.extend( $.fn.dataTable.ext.order, {
  12408. * "string-case-asc": function(x,y) {
  12409. * return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12410. * },
  12411. * "string-case-desc": function(x,y) {
  12412. * return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12413. * }
  12414. * } );
  12415. */
  12416. order: {}
  12417. },
  12418. /**
  12419. * Unique DataTables instance counter
  12420. *
  12421. * @type int
  12422. * @private
  12423. */
  12424. _unique: 0,
  12425. //
  12426. // Depreciated
  12427. // The following properties are retained for backwards compatiblity only.
  12428. // The should not be used in new projects and will be removed in a future
  12429. // version
  12430. //
  12431. /**
  12432. * Version check function.
  12433. * @type function
  12434. * @depreciated Since 1.10
  12435. */
  12436. fnVersionCheck: DataTable.fnVersionCheck,
  12437. /**
  12438. * Index for what 'this' index API functions should use
  12439. * @type int
  12440. * @deprecated Since v1.10
  12441. */
  12442. iApiIndex: 0,
  12443. /**
  12444. * jQuery UI class container
  12445. * @type object
  12446. * @deprecated Since v1.10
  12447. */
  12448. oJUIClasses: {},
  12449. /**
  12450. * Software version
  12451. * @type string
  12452. * @deprecated Since v1.10
  12453. */
  12454. sVersion: DataTable.version
  12455. };
  12456. //
  12457. // Backwards compatibility. Alias to pre 1.10 Hungarian notation counter parts
  12458. //
  12459. $.extend( _ext, {
  12460. afnFiltering: _ext.search,
  12461. aTypes: _ext.type.detect,
  12462. ofnSearch: _ext.type.search,
  12463. oSort: _ext.type.order,
  12464. afnSortData: _ext.order,
  12465. aoFeatures: _ext.feature,
  12466. oApi: _ext.internal,
  12467. oStdClasses: _ext.classes,
  12468. oPagination: _ext.pager
  12469. } );
  12470. $.extend( DataTable.ext.classes, {
  12471. "sTable": "dataTable",
  12472. "sNoFooter": "no-footer",
  12473. /* Paging buttons */
  12474. "sPageButton": "paginate_button",
  12475. "sPageButtonActive": "current",
  12476. "sPageButtonDisabled": "disabled",
  12477. /* Striping classes */
  12478. "sStripeOdd": "odd",
  12479. "sStripeEven": "even",
  12480. /* Empty row */
  12481. "sRowEmpty": "dataTables_empty",
  12482. /* Features */
  12483. "sWrapper": "dataTables_wrapper",
  12484. "sFilter": "dataTables_filter",
  12485. "sInfo": "dataTables_info",
  12486. "sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */
  12487. "sLength": "dataTables_length",
  12488. "sProcessing": "dataTables_processing",
  12489. /* Sorting */
  12490. "sSortAsc": "sorting_asc",
  12491. "sSortDesc": "sorting_desc",
  12492. "sSortable": "sorting", /* Sortable in both directions */
  12493. "sSortableAsc": "sorting_asc_disabled",
  12494. "sSortableDesc": "sorting_desc_disabled",
  12495. "sSortableNone": "sorting_disabled",
  12496. "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
  12497. /* Filtering */
  12498. "sFilterInput": "",
  12499. /* Page length */
  12500. "sLengthSelect": "",
  12501. /* Scrolling */
  12502. "sScrollWrapper": "dataTables_scroll",
  12503. "sScrollHead": "dataTables_scrollHead",
  12504. "sScrollHeadInner": "dataTables_scrollHeadInner",
  12505. "sScrollBody": "dataTables_scrollBody",
  12506. "sScrollFoot": "dataTables_scrollFoot",
  12507. "sScrollFootInner": "dataTables_scrollFootInner",
  12508. /* Misc */
  12509. "sHeaderTH": "",
  12510. "sFooterTH": "",
  12511. // Deprecated
  12512. "sSortJUIAsc": "",
  12513. "sSortJUIDesc": "",
  12514. "sSortJUI": "",
  12515. "sSortJUIAscAllowed": "",
  12516. "sSortJUIDescAllowed": "",
  12517. "sSortJUIWrapper": "",
  12518. "sSortIcon": "",
  12519. "sJUIHeader": "",
  12520. "sJUIFooter": ""
  12521. } );
  12522. (function() {
  12523. // Reused strings for better compression. Closure compiler appears to have a
  12524. // weird edge case where it is trying to expand strings rather than use the
  12525. // variable version. This results in about 200 bytes being added, for very
  12526. // little preference benefit since it this run on script load only.
  12527. var _empty = '';
  12528. _empty = '';
  12529. var _stateDefault = _empty + 'ui-state-default';
  12530. var _sortIcon = _empty + 'css_right ui-icon ui-icon-';
  12531. var _headerFooter = _empty + 'fg-toolbar ui-toolbar ui-widget-header ui-helper-clearfix';
  12532. $.extend( DataTable.ext.oJUIClasses, DataTable.ext.classes, {
  12533. /* Full numbers paging buttons */
  12534. "sPageButton": "fg-button ui-button "+_stateDefault,
  12535. "sPageButtonActive": "ui-state-disabled",
  12536. "sPageButtonDisabled": "ui-state-disabled",
  12537. /* Features */
  12538. "sPaging": "dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi "+
  12539. "ui-buttonset-multi paging_", /* Note that the type is postfixed */
  12540. /* Sorting */
  12541. "sSortAsc": _stateDefault+" sorting_asc",
  12542. "sSortDesc": _stateDefault+" sorting_desc",
  12543. "sSortable": _stateDefault+" sorting",
  12544. "sSortableAsc": _stateDefault+" sorting_asc_disabled",
  12545. "sSortableDesc": _stateDefault+" sorting_desc_disabled",
  12546. "sSortableNone": _stateDefault+" sorting_disabled",
  12547. "sSortJUIAsc": _sortIcon+"triangle-1-n",
  12548. "sSortJUIDesc": _sortIcon+"triangle-1-s",
  12549. "sSortJUI": _sortIcon+"carat-2-n-s",
  12550. "sSortJUIAscAllowed": _sortIcon+"carat-1-n",
  12551. "sSortJUIDescAllowed": _sortIcon+"carat-1-s",
  12552. "sSortJUIWrapper": "DataTables_sort_wrapper",
  12553. "sSortIcon": "DataTables_sort_icon",
  12554. /* Scrolling */
  12555. "sScrollHead": "dataTables_scrollHead "+_stateDefault,
  12556. "sScrollFoot": "dataTables_scrollFoot "+_stateDefault,
  12557. /* Misc */
  12558. "sHeaderTH": _stateDefault,
  12559. "sFooterTH": _stateDefault,
  12560. "sJUIHeader": _headerFooter+" ui-corner-tl ui-corner-tr",
  12561. "sJUIFooter": _headerFooter+" ui-corner-bl ui-corner-br"
  12562. } );
  12563. }());
  12564. var extPagination = DataTable.ext.pager;
  12565. function _numbers ( page, pages ) {
  12566. var
  12567. numbers = [],
  12568. buttons = extPagination.numbers_length,
  12569. half = Math.floor( buttons / 2 ),
  12570. i = 1;
  12571. if ( pages <= buttons ) {
  12572. numbers = _range( 0, pages );
  12573. }
  12574. else if ( page <= half ) {
  12575. numbers = _range( 0, buttons-2 );
  12576. numbers.push( 'ellipsis' );
  12577. numbers.push( pages-1 );
  12578. }
  12579. else if ( page >= pages - 1 - half ) {
  12580. numbers = _range( pages-(buttons-2), pages );
  12581. numbers.splice( 0, 0, 'ellipsis' ); // no unshift in ie6
  12582. numbers.splice( 0, 0, 0 );
  12583. }
  12584. else {
  12585. numbers = _range( page-half+2, page+half-1 );
  12586. numbers.push( 'ellipsis' );
  12587. numbers.push( pages-1 );
  12588. numbers.splice( 0, 0, 'ellipsis' );
  12589. numbers.splice( 0, 0, 0 );
  12590. }
  12591. numbers.DT_el = 'span';
  12592. return numbers;
  12593. }
  12594. $.extend( extPagination, {
  12595. simple: function ( page, pages ) {
  12596. return [ 'previous', 'next' ];
  12597. },
  12598. full: function ( page, pages ) {
  12599. return [ 'first', 'previous', 'next', 'last' ];
  12600. },
  12601. numbers: function ( page, pages ) {
  12602. return [ _numbers(page, pages) ];
  12603. },
  12604. simple_numbers: function ( page, pages ) {
  12605. return [ 'previous', _numbers(page, pages), 'next' ];
  12606. },
  12607. full_numbers: function ( page, pages ) {
  12608. return [ 'first', 'previous', _numbers(page, pages), 'next', 'last' ];
  12609. },
  12610. // For testing and plug-ins to use
  12611. _numbers: _numbers,
  12612. // Number of number buttons (including ellipsis) to show. _Must be odd!_
  12613. numbers_length: 7
  12614. } );
  12615. $.extend( true, DataTable.ext.renderer, {
  12616. pageButton: {
  12617. _: function ( settings, host, idx, buttons, page, pages ) {
  12618. var classes = settings.oClasses;
  12619. var lang = settings.oLanguage.oPaginate;
  12620. var aria = settings.oLanguage.oAria.paginate || {};
  12621. var btnDisplay, btnClass, counter=0;
  12622. var attach = function( container, buttons ) {
  12623. var i, ien, node, button;
  12624. var clickHandler = function ( e ) {
  12625. _fnPageChange( settings, e.data.action, true );
  12626. };
  12627. for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
  12628. button = buttons[i];
  12629. if ( $.isArray( button ) ) {
  12630. var inner = $( '<'+(button.DT_el || 'div')+'/>' )
  12631. .appendTo( container );
  12632. attach( inner, button );
  12633. }
  12634. else {
  12635. btnDisplay = null;
  12636. btnClass = '';
  12637. switch ( button ) {
  12638. case 'ellipsis':
  12639. container.append('<span class="ellipsis">&#x2026;</span>');
  12640. break;
  12641. case 'first':
  12642. btnDisplay = lang.sFirst;
  12643. btnClass = button + (page > 0 ?
  12644. '' : ' '+classes.sPageButtonDisabled);
  12645. break;
  12646. case 'previous':
  12647. btnDisplay = lang.sPrevious;
  12648. btnClass = button + (page > 0 ?
  12649. '' : ' '+classes.sPageButtonDisabled);
  12650. break;
  12651. case 'next':
  12652. btnDisplay = lang.sNext;
  12653. btnClass = button + (page < pages-1 ?
  12654. '' : ' '+classes.sPageButtonDisabled);
  12655. break;
  12656. case 'last':
  12657. btnDisplay = lang.sLast;
  12658. btnClass = button + (page < pages-1 ?
  12659. '' : ' '+classes.sPageButtonDisabled);
  12660. break;
  12661. default:
  12662. btnDisplay = button + 1;
  12663. btnClass = page === button ?
  12664. classes.sPageButtonActive : '';
  12665. break;
  12666. }
  12667. if ( btnDisplay !== null ) {
  12668. node = $('<a>', {
  12669. 'class': classes.sPageButton+' '+btnClass,
  12670. 'aria-controls': settings.sTableId,
  12671. 'aria-label': aria[ button ],
  12672. 'data-dt-idx': counter,
  12673. 'tabindex': settings.iTabIndex,
  12674. 'id': idx === 0 && typeof button === 'string' ?
  12675. settings.sTableId +'_'+ button :
  12676. null
  12677. } )
  12678. .html( btnDisplay )
  12679. .appendTo( container );
  12680. _fnBindAction(
  12681. node, {action: button}, clickHandler
  12682. );
  12683. counter++;
  12684. }
  12685. }
  12686. }
  12687. };
  12688. // IE9 throws an 'unknown error' if document.activeElement is used
  12689. // inside an iframe or frame. Try / catch the error. Not good for
  12690. // accessibility, but neither are frames.
  12691. var activeEl;
  12692. try {
  12693. // Because this approach is destroying and recreating the paging
  12694. // elements, focus is lost on the select button which is bad for
  12695. // accessibility. So we want to restore focus once the draw has
  12696. // completed
  12697. activeEl = $(host).find(document.activeElement).data('dt-idx');
  12698. }
  12699. catch (e) {}
  12700. attach( $(host).empty(), buttons );
  12701. if ( activeEl ) {
  12702. $(host).find( '[data-dt-idx='+activeEl+']' ).focus();
  12703. }
  12704. }
  12705. }
  12706. } );
  12707. // Built in type detection. See model.ext.aTypes for information about
  12708. // what is required from this methods.
  12709. $.extend( DataTable.ext.type.detect, [
  12710. // Plain numbers - first since V8 detects some plain numbers as dates
  12711. // e.g. Date.parse('55') (but not all, e.g. Date.parse('22')...).
  12712. function ( d, settings )
  12713. {
  12714. var decimal = settings.oLanguage.sDecimal;
  12715. return _isNumber( d, decimal ) ? 'num'+decimal : null;
  12716. },
  12717. // Dates (only those recognised by the browser's Date.parse)
  12718. function ( d, settings )
  12719. {
  12720. // V8 will remove any unknown characters at the start and end of the
  12721. // expression, leading to false matches such as `$245.12` or `10%` being
  12722. // a valid date. See forum thread 18941 for detail.
  12723. if ( d && !(d instanceof Date) && ( ! _re_date_start.test(d) || ! _re_date_end.test(d) ) ) {
  12724. return null;
  12725. }
  12726. var parsed = Date.parse(d);
  12727. return (parsed !== null && !isNaN(parsed)) || _empty(d) ? 'date' : null;
  12728. },
  12729. // Formatted numbers
  12730. function ( d, settings )
  12731. {
  12732. var decimal = settings.oLanguage.sDecimal;
  12733. return _isNumber( d, decimal, true ) ? 'num-fmt'+decimal : null;
  12734. },
  12735. // HTML numeric
  12736. function ( d, settings )
  12737. {
  12738. var decimal = settings.oLanguage.sDecimal;
  12739. return _htmlNumeric( d, decimal ) ? 'html-num'+decimal : null;
  12740. },
  12741. // HTML numeric, formatted
  12742. function ( d, settings )
  12743. {
  12744. var decimal = settings.oLanguage.sDecimal;
  12745. return _htmlNumeric( d, decimal, true ) ? 'html-num-fmt'+decimal : null;
  12746. },
  12747. // HTML (this is strict checking - there must be html)
  12748. function ( d, settings )
  12749. {
  12750. return _empty( d ) || (typeof d === 'string' && d.indexOf('<') !== -1) ?
  12751. 'html' : null;
  12752. }
  12753. ] );
  12754. // Filter formatting functions. See model.ext.ofnSearch for information about
  12755. // what is required from these methods.
  12756. //
  12757. // Note that additional search methods are added for the html numbers and
  12758. // html formatted numbers by `_addNumericSort()` when we know what the decimal
  12759. // place is
  12760. $.extend( DataTable.ext.type.search, {
  12761. html: function ( data ) {
  12762. return _empty(data) ?
  12763. data :
  12764. typeof data === 'string' ?
  12765. data
  12766. .replace( _re_new_lines, " " )
  12767. .replace( _re_html, "" ) :
  12768. '';
  12769. },
  12770. string: function ( data ) {
  12771. return _empty(data) ?
  12772. data :
  12773. typeof data === 'string' ?
  12774. data.replace( _re_new_lines, " " ) :
  12775. data;
  12776. }
  12777. } );
  12778. var __numericReplace = function ( d, decimalPlace, re1, re2 ) {
  12779. if ( d !== 0 && (!d || d === '-') ) {
  12780. return -Infinity;
  12781. }
  12782. // If a decimal place other than `.` is used, it needs to be given to the
  12783. // function so we can detect it and replace with a `.` which is the only
  12784. // decimal place Javascript recognises - it is not locale aware.
  12785. if ( decimalPlace ) {
  12786. d = _numToDecimal( d, decimalPlace );
  12787. }
  12788. if ( d.replace ) {
  12789. if ( re1 ) {
  12790. d = d.replace( re1, '' );
  12791. }
  12792. if ( re2 ) {
  12793. d = d.replace( re2, '' );
  12794. }
  12795. }
  12796. return d * 1;
  12797. };
  12798. // Add the numeric 'deformatting' functions for sorting and search. This is done
  12799. // in a function to provide an easy ability for the language options to add
  12800. // additional methods if a non-period decimal place is used.
  12801. function _addNumericSort ( decimalPlace ) {
  12802. $.each(
  12803. {
  12804. // Plain numbers
  12805. "num": function ( d ) {
  12806. return __numericReplace( d, decimalPlace );
  12807. },
  12808. // Formatted numbers
  12809. "num-fmt": function ( d ) {
  12810. return __numericReplace( d, decimalPlace, _re_formatted_numeric );
  12811. },
  12812. // HTML numeric
  12813. "html-num": function ( d ) {
  12814. return __numericReplace( d, decimalPlace, _re_html );
  12815. },
  12816. // HTML numeric, formatted
  12817. "html-num-fmt": function ( d ) {
  12818. return __numericReplace( d, decimalPlace, _re_html, _re_formatted_numeric );
  12819. }
  12820. },
  12821. function ( key, fn ) {
  12822. // Add the ordering method
  12823. _ext.type.order[ key+decimalPlace+'-pre' ] = fn;
  12824. // For HTML types add a search formatter that will strip the HTML
  12825. if ( key.match(/^html\-/) ) {
  12826. _ext.type.search[ key+decimalPlace ] = _ext.type.search.html;
  12827. }
  12828. }
  12829. );
  12830. }
  12831. // Default sort methods
  12832. $.extend( _ext.type.order, {
  12833. // Dates
  12834. "date-pre": function ( d ) {
  12835. return Date.parse( d ) || 0;
  12836. },
  12837. // html
  12838. "html-pre": function ( a ) {
  12839. return _empty(a) ?
  12840. '' :
  12841. a.replace ?
  12842. a.replace( /<.*?>/g, "" ).toLowerCase() :
  12843. a+'';
  12844. },
  12845. // string
  12846. "string-pre": function ( a ) {
  12847. // This is a little complex, but faster than always calling toString,
  12848. // http://jsperf.com/tostring-v-check
  12849. return _empty(a) ?
  12850. '' :
  12851. typeof a === 'string' ?
  12852. a.toLowerCase() :
  12853. ! a.toString ?
  12854. '' :
  12855. a.toString();
  12856. },
  12857. // string-asc and -desc are retained only for compatibility with the old
  12858. // sort methods
  12859. "string-asc": function ( x, y ) {
  12860. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12861. },
  12862. "string-desc": function ( x, y ) {
  12863. return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12864. }
  12865. } );
  12866. // Numeric sorting types - order doesn't matter here
  12867. _addNumericSort( '' );
  12868. $.extend( true, DataTable.ext.renderer, {
  12869. header: {
  12870. _: function ( settings, cell, column, classes ) {
  12871. // No additional mark-up required
  12872. // Attach a sort listener to update on sort - note that using the
  12873. // `DT` namespace will allow the event to be removed automatically
  12874. // on destroy, while the `dt` namespaced event is the one we are
  12875. // listening for
  12876. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  12877. if ( settings !== ctx ) { // need to check this this is the host
  12878. return; // table, not a nested one
  12879. }
  12880. var colIdx = column.idx;
  12881. cell
  12882. .removeClass(
  12883. column.sSortingClass +' '+
  12884. classes.sSortAsc +' '+
  12885. classes.sSortDesc
  12886. )
  12887. .addClass( columns[ colIdx ] == 'asc' ?
  12888. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  12889. classes.sSortDesc :
  12890. column.sSortingClass
  12891. );
  12892. } );
  12893. },
  12894. jqueryui: function ( settings, cell, column, classes ) {
  12895. $('<div/>')
  12896. .addClass( classes.sSortJUIWrapper )
  12897. .append( cell.contents() )
  12898. .append( $('<span/>')
  12899. .addClass( classes.sSortIcon+' '+column.sSortingClassJUI )
  12900. )
  12901. .appendTo( cell );
  12902. // Attach a sort listener to update on sort
  12903. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  12904. if ( settings !== ctx ) {
  12905. return;
  12906. }
  12907. var colIdx = column.idx;
  12908. cell
  12909. .removeClass( classes.sSortAsc +" "+classes.sSortDesc )
  12910. .addClass( columns[ colIdx ] == 'asc' ?
  12911. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  12912. classes.sSortDesc :
  12913. column.sSortingClass
  12914. );
  12915. cell
  12916. .find( 'span.'+classes.sSortIcon )
  12917. .removeClass(
  12918. classes.sSortJUIAsc +" "+
  12919. classes.sSortJUIDesc +" "+
  12920. classes.sSortJUI +" "+
  12921. classes.sSortJUIAscAllowed +" "+
  12922. classes.sSortJUIDescAllowed
  12923. )
  12924. .addClass( columns[ colIdx ] == 'asc' ?
  12925. classes.sSortJUIAsc : columns[ colIdx ] == 'desc' ?
  12926. classes.sSortJUIDesc :
  12927. column.sSortingClassJUI
  12928. );
  12929. } );
  12930. }
  12931. }
  12932. } );
  12933. /*
  12934. * Public helper functions. These aren't used internally by DataTables, or
  12935. * called by any of the options passed into DataTables, but they can be used
  12936. * externally by developers working with DataTables. They are helper functions
  12937. * to make working with DataTables a little bit easier.
  12938. */
  12939. var __htmlEscapeEntities = function ( d ) {
  12940. return typeof d === 'string' ?
  12941. d.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;') :
  12942. d;
  12943. };
  12944. /**
  12945. * Helpers for `columns.render`.
  12946. *
  12947. * The options defined here can be used with the `columns.render` initialisation
  12948. * option to provide a display renderer. The following functions are defined:
  12949. *
  12950. * * `number` - Will format numeric data (defined by `columns.data`) for
  12951. * display, retaining the original unformatted data for sorting and filtering.
  12952. * It takes 5 parameters:
  12953. * * `string` - Thousands grouping separator
  12954. * * `string` - Decimal point indicator
  12955. * * `integer` - Number of decimal points to show
  12956. * * `string` (optional) - Prefix.
  12957. * * `string` (optional) - Postfix (/suffix).
  12958. * * `text` - Escape HTML to help prevent XSS attacks. It has no optional
  12959. * parameters.
  12960. *
  12961. * @example
  12962. * // Column definition using the number renderer
  12963. * {
  12964. * data: "salary",
  12965. * render: $.fn.dataTable.render.number( '\'', '.', 0, '$' )
  12966. * }
  12967. *
  12968. * @namespace
  12969. */
  12970. DataTable.render = {
  12971. number: function ( thousands, decimal, precision, prefix, postfix ) {
  12972. return {
  12973. display: function ( d ) {
  12974. if ( typeof d !== 'number' && typeof d !== 'string' ) {
  12975. return d;
  12976. }
  12977. var negative = d < 0 ? '-' : '';
  12978. var flo = parseFloat( d );
  12979. // If NaN then there isn't much formatting that we can do - just
  12980. // return immediately, escaping any HTML (this was supposed to
  12981. // be a number after all)
  12982. if ( isNaN( flo ) ) {
  12983. return __htmlEscapeEntities( d );
  12984. }
  12985. d = Math.abs( flo );
  12986. var intPart = parseInt( d, 10 );
  12987. var floatPart = precision ?
  12988. decimal+(d - intPart).toFixed( precision ).substring( 2 ):
  12989. '';
  12990. return negative + (prefix||'') +
  12991. intPart.toString().replace(
  12992. /\B(?=(\d{3})+(?!\d))/g, thousands
  12993. ) +
  12994. floatPart +
  12995. (postfix||'');
  12996. }
  12997. };
  12998. },
  12999. text: function () {
  13000. return {
  13001. display: __htmlEscapeEntities
  13002. };
  13003. }
  13004. };
  13005. /*
  13006. * This is really a good bit rubbish this method of exposing the internal methods
  13007. * publicly... - To be fixed in 2.0 using methods on the prototype
  13008. */
  13009. /**
  13010. * Create a wrapper function for exporting an internal functions to an external API.
  13011. * @param {string} fn API function name
  13012. * @returns {function} wrapped function
  13013. * @memberof DataTable#internal
  13014. */
  13015. function _fnExternApiFunc (fn)
  13016. {
  13017. return function() {
  13018. var args = [_fnSettingsFromNode( this[DataTable.ext.iApiIndex] )].concat(
  13019. Array.prototype.slice.call(arguments)
  13020. );
  13021. return DataTable.ext.internal[fn].apply( this, args );
  13022. };
  13023. }
  13024. /**
  13025. * Reference to internal functions for use by plug-in developers. Note that
  13026. * these methods are references to internal functions and are considered to be
  13027. * private. If you use these methods, be aware that they are liable to change
  13028. * between versions.
  13029. * @namespace
  13030. */
  13031. $.extend( DataTable.ext.internal, {
  13032. _fnExternApiFunc: _fnExternApiFunc,
  13033. _fnBuildAjax: _fnBuildAjax,
  13034. _fnAjaxUpdate: _fnAjaxUpdate,
  13035. _fnAjaxParameters: _fnAjaxParameters,
  13036. _fnAjaxUpdateDraw: _fnAjaxUpdateDraw,
  13037. _fnAjaxDataSrc: _fnAjaxDataSrc,
  13038. _fnAddColumn: _fnAddColumn,
  13039. _fnColumnOptions: _fnColumnOptions,
  13040. _fnAdjustColumnSizing: _fnAdjustColumnSizing,
  13041. _fnVisibleToColumnIndex: _fnVisibleToColumnIndex,
  13042. _fnColumnIndexToVisible: _fnColumnIndexToVisible,
  13043. _fnVisbleColumns: _fnVisbleColumns,
  13044. _fnGetColumns: _fnGetColumns,
  13045. _fnColumnTypes: _fnColumnTypes,
  13046. _fnApplyColumnDefs: _fnApplyColumnDefs,
  13047. _fnHungarianMap: _fnHungarianMap,
  13048. _fnCamelToHungarian: _fnCamelToHungarian,
  13049. _fnLanguageCompat: _fnLanguageCompat,
  13050. _fnBrowserDetect: _fnBrowserDetect,
  13051. _fnAddData: _fnAddData,
  13052. _fnAddTr: _fnAddTr,
  13053. _fnNodeToDataIndex: _fnNodeToDataIndex,
  13054. _fnNodeToColumnIndex: _fnNodeToColumnIndex,
  13055. _fnGetCellData: _fnGetCellData,
  13056. _fnSetCellData: _fnSetCellData,
  13057. _fnSplitObjNotation: _fnSplitObjNotation,
  13058. _fnGetObjectDataFn: _fnGetObjectDataFn,
  13059. _fnSetObjectDataFn: _fnSetObjectDataFn,
  13060. _fnGetDataMaster: _fnGetDataMaster,
  13061. _fnClearTable: _fnClearTable,
  13062. _fnDeleteIndex: _fnDeleteIndex,
  13063. _fnInvalidate: _fnInvalidate,
  13064. _fnGetRowElements: _fnGetRowElements,
  13065. _fnCreateTr: _fnCreateTr,
  13066. _fnBuildHead: _fnBuildHead,
  13067. _fnDrawHead: _fnDrawHead,
  13068. _fnDraw: _fnDraw,
  13069. _fnReDraw: _fnReDraw,
  13070. _fnAddOptionsHtml: _fnAddOptionsHtml,
  13071. _fnDetectHeader: _fnDetectHeader,
  13072. _fnGetUniqueThs: _fnGetUniqueThs,
  13073. _fnFeatureHtmlFilter: _fnFeatureHtmlFilter,
  13074. _fnFilterComplete: _fnFilterComplete,
  13075. _fnFilterCustom: _fnFilterCustom,
  13076. _fnFilterColumn: _fnFilterColumn,
  13077. _fnFilter: _fnFilter,
  13078. _fnFilterCreateSearch: _fnFilterCreateSearch,
  13079. _fnEscapeRegex: _fnEscapeRegex,
  13080. _fnFilterData: _fnFilterData,
  13081. _fnFeatureHtmlInfo: _fnFeatureHtmlInfo,
  13082. _fnUpdateInfo: _fnUpdateInfo,
  13083. _fnInfoMacros: _fnInfoMacros,
  13084. _fnInitialise: _fnInitialise,
  13085. _fnInitComplete: _fnInitComplete,
  13086. _fnLengthChange: _fnLengthChange,
  13087. _fnFeatureHtmlLength: _fnFeatureHtmlLength,
  13088. _fnFeatureHtmlPaginate: _fnFeatureHtmlPaginate,
  13089. _fnPageChange: _fnPageChange,
  13090. _fnFeatureHtmlProcessing: _fnFeatureHtmlProcessing,
  13091. _fnProcessingDisplay: _fnProcessingDisplay,
  13092. _fnFeatureHtmlTable: _fnFeatureHtmlTable,
  13093. _fnScrollDraw: _fnScrollDraw,
  13094. _fnApplyToChildren: _fnApplyToChildren,
  13095. _fnCalculateColumnWidths: _fnCalculateColumnWidths,
  13096. _fnThrottle: _fnThrottle,
  13097. _fnConvertToWidth: _fnConvertToWidth,
  13098. _fnGetWidestNode: _fnGetWidestNode,
  13099. _fnGetMaxLenString: _fnGetMaxLenString,
  13100. _fnStringToCss: _fnStringToCss,
  13101. _fnSortFlatten: _fnSortFlatten,
  13102. _fnSort: _fnSort,
  13103. _fnSortAria: _fnSortAria,
  13104. _fnSortListener: _fnSortListener,
  13105. _fnSortAttachListener: _fnSortAttachListener,
  13106. _fnSortingClasses: _fnSortingClasses,
  13107. _fnSortData: _fnSortData,
  13108. _fnSaveState: _fnSaveState,
  13109. _fnLoadState: _fnLoadState,
  13110. _fnSettingsFromNode: _fnSettingsFromNode,
  13111. _fnLog: _fnLog,
  13112. _fnMap: _fnMap,
  13113. _fnBindAction: _fnBindAction,
  13114. _fnCallbackReg: _fnCallbackReg,
  13115. _fnCallbackFire: _fnCallbackFire,
  13116. _fnLengthOverflow: _fnLengthOverflow,
  13117. _fnRenderer: _fnRenderer,
  13118. _fnDataSource: _fnDataSource,
  13119. _fnRowAttributes: _fnRowAttributes,
  13120. _fnCalculateEnd: function () {} // Used by a lot of plug-ins, but redundant
  13121. // in 1.10, so this dead-end function is
  13122. // added to prevent errors
  13123. } );
  13124. // jQuery access
  13125. $.fn.dataTable = DataTable;
  13126. // Provide access to the host jQuery object (circular reference)
  13127. DataTable.$ = $;
  13128. // Legacy aliases
  13129. $.fn.dataTableSettings = DataTable.settings;
  13130. $.fn.dataTableExt = DataTable.ext;
  13131. // With a capital `D` we return a DataTables API instance rather than a
  13132. // jQuery object
  13133. $.fn.DataTable = function ( opts ) {
  13134. return $(this).dataTable( opts ).api();
  13135. };
  13136. // All properties that are available to $.fn.dataTable should also be
  13137. // available on $.fn.DataTable
  13138. $.each( DataTable, function ( prop, val ) {
  13139. $.fn.DataTable[ prop ] = val;
  13140. } );
  13141. // Information about events fired by DataTables - for documentation.
  13142. /**
  13143. * Draw event, fired whenever the table is redrawn on the page, at the same
  13144. * point as fnDrawCallback. This may be useful for binding events or
  13145. * performing calculations when the table is altered at all.
  13146. * @name DataTable#draw.dt
  13147. * @event
  13148. * @param {event} e jQuery event object
  13149. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13150. */
  13151. /**
  13152. * Search event, fired when the searching applied to the table (using the
  13153. * built-in global search, or column filters) is altered.
  13154. * @name DataTable#search.dt
  13155. * @event
  13156. * @param {event} e jQuery event object
  13157. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13158. */
  13159. /**
  13160. * Page change event, fired when the paging of the table is altered.
  13161. * @name DataTable#page.dt
  13162. * @event
  13163. * @param {event} e jQuery event object
  13164. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13165. */
  13166. /**
  13167. * Order event, fired when the ordering applied to the table is altered.
  13168. * @name DataTable#order.dt
  13169. * @event
  13170. * @param {event} e jQuery event object
  13171. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13172. */
  13173. /**
  13174. * DataTables initialisation complete event, fired when the table is fully
  13175. * drawn, including Ajax data loaded, if Ajax data is required.
  13176. * @name DataTable#init.dt
  13177. * @event
  13178. * @param {event} e jQuery event object
  13179. * @param {object} oSettings DataTables settings object
  13180. * @param {object} json The JSON object request from the server - only
  13181. * present if client-side Ajax sourced data is used</li></ol>
  13182. */
  13183. /**
  13184. * State save event, fired when the table has changed state a new state save
  13185. * is required. This event allows modification of the state saving object
  13186. * prior to actually doing the save, including addition or other state
  13187. * properties (for plug-ins) or modification of a DataTables core property.
  13188. * @name DataTable#stateSaveParams.dt
  13189. * @event
  13190. * @param {event} e jQuery event object
  13191. * @param {object} oSettings DataTables settings object
  13192. * @param {object} json The state information to be saved
  13193. */
  13194. /**
  13195. * State load event, fired when the table is loading state from the stored
  13196. * data, but prior to the settings object being modified by the saved state
  13197. * - allowing modification of the saved state is required or loading of
  13198. * state for a plug-in.
  13199. * @name DataTable#stateLoadParams.dt
  13200. * @event
  13201. * @param {event} e jQuery event object
  13202. * @param {object} oSettings DataTables settings object
  13203. * @param {object} json The saved state information
  13204. */
  13205. /**
  13206. * State loaded event, fired when state has been loaded from stored data and
  13207. * the settings object has been modified by the loaded data.
  13208. * @name DataTable#stateLoaded.dt
  13209. * @event
  13210. * @param {event} e jQuery event object
  13211. * @param {object} oSettings DataTables settings object
  13212. * @param {object} json The saved state information
  13213. */
  13214. /**
  13215. * Processing event, fired when DataTables is doing some kind of processing
  13216. * (be it, order, searcg or anything else). It can be used to indicate to
  13217. * the end user that there is something happening, or that something has
  13218. * finished.
  13219. * @name DataTable#processing.dt
  13220. * @event
  13221. * @param {event} e jQuery event object
  13222. * @param {object} oSettings DataTables settings object
  13223. * @param {boolean} bShow Flag for if DataTables is doing processing or not
  13224. */
  13225. /**
  13226. * Ajax (XHR) event, fired whenever an Ajax request is completed from a
  13227. * request to made to the server for new data. This event is called before
  13228. * DataTables processed the returned data, so it can also be used to pre-
  13229. * process the data returned from the server, if needed.
  13230. *
  13231. * Note that this trigger is called in `fnServerData`, if you override
  13232. * `fnServerData` and which to use this event, you need to trigger it in you
  13233. * success function.
  13234. * @name DataTable#xhr.dt
  13235. * @event
  13236. * @param {event} e jQuery event object
  13237. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13238. * @param {object} json JSON returned from the server
  13239. *
  13240. * @example
  13241. * // Use a custom property returned from the server in another DOM element
  13242. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  13243. * $('#status').html( json.status );
  13244. * } );
  13245. *
  13246. * @example
  13247. * // Pre-process the data returned from the server
  13248. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  13249. * for ( var i=0, ien=json.aaData.length ; i<ien ; i++ ) {
  13250. * json.aaData[i].sum = json.aaData[i].one + json.aaData[i].two;
  13251. * }
  13252. * // Note no return - manipulate the data directly in the JSON object.
  13253. * } );
  13254. */
  13255. /**
  13256. * Destroy event, fired when the DataTable is destroyed by calling fnDestroy
  13257. * or passing the bDestroy:true parameter in the initialisation object. This
  13258. * can be used to remove bound events, added DOM nodes, etc.
  13259. * @name DataTable#destroy.dt
  13260. * @event
  13261. * @param {event} e jQuery event object
  13262. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13263. */
  13264. /**
  13265. * Page length change event, fired when number of records to show on each
  13266. * page (the length) is changed.
  13267. * @name DataTable#length.dt
  13268. * @event
  13269. * @param {event} e jQuery event object
  13270. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13271. * @param {integer} len New length
  13272. */
  13273. /**
  13274. * Column sizing has changed.
  13275. * @name DataTable#column-sizing.dt
  13276. * @event
  13277. * @param {event} e jQuery event object
  13278. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13279. */
  13280. /**
  13281. * Column visibility has changed.
  13282. * @name DataTable#column-visibility.dt
  13283. * @event
  13284. * @param {event} e jQuery event object
  13285. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13286. * @param {int} column Column index
  13287. * @param {bool} vis `false` if column now hidden, or `true` if visible
  13288. */
  13289. return $.fn.dataTable;
  13290. }));