jquery.dataTables.js 432 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095
  1. /*! DataTables 1.10.8
  2. * ©2008-2014 SpryMedia Ltd - datatables.net/license
  3. */
  4. /**
  5. * @summary DataTables
  6. * @description Paginate, search and order HTML tables
  7. * @version 1.10.8
  8. * @file jquery.dataTables.js
  9. * @author SpryMedia Ltd (www.sprymedia.co.uk)
  10. * @contact www.sprymedia.co.uk/contact
  11. * @copyright Copyright 2008-2014 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,_fnScrollBarWidth,_fnSortFlatten,_fnSort,_fnSortAria,_fnSortListener,_fnSortAttachListener,_fnSortingClasses,_fnSortData,_fnSaveState,_fnLoadState,_fnSettingsFromNode,_fnLog,_fnMap,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnLengthOverflow,_fnRenderer,_fnDataSource,_fnRowAttributes*/
  24. (/** @lends <global> */function( window, document, undefined ) {
  25. (function( factory ) {
  26. "use strict";
  27. if ( typeof define === 'function' && define.amd ) {
  28. // Define as an AMD module if possible
  29. define( 'datatables', ['jquery'], factory );
  30. }
  31. else if ( typeof exports === 'object' ) {
  32. // Node/CommonJS
  33. module.exports = factory( require( 'jquery' ) );
  34. }
  35. else if ( jQuery && !jQuery.fn.dataTable ) {
  36. // Define using browser globals otherwise
  37. // Prevent multiple instantiations if the script is loaded twice
  38. factory( jQuery );
  39. }
  40. }
  41. (/** @lends <global> */function( $ ) {
  42. "use strict";
  43. /**
  44. * DataTables is a plug-in for the jQuery Javascript library. It is a highly
  45. * flexible tool, based upon the foundations of progressive enhancement,
  46. * which will add advanced interaction controls to any HTML table. For a
  47. * full list of features please refer to
  48. * [DataTables.net](href="http://datatables.net).
  49. *
  50. * Note that the `DataTable` object is not a global variable but is aliased
  51. * to `jQuery.fn.DataTable` and `jQuery.fn.dataTable` through which it may
  52. * be accessed.
  53. *
  54. * @class
  55. * @param {object} [init={}] Configuration object for DataTables. Options
  56. * are defined by {@link DataTable.defaults}
  57. * @requires jQuery 1.7+
  58. *
  59. * @example
  60. * // Basic initialisation
  61. * $(document).ready( function {
  62. * $('#example').dataTable();
  63. * } );
  64. *
  65. * @example
  66. * // Initialisation with configuration options - in this case, disable
  67. * // pagination and sorting.
  68. * $(document).ready( function {
  69. * $('#example').dataTable( {
  70. * "paginate": false,
  71. * "sort": false
  72. * } );
  73. * } );
  74. */
  75. var DataTable;
  76. /*
  77. * It is useful to have variables which are scoped locally so only the
  78. * DataTables functions can access them and they don't leak into global space.
  79. * At the same time these functions are often useful over multiple files in the
  80. * core and API, so we list, or at least document, all variables which are used
  81. * by DataTables as private variables here. This also ensures that there is no
  82. * clashing of variable names and that they can easily referenced for reuse.
  83. */
  84. // Defined else where
  85. // _selector_run
  86. // _selector_opts
  87. // _selector_first
  88. // _selector_row_indexes
  89. var _ext; // DataTable.ext
  90. var _Api; // DataTable.Api
  91. var _api_register; // DataTable.Api.register
  92. var _api_registerPlural; // DataTable.Api.registerPlural
  93. var _re_dic = {};
  94. var _re_new_lines = /[\r\n]/g;
  95. var _re_html = /<.*?>/g;
  96. var _re_date_start = /^[\w\+\-]/;
  97. var _re_date_end = /[\w\+\-]$/;
  98. // Escape regular expression special characters
  99. var _re_escape_regex = new RegExp( '(\\' + [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^', '-' ].join('|\\') + ')', 'g' );
  100. // http://en.wikipedia.org/wiki/Foreign_exchange_market
  101. // - \u20BD - Russian ruble.
  102. // - \u20a9 - South Korean Won
  103. // - \u20BA - Turkish Lira
  104. // - \u20B9 - Indian Rupee
  105. // - R - Brazil (R$) and South Africa
  106. // - fr - Swiss Franc
  107. // - kr - Swedish krona, Norwegian krone and Danish krone
  108. // - \u2009 is thin space and \u202F is narrow no-break space, both used in many
  109. // standards as thousands separators.
  110. var _re_formatted_numeric = /[',$£€¥%\u2009\u202F\u20BD\u20a9\u20BArfk]/gi;
  111. var _empty = function ( d ) {
  112. return !d || d === true || d === '-' ? true : false;
  113. };
  114. var _intVal = function ( s ) {
  115. var integer = parseInt( s, 10 );
  116. return !isNaN(integer) && isFinite(s) ? integer : null;
  117. };
  118. // Convert from a formatted number with characters other than `.` as the
  119. // decimal place, to a Javascript number
  120. var _numToDecimal = function ( num, decimalPoint ) {
  121. // Cache created regular expressions for speed as this function is called often
  122. if ( ! _re_dic[ decimalPoint ] ) {
  123. _re_dic[ decimalPoint ] = new RegExp( _fnEscapeRegex( decimalPoint ), 'g' );
  124. }
  125. return typeof num === 'string' && decimalPoint !== '.' ?
  126. num.replace( /\./g, '' ).replace( _re_dic[ decimalPoint ], '.' ) :
  127. num;
  128. };
  129. var _isNumber = function ( d, decimalPoint, formatted ) {
  130. var strType = typeof d === 'string';
  131. // If empty return immediately so there must be a number if it is a
  132. // formatted string (this stops the string "k", or "kr", etc being detected
  133. // as a formatted number for currency
  134. if ( _empty( d ) ) {
  135. return true;
  136. }
  137. if ( decimalPoint && strType ) {
  138. d = _numToDecimal( d, decimalPoint );
  139. }
  140. if ( formatted && strType ) {
  141. d = d.replace( _re_formatted_numeric, '' );
  142. }
  143. return !isNaN( parseFloat(d) ) && isFinite( d );
  144. };
  145. // A string without HTML in it can be considered to be HTML still
  146. var _isHtml = function ( d ) {
  147. return _empty( d ) || typeof d === 'string';
  148. };
  149. var _htmlNumeric = function ( d, decimalPoint, formatted ) {
  150. if ( _empty( d ) ) {
  151. return true;
  152. }
  153. var html = _isHtml( d );
  154. return ! html ?
  155. null :
  156. _isNumber( _stripHtml( d ), decimalPoint, formatted ) ?
  157. true :
  158. null;
  159. };
  160. var _pluck = function ( a, prop, prop2 ) {
  161. var out = [];
  162. var i=0, ien=a.length;
  163. // Could have the test in the loop for slightly smaller code, but speed
  164. // is essential here
  165. if ( prop2 !== undefined ) {
  166. for ( ; i<ien ; i++ ) {
  167. if ( a[i] && a[i][ prop ] ) {
  168. out.push( a[i][ prop ][ prop2 ] );
  169. }
  170. }
  171. }
  172. else {
  173. for ( ; i<ien ; i++ ) {
  174. if ( a[i] ) {
  175. out.push( a[i][ prop ] );
  176. }
  177. }
  178. }
  179. return out;
  180. };
  181. // Basically the same as _pluck, but rather than looping over `a` we use `order`
  182. // as the indexes to pick from `a`
  183. var _pluck_order = function ( a, order, prop, prop2 )
  184. {
  185. var out = [];
  186. var i=0, ien=order.length;
  187. // Could have the test in the loop for slightly smaller code, but speed
  188. // is essential here
  189. if ( prop2 !== undefined ) {
  190. for ( ; i<ien ; i++ ) {
  191. if ( a[ order[i] ][ prop ] ) {
  192. out.push( a[ order[i] ][ prop ][ prop2 ] );
  193. }
  194. }
  195. }
  196. else {
  197. for ( ; i<ien ; i++ ) {
  198. out.push( a[ order[i] ][ prop ] );
  199. }
  200. }
  201. return out;
  202. };
  203. var _range = function ( len, start )
  204. {
  205. var out = [];
  206. var end;
  207. if ( start === undefined ) {
  208. start = 0;
  209. end = len;
  210. }
  211. else {
  212. end = start;
  213. start = len;
  214. }
  215. for ( var i=start ; i<end ; i++ ) {
  216. out.push( i );
  217. }
  218. return out;
  219. };
  220. var _removeEmpty = function ( a )
  221. {
  222. var out = [];
  223. for ( var i=0, ien=a.length ; i<ien ; i++ ) {
  224. if ( a[i] ) { // careful - will remove all falsy values!
  225. out.push( a[i] );
  226. }
  227. }
  228. return out;
  229. };
  230. var _stripHtml = function ( d ) {
  231. return d.replace( _re_html, '' );
  232. };
  233. /**
  234. * Find the unique elements in a source array.
  235. *
  236. * @param {array} src Source array
  237. * @return {array} Array of unique items
  238. * @ignore
  239. */
  240. var _unique = function ( src )
  241. {
  242. // A faster unique method is to use object keys to identify used values,
  243. // but this doesn't work with arrays or objects, which we must also
  244. // consider. See jsperf.com/compare-array-unique-versions/4 for more
  245. // information.
  246. var
  247. out = [],
  248. val,
  249. i, ien=src.length,
  250. j, k=0;
  251. again: for ( i=0 ; i<ien ; i++ ) {
  252. val = src[i];
  253. for ( j=0 ; j<k ; j++ ) {
  254. if ( out[j] === val ) {
  255. continue again;
  256. }
  257. }
  258. out.push( val );
  259. k++;
  260. }
  261. return out;
  262. };
  263. /**
  264. * Create a mapping object that allows camel case parameters to be looked up
  265. * for their Hungarian counterparts. The mapping is stored in a private
  266. * parameter called `_hungarianMap` which can be accessed on the source object.
  267. * @param {object} o
  268. * @memberof DataTable#oApi
  269. */
  270. function _fnHungarianMap ( o )
  271. {
  272. var
  273. hungarian = 'a aa ai ao as b fn i m o s ',
  274. match,
  275. newKey,
  276. map = {};
  277. $.each( o, function (key, val) {
  278. match = key.match(/^([^A-Z]+?)([A-Z])/);
  279. if ( match && hungarian.indexOf(match[1]+' ') !== -1 )
  280. {
  281. newKey = key.replace( match[0], match[2].toLowerCase() );
  282. map[ newKey ] = key;
  283. if ( match[1] === 'o' )
  284. {
  285. _fnHungarianMap( o[key] );
  286. }
  287. }
  288. } );
  289. o._hungarianMap = map;
  290. }
  291. /**
  292. * Convert from camel case parameters to Hungarian, based on a Hungarian map
  293. * created by _fnHungarianMap.
  294. * @param {object} src The model object which holds all parameters that can be
  295. * mapped.
  296. * @param {object} user The object to convert from camel case to Hungarian.
  297. * @param {boolean} force When set to `true`, properties which already have a
  298. * Hungarian value in the `user` object will be overwritten. Otherwise they
  299. * won't be.
  300. * @memberof DataTable#oApi
  301. */
  302. function _fnCamelToHungarian ( src, user, force )
  303. {
  304. if ( ! src._hungarianMap ) {
  305. _fnHungarianMap( src );
  306. }
  307. var hungarianKey;
  308. $.each( user, function (key, val) {
  309. hungarianKey = src._hungarianMap[ key ];
  310. if ( hungarianKey !== undefined && (force || user[hungarianKey] === undefined) )
  311. {
  312. // For objects, we need to buzz down into the object to copy parameters
  313. if ( hungarianKey.charAt(0) === 'o' )
  314. {
  315. // Copy the camelCase options over to the hungarian
  316. if ( ! user[ hungarianKey ] ) {
  317. user[ hungarianKey ] = {};
  318. }
  319. $.extend( true, user[hungarianKey], user[key] );
  320. _fnCamelToHungarian( src[hungarianKey], user[hungarianKey], force );
  321. }
  322. else {
  323. user[hungarianKey] = user[ key ];
  324. }
  325. }
  326. } );
  327. }
  328. /**
  329. * Language compatibility - when certain options are given, and others aren't, we
  330. * need to duplicate the values over, in order to provide backwards compatibility
  331. * with older language files.
  332. * @param {object} oSettings dataTables settings object
  333. * @memberof DataTable#oApi
  334. */
  335. function _fnLanguageCompat( lang )
  336. {
  337. var defaults = DataTable.defaults.oLanguage;
  338. var zeroRecords = lang.sZeroRecords;
  339. /* Backwards compatibility - if there is no sEmptyTable given, then use the same as
  340. * sZeroRecords - assuming that is given.
  341. */
  342. if ( ! lang.sEmptyTable && zeroRecords &&
  343. defaults.sEmptyTable === "No data available in table" )
  344. {
  345. _fnMap( lang, lang, 'sZeroRecords', 'sEmptyTable' );
  346. }
  347. /* Likewise with loading records */
  348. if ( ! lang.sLoadingRecords && zeroRecords &&
  349. defaults.sLoadingRecords === "Loading..." )
  350. {
  351. _fnMap( lang, lang, 'sZeroRecords', 'sLoadingRecords' );
  352. }
  353. // Old parameter name of the thousands separator mapped onto the new
  354. if ( lang.sInfoThousands ) {
  355. lang.sThousands = lang.sInfoThousands;
  356. }
  357. var decimal = lang.sDecimal;
  358. if ( decimal ) {
  359. _addNumericSort( decimal );
  360. }
  361. }
  362. /**
  363. * Map one parameter onto another
  364. * @param {object} o Object to map
  365. * @param {*} knew The new parameter name
  366. * @param {*} old The old parameter name
  367. */
  368. var _fnCompatMap = function ( o, knew, old ) {
  369. if ( o[ knew ] !== undefined ) {
  370. o[ old ] = o[ knew ];
  371. }
  372. };
  373. /**
  374. * Provide backwards compatibility for the main DT options. Note that the new
  375. * options are mapped onto the old parameters, so this is an external interface
  376. * change only.
  377. * @param {object} init Object to map
  378. */
  379. function _fnCompatOpts ( init )
  380. {
  381. _fnCompatMap( init, 'ordering', 'bSort' );
  382. _fnCompatMap( init, 'orderMulti', 'bSortMulti' );
  383. _fnCompatMap( init, 'orderClasses', 'bSortClasses' );
  384. _fnCompatMap( init, 'orderCellsTop', 'bSortCellsTop' );
  385. _fnCompatMap( init, 'order', 'aaSorting' );
  386. _fnCompatMap( init, 'orderFixed', 'aaSortingFixed' );
  387. _fnCompatMap( init, 'paging', 'bPaginate' );
  388. _fnCompatMap( init, 'pagingType', 'sPaginationType' );
  389. _fnCompatMap( init, 'pageLength', 'iDisplayLength' );
  390. _fnCompatMap( init, 'searching', 'bFilter' );
  391. // Boolean initialisation of x-scrolling
  392. if ( typeof init.sScrollX === 'boolean' ) {
  393. init.sScrollX = init.sScrollX ? '100%' : '';
  394. }
  395. // Column search objects are in an array, so it needs to be converted
  396. // element by element
  397. var searchCols = init.aoSearchCols;
  398. if ( searchCols ) {
  399. for ( var i=0, ien=searchCols.length ; i<ien ; i++ ) {
  400. if ( searchCols[i] ) {
  401. _fnCamelToHungarian( DataTable.models.oSearch, searchCols[i] );
  402. }
  403. }
  404. }
  405. }
  406. /**
  407. * Provide backwards compatibility for column options. Note that the new options
  408. * are mapped onto the old parameters, so this is an external interface change
  409. * only.
  410. * @param {object} init Object to map
  411. */
  412. function _fnCompatCols ( init )
  413. {
  414. _fnCompatMap( init, 'orderable', 'bSortable' );
  415. _fnCompatMap( init, 'orderData', 'aDataSort' );
  416. _fnCompatMap( init, 'orderSequence', 'asSorting' );
  417. _fnCompatMap( init, 'orderDataType', 'sortDataType' );
  418. // orderData can be given as an integer
  419. var dataSort = init.aDataSort;
  420. if ( dataSort && ! $.isArray( dataSort ) ) {
  421. init.aDataSort = [ dataSort ];
  422. }
  423. }
  424. /**
  425. * Browser feature detection for capabilities, quirks
  426. * @param {object} settings dataTables settings object
  427. * @memberof DataTable#oApi
  428. */
  429. function _fnBrowserDetect( settings )
  430. {
  431. var browser = settings.oBrowser;
  432. // Scrolling feature / quirks detection
  433. var n = $('<div/>')
  434. .css( {
  435. position: 'fixed',
  436. top: 0,
  437. left: 0,
  438. height: 1,
  439. width: 1,
  440. overflow: 'hidden'
  441. } )
  442. .append(
  443. $('<div/>')
  444. .css( {
  445. position: 'absolute',
  446. top: 1,
  447. left: 1,
  448. width: 100,
  449. overflow: 'scroll'
  450. } )
  451. .append(
  452. $('<div class="test"/>')
  453. .css( {
  454. width: '100%',
  455. height: 10
  456. } )
  457. )
  458. )
  459. .appendTo( 'body' );
  460. var test = n.find('.test');
  461. // IE6/7 will oversize a width 100% element inside a scrolling element, to
  462. // include the width of the scrollbar, while other browsers ensure the inner
  463. // element is contained without forcing scrolling
  464. browser.bScrollOversize = test[0].offsetWidth === 100;
  465. // In rtl text layout, some browsers (most, but not all) will place the
  466. // scrollbar on the left, rather than the right.
  467. browser.bScrollbarLeft = Math.round( test.offset().left ) !== 1;
  468. // IE8- don't provide height and width for getBoundingClientRect
  469. browser.bBounding = n[0].getBoundingClientRect().width ? true : false;
  470. n.remove();
  471. }
  472. /**
  473. * Array.prototype reduce[Right] method, used for browsers which don't support
  474. * JS 1.6. Done this way to reduce code size, since we iterate either way
  475. * @param {object} settings dataTables settings object
  476. * @memberof DataTable#oApi
  477. */
  478. function _fnReduce ( that, fn, init, start, end, inc )
  479. {
  480. var
  481. i = start,
  482. value,
  483. isSet = false;
  484. if ( init !== undefined ) {
  485. value = init;
  486. isSet = true;
  487. }
  488. while ( i !== end ) {
  489. if ( ! that.hasOwnProperty(i) ) {
  490. continue;
  491. }
  492. value = isSet ?
  493. fn( value, that[i], i, that ) :
  494. that[i];
  495. isSet = true;
  496. i += inc;
  497. }
  498. return value;
  499. }
  500. /**
  501. * Add a column to the list used for the table with default values
  502. * @param {object} oSettings dataTables settings object
  503. * @param {node} nTh The th element for this column
  504. * @memberof DataTable#oApi
  505. */
  506. function _fnAddColumn( oSettings, nTh )
  507. {
  508. // Add column to aoColumns array
  509. var oDefaults = DataTable.defaults.column;
  510. var iCol = oSettings.aoColumns.length;
  511. var oCol = $.extend( {}, DataTable.models.oColumn, oDefaults, {
  512. "nTh": nTh ? nTh : document.createElement('th'),
  513. "sTitle": oDefaults.sTitle ? oDefaults.sTitle : nTh ? nTh.innerHTML : '',
  514. "aDataSort": oDefaults.aDataSort ? oDefaults.aDataSort : [iCol],
  515. "mData": oDefaults.mData ? oDefaults.mData : iCol,
  516. idx: iCol
  517. } );
  518. oSettings.aoColumns.push( oCol );
  519. // Add search object for column specific search. Note that the `searchCols[ iCol ]`
  520. // passed into extend can be undefined. This allows the user to give a default
  521. // with only some of the parameters defined, and also not give a default
  522. var searchCols = oSettings.aoPreSearchCols;
  523. searchCols[ iCol ] = $.extend( {}, DataTable.models.oSearch, searchCols[ iCol ] );
  524. // Use the default column options function to initialise classes etc
  525. _fnColumnOptions( oSettings, iCol, $(nTh).data() );
  526. }
  527. /**
  528. * Apply options for a column
  529. * @param {object} oSettings dataTables settings object
  530. * @param {int} iCol column index to consider
  531. * @param {object} oOptions object with sType, bVisible and bSearchable etc
  532. * @memberof DataTable#oApi
  533. */
  534. function _fnColumnOptions( oSettings, iCol, oOptions )
  535. {
  536. var oCol = oSettings.aoColumns[ iCol ];
  537. var oClasses = oSettings.oClasses;
  538. var th = $(oCol.nTh);
  539. // Try to get width information from the DOM. We can't get it from CSS
  540. // as we'd need to parse the CSS stylesheet. `width` option can override
  541. if ( ! oCol.sWidthOrig ) {
  542. // Width attribute
  543. oCol.sWidthOrig = th.attr('width') || null;
  544. // Style attribute
  545. var t = (th.attr('style') || '').match(/width:\s*(\d+[pxem%]+)/);
  546. if ( t ) {
  547. oCol.sWidthOrig = t[1];
  548. }
  549. }
  550. /* User specified column options */
  551. if ( oOptions !== undefined && oOptions !== null )
  552. {
  553. // Backwards compatibility
  554. _fnCompatCols( oOptions );
  555. // Map camel case parameters to their Hungarian counterparts
  556. _fnCamelToHungarian( DataTable.defaults.column, oOptions );
  557. /* Backwards compatibility for mDataProp */
  558. if ( oOptions.mDataProp !== undefined && !oOptions.mData )
  559. {
  560. oOptions.mData = oOptions.mDataProp;
  561. }
  562. if ( oOptions.sType )
  563. {
  564. oCol._sManualType = oOptions.sType;
  565. }
  566. // `class` is a reserved word in Javascript, so we need to provide
  567. // the ability to use a valid name for the camel case input
  568. if ( oOptions.className && ! oOptions.sClass )
  569. {
  570. oOptions.sClass = oOptions.className;
  571. }
  572. $.extend( oCol, oOptions );
  573. _fnMap( oCol, oOptions, "sWidth", "sWidthOrig" );
  574. /* iDataSort to be applied (backwards compatibility), but aDataSort will take
  575. * priority if defined
  576. */
  577. if ( oOptions.iDataSort !== undefined )
  578. {
  579. oCol.aDataSort = [ oOptions.iDataSort ];
  580. }
  581. _fnMap( oCol, oOptions, "aDataSort" );
  582. }
  583. /* Cache the data get and set functions for speed */
  584. var mDataSrc = oCol.mData;
  585. var mData = _fnGetObjectDataFn( mDataSrc );
  586. var mRender = oCol.mRender ? _fnGetObjectDataFn( oCol.mRender ) : null;
  587. var attrTest = function( src ) {
  588. return typeof src === 'string' && src.indexOf('@') !== -1;
  589. };
  590. oCol._bAttrSrc = $.isPlainObject( mDataSrc ) && (
  591. attrTest(mDataSrc.sort) || attrTest(mDataSrc.type) || attrTest(mDataSrc.filter)
  592. );
  593. oCol.fnGetData = function (rowData, type, meta) {
  594. var innerData = mData( rowData, type, undefined, meta );
  595. return mRender && type ?
  596. mRender( innerData, type, rowData, meta ) :
  597. innerData;
  598. };
  599. oCol.fnSetData = function ( rowData, val, meta ) {
  600. return _fnSetObjectDataFn( mDataSrc )( rowData, val, meta );
  601. };
  602. // Indicate if DataTables should read DOM data as an object or array
  603. // Used in _fnGetRowElements
  604. if ( typeof mDataSrc !== 'number' ) {
  605. oSettings._rowReadObject = true;
  606. }
  607. /* Feature sorting overrides column specific when off */
  608. if ( !oSettings.oFeatures.bSort )
  609. {
  610. oCol.bSortable = false;
  611. th.addClass( oClasses.sSortableNone ); // Have to add class here as order event isn't called
  612. }
  613. /* Check that the class assignment is correct for sorting */
  614. var bAsc = $.inArray('asc', oCol.asSorting) !== -1;
  615. var bDesc = $.inArray('desc', oCol.asSorting) !== -1;
  616. if ( !oCol.bSortable || (!bAsc && !bDesc) )
  617. {
  618. oCol.sSortingClass = oClasses.sSortableNone;
  619. oCol.sSortingClassJUI = "";
  620. }
  621. else if ( bAsc && !bDesc )
  622. {
  623. oCol.sSortingClass = oClasses.sSortableAsc;
  624. oCol.sSortingClassJUI = oClasses.sSortJUIAscAllowed;
  625. }
  626. else if ( !bAsc && bDesc )
  627. {
  628. oCol.sSortingClass = oClasses.sSortableDesc;
  629. oCol.sSortingClassJUI = oClasses.sSortJUIDescAllowed;
  630. }
  631. else
  632. {
  633. oCol.sSortingClass = oClasses.sSortable;
  634. oCol.sSortingClassJUI = oClasses.sSortJUI;
  635. }
  636. }
  637. /**
  638. * Adjust the table column widths for new data. Note: you would probably want to
  639. * do a redraw after calling this function!
  640. * @param {object} settings dataTables settings object
  641. * @memberof DataTable#oApi
  642. */
  643. function _fnAdjustColumnSizing ( settings )
  644. {
  645. /* Not interested in doing column width calculation if auto-width is disabled */
  646. if ( settings.oFeatures.bAutoWidth !== false )
  647. {
  648. var columns = settings.aoColumns;
  649. _fnCalculateColumnWidths( settings );
  650. for ( var i=0 , iLen=columns.length ; i<iLen ; i++ )
  651. {
  652. columns[i].nTh.style.width = columns[i].sWidth;
  653. }
  654. }
  655. var scroll = settings.oScroll;
  656. if ( scroll.sY !== '' || scroll.sX !== '')
  657. {
  658. _fnScrollDraw( settings );
  659. }
  660. _fnCallbackFire( settings, null, 'column-sizing', [settings] );
  661. }
  662. /**
  663. * Covert the index of a visible column to the index in the data array (take account
  664. * of hidden columns)
  665. * @param {object} oSettings dataTables settings object
  666. * @param {int} iMatch Visible column index to lookup
  667. * @returns {int} i the data index
  668. * @memberof DataTable#oApi
  669. */
  670. function _fnVisibleToColumnIndex( oSettings, iMatch )
  671. {
  672. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  673. return typeof aiVis[iMatch] === 'number' ?
  674. aiVis[iMatch] :
  675. null;
  676. }
  677. /**
  678. * Covert the index of an index in the data array and convert it to the visible
  679. * column index (take account of hidden columns)
  680. * @param {int} iMatch Column index to lookup
  681. * @param {object} oSettings dataTables settings object
  682. * @returns {int} i the data index
  683. * @memberof DataTable#oApi
  684. */
  685. function _fnColumnIndexToVisible( oSettings, iMatch )
  686. {
  687. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  688. var iPos = $.inArray( iMatch, aiVis );
  689. return iPos !== -1 ? iPos : null;
  690. }
  691. /**
  692. * Get the number of visible columns
  693. * @param {object} oSettings dataTables settings object
  694. * @returns {int} i the number of visible columns
  695. * @memberof DataTable#oApi
  696. */
  697. function _fnVisbleColumns( oSettings )
  698. {
  699. return _fnGetColumns( oSettings, 'bVisible' ).length;
  700. }
  701. /**
  702. * Get an array of column indexes that match a given property
  703. * @param {object} oSettings dataTables settings object
  704. * @param {string} sParam Parameter in aoColumns to look for - typically
  705. * bVisible or bSearchable
  706. * @returns {array} Array of indexes with matched properties
  707. * @memberof DataTable#oApi
  708. */
  709. function _fnGetColumns( oSettings, sParam )
  710. {
  711. var a = [];
  712. $.map( oSettings.aoColumns, function(val, i) {
  713. if ( val[sParam] ) {
  714. a.push( i );
  715. }
  716. } );
  717. return a;
  718. }
  719. /**
  720. * Calculate the 'type' of a column
  721. * @param {object} settings dataTables settings object
  722. * @memberof DataTable#oApi
  723. */
  724. function _fnColumnTypes ( settings )
  725. {
  726. var columns = settings.aoColumns;
  727. var data = settings.aoData;
  728. var types = DataTable.ext.type.detect;
  729. var i, ien, j, jen, k, ken;
  730. var col, cell, detectedType, cache;
  731. // For each column, spin over the
  732. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  733. col = columns[i];
  734. cache = [];
  735. if ( ! col.sType && col._sManualType ) {
  736. col.sType = col._sManualType;
  737. }
  738. else if ( ! col.sType ) {
  739. for ( j=0, jen=types.length ; j<jen ; j++ ) {
  740. for ( k=0, ken=data.length ; k<ken ; k++ ) {
  741. // Use a cache array so we only need to get the type data
  742. // from the formatter once (when using multiple detectors)
  743. if ( cache[k] === undefined ) {
  744. cache[k] = _fnGetCellData( settings, k, i, 'type' );
  745. }
  746. detectedType = types[j]( cache[k], settings );
  747. // If null, then this type can't apply to this column, so
  748. // rather than testing all cells, break out. There is an
  749. // exception for the last type which is `html`. We need to
  750. // scan all rows since it is possible to mix string and HTML
  751. // types
  752. if ( ! detectedType && j !== types.length-1 ) {
  753. break;
  754. }
  755. // Only a single match is needed for html type since it is
  756. // bottom of the pile and very similar to string
  757. if ( detectedType === 'html' ) {
  758. break;
  759. }
  760. }
  761. // Type is valid for all data points in the column - use this
  762. // type
  763. if ( detectedType ) {
  764. col.sType = detectedType;
  765. break;
  766. }
  767. }
  768. // Fall back - if no type was detected, always use string
  769. if ( ! col.sType ) {
  770. col.sType = 'string';
  771. }
  772. }
  773. }
  774. }
  775. /**
  776. * Take the column definitions and static columns arrays and calculate how
  777. * they relate to column indexes. The callback function will then apply the
  778. * definition found for a column to a suitable configuration object.
  779. * @param {object} oSettings dataTables settings object
  780. * @param {array} aoColDefs The aoColumnDefs array that is to be applied
  781. * @param {array} aoCols The aoColumns array that defines columns individually
  782. * @param {function} fn Callback function - takes two parameters, the calculated
  783. * column index and the definition for that column.
  784. * @memberof DataTable#oApi
  785. */
  786. function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, fn )
  787. {
  788. var i, iLen, j, jLen, k, kLen, def;
  789. var columns = oSettings.aoColumns;
  790. // Column definitions with aTargets
  791. if ( aoColDefs )
  792. {
  793. /* Loop over the definitions array - loop in reverse so first instance has priority */
  794. for ( i=aoColDefs.length-1 ; i>=0 ; i-- )
  795. {
  796. def = aoColDefs[i];
  797. /* Each definition can target multiple columns, as it is an array */
  798. var aTargets = def.targets !== undefined ?
  799. def.targets :
  800. def.aTargets;
  801. if ( ! $.isArray( aTargets ) )
  802. {
  803. aTargets = [ aTargets ];
  804. }
  805. for ( j=0, jLen=aTargets.length ; j<jLen ; j++ )
  806. {
  807. if ( typeof aTargets[j] === 'number' && aTargets[j] >= 0 )
  808. {
  809. /* Add columns that we don't yet know about */
  810. while( columns.length <= aTargets[j] )
  811. {
  812. _fnAddColumn( oSettings );
  813. }
  814. /* Integer, basic index */
  815. fn( aTargets[j], def );
  816. }
  817. else if ( typeof aTargets[j] === 'number' && aTargets[j] < 0 )
  818. {
  819. /* Negative integer, right to left column counting */
  820. fn( columns.length+aTargets[j], def );
  821. }
  822. else if ( typeof aTargets[j] === 'string' )
  823. {
  824. /* Class name matching on TH element */
  825. for ( k=0, kLen=columns.length ; k<kLen ; k++ )
  826. {
  827. if ( aTargets[j] == "_all" ||
  828. $(columns[k].nTh).hasClass( aTargets[j] ) )
  829. {
  830. fn( k, def );
  831. }
  832. }
  833. }
  834. }
  835. }
  836. }
  837. // Statically defined columns array
  838. if ( aoCols )
  839. {
  840. for ( i=0, iLen=aoCols.length ; i<iLen ; i++ )
  841. {
  842. fn( i, aoCols[i] );
  843. }
  844. }
  845. }
  846. /**
  847. * Add a data array to the table, creating DOM node etc. This is the parallel to
  848. * _fnGatherData, but for adding rows from a Javascript source, rather than a
  849. * DOM source.
  850. * @param {object} oSettings dataTables settings object
  851. * @param {array} aData data array to be added
  852. * @param {node} [nTr] TR element to add to the table - optional. If not given,
  853. * DataTables will create a row automatically
  854. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  855. * if nTr is.
  856. * @returns {int} >=0 if successful (index of new aoData entry), -1 if failed
  857. * @memberof DataTable#oApi
  858. */
  859. function _fnAddData ( oSettings, aDataIn, nTr, anTds )
  860. {
  861. /* Create the object for storing information about this new row */
  862. var iRow = oSettings.aoData.length;
  863. var oData = $.extend( true, {}, DataTable.models.oRow, {
  864. src: nTr ? 'dom' : 'data',
  865. idx: iRow
  866. } );
  867. oData._aData = aDataIn;
  868. oSettings.aoData.push( oData );
  869. /* Create the cells */
  870. var nTd, sThisType;
  871. var columns = oSettings.aoColumns;
  872. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  873. {
  874. // When working with a row, the data source object must be populated. In
  875. // all other cases, the data source object is already populated, so we
  876. // don't overwrite it, which might break bindings etc
  877. if ( nTr ) {
  878. _fnSetCellData( oSettings, iRow, i, _fnGetCellData( oSettings, iRow, i ) );
  879. }
  880. columns[i].sType = null;
  881. }
  882. /* Add to the display array */
  883. oSettings.aiDisplayMaster.push( iRow );
  884. var id = oSettings.rowIdFn( aDataIn );
  885. if ( id !== undefined ) {
  886. oSettings.aIds[ id ] = oData;
  887. }
  888. /* Create the DOM information, or register it if already present */
  889. if ( nTr || ! oSettings.oFeatures.bDeferRender )
  890. {
  891. _fnCreateTr( oSettings, iRow, nTr, anTds );
  892. }
  893. return iRow;
  894. }
  895. /**
  896. * Add one or more TR elements to the table. Generally we'd expect to
  897. * use this for reading data from a DOM sourced table, but it could be
  898. * used for an TR element. Note that if a TR is given, it is used (i.e.
  899. * it is not cloned).
  900. * @param {object} settings dataTables settings object
  901. * @param {array|node|jQuery} trs The TR element(s) to add to the table
  902. * @returns {array} Array of indexes for the added rows
  903. * @memberof DataTable#oApi
  904. */
  905. function _fnAddTr( settings, trs )
  906. {
  907. var row;
  908. // Allow an individual node to be passed in
  909. if ( ! (trs instanceof $) ) {
  910. trs = $(trs);
  911. }
  912. return trs.map( function (i, el) {
  913. row = _fnGetRowElements( settings, el );
  914. return _fnAddData( settings, row.data, el, row.cells );
  915. } );
  916. }
  917. /**
  918. * Take a TR element and convert it to an index in aoData
  919. * @param {object} oSettings dataTables settings object
  920. * @param {node} n the TR element to find
  921. * @returns {int} index if the node is found, null if not
  922. * @memberof DataTable#oApi
  923. */
  924. function _fnNodeToDataIndex( oSettings, n )
  925. {
  926. return (n._DT_RowIndex!==undefined) ? n._DT_RowIndex : null;
  927. }
  928. /**
  929. * Take a TD element and convert it into a column data index (not the visible index)
  930. * @param {object} oSettings dataTables settings object
  931. * @param {int} iRow The row number the TD/TH can be found in
  932. * @param {node} n The TD/TH element to find
  933. * @returns {int} index if the node is found, -1 if not
  934. * @memberof DataTable#oApi
  935. */
  936. function _fnNodeToColumnIndex( oSettings, iRow, n )
  937. {
  938. return $.inArray( n, oSettings.aoData[ iRow ].anCells );
  939. }
  940. /**
  941. * Get the data for a given cell from the internal cache, taking into account data mapping
  942. * @param {object} settings dataTables settings object
  943. * @param {int} rowIdx aoData row id
  944. * @param {int} colIdx Column index
  945. * @param {string} type data get type ('display', 'type' 'filter' 'sort')
  946. * @returns {*} Cell data
  947. * @memberof DataTable#oApi
  948. */
  949. function _fnGetCellData( settings, rowIdx, colIdx, type )
  950. {
  951. var draw = settings.iDraw;
  952. var col = settings.aoColumns[colIdx];
  953. var rowData = settings.aoData[rowIdx]._aData;
  954. var defaultContent = col.sDefaultContent;
  955. var cellData = col.fnGetData( rowData, type, {
  956. settings: settings,
  957. row: rowIdx,
  958. col: colIdx
  959. } );
  960. if ( cellData === undefined ) {
  961. if ( settings.iDrawError != draw && defaultContent === null ) {
  962. _fnLog( settings, 0, "Requested unknown parameter "+
  963. (typeof col.mData=='function' ? '{function}' : "'"+col.mData+"'")+
  964. " for row "+rowIdx, 4 );
  965. settings.iDrawError = draw;
  966. }
  967. return defaultContent;
  968. }
  969. /* When the data source is null, we can use default column data */
  970. if ( (cellData === rowData || cellData === null) && defaultContent !== null ) {
  971. cellData = defaultContent;
  972. }
  973. else if ( typeof cellData === 'function' ) {
  974. // If the data source is a function, then we run it and use the return,
  975. // executing in the scope of the data object (for instances)
  976. return cellData.call( rowData );
  977. }
  978. if ( cellData === null && type == 'display' ) {
  979. return '';
  980. }
  981. return cellData;
  982. }
  983. /**
  984. * Set the value for a specific cell, into the internal data cache
  985. * @param {object} settings dataTables settings object
  986. * @param {int} rowIdx aoData row id
  987. * @param {int} colIdx Column index
  988. * @param {*} val Value to set
  989. * @memberof DataTable#oApi
  990. */
  991. function _fnSetCellData( settings, rowIdx, colIdx, val )
  992. {
  993. var col = settings.aoColumns[colIdx];
  994. var rowData = settings.aoData[rowIdx]._aData;
  995. col.fnSetData( rowData, val, {
  996. settings: settings,
  997. row: rowIdx,
  998. col: colIdx
  999. } );
  1000. }
  1001. // Private variable that is used to match action syntax in the data property object
  1002. var __reArray = /\[.*?\]$/;
  1003. var __reFn = /\(\)$/;
  1004. /**
  1005. * Split string on periods, taking into account escaped periods
  1006. * @param {string} str String to split
  1007. * @return {array} Split string
  1008. */
  1009. function _fnSplitObjNotation( str )
  1010. {
  1011. return $.map( str.match(/(\\.|[^\.])+/g) || [''], function ( s ) {
  1012. return s.replace(/\\./g, '.');
  1013. } );
  1014. }
  1015. /**
  1016. * Return a function that can be used to get data from a source object, taking
  1017. * into account the ability to use nested objects as a source
  1018. * @param {string|int|function} mSource The data source for the object
  1019. * @returns {function} Data get function
  1020. * @memberof DataTable#oApi
  1021. */
  1022. function _fnGetObjectDataFn( mSource )
  1023. {
  1024. if ( $.isPlainObject( mSource ) )
  1025. {
  1026. /* Build an object of get functions, and wrap them in a single call */
  1027. var o = {};
  1028. $.each( mSource, function (key, val) {
  1029. if ( val ) {
  1030. o[key] = _fnGetObjectDataFn( val );
  1031. }
  1032. } );
  1033. return function (data, type, row, meta) {
  1034. var t = o[type] || o._;
  1035. return t !== undefined ?
  1036. t(data, type, row, meta) :
  1037. data;
  1038. };
  1039. }
  1040. else if ( mSource === null )
  1041. {
  1042. /* Give an empty string for rendering / sorting etc */
  1043. return function (data) { // type, row and meta also passed, but not used
  1044. return data;
  1045. };
  1046. }
  1047. else if ( typeof mSource === 'function' )
  1048. {
  1049. return function (data, type, row, meta) {
  1050. return mSource( data, type, row, meta );
  1051. };
  1052. }
  1053. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  1054. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  1055. {
  1056. /* If there is a . in the source string then the data source is in a
  1057. * nested object so we loop over the data for each level to get the next
  1058. * level down. On each loop we test for undefined, and if found immediately
  1059. * return. This allows entire objects to be missing and sDefaultContent to
  1060. * be used if defined, rather than throwing an error
  1061. */
  1062. var fetchData = function (data, type, src) {
  1063. var arrayNotation, funcNotation, out, innerSrc;
  1064. if ( src !== "" )
  1065. {
  1066. var a = _fnSplitObjNotation( src );
  1067. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  1068. {
  1069. // Check if we are dealing with special notation
  1070. arrayNotation = a[i].match(__reArray);
  1071. funcNotation = a[i].match(__reFn);
  1072. if ( arrayNotation )
  1073. {
  1074. // Array notation
  1075. a[i] = a[i].replace(__reArray, '');
  1076. // Condition allows simply [] to be passed in
  1077. if ( a[i] !== "" ) {
  1078. data = data[ a[i] ];
  1079. }
  1080. out = [];
  1081. // Get the remainder of the nested object to get
  1082. a.splice( 0, i+1 );
  1083. innerSrc = a.join('.');
  1084. // Traverse each entry in the array getting the properties requested
  1085. for ( var j=0, jLen=data.length ; j<jLen ; j++ ) {
  1086. out.push( fetchData( data[j], type, innerSrc ) );
  1087. }
  1088. // If a string is given in between the array notation indicators, that
  1089. // is used to join the strings together, otherwise an array is returned
  1090. var join = arrayNotation[0].substring(1, arrayNotation[0].length-1);
  1091. data = (join==="") ? out : out.join(join);
  1092. // The inner call to fetchData has already traversed through the remainder
  1093. // of the source requested, so we exit from the loop
  1094. break;
  1095. }
  1096. else if ( funcNotation )
  1097. {
  1098. // Function call
  1099. a[i] = a[i].replace(__reFn, '');
  1100. data = data[ a[i] ]();
  1101. continue;
  1102. }
  1103. if ( data === null || data[ a[i] ] === undefined )
  1104. {
  1105. return undefined;
  1106. }
  1107. data = data[ a[i] ];
  1108. }
  1109. }
  1110. return data;
  1111. };
  1112. return function (data, type) { // row and meta also passed, but not used
  1113. return fetchData( data, type, mSource );
  1114. };
  1115. }
  1116. else
  1117. {
  1118. /* Array or flat object mapping */
  1119. return function (data, type) { // row and meta also passed, but not used
  1120. return data[mSource];
  1121. };
  1122. }
  1123. }
  1124. /**
  1125. * Return a function that can be used to set data from a source object, taking
  1126. * into account the ability to use nested objects as a source
  1127. * @param {string|int|function} mSource The data source for the object
  1128. * @returns {function} Data set function
  1129. * @memberof DataTable#oApi
  1130. */
  1131. function _fnSetObjectDataFn( mSource )
  1132. {
  1133. if ( $.isPlainObject( mSource ) )
  1134. {
  1135. /* Unlike get, only the underscore (global) option is used for for
  1136. * setting data since we don't know the type here. This is why an object
  1137. * option is not documented for `mData` (which is read/write), but it is
  1138. * for `mRender` which is read only.
  1139. */
  1140. return _fnSetObjectDataFn( mSource._ );
  1141. }
  1142. else if ( mSource === null )
  1143. {
  1144. /* Nothing to do when the data source is null */
  1145. return function () {};
  1146. }
  1147. else if ( typeof mSource === 'function' )
  1148. {
  1149. return function (data, val, meta) {
  1150. mSource( data, 'set', val, meta );
  1151. };
  1152. }
  1153. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  1154. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  1155. {
  1156. /* Like the get, we need to get data from a nested object */
  1157. var setData = function (data, val, src) {
  1158. var a = _fnSplitObjNotation( src ), b;
  1159. var aLast = a[a.length-1];
  1160. var arrayNotation, funcNotation, o, innerSrc;
  1161. for ( var i=0, iLen=a.length-1 ; i<iLen ; i++ )
  1162. {
  1163. // Check if we are dealing with an array notation request
  1164. arrayNotation = a[i].match(__reArray);
  1165. funcNotation = a[i].match(__reFn);
  1166. if ( arrayNotation )
  1167. {
  1168. a[i] = a[i].replace(__reArray, '');
  1169. data[ a[i] ] = [];
  1170. // Get the remainder of the nested object to set so we can recurse
  1171. b = a.slice();
  1172. b.splice( 0, i+1 );
  1173. innerSrc = b.join('.');
  1174. // Traverse each entry in the array setting the properties requested
  1175. for ( var j=0, jLen=val.length ; j<jLen ; j++ )
  1176. {
  1177. o = {};
  1178. setData( o, val[j], innerSrc );
  1179. data[ a[i] ].push( o );
  1180. }
  1181. // The inner call to setData has already traversed through the remainder
  1182. // of the source and has set the data, thus we can exit here
  1183. return;
  1184. }
  1185. else if ( funcNotation )
  1186. {
  1187. // Function call
  1188. a[i] = a[i].replace(__reFn, '');
  1189. data = data[ a[i] ]( val );
  1190. }
  1191. // If the nested object doesn't currently exist - since we are
  1192. // trying to set the value - create it
  1193. if ( data[ a[i] ] === null || data[ a[i] ] === undefined )
  1194. {
  1195. data[ a[i] ] = {};
  1196. }
  1197. data = data[ a[i] ];
  1198. }
  1199. // Last item in the input - i.e, the actual set
  1200. if ( aLast.match(__reFn ) )
  1201. {
  1202. // Function call
  1203. data = data[ aLast.replace(__reFn, '') ]( val );
  1204. }
  1205. else
  1206. {
  1207. // If array notation is used, we just want to strip it and use the property name
  1208. // and assign the value. If it isn't used, then we get the result we want anyway
  1209. data[ aLast.replace(__reArray, '') ] = val;
  1210. }
  1211. };
  1212. return function (data, val) { // meta is also passed in, but not used
  1213. return setData( data, val, mSource );
  1214. };
  1215. }
  1216. else
  1217. {
  1218. /* Array or flat object mapping */
  1219. return function (data, val) { // meta is also passed in, but not used
  1220. data[mSource] = val;
  1221. };
  1222. }
  1223. }
  1224. /**
  1225. * Return an array with the full table data
  1226. * @param {object} oSettings dataTables settings object
  1227. * @returns array {array} aData Master data array
  1228. * @memberof DataTable#oApi
  1229. */
  1230. function _fnGetDataMaster ( settings )
  1231. {
  1232. return _pluck( settings.aoData, '_aData' );
  1233. }
  1234. /**
  1235. * Nuke the table
  1236. * @param {object} oSettings dataTables settings object
  1237. * @memberof DataTable#oApi
  1238. */
  1239. function _fnClearTable( settings )
  1240. {
  1241. settings.aoData.length = 0;
  1242. settings.aiDisplayMaster.length = 0;
  1243. settings.aiDisplay.length = 0;
  1244. }
  1245. /**
  1246. * Take an array of integers (index array) and remove a target integer (value - not
  1247. * the key!)
  1248. * @param {array} a Index array to target
  1249. * @param {int} iTarget value to find
  1250. * @memberof DataTable#oApi
  1251. */
  1252. function _fnDeleteIndex( a, iTarget, splice )
  1253. {
  1254. var iTargetIndex = -1;
  1255. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  1256. {
  1257. if ( a[i] == iTarget )
  1258. {
  1259. iTargetIndex = i;
  1260. }
  1261. else if ( a[i] > iTarget )
  1262. {
  1263. a[i]--;
  1264. }
  1265. }
  1266. if ( iTargetIndex != -1 && splice === undefined )
  1267. {
  1268. a.splice( iTargetIndex, 1 );
  1269. }
  1270. }
  1271. /**
  1272. * Mark cached data as invalid such that a re-read of the data will occur when
  1273. * the cached data is next requested. Also update from the data source object.
  1274. *
  1275. * @param {object} settings DataTables settings object
  1276. * @param {int} rowIdx Row index to invalidate
  1277. * @param {string} [src] Source to invalidate from: undefined, 'auto', 'dom'
  1278. * or 'data'
  1279. * @param {int} [colIdx] Column index to invalidate. If undefined the whole
  1280. * row will be invalidated
  1281. * @memberof DataTable#oApi
  1282. *
  1283. * @todo For the modularisation of v1.11 this will need to become a callback, so
  1284. * the sort and filter methods can subscribe to it. That will required
  1285. * initialisation options for sorting, which is why it is not already baked in
  1286. */
  1287. function _fnInvalidate( settings, rowIdx, src, colIdx )
  1288. {
  1289. var row = settings.aoData[ rowIdx ];
  1290. var i, ien;
  1291. var cellWrite = function ( cell, col ) {
  1292. // This is very frustrating, but in IE if you just write directly
  1293. // to innerHTML, and elements that are overwritten are GC'ed,
  1294. // even if there is a reference to them elsewhere
  1295. while ( cell.childNodes.length ) {
  1296. cell.removeChild( cell.firstChild );
  1297. }
  1298. cell.innerHTML = _fnGetCellData( settings, rowIdx, col, 'display' );
  1299. };
  1300. // Are we reading last data from DOM or the data object?
  1301. if ( src === 'dom' || ((! src || src === 'auto') && row.src === 'dom') ) {
  1302. // Read the data from the DOM
  1303. row._aData = _fnGetRowElements(
  1304. settings, row, colIdx, colIdx === undefined ? undefined : row._aData
  1305. )
  1306. .data;
  1307. }
  1308. else {
  1309. // Reading from data object, update the DOM
  1310. var cells = row.anCells;
  1311. if ( cells ) {
  1312. if ( colIdx !== undefined ) {
  1313. cellWrite( cells[colIdx], colIdx );
  1314. }
  1315. else {
  1316. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  1317. cellWrite( cells[i], i );
  1318. }
  1319. }
  1320. }
  1321. }
  1322. // For both row and cell invalidation, the cached data for sorting and
  1323. // filtering is nulled out
  1324. row._aSortData = null;
  1325. row._aFilterData = null;
  1326. // Invalidate the type for a specific column (if given) or all columns since
  1327. // the data might have changed
  1328. var cols = settings.aoColumns;
  1329. if ( colIdx !== undefined ) {
  1330. cols[ colIdx ].sType = null;
  1331. }
  1332. else {
  1333. for ( i=0, ien=cols.length ; i<ien ; i++ ) {
  1334. cols[i].sType = null;
  1335. }
  1336. // Update DataTables special `DT_*` attributes for the row
  1337. _fnRowAttributes( settings, row );
  1338. }
  1339. }
  1340. /**
  1341. * Build a data source object from an HTML row, reading the contents of the
  1342. * cells that are in the row.
  1343. *
  1344. * @param {object} settings DataTables settings object
  1345. * @param {node|object} TR element from which to read data or existing row
  1346. * object from which to re-read the data from the cells
  1347. * @param {int} [colIdx] Optional column index
  1348. * @param {array|object} [d] Data source object. If `colIdx` is given then this
  1349. * parameter should also be given and will be used to write the data into.
  1350. * Only the column in question will be written
  1351. * @returns {object} Object with two parameters: `data` the data read, in
  1352. * document order, and `cells` and array of nodes (they can be useful to the
  1353. * caller, so rather than needing a second traversal to get them, just return
  1354. * them from here).
  1355. * @memberof DataTable#oApi
  1356. */
  1357. function _fnGetRowElements( settings, row, colIdx, d )
  1358. {
  1359. var
  1360. tds = [],
  1361. td = row.firstChild,
  1362. name, col, o, i=0, contents,
  1363. columns = settings.aoColumns,
  1364. objectRead = settings._rowReadObject;
  1365. // Allow the data object to be passed in, or construct
  1366. d = d || objectRead ? {} : [];
  1367. var attr = function ( str, td ) {
  1368. if ( typeof str === 'string' ) {
  1369. var idx = str.indexOf('@');
  1370. if ( idx !== -1 ) {
  1371. var attr = str.substring( idx+1 );
  1372. var setter = _fnSetObjectDataFn( str );
  1373. setter( d, td.getAttribute( attr ) );
  1374. }
  1375. }
  1376. };
  1377. // Read data from a cell and store into the data object
  1378. var cellProcess = function ( cell ) {
  1379. if ( colIdx === undefined || colIdx === i ) {
  1380. col = columns[i];
  1381. contents = $.trim(cell.innerHTML);
  1382. if ( col && col._bAttrSrc ) {
  1383. var setter = _fnSetObjectDataFn( col.mData._ );
  1384. setter( d, contents );
  1385. attr( col.mData.sort, cell );
  1386. attr( col.mData.type, cell );
  1387. attr( col.mData.filter, cell );
  1388. }
  1389. else {
  1390. // Depending on the `data` option for the columns the data can
  1391. // be read to either an object or an array.
  1392. if ( objectRead ) {
  1393. if ( ! col._setter ) {
  1394. // Cache the setter function
  1395. col._setter = _fnSetObjectDataFn( col.mData );
  1396. }
  1397. col._setter( d, contents );
  1398. }
  1399. else {
  1400. d[i] = contents;
  1401. }
  1402. }
  1403. }
  1404. i++;
  1405. };
  1406. if ( td ) {
  1407. // `tr` element was passed in
  1408. while ( td ) {
  1409. name = td.nodeName.toUpperCase();
  1410. if ( name == "TD" || name == "TH" ) {
  1411. cellProcess( td );
  1412. tds.push( td );
  1413. }
  1414. td = td.nextSibling;
  1415. }
  1416. }
  1417. else {
  1418. // Existing row object passed in
  1419. tds = row.anCells;
  1420. for ( var j=0, jen=tds.length ; j<jen ; j++ ) {
  1421. cellProcess( tds[j] );
  1422. }
  1423. }
  1424. // Read the ID from the DOM if present
  1425. var id = row.getAttribute( 'id' );
  1426. if ( id ) {
  1427. _fnSetObjectDataFn( settings.rowId )( d, id );
  1428. }
  1429. return {
  1430. data: d,
  1431. cells: tds
  1432. };
  1433. }
  1434. /**
  1435. * Create a new TR element (and it's TD children) for a row
  1436. * @param {object} oSettings dataTables settings object
  1437. * @param {int} iRow Row to consider
  1438. * @param {node} [nTrIn] TR element to add to the table - optional. If not given,
  1439. * DataTables will create a row automatically
  1440. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  1441. * if nTr is.
  1442. * @memberof DataTable#oApi
  1443. */
  1444. function _fnCreateTr ( oSettings, iRow, nTrIn, anTds )
  1445. {
  1446. var
  1447. row = oSettings.aoData[iRow],
  1448. rowData = row._aData,
  1449. cells = [],
  1450. nTr, nTd, oCol,
  1451. i, iLen;
  1452. if ( row.nTr === null )
  1453. {
  1454. nTr = nTrIn || document.createElement('tr');
  1455. row.nTr = nTr;
  1456. row.anCells = cells;
  1457. /* Use a private property on the node to allow reserve mapping from the node
  1458. * to the aoData array for fast look up
  1459. */
  1460. nTr._DT_RowIndex = iRow;
  1461. /* Special parameters can be given by the data source to be used on the row */
  1462. _fnRowAttributes( oSettings, row );
  1463. /* Process each column */
  1464. for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
  1465. {
  1466. oCol = oSettings.aoColumns[i];
  1467. nTd = nTrIn ? anTds[i] : document.createElement( oCol.sCellType );
  1468. cells.push( nTd );
  1469. // Need to create the HTML if new, or if a rendering function is defined
  1470. if ( !nTrIn || oCol.mRender || oCol.mData !== i )
  1471. {
  1472. nTd.innerHTML = _fnGetCellData( oSettings, iRow, i, 'display' );
  1473. }
  1474. /* Add user defined class */
  1475. if ( oCol.sClass )
  1476. {
  1477. nTd.className += ' '+oCol.sClass;
  1478. }
  1479. // Visibility - add or remove as required
  1480. if ( oCol.bVisible && ! nTrIn )
  1481. {
  1482. nTr.appendChild( nTd );
  1483. }
  1484. else if ( ! oCol.bVisible && nTrIn )
  1485. {
  1486. nTd.parentNode.removeChild( nTd );
  1487. }
  1488. if ( oCol.fnCreatedCell )
  1489. {
  1490. oCol.fnCreatedCell.call( oSettings.oInstance,
  1491. nTd, _fnGetCellData( oSettings, iRow, i ), rowData, iRow, i
  1492. );
  1493. }
  1494. }
  1495. _fnCallbackFire( oSettings, 'aoRowCreatedCallback', null, [nTr, rowData, iRow] );
  1496. }
  1497. // Remove once webkit bug 131819 and Chromium bug 365619 have been resolved
  1498. // and deployed
  1499. row.nTr.setAttribute( 'role', 'row' );
  1500. }
  1501. /**
  1502. * Add attributes to a row based on the special `DT_*` parameters in a data
  1503. * source object.
  1504. * @param {object} settings DataTables settings object
  1505. * @param {object} DataTables row object for the row to be modified
  1506. * @memberof DataTable#oApi
  1507. */
  1508. function _fnRowAttributes( settings, row )
  1509. {
  1510. var tr = row.nTr;
  1511. var data = row._aData;
  1512. if ( tr ) {
  1513. var id = settings.rowIdFn( data );
  1514. if ( id ) {
  1515. tr.id = id;
  1516. }
  1517. if ( data.DT_RowClass ) {
  1518. // Remove any classes added by DT_RowClass before
  1519. var a = data.DT_RowClass.split(' ');
  1520. row.__rowc = row.__rowc ?
  1521. _unique( row.__rowc.concat( a ) ) :
  1522. a;
  1523. $(tr)
  1524. .removeClass( row.__rowc.join(' ') )
  1525. .addClass( data.DT_RowClass );
  1526. }
  1527. if ( data.DT_RowAttr ) {
  1528. $(tr).attr( data.DT_RowAttr );
  1529. }
  1530. if ( data.DT_RowData ) {
  1531. $(tr).data( data.DT_RowData );
  1532. }
  1533. }
  1534. }
  1535. /**
  1536. * Create the HTML header for the table
  1537. * @param {object} oSettings dataTables settings object
  1538. * @memberof DataTable#oApi
  1539. */
  1540. function _fnBuildHead( oSettings )
  1541. {
  1542. var i, ien, cell, row, column;
  1543. var thead = oSettings.nTHead;
  1544. var tfoot = oSettings.nTFoot;
  1545. var createHeader = $('th, td', thead).length === 0;
  1546. var classes = oSettings.oClasses;
  1547. var columns = oSettings.aoColumns;
  1548. if ( createHeader ) {
  1549. row = $('<tr/>').appendTo( thead );
  1550. }
  1551. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  1552. column = columns[i];
  1553. cell = $( column.nTh ).addClass( column.sClass );
  1554. if ( createHeader ) {
  1555. cell.appendTo( row );
  1556. }
  1557. // 1.11 move into sorting
  1558. if ( oSettings.oFeatures.bSort ) {
  1559. cell.addClass( column.sSortingClass );
  1560. if ( column.bSortable !== false ) {
  1561. cell
  1562. .attr( 'tabindex', oSettings.iTabIndex )
  1563. .attr( 'aria-controls', oSettings.sTableId );
  1564. _fnSortAttachListener( oSettings, column.nTh, i );
  1565. }
  1566. }
  1567. if ( column.sTitle != cell[0].innerHTML ) {
  1568. cell.html( column.sTitle );
  1569. }
  1570. _fnRenderer( oSettings, 'header' )(
  1571. oSettings, cell, column, classes
  1572. );
  1573. }
  1574. if ( createHeader ) {
  1575. _fnDetectHeader( oSettings.aoHeader, thead );
  1576. }
  1577. /* ARIA role for the rows */
  1578. $(thead).find('>tr').attr('role', 'row');
  1579. /* Deal with the footer - add classes if required */
  1580. $(thead).find('>tr>th, >tr>td').addClass( classes.sHeaderTH );
  1581. $(tfoot).find('>tr>th, >tr>td').addClass( classes.sFooterTH );
  1582. // Cache the footer cells. Note that we only take the cells from the first
  1583. // row in the footer. If there is more than one row the user wants to
  1584. // interact with, they need to use the table().foot() method. Note also this
  1585. // allows cells to be used for multiple columns using colspan
  1586. if ( tfoot !== null ) {
  1587. var cells = oSettings.aoFooter[0];
  1588. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  1589. column = columns[i];
  1590. column.nTf = cells[i].cell;
  1591. if ( column.sClass ) {
  1592. $(column.nTf).addClass( column.sClass );
  1593. }
  1594. }
  1595. }
  1596. }
  1597. /**
  1598. * Draw the header (or footer) element based on the column visibility states. The
  1599. * methodology here is to use the layout array from _fnDetectHeader, modified for
  1600. * the instantaneous column visibility, to construct the new layout. The grid is
  1601. * traversed over cell at a time in a rows x columns grid fashion, although each
  1602. * cell insert can cover multiple elements in the grid - which is tracks using the
  1603. * aApplied array. Cell inserts in the grid will only occur where there isn't
  1604. * already a cell in that position.
  1605. * @param {object} oSettings dataTables settings object
  1606. * @param array {objects} aoSource Layout array from _fnDetectHeader
  1607. * @param {boolean} [bIncludeHidden=false] If true then include the hidden columns in the calc,
  1608. * @memberof DataTable#oApi
  1609. */
  1610. function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
  1611. {
  1612. var i, iLen, j, jLen, k, kLen, n, nLocalTr;
  1613. var aoLocal = [];
  1614. var aApplied = [];
  1615. var iColumns = oSettings.aoColumns.length;
  1616. var iRowspan, iColspan;
  1617. if ( ! aoSource )
  1618. {
  1619. return;
  1620. }
  1621. if ( bIncludeHidden === undefined )
  1622. {
  1623. bIncludeHidden = false;
  1624. }
  1625. /* Make a copy of the master layout array, but without the visible columns in it */
  1626. for ( i=0, iLen=aoSource.length ; i<iLen ; i++ )
  1627. {
  1628. aoLocal[i] = aoSource[i].slice();
  1629. aoLocal[i].nTr = aoSource[i].nTr;
  1630. /* Remove any columns which are currently hidden */
  1631. for ( j=iColumns-1 ; j>=0 ; j-- )
  1632. {
  1633. if ( !oSettings.aoColumns[j].bVisible && !bIncludeHidden )
  1634. {
  1635. aoLocal[i].splice( j, 1 );
  1636. }
  1637. }
  1638. /* Prep the applied array - it needs an element for each row */
  1639. aApplied.push( [] );
  1640. }
  1641. for ( i=0, iLen=aoLocal.length ; i<iLen ; i++ )
  1642. {
  1643. nLocalTr = aoLocal[i].nTr;
  1644. /* All cells are going to be replaced, so empty out the row */
  1645. if ( nLocalTr )
  1646. {
  1647. while( (n = nLocalTr.firstChild) )
  1648. {
  1649. nLocalTr.removeChild( n );
  1650. }
  1651. }
  1652. for ( j=0, jLen=aoLocal[i].length ; j<jLen ; j++ )
  1653. {
  1654. iRowspan = 1;
  1655. iColspan = 1;
  1656. /* Check to see if there is already a cell (row/colspan) covering our target
  1657. * insert point. If there is, then there is nothing to do.
  1658. */
  1659. if ( aApplied[i][j] === undefined )
  1660. {
  1661. nLocalTr.appendChild( aoLocal[i][j].cell );
  1662. aApplied[i][j] = 1;
  1663. /* Expand the cell to cover as many rows as needed */
  1664. while ( aoLocal[i+iRowspan] !== undefined &&
  1665. aoLocal[i][j].cell == aoLocal[i+iRowspan][j].cell )
  1666. {
  1667. aApplied[i+iRowspan][j] = 1;
  1668. iRowspan++;
  1669. }
  1670. /* Expand the cell to cover as many columns as needed */
  1671. while ( aoLocal[i][j+iColspan] !== undefined &&
  1672. aoLocal[i][j].cell == aoLocal[i][j+iColspan].cell )
  1673. {
  1674. /* Must update the applied array over the rows for the columns */
  1675. for ( k=0 ; k<iRowspan ; k++ )
  1676. {
  1677. aApplied[i+k][j+iColspan] = 1;
  1678. }
  1679. iColspan++;
  1680. }
  1681. /* Do the actual expansion in the DOM */
  1682. $(aoLocal[i][j].cell)
  1683. .attr('rowspan', iRowspan)
  1684. .attr('colspan', iColspan);
  1685. }
  1686. }
  1687. }
  1688. }
  1689. /**
  1690. * Insert the required TR nodes into the table for display
  1691. * @param {object} oSettings dataTables settings object
  1692. * @memberof DataTable#oApi
  1693. */
  1694. function _fnDraw( oSettings )
  1695. {
  1696. /* Provide a pre-callback function which can be used to cancel the draw is false is returned */
  1697. var aPreDraw = _fnCallbackFire( oSettings, 'aoPreDrawCallback', 'preDraw', [oSettings] );
  1698. if ( $.inArray( false, aPreDraw ) !== -1 )
  1699. {
  1700. _fnProcessingDisplay( oSettings, false );
  1701. return;
  1702. }
  1703. var i, iLen, n;
  1704. var anRows = [];
  1705. var iRowCount = 0;
  1706. var asStripeClasses = oSettings.asStripeClasses;
  1707. var iStripes = asStripeClasses.length;
  1708. var iOpenRows = oSettings.aoOpenRows.length;
  1709. var oLang = oSettings.oLanguage;
  1710. var iInitDisplayStart = oSettings.iInitDisplayStart;
  1711. var bServerSide = _fnDataSource( oSettings ) == 'ssp';
  1712. var aiDisplay = oSettings.aiDisplay;
  1713. oSettings.bDrawing = true;
  1714. /* Check and see if we have an initial draw position from state saving */
  1715. if ( iInitDisplayStart !== undefined && iInitDisplayStart !== -1 )
  1716. {
  1717. oSettings._iDisplayStart = bServerSide ?
  1718. iInitDisplayStart :
  1719. iInitDisplayStart >= oSettings.fnRecordsDisplay() ?
  1720. 0 :
  1721. iInitDisplayStart;
  1722. oSettings.iInitDisplayStart = -1;
  1723. }
  1724. var iDisplayStart = oSettings._iDisplayStart;
  1725. var iDisplayEnd = oSettings.fnDisplayEnd();
  1726. /* Server-side processing draw intercept */
  1727. if ( oSettings.bDeferLoading )
  1728. {
  1729. oSettings.bDeferLoading = false;
  1730. oSettings.iDraw++;
  1731. _fnProcessingDisplay( oSettings, false );
  1732. }
  1733. else if ( !bServerSide )
  1734. {
  1735. oSettings.iDraw++;
  1736. }
  1737. else if ( !oSettings.bDestroying && !_fnAjaxUpdate( oSettings ) )
  1738. {
  1739. return;
  1740. }
  1741. if ( aiDisplay.length !== 0 )
  1742. {
  1743. var iStart = bServerSide ? 0 : iDisplayStart;
  1744. var iEnd = bServerSide ? oSettings.aoData.length : iDisplayEnd;
  1745. for ( var j=iStart ; j<iEnd ; j++ )
  1746. {
  1747. var iDataIndex = aiDisplay[j];
  1748. var aoData = oSettings.aoData[ iDataIndex ];
  1749. if ( aoData.nTr === null )
  1750. {
  1751. _fnCreateTr( oSettings, iDataIndex );
  1752. }
  1753. var nRow = aoData.nTr;
  1754. /* Remove the old striping classes and then add the new one */
  1755. if ( iStripes !== 0 )
  1756. {
  1757. var sStripe = asStripeClasses[ iRowCount % iStripes ];
  1758. if ( aoData._sRowStripe != sStripe )
  1759. {
  1760. $(nRow).removeClass( aoData._sRowStripe ).addClass( sStripe );
  1761. aoData._sRowStripe = sStripe;
  1762. }
  1763. }
  1764. // Row callback functions - might want to manipulate the row
  1765. // iRowCount and j are not currently documented. Are they at all
  1766. // useful?
  1767. _fnCallbackFire( oSettings, 'aoRowCallback', null,
  1768. [nRow, aoData._aData, iRowCount, j] );
  1769. anRows.push( nRow );
  1770. iRowCount++;
  1771. }
  1772. }
  1773. else
  1774. {
  1775. /* Table is empty - create a row with an empty message in it */
  1776. var sZero = oLang.sZeroRecords;
  1777. if ( oSettings.iDraw == 1 && _fnDataSource( oSettings ) == 'ajax' )
  1778. {
  1779. sZero = oLang.sLoadingRecords;
  1780. }
  1781. else if ( oLang.sEmptyTable && oSettings.fnRecordsTotal() === 0 )
  1782. {
  1783. sZero = oLang.sEmptyTable;
  1784. }
  1785. anRows[ 0 ] = $( '<tr/>', { 'class': iStripes ? asStripeClasses[0] : '' } )
  1786. .append( $('<td />', {
  1787. 'valign': 'top',
  1788. 'colSpan': _fnVisbleColumns( oSettings ),
  1789. 'class': oSettings.oClasses.sRowEmpty
  1790. } ).html( sZero ) )[0];
  1791. }
  1792. /* Header and footer callbacks */
  1793. _fnCallbackFire( oSettings, 'aoHeaderCallback', 'header', [ $(oSettings.nTHead).children('tr')[0],
  1794. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  1795. _fnCallbackFire( oSettings, 'aoFooterCallback', 'footer', [ $(oSettings.nTFoot).children('tr')[0],
  1796. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  1797. var body = $(oSettings.nTBody);
  1798. body.children().detach();
  1799. body.append( $(anRows) );
  1800. /* Call all required callback functions for the end of a draw */
  1801. _fnCallbackFire( oSettings, 'aoDrawCallback', 'draw', [oSettings] );
  1802. /* Draw is complete, sorting and filtering must be as well */
  1803. oSettings.bSorted = false;
  1804. oSettings.bFiltered = false;
  1805. oSettings.bDrawing = false;
  1806. }
  1807. /**
  1808. * Redraw the table - taking account of the various features which are enabled
  1809. * @param {object} oSettings dataTables settings object
  1810. * @param {boolean} [holdPosition] Keep the current paging position. By default
  1811. * the paging is reset to the first page
  1812. * @memberof DataTable#oApi
  1813. */
  1814. function _fnReDraw( settings, holdPosition )
  1815. {
  1816. var
  1817. features = settings.oFeatures,
  1818. sort = features.bSort,
  1819. filter = features.bFilter;
  1820. if ( sort ) {
  1821. _fnSort( settings );
  1822. }
  1823. if ( filter ) {
  1824. _fnFilterComplete( settings, settings.oPreviousSearch );
  1825. }
  1826. else {
  1827. // No filtering, so we want to just use the display master
  1828. settings.aiDisplay = settings.aiDisplayMaster.slice();
  1829. }
  1830. if ( holdPosition !== true ) {
  1831. settings._iDisplayStart = 0;
  1832. }
  1833. // Let any modules know about the draw hold position state (used by
  1834. // scrolling internally)
  1835. settings._drawHold = holdPosition;
  1836. _fnDraw( settings );
  1837. settings._drawHold = false;
  1838. }
  1839. /**
  1840. * Add the options to the page HTML for the table
  1841. * @param {object} oSettings dataTables settings object
  1842. * @memberof DataTable#oApi
  1843. */
  1844. function _fnAddOptionsHtml ( oSettings )
  1845. {
  1846. var classes = oSettings.oClasses;
  1847. var table = $(oSettings.nTable);
  1848. var holding = $('<div/>').insertBefore( table ); // Holding element for speed
  1849. var features = oSettings.oFeatures;
  1850. // All DataTables are wrapped in a div
  1851. var insert = $('<div/>', {
  1852. id: oSettings.sTableId+'_wrapper',
  1853. 'class': classes.sWrapper + (oSettings.nTFoot ? '' : ' '+classes.sNoFooter)
  1854. } );
  1855. oSettings.nHolding = holding[0];
  1856. oSettings.nTableWrapper = insert[0];
  1857. oSettings.nTableReinsertBefore = oSettings.nTable.nextSibling;
  1858. /* Loop over the user set positioning and place the elements as needed */
  1859. var aDom = oSettings.sDom.split('');
  1860. var featureNode, cOption, nNewNode, cNext, sAttr, j;
  1861. for ( var i=0 ; i<aDom.length ; i++ )
  1862. {
  1863. featureNode = null;
  1864. cOption = aDom[i];
  1865. if ( cOption == '<' )
  1866. {
  1867. /* New container div */
  1868. nNewNode = $('<div/>')[0];
  1869. /* Check to see if we should append an id and/or a class name to the container */
  1870. cNext = aDom[i+1];
  1871. if ( cNext == "'" || cNext == '"' )
  1872. {
  1873. sAttr = "";
  1874. j = 2;
  1875. while ( aDom[i+j] != cNext )
  1876. {
  1877. sAttr += aDom[i+j];
  1878. j++;
  1879. }
  1880. /* Replace jQuery UI constants @todo depreciated */
  1881. if ( sAttr == "H" )
  1882. {
  1883. sAttr = classes.sJUIHeader;
  1884. }
  1885. else if ( sAttr == "F" )
  1886. {
  1887. sAttr = classes.sJUIFooter;
  1888. }
  1889. /* The attribute can be in the format of "#id.class", "#id" or "class" This logic
  1890. * breaks the string into parts and applies them as needed
  1891. */
  1892. if ( sAttr.indexOf('.') != -1 )
  1893. {
  1894. var aSplit = sAttr.split('.');
  1895. nNewNode.id = aSplit[0].substr(1, aSplit[0].length-1);
  1896. nNewNode.className = aSplit[1];
  1897. }
  1898. else if ( sAttr.charAt(0) == "#" )
  1899. {
  1900. nNewNode.id = sAttr.substr(1, sAttr.length-1);
  1901. }
  1902. else
  1903. {
  1904. nNewNode.className = sAttr;
  1905. }
  1906. i += j; /* Move along the position array */
  1907. }
  1908. insert.append( nNewNode );
  1909. insert = $(nNewNode);
  1910. }
  1911. else if ( cOption == '>' )
  1912. {
  1913. /* End container div */
  1914. insert = insert.parent();
  1915. }
  1916. // @todo Move options into their own plugins?
  1917. else if ( cOption == 'l' && features.bPaginate && features.bLengthChange )
  1918. {
  1919. /* Length */
  1920. featureNode = _fnFeatureHtmlLength( oSettings );
  1921. }
  1922. else if ( cOption == 'f' && features.bFilter )
  1923. {
  1924. /* Filter */
  1925. featureNode = _fnFeatureHtmlFilter( oSettings );
  1926. }
  1927. else if ( cOption == 'r' && features.bProcessing )
  1928. {
  1929. /* pRocessing */
  1930. featureNode = _fnFeatureHtmlProcessing( oSettings );
  1931. }
  1932. else if ( cOption == 't' )
  1933. {
  1934. /* Table */
  1935. featureNode = _fnFeatureHtmlTable( oSettings );
  1936. }
  1937. else if ( cOption == 'i' && features.bInfo )
  1938. {
  1939. /* Info */
  1940. featureNode = _fnFeatureHtmlInfo( oSettings );
  1941. }
  1942. else if ( cOption == 'p' && features.bPaginate )
  1943. {
  1944. /* Pagination */
  1945. featureNode = _fnFeatureHtmlPaginate( oSettings );
  1946. }
  1947. else if ( DataTable.ext.feature.length !== 0 )
  1948. {
  1949. /* Plug-in features */
  1950. var aoFeatures = DataTable.ext.feature;
  1951. for ( var k=0, kLen=aoFeatures.length ; k<kLen ; k++ )
  1952. {
  1953. if ( cOption == aoFeatures[k].cFeature )
  1954. {
  1955. featureNode = aoFeatures[k].fnInit( oSettings );
  1956. break;
  1957. }
  1958. }
  1959. }
  1960. /* Add to the 2D features array */
  1961. if ( featureNode )
  1962. {
  1963. var aanFeatures = oSettings.aanFeatures;
  1964. if ( ! aanFeatures[cOption] )
  1965. {
  1966. aanFeatures[cOption] = [];
  1967. }
  1968. aanFeatures[cOption].push( featureNode );
  1969. insert.append( featureNode );
  1970. }
  1971. }
  1972. /* Built our DOM structure - replace the holding div with what we want */
  1973. holding.replaceWith( insert );
  1974. oSettings.nHolding = null;
  1975. }
  1976. /**
  1977. * Use the DOM source to create up an array of header cells. The idea here is to
  1978. * create a layout grid (array) of rows x columns, which contains a reference
  1979. * to the cell that that point in the grid (regardless of col/rowspan), such that
  1980. * any column / row could be removed and the new grid constructed
  1981. * @param array {object} aLayout Array to store the calculated layout in
  1982. * @param {node} nThead The header/footer element for the table
  1983. * @memberof DataTable#oApi
  1984. */
  1985. function _fnDetectHeader ( aLayout, nThead )
  1986. {
  1987. var nTrs = $(nThead).children('tr');
  1988. var nTr, nCell;
  1989. var i, k, l, iLen, jLen, iColShifted, iColumn, iColspan, iRowspan;
  1990. var bUnique;
  1991. var fnShiftCol = function ( a, i, j ) {
  1992. var k = a[i];
  1993. while ( k[j] ) {
  1994. j++;
  1995. }
  1996. return j;
  1997. };
  1998. aLayout.splice( 0, aLayout.length );
  1999. /* We know how many rows there are in the layout - so prep it */
  2000. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  2001. {
  2002. aLayout.push( [] );
  2003. }
  2004. /* Calculate a layout array */
  2005. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  2006. {
  2007. nTr = nTrs[i];
  2008. iColumn = 0;
  2009. /* For every cell in the row... */
  2010. nCell = nTr.firstChild;
  2011. while ( nCell ) {
  2012. if ( nCell.nodeName.toUpperCase() == "TD" ||
  2013. nCell.nodeName.toUpperCase() == "TH" )
  2014. {
  2015. /* Get the col and rowspan attributes from the DOM and sanitise them */
  2016. iColspan = nCell.getAttribute('colspan') * 1;
  2017. iRowspan = nCell.getAttribute('rowspan') * 1;
  2018. iColspan = (!iColspan || iColspan===0 || iColspan===1) ? 1 : iColspan;
  2019. iRowspan = (!iRowspan || iRowspan===0 || iRowspan===1) ? 1 : iRowspan;
  2020. /* There might be colspan cells already in this row, so shift our target
  2021. * accordingly
  2022. */
  2023. iColShifted = fnShiftCol( aLayout, i, iColumn );
  2024. /* Cache calculation for unique columns */
  2025. bUnique = iColspan === 1 ? true : false;
  2026. /* If there is col / rowspan, copy the information into the layout grid */
  2027. for ( l=0 ; l<iColspan ; l++ )
  2028. {
  2029. for ( k=0 ; k<iRowspan ; k++ )
  2030. {
  2031. aLayout[i+k][iColShifted+l] = {
  2032. "cell": nCell,
  2033. "unique": bUnique
  2034. };
  2035. aLayout[i+k].nTr = nTr;
  2036. }
  2037. }
  2038. }
  2039. nCell = nCell.nextSibling;
  2040. }
  2041. }
  2042. }
  2043. /**
  2044. * Get an array of unique th elements, one for each column
  2045. * @param {object} oSettings dataTables settings object
  2046. * @param {node} nHeader automatically detect the layout from this node - optional
  2047. * @param {array} aLayout thead/tfoot layout from _fnDetectHeader - optional
  2048. * @returns array {node} aReturn list of unique th's
  2049. * @memberof DataTable#oApi
  2050. */
  2051. function _fnGetUniqueThs ( oSettings, nHeader, aLayout )
  2052. {
  2053. var aReturn = [];
  2054. if ( !aLayout )
  2055. {
  2056. aLayout = oSettings.aoHeader;
  2057. if ( nHeader )
  2058. {
  2059. aLayout = [];
  2060. _fnDetectHeader( aLayout, nHeader );
  2061. }
  2062. }
  2063. for ( var i=0, iLen=aLayout.length ; i<iLen ; i++ )
  2064. {
  2065. for ( var j=0, jLen=aLayout[i].length ; j<jLen ; j++ )
  2066. {
  2067. if ( aLayout[i][j].unique &&
  2068. (!aReturn[j] || !oSettings.bSortCellsTop) )
  2069. {
  2070. aReturn[j] = aLayout[i][j].cell;
  2071. }
  2072. }
  2073. }
  2074. return aReturn;
  2075. }
  2076. /**
  2077. * Create an Ajax call based on the table's settings, taking into account that
  2078. * parameters can have multiple forms, and backwards compatibility.
  2079. *
  2080. * @param {object} oSettings dataTables settings object
  2081. * @param {array} data Data to send to the server, required by
  2082. * DataTables - may be augmented by developer callbacks
  2083. * @param {function} fn Callback function to run when data is obtained
  2084. */
  2085. function _fnBuildAjax( oSettings, data, fn )
  2086. {
  2087. // Compatibility with 1.9-, allow fnServerData and event to manipulate
  2088. _fnCallbackFire( oSettings, 'aoServerParams', 'serverParams', [data] );
  2089. // Convert to object based for 1.10+ if using the old array scheme which can
  2090. // come from server-side processing or serverParams
  2091. if ( data && $.isArray(data) ) {
  2092. var tmp = {};
  2093. var rbracket = /(.*?)\[\]$/;
  2094. $.each( data, function (key, val) {
  2095. var match = val.name.match(rbracket);
  2096. if ( match ) {
  2097. // Support for arrays
  2098. var name = match[0];
  2099. if ( ! tmp[ name ] ) {
  2100. tmp[ name ] = [];
  2101. }
  2102. tmp[ name ].push( val.value );
  2103. }
  2104. else {
  2105. tmp[val.name] = val.value;
  2106. }
  2107. } );
  2108. data = tmp;
  2109. }
  2110. var ajaxData;
  2111. var ajax = oSettings.ajax;
  2112. var instance = oSettings.oInstance;
  2113. var callback = function ( json ) {
  2114. _fnCallbackFire( oSettings, null, 'xhr', [oSettings, json, oSettings.jqXHR] );
  2115. fn( json );
  2116. };
  2117. if ( $.isPlainObject( ajax ) && ajax.data )
  2118. {
  2119. ajaxData = ajax.data;
  2120. var newData = $.isFunction( ajaxData ) ?
  2121. ajaxData( data, oSettings ) : // fn can manipulate data or return
  2122. ajaxData; // an object object or array to merge
  2123. // If the function returned something, use that alone
  2124. data = $.isFunction( ajaxData ) && newData ?
  2125. newData :
  2126. $.extend( true, data, newData );
  2127. // Remove the data property as we've resolved it already and don't want
  2128. // jQuery to do it again (it is restored at the end of the function)
  2129. delete ajax.data;
  2130. }
  2131. var baseAjax = {
  2132. "data": data,
  2133. "success": function (json) {
  2134. var error = json.error || json.sError;
  2135. if ( error ) {
  2136. _fnLog( oSettings, 0, error );
  2137. }
  2138. oSettings.json = json;
  2139. callback( json );
  2140. },
  2141. "dataType": "json",
  2142. "cache": false,
  2143. "type": oSettings.sServerMethod,
  2144. "error": function (xhr, error, thrown) {
  2145. var ret = _fnCallbackFire( oSettings, null, 'xhr', [oSettings, null, oSettings.jqXHR] );
  2146. if ( $.inArray( true, ret ) === -1 ) {
  2147. if ( error == "parsererror" ) {
  2148. _fnLog( oSettings, 0, 'Invalid JSON response', 1 );
  2149. }
  2150. else if ( xhr.readyState === 4 ) {
  2151. _fnLog( oSettings, 0, 'Ajax error', 7 );
  2152. }
  2153. }
  2154. _fnProcessingDisplay( oSettings, false );
  2155. }
  2156. };
  2157. // Store the data submitted for the API
  2158. oSettings.oAjaxData = data;
  2159. // Allow plug-ins and external processes to modify the data
  2160. _fnCallbackFire( oSettings, null, 'preXhr', [oSettings, data] );
  2161. if ( oSettings.fnServerData )
  2162. {
  2163. // DataTables 1.9- compatibility
  2164. oSettings.fnServerData.call( instance,
  2165. oSettings.sAjaxSource,
  2166. $.map( data, function (val, key) { // Need to convert back to 1.9 trad format
  2167. return { name: key, value: val };
  2168. } ),
  2169. callback,
  2170. oSettings
  2171. );
  2172. }
  2173. else if ( oSettings.sAjaxSource || typeof ajax === 'string' )
  2174. {
  2175. // DataTables 1.9- compatibility
  2176. oSettings.jqXHR = $.ajax( $.extend( baseAjax, {
  2177. url: ajax || oSettings.sAjaxSource
  2178. } ) );
  2179. }
  2180. else if ( $.isFunction( ajax ) )
  2181. {
  2182. // Is a function - let the caller define what needs to be done
  2183. oSettings.jqXHR = ajax.call( instance, data, callback, oSettings );
  2184. }
  2185. else
  2186. {
  2187. // Object to extend the base settings
  2188. oSettings.jqXHR = $.ajax( $.extend( baseAjax, ajax ) );
  2189. // Restore for next time around
  2190. ajax.data = ajaxData;
  2191. }
  2192. }
  2193. /**
  2194. * Update the table using an Ajax call
  2195. * @param {object} settings dataTables settings object
  2196. * @returns {boolean} Block the table drawing or not
  2197. * @memberof DataTable#oApi
  2198. */
  2199. function _fnAjaxUpdate( settings )
  2200. {
  2201. if ( settings.bAjaxDataGet ) {
  2202. settings.iDraw++;
  2203. _fnProcessingDisplay( settings, true );
  2204. _fnBuildAjax(
  2205. settings,
  2206. _fnAjaxParameters( settings ),
  2207. function(json) {
  2208. _fnAjaxUpdateDraw( settings, json );
  2209. }
  2210. );
  2211. return false;
  2212. }
  2213. return true;
  2214. }
  2215. /**
  2216. * Build up the parameters in an object needed for a server-side processing
  2217. * request. Note that this is basically done twice, is different ways - a modern
  2218. * method which is used by default in DataTables 1.10 which uses objects and
  2219. * arrays, or the 1.9- method with is name / value pairs. 1.9 method is used if
  2220. * the sAjaxSource option is used in the initialisation, or the legacyAjax
  2221. * option is set.
  2222. * @param {object} oSettings dataTables settings object
  2223. * @returns {bool} block the table drawing or not
  2224. * @memberof DataTable#oApi
  2225. */
  2226. function _fnAjaxParameters( settings )
  2227. {
  2228. var
  2229. columns = settings.aoColumns,
  2230. columnCount = columns.length,
  2231. features = settings.oFeatures,
  2232. preSearch = settings.oPreviousSearch,
  2233. preColSearch = settings.aoPreSearchCols,
  2234. i, data = [], dataProp, column, columnSearch,
  2235. sort = _fnSortFlatten( settings ),
  2236. displayStart = settings._iDisplayStart,
  2237. displayLength = features.bPaginate !== false ?
  2238. settings._iDisplayLength :
  2239. -1;
  2240. var param = function ( name, value ) {
  2241. data.push( { 'name': name, 'value': value } );
  2242. };
  2243. // DataTables 1.9- compatible method
  2244. param( 'sEcho', settings.iDraw );
  2245. param( 'iColumns', columnCount );
  2246. param( 'sColumns', _pluck( columns, 'sName' ).join(',') );
  2247. param( 'iDisplayStart', displayStart );
  2248. param( 'iDisplayLength', displayLength );
  2249. // DataTables 1.10+ method
  2250. var d = {
  2251. draw: settings.iDraw,
  2252. columns: [],
  2253. order: [],
  2254. start: displayStart,
  2255. length: displayLength,
  2256. search: {
  2257. value: preSearch.sSearch,
  2258. regex: preSearch.bRegex
  2259. }
  2260. };
  2261. for ( i=0 ; i<columnCount ; i++ ) {
  2262. column = columns[i];
  2263. columnSearch = preColSearch[i];
  2264. dataProp = typeof column.mData=="function" ? 'function' : column.mData ;
  2265. d.columns.push( {
  2266. data: dataProp,
  2267. name: column.sName,
  2268. searchable: column.bSearchable,
  2269. orderable: column.bSortable,
  2270. search: {
  2271. value: columnSearch.sSearch,
  2272. regex: columnSearch.bRegex
  2273. }
  2274. } );
  2275. param( "mDataProp_"+i, dataProp );
  2276. if ( features.bFilter ) {
  2277. param( 'sSearch_'+i, columnSearch.sSearch );
  2278. param( 'bRegex_'+i, columnSearch.bRegex );
  2279. param( 'bSearchable_'+i, column.bSearchable );
  2280. }
  2281. if ( features.bSort ) {
  2282. param( 'bSortable_'+i, column.bSortable );
  2283. }
  2284. }
  2285. if ( features.bFilter ) {
  2286. param( 'sSearch', preSearch.sSearch );
  2287. param( 'bRegex', preSearch.bRegex );
  2288. }
  2289. if ( features.bSort ) {
  2290. $.each( sort, function ( i, val ) {
  2291. d.order.push( { column: val.col, dir: val.dir } );
  2292. param( 'iSortCol_'+i, val.col );
  2293. param( 'sSortDir_'+i, val.dir );
  2294. } );
  2295. param( 'iSortingCols', sort.length );
  2296. }
  2297. // If the legacy.ajax parameter is null, then we automatically decide which
  2298. // form to use, based on sAjaxSource
  2299. var legacy = DataTable.ext.legacy.ajax;
  2300. if ( legacy === null ) {
  2301. return settings.sAjaxSource ? data : d;
  2302. }
  2303. // Otherwise, if legacy has been specified then we use that to decide on the
  2304. // form
  2305. return legacy ? data : d;
  2306. }
  2307. /**
  2308. * Data the data from the server (nuking the old) and redraw the table
  2309. * @param {object} oSettings dataTables settings object
  2310. * @param {object} json json data return from the server.
  2311. * @param {string} json.sEcho Tracking flag for DataTables to match requests
  2312. * @param {int} json.iTotalRecords Number of records in the data set, not accounting for filtering
  2313. * @param {int} json.iTotalDisplayRecords Number of records in the data set, accounting for filtering
  2314. * @param {array} json.aaData The data to display on this page
  2315. * @param {string} [json.sColumns] Column ordering (sName, comma separated)
  2316. * @memberof DataTable#oApi
  2317. */
  2318. function _fnAjaxUpdateDraw ( settings, json )
  2319. {
  2320. // v1.10 uses camelCase variables, while 1.9 uses Hungarian notation.
  2321. // Support both
  2322. var compat = function ( old, modern ) {
  2323. return json[old] !== undefined ? json[old] : json[modern];
  2324. };
  2325. var data = _fnAjaxDataSrc( settings, json );
  2326. var draw = compat( 'sEcho', 'draw' );
  2327. var recordsTotal = compat( 'iTotalRecords', 'recordsTotal' );
  2328. var recordsFiltered = compat( 'iTotalDisplayRecords', 'recordsFiltered' );
  2329. if ( draw ) {
  2330. // Protect against out of sequence returns
  2331. if ( draw*1 < settings.iDraw ) {
  2332. return;
  2333. }
  2334. settings.iDraw = draw * 1;
  2335. }
  2336. _fnClearTable( settings );
  2337. settings._iRecordsTotal = parseInt(recordsTotal, 10);
  2338. settings._iRecordsDisplay = parseInt(recordsFiltered, 10);
  2339. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  2340. _fnAddData( settings, data[i] );
  2341. }
  2342. settings.aiDisplay = settings.aiDisplayMaster.slice();
  2343. settings.bAjaxDataGet = false;
  2344. _fnDraw( settings );
  2345. if ( ! settings._bInitComplete ) {
  2346. _fnInitComplete( settings, json );
  2347. }
  2348. settings.bAjaxDataGet = true;
  2349. _fnProcessingDisplay( settings, false );
  2350. }
  2351. /**
  2352. * Get the data from the JSON data source to use for drawing a table. Using
  2353. * `_fnGetObjectDataFn` allows the data to be sourced from a property of the
  2354. * source object, or from a processing function.
  2355. * @param {object} oSettings dataTables settings object
  2356. * @param {object} json Data source object / array from the server
  2357. * @return {array} Array of data to use
  2358. */
  2359. function _fnAjaxDataSrc ( oSettings, json )
  2360. {
  2361. var dataSrc = $.isPlainObject( oSettings.ajax ) && oSettings.ajax.dataSrc !== undefined ?
  2362. oSettings.ajax.dataSrc :
  2363. oSettings.sAjaxDataProp; // Compatibility with 1.9-.
  2364. // Compatibility with 1.9-. In order to read from aaData, check if the
  2365. // default has been changed, if not, check for aaData
  2366. if ( dataSrc === 'data' ) {
  2367. return json.aaData || json[dataSrc];
  2368. }
  2369. return dataSrc !== "" ?
  2370. _fnGetObjectDataFn( dataSrc )( json ) :
  2371. json;
  2372. }
  2373. /**
  2374. * Generate the node required for filtering text
  2375. * @returns {node} Filter control element
  2376. * @param {object} oSettings dataTables settings object
  2377. * @memberof DataTable#oApi
  2378. */
  2379. function _fnFeatureHtmlFilter ( settings )
  2380. {
  2381. var classes = settings.oClasses;
  2382. var tableId = settings.sTableId;
  2383. var language = settings.oLanguage;
  2384. var previousSearch = settings.oPreviousSearch;
  2385. var features = settings.aanFeatures;
  2386. var input = '<input type="search" class="'+classes.sFilterInput+'"/>';
  2387. var str = language.sSearch;
  2388. str = str.match(/_INPUT_/) ?
  2389. str.replace('_INPUT_', input) :
  2390. str+input;
  2391. var filter = $('<div/>', {
  2392. 'id': ! features.f ? tableId+'_filter' : null,
  2393. 'class': classes.sFilter
  2394. } )
  2395. .append( $('<label/>' ).append( str ) );
  2396. var searchFn = function() {
  2397. /* Update all other filter input elements for the new display */
  2398. var n = features.f;
  2399. var val = !this.value ? "" : this.value; // mental IE8 fix :-(
  2400. /* Now do the filter */
  2401. if ( val != previousSearch.sSearch ) {
  2402. _fnFilterComplete( settings, {
  2403. "sSearch": val,
  2404. "bRegex": previousSearch.bRegex,
  2405. "bSmart": previousSearch.bSmart ,
  2406. "bCaseInsensitive": previousSearch.bCaseInsensitive
  2407. } );
  2408. // Need to redraw, without resorting
  2409. settings._iDisplayStart = 0;
  2410. _fnDraw( settings );
  2411. }
  2412. };
  2413. var searchDelay = settings.searchDelay !== null ?
  2414. settings.searchDelay :
  2415. _fnDataSource( settings ) === 'ssp' ?
  2416. 400 :
  2417. 0;
  2418. var jqFilter = $('input', filter)
  2419. .val( previousSearch.sSearch )
  2420. .attr( 'placeholder', language.sSearchPlaceholder )
  2421. .bind(
  2422. 'keyup.DT search.DT input.DT paste.DT cut.DT',
  2423. searchDelay ?
  2424. _fnThrottle( searchFn, searchDelay ) :
  2425. searchFn
  2426. )
  2427. .bind( 'keypress.DT', function(e) {
  2428. /* Prevent form submission */
  2429. if ( e.keyCode == 13 ) {
  2430. return false;
  2431. }
  2432. } )
  2433. .attr('aria-controls', tableId);
  2434. // Update the input elements whenever the table is filtered
  2435. $(settings.nTable).on( 'search.dt.DT', function ( ev, s ) {
  2436. if ( settings === s ) {
  2437. // IE9 throws an 'unknown error' if document.activeElement is used
  2438. // inside an iframe or frame...
  2439. try {
  2440. if ( jqFilter[0] !== document.activeElement ) {
  2441. jqFilter.val( previousSearch.sSearch );
  2442. }
  2443. }
  2444. catch ( e ) {}
  2445. }
  2446. } );
  2447. return filter[0];
  2448. }
  2449. /**
  2450. * Filter the table using both the global filter and column based filtering
  2451. * @param {object} oSettings dataTables settings object
  2452. * @param {object} oSearch search information
  2453. * @param {int} [iForce] force a research of the master array (1) or not (undefined or 0)
  2454. * @memberof DataTable#oApi
  2455. */
  2456. function _fnFilterComplete ( oSettings, oInput, iForce )
  2457. {
  2458. var oPrevSearch = oSettings.oPreviousSearch;
  2459. var aoPrevSearch = oSettings.aoPreSearchCols;
  2460. var fnSaveFilter = function ( oFilter ) {
  2461. /* Save the filtering values */
  2462. oPrevSearch.sSearch = oFilter.sSearch;
  2463. oPrevSearch.bRegex = oFilter.bRegex;
  2464. oPrevSearch.bSmart = oFilter.bSmart;
  2465. oPrevSearch.bCaseInsensitive = oFilter.bCaseInsensitive;
  2466. };
  2467. var fnRegex = function ( o ) {
  2468. // Backwards compatibility with the bEscapeRegex option
  2469. return o.bEscapeRegex !== undefined ? !o.bEscapeRegex : o.bRegex;
  2470. };
  2471. // Resolve any column types that are unknown due to addition or invalidation
  2472. // @todo As per sort - can this be moved into an event handler?
  2473. _fnColumnTypes( oSettings );
  2474. /* In server-side processing all filtering is done by the server, so no point hanging around here */
  2475. if ( _fnDataSource( oSettings ) != 'ssp' )
  2476. {
  2477. /* Global filter */
  2478. _fnFilter( oSettings, oInput.sSearch, iForce, fnRegex(oInput), oInput.bSmart, oInput.bCaseInsensitive );
  2479. fnSaveFilter( oInput );
  2480. /* Now do the individual column filter */
  2481. for ( var i=0 ; i<aoPrevSearch.length ; i++ )
  2482. {
  2483. _fnFilterColumn( oSettings, aoPrevSearch[i].sSearch, i, fnRegex(aoPrevSearch[i]),
  2484. aoPrevSearch[i].bSmart, aoPrevSearch[i].bCaseInsensitive );
  2485. }
  2486. /* Custom filtering */
  2487. _fnFilterCustom( oSettings );
  2488. }
  2489. else
  2490. {
  2491. fnSaveFilter( oInput );
  2492. }
  2493. /* Tell the draw function we have been filtering */
  2494. oSettings.bFiltered = true;
  2495. _fnCallbackFire( oSettings, null, 'search', [oSettings] );
  2496. }
  2497. /**
  2498. * Apply custom filtering functions
  2499. * @param {object} oSettings dataTables settings object
  2500. * @memberof DataTable#oApi
  2501. */
  2502. function _fnFilterCustom( settings )
  2503. {
  2504. var filters = DataTable.ext.search;
  2505. var displayRows = settings.aiDisplay;
  2506. var row, rowIdx;
  2507. for ( var i=0, ien=filters.length ; i<ien ; i++ ) {
  2508. var rows = [];
  2509. // Loop over each row and see if it should be included
  2510. for ( var j=0, jen=displayRows.length ; j<jen ; j++ ) {
  2511. rowIdx = displayRows[ j ];
  2512. row = settings.aoData[ rowIdx ];
  2513. if ( filters[i]( settings, row._aFilterData, rowIdx, row._aData, j ) ) {
  2514. rows.push( rowIdx );
  2515. }
  2516. }
  2517. // So the array reference doesn't break set the results into the
  2518. // existing array
  2519. displayRows.length = 0;
  2520. displayRows.push.apply( displayRows, rows );
  2521. }
  2522. }
  2523. /**
  2524. * Filter the table on a per-column basis
  2525. * @param {object} oSettings dataTables settings object
  2526. * @param {string} sInput string to filter on
  2527. * @param {int} iColumn column to filter
  2528. * @param {bool} bRegex treat search string as a regular expression or not
  2529. * @param {bool} bSmart use smart filtering or not
  2530. * @param {bool} bCaseInsensitive Do case insenstive matching or not
  2531. * @memberof DataTable#oApi
  2532. */
  2533. function _fnFilterColumn ( settings, searchStr, colIdx, regex, smart, caseInsensitive )
  2534. {
  2535. if ( searchStr === '' ) {
  2536. return;
  2537. }
  2538. var data;
  2539. var display = settings.aiDisplay;
  2540. var rpSearch = _fnFilterCreateSearch( searchStr, regex, smart, caseInsensitive );
  2541. for ( var i=display.length-1 ; i>=0 ; i-- ) {
  2542. data = settings.aoData[ display[i] ]._aFilterData[ colIdx ];
  2543. if ( ! rpSearch.test( data ) ) {
  2544. display.splice( i, 1 );
  2545. }
  2546. }
  2547. }
  2548. /**
  2549. * Filter the data table based on user input and draw the table
  2550. * @param {object} settings dataTables settings object
  2551. * @param {string} input string to filter on
  2552. * @param {int} force optional - force a research of the master array (1) or not (undefined or 0)
  2553. * @param {bool} regex treat as a regular expression or not
  2554. * @param {bool} smart perform smart filtering or not
  2555. * @param {bool} caseInsensitive Do case insenstive matching or not
  2556. * @memberof DataTable#oApi
  2557. */
  2558. function _fnFilter( settings, input, force, regex, smart, caseInsensitive )
  2559. {
  2560. var rpSearch = _fnFilterCreateSearch( input, regex, smart, caseInsensitive );
  2561. var prevSearch = settings.oPreviousSearch.sSearch;
  2562. var displayMaster = settings.aiDisplayMaster;
  2563. var display, invalidated, i;
  2564. // Need to take account of custom filtering functions - always filter
  2565. if ( DataTable.ext.search.length !== 0 ) {
  2566. force = true;
  2567. }
  2568. // Check if any of the rows were invalidated
  2569. invalidated = _fnFilterData( settings );
  2570. // If the input is blank - we just want the full data set
  2571. if ( input.length <= 0 ) {
  2572. settings.aiDisplay = displayMaster.slice();
  2573. }
  2574. else {
  2575. // New search - start from the master array
  2576. if ( invalidated ||
  2577. force ||
  2578. prevSearch.length > input.length ||
  2579. input.indexOf(prevSearch) !== 0 ||
  2580. settings.bSorted // On resort, the display master needs to be
  2581. // re-filtered since indexes will have changed
  2582. ) {
  2583. settings.aiDisplay = displayMaster.slice();
  2584. }
  2585. // Search the display array
  2586. display = settings.aiDisplay;
  2587. for ( i=display.length-1 ; i>=0 ; i-- ) {
  2588. if ( ! rpSearch.test( settings.aoData[ display[i] ]._sFilterRow ) ) {
  2589. display.splice( i, 1 );
  2590. }
  2591. }
  2592. }
  2593. }
  2594. /**
  2595. * Build a regular expression object suitable for searching a table
  2596. * @param {string} sSearch string to search for
  2597. * @param {bool} bRegex treat as a regular expression or not
  2598. * @param {bool} bSmart perform smart filtering or not
  2599. * @param {bool} bCaseInsensitive Do case insensitive matching or not
  2600. * @returns {RegExp} constructed object
  2601. * @memberof DataTable#oApi
  2602. */
  2603. function _fnFilterCreateSearch( search, regex, smart, caseInsensitive )
  2604. {
  2605. search = regex ?
  2606. search :
  2607. _fnEscapeRegex( search );
  2608. if ( smart ) {
  2609. /* For smart filtering we want to allow the search to work regardless of
  2610. * word order. We also want double quoted text to be preserved, so word
  2611. * order is important - a la google. So this is what we want to
  2612. * generate:
  2613. *
  2614. * ^(?=.*?\bone\b)(?=.*?\btwo three\b)(?=.*?\bfour\b).*$
  2615. */
  2616. var a = $.map( search.match( /"[^"]+"|[^ ]+/g ) || [''], function ( word ) {
  2617. if ( word.charAt(0) === '"' ) {
  2618. var m = word.match( /^"(.*)"$/ );
  2619. word = m ? m[1] : word;
  2620. }
  2621. return word.replace('"', '');
  2622. } );
  2623. search = '^(?=.*?'+a.join( ')(?=.*?' )+').*$';
  2624. }
  2625. return new RegExp( search, caseInsensitive ? 'i' : '' );
  2626. }
  2627. /**
  2628. * Escape a string such that it can be used in a regular expression
  2629. * @param {string} sVal string to escape
  2630. * @returns {string} escaped string
  2631. * @memberof DataTable#oApi
  2632. */
  2633. function _fnEscapeRegex ( sVal )
  2634. {
  2635. return sVal.replace( _re_escape_regex, '\\$1' );
  2636. }
  2637. var __filter_div = $('<div>')[0];
  2638. var __filter_div_textContent = __filter_div.textContent !== undefined;
  2639. // Update the filtering data for each row if needed (by invalidation or first run)
  2640. function _fnFilterData ( settings )
  2641. {
  2642. var columns = settings.aoColumns;
  2643. var column;
  2644. var i, j, ien, jen, filterData, cellData, row;
  2645. var fomatters = DataTable.ext.type.search;
  2646. var wasInvalidated = false;
  2647. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  2648. row = settings.aoData[i];
  2649. if ( ! row._aFilterData ) {
  2650. filterData = [];
  2651. for ( j=0, jen=columns.length ; j<jen ; j++ ) {
  2652. column = columns[j];
  2653. if ( column.bSearchable ) {
  2654. cellData = _fnGetCellData( settings, i, j, 'filter' );
  2655. if ( fomatters[ column.sType ] ) {
  2656. cellData = fomatters[ column.sType ]( cellData );
  2657. }
  2658. // Search in DataTables 1.10 is string based. In 1.11 this
  2659. // should be altered to also allow strict type checking.
  2660. if ( cellData === null ) {
  2661. cellData = '';
  2662. }
  2663. if ( typeof cellData !== 'string' && cellData.toString ) {
  2664. cellData = cellData.toString();
  2665. }
  2666. }
  2667. else {
  2668. cellData = '';
  2669. }
  2670. // If it looks like there is an HTML entity in the string,
  2671. // attempt to decode it so sorting works as expected. Note that
  2672. // we could use a single line of jQuery to do this, but the DOM
  2673. // method used here is much faster http://jsperf.com/html-decode
  2674. if ( cellData.indexOf && cellData.indexOf('&') !== -1 ) {
  2675. __filter_div.innerHTML = cellData;
  2676. cellData = __filter_div_textContent ?
  2677. __filter_div.textContent :
  2678. __filter_div.innerText;
  2679. }
  2680. if ( cellData.replace ) {
  2681. cellData = cellData.replace(/[\r\n]/g, '');
  2682. }
  2683. filterData.push( cellData );
  2684. }
  2685. row._aFilterData = filterData;
  2686. row._sFilterRow = filterData.join(' ');
  2687. wasInvalidated = true;
  2688. }
  2689. }
  2690. return wasInvalidated;
  2691. }
  2692. /**
  2693. * Convert from the internal Hungarian notation to camelCase for external
  2694. * interaction
  2695. * @param {object} obj Object to convert
  2696. * @returns {object} Inverted object
  2697. * @memberof DataTable#oApi
  2698. */
  2699. function _fnSearchToCamel ( obj )
  2700. {
  2701. return {
  2702. search: obj.sSearch,
  2703. smart: obj.bSmart,
  2704. regex: obj.bRegex,
  2705. caseInsensitive: obj.bCaseInsensitive
  2706. };
  2707. }
  2708. /**
  2709. * Convert from camelCase notation to the internal Hungarian. We could use the
  2710. * Hungarian convert function here, but this is cleaner
  2711. * @param {object} obj Object to convert
  2712. * @returns {object} Inverted object
  2713. * @memberof DataTable#oApi
  2714. */
  2715. function _fnSearchToHung ( obj )
  2716. {
  2717. return {
  2718. sSearch: obj.search,
  2719. bSmart: obj.smart,
  2720. bRegex: obj.regex,
  2721. bCaseInsensitive: obj.caseInsensitive
  2722. };
  2723. }
  2724. /**
  2725. * Generate the node required for the info display
  2726. * @param {object} oSettings dataTables settings object
  2727. * @returns {node} Information element
  2728. * @memberof DataTable#oApi
  2729. */
  2730. function _fnFeatureHtmlInfo ( settings )
  2731. {
  2732. var
  2733. tid = settings.sTableId,
  2734. nodes = settings.aanFeatures.i,
  2735. n = $('<div/>', {
  2736. 'class': settings.oClasses.sInfo,
  2737. 'id': ! nodes ? tid+'_info' : null
  2738. } );
  2739. if ( ! nodes ) {
  2740. // Update display on each draw
  2741. settings.aoDrawCallback.push( {
  2742. "fn": _fnUpdateInfo,
  2743. "sName": "information"
  2744. } );
  2745. n
  2746. .attr( 'role', 'status' )
  2747. .attr( 'aria-live', 'polite' );
  2748. // Table is described by our info div
  2749. $(settings.nTable).attr( 'aria-describedby', tid+'_info' );
  2750. }
  2751. return n[0];
  2752. }
  2753. /**
  2754. * Update the information elements in the display
  2755. * @param {object} settings dataTables settings object
  2756. * @memberof DataTable#oApi
  2757. */
  2758. function _fnUpdateInfo ( settings )
  2759. {
  2760. /* Show information about the table */
  2761. var nodes = settings.aanFeatures.i;
  2762. if ( nodes.length === 0 ) {
  2763. return;
  2764. }
  2765. var
  2766. lang = settings.oLanguage,
  2767. start = settings._iDisplayStart+1,
  2768. end = settings.fnDisplayEnd(),
  2769. max = settings.fnRecordsTotal(),
  2770. total = settings.fnRecordsDisplay(),
  2771. out = total ?
  2772. lang.sInfo :
  2773. lang.sInfoEmpty;
  2774. if ( total !== max ) {
  2775. /* Record set after filtering */
  2776. out += ' ' + lang.sInfoFiltered;
  2777. }
  2778. // Convert the macros
  2779. out += lang.sInfoPostFix;
  2780. out = _fnInfoMacros( settings, out );
  2781. var callback = lang.fnInfoCallback;
  2782. if ( callback !== null ) {
  2783. out = callback.call( settings.oInstance,
  2784. settings, start, end, max, total, out
  2785. );
  2786. }
  2787. $(nodes).html( out );
  2788. }
  2789. function _fnInfoMacros ( settings, str )
  2790. {
  2791. // When infinite scrolling, we are always starting at 1. _iDisplayStart is used only
  2792. // internally
  2793. var
  2794. formatter = settings.fnFormatNumber,
  2795. start = settings._iDisplayStart+1,
  2796. len = settings._iDisplayLength,
  2797. vis = settings.fnRecordsDisplay(),
  2798. all = len === -1;
  2799. return str.
  2800. replace(/_START_/g, formatter.call( settings, start ) ).
  2801. replace(/_END_/g, formatter.call( settings, settings.fnDisplayEnd() ) ).
  2802. replace(/_MAX_/g, formatter.call( settings, settings.fnRecordsTotal() ) ).
  2803. replace(/_TOTAL_/g, formatter.call( settings, vis ) ).
  2804. replace(/_PAGE_/g, formatter.call( settings, all ? 1 : Math.ceil( start / len ) ) ).
  2805. replace(/_PAGES_/g, formatter.call( settings, all ? 1 : Math.ceil( vis / len ) ) );
  2806. }
  2807. /**
  2808. * Draw the table for the first time, adding all required features
  2809. * @param {object} settings dataTables settings object
  2810. * @memberof DataTable#oApi
  2811. */
  2812. function _fnInitialise ( settings )
  2813. {
  2814. var i, iLen, iAjaxStart=settings.iInitDisplayStart;
  2815. var columns = settings.aoColumns, column;
  2816. var features = settings.oFeatures;
  2817. var deferLoading = settings.bDeferLoading; // value modified by the draw
  2818. /* Ensure that the table data is fully initialised */
  2819. if ( ! settings.bInitialised ) {
  2820. setTimeout( function(){ _fnInitialise( settings ); }, 200 );
  2821. return;
  2822. }
  2823. /* Show the display HTML options */
  2824. _fnAddOptionsHtml( settings );
  2825. /* Build and draw the header / footer for the table */
  2826. _fnBuildHead( settings );
  2827. _fnDrawHead( settings, settings.aoHeader );
  2828. _fnDrawHead( settings, settings.aoFooter );
  2829. /* Okay to show that something is going on now */
  2830. _fnProcessingDisplay( settings, true );
  2831. /* Calculate sizes for columns */
  2832. if ( features.bAutoWidth ) {
  2833. _fnCalculateColumnWidths( settings );
  2834. }
  2835. for ( i=0, iLen=columns.length ; i<iLen ; i++ ) {
  2836. column = columns[i];
  2837. if ( column.sWidth ) {
  2838. column.nTh.style.width = _fnStringToCss( column.sWidth );
  2839. }
  2840. }
  2841. _fnCallbackFire( settings, null, 'preInit', [settings] );
  2842. // If there is default sorting required - let's do it. The sort function
  2843. // will do the drawing for us. Otherwise we draw the table regardless of the
  2844. // Ajax source - this allows the table to look initialised for Ajax sourcing
  2845. // data (show 'loading' message possibly)
  2846. _fnReDraw( settings );
  2847. // Server-side processing init complete is done by _fnAjaxUpdateDraw
  2848. var dataSrc = _fnDataSource( settings );
  2849. if ( dataSrc != 'ssp' || deferLoading ) {
  2850. // if there is an ajax source load the data
  2851. if ( dataSrc == 'ajax' ) {
  2852. _fnBuildAjax( settings, [], function(json) {
  2853. var aData = _fnAjaxDataSrc( settings, json );
  2854. // Got the data - add it to the table
  2855. for ( i=0 ; i<aData.length ; i++ ) {
  2856. _fnAddData( settings, aData[i] );
  2857. }
  2858. // Reset the init display for cookie saving. We've already done
  2859. // a filter, and therefore cleared it before. So we need to make
  2860. // it appear 'fresh'
  2861. settings.iInitDisplayStart = iAjaxStart;
  2862. _fnReDraw( settings );
  2863. _fnProcessingDisplay( settings, false );
  2864. _fnInitComplete( settings, json );
  2865. }, settings );
  2866. }
  2867. else {
  2868. _fnProcessingDisplay( settings, false );
  2869. _fnInitComplete( settings );
  2870. }
  2871. }
  2872. }
  2873. /**
  2874. * Draw the table for the first time, adding all required features
  2875. * @param {object} oSettings dataTables settings object
  2876. * @param {object} [json] JSON from the server that completed the table, if using Ajax source
  2877. * with client-side processing (optional)
  2878. * @memberof DataTable#oApi
  2879. */
  2880. function _fnInitComplete ( settings, json )
  2881. {
  2882. settings._bInitComplete = true;
  2883. // When data was added after the initialisation (data or Ajax) we need to
  2884. // calculate the column sizing
  2885. if ( json || settings.oInit.aaData ) {
  2886. _fnAdjustColumnSizing( settings );
  2887. }
  2888. _fnCallbackFire( settings, 'aoInitComplete', 'init', [settings, json] );
  2889. }
  2890. function _fnLengthChange ( settings, val )
  2891. {
  2892. var len = parseInt( val, 10 );
  2893. settings._iDisplayLength = len;
  2894. _fnLengthOverflow( settings );
  2895. // Fire length change event
  2896. _fnCallbackFire( settings, null, 'length', [settings, len] );
  2897. }
  2898. /**
  2899. * Generate the node required for user display length changing
  2900. * @param {object} settings dataTables settings object
  2901. * @returns {node} Display length feature node
  2902. * @memberof DataTable#oApi
  2903. */
  2904. function _fnFeatureHtmlLength ( settings )
  2905. {
  2906. var
  2907. classes = settings.oClasses,
  2908. tableId = settings.sTableId,
  2909. menu = settings.aLengthMenu,
  2910. d2 = $.isArray( menu[0] ),
  2911. lengths = d2 ? menu[0] : menu,
  2912. language = d2 ? menu[1] : menu;
  2913. var select = $('<select/>', {
  2914. 'name': tableId+'_length',
  2915. 'aria-controls': tableId,
  2916. 'class': classes.sLengthSelect
  2917. } );
  2918. for ( var i=0, ien=lengths.length ; i<ien ; i++ ) {
  2919. select[0][ i ] = new Option( language[i], lengths[i] );
  2920. }
  2921. var div = $('<div><label/></div>').addClass( classes.sLength );
  2922. if ( ! settings.aanFeatures.l ) {
  2923. div[0].id = tableId+'_length';
  2924. }
  2925. div.children().append(
  2926. settings.oLanguage.sLengthMenu.replace( '_MENU_', select[0].outerHTML )
  2927. );
  2928. // Can't use `select` variable as user might provide their own and the
  2929. // reference is broken by the use of outerHTML
  2930. $('select', div)
  2931. .val( settings._iDisplayLength )
  2932. .bind( 'change.DT', function(e) {
  2933. _fnLengthChange( settings, $(this).val() );
  2934. _fnDraw( settings );
  2935. } );
  2936. // Update node value whenever anything changes the table's length
  2937. $(settings.nTable).bind( 'length.dt.DT', function (e, s, len) {
  2938. if ( settings === s ) {
  2939. $('select', div).val( len );
  2940. }
  2941. } );
  2942. return div[0];
  2943. }
  2944. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  2945. * Note that most of the paging logic is done in
  2946. * DataTable.ext.pager
  2947. */
  2948. /**
  2949. * Generate the node required for default pagination
  2950. * @param {object} oSettings dataTables settings object
  2951. * @returns {node} Pagination feature node
  2952. * @memberof DataTable#oApi
  2953. */
  2954. function _fnFeatureHtmlPaginate ( settings )
  2955. {
  2956. var
  2957. type = settings.sPaginationType,
  2958. plugin = DataTable.ext.pager[ type ],
  2959. modern = typeof plugin === 'function',
  2960. redraw = function( settings ) {
  2961. _fnDraw( settings );
  2962. },
  2963. node = $('<div/>').addClass( settings.oClasses.sPaging + type )[0],
  2964. features = settings.aanFeatures;
  2965. if ( ! modern ) {
  2966. plugin.fnInit( settings, node, redraw );
  2967. }
  2968. /* Add a draw callback for the pagination on first instance, to update the paging display */
  2969. if ( ! features.p )
  2970. {
  2971. node.id = settings.sTableId+'_paginate';
  2972. settings.aoDrawCallback.push( {
  2973. "fn": function( settings ) {
  2974. if ( modern ) {
  2975. var
  2976. start = settings._iDisplayStart,
  2977. len = settings._iDisplayLength,
  2978. visRecords = settings.fnRecordsDisplay(),
  2979. all = len === -1,
  2980. page = all ? 0 : Math.ceil( start / len ),
  2981. pages = all ? 1 : Math.ceil( visRecords / len ),
  2982. buttons = plugin(page, pages),
  2983. i, ien;
  2984. for ( i=0, ien=features.p.length ; i<ien ; i++ ) {
  2985. _fnRenderer( settings, 'pageButton' )(
  2986. settings, features.p[i], i, buttons, page, pages
  2987. );
  2988. }
  2989. }
  2990. else {
  2991. plugin.fnUpdate( settings, redraw );
  2992. }
  2993. },
  2994. "sName": "pagination"
  2995. } );
  2996. }
  2997. return node;
  2998. }
  2999. /**
  3000. * Alter the display settings to change the page
  3001. * @param {object} settings DataTables settings object
  3002. * @param {string|int} action Paging action to take: "first", "previous",
  3003. * "next" or "last" or page number to jump to (integer)
  3004. * @param [bool] redraw Automatically draw the update or not
  3005. * @returns {bool} true page has changed, false - no change
  3006. * @memberof DataTable#oApi
  3007. */
  3008. function _fnPageChange ( settings, action, redraw )
  3009. {
  3010. var
  3011. start = settings._iDisplayStart,
  3012. len = settings._iDisplayLength,
  3013. records = settings.fnRecordsDisplay();
  3014. if ( records === 0 || len === -1 )
  3015. {
  3016. start = 0;
  3017. }
  3018. else if ( typeof action === "number" )
  3019. {
  3020. start = action * len;
  3021. if ( start > records )
  3022. {
  3023. start = 0;
  3024. }
  3025. }
  3026. else if ( action == "first" )
  3027. {
  3028. start = 0;
  3029. }
  3030. else if ( action == "previous" )
  3031. {
  3032. start = len >= 0 ?
  3033. start - len :
  3034. 0;
  3035. if ( start < 0 )
  3036. {
  3037. start = 0;
  3038. }
  3039. }
  3040. else if ( action == "next" )
  3041. {
  3042. if ( start + len < records )
  3043. {
  3044. start += len;
  3045. }
  3046. }
  3047. else if ( action == "last" )
  3048. {
  3049. start = Math.floor( (records-1) / len) * len;
  3050. }
  3051. else
  3052. {
  3053. _fnLog( settings, 0, "Unknown paging action: "+action, 5 );
  3054. }
  3055. var changed = settings._iDisplayStart !== start;
  3056. settings._iDisplayStart = start;
  3057. if ( changed ) {
  3058. _fnCallbackFire( settings, null, 'page', [settings] );
  3059. if ( redraw ) {
  3060. _fnDraw( settings );
  3061. }
  3062. }
  3063. return changed;
  3064. }
  3065. /**
  3066. * Generate the node required for the processing node
  3067. * @param {object} settings dataTables settings object
  3068. * @returns {node} Processing element
  3069. * @memberof DataTable#oApi
  3070. */
  3071. function _fnFeatureHtmlProcessing ( settings )
  3072. {
  3073. return $('<div/>', {
  3074. 'id': ! settings.aanFeatures.r ? settings.sTableId+'_processing' : null,
  3075. 'class': settings.oClasses.sProcessing
  3076. } )
  3077. .html( settings.oLanguage.sProcessing )
  3078. .insertBefore( settings.nTable )[0];
  3079. }
  3080. /**
  3081. * Display or hide the processing indicator
  3082. * @param {object} settings dataTables settings object
  3083. * @param {bool} show Show the processing indicator (true) or not (false)
  3084. * @memberof DataTable#oApi
  3085. */
  3086. function _fnProcessingDisplay ( settings, show )
  3087. {
  3088. if ( settings.oFeatures.bProcessing ) {
  3089. $(settings.aanFeatures.r).css( 'display', show ? 'block' : 'none' );
  3090. }
  3091. _fnCallbackFire( settings, null, 'processing', [settings, show] );
  3092. }
  3093. /**
  3094. * Add any control elements for the table - specifically scrolling
  3095. * @param {object} settings dataTables settings object
  3096. * @returns {node} Node to add to the DOM
  3097. * @memberof DataTable#oApi
  3098. */
  3099. function _fnFeatureHtmlTable ( settings )
  3100. {
  3101. var table = $(settings.nTable);
  3102. // Add the ARIA grid role to the table
  3103. table.attr( 'role', 'grid' );
  3104. // Scrolling from here on in
  3105. var scroll = settings.oScroll;
  3106. if ( scroll.sX === '' && scroll.sY === '' ) {
  3107. return settings.nTable;
  3108. }
  3109. var scrollX = scroll.sX;
  3110. var scrollY = scroll.sY;
  3111. var classes = settings.oClasses;
  3112. var caption = table.children('caption');
  3113. var captionSide = caption.length ? caption[0]._captionSide : null;
  3114. var headerClone = $( table[0].cloneNode(false) );
  3115. var footerClone = $( table[0].cloneNode(false) );
  3116. var footer = table.children('tfoot');
  3117. var _div = '<div/>';
  3118. var size = function ( s ) {
  3119. return !s ? null : _fnStringToCss( s );
  3120. };
  3121. // This is fairly messy, but with x scrolling enabled, if the table has a
  3122. // width attribute, regardless of any width applied using the column width
  3123. // options, the browser will shrink or grow the table as needed to fit into
  3124. // that 100%. That would make the width options useless. So we remove it.
  3125. // This is okay, under the assumption that width:100% is applied to the
  3126. // table in CSS (it is in the default stylesheet) which will set the table
  3127. // width as appropriate (the attribute and css behave differently...)
  3128. if ( scroll.sX && table.attr('width') === '100%' ) {
  3129. table.removeAttr('width');
  3130. }
  3131. if ( ! footer.length ) {
  3132. footer = null;
  3133. }
  3134. /*
  3135. * The HTML structure that we want to generate in this function is:
  3136. * div - scroller
  3137. * div - scroll head
  3138. * div - scroll head inner
  3139. * table - scroll head table
  3140. * thead - thead
  3141. * div - scroll body
  3142. * table - table (master table)
  3143. * thead - thead clone for sizing
  3144. * tbody - tbody
  3145. * div - scroll foot
  3146. * div - scroll foot inner
  3147. * table - scroll foot table
  3148. * tfoot - tfoot
  3149. */
  3150. var scroller = $( _div, { 'class': classes.sScrollWrapper } )
  3151. .append(
  3152. $(_div, { 'class': classes.sScrollHead } )
  3153. .css( {
  3154. overflow: 'hidden',
  3155. position: 'relative',
  3156. border: 0,
  3157. width: scrollX ? size(scrollX) : '100%'
  3158. } )
  3159. .append(
  3160. $(_div, { 'class': classes.sScrollHeadInner } )
  3161. .css( {
  3162. 'box-sizing': 'content-box',
  3163. width: scroll.sXInner || '100%'
  3164. } )
  3165. .append(
  3166. headerClone
  3167. .removeAttr('id')
  3168. .css( 'margin-left', 0 )
  3169. .append( captionSide === 'top' ? caption : null )
  3170. .append(
  3171. table.children('thead')
  3172. )
  3173. )
  3174. )
  3175. )
  3176. .append(
  3177. $(_div, { 'class': classes.sScrollBody } )
  3178. .css( {
  3179. position: 'relative',
  3180. overflow: 'auto',
  3181. width: size( scrollX )
  3182. } )
  3183. .append( table )
  3184. );
  3185. if ( footer ) {
  3186. scroller.append(
  3187. $(_div, { 'class': classes.sScrollFoot } )
  3188. .css( {
  3189. overflow: 'hidden',
  3190. border: 0,
  3191. width: scrollX ? size(scrollX) : '100%'
  3192. } )
  3193. .append(
  3194. $(_div, { 'class': classes.sScrollFootInner } )
  3195. .append(
  3196. footerClone
  3197. .removeAttr('id')
  3198. .css( 'margin-left', 0 )
  3199. .append( captionSide === 'bottom' ? caption : null )
  3200. .append(
  3201. table.children('tfoot')
  3202. )
  3203. )
  3204. )
  3205. );
  3206. }
  3207. var children = scroller.children();
  3208. var scrollHead = children[0];
  3209. var scrollBody = children[1];
  3210. var scrollFoot = footer ? children[2] : null;
  3211. // When the body is scrolled, then we also want to scroll the headers
  3212. if ( scrollX ) {
  3213. $(scrollBody).on( 'scroll.DT', function (e) {
  3214. var scrollLeft = this.scrollLeft;
  3215. scrollHead.scrollLeft = scrollLeft;
  3216. if ( footer ) {
  3217. scrollFoot.scrollLeft = scrollLeft;
  3218. }
  3219. } );
  3220. }
  3221. $(scrollBody).css(
  3222. scrollY && scroll.bCollapse ? 'max-height' : 'height',
  3223. scrollY
  3224. );
  3225. settings.nScrollHead = scrollHead;
  3226. settings.nScrollBody = scrollBody;
  3227. settings.nScrollFoot = scrollFoot;
  3228. // On redraw - align columns
  3229. settings.aoDrawCallback.push( {
  3230. "fn": _fnScrollDraw,
  3231. "sName": "scrolling"
  3232. } );
  3233. return scroller[0];
  3234. }
  3235. /**
  3236. * Update the header, footer and body tables for resizing - i.e. column
  3237. * alignment.
  3238. *
  3239. * Welcome to the most horrible function DataTables. The process that this
  3240. * function follows is basically:
  3241. * 1. Re-create the table inside the scrolling div
  3242. * 2. Take live measurements from the DOM
  3243. * 3. Apply the measurements to align the columns
  3244. * 4. Clean up
  3245. *
  3246. * @param {object} settings dataTables settings object
  3247. * @memberof DataTable#oApi
  3248. */
  3249. function _fnScrollDraw ( settings )
  3250. {
  3251. // Given that this is such a monster function, a lot of variables are use
  3252. // to try and keep the minimised size as small as possible
  3253. var
  3254. scroll = settings.oScroll,
  3255. scrollX = scroll.sX,
  3256. scrollXInner = scroll.sXInner,
  3257. scrollY = scroll.sY,
  3258. barWidth = scroll.iBarWidth,
  3259. divHeader = $(settings.nScrollHead),
  3260. divHeaderStyle = divHeader[0].style,
  3261. divHeaderInner = divHeader.children('div'),
  3262. divHeaderInnerStyle = divHeaderInner[0].style,
  3263. divHeaderTable = divHeaderInner.children('table'),
  3264. divBodyEl = settings.nScrollBody,
  3265. divBody = $(divBodyEl),
  3266. divBodyStyle = divBodyEl.style,
  3267. divFooter = $(settings.nScrollFoot),
  3268. divFooterInner = divFooter.children('div'),
  3269. divFooterTable = divFooterInner.children('table'),
  3270. header = $(settings.nTHead),
  3271. table = $(settings.nTable),
  3272. tableEl = table[0],
  3273. tableStyle = tableEl.style,
  3274. footer = settings.nTFoot ? $(settings.nTFoot) : null,
  3275. browser = settings.oBrowser,
  3276. ie67 = browser.bScrollOversize,
  3277. headerTrgEls, footerTrgEls,
  3278. headerSrcEls, footerSrcEls,
  3279. headerCopy, footerCopy,
  3280. headerWidths=[], footerWidths=[],
  3281. headerContent=[],
  3282. idx, correction, sanityWidth,
  3283. zeroOut = function(nSizer) {
  3284. var style = nSizer.style;
  3285. style.paddingTop = "0";
  3286. style.paddingBottom = "0";
  3287. style.borderTopWidth = "0";
  3288. style.borderBottomWidth = "0";
  3289. style.height = 0;
  3290. };
  3291. /*
  3292. * 1. Re-create the table inside the scrolling div
  3293. */
  3294. // Remove the old minimised thead and tfoot elements in the inner table
  3295. table.children('thead, tfoot').remove();
  3296. // Clone the current header and footer elements and then place it into the inner table
  3297. headerCopy = header.clone().prependTo( table );
  3298. headerTrgEls = header.find('tr'); // original header is in its own table
  3299. headerSrcEls = headerCopy.find('tr');
  3300. headerCopy.find('th, td').removeAttr('tabindex');
  3301. if ( footer ) {
  3302. footerCopy = footer.clone().prependTo( table );
  3303. footerTrgEls = footer.find('tr'); // the original tfoot is in its own table and must be sized
  3304. footerSrcEls = footerCopy.find('tr');
  3305. }
  3306. /*
  3307. * 2. Take live measurements from the DOM - do not alter the DOM itself!
  3308. */
  3309. // Remove old sizing and apply the calculated column widths
  3310. // Get the unique column headers in the newly created (cloned) header. We want to apply the
  3311. // calculated sizes to this header
  3312. if ( ! scrollX )
  3313. {
  3314. divBodyStyle.width = '100%';
  3315. divHeader[0].style.width = '100%';
  3316. }
  3317. $.each( _fnGetUniqueThs( settings, headerCopy ), function ( i, el ) {
  3318. idx = _fnVisibleToColumnIndex( settings, i );
  3319. el.style.width = settings.aoColumns[idx].sWidth;
  3320. } );
  3321. if ( footer ) {
  3322. _fnApplyToChildren( function(n) {
  3323. n.style.width = "";
  3324. }, footerSrcEls );
  3325. }
  3326. // Size the table as a whole
  3327. sanityWidth = table.outerWidth();
  3328. if ( scrollX === "" ) {
  3329. // No x scrolling
  3330. tableStyle.width = "100%";
  3331. // IE7 will make the width of the table when 100% include the scrollbar
  3332. // - which is shouldn't. When there is a scrollbar we need to take this
  3333. // into account.
  3334. if ( ie67 && (table.find('tbody').height() > divBodyEl.offsetHeight ||
  3335. divBody.css('overflow-y') == "scroll")
  3336. ) {
  3337. tableStyle.width = _fnStringToCss( table.outerWidth() - barWidth);
  3338. }
  3339. // Recalculate the sanity width
  3340. sanityWidth = table.outerWidth();
  3341. }
  3342. else if ( scrollXInner !== "" ) {
  3343. // legacy x scroll inner has been given - use it
  3344. tableStyle.width = _fnStringToCss(scrollXInner);
  3345. // Recalculate the sanity width
  3346. sanityWidth = table.outerWidth();
  3347. }
  3348. // Hidden header should have zero height, so remove padding and borders. Then
  3349. // set the width based on the real headers
  3350. // Apply all styles in one pass
  3351. _fnApplyToChildren( zeroOut, headerSrcEls );
  3352. // Read all widths in next pass
  3353. _fnApplyToChildren( function(nSizer) {
  3354. headerContent.push( nSizer.innerHTML );
  3355. headerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  3356. }, headerSrcEls );
  3357. // Apply all widths in final pass
  3358. _fnApplyToChildren( function(nToSize, i) {
  3359. nToSize.style.width = headerWidths[i];
  3360. }, headerTrgEls );
  3361. $(headerSrcEls).height(0);
  3362. /* Same again with the footer if we have one */
  3363. if ( footer )
  3364. {
  3365. _fnApplyToChildren( zeroOut, footerSrcEls );
  3366. _fnApplyToChildren( function(nSizer) {
  3367. footerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  3368. }, footerSrcEls );
  3369. _fnApplyToChildren( function(nToSize, i) {
  3370. nToSize.style.width = footerWidths[i];
  3371. }, footerTrgEls );
  3372. $(footerSrcEls).height(0);
  3373. }
  3374. /*
  3375. * 3. Apply the measurements
  3376. */
  3377. // "Hide" the header and footer that we used for the sizing. We need to keep
  3378. // the content of the cell so that the width applied to the header and body
  3379. // both match, but we want to hide it completely. We want to also fix their
  3380. // width to what they currently are
  3381. _fnApplyToChildren( function(nSizer, i) {
  3382. nSizer.innerHTML = '<div class="dataTables_sizing" style="height:0;overflow:hidden;">'+headerContent[i]+'</div>';
  3383. nSizer.style.width = headerWidths[i];
  3384. }, headerSrcEls );
  3385. if ( footer )
  3386. {
  3387. _fnApplyToChildren( function(nSizer, i) {
  3388. nSizer.innerHTML = "";
  3389. nSizer.style.width = footerWidths[i];
  3390. }, footerSrcEls );
  3391. }
  3392. // Sanity check that the table is of a sensible width. If not then we are going to get
  3393. // misalignment - try to prevent this by not allowing the table to shrink below its min width
  3394. if ( table.outerWidth() < sanityWidth )
  3395. {
  3396. // The min width depends upon if we have a vertical scrollbar visible or not */
  3397. correction = ((divBodyEl.scrollHeight > divBodyEl.offsetHeight ||
  3398. divBody.css('overflow-y') == "scroll")) ?
  3399. sanityWidth+barWidth :
  3400. sanityWidth;
  3401. // IE6/7 are a law unto themselves...
  3402. if ( ie67 && (divBodyEl.scrollHeight >
  3403. divBodyEl.offsetHeight || divBody.css('overflow-y') == "scroll")
  3404. ) {
  3405. tableStyle.width = _fnStringToCss( correction-barWidth );
  3406. }
  3407. // And give the user a warning that we've stopped the table getting too small
  3408. if ( scrollX === "" || scrollXInner !== "" ) {
  3409. _fnLog( settings, 1, 'Possible column misalignment', 6 );
  3410. }
  3411. }
  3412. else
  3413. {
  3414. correction = '100%';
  3415. }
  3416. // Apply to the container elements
  3417. divBodyStyle.width = _fnStringToCss( correction );
  3418. divHeaderStyle.width = _fnStringToCss( correction );
  3419. if ( footer ) {
  3420. settings.nScrollFoot.style.width = _fnStringToCss( correction );
  3421. }
  3422. /*
  3423. * 4. Clean up
  3424. */
  3425. if ( ! scrollY ) {
  3426. /* IE7< puts a vertical scrollbar in place (when it shouldn't be) due to subtracting
  3427. * the scrollbar height from the visible display, rather than adding it on. We need to
  3428. * set the height in order to sort this. Don't want to do it in any other browsers.
  3429. */
  3430. if ( ie67 ) {
  3431. divBodyStyle.height = _fnStringToCss( tableEl.offsetHeight+barWidth );
  3432. }
  3433. }
  3434. /* Finally set the width's of the header and footer tables */
  3435. var iOuterWidth = table.outerWidth();
  3436. divHeaderTable[0].style.width = _fnStringToCss( iOuterWidth );
  3437. divHeaderInnerStyle.width = _fnStringToCss( iOuterWidth );
  3438. // Figure out if there are scrollbar present - if so then we need a the header and footer to
  3439. // provide a bit more space to allow "overflow" scrolling (i.e. past the scrollbar)
  3440. var bScrolling = table.height() > divBodyEl.clientHeight || divBody.css('overflow-y') == "scroll";
  3441. var padding = 'padding' + (browser.bScrollbarLeft ? 'Left' : 'Right' );
  3442. divHeaderInnerStyle[ padding ] = bScrolling ? barWidth+"px" : "0px";
  3443. if ( footer ) {
  3444. divFooterTable[0].style.width = _fnStringToCss( iOuterWidth );
  3445. divFooterInner[0].style.width = _fnStringToCss( iOuterWidth );
  3446. divFooterInner[0].style[padding] = bScrolling ? barWidth+"px" : "0px";
  3447. }
  3448. /* Adjust the position of the header in case we loose the y-scrollbar */
  3449. divBody.scroll();
  3450. // If sorting or filtering has occurred, jump the scrolling back to the top
  3451. // only if we aren't holding the position
  3452. if ( (settings.bSorted || settings.bFiltered) && ! settings._drawHold ) {
  3453. divBodyEl.scrollTop = 0;
  3454. }
  3455. }
  3456. /**
  3457. * Apply a given function to the display child nodes of an element array (typically
  3458. * TD children of TR rows
  3459. * @param {function} fn Method to apply to the objects
  3460. * @param array {nodes} an1 List of elements to look through for display children
  3461. * @param array {nodes} an2 Another list (identical structure to the first) - optional
  3462. * @memberof DataTable#oApi
  3463. */
  3464. function _fnApplyToChildren( fn, an1, an2 )
  3465. {
  3466. var index=0, i=0, iLen=an1.length;
  3467. var nNode1, nNode2;
  3468. while ( i < iLen ) {
  3469. nNode1 = an1[i].firstChild;
  3470. nNode2 = an2 ? an2[i].firstChild : null;
  3471. while ( nNode1 ) {
  3472. if ( nNode1.nodeType === 1 ) {
  3473. if ( an2 ) {
  3474. fn( nNode1, nNode2, index );
  3475. }
  3476. else {
  3477. fn( nNode1, index );
  3478. }
  3479. index++;
  3480. }
  3481. nNode1 = nNode1.nextSibling;
  3482. nNode2 = an2 ? nNode2.nextSibling : null;
  3483. }
  3484. i++;
  3485. }
  3486. }
  3487. var __re_html_remove = /<.*?>/g;
  3488. /**
  3489. * Calculate the width of columns for the table
  3490. * @param {object} oSettings dataTables settings object
  3491. * @memberof DataTable#oApi
  3492. */
  3493. function _fnCalculateColumnWidths ( oSettings )
  3494. {
  3495. var
  3496. table = oSettings.nTable,
  3497. columns = oSettings.aoColumns,
  3498. scroll = oSettings.oScroll,
  3499. scrollY = scroll.sY,
  3500. scrollX = scroll.sX,
  3501. scrollXInner = scroll.sXInner,
  3502. columnCount = columns.length,
  3503. visibleColumns = _fnGetColumns( oSettings, 'bVisible' ),
  3504. headerCells = $('th', oSettings.nTHead),
  3505. tableWidthAttr = table.getAttribute('width'), // from DOM element
  3506. tableContainer = table.parentNode,
  3507. userInputs = false,
  3508. i, column, columnIdx, width, outerWidth,
  3509. browser = oSettings.oBrowser,
  3510. ie67 = browser.bScrollOversize;
  3511. var styleWidth = table.style.width;
  3512. if ( styleWidth && styleWidth.indexOf('%') !== -1 ) {
  3513. tableWidthAttr = styleWidth;
  3514. }
  3515. /* Convert any user input sizes into pixel sizes */
  3516. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3517. column = columns[ visibleColumns[i] ];
  3518. if ( column.sWidth !== null ) {
  3519. column.sWidth = _fnConvertToWidth( column.sWidthOrig, tableContainer );
  3520. userInputs = true;
  3521. }
  3522. }
  3523. /* If the number of columns in the DOM equals the number that we have to
  3524. * process in DataTables, then we can use the offsets that are created by
  3525. * the web- browser. No custom sizes can be set in order for this to happen,
  3526. * nor scrolling used
  3527. */
  3528. if ( ie67 || ! userInputs && ! scrollX && ! scrollY &&
  3529. columnCount == _fnVisbleColumns( oSettings ) &&
  3530. columnCount == headerCells.length
  3531. ) {
  3532. for ( i=0 ; i<columnCount ; i++ ) {
  3533. columns[i].sWidth = _fnStringToCss( headerCells.eq(i).width() );
  3534. }
  3535. }
  3536. else
  3537. {
  3538. // Otherwise construct a single row, worst case, table with the widest
  3539. // node in the data, assign any user defined widths, then insert it into
  3540. // the DOM and allow the browser to do all the hard work of calculating
  3541. // table widths
  3542. var tmpTable = $(table).clone() // don't use cloneNode - IE8 will remove events on the main table
  3543. .css( 'visibility', 'hidden' )
  3544. .removeAttr( 'id' );
  3545. // Clean up the table body
  3546. tmpTable.find('tbody tr').remove();
  3547. var tr = $('<tr/>').appendTo( tmpTable.find('tbody') );
  3548. // Clone the table header and footer - we can't use the header / footer
  3549. // from the cloned table, since if scrolling is active, the table's
  3550. // real header and footer are contained in different table tags
  3551. tmpTable.find('thead, tfoot').remove();
  3552. tmpTable
  3553. .append( $(oSettings.nTHead).clone() )
  3554. .append( $(oSettings.nTFoot).clone() );
  3555. // Remove any assigned widths from the footer (from scrolling)
  3556. tmpTable.find('tfoot th, tfoot td').css('width', '');
  3557. // Apply custom sizing to the cloned header
  3558. headerCells = _fnGetUniqueThs( oSettings, tmpTable.find('thead')[0] );
  3559. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3560. column = columns[ visibleColumns[i] ];
  3561. headerCells[i].style.width = column.sWidthOrig !== null && column.sWidthOrig !== '' ?
  3562. _fnStringToCss( column.sWidthOrig ) :
  3563. '';
  3564. }
  3565. // Find the widest cell for each column and put it into the table
  3566. if ( oSettings.aoData.length ) {
  3567. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3568. columnIdx = visibleColumns[i];
  3569. column = columns[ columnIdx ];
  3570. $( _fnGetWidestNode( oSettings, columnIdx ) )
  3571. .clone( false )
  3572. .append( column.sContentPadding )
  3573. .appendTo( tr );
  3574. }
  3575. }
  3576. // Table has been built, attach to the document so we can work with it.
  3577. // A holding element is used, positioned at the top of the container
  3578. // with minimal height, so it has no effect on if the container scrolls
  3579. // or not. Otherwise it might trigger scrolling when it actually isn't
  3580. // needed
  3581. var holder = $('<div/>').css( scrollX || scrollY ?
  3582. {
  3583. position: 'absolute',
  3584. top: 0,
  3585. left: 0,
  3586. height: 1,
  3587. right: 0,
  3588. overflow: 'hidden'
  3589. } :
  3590. {}
  3591. )
  3592. .append( tmpTable )
  3593. .appendTo( tableContainer );
  3594. // When scrolling (X or Y) we want to set the width of the table as
  3595. // appropriate. However, when not scrolling leave the table width as it
  3596. // is. This results in slightly different, but I think correct behaviour
  3597. if ( scrollX && scrollXInner ) {
  3598. tmpTable.width( scrollXInner );
  3599. }
  3600. else if ( scrollX ) {
  3601. tmpTable.css( 'width', 'auto' );
  3602. if ( tmpTable.width() < tableContainer.clientWidth ) {
  3603. tmpTable.width( tableContainer.clientWidth );
  3604. }
  3605. }
  3606. else if ( scrollY ) {
  3607. tmpTable.width( tableContainer.clientWidth );
  3608. }
  3609. else if ( tableWidthAttr ) {
  3610. tmpTable.width( tableWidthAttr );
  3611. }
  3612. // Browsers need a bit of a hand when a width is assigned to any columns
  3613. // when x-scrolling as they tend to collapse the table to the min-width,
  3614. // even if we sent the column widths. So we need to keep track of what
  3615. // the table width should be by summing the user given values, and the
  3616. // automatic values
  3617. if ( scrollX )
  3618. {
  3619. var total = 0;
  3620. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3621. column = columns[ visibleColumns[i] ];
  3622. // Much prefer to use getBoundingClientRect due to its sub-pixel
  3623. // resolution, but IE8- do not support the width property.
  3624. outerWidth = browser.bBounding ?
  3625. headerCells[i].getBoundingClientRect().width :
  3626. $(headerCells[i]).outerWidth();
  3627. total += column.sWidthOrig === null ?
  3628. outerWidth :
  3629. parseInt( column.sWidth, 10 ) + outerWidth - $(headerCells[i]).width();
  3630. }
  3631. tmpTable.width( _fnStringToCss( total ) );
  3632. table.style.width = _fnStringToCss( total );
  3633. }
  3634. // Get the width of each column in the constructed table
  3635. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3636. column = columns[ visibleColumns[i] ];
  3637. width = $(headerCells[i]).width();
  3638. if ( width ) {
  3639. column.sWidth = _fnStringToCss( width );
  3640. }
  3641. }
  3642. table.style.width = _fnStringToCss( tmpTable.css('width') );
  3643. // Finished with the table - ditch it
  3644. holder.remove();
  3645. }
  3646. // If there is a width attr, we want to attach an event listener which
  3647. // allows the table sizing to automatically adjust when the window is
  3648. // resized. Use the width attr rather than CSS, since we can't know if the
  3649. // CSS is a relative value or absolute - DOM read is always px.
  3650. if ( tableWidthAttr ) {
  3651. table.style.width = _fnStringToCss( tableWidthAttr );
  3652. }
  3653. if ( (tableWidthAttr || scrollX) && ! oSettings._reszEvt ) {
  3654. var bindResize = function () {
  3655. $(window).bind('resize.DT-'+oSettings.sInstance, _fnThrottle( function () {
  3656. _fnAdjustColumnSizing( oSettings );
  3657. } ) );
  3658. };
  3659. // IE6/7 will crash if we bind a resize event handler on page load.
  3660. // To be removed in 1.11 which drops IE6/7 support
  3661. if ( ie67 ) {
  3662. setTimeout( bindResize, 1000 );
  3663. }
  3664. else {
  3665. bindResize();
  3666. }
  3667. oSettings._reszEvt = true;
  3668. }
  3669. }
  3670. /**
  3671. * Throttle the calls to a function. Arguments and context are maintained for
  3672. * the throttled function
  3673. * @param {function} fn Function to be called
  3674. * @param {int} [freq=200] call frequency in mS
  3675. * @returns {function} wrapped function
  3676. * @memberof DataTable#oApi
  3677. */
  3678. function _fnThrottle( fn, freq ) {
  3679. var
  3680. frequency = freq !== undefined ? freq : 200,
  3681. last,
  3682. timer;
  3683. return function () {
  3684. var
  3685. that = this,
  3686. now = +new Date(),
  3687. args = arguments;
  3688. if ( last && now < last + frequency ) {
  3689. clearTimeout( timer );
  3690. timer = setTimeout( function () {
  3691. last = undefined;
  3692. fn.apply( that, args );
  3693. }, frequency );
  3694. }
  3695. else {
  3696. last = now;
  3697. fn.apply( that, args );
  3698. }
  3699. };
  3700. }
  3701. /**
  3702. * Convert a CSS unit width to pixels (e.g. 2em)
  3703. * @param {string} width width to be converted
  3704. * @param {node} parent parent to get the with for (required for relative widths) - optional
  3705. * @returns {int} width in pixels
  3706. * @memberof DataTable#oApi
  3707. */
  3708. function _fnConvertToWidth ( width, parent )
  3709. {
  3710. if ( ! width ) {
  3711. return 0;
  3712. }
  3713. var n = $('<div/>')
  3714. .css( 'width', _fnStringToCss( width ) )
  3715. .appendTo( parent || document.body );
  3716. var val = n[0].offsetWidth;
  3717. n.remove();
  3718. return val;
  3719. }
  3720. /**
  3721. * Get the widest node
  3722. * @param {object} settings dataTables settings object
  3723. * @param {int} colIdx column of interest
  3724. * @returns {node} widest table node
  3725. * @memberof DataTable#oApi
  3726. */
  3727. function _fnGetWidestNode( settings, colIdx )
  3728. {
  3729. var idx = _fnGetMaxLenString( settings, colIdx );
  3730. if ( idx < 0 ) {
  3731. return null;
  3732. }
  3733. var data = settings.aoData[ idx ];
  3734. return ! data.nTr ? // Might not have been created when deferred rendering
  3735. $('<td/>').html( _fnGetCellData( settings, idx, colIdx, 'display' ) )[0] :
  3736. data.anCells[ colIdx ];
  3737. }
  3738. /**
  3739. * Get the maximum strlen for each data column
  3740. * @param {object} settings dataTables settings object
  3741. * @param {int} colIdx column of interest
  3742. * @returns {string} max string length for each column
  3743. * @memberof DataTable#oApi
  3744. */
  3745. function _fnGetMaxLenString( settings, colIdx )
  3746. {
  3747. var s, max=-1, maxIdx = -1;
  3748. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  3749. s = _fnGetCellData( settings, i, colIdx, 'display' )+'';
  3750. s = s.replace( __re_html_remove, '' );
  3751. if ( s.length > max ) {
  3752. max = s.length;
  3753. maxIdx = i;
  3754. }
  3755. }
  3756. return maxIdx;
  3757. }
  3758. /**
  3759. * Append a CSS unit (only if required) to a string
  3760. * @param {string} value to css-ify
  3761. * @returns {string} value with css unit
  3762. * @memberof DataTable#oApi
  3763. */
  3764. function _fnStringToCss( s )
  3765. {
  3766. if ( s === null ) {
  3767. return '0px';
  3768. }
  3769. if ( typeof s == 'number' ) {
  3770. return s < 0 ?
  3771. '0px' :
  3772. s+'px';
  3773. }
  3774. // Check it has a unit character already
  3775. return s.match(/\d$/) ?
  3776. s+'px' :
  3777. s;
  3778. }
  3779. /**
  3780. * Get the width of a scroll bar in this browser being used
  3781. * @returns {int} width in pixels
  3782. * @memberof DataTable#oApi
  3783. */
  3784. function _fnScrollBarWidth ()
  3785. {
  3786. // On first run a static variable is set, since this is only needed once.
  3787. // Subsequent runs will just use the previously calculated value
  3788. var width = DataTable.__scrollbarWidth;
  3789. if ( width === undefined ) {
  3790. var sizer = $('<p/>').css( {
  3791. position: 'absolute',
  3792. top: 0,
  3793. left: 0,
  3794. width: '100%',
  3795. height: 150,
  3796. padding: 0,
  3797. overflow: 'scroll',
  3798. visibility: 'hidden'
  3799. } )
  3800. .appendTo('body');
  3801. width = sizer[0].offsetWidth - sizer[0].clientWidth;
  3802. DataTable.__scrollbarWidth = width;
  3803. sizer.remove();
  3804. }
  3805. return width;
  3806. }
  3807. function _fnSortFlatten ( settings )
  3808. {
  3809. var
  3810. i, iLen, k, kLen,
  3811. aSort = [],
  3812. aiOrig = [],
  3813. aoColumns = settings.aoColumns,
  3814. aDataSort, iCol, sType, srcCol,
  3815. fixed = settings.aaSortingFixed,
  3816. fixedObj = $.isPlainObject( fixed ),
  3817. nestedSort = [],
  3818. add = function ( a ) {
  3819. if ( a.length && ! $.isArray( a[0] ) ) {
  3820. // 1D array
  3821. nestedSort.push( a );
  3822. }
  3823. else {
  3824. // 2D array
  3825. nestedSort.push.apply( nestedSort, a );
  3826. }
  3827. };
  3828. // Build the sort array, with pre-fix and post-fix options if they have been
  3829. // specified
  3830. if ( $.isArray( fixed ) ) {
  3831. add( fixed );
  3832. }
  3833. if ( fixedObj && fixed.pre ) {
  3834. add( fixed.pre );
  3835. }
  3836. add( settings.aaSorting );
  3837. if (fixedObj && fixed.post ) {
  3838. add( fixed.post );
  3839. }
  3840. for ( i=0 ; i<nestedSort.length ; i++ )
  3841. {
  3842. srcCol = nestedSort[i][0];
  3843. aDataSort = aoColumns[ srcCol ].aDataSort;
  3844. for ( k=0, kLen=aDataSort.length ; k<kLen ; k++ )
  3845. {
  3846. iCol = aDataSort[k];
  3847. sType = aoColumns[ iCol ].sType || 'string';
  3848. if ( nestedSort[i]._idx === undefined ) {
  3849. nestedSort[i]._idx = $.inArray( nestedSort[i][1], aoColumns[iCol].asSorting );
  3850. }
  3851. aSort.push( {
  3852. src: srcCol,
  3853. col: iCol,
  3854. dir: nestedSort[i][1],
  3855. index: nestedSort[i]._idx,
  3856. type: sType,
  3857. formatter: DataTable.ext.type.order[ sType+"-pre" ]
  3858. } );
  3859. }
  3860. }
  3861. return aSort;
  3862. }
  3863. /**
  3864. * Change the order of the table
  3865. * @param {object} oSettings dataTables settings object
  3866. * @memberof DataTable#oApi
  3867. * @todo This really needs split up!
  3868. */
  3869. function _fnSort ( oSettings )
  3870. {
  3871. var
  3872. i, ien, iLen, j, jLen, k, kLen,
  3873. sDataType, nTh,
  3874. aiOrig = [],
  3875. oExtSort = DataTable.ext.type.order,
  3876. aoData = oSettings.aoData,
  3877. aoColumns = oSettings.aoColumns,
  3878. aDataSort, data, iCol, sType, oSort,
  3879. formatters = 0,
  3880. sortCol,
  3881. displayMaster = oSettings.aiDisplayMaster,
  3882. aSort;
  3883. // Resolve any column types that are unknown due to addition or invalidation
  3884. // @todo Can this be moved into a 'data-ready' handler which is called when
  3885. // data is going to be used in the table?
  3886. _fnColumnTypes( oSettings );
  3887. aSort = _fnSortFlatten( oSettings );
  3888. for ( i=0, ien=aSort.length ; i<ien ; i++ ) {
  3889. sortCol = aSort[i];
  3890. // Track if we can use the fast sort algorithm
  3891. if ( sortCol.formatter ) {
  3892. formatters++;
  3893. }
  3894. // Load the data needed for the sort, for each cell
  3895. _fnSortData( oSettings, sortCol.col );
  3896. }
  3897. /* No sorting required if server-side or no sorting array */
  3898. if ( _fnDataSource( oSettings ) != 'ssp' && aSort.length !== 0 )
  3899. {
  3900. // Create a value - key array of the current row positions such that we can use their
  3901. // current position during the sort, if values match, in order to perform stable sorting
  3902. for ( i=0, iLen=displayMaster.length ; i<iLen ; i++ ) {
  3903. aiOrig[ displayMaster[i] ] = i;
  3904. }
  3905. /* Do the sort - here we want multi-column sorting based on a given data source (column)
  3906. * and sorting function (from oSort) in a certain direction. It's reasonably complex to
  3907. * follow on it's own, but this is what we want (example two column sorting):
  3908. * fnLocalSorting = function(a,b){
  3909. * var iTest;
  3910. * iTest = oSort['string-asc']('data11', 'data12');
  3911. * if (iTest !== 0)
  3912. * return iTest;
  3913. * iTest = oSort['numeric-desc']('data21', 'data22');
  3914. * if (iTest !== 0)
  3915. * return iTest;
  3916. * return oSort['numeric-asc']( aiOrig[a], aiOrig[b] );
  3917. * }
  3918. * Basically we have a test for each sorting column, if the data in that column is equal,
  3919. * test the next column. If all columns match, then we use a numeric sort on the row
  3920. * positions in the original data array to provide a stable sort.
  3921. *
  3922. * Note - I know it seems excessive to have two sorting methods, but the first is around
  3923. * 15% faster, so the second is only maintained for backwards compatibility with sorting
  3924. * methods which do not have a pre-sort formatting function.
  3925. */
  3926. if ( formatters === aSort.length ) {
  3927. // All sort types have formatting functions
  3928. displayMaster.sort( function ( a, b ) {
  3929. var
  3930. x, y, k, test, sort,
  3931. len=aSort.length,
  3932. dataA = aoData[a]._aSortData,
  3933. dataB = aoData[b]._aSortData;
  3934. for ( k=0 ; k<len ; k++ ) {
  3935. sort = aSort[k];
  3936. x = dataA[ sort.col ];
  3937. y = dataB[ sort.col ];
  3938. test = x<y ? -1 : x>y ? 1 : 0;
  3939. if ( test !== 0 ) {
  3940. return sort.dir === 'asc' ? test : -test;
  3941. }
  3942. }
  3943. x = aiOrig[a];
  3944. y = aiOrig[b];
  3945. return x<y ? -1 : x>y ? 1 : 0;
  3946. } );
  3947. }
  3948. else {
  3949. // Depreciated - remove in 1.11 (providing a plug-in option)
  3950. // Not all sort types have formatting methods, so we have to call their sorting
  3951. // methods.
  3952. displayMaster.sort( function ( a, b ) {
  3953. var
  3954. x, y, k, l, test, sort, fn,
  3955. len=aSort.length,
  3956. dataA = aoData[a]._aSortData,
  3957. dataB = aoData[b]._aSortData;
  3958. for ( k=0 ; k<len ; k++ ) {
  3959. sort = aSort[k];
  3960. x = dataA[ sort.col ];
  3961. y = dataB[ sort.col ];
  3962. fn = oExtSort[ sort.type+"-"+sort.dir ] || oExtSort[ "string-"+sort.dir ];
  3963. test = fn( x, y );
  3964. if ( test !== 0 ) {
  3965. return test;
  3966. }
  3967. }
  3968. x = aiOrig[a];
  3969. y = aiOrig[b];
  3970. return x<y ? -1 : x>y ? 1 : 0;
  3971. } );
  3972. }
  3973. }
  3974. /* Tell the draw function that we have sorted the data */
  3975. oSettings.bSorted = true;
  3976. }
  3977. function _fnSortAria ( settings )
  3978. {
  3979. var label;
  3980. var nextSort;
  3981. var columns = settings.aoColumns;
  3982. var aSort = _fnSortFlatten( settings );
  3983. var oAria = settings.oLanguage.oAria;
  3984. // ARIA attributes - need to loop all columns, to update all (removing old
  3985. // attributes as needed)
  3986. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  3987. {
  3988. var col = columns[i];
  3989. var asSorting = col.asSorting;
  3990. var sTitle = col.sTitle.replace( /<.*?>/g, "" );
  3991. var th = col.nTh;
  3992. // IE7 is throwing an error when setting these properties with jQuery's
  3993. // attr() and removeAttr() methods...
  3994. th.removeAttribute('aria-sort');
  3995. /* In ARIA only the first sorting column can be marked as sorting - no multi-sort option */
  3996. if ( col.bSortable ) {
  3997. if ( aSort.length > 0 && aSort[0].col == i ) {
  3998. th.setAttribute('aria-sort', aSort[0].dir=="asc" ? "ascending" : "descending" );
  3999. nextSort = asSorting[ aSort[0].index+1 ] || asSorting[0];
  4000. }
  4001. else {
  4002. nextSort = asSorting[0];
  4003. }
  4004. label = sTitle + ( nextSort === "asc" ?
  4005. oAria.sSortAscending :
  4006. oAria.sSortDescending
  4007. );
  4008. }
  4009. else {
  4010. label = sTitle;
  4011. }
  4012. th.setAttribute('aria-label', label);
  4013. }
  4014. }
  4015. /**
  4016. * Function to run on user sort request
  4017. * @param {object} settings dataTables settings object
  4018. * @param {node} attachTo node to attach the handler to
  4019. * @param {int} colIdx column sorting index
  4020. * @param {boolean} [append=false] Append the requested sort to the existing
  4021. * sort if true (i.e. multi-column sort)
  4022. * @param {function} [callback] callback function
  4023. * @memberof DataTable#oApi
  4024. */
  4025. function _fnSortListener ( settings, colIdx, append, callback )
  4026. {
  4027. var col = settings.aoColumns[ colIdx ];
  4028. var sorting = settings.aaSorting;
  4029. var asSorting = col.asSorting;
  4030. var nextSortIdx;
  4031. var next = function ( a, overflow ) {
  4032. var idx = a._idx;
  4033. if ( idx === undefined ) {
  4034. idx = $.inArray( a[1], asSorting );
  4035. }
  4036. return idx+1 < asSorting.length ?
  4037. idx+1 :
  4038. overflow ?
  4039. null :
  4040. 0;
  4041. };
  4042. // Convert to 2D array if needed
  4043. if ( typeof sorting[0] === 'number' ) {
  4044. sorting = settings.aaSorting = [ sorting ];
  4045. }
  4046. // If appending the sort then we are multi-column sorting
  4047. if ( append && settings.oFeatures.bSortMulti ) {
  4048. // Are we already doing some kind of sort on this column?
  4049. var sortIdx = $.inArray( colIdx, _pluck(sorting, '0') );
  4050. if ( sortIdx !== -1 ) {
  4051. // Yes, modify the sort
  4052. nextSortIdx = next( sorting[sortIdx], true );
  4053. if ( nextSortIdx === null && sorting.length === 1 ) {
  4054. nextSortIdx = 0; // can't remove sorting completely
  4055. }
  4056. if ( nextSortIdx === null ) {
  4057. sorting.splice( sortIdx, 1 );
  4058. }
  4059. else {
  4060. sorting[sortIdx][1] = asSorting[ nextSortIdx ];
  4061. sorting[sortIdx]._idx = nextSortIdx;
  4062. }
  4063. }
  4064. else {
  4065. // No sort on this column yet
  4066. sorting.push( [ colIdx, asSorting[0], 0 ] );
  4067. sorting[sorting.length-1]._idx = 0;
  4068. }
  4069. }
  4070. else if ( sorting.length && sorting[0][0] == colIdx ) {
  4071. // Single column - already sorting on this column, modify the sort
  4072. nextSortIdx = next( sorting[0] );
  4073. sorting.length = 1;
  4074. sorting[0][1] = asSorting[ nextSortIdx ];
  4075. sorting[0]._idx = nextSortIdx;
  4076. }
  4077. else {
  4078. // Single column - sort only on this column
  4079. sorting.length = 0;
  4080. sorting.push( [ colIdx, asSorting[0] ] );
  4081. sorting[0]._idx = 0;
  4082. }
  4083. // Run the sort by calling a full redraw
  4084. _fnReDraw( settings );
  4085. // callback used for async user interaction
  4086. if ( typeof callback == 'function' ) {
  4087. callback( settings );
  4088. }
  4089. }
  4090. /**
  4091. * Attach a sort handler (click) to a node
  4092. * @param {object} settings dataTables settings object
  4093. * @param {node} attachTo node to attach the handler to
  4094. * @param {int} colIdx column sorting index
  4095. * @param {function} [callback] callback function
  4096. * @memberof DataTable#oApi
  4097. */
  4098. function _fnSortAttachListener ( settings, attachTo, colIdx, callback )
  4099. {
  4100. var col = settings.aoColumns[ colIdx ];
  4101. _fnBindAction( attachTo, {}, function (e) {
  4102. /* If the column is not sortable - don't to anything */
  4103. if ( col.bSortable === false ) {
  4104. return;
  4105. }
  4106. // If processing is enabled use a timeout to allow the processing
  4107. // display to be shown - otherwise to it synchronously
  4108. if ( settings.oFeatures.bProcessing ) {
  4109. _fnProcessingDisplay( settings, true );
  4110. setTimeout( function() {
  4111. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  4112. // In server-side processing, the draw callback will remove the
  4113. // processing display
  4114. if ( _fnDataSource( settings ) !== 'ssp' ) {
  4115. _fnProcessingDisplay( settings, false );
  4116. }
  4117. }, 0 );
  4118. }
  4119. else {
  4120. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  4121. }
  4122. } );
  4123. }
  4124. /**
  4125. * Set the sorting classes on table's body, Note: it is safe to call this function
  4126. * when bSort and bSortClasses are false
  4127. * @param {object} oSettings dataTables settings object
  4128. * @memberof DataTable#oApi
  4129. */
  4130. function _fnSortingClasses( settings )
  4131. {
  4132. var oldSort = settings.aLastSort;
  4133. var sortClass = settings.oClasses.sSortColumn;
  4134. var sort = _fnSortFlatten( settings );
  4135. var features = settings.oFeatures;
  4136. var i, ien, colIdx;
  4137. if ( features.bSort && features.bSortClasses ) {
  4138. // Remove old sorting classes
  4139. for ( i=0, ien=oldSort.length ; i<ien ; i++ ) {
  4140. colIdx = oldSort[i].src;
  4141. // Remove column sorting
  4142. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  4143. .removeClass( sortClass + (i<2 ? i+1 : 3) );
  4144. }
  4145. // Add new column sorting
  4146. for ( i=0, ien=sort.length ; i<ien ; i++ ) {
  4147. colIdx = sort[i].src;
  4148. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  4149. .addClass( sortClass + (i<2 ? i+1 : 3) );
  4150. }
  4151. }
  4152. settings.aLastSort = sort;
  4153. }
  4154. // Get the data to sort a column, be it from cache, fresh (populating the
  4155. // cache), or from a sort formatter
  4156. function _fnSortData( settings, idx )
  4157. {
  4158. // Custom sorting function - provided by the sort data type
  4159. var column = settings.aoColumns[ idx ];
  4160. var customSort = DataTable.ext.order[ column.sSortDataType ];
  4161. var customData;
  4162. if ( customSort ) {
  4163. customData = customSort.call( settings.oInstance, settings, idx,
  4164. _fnColumnIndexToVisible( settings, idx )
  4165. );
  4166. }
  4167. // Use / populate cache
  4168. var row, cellData;
  4169. var formatter = DataTable.ext.type.order[ column.sType+"-pre" ];
  4170. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  4171. row = settings.aoData[i];
  4172. if ( ! row._aSortData ) {
  4173. row._aSortData = [];
  4174. }
  4175. if ( ! row._aSortData[idx] || customSort ) {
  4176. cellData = customSort ?
  4177. customData[i] : // If there was a custom sort function, use data from there
  4178. _fnGetCellData( settings, i, idx, 'sort' );
  4179. row._aSortData[ idx ] = formatter ?
  4180. formatter( cellData ) :
  4181. cellData;
  4182. }
  4183. }
  4184. }
  4185. /**
  4186. * Save the state of a table
  4187. * @param {object} oSettings dataTables settings object
  4188. * @memberof DataTable#oApi
  4189. */
  4190. function _fnSaveState ( settings )
  4191. {
  4192. if ( !settings.oFeatures.bStateSave || settings.bDestroying )
  4193. {
  4194. return;
  4195. }
  4196. /* Store the interesting variables */
  4197. var state = {
  4198. time: +new Date(),
  4199. start: settings._iDisplayStart,
  4200. length: settings._iDisplayLength,
  4201. order: $.extend( true, [], settings.aaSorting ),
  4202. search: _fnSearchToCamel( settings.oPreviousSearch ),
  4203. columns: $.map( settings.aoColumns, function ( col, i ) {
  4204. return {
  4205. visible: col.bVisible,
  4206. search: _fnSearchToCamel( settings.aoPreSearchCols[i] )
  4207. };
  4208. } )
  4209. };
  4210. _fnCallbackFire( settings, "aoStateSaveParams", 'stateSaveParams', [settings, state] );
  4211. settings.oSavedState = state;
  4212. settings.fnStateSaveCallback.call( settings.oInstance, settings, state );
  4213. }
  4214. /**
  4215. * Attempt to load a saved table state
  4216. * @param {object} oSettings dataTables settings object
  4217. * @param {object} oInit DataTables init object so we can override settings
  4218. * @memberof DataTable#oApi
  4219. */
  4220. function _fnLoadState ( settings, oInit )
  4221. {
  4222. var i, ien;
  4223. var columns = settings.aoColumns;
  4224. if ( ! settings.oFeatures.bStateSave ) {
  4225. return;
  4226. }
  4227. var state = settings.fnStateLoadCallback.call( settings.oInstance, settings );
  4228. if ( ! state || ! state.time ) {
  4229. return;
  4230. }
  4231. /* Allow custom and plug-in manipulation functions to alter the saved data set and
  4232. * cancelling of loading by returning false
  4233. */
  4234. var abStateLoad = _fnCallbackFire( settings, 'aoStateLoadParams', 'stateLoadParams', [settings, state] );
  4235. if ( $.inArray( false, abStateLoad ) !== -1 ) {
  4236. return;
  4237. }
  4238. /* Reject old data */
  4239. var duration = settings.iStateDuration;
  4240. if ( duration > 0 && state.time < +new Date() - (duration*1000) ) {
  4241. return;
  4242. }
  4243. // Number of columns have changed - all bets are off, no restore of settings
  4244. if ( columns.length !== state.columns.length ) {
  4245. return;
  4246. }
  4247. // Store the saved state so it might be accessed at any time
  4248. settings.oLoadedState = $.extend( true, {}, state );
  4249. // Restore key features - todo - for 1.11 this needs to be done by
  4250. // subscribed events
  4251. if ( state.start !== undefined ) {
  4252. settings._iDisplayStart = state.start;
  4253. settings.iInitDisplayStart = state.start;
  4254. }
  4255. if ( state.length !== undefined ) {
  4256. settings._iDisplayLength = state.length;
  4257. }
  4258. // Order
  4259. if ( state.order !== undefined ) {
  4260. settings.aaSorting = [];
  4261. $.each( state.order, function ( i, col ) {
  4262. settings.aaSorting.push( col[0] >= columns.length ?
  4263. [ 0, col[1] ] :
  4264. col
  4265. );
  4266. } );
  4267. }
  4268. // Search
  4269. if ( state.search !== undefined ) {
  4270. $.extend( settings.oPreviousSearch, _fnSearchToHung( state.search ) );
  4271. }
  4272. // Columns
  4273. for ( i=0, ien=state.columns.length ; i<ien ; i++ ) {
  4274. var col = state.columns[i];
  4275. // Visibility
  4276. if ( col.visible !== undefined ) {
  4277. columns[i].bVisible = col.visible;
  4278. }
  4279. // Search
  4280. if ( col.search !== undefined ) {
  4281. $.extend( settings.aoPreSearchCols[i], _fnSearchToHung( col.search ) );
  4282. }
  4283. }
  4284. _fnCallbackFire( settings, 'aoStateLoaded', 'stateLoaded', [settings, state] );
  4285. }
  4286. /**
  4287. * Return the settings object for a particular table
  4288. * @param {node} table table we are using as a dataTable
  4289. * @returns {object} Settings object - or null if not found
  4290. * @memberof DataTable#oApi
  4291. */
  4292. function _fnSettingsFromNode ( table )
  4293. {
  4294. var settings = DataTable.settings;
  4295. var idx = $.inArray( table, _pluck( settings, 'nTable' ) );
  4296. return idx !== -1 ?
  4297. settings[ idx ] :
  4298. null;
  4299. }
  4300. /**
  4301. * Log an error message
  4302. * @param {object} settings dataTables settings object
  4303. * @param {int} level log error messages, or display them to the user
  4304. * @param {string} msg error message
  4305. * @param {int} tn Technical note id to get more information about the error.
  4306. * @memberof DataTable#oApi
  4307. */
  4308. function _fnLog( settings, level, msg, tn )
  4309. {
  4310. msg = 'DataTables warning: '+
  4311. (settings ? 'table id='+settings.sTableId+' - ' : '')+msg;
  4312. if ( tn ) {
  4313. msg += '. For more information about this error, please see '+
  4314. 'http://datatables.net/tn/'+tn;
  4315. }
  4316. if ( ! level ) {
  4317. // Backwards compatibility pre 1.10
  4318. var ext = DataTable.ext;
  4319. var type = ext.sErrMode || ext.errMode;
  4320. if ( settings ) {
  4321. _fnCallbackFire( settings, null, 'error', [ settings, tn, msg ] );
  4322. }
  4323. if ( type == 'alert' ) {
  4324. alert( msg );
  4325. }
  4326. else if ( type == 'throw' ) {
  4327. throw new Error(msg);
  4328. }
  4329. else if ( typeof type == 'function' ) {
  4330. type( settings, tn, msg );
  4331. }
  4332. }
  4333. else if ( window.console && console.log ) {
  4334. console.log( msg );
  4335. }
  4336. }
  4337. /**
  4338. * See if a property is defined on one object, if so assign it to the other object
  4339. * @param {object} ret target object
  4340. * @param {object} src source object
  4341. * @param {string} name property
  4342. * @param {string} [mappedName] name to map too - optional, name used if not given
  4343. * @memberof DataTable#oApi
  4344. */
  4345. function _fnMap( ret, src, name, mappedName )
  4346. {
  4347. if ( $.isArray( name ) ) {
  4348. $.each( name, function (i, val) {
  4349. if ( $.isArray( val ) ) {
  4350. _fnMap( ret, src, val[0], val[1] );
  4351. }
  4352. else {
  4353. _fnMap( ret, src, val );
  4354. }
  4355. } );
  4356. return;
  4357. }
  4358. if ( mappedName === undefined ) {
  4359. mappedName = name;
  4360. }
  4361. if ( src[name] !== undefined ) {
  4362. ret[mappedName] = src[name];
  4363. }
  4364. }
  4365. /**
  4366. * Extend objects - very similar to jQuery.extend, but deep copy objects, and
  4367. * shallow copy arrays. The reason we need to do this, is that we don't want to
  4368. * deep copy array init values (such as aaSorting) since the dev wouldn't be
  4369. * able to override them, but we do want to deep copy arrays.
  4370. * @param {object} out Object to extend
  4371. * @param {object} extender Object from which the properties will be applied to
  4372. * out
  4373. * @param {boolean} breakRefs If true, then arrays will be sliced to take an
  4374. * independent copy with the exception of the `data` or `aaData` parameters
  4375. * if they are present. This is so you can pass in a collection to
  4376. * DataTables and have that used as your data source without breaking the
  4377. * references
  4378. * @returns {object} out Reference, just for convenience - out === the return.
  4379. * @memberof DataTable#oApi
  4380. * @todo This doesn't take account of arrays inside the deep copied objects.
  4381. */
  4382. function _fnExtend( out, extender, breakRefs )
  4383. {
  4384. var val;
  4385. for ( var prop in extender ) {
  4386. if ( extender.hasOwnProperty(prop) ) {
  4387. val = extender[prop];
  4388. if ( $.isPlainObject( val ) ) {
  4389. if ( ! $.isPlainObject( out[prop] ) ) {
  4390. out[prop] = {};
  4391. }
  4392. $.extend( true, out[prop], val );
  4393. }
  4394. else if ( breakRefs && prop !== 'data' && prop !== 'aaData' && $.isArray(val) ) {
  4395. out[prop] = val.slice();
  4396. }
  4397. else {
  4398. out[prop] = val;
  4399. }
  4400. }
  4401. }
  4402. return out;
  4403. }
  4404. /**
  4405. * Bind an event handers to allow a click or return key to activate the callback.
  4406. * This is good for accessibility since a return on the keyboard will have the
  4407. * same effect as a click, if the element has focus.
  4408. * @param {element} n Element to bind the action to
  4409. * @param {object} oData Data object to pass to the triggered function
  4410. * @param {function} fn Callback function for when the event is triggered
  4411. * @memberof DataTable#oApi
  4412. */
  4413. function _fnBindAction( n, oData, fn )
  4414. {
  4415. $(n)
  4416. .bind( 'click.DT', oData, function (e) {
  4417. n.blur(); // Remove focus outline for mouse users
  4418. fn(e);
  4419. } )
  4420. .bind( 'keypress.DT', oData, function (e){
  4421. if ( e.which === 13 ) {
  4422. e.preventDefault();
  4423. fn(e);
  4424. }
  4425. } )
  4426. .bind( 'selectstart.DT', function () {
  4427. /* Take the brutal approach to cancelling text selection */
  4428. return false;
  4429. } );
  4430. }
  4431. /**
  4432. * Register a callback function. Easily allows a callback function to be added to
  4433. * an array store of callback functions that can then all be called together.
  4434. * @param {object} oSettings dataTables settings object
  4435. * @param {string} sStore Name of the array storage for the callbacks in oSettings
  4436. * @param {function} fn Function to be called back
  4437. * @param {string} sName Identifying name for the callback (i.e. a label)
  4438. * @memberof DataTable#oApi
  4439. */
  4440. function _fnCallbackReg( oSettings, sStore, fn, sName )
  4441. {
  4442. if ( fn )
  4443. {
  4444. oSettings[sStore].push( {
  4445. "fn": fn,
  4446. "sName": sName
  4447. } );
  4448. }
  4449. }
  4450. /**
  4451. * Fire callback functions and trigger events. Note that the loop over the
  4452. * callback array store is done backwards! Further note that you do not want to
  4453. * fire off triggers in time sensitive applications (for example cell creation)
  4454. * as its slow.
  4455. * @param {object} settings dataTables settings object
  4456. * @param {string} callbackArr Name of the array storage for the callbacks in
  4457. * oSettings
  4458. * @param {string} eventName Name of the jQuery custom event to trigger. If
  4459. * null no trigger is fired
  4460. * @param {array} args Array of arguments to pass to the callback function /
  4461. * trigger
  4462. * @memberof DataTable#oApi
  4463. */
  4464. function _fnCallbackFire( settings, callbackArr, eventName, args )
  4465. {
  4466. var ret = [];
  4467. if ( callbackArr ) {
  4468. ret = $.map( settings[callbackArr].slice().reverse(), function (val, i) {
  4469. return val.fn.apply( settings.oInstance, args );
  4470. } );
  4471. }
  4472. if ( eventName !== null ) {
  4473. var e = $.Event( eventName+'.dt' );
  4474. $(settings.nTable).trigger( e, args );
  4475. ret.push( e.result );
  4476. }
  4477. return ret;
  4478. }
  4479. function _fnLengthOverflow ( settings )
  4480. {
  4481. var
  4482. start = settings._iDisplayStart,
  4483. end = settings.fnDisplayEnd(),
  4484. len = settings._iDisplayLength;
  4485. /* If we have space to show extra rows (backing up from the end point - then do so */
  4486. if ( start >= end )
  4487. {
  4488. start = end - len;
  4489. }
  4490. // Keep the start record on the current page
  4491. start -= (start % len);
  4492. if ( len === -1 || start < 0 )
  4493. {
  4494. start = 0;
  4495. }
  4496. settings._iDisplayStart = start;
  4497. }
  4498. function _fnRenderer( settings, type )
  4499. {
  4500. var renderer = settings.renderer;
  4501. var host = DataTable.ext.renderer[type];
  4502. if ( $.isPlainObject( renderer ) && renderer[type] ) {
  4503. // Specific renderer for this type. If available use it, otherwise use
  4504. // the default.
  4505. return host[renderer[type]] || host._;
  4506. }
  4507. else if ( typeof renderer === 'string' ) {
  4508. // Common renderer - if there is one available for this type use it,
  4509. // otherwise use the default
  4510. return host[renderer] || host._;
  4511. }
  4512. // Use the default
  4513. return host._;
  4514. }
  4515. /**
  4516. * Detect the data source being used for the table. Used to simplify the code
  4517. * a little (ajax) and to make it compress a little smaller.
  4518. *
  4519. * @param {object} settings dataTables settings object
  4520. * @returns {string} Data source
  4521. * @memberof DataTable#oApi
  4522. */
  4523. function _fnDataSource ( settings )
  4524. {
  4525. if ( settings.oFeatures.bServerSide ) {
  4526. return 'ssp';
  4527. }
  4528. else if ( settings.ajax || settings.sAjaxSource ) {
  4529. return 'ajax';
  4530. }
  4531. return 'dom';
  4532. }
  4533. DataTable = function( options )
  4534. {
  4535. /**
  4536. * Perform a jQuery selector action on the table's TR elements (from the tbody) and
  4537. * return the resulting jQuery object.
  4538. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  4539. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  4540. * @param {string} [oOpts.filter=none] Select TR elements that meet the current filter
  4541. * criterion ("applied") or all TR elements (i.e. no filter).
  4542. * @param {string} [oOpts.order=current] Order of the TR elements in the processed array.
  4543. * Can be either 'current', whereby the current sorting of the table is used, or
  4544. * 'original' whereby the original order the data was read into the table is used.
  4545. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  4546. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  4547. * 'current' and filter is 'applied', regardless of what they might be given as.
  4548. * @returns {object} jQuery object, filtered by the given selector.
  4549. * @dtopt API
  4550. * @deprecated Since v1.10
  4551. *
  4552. * @example
  4553. * $(document).ready(function() {
  4554. * var oTable = $('#example').dataTable();
  4555. *
  4556. * // Highlight every second row
  4557. * oTable.$('tr:odd').css('backgroundColor', 'blue');
  4558. * } );
  4559. *
  4560. * @example
  4561. * $(document).ready(function() {
  4562. * var oTable = $('#example').dataTable();
  4563. *
  4564. * // Filter to rows with 'Webkit' in them, add a background colour and then
  4565. * // remove the filter, thus highlighting the 'Webkit' rows only.
  4566. * oTable.fnFilter('Webkit');
  4567. * oTable.$('tr', {"search": "applied"}).css('backgroundColor', 'blue');
  4568. * oTable.fnFilter('');
  4569. * } );
  4570. */
  4571. this.$ = function ( sSelector, oOpts )
  4572. {
  4573. return this.api(true).$( sSelector, oOpts );
  4574. };
  4575. /**
  4576. * Almost identical to $ in operation, but in this case returns the data for the matched
  4577. * rows - as such, the jQuery selector used should match TR row nodes or TD/TH cell nodes
  4578. * rather than any descendants, so the data can be obtained for the row/cell. If matching
  4579. * rows are found, the data returned is the original data array/object that was used to
  4580. * create the row (or a generated array if from a DOM source).
  4581. *
  4582. * This method is often useful in-combination with $ where both functions are given the
  4583. * same parameters and the array indexes will match identically.
  4584. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  4585. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  4586. * @param {string} [oOpts.filter=none] Select elements that meet the current filter
  4587. * criterion ("applied") or all elements (i.e. no filter).
  4588. * @param {string} [oOpts.order=current] Order of the data in the processed array.
  4589. * Can be either 'current', whereby the current sorting of the table is used, or
  4590. * 'original' whereby the original order the data was read into the table is used.
  4591. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  4592. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  4593. * 'current' and filter is 'applied', regardless of what they might be given as.
  4594. * @returns {array} Data for the matched elements. If any elements, as a result of the
  4595. * selector, were not TR, TD or TH elements in the DataTable, they will have a null
  4596. * entry in the array.
  4597. * @dtopt API
  4598. * @deprecated Since v1.10
  4599. *
  4600. * @example
  4601. * $(document).ready(function() {
  4602. * var oTable = $('#example').dataTable();
  4603. *
  4604. * // Get the data from the first row in the table
  4605. * var data = oTable._('tr:first');
  4606. *
  4607. * // Do something useful with the data
  4608. * alert( "First cell is: "+data[0] );
  4609. * } );
  4610. *
  4611. * @example
  4612. * $(document).ready(function() {
  4613. * var oTable = $('#example').dataTable();
  4614. *
  4615. * // Filter to 'Webkit' and get all data for
  4616. * oTable.fnFilter('Webkit');
  4617. * var data = oTable._('tr', {"search": "applied"});
  4618. *
  4619. * // Do something with the data
  4620. * alert( data.length+" rows matched the search" );
  4621. * } );
  4622. */
  4623. this._ = function ( sSelector, oOpts )
  4624. {
  4625. return this.api(true).rows( sSelector, oOpts ).data();
  4626. };
  4627. /**
  4628. * Create a DataTables Api instance, with the currently selected tables for
  4629. * the Api's context.
  4630. * @param {boolean} [traditional=false] Set the API instance's context to be
  4631. * only the table referred to by the `DataTable.ext.iApiIndex` option, as was
  4632. * used in the API presented by DataTables 1.9- (i.e. the traditional mode),
  4633. * or if all tables captured in the jQuery object should be used.
  4634. * @return {DataTables.Api}
  4635. */
  4636. this.api = function ( traditional )
  4637. {
  4638. return traditional ?
  4639. new _Api(
  4640. _fnSettingsFromNode( this[ _ext.iApiIndex ] )
  4641. ) :
  4642. new _Api( this );
  4643. };
  4644. /**
  4645. * Add a single new row or multiple rows of data to the table. Please note
  4646. * that this is suitable for client-side processing only - if you are using
  4647. * server-side processing (i.e. "bServerSide": true), then to add data, you
  4648. * must add it to the data source, i.e. the server-side, through an Ajax call.
  4649. * @param {array|object} data The data to be added to the table. This can be:
  4650. * <ul>
  4651. * <li>1D array of data - add a single row with the data provided</li>
  4652. * <li>2D array of arrays - add multiple rows in a single call</li>
  4653. * <li>object - data object when using <i>mData</i></li>
  4654. * <li>array of objects - multiple data objects when using <i>mData</i></li>
  4655. * </ul>
  4656. * @param {bool} [redraw=true] redraw the table or not
  4657. * @returns {array} An array of integers, representing the list of indexes in
  4658. * <i>aoData</i> ({@link DataTable.models.oSettings}) that have been added to
  4659. * the table.
  4660. * @dtopt API
  4661. * @deprecated Since v1.10
  4662. *
  4663. * @example
  4664. * // Global var for counter
  4665. * var giCount = 2;
  4666. *
  4667. * $(document).ready(function() {
  4668. * $('#example').dataTable();
  4669. * } );
  4670. *
  4671. * function fnClickAddRow() {
  4672. * $('#example').dataTable().fnAddData( [
  4673. * giCount+".1",
  4674. * giCount+".2",
  4675. * giCount+".3",
  4676. * giCount+".4" ]
  4677. * );
  4678. *
  4679. * giCount++;
  4680. * }
  4681. */
  4682. this.fnAddData = function( data, redraw )
  4683. {
  4684. var api = this.api( true );
  4685. /* Check if we want to add multiple rows or not */
  4686. var rows = $.isArray(data) && ( $.isArray(data[0]) || $.isPlainObject(data[0]) ) ?
  4687. api.rows.add( data ) :
  4688. api.row.add( data );
  4689. if ( redraw === undefined || redraw ) {
  4690. api.draw();
  4691. }
  4692. return rows.flatten().toArray();
  4693. };
  4694. /**
  4695. * This function will make DataTables recalculate the column sizes, based on the data
  4696. * contained in the table and the sizes applied to the columns (in the DOM, CSS or
  4697. * through the sWidth parameter). This can be useful when the width of the table's
  4698. * parent element changes (for example a window resize).
  4699. * @param {boolean} [bRedraw=true] Redraw the table or not, you will typically want to
  4700. * @dtopt API
  4701. * @deprecated Since v1.10
  4702. *
  4703. * @example
  4704. * $(document).ready(function() {
  4705. * var oTable = $('#example').dataTable( {
  4706. * "sScrollY": "200px",
  4707. * "bPaginate": false
  4708. * } );
  4709. *
  4710. * $(window).bind('resize', function () {
  4711. * oTable.fnAdjustColumnSizing();
  4712. * } );
  4713. * } );
  4714. */
  4715. this.fnAdjustColumnSizing = function ( bRedraw )
  4716. {
  4717. var api = this.api( true ).columns.adjust();
  4718. var settings = api.settings()[0];
  4719. var scroll = settings.oScroll;
  4720. if ( bRedraw === undefined || bRedraw ) {
  4721. api.draw( false );
  4722. }
  4723. else if ( scroll.sX !== "" || scroll.sY !== "" ) {
  4724. /* If not redrawing, but scrolling, we want to apply the new column sizes anyway */
  4725. _fnScrollDraw( settings );
  4726. }
  4727. };
  4728. /**
  4729. * Quickly and simply clear a table
  4730. * @param {bool} [bRedraw=true] redraw the table or not
  4731. * @dtopt API
  4732. * @deprecated Since v1.10
  4733. *
  4734. * @example
  4735. * $(document).ready(function() {
  4736. * var oTable = $('#example').dataTable();
  4737. *
  4738. * // Immediately 'nuke' the current rows (perhaps waiting for an Ajax callback...)
  4739. * oTable.fnClearTable();
  4740. * } );
  4741. */
  4742. this.fnClearTable = function( bRedraw )
  4743. {
  4744. var api = this.api( true ).clear();
  4745. if ( bRedraw === undefined || bRedraw ) {
  4746. api.draw();
  4747. }
  4748. };
  4749. /**
  4750. * The exact opposite of 'opening' a row, this function will close any rows which
  4751. * are currently 'open'.
  4752. * @param {node} nTr the table row to 'close'
  4753. * @returns {int} 0 on success, or 1 if failed (can't find the row)
  4754. * @dtopt API
  4755. * @deprecated Since v1.10
  4756. *
  4757. * @example
  4758. * $(document).ready(function() {
  4759. * var oTable;
  4760. *
  4761. * // 'open' an information row when a row is clicked on
  4762. * $('#example tbody tr').click( function () {
  4763. * if ( oTable.fnIsOpen(this) ) {
  4764. * oTable.fnClose( this );
  4765. * } else {
  4766. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  4767. * }
  4768. * } );
  4769. *
  4770. * oTable = $('#example').dataTable();
  4771. * } );
  4772. */
  4773. this.fnClose = function( nTr )
  4774. {
  4775. this.api( true ).row( nTr ).child.hide();
  4776. };
  4777. /**
  4778. * Remove a row for the table
  4779. * @param {mixed} target The index of the row from aoData to be deleted, or
  4780. * the TR element you want to delete
  4781. * @param {function|null} [callBack] Callback function
  4782. * @param {bool} [redraw=true] Redraw the table or not
  4783. * @returns {array} The row that was deleted
  4784. * @dtopt API
  4785. * @deprecated Since v1.10
  4786. *
  4787. * @example
  4788. * $(document).ready(function() {
  4789. * var oTable = $('#example').dataTable();
  4790. *
  4791. * // Immediately remove the first row
  4792. * oTable.fnDeleteRow( 0 );
  4793. * } );
  4794. */
  4795. this.fnDeleteRow = function( target, callback, redraw )
  4796. {
  4797. var api = this.api( true );
  4798. var rows = api.rows( target );
  4799. var settings = rows.settings()[0];
  4800. var data = settings.aoData[ rows[0][0] ];
  4801. rows.remove();
  4802. if ( callback ) {
  4803. callback.call( this, settings, data );
  4804. }
  4805. if ( redraw === undefined || redraw ) {
  4806. api.draw();
  4807. }
  4808. return data;
  4809. };
  4810. /**
  4811. * Restore the table to it's original state in the DOM by removing all of DataTables
  4812. * enhancements, alterations to the DOM structure of the table and event listeners.
  4813. * @param {boolean} [remove=false] Completely remove the table from the DOM
  4814. * @dtopt API
  4815. * @deprecated Since v1.10
  4816. *
  4817. * @example
  4818. * $(document).ready(function() {
  4819. * // This example is fairly pointless in reality, but shows how fnDestroy can be used
  4820. * var oTable = $('#example').dataTable();
  4821. * oTable.fnDestroy();
  4822. * } );
  4823. */
  4824. this.fnDestroy = function ( remove )
  4825. {
  4826. this.api( true ).destroy( remove );
  4827. };
  4828. /**
  4829. * Redraw the table
  4830. * @param {bool} [complete=true] Re-filter and resort (if enabled) the table before the draw.
  4831. * @dtopt API
  4832. * @deprecated Since v1.10
  4833. *
  4834. * @example
  4835. * $(document).ready(function() {
  4836. * var oTable = $('#example').dataTable();
  4837. *
  4838. * // Re-draw the table - you wouldn't want to do it here, but it's an example :-)
  4839. * oTable.fnDraw();
  4840. * } );
  4841. */
  4842. this.fnDraw = function( complete )
  4843. {
  4844. // Note that this isn't an exact match to the old call to _fnDraw - it takes
  4845. // into account the new data, but can hold position.
  4846. this.api( true ).draw( complete );
  4847. };
  4848. /**
  4849. * Filter the input based on data
  4850. * @param {string} sInput String to filter the table on
  4851. * @param {int|null} [iColumn] Column to limit filtering to
  4852. * @param {bool} [bRegex=false] Treat as regular expression or not
  4853. * @param {bool} [bSmart=true] Perform smart filtering or not
  4854. * @param {bool} [bShowGlobal=true] Show the input global filter in it's input box(es)
  4855. * @param {bool} [bCaseInsensitive=true] Do case-insensitive matching (true) or not (false)
  4856. * @dtopt API
  4857. * @deprecated Since v1.10
  4858. *
  4859. * @example
  4860. * $(document).ready(function() {
  4861. * var oTable = $('#example').dataTable();
  4862. *
  4863. * // Sometime later - filter...
  4864. * oTable.fnFilter( 'test string' );
  4865. * } );
  4866. */
  4867. this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal, bCaseInsensitive )
  4868. {
  4869. var api = this.api( true );
  4870. if ( iColumn === null || iColumn === undefined ) {
  4871. api.search( sInput, bRegex, bSmart, bCaseInsensitive );
  4872. }
  4873. else {
  4874. api.column( iColumn ).search( sInput, bRegex, bSmart, bCaseInsensitive );
  4875. }
  4876. api.draw();
  4877. };
  4878. /**
  4879. * Get the data for the whole table, an individual row or an individual cell based on the
  4880. * provided parameters.
  4881. * @param {int|node} [src] A TR row node, TD/TH cell node or an integer. If given as
  4882. * a TR node then the data source for the whole row will be returned. If given as a
  4883. * TD/TH cell node then iCol will be automatically calculated and the data for the
  4884. * cell returned. If given as an integer, then this is treated as the aoData internal
  4885. * data index for the row (see fnGetPosition) and the data for that row used.
  4886. * @param {int} [col] Optional column index that you want the data of.
  4887. * @returns {array|object|string} If mRow is undefined, then the data for all rows is
  4888. * returned. If mRow is defined, just data for that row, and is iCol is
  4889. * defined, only data for the designated cell is returned.
  4890. * @dtopt API
  4891. * @deprecated Since v1.10
  4892. *
  4893. * @example
  4894. * // Row data
  4895. * $(document).ready(function() {
  4896. * oTable = $('#example').dataTable();
  4897. *
  4898. * oTable.$('tr').click( function () {
  4899. * var data = oTable.fnGetData( this );
  4900. * // ... do something with the array / object of data for the row
  4901. * } );
  4902. * } );
  4903. *
  4904. * @example
  4905. * // Individual cell data
  4906. * $(document).ready(function() {
  4907. * oTable = $('#example').dataTable();
  4908. *
  4909. * oTable.$('td').click( function () {
  4910. * var sData = oTable.fnGetData( this );
  4911. * alert( 'The cell clicked on had the value of '+sData );
  4912. * } );
  4913. * } );
  4914. */
  4915. this.fnGetData = function( src, col )
  4916. {
  4917. var api = this.api( true );
  4918. if ( src !== undefined ) {
  4919. var type = src.nodeName ? src.nodeName.toLowerCase() : '';
  4920. return col !== undefined || type == 'td' || type == 'th' ?
  4921. api.cell( src, col ).data() :
  4922. api.row( src ).data() || null;
  4923. }
  4924. return api.data().toArray();
  4925. };
  4926. /**
  4927. * Get an array of the TR nodes that are used in the table's body. Note that you will
  4928. * typically want to use the '$' API method in preference to this as it is more
  4929. * flexible.
  4930. * @param {int} [iRow] Optional row index for the TR element you want
  4931. * @returns {array|node} If iRow is undefined, returns an array of all TR elements
  4932. * in the table's body, or iRow is defined, just the TR element requested.
  4933. * @dtopt API
  4934. * @deprecated Since v1.10
  4935. *
  4936. * @example
  4937. * $(document).ready(function() {
  4938. * var oTable = $('#example').dataTable();
  4939. *
  4940. * // Get the nodes from the table
  4941. * var nNodes = oTable.fnGetNodes( );
  4942. * } );
  4943. */
  4944. this.fnGetNodes = function( iRow )
  4945. {
  4946. var api = this.api( true );
  4947. return iRow !== undefined ?
  4948. api.row( iRow ).node() :
  4949. api.rows().nodes().flatten().toArray();
  4950. };
  4951. /**
  4952. * Get the array indexes of a particular cell from it's DOM element
  4953. * and column index including hidden columns
  4954. * @param {node} node this can either be a TR, TD or TH in the table's body
  4955. * @returns {int} If nNode is given as a TR, then a single index is returned, or
  4956. * if given as a cell, an array of [row index, column index (visible),
  4957. * column index (all)] is given.
  4958. * @dtopt API
  4959. * @deprecated Since v1.10
  4960. *
  4961. * @example
  4962. * $(document).ready(function() {
  4963. * $('#example tbody td').click( function () {
  4964. * // Get the position of the current data from the node
  4965. * var aPos = oTable.fnGetPosition( this );
  4966. *
  4967. * // Get the data array for this row
  4968. * var aData = oTable.fnGetData( aPos[0] );
  4969. *
  4970. * // Update the data array and return the value
  4971. * aData[ aPos[1] ] = 'clicked';
  4972. * this.innerHTML = 'clicked';
  4973. * } );
  4974. *
  4975. * // Init DataTables
  4976. * oTable = $('#example').dataTable();
  4977. * } );
  4978. */
  4979. this.fnGetPosition = function( node )
  4980. {
  4981. var api = this.api( true );
  4982. var nodeName = node.nodeName.toUpperCase();
  4983. if ( nodeName == 'TR' ) {
  4984. return api.row( node ).index();
  4985. }
  4986. else if ( nodeName == 'TD' || nodeName == 'TH' ) {
  4987. var cell = api.cell( node ).index();
  4988. return [
  4989. cell.row,
  4990. cell.columnVisible,
  4991. cell.column
  4992. ];
  4993. }
  4994. return null;
  4995. };
  4996. /**
  4997. * Check to see if a row is 'open' or not.
  4998. * @param {node} nTr the table row to check
  4999. * @returns {boolean} true if the row is currently open, false otherwise
  5000. * @dtopt API
  5001. * @deprecated Since v1.10
  5002. *
  5003. * @example
  5004. * $(document).ready(function() {
  5005. * var oTable;
  5006. *
  5007. * // 'open' an information row when a row is clicked on
  5008. * $('#example tbody tr').click( function () {
  5009. * if ( oTable.fnIsOpen(this) ) {
  5010. * oTable.fnClose( this );
  5011. * } else {
  5012. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  5013. * }
  5014. * } );
  5015. *
  5016. * oTable = $('#example').dataTable();
  5017. * } );
  5018. */
  5019. this.fnIsOpen = function( nTr )
  5020. {
  5021. return this.api( true ).row( nTr ).child.isShown();
  5022. };
  5023. /**
  5024. * This function will place a new row directly after a row which is currently
  5025. * on display on the page, with the HTML contents that is passed into the
  5026. * function. This can be used, for example, to ask for confirmation that a
  5027. * particular record should be deleted.
  5028. * @param {node} nTr The table row to 'open'
  5029. * @param {string|node|jQuery} mHtml The HTML to put into the row
  5030. * @param {string} sClass Class to give the new TD cell
  5031. * @returns {node} The row opened. Note that if the table row passed in as the
  5032. * first parameter, is not found in the table, this method will silently
  5033. * return.
  5034. * @dtopt API
  5035. * @deprecated Since v1.10
  5036. *
  5037. * @example
  5038. * $(document).ready(function() {
  5039. * var oTable;
  5040. *
  5041. * // 'open' an information row when a row is clicked on
  5042. * $('#example tbody tr').click( function () {
  5043. * if ( oTable.fnIsOpen(this) ) {
  5044. * oTable.fnClose( this );
  5045. * } else {
  5046. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  5047. * }
  5048. * } );
  5049. *
  5050. * oTable = $('#example').dataTable();
  5051. * } );
  5052. */
  5053. this.fnOpen = function( nTr, mHtml, sClass )
  5054. {
  5055. return this.api( true )
  5056. .row( nTr )
  5057. .child( mHtml, sClass )
  5058. .show()
  5059. .child()[0];
  5060. };
  5061. /**
  5062. * Change the pagination - provides the internal logic for pagination in a simple API
  5063. * function. With this function you can have a DataTables table go to the next,
  5064. * previous, first or last pages.
  5065. * @param {string|int} mAction Paging action to take: "first", "previous", "next" or "last"
  5066. * or page number to jump to (integer), note that page 0 is the first page.
  5067. * @param {bool} [bRedraw=true] Redraw the table or not
  5068. * @dtopt API
  5069. * @deprecated Since v1.10
  5070. *
  5071. * @example
  5072. * $(document).ready(function() {
  5073. * var oTable = $('#example').dataTable();
  5074. * oTable.fnPageChange( 'next' );
  5075. * } );
  5076. */
  5077. this.fnPageChange = function ( mAction, bRedraw )
  5078. {
  5079. var api = this.api( true ).page( mAction );
  5080. if ( bRedraw === undefined || bRedraw ) {
  5081. api.draw(false);
  5082. }
  5083. };
  5084. /**
  5085. * Show a particular column
  5086. * @param {int} iCol The column whose display should be changed
  5087. * @param {bool} bShow Show (true) or hide (false) the column
  5088. * @param {bool} [bRedraw=true] Redraw the table or not
  5089. * @dtopt API
  5090. * @deprecated Since v1.10
  5091. *
  5092. * @example
  5093. * $(document).ready(function() {
  5094. * var oTable = $('#example').dataTable();
  5095. *
  5096. * // Hide the second column after initialisation
  5097. * oTable.fnSetColumnVis( 1, false );
  5098. * } );
  5099. */
  5100. this.fnSetColumnVis = function ( iCol, bShow, bRedraw )
  5101. {
  5102. var api = this.api( true ).column( iCol ).visible( bShow );
  5103. if ( bRedraw === undefined || bRedraw ) {
  5104. api.columns.adjust().draw();
  5105. }
  5106. };
  5107. /**
  5108. * Get the settings for a particular table for external manipulation
  5109. * @returns {object} DataTables settings object. See
  5110. * {@link DataTable.models.oSettings}
  5111. * @dtopt API
  5112. * @deprecated Since v1.10
  5113. *
  5114. * @example
  5115. * $(document).ready(function() {
  5116. * var oTable = $('#example').dataTable();
  5117. * var oSettings = oTable.fnSettings();
  5118. *
  5119. * // Show an example parameter from the settings
  5120. * alert( oSettings._iDisplayStart );
  5121. * } );
  5122. */
  5123. this.fnSettings = function()
  5124. {
  5125. return _fnSettingsFromNode( this[_ext.iApiIndex] );
  5126. };
  5127. /**
  5128. * Sort the table by a particular column
  5129. * @param {int} iCol the data index to sort on. Note that this will not match the
  5130. * 'display index' if you have hidden data entries
  5131. * @dtopt API
  5132. * @deprecated Since v1.10
  5133. *
  5134. * @example
  5135. * $(document).ready(function() {
  5136. * var oTable = $('#example').dataTable();
  5137. *
  5138. * // Sort immediately with columns 0 and 1
  5139. * oTable.fnSort( [ [0,'asc'], [1,'asc'] ] );
  5140. * } );
  5141. */
  5142. this.fnSort = function( aaSort )
  5143. {
  5144. this.api( true ).order( aaSort ).draw();
  5145. };
  5146. /**
  5147. * Attach a sort listener to an element for a given column
  5148. * @param {node} nNode the element to attach the sort listener to
  5149. * @param {int} iColumn the column that a click on this node will sort on
  5150. * @param {function} [fnCallback] callback function when sort is run
  5151. * @dtopt API
  5152. * @deprecated Since v1.10
  5153. *
  5154. * @example
  5155. * $(document).ready(function() {
  5156. * var oTable = $('#example').dataTable();
  5157. *
  5158. * // Sort on column 1, when 'sorter' is clicked on
  5159. * oTable.fnSortListener( document.getElementById('sorter'), 1 );
  5160. * } );
  5161. */
  5162. this.fnSortListener = function( nNode, iColumn, fnCallback )
  5163. {
  5164. this.api( true ).order.listener( nNode, iColumn, fnCallback );
  5165. };
  5166. /**
  5167. * Update a table cell or row - this method will accept either a single value to
  5168. * update the cell with, an array of values with one element for each column or
  5169. * an object in the same format as the original data source. The function is
  5170. * self-referencing in order to make the multi column updates easier.
  5171. * @param {object|array|string} mData Data to update the cell/row with
  5172. * @param {node|int} mRow TR element you want to update or the aoData index
  5173. * @param {int} [iColumn] The column to update, give as null or undefined to
  5174. * update a whole row.
  5175. * @param {bool} [bRedraw=true] Redraw the table or not
  5176. * @param {bool} [bAction=true] Perform pre-draw actions or not
  5177. * @returns {int} 0 on success, 1 on error
  5178. * @dtopt API
  5179. * @deprecated Since v1.10
  5180. *
  5181. * @example
  5182. * $(document).ready(function() {
  5183. * var oTable = $('#example').dataTable();
  5184. * oTable.fnUpdate( 'Example update', 0, 0 ); // Single cell
  5185. * oTable.fnUpdate( ['a', 'b', 'c', 'd', 'e'], $('tbody tr')[0] ); // Row
  5186. * } );
  5187. */
  5188. this.fnUpdate = function( mData, mRow, iColumn, bRedraw, bAction )
  5189. {
  5190. var api = this.api( true );
  5191. if ( iColumn === undefined || iColumn === null ) {
  5192. api.row( mRow ).data( mData );
  5193. }
  5194. else {
  5195. api.cell( mRow, iColumn ).data( mData );
  5196. }
  5197. if ( bAction === undefined || bAction ) {
  5198. api.columns.adjust();
  5199. }
  5200. if ( bRedraw === undefined || bRedraw ) {
  5201. api.draw();
  5202. }
  5203. return 0;
  5204. };
  5205. /**
  5206. * Provide a common method for plug-ins to check the version of DataTables being used, in order
  5207. * to ensure compatibility.
  5208. * @param {string} sVersion Version string to check for, in the format "X.Y.Z". Note that the
  5209. * formats "X" and "X.Y" are also acceptable.
  5210. * @returns {boolean} true if this version of DataTables is greater or equal to the required
  5211. * version, or false if this version of DataTales is not suitable
  5212. * @method
  5213. * @dtopt API
  5214. * @deprecated Since v1.10
  5215. *
  5216. * @example
  5217. * $(document).ready(function() {
  5218. * var oTable = $('#example').dataTable();
  5219. * alert( oTable.fnVersionCheck( '1.9.0' ) );
  5220. * } );
  5221. */
  5222. this.fnVersionCheck = _ext.fnVersionCheck;
  5223. var _that = this;
  5224. var emptyInit = options === undefined;
  5225. var len = this.length;
  5226. if ( emptyInit ) {
  5227. options = {};
  5228. }
  5229. this.oApi = this.internal = _ext.internal;
  5230. // Extend with old style plug-in API methods
  5231. for ( var fn in DataTable.ext.internal ) {
  5232. if ( fn ) {
  5233. this[fn] = _fnExternApiFunc(fn);
  5234. }
  5235. }
  5236. this.each(function() {
  5237. // For each initialisation we want to give it a clean initialisation
  5238. // object that can be bashed around
  5239. var o = {};
  5240. var oInit = len > 1 ? // optimisation for single table case
  5241. _fnExtend( o, options, true ) :
  5242. options;
  5243. /*global oInit,_that,emptyInit*/
  5244. var i=0, iLen, j, jLen, k, kLen;
  5245. var sId = this.getAttribute( 'id' );
  5246. var bInitHandedOff = false;
  5247. var defaults = DataTable.defaults;
  5248. var $this = $(this);
  5249. /* Sanity check */
  5250. if ( this.nodeName.toLowerCase() != 'table' )
  5251. {
  5252. _fnLog( null, 0, 'Non-table node initialisation ('+this.nodeName+')', 2 );
  5253. return;
  5254. }
  5255. /* Backwards compatibility for the defaults */
  5256. _fnCompatOpts( defaults );
  5257. _fnCompatCols( defaults.column );
  5258. /* Convert the camel-case defaults to Hungarian */
  5259. _fnCamelToHungarian( defaults, defaults, true );
  5260. _fnCamelToHungarian( defaults.column, defaults.column, true );
  5261. /* Setting up the initialisation object */
  5262. _fnCamelToHungarian( defaults, $.extend( oInit, $this.data() ) );
  5263. /* Check to see if we are re-initialising a table */
  5264. var allSettings = DataTable.settings;
  5265. for ( i=0, iLen=allSettings.length ; i<iLen ; i++ )
  5266. {
  5267. var s = allSettings[i];
  5268. /* Base check on table node */
  5269. if ( s.nTable == this || s.nTHead.parentNode == this || (s.nTFoot && s.nTFoot.parentNode == this) )
  5270. {
  5271. var bRetrieve = oInit.bRetrieve !== undefined ? oInit.bRetrieve : defaults.bRetrieve;
  5272. var bDestroy = oInit.bDestroy !== undefined ? oInit.bDestroy : defaults.bDestroy;
  5273. if ( emptyInit || bRetrieve )
  5274. {
  5275. return s.oInstance;
  5276. }
  5277. else if ( bDestroy )
  5278. {
  5279. s.oInstance.fnDestroy();
  5280. break;
  5281. }
  5282. else
  5283. {
  5284. _fnLog( s, 0, 'Cannot reinitialise DataTable', 3 );
  5285. return;
  5286. }
  5287. }
  5288. /* If the element we are initialising has the same ID as a table which was previously
  5289. * initialised, but the table nodes don't match (from before) then we destroy the old
  5290. * instance by simply deleting it. This is under the assumption that the table has been
  5291. * destroyed by other methods. Anyone using non-id selectors will need to do this manually
  5292. */
  5293. if ( s.sTableId == this.id )
  5294. {
  5295. allSettings.splice( i, 1 );
  5296. break;
  5297. }
  5298. }
  5299. /* Ensure the table has an ID - required for accessibility */
  5300. if ( sId === null || sId === "" )
  5301. {
  5302. sId = "DataTables_Table_"+(DataTable.ext._unique++);
  5303. this.id = sId;
  5304. }
  5305. /* Create the settings object for this table and set some of the default parameters */
  5306. var oSettings = $.extend( true, {}, DataTable.models.oSettings, {
  5307. "sDestroyWidth": $this[0].style.width,
  5308. "sInstance": sId,
  5309. "sTableId": sId
  5310. } );
  5311. oSettings.nTable = this;
  5312. oSettings.oApi = _that.internal;
  5313. oSettings.oInit = oInit;
  5314. allSettings.push( oSettings );
  5315. // Need to add the instance after the instance after the settings object has been added
  5316. // to the settings array, so we can self reference the table instance if more than one
  5317. oSettings.oInstance = (_that.length===1) ? _that : $this.dataTable();
  5318. // Backwards compatibility, before we apply all the defaults
  5319. _fnCompatOpts( oInit );
  5320. if ( oInit.oLanguage )
  5321. {
  5322. _fnLanguageCompat( oInit.oLanguage );
  5323. }
  5324. // If the length menu is given, but the init display length is not, use the length menu
  5325. if ( oInit.aLengthMenu && ! oInit.iDisplayLength )
  5326. {
  5327. oInit.iDisplayLength = $.isArray( oInit.aLengthMenu[0] ) ?
  5328. oInit.aLengthMenu[0][0] : oInit.aLengthMenu[0];
  5329. }
  5330. // Apply the defaults and init options to make a single init object will all
  5331. // options defined from defaults and instance options.
  5332. oInit = _fnExtend( $.extend( true, {}, defaults ), oInit );
  5333. // Map the initialisation options onto the settings object
  5334. _fnMap( oSettings.oFeatures, oInit, [
  5335. "bPaginate",
  5336. "bLengthChange",
  5337. "bFilter",
  5338. "bSort",
  5339. "bSortMulti",
  5340. "bInfo",
  5341. "bProcessing",
  5342. "bAutoWidth",
  5343. "bSortClasses",
  5344. "bServerSide",
  5345. "bDeferRender"
  5346. ] );
  5347. _fnMap( oSettings, oInit, [
  5348. "asStripeClasses",
  5349. "ajax",
  5350. "fnServerData",
  5351. "fnFormatNumber",
  5352. "sServerMethod",
  5353. "aaSorting",
  5354. "aaSortingFixed",
  5355. "aLengthMenu",
  5356. "sPaginationType",
  5357. "sAjaxSource",
  5358. "sAjaxDataProp",
  5359. "iStateDuration",
  5360. "sDom",
  5361. "bSortCellsTop",
  5362. "iTabIndex",
  5363. "fnStateLoadCallback",
  5364. "fnStateSaveCallback",
  5365. "renderer",
  5366. "searchDelay",
  5367. "rowId",
  5368. [ "iCookieDuration", "iStateDuration" ], // backwards compat
  5369. [ "oSearch", "oPreviousSearch" ],
  5370. [ "aoSearchCols", "aoPreSearchCols" ],
  5371. [ "iDisplayLength", "_iDisplayLength" ],
  5372. [ "bJQueryUI", "bJUI" ]
  5373. ] );
  5374. _fnMap( oSettings.oScroll, oInit, [
  5375. [ "sScrollX", "sX" ],
  5376. [ "sScrollXInner", "sXInner" ],
  5377. [ "sScrollY", "sY" ],
  5378. [ "bScrollCollapse", "bCollapse" ]
  5379. ] );
  5380. _fnMap( oSettings.oLanguage, oInit, "fnInfoCallback" );
  5381. /* Callback functions which are array driven */
  5382. _fnCallbackReg( oSettings, 'aoDrawCallback', oInit.fnDrawCallback, 'user' );
  5383. _fnCallbackReg( oSettings, 'aoServerParams', oInit.fnServerParams, 'user' );
  5384. _fnCallbackReg( oSettings, 'aoStateSaveParams', oInit.fnStateSaveParams, 'user' );
  5385. _fnCallbackReg( oSettings, 'aoStateLoadParams', oInit.fnStateLoadParams, 'user' );
  5386. _fnCallbackReg( oSettings, 'aoStateLoaded', oInit.fnStateLoaded, 'user' );
  5387. _fnCallbackReg( oSettings, 'aoRowCallback', oInit.fnRowCallback, 'user' );
  5388. _fnCallbackReg( oSettings, 'aoRowCreatedCallback', oInit.fnCreatedRow, 'user' );
  5389. _fnCallbackReg( oSettings, 'aoHeaderCallback', oInit.fnHeaderCallback, 'user' );
  5390. _fnCallbackReg( oSettings, 'aoFooterCallback', oInit.fnFooterCallback, 'user' );
  5391. _fnCallbackReg( oSettings, 'aoInitComplete', oInit.fnInitComplete, 'user' );
  5392. _fnCallbackReg( oSettings, 'aoPreDrawCallback', oInit.fnPreDrawCallback, 'user' );
  5393. oSettings.rowIdFn = _fnGetObjectDataFn( oInit.rowId );
  5394. var oClasses = oSettings.oClasses;
  5395. // @todo Remove in 1.11
  5396. if ( oInit.bJQueryUI )
  5397. {
  5398. /* Use the JUI classes object for display. You could clone the oStdClasses object if
  5399. * you want to have multiple tables with multiple independent classes
  5400. */
  5401. $.extend( oClasses, DataTable.ext.oJUIClasses, oInit.oClasses );
  5402. if ( oInit.sDom === defaults.sDom && defaults.sDom === "lfrtip" )
  5403. {
  5404. /* Set the DOM to use a layout suitable for jQuery UI's theming */
  5405. oSettings.sDom = '<"H"lfr>t<"F"ip>';
  5406. }
  5407. if ( ! oSettings.renderer ) {
  5408. oSettings.renderer = 'jqueryui';
  5409. }
  5410. else if ( $.isPlainObject( oSettings.renderer ) && ! oSettings.renderer.header ) {
  5411. oSettings.renderer.header = 'jqueryui';
  5412. }
  5413. }
  5414. else
  5415. {
  5416. $.extend( oClasses, DataTable.ext.classes, oInit.oClasses );
  5417. }
  5418. $this.addClass( oClasses.sTable );
  5419. /* Calculate the scroll bar width and cache it for use later on */
  5420. if ( oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "" )
  5421. {
  5422. oSettings.oScroll.iBarWidth = _fnScrollBarWidth();
  5423. }
  5424. if ( oSettings.iInitDisplayStart === undefined )
  5425. {
  5426. /* Display start point, taking into account the save saving */
  5427. oSettings.iInitDisplayStart = oInit.iDisplayStart;
  5428. oSettings._iDisplayStart = oInit.iDisplayStart;
  5429. }
  5430. if ( oInit.iDeferLoading !== null )
  5431. {
  5432. oSettings.bDeferLoading = true;
  5433. var tmp = $.isArray( oInit.iDeferLoading );
  5434. oSettings._iRecordsDisplay = tmp ? oInit.iDeferLoading[0] : oInit.iDeferLoading;
  5435. oSettings._iRecordsTotal = tmp ? oInit.iDeferLoading[1] : oInit.iDeferLoading;
  5436. }
  5437. /* Language definitions */
  5438. var oLanguage = oSettings.oLanguage;
  5439. $.extend( true, oLanguage, oInit.oLanguage );
  5440. if ( oLanguage.sUrl !== "" )
  5441. {
  5442. /* Get the language definitions from a file - because this Ajax call makes the language
  5443. * get async to the remainder of this function we use bInitHandedOff to indicate that
  5444. * _fnInitialise will be fired by the returned Ajax handler, rather than the constructor
  5445. */
  5446. $.ajax( {
  5447. dataType: 'json',
  5448. url: oLanguage.sUrl,
  5449. success: function ( json ) {
  5450. _fnLanguageCompat( json );
  5451. _fnCamelToHungarian( defaults.oLanguage, json );
  5452. $.extend( true, oLanguage, json );
  5453. _fnInitialise( oSettings );
  5454. },
  5455. error: function () {
  5456. // Error occurred loading language file, continue on as best we can
  5457. _fnInitialise( oSettings );
  5458. }
  5459. } );
  5460. bInitHandedOff = true;
  5461. }
  5462. /*
  5463. * Stripes
  5464. */
  5465. if ( oInit.asStripeClasses === null )
  5466. {
  5467. oSettings.asStripeClasses =[
  5468. oClasses.sStripeOdd,
  5469. oClasses.sStripeEven
  5470. ];
  5471. }
  5472. /* Remove row stripe classes if they are already on the table row */
  5473. var stripeClasses = oSettings.asStripeClasses;
  5474. var rowOne = $this.children('tbody').find('tr').eq(0);
  5475. if ( $.inArray( true, $.map( stripeClasses, function(el, i) {
  5476. return rowOne.hasClass(el);
  5477. } ) ) !== -1 ) {
  5478. $('tbody tr', this).removeClass( stripeClasses.join(' ') );
  5479. oSettings.asDestroyStripes = stripeClasses.slice();
  5480. }
  5481. /*
  5482. * Columns
  5483. * See if we should load columns automatically or use defined ones
  5484. */
  5485. var anThs = [];
  5486. var aoColumnsInit;
  5487. var nThead = this.getElementsByTagName('thead');
  5488. if ( nThead.length !== 0 )
  5489. {
  5490. _fnDetectHeader( oSettings.aoHeader, nThead[0] );
  5491. anThs = _fnGetUniqueThs( oSettings );
  5492. }
  5493. /* If not given a column array, generate one with nulls */
  5494. if ( oInit.aoColumns === null )
  5495. {
  5496. aoColumnsInit = [];
  5497. for ( i=0, iLen=anThs.length ; i<iLen ; i++ )
  5498. {
  5499. aoColumnsInit.push( null );
  5500. }
  5501. }
  5502. else
  5503. {
  5504. aoColumnsInit = oInit.aoColumns;
  5505. }
  5506. /* Add the columns */
  5507. for ( i=0, iLen=aoColumnsInit.length ; i<iLen ; i++ )
  5508. {
  5509. _fnAddColumn( oSettings, anThs ? anThs[i] : null );
  5510. }
  5511. /* Apply the column definitions */
  5512. _fnApplyColumnDefs( oSettings, oInit.aoColumnDefs, aoColumnsInit, function (iCol, oDef) {
  5513. _fnColumnOptions( oSettings, iCol, oDef );
  5514. } );
  5515. /* HTML5 attribute detection - build an mData object automatically if the
  5516. * attributes are found
  5517. */
  5518. if ( rowOne.length ) {
  5519. var a = function ( cell, name ) {
  5520. return cell.getAttribute( 'data-'+name ) !== null ? name : null;
  5521. };
  5522. $.each( _fnGetRowElements( oSettings, rowOne[0] ).cells, function (i, cell) {
  5523. var col = oSettings.aoColumns[i];
  5524. if ( col.mData === i ) {
  5525. var sort = a( cell, 'sort' ) || a( cell, 'order' );
  5526. var filter = a( cell, 'filter' ) || a( cell, 'search' );
  5527. if ( sort !== null || filter !== null ) {
  5528. col.mData = {
  5529. _: i+'.display',
  5530. sort: sort !== null ? i+'.@data-'+sort : undefined,
  5531. type: sort !== null ? i+'.@data-'+sort : undefined,
  5532. filter: filter !== null ? i+'.@data-'+filter : undefined
  5533. };
  5534. _fnColumnOptions( oSettings, i );
  5535. }
  5536. }
  5537. } );
  5538. }
  5539. var features = oSettings.oFeatures;
  5540. /* Must be done after everything which can be overridden by the state saving! */
  5541. if ( oInit.bStateSave )
  5542. {
  5543. features.bStateSave = true;
  5544. _fnLoadState( oSettings, oInit );
  5545. _fnCallbackReg( oSettings, 'aoDrawCallback', _fnSaveState, 'state_save' );
  5546. }
  5547. /*
  5548. * Sorting
  5549. * @todo For modularisation (1.11) this needs to do into a sort start up handler
  5550. */
  5551. // If aaSorting is not defined, then we use the first indicator in asSorting
  5552. // in case that has been altered, so the default sort reflects that option
  5553. if ( oInit.aaSorting === undefined )
  5554. {
  5555. var sorting = oSettings.aaSorting;
  5556. for ( i=0, iLen=sorting.length ; i<iLen ; i++ )
  5557. {
  5558. sorting[i][1] = oSettings.aoColumns[ i ].asSorting[0];
  5559. }
  5560. }
  5561. /* Do a first pass on the sorting classes (allows any size changes to be taken into
  5562. * account, and also will apply sorting disabled classes if disabled
  5563. */
  5564. _fnSortingClasses( oSettings );
  5565. if ( features.bSort )
  5566. {
  5567. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  5568. if ( oSettings.bSorted ) {
  5569. var aSort = _fnSortFlatten( oSettings );
  5570. var sortedColumns = {};
  5571. $.each( aSort, function (i, val) {
  5572. sortedColumns[ val.src ] = val.dir;
  5573. } );
  5574. _fnCallbackFire( oSettings, null, 'order', [oSettings, aSort, sortedColumns] );
  5575. _fnSortAria( oSettings );
  5576. }
  5577. } );
  5578. }
  5579. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  5580. if ( oSettings.bSorted || _fnDataSource( oSettings ) === 'ssp' || features.bDeferRender ) {
  5581. _fnSortingClasses( oSettings );
  5582. }
  5583. }, 'sc' );
  5584. /*
  5585. * Final init
  5586. * Cache the header, body and footer as required, creating them if needed
  5587. */
  5588. /* Browser support detection */
  5589. _fnBrowserDetect( oSettings );
  5590. // Work around for Webkit bug 83867 - store the caption-side before removing from doc
  5591. var captions = $this.children('caption').each( function () {
  5592. this._captionSide = $this.css('caption-side');
  5593. } );
  5594. var thead = $this.children('thead');
  5595. if ( thead.length === 0 )
  5596. {
  5597. thead = $('<thead/>').appendTo(this);
  5598. }
  5599. oSettings.nTHead = thead[0];
  5600. var tbody = $this.children('tbody');
  5601. if ( tbody.length === 0 )
  5602. {
  5603. tbody = $('<tbody/>').appendTo(this);
  5604. }
  5605. oSettings.nTBody = tbody[0];
  5606. var tfoot = $this.children('tfoot');
  5607. if ( tfoot.length === 0 && captions.length > 0 && (oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "") )
  5608. {
  5609. // If we are a scrolling table, and no footer has been given, then we need to create
  5610. // a tfoot element for the caption element to be appended to
  5611. tfoot = $('<tfoot/>').appendTo(this);
  5612. }
  5613. if ( tfoot.length === 0 || tfoot.children().length === 0 ) {
  5614. $this.addClass( oClasses.sNoFooter );
  5615. }
  5616. else if ( tfoot.length > 0 ) {
  5617. oSettings.nTFoot = tfoot[0];
  5618. _fnDetectHeader( oSettings.aoFooter, oSettings.nTFoot );
  5619. }
  5620. /* Check if there is data passing into the constructor */
  5621. if ( oInit.aaData )
  5622. {
  5623. for ( i=0 ; i<oInit.aaData.length ; i++ )
  5624. {
  5625. _fnAddData( oSettings, oInit.aaData[ i ] );
  5626. }
  5627. }
  5628. else if ( oSettings.bDeferLoading || _fnDataSource( oSettings ) == 'dom' )
  5629. {
  5630. /* Grab the data from the page - only do this when deferred loading or no Ajax
  5631. * source since there is no point in reading the DOM data if we are then going
  5632. * to replace it with Ajax data
  5633. */
  5634. _fnAddTr( oSettings, $(oSettings.nTBody).children('tr') );
  5635. }
  5636. /* Copy the data index array */
  5637. oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
  5638. /* Initialisation complete - table can be drawn */
  5639. oSettings.bInitialised = true;
  5640. /* Check if we need to initialise the table (it might not have been handed off to the
  5641. * language processor)
  5642. */
  5643. if ( bInitHandedOff === false )
  5644. {
  5645. _fnInitialise( oSettings );
  5646. }
  5647. } );
  5648. _that = null;
  5649. return this;
  5650. };
  5651. /**
  5652. * Computed structure of the DataTables API, defined by the options passed to
  5653. * `DataTable.Api.register()` when building the API.
  5654. *
  5655. * The structure is built in order to speed creation and extension of the Api
  5656. * objects since the extensions are effectively pre-parsed.
  5657. *
  5658. * The array is an array of objects with the following structure, where this
  5659. * base array represents the Api prototype base:
  5660. *
  5661. * [
  5662. * {
  5663. * name: 'data' -- string - Property name
  5664. * val: function () {}, -- function - Api method (or undefined if just an object
  5665. * methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  5666. * propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  5667. * },
  5668. * {
  5669. * name: 'row'
  5670. * val: {},
  5671. * methodExt: [ ... ],
  5672. * propExt: [
  5673. * {
  5674. * name: 'data'
  5675. * val: function () {},
  5676. * methodExt: [ ... ],
  5677. * propExt: [ ... ]
  5678. * },
  5679. * ...
  5680. * ]
  5681. * }
  5682. * ]
  5683. *
  5684. * @type {Array}
  5685. * @ignore
  5686. */
  5687. var __apiStruct = [];
  5688. /**
  5689. * `Array.prototype` reference.
  5690. *
  5691. * @type object
  5692. * @ignore
  5693. */
  5694. var __arrayProto = Array.prototype;
  5695. /**
  5696. * Abstraction for `context` parameter of the `Api` constructor to allow it to
  5697. * take several different forms for ease of use.
  5698. *
  5699. * Each of the input parameter types will be converted to a DataTables settings
  5700. * object where possible.
  5701. *
  5702. * @param {string|node|jQuery|object} mixed DataTable identifier. Can be one
  5703. * of:
  5704. *
  5705. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5706. * with be found and used.
  5707. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5708. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5709. * * `object` - DataTables settings object
  5710. * * `DataTables.Api` - API instance
  5711. * @return {array|null} Matching DataTables settings objects. `null` or
  5712. * `undefined` is returned if no matching DataTable is found.
  5713. * @ignore
  5714. */
  5715. var _toSettings = function ( mixed )
  5716. {
  5717. var idx, jq;
  5718. var settings = DataTable.settings;
  5719. var tables = $.map( settings, function (el, i) {
  5720. return el.nTable;
  5721. } );
  5722. if ( ! mixed ) {
  5723. return [];
  5724. }
  5725. else if ( mixed.nTable && mixed.oApi ) {
  5726. // DataTables settings object
  5727. return [ mixed ];
  5728. }
  5729. else if ( mixed.nodeName && mixed.nodeName.toLowerCase() === 'table' ) {
  5730. // Table node
  5731. idx = $.inArray( mixed, tables );
  5732. return idx !== -1 ? [ settings[idx] ] : null;
  5733. }
  5734. else if ( mixed && typeof mixed.settings === 'function' ) {
  5735. return mixed.settings().toArray();
  5736. }
  5737. else if ( typeof mixed === 'string' ) {
  5738. // jQuery selector
  5739. jq = $(mixed);
  5740. }
  5741. else if ( mixed instanceof $ ) {
  5742. // jQuery object (also DataTables instance)
  5743. jq = mixed;
  5744. }
  5745. if ( jq ) {
  5746. return jq.map( function(i) {
  5747. idx = $.inArray( this, tables );
  5748. return idx !== -1 ? settings[idx] : null;
  5749. } ).toArray();
  5750. }
  5751. };
  5752. /**
  5753. * DataTables API class - used to control and interface with one or more
  5754. * DataTables enhanced tables.
  5755. *
  5756. * The API class is heavily based on jQuery, presenting a chainable interface
  5757. * that you can use to interact with tables. Each instance of the API class has
  5758. * a "context" - i.e. the tables that it will operate on. This could be a single
  5759. * table, all tables on a page or a sub-set thereof.
  5760. *
  5761. * Additionally the API is designed to allow you to easily work with the data in
  5762. * the tables, retrieving and manipulating it as required. This is done by
  5763. * presenting the API class as an array like interface. The contents of the
  5764. * array depend upon the actions requested by each method (for example
  5765. * `rows().nodes()` will return an array of nodes, while `rows().data()` will
  5766. * return an array of objects or arrays depending upon your table's
  5767. * configuration). The API object has a number of array like methods (`push`,
  5768. * `pop`, `reverse` etc) as well as additional helper methods (`each`, `pluck`,
  5769. * `unique` etc) to assist your working with the data held in a table.
  5770. *
  5771. * Most methods (those which return an Api instance) are chainable, which means
  5772. * the return from a method call also has all of the methods available that the
  5773. * top level object had. For example, these two calls are equivalent:
  5774. *
  5775. * // Not chained
  5776. * api.row.add( {...} );
  5777. * api.draw();
  5778. *
  5779. * // Chained
  5780. * api.row.add( {...} ).draw();
  5781. *
  5782. * @class DataTable.Api
  5783. * @param {array|object|string|jQuery} context DataTable identifier. This is
  5784. * used to define which DataTables enhanced tables this API will operate on.
  5785. * Can be one of:
  5786. *
  5787. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5788. * with be found and used.
  5789. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5790. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5791. * * `object` - DataTables settings object
  5792. * @param {array} [data] Data to initialise the Api instance with.
  5793. *
  5794. * @example
  5795. * // Direct initialisation during DataTables construction
  5796. * var api = $('#example').DataTable();
  5797. *
  5798. * @example
  5799. * // Initialisation using a DataTables jQuery object
  5800. * var api = $('#example').dataTable().api();
  5801. *
  5802. * @example
  5803. * // Initialisation as a constructor
  5804. * var api = new $.fn.DataTable.Api( 'table.dataTable' );
  5805. */
  5806. _Api = function ( context, data )
  5807. {
  5808. if ( ! (this instanceof _Api) ) {
  5809. return new _Api( context, data );
  5810. }
  5811. var settings = [];
  5812. var ctxSettings = function ( o ) {
  5813. var a = _toSettings( o );
  5814. if ( a ) {
  5815. settings.push.apply( settings, a );
  5816. }
  5817. };
  5818. if ( $.isArray( context ) ) {
  5819. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  5820. ctxSettings( context[i] );
  5821. }
  5822. }
  5823. else {
  5824. ctxSettings( context );
  5825. }
  5826. // Remove duplicates
  5827. this.context = _unique( settings );
  5828. // Initial data
  5829. if ( data ) {
  5830. this.push.apply( this, data.toArray ? data.toArray() : data );
  5831. }
  5832. // selector
  5833. this.selector = {
  5834. rows: null,
  5835. cols: null,
  5836. opts: null
  5837. };
  5838. _Api.extend( this, this, __apiStruct );
  5839. };
  5840. DataTable.Api = _Api;
  5841. _Api.prototype = /** @lends DataTables.Api */{
  5842. any: function ()
  5843. {
  5844. return this.count() !== 0;
  5845. },
  5846. concat: __arrayProto.concat,
  5847. context: [], // array of table settings objects
  5848. count: function ()
  5849. {
  5850. return this.flatten().length;
  5851. },
  5852. each: function ( fn )
  5853. {
  5854. for ( var i=0, ien=this.length ; i<ien; i++ ) {
  5855. fn.call( this, this[i], i, this );
  5856. }
  5857. return this;
  5858. },
  5859. eq: function ( idx )
  5860. {
  5861. var ctx = this.context;
  5862. return ctx.length > idx ?
  5863. new _Api( ctx[idx], this[idx] ) :
  5864. null;
  5865. },
  5866. filter: function ( fn )
  5867. {
  5868. var a = [];
  5869. if ( __arrayProto.filter ) {
  5870. a = __arrayProto.filter.call( this, fn, this );
  5871. }
  5872. else {
  5873. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  5874. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  5875. if ( fn.call( this, this[i], i, this ) ) {
  5876. a.push( this[i] );
  5877. }
  5878. }
  5879. }
  5880. return new _Api( this.context, a );
  5881. },
  5882. flatten: function ()
  5883. {
  5884. var a = [];
  5885. return new _Api( this.context, a.concat.apply( a, this.toArray() ) );
  5886. },
  5887. join: __arrayProto.join,
  5888. indexOf: __arrayProto.indexOf || function (obj, start)
  5889. {
  5890. for ( var i=(start || 0), ien=this.length ; i<ien ; i++ ) {
  5891. if ( this[i] === obj ) {
  5892. return i;
  5893. }
  5894. }
  5895. return -1;
  5896. },
  5897. iterator: function ( flatten, type, fn, alwaysNew ) {
  5898. var
  5899. a = [], ret,
  5900. i, ien, j, jen,
  5901. context = this.context,
  5902. rows, items, item,
  5903. selector = this.selector;
  5904. // Argument shifting
  5905. if ( typeof flatten === 'string' ) {
  5906. alwaysNew = fn;
  5907. fn = type;
  5908. type = flatten;
  5909. flatten = false;
  5910. }
  5911. for ( i=0, ien=context.length ; i<ien ; i++ ) {
  5912. var apiInst = new _Api( context[i] );
  5913. if ( type === 'table' ) {
  5914. ret = fn.call( apiInst, context[i], i );
  5915. if ( ret !== undefined ) {
  5916. a.push( ret );
  5917. }
  5918. }
  5919. else if ( type === 'columns' || type === 'rows' ) {
  5920. // this has same length as context - one entry for each table
  5921. ret = fn.call( apiInst, context[i], this[i], i );
  5922. if ( ret !== undefined ) {
  5923. a.push( ret );
  5924. }
  5925. }
  5926. else if ( type === 'column' || type === 'column-rows' || type === 'row' || type === 'cell' ) {
  5927. // columns and rows share the same structure.
  5928. // 'this' is an array of column indexes for each context
  5929. items = this[i];
  5930. if ( type === 'column-rows' ) {
  5931. rows = _selector_row_indexes( context[i], selector.opts );
  5932. }
  5933. for ( j=0, jen=items.length ; j<jen ; j++ ) {
  5934. item = items[j];
  5935. if ( type === 'cell' ) {
  5936. ret = fn.call( apiInst, context[i], item.row, item.column, i, j );
  5937. }
  5938. else {
  5939. ret = fn.call( apiInst, context[i], item, i, j, rows );
  5940. }
  5941. if ( ret !== undefined ) {
  5942. a.push( ret );
  5943. }
  5944. }
  5945. }
  5946. }
  5947. if ( a.length || alwaysNew ) {
  5948. var api = new _Api( context, flatten ? a.concat.apply( [], a ) : a );
  5949. var apiSelector = api.selector;
  5950. apiSelector.rows = selector.rows;
  5951. apiSelector.cols = selector.cols;
  5952. apiSelector.opts = selector.opts;
  5953. return api;
  5954. }
  5955. return this;
  5956. },
  5957. lastIndexOf: __arrayProto.lastIndexOf || function (obj, start)
  5958. {
  5959. // Bit cheeky...
  5960. return this.indexOf.apply( this.toArray.reverse(), arguments );
  5961. },
  5962. length: 0,
  5963. map: function ( fn )
  5964. {
  5965. var a = [];
  5966. if ( __arrayProto.map ) {
  5967. a = __arrayProto.map.call( this, fn, this );
  5968. }
  5969. else {
  5970. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  5971. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  5972. a.push( fn.call( this, this[i], i ) );
  5973. }
  5974. }
  5975. return new _Api( this.context, a );
  5976. },
  5977. pluck: function ( prop )
  5978. {
  5979. return this.map( function ( el ) {
  5980. return el[ prop ];
  5981. } );
  5982. },
  5983. pop: __arrayProto.pop,
  5984. push: __arrayProto.push,
  5985. // Does not return an API instance
  5986. reduce: __arrayProto.reduce || function ( fn, init )
  5987. {
  5988. return _fnReduce( this, fn, init, 0, this.length, 1 );
  5989. },
  5990. reduceRight: __arrayProto.reduceRight || function ( fn, init )
  5991. {
  5992. return _fnReduce( this, fn, init, this.length-1, -1, -1 );
  5993. },
  5994. reverse: __arrayProto.reverse,
  5995. // Object with rows, columns and opts
  5996. selector: null,
  5997. shift: __arrayProto.shift,
  5998. sort: __arrayProto.sort, // ? name - order?
  5999. splice: __arrayProto.splice,
  6000. toArray: function ()
  6001. {
  6002. return __arrayProto.slice.call( this );
  6003. },
  6004. to$: function ()
  6005. {
  6006. return $( this );
  6007. },
  6008. toJQuery: function ()
  6009. {
  6010. return $( this );
  6011. },
  6012. unique: function ()
  6013. {
  6014. return new _Api( this.context, _unique(this) );
  6015. },
  6016. unshift: __arrayProto.unshift
  6017. };
  6018. _Api.extend = function ( scope, obj, ext )
  6019. {
  6020. // Only extend API instances and static properties of the API
  6021. if ( ! ext.length || ! obj || ( ! (obj instanceof _Api) && ! obj.__dt_wrapper ) ) {
  6022. return;
  6023. }
  6024. var
  6025. i, ien,
  6026. j, jen,
  6027. struct, inner,
  6028. methodScoping = function ( scope, fn, struc ) {
  6029. return function () {
  6030. var ret = fn.apply( scope, arguments );
  6031. // Method extension
  6032. _Api.extend( ret, ret, struc.methodExt );
  6033. return ret;
  6034. };
  6035. };
  6036. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  6037. struct = ext[i];
  6038. // Value
  6039. obj[ struct.name ] = typeof struct.val === 'function' ?
  6040. methodScoping( scope, struct.val, struct ) :
  6041. $.isPlainObject( struct.val ) ?
  6042. {} :
  6043. struct.val;
  6044. obj[ struct.name ].__dt_wrapper = true;
  6045. // Property extension
  6046. _Api.extend( scope, obj[ struct.name ], struct.propExt );
  6047. }
  6048. };
  6049. // @todo - Is there need for an augment function?
  6050. // _Api.augment = function ( inst, name )
  6051. // {
  6052. // // Find src object in the structure from the name
  6053. // var parts = name.split('.');
  6054. // _Api.extend( inst, obj );
  6055. // };
  6056. // [
  6057. // {
  6058. // name: 'data' -- string - Property name
  6059. // val: function () {}, -- function - Api method (or undefined if just an object
  6060. // methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  6061. // propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  6062. // },
  6063. // {
  6064. // name: 'row'
  6065. // val: {},
  6066. // methodExt: [ ... ],
  6067. // propExt: [
  6068. // {
  6069. // name: 'data'
  6070. // val: function () {},
  6071. // methodExt: [ ... ],
  6072. // propExt: [ ... ]
  6073. // },
  6074. // ...
  6075. // ]
  6076. // }
  6077. // ]
  6078. _Api.register = _api_register = function ( name, val )
  6079. {
  6080. if ( $.isArray( name ) ) {
  6081. for ( var j=0, jen=name.length ; j<jen ; j++ ) {
  6082. _Api.register( name[j], val );
  6083. }
  6084. return;
  6085. }
  6086. var
  6087. i, ien,
  6088. heir = name.split('.'),
  6089. struct = __apiStruct,
  6090. key, method;
  6091. var find = function ( src, name ) {
  6092. for ( var i=0, ien=src.length ; i<ien ; i++ ) {
  6093. if ( src[i].name === name ) {
  6094. return src[i];
  6095. }
  6096. }
  6097. return null;
  6098. };
  6099. for ( i=0, ien=heir.length ; i<ien ; i++ ) {
  6100. method = heir[i].indexOf('()') !== -1;
  6101. key = method ?
  6102. heir[i].replace('()', '') :
  6103. heir[i];
  6104. var src = find( struct, key );
  6105. if ( ! src ) {
  6106. src = {
  6107. name: key,
  6108. val: {},
  6109. methodExt: [],
  6110. propExt: []
  6111. };
  6112. struct.push( src );
  6113. }
  6114. if ( i === ien-1 ) {
  6115. src.val = val;
  6116. }
  6117. else {
  6118. struct = method ?
  6119. src.methodExt :
  6120. src.propExt;
  6121. }
  6122. }
  6123. };
  6124. _Api.registerPlural = _api_registerPlural = function ( pluralName, singularName, val ) {
  6125. _Api.register( pluralName, val );
  6126. _Api.register( singularName, function () {
  6127. var ret = val.apply( this, arguments );
  6128. if ( ret === this ) {
  6129. // Returned item is the API instance that was passed in, return it
  6130. return this;
  6131. }
  6132. else if ( ret instanceof _Api ) {
  6133. // New API instance returned, want the value from the first item
  6134. // in the returned array for the singular result.
  6135. return ret.length ?
  6136. $.isArray( ret[0] ) ?
  6137. new _Api( ret.context, ret[0] ) : // Array results are 'enhanced'
  6138. ret[0] :
  6139. undefined;
  6140. }
  6141. // Non-API return - just fire it back
  6142. return ret;
  6143. } );
  6144. };
  6145. /**
  6146. * Selector for HTML tables. Apply the given selector to the give array of
  6147. * DataTables settings objects.
  6148. *
  6149. * @param {string|integer} [selector] jQuery selector string or integer
  6150. * @param {array} Array of DataTables settings objects to be filtered
  6151. * @return {array}
  6152. * @ignore
  6153. */
  6154. var __table_selector = function ( selector, a )
  6155. {
  6156. // Integer is used to pick out a table by index
  6157. if ( typeof selector === 'number' ) {
  6158. return [ a[ selector ] ];
  6159. }
  6160. // Perform a jQuery selector on the table nodes
  6161. var nodes = $.map( a, function (el, i) {
  6162. return el.nTable;
  6163. } );
  6164. return $(nodes)
  6165. .filter( selector )
  6166. .map( function (i) {
  6167. // Need to translate back from the table node to the settings
  6168. var idx = $.inArray( this, nodes );
  6169. return a[ idx ];
  6170. } )
  6171. .toArray();
  6172. };
  6173. /**
  6174. * Context selector for the API's context (i.e. the tables the API instance
  6175. * refers to.
  6176. *
  6177. * @name DataTable.Api#tables
  6178. * @param {string|integer} [selector] Selector to pick which tables the iterator
  6179. * should operate on. If not given, all tables in the current context are
  6180. * used. This can be given as a jQuery selector (for example `':gt(0)'`) to
  6181. * select multiple tables or as an integer to select a single table.
  6182. * @returns {DataTable.Api} Returns a new API instance if a selector is given.
  6183. */
  6184. _api_register( 'tables()', function ( selector ) {
  6185. // A new instance is created if there was a selector specified
  6186. return selector ?
  6187. new _Api( __table_selector( selector, this.context ) ) :
  6188. this;
  6189. } );
  6190. _api_register( 'table()', function ( selector ) {
  6191. var tables = this.tables( selector );
  6192. var ctx = tables.context;
  6193. // Truncate to the first matched table
  6194. return ctx.length ?
  6195. new _Api( ctx[0] ) :
  6196. tables;
  6197. } );
  6198. _api_registerPlural( 'tables().nodes()', 'table().node()' , function () {
  6199. return this.iterator( 'table', function ( ctx ) {
  6200. return ctx.nTable;
  6201. }, 1 );
  6202. } );
  6203. _api_registerPlural( 'tables().body()', 'table().body()' , function () {
  6204. return this.iterator( 'table', function ( ctx ) {
  6205. return ctx.nTBody;
  6206. }, 1 );
  6207. } );
  6208. _api_registerPlural( 'tables().header()', 'table().header()' , function () {
  6209. return this.iterator( 'table', function ( ctx ) {
  6210. return ctx.nTHead;
  6211. }, 1 );
  6212. } );
  6213. _api_registerPlural( 'tables().footer()', 'table().footer()' , function () {
  6214. return this.iterator( 'table', function ( ctx ) {
  6215. return ctx.nTFoot;
  6216. }, 1 );
  6217. } );
  6218. _api_registerPlural( 'tables().containers()', 'table().container()' , function () {
  6219. return this.iterator( 'table', function ( ctx ) {
  6220. return ctx.nTableWrapper;
  6221. }, 1 );
  6222. } );
  6223. /**
  6224. * Redraw the tables in the current context.
  6225. */
  6226. _api_register( 'draw()', function ( paging ) {
  6227. return this.iterator( 'table', function ( settings ) {
  6228. if ( paging === 'page' ) {
  6229. _fnDraw( settings );
  6230. }
  6231. else {
  6232. if ( typeof paging === 'string' ) {
  6233. paging = paging === 'full-hold' ?
  6234. false :
  6235. true;
  6236. }
  6237. _fnReDraw( settings, paging===false );
  6238. }
  6239. } );
  6240. } );
  6241. /**
  6242. * Get the current page index.
  6243. *
  6244. * @return {integer} Current page index (zero based)
  6245. *//**
  6246. * Set the current page.
  6247. *
  6248. * Note that if you attempt to show a page which does not exist, DataTables will
  6249. * not throw an error, but rather reset the paging.
  6250. *
  6251. * @param {integer|string} action The paging action to take. This can be one of:
  6252. * * `integer` - The page index to jump to
  6253. * * `string` - An action to take:
  6254. * * `first` - Jump to first page.
  6255. * * `next` - Jump to the next page
  6256. * * `previous` - Jump to previous page
  6257. * * `last` - Jump to the last page.
  6258. * @returns {DataTables.Api} this
  6259. */
  6260. _api_register( 'page()', function ( action ) {
  6261. if ( action === undefined ) {
  6262. return this.page.info().page; // not an expensive call
  6263. }
  6264. // else, have an action to take on all tables
  6265. return this.iterator( 'table', function ( settings ) {
  6266. _fnPageChange( settings, action );
  6267. } );
  6268. } );
  6269. /**
  6270. * Paging information for the first table in the current context.
  6271. *
  6272. * If you require paging information for another table, use the `table()` method
  6273. * with a suitable selector.
  6274. *
  6275. * @return {object} Object with the following properties set:
  6276. * * `page` - Current page index (zero based - i.e. the first page is `0`)
  6277. * * `pages` - Total number of pages
  6278. * * `start` - Display index for the first record shown on the current page
  6279. * * `end` - Display index for the last record shown on the current page
  6280. * * `length` - Display length (number of records). Note that generally `start
  6281. * + length = end`, but this is not always true, for example if there are
  6282. * only 2 records to show on the final page, with a length of 10.
  6283. * * `recordsTotal` - Full data set length
  6284. * * `recordsDisplay` - Data set length once the current filtering criterion
  6285. * are applied.
  6286. */
  6287. _api_register( 'page.info()', function ( action ) {
  6288. if ( this.context.length === 0 ) {
  6289. return undefined;
  6290. }
  6291. var
  6292. settings = this.context[0],
  6293. start = settings._iDisplayStart,
  6294. len = settings._iDisplayLength,
  6295. visRecords = settings.fnRecordsDisplay(),
  6296. all = len === -1;
  6297. return {
  6298. "page": all ? 0 : Math.floor( start / len ),
  6299. "pages": all ? 1 : Math.ceil( visRecords / len ),
  6300. "start": start,
  6301. "end": settings.fnDisplayEnd(),
  6302. "length": len,
  6303. "recordsTotal": settings.fnRecordsTotal(),
  6304. "recordsDisplay": visRecords,
  6305. "serverSide": _fnDataSource( settings ) === 'ssp'
  6306. };
  6307. } );
  6308. /**
  6309. * Get the current page length.
  6310. *
  6311. * @return {integer} Current page length. Note `-1` indicates that all records
  6312. * are to be shown.
  6313. *//**
  6314. * Set the current page length.
  6315. *
  6316. * @param {integer} Page length to set. Use `-1` to show all records.
  6317. * @returns {DataTables.Api} this
  6318. */
  6319. _api_register( 'page.len()', function ( len ) {
  6320. // Note that we can't call this function 'length()' because `length`
  6321. // is a Javascript property of functions which defines how many arguments
  6322. // the function expects.
  6323. if ( len === undefined ) {
  6324. return this.context.length !== 0 ?
  6325. this.context[0]._iDisplayLength :
  6326. undefined;
  6327. }
  6328. // else, set the page length
  6329. return this.iterator( 'table', function ( settings ) {
  6330. _fnLengthChange( settings, len );
  6331. } );
  6332. } );
  6333. var __reload = function ( settings, holdPosition, callback ) {
  6334. // Use the draw event to trigger a callback
  6335. if ( callback ) {
  6336. var api = new _Api( settings );
  6337. api.one( 'draw', function () {
  6338. callback( api.ajax.json() );
  6339. } );
  6340. }
  6341. if ( _fnDataSource( settings ) == 'ssp' ) {
  6342. _fnReDraw( settings, holdPosition );
  6343. }
  6344. else {
  6345. _fnProcessingDisplay( settings, true );
  6346. // Cancel an existing request
  6347. var xhr = settings.jqXHR;
  6348. if ( xhr && xhr.readyState !== 4 ) {
  6349. xhr.abort();
  6350. }
  6351. // Trigger xhr
  6352. _fnBuildAjax( settings, [], function( json ) {
  6353. _fnClearTable( settings );
  6354. var data = _fnAjaxDataSrc( settings, json );
  6355. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6356. _fnAddData( settings, data[i] );
  6357. }
  6358. _fnReDraw( settings, holdPosition );
  6359. _fnProcessingDisplay( settings, false );
  6360. } );
  6361. }
  6362. };
  6363. /**
  6364. * Get the JSON response from the last Ajax request that DataTables made to the
  6365. * server. Note that this returns the JSON from the first table in the current
  6366. * context.
  6367. *
  6368. * @return {object} JSON received from the server.
  6369. */
  6370. _api_register( 'ajax.json()', function () {
  6371. var ctx = this.context;
  6372. if ( ctx.length > 0 ) {
  6373. return ctx[0].json;
  6374. }
  6375. // else return undefined;
  6376. } );
  6377. /**
  6378. * Get the data submitted in the last Ajax request
  6379. */
  6380. _api_register( 'ajax.params()', function () {
  6381. var ctx = this.context;
  6382. if ( ctx.length > 0 ) {
  6383. return ctx[0].oAjaxData;
  6384. }
  6385. // else return undefined;
  6386. } );
  6387. /**
  6388. * Reload tables from the Ajax data source. Note that this function will
  6389. * automatically re-draw the table when the remote data has been loaded.
  6390. *
  6391. * @param {boolean} [reset=true] Reset (default) or hold the current paging
  6392. * position. A full re-sort and re-filter is performed when this method is
  6393. * called, which is why the pagination reset is the default action.
  6394. * @returns {DataTables.Api} this
  6395. */
  6396. _api_register( 'ajax.reload()', function ( callback, resetPaging ) {
  6397. return this.iterator( 'table', function (settings) {
  6398. __reload( settings, resetPaging===false, callback );
  6399. } );
  6400. } );
  6401. /**
  6402. * Get the current Ajax URL. Note that this returns the URL from the first
  6403. * table in the current context.
  6404. *
  6405. * @return {string} Current Ajax source URL
  6406. *//**
  6407. * Set the Ajax URL. Note that this will set the URL for all tables in the
  6408. * current context.
  6409. *
  6410. * @param {string} url URL to set.
  6411. * @returns {DataTables.Api} this
  6412. */
  6413. _api_register( 'ajax.url()', function ( url ) {
  6414. var ctx = this.context;
  6415. if ( url === undefined ) {
  6416. // get
  6417. if ( ctx.length === 0 ) {
  6418. return undefined;
  6419. }
  6420. ctx = ctx[0];
  6421. return ctx.ajax ?
  6422. $.isPlainObject( ctx.ajax ) ?
  6423. ctx.ajax.url :
  6424. ctx.ajax :
  6425. ctx.sAjaxSource;
  6426. }
  6427. // set
  6428. return this.iterator( 'table', function ( settings ) {
  6429. if ( $.isPlainObject( settings.ajax ) ) {
  6430. settings.ajax.url = url;
  6431. }
  6432. else {
  6433. settings.ajax = url;
  6434. }
  6435. // No need to consider sAjaxSource here since DataTables gives priority
  6436. // to `ajax` over `sAjaxSource`. So setting `ajax` here, renders any
  6437. // value of `sAjaxSource` redundant.
  6438. } );
  6439. } );
  6440. /**
  6441. * Load data from the newly set Ajax URL. Note that this method is only
  6442. * available when `ajax.url()` is used to set a URL. Additionally, this method
  6443. * has the same effect as calling `ajax.reload()` but is provided for
  6444. * convenience when setting a new URL. Like `ajax.reload()` it will
  6445. * automatically redraw the table once the remote data has been loaded.
  6446. *
  6447. * @returns {DataTables.Api} this
  6448. */
  6449. _api_register( 'ajax.url().load()', function ( callback, resetPaging ) {
  6450. // Same as a reload, but makes sense to present it for easy access after a
  6451. // url change
  6452. return this.iterator( 'table', function ( ctx ) {
  6453. __reload( ctx, resetPaging===false, callback );
  6454. } );
  6455. } );
  6456. var _selector_run = function ( type, selector, selectFn, settings, opts )
  6457. {
  6458. var
  6459. out = [], res,
  6460. a, i, ien, j, jen,
  6461. selectorType = typeof selector;
  6462. // Can't just check for isArray here, as an API or jQuery instance might be
  6463. // given with their array like look
  6464. if ( ! selector || selectorType === 'string' || selectorType === 'function' || selector.length === undefined ) {
  6465. selector = [ selector ];
  6466. }
  6467. for ( i=0, ien=selector.length ; i<ien ; i++ ) {
  6468. a = selector[i] && selector[i].split ?
  6469. selector[i].split(',') :
  6470. [ selector[i] ];
  6471. for ( j=0, jen=a.length ; j<jen ; j++ ) {
  6472. res = selectFn( typeof a[j] === 'string' ? $.trim(a[j]) : a[j] );
  6473. if ( res && res.length ) {
  6474. out.push.apply( out, res );
  6475. }
  6476. }
  6477. }
  6478. // selector extensions
  6479. var ext = _ext.selector[ type ];
  6480. if ( ext.length ) {
  6481. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  6482. out = ext[i]( settings, opts, out );
  6483. }
  6484. }
  6485. return out;
  6486. };
  6487. var _selector_opts = function ( opts )
  6488. {
  6489. if ( ! opts ) {
  6490. opts = {};
  6491. }
  6492. // Backwards compatibility for 1.9- which used the terminology filter rather
  6493. // than search
  6494. if ( opts.filter && opts.search === undefined ) {
  6495. opts.search = opts.filter;
  6496. }
  6497. return $.extend( {
  6498. search: 'none',
  6499. order: 'current',
  6500. page: 'all'
  6501. }, opts );
  6502. };
  6503. var _selector_first = function ( inst )
  6504. {
  6505. // Reduce the API instance to the first item found
  6506. for ( var i=0, ien=inst.length ; i<ien ; i++ ) {
  6507. if ( inst[i].length > 0 ) {
  6508. // Assign the first element to the first item in the instance
  6509. // and truncate the instance and context
  6510. inst[0] = inst[i];
  6511. inst[0].length = 1;
  6512. inst.length = 1;
  6513. inst.context = [ inst.context[i] ];
  6514. return inst;
  6515. }
  6516. }
  6517. // Not found - return an empty instance
  6518. inst.length = 0;
  6519. return inst;
  6520. };
  6521. var _selector_row_indexes = function ( settings, opts )
  6522. {
  6523. var
  6524. i, ien, tmp, a=[],
  6525. displayFiltered = settings.aiDisplay,
  6526. displayMaster = settings.aiDisplayMaster;
  6527. var
  6528. search = opts.search, // none, applied, removed
  6529. order = opts.order, // applied, current, index (original - compatibility with 1.9)
  6530. page = opts.page; // all, current
  6531. if ( _fnDataSource( settings ) == 'ssp' ) {
  6532. // In server-side processing mode, most options are irrelevant since
  6533. // rows not shown don't exist and the index order is the applied order
  6534. // Removed is a special case - for consistency just return an empty
  6535. // array
  6536. return search === 'removed' ?
  6537. [] :
  6538. _range( 0, displayMaster.length );
  6539. }
  6540. else if ( page == 'current' ) {
  6541. // Current page implies that order=current and fitler=applied, since it is
  6542. // fairly senseless otherwise, regardless of what order and search actually
  6543. // are
  6544. for ( i=settings._iDisplayStart, ien=settings.fnDisplayEnd() ; i<ien ; i++ ) {
  6545. a.push( displayFiltered[i] );
  6546. }
  6547. }
  6548. else if ( order == 'current' || order == 'applied' ) {
  6549. a = search == 'none' ?
  6550. displayMaster.slice() : // no search
  6551. search == 'applied' ?
  6552. displayFiltered.slice() : // applied search
  6553. $.map( displayMaster, function (el, i) { // removed search
  6554. return $.inArray( el, displayFiltered ) === -1 ? el : null;
  6555. } );
  6556. }
  6557. else if ( order == 'index' || order == 'original' ) {
  6558. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  6559. if ( search == 'none' ) {
  6560. a.push( i );
  6561. }
  6562. else { // applied | removed
  6563. tmp = $.inArray( i, displayFiltered );
  6564. if ((tmp === -1 && search == 'removed') ||
  6565. (tmp >= 0 && search == 'applied') )
  6566. {
  6567. a.push( i );
  6568. }
  6569. }
  6570. }
  6571. }
  6572. return a;
  6573. };
  6574. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6575. * Rows
  6576. *
  6577. * {} - no selector - use all available rows
  6578. * {integer} - row aoData index
  6579. * {node} - TR node
  6580. * {string} - jQuery selector to apply to the TR elements
  6581. * {array} - jQuery array of nodes, or simply an array of TR nodes
  6582. *
  6583. */
  6584. var __row_selector = function ( settings, selector, opts )
  6585. {
  6586. var run = function ( sel ) {
  6587. var selInt = _intVal( sel );
  6588. var i, ien;
  6589. // Short cut - selector is a number and no options provided (default is
  6590. // all records, so no need to check if the index is in there, since it
  6591. // must be - dev error if the index doesn't exist).
  6592. if ( selInt !== null && ! opts ) {
  6593. return [ selInt ];
  6594. }
  6595. var rows = _selector_row_indexes( settings, opts );
  6596. if ( selInt !== null && $.inArray( selInt, rows ) !== -1 ) {
  6597. // Selector - integer
  6598. return [ selInt ];
  6599. }
  6600. else if ( ! sel ) {
  6601. // Selector - none
  6602. return rows;
  6603. }
  6604. // Selector - function
  6605. if ( typeof sel === 'function' ) {
  6606. return $.map( rows, function (idx) {
  6607. var row = settings.aoData[ idx ];
  6608. return sel( idx, row._aData, row.nTr ) ? idx : null;
  6609. } );
  6610. }
  6611. // Get nodes in the order from the `rows` array with null values removed
  6612. var nodes = _removeEmpty(
  6613. _pluck_order( settings.aoData, rows, 'nTr' )
  6614. );
  6615. // Selector - node
  6616. if ( sel.nodeName ) {
  6617. if ( $.inArray( sel, nodes ) !== -1 ) {
  6618. return [ sel._DT_RowIndex ]; // sel is a TR node that is in the table
  6619. // and DataTables adds a prop for fast lookup
  6620. }
  6621. }
  6622. // ID selector. Want to always be able to select rows by id, regardless
  6623. // of if the tr element has been created or not, so can't rely upon
  6624. // jQuery here - hence a custom implementation. This does not match
  6625. // Sizzle's fast selector or HTML4 - in HTML5 the ID can be anything,
  6626. // but to select it using a CSS selector engine (like Sizzle or
  6627. // querySelect) it would need to need to be escaped for some characters.
  6628. // DataTables simplifies this for row selectors since you can select
  6629. // only a row. A # indicates an id any anything that follows is the id -
  6630. // unescaped.
  6631. if ( typeof sel === 'string' && sel.charAt(0) === '#' ) {
  6632. // get row index from id
  6633. var rowObj = settings.aIds[ sel.replace( /^#/, '' ) ];
  6634. if ( rowObj !== undefined ) {
  6635. return [ rowObj.idx ];
  6636. }
  6637. // need to fall through to jQuery in case there is DOM id that
  6638. // matches
  6639. }
  6640. // Selector - jQuery selector string, array of nodes or jQuery object/
  6641. // As jQuery's .filter() allows jQuery objects to be passed in filter,
  6642. // it also allows arrays, so this will cope with all three options
  6643. return $(nodes)
  6644. .filter( sel )
  6645. .map( function () {
  6646. return this._DT_RowIndex;
  6647. } )
  6648. .toArray();
  6649. };
  6650. return _selector_run( 'row', selector, run, settings, opts );
  6651. };
  6652. _api_register( 'rows()', function ( selector, opts ) {
  6653. // argument shifting
  6654. if ( selector === undefined ) {
  6655. selector = '';
  6656. }
  6657. else if ( $.isPlainObject( selector ) ) {
  6658. opts = selector;
  6659. selector = '';
  6660. }
  6661. opts = _selector_opts( opts );
  6662. var inst = this.iterator( 'table', function ( settings ) {
  6663. return __row_selector( settings, selector, opts );
  6664. }, 1 );
  6665. // Want argument shifting here and in __row_selector?
  6666. inst.selector.rows = selector;
  6667. inst.selector.opts = opts;
  6668. return inst;
  6669. } );
  6670. _api_register( 'rows().nodes()', function () {
  6671. return this.iterator( 'row', function ( settings, row ) {
  6672. return settings.aoData[ row ].nTr || undefined;
  6673. }, 1 );
  6674. } );
  6675. _api_register( 'rows().data()', function () {
  6676. return this.iterator( true, 'rows', function ( settings, rows ) {
  6677. return _pluck_order( settings.aoData, rows, '_aData' );
  6678. }, 1 );
  6679. } );
  6680. _api_registerPlural( 'rows().cache()', 'row().cache()', function ( type ) {
  6681. return this.iterator( 'row', function ( settings, row ) {
  6682. var r = settings.aoData[ row ];
  6683. return type === 'search' ? r._aFilterData : r._aSortData;
  6684. }, 1 );
  6685. } );
  6686. _api_registerPlural( 'rows().invalidate()', 'row().invalidate()', function ( src ) {
  6687. return this.iterator( 'row', function ( settings, row ) {
  6688. _fnInvalidate( settings, row, src );
  6689. } );
  6690. } );
  6691. _api_registerPlural( 'rows().indexes()', 'row().index()', function () {
  6692. return this.iterator( 'row', function ( settings, row ) {
  6693. return row;
  6694. }, 1 );
  6695. } );
  6696. _api_registerPlural( 'rows().ids()', 'row().id()', function ( hash ) {
  6697. var a = [];
  6698. var context = this.context;
  6699. // `iterator` will drop undefined values, but in this case we want them
  6700. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  6701. for ( var j=0, jen=this[i].length ; j<jen ; j++ ) {
  6702. var id = context[i].rowIdFn( context[i].aoData[ this[i][j] ]._aData );
  6703. a.push( (hash === true ? '#' : '' )+ id );
  6704. }
  6705. }
  6706. return new _Api( context, a );
  6707. } );
  6708. _api_registerPlural( 'rows().remove()', 'row().remove()', function () {
  6709. var that = this;
  6710. this.iterator( 'row', function ( settings, row, thatIdx ) {
  6711. var data = settings.aoData;
  6712. data.splice( row, 1 );
  6713. // Update the _DT_RowIndex parameter on all rows in the table
  6714. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6715. if ( data[i].nTr !== null ) {
  6716. data[i].nTr._DT_RowIndex = i;
  6717. }
  6718. }
  6719. // Delete from the display arrays
  6720. _fnDeleteIndex( settings.aiDisplayMaster, row );
  6721. _fnDeleteIndex( settings.aiDisplay, row );
  6722. _fnDeleteIndex( that[ thatIdx ], row, false ); // maintain local indexes
  6723. // Check for an 'overflow' they case for displaying the table
  6724. _fnLengthOverflow( settings );
  6725. } );
  6726. this.iterator( 'table', function ( settings ) {
  6727. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  6728. settings.aoData[i].idx = i;
  6729. }
  6730. } );
  6731. return this;
  6732. } );
  6733. _api_register( 'rows.add()', function ( rows ) {
  6734. var newRows = this.iterator( 'table', function ( settings ) {
  6735. var row, i, ien;
  6736. var out = [];
  6737. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  6738. row = rows[i];
  6739. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  6740. out.push( _fnAddTr( settings, row )[0] );
  6741. }
  6742. else {
  6743. out.push( _fnAddData( settings, row ) );
  6744. }
  6745. }
  6746. return out;
  6747. }, 1 );
  6748. // Return an Api.rows() extended instance, so rows().nodes() etc can be used
  6749. var modRows = this.rows( -1 );
  6750. modRows.pop();
  6751. modRows.push.apply( modRows, newRows.toArray() );
  6752. return modRows;
  6753. } );
  6754. /**
  6755. *
  6756. */
  6757. _api_register( 'row()', function ( selector, opts ) {
  6758. return _selector_first( this.rows( selector, opts ) );
  6759. } );
  6760. _api_register( 'row().data()', function ( data ) {
  6761. var ctx = this.context;
  6762. if ( data === undefined ) {
  6763. // Get
  6764. return ctx.length && this.length ?
  6765. ctx[0].aoData[ this[0] ]._aData :
  6766. undefined;
  6767. }
  6768. // Set
  6769. ctx[0].aoData[ this[0] ]._aData = data;
  6770. // Automatically invalidate
  6771. _fnInvalidate( ctx[0], this[0], 'data' );
  6772. return this;
  6773. } );
  6774. _api_register( 'row().node()', function () {
  6775. var ctx = this.context;
  6776. return ctx.length && this.length ?
  6777. ctx[0].aoData[ this[0] ].nTr || null :
  6778. null;
  6779. } );
  6780. _api_register( 'row.add()', function ( row ) {
  6781. // Allow a jQuery object to be passed in - only a single row is added from
  6782. // it though - the first element in the set
  6783. if ( row instanceof $ && row.length ) {
  6784. row = row[0];
  6785. }
  6786. var rows = this.iterator( 'table', function ( settings ) {
  6787. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  6788. return _fnAddTr( settings, row )[0];
  6789. }
  6790. return _fnAddData( settings, row );
  6791. } );
  6792. // Return an Api.rows() extended instance, with the newly added row selected
  6793. return this.row( rows[0] );
  6794. } );
  6795. var __details_add = function ( ctx, row, data, klass )
  6796. {
  6797. // Convert to array of TR elements
  6798. var rows = [];
  6799. var addRow = function ( r, k ) {
  6800. // Recursion to allow for arrays of jQuery objects
  6801. if ( $.isArray( r ) || r instanceof $ ) {
  6802. for ( var i=0, ien=r.length ; i<ien ; i++ ) {
  6803. addRow( r[i], k );
  6804. }
  6805. return;
  6806. }
  6807. // If we get a TR element, then just add it directly - up to the dev
  6808. // to add the correct number of columns etc
  6809. if ( r.nodeName && r.nodeName.toLowerCase() === 'tr' ) {
  6810. rows.push( r );
  6811. }
  6812. else {
  6813. // Otherwise create a row with a wrapper
  6814. var created = $('<tr><td/></tr>').addClass( k );
  6815. $('td', created)
  6816. .addClass( k )
  6817. .html( r )
  6818. [0].colSpan = _fnVisbleColumns( ctx );
  6819. rows.push( created[0] );
  6820. }
  6821. };
  6822. addRow( data, klass );
  6823. if ( row._details ) {
  6824. row._details.remove();
  6825. }
  6826. row._details = $(rows);
  6827. // If the children were already shown, that state should be retained
  6828. if ( row._detailsShow ) {
  6829. row._details.insertAfter( row.nTr );
  6830. }
  6831. };
  6832. var __details_remove = function ( api, idx )
  6833. {
  6834. var ctx = api.context;
  6835. if ( ctx.length ) {
  6836. var row = ctx[0].aoData[ idx !== undefined ? idx : api[0] ];
  6837. if ( row && row._details ) {
  6838. row._details.remove();
  6839. row._detailsShow = undefined;
  6840. row._details = undefined;
  6841. }
  6842. }
  6843. };
  6844. var __details_display = function ( api, show ) {
  6845. var ctx = api.context;
  6846. if ( ctx.length && api.length ) {
  6847. var row = ctx[0].aoData[ api[0] ];
  6848. if ( row._details ) {
  6849. row._detailsShow = show;
  6850. if ( show ) {
  6851. row._details.insertAfter( row.nTr );
  6852. }
  6853. else {
  6854. row._details.detach();
  6855. }
  6856. __details_events( ctx[0] );
  6857. }
  6858. }
  6859. };
  6860. var __details_events = function ( settings )
  6861. {
  6862. var api = new _Api( settings );
  6863. var namespace = '.dt.DT_details';
  6864. var drawEvent = 'draw'+namespace;
  6865. var colvisEvent = 'column-visibility'+namespace;
  6866. var destroyEvent = 'destroy'+namespace;
  6867. var data = settings.aoData;
  6868. api.off( drawEvent +' '+ colvisEvent +' '+ destroyEvent );
  6869. if ( _pluck( data, '_details' ).length > 0 ) {
  6870. // On each draw, insert the required elements into the document
  6871. api.on( drawEvent, function ( e, ctx ) {
  6872. if ( settings !== ctx ) {
  6873. return;
  6874. }
  6875. api.rows( {page:'current'} ).eq(0).each( function (idx) {
  6876. // Internal data grab
  6877. var row = data[ idx ];
  6878. if ( row._detailsShow ) {
  6879. row._details.insertAfter( row.nTr );
  6880. }
  6881. } );
  6882. } );
  6883. // Column visibility change - update the colspan
  6884. api.on( colvisEvent, function ( e, ctx, idx, vis ) {
  6885. if ( settings !== ctx ) {
  6886. return;
  6887. }
  6888. // Update the colspan for the details rows (note, only if it already has
  6889. // a colspan)
  6890. var row, visible = _fnVisbleColumns( ctx );
  6891. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6892. row = data[i];
  6893. if ( row._details ) {
  6894. row._details.children('td[colspan]').attr('colspan', visible );
  6895. }
  6896. }
  6897. } );
  6898. // Table destroyed - nuke any child rows
  6899. api.on( destroyEvent, function ( e, ctx ) {
  6900. if ( settings !== ctx ) {
  6901. return;
  6902. }
  6903. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6904. if ( data[i]._details ) {
  6905. __details_remove( api, i );
  6906. }
  6907. }
  6908. } );
  6909. }
  6910. };
  6911. // Strings for the method names to help minification
  6912. var _emp = '';
  6913. var _child_obj = _emp+'row().child';
  6914. var _child_mth = _child_obj+'()';
  6915. // data can be:
  6916. // tr
  6917. // string
  6918. // jQuery or array of any of the above
  6919. _api_register( _child_mth, function ( data, klass ) {
  6920. var ctx = this.context;
  6921. if ( data === undefined ) {
  6922. // get
  6923. return ctx.length && this.length ?
  6924. ctx[0].aoData[ this[0] ]._details :
  6925. undefined;
  6926. }
  6927. else if ( data === true ) {
  6928. // show
  6929. this.child.show();
  6930. }
  6931. else if ( data === false ) {
  6932. // remove
  6933. __details_remove( this );
  6934. }
  6935. else if ( ctx.length && this.length ) {
  6936. // set
  6937. __details_add( ctx[0], ctx[0].aoData[ this[0] ], data, klass );
  6938. }
  6939. return this;
  6940. } );
  6941. _api_register( [
  6942. _child_obj+'.show()',
  6943. _child_mth+'.show()' // only when `child()` was called with parameters (without
  6944. ], function ( show ) { // it returns an object and this method is not executed)
  6945. __details_display( this, true );
  6946. return this;
  6947. } );
  6948. _api_register( [
  6949. _child_obj+'.hide()',
  6950. _child_mth+'.hide()' // only when `child()` was called with parameters (without
  6951. ], function () { // it returns an object and this method is not executed)
  6952. __details_display( this, false );
  6953. return this;
  6954. } );
  6955. _api_register( [
  6956. _child_obj+'.remove()',
  6957. _child_mth+'.remove()' // only when `child()` was called with parameters (without
  6958. ], function () { // it returns an object and this method is not executed)
  6959. __details_remove( this );
  6960. return this;
  6961. } );
  6962. _api_register( _child_obj+'.isShown()', function () {
  6963. var ctx = this.context;
  6964. if ( ctx.length && this.length ) {
  6965. // _detailsShown as false or undefined will fall through to return false
  6966. return ctx[0].aoData[ this[0] ]._detailsShow || false;
  6967. }
  6968. return false;
  6969. } );
  6970. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6971. * Columns
  6972. *
  6973. * {integer} - column index (>=0 count from left, <0 count from right)
  6974. * "{integer}:visIdx" - visible column index (i.e. translate to column index) (>=0 count from left, <0 count from right)
  6975. * "{integer}:visible" - alias for {integer}:visIdx (>=0 count from left, <0 count from right)
  6976. * "{string}:name" - column name
  6977. * "{string}" - jQuery selector on column header nodes
  6978. *
  6979. */
  6980. // can be an array of these items, comma separated list, or an array of comma
  6981. // separated lists
  6982. var __re_column_selector = /^(.+):(name|visIdx|visible)$/;
  6983. // r1 and r2 are redundant - but it means that the parameters match for the
  6984. // iterator callback in columns().data()
  6985. var __columnData = function ( settings, column, r1, r2, rows ) {
  6986. var a = [];
  6987. for ( var row=0, ien=rows.length ; row<ien ; row++ ) {
  6988. a.push( _fnGetCellData( settings, rows[row], column ) );
  6989. }
  6990. return a;
  6991. };
  6992. var __column_selector = function ( settings, selector, opts )
  6993. {
  6994. var
  6995. columns = settings.aoColumns,
  6996. names = _pluck( columns, 'sName' ),
  6997. nodes = _pluck( columns, 'nTh' );
  6998. var run = function ( s ) {
  6999. var selInt = _intVal( s );
  7000. // Selector - all
  7001. if ( s === '' ) {
  7002. return _range( columns.length );
  7003. }
  7004. // Selector - index
  7005. if ( selInt !== null ) {
  7006. return [ selInt >= 0 ?
  7007. selInt : // Count from left
  7008. columns.length + selInt // Count from right (+ because its a negative value)
  7009. ];
  7010. }
  7011. // Selector = function
  7012. if ( typeof s === 'function' ) {
  7013. var rows = _selector_row_indexes( settings, opts );
  7014. return $.map( columns, function (col, idx) {
  7015. return s(
  7016. idx,
  7017. __columnData( settings, idx, 0, 0, rows ),
  7018. nodes[ idx ]
  7019. ) ? idx : null;
  7020. } );
  7021. }
  7022. // jQuery or string selector
  7023. var match = typeof s === 'string' ?
  7024. s.match( __re_column_selector ) :
  7025. '';
  7026. if ( match ) {
  7027. switch( match[2] ) {
  7028. case 'visIdx':
  7029. case 'visible':
  7030. var idx = parseInt( match[1], 10 );
  7031. // Visible index given, convert to column index
  7032. if ( idx < 0 ) {
  7033. // Counting from the right
  7034. var visColumns = $.map( columns, function (col,i) {
  7035. return col.bVisible ? i : null;
  7036. } );
  7037. return [ visColumns[ visColumns.length + idx ] ];
  7038. }
  7039. // Counting from the left
  7040. return [ _fnVisibleToColumnIndex( settings, idx ) ];
  7041. case 'name':
  7042. // match by name. `names` is column index complete and in order
  7043. return $.map( names, function (name, i) {
  7044. return name === match[1] ? i : null;
  7045. } );
  7046. }
  7047. }
  7048. else {
  7049. // jQuery selector on the TH elements for the columns
  7050. return $( nodes )
  7051. .filter( s )
  7052. .map( function () {
  7053. return $.inArray( this, nodes ); // `nodes` is column index complete and in order
  7054. } )
  7055. .toArray();
  7056. }
  7057. };
  7058. return _selector_run( 'column', selector, run, settings, opts );
  7059. };
  7060. var __setColumnVis = function ( settings, column, vis, recalc ) {
  7061. var
  7062. cols = settings.aoColumns,
  7063. col = cols[ column ],
  7064. data = settings.aoData,
  7065. row, cells, i, ien, tr;
  7066. // Get
  7067. if ( vis === undefined ) {
  7068. return col.bVisible;
  7069. }
  7070. // Set
  7071. // No change
  7072. if ( col.bVisible === vis ) {
  7073. return;
  7074. }
  7075. if ( vis ) {
  7076. // Insert column
  7077. // Need to decide if we should use appendChild or insertBefore
  7078. var insertBefore = $.inArray( true, _pluck(cols, 'bVisible'), column+1 );
  7079. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  7080. tr = data[i].nTr;
  7081. cells = data[i].anCells;
  7082. if ( tr ) {
  7083. // insertBefore can act like appendChild if 2nd arg is null
  7084. tr.insertBefore( cells[ column ], cells[ insertBefore ] || null );
  7085. }
  7086. }
  7087. }
  7088. else {
  7089. // Remove column
  7090. $( _pluck( settings.aoData, 'anCells', column ) ).detach();
  7091. }
  7092. // Common actions
  7093. col.bVisible = vis;
  7094. _fnDrawHead( settings, settings.aoHeader );
  7095. _fnDrawHead( settings, settings.aoFooter );
  7096. if ( recalc === undefined || recalc ) {
  7097. // Automatically adjust column sizing
  7098. _fnAdjustColumnSizing( settings );
  7099. // Realign columns for scrolling
  7100. if ( settings.oScroll.sX || settings.oScroll.sY ) {
  7101. _fnScrollDraw( settings );
  7102. }
  7103. }
  7104. _fnCallbackFire( settings, null, 'column-visibility', [settings, column, vis] );
  7105. _fnSaveState( settings );
  7106. };
  7107. _api_register( 'columns()', function ( selector, opts ) {
  7108. // argument shifting
  7109. if ( selector === undefined ) {
  7110. selector = '';
  7111. }
  7112. else if ( $.isPlainObject( selector ) ) {
  7113. opts = selector;
  7114. selector = '';
  7115. }
  7116. opts = _selector_opts( opts );
  7117. var inst = this.iterator( 'table', function ( settings ) {
  7118. return __column_selector( settings, selector, opts );
  7119. }, 1 );
  7120. // Want argument shifting here and in _row_selector?
  7121. inst.selector.cols = selector;
  7122. inst.selector.opts = opts;
  7123. return inst;
  7124. } );
  7125. _api_registerPlural( 'columns().header()', 'column().header()', function ( selector, opts ) {
  7126. return this.iterator( 'column', function ( settings, column ) {
  7127. return settings.aoColumns[column].nTh;
  7128. }, 1 );
  7129. } );
  7130. _api_registerPlural( 'columns().footer()', 'column().footer()', function ( selector, opts ) {
  7131. return this.iterator( 'column', function ( settings, column ) {
  7132. return settings.aoColumns[column].nTf;
  7133. }, 1 );
  7134. } );
  7135. _api_registerPlural( 'columns().data()', 'column().data()', function () {
  7136. return this.iterator( 'column-rows', __columnData, 1 );
  7137. } );
  7138. _api_registerPlural( 'columns().dataSrc()', 'column().dataSrc()', function () {
  7139. return this.iterator( 'column', function ( settings, column ) {
  7140. return settings.aoColumns[column].mData;
  7141. }, 1 );
  7142. } );
  7143. _api_registerPlural( 'columns().cache()', 'column().cache()', function ( type ) {
  7144. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7145. return _pluck_order( settings.aoData, rows,
  7146. type === 'search' ? '_aFilterData' : '_aSortData', column
  7147. );
  7148. }, 1 );
  7149. } );
  7150. _api_registerPlural( 'columns().nodes()', 'column().nodes()', function () {
  7151. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7152. return _pluck_order( settings.aoData, rows, 'anCells', column ) ;
  7153. }, 1 );
  7154. } );
  7155. _api_registerPlural( 'columns().visible()', 'column().visible()', function ( vis, calc ) {
  7156. return this.iterator( 'column', function ( settings, column ) {
  7157. if ( vis === undefined ) {
  7158. return settings.aoColumns[ column ].bVisible;
  7159. } // else
  7160. __setColumnVis( settings, column, vis, calc );
  7161. } );
  7162. } );
  7163. _api_registerPlural( 'columns().indexes()', 'column().index()', function ( type ) {
  7164. return this.iterator( 'column', function ( settings, column ) {
  7165. return type === 'visible' ?
  7166. _fnColumnIndexToVisible( settings, column ) :
  7167. column;
  7168. }, 1 );
  7169. } );
  7170. _api_register( 'columns.adjust()', function () {
  7171. return this.iterator( 'table', function ( settings ) {
  7172. _fnAdjustColumnSizing( settings );
  7173. }, 1 );
  7174. } );
  7175. _api_register( 'column.index()', function ( type, idx ) {
  7176. if ( this.context.length !== 0 ) {
  7177. var ctx = this.context[0];
  7178. if ( type === 'fromVisible' || type === 'toData' ) {
  7179. return _fnVisibleToColumnIndex( ctx, idx );
  7180. }
  7181. else if ( type === 'fromData' || type === 'toVisible' ) {
  7182. return _fnColumnIndexToVisible( ctx, idx );
  7183. }
  7184. }
  7185. } );
  7186. _api_register( 'column()', function ( selector, opts ) {
  7187. return _selector_first( this.columns( selector, opts ) );
  7188. } );
  7189. var __cell_selector = function ( settings, selector, opts )
  7190. {
  7191. var data = settings.aoData;
  7192. var rows = _selector_row_indexes( settings, opts );
  7193. var cells = _removeEmpty( _pluck_order( data, rows, 'anCells' ) );
  7194. var allCells = $( [].concat.apply([], cells) );
  7195. var row;
  7196. var columns = settings.aoColumns.length;
  7197. var a, i, ien, j, o, host;
  7198. var run = function ( s ) {
  7199. var fnSelector = typeof s === 'function';
  7200. if ( s === null || s === undefined || fnSelector ) {
  7201. // All cells and function selectors
  7202. a = [];
  7203. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  7204. row = rows[i];
  7205. for ( j=0 ; j<columns ; j++ ) {
  7206. o = {
  7207. row: row,
  7208. column: j
  7209. };
  7210. if ( fnSelector ) {
  7211. // Selector - function
  7212. host = settings.aoData[ row ];
  7213. if ( s( o, _fnGetCellData(settings, row, j), host.anCells ? host.anCells[j] : null ) ) {
  7214. a.push( o );
  7215. }
  7216. }
  7217. else {
  7218. // Selector - all
  7219. a.push( o );
  7220. }
  7221. }
  7222. }
  7223. return a;
  7224. }
  7225. // Selector - index
  7226. if ( $.isPlainObject( s ) ) {
  7227. return [s];
  7228. }
  7229. // Selector - jQuery filtered cells
  7230. return allCells
  7231. .filter( s )
  7232. .map( function (i, el) {
  7233. row = el.parentNode._DT_RowIndex;
  7234. return {
  7235. row: row,
  7236. column: $.inArray( el, data[ row ].anCells )
  7237. };
  7238. } )
  7239. .toArray();
  7240. };
  7241. return _selector_run( 'cell', selector, run, settings, opts );
  7242. };
  7243. _api_register( 'cells()', function ( rowSelector, columnSelector, opts ) {
  7244. // Argument shifting
  7245. if ( $.isPlainObject( rowSelector ) ) {
  7246. // Indexes
  7247. if ( rowSelector.row === undefined ) {
  7248. // Selector options in first parameter
  7249. opts = rowSelector;
  7250. rowSelector = null;
  7251. }
  7252. else {
  7253. // Cell index objects in first parameter
  7254. opts = columnSelector;
  7255. columnSelector = null;
  7256. }
  7257. }
  7258. if ( $.isPlainObject( columnSelector ) ) {
  7259. opts = columnSelector;
  7260. columnSelector = null;
  7261. }
  7262. // Cell selector
  7263. if ( columnSelector === null || columnSelector === undefined ) {
  7264. return this.iterator( 'table', function ( settings ) {
  7265. return __cell_selector( settings, rowSelector, _selector_opts( opts ) );
  7266. } );
  7267. }
  7268. // Row + column selector
  7269. var columns = this.columns( columnSelector, opts );
  7270. var rows = this.rows( rowSelector, opts );
  7271. var a, i, ien, j, jen;
  7272. var cells = this.iterator( 'table', function ( settings, idx ) {
  7273. a = [];
  7274. for ( i=0, ien=rows[idx].length ; i<ien ; i++ ) {
  7275. for ( j=0, jen=columns[idx].length ; j<jen ; j++ ) {
  7276. a.push( {
  7277. row: rows[idx][i],
  7278. column: columns[idx][j]
  7279. } );
  7280. }
  7281. }
  7282. return a;
  7283. }, 1 );
  7284. $.extend( cells.selector, {
  7285. cols: columnSelector,
  7286. rows: rowSelector,
  7287. opts: opts
  7288. } );
  7289. return cells;
  7290. } );
  7291. _api_registerPlural( 'cells().nodes()', 'cell().node()', function () {
  7292. return this.iterator( 'cell', function ( settings, row, column ) {
  7293. var cells = settings.aoData[ row ].anCells;
  7294. return cells ?
  7295. cells[ column ] :
  7296. undefined;
  7297. }, 1 );
  7298. } );
  7299. _api_register( 'cells().data()', function () {
  7300. return this.iterator( 'cell', function ( settings, row, column ) {
  7301. return _fnGetCellData( settings, row, column );
  7302. }, 1 );
  7303. } );
  7304. _api_registerPlural( 'cells().cache()', 'cell().cache()', function ( type ) {
  7305. type = type === 'search' ? '_aFilterData' : '_aSortData';
  7306. return this.iterator( 'cell', function ( settings, row, column ) {
  7307. return settings.aoData[ row ][ type ][ column ];
  7308. }, 1 );
  7309. } );
  7310. _api_registerPlural( 'cells().render()', 'cell().render()', function ( type ) {
  7311. return this.iterator( 'cell', function ( settings, row, column ) {
  7312. return _fnGetCellData( settings, row, column, type );
  7313. }, 1 );
  7314. } );
  7315. _api_registerPlural( 'cells().indexes()', 'cell().index()', function () {
  7316. return this.iterator( 'cell', function ( settings, row, column ) {
  7317. return {
  7318. row: row,
  7319. column: column,
  7320. columnVisible: _fnColumnIndexToVisible( settings, column )
  7321. };
  7322. }, 1 );
  7323. } );
  7324. _api_registerPlural( 'cells().invalidate()', 'cell().invalidate()', function ( src ) {
  7325. return this.iterator( 'cell', function ( settings, row, column ) {
  7326. _fnInvalidate( settings, row, src, column );
  7327. } );
  7328. } );
  7329. _api_register( 'cell()', function ( rowSelector, columnSelector, opts ) {
  7330. return _selector_first( this.cells( rowSelector, columnSelector, opts ) );
  7331. } );
  7332. _api_register( 'cell().data()', function ( data ) {
  7333. var ctx = this.context;
  7334. var cell = this[0];
  7335. if ( data === undefined ) {
  7336. // Get
  7337. return ctx.length && cell.length ?
  7338. _fnGetCellData( ctx[0], cell[0].row, cell[0].column ) :
  7339. undefined;
  7340. }
  7341. // Set
  7342. _fnSetCellData( ctx[0], cell[0].row, cell[0].column, data );
  7343. _fnInvalidate( ctx[0], cell[0].row, 'data', cell[0].column );
  7344. return this;
  7345. } );
  7346. /**
  7347. * Get current ordering (sorting) that has been applied to the table.
  7348. *
  7349. * @returns {array} 2D array containing the sorting information for the first
  7350. * table in the current context. Each element in the parent array represents
  7351. * a column being sorted upon (i.e. multi-sorting with two columns would have
  7352. * 2 inner arrays). The inner arrays may have 2 or 3 elements. The first is
  7353. * the column index that the sorting condition applies to, the second is the
  7354. * direction of the sort (`desc` or `asc`) and, optionally, the third is the
  7355. * index of the sorting order from the `column.sorting` initialisation array.
  7356. *//**
  7357. * Set the ordering for the table.
  7358. *
  7359. * @param {integer} order Column index to sort upon.
  7360. * @param {string} direction Direction of the sort to be applied (`asc` or `desc`)
  7361. * @returns {DataTables.Api} this
  7362. *//**
  7363. * Set the ordering for the table.
  7364. *
  7365. * @param {array} order 1D array of sorting information to be applied.
  7366. * @param {array} [...] Optional additional sorting conditions
  7367. * @returns {DataTables.Api} this
  7368. *//**
  7369. * Set the ordering for the table.
  7370. *
  7371. * @param {array} order 2D array of sorting information to be applied.
  7372. * @returns {DataTables.Api} this
  7373. */
  7374. _api_register( 'order()', function ( order, dir ) {
  7375. var ctx = this.context;
  7376. if ( order === undefined ) {
  7377. // get
  7378. return ctx.length !== 0 ?
  7379. ctx[0].aaSorting :
  7380. undefined;
  7381. }
  7382. // set
  7383. if ( typeof order === 'number' ) {
  7384. // Simple column / direction passed in
  7385. order = [ [ order, dir ] ];
  7386. }
  7387. else if ( ! $.isArray( order[0] ) ) {
  7388. // Arguments passed in (list of 1D arrays)
  7389. order = Array.prototype.slice.call( arguments );
  7390. }
  7391. // otherwise a 2D array was passed in
  7392. return this.iterator( 'table', function ( settings ) {
  7393. settings.aaSorting = order.slice();
  7394. } );
  7395. } );
  7396. /**
  7397. * Attach a sort listener to an element for a given column
  7398. *
  7399. * @param {node|jQuery|string} node Identifier for the element(s) to attach the
  7400. * listener to. This can take the form of a single DOM node, a jQuery
  7401. * collection of nodes or a jQuery selector which will identify the node(s).
  7402. * @param {integer} column the column that a click on this node will sort on
  7403. * @param {function} [callback] callback function when sort is run
  7404. * @returns {DataTables.Api} this
  7405. */
  7406. _api_register( 'order.listener()', function ( node, column, callback ) {
  7407. return this.iterator( 'table', function ( settings ) {
  7408. _fnSortAttachListener( settings, node, column, callback );
  7409. } );
  7410. } );
  7411. // Order by the selected column(s)
  7412. _api_register( [
  7413. 'columns().order()',
  7414. 'column().order()'
  7415. ], function ( dir ) {
  7416. var that = this;
  7417. return this.iterator( 'table', function ( settings, i ) {
  7418. var sort = [];
  7419. $.each( that[i], function (j, col) {
  7420. sort.push( [ col, dir ] );
  7421. } );
  7422. settings.aaSorting = sort;
  7423. } );
  7424. } );
  7425. _api_register( 'search()', function ( input, regex, smart, caseInsen ) {
  7426. var ctx = this.context;
  7427. if ( input === undefined ) {
  7428. // get
  7429. return ctx.length !== 0 ?
  7430. ctx[0].oPreviousSearch.sSearch :
  7431. undefined;
  7432. }
  7433. // set
  7434. return this.iterator( 'table', function ( settings ) {
  7435. if ( ! settings.oFeatures.bFilter ) {
  7436. return;
  7437. }
  7438. _fnFilterComplete( settings, $.extend( {}, settings.oPreviousSearch, {
  7439. "sSearch": input+"",
  7440. "bRegex": regex === null ? false : regex,
  7441. "bSmart": smart === null ? true : smart,
  7442. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7443. } ), 1 );
  7444. } );
  7445. } );
  7446. _api_registerPlural(
  7447. 'columns().search()',
  7448. 'column().search()',
  7449. function ( input, regex, smart, caseInsen ) {
  7450. return this.iterator( 'column', function ( settings, column ) {
  7451. var preSearch = settings.aoPreSearchCols;
  7452. if ( input === undefined ) {
  7453. // get
  7454. return preSearch[ column ].sSearch;
  7455. }
  7456. // set
  7457. if ( ! settings.oFeatures.bFilter ) {
  7458. return;
  7459. }
  7460. $.extend( preSearch[ column ], {
  7461. "sSearch": input+"",
  7462. "bRegex": regex === null ? false : regex,
  7463. "bSmart": smart === null ? true : smart,
  7464. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7465. } );
  7466. _fnFilterComplete( settings, settings.oPreviousSearch, 1 );
  7467. } );
  7468. }
  7469. );
  7470. /*
  7471. * State API methods
  7472. */
  7473. _api_register( 'state()', function () {
  7474. return this.context.length ?
  7475. this.context[0].oSavedState :
  7476. null;
  7477. } );
  7478. _api_register( 'state.clear()', function () {
  7479. return this.iterator( 'table', function ( settings ) {
  7480. // Save an empty object
  7481. settings.fnStateSaveCallback.call( settings.oInstance, settings, {} );
  7482. } );
  7483. } );
  7484. _api_register( 'state.loaded()', function () {
  7485. return this.context.length ?
  7486. this.context[0].oLoadedState :
  7487. null;
  7488. } );
  7489. _api_register( 'state.save()', function () {
  7490. return this.iterator( 'table', function ( settings ) {
  7491. _fnSaveState( settings );
  7492. } );
  7493. } );
  7494. /**
  7495. * Provide a common method for plug-ins to check the version of DataTables being
  7496. * used, in order to ensure compatibility.
  7497. *
  7498. * @param {string} version Version string to check for, in the format "X.Y.Z".
  7499. * Note that the formats "X" and "X.Y" are also acceptable.
  7500. * @returns {boolean} true if this version of DataTables is greater or equal to
  7501. * the required version, or false if this version of DataTales is not
  7502. * suitable
  7503. * @static
  7504. * @dtopt API-Static
  7505. *
  7506. * @example
  7507. * alert( $.fn.dataTable.versionCheck( '1.9.0' ) );
  7508. */
  7509. DataTable.versionCheck = DataTable.fnVersionCheck = function( version )
  7510. {
  7511. var aThis = DataTable.version.split('.');
  7512. var aThat = version.split('.');
  7513. var iThis, iThat;
  7514. for ( var i=0, iLen=aThat.length ; i<iLen ; i++ ) {
  7515. iThis = parseInt( aThis[i], 10 ) || 0;
  7516. iThat = parseInt( aThat[i], 10 ) || 0;
  7517. // Parts are the same, keep comparing
  7518. if (iThis === iThat) {
  7519. continue;
  7520. }
  7521. // Parts are different, return immediately
  7522. return iThis > iThat;
  7523. }
  7524. return true;
  7525. };
  7526. /**
  7527. * Check if a `<table>` node is a DataTable table already or not.
  7528. *
  7529. * @param {node|jquery|string} table Table node, jQuery object or jQuery
  7530. * selector for the table to test. Note that if more than more than one
  7531. * table is passed on, only the first will be checked
  7532. * @returns {boolean} true the table given is a DataTable, or false otherwise
  7533. * @static
  7534. * @dtopt API-Static
  7535. *
  7536. * @example
  7537. * if ( ! $.fn.DataTable.isDataTable( '#example' ) ) {
  7538. * $('#example').dataTable();
  7539. * }
  7540. */
  7541. DataTable.isDataTable = DataTable.fnIsDataTable = function ( table )
  7542. {
  7543. var t = $(table).get(0);
  7544. var is = false;
  7545. $.each( DataTable.settings, function (i, o) {
  7546. var head = o.nScrollHead ? $('table', o.nScrollHead)[0] : null;
  7547. var foot = o.nScrollFoot ? $('table', o.nScrollFoot)[0] : null;
  7548. if ( o.nTable === t || head === t || foot === t ) {
  7549. is = true;
  7550. }
  7551. } );
  7552. return is;
  7553. };
  7554. /**
  7555. * Get all DataTable tables that have been initialised - optionally you can
  7556. * select to get only currently visible tables.
  7557. *
  7558. * @param {boolean} [visible=false] Flag to indicate if you want all (default)
  7559. * or visible tables only.
  7560. * @returns {array} Array of `table` nodes (not DataTable instances) which are
  7561. * DataTables
  7562. * @static
  7563. * @dtopt API-Static
  7564. *
  7565. * @example
  7566. * $.each( $.fn.dataTable.tables(true), function () {
  7567. * $(table).DataTable().columns.adjust();
  7568. * } );
  7569. */
  7570. DataTable.tables = DataTable.fnTables = function ( visible )
  7571. {
  7572. var api = false;
  7573. if ( $.isPlainObject( visible ) ) {
  7574. api = visible.api;
  7575. visible = visible.visible;
  7576. }
  7577. var a = $.map( DataTable.settings, function (o) {
  7578. if ( !visible || (visible && $(o.nTable).is(':visible')) ) {
  7579. return o.nTable;
  7580. }
  7581. } );
  7582. return api ?
  7583. new _Api( a ) :
  7584. a;
  7585. };
  7586. /**
  7587. * DataTables utility methods
  7588. *
  7589. * This namespace provides helper methods that DataTables uses internally to
  7590. * create a DataTable, but which are not exclusively used only for DataTables.
  7591. * These methods can be used by extension authors to save the duplication of
  7592. * code.
  7593. *
  7594. * @namespace
  7595. */
  7596. DataTable.util = {
  7597. /**
  7598. * Throttle the calls to a function. Arguments and context are maintained
  7599. * for the throttled function.
  7600. *
  7601. * @param {function} fn Function to be called
  7602. * @param {integer} freq Call frequency in mS
  7603. * @return {function} Wrapped function
  7604. */
  7605. throttle: _fnThrottle,
  7606. /**
  7607. * Escape a string such that it can be used in a regular expression
  7608. *
  7609. * @param {string} sVal string to escape
  7610. * @returns {string} escaped string
  7611. */
  7612. escapeRegex: _fnEscapeRegex
  7613. };
  7614. /**
  7615. * Convert from camel case parameters to Hungarian notation. This is made public
  7616. * for the extensions to provide the same ability as DataTables core to accept
  7617. * either the 1.9 style Hungarian notation, or the 1.10+ style camelCase
  7618. * parameters.
  7619. *
  7620. * @param {object} src The model object which holds all parameters that can be
  7621. * mapped.
  7622. * @param {object} user The object to convert from camel case to Hungarian.
  7623. * @param {boolean} force When set to `true`, properties which already have a
  7624. * Hungarian value in the `user` object will be overwritten. Otherwise they
  7625. * won't be.
  7626. */
  7627. DataTable.camelToHungarian = _fnCamelToHungarian;
  7628. /**
  7629. *
  7630. */
  7631. _api_register( '$()', function ( selector, opts ) {
  7632. var
  7633. rows = this.rows( opts ).nodes(), // Get all rows
  7634. jqRows = $(rows);
  7635. return $( [].concat(
  7636. jqRows.filter( selector ).toArray(),
  7637. jqRows.find( selector ).toArray()
  7638. ) );
  7639. } );
  7640. // jQuery functions to operate on the tables
  7641. $.each( [ 'on', 'one', 'off' ], function (i, key) {
  7642. _api_register( key+'()', function ( /* event, handler */ ) {
  7643. var args = Array.prototype.slice.call(arguments);
  7644. // Add the `dt` namespace automatically if it isn't already present
  7645. if ( ! args[0].match(/\.dt\b/) ) {
  7646. args[0] += '.dt';
  7647. }
  7648. var inst = $( this.tables().nodes() );
  7649. inst[key].apply( inst, args );
  7650. return this;
  7651. } );
  7652. } );
  7653. _api_register( 'clear()', function () {
  7654. return this.iterator( 'table', function ( settings ) {
  7655. _fnClearTable( settings );
  7656. } );
  7657. } );
  7658. _api_register( 'settings()', function () {
  7659. return new _Api( this.context, this.context );
  7660. } );
  7661. _api_register( 'init()', function () {
  7662. var ctx = this.context;
  7663. return ctx.length ? ctx[0].oInit : null;
  7664. } );
  7665. _api_register( 'data()', function () {
  7666. return this.iterator( 'table', function ( settings ) {
  7667. return _pluck( settings.aoData, '_aData' );
  7668. } ).flatten();
  7669. } );
  7670. _api_register( 'destroy()', function ( remove ) {
  7671. remove = remove || false;
  7672. return this.iterator( 'table', function ( settings ) {
  7673. var orig = settings.nTableWrapper.parentNode;
  7674. var classes = settings.oClasses;
  7675. var table = settings.nTable;
  7676. var tbody = settings.nTBody;
  7677. var thead = settings.nTHead;
  7678. var tfoot = settings.nTFoot;
  7679. var jqTable = $(table);
  7680. var jqTbody = $(tbody);
  7681. var jqWrapper = $(settings.nTableWrapper);
  7682. var rows = $.map( settings.aoData, function (r) { return r.nTr; } );
  7683. var i, ien;
  7684. // Flag to note that the table is currently being destroyed - no action
  7685. // should be taken
  7686. settings.bDestroying = true;
  7687. // Fire off the destroy callbacks for plug-ins etc
  7688. _fnCallbackFire( settings, "aoDestroyCallback", "destroy", [settings] );
  7689. // If not being removed from the document, make all columns visible
  7690. if ( ! remove ) {
  7691. new _Api( settings ).columns().visible( true );
  7692. }
  7693. // Blitz all `DT` namespaced events (these are internal events, the
  7694. // lowercase, `dt` events are user subscribed and they are responsible
  7695. // for removing them
  7696. jqWrapper.unbind('.DT').find(':not(tbody *)').unbind('.DT');
  7697. $(window).unbind('.DT-'+settings.sInstance);
  7698. // When scrolling we had to break the table up - restore it
  7699. if ( table != thead.parentNode ) {
  7700. jqTable.children('thead').detach();
  7701. jqTable.append( thead );
  7702. }
  7703. if ( tfoot && table != tfoot.parentNode ) {
  7704. jqTable.children('tfoot').detach();
  7705. jqTable.append( tfoot );
  7706. }
  7707. settings.aaSorting = [];
  7708. settings.aaSortingFixed = [];
  7709. _fnSortingClasses( settings );
  7710. $( rows ).removeClass( settings.asStripeClasses.join(' ') );
  7711. $('th, td', thead).removeClass( classes.sSortable+' '+
  7712. classes.sSortableAsc+' '+classes.sSortableDesc+' '+classes.sSortableNone
  7713. );
  7714. if ( settings.bJUI ) {
  7715. $('th span.'+classes.sSortIcon+ ', td span.'+classes.sSortIcon, thead).detach();
  7716. $('th, td', thead).each( function () {
  7717. var wrapper = $('div.'+classes.sSortJUIWrapper, this);
  7718. $(this).append( wrapper.contents() );
  7719. wrapper.detach();
  7720. } );
  7721. }
  7722. // Add the TR elements back into the table in their original order
  7723. jqTbody.children().detach();
  7724. jqTbody.append( rows );
  7725. // Remove the DataTables generated nodes, events and classes
  7726. var removedMethod = remove ? 'remove' : 'detach';
  7727. jqTable[ removedMethod ]();
  7728. jqWrapper[ removedMethod ]();
  7729. // If we need to reattach the table to the document
  7730. if ( ! remove && orig ) {
  7731. // insertBefore acts like appendChild if !arg[1]
  7732. orig.insertBefore( table, settings.nTableReinsertBefore );
  7733. // Restore the width of the original table - was read from the style property,
  7734. // so we can restore directly to that
  7735. jqTable
  7736. .css( 'width', settings.sDestroyWidth )
  7737. .removeClass( classes.sTable );
  7738. // If the were originally stripe classes - then we add them back here.
  7739. // Note this is not fool proof (for example if not all rows had stripe
  7740. // classes - but it's a good effort without getting carried away
  7741. ien = settings.asDestroyStripes.length;
  7742. if ( ien ) {
  7743. jqTbody.children().each( function (i) {
  7744. $(this).addClass( settings.asDestroyStripes[i % ien] );
  7745. } );
  7746. }
  7747. }
  7748. /* Remove the settings object from the settings array */
  7749. var idx = $.inArray( settings, DataTable.settings );
  7750. if ( idx !== -1 ) {
  7751. DataTable.settings.splice( idx, 1 );
  7752. }
  7753. } );
  7754. } );
  7755. // Add the `every()` method for rows, columns and cells in a compact form
  7756. $.each( [ 'column', 'row', 'cell' ], function ( i, type ) {
  7757. _api_register( type+'s().every()', function ( fn ) {
  7758. return this.iterator( type, function ( settings, arg1, arg2, arg3, arg4 ) {
  7759. // Rows and columns:
  7760. // arg1 - index
  7761. // arg2 - table counter
  7762. // arg3 - loop counter
  7763. // arg4 - undefined
  7764. // Cells:
  7765. // arg1 - row index
  7766. // arg2 - column index
  7767. // arg3 - table counter
  7768. // arg4 - loop counter
  7769. fn.call(
  7770. new _Api( settings )[ type ]( arg1, type==='cell' ? arg2 : undefined ),
  7771. arg1, arg2, arg3, arg4
  7772. );
  7773. } );
  7774. } );
  7775. } );
  7776. // i18n method for extensions to be able to use the language object from the
  7777. // DataTable
  7778. _api_register( 'i18n()', function ( token, def, plural ) {
  7779. var ctx = this.context[0];
  7780. var resolved = _fnGetObjectDataFn( token )( ctx.oLanguage );
  7781. if ( resolved === undefined ) {
  7782. resolved = def;
  7783. }
  7784. if ( plural !== undefined && $.isPlainObject( resolved ) ) {
  7785. resolved = resolved[ plural ] !== undefined ?
  7786. resolved[ plural ] :
  7787. resolved._;
  7788. }
  7789. return resolved.replace( '%d', plural ); // nb: plural might be undefined,
  7790. } );
  7791. /**
  7792. * Version string for plug-ins to check compatibility. Allowed format is
  7793. * `a.b.c-d` where: a:int, b:int, c:int, d:string(dev|beta|alpha). `d` is used
  7794. * only for non-release builds. See http://semver.org/ for more information.
  7795. * @member
  7796. * @type string
  7797. * @default Version number
  7798. */
  7799. DataTable.version = "1.10.8";
  7800. /**
  7801. * Private data store, containing all of the settings objects that are
  7802. * created for the tables on a given page.
  7803. *
  7804. * Note that the `DataTable.settings` object is aliased to
  7805. * `jQuery.fn.dataTableExt` through which it may be accessed and
  7806. * manipulated, or `jQuery.fn.dataTable.settings`.
  7807. * @member
  7808. * @type array
  7809. * @default []
  7810. * @private
  7811. */
  7812. DataTable.settings = [];
  7813. /**
  7814. * Object models container, for the various models that DataTables has
  7815. * available to it. These models define the objects that are used to hold
  7816. * the active state and configuration of the table.
  7817. * @namespace
  7818. */
  7819. DataTable.models = {};
  7820. /**
  7821. * Template object for the way in which DataTables holds information about
  7822. * search information for the global filter and individual column filters.
  7823. * @namespace
  7824. */
  7825. DataTable.models.oSearch = {
  7826. /**
  7827. * Flag to indicate if the filtering should be case insensitive or not
  7828. * @type boolean
  7829. * @default true
  7830. */
  7831. "bCaseInsensitive": true,
  7832. /**
  7833. * Applied search term
  7834. * @type string
  7835. * @default <i>Empty string</i>
  7836. */
  7837. "sSearch": "",
  7838. /**
  7839. * Flag to indicate if the search term should be interpreted as a
  7840. * regular expression (true) or not (false) and therefore and special
  7841. * regex characters escaped.
  7842. * @type boolean
  7843. * @default false
  7844. */
  7845. "bRegex": false,
  7846. /**
  7847. * Flag to indicate if DataTables is to use its smart filtering or not.
  7848. * @type boolean
  7849. * @default true
  7850. */
  7851. "bSmart": true
  7852. };
  7853. /**
  7854. * Template object for the way in which DataTables holds information about
  7855. * each individual row. This is the object format used for the settings
  7856. * aoData array.
  7857. * @namespace
  7858. */
  7859. DataTable.models.oRow = {
  7860. /**
  7861. * TR element for the row
  7862. * @type node
  7863. * @default null
  7864. */
  7865. "nTr": null,
  7866. /**
  7867. * Array of TD elements for each row. This is null until the row has been
  7868. * created.
  7869. * @type array nodes
  7870. * @default []
  7871. */
  7872. "anCells": null,
  7873. /**
  7874. * Data object from the original data source for the row. This is either
  7875. * an array if using the traditional form of DataTables, or an object if
  7876. * using mData options. The exact type will depend on the passed in
  7877. * data from the data source, or will be an array if using DOM a data
  7878. * source.
  7879. * @type array|object
  7880. * @default []
  7881. */
  7882. "_aData": [],
  7883. /**
  7884. * Sorting data cache - this array is ostensibly the same length as the
  7885. * number of columns (although each index is generated only as it is
  7886. * needed), and holds the data that is used for sorting each column in the
  7887. * row. We do this cache generation at the start of the sort in order that
  7888. * the formatting of the sort data need be done only once for each cell
  7889. * per sort. This array should not be read from or written to by anything
  7890. * other than the master sorting methods.
  7891. * @type array
  7892. * @default null
  7893. * @private
  7894. */
  7895. "_aSortData": null,
  7896. /**
  7897. * Per cell filtering data cache. As per the sort data cache, used to
  7898. * increase the performance of the filtering in DataTables
  7899. * @type array
  7900. * @default null
  7901. * @private
  7902. */
  7903. "_aFilterData": null,
  7904. /**
  7905. * Filtering data cache. This is the same as the cell filtering cache, but
  7906. * in this case a string rather than an array. This is easily computed with
  7907. * a join on `_aFilterData`, but is provided as a cache so the join isn't
  7908. * needed on every search (memory traded for performance)
  7909. * @type array
  7910. * @default null
  7911. * @private
  7912. */
  7913. "_sFilterRow": null,
  7914. /**
  7915. * Cache of the class name that DataTables has applied to the row, so we
  7916. * can quickly look at this variable rather than needing to do a DOM check
  7917. * on className for the nTr property.
  7918. * @type string
  7919. * @default <i>Empty string</i>
  7920. * @private
  7921. */
  7922. "_sRowStripe": "",
  7923. /**
  7924. * Denote if the original data source was from the DOM, or the data source
  7925. * object. This is used for invalidating data, so DataTables can
  7926. * automatically read data from the original source, unless uninstructed
  7927. * otherwise.
  7928. * @type string
  7929. * @default null
  7930. * @private
  7931. */
  7932. "src": null,
  7933. /**
  7934. * Index in the aoData array. This saves an indexOf lookup when we have the
  7935. * object, but want to know the index
  7936. * @type integer
  7937. * @default -1
  7938. * @private
  7939. */
  7940. "idx": -1
  7941. };
  7942. /**
  7943. * Template object for the column information object in DataTables. This object
  7944. * is held in the settings aoColumns array and contains all the information that
  7945. * DataTables needs about each individual column.
  7946. *
  7947. * Note that this object is related to {@link DataTable.defaults.column}
  7948. * but this one is the internal data store for DataTables's cache of columns.
  7949. * It should NOT be manipulated outside of DataTables. Any configuration should
  7950. * be done through the initialisation options.
  7951. * @namespace
  7952. */
  7953. DataTable.models.oColumn = {
  7954. /**
  7955. * Column index. This could be worked out on-the-fly with $.inArray, but it
  7956. * is faster to just hold it as a variable
  7957. * @type integer
  7958. * @default null
  7959. */
  7960. "idx": null,
  7961. /**
  7962. * A list of the columns that sorting should occur on when this column
  7963. * is sorted. That this property is an array allows multi-column sorting
  7964. * to be defined for a column (for example first name / last name columns
  7965. * would benefit from this). The values are integers pointing to the
  7966. * columns to be sorted on (typically it will be a single integer pointing
  7967. * at itself, but that doesn't need to be the case).
  7968. * @type array
  7969. */
  7970. "aDataSort": null,
  7971. /**
  7972. * Define the sorting directions that are applied to the column, in sequence
  7973. * as the column is repeatedly sorted upon - i.e. the first value is used
  7974. * as the sorting direction when the column if first sorted (clicked on).
  7975. * Sort it again (click again) and it will move on to the next index.
  7976. * Repeat until loop.
  7977. * @type array
  7978. */
  7979. "asSorting": null,
  7980. /**
  7981. * Flag to indicate if the column is searchable, and thus should be included
  7982. * in the filtering or not.
  7983. * @type boolean
  7984. */
  7985. "bSearchable": null,
  7986. /**
  7987. * Flag to indicate if the column is sortable or not.
  7988. * @type boolean
  7989. */
  7990. "bSortable": null,
  7991. /**
  7992. * Flag to indicate if the column is currently visible in the table or not
  7993. * @type boolean
  7994. */
  7995. "bVisible": null,
  7996. /**
  7997. * Store for manual type assignment using the `column.type` option. This
  7998. * is held in store so we can manipulate the column's `sType` property.
  7999. * @type string
  8000. * @default null
  8001. * @private
  8002. */
  8003. "_sManualType": null,
  8004. /**
  8005. * Flag to indicate if HTML5 data attributes should be used as the data
  8006. * source for filtering or sorting. True is either are.
  8007. * @type boolean
  8008. * @default false
  8009. * @private
  8010. */
  8011. "_bAttrSrc": false,
  8012. /**
  8013. * Developer definable function that is called whenever a cell is created (Ajax source,
  8014. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  8015. * allowing you to modify the DOM element (add background colour for example) when the
  8016. * element is available.
  8017. * @type function
  8018. * @param {element} nTd The TD node that has been created
  8019. * @param {*} sData The Data for the cell
  8020. * @param {array|object} oData The data for the whole row
  8021. * @param {int} iRow The row index for the aoData data store
  8022. * @default null
  8023. */
  8024. "fnCreatedCell": null,
  8025. /**
  8026. * Function to get data from a cell in a column. You should <b>never</b>
  8027. * access data directly through _aData internally in DataTables - always use
  8028. * the method attached to this property. It allows mData to function as
  8029. * required. This function is automatically assigned by the column
  8030. * initialisation method
  8031. * @type function
  8032. * @param {array|object} oData The data array/object for the array
  8033. * (i.e. aoData[]._aData)
  8034. * @param {string} sSpecific The specific data type you want to get -
  8035. * 'display', 'type' 'filter' 'sort'
  8036. * @returns {*} The data for the cell from the given row's data
  8037. * @default null
  8038. */
  8039. "fnGetData": null,
  8040. /**
  8041. * Function to set data for a cell in the column. You should <b>never</b>
  8042. * set the data directly to _aData internally in DataTables - always use
  8043. * this method. It allows mData to function as required. This function
  8044. * is automatically assigned by the column initialisation method
  8045. * @type function
  8046. * @param {array|object} oData The data array/object for the array
  8047. * (i.e. aoData[]._aData)
  8048. * @param {*} sValue Value to set
  8049. * @default null
  8050. */
  8051. "fnSetData": null,
  8052. /**
  8053. * Property to read the value for the cells in the column from the data
  8054. * source array / object. If null, then the default content is used, if a
  8055. * function is given then the return from the function is used.
  8056. * @type function|int|string|null
  8057. * @default null
  8058. */
  8059. "mData": null,
  8060. /**
  8061. * Partner property to mData which is used (only when defined) to get
  8062. * the data - i.e. it is basically the same as mData, but without the
  8063. * 'set' option, and also the data fed to it is the result from mData.
  8064. * This is the rendering method to match the data method of mData.
  8065. * @type function|int|string|null
  8066. * @default null
  8067. */
  8068. "mRender": null,
  8069. /**
  8070. * Unique header TH/TD element for this column - this is what the sorting
  8071. * listener is attached to (if sorting is enabled.)
  8072. * @type node
  8073. * @default null
  8074. */
  8075. "nTh": null,
  8076. /**
  8077. * Unique footer TH/TD element for this column (if there is one). Not used
  8078. * in DataTables as such, but can be used for plug-ins to reference the
  8079. * footer for each column.
  8080. * @type node
  8081. * @default null
  8082. */
  8083. "nTf": null,
  8084. /**
  8085. * The class to apply to all TD elements in the table's TBODY for the column
  8086. * @type string
  8087. * @default null
  8088. */
  8089. "sClass": null,
  8090. /**
  8091. * When DataTables calculates the column widths to assign to each column,
  8092. * it finds the longest string in each column and then constructs a
  8093. * temporary table and reads the widths from that. The problem with this
  8094. * is that "mmm" is much wider then "iiii", but the latter is a longer
  8095. * string - thus the calculation can go wrong (doing it properly and putting
  8096. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  8097. * a "work around" we provide this option. It will append its value to the
  8098. * text that is found to be the longest string for the column - i.e. padding.
  8099. * @type string
  8100. */
  8101. "sContentPadding": null,
  8102. /**
  8103. * Allows a default value to be given for a column's data, and will be used
  8104. * whenever a null data source is encountered (this can be because mData
  8105. * is set to null, or because the data source itself is null).
  8106. * @type string
  8107. * @default null
  8108. */
  8109. "sDefaultContent": null,
  8110. /**
  8111. * Name for the column, allowing reference to the column by name as well as
  8112. * by index (needs a lookup to work by name).
  8113. * @type string
  8114. */
  8115. "sName": null,
  8116. /**
  8117. * Custom sorting data type - defines which of the available plug-ins in
  8118. * afnSortData the custom sorting will use - if any is defined.
  8119. * @type string
  8120. * @default std
  8121. */
  8122. "sSortDataType": 'std',
  8123. /**
  8124. * Class to be applied to the header element when sorting on this column
  8125. * @type string
  8126. * @default null
  8127. */
  8128. "sSortingClass": null,
  8129. /**
  8130. * Class to be applied to the header element when sorting on this column -
  8131. * when jQuery UI theming is used.
  8132. * @type string
  8133. * @default null
  8134. */
  8135. "sSortingClassJUI": null,
  8136. /**
  8137. * Title of the column - what is seen in the TH element (nTh).
  8138. * @type string
  8139. */
  8140. "sTitle": null,
  8141. /**
  8142. * Column sorting and filtering type
  8143. * @type string
  8144. * @default null
  8145. */
  8146. "sType": null,
  8147. /**
  8148. * Width of the column
  8149. * @type string
  8150. * @default null
  8151. */
  8152. "sWidth": null,
  8153. /**
  8154. * Width of the column when it was first "encountered"
  8155. * @type string
  8156. * @default null
  8157. */
  8158. "sWidthOrig": null
  8159. };
  8160. /*
  8161. * Developer note: The properties of the object below are given in Hungarian
  8162. * notation, that was used as the interface for DataTables prior to v1.10, however
  8163. * from v1.10 onwards the primary interface is camel case. In order to avoid
  8164. * breaking backwards compatibility utterly with this change, the Hungarian
  8165. * version is still, internally the primary interface, but is is not documented
  8166. * - hence the @name tags in each doc comment. This allows a Javascript function
  8167. * to create a map from Hungarian notation to camel case (going the other direction
  8168. * would require each property to be listed, which would at around 3K to the size
  8169. * of DataTables, while this method is about a 0.5K hit.
  8170. *
  8171. * Ultimately this does pave the way for Hungarian notation to be dropped
  8172. * completely, but that is a massive amount of work and will break current
  8173. * installs (therefore is on-hold until v2).
  8174. */
  8175. /**
  8176. * Initialisation options that can be given to DataTables at initialisation
  8177. * time.
  8178. * @namespace
  8179. */
  8180. DataTable.defaults = {
  8181. /**
  8182. * An array of data to use for the table, passed in at initialisation which
  8183. * will be used in preference to any data which is already in the DOM. This is
  8184. * particularly useful for constructing tables purely in Javascript, for
  8185. * example with a custom Ajax call.
  8186. * @type array
  8187. * @default null
  8188. *
  8189. * @dtopt Option
  8190. * @name DataTable.defaults.data
  8191. *
  8192. * @example
  8193. * // Using a 2D array data source
  8194. * $(document).ready( function () {
  8195. * $('#example').dataTable( {
  8196. * "data": [
  8197. * ['Trident', 'Internet Explorer 4.0', 'Win 95+', 4, 'X'],
  8198. * ['Trident', 'Internet Explorer 5.0', 'Win 95+', 5, 'C'],
  8199. * ],
  8200. * "columns": [
  8201. * { "title": "Engine" },
  8202. * { "title": "Browser" },
  8203. * { "title": "Platform" },
  8204. * { "title": "Version" },
  8205. * { "title": "Grade" }
  8206. * ]
  8207. * } );
  8208. * } );
  8209. *
  8210. * @example
  8211. * // Using an array of objects as a data source (`data`)
  8212. * $(document).ready( function () {
  8213. * $('#example').dataTable( {
  8214. * "data": [
  8215. * {
  8216. * "engine": "Trident",
  8217. * "browser": "Internet Explorer 4.0",
  8218. * "platform": "Win 95+",
  8219. * "version": 4,
  8220. * "grade": "X"
  8221. * },
  8222. * {
  8223. * "engine": "Trident",
  8224. * "browser": "Internet Explorer 5.0",
  8225. * "platform": "Win 95+",
  8226. * "version": 5,
  8227. * "grade": "C"
  8228. * }
  8229. * ],
  8230. * "columns": [
  8231. * { "title": "Engine", "data": "engine" },
  8232. * { "title": "Browser", "data": "browser" },
  8233. * { "title": "Platform", "data": "platform" },
  8234. * { "title": "Version", "data": "version" },
  8235. * { "title": "Grade", "data": "grade" }
  8236. * ]
  8237. * } );
  8238. * } );
  8239. */
  8240. "aaData": null,
  8241. /**
  8242. * If ordering is enabled, then DataTables will perform a first pass sort on
  8243. * initialisation. You can define which column(s) the sort is performed
  8244. * upon, and the sorting direction, with this variable. The `sorting` array
  8245. * should contain an array for each column to be sorted initially containing
  8246. * the column's index and a direction string ('asc' or 'desc').
  8247. * @type array
  8248. * @default [[0,'asc']]
  8249. *
  8250. * @dtopt Option
  8251. * @name DataTable.defaults.order
  8252. *
  8253. * @example
  8254. * // Sort by 3rd column first, and then 4th column
  8255. * $(document).ready( function() {
  8256. * $('#example').dataTable( {
  8257. * "order": [[2,'asc'], [3,'desc']]
  8258. * } );
  8259. * } );
  8260. *
  8261. * // No initial sorting
  8262. * $(document).ready( function() {
  8263. * $('#example').dataTable( {
  8264. * "order": []
  8265. * } );
  8266. * } );
  8267. */
  8268. "aaSorting": [[0,'asc']],
  8269. /**
  8270. * This parameter is basically identical to the `sorting` parameter, but
  8271. * cannot be overridden by user interaction with the table. What this means
  8272. * is that you could have a column (visible or hidden) which the sorting
  8273. * will always be forced on first - any sorting after that (from the user)
  8274. * will then be performed as required. This can be useful for grouping rows
  8275. * together.
  8276. * @type array
  8277. * @default null
  8278. *
  8279. * @dtopt Option
  8280. * @name DataTable.defaults.orderFixed
  8281. *
  8282. * @example
  8283. * $(document).ready( function() {
  8284. * $('#example').dataTable( {
  8285. * "orderFixed": [[0,'asc']]
  8286. * } );
  8287. * } )
  8288. */
  8289. "aaSortingFixed": [],
  8290. /**
  8291. * DataTables can be instructed to load data to display in the table from a
  8292. * Ajax source. This option defines how that Ajax call is made and where to.
  8293. *
  8294. * The `ajax` property has three different modes of operation, depending on
  8295. * how it is defined. These are:
  8296. *
  8297. * * `string` - Set the URL from where the data should be loaded from.
  8298. * * `object` - Define properties for `jQuery.ajax`.
  8299. * * `function` - Custom data get function
  8300. *
  8301. * `string`
  8302. * --------
  8303. *
  8304. * As a string, the `ajax` property simply defines the URL from which
  8305. * DataTables will load data.
  8306. *
  8307. * `object`
  8308. * --------
  8309. *
  8310. * As an object, the parameters in the object are passed to
  8311. * [jQuery.ajax](http://api.jquery.com/jQuery.ajax/) allowing fine control
  8312. * of the Ajax request. DataTables has a number of default parameters which
  8313. * you can override using this option. Please refer to the jQuery
  8314. * documentation for a full description of the options available, although
  8315. * the following parameters provide additional options in DataTables or
  8316. * require special consideration:
  8317. *
  8318. * * `data` - As with jQuery, `data` can be provided as an object, but it
  8319. * can also be used as a function to manipulate the data DataTables sends
  8320. * to the server. The function takes a single parameter, an object of
  8321. * parameters with the values that DataTables has readied for sending. An
  8322. * object may be returned which will be merged into the DataTables
  8323. * defaults, or you can add the items to the object that was passed in and
  8324. * not return anything from the function. This supersedes `fnServerParams`
  8325. * from DataTables 1.9-.
  8326. *
  8327. * * `dataSrc` - By default DataTables will look for the property `data` (or
  8328. * `aaData` for compatibility with DataTables 1.9-) when obtaining data
  8329. * from an Ajax source or for server-side processing - this parameter
  8330. * allows that property to be changed. You can use Javascript dotted
  8331. * object notation to get a data source for multiple levels of nesting, or
  8332. * it my be used as a function. As a function it takes a single parameter,
  8333. * the JSON returned from the server, which can be manipulated as
  8334. * required, with the returned value being that used by DataTables as the
  8335. * data source for the table. This supersedes `sAjaxDataProp` from
  8336. * DataTables 1.9-.
  8337. *
  8338. * * `success` - Should not be overridden it is used internally in
  8339. * DataTables. To manipulate / transform the data returned by the server
  8340. * use `ajax.dataSrc`, or use `ajax` as a function (see below).
  8341. *
  8342. * `function`
  8343. * ----------
  8344. *
  8345. * As a function, making the Ajax call is left up to yourself allowing
  8346. * complete control of the Ajax request. Indeed, if desired, a method other
  8347. * than Ajax could be used to obtain the required data, such as Web storage
  8348. * or an AIR database.
  8349. *
  8350. * The function is given four parameters and no return is required. The
  8351. * parameters are:
  8352. *
  8353. * 1. _object_ - Data to send to the server
  8354. * 2. _function_ - Callback function that must be executed when the required
  8355. * data has been obtained. That data should be passed into the callback
  8356. * as the only parameter
  8357. * 3. _object_ - DataTables settings object for the table
  8358. *
  8359. * Note that this supersedes `fnServerData` from DataTables 1.9-.
  8360. *
  8361. * @type string|object|function
  8362. * @default null
  8363. *
  8364. * @dtopt Option
  8365. * @name DataTable.defaults.ajax
  8366. * @since 1.10.0
  8367. *
  8368. * @example
  8369. * // Get JSON data from a file via Ajax.
  8370. * // Note DataTables expects data in the form `{ data: [ ...data... ] }` by default).
  8371. * $('#example').dataTable( {
  8372. * "ajax": "data.json"
  8373. * } );
  8374. *
  8375. * @example
  8376. * // Get JSON data from a file via Ajax, using `dataSrc` to change
  8377. * // `data` to `tableData` (i.e. `{ tableData: [ ...data... ] }`)
  8378. * $('#example').dataTable( {
  8379. * "ajax": {
  8380. * "url": "data.json",
  8381. * "dataSrc": "tableData"
  8382. * }
  8383. * } );
  8384. *
  8385. * @example
  8386. * // Get JSON data from a file via Ajax, using `dataSrc` to read data
  8387. * // from a plain array rather than an array in an object
  8388. * $('#example').dataTable( {
  8389. * "ajax": {
  8390. * "url": "data.json",
  8391. * "dataSrc": ""
  8392. * }
  8393. * } );
  8394. *
  8395. * @example
  8396. * // Manipulate the data returned from the server - add a link to data
  8397. * // (note this can, should, be done using `render` for the column - this
  8398. * // is just a simple example of how the data can be manipulated).
  8399. * $('#example').dataTable( {
  8400. * "ajax": {
  8401. * "url": "data.json",
  8402. * "dataSrc": function ( json ) {
  8403. * for ( var i=0, ien=json.length ; i<ien ; i++ ) {
  8404. * json[i][0] = '<a href="/message/'+json[i][0]+'>View message</a>';
  8405. * }
  8406. * return json;
  8407. * }
  8408. * }
  8409. * } );
  8410. *
  8411. * @example
  8412. * // Add data to the request
  8413. * $('#example').dataTable( {
  8414. * "ajax": {
  8415. * "url": "data.json",
  8416. * "data": function ( d ) {
  8417. * return {
  8418. * "extra_search": $('#extra').val()
  8419. * };
  8420. * }
  8421. * }
  8422. * } );
  8423. *
  8424. * @example
  8425. * // Send request as POST
  8426. * $('#example').dataTable( {
  8427. * "ajax": {
  8428. * "url": "data.json",
  8429. * "type": "POST"
  8430. * }
  8431. * } );
  8432. *
  8433. * @example
  8434. * // Get the data from localStorage (could interface with a form for
  8435. * // adding, editing and removing rows).
  8436. * $('#example').dataTable( {
  8437. * "ajax": function (data, callback, settings) {
  8438. * callback(
  8439. * JSON.parse( localStorage.getItem('dataTablesData') )
  8440. * );
  8441. * }
  8442. * } );
  8443. */
  8444. "ajax": null,
  8445. /**
  8446. * This parameter allows you to readily specify the entries in the length drop
  8447. * down menu that DataTables shows when pagination is enabled. It can be
  8448. * either a 1D array of options which will be used for both the displayed
  8449. * option and the value, or a 2D array which will use the array in the first
  8450. * position as the value, and the array in the second position as the
  8451. * displayed options (useful for language strings such as 'All').
  8452. *
  8453. * Note that the `pageLength` property will be automatically set to the
  8454. * first value given in this array, unless `pageLength` is also provided.
  8455. * @type array
  8456. * @default [ 10, 25, 50, 100 ]
  8457. *
  8458. * @dtopt Option
  8459. * @name DataTable.defaults.lengthMenu
  8460. *
  8461. * @example
  8462. * $(document).ready( function() {
  8463. * $('#example').dataTable( {
  8464. * "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
  8465. * } );
  8466. * } );
  8467. */
  8468. "aLengthMenu": [ 10, 25, 50, 100 ],
  8469. /**
  8470. * The `columns` option in the initialisation parameter allows you to define
  8471. * details about the way individual columns behave. For a full list of
  8472. * column options that can be set, please see
  8473. * {@link DataTable.defaults.column}. Note that if you use `columns` to
  8474. * define your columns, you must have an entry in the array for every single
  8475. * column that you have in your table (these can be null if you don't which
  8476. * to specify any options).
  8477. * @member
  8478. *
  8479. * @name DataTable.defaults.column
  8480. */
  8481. "aoColumns": null,
  8482. /**
  8483. * Very similar to `columns`, `columnDefs` allows you to target a specific
  8484. * column, multiple columns, or all columns, using the `targets` property of
  8485. * each object in the array. This allows great flexibility when creating
  8486. * tables, as the `columnDefs` arrays can be of any length, targeting the
  8487. * columns you specifically want. `columnDefs` may use any of the column
  8488. * options available: {@link DataTable.defaults.column}, but it _must_
  8489. * have `targets` defined in each object in the array. Values in the `targets`
  8490. * array may be:
  8491. * <ul>
  8492. * <li>a string - class name will be matched on the TH for the column</li>
  8493. * <li>0 or a positive integer - column index counting from the left</li>
  8494. * <li>a negative integer - column index counting from the right</li>
  8495. * <li>the string "_all" - all columns (i.e. assign a default)</li>
  8496. * </ul>
  8497. * @member
  8498. *
  8499. * @name DataTable.defaults.columnDefs
  8500. */
  8501. "aoColumnDefs": null,
  8502. /**
  8503. * Basically the same as `search`, this parameter defines the individual column
  8504. * filtering state at initialisation time. The array must be of the same size
  8505. * as the number of columns, and each element be an object with the parameters
  8506. * `search` and `escapeRegex` (the latter is optional). 'null' is also
  8507. * accepted and the default will be used.
  8508. * @type array
  8509. * @default []
  8510. *
  8511. * @dtopt Option
  8512. * @name DataTable.defaults.searchCols
  8513. *
  8514. * @example
  8515. * $(document).ready( function() {
  8516. * $('#example').dataTable( {
  8517. * "searchCols": [
  8518. * null,
  8519. * { "search": "My filter" },
  8520. * null,
  8521. * { "search": "^[0-9]", "escapeRegex": false }
  8522. * ]
  8523. * } );
  8524. * } )
  8525. */
  8526. "aoSearchCols": [],
  8527. /**
  8528. * An array of CSS classes that should be applied to displayed rows. This
  8529. * array may be of any length, and DataTables will apply each class
  8530. * sequentially, looping when required.
  8531. * @type array
  8532. * @default null <i>Will take the values determined by the `oClasses.stripe*`
  8533. * options</i>
  8534. *
  8535. * @dtopt Option
  8536. * @name DataTable.defaults.stripeClasses
  8537. *
  8538. * @example
  8539. * $(document).ready( function() {
  8540. * $('#example').dataTable( {
  8541. * "stripeClasses": [ 'strip1', 'strip2', 'strip3' ]
  8542. * } );
  8543. * } )
  8544. */
  8545. "asStripeClasses": null,
  8546. /**
  8547. * Enable or disable automatic column width calculation. This can be disabled
  8548. * as an optimisation (it takes some time to calculate the widths) if the
  8549. * tables widths are passed in using `columns`.
  8550. * @type boolean
  8551. * @default true
  8552. *
  8553. * @dtopt Features
  8554. * @name DataTable.defaults.autoWidth
  8555. *
  8556. * @example
  8557. * $(document).ready( function () {
  8558. * $('#example').dataTable( {
  8559. * "autoWidth": false
  8560. * } );
  8561. * } );
  8562. */
  8563. "bAutoWidth": true,
  8564. /**
  8565. * Deferred rendering can provide DataTables with a huge speed boost when you
  8566. * are using an Ajax or JS data source for the table. This option, when set to
  8567. * true, will cause DataTables to defer the creation of the table elements for
  8568. * each row until they are needed for a draw - saving a significant amount of
  8569. * time.
  8570. * @type boolean
  8571. * @default false
  8572. *
  8573. * @dtopt Features
  8574. * @name DataTable.defaults.deferRender
  8575. *
  8576. * @example
  8577. * $(document).ready( function() {
  8578. * $('#example').dataTable( {
  8579. * "ajax": "sources/arrays.txt",
  8580. * "deferRender": true
  8581. * } );
  8582. * } );
  8583. */
  8584. "bDeferRender": false,
  8585. /**
  8586. * Replace a DataTable which matches the given selector and replace it with
  8587. * one which has the properties of the new initialisation object passed. If no
  8588. * table matches the selector, then the new DataTable will be constructed as
  8589. * per normal.
  8590. * @type boolean
  8591. * @default false
  8592. *
  8593. * @dtopt Options
  8594. * @name DataTable.defaults.destroy
  8595. *
  8596. * @example
  8597. * $(document).ready( function() {
  8598. * $('#example').dataTable( {
  8599. * "srollY": "200px",
  8600. * "paginate": false
  8601. * } );
  8602. *
  8603. * // Some time later....
  8604. * $('#example').dataTable( {
  8605. * "filter": false,
  8606. * "destroy": true
  8607. * } );
  8608. * } );
  8609. */
  8610. "bDestroy": false,
  8611. /**
  8612. * Enable or disable filtering of data. Filtering in DataTables is "smart" in
  8613. * that it allows the end user to input multiple words (space separated) and
  8614. * will match a row containing those words, even if not in the order that was
  8615. * specified (this allow matching across multiple columns). Note that if you
  8616. * wish to use filtering in DataTables this must remain 'true' - to remove the
  8617. * default filtering input box and retain filtering abilities, please use
  8618. * {@link DataTable.defaults.dom}.
  8619. * @type boolean
  8620. * @default true
  8621. *
  8622. * @dtopt Features
  8623. * @name DataTable.defaults.searching
  8624. *
  8625. * @example
  8626. * $(document).ready( function () {
  8627. * $('#example').dataTable( {
  8628. * "searching": false
  8629. * } );
  8630. * } );
  8631. */
  8632. "bFilter": true,
  8633. /**
  8634. * Enable or disable the table information display. This shows information
  8635. * about the data that is currently visible on the page, including information
  8636. * about filtered data if that action is being performed.
  8637. * @type boolean
  8638. * @default true
  8639. *
  8640. * @dtopt Features
  8641. * @name DataTable.defaults.info
  8642. *
  8643. * @example
  8644. * $(document).ready( function () {
  8645. * $('#example').dataTable( {
  8646. * "info": false
  8647. * } );
  8648. * } );
  8649. */
  8650. "bInfo": true,
  8651. /**
  8652. * Enable jQuery UI ThemeRoller support (required as ThemeRoller requires some
  8653. * slightly different and additional mark-up from what DataTables has
  8654. * traditionally used).
  8655. * @type boolean
  8656. * @default false
  8657. *
  8658. * @dtopt Features
  8659. * @name DataTable.defaults.jQueryUI
  8660. *
  8661. * @example
  8662. * $(document).ready( function() {
  8663. * $('#example').dataTable( {
  8664. * "jQueryUI": true
  8665. * } );
  8666. * } );
  8667. */
  8668. "bJQueryUI": false,
  8669. /**
  8670. * Allows the end user to select the size of a formatted page from a select
  8671. * menu (sizes are 10, 25, 50 and 100). Requires pagination (`paginate`).
  8672. * @type boolean
  8673. * @default true
  8674. *
  8675. * @dtopt Features
  8676. * @name DataTable.defaults.lengthChange
  8677. *
  8678. * @example
  8679. * $(document).ready( function () {
  8680. * $('#example').dataTable( {
  8681. * "lengthChange": false
  8682. * } );
  8683. * } );
  8684. */
  8685. "bLengthChange": true,
  8686. /**
  8687. * Enable or disable pagination.
  8688. * @type boolean
  8689. * @default true
  8690. *
  8691. * @dtopt Features
  8692. * @name DataTable.defaults.paging
  8693. *
  8694. * @example
  8695. * $(document).ready( function () {
  8696. * $('#example').dataTable( {
  8697. * "paging": false
  8698. * } );
  8699. * } );
  8700. */
  8701. "bPaginate": true,
  8702. /**
  8703. * Enable or disable the display of a 'processing' indicator when the table is
  8704. * being processed (e.g. a sort). This is particularly useful for tables with
  8705. * large amounts of data where it can take a noticeable amount of time to sort
  8706. * the entries.
  8707. * @type boolean
  8708. * @default false
  8709. *
  8710. * @dtopt Features
  8711. * @name DataTable.defaults.processing
  8712. *
  8713. * @example
  8714. * $(document).ready( function () {
  8715. * $('#example').dataTable( {
  8716. * "processing": true
  8717. * } );
  8718. * } );
  8719. */
  8720. "bProcessing": false,
  8721. /**
  8722. * Retrieve the DataTables object for the given selector. Note that if the
  8723. * table has already been initialised, this parameter will cause DataTables
  8724. * to simply return the object that has already been set up - it will not take
  8725. * account of any changes you might have made to the initialisation object
  8726. * passed to DataTables (setting this parameter to true is an acknowledgement
  8727. * that you understand this). `destroy` can be used to reinitialise a table if
  8728. * you need.
  8729. * @type boolean
  8730. * @default false
  8731. *
  8732. * @dtopt Options
  8733. * @name DataTable.defaults.retrieve
  8734. *
  8735. * @example
  8736. * $(document).ready( function() {
  8737. * initTable();
  8738. * tableActions();
  8739. * } );
  8740. *
  8741. * function initTable ()
  8742. * {
  8743. * return $('#example').dataTable( {
  8744. * "scrollY": "200px",
  8745. * "paginate": false,
  8746. * "retrieve": true
  8747. * } );
  8748. * }
  8749. *
  8750. * function tableActions ()
  8751. * {
  8752. * var table = initTable();
  8753. * // perform API operations with oTable
  8754. * }
  8755. */
  8756. "bRetrieve": false,
  8757. /**
  8758. * When vertical (y) scrolling is enabled, DataTables will force the height of
  8759. * the table's viewport to the given height at all times (useful for layout).
  8760. * However, this can look odd when filtering data down to a small data set,
  8761. * and the footer is left "floating" further down. This parameter (when
  8762. * enabled) will cause DataTables to collapse the table's viewport down when
  8763. * the result set will fit within the given Y height.
  8764. * @type boolean
  8765. * @default false
  8766. *
  8767. * @dtopt Options
  8768. * @name DataTable.defaults.scrollCollapse
  8769. *
  8770. * @example
  8771. * $(document).ready( function() {
  8772. * $('#example').dataTable( {
  8773. * "scrollY": "200",
  8774. * "scrollCollapse": true
  8775. * } );
  8776. * } );
  8777. */
  8778. "bScrollCollapse": false,
  8779. /**
  8780. * Configure DataTables to use server-side processing. Note that the
  8781. * `ajax` parameter must also be given in order to give DataTables a
  8782. * source to obtain the required data for each draw.
  8783. * @type boolean
  8784. * @default false
  8785. *
  8786. * @dtopt Features
  8787. * @dtopt Server-side
  8788. * @name DataTable.defaults.serverSide
  8789. *
  8790. * @example
  8791. * $(document).ready( function () {
  8792. * $('#example').dataTable( {
  8793. * "serverSide": true,
  8794. * "ajax": "xhr.php"
  8795. * } );
  8796. * } );
  8797. */
  8798. "bServerSide": false,
  8799. /**
  8800. * Enable or disable sorting of columns. Sorting of individual columns can be
  8801. * disabled by the `sortable` option for each column.
  8802. * @type boolean
  8803. * @default true
  8804. *
  8805. * @dtopt Features
  8806. * @name DataTable.defaults.ordering
  8807. *
  8808. * @example
  8809. * $(document).ready( function () {
  8810. * $('#example').dataTable( {
  8811. * "ordering": false
  8812. * } );
  8813. * } );
  8814. */
  8815. "bSort": true,
  8816. /**
  8817. * Enable or display DataTables' ability to sort multiple columns at the
  8818. * same time (activated by shift-click by the user).
  8819. * @type boolean
  8820. * @default true
  8821. *
  8822. * @dtopt Options
  8823. * @name DataTable.defaults.orderMulti
  8824. *
  8825. * @example
  8826. * // Disable multiple column sorting ability
  8827. * $(document).ready( function () {
  8828. * $('#example').dataTable( {
  8829. * "orderMulti": false
  8830. * } );
  8831. * } );
  8832. */
  8833. "bSortMulti": true,
  8834. /**
  8835. * Allows control over whether DataTables should use the top (true) unique
  8836. * cell that is found for a single column, or the bottom (false - default).
  8837. * This is useful when using complex headers.
  8838. * @type boolean
  8839. * @default false
  8840. *
  8841. * @dtopt Options
  8842. * @name DataTable.defaults.orderCellsTop
  8843. *
  8844. * @example
  8845. * $(document).ready( function() {
  8846. * $('#example').dataTable( {
  8847. * "orderCellsTop": true
  8848. * } );
  8849. * } );
  8850. */
  8851. "bSortCellsTop": false,
  8852. /**
  8853. * Enable or disable the addition of the classes `sorting\_1`, `sorting\_2` and
  8854. * `sorting\_3` to the columns which are currently being sorted on. This is
  8855. * presented as a feature switch as it can increase processing time (while
  8856. * classes are removed and added) so for large data sets you might want to
  8857. * turn this off.
  8858. * @type boolean
  8859. * @default true
  8860. *
  8861. * @dtopt Features
  8862. * @name DataTable.defaults.orderClasses
  8863. *
  8864. * @example
  8865. * $(document).ready( function () {
  8866. * $('#example').dataTable( {
  8867. * "orderClasses": false
  8868. * } );
  8869. * } );
  8870. */
  8871. "bSortClasses": true,
  8872. /**
  8873. * Enable or disable state saving. When enabled HTML5 `localStorage` will be
  8874. * used to save table display information such as pagination information,
  8875. * display length, filtering and sorting. As such when the end user reloads
  8876. * the page the display display will match what thy had previously set up.
  8877. *
  8878. * Due to the use of `localStorage` the default state saving is not supported
  8879. * in IE6 or 7. If state saving is required in those browsers, use
  8880. * `stateSaveCallback` to provide a storage solution such as cookies.
  8881. * @type boolean
  8882. * @default false
  8883. *
  8884. * @dtopt Features
  8885. * @name DataTable.defaults.stateSave
  8886. *
  8887. * @example
  8888. * $(document).ready( function () {
  8889. * $('#example').dataTable( {
  8890. * "stateSave": true
  8891. * } );
  8892. * } );
  8893. */
  8894. "bStateSave": false,
  8895. /**
  8896. * This function is called when a TR element is created (and all TD child
  8897. * elements have been inserted), or registered if using a DOM source, allowing
  8898. * manipulation of the TR element (adding classes etc).
  8899. * @type function
  8900. * @param {node} row "TR" element for the current row
  8901. * @param {array} data Raw data array for this row
  8902. * @param {int} dataIndex The index of this row in the internal aoData array
  8903. *
  8904. * @dtopt Callbacks
  8905. * @name DataTable.defaults.createdRow
  8906. *
  8907. * @example
  8908. * $(document).ready( function() {
  8909. * $('#example').dataTable( {
  8910. * "createdRow": function( row, data, dataIndex ) {
  8911. * // Bold the grade for all 'A' grade browsers
  8912. * if ( data[4] == "A" )
  8913. * {
  8914. * $('td:eq(4)', row).html( '<b>A</b>' );
  8915. * }
  8916. * }
  8917. * } );
  8918. * } );
  8919. */
  8920. "fnCreatedRow": null,
  8921. /**
  8922. * This function is called on every 'draw' event, and allows you to
  8923. * dynamically modify any aspect you want about the created DOM.
  8924. * @type function
  8925. * @param {object} settings DataTables settings object
  8926. *
  8927. * @dtopt Callbacks
  8928. * @name DataTable.defaults.drawCallback
  8929. *
  8930. * @example
  8931. * $(document).ready( function() {
  8932. * $('#example').dataTable( {
  8933. * "drawCallback": function( settings ) {
  8934. * alert( 'DataTables has redrawn the table' );
  8935. * }
  8936. * } );
  8937. * } );
  8938. */
  8939. "fnDrawCallback": null,
  8940. /**
  8941. * Identical to fnHeaderCallback() but for the table footer this function
  8942. * allows you to modify the table footer on every 'draw' event.
  8943. * @type function
  8944. * @param {node} foot "TR" element for the footer
  8945. * @param {array} data Full table data (as derived from the original HTML)
  8946. * @param {int} start Index for the current display starting point in the
  8947. * display array
  8948. * @param {int} end Index for the current display ending point in the
  8949. * display array
  8950. * @param {array int} display Index array to translate the visual position
  8951. * to the full data array
  8952. *
  8953. * @dtopt Callbacks
  8954. * @name DataTable.defaults.footerCallback
  8955. *
  8956. * @example
  8957. * $(document).ready( function() {
  8958. * $('#example').dataTable( {
  8959. * "footerCallback": function( tfoot, data, start, end, display ) {
  8960. * tfoot.getElementsByTagName('th')[0].innerHTML = "Starting index is "+start;
  8961. * }
  8962. * } );
  8963. * } )
  8964. */
  8965. "fnFooterCallback": null,
  8966. /**
  8967. * When rendering large numbers in the information element for the table
  8968. * (i.e. "Showing 1 to 10 of 57 entries") DataTables will render large numbers
  8969. * to have a comma separator for the 'thousands' units (e.g. 1 million is
  8970. * rendered as "1,000,000") to help readability for the end user. This
  8971. * function will override the default method DataTables uses.
  8972. * @type function
  8973. * @member
  8974. * @param {int} toFormat number to be formatted
  8975. * @returns {string} formatted string for DataTables to show the number
  8976. *
  8977. * @dtopt Callbacks
  8978. * @name DataTable.defaults.formatNumber
  8979. *
  8980. * @example
  8981. * // Format a number using a single quote for the separator (note that
  8982. * // this can also be done with the language.thousands option)
  8983. * $(document).ready( function() {
  8984. * $('#example').dataTable( {
  8985. * "formatNumber": function ( toFormat ) {
  8986. * return toFormat.toString().replace(
  8987. * /\B(?=(\d{3})+(?!\d))/g, "'"
  8988. * );
  8989. * };
  8990. * } );
  8991. * } );
  8992. */
  8993. "fnFormatNumber": function ( toFormat ) {
  8994. return toFormat.toString().replace(
  8995. /\B(?=(\d{3})+(?!\d))/g,
  8996. this.oLanguage.sThousands
  8997. );
  8998. },
  8999. /**
  9000. * This function is called on every 'draw' event, and allows you to
  9001. * dynamically modify the header row. This can be used to calculate and
  9002. * display useful information about the table.
  9003. * @type function
  9004. * @param {node} head "TR" element for the header
  9005. * @param {array} data Full table data (as derived from the original HTML)
  9006. * @param {int} start Index for the current display starting point in the
  9007. * display array
  9008. * @param {int} end Index for the current display ending point in the
  9009. * display array
  9010. * @param {array int} display Index array to translate the visual position
  9011. * to the full data array
  9012. *
  9013. * @dtopt Callbacks
  9014. * @name DataTable.defaults.headerCallback
  9015. *
  9016. * @example
  9017. * $(document).ready( function() {
  9018. * $('#example').dataTable( {
  9019. * "fheaderCallback": function( head, data, start, end, display ) {
  9020. * head.getElementsByTagName('th')[0].innerHTML = "Displaying "+(end-start)+" records";
  9021. * }
  9022. * } );
  9023. * } )
  9024. */
  9025. "fnHeaderCallback": null,
  9026. /**
  9027. * The information element can be used to convey information about the current
  9028. * state of the table. Although the internationalisation options presented by
  9029. * DataTables are quite capable of dealing with most customisations, there may
  9030. * be times where you wish to customise the string further. This callback
  9031. * allows you to do exactly that.
  9032. * @type function
  9033. * @param {object} oSettings DataTables settings object
  9034. * @param {int} start Starting position in data for the draw
  9035. * @param {int} end End position in data for the draw
  9036. * @param {int} max Total number of rows in the table (regardless of
  9037. * filtering)
  9038. * @param {int} total Total number of rows in the data set, after filtering
  9039. * @param {string} pre The string that DataTables has formatted using it's
  9040. * own rules
  9041. * @returns {string} The string to be displayed in the information element.
  9042. *
  9043. * @dtopt Callbacks
  9044. * @name DataTable.defaults.infoCallback
  9045. *
  9046. * @example
  9047. * $('#example').dataTable( {
  9048. * "infoCallback": function( settings, start, end, max, total, pre ) {
  9049. * return start +" to "+ end;
  9050. * }
  9051. * } );
  9052. */
  9053. "fnInfoCallback": null,
  9054. /**
  9055. * Called when the table has been initialised. Normally DataTables will
  9056. * initialise sequentially and there will be no need for this function,
  9057. * however, this does not hold true when using external language information
  9058. * since that is obtained using an async XHR call.
  9059. * @type function
  9060. * @param {object} settings DataTables settings object
  9061. * @param {object} json The JSON object request from the server - only
  9062. * present if client-side Ajax sourced data is used
  9063. *
  9064. * @dtopt Callbacks
  9065. * @name DataTable.defaults.initComplete
  9066. *
  9067. * @example
  9068. * $(document).ready( function() {
  9069. * $('#example').dataTable( {
  9070. * "initComplete": function(settings, json) {
  9071. * alert( 'DataTables has finished its initialisation.' );
  9072. * }
  9073. * } );
  9074. * } )
  9075. */
  9076. "fnInitComplete": null,
  9077. /**
  9078. * Called at the very start of each table draw and can be used to cancel the
  9079. * draw by returning false, any other return (including undefined) results in
  9080. * the full draw occurring).
  9081. * @type function
  9082. * @param {object} settings DataTables settings object
  9083. * @returns {boolean} False will cancel the draw, anything else (including no
  9084. * return) will allow it to complete.
  9085. *
  9086. * @dtopt Callbacks
  9087. * @name DataTable.defaults.preDrawCallback
  9088. *
  9089. * @example
  9090. * $(document).ready( function() {
  9091. * $('#example').dataTable( {
  9092. * "preDrawCallback": function( settings ) {
  9093. * if ( $('#test').val() == 1 ) {
  9094. * return false;
  9095. * }
  9096. * }
  9097. * } );
  9098. * } );
  9099. */
  9100. "fnPreDrawCallback": null,
  9101. /**
  9102. * This function allows you to 'post process' each row after it have been
  9103. * generated for each table draw, but before it is rendered on screen. This
  9104. * function might be used for setting the row class name etc.
  9105. * @type function
  9106. * @param {node} row "TR" element for the current row
  9107. * @param {array} data Raw data array for this row
  9108. * @param {int} displayIndex The display index for the current table draw
  9109. * @param {int} displayIndexFull The index of the data in the full list of
  9110. * rows (after filtering)
  9111. *
  9112. * @dtopt Callbacks
  9113. * @name DataTable.defaults.rowCallback
  9114. *
  9115. * @example
  9116. * $(document).ready( function() {
  9117. * $('#example').dataTable( {
  9118. * "rowCallback": function( row, data, displayIndex, displayIndexFull ) {
  9119. * // Bold the grade for all 'A' grade browsers
  9120. * if ( data[4] == "A" ) {
  9121. * $('td:eq(4)', row).html( '<b>A</b>' );
  9122. * }
  9123. * }
  9124. * } );
  9125. * } );
  9126. */
  9127. "fnRowCallback": null,
  9128. /**
  9129. * __Deprecated__ The functionality provided by this parameter has now been
  9130. * superseded by that provided through `ajax`, which should be used instead.
  9131. *
  9132. * This parameter allows you to override the default function which obtains
  9133. * the data from the server so something more suitable for your application.
  9134. * For example you could use POST data, or pull information from a Gears or
  9135. * AIR database.
  9136. * @type function
  9137. * @member
  9138. * @param {string} source HTTP source to obtain the data from (`ajax`)
  9139. * @param {array} data A key/value pair object containing the data to send
  9140. * to the server
  9141. * @param {function} callback to be called on completion of the data get
  9142. * process that will draw the data on the page.
  9143. * @param {object} settings DataTables settings object
  9144. *
  9145. * @dtopt Callbacks
  9146. * @dtopt Server-side
  9147. * @name DataTable.defaults.serverData
  9148. *
  9149. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9150. */
  9151. "fnServerData": null,
  9152. /**
  9153. * __Deprecated__ The functionality provided by this parameter has now been
  9154. * superseded by that provided through `ajax`, which should be used instead.
  9155. *
  9156. * It is often useful to send extra data to the server when making an Ajax
  9157. * request - for example custom filtering information, and this callback
  9158. * function makes it trivial to send extra information to the server. The
  9159. * passed in parameter is the data set that has been constructed by
  9160. * DataTables, and you can add to this or modify it as you require.
  9161. * @type function
  9162. * @param {array} data Data array (array of objects which are name/value
  9163. * pairs) that has been constructed by DataTables and will be sent to the
  9164. * server. In the case of Ajax sourced data with server-side processing
  9165. * this will be an empty array, for server-side processing there will be a
  9166. * significant number of parameters!
  9167. * @returns {undefined} Ensure that you modify the data array passed in,
  9168. * as this is passed by reference.
  9169. *
  9170. * @dtopt Callbacks
  9171. * @dtopt Server-side
  9172. * @name DataTable.defaults.serverParams
  9173. *
  9174. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9175. */
  9176. "fnServerParams": null,
  9177. /**
  9178. * Load the table state. With this function you can define from where, and how, the
  9179. * state of a table is loaded. By default DataTables will load from `localStorage`
  9180. * but you might wish to use a server-side database or cookies.
  9181. * @type function
  9182. * @member
  9183. * @param {object} settings DataTables settings object
  9184. * @return {object} The DataTables state object to be loaded
  9185. *
  9186. * @dtopt Callbacks
  9187. * @name DataTable.defaults.stateLoadCallback
  9188. *
  9189. * @example
  9190. * $(document).ready( function() {
  9191. * $('#example').dataTable( {
  9192. * "stateSave": true,
  9193. * "stateLoadCallback": function (settings) {
  9194. * var o;
  9195. *
  9196. * // Send an Ajax request to the server to get the data. Note that
  9197. * // this is a synchronous request.
  9198. * $.ajax( {
  9199. * "url": "/state_load",
  9200. * "async": false,
  9201. * "dataType": "json",
  9202. * "success": function (json) {
  9203. * o = json;
  9204. * }
  9205. * } );
  9206. *
  9207. * return o;
  9208. * }
  9209. * } );
  9210. * } );
  9211. */
  9212. "fnStateLoadCallback": function ( settings ) {
  9213. try {
  9214. return JSON.parse(
  9215. (settings.iStateDuration === -1 ? sessionStorage : localStorage).getItem(
  9216. 'DataTables_'+settings.sInstance+'_'+location.pathname
  9217. )
  9218. );
  9219. } catch (e) {}
  9220. },
  9221. /**
  9222. * Callback which allows modification of the saved state prior to loading that state.
  9223. * This callback is called when the table is loading state from the stored data, but
  9224. * prior to the settings object being modified by the saved state. Note that for
  9225. * plug-in authors, you should use the `stateLoadParams` event to load parameters for
  9226. * a plug-in.
  9227. * @type function
  9228. * @param {object} settings DataTables settings object
  9229. * @param {object} data The state object that is to be loaded
  9230. *
  9231. * @dtopt Callbacks
  9232. * @name DataTable.defaults.stateLoadParams
  9233. *
  9234. * @example
  9235. * // Remove a saved filter, so filtering is never loaded
  9236. * $(document).ready( function() {
  9237. * $('#example').dataTable( {
  9238. * "stateSave": true,
  9239. * "stateLoadParams": function (settings, data) {
  9240. * data.oSearch.sSearch = "";
  9241. * }
  9242. * } );
  9243. * } );
  9244. *
  9245. * @example
  9246. * // Disallow state loading by returning false
  9247. * $(document).ready( function() {
  9248. * $('#example').dataTable( {
  9249. * "stateSave": true,
  9250. * "stateLoadParams": function (settings, data) {
  9251. * return false;
  9252. * }
  9253. * } );
  9254. * } );
  9255. */
  9256. "fnStateLoadParams": null,
  9257. /**
  9258. * Callback that is called when the state has been loaded from the state saving method
  9259. * and the DataTables settings object has been modified as a result of the loaded state.
  9260. * @type function
  9261. * @param {object} settings DataTables settings object
  9262. * @param {object} data The state object that was loaded
  9263. *
  9264. * @dtopt Callbacks
  9265. * @name DataTable.defaults.stateLoaded
  9266. *
  9267. * @example
  9268. * // Show an alert with the filtering value that was saved
  9269. * $(document).ready( function() {
  9270. * $('#example').dataTable( {
  9271. * "stateSave": true,
  9272. * "stateLoaded": function (settings, data) {
  9273. * alert( 'Saved filter was: '+data.oSearch.sSearch );
  9274. * }
  9275. * } );
  9276. * } );
  9277. */
  9278. "fnStateLoaded": null,
  9279. /**
  9280. * Save the table state. This function allows you to define where and how the state
  9281. * information for the table is stored By default DataTables will use `localStorage`
  9282. * but you might wish to use a server-side database or cookies.
  9283. * @type function
  9284. * @member
  9285. * @param {object} settings DataTables settings object
  9286. * @param {object} data The state object to be saved
  9287. *
  9288. * @dtopt Callbacks
  9289. * @name DataTable.defaults.stateSaveCallback
  9290. *
  9291. * @example
  9292. * $(document).ready( function() {
  9293. * $('#example').dataTable( {
  9294. * "stateSave": true,
  9295. * "stateSaveCallback": function (settings, data) {
  9296. * // Send an Ajax request to the server with the state object
  9297. * $.ajax( {
  9298. * "url": "/state_save",
  9299. * "data": data,
  9300. * "dataType": "json",
  9301. * "method": "POST"
  9302. * "success": function () {}
  9303. * } );
  9304. * }
  9305. * } );
  9306. * } );
  9307. */
  9308. "fnStateSaveCallback": function ( settings, data ) {
  9309. try {
  9310. (settings.iStateDuration === -1 ? sessionStorage : localStorage).setItem(
  9311. 'DataTables_'+settings.sInstance+'_'+location.pathname,
  9312. JSON.stringify( data )
  9313. );
  9314. } catch (e) {}
  9315. },
  9316. /**
  9317. * Callback which allows modification of the state to be saved. Called when the table
  9318. * has changed state a new state save is required. This method allows modification of
  9319. * the state saving object prior to actually doing the save, including addition or
  9320. * other state properties or modification. Note that for plug-in authors, you should
  9321. * use the `stateSaveParams` event to save parameters for a plug-in.
  9322. * @type function
  9323. * @param {object} settings DataTables settings object
  9324. * @param {object} data The state object to be saved
  9325. *
  9326. * @dtopt Callbacks
  9327. * @name DataTable.defaults.stateSaveParams
  9328. *
  9329. * @example
  9330. * // Remove a saved filter, so filtering is never saved
  9331. * $(document).ready( function() {
  9332. * $('#example').dataTable( {
  9333. * "stateSave": true,
  9334. * "stateSaveParams": function (settings, data) {
  9335. * data.oSearch.sSearch = "";
  9336. * }
  9337. * } );
  9338. * } );
  9339. */
  9340. "fnStateSaveParams": null,
  9341. /**
  9342. * Duration for which the saved state information is considered valid. After this period
  9343. * has elapsed the state will be returned to the default.
  9344. * Value is given in seconds.
  9345. * @type int
  9346. * @default 7200 <i>(2 hours)</i>
  9347. *
  9348. * @dtopt Options
  9349. * @name DataTable.defaults.stateDuration
  9350. *
  9351. * @example
  9352. * $(document).ready( function() {
  9353. * $('#example').dataTable( {
  9354. * "stateDuration": 60*60*24; // 1 day
  9355. * } );
  9356. * } )
  9357. */
  9358. "iStateDuration": 7200,
  9359. /**
  9360. * When enabled DataTables will not make a request to the server for the first
  9361. * page draw - rather it will use the data already on the page (no sorting etc
  9362. * will be applied to it), thus saving on an XHR at load time. `deferLoading`
  9363. * is used to indicate that deferred loading is required, but it is also used
  9364. * to tell DataTables how many records there are in the full table (allowing
  9365. * the information element and pagination to be displayed correctly). In the case
  9366. * where a filtering is applied to the table on initial load, this can be
  9367. * indicated by giving the parameter as an array, where the first element is
  9368. * the number of records available after filtering and the second element is the
  9369. * number of records without filtering (allowing the table information element
  9370. * to be shown correctly).
  9371. * @type int | array
  9372. * @default null
  9373. *
  9374. * @dtopt Options
  9375. * @name DataTable.defaults.deferLoading
  9376. *
  9377. * @example
  9378. * // 57 records available in the table, no filtering applied
  9379. * $(document).ready( function() {
  9380. * $('#example').dataTable( {
  9381. * "serverSide": true,
  9382. * "ajax": "scripts/server_processing.php",
  9383. * "deferLoading": 57
  9384. * } );
  9385. * } );
  9386. *
  9387. * @example
  9388. * // 57 records after filtering, 100 without filtering (an initial filter applied)
  9389. * $(document).ready( function() {
  9390. * $('#example').dataTable( {
  9391. * "serverSide": true,
  9392. * "ajax": "scripts/server_processing.php",
  9393. * "deferLoading": [ 57, 100 ],
  9394. * "search": {
  9395. * "search": "my_filter"
  9396. * }
  9397. * } );
  9398. * } );
  9399. */
  9400. "iDeferLoading": null,
  9401. /**
  9402. * Number of rows to display on a single page when using pagination. If
  9403. * feature enabled (`lengthChange`) then the end user will be able to override
  9404. * this to a custom setting using a pop-up menu.
  9405. * @type int
  9406. * @default 10
  9407. *
  9408. * @dtopt Options
  9409. * @name DataTable.defaults.pageLength
  9410. *
  9411. * @example
  9412. * $(document).ready( function() {
  9413. * $('#example').dataTable( {
  9414. * "pageLength": 50
  9415. * } );
  9416. * } )
  9417. */
  9418. "iDisplayLength": 10,
  9419. /**
  9420. * Define the starting point for data display when using DataTables with
  9421. * pagination. Note that this parameter is the number of records, rather than
  9422. * the page number, so if you have 10 records per page and want to start on
  9423. * the third page, it should be "20".
  9424. * @type int
  9425. * @default 0
  9426. *
  9427. * @dtopt Options
  9428. * @name DataTable.defaults.displayStart
  9429. *
  9430. * @example
  9431. * $(document).ready( function() {
  9432. * $('#example').dataTable( {
  9433. * "displayStart": 20
  9434. * } );
  9435. * } )
  9436. */
  9437. "iDisplayStart": 0,
  9438. /**
  9439. * By default DataTables allows keyboard navigation of the table (sorting, paging,
  9440. * and filtering) by adding a `tabindex` attribute to the required elements. This
  9441. * allows you to tab through the controls and press the enter key to activate them.
  9442. * The tabindex is default 0, meaning that the tab follows the flow of the document.
  9443. * You can overrule this using this parameter if you wish. Use a value of -1 to
  9444. * disable built-in keyboard navigation.
  9445. * @type int
  9446. * @default 0
  9447. *
  9448. * @dtopt Options
  9449. * @name DataTable.defaults.tabIndex
  9450. *
  9451. * @example
  9452. * $(document).ready( function() {
  9453. * $('#example').dataTable( {
  9454. * "tabIndex": 1
  9455. * } );
  9456. * } );
  9457. */
  9458. "iTabIndex": 0,
  9459. /**
  9460. * Classes that DataTables assigns to the various components and features
  9461. * that it adds to the HTML table. This allows classes to be configured
  9462. * during initialisation in addition to through the static
  9463. * {@link DataTable.ext.oStdClasses} object).
  9464. * @namespace
  9465. * @name DataTable.defaults.classes
  9466. */
  9467. "oClasses": {},
  9468. /**
  9469. * All strings that DataTables uses in the user interface that it creates
  9470. * are defined in this object, allowing you to modified them individually or
  9471. * completely replace them all as required.
  9472. * @namespace
  9473. * @name DataTable.defaults.language
  9474. */
  9475. "oLanguage": {
  9476. /**
  9477. * Strings that are used for WAI-ARIA labels and controls only (these are not
  9478. * actually visible on the page, but will be read by screenreaders, and thus
  9479. * must be internationalised as well).
  9480. * @namespace
  9481. * @name DataTable.defaults.language.aria
  9482. */
  9483. "oAria": {
  9484. /**
  9485. * ARIA label that is added to the table headers when the column may be
  9486. * sorted ascending by activing the column (click or return when focused).
  9487. * Note that the column header is prefixed to this string.
  9488. * @type string
  9489. * @default : activate to sort column ascending
  9490. *
  9491. * @dtopt Language
  9492. * @name DataTable.defaults.language.aria.sortAscending
  9493. *
  9494. * @example
  9495. * $(document).ready( function() {
  9496. * $('#example').dataTable( {
  9497. * "language": {
  9498. * "aria": {
  9499. * "sortAscending": " - click/return to sort ascending"
  9500. * }
  9501. * }
  9502. * } );
  9503. * } );
  9504. */
  9505. "sSortAscending": ": activate to sort column ascending",
  9506. /**
  9507. * ARIA label that is added to the table headers when the column may be
  9508. * sorted descending by activing the column (click or return when focused).
  9509. * Note that the column header is prefixed to this string.
  9510. * @type string
  9511. * @default : activate to sort column ascending
  9512. *
  9513. * @dtopt Language
  9514. * @name DataTable.defaults.language.aria.sortDescending
  9515. *
  9516. * @example
  9517. * $(document).ready( function() {
  9518. * $('#example').dataTable( {
  9519. * "language": {
  9520. * "aria": {
  9521. * "sortDescending": " - click/return to sort descending"
  9522. * }
  9523. * }
  9524. * } );
  9525. * } );
  9526. */
  9527. "sSortDescending": ": activate to sort column descending"
  9528. },
  9529. /**
  9530. * Pagination string used by DataTables for the built-in pagination
  9531. * control types.
  9532. * @namespace
  9533. * @name DataTable.defaults.language.paginate
  9534. */
  9535. "oPaginate": {
  9536. /**
  9537. * Text to use when using the 'full_numbers' type of pagination for the
  9538. * button to take the user to the first page.
  9539. * @type string
  9540. * @default First
  9541. *
  9542. * @dtopt Language
  9543. * @name DataTable.defaults.language.paginate.first
  9544. *
  9545. * @example
  9546. * $(document).ready( function() {
  9547. * $('#example').dataTable( {
  9548. * "language": {
  9549. * "paginate": {
  9550. * "first": "First page"
  9551. * }
  9552. * }
  9553. * } );
  9554. * } );
  9555. */
  9556. "sFirst": "First",
  9557. /**
  9558. * Text to use when using the 'full_numbers' type of pagination for the
  9559. * button to take the user to the last page.
  9560. * @type string
  9561. * @default Last
  9562. *
  9563. * @dtopt Language
  9564. * @name DataTable.defaults.language.paginate.last
  9565. *
  9566. * @example
  9567. * $(document).ready( function() {
  9568. * $('#example').dataTable( {
  9569. * "language": {
  9570. * "paginate": {
  9571. * "last": "Last page"
  9572. * }
  9573. * }
  9574. * } );
  9575. * } );
  9576. */
  9577. "sLast": "Last",
  9578. /**
  9579. * Text to use for the 'next' pagination button (to take the user to the
  9580. * next page).
  9581. * @type string
  9582. * @default Next
  9583. *
  9584. * @dtopt Language
  9585. * @name DataTable.defaults.language.paginate.next
  9586. *
  9587. * @example
  9588. * $(document).ready( function() {
  9589. * $('#example').dataTable( {
  9590. * "language": {
  9591. * "paginate": {
  9592. * "next": "Next page"
  9593. * }
  9594. * }
  9595. * } );
  9596. * } );
  9597. */
  9598. "sNext": "Next",
  9599. /**
  9600. * Text to use for the 'previous' pagination button (to take the user to
  9601. * the previous page).
  9602. * @type string
  9603. * @default Previous
  9604. *
  9605. * @dtopt Language
  9606. * @name DataTable.defaults.language.paginate.previous
  9607. *
  9608. * @example
  9609. * $(document).ready( function() {
  9610. * $('#example').dataTable( {
  9611. * "language": {
  9612. * "paginate": {
  9613. * "previous": "Previous page"
  9614. * }
  9615. * }
  9616. * } );
  9617. * } );
  9618. */
  9619. "sPrevious": "Previous"
  9620. },
  9621. /**
  9622. * This string is shown in preference to `zeroRecords` when the table is
  9623. * empty of data (regardless of filtering). Note that this is an optional
  9624. * parameter - if it is not given, the value of `zeroRecords` will be used
  9625. * instead (either the default or given value).
  9626. * @type string
  9627. * @default No data available in table
  9628. *
  9629. * @dtopt Language
  9630. * @name DataTable.defaults.language.emptyTable
  9631. *
  9632. * @example
  9633. * $(document).ready( function() {
  9634. * $('#example').dataTable( {
  9635. * "language": {
  9636. * "emptyTable": "No data available in table"
  9637. * }
  9638. * } );
  9639. * } );
  9640. */
  9641. "sEmptyTable": "No data available in table",
  9642. /**
  9643. * This string gives information to the end user about the information
  9644. * that is current on display on the page. The following tokens can be
  9645. * used in the string and will be dynamically replaced as the table
  9646. * display updates. This tokens can be placed anywhere in the string, or
  9647. * removed as needed by the language requires:
  9648. *
  9649. * * `\_START\_` - Display index of the first record on the current page
  9650. * * `\_END\_` - Display index of the last record on the current page
  9651. * * `\_TOTAL\_` - Number of records in the table after filtering
  9652. * * `\_MAX\_` - Number of records in the table without filtering
  9653. * * `\_PAGE\_` - Current page number
  9654. * * `\_PAGES\_` - Total number of pages of data in the table
  9655. *
  9656. * @type string
  9657. * @default Showing _START_ to _END_ of _TOTAL_ entries
  9658. *
  9659. * @dtopt Language
  9660. * @name DataTable.defaults.language.info
  9661. *
  9662. * @example
  9663. * $(document).ready( function() {
  9664. * $('#example').dataTable( {
  9665. * "language": {
  9666. * "info": "Showing page _PAGE_ of _PAGES_"
  9667. * }
  9668. * } );
  9669. * } );
  9670. */
  9671. "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
  9672. /**
  9673. * Display information string for when the table is empty. Typically the
  9674. * format of this string should match `info`.
  9675. * @type string
  9676. * @default Showing 0 to 0 of 0 entries
  9677. *
  9678. * @dtopt Language
  9679. * @name DataTable.defaults.language.infoEmpty
  9680. *
  9681. * @example
  9682. * $(document).ready( function() {
  9683. * $('#example').dataTable( {
  9684. * "language": {
  9685. * "infoEmpty": "No entries to show"
  9686. * }
  9687. * } );
  9688. * } );
  9689. */
  9690. "sInfoEmpty": "Showing 0 to 0 of 0 entries",
  9691. /**
  9692. * When a user filters the information in a table, this string is appended
  9693. * to the information (`info`) to give an idea of how strong the filtering
  9694. * is. The variable _MAX_ is dynamically updated.
  9695. * @type string
  9696. * @default (filtered from _MAX_ total entries)
  9697. *
  9698. * @dtopt Language
  9699. * @name DataTable.defaults.language.infoFiltered
  9700. *
  9701. * @example
  9702. * $(document).ready( function() {
  9703. * $('#example').dataTable( {
  9704. * "language": {
  9705. * "infoFiltered": " - filtering from _MAX_ records"
  9706. * }
  9707. * } );
  9708. * } );
  9709. */
  9710. "sInfoFiltered": "(filtered from _MAX_ total entries)",
  9711. /**
  9712. * If can be useful to append extra information to the info string at times,
  9713. * and this variable does exactly that. This information will be appended to
  9714. * the `info` (`infoEmpty` and `infoFiltered` in whatever combination they are
  9715. * being used) at all times.
  9716. * @type string
  9717. * @default <i>Empty string</i>
  9718. *
  9719. * @dtopt Language
  9720. * @name DataTable.defaults.language.infoPostFix
  9721. *
  9722. * @example
  9723. * $(document).ready( function() {
  9724. * $('#example').dataTable( {
  9725. * "language": {
  9726. * "infoPostFix": "All records shown are derived from real information."
  9727. * }
  9728. * } );
  9729. * } );
  9730. */
  9731. "sInfoPostFix": "",
  9732. /**
  9733. * This decimal place operator is a little different from the other
  9734. * language options since DataTables doesn't output floating point
  9735. * numbers, so it won't ever use this for display of a number. Rather,
  9736. * what this parameter does is modify the sort methods of the table so
  9737. * that numbers which are in a format which has a character other than
  9738. * a period (`.`) as a decimal place will be sorted numerically.
  9739. *
  9740. * Note that numbers with different decimal places cannot be shown in
  9741. * the same table and still be sortable, the table must be consistent.
  9742. * However, multiple different tables on the page can use different
  9743. * decimal place characters.
  9744. * @type string
  9745. * @default
  9746. *
  9747. * @dtopt Language
  9748. * @name DataTable.defaults.language.decimal
  9749. *
  9750. * @example
  9751. * $(document).ready( function() {
  9752. * $('#example').dataTable( {
  9753. * "language": {
  9754. * "decimal": ","
  9755. * "thousands": "."
  9756. * }
  9757. * } );
  9758. * } );
  9759. */
  9760. "sDecimal": "",
  9761. /**
  9762. * DataTables has a build in number formatter (`formatNumber`) which is
  9763. * used to format large numbers that are used in the table information.
  9764. * By default a comma is used, but this can be trivially changed to any
  9765. * character you wish with this parameter.
  9766. * @type string
  9767. * @default ,
  9768. *
  9769. * @dtopt Language
  9770. * @name DataTable.defaults.language.thousands
  9771. *
  9772. * @example
  9773. * $(document).ready( function() {
  9774. * $('#example').dataTable( {
  9775. * "language": {
  9776. * "thousands": "'"
  9777. * }
  9778. * } );
  9779. * } );
  9780. */
  9781. "sThousands": ",",
  9782. /**
  9783. * Detail the action that will be taken when the drop down menu for the
  9784. * pagination length option is changed. The '_MENU_' variable is replaced
  9785. * with a default select list of 10, 25, 50 and 100, and can be replaced
  9786. * with a custom select box if required.
  9787. * @type string
  9788. * @default Show _MENU_ entries
  9789. *
  9790. * @dtopt Language
  9791. * @name DataTable.defaults.language.lengthMenu
  9792. *
  9793. * @example
  9794. * // Language change only
  9795. * $(document).ready( function() {
  9796. * $('#example').dataTable( {
  9797. * "language": {
  9798. * "lengthMenu": "Display _MENU_ records"
  9799. * }
  9800. * } );
  9801. * } );
  9802. *
  9803. * @example
  9804. * // Language and options change
  9805. * $(document).ready( function() {
  9806. * $('#example').dataTable( {
  9807. * "language": {
  9808. * "lengthMenu": 'Display <select>'+
  9809. * '<option value="10">10</option>'+
  9810. * '<option value="20">20</option>'+
  9811. * '<option value="30">30</option>'+
  9812. * '<option value="40">40</option>'+
  9813. * '<option value="50">50</option>'+
  9814. * '<option value="-1">All</option>'+
  9815. * '</select> records'
  9816. * }
  9817. * } );
  9818. * } );
  9819. */
  9820. "sLengthMenu": "Show _MENU_ entries",
  9821. /**
  9822. * When using Ajax sourced data and during the first draw when DataTables is
  9823. * gathering the data, this message is shown in an empty row in the table to
  9824. * indicate to the end user the the data is being loaded. Note that this
  9825. * parameter is not used when loading data by server-side processing, just
  9826. * Ajax sourced data with client-side processing.
  9827. * @type string
  9828. * @default Loading...
  9829. *
  9830. * @dtopt Language
  9831. * @name DataTable.defaults.language.loadingRecords
  9832. *
  9833. * @example
  9834. * $(document).ready( function() {
  9835. * $('#example').dataTable( {
  9836. * "language": {
  9837. * "loadingRecords": "Please wait - loading..."
  9838. * }
  9839. * } );
  9840. * } );
  9841. */
  9842. "sLoadingRecords": "Loading...",
  9843. /**
  9844. * Text which is displayed when the table is processing a user action
  9845. * (usually a sort command or similar).
  9846. * @type string
  9847. * @default Processing...
  9848. *
  9849. * @dtopt Language
  9850. * @name DataTable.defaults.language.processing
  9851. *
  9852. * @example
  9853. * $(document).ready( function() {
  9854. * $('#example').dataTable( {
  9855. * "language": {
  9856. * "processing": "DataTables is currently busy"
  9857. * }
  9858. * } );
  9859. * } );
  9860. */
  9861. "sProcessing": "Processing...",
  9862. /**
  9863. * Details the actions that will be taken when the user types into the
  9864. * filtering input text box. The variable "_INPUT_", if used in the string,
  9865. * is replaced with the HTML text box for the filtering input allowing
  9866. * control over where it appears in the string. If "_INPUT_" is not given
  9867. * then the input box is appended to the string automatically.
  9868. * @type string
  9869. * @default Search:
  9870. *
  9871. * @dtopt Language
  9872. * @name DataTable.defaults.language.search
  9873. *
  9874. * @example
  9875. * // Input text box will be appended at the end automatically
  9876. * $(document).ready( function() {
  9877. * $('#example').dataTable( {
  9878. * "language": {
  9879. * "search": "Filter records:"
  9880. * }
  9881. * } );
  9882. * } );
  9883. *
  9884. * @example
  9885. * // Specify where the filter should appear
  9886. * $(document).ready( function() {
  9887. * $('#example').dataTable( {
  9888. * "language": {
  9889. * "search": "Apply filter _INPUT_ to table"
  9890. * }
  9891. * } );
  9892. * } );
  9893. */
  9894. "sSearch": "Search:",
  9895. /**
  9896. * Assign a `placeholder` attribute to the search `input` element
  9897. * @type string
  9898. * @default
  9899. *
  9900. * @dtopt Language
  9901. * @name DataTable.defaults.language.searchPlaceholder
  9902. */
  9903. "sSearchPlaceholder": "",
  9904. /**
  9905. * All of the language information can be stored in a file on the
  9906. * server-side, which DataTables will look up if this parameter is passed.
  9907. * It must store the URL of the language file, which is in a JSON format,
  9908. * and the object has the same properties as the oLanguage object in the
  9909. * initialiser object (i.e. the above parameters). Please refer to one of
  9910. * the example language files to see how this works in action.
  9911. * @type string
  9912. * @default <i>Empty string - i.e. disabled</i>
  9913. *
  9914. * @dtopt Language
  9915. * @name DataTable.defaults.language.url
  9916. *
  9917. * @example
  9918. * $(document).ready( function() {
  9919. * $('#example').dataTable( {
  9920. * "language": {
  9921. * "url": "http://www.sprymedia.co.uk/dataTables/lang.txt"
  9922. * }
  9923. * } );
  9924. * } );
  9925. */
  9926. "sUrl": "",
  9927. /**
  9928. * Text shown inside the table records when the is no information to be
  9929. * displayed after filtering. `emptyTable` is shown when there is simply no
  9930. * information in the table at all (regardless of filtering).
  9931. * @type string
  9932. * @default No matching records found
  9933. *
  9934. * @dtopt Language
  9935. * @name DataTable.defaults.language.zeroRecords
  9936. *
  9937. * @example
  9938. * $(document).ready( function() {
  9939. * $('#example').dataTable( {
  9940. * "language": {
  9941. * "zeroRecords": "No records to display"
  9942. * }
  9943. * } );
  9944. * } );
  9945. */
  9946. "sZeroRecords": "No matching records found"
  9947. },
  9948. /**
  9949. * This parameter allows you to have define the global filtering state at
  9950. * initialisation time. As an object the `search` parameter must be
  9951. * defined, but all other parameters are optional. When `regex` is true,
  9952. * the search string will be treated as a regular expression, when false
  9953. * (default) it will be treated as a straight string. When `smart`
  9954. * DataTables will use it's smart filtering methods (to word match at
  9955. * any point in the data), when false this will not be done.
  9956. * @namespace
  9957. * @extends DataTable.models.oSearch
  9958. *
  9959. * @dtopt Options
  9960. * @name DataTable.defaults.search
  9961. *
  9962. * @example
  9963. * $(document).ready( function() {
  9964. * $('#example').dataTable( {
  9965. * "search": {"search": "Initial search"}
  9966. * } );
  9967. * } )
  9968. */
  9969. "oSearch": $.extend( {}, DataTable.models.oSearch ),
  9970. /**
  9971. * __Deprecated__ The functionality provided by this parameter has now been
  9972. * superseded by that provided through `ajax`, which should be used instead.
  9973. *
  9974. * By default DataTables will look for the property `data` (or `aaData` for
  9975. * compatibility with DataTables 1.9-) when obtaining data from an Ajax
  9976. * source or for server-side processing - this parameter allows that
  9977. * property to be changed. You can use Javascript dotted object notation to
  9978. * get a data source for multiple levels of nesting.
  9979. * @type string
  9980. * @default data
  9981. *
  9982. * @dtopt Options
  9983. * @dtopt Server-side
  9984. * @name DataTable.defaults.ajaxDataProp
  9985. *
  9986. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9987. */
  9988. "sAjaxDataProp": "data",
  9989. /**
  9990. * __Deprecated__ The functionality provided by this parameter has now been
  9991. * superseded by that provided through `ajax`, which should be used instead.
  9992. *
  9993. * You can instruct DataTables to load data from an external
  9994. * source using this parameter (use aData if you want to pass data in you
  9995. * already have). Simply provide a url a JSON object can be obtained from.
  9996. * @type string
  9997. * @default null
  9998. *
  9999. * @dtopt Options
  10000. * @dtopt Server-side
  10001. * @name DataTable.defaults.ajaxSource
  10002. *
  10003. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10004. */
  10005. "sAjaxSource": null,
  10006. /**
  10007. * This initialisation variable allows you to specify exactly where in the
  10008. * DOM you want DataTables to inject the various controls it adds to the page
  10009. * (for example you might want the pagination controls at the top of the
  10010. * table). DIV elements (with or without a custom class) can also be added to
  10011. * aid styling. The follow syntax is used:
  10012. * <ul>
  10013. * <li>The following options are allowed:
  10014. * <ul>
  10015. * <li>'l' - Length changing</li>
  10016. * <li>'f' - Filtering input</li>
  10017. * <li>'t' - The table!</li>
  10018. * <li>'i' - Information</li>
  10019. * <li>'p' - Pagination</li>
  10020. * <li>'r' - pRocessing</li>
  10021. * </ul>
  10022. * </li>
  10023. * <li>The following constants are allowed:
  10024. * <ul>
  10025. * <li>'H' - jQueryUI theme "header" classes ('fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix')</li>
  10026. * <li>'F' - jQueryUI theme "footer" classes ('fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix')</li>
  10027. * </ul>
  10028. * </li>
  10029. * <li>The following syntax is expected:
  10030. * <ul>
  10031. * <li>'&lt;' and '&gt;' - div elements</li>
  10032. * <li>'&lt;"class" and '&gt;' - div with a class</li>
  10033. * <li>'&lt;"#id" and '&gt;' - div with an ID</li>
  10034. * </ul>
  10035. * </li>
  10036. * <li>Examples:
  10037. * <ul>
  10038. * <li>'&lt;"wrapper"flipt&gt;'</li>
  10039. * <li>'&lt;lf&lt;t&gt;ip&gt;'</li>
  10040. * </ul>
  10041. * </li>
  10042. * </ul>
  10043. * @type string
  10044. * @default lfrtip <i>(when `jQueryUI` is false)</i> <b>or</b>
  10045. * <"H"lfr>t<"F"ip> <i>(when `jQueryUI` is true)</i>
  10046. *
  10047. * @dtopt Options
  10048. * @name DataTable.defaults.dom
  10049. *
  10050. * @example
  10051. * $(document).ready( function() {
  10052. * $('#example').dataTable( {
  10053. * "dom": '&lt;"top"i&gt;rt&lt;"bottom"flp&gt;&lt;"clear"&gt;'
  10054. * } );
  10055. * } );
  10056. */
  10057. "sDom": "lfrtip",
  10058. /**
  10059. * Search delay option. This will throttle full table searches that use the
  10060. * DataTables provided search input element (it does not effect calls to
  10061. * `dt-api search()`, providing a delay before the search is made.
  10062. * @type integer
  10063. * @default 0
  10064. *
  10065. * @dtopt Options
  10066. * @name DataTable.defaults.searchDelay
  10067. *
  10068. * @example
  10069. * $(document).ready( function() {
  10070. * $('#example').dataTable( {
  10071. * "searchDelay": 200
  10072. * } );
  10073. * } )
  10074. */
  10075. "searchDelay": null,
  10076. /**
  10077. * DataTables features four different built-in options for the buttons to
  10078. * display for pagination control:
  10079. *
  10080. * * `simple` - 'Previous' and 'Next' buttons only
  10081. * * 'simple_numbers` - 'Previous' and 'Next' buttons, plus page numbers
  10082. * * `full` - 'First', 'Previous', 'Next' and 'Last' buttons
  10083. * * `full_numbers` - 'First', 'Previous', 'Next' and 'Last' buttons, plus
  10084. * page numbers
  10085. *
  10086. * Further methods can be added using {@link DataTable.ext.oPagination}.
  10087. * @type string
  10088. * @default simple_numbers
  10089. *
  10090. * @dtopt Options
  10091. * @name DataTable.defaults.pagingType
  10092. *
  10093. * @example
  10094. * $(document).ready( function() {
  10095. * $('#example').dataTable( {
  10096. * "pagingType": "full_numbers"
  10097. * } );
  10098. * } )
  10099. */
  10100. "sPaginationType": "simple_numbers",
  10101. /**
  10102. * Enable horizontal scrolling. When a table is too wide to fit into a
  10103. * certain layout, or you have a large number of columns in the table, you
  10104. * can enable x-scrolling to show the table in a viewport, which can be
  10105. * scrolled. This property can be `true` which will allow the table to
  10106. * scroll horizontally when needed, or any CSS unit, or a number (in which
  10107. * case it will be treated as a pixel measurement). Setting as simply `true`
  10108. * is recommended.
  10109. * @type boolean|string
  10110. * @default <i>blank string - i.e. disabled</i>
  10111. *
  10112. * @dtopt Features
  10113. * @name DataTable.defaults.scrollX
  10114. *
  10115. * @example
  10116. * $(document).ready( function() {
  10117. * $('#example').dataTable( {
  10118. * "scrollX": true,
  10119. * "scrollCollapse": true
  10120. * } );
  10121. * } );
  10122. */
  10123. "sScrollX": "",
  10124. /**
  10125. * This property can be used to force a DataTable to use more width than it
  10126. * might otherwise do when x-scrolling is enabled. For example if you have a
  10127. * table which requires to be well spaced, this parameter is useful for
  10128. * "over-sizing" the table, and thus forcing scrolling. This property can by
  10129. * any CSS unit, or a number (in which case it will be treated as a pixel
  10130. * measurement).
  10131. * @type string
  10132. * @default <i>blank string - i.e. disabled</i>
  10133. *
  10134. * @dtopt Options
  10135. * @name DataTable.defaults.scrollXInner
  10136. *
  10137. * @example
  10138. * $(document).ready( function() {
  10139. * $('#example').dataTable( {
  10140. * "scrollX": "100%",
  10141. * "scrollXInner": "110%"
  10142. * } );
  10143. * } );
  10144. */
  10145. "sScrollXInner": "",
  10146. /**
  10147. * Enable vertical scrolling. Vertical scrolling will constrain the DataTable
  10148. * to the given height, and enable scrolling for any data which overflows the
  10149. * current viewport. This can be used as an alternative to paging to display
  10150. * a lot of data in a small area (although paging and scrolling can both be
  10151. * enabled at the same time). This property can be any CSS unit, or a number
  10152. * (in which case it will be treated as a pixel measurement).
  10153. * @type string
  10154. * @default <i>blank string - i.e. disabled</i>
  10155. *
  10156. * @dtopt Features
  10157. * @name DataTable.defaults.scrollY
  10158. *
  10159. * @example
  10160. * $(document).ready( function() {
  10161. * $('#example').dataTable( {
  10162. * "scrollY": "200px",
  10163. * "paginate": false
  10164. * } );
  10165. * } );
  10166. */
  10167. "sScrollY": "",
  10168. /**
  10169. * __Deprecated__ The functionality provided by this parameter has now been
  10170. * superseded by that provided through `ajax`, which should be used instead.
  10171. *
  10172. * Set the HTTP method that is used to make the Ajax call for server-side
  10173. * processing or Ajax sourced data.
  10174. * @type string
  10175. * @default GET
  10176. *
  10177. * @dtopt Options
  10178. * @dtopt Server-side
  10179. * @name DataTable.defaults.serverMethod
  10180. *
  10181. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10182. */
  10183. "sServerMethod": "GET",
  10184. /**
  10185. * DataTables makes use of renderers when displaying HTML elements for
  10186. * a table. These renderers can be added or modified by plug-ins to
  10187. * generate suitable mark-up for a site. For example the Bootstrap
  10188. * integration plug-in for DataTables uses a paging button renderer to
  10189. * display pagination buttons in the mark-up required by Bootstrap.
  10190. *
  10191. * For further information about the renderers available see
  10192. * DataTable.ext.renderer
  10193. * @type string|object
  10194. * @default null
  10195. *
  10196. * @name DataTable.defaults.renderer
  10197. *
  10198. */
  10199. "renderer": null,
  10200. /**
  10201. * Set the data property name that DataTables should use to get a row's id
  10202. * to set as the `id` property in the node.
  10203. * @type string
  10204. * @default DT_RowId
  10205. *
  10206. * @name DataTable.defaults.rowId
  10207. */
  10208. "rowId": "DT_RowId"
  10209. };
  10210. _fnHungarianMap( DataTable.defaults );
  10211. /*
  10212. * Developer note - See note in model.defaults.js about the use of Hungarian
  10213. * notation and camel case.
  10214. */
  10215. /**
  10216. * Column options that can be given to DataTables at initialisation time.
  10217. * @namespace
  10218. */
  10219. DataTable.defaults.column = {
  10220. /**
  10221. * Define which column(s) an order will occur on for this column. This
  10222. * allows a column's ordering to take multiple columns into account when
  10223. * doing a sort or use the data from a different column. For example first
  10224. * name / last name columns make sense to do a multi-column sort over the
  10225. * two columns.
  10226. * @type array|int
  10227. * @default null <i>Takes the value of the column index automatically</i>
  10228. *
  10229. * @name DataTable.defaults.column.orderData
  10230. * @dtopt Columns
  10231. *
  10232. * @example
  10233. * // Using `columnDefs`
  10234. * $(document).ready( function() {
  10235. * $('#example').dataTable( {
  10236. * "columnDefs": [
  10237. * { "orderData": [ 0, 1 ], "targets": [ 0 ] },
  10238. * { "orderData": [ 1, 0 ], "targets": [ 1 ] },
  10239. * { "orderData": 2, "targets": [ 2 ] }
  10240. * ]
  10241. * } );
  10242. * } );
  10243. *
  10244. * @example
  10245. * // Using `columns`
  10246. * $(document).ready( function() {
  10247. * $('#example').dataTable( {
  10248. * "columns": [
  10249. * { "orderData": [ 0, 1 ] },
  10250. * { "orderData": [ 1, 0 ] },
  10251. * { "orderData": 2 },
  10252. * null,
  10253. * null
  10254. * ]
  10255. * } );
  10256. * } );
  10257. */
  10258. "aDataSort": null,
  10259. "iDataSort": -1,
  10260. /**
  10261. * You can control the default ordering direction, and even alter the
  10262. * behaviour of the sort handler (i.e. only allow ascending ordering etc)
  10263. * using this parameter.
  10264. * @type array
  10265. * @default [ 'asc', 'desc' ]
  10266. *
  10267. * @name DataTable.defaults.column.orderSequence
  10268. * @dtopt Columns
  10269. *
  10270. * @example
  10271. * // Using `columnDefs`
  10272. * $(document).ready( function() {
  10273. * $('#example').dataTable( {
  10274. * "columnDefs": [
  10275. * { "orderSequence": [ "asc" ], "targets": [ 1 ] },
  10276. * { "orderSequence": [ "desc", "asc", "asc" ], "targets": [ 2 ] },
  10277. * { "orderSequence": [ "desc" ], "targets": [ 3 ] }
  10278. * ]
  10279. * } );
  10280. * } );
  10281. *
  10282. * @example
  10283. * // Using `columns`
  10284. * $(document).ready( function() {
  10285. * $('#example').dataTable( {
  10286. * "columns": [
  10287. * null,
  10288. * { "orderSequence": [ "asc" ] },
  10289. * { "orderSequence": [ "desc", "asc", "asc" ] },
  10290. * { "orderSequence": [ "desc" ] },
  10291. * null
  10292. * ]
  10293. * } );
  10294. * } );
  10295. */
  10296. "asSorting": [ 'asc', 'desc' ],
  10297. /**
  10298. * Enable or disable filtering on the data in this column.
  10299. * @type boolean
  10300. * @default true
  10301. *
  10302. * @name DataTable.defaults.column.searchable
  10303. * @dtopt Columns
  10304. *
  10305. * @example
  10306. * // Using `columnDefs`
  10307. * $(document).ready( function() {
  10308. * $('#example').dataTable( {
  10309. * "columnDefs": [
  10310. * { "searchable": false, "targets": [ 0 ] }
  10311. * ] } );
  10312. * } );
  10313. *
  10314. * @example
  10315. * // Using `columns`
  10316. * $(document).ready( function() {
  10317. * $('#example').dataTable( {
  10318. * "columns": [
  10319. * { "searchable": false },
  10320. * null,
  10321. * null,
  10322. * null,
  10323. * null
  10324. * ] } );
  10325. * } );
  10326. */
  10327. "bSearchable": true,
  10328. /**
  10329. * Enable or disable ordering on this column.
  10330. * @type boolean
  10331. * @default true
  10332. *
  10333. * @name DataTable.defaults.column.orderable
  10334. * @dtopt Columns
  10335. *
  10336. * @example
  10337. * // Using `columnDefs`
  10338. * $(document).ready( function() {
  10339. * $('#example').dataTable( {
  10340. * "columnDefs": [
  10341. * { "orderable": false, "targets": [ 0 ] }
  10342. * ] } );
  10343. * } );
  10344. *
  10345. * @example
  10346. * // Using `columns`
  10347. * $(document).ready( function() {
  10348. * $('#example').dataTable( {
  10349. * "columns": [
  10350. * { "orderable": false },
  10351. * null,
  10352. * null,
  10353. * null,
  10354. * null
  10355. * ] } );
  10356. * } );
  10357. */
  10358. "bSortable": true,
  10359. /**
  10360. * Enable or disable the display of this column.
  10361. * @type boolean
  10362. * @default true
  10363. *
  10364. * @name DataTable.defaults.column.visible
  10365. * @dtopt Columns
  10366. *
  10367. * @example
  10368. * // Using `columnDefs`
  10369. * $(document).ready( function() {
  10370. * $('#example').dataTable( {
  10371. * "columnDefs": [
  10372. * { "visible": false, "targets": [ 0 ] }
  10373. * ] } );
  10374. * } );
  10375. *
  10376. * @example
  10377. * // Using `columns`
  10378. * $(document).ready( function() {
  10379. * $('#example').dataTable( {
  10380. * "columns": [
  10381. * { "visible": false },
  10382. * null,
  10383. * null,
  10384. * null,
  10385. * null
  10386. * ] } );
  10387. * } );
  10388. */
  10389. "bVisible": true,
  10390. /**
  10391. * Developer definable function that is called whenever a cell is created (Ajax source,
  10392. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  10393. * allowing you to modify the DOM element (add background colour for example) when the
  10394. * element is available.
  10395. * @type function
  10396. * @param {element} td The TD node that has been created
  10397. * @param {*} cellData The Data for the cell
  10398. * @param {array|object} rowData The data for the whole row
  10399. * @param {int} row The row index for the aoData data store
  10400. * @param {int} col The column index for aoColumns
  10401. *
  10402. * @name DataTable.defaults.column.createdCell
  10403. * @dtopt Columns
  10404. *
  10405. * @example
  10406. * $(document).ready( function() {
  10407. * $('#example').dataTable( {
  10408. * "columnDefs": [ {
  10409. * "targets": [3],
  10410. * "createdCell": function (td, cellData, rowData, row, col) {
  10411. * if ( cellData == "1.7" ) {
  10412. * $(td).css('color', 'blue')
  10413. * }
  10414. * }
  10415. * } ]
  10416. * });
  10417. * } );
  10418. */
  10419. "fnCreatedCell": null,
  10420. /**
  10421. * This parameter has been replaced by `data` in DataTables to ensure naming
  10422. * consistency. `dataProp` can still be used, as there is backwards
  10423. * compatibility in DataTables for this option, but it is strongly
  10424. * recommended that you use `data` in preference to `dataProp`.
  10425. * @name DataTable.defaults.column.dataProp
  10426. */
  10427. /**
  10428. * This property can be used to read data from any data source property,
  10429. * including deeply nested objects / properties. `data` can be given in a
  10430. * number of different ways which effect its behaviour:
  10431. *
  10432. * * `integer` - treated as an array index for the data source. This is the
  10433. * default that DataTables uses (incrementally increased for each column).
  10434. * * `string` - read an object property from the data source. There are
  10435. * three 'special' options that can be used in the string to alter how
  10436. * DataTables reads the data from the source object:
  10437. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10438. * Javascript to read from nested objects, so to can the options
  10439. * specified in `data`. For example: `browser.version` or
  10440. * `browser.name`. If your object parameter name contains a period, use
  10441. * `\\` to escape it - i.e. `first\\.name`.
  10442. * * `[]` - Array notation. DataTables can automatically combine data
  10443. * from and array source, joining the data with the characters provided
  10444. * between the two brackets. For example: `name[, ]` would provide a
  10445. * comma-space separated list from the source array. If no characters
  10446. * are provided between the brackets, the original array source is
  10447. * returned.
  10448. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10449. * execute a function of the name given. For example: `browser()` for a
  10450. * simple function on the data source, `browser.version()` for a
  10451. * function in a nested property or even `browser().version` to get an
  10452. * object property if the function called returns an object. Note that
  10453. * function notation is recommended for use in `render` rather than
  10454. * `data` as it is much simpler to use as a renderer.
  10455. * * `null` - use the original data source for the row rather than plucking
  10456. * data directly from it. This action has effects on two other
  10457. * initialisation options:
  10458. * * `defaultContent` - When null is given as the `data` option and
  10459. * `defaultContent` is specified for the column, the value defined by
  10460. * `defaultContent` will be used for the cell.
  10461. * * `render` - When null is used for the `data` option and the `render`
  10462. * option is specified for the column, the whole data source for the
  10463. * row is used for the renderer.
  10464. * * `function` - the function given will be executed whenever DataTables
  10465. * needs to set or get the data for a cell in the column. The function
  10466. * takes three parameters:
  10467. * * Parameters:
  10468. * * `{array|object}` The data source for the row
  10469. * * `{string}` The type call data requested - this will be 'set' when
  10470. * setting data or 'filter', 'display', 'type', 'sort' or undefined
  10471. * when gathering data. Note that when `undefined` is given for the
  10472. * type DataTables expects to get the raw data for the object back<
  10473. * * `{*}` Data to set when the second parameter is 'set'.
  10474. * * Return:
  10475. * * The return value from the function is not required when 'set' is
  10476. * the type of call, but otherwise the return is what will be used
  10477. * for the data requested.
  10478. *
  10479. * Note that `data` is a getter and setter option. If you just require
  10480. * formatting of data for output, you will likely want to use `render` which
  10481. * is simply a getter and thus simpler to use.
  10482. *
  10483. * Note that prior to DataTables 1.9.2 `data` was called `mDataProp`. The
  10484. * name change reflects the flexibility of this property and is consistent
  10485. * with the naming of mRender. If 'mDataProp' is given, then it will still
  10486. * be used by DataTables, as it automatically maps the old name to the new
  10487. * if required.
  10488. *
  10489. * @type string|int|function|null
  10490. * @default null <i>Use automatically calculated column index</i>
  10491. *
  10492. * @name DataTable.defaults.column.data
  10493. * @dtopt Columns
  10494. *
  10495. * @example
  10496. * // Read table data from objects
  10497. * // JSON structure for each row:
  10498. * // {
  10499. * // "engine": {value},
  10500. * // "browser": {value},
  10501. * // "platform": {value},
  10502. * // "version": {value},
  10503. * // "grade": {value}
  10504. * // }
  10505. * $(document).ready( function() {
  10506. * $('#example').dataTable( {
  10507. * "ajaxSource": "sources/objects.txt",
  10508. * "columns": [
  10509. * { "data": "engine" },
  10510. * { "data": "browser" },
  10511. * { "data": "platform" },
  10512. * { "data": "version" },
  10513. * { "data": "grade" }
  10514. * ]
  10515. * } );
  10516. * } );
  10517. *
  10518. * @example
  10519. * // Read information from deeply nested objects
  10520. * // JSON structure for each row:
  10521. * // {
  10522. * // "engine": {value},
  10523. * // "browser": {value},
  10524. * // "platform": {
  10525. * // "inner": {value}
  10526. * // },
  10527. * // "details": [
  10528. * // {value}, {value}
  10529. * // ]
  10530. * // }
  10531. * $(document).ready( function() {
  10532. * $('#example').dataTable( {
  10533. * "ajaxSource": "sources/deep.txt",
  10534. * "columns": [
  10535. * { "data": "engine" },
  10536. * { "data": "browser" },
  10537. * { "data": "platform.inner" },
  10538. * { "data": "platform.details.0" },
  10539. * { "data": "platform.details.1" }
  10540. * ]
  10541. * } );
  10542. * } );
  10543. *
  10544. * @example
  10545. * // Using `data` as a function to provide different information for
  10546. * // sorting, filtering and display. In this case, currency (price)
  10547. * $(document).ready( function() {
  10548. * $('#example').dataTable( {
  10549. * "columnDefs": [ {
  10550. * "targets": [ 0 ],
  10551. * "data": function ( source, type, val ) {
  10552. * if (type === 'set') {
  10553. * source.price = val;
  10554. * // Store the computed dislay and filter values for efficiency
  10555. * source.price_display = val=="" ? "" : "$"+numberFormat(val);
  10556. * source.price_filter = val=="" ? "" : "$"+numberFormat(val)+" "+val;
  10557. * return;
  10558. * }
  10559. * else if (type === 'display') {
  10560. * return source.price_display;
  10561. * }
  10562. * else if (type === 'filter') {
  10563. * return source.price_filter;
  10564. * }
  10565. * // 'sort', 'type' and undefined all just use the integer
  10566. * return source.price;
  10567. * }
  10568. * } ]
  10569. * } );
  10570. * } );
  10571. *
  10572. * @example
  10573. * // Using default content
  10574. * $(document).ready( function() {
  10575. * $('#example').dataTable( {
  10576. * "columnDefs": [ {
  10577. * "targets": [ 0 ],
  10578. * "data": null,
  10579. * "defaultContent": "Click to edit"
  10580. * } ]
  10581. * } );
  10582. * } );
  10583. *
  10584. * @example
  10585. * // Using array notation - outputting a list from an array
  10586. * $(document).ready( function() {
  10587. * $('#example').dataTable( {
  10588. * "columnDefs": [ {
  10589. * "targets": [ 0 ],
  10590. * "data": "name[, ]"
  10591. * } ]
  10592. * } );
  10593. * } );
  10594. *
  10595. */
  10596. "mData": null,
  10597. /**
  10598. * This property is the rendering partner to `data` and it is suggested that
  10599. * when you want to manipulate data for display (including filtering,
  10600. * sorting etc) without altering the underlying data for the table, use this
  10601. * property. `render` can be considered to be the the read only companion to
  10602. * `data` which is read / write (then as such more complex). Like `data`
  10603. * this option can be given in a number of different ways to effect its
  10604. * behaviour:
  10605. *
  10606. * * `integer` - treated as an array index for the data source. This is the
  10607. * default that DataTables uses (incrementally increased for each column).
  10608. * * `string` - read an object property from the data source. There are
  10609. * three 'special' options that can be used in the string to alter how
  10610. * DataTables reads the data from the source object:
  10611. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10612. * Javascript to read from nested objects, so to can the options
  10613. * specified in `data`. For example: `browser.version` or
  10614. * `browser.name`. If your object parameter name contains a period, use
  10615. * `\\` to escape it - i.e. `first\\.name`.
  10616. * * `[]` - Array notation. DataTables can automatically combine data
  10617. * from and array source, joining the data with the characters provided
  10618. * between the two brackets. For example: `name[, ]` would provide a
  10619. * comma-space separated list from the source array. If no characters
  10620. * are provided between the brackets, the original array source is
  10621. * returned.
  10622. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10623. * execute a function of the name given. For example: `browser()` for a
  10624. * simple function on the data source, `browser.version()` for a
  10625. * function in a nested property or even `browser().version` to get an
  10626. * object property if the function called returns an object.
  10627. * * `object` - use different data for the different data types requested by
  10628. * DataTables ('filter', 'display', 'type' or 'sort'). The property names
  10629. * of the object is the data type the property refers to and the value can
  10630. * defined using an integer, string or function using the same rules as
  10631. * `render` normally does. Note that an `_` option _must_ be specified.
  10632. * This is the default value to use if you haven't specified a value for
  10633. * the data type requested by DataTables.
  10634. * * `function` - the function given will be executed whenever DataTables
  10635. * needs to set or get the data for a cell in the column. The function
  10636. * takes three parameters:
  10637. * * Parameters:
  10638. * * {array|object} The data source for the row (based on `data`)
  10639. * * {string} The type call data requested - this will be 'filter',
  10640. * 'display', 'type' or 'sort'.
  10641. * * {array|object} The full data source for the row (not based on
  10642. * `data`)
  10643. * * Return:
  10644. * * The return value from the function is what will be used for the
  10645. * data requested.
  10646. *
  10647. * @type string|int|function|object|null
  10648. * @default null Use the data source value.
  10649. *
  10650. * @name DataTable.defaults.column.render
  10651. * @dtopt Columns
  10652. *
  10653. * @example
  10654. * // Create a comma separated list from an array of objects
  10655. * $(document).ready( function() {
  10656. * $('#example').dataTable( {
  10657. * "ajaxSource": "sources/deep.txt",
  10658. * "columns": [
  10659. * { "data": "engine" },
  10660. * { "data": "browser" },
  10661. * {
  10662. * "data": "platform",
  10663. * "render": "[, ].name"
  10664. * }
  10665. * ]
  10666. * } );
  10667. * } );
  10668. *
  10669. * @example
  10670. * // Execute a function to obtain data
  10671. * $(document).ready( function() {
  10672. * $('#example').dataTable( {
  10673. * "columnDefs": [ {
  10674. * "targets": [ 0 ],
  10675. * "data": null, // Use the full data source object for the renderer's source
  10676. * "render": "browserName()"
  10677. * } ]
  10678. * } );
  10679. * } );
  10680. *
  10681. * @example
  10682. * // As an object, extracting different data for the different types
  10683. * // This would be used with a data source such as:
  10684. * // { "phone": 5552368, "phone_filter": "5552368 555-2368", "phone_display": "555-2368" }
  10685. * // Here the `phone` integer is used for sorting and type detection, while `phone_filter`
  10686. * // (which has both forms) is used for filtering for if a user inputs either format, while
  10687. * // the formatted phone number is the one that is shown in the table.
  10688. * $(document).ready( function() {
  10689. * $('#example').dataTable( {
  10690. * "columnDefs": [ {
  10691. * "targets": [ 0 ],
  10692. * "data": null, // Use the full data source object for the renderer's source
  10693. * "render": {
  10694. * "_": "phone",
  10695. * "filter": "phone_filter",
  10696. * "display": "phone_display"
  10697. * }
  10698. * } ]
  10699. * } );
  10700. * } );
  10701. *
  10702. * @example
  10703. * // Use as a function to create a link from the data source
  10704. * $(document).ready( function() {
  10705. * $('#example').dataTable( {
  10706. * "columnDefs": [ {
  10707. * "targets": [ 0 ],
  10708. * "data": "download_link",
  10709. * "render": function ( data, type, full ) {
  10710. * return '<a href="'+data+'">Download</a>';
  10711. * }
  10712. * } ]
  10713. * } );
  10714. * } );
  10715. */
  10716. "mRender": null,
  10717. /**
  10718. * Change the cell type created for the column - either TD cells or TH cells. This
  10719. * can be useful as TH cells have semantic meaning in the table body, allowing them
  10720. * to act as a header for a row (you may wish to add scope='row' to the TH elements).
  10721. * @type string
  10722. * @default td
  10723. *
  10724. * @name DataTable.defaults.column.cellType
  10725. * @dtopt Columns
  10726. *
  10727. * @example
  10728. * // Make the first column use TH cells
  10729. * $(document).ready( function() {
  10730. * $('#example').dataTable( {
  10731. * "columnDefs": [ {
  10732. * "targets": [ 0 ],
  10733. * "cellType": "th"
  10734. * } ]
  10735. * } );
  10736. * } );
  10737. */
  10738. "sCellType": "td",
  10739. /**
  10740. * Class to give to each cell in this column.
  10741. * @type string
  10742. * @default <i>Empty string</i>
  10743. *
  10744. * @name DataTable.defaults.column.class
  10745. * @dtopt Columns
  10746. *
  10747. * @example
  10748. * // Using `columnDefs`
  10749. * $(document).ready( function() {
  10750. * $('#example').dataTable( {
  10751. * "columnDefs": [
  10752. * { "class": "my_class", "targets": [ 0 ] }
  10753. * ]
  10754. * } );
  10755. * } );
  10756. *
  10757. * @example
  10758. * // Using `columns`
  10759. * $(document).ready( function() {
  10760. * $('#example').dataTable( {
  10761. * "columns": [
  10762. * { "class": "my_class" },
  10763. * null,
  10764. * null,
  10765. * null,
  10766. * null
  10767. * ]
  10768. * } );
  10769. * } );
  10770. */
  10771. "sClass": "",
  10772. /**
  10773. * When DataTables calculates the column widths to assign to each column,
  10774. * it finds the longest string in each column and then constructs a
  10775. * temporary table and reads the widths from that. The problem with this
  10776. * is that "mmm" is much wider then "iiii", but the latter is a longer
  10777. * string - thus the calculation can go wrong (doing it properly and putting
  10778. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  10779. * a "work around" we provide this option. It will append its value to the
  10780. * text that is found to be the longest string for the column - i.e. padding.
  10781. * Generally you shouldn't need this!
  10782. * @type string
  10783. * @default <i>Empty string<i>
  10784. *
  10785. * @name DataTable.defaults.column.contentPadding
  10786. * @dtopt Columns
  10787. *
  10788. * @example
  10789. * // Using `columns`
  10790. * $(document).ready( function() {
  10791. * $('#example').dataTable( {
  10792. * "columns": [
  10793. * null,
  10794. * null,
  10795. * null,
  10796. * {
  10797. * "contentPadding": "mmm"
  10798. * }
  10799. * ]
  10800. * } );
  10801. * } );
  10802. */
  10803. "sContentPadding": "",
  10804. /**
  10805. * Allows a default value to be given for a column's data, and will be used
  10806. * whenever a null data source is encountered (this can be because `data`
  10807. * is set to null, or because the data source itself is null).
  10808. * @type string
  10809. * @default null
  10810. *
  10811. * @name DataTable.defaults.column.defaultContent
  10812. * @dtopt Columns
  10813. *
  10814. * @example
  10815. * // Using `columnDefs`
  10816. * $(document).ready( function() {
  10817. * $('#example').dataTable( {
  10818. * "columnDefs": [
  10819. * {
  10820. * "data": null,
  10821. * "defaultContent": "Edit",
  10822. * "targets": [ -1 ]
  10823. * }
  10824. * ]
  10825. * } );
  10826. * } );
  10827. *
  10828. * @example
  10829. * // Using `columns`
  10830. * $(document).ready( function() {
  10831. * $('#example').dataTable( {
  10832. * "columns": [
  10833. * null,
  10834. * null,
  10835. * null,
  10836. * {
  10837. * "data": null,
  10838. * "defaultContent": "Edit"
  10839. * }
  10840. * ]
  10841. * } );
  10842. * } );
  10843. */
  10844. "sDefaultContent": null,
  10845. /**
  10846. * This parameter is only used in DataTables' server-side processing. It can
  10847. * be exceptionally useful to know what columns are being displayed on the
  10848. * client side, and to map these to database fields. When defined, the names
  10849. * also allow DataTables to reorder information from the server if it comes
  10850. * back in an unexpected order (i.e. if you switch your columns around on the
  10851. * client-side, your server-side code does not also need updating).
  10852. * @type string
  10853. * @default <i>Empty string</i>
  10854. *
  10855. * @name DataTable.defaults.column.name
  10856. * @dtopt Columns
  10857. *
  10858. * @example
  10859. * // Using `columnDefs`
  10860. * $(document).ready( function() {
  10861. * $('#example').dataTable( {
  10862. * "columnDefs": [
  10863. * { "name": "engine", "targets": [ 0 ] },
  10864. * { "name": "browser", "targets": [ 1 ] },
  10865. * { "name": "platform", "targets": [ 2 ] },
  10866. * { "name": "version", "targets": [ 3 ] },
  10867. * { "name": "grade", "targets": [ 4 ] }
  10868. * ]
  10869. * } );
  10870. * } );
  10871. *
  10872. * @example
  10873. * // Using `columns`
  10874. * $(document).ready( function() {
  10875. * $('#example').dataTable( {
  10876. * "columns": [
  10877. * { "name": "engine" },
  10878. * { "name": "browser" },
  10879. * { "name": "platform" },
  10880. * { "name": "version" },
  10881. * { "name": "grade" }
  10882. * ]
  10883. * } );
  10884. * } );
  10885. */
  10886. "sName": "",
  10887. /**
  10888. * Defines a data source type for the ordering which can be used to read
  10889. * real-time information from the table (updating the internally cached
  10890. * version) prior to ordering. This allows ordering to occur on user
  10891. * editable elements such as form inputs.
  10892. * @type string
  10893. * @default std
  10894. *
  10895. * @name DataTable.defaults.column.orderDataType
  10896. * @dtopt Columns
  10897. *
  10898. * @example
  10899. * // Using `columnDefs`
  10900. * $(document).ready( function() {
  10901. * $('#example').dataTable( {
  10902. * "columnDefs": [
  10903. * { "orderDataType": "dom-text", "targets": [ 2, 3 ] },
  10904. * { "type": "numeric", "targets": [ 3 ] },
  10905. * { "orderDataType": "dom-select", "targets": [ 4 ] },
  10906. * { "orderDataType": "dom-checkbox", "targets": [ 5 ] }
  10907. * ]
  10908. * } );
  10909. * } );
  10910. *
  10911. * @example
  10912. * // Using `columns`
  10913. * $(document).ready( function() {
  10914. * $('#example').dataTable( {
  10915. * "columns": [
  10916. * null,
  10917. * null,
  10918. * { "orderDataType": "dom-text" },
  10919. * { "orderDataType": "dom-text", "type": "numeric" },
  10920. * { "orderDataType": "dom-select" },
  10921. * { "orderDataType": "dom-checkbox" }
  10922. * ]
  10923. * } );
  10924. * } );
  10925. */
  10926. "sSortDataType": "std",
  10927. /**
  10928. * The title of this column.
  10929. * @type string
  10930. * @default null <i>Derived from the 'TH' value for this column in the
  10931. * original HTML table.</i>
  10932. *
  10933. * @name DataTable.defaults.column.title
  10934. * @dtopt Columns
  10935. *
  10936. * @example
  10937. * // Using `columnDefs`
  10938. * $(document).ready( function() {
  10939. * $('#example').dataTable( {
  10940. * "columnDefs": [
  10941. * { "title": "My column title", "targets": [ 0 ] }
  10942. * ]
  10943. * } );
  10944. * } );
  10945. *
  10946. * @example
  10947. * // Using `columns`
  10948. * $(document).ready( function() {
  10949. * $('#example').dataTable( {
  10950. * "columns": [
  10951. * { "title": "My column title" },
  10952. * null,
  10953. * null,
  10954. * null,
  10955. * null
  10956. * ]
  10957. * } );
  10958. * } );
  10959. */
  10960. "sTitle": null,
  10961. /**
  10962. * The type allows you to specify how the data for this column will be
  10963. * ordered. Four types (string, numeric, date and html (which will strip
  10964. * HTML tags before ordering)) are currently available. Note that only date
  10965. * formats understood by Javascript's Date() object will be accepted as type
  10966. * date. For example: "Mar 26, 2008 5:03 PM". May take the values: 'string',
  10967. * 'numeric', 'date' or 'html' (by default). Further types can be adding
  10968. * through plug-ins.
  10969. * @type string
  10970. * @default null <i>Auto-detected from raw data</i>
  10971. *
  10972. * @name DataTable.defaults.column.type
  10973. * @dtopt Columns
  10974. *
  10975. * @example
  10976. * // Using `columnDefs`
  10977. * $(document).ready( function() {
  10978. * $('#example').dataTable( {
  10979. * "columnDefs": [
  10980. * { "type": "html", "targets": [ 0 ] }
  10981. * ]
  10982. * } );
  10983. * } );
  10984. *
  10985. * @example
  10986. * // Using `columns`
  10987. * $(document).ready( function() {
  10988. * $('#example').dataTable( {
  10989. * "columns": [
  10990. * { "type": "html" },
  10991. * null,
  10992. * null,
  10993. * null,
  10994. * null
  10995. * ]
  10996. * } );
  10997. * } );
  10998. */
  10999. "sType": null,
  11000. /**
  11001. * Defining the width of the column, this parameter may take any CSS value
  11002. * (3em, 20px etc). DataTables applies 'smart' widths to columns which have not
  11003. * been given a specific width through this interface ensuring that the table
  11004. * remains readable.
  11005. * @type string
  11006. * @default null <i>Automatic</i>
  11007. *
  11008. * @name DataTable.defaults.column.width
  11009. * @dtopt Columns
  11010. *
  11011. * @example
  11012. * // Using `columnDefs`
  11013. * $(document).ready( function() {
  11014. * $('#example').dataTable( {
  11015. * "columnDefs": [
  11016. * { "width": "20%", "targets": [ 0 ] }
  11017. * ]
  11018. * } );
  11019. * } );
  11020. *
  11021. * @example
  11022. * // Using `columns`
  11023. * $(document).ready( function() {
  11024. * $('#example').dataTable( {
  11025. * "columns": [
  11026. * { "width": "20%" },
  11027. * null,
  11028. * null,
  11029. * null,
  11030. * null
  11031. * ]
  11032. * } );
  11033. * } );
  11034. */
  11035. "sWidth": null
  11036. };
  11037. _fnHungarianMap( DataTable.defaults.column );
  11038. /**
  11039. * DataTables settings object - this holds all the information needed for a
  11040. * given table, including configuration, data and current application of the
  11041. * table options. DataTables does not have a single instance for each DataTable
  11042. * with the settings attached to that instance, but rather instances of the
  11043. * DataTable "class" are created on-the-fly as needed (typically by a
  11044. * $().dataTable() call) and the settings object is then applied to that
  11045. * instance.
  11046. *
  11047. * Note that this object is related to {@link DataTable.defaults} but this
  11048. * one is the internal data store for DataTables's cache of columns. It should
  11049. * NOT be manipulated outside of DataTables. Any configuration should be done
  11050. * through the initialisation options.
  11051. * @namespace
  11052. * @todo Really should attach the settings object to individual instances so we
  11053. * don't need to create new instances on each $().dataTable() call (if the
  11054. * table already exists). It would also save passing oSettings around and
  11055. * into every single function. However, this is a very significant
  11056. * architecture change for DataTables and will almost certainly break
  11057. * backwards compatibility with older installations. This is something that
  11058. * will be done in 2.0.
  11059. */
  11060. DataTable.models.oSettings = {
  11061. /**
  11062. * Primary features of DataTables and their enablement state.
  11063. * @namespace
  11064. */
  11065. "oFeatures": {
  11066. /**
  11067. * Flag to say if DataTables should automatically try to calculate the
  11068. * optimum table and columns widths (true) or not (false).
  11069. * Note that this parameter will be set by the initialisation routine. To
  11070. * set a default use {@link DataTable.defaults}.
  11071. * @type boolean
  11072. */
  11073. "bAutoWidth": null,
  11074. /**
  11075. * Delay the creation of TR and TD elements until they are actually
  11076. * needed by a driven page draw. This can give a significant speed
  11077. * increase for Ajax source and Javascript source data, but makes no
  11078. * difference at all fro DOM and server-side processing tables.
  11079. * Note that this parameter will be set by the initialisation routine. To
  11080. * set a default use {@link DataTable.defaults}.
  11081. * @type boolean
  11082. */
  11083. "bDeferRender": null,
  11084. /**
  11085. * Enable filtering on the table or not. Note that if this is disabled
  11086. * then there is no filtering at all on the table, including fnFilter.
  11087. * To just remove the filtering input use sDom and remove the 'f' option.
  11088. * Note that this parameter will be set by the initialisation routine. To
  11089. * set a default use {@link DataTable.defaults}.
  11090. * @type boolean
  11091. */
  11092. "bFilter": null,
  11093. /**
  11094. * Table information element (the 'Showing x of y records' div) enable
  11095. * flag.
  11096. * Note that this parameter will be set by the initialisation routine. To
  11097. * set a default use {@link DataTable.defaults}.
  11098. * @type boolean
  11099. */
  11100. "bInfo": null,
  11101. /**
  11102. * Present a user control allowing the end user to change the page size
  11103. * when pagination is enabled.
  11104. * Note that this parameter will be set by the initialisation routine. To
  11105. * set a default use {@link DataTable.defaults}.
  11106. * @type boolean
  11107. */
  11108. "bLengthChange": null,
  11109. /**
  11110. * Pagination enabled or not. Note that if this is disabled then length
  11111. * changing must also be disabled.
  11112. * Note that this parameter will be set by the initialisation routine. To
  11113. * set a default use {@link DataTable.defaults}.
  11114. * @type boolean
  11115. */
  11116. "bPaginate": null,
  11117. /**
  11118. * Processing indicator enable flag whenever DataTables is enacting a
  11119. * user request - typically an Ajax request for server-side processing.
  11120. * Note that this parameter will be set by the initialisation routine. To
  11121. * set a default use {@link DataTable.defaults}.
  11122. * @type boolean
  11123. */
  11124. "bProcessing": null,
  11125. /**
  11126. * Server-side processing enabled flag - when enabled DataTables will
  11127. * get all data from the server for every draw - there is no filtering,
  11128. * sorting or paging done on the client-side.
  11129. * Note that this parameter will be set by the initialisation routine. To
  11130. * set a default use {@link DataTable.defaults}.
  11131. * @type boolean
  11132. */
  11133. "bServerSide": null,
  11134. /**
  11135. * Sorting enablement flag.
  11136. * Note that this parameter will be set by the initialisation routine. To
  11137. * set a default use {@link DataTable.defaults}.
  11138. * @type boolean
  11139. */
  11140. "bSort": null,
  11141. /**
  11142. * Multi-column sorting
  11143. * Note that this parameter will be set by the initialisation routine. To
  11144. * set a default use {@link DataTable.defaults}.
  11145. * @type boolean
  11146. */
  11147. "bSortMulti": null,
  11148. /**
  11149. * Apply a class to the columns which are being sorted to provide a
  11150. * visual highlight or not. This can slow things down when enabled since
  11151. * there is a lot of DOM interaction.
  11152. * Note that this parameter will be set by the initialisation routine. To
  11153. * set a default use {@link DataTable.defaults}.
  11154. * @type boolean
  11155. */
  11156. "bSortClasses": null,
  11157. /**
  11158. * State saving enablement flag.
  11159. * Note that this parameter will be set by the initialisation routine. To
  11160. * set a default use {@link DataTable.defaults}.
  11161. * @type boolean
  11162. */
  11163. "bStateSave": null
  11164. },
  11165. /**
  11166. * Scrolling settings for a table.
  11167. * @namespace
  11168. */
  11169. "oScroll": {
  11170. /**
  11171. * When the table is shorter in height than sScrollY, collapse the
  11172. * table container down to the height of the table (when true).
  11173. * Note that this parameter will be set by the initialisation routine. To
  11174. * set a default use {@link DataTable.defaults}.
  11175. * @type boolean
  11176. */
  11177. "bCollapse": null,
  11178. /**
  11179. * Width of the scrollbar for the web-browser's platform. Calculated
  11180. * during table initialisation.
  11181. * @type int
  11182. * @default 0
  11183. */
  11184. "iBarWidth": 0,
  11185. /**
  11186. * Viewport width for horizontal scrolling. Horizontal scrolling is
  11187. * disabled if an empty string.
  11188. * Note that this parameter will be set by the initialisation routine. To
  11189. * set a default use {@link DataTable.defaults}.
  11190. * @type string
  11191. */
  11192. "sX": null,
  11193. /**
  11194. * Width to expand the table to when using x-scrolling. Typically you
  11195. * should not need to use this.
  11196. * Note that this parameter will be set by the initialisation routine. To
  11197. * set a default use {@link DataTable.defaults}.
  11198. * @type string
  11199. * @deprecated
  11200. */
  11201. "sXInner": null,
  11202. /**
  11203. * Viewport height for vertical scrolling. Vertical scrolling is disabled
  11204. * if an empty string.
  11205. * Note that this parameter will be set by the initialisation routine. To
  11206. * set a default use {@link DataTable.defaults}.
  11207. * @type string
  11208. */
  11209. "sY": null
  11210. },
  11211. /**
  11212. * Language information for the table.
  11213. * @namespace
  11214. * @extends DataTable.defaults.oLanguage
  11215. */
  11216. "oLanguage": {
  11217. /**
  11218. * Information callback function. See
  11219. * {@link DataTable.defaults.fnInfoCallback}
  11220. * @type function
  11221. * @default null
  11222. */
  11223. "fnInfoCallback": null
  11224. },
  11225. /**
  11226. * Browser support parameters
  11227. * @namespace
  11228. */
  11229. "oBrowser": {
  11230. /**
  11231. * Indicate if the browser incorrectly calculates width:100% inside a
  11232. * scrolling element (IE6/7)
  11233. * @type boolean
  11234. * @default false
  11235. */
  11236. "bScrollOversize": false,
  11237. /**
  11238. * Determine if the vertical scrollbar is on the right or left of the
  11239. * scrolling container - needed for rtl language layout, although not
  11240. * all browsers move the scrollbar (Safari).
  11241. * @type boolean
  11242. * @default false
  11243. */
  11244. "bScrollbarLeft": false,
  11245. /**
  11246. * Flag for if `getBoundingClientRect` is fully supported or not
  11247. * @type boolean
  11248. * @default false
  11249. */
  11250. "bBounding": false
  11251. },
  11252. "ajax": null,
  11253. /**
  11254. * Array referencing the nodes which are used for the features. The
  11255. * parameters of this object match what is allowed by sDom - i.e.
  11256. * <ul>
  11257. * <li>'l' - Length changing</li>
  11258. * <li>'f' - Filtering input</li>
  11259. * <li>'t' - The table!</li>
  11260. * <li>'i' - Information</li>
  11261. * <li>'p' - Pagination</li>
  11262. * <li>'r' - pRocessing</li>
  11263. * </ul>
  11264. * @type array
  11265. * @default []
  11266. */
  11267. "aanFeatures": [],
  11268. /**
  11269. * Store data information - see {@link DataTable.models.oRow} for detailed
  11270. * information.
  11271. * @type array
  11272. * @default []
  11273. */
  11274. "aoData": [],
  11275. /**
  11276. * Array of indexes which are in the current display (after filtering etc)
  11277. * @type array
  11278. * @default []
  11279. */
  11280. "aiDisplay": [],
  11281. /**
  11282. * Array of indexes for display - no filtering
  11283. * @type array
  11284. * @default []
  11285. */
  11286. "aiDisplayMaster": [],
  11287. /**
  11288. * Map of row ids to data indexes
  11289. * @type object
  11290. * @default {}
  11291. */
  11292. "aIds": {},
  11293. /**
  11294. * Store information about each column that is in use
  11295. * @type array
  11296. * @default []
  11297. */
  11298. "aoColumns": [],
  11299. /**
  11300. * Store information about the table's header
  11301. * @type array
  11302. * @default []
  11303. */
  11304. "aoHeader": [],
  11305. /**
  11306. * Store information about the table's footer
  11307. * @type array
  11308. * @default []
  11309. */
  11310. "aoFooter": [],
  11311. /**
  11312. * Store the applied global search information in case we want to force a
  11313. * research or compare the old search to a new one.
  11314. * Note that this parameter will be set by the initialisation routine. To
  11315. * set a default use {@link DataTable.defaults}.
  11316. * @namespace
  11317. * @extends DataTable.models.oSearch
  11318. */
  11319. "oPreviousSearch": {},
  11320. /**
  11321. * Store the applied search for each column - see
  11322. * {@link DataTable.models.oSearch} for the format that is used for the
  11323. * filtering information for each column.
  11324. * @type array
  11325. * @default []
  11326. */
  11327. "aoPreSearchCols": [],
  11328. /**
  11329. * Sorting that is applied to the table. Note that the inner arrays are
  11330. * used in the following manner:
  11331. * <ul>
  11332. * <li>Index 0 - column number</li>
  11333. * <li>Index 1 - current sorting direction</li>
  11334. * </ul>
  11335. * Note that this parameter will be set by the initialisation routine. To
  11336. * set a default use {@link DataTable.defaults}.
  11337. * @type array
  11338. * @todo These inner arrays should really be objects
  11339. */
  11340. "aaSorting": null,
  11341. /**
  11342. * Sorting that is always applied to the table (i.e. prefixed in front of
  11343. * aaSorting).
  11344. * Note that this parameter will be set by the initialisation routine. To
  11345. * set a default use {@link DataTable.defaults}.
  11346. * @type array
  11347. * @default []
  11348. */
  11349. "aaSortingFixed": [],
  11350. /**
  11351. * Classes to use for the striping of a table.
  11352. * Note that this parameter will be set by the initialisation routine. To
  11353. * set a default use {@link DataTable.defaults}.
  11354. * @type array
  11355. * @default []
  11356. */
  11357. "asStripeClasses": null,
  11358. /**
  11359. * If restoring a table - we should restore its striping classes as well
  11360. * @type array
  11361. * @default []
  11362. */
  11363. "asDestroyStripes": [],
  11364. /**
  11365. * If restoring a table - we should restore its width
  11366. * @type int
  11367. * @default 0
  11368. */
  11369. "sDestroyWidth": 0,
  11370. /**
  11371. * Callback functions array for every time a row is inserted (i.e. on a draw).
  11372. * @type array
  11373. * @default []
  11374. */
  11375. "aoRowCallback": [],
  11376. /**
  11377. * Callback functions for the header on each draw.
  11378. * @type array
  11379. * @default []
  11380. */
  11381. "aoHeaderCallback": [],
  11382. /**
  11383. * Callback function for the footer on each draw.
  11384. * @type array
  11385. * @default []
  11386. */
  11387. "aoFooterCallback": [],
  11388. /**
  11389. * Array of callback functions for draw callback functions
  11390. * @type array
  11391. * @default []
  11392. */
  11393. "aoDrawCallback": [],
  11394. /**
  11395. * Array of callback functions for row created function
  11396. * @type array
  11397. * @default []
  11398. */
  11399. "aoRowCreatedCallback": [],
  11400. /**
  11401. * Callback functions for just before the table is redrawn. A return of
  11402. * false will be used to cancel the draw.
  11403. * @type array
  11404. * @default []
  11405. */
  11406. "aoPreDrawCallback": [],
  11407. /**
  11408. * Callback functions for when the table has been initialised.
  11409. * @type array
  11410. * @default []
  11411. */
  11412. "aoInitComplete": [],
  11413. /**
  11414. * Callbacks for modifying the settings to be stored for state saving, prior to
  11415. * saving state.
  11416. * @type array
  11417. * @default []
  11418. */
  11419. "aoStateSaveParams": [],
  11420. /**
  11421. * Callbacks for modifying the settings that have been stored for state saving
  11422. * prior to using the stored values to restore the state.
  11423. * @type array
  11424. * @default []
  11425. */
  11426. "aoStateLoadParams": [],
  11427. /**
  11428. * Callbacks for operating on the settings object once the saved state has been
  11429. * loaded
  11430. * @type array
  11431. * @default []
  11432. */
  11433. "aoStateLoaded": [],
  11434. /**
  11435. * Cache the table ID for quick access
  11436. * @type string
  11437. * @default <i>Empty string</i>
  11438. */
  11439. "sTableId": "",
  11440. /**
  11441. * The TABLE node for the main table
  11442. * @type node
  11443. * @default null
  11444. */
  11445. "nTable": null,
  11446. /**
  11447. * Permanent ref to the thead element
  11448. * @type node
  11449. * @default null
  11450. */
  11451. "nTHead": null,
  11452. /**
  11453. * Permanent ref to the tfoot element - if it exists
  11454. * @type node
  11455. * @default null
  11456. */
  11457. "nTFoot": null,
  11458. /**
  11459. * Permanent ref to the tbody element
  11460. * @type node
  11461. * @default null
  11462. */
  11463. "nTBody": null,
  11464. /**
  11465. * Cache the wrapper node (contains all DataTables controlled elements)
  11466. * @type node
  11467. * @default null
  11468. */
  11469. "nTableWrapper": null,
  11470. /**
  11471. * Indicate if when using server-side processing the loading of data
  11472. * should be deferred until the second draw.
  11473. * Note that this parameter will be set by the initialisation routine. To
  11474. * set a default use {@link DataTable.defaults}.
  11475. * @type boolean
  11476. * @default false
  11477. */
  11478. "bDeferLoading": false,
  11479. /**
  11480. * Indicate if all required information has been read in
  11481. * @type boolean
  11482. * @default false
  11483. */
  11484. "bInitialised": false,
  11485. /**
  11486. * Information about open rows. Each object in the array has the parameters
  11487. * 'nTr' and 'nParent'
  11488. * @type array
  11489. * @default []
  11490. */
  11491. "aoOpenRows": [],
  11492. /**
  11493. * Dictate the positioning of DataTables' control elements - see
  11494. * {@link DataTable.model.oInit.sDom}.
  11495. * Note that this parameter will be set by the initialisation routine. To
  11496. * set a default use {@link DataTable.defaults}.
  11497. * @type string
  11498. * @default null
  11499. */
  11500. "sDom": null,
  11501. /**
  11502. * Search delay (in mS)
  11503. * @type integer
  11504. * @default null
  11505. */
  11506. "searchDelay": null,
  11507. /**
  11508. * Which type of pagination should be used.
  11509. * Note that this parameter will be set by the initialisation routine. To
  11510. * set a default use {@link DataTable.defaults}.
  11511. * @type string
  11512. * @default two_button
  11513. */
  11514. "sPaginationType": "two_button",
  11515. /**
  11516. * The state duration (for `stateSave`) in seconds.
  11517. * Note that this parameter will be set by the initialisation routine. To
  11518. * set a default use {@link DataTable.defaults}.
  11519. * @type int
  11520. * @default 0
  11521. */
  11522. "iStateDuration": 0,
  11523. /**
  11524. * Array of callback functions for state saving. Each array element is an
  11525. * object with the following parameters:
  11526. * <ul>
  11527. * <li>function:fn - function to call. Takes two parameters, oSettings
  11528. * and the JSON string to save that has been thus far created. Returns
  11529. * a JSON string to be inserted into a json object
  11530. * (i.e. '"param": [ 0, 1, 2]')</li>
  11531. * <li>string:sName - name of callback</li>
  11532. * </ul>
  11533. * @type array
  11534. * @default []
  11535. */
  11536. "aoStateSave": [],
  11537. /**
  11538. * Array of callback functions for state loading. Each array element is an
  11539. * object with the following parameters:
  11540. * <ul>
  11541. * <li>function:fn - function to call. Takes two parameters, oSettings
  11542. * and the object stored. May return false to cancel state loading</li>
  11543. * <li>string:sName - name of callback</li>
  11544. * </ul>
  11545. * @type array
  11546. * @default []
  11547. */
  11548. "aoStateLoad": [],
  11549. /**
  11550. * State that was saved. Useful for back reference
  11551. * @type object
  11552. * @default null
  11553. */
  11554. "oSavedState": null,
  11555. /**
  11556. * State that was loaded. Useful for back reference
  11557. * @type object
  11558. * @default null
  11559. */
  11560. "oLoadedState": null,
  11561. /**
  11562. * Source url for AJAX data for the table.
  11563. * Note that this parameter will be set by the initialisation routine. To
  11564. * set a default use {@link DataTable.defaults}.
  11565. * @type string
  11566. * @default null
  11567. */
  11568. "sAjaxSource": null,
  11569. /**
  11570. * Property from a given object from which to read the table data from. This
  11571. * can be an empty string (when not server-side processing), in which case
  11572. * it is assumed an an array is given directly.
  11573. * Note that this parameter will be set by the initialisation routine. To
  11574. * set a default use {@link DataTable.defaults}.
  11575. * @type string
  11576. */
  11577. "sAjaxDataProp": null,
  11578. /**
  11579. * Note if draw should be blocked while getting data
  11580. * @type boolean
  11581. * @default true
  11582. */
  11583. "bAjaxDataGet": true,
  11584. /**
  11585. * The last jQuery XHR object that was used for server-side data gathering.
  11586. * This can be used for working with the XHR information in one of the
  11587. * callbacks
  11588. * @type object
  11589. * @default null
  11590. */
  11591. "jqXHR": null,
  11592. /**
  11593. * JSON returned from the server in the last Ajax request
  11594. * @type object
  11595. * @default undefined
  11596. */
  11597. "json": undefined,
  11598. /**
  11599. * Data submitted as part of the last Ajax request
  11600. * @type object
  11601. * @default undefined
  11602. */
  11603. "oAjaxData": undefined,
  11604. /**
  11605. * Function to get the server-side data.
  11606. * Note that this parameter will be set by the initialisation routine. To
  11607. * set a default use {@link DataTable.defaults}.
  11608. * @type function
  11609. */
  11610. "fnServerData": null,
  11611. /**
  11612. * Functions which are called prior to sending an Ajax request so extra
  11613. * parameters can easily be sent to the server
  11614. * @type array
  11615. * @default []
  11616. */
  11617. "aoServerParams": [],
  11618. /**
  11619. * Send the XHR HTTP method - GET or POST (could be PUT or DELETE if
  11620. * required).
  11621. * Note that this parameter will be set by the initialisation routine. To
  11622. * set a default use {@link DataTable.defaults}.
  11623. * @type string
  11624. */
  11625. "sServerMethod": null,
  11626. /**
  11627. * Format numbers for display.
  11628. * Note that this parameter will be set by the initialisation routine. To
  11629. * set a default use {@link DataTable.defaults}.
  11630. * @type function
  11631. */
  11632. "fnFormatNumber": null,
  11633. /**
  11634. * List of options that can be used for the user selectable length menu.
  11635. * Note that this parameter will be set by the initialisation routine. To
  11636. * set a default use {@link DataTable.defaults}.
  11637. * @type array
  11638. * @default []
  11639. */
  11640. "aLengthMenu": null,
  11641. /**
  11642. * Counter for the draws that the table does. Also used as a tracker for
  11643. * server-side processing
  11644. * @type int
  11645. * @default 0
  11646. */
  11647. "iDraw": 0,
  11648. /**
  11649. * Indicate if a redraw is being done - useful for Ajax
  11650. * @type boolean
  11651. * @default false
  11652. */
  11653. "bDrawing": false,
  11654. /**
  11655. * Draw index (iDraw) of the last error when parsing the returned data
  11656. * @type int
  11657. * @default -1
  11658. */
  11659. "iDrawError": -1,
  11660. /**
  11661. * Paging display length
  11662. * @type int
  11663. * @default 10
  11664. */
  11665. "_iDisplayLength": 10,
  11666. /**
  11667. * Paging start point - aiDisplay index
  11668. * @type int
  11669. * @default 0
  11670. */
  11671. "_iDisplayStart": 0,
  11672. /**
  11673. * Server-side processing - number of records in the result set
  11674. * (i.e. before filtering), Use fnRecordsTotal rather than
  11675. * this property to get the value of the number of records, regardless of
  11676. * the server-side processing setting.
  11677. * @type int
  11678. * @default 0
  11679. * @private
  11680. */
  11681. "_iRecordsTotal": 0,
  11682. /**
  11683. * Server-side processing - number of records in the current display set
  11684. * (i.e. after filtering). Use fnRecordsDisplay rather than
  11685. * this property to get the value of the number of records, regardless of
  11686. * the server-side processing setting.
  11687. * @type boolean
  11688. * @default 0
  11689. * @private
  11690. */
  11691. "_iRecordsDisplay": 0,
  11692. /**
  11693. * Flag to indicate if jQuery UI marking and classes should be used.
  11694. * Note that this parameter will be set by the initialisation routine. To
  11695. * set a default use {@link DataTable.defaults}.
  11696. * @type boolean
  11697. */
  11698. "bJUI": null,
  11699. /**
  11700. * The classes to use for the table
  11701. * @type object
  11702. * @default {}
  11703. */
  11704. "oClasses": {},
  11705. /**
  11706. * Flag attached to the settings object so you can check in the draw
  11707. * callback if filtering has been done in the draw. Deprecated in favour of
  11708. * events.
  11709. * @type boolean
  11710. * @default false
  11711. * @deprecated
  11712. */
  11713. "bFiltered": false,
  11714. /**
  11715. * Flag attached to the settings object so you can check in the draw
  11716. * callback if sorting has been done in the draw. Deprecated in favour of
  11717. * events.
  11718. * @type boolean
  11719. * @default false
  11720. * @deprecated
  11721. */
  11722. "bSorted": false,
  11723. /**
  11724. * Indicate that if multiple rows are in the header and there is more than
  11725. * one unique cell per column, if the top one (true) or bottom one (false)
  11726. * should be used for sorting / title by DataTables.
  11727. * Note that this parameter will be set by the initialisation routine. To
  11728. * set a default use {@link DataTable.defaults}.
  11729. * @type boolean
  11730. */
  11731. "bSortCellsTop": null,
  11732. /**
  11733. * Initialisation object that is used for the table
  11734. * @type object
  11735. * @default null
  11736. */
  11737. "oInit": null,
  11738. /**
  11739. * Destroy callback functions - for plug-ins to attach themselves to the
  11740. * destroy so they can clean up markup and events.
  11741. * @type array
  11742. * @default []
  11743. */
  11744. "aoDestroyCallback": [],
  11745. /**
  11746. * Get the number of records in the current record set, before filtering
  11747. * @type function
  11748. */
  11749. "fnRecordsTotal": function ()
  11750. {
  11751. return _fnDataSource( this ) == 'ssp' ?
  11752. this._iRecordsTotal * 1 :
  11753. this.aiDisplayMaster.length;
  11754. },
  11755. /**
  11756. * Get the number of records in the current record set, after filtering
  11757. * @type function
  11758. */
  11759. "fnRecordsDisplay": function ()
  11760. {
  11761. return _fnDataSource( this ) == 'ssp' ?
  11762. this._iRecordsDisplay * 1 :
  11763. this.aiDisplay.length;
  11764. },
  11765. /**
  11766. * Get the display end point - aiDisplay index
  11767. * @type function
  11768. */
  11769. "fnDisplayEnd": function ()
  11770. {
  11771. var
  11772. len = this._iDisplayLength,
  11773. start = this._iDisplayStart,
  11774. calc = start + len,
  11775. records = this.aiDisplay.length,
  11776. features = this.oFeatures,
  11777. paginate = features.bPaginate;
  11778. if ( features.bServerSide ) {
  11779. return paginate === false || len === -1 ?
  11780. start + records :
  11781. Math.min( start+len, this._iRecordsDisplay );
  11782. }
  11783. else {
  11784. return ! paginate || calc>records || len===-1 ?
  11785. records :
  11786. calc;
  11787. }
  11788. },
  11789. /**
  11790. * The DataTables object for this table
  11791. * @type object
  11792. * @default null
  11793. */
  11794. "oInstance": null,
  11795. /**
  11796. * Unique identifier for each instance of the DataTables object. If there
  11797. * is an ID on the table node, then it takes that value, otherwise an
  11798. * incrementing internal counter is used.
  11799. * @type string
  11800. * @default null
  11801. */
  11802. "sInstance": null,
  11803. /**
  11804. * tabindex attribute value that is added to DataTables control elements, allowing
  11805. * keyboard navigation of the table and its controls.
  11806. */
  11807. "iTabIndex": 0,
  11808. /**
  11809. * DIV container for the footer scrolling table if scrolling
  11810. */
  11811. "nScrollHead": null,
  11812. /**
  11813. * DIV container for the footer scrolling table if scrolling
  11814. */
  11815. "nScrollFoot": null,
  11816. /**
  11817. * Last applied sort
  11818. * @type array
  11819. * @default []
  11820. */
  11821. "aLastSort": [],
  11822. /**
  11823. * Stored plug-in instances
  11824. * @type object
  11825. * @default {}
  11826. */
  11827. "oPlugins": {},
  11828. /**
  11829. * Function used to get a row's id from the row's data
  11830. * @type function
  11831. * @default null
  11832. */
  11833. "rowIdFn": null,
  11834. /**
  11835. * Data location where to store a row's id
  11836. * @type string
  11837. * @default null
  11838. */
  11839. "rowId": null
  11840. };
  11841. /**
  11842. * Extension object for DataTables that is used to provide all extension
  11843. * options.
  11844. *
  11845. * Note that the `DataTable.ext` object is available through
  11846. * `jQuery.fn.dataTable.ext` where it may be accessed and manipulated. It is
  11847. * also aliased to `jQuery.fn.dataTableExt` for historic reasons.
  11848. * @namespace
  11849. * @extends DataTable.models.ext
  11850. */
  11851. /**
  11852. * DataTables extensions
  11853. *
  11854. * This namespace acts as a collection area for plug-ins that can be used to
  11855. * extend DataTables capabilities. Indeed many of the build in methods
  11856. * use this method to provide their own capabilities (sorting methods for
  11857. * example).
  11858. *
  11859. * Note that this namespace is aliased to `jQuery.fn.dataTableExt` for legacy
  11860. * reasons
  11861. *
  11862. * @namespace
  11863. */
  11864. DataTable.ext = _ext = {
  11865. /**
  11866. * Buttons. For use with the Buttons extension for DataTables. This is
  11867. * defined here so other extensions can define buttons regardless of load
  11868. * order. It is _not_ used by DataTables core.
  11869. *
  11870. * @type object
  11871. * @default {}
  11872. */
  11873. buttons: {},
  11874. /**
  11875. * Element class names
  11876. *
  11877. * @type object
  11878. * @default {}
  11879. */
  11880. classes: {},
  11881. /**
  11882. * Error reporting.
  11883. *
  11884. * How should DataTables report an error. Can take the value 'alert',
  11885. * 'throw', 'none' or a function.
  11886. *
  11887. * @type string|function
  11888. * @default alert
  11889. */
  11890. errMode: "alert",
  11891. /**
  11892. * Feature plug-ins.
  11893. *
  11894. * This is an array of objects which describe the feature plug-ins that are
  11895. * available to DataTables. These feature plug-ins are then available for
  11896. * use through the `dom` initialisation option.
  11897. *
  11898. * Each feature plug-in is described by an object which must have the
  11899. * following properties:
  11900. *
  11901. * * `fnInit` - function that is used to initialise the plug-in,
  11902. * * `cFeature` - a character so the feature can be enabled by the `dom`
  11903. * instillation option. This is case sensitive.
  11904. *
  11905. * The `fnInit` function has the following input parameters:
  11906. *
  11907. * 1. `{object}` DataTables settings object: see
  11908. * {@link DataTable.models.oSettings}
  11909. *
  11910. * And the following return is expected:
  11911. *
  11912. * * {node|null} The element which contains your feature. Note that the
  11913. * return may also be void if your plug-in does not require to inject any
  11914. * DOM elements into DataTables control (`dom`) - for example this might
  11915. * be useful when developing a plug-in which allows table control via
  11916. * keyboard entry
  11917. *
  11918. * @type array
  11919. *
  11920. * @example
  11921. * $.fn.dataTable.ext.features.push( {
  11922. * "fnInit": function( oSettings ) {
  11923. * return new TableTools( { "oDTSettings": oSettings } );
  11924. * },
  11925. * "cFeature": "T"
  11926. * } );
  11927. */
  11928. feature: [],
  11929. /**
  11930. * Row searching.
  11931. *
  11932. * This method of searching is complimentary to the default type based
  11933. * searching, and a lot more comprehensive as it allows you complete control
  11934. * over the searching logic. Each element in this array is a function
  11935. * (parameters described below) that is called for every row in the table,
  11936. * and your logic decides if it should be included in the searching data set
  11937. * or not.
  11938. *
  11939. * Searching functions have the following input parameters:
  11940. *
  11941. * 1. `{object}` DataTables settings object: see
  11942. * {@link DataTable.models.oSettings}
  11943. * 2. `{array|object}` Data for the row to be processed (same as the
  11944. * original format that was passed in as the data source, or an array
  11945. * from a DOM data source
  11946. * 3. `{int}` Row index ({@link DataTable.models.oSettings.aoData}), which
  11947. * can be useful to retrieve the `TR` element if you need DOM interaction.
  11948. *
  11949. * And the following return is expected:
  11950. *
  11951. * * {boolean} Include the row in the searched result set (true) or not
  11952. * (false)
  11953. *
  11954. * Note that as with the main search ability in DataTables, technically this
  11955. * is "filtering", since it is subtractive. However, for consistency in
  11956. * naming we call it searching here.
  11957. *
  11958. * @type array
  11959. * @default []
  11960. *
  11961. * @example
  11962. * // The following example shows custom search being applied to the
  11963. * // fourth column (i.e. the data[3] index) based on two input values
  11964. * // from the end-user, matching the data in a certain range.
  11965. * $.fn.dataTable.ext.search.push(
  11966. * function( settings, data, dataIndex ) {
  11967. * var min = document.getElementById('min').value * 1;
  11968. * var max = document.getElementById('max').value * 1;
  11969. * var version = data[3] == "-" ? 0 : data[3]*1;
  11970. *
  11971. * if ( min == "" && max == "" ) {
  11972. * return true;
  11973. * }
  11974. * else if ( min == "" && version < max ) {
  11975. * return true;
  11976. * }
  11977. * else if ( min < version && "" == max ) {
  11978. * return true;
  11979. * }
  11980. * else if ( min < version && version < max ) {
  11981. * return true;
  11982. * }
  11983. * return false;
  11984. * }
  11985. * );
  11986. */
  11987. search: [],
  11988. /**
  11989. * Selector extensions
  11990. *
  11991. * The `selector` option can be used to extend the options available for the
  11992. * selector modifier options (`selector-modifier` object data type) that
  11993. * each of the three built in selector types offer (row, column and cell +
  11994. * their plural counterparts). For example the Select extension uses this
  11995. * mechanism to provide an option to select only rows, columns and cells
  11996. * that have been marked as selected by the end user (`{selected: true}`),
  11997. * which can be used in conjunction with the existing built in selector
  11998. * options.
  11999. *
  12000. * Each property is an array to which functions can be pushed. The functions
  12001. * take three attributes:
  12002. *
  12003. * * Settings object for the host table
  12004. * * Options object (`selector-modifier` object type)
  12005. * * Array of selected item indexes
  12006. *
  12007. * The return is an array of the resulting item indexes after the custom
  12008. * selector has been applied.
  12009. *
  12010. * @type object
  12011. */
  12012. selector: {
  12013. cell: [],
  12014. column: [],
  12015. row: []
  12016. },
  12017. /**
  12018. * Internal functions, exposed for used in plug-ins.
  12019. *
  12020. * Please note that you should not need to use the internal methods for
  12021. * anything other than a plug-in (and even then, try to avoid if possible).
  12022. * The internal function may change between releases.
  12023. *
  12024. * @type object
  12025. * @default {}
  12026. */
  12027. internal: {},
  12028. /**
  12029. * Legacy configuration options. Enable and disable legacy options that
  12030. * are available in DataTables.
  12031. *
  12032. * @type object
  12033. */
  12034. legacy: {
  12035. /**
  12036. * Enable / disable DataTables 1.9 compatible server-side processing
  12037. * requests
  12038. *
  12039. * @type boolean
  12040. * @default null
  12041. */
  12042. ajax: null
  12043. },
  12044. /**
  12045. * Pagination plug-in methods.
  12046. *
  12047. * Each entry in this object is a function and defines which buttons should
  12048. * be shown by the pagination rendering method that is used for the table:
  12049. * {@link DataTable.ext.renderer.pageButton}. The renderer addresses how the
  12050. * buttons are displayed in the document, while the functions here tell it
  12051. * what buttons to display. This is done by returning an array of button
  12052. * descriptions (what each button will do).
  12053. *
  12054. * Pagination types (the four built in options and any additional plug-in
  12055. * options defined here) can be used through the `paginationType`
  12056. * initialisation parameter.
  12057. *
  12058. * The functions defined take two parameters:
  12059. *
  12060. * 1. `{int} page` The current page index
  12061. * 2. `{int} pages` The number of pages in the table
  12062. *
  12063. * Each function is expected to return an array where each element of the
  12064. * array can be one of:
  12065. *
  12066. * * `first` - Jump to first page when activated
  12067. * * `last` - Jump to last page when activated
  12068. * * `previous` - Show previous page when activated
  12069. * * `next` - Show next page when activated
  12070. * * `{int}` - Show page of the index given
  12071. * * `{array}` - A nested array containing the above elements to add a
  12072. * containing 'DIV' element (might be useful for styling).
  12073. *
  12074. * Note that DataTables v1.9- used this object slightly differently whereby
  12075. * an object with two functions would be defined for each plug-in. That
  12076. * ability is still supported by DataTables 1.10+ to provide backwards
  12077. * compatibility, but this option of use is now decremented and no longer
  12078. * documented in DataTables 1.10+.
  12079. *
  12080. * @type object
  12081. * @default {}
  12082. *
  12083. * @example
  12084. * // Show previous, next and current page buttons only
  12085. * $.fn.dataTableExt.oPagination.current = function ( page, pages ) {
  12086. * return [ 'previous', page, 'next' ];
  12087. * };
  12088. */
  12089. pager: {},
  12090. renderer: {
  12091. pageButton: {},
  12092. header: {}
  12093. },
  12094. /**
  12095. * Ordering plug-ins - custom data source
  12096. *
  12097. * The extension options for ordering of data available here is complimentary
  12098. * to the default type based ordering that DataTables typically uses. It
  12099. * allows much greater control over the the data that is being used to
  12100. * order a column, but is necessarily therefore more complex.
  12101. *
  12102. * This type of ordering is useful if you want to do ordering based on data
  12103. * live from the DOM (for example the contents of an 'input' element) rather
  12104. * than just the static string that DataTables knows of.
  12105. *
  12106. * The way these plug-ins work is that you create an array of the values you
  12107. * wish to be ordering for the column in question and then return that
  12108. * array. The data in the array much be in the index order of the rows in
  12109. * the table (not the currently ordering order!). Which order data gathering
  12110. * function is run here depends on the `dt-init columns.orderDataType`
  12111. * parameter that is used for the column (if any).
  12112. *
  12113. * The functions defined take two parameters:
  12114. *
  12115. * 1. `{object}` DataTables settings object: see
  12116. * {@link DataTable.models.oSettings}
  12117. * 2. `{int}` Target column index
  12118. *
  12119. * Each function is expected to return an array:
  12120. *
  12121. * * `{array}` Data for the column to be ordering upon
  12122. *
  12123. * @type array
  12124. *
  12125. * @example
  12126. * // Ordering using `input` node values
  12127. * $.fn.dataTable.ext.order['dom-text'] = function ( settings, col )
  12128. * {
  12129. * return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
  12130. * return $('input', td).val();
  12131. * } );
  12132. * }
  12133. */
  12134. order: {},
  12135. /**
  12136. * Type based plug-ins.
  12137. *
  12138. * Each column in DataTables has a type assigned to it, either by automatic
  12139. * detection or by direct assignment using the `type` option for the column.
  12140. * The type of a column will effect how it is ordering and search (plug-ins
  12141. * can also make use of the column type if required).
  12142. *
  12143. * @namespace
  12144. */
  12145. type: {
  12146. /**
  12147. * Type detection functions.
  12148. *
  12149. * The functions defined in this object are used to automatically detect
  12150. * a column's type, making initialisation of DataTables super easy, even
  12151. * when complex data is in the table.
  12152. *
  12153. * The functions defined take two parameters:
  12154. *
  12155. * 1. `{*}` Data from the column cell to be analysed
  12156. * 2. `{settings}` DataTables settings object. This can be used to
  12157. * perform context specific type detection - for example detection
  12158. * based on language settings such as using a comma for a decimal
  12159. * place. Generally speaking the options from the settings will not
  12160. * be required
  12161. *
  12162. * Each function is expected to return:
  12163. *
  12164. * * `{string|null}` Data type detected, or null if unknown (and thus
  12165. * pass it on to the other type detection functions.
  12166. *
  12167. * @type array
  12168. *
  12169. * @example
  12170. * // Currency type detection plug-in:
  12171. * $.fn.dataTable.ext.type.detect.push(
  12172. * function ( data, settings ) {
  12173. * // Check the numeric part
  12174. * if ( ! $.isNumeric( data.substring(1) ) ) {
  12175. * return null;
  12176. * }
  12177. *
  12178. * // Check prefixed by currency
  12179. * if ( data.charAt(0) == '$' || data.charAt(0) == '&pound;' ) {
  12180. * return 'currency';
  12181. * }
  12182. * return null;
  12183. * }
  12184. * );
  12185. */
  12186. detect: [],
  12187. /**
  12188. * Type based search formatting.
  12189. *
  12190. * The type based searching functions can be used to pre-format the
  12191. * data to be search on. For example, it can be used to strip HTML
  12192. * tags or to de-format telephone numbers for numeric only searching.
  12193. *
  12194. * Note that is a search is not defined for a column of a given type,
  12195. * no search formatting will be performed.
  12196. *
  12197. * Pre-processing of searching data plug-ins - When you assign the sType
  12198. * for a column (or have it automatically detected for you by DataTables
  12199. * or a type detection plug-in), you will typically be using this for
  12200. * custom sorting, but it can also be used to provide custom searching
  12201. * by allowing you to pre-processing the data and returning the data in
  12202. * the format that should be searched upon. This is done by adding
  12203. * functions this object with a parameter name which matches the sType
  12204. * for that target column. This is the corollary of <i>afnSortData</i>
  12205. * for searching data.
  12206. *
  12207. * The functions defined take a single parameter:
  12208. *
  12209. * 1. `{*}` Data from the column cell to be prepared for searching
  12210. *
  12211. * Each function is expected to return:
  12212. *
  12213. * * `{string|null}` Formatted string that will be used for the searching.
  12214. *
  12215. * @type object
  12216. * @default {}
  12217. *
  12218. * @example
  12219. * $.fn.dataTable.ext.type.search['title-numeric'] = function ( d ) {
  12220. * return d.replace(/\n/g," ").replace( /<.*?>/g, "" );
  12221. * }
  12222. */
  12223. search: {},
  12224. /**
  12225. * Type based ordering.
  12226. *
  12227. * The column type tells DataTables what ordering to apply to the table
  12228. * when a column is sorted upon. The order for each type that is defined,
  12229. * is defined by the functions available in this object.
  12230. *
  12231. * Each ordering option can be described by three properties added to
  12232. * this object:
  12233. *
  12234. * * `{type}-pre` - Pre-formatting function
  12235. * * `{type}-asc` - Ascending order function
  12236. * * `{type}-desc` - Descending order function
  12237. *
  12238. * All three can be used together, only `{type}-pre` or only
  12239. * `{type}-asc` and `{type}-desc` together. It is generally recommended
  12240. * that only `{type}-pre` is used, as this provides the optimal
  12241. * implementation in terms of speed, although the others are provided
  12242. * for compatibility with existing Javascript sort functions.
  12243. *
  12244. * `{type}-pre`: Functions defined take a single parameter:
  12245. *
  12246. * 1. `{*}` Data from the column cell to be prepared for ordering
  12247. *
  12248. * And return:
  12249. *
  12250. * * `{*}` Data to be sorted upon
  12251. *
  12252. * `{type}-asc` and `{type}-desc`: Functions are typical Javascript sort
  12253. * functions, taking two parameters:
  12254. *
  12255. * 1. `{*}` Data to compare to the second parameter
  12256. * 2. `{*}` Data to compare to the first parameter
  12257. *
  12258. * And returning:
  12259. *
  12260. * * `{*}` Ordering match: <0 if first parameter should be sorted lower
  12261. * than the second parameter, ===0 if the two parameters are equal and
  12262. * >0 if the first parameter should be sorted height than the second
  12263. * parameter.
  12264. *
  12265. * @type object
  12266. * @default {}
  12267. *
  12268. * @example
  12269. * // Numeric ordering of formatted numbers with a pre-formatter
  12270. * $.extend( $.fn.dataTable.ext.type.order, {
  12271. * "string-pre": function(x) {
  12272. * a = (a === "-" || a === "") ? 0 : a.replace( /[^\d\-\.]/g, "" );
  12273. * return parseFloat( a );
  12274. * }
  12275. * } );
  12276. *
  12277. * @example
  12278. * // Case-sensitive string ordering, with no pre-formatting method
  12279. * $.extend( $.fn.dataTable.ext.order, {
  12280. * "string-case-asc": function(x,y) {
  12281. * return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12282. * },
  12283. * "string-case-desc": function(x,y) {
  12284. * return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12285. * }
  12286. * } );
  12287. */
  12288. order: {}
  12289. },
  12290. /**
  12291. * Unique DataTables instance counter
  12292. *
  12293. * @type int
  12294. * @private
  12295. */
  12296. _unique: 0,
  12297. //
  12298. // Depreciated
  12299. // The following properties are retained for backwards compatiblity only.
  12300. // The should not be used in new projects and will be removed in a future
  12301. // version
  12302. //
  12303. /**
  12304. * Version check function.
  12305. * @type function
  12306. * @depreciated Since 1.10
  12307. */
  12308. fnVersionCheck: DataTable.fnVersionCheck,
  12309. /**
  12310. * Index for what 'this' index API functions should use
  12311. * @type int
  12312. * @deprecated Since v1.10
  12313. */
  12314. iApiIndex: 0,
  12315. /**
  12316. * jQuery UI class container
  12317. * @type object
  12318. * @deprecated Since v1.10
  12319. */
  12320. oJUIClasses: {},
  12321. /**
  12322. * Software version
  12323. * @type string
  12324. * @deprecated Since v1.10
  12325. */
  12326. sVersion: DataTable.version
  12327. };
  12328. //
  12329. // Backwards compatibility. Alias to pre 1.10 Hungarian notation counter parts
  12330. //
  12331. $.extend( _ext, {
  12332. afnFiltering: _ext.search,
  12333. aTypes: _ext.type.detect,
  12334. ofnSearch: _ext.type.search,
  12335. oSort: _ext.type.order,
  12336. afnSortData: _ext.order,
  12337. aoFeatures: _ext.feature,
  12338. oApi: _ext.internal,
  12339. oStdClasses: _ext.classes,
  12340. oPagination: _ext.pager
  12341. } );
  12342. $.extend( DataTable.ext.classes, {
  12343. "sTable": "dataTable",
  12344. "sNoFooter": "no-footer",
  12345. /* Paging buttons */
  12346. "sPageButton": "paginate_button",
  12347. "sPageButtonActive": "current",
  12348. "sPageButtonDisabled": "disabled",
  12349. /* Striping classes */
  12350. "sStripeOdd": "odd",
  12351. "sStripeEven": "even",
  12352. /* Empty row */
  12353. "sRowEmpty": "dataTables_empty",
  12354. /* Features */
  12355. "sWrapper": "dataTables_wrapper",
  12356. "sFilter": "dataTables_filter",
  12357. "sInfo": "dataTables_info",
  12358. "sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */
  12359. "sLength": "dataTables_length",
  12360. "sProcessing": "dataTables_processing",
  12361. /* Sorting */
  12362. "sSortAsc": "sorting_asc",
  12363. "sSortDesc": "sorting_desc",
  12364. "sSortable": "sorting", /* Sortable in both directions */
  12365. "sSortableAsc": "sorting_asc_disabled",
  12366. "sSortableDesc": "sorting_desc_disabled",
  12367. "sSortableNone": "sorting_disabled",
  12368. "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
  12369. /* Filtering */
  12370. "sFilterInput": "",
  12371. /* Page length */
  12372. "sLengthSelect": "",
  12373. /* Scrolling */
  12374. "sScrollWrapper": "dataTables_scroll",
  12375. "sScrollHead": "dataTables_scrollHead",
  12376. "sScrollHeadInner": "dataTables_scrollHeadInner",
  12377. "sScrollBody": "dataTables_scrollBody",
  12378. "sScrollFoot": "dataTables_scrollFoot",
  12379. "sScrollFootInner": "dataTables_scrollFootInner",
  12380. /* Misc */
  12381. "sHeaderTH": "",
  12382. "sFooterTH": "",
  12383. // Deprecated
  12384. "sSortJUIAsc": "",
  12385. "sSortJUIDesc": "",
  12386. "sSortJUI": "",
  12387. "sSortJUIAscAllowed": "",
  12388. "sSortJUIDescAllowed": "",
  12389. "sSortJUIWrapper": "",
  12390. "sSortIcon": "",
  12391. "sJUIHeader": "",
  12392. "sJUIFooter": ""
  12393. } );
  12394. (function() {
  12395. // Reused strings for better compression. Closure compiler appears to have a
  12396. // weird edge case where it is trying to expand strings rather than use the
  12397. // variable version. This results in about 200 bytes being added, for very
  12398. // little preference benefit since it this run on script load only.
  12399. var _empty = '';
  12400. _empty = '';
  12401. var _stateDefault = _empty + 'ui-state-default';
  12402. var _sortIcon = _empty + 'css_right ui-icon ui-icon-';
  12403. var _headerFooter = _empty + 'fg-toolbar ui-toolbar ui-widget-header ui-helper-clearfix';
  12404. $.extend( DataTable.ext.oJUIClasses, DataTable.ext.classes, {
  12405. /* Full numbers paging buttons */
  12406. "sPageButton": "fg-button ui-button "+_stateDefault,
  12407. "sPageButtonActive": "ui-state-disabled",
  12408. "sPageButtonDisabled": "ui-state-disabled",
  12409. /* Features */
  12410. "sPaging": "dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi "+
  12411. "ui-buttonset-multi paging_", /* Note that the type is postfixed */
  12412. /* Sorting */
  12413. "sSortAsc": _stateDefault+" sorting_asc",
  12414. "sSortDesc": _stateDefault+" sorting_desc",
  12415. "sSortable": _stateDefault+" sorting",
  12416. "sSortableAsc": _stateDefault+" sorting_asc_disabled",
  12417. "sSortableDesc": _stateDefault+" sorting_desc_disabled",
  12418. "sSortableNone": _stateDefault+" sorting_disabled",
  12419. "sSortJUIAsc": _sortIcon+"triangle-1-n",
  12420. "sSortJUIDesc": _sortIcon+"triangle-1-s",
  12421. "sSortJUI": _sortIcon+"carat-2-n-s",
  12422. "sSortJUIAscAllowed": _sortIcon+"carat-1-n",
  12423. "sSortJUIDescAllowed": _sortIcon+"carat-1-s",
  12424. "sSortJUIWrapper": "DataTables_sort_wrapper",
  12425. "sSortIcon": "DataTables_sort_icon",
  12426. /* Scrolling */
  12427. "sScrollHead": "dataTables_scrollHead "+_stateDefault,
  12428. "sScrollFoot": "dataTables_scrollFoot "+_stateDefault,
  12429. /* Misc */
  12430. "sHeaderTH": _stateDefault,
  12431. "sFooterTH": _stateDefault,
  12432. "sJUIHeader": _headerFooter+" ui-corner-tl ui-corner-tr",
  12433. "sJUIFooter": _headerFooter+" ui-corner-bl ui-corner-br"
  12434. } );
  12435. }());
  12436. var extPagination = DataTable.ext.pager;
  12437. function _numbers ( page, pages ) {
  12438. var
  12439. numbers = [],
  12440. buttons = extPagination.numbers_length,
  12441. half = Math.floor( buttons / 2 ),
  12442. i = 1;
  12443. if ( pages <= buttons ) {
  12444. numbers = _range( 0, pages );
  12445. }
  12446. else if ( page <= half ) {
  12447. numbers = _range( 0, buttons-2 );
  12448. numbers.push( 'ellipsis' );
  12449. numbers.push( pages-1 );
  12450. }
  12451. else if ( page >= pages - 1 - half ) {
  12452. numbers = _range( pages-(buttons-2), pages );
  12453. numbers.splice( 0, 0, 'ellipsis' ); // no unshift in ie6
  12454. numbers.splice( 0, 0, 0 );
  12455. }
  12456. else {
  12457. numbers = _range( page-half+2, page+half-1 );
  12458. numbers.push( 'ellipsis' );
  12459. numbers.push( pages-1 );
  12460. numbers.splice( 0, 0, 'ellipsis' );
  12461. numbers.splice( 0, 0, 0 );
  12462. }
  12463. numbers.DT_el = 'span';
  12464. return numbers;
  12465. }
  12466. $.extend( extPagination, {
  12467. simple: function ( page, pages ) {
  12468. return [ 'previous', 'next' ];
  12469. },
  12470. full: function ( page, pages ) {
  12471. return [ 'first', 'previous', 'next', 'last' ];
  12472. },
  12473. numbers: function ( page, pages ) {
  12474. return [ _numbers(page, pages) ];
  12475. },
  12476. simple_numbers: function ( page, pages ) {
  12477. return [ 'previous', _numbers(page, pages), 'next' ];
  12478. },
  12479. full_numbers: function ( page, pages ) {
  12480. return [ 'first', 'previous', _numbers(page, pages), 'next', 'last' ];
  12481. },
  12482. // For testing and plug-ins to use
  12483. _numbers: _numbers,
  12484. // Number of number buttons (including ellipsis) to show. _Must be odd!_
  12485. numbers_length: 7
  12486. } );
  12487. $.extend( true, DataTable.ext.renderer, {
  12488. pageButton: {
  12489. _: function ( settings, host, idx, buttons, page, pages ) {
  12490. var classes = settings.oClasses;
  12491. var lang = settings.oLanguage.oPaginate;
  12492. var btnDisplay, btnClass, counter=0;
  12493. var attach = function( container, buttons ) {
  12494. var i, ien, node, button;
  12495. var clickHandler = function ( e ) {
  12496. _fnPageChange( settings, e.data.action, true );
  12497. };
  12498. for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
  12499. button = buttons[i];
  12500. if ( $.isArray( button ) ) {
  12501. var inner = $( '<'+(button.DT_el || 'div')+'/>' )
  12502. .appendTo( container );
  12503. attach( inner, button );
  12504. }
  12505. else {
  12506. btnDisplay = null;
  12507. btnClass = '';
  12508. switch ( button ) {
  12509. case 'ellipsis':
  12510. container.append('<span class="ellipsis">&#x2026;</span>');
  12511. break;
  12512. case 'first':
  12513. btnDisplay = lang.sFirst;
  12514. btnClass = button + (page > 0 ?
  12515. '' : ' '+classes.sPageButtonDisabled);
  12516. break;
  12517. case 'previous':
  12518. btnDisplay = lang.sPrevious;
  12519. btnClass = button + (page > 0 ?
  12520. '' : ' '+classes.sPageButtonDisabled);
  12521. break;
  12522. case 'next':
  12523. btnDisplay = lang.sNext;
  12524. btnClass = button + (page < pages-1 ?
  12525. '' : ' '+classes.sPageButtonDisabled);
  12526. break;
  12527. case 'last':
  12528. btnDisplay = lang.sLast;
  12529. btnClass = button + (page < pages-1 ?
  12530. '' : ' '+classes.sPageButtonDisabled);
  12531. break;
  12532. default:
  12533. btnDisplay = button + 1;
  12534. btnClass = page === button ?
  12535. classes.sPageButtonActive : '';
  12536. break;
  12537. }
  12538. if ( btnDisplay !== null ) {
  12539. node = $('<a>', {
  12540. 'class': classes.sPageButton+' '+btnClass,
  12541. 'aria-controls': settings.sTableId,
  12542. 'data-dt-idx': counter,
  12543. 'tabindex': settings.iTabIndex,
  12544. 'id': idx === 0 && typeof button === 'string' ?
  12545. settings.sTableId +'_'+ button :
  12546. null
  12547. } )
  12548. .html( btnDisplay )
  12549. .appendTo( container );
  12550. _fnBindAction(
  12551. node, {action: button}, clickHandler
  12552. );
  12553. counter++;
  12554. }
  12555. }
  12556. }
  12557. };
  12558. // IE9 throws an 'unknown error' if document.activeElement is used
  12559. // inside an iframe or frame. Try / catch the error. Not good for
  12560. // accessibility, but neither are frames.
  12561. var activeEl;
  12562. try {
  12563. // Because this approach is destroying and recreating the paging
  12564. // elements, focus is lost on the select button which is bad for
  12565. // accessibility. So we want to restore focus once the draw has
  12566. // completed
  12567. activeEl = $(host).find(document.activeElement).data('dt-idx');
  12568. }
  12569. catch (e) {}
  12570. attach( $(host).empty(), buttons );
  12571. if ( activeEl ) {
  12572. $(host).find( '[data-dt-idx='+activeEl+']' ).focus();
  12573. }
  12574. }
  12575. }
  12576. } );
  12577. // Built in type detection. See model.ext.aTypes for information about
  12578. // what is required from this methods.
  12579. $.extend( DataTable.ext.type.detect, [
  12580. // Plain numbers - first since V8 detects some plain numbers as dates
  12581. // e.g. Date.parse('55') (but not all, e.g. Date.parse('22')...).
  12582. function ( d, settings )
  12583. {
  12584. var decimal = settings.oLanguage.sDecimal;
  12585. return _isNumber( d, decimal ) ? 'num'+decimal : null;
  12586. },
  12587. // Dates (only those recognised by the browser's Date.parse)
  12588. function ( d, settings )
  12589. {
  12590. // V8 will remove any unknown characters at the start and end of the
  12591. // expression, leading to false matches such as `$245.12` or `10%` being
  12592. // a valid date. See forum thread 18941 for detail.
  12593. if ( d && !(d instanceof Date) && ( ! _re_date_start.test(d) || ! _re_date_end.test(d) ) ) {
  12594. return null;
  12595. }
  12596. var parsed = Date.parse(d);
  12597. return (parsed !== null && !isNaN(parsed)) || _empty(d) ? 'date' : null;
  12598. },
  12599. // Formatted numbers
  12600. function ( d, settings )
  12601. {
  12602. var decimal = settings.oLanguage.sDecimal;
  12603. return _isNumber( d, decimal, true ) ? 'num-fmt'+decimal : null;
  12604. },
  12605. // HTML numeric
  12606. function ( d, settings )
  12607. {
  12608. var decimal = settings.oLanguage.sDecimal;
  12609. return _htmlNumeric( d, decimal ) ? 'html-num'+decimal : null;
  12610. },
  12611. // HTML numeric, formatted
  12612. function ( d, settings )
  12613. {
  12614. var decimal = settings.oLanguage.sDecimal;
  12615. return _htmlNumeric( d, decimal, true ) ? 'html-num-fmt'+decimal : null;
  12616. },
  12617. // HTML (this is strict checking - there must be html)
  12618. function ( d, settings )
  12619. {
  12620. return _empty( d ) || (typeof d === 'string' && d.indexOf('<') !== -1) ?
  12621. 'html' : null;
  12622. }
  12623. ] );
  12624. // Filter formatting functions. See model.ext.ofnSearch for information about
  12625. // what is required from these methods.
  12626. //
  12627. // Note that additional search methods are added for the html numbers and
  12628. // html formatted numbers by `_addNumericSort()` when we know what the decimal
  12629. // place is
  12630. $.extend( DataTable.ext.type.search, {
  12631. html: function ( data ) {
  12632. return _empty(data) ?
  12633. data :
  12634. typeof data === 'string' ?
  12635. data
  12636. .replace( _re_new_lines, " " )
  12637. .replace( _re_html, "" ) :
  12638. '';
  12639. },
  12640. string: function ( data ) {
  12641. return _empty(data) ?
  12642. data :
  12643. typeof data === 'string' ?
  12644. data.replace( _re_new_lines, " " ) :
  12645. data;
  12646. }
  12647. } );
  12648. var __numericReplace = function ( d, decimalPlace, re1, re2 ) {
  12649. if ( d !== 0 && (!d || d === '-') ) {
  12650. return -Infinity;
  12651. }
  12652. // If a decimal place other than `.` is used, it needs to be given to the
  12653. // function so we can detect it and replace with a `.` which is the only
  12654. // decimal place Javascript recognises - it is not locale aware.
  12655. if ( decimalPlace ) {
  12656. d = _numToDecimal( d, decimalPlace );
  12657. }
  12658. if ( d.replace ) {
  12659. if ( re1 ) {
  12660. d = d.replace( re1, '' );
  12661. }
  12662. if ( re2 ) {
  12663. d = d.replace( re2, '' );
  12664. }
  12665. }
  12666. return d * 1;
  12667. };
  12668. // Add the numeric 'deformatting' functions for sorting and search. This is done
  12669. // in a function to provide an easy ability for the language options to add
  12670. // additional methods if a non-period decimal place is used.
  12671. function _addNumericSort ( decimalPlace ) {
  12672. $.each(
  12673. {
  12674. // Plain numbers
  12675. "num": function ( d ) {
  12676. return __numericReplace( d, decimalPlace );
  12677. },
  12678. // Formatted numbers
  12679. "num-fmt": function ( d ) {
  12680. return __numericReplace( d, decimalPlace, _re_formatted_numeric );
  12681. },
  12682. // HTML numeric
  12683. "html-num": function ( d ) {
  12684. return __numericReplace( d, decimalPlace, _re_html );
  12685. },
  12686. // HTML numeric, formatted
  12687. "html-num-fmt": function ( d ) {
  12688. return __numericReplace( d, decimalPlace, _re_html, _re_formatted_numeric );
  12689. }
  12690. },
  12691. function ( key, fn ) {
  12692. // Add the ordering method
  12693. _ext.type.order[ key+decimalPlace+'-pre' ] = fn;
  12694. // For HTML types add a search formatter that will strip the HTML
  12695. if ( key.match(/^html\-/) ) {
  12696. _ext.type.search[ key+decimalPlace ] = _ext.type.search.html;
  12697. }
  12698. }
  12699. );
  12700. }
  12701. // Default sort methods
  12702. $.extend( _ext.type.order, {
  12703. // Dates
  12704. "date-pre": function ( d ) {
  12705. return Date.parse( d ) || 0;
  12706. },
  12707. // html
  12708. "html-pre": function ( a ) {
  12709. return _empty(a) ?
  12710. '' :
  12711. a.replace ?
  12712. a.replace( /<.*?>/g, "" ).toLowerCase() :
  12713. a+'';
  12714. },
  12715. // string
  12716. "string-pre": function ( a ) {
  12717. // This is a little complex, but faster than always calling toString,
  12718. // http://jsperf.com/tostring-v-check
  12719. return _empty(a) ?
  12720. '' :
  12721. typeof a === 'string' ?
  12722. a.toLowerCase() :
  12723. ! a.toString ?
  12724. '' :
  12725. a.toString();
  12726. },
  12727. // string-asc and -desc are retained only for compatibility with the old
  12728. // sort methods
  12729. "string-asc": function ( x, y ) {
  12730. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12731. },
  12732. "string-desc": function ( x, y ) {
  12733. return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12734. }
  12735. } );
  12736. // Numeric sorting types - order doesn't matter here
  12737. _addNumericSort( '' );
  12738. $.extend( true, DataTable.ext.renderer, {
  12739. header: {
  12740. _: function ( settings, cell, column, classes ) {
  12741. // No additional mark-up required
  12742. // Attach a sort listener to update on sort - note that using the
  12743. // `DT` namespace will allow the event to be removed automatically
  12744. // on destroy, while the `dt` namespaced event is the one we are
  12745. // listening for
  12746. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  12747. if ( settings !== ctx ) { // need to check this this is the host
  12748. return; // table, not a nested one
  12749. }
  12750. var colIdx = column.idx;
  12751. cell
  12752. .removeClass(
  12753. column.sSortingClass +' '+
  12754. classes.sSortAsc +' '+
  12755. classes.sSortDesc
  12756. )
  12757. .addClass( columns[ colIdx ] == 'asc' ?
  12758. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  12759. classes.sSortDesc :
  12760. column.sSortingClass
  12761. );
  12762. } );
  12763. },
  12764. jqueryui: function ( settings, cell, column, classes ) {
  12765. $('<div/>')
  12766. .addClass( classes.sSortJUIWrapper )
  12767. .append( cell.contents() )
  12768. .append( $('<span/>')
  12769. .addClass( classes.sSortIcon+' '+column.sSortingClassJUI )
  12770. )
  12771. .appendTo( cell );
  12772. // Attach a sort listener to update on sort
  12773. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  12774. if ( settings !== ctx ) {
  12775. return;
  12776. }
  12777. var colIdx = column.idx;
  12778. cell
  12779. .removeClass( classes.sSortAsc +" "+classes.sSortDesc )
  12780. .addClass( columns[ colIdx ] == 'asc' ?
  12781. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  12782. classes.sSortDesc :
  12783. column.sSortingClass
  12784. );
  12785. cell
  12786. .find( 'span.'+classes.sSortIcon )
  12787. .removeClass(
  12788. classes.sSortJUIAsc +" "+
  12789. classes.sSortJUIDesc +" "+
  12790. classes.sSortJUI +" "+
  12791. classes.sSortJUIAscAllowed +" "+
  12792. classes.sSortJUIDescAllowed
  12793. )
  12794. .addClass( columns[ colIdx ] == 'asc' ?
  12795. classes.sSortJUIAsc : columns[ colIdx ] == 'desc' ?
  12796. classes.sSortJUIDesc :
  12797. column.sSortingClassJUI
  12798. );
  12799. } );
  12800. }
  12801. }
  12802. } );
  12803. /*
  12804. * Public helper functions. These aren't used internally by DataTables, or
  12805. * called by any of the options passed into DataTables, but they can be used
  12806. * externally by developers working with DataTables. They are helper functions
  12807. * to make working with DataTables a little bit easier.
  12808. */
  12809. /**
  12810. * Helpers for `columns.render`.
  12811. *
  12812. * The options defined here can be used with the `columns.render` initialisation
  12813. * option to provide a display renderer. The following functions are defined:
  12814. *
  12815. * * `number` - Will format numeric data (defined by `columns.data`) for
  12816. * display, retaining the original unformatted data for sorting and filtering.
  12817. * It takes 5 parameters:
  12818. * * `string` - Thousands grouping separator
  12819. * * `string` - Decimal point indicator
  12820. * * `integer` - Number of decimal points to show
  12821. * * `string` (optional) - Prefix.
  12822. * * `string` (optional) - Postfix (/suffix).
  12823. *
  12824. * @example
  12825. * // Column definition using the number renderer
  12826. * {
  12827. * data: "salary",
  12828. * render: $.fn.dataTable.render.number( '\'', '.', 0, '$' )
  12829. * }
  12830. *
  12831. * @namespace
  12832. */
  12833. DataTable.render = {
  12834. number: function ( thousands, decimal, precision, prefix, postfix ) {
  12835. return {
  12836. display: function ( d ) {
  12837. if ( typeof d !== 'number' && typeof d !== 'string' ) {
  12838. return d;
  12839. }
  12840. var negative = d < 0 ? '-' : '';
  12841. d = Math.abs( parseFloat( d ) );
  12842. var intPart = parseInt( d, 10 );
  12843. var floatPart = precision ?
  12844. decimal+(d - intPart).toFixed( precision ).substring( 2 ):
  12845. '';
  12846. return negative + (prefix||'') +
  12847. intPart.toString().replace(
  12848. /\B(?=(\d{3})+(?!\d))/g, thousands
  12849. ) +
  12850. floatPart +
  12851. (postfix||'');
  12852. }
  12853. };
  12854. }
  12855. };
  12856. /*
  12857. * This is really a good bit rubbish this method of exposing the internal methods
  12858. * publicly... - To be fixed in 2.0 using methods on the prototype
  12859. */
  12860. /**
  12861. * Create a wrapper function for exporting an internal functions to an external API.
  12862. * @param {string} fn API function name
  12863. * @returns {function} wrapped function
  12864. * @memberof DataTable#internal
  12865. */
  12866. function _fnExternApiFunc (fn)
  12867. {
  12868. return function() {
  12869. var args = [_fnSettingsFromNode( this[DataTable.ext.iApiIndex] )].concat(
  12870. Array.prototype.slice.call(arguments)
  12871. );
  12872. return DataTable.ext.internal[fn].apply( this, args );
  12873. };
  12874. }
  12875. /**
  12876. * Reference to internal functions for use by plug-in developers. Note that
  12877. * these methods are references to internal functions and are considered to be
  12878. * private. If you use these methods, be aware that they are liable to change
  12879. * between versions.
  12880. * @namespace
  12881. */
  12882. $.extend( DataTable.ext.internal, {
  12883. _fnExternApiFunc: _fnExternApiFunc,
  12884. _fnBuildAjax: _fnBuildAjax,
  12885. _fnAjaxUpdate: _fnAjaxUpdate,
  12886. _fnAjaxParameters: _fnAjaxParameters,
  12887. _fnAjaxUpdateDraw: _fnAjaxUpdateDraw,
  12888. _fnAjaxDataSrc: _fnAjaxDataSrc,
  12889. _fnAddColumn: _fnAddColumn,
  12890. _fnColumnOptions: _fnColumnOptions,
  12891. _fnAdjustColumnSizing: _fnAdjustColumnSizing,
  12892. _fnVisibleToColumnIndex: _fnVisibleToColumnIndex,
  12893. _fnColumnIndexToVisible: _fnColumnIndexToVisible,
  12894. _fnVisbleColumns: _fnVisbleColumns,
  12895. _fnGetColumns: _fnGetColumns,
  12896. _fnColumnTypes: _fnColumnTypes,
  12897. _fnApplyColumnDefs: _fnApplyColumnDefs,
  12898. _fnHungarianMap: _fnHungarianMap,
  12899. _fnCamelToHungarian: _fnCamelToHungarian,
  12900. _fnLanguageCompat: _fnLanguageCompat,
  12901. _fnBrowserDetect: _fnBrowserDetect,
  12902. _fnAddData: _fnAddData,
  12903. _fnAddTr: _fnAddTr,
  12904. _fnNodeToDataIndex: _fnNodeToDataIndex,
  12905. _fnNodeToColumnIndex: _fnNodeToColumnIndex,
  12906. _fnGetCellData: _fnGetCellData,
  12907. _fnSetCellData: _fnSetCellData,
  12908. _fnSplitObjNotation: _fnSplitObjNotation,
  12909. _fnGetObjectDataFn: _fnGetObjectDataFn,
  12910. _fnSetObjectDataFn: _fnSetObjectDataFn,
  12911. _fnGetDataMaster: _fnGetDataMaster,
  12912. _fnClearTable: _fnClearTable,
  12913. _fnDeleteIndex: _fnDeleteIndex,
  12914. _fnInvalidate: _fnInvalidate,
  12915. _fnGetRowElements: _fnGetRowElements,
  12916. _fnCreateTr: _fnCreateTr,
  12917. _fnBuildHead: _fnBuildHead,
  12918. _fnDrawHead: _fnDrawHead,
  12919. _fnDraw: _fnDraw,
  12920. _fnReDraw: _fnReDraw,
  12921. _fnAddOptionsHtml: _fnAddOptionsHtml,
  12922. _fnDetectHeader: _fnDetectHeader,
  12923. _fnGetUniqueThs: _fnGetUniqueThs,
  12924. _fnFeatureHtmlFilter: _fnFeatureHtmlFilter,
  12925. _fnFilterComplete: _fnFilterComplete,
  12926. _fnFilterCustom: _fnFilterCustom,
  12927. _fnFilterColumn: _fnFilterColumn,
  12928. _fnFilter: _fnFilter,
  12929. _fnFilterCreateSearch: _fnFilterCreateSearch,
  12930. _fnEscapeRegex: _fnEscapeRegex,
  12931. _fnFilterData: _fnFilterData,
  12932. _fnFeatureHtmlInfo: _fnFeatureHtmlInfo,
  12933. _fnUpdateInfo: _fnUpdateInfo,
  12934. _fnInfoMacros: _fnInfoMacros,
  12935. _fnInitialise: _fnInitialise,
  12936. _fnInitComplete: _fnInitComplete,
  12937. _fnLengthChange: _fnLengthChange,
  12938. _fnFeatureHtmlLength: _fnFeatureHtmlLength,
  12939. _fnFeatureHtmlPaginate: _fnFeatureHtmlPaginate,
  12940. _fnPageChange: _fnPageChange,
  12941. _fnFeatureHtmlProcessing: _fnFeatureHtmlProcessing,
  12942. _fnProcessingDisplay: _fnProcessingDisplay,
  12943. _fnFeatureHtmlTable: _fnFeatureHtmlTable,
  12944. _fnScrollDraw: _fnScrollDraw,
  12945. _fnApplyToChildren: _fnApplyToChildren,
  12946. _fnCalculateColumnWidths: _fnCalculateColumnWidths,
  12947. _fnThrottle: _fnThrottle,
  12948. _fnConvertToWidth: _fnConvertToWidth,
  12949. _fnGetWidestNode: _fnGetWidestNode,
  12950. _fnGetMaxLenString: _fnGetMaxLenString,
  12951. _fnStringToCss: _fnStringToCss,
  12952. _fnScrollBarWidth: _fnScrollBarWidth,
  12953. _fnSortFlatten: _fnSortFlatten,
  12954. _fnSort: _fnSort,
  12955. _fnSortAria: _fnSortAria,
  12956. _fnSortListener: _fnSortListener,
  12957. _fnSortAttachListener: _fnSortAttachListener,
  12958. _fnSortingClasses: _fnSortingClasses,
  12959. _fnSortData: _fnSortData,
  12960. _fnSaveState: _fnSaveState,
  12961. _fnLoadState: _fnLoadState,
  12962. _fnSettingsFromNode: _fnSettingsFromNode,
  12963. _fnLog: _fnLog,
  12964. _fnMap: _fnMap,
  12965. _fnBindAction: _fnBindAction,
  12966. _fnCallbackReg: _fnCallbackReg,
  12967. _fnCallbackFire: _fnCallbackFire,
  12968. _fnLengthOverflow: _fnLengthOverflow,
  12969. _fnRenderer: _fnRenderer,
  12970. _fnDataSource: _fnDataSource,
  12971. _fnRowAttributes: _fnRowAttributes,
  12972. _fnCalculateEnd: function () {} // Used by a lot of plug-ins, but redundant
  12973. // in 1.10, so this dead-end function is
  12974. // added to prevent errors
  12975. } );
  12976. // jQuery access
  12977. $.fn.dataTable = DataTable;
  12978. // Legacy aliases
  12979. $.fn.dataTableSettings = DataTable.settings;
  12980. $.fn.dataTableExt = DataTable.ext;
  12981. // With a capital `D` we return a DataTables API instance rather than a
  12982. // jQuery object
  12983. $.fn.DataTable = function ( opts ) {
  12984. return $(this).dataTable( opts ).api();
  12985. };
  12986. // All properties that are available to $.fn.dataTable should also be
  12987. // available on $.fn.DataTable
  12988. $.each( DataTable, function ( prop, val ) {
  12989. $.fn.DataTable[ prop ] = val;
  12990. } );
  12991. // Information about events fired by DataTables - for documentation.
  12992. /**
  12993. * Draw event, fired whenever the table is redrawn on the page, at the same
  12994. * point as fnDrawCallback. This may be useful for binding events or
  12995. * performing calculations when the table is altered at all.
  12996. * @name DataTable#draw.dt
  12997. * @event
  12998. * @param {event} e jQuery event object
  12999. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13000. */
  13001. /**
  13002. * Search event, fired when the searching applied to the table (using the
  13003. * built-in global search, or column filters) is altered.
  13004. * @name DataTable#search.dt
  13005. * @event
  13006. * @param {event} e jQuery event object
  13007. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13008. */
  13009. /**
  13010. * Page change event, fired when the paging of the table is altered.
  13011. * @name DataTable#page.dt
  13012. * @event
  13013. * @param {event} e jQuery event object
  13014. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13015. */
  13016. /**
  13017. * Order event, fired when the ordering applied to the table is altered.
  13018. * @name DataTable#order.dt
  13019. * @event
  13020. * @param {event} e jQuery event object
  13021. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13022. */
  13023. /**
  13024. * DataTables initialisation complete event, fired when the table is fully
  13025. * drawn, including Ajax data loaded, if Ajax data is required.
  13026. * @name DataTable#init.dt
  13027. * @event
  13028. * @param {event} e jQuery event object
  13029. * @param {object} oSettings DataTables settings object
  13030. * @param {object} json The JSON object request from the server - only
  13031. * present if client-side Ajax sourced data is used</li></ol>
  13032. */
  13033. /**
  13034. * State save event, fired when the table has changed state a new state save
  13035. * is required. This event allows modification of the state saving object
  13036. * prior to actually doing the save, including addition or other state
  13037. * properties (for plug-ins) or modification of a DataTables core property.
  13038. * @name DataTable#stateSaveParams.dt
  13039. * @event
  13040. * @param {event} e jQuery event object
  13041. * @param {object} oSettings DataTables settings object
  13042. * @param {object} json The state information to be saved
  13043. */
  13044. /**
  13045. * State load event, fired when the table is loading state from the stored
  13046. * data, but prior to the settings object being modified by the saved state
  13047. * - allowing modification of the saved state is required or loading of
  13048. * state for a plug-in.
  13049. * @name DataTable#stateLoadParams.dt
  13050. * @event
  13051. * @param {event} e jQuery event object
  13052. * @param {object} oSettings DataTables settings object
  13053. * @param {object} json The saved state information
  13054. */
  13055. /**
  13056. * State loaded event, fired when state has been loaded from stored data and
  13057. * the settings object has been modified by the loaded data.
  13058. * @name DataTable#stateLoaded.dt
  13059. * @event
  13060. * @param {event} e jQuery event object
  13061. * @param {object} oSettings DataTables settings object
  13062. * @param {object} json The saved state information
  13063. */
  13064. /**
  13065. * Processing event, fired when DataTables is doing some kind of processing
  13066. * (be it, order, searcg or anything else). It can be used to indicate to
  13067. * the end user that there is something happening, or that something has
  13068. * finished.
  13069. * @name DataTable#processing.dt
  13070. * @event
  13071. * @param {event} e jQuery event object
  13072. * @param {object} oSettings DataTables settings object
  13073. * @param {boolean} bShow Flag for if DataTables is doing processing or not
  13074. */
  13075. /**
  13076. * Ajax (XHR) event, fired whenever an Ajax request is completed from a
  13077. * request to made to the server for new data. This event is called before
  13078. * DataTables processed the returned data, so it can also be used to pre-
  13079. * process the data returned from the server, if needed.
  13080. *
  13081. * Note that this trigger is called in `fnServerData`, if you override
  13082. * `fnServerData` and which to use this event, you need to trigger it in you
  13083. * success function.
  13084. * @name DataTable#xhr.dt
  13085. * @event
  13086. * @param {event} e jQuery event object
  13087. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13088. * @param {object} json JSON returned from the server
  13089. *
  13090. * @example
  13091. * // Use a custom property returned from the server in another DOM element
  13092. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  13093. * $('#status').html( json.status );
  13094. * } );
  13095. *
  13096. * @example
  13097. * // Pre-process the data returned from the server
  13098. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  13099. * for ( var i=0, ien=json.aaData.length ; i<ien ; i++ ) {
  13100. * json.aaData[i].sum = json.aaData[i].one + json.aaData[i].two;
  13101. * }
  13102. * // Note no return - manipulate the data directly in the JSON object.
  13103. * } );
  13104. */
  13105. /**
  13106. * Destroy event, fired when the DataTable is destroyed by calling fnDestroy
  13107. * or passing the bDestroy:true parameter in the initialisation object. This
  13108. * can be used to remove bound events, added DOM nodes, etc.
  13109. * @name DataTable#destroy.dt
  13110. * @event
  13111. * @param {event} e jQuery event object
  13112. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13113. */
  13114. /**
  13115. * Page length change event, fired when number of records to show on each
  13116. * page (the length) is changed.
  13117. * @name DataTable#length.dt
  13118. * @event
  13119. * @param {event} e jQuery event object
  13120. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13121. * @param {integer} len New length
  13122. */
  13123. /**
  13124. * Column sizing has changed.
  13125. * @name DataTable#column-sizing.dt
  13126. * @event
  13127. * @param {event} e jQuery event object
  13128. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13129. */
  13130. /**
  13131. * Column visibility has changed.
  13132. * @name DataTable#column-visibility.dt
  13133. * @event
  13134. * @param {event} e jQuery event object
  13135. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13136. * @param {int} column Column index
  13137. * @param {bool} vis `false` if column now hidden, or `true` if visible
  13138. */
  13139. return $.fn.dataTable;
  13140. }));
  13141. }(window, document));