jquery.datatables.js 598 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482
  1. /*! DataTables 1.10.12
  2. * ©2008-2015 SpryMedia Ltd - datatables.net/license
  3. */
  4. /**
  5. * @summary DataTables
  6. * @description Paginate, search and order HTML tables
  7. * @version 1.10.12
  8. * @file jquery.dataTables.js
  9. * @author SpryMedia Ltd (www.sprymedia.co.uk)
  10. * @contact www.sprymedia.co.uk/contact
  11. * @copyright Copyright 2008-2015 SpryMedia Ltd.
  12. *
  13. * This source file is free software, available under the following license:
  14. * MIT license - http://datatables.net/license
  15. *
  16. * This source file is distributed in the hope that it will be useful, but
  17. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  18. * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
  19. *
  20. * For details please refer to: http://www.datatables.net
  21. */
  22. /*jslint evil: true, undef: true, browser: true */
  23. /*globals $,require,jQuery,define,_selector_run,_selector_opts,_selector_first,_selector_row_indexes,_ext,_Api,_api_register,_api_registerPlural,_re_new_lines,_re_html,_re_formatted_numeric,_re_escape_regex,_empty,_intVal,_numToDecimal,_isNumber,_isHtml,_htmlNumeric,_pluck,_pluck_order,_range,_stripHtml,_unique,_fnBuildAjax,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnAjaxDataSrc,_fnAddColumn,_fnColumnOptions,_fnAdjustColumnSizing,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnVisbleColumns,_fnGetColumns,_fnColumnTypes,_fnApplyColumnDefs,_fnHungarianMap,_fnCamelToHungarian,_fnLanguageCompat,_fnBrowserDetect,_fnAddData,_fnAddTr,_fnNodeToDataIndex,_fnNodeToColumnIndex,_fnGetCellData,_fnSetCellData,_fnSplitObjNotation,_fnGetObjectDataFn,_fnSetObjectDataFn,_fnGetDataMaster,_fnClearTable,_fnDeleteIndex,_fnInvalidate,_fnGetRowElements,_fnCreateTr,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAddOptionsHtml,_fnDetectHeader,_fnGetUniqueThs,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnFilterCreateSearch,_fnEscapeRegex,_fnFilterData,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnInfoMacros,_fnInitialise,_fnInitComplete,_fnLengthChange,_fnFeatureHtmlLength,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnFeatureHtmlTable,_fnScrollDraw,_fnApplyToChildren,_fnCalculateColumnWidths,_fnThrottle,_fnConvertToWidth,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnSortFlatten,_fnSort,_fnSortAria,_fnSortListener,_fnSortAttachListener,_fnSortingClasses,_fnSortData,_fnSaveState,_fnLoadState,_fnSettingsFromNode,_fnLog,_fnMap,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnLengthOverflow,_fnRenderer,_fnDataSource,_fnRowAttributes*/
  24. (function(factory) {
  25. "use strict";
  26. if (typeof define === 'function' && define.amd) {
  27. // AMD
  28. define(['jquery'], function($) {
  29. return factory($, window, document);
  30. });
  31. } else if (typeof exports === 'object') {
  32. // CommonJS
  33. module.exports = function(root, $) {
  34. if (!root) {
  35. // CommonJS environments without a window global must pass a
  36. // root. This will give an error otherwise
  37. root = window;
  38. }
  39. if (!$) {
  40. $ = typeof window !== 'undefined' ? // jQuery's factory checks for a global window
  41. require('jquery') :
  42. require('jquery')(root);
  43. }
  44. return factory($, root, root.document);
  45. };
  46. } else {
  47. // Browser
  48. factory(jQuery, window, document);
  49. }
  50. }
  51. (function($, window, document, undefined) {
  52. "use strict";
  53. /**
  54. * DataTables is a plug-in for the jQuery Javascript library. It is a highly
  55. * flexible tool, based upon the foundations of progressive enhancement,
  56. * which will add advanced interaction controls to any HTML table. For a
  57. * full list of features please refer to
  58. * [DataTables.net](href="http://datatables.net).
  59. *
  60. * Note that the `DataTable` object is not a global variable but is aliased
  61. * to `jQuery.fn.DataTable` and `jQuery.fn.dataTable` through which it may
  62. * be accessed.
  63. *
  64. * @class
  65. * @param {object} [init={}] Configuration object for DataTables. Options
  66. * are defined by {@link DataTable.defaults}
  67. * @requires jQuery 1.7+
  68. *
  69. * @example
  70. * // Basic initialisation
  71. * $(document).ready( function {
  72. * $('#example').dataTable();
  73. * } );
  74. *
  75. * @example
  76. * // Initialisation with configuration options - in this case, disable
  77. * // pagination and sorting.
  78. * $(document).ready( function {
  79. * $('#example').dataTable( {
  80. * "paginate": false,
  81. * "sort": false
  82. * } );
  83. * } );
  84. */
  85. var DataTable = function(options) {
  86. /**
  87. * Perform a jQuery selector action on the table's TR elements (from the tbody) and
  88. * return the resulting jQuery object.
  89. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  90. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  91. * @param {string} [oOpts.filter=none] Select TR elements that meet the current filter
  92. * criterion ("applied") or all TR elements (i.e. no filter).
  93. * @param {string} [oOpts.order=current] Order of the TR elements in the processed array.
  94. * Can be either 'current', whereby the current sorting of the table is used, or
  95. * 'original' whereby the original order the data was read into the table is used.
  96. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  97. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  98. * 'current' and filter is 'applied', regardless of what they might be given as.
  99. * @returns {object} jQuery object, filtered by the given selector.
  100. * @dtopt API
  101. * @deprecated Since v1.10
  102. *
  103. * @example
  104. * $(document).ready(function() {
  105. * var oTable = $('#example').dataTable();
  106. *
  107. * // Highlight every second row
  108. * oTable.$('tr:odd').css('backgroundColor', 'blue');
  109. * } );
  110. *
  111. * @example
  112. * $(document).ready(function() {
  113. * var oTable = $('#example').dataTable();
  114. *
  115. * // Filter to rows with 'Webkit' in them, add a background colour and then
  116. * // remove the filter, thus highlighting the 'Webkit' rows only.
  117. * oTable.fnFilter('Webkit');
  118. * oTable.$('tr', {"search": "applied"}).css('backgroundColor', 'blue');
  119. * oTable.fnFilter('');
  120. * } );
  121. */
  122. this.$ = function(sSelector, oOpts) {
  123. return this.api(true).$(sSelector, oOpts);
  124. };
  125. /**
  126. * Almost identical to $ in operation, but in this case returns the data for the matched
  127. * rows - as such, the jQuery selector used should match TR row nodes or TD/TH cell nodes
  128. * rather than any descendants, so the data can be obtained for the row/cell. If matching
  129. * rows are found, the data returned is the original data array/object that was used to
  130. * create the row (or a generated array if from a DOM source).
  131. *
  132. * This method is often useful in-combination with $ where both functions are given the
  133. * same parameters and the array indexes will match identically.
  134. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  135. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  136. * @param {string} [oOpts.filter=none] Select elements that meet the current filter
  137. * criterion ("applied") or all elements (i.e. no filter).
  138. * @param {string} [oOpts.order=current] Order of the data in the processed array.
  139. * Can be either 'current', whereby the current sorting of the table is used, or
  140. * 'original' whereby the original order the data was read into the table is used.
  141. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  142. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  143. * 'current' and filter is 'applied', regardless of what they might be given as.
  144. * @returns {array} Data for the matched elements. If any elements, as a result of the
  145. * selector, were not TR, TD or TH elements in the DataTable, they will have a null
  146. * entry in the array.
  147. * @dtopt API
  148. * @deprecated Since v1.10
  149. *
  150. * @example
  151. * $(document).ready(function() {
  152. * var oTable = $('#example').dataTable();
  153. *
  154. * // Get the data from the first row in the table
  155. * var data = oTable._('tr:first');
  156. *
  157. * // Do something useful with the data
  158. * alert( "First cell is: "+data[0] );
  159. * } );
  160. *
  161. * @example
  162. * $(document).ready(function() {
  163. * var oTable = $('#example').dataTable();
  164. *
  165. * // Filter to 'Webkit' and get all data for
  166. * oTable.fnFilter('Webkit');
  167. * var data = oTable._('tr', {"search": "applied"});
  168. *
  169. * // Do something with the data
  170. * alert( data.length+" rows matched the search" );
  171. * } );
  172. */
  173. this._ = function(sSelector, oOpts) {
  174. return this.api(true).rows(sSelector, oOpts).data();
  175. };
  176. /**
  177. * Create a DataTables Api instance, with the currently selected tables for
  178. * the Api's context.
  179. * @param {boolean} [traditional=false] Set the API instance's context to be
  180. * only the table referred to by the `DataTable.ext.iApiIndex` option, as was
  181. * used in the API presented by DataTables 1.9- (i.e. the traditional mode),
  182. * or if all tables captured in the jQuery object should be used.
  183. * @return {DataTables.Api}
  184. */
  185. this.api = function(traditional) {
  186. return traditional ?
  187. new _Api(
  188. _fnSettingsFromNode(this[_ext.iApiIndex])
  189. ) :
  190. new _Api(this);
  191. };
  192. /**
  193. * Add a single new row or multiple rows of data to the table. Please note
  194. * that this is suitable for client-side processing only - if you are using
  195. * server-side processing (i.e. "bServerSide": true), then to add data, you
  196. * must add it to the data source, i.e. the server-side, through an Ajax call.
  197. * @param {array|object} data The data to be added to the table. This can be:
  198. * <ul>
  199. * <li>1D array of data - add a single row with the data provided</li>
  200. * <li>2D array of arrays - add multiple rows in a single call</li>
  201. * <li>object - data object when using <i>mData</i></li>
  202. * <li>array of objects - multiple data objects when using <i>mData</i></li>
  203. * </ul>
  204. * @param {bool} [redraw=true] redraw the table or not
  205. * @returns {array} An array of integers, representing the list of indexes in
  206. * <i>aoData</i> ({@link DataTable.models.oSettings}) that have been added to
  207. * the table.
  208. * @dtopt API
  209. * @deprecated Since v1.10
  210. *
  211. * @example
  212. * // Global var for counter
  213. * var giCount = 2;
  214. *
  215. * $(document).ready(function() {
  216. * $('#example').dataTable();
  217. * } );
  218. *
  219. * function fnClickAddRow() {
  220. * $('#example').dataTable().fnAddData( [
  221. * giCount+".1",
  222. * giCount+".2",
  223. * giCount+".3",
  224. * giCount+".4" ]
  225. * );
  226. *
  227. * giCount++;
  228. * }
  229. */
  230. this.fnAddData = function(data, redraw) {
  231. var api = this.api(true);
  232. /* Check if we want to add multiple rows or not */
  233. var rows = $.isArray(data) && ($.isArray(data[0]) || $.isPlainObject(data[0])) ?
  234. api.rows.add(data) :
  235. api.row.add(data);
  236. if (redraw === undefined || redraw) {
  237. api.draw();
  238. }
  239. return rows.flatten().toArray();
  240. };
  241. /**
  242. * This function will make DataTables recalculate the column sizes, based on the data
  243. * contained in the table and the sizes applied to the columns (in the DOM, CSS or
  244. * through the sWidth parameter). This can be useful when the width of the table's
  245. * parent element changes (for example a window resize).
  246. * @param {boolean} [bRedraw=true] Redraw the table or not, you will typically want to
  247. * @dtopt API
  248. * @deprecated Since v1.10
  249. *
  250. * @example
  251. * $(document).ready(function() {
  252. * var oTable = $('#example').dataTable( {
  253. * "sScrollY": "200px",
  254. * "bPaginate": false
  255. * } );
  256. *
  257. * $(window).bind('resize', function () {
  258. * oTable.fnAdjustColumnSizing();
  259. * } );
  260. * } );
  261. */
  262. this.fnAdjustColumnSizing = function(bRedraw) {
  263. var api = this.api(true).columns.adjust();
  264. var settings = api.settings()[0];
  265. var scroll = settings.oScroll;
  266. if (bRedraw === undefined || bRedraw) {
  267. api.draw(false);
  268. } else if (scroll.sX !== "" || scroll.sY !== "") {
  269. /* If not redrawing, but scrolling, we want to apply the new column sizes anyway */
  270. _fnScrollDraw(settings);
  271. }
  272. };
  273. /**
  274. * Quickly and simply clear a table
  275. * @param {bool} [bRedraw=true] redraw the table or not
  276. * @dtopt API
  277. * @deprecated Since v1.10
  278. *
  279. * @example
  280. * $(document).ready(function() {
  281. * var oTable = $('#example').dataTable();
  282. *
  283. * // Immediately 'nuke' the current rows (perhaps waiting for an Ajax callback...)
  284. * oTable.fnClearTable();
  285. * } );
  286. */
  287. this.fnClearTable = function(bRedraw) {
  288. var api = this.api(true).clear();
  289. if (bRedraw === undefined || bRedraw) {
  290. api.draw();
  291. }
  292. };
  293. /**
  294. * The exact opposite of 'opening' a row, this function will close any rows which
  295. * are currently 'open'.
  296. * @param {node} nTr the table row to 'close'
  297. * @returns {int} 0 on success, or 1 if failed (can't find the row)
  298. * @dtopt API
  299. * @deprecated Since v1.10
  300. *
  301. * @example
  302. * $(document).ready(function() {
  303. * var oTable;
  304. *
  305. * // 'open' an information row when a row is clicked on
  306. * $('#example tbody tr').click( function () {
  307. * if ( oTable.fnIsOpen(this) ) {
  308. * oTable.fnClose( this );
  309. * } else {
  310. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  311. * }
  312. * } );
  313. *
  314. * oTable = $('#example').dataTable();
  315. * } );
  316. */
  317. this.fnClose = function(nTr) {
  318. this.api(true).row(nTr).child.hide();
  319. };
  320. /**
  321. * Remove a row for the table
  322. * @param {mixed} target The index of the row from aoData to be deleted, or
  323. * the TR element you want to delete
  324. * @param {function|null} [callBack] Callback function
  325. * @param {bool} [redraw=true] Redraw the table or not
  326. * @returns {array} The row that was deleted
  327. * @dtopt API
  328. * @deprecated Since v1.10
  329. *
  330. * @example
  331. * $(document).ready(function() {
  332. * var oTable = $('#example').dataTable();
  333. *
  334. * // Immediately remove the first row
  335. * oTable.fnDeleteRow( 0 );
  336. * } );
  337. */
  338. this.fnDeleteRow = function(target, callback, redraw) {
  339. var api = this.api(true);
  340. var rows = api.rows(target);
  341. var settings = rows.settings()[0];
  342. var data = settings.aoData[rows[0][0]];
  343. rows.remove();
  344. if (callback) {
  345. callback.call(this, settings, data);
  346. }
  347. if (redraw === undefined || redraw) {
  348. api.draw();
  349. }
  350. return data;
  351. };
  352. /**
  353. * Restore the table to it's original state in the DOM by removing all of DataTables
  354. * enhancements, alterations to the DOM structure of the table and event listeners.
  355. * @param {boolean} [remove=false] Completely remove the table from the DOM
  356. * @dtopt API
  357. * @deprecated Since v1.10
  358. *
  359. * @example
  360. * $(document).ready(function() {
  361. * // This example is fairly pointless in reality, but shows how fnDestroy can be used
  362. * var oTable = $('#example').dataTable();
  363. * oTable.fnDestroy();
  364. * } );
  365. */
  366. this.fnDestroy = function(remove) {
  367. this.api(true).destroy(remove);
  368. };
  369. /**
  370. * Redraw the table
  371. * @param {bool} [complete=true] Re-filter and resort (if enabled) the table before the draw.
  372. * @dtopt API
  373. * @deprecated Since v1.10
  374. *
  375. * @example
  376. * $(document).ready(function() {
  377. * var oTable = $('#example').dataTable();
  378. *
  379. * // Re-draw the table - you wouldn't want to do it here, but it's an example :-)
  380. * oTable.fnDraw();
  381. * } );
  382. */
  383. this.fnDraw = function(complete) {
  384. // Note that this isn't an exact match to the old call to _fnDraw - it takes
  385. // into account the new data, but can hold position.
  386. this.api(true).draw(complete);
  387. };
  388. /**
  389. * Filter the input based on data
  390. * @param {string} sInput String to filter the table on
  391. * @param {int|null} [iColumn] Column to limit filtering to
  392. * @param {bool} [bRegex=false] Treat as regular expression or not
  393. * @param {bool} [bSmart=true] Perform smart filtering or not
  394. * @param {bool} [bShowGlobal=true] Show the input global filter in it's input box(es)
  395. * @param {bool} [bCaseInsensitive=true] Do case-insensitive matching (true) or not (false)
  396. * @dtopt API
  397. * @deprecated Since v1.10
  398. *
  399. * @example
  400. * $(document).ready(function() {
  401. * var oTable = $('#example').dataTable();
  402. *
  403. * // Sometime later - filter...
  404. * oTable.fnFilter( 'test string' );
  405. * } );
  406. */
  407. this.fnFilter = function(sInput, iColumn, bRegex, bSmart, bShowGlobal, bCaseInsensitive) {
  408. var api = this.api(true);
  409. if (iColumn === null || iColumn === undefined) {
  410. api.search(sInput, bRegex, bSmart, bCaseInsensitive);
  411. } else {
  412. api.column(iColumn).search(sInput, bRegex, bSmart, bCaseInsensitive);
  413. }
  414. api.draw();
  415. };
  416. /**
  417. * Get the data for the whole table, an individual row or an individual cell based on the
  418. * provided parameters.
  419. * @param {int|node} [src] A TR row node, TD/TH cell node or an integer. If given as
  420. * a TR node then the data source for the whole row will be returned. If given as a
  421. * TD/TH cell node then iCol will be automatically calculated and the data for the
  422. * cell returned. If given as an integer, then this is treated as the aoData internal
  423. * data index for the row (see fnGetPosition) and the data for that row used.
  424. * @param {int} [col] Optional column index that you want the data of.
  425. * @returns {array|object|string} If mRow is undefined, then the data for all rows is
  426. * returned. If mRow is defined, just data for that row, and is iCol is
  427. * defined, only data for the designated cell is returned.
  428. * @dtopt API
  429. * @deprecated Since v1.10
  430. *
  431. * @example
  432. * // Row data
  433. * $(document).ready(function() {
  434. * oTable = $('#example').dataTable();
  435. *
  436. * oTable.$('tr').click( function () {
  437. * var data = oTable.fnGetData( this );
  438. * // ... do something with the array / object of data for the row
  439. * } );
  440. * } );
  441. *
  442. * @example
  443. * // Individual cell data
  444. * $(document).ready(function() {
  445. * oTable = $('#example').dataTable();
  446. *
  447. * oTable.$('td').click( function () {
  448. * var sData = oTable.fnGetData( this );
  449. * alert( 'The cell clicked on had the value of '+sData );
  450. * } );
  451. * } );
  452. */
  453. this.fnGetData = function(src, col) {
  454. var api = this.api(true);
  455. if (src !== undefined) {
  456. var type = src.nodeName ? src.nodeName.toLowerCase() : '';
  457. return col !== undefined || type == 'td' || type == 'th' ?
  458. api.cell(src, col).data() :
  459. api.row(src).data() || null;
  460. }
  461. return api.data().toArray();
  462. };
  463. /**
  464. * Get an array of the TR nodes that are used in the table's body. Note that you will
  465. * typically want to use the '$' API method in preference to this as it is more
  466. * flexible.
  467. * @param {int} [iRow] Optional row index for the TR element you want
  468. * @returns {array|node} If iRow is undefined, returns an array of all TR elements
  469. * in the table's body, or iRow is defined, just the TR element requested.
  470. * @dtopt API
  471. * @deprecated Since v1.10
  472. *
  473. * @example
  474. * $(document).ready(function() {
  475. * var oTable = $('#example').dataTable();
  476. *
  477. * // Get the nodes from the table
  478. * var nNodes = oTable.fnGetNodes( );
  479. * } );
  480. */
  481. this.fnGetNodes = function(iRow) {
  482. var api = this.api(true);
  483. return iRow !== undefined ?
  484. api.row(iRow).node() :
  485. api.rows().nodes().flatten().toArray();
  486. };
  487. /**
  488. * Get the array indexes of a particular cell from it's DOM element
  489. * and column index including hidden columns
  490. * @param {node} node this can either be a TR, TD or TH in the table's body
  491. * @returns {int} If nNode is given as a TR, then a single index is returned, or
  492. * if given as a cell, an array of [row index, column index (visible),
  493. * column index (all)] is given.
  494. * @dtopt API
  495. * @deprecated Since v1.10
  496. *
  497. * @example
  498. * $(document).ready(function() {
  499. * $('#example tbody td').click( function () {
  500. * // Get the position of the current data from the node
  501. * var aPos = oTable.fnGetPosition( this );
  502. *
  503. * // Get the data array for this row
  504. * var aData = oTable.fnGetData( aPos[0] );
  505. *
  506. * // Update the data array and return the value
  507. * aData[ aPos[1] ] = 'clicked';
  508. * this.innerHTML = 'clicked';
  509. * } );
  510. *
  511. * // Init DataTables
  512. * oTable = $('#example').dataTable();
  513. * } );
  514. */
  515. this.fnGetPosition = function(node) {
  516. var api = this.api(true);
  517. var nodeName = node.nodeName.toUpperCase();
  518. if (nodeName == 'TR') {
  519. return api.row(node).index();
  520. } else if (nodeName == 'TD' || nodeName == 'TH') {
  521. var cell = api.cell(node).index();
  522. return [
  523. cell.row,
  524. cell.columnVisible,
  525. cell.column
  526. ];
  527. }
  528. return null;
  529. };
  530. /**
  531. * Check to see if a row is 'open' or not.
  532. * @param {node} nTr the table row to check
  533. * @returns {boolean} true if the row is currently open, false otherwise
  534. * @dtopt API
  535. * @deprecated Since v1.10
  536. *
  537. * @example
  538. * $(document).ready(function() {
  539. * var oTable;
  540. *
  541. * // 'open' an information row when a row is clicked on
  542. * $('#example tbody tr').click( function () {
  543. * if ( oTable.fnIsOpen(this) ) {
  544. * oTable.fnClose( this );
  545. * } else {
  546. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  547. * }
  548. * } );
  549. *
  550. * oTable = $('#example').dataTable();
  551. * } );
  552. */
  553. this.fnIsOpen = function(nTr) {
  554. return this.api(true).row(nTr).child.isShown();
  555. };
  556. /**
  557. * This function will place a new row directly after a row which is currently
  558. * on display on the page, with the HTML contents that is passed into the
  559. * function. This can be used, for example, to ask for confirmation that a
  560. * particular record should be deleted.
  561. * @param {node} nTr The table row to 'open'
  562. * @param {string|node|jQuery} mHtml The HTML to put into the row
  563. * @param {string} sClass Class to give the new TD cell
  564. * @returns {node} The row opened. Note that if the table row passed in as the
  565. * first parameter, is not found in the table, this method will silently
  566. * return.
  567. * @dtopt API
  568. * @deprecated Since v1.10
  569. *
  570. * @example
  571. * $(document).ready(function() {
  572. * var oTable;
  573. *
  574. * // 'open' an information row when a row is clicked on
  575. * $('#example tbody tr').click( function () {
  576. * if ( oTable.fnIsOpen(this) ) {
  577. * oTable.fnClose( this );
  578. * } else {
  579. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  580. * }
  581. * } );
  582. *
  583. * oTable = $('#example').dataTable();
  584. * } );
  585. */
  586. this.fnOpen = function(nTr, mHtml, sClass) {
  587. return this.api(true)
  588. .row(nTr)
  589. .child(mHtml, sClass)
  590. .show()
  591. .child()[0];
  592. };
  593. /**
  594. * Change the pagination - provides the internal logic for pagination in a simple API
  595. * function. With this function you can have a DataTables table go to the next,
  596. * previous, first or last pages.
  597. * @param {string|int} mAction Paging action to take: "first", "previous", "next" or "last"
  598. * or page number to jump to (integer), note that page 0 is the first page.
  599. * @param {bool} [bRedraw=true] Redraw the table or not
  600. * @dtopt API
  601. * @deprecated Since v1.10
  602. *
  603. * @example
  604. * $(document).ready(function() {
  605. * var oTable = $('#example').dataTable();
  606. * oTable.fnPageChange( 'next' );
  607. * } );
  608. */
  609. this.fnPageChange = function(mAction, bRedraw) {
  610. var api = this.api(true).page(mAction);
  611. if (bRedraw === undefined || bRedraw) {
  612. api.draw(false);
  613. }
  614. };
  615. /**
  616. * Show a particular column
  617. * @param {int} iCol The column whose display should be changed
  618. * @param {bool} bShow Show (true) or hide (false) the column
  619. * @param {bool} [bRedraw=true] Redraw the table or not
  620. * @dtopt API
  621. * @deprecated Since v1.10
  622. *
  623. * @example
  624. * $(document).ready(function() {
  625. * var oTable = $('#example').dataTable();
  626. *
  627. * // Hide the second column after initialisation
  628. * oTable.fnSetColumnVis( 1, false );
  629. * } );
  630. */
  631. this.fnSetColumnVis = function(iCol, bShow, bRedraw) {
  632. var api = this.api(true).column(iCol).visible(bShow);
  633. if (bRedraw === undefined || bRedraw) {
  634. api.columns.adjust().draw();
  635. }
  636. };
  637. /**
  638. * Get the settings for a particular table for external manipulation
  639. * @returns {object} DataTables settings object. See
  640. * {@link DataTable.models.oSettings}
  641. * @dtopt API
  642. * @deprecated Since v1.10
  643. *
  644. * @example
  645. * $(document).ready(function() {
  646. * var oTable = $('#example').dataTable();
  647. * var oSettings = oTable.fnSettings();
  648. *
  649. * // Show an example parameter from the settings
  650. * alert( oSettings._iDisplayStart );
  651. * } );
  652. */
  653. this.fnSettings = function() {
  654. return _fnSettingsFromNode(this[_ext.iApiIndex]);
  655. };
  656. /**
  657. * Sort the table by a particular column
  658. * @param {int} iCol the data index to sort on. Note that this will not match the
  659. * 'display index' if you have hidden data entries
  660. * @dtopt API
  661. * @deprecated Since v1.10
  662. *
  663. * @example
  664. * $(document).ready(function() {
  665. * var oTable = $('#example').dataTable();
  666. *
  667. * // Sort immediately with columns 0 and 1
  668. * oTable.fnSort( [ [0,'asc'], [1,'asc'] ] );
  669. * } );
  670. */
  671. this.fnSort = function(aaSort) {
  672. this.api(true).order(aaSort).draw();
  673. };
  674. /**
  675. * Attach a sort listener to an element for a given column
  676. * @param {node} nNode the element to attach the sort listener to
  677. * @param {int} iColumn the column that a click on this node will sort on
  678. * @param {function} [fnCallback] callback function when sort is run
  679. * @dtopt API
  680. * @deprecated Since v1.10
  681. *
  682. * @example
  683. * $(document).ready(function() {
  684. * var oTable = $('#example').dataTable();
  685. *
  686. * // Sort on column 1, when 'sorter' is clicked on
  687. * oTable.fnSortListener( document.getElementById('sorter'), 1 );
  688. * } );
  689. */
  690. this.fnSortListener = function(nNode, iColumn, fnCallback) {
  691. this.api(true).order.listener(nNode, iColumn, fnCallback);
  692. };
  693. /**
  694. * Update a table cell or row - this method will accept either a single value to
  695. * update the cell with, an array of values with one element for each column or
  696. * an object in the same format as the original data source. The function is
  697. * self-referencing in order to make the multi column updates easier.
  698. * @param {object|array|string} mData Data to update the cell/row with
  699. * @param {node|int} mRow TR element you want to update or the aoData index
  700. * @param {int} [iColumn] The column to update, give as null or undefined to
  701. * update a whole row.
  702. * @param {bool} [bRedraw=true] Redraw the table or not
  703. * @param {bool} [bAction=true] Perform pre-draw actions or not
  704. * @returns {int} 0 on success, 1 on error
  705. * @dtopt API
  706. * @deprecated Since v1.10
  707. *
  708. * @example
  709. * $(document).ready(function() {
  710. * var oTable = $('#example').dataTable();
  711. * oTable.fnUpdate( 'Example update', 0, 0 ); // Single cell
  712. * oTable.fnUpdate( ['a', 'b', 'c', 'd', 'e'], $('tbody tr')[0] ); // Row
  713. * } );
  714. */
  715. this.fnUpdate = function(mData, mRow, iColumn, bRedraw, bAction) {
  716. var api = this.api(true);
  717. if (iColumn === undefined || iColumn === null) {
  718. api.row(mRow).data(mData);
  719. } else {
  720. api.cell(mRow, iColumn).data(mData);
  721. }
  722. if (bAction === undefined || bAction) {
  723. api.columns.adjust();
  724. }
  725. if (bRedraw === undefined || bRedraw) {
  726. api.draw();
  727. }
  728. return 0;
  729. };
  730. /**
  731. * Provide a common method for plug-ins to check the version of DataTables being used, in order
  732. * to ensure compatibility.
  733. * @param {string} sVersion Version string to check for, in the format "X.Y.Z". Note that the
  734. * formats "X" and "X.Y" are also acceptable.
  735. * @returns {boolean} true if this version of DataTables is greater or equal to the required
  736. * version, or false if this version of DataTales is not suitable
  737. * @method
  738. * @dtopt API
  739. * @deprecated Since v1.10
  740. *
  741. * @example
  742. * $(document).ready(function() {
  743. * var oTable = $('#example').dataTable();
  744. * alert( oTable.fnVersionCheck( '1.9.0' ) );
  745. * } );
  746. */
  747. this.fnVersionCheck = _ext.fnVersionCheck;
  748. var _that = this;
  749. var emptyInit = options === undefined;
  750. var len = this.length;
  751. if (emptyInit) {
  752. options = {};
  753. }
  754. this.oApi = this.internal = _ext.internal;
  755. // Extend with old style plug-in API methods
  756. for (var fn in DataTable.ext.internal) {
  757. if (fn) {
  758. this[fn] = _fnExternApiFunc(fn);
  759. }
  760. }
  761. this.each(function() {
  762. // For each initialisation we want to give it a clean initialisation
  763. // object that can be bashed around
  764. var o = {};
  765. var oInit = len > 1 ? // optimisation for single table case
  766. _fnExtend(o, options, true) :
  767. options;
  768. /*global oInit,_that,emptyInit*/
  769. var i = 0,
  770. iLen, j, jLen, k, kLen;
  771. var sId = this.getAttribute('id');
  772. var bInitHandedOff = false;
  773. var defaults = DataTable.defaults;
  774. var $this = $(this);
  775. /* Sanity check */
  776. if (this.nodeName.toLowerCase() != 'table') {
  777. _fnLog(null, 0, 'Non-table node initialisation (' + this.nodeName + ')', 2);
  778. return;
  779. }
  780. /* Backwards compatibility for the defaults */
  781. _fnCompatOpts(defaults);
  782. _fnCompatCols(defaults.column);
  783. /* Convert the camel-case defaults to Hungarian */
  784. _fnCamelToHungarian(defaults, defaults, true);
  785. _fnCamelToHungarian(defaults.column, defaults.column, true);
  786. /* Setting up the initialisation object */
  787. _fnCamelToHungarian(defaults, $.extend(oInit, $this.data()));
  788. /* Check to see if we are re-initialising a table */
  789. var allSettings = DataTable.settings;
  790. for (i = 0, iLen = allSettings.length; i < iLen; i++) {
  791. var s = allSettings[i];
  792. /* Base check on table node */
  793. if (s.nTable == this || s.nTHead.parentNode == this || (s.nTFoot && s.nTFoot.parentNode == this)) {
  794. var bRetrieve = oInit.bRetrieve !== undefined ? oInit.bRetrieve : defaults.bRetrieve;
  795. var bDestroy = oInit.bDestroy !== undefined ? oInit.bDestroy : defaults.bDestroy;
  796. if (emptyInit || bRetrieve) {
  797. return s.oInstance;
  798. } else if (bDestroy) {
  799. s.oInstance.fnDestroy();
  800. break;
  801. } else {
  802. _fnLog(s, 0, 'Cannot reinitialise DataTable', 3);
  803. return;
  804. }
  805. }
  806. /* If the element we are initialising has the same ID as a table which was previously
  807. * initialised, but the table nodes don't match (from before) then we destroy the old
  808. * instance by simply deleting it. This is under the assumption that the table has been
  809. * destroyed by other methods. Anyone using non-id selectors will need to do this manually
  810. */
  811. if (s.sTableId == this.id) {
  812. allSettings.splice(i, 1);
  813. break;
  814. }
  815. }
  816. /* Ensure the table has an ID - required for accessibility */
  817. if (sId === null || sId === "") {
  818. sId = "DataTables_Table_" + (DataTable.ext._unique++);
  819. this.id = sId;
  820. }
  821. /* Create the settings object for this table and set some of the default parameters */
  822. var oSettings = $.extend(true, {}, DataTable.models.oSettings, {
  823. "sDestroyWidth": $this[0].style.width,
  824. "sInstance": sId,
  825. "sTableId": sId
  826. });
  827. oSettings.nTable = this;
  828. oSettings.oApi = _that.internal;
  829. oSettings.oInit = oInit;
  830. allSettings.push(oSettings);
  831. // Need to add the instance after the instance after the settings object has been added
  832. // to the settings array, so we can self reference the table instance if more than one
  833. oSettings.oInstance = (_that.length === 1) ? _that : $this.dataTable();
  834. // Backwards compatibility, before we apply all the defaults
  835. _fnCompatOpts(oInit);
  836. if (oInit.oLanguage) {
  837. _fnLanguageCompat(oInit.oLanguage);
  838. }
  839. // If the length menu is given, but the init display length is not, use the length menu
  840. if (oInit.aLengthMenu && !oInit.iDisplayLength) {
  841. oInit.iDisplayLength = $.isArray(oInit.aLengthMenu[0]) ?
  842. oInit.aLengthMenu[0][0] : oInit.aLengthMenu[0];
  843. }
  844. // Apply the defaults and init options to make a single init object will all
  845. // options defined from defaults and instance options.
  846. oInit = _fnExtend($.extend(true, {}, defaults), oInit);
  847. // Map the initialisation options onto the settings object
  848. _fnMap(oSettings.oFeatures, oInit, [
  849. "bPaginate",
  850. "bLengthChange",
  851. "bFilter",
  852. "bSort",
  853. "bSortMulti",
  854. "bInfo",
  855. "bProcessing",
  856. "bAutoWidth",
  857. "bSortClasses",
  858. "bServerSide",
  859. "bDeferRender"
  860. ]);
  861. _fnMap(oSettings, oInit, [
  862. "asStripeClasses",
  863. "ajax",
  864. "fnServerData",
  865. "fnFormatNumber",
  866. "sServerMethod",
  867. "aaSorting",
  868. "aaSortingFixed",
  869. "aLengthMenu",
  870. "sPaginationType",
  871. "sAjaxSource",
  872. "sAjaxDataProp",
  873. "iStateDuration",
  874. "sDom",
  875. "bSortCellsTop",
  876. "iTabIndex",
  877. "fnStateLoadCallback",
  878. "fnStateSaveCallback",
  879. "renderer",
  880. "searchDelay",
  881. "rowId", ["iCookieDuration", "iStateDuration"], // backwards compat
  882. ["oSearch", "oPreviousSearch"],
  883. ["aoSearchCols", "aoPreSearchCols"],
  884. ["iDisplayLength", "_iDisplayLength"],
  885. ["bJQueryUI", "bJUI"]
  886. ]);
  887. _fnMap(oSettings.oScroll, oInit, [
  888. ["sScrollX", "sX"],
  889. ["sScrollXInner", "sXInner"],
  890. ["sScrollY", "sY"],
  891. ["bScrollCollapse", "bCollapse"]
  892. ]);
  893. _fnMap(oSettings.oLanguage, oInit, "fnInfoCallback");
  894. /* Callback functions which are array driven */
  895. _fnCallbackReg(oSettings, 'aoDrawCallback', oInit.fnDrawCallback, 'user');
  896. _fnCallbackReg(oSettings, 'aoServerParams', oInit.fnServerParams, 'user');
  897. _fnCallbackReg(oSettings, 'aoStateSaveParams', oInit.fnStateSaveParams, 'user');
  898. _fnCallbackReg(oSettings, 'aoStateLoadParams', oInit.fnStateLoadParams, 'user');
  899. _fnCallbackReg(oSettings, 'aoStateLoaded', oInit.fnStateLoaded, 'user');
  900. _fnCallbackReg(oSettings, 'aoRowCallback', oInit.fnRowCallback, 'user');
  901. _fnCallbackReg(oSettings, 'aoRowCreatedCallback', oInit.fnCreatedRow, 'user');
  902. _fnCallbackReg(oSettings, 'aoHeaderCallback', oInit.fnHeaderCallback, 'user');
  903. _fnCallbackReg(oSettings, 'aoFooterCallback', oInit.fnFooterCallback, 'user');
  904. _fnCallbackReg(oSettings, 'aoInitComplete', oInit.fnInitComplete, 'user');
  905. _fnCallbackReg(oSettings, 'aoPreDrawCallback', oInit.fnPreDrawCallback, 'user');
  906. oSettings.rowIdFn = _fnGetObjectDataFn(oInit.rowId);
  907. /* Browser support detection */
  908. _fnBrowserDetect(oSettings);
  909. var oClasses = oSettings.oClasses;
  910. // @todo Remove in 1.11
  911. if (oInit.bJQueryUI) {
  912. /* Use the JUI classes object for display. You could clone the oStdClasses object if
  913. * you want to have multiple tables with multiple independent classes
  914. */
  915. $.extend(oClasses, DataTable.ext.oJUIClasses, oInit.oClasses);
  916. if (oInit.sDom === defaults.sDom && defaults.sDom === "lfrtip") {
  917. /* Set the DOM to use a layout suitable for jQuery UI's theming */
  918. oSettings.sDom = '<"H"lfr>t<"F"ip>';
  919. }
  920. if (!oSettings.renderer) {
  921. oSettings.renderer = 'jqueryui';
  922. } else if ($.isPlainObject(oSettings.renderer) && !oSettings.renderer.header) {
  923. oSettings.renderer.header = 'jqueryui';
  924. }
  925. } else {
  926. $.extend(oClasses, DataTable.ext.classes, oInit.oClasses);
  927. }
  928. $this.addClass(oClasses.sTable);
  929. if (oSettings.iInitDisplayStart === undefined) {
  930. /* Display start point, taking into account the save saving */
  931. oSettings.iInitDisplayStart = oInit.iDisplayStart;
  932. oSettings._iDisplayStart = oInit.iDisplayStart;
  933. }
  934. if (oInit.iDeferLoading !== null) {
  935. oSettings.bDeferLoading = true;
  936. var tmp = $.isArray(oInit.iDeferLoading);
  937. oSettings._iRecordsDisplay = tmp ? oInit.iDeferLoading[0] : oInit.iDeferLoading;
  938. oSettings._iRecordsTotal = tmp ? oInit.iDeferLoading[1] : oInit.iDeferLoading;
  939. }
  940. /* Language definitions */
  941. var oLanguage = oSettings.oLanguage;
  942. $.extend(true, oLanguage, oInit.oLanguage);
  943. if (oLanguage.sUrl !== "") {
  944. /* Get the language definitions from a file - because this Ajax call makes the language
  945. * get async to the remainder of this function we use bInitHandedOff to indicate that
  946. * _fnInitialise will be fired by the returned Ajax handler, rather than the constructor
  947. */
  948. $.ajax({
  949. dataType: 'json',
  950. url: oLanguage.sUrl,
  951. success: function(json) {
  952. _fnLanguageCompat(json);
  953. _fnCamelToHungarian(defaults.oLanguage, json);
  954. $.extend(true, oLanguage, json);
  955. _fnInitialise(oSettings);
  956. },
  957. error: function() {
  958. // Error occurred loading language file, continue on as best we can
  959. _fnInitialise(oSettings);
  960. }
  961. });
  962. bInitHandedOff = true;
  963. }
  964. /*
  965. * Stripes
  966. */
  967. if (oInit.asStripeClasses === null) {
  968. oSettings.asStripeClasses = [
  969. oClasses.sStripeOdd,
  970. oClasses.sStripeEven
  971. ];
  972. }
  973. /* Remove row stripe classes if they are already on the table row */
  974. var stripeClasses = oSettings.asStripeClasses;
  975. var rowOne = $this.children('tbody').find('tr').eq(0);
  976. if ($.inArray(true, $.map(stripeClasses, function(el, i) {
  977. return rowOne.hasClass(el);
  978. })) !== -1) {
  979. $('tbody tr', this).removeClass(stripeClasses.join(' '));
  980. oSettings.asDestroyStripes = stripeClasses.slice();
  981. }
  982. /*
  983. * Columns
  984. * See if we should load columns automatically or use defined ones
  985. */
  986. var anThs = [];
  987. var aoColumnsInit;
  988. var nThead = this.getElementsByTagName('thead');
  989. if (nThead.length !== 0) {
  990. _fnDetectHeader(oSettings.aoHeader, nThead[0]);
  991. anThs = _fnGetUniqueThs(oSettings);
  992. }
  993. /* If not given a column array, generate one with nulls */
  994. if (oInit.aoColumns === null) {
  995. aoColumnsInit = [];
  996. for (i = 0, iLen = anThs.length; i < iLen; i++) {
  997. aoColumnsInit.push(null);
  998. }
  999. } else {
  1000. aoColumnsInit = oInit.aoColumns;
  1001. }
  1002. /* Add the columns */
  1003. for (i = 0, iLen = aoColumnsInit.length; i < iLen; i++) {
  1004. _fnAddColumn(oSettings, anThs ? anThs[i] : null);
  1005. }
  1006. /* Apply the column definitions */
  1007. _fnApplyColumnDefs(oSettings, oInit.aoColumnDefs, aoColumnsInit, function(iCol, oDef) {
  1008. _fnColumnOptions(oSettings, iCol, oDef);
  1009. });
  1010. /* HTML5 attribute detection - build an mData object automatically if the
  1011. * attributes are found
  1012. */
  1013. if (rowOne.length) {
  1014. var a = function(cell, name) {
  1015. return cell.getAttribute('data-' + name) !== null ? name : null;
  1016. };
  1017. $(rowOne[0]).children('th, td').each(function(i, cell) {
  1018. var col = oSettings.aoColumns[i];
  1019. if (col.mData === i) {
  1020. var sort = a(cell, 'sort') || a(cell, 'order');
  1021. var filter = a(cell, 'filter') || a(cell, 'search');
  1022. if (sort !== null || filter !== null) {
  1023. col.mData = {
  1024. _: i + '.display',
  1025. sort: sort !== null ? i + '.@data-' + sort : undefined,
  1026. type: sort !== null ? i + '.@data-' + sort : undefined,
  1027. filter: filter !== null ? i + '.@data-' + filter : undefined
  1028. };
  1029. _fnColumnOptions(oSettings, i);
  1030. }
  1031. }
  1032. });
  1033. }
  1034. var features = oSettings.oFeatures;
  1035. /* Must be done after everything which can be overridden by the state saving! */
  1036. if (oInit.bStateSave) {
  1037. features.bStateSave = true;
  1038. _fnLoadState(oSettings, oInit);
  1039. _fnCallbackReg(oSettings, 'aoDrawCallback', _fnSaveState, 'state_save');
  1040. }
  1041. /*
  1042. * Sorting
  1043. * @todo For modularisation (1.11) this needs to do into a sort start up handler
  1044. */
  1045. // If aaSorting is not defined, then we use the first indicator in asSorting
  1046. // in case that has been altered, so the default sort reflects that option
  1047. if (oInit.aaSorting === undefined) {
  1048. var sorting = oSettings.aaSorting;
  1049. for (i = 0, iLen = sorting.length; i < iLen; i++) {
  1050. sorting[i][1] = oSettings.aoColumns[i].asSorting[0];
  1051. }
  1052. }
  1053. /* Do a first pass on the sorting classes (allows any size changes to be taken into
  1054. * account, and also will apply sorting disabled classes if disabled
  1055. */
  1056. _fnSortingClasses(oSettings);
  1057. if (features.bSort) {
  1058. _fnCallbackReg(oSettings, 'aoDrawCallback', function() {
  1059. if (oSettings.bSorted) {
  1060. var aSort = _fnSortFlatten(oSettings);
  1061. var sortedColumns = {};
  1062. $.each(aSort, function(i, val) {
  1063. sortedColumns[val.src] = val.dir;
  1064. });
  1065. _fnCallbackFire(oSettings, null, 'order', [oSettings, aSort, sortedColumns]);
  1066. _fnSortAria(oSettings);
  1067. }
  1068. });
  1069. }
  1070. _fnCallbackReg(oSettings, 'aoDrawCallback', function() {
  1071. if (oSettings.bSorted || _fnDataSource(oSettings) === 'ssp' || features.bDeferRender) {
  1072. _fnSortingClasses(oSettings);
  1073. }
  1074. }, 'sc');
  1075. /*
  1076. * Final init
  1077. * Cache the header, body and footer as required, creating them if needed
  1078. */
  1079. // Work around for Webkit bug 83867 - store the caption-side before removing from doc
  1080. var captions = $this.children('caption').each(function() {
  1081. this._captionSide = $this.css('caption-side');
  1082. });
  1083. var thead = $this.children('thead');
  1084. if (thead.length === 0) {
  1085. thead = $('<thead/>').appendTo(this);
  1086. }
  1087. oSettings.nTHead = thead[0];
  1088. var tbody = $this.children('tbody');
  1089. if (tbody.length === 0) {
  1090. tbody = $('<tbody/>').appendTo(this);
  1091. }
  1092. oSettings.nTBody = tbody[0];
  1093. var tfoot = $this.children('tfoot');
  1094. if (tfoot.length === 0 && captions.length > 0 && (oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "")) {
  1095. // If we are a scrolling table, and no footer has been given, then we need to create
  1096. // a tfoot element for the caption element to be appended to
  1097. tfoot = $('<tfoot/>').appendTo(this);
  1098. }
  1099. if (tfoot.length === 0 || tfoot.children().length === 0) {
  1100. $this.addClass(oClasses.sNoFooter);
  1101. } else if (tfoot.length > 0) {
  1102. oSettings.nTFoot = tfoot[0];
  1103. _fnDetectHeader(oSettings.aoFooter, oSettings.nTFoot);
  1104. }
  1105. /* Check if there is data passing into the constructor */
  1106. if (oInit.aaData) {
  1107. for (i = 0; i < oInit.aaData.length; i++) {
  1108. _fnAddData(oSettings, oInit.aaData[i]);
  1109. }
  1110. } else if (oSettings.bDeferLoading || _fnDataSource(oSettings) == 'dom') {
  1111. /* Grab the data from the page - only do this when deferred loading or no Ajax
  1112. * source since there is no point in reading the DOM data if we are then going
  1113. * to replace it with Ajax data
  1114. */
  1115. _fnAddTr(oSettings, $(oSettings.nTBody).children('tr'));
  1116. }
  1117. /* Copy the data index array */
  1118. oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
  1119. /* Initialisation complete - table can be drawn */
  1120. oSettings.bInitialised = true;
  1121. /* Check if we need to initialise the table (it might not have been handed off to the
  1122. * language processor)
  1123. */
  1124. if (bInitHandedOff === false) {
  1125. _fnInitialise(oSettings);
  1126. }
  1127. });
  1128. _that = null;
  1129. return this;
  1130. };
  1131. /*
  1132. * It is useful to have variables which are scoped locally so only the
  1133. * DataTables functions can access them and they don't leak into global space.
  1134. * At the same time these functions are often useful over multiple files in the
  1135. * core and API, so we list, or at least document, all variables which are used
  1136. * by DataTables as private variables here. This also ensures that there is no
  1137. * clashing of variable names and that they can easily referenced for reuse.
  1138. */
  1139. // Defined else where
  1140. // _selector_run
  1141. // _selector_opts
  1142. // _selector_first
  1143. // _selector_row_indexes
  1144. var _ext; // DataTable.ext
  1145. var _Api; // DataTable.Api
  1146. var _api_register; // DataTable.Api.register
  1147. var _api_registerPlural; // DataTable.Api.registerPlural
  1148. var _re_dic = {};
  1149. var _re_new_lines = /[\r\n]/g;
  1150. var _re_html = /<.*?>/g;
  1151. var _re_date_start = /^[\w\+\-]/;
  1152. var _re_date_end = /[\w\+\-]$/;
  1153. // Escape regular expression special characters
  1154. var _re_escape_regex = new RegExp('(\\' + ['/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^', '-'].join('|\\') + ')', 'g');
  1155. // http://en.wikipedia.org/wiki/Foreign_exchange_market
  1156. // - \u20BD - Russian ruble.
  1157. // - \u20a9 - South Korean Won
  1158. // - \u20BA - Turkish Lira
  1159. // - \u20B9 - Indian Rupee
  1160. // - R - Brazil (R$) and South Africa
  1161. // - fr - Swiss Franc
  1162. // - kr - Swedish krona, Norwegian krone and Danish krone
  1163. // - \u2009 is thin space and \u202F is narrow no-break space, both used in many
  1164. // standards as thousands separators.
  1165. var _re_formatted_numeric = /[',$£€¥%\u2009\u202F\u20BD\u20a9\u20BArfk]/gi;
  1166. var _empty = function(d) {
  1167. return !d || d === true || d === '-' ? true : false;
  1168. };
  1169. var _intVal = function(s) {
  1170. var integer = parseInt(s, 10);
  1171. return !isNaN(integer) && isFinite(s) ? integer : null;
  1172. };
  1173. // Convert from a formatted number with characters other than `.` as the
  1174. // decimal place, to a Javascript number
  1175. var _numToDecimal = function(num, decimalPoint) {
  1176. // Cache created regular expressions for speed as this function is called often
  1177. if (!_re_dic[decimalPoint]) {
  1178. _re_dic[decimalPoint] = new RegExp(_fnEscapeRegex(decimalPoint), 'g');
  1179. }
  1180. return typeof num === 'string' && decimalPoint !== '.' ?
  1181. num.replace(/\./g, '').replace(_re_dic[decimalPoint], '.') :
  1182. num;
  1183. };
  1184. var _isNumber = function(d, decimalPoint, formatted) {
  1185. var strType = typeof d === 'string';
  1186. // If empty return immediately so there must be a number if it is a
  1187. // formatted string (this stops the string "k", or "kr", etc being detected
  1188. // as a formatted number for currency
  1189. if (_empty(d)) {
  1190. return true;
  1191. }
  1192. if (decimalPoint && strType) {
  1193. d = _numToDecimal(d, decimalPoint);
  1194. }
  1195. if (formatted && strType) {
  1196. d = d.replace(_re_formatted_numeric, '');
  1197. }
  1198. return !isNaN(parseFloat(d)) && isFinite(d);
  1199. };
  1200. // A string without HTML in it can be considered to be HTML still
  1201. var _isHtml = function(d) {
  1202. return _empty(d) || typeof d === 'string';
  1203. };
  1204. var _htmlNumeric = function(d, decimalPoint, formatted) {
  1205. if (_empty(d)) {
  1206. return true;
  1207. }
  1208. var html = _isHtml(d);
  1209. return !html ?
  1210. null :
  1211. _isNumber(_stripHtml(d), decimalPoint, formatted) ?
  1212. true :
  1213. null;
  1214. };
  1215. var _pluck = function(a, prop, prop2) {
  1216. var out = [];
  1217. var i = 0,
  1218. ien = a.length;
  1219. // Could have the test in the loop for slightly smaller code, but speed
  1220. // is essential here
  1221. if (prop2 !== undefined) {
  1222. for (; i < ien; i++) {
  1223. if (a[i] && a[i][prop]) {
  1224. out.push(a[i][prop][prop2]);
  1225. }
  1226. }
  1227. } else {
  1228. for (; i < ien; i++) {
  1229. if (a[i]) {
  1230. out.push(a[i][prop]);
  1231. }
  1232. }
  1233. }
  1234. return out;
  1235. };
  1236. // Basically the same as _pluck, but rather than looping over `a` we use `order`
  1237. // as the indexes to pick from `a`
  1238. var _pluck_order = function(a, order, prop, prop2) {
  1239. var out = [];
  1240. var i = 0,
  1241. ien = order.length;
  1242. // Could have the test in the loop for slightly smaller code, but speed
  1243. // is essential here
  1244. if (prop2 !== undefined) {
  1245. for (; i < ien; i++) {
  1246. if (a[order[i]][prop]) {
  1247. out.push(a[order[i]][prop][prop2]);
  1248. }
  1249. }
  1250. } else {
  1251. for (; i < ien; i++) {
  1252. out.push(a[order[i]][prop]);
  1253. }
  1254. }
  1255. return out;
  1256. };
  1257. var _range = function(len, start) {
  1258. var out = [];
  1259. var end;
  1260. if (start === undefined) {
  1261. start = 0;
  1262. end = len;
  1263. } else {
  1264. end = start;
  1265. start = len;
  1266. }
  1267. for (var i = start; i < end; i++) {
  1268. out.push(i);
  1269. }
  1270. return out;
  1271. };
  1272. var _removeEmpty = function(a) {
  1273. var out = [];
  1274. for (var i = 0, ien = a.length; i < ien; i++) {
  1275. if (a[i]) { // careful - will remove all falsy values!
  1276. out.push(a[i]);
  1277. }
  1278. }
  1279. return out;
  1280. };
  1281. var _stripHtml = function(d) {
  1282. return d.replace(_re_html, '');
  1283. };
  1284. /**
  1285. * Find the unique elements in a source array.
  1286. *
  1287. * @param {array} src Source array
  1288. * @return {array} Array of unique items
  1289. * @ignore
  1290. */
  1291. var _unique = function(src) {
  1292. // A faster unique method is to use object keys to identify used values,
  1293. // but this doesn't work with arrays or objects, which we must also
  1294. // consider. See jsperf.com/compare-array-unique-versions/4 for more
  1295. // information.
  1296. var
  1297. out = [],
  1298. val,
  1299. i, ien = src.length,
  1300. j, k = 0;
  1301. again: for (i = 0; i < ien; i++) {
  1302. val = src[i];
  1303. for (j = 0; j < k; j++) {
  1304. if (out[j] === val) {
  1305. continue again;
  1306. }
  1307. }
  1308. out.push(val);
  1309. k++;
  1310. }
  1311. return out;
  1312. };
  1313. /**
  1314. * DataTables utility methods
  1315. *
  1316. * This namespace provides helper methods that DataTables uses internally to
  1317. * create a DataTable, but which are not exclusively used only for DataTables.
  1318. * These methods can be used by extension authors to save the duplication of
  1319. * code.
  1320. *
  1321. * @namespace
  1322. */
  1323. DataTable.util = {
  1324. /**
  1325. * Throttle the calls to a function. Arguments and context are maintained
  1326. * for the throttled function.
  1327. *
  1328. * @param {function} fn Function to be called
  1329. * @param {integer} freq Call frequency in mS
  1330. * @return {function} Wrapped function
  1331. */
  1332. throttle: function(fn, freq) {
  1333. var
  1334. frequency = freq !== undefined ? freq : 200,
  1335. last,
  1336. timer;
  1337. return function() {
  1338. var
  1339. that = this,
  1340. now = +new Date(),
  1341. args = arguments;
  1342. if (last && now < last + frequency) {
  1343. clearTimeout(timer);
  1344. timer = setTimeout(function() {
  1345. last = undefined;
  1346. fn.apply(that, args);
  1347. }, frequency);
  1348. } else {
  1349. last = now;
  1350. fn.apply(that, args);
  1351. }
  1352. };
  1353. },
  1354. /**
  1355. * Escape a string such that it can be used in a regular expression
  1356. *
  1357. * @param {string} val string to escape
  1358. * @returns {string} escaped string
  1359. */
  1360. escapeRegex: function(val) {
  1361. return val.replace(_re_escape_regex, '\\$1');
  1362. }
  1363. };
  1364. /**
  1365. * Create a mapping object that allows camel case parameters to be looked up
  1366. * for their Hungarian counterparts. The mapping is stored in a private
  1367. * parameter called `_hungarianMap` which can be accessed on the source object.
  1368. * @param {object} o
  1369. * @memberof DataTable#oApi
  1370. */
  1371. function _fnHungarianMap(o) {
  1372. var
  1373. hungarian = 'a aa ai ao as b fn i m o s ',
  1374. match,
  1375. newKey,
  1376. map = {};
  1377. $.each(o, function(key, val) {
  1378. match = key.match(/^([^A-Z]+?)([A-Z])/);
  1379. if (match && hungarian.indexOf(match[1] + ' ') !== -1) {
  1380. newKey = key.replace(match[0], match[2].toLowerCase());
  1381. map[newKey] = key;
  1382. if (match[1] === 'o') {
  1383. _fnHungarianMap(o[key]);
  1384. }
  1385. }
  1386. });
  1387. o._hungarianMap = map;
  1388. }
  1389. /**
  1390. * Convert from camel case parameters to Hungarian, based on a Hungarian map
  1391. * created by _fnHungarianMap.
  1392. * @param {object} src The model object which holds all parameters that can be
  1393. * mapped.
  1394. * @param {object} user The object to convert from camel case to Hungarian.
  1395. * @param {boolean} force When set to `true`, properties which already have a
  1396. * Hungarian value in the `user` object will be overwritten. Otherwise they
  1397. * won't be.
  1398. * @memberof DataTable#oApi
  1399. */
  1400. function _fnCamelToHungarian(src, user, force) {
  1401. if (!src._hungarianMap) {
  1402. _fnHungarianMap(src);
  1403. }
  1404. var hungarianKey;
  1405. $.each(user, function(key, val) {
  1406. hungarianKey = src._hungarianMap[key];
  1407. if (hungarianKey !== undefined && (force || user[hungarianKey] === undefined)) {
  1408. // For objects, we need to buzz down into the object to copy parameters
  1409. if (hungarianKey.charAt(0) === 'o') {
  1410. // Copy the camelCase options over to the hungarian
  1411. if (!user[hungarianKey]) {
  1412. user[hungarianKey] = {};
  1413. }
  1414. $.extend(true, user[hungarianKey], user[key]);
  1415. _fnCamelToHungarian(src[hungarianKey], user[hungarianKey], force);
  1416. } else {
  1417. user[hungarianKey] = user[key];
  1418. }
  1419. }
  1420. });
  1421. }
  1422. /**
  1423. * Language compatibility - when certain options are given, and others aren't, we
  1424. * need to duplicate the values over, in order to provide backwards compatibility
  1425. * with older language files.
  1426. * @param {object} oSettings dataTables settings object
  1427. * @memberof DataTable#oApi
  1428. */
  1429. function _fnLanguageCompat(lang) {
  1430. var defaults = DataTable.defaults.oLanguage;
  1431. var zeroRecords = lang.sZeroRecords;
  1432. /* Backwards compatibility - if there is no sEmptyTable given, then use the same as
  1433. * sZeroRecords - assuming that is given.
  1434. */
  1435. if (!lang.sEmptyTable && zeroRecords &&
  1436. defaults.sEmptyTable === "No data available in table") {
  1437. _fnMap(lang, lang, 'sZeroRecords', 'sEmptyTable');
  1438. }
  1439. /* Likewise with loading records */
  1440. if (!lang.sLoadingRecords && zeroRecords &&
  1441. defaults.sLoadingRecords === "Loading...") {
  1442. _fnMap(lang, lang, 'sZeroRecords', 'sLoadingRecords');
  1443. }
  1444. // Old parameter name of the thousands separator mapped onto the new
  1445. if (lang.sInfoThousands) {
  1446. lang.sThousands = lang.sInfoThousands;
  1447. }
  1448. var decimal = lang.sDecimal;
  1449. if (decimal) {
  1450. _addNumericSort(decimal);
  1451. }
  1452. }
  1453. /**
  1454. * Map one parameter onto another
  1455. * @param {object} o Object to map
  1456. * @param {*} knew The new parameter name
  1457. * @param {*} old The old parameter name
  1458. */
  1459. var _fnCompatMap = function(o, knew, old) {
  1460. if (o[knew] !== undefined) {
  1461. o[old] = o[knew];
  1462. }
  1463. };
  1464. /**
  1465. * Provide backwards compatibility for the main DT options. Note that the new
  1466. * options are mapped onto the old parameters, so this is an external interface
  1467. * change only.
  1468. * @param {object} init Object to map
  1469. */
  1470. function _fnCompatOpts(init) {
  1471. _fnCompatMap(init, 'ordering', 'bSort');
  1472. _fnCompatMap(init, 'orderMulti', 'bSortMulti');
  1473. _fnCompatMap(init, 'orderClasses', 'bSortClasses');
  1474. _fnCompatMap(init, 'orderCellsTop', 'bSortCellsTop');
  1475. _fnCompatMap(init, 'order', 'aaSorting');
  1476. _fnCompatMap(init, 'orderFixed', 'aaSortingFixed');
  1477. _fnCompatMap(init, 'paging', 'bPaginate');
  1478. _fnCompatMap(init, 'pagingType', 'sPaginationType');
  1479. _fnCompatMap(init, 'pageLength', 'iDisplayLength');
  1480. _fnCompatMap(init, 'searching', 'bFilter');
  1481. // Boolean initialisation of x-scrolling
  1482. if (typeof init.sScrollX === 'boolean') {
  1483. init.sScrollX = init.sScrollX ? '100%' : '';
  1484. }
  1485. if (typeof init.scrollX === 'boolean') {
  1486. init.scrollX = init.scrollX ? '100%' : '';
  1487. }
  1488. // Column search objects are in an array, so it needs to be converted
  1489. // element by element
  1490. var searchCols = init.aoSearchCols;
  1491. if (searchCols) {
  1492. for (var i = 0, ien = searchCols.length; i < ien; i++) {
  1493. if (searchCols[i]) {
  1494. _fnCamelToHungarian(DataTable.models.oSearch, searchCols[i]);
  1495. }
  1496. }
  1497. }
  1498. }
  1499. /**
  1500. * Provide backwards compatibility for column options. Note that the new options
  1501. * are mapped onto the old parameters, so this is an external interface change
  1502. * only.
  1503. * @param {object} init Object to map
  1504. */
  1505. function _fnCompatCols(init) {
  1506. _fnCompatMap(init, 'orderable', 'bSortable');
  1507. _fnCompatMap(init, 'orderData', 'aDataSort');
  1508. _fnCompatMap(init, 'orderSequence', 'asSorting');
  1509. _fnCompatMap(init, 'orderDataType', 'sortDataType');
  1510. // orderData can be given as an integer
  1511. var dataSort = init.aDataSort;
  1512. if (dataSort && !$.isArray(dataSort)) {
  1513. init.aDataSort = [dataSort];
  1514. }
  1515. }
  1516. /**
  1517. * Browser feature detection for capabilities, quirks
  1518. * @param {object} settings dataTables settings object
  1519. * @memberof DataTable#oApi
  1520. */
  1521. function _fnBrowserDetect(settings) {
  1522. // We don't need to do this every time DataTables is constructed, the values
  1523. // calculated are specific to the browser and OS configuration which we
  1524. // don't expect to change between initialisations
  1525. if (!DataTable.__browser) {
  1526. var browser = {};
  1527. DataTable.__browser = browser;
  1528. // Scrolling feature / quirks detection
  1529. var n = $('<div/>')
  1530. .css({
  1531. position: 'fixed',
  1532. top: 0,
  1533. left: 0,
  1534. height: 1,
  1535. width: 1,
  1536. overflow: 'hidden'
  1537. })
  1538. .append(
  1539. $('<div/>')
  1540. .css({
  1541. position: 'absolute',
  1542. top: 1,
  1543. left: 1,
  1544. width: 100,
  1545. overflow: 'scroll'
  1546. })
  1547. .append(
  1548. $('<div/>')
  1549. .css({
  1550. width: '100%',
  1551. height: 10
  1552. })
  1553. )
  1554. )
  1555. .appendTo('body');
  1556. var outer = n.children();
  1557. var inner = outer.children();
  1558. // Numbers below, in order, are:
  1559. // inner.offsetWidth, inner.clientWidth, outer.offsetWidth, outer.clientWidth
  1560. //
  1561. // IE6 XP: 100 100 100 83
  1562. // IE7 Vista: 100 100 100 83
  1563. // IE 8+ Windows: 83 83 100 83
  1564. // Evergreen Windows: 83 83 100 83
  1565. // Evergreen Mac with scrollbars: 85 85 100 85
  1566. // Evergreen Mac without scrollbars: 100 100 100 100
  1567. // Get scrollbar width
  1568. browser.barWidth = outer[0].offsetWidth - outer[0].clientWidth;
  1569. // IE6/7 will oversize a width 100% element inside a scrolling element, to
  1570. // include the width of the scrollbar, while other browsers ensure the inner
  1571. // element is contained without forcing scrolling
  1572. browser.bScrollOversize = inner[0].offsetWidth === 100 && outer[0].clientWidth !== 100;
  1573. // In rtl text layout, some browsers (most, but not all) will place the
  1574. // scrollbar on the left, rather than the right.
  1575. browser.bScrollbarLeft = Math.round(inner.offset().left) !== 1;
  1576. // IE8- don't provide height and width for getBoundingClientRect
  1577. browser.bBounding = n[0].getBoundingClientRect().width ? true : false;
  1578. n.remove();
  1579. }
  1580. $.extend(settings.oBrowser, DataTable.__browser);
  1581. settings.oScroll.iBarWidth = DataTable.__browser.barWidth;
  1582. }
  1583. /**
  1584. * Array.prototype reduce[Right] method, used for browsers which don't support
  1585. * JS 1.6. Done this way to reduce code size, since we iterate either way
  1586. * @param {object} settings dataTables settings object
  1587. * @memberof DataTable#oApi
  1588. */
  1589. function _fnReduce(that, fn, init, start, end, inc) {
  1590. var
  1591. i = start,
  1592. value,
  1593. isSet = false;
  1594. if (init !== undefined) {
  1595. value = init;
  1596. isSet = true;
  1597. }
  1598. while (i !== end) {
  1599. if (!that.hasOwnProperty(i)) {
  1600. continue;
  1601. }
  1602. value = isSet ?
  1603. fn(value, that[i], i, that) :
  1604. that[i];
  1605. isSet = true;
  1606. i += inc;
  1607. }
  1608. return value;
  1609. }
  1610. /**
  1611. * Add a column to the list used for the table with default values
  1612. * @param {object} oSettings dataTables settings object
  1613. * @param {node} nTh The th element for this column
  1614. * @memberof DataTable#oApi
  1615. */
  1616. function _fnAddColumn(oSettings, nTh) {
  1617. // Add column to aoColumns array
  1618. var oDefaults = DataTable.defaults.column;
  1619. var iCol = oSettings.aoColumns.length;
  1620. var oCol = $.extend({}, DataTable.models.oColumn, oDefaults, {
  1621. "nTh": nTh ? nTh : document.createElement('th'),
  1622. "sTitle": oDefaults.sTitle ? oDefaults.sTitle : nTh ? nTh.innerHTML : '',
  1623. "aDataSort": oDefaults.aDataSort ? oDefaults.aDataSort : [iCol],
  1624. "mData": oDefaults.mData ? oDefaults.mData : iCol,
  1625. idx: iCol
  1626. });
  1627. oSettings.aoColumns.push(oCol);
  1628. // Add search object for column specific search. Note that the `searchCols[ iCol ]`
  1629. // passed into extend can be undefined. This allows the user to give a default
  1630. // with only some of the parameters defined, and also not give a default
  1631. var searchCols = oSettings.aoPreSearchCols;
  1632. searchCols[iCol] = $.extend({}, DataTable.models.oSearch, searchCols[iCol]);
  1633. // Use the default column options function to initialise classes etc
  1634. _fnColumnOptions(oSettings, iCol, $(nTh).data());
  1635. }
  1636. /**
  1637. * Apply options for a column
  1638. * @param {object} oSettings dataTables settings object
  1639. * @param {int} iCol column index to consider
  1640. * @param {object} oOptions object with sType, bVisible and bSearchable etc
  1641. * @memberof DataTable#oApi
  1642. */
  1643. function _fnColumnOptions(oSettings, iCol, oOptions) {
  1644. var oCol = oSettings.aoColumns[iCol];
  1645. var oClasses = oSettings.oClasses;
  1646. var th = $(oCol.nTh);
  1647. // Try to get width information from the DOM. We can't get it from CSS
  1648. // as we'd need to parse the CSS stylesheet. `width` option can override
  1649. if (!oCol.sWidthOrig) {
  1650. // Width attribute
  1651. oCol.sWidthOrig = th.attr('width') || null;
  1652. // Style attribute
  1653. var t = (th.attr('style') || '').match(/width:\s*(\d+[pxem%]+)/);
  1654. if (t) {
  1655. oCol.sWidthOrig = t[1];
  1656. }
  1657. }
  1658. /* User specified column options */
  1659. if (oOptions !== undefined && oOptions !== null) {
  1660. // Backwards compatibility
  1661. _fnCompatCols(oOptions);
  1662. // Map camel case parameters to their Hungarian counterparts
  1663. _fnCamelToHungarian(DataTable.defaults.column, oOptions);
  1664. /* Backwards compatibility for mDataProp */
  1665. if (oOptions.mDataProp !== undefined && !oOptions.mData) {
  1666. oOptions.mData = oOptions.mDataProp;
  1667. }
  1668. if (oOptions.sType) {
  1669. oCol._sManualType = oOptions.sType;
  1670. }
  1671. // `class` is a reserved word in Javascript, so we need to provide
  1672. // the ability to use a valid name for the camel case input
  1673. if (oOptions.className && !oOptions.sClass) {
  1674. oOptions.sClass = oOptions.className;
  1675. }
  1676. $.extend(oCol, oOptions);
  1677. _fnMap(oCol, oOptions, "sWidth", "sWidthOrig");
  1678. /* iDataSort to be applied (backwards compatibility), but aDataSort will take
  1679. * priority if defined
  1680. */
  1681. if (oOptions.iDataSort !== undefined) {
  1682. oCol.aDataSort = [oOptions.iDataSort];
  1683. }
  1684. _fnMap(oCol, oOptions, "aDataSort");
  1685. }
  1686. /* Cache the data get and set functions for speed */
  1687. var mDataSrc = oCol.mData;
  1688. var mData = _fnGetObjectDataFn(mDataSrc);
  1689. var mRender = oCol.mRender ? _fnGetObjectDataFn(oCol.mRender) : null;
  1690. var attrTest = function(src) {
  1691. return typeof src === 'string' && src.indexOf('@') !== -1;
  1692. };
  1693. oCol._bAttrSrc = $.isPlainObject(mDataSrc) && (
  1694. attrTest(mDataSrc.sort) || attrTest(mDataSrc.type) || attrTest(mDataSrc.filter)
  1695. );
  1696. oCol._setter = null;
  1697. oCol.fnGetData = function(rowData, type, meta) {
  1698. var innerData = mData(rowData, type, undefined, meta);
  1699. return mRender && type ?
  1700. mRender(innerData, type, rowData, meta) :
  1701. innerData;
  1702. };
  1703. oCol.fnSetData = function(rowData, val, meta) {
  1704. return _fnSetObjectDataFn(mDataSrc)(rowData, val, meta);
  1705. };
  1706. // Indicate if DataTables should read DOM data as an object or array
  1707. // Used in _fnGetRowElements
  1708. if (typeof mDataSrc !== 'number') {
  1709. oSettings._rowReadObject = true;
  1710. }
  1711. /* Feature sorting overrides column specific when off */
  1712. if (!oSettings.oFeatures.bSort) {
  1713. oCol.bSortable = false;
  1714. th.addClass(oClasses.sSortableNone); // Have to add class here as order event isn't called
  1715. }
  1716. /* Check that the class assignment is correct for sorting */
  1717. var bAsc = $.inArray('asc', oCol.asSorting) !== -1;
  1718. var bDesc = $.inArray('desc', oCol.asSorting) !== -1;
  1719. if (!oCol.bSortable || (!bAsc && !bDesc)) {
  1720. oCol.sSortingClass = oClasses.sSortableNone;
  1721. oCol.sSortingClassJUI = "";
  1722. } else if (bAsc && !bDesc) {
  1723. oCol.sSortingClass = oClasses.sSortableAsc;
  1724. oCol.sSortingClassJUI = oClasses.sSortJUIAscAllowed;
  1725. } else if (!bAsc && bDesc) {
  1726. oCol.sSortingClass = oClasses.sSortableDesc;
  1727. oCol.sSortingClassJUI = oClasses.sSortJUIDescAllowed;
  1728. } else {
  1729. oCol.sSortingClass = oClasses.sSortable;
  1730. oCol.sSortingClassJUI = oClasses.sSortJUI;
  1731. }
  1732. }
  1733. /**
  1734. * Adjust the table column widths for new data. Note: you would probably want to
  1735. * do a redraw after calling this function!
  1736. * @param {object} settings dataTables settings object
  1737. * @memberof DataTable#oApi
  1738. */
  1739. function _fnAdjustColumnSizing(settings) {
  1740. /* Not interested in doing column width calculation if auto-width is disabled */
  1741. if (settings.oFeatures.bAutoWidth !== false) {
  1742. var columns = settings.aoColumns;
  1743. _fnCalculateColumnWidths(settings);
  1744. for (var i = 0, iLen = columns.length; i < iLen; i++) {
  1745. columns[i].nTh.style.width = columns[i].sWidth;
  1746. }
  1747. }
  1748. var scroll = settings.oScroll;
  1749. if (scroll.sY !== '' || scroll.sX !== '') {
  1750. _fnScrollDraw(settings);
  1751. }
  1752. _fnCallbackFire(settings, null, 'column-sizing', [settings]);
  1753. }
  1754. /**
  1755. * Covert the index of a visible column to the index in the data array (take account
  1756. * of hidden columns)
  1757. * @param {object} oSettings dataTables settings object
  1758. * @param {int} iMatch Visible column index to lookup
  1759. * @returns {int} i the data index
  1760. * @memberof DataTable#oApi
  1761. */
  1762. function _fnVisibleToColumnIndex(oSettings, iMatch) {
  1763. var aiVis = _fnGetColumns(oSettings, 'bVisible');
  1764. return typeof aiVis[iMatch] === 'number' ?
  1765. aiVis[iMatch] :
  1766. null;
  1767. }
  1768. /**
  1769. * Covert the index of an index in the data array and convert it to the visible
  1770. * column index (take account of hidden columns)
  1771. * @param {int} iMatch Column index to lookup
  1772. * @param {object} oSettings dataTables settings object
  1773. * @returns {int} i the data index
  1774. * @memberof DataTable#oApi
  1775. */
  1776. function _fnColumnIndexToVisible(oSettings, iMatch) {
  1777. var aiVis = _fnGetColumns(oSettings, 'bVisible');
  1778. var iPos = $.inArray(iMatch, aiVis);
  1779. return iPos !== -1 ? iPos : null;
  1780. }
  1781. /**
  1782. * Get the number of visible columns
  1783. * @param {object} oSettings dataTables settings object
  1784. * @returns {int} i the number of visible columns
  1785. * @memberof DataTable#oApi
  1786. */
  1787. function _fnVisbleColumns(oSettings) {
  1788. var vis = 0;
  1789. // No reduce in IE8, use a loop for now
  1790. $.each(oSettings.aoColumns, function(i, col) {
  1791. if (col.bVisible && $(col.nTh).css('display') !== 'none') {
  1792. vis++;
  1793. }
  1794. });
  1795. return vis;
  1796. }
  1797. /**
  1798. * Get an array of column indexes that match a given property
  1799. * @param {object} oSettings dataTables settings object
  1800. * @param {string} sParam Parameter in aoColumns to look for - typically
  1801. * bVisible or bSearchable
  1802. * @returns {array} Array of indexes with matched properties
  1803. * @memberof DataTable#oApi
  1804. */
  1805. function _fnGetColumns(oSettings, sParam) {
  1806. var a = [];
  1807. $.map(oSettings.aoColumns, function(val, i) {
  1808. if (val[sParam]) {
  1809. a.push(i);
  1810. }
  1811. });
  1812. return a;
  1813. }
  1814. /**
  1815. * Calculate the 'type' of a column
  1816. * @param {object} settings dataTables settings object
  1817. * @memberof DataTable#oApi
  1818. */
  1819. function _fnColumnTypes(settings) {
  1820. var columns = settings.aoColumns;
  1821. var data = settings.aoData;
  1822. var types = DataTable.ext.type.detect;
  1823. var i, ien, j, jen, k, ken;
  1824. var col, cell, detectedType, cache;
  1825. // For each column, spin over the
  1826. for (i = 0, ien = columns.length; i < ien; i++) {
  1827. col = columns[i];
  1828. cache = [];
  1829. if (!col.sType && col._sManualType) {
  1830. col.sType = col._sManualType;
  1831. } else if (!col.sType) {
  1832. for (j = 0, jen = types.length; j < jen; j++) {
  1833. for (k = 0, ken = data.length; k < ken; k++) {
  1834. // Use a cache array so we only need to get the type data
  1835. // from the formatter once (when using multiple detectors)
  1836. if (cache[k] === undefined) {
  1837. cache[k] = _fnGetCellData(settings, k, i, 'type');
  1838. }
  1839. detectedType = types[j](cache[k], settings);
  1840. // If null, then this type can't apply to this column, so
  1841. // rather than testing all cells, break out. There is an
  1842. // exception for the last type which is `html`. We need to
  1843. // scan all rows since it is possible to mix string and HTML
  1844. // types
  1845. if (!detectedType && j !== types.length - 1) {
  1846. break;
  1847. }
  1848. // Only a single match is needed for html type since it is
  1849. // bottom of the pile and very similar to string
  1850. if (detectedType === 'html') {
  1851. break;
  1852. }
  1853. }
  1854. // Type is valid for all data points in the column - use this
  1855. // type
  1856. if (detectedType) {
  1857. col.sType = detectedType;
  1858. break;
  1859. }
  1860. }
  1861. // Fall back - if no type was detected, always use string
  1862. if (!col.sType) {
  1863. col.sType = 'string';
  1864. }
  1865. }
  1866. }
  1867. }
  1868. /**
  1869. * Take the column definitions and static columns arrays and calculate how
  1870. * they relate to column indexes. The callback function will then apply the
  1871. * definition found for a column to a suitable configuration object.
  1872. * @param {object} oSettings dataTables settings object
  1873. * @param {array} aoColDefs The aoColumnDefs array that is to be applied
  1874. * @param {array} aoCols The aoColumns array that defines columns individually
  1875. * @param {function} fn Callback function - takes two parameters, the calculated
  1876. * column index and the definition for that column.
  1877. * @memberof DataTable#oApi
  1878. */
  1879. function _fnApplyColumnDefs(oSettings, aoColDefs, aoCols, fn) {
  1880. var i, iLen, j, jLen, k, kLen, def;
  1881. var columns = oSettings.aoColumns;
  1882. // Column definitions with aTargets
  1883. if (aoColDefs) {
  1884. /* Loop over the definitions array - loop in reverse so first instance has priority */
  1885. for (i = aoColDefs.length - 1; i >= 0; i--) {
  1886. def = aoColDefs[i];
  1887. /* Each definition can target multiple columns, as it is an array */
  1888. var aTargets = def.targets !== undefined ?
  1889. def.targets :
  1890. def.aTargets;
  1891. if (!$.isArray(aTargets)) {
  1892. aTargets = [aTargets];
  1893. }
  1894. for (j = 0, jLen = aTargets.length; j < jLen; j++) {
  1895. if (typeof aTargets[j] === 'number' && aTargets[j] >= 0) {
  1896. /* Add columns that we don't yet know about */
  1897. while (columns.length <= aTargets[j]) {
  1898. _fnAddColumn(oSettings);
  1899. }
  1900. /* Integer, basic index */
  1901. fn(aTargets[j], def);
  1902. } else if (typeof aTargets[j] === 'number' && aTargets[j] < 0) {
  1903. /* Negative integer, right to left column counting */
  1904. fn(columns.length + aTargets[j], def);
  1905. } else if (typeof aTargets[j] === 'string') {
  1906. /* Class name matching on TH element */
  1907. for (k = 0, kLen = columns.length; k < kLen; k++) {
  1908. if (aTargets[j] == "_all" ||
  1909. $(columns[k].nTh).hasClass(aTargets[j])) {
  1910. fn(k, def);
  1911. }
  1912. }
  1913. }
  1914. }
  1915. }
  1916. }
  1917. // Statically defined columns array
  1918. if (aoCols) {
  1919. for (i = 0, iLen = aoCols.length; i < iLen; i++) {
  1920. fn(i, aoCols[i]);
  1921. }
  1922. }
  1923. }
  1924. /**
  1925. * Add a data array to the table, creating DOM node etc. This is the parallel to
  1926. * _fnGatherData, but for adding rows from a Javascript source, rather than a
  1927. * DOM source.
  1928. * @param {object} oSettings dataTables settings object
  1929. * @param {array} aData data array to be added
  1930. * @param {node} [nTr] TR element to add to the table - optional. If not given,
  1931. * DataTables will create a row automatically
  1932. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  1933. * if nTr is.
  1934. * @returns {int} >=0 if successful (index of new aoData entry), -1 if failed
  1935. * @memberof DataTable#oApi
  1936. */
  1937. function _fnAddData(oSettings, aDataIn, nTr, anTds) {
  1938. /* Create the object for storing information about this new row */
  1939. var iRow = oSettings.aoData.length;
  1940. var oData = $.extend(true, {}, DataTable.models.oRow, {
  1941. src: nTr ? 'dom' : 'data',
  1942. idx: iRow
  1943. });
  1944. oData._aData = aDataIn;
  1945. oSettings.aoData.push(oData);
  1946. /* Create the cells */
  1947. var nTd, sThisType;
  1948. var columns = oSettings.aoColumns;
  1949. // Invalidate the column types as the new data needs to be revalidated
  1950. for (var i = 0, iLen = columns.length; i < iLen; i++) {
  1951. columns[i].sType = null;
  1952. }
  1953. /* Add to the display array */
  1954. oSettings.aiDisplayMaster.push(iRow);
  1955. var id = oSettings.rowIdFn(aDataIn);
  1956. if (id !== undefined) {
  1957. oSettings.aIds[id] = oData;
  1958. }
  1959. /* Create the DOM information, or register it if already present */
  1960. if (nTr || !oSettings.oFeatures.bDeferRender) {
  1961. _fnCreateTr(oSettings, iRow, nTr, anTds);
  1962. }
  1963. return iRow;
  1964. }
  1965. /**
  1966. * Add one or more TR elements to the table. Generally we'd expect to
  1967. * use this for reading data from a DOM sourced table, but it could be
  1968. * used for an TR element. Note that if a TR is given, it is used (i.e.
  1969. * it is not cloned).
  1970. * @param {object} settings dataTables settings object
  1971. * @param {array|node|jQuery} trs The TR element(s) to add to the table
  1972. * @returns {array} Array of indexes for the added rows
  1973. * @memberof DataTable#oApi
  1974. */
  1975. function _fnAddTr(settings, trs) {
  1976. var row;
  1977. // Allow an individual node to be passed in
  1978. if (!(trs instanceof $)) {
  1979. trs = $(trs);
  1980. }
  1981. return trs.map(function(i, el) {
  1982. row = _fnGetRowElements(settings, el);
  1983. return _fnAddData(settings, row.data, el, row.cells);
  1984. });
  1985. }
  1986. /**
  1987. * Take a TR element and convert it to an index in aoData
  1988. * @param {object} oSettings dataTables settings object
  1989. * @param {node} n the TR element to find
  1990. * @returns {int} index if the node is found, null if not
  1991. * @memberof DataTable#oApi
  1992. */
  1993. function _fnNodeToDataIndex(oSettings, n) {
  1994. return (n._DT_RowIndex !== undefined) ? n._DT_RowIndex : null;
  1995. }
  1996. /**
  1997. * Take a TD element and convert it into a column data index (not the visible index)
  1998. * @param {object} oSettings dataTables settings object
  1999. * @param {int} iRow The row number the TD/TH can be found in
  2000. * @param {node} n The TD/TH element to find
  2001. * @returns {int} index if the node is found, -1 if not
  2002. * @memberof DataTable#oApi
  2003. */
  2004. function _fnNodeToColumnIndex(oSettings, iRow, n) {
  2005. return $.inArray(n, oSettings.aoData[iRow].anCells);
  2006. }
  2007. /**
  2008. * Get the data for a given cell from the internal cache, taking into account data mapping
  2009. * @param {object} settings dataTables settings object
  2010. * @param {int} rowIdx aoData row id
  2011. * @param {int} colIdx Column index
  2012. * @param {string} type data get type ('display', 'type' 'filter' 'sort')
  2013. * @returns {*} Cell data
  2014. * @memberof DataTable#oApi
  2015. */
  2016. function _fnGetCellData(settings, rowIdx, colIdx, type) {
  2017. var draw = settings.iDraw;
  2018. var col = settings.aoColumns[colIdx];
  2019. var rowData = settings.aoData[rowIdx]._aData;
  2020. var defaultContent = col.sDefaultContent;
  2021. var cellData = col.fnGetData(rowData, type, {
  2022. settings: settings,
  2023. row: rowIdx,
  2024. col: colIdx
  2025. });
  2026. if (cellData === undefined) {
  2027. if (settings.iDrawError != draw && defaultContent === null) {
  2028. _fnLog(settings, 0, "Requested unknown parameter " +
  2029. (typeof col.mData == 'function' ? '{function}' : "'" + col.mData + "'") +
  2030. " for row " + rowIdx + ", column " + colIdx, 4);
  2031. settings.iDrawError = draw;
  2032. }
  2033. return defaultContent;
  2034. }
  2035. // When the data source is null and a specific data type is requested (i.e.
  2036. // not the original data), we can use default column data
  2037. if ((cellData === rowData || cellData === null) && defaultContent !== null && type !== undefined) {
  2038. cellData = defaultContent;
  2039. } else if (typeof cellData === 'function') {
  2040. // If the data source is a function, then we run it and use the return,
  2041. // executing in the scope of the data object (for instances)
  2042. return cellData.call(rowData);
  2043. }
  2044. if (cellData === null && type == 'display') {
  2045. return '';
  2046. }
  2047. return cellData;
  2048. }
  2049. /**
  2050. * Set the value for a specific cell, into the internal data cache
  2051. * @param {object} settings dataTables settings object
  2052. * @param {int} rowIdx aoData row id
  2053. * @param {int} colIdx Column index
  2054. * @param {*} val Value to set
  2055. * @memberof DataTable#oApi
  2056. */
  2057. function _fnSetCellData(settings, rowIdx, colIdx, val) {
  2058. var col = settings.aoColumns[colIdx];
  2059. var rowData = settings.aoData[rowIdx]._aData;
  2060. col.fnSetData(rowData, val, {
  2061. settings: settings,
  2062. row: rowIdx,
  2063. col: colIdx
  2064. });
  2065. }
  2066. // Private variable that is used to match action syntax in the data property object
  2067. var __reArray = /\[.*?\]$/;
  2068. var __reFn = /\(\)$/;
  2069. /**
  2070. * Split string on periods, taking into account escaped periods
  2071. * @param {string} str String to split
  2072. * @return {array} Split string
  2073. */
  2074. function _fnSplitObjNotation(str) {
  2075. return $.map(str.match(/(\\.|[^\.])+/g) || [''], function(s) {
  2076. return s.replace(/\\./g, '.');
  2077. });
  2078. }
  2079. /**
  2080. * Return a function that can be used to get data from a source object, taking
  2081. * into account the ability to use nested objects as a source
  2082. * @param {string|int|function} mSource The data source for the object
  2083. * @returns {function} Data get function
  2084. * @memberof DataTable#oApi
  2085. */
  2086. function _fnGetObjectDataFn(mSource) {
  2087. if ($.isPlainObject(mSource)) {
  2088. /* Build an object of get functions, and wrap them in a single call */
  2089. var o = {};
  2090. $.each(mSource, function(key, val) {
  2091. if (val) {
  2092. o[key] = _fnGetObjectDataFn(val);
  2093. }
  2094. });
  2095. return function(data, type, row, meta) {
  2096. var t = o[type] || o._;
  2097. return t !== undefined ?
  2098. t(data, type, row, meta) :
  2099. data;
  2100. };
  2101. } else if (mSource === null) {
  2102. /* Give an empty string for rendering / sorting etc */
  2103. return function(data) { // type, row and meta also passed, but not used
  2104. return data;
  2105. };
  2106. } else if (typeof mSource === 'function') {
  2107. return function(data, type, row, meta) {
  2108. return mSource(data, type, row, meta);
  2109. };
  2110. } else if (typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  2111. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1)) {
  2112. /* If there is a . in the source string then the data source is in a
  2113. * nested object so we loop over the data for each level to get the next
  2114. * level down. On each loop we test for undefined, and if found immediately
  2115. * return. This allows entire objects to be missing and sDefaultContent to
  2116. * be used if defined, rather than throwing an error
  2117. */
  2118. var fetchData = function(data, type, src) {
  2119. var arrayNotation, funcNotation, out, innerSrc;
  2120. if (src !== "") {
  2121. var a = _fnSplitObjNotation(src);
  2122. for (var i = 0, iLen = a.length; i < iLen; i++) {
  2123. // Check if we are dealing with special notation
  2124. arrayNotation = a[i].match(__reArray);
  2125. funcNotation = a[i].match(__reFn);
  2126. if (arrayNotation) {
  2127. // Array notation
  2128. a[i] = a[i].replace(__reArray, '');
  2129. // Condition allows simply [] to be passed in
  2130. if (a[i] !== "") {
  2131. data = data[a[i]];
  2132. }
  2133. out = [];
  2134. // Get the remainder of the nested object to get
  2135. a.splice(0, i + 1);
  2136. innerSrc = a.join('.');
  2137. // Traverse each entry in the array getting the properties requested
  2138. if ($.isArray(data)) {
  2139. for (var j = 0, jLen = data.length; j < jLen; j++) {
  2140. out.push(fetchData(data[j], type, innerSrc));
  2141. }
  2142. }
  2143. // If a string is given in between the array notation indicators, that
  2144. // is used to join the strings together, otherwise an array is returned
  2145. var join = arrayNotation[0].substring(1, arrayNotation[0].length - 1);
  2146. data = (join === "") ? out : out.join(join);
  2147. // The inner call to fetchData has already traversed through the remainder
  2148. // of the source requested, so we exit from the loop
  2149. break;
  2150. } else if (funcNotation) {
  2151. // Function call
  2152. a[i] = a[i].replace(__reFn, '');
  2153. data = data[a[i]]();
  2154. continue;
  2155. }
  2156. if (data === null || data[a[i]] === undefined) {
  2157. return undefined;
  2158. }
  2159. data = data[a[i]];
  2160. }
  2161. }
  2162. return data;
  2163. };
  2164. return function(data, type) { // row and meta also passed, but not used
  2165. return fetchData(data, type, mSource);
  2166. };
  2167. } else {
  2168. /* Array or flat object mapping */
  2169. return function(data, type) { // row and meta also passed, but not used
  2170. return data[mSource];
  2171. };
  2172. }
  2173. }
  2174. /**
  2175. * Return a function that can be used to set data from a source object, taking
  2176. * into account the ability to use nested objects as a source
  2177. * @param {string|int|function} mSource The data source for the object
  2178. * @returns {function} Data set function
  2179. * @memberof DataTable#oApi
  2180. */
  2181. function _fnSetObjectDataFn(mSource) {
  2182. if ($.isPlainObject(mSource)) {
  2183. /* Unlike get, only the underscore (global) option is used for for
  2184. * setting data since we don't know the type here. This is why an object
  2185. * option is not documented for `mData` (which is read/write), but it is
  2186. * for `mRender` which is read only.
  2187. */
  2188. return _fnSetObjectDataFn(mSource._);
  2189. } else if (mSource === null) {
  2190. /* Nothing to do when the data source is null */
  2191. return function() {};
  2192. } else if (typeof mSource === 'function') {
  2193. return function(data, val, meta) {
  2194. mSource(data, 'set', val, meta);
  2195. };
  2196. } else if (typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  2197. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1)) {
  2198. /* Like the get, we need to get data from a nested object */
  2199. var setData = function(data, val, src) {
  2200. var a = _fnSplitObjNotation(src),
  2201. b;
  2202. var aLast = a[a.length - 1];
  2203. var arrayNotation, funcNotation, o, innerSrc;
  2204. for (var i = 0, iLen = a.length - 1; i < iLen; i++) {
  2205. // Check if we are dealing with an array notation request
  2206. arrayNotation = a[i].match(__reArray);
  2207. funcNotation = a[i].match(__reFn);
  2208. if (arrayNotation) {
  2209. a[i] = a[i].replace(__reArray, '');
  2210. data[a[i]] = [];
  2211. // Get the remainder of the nested object to set so we can recurse
  2212. b = a.slice();
  2213. b.splice(0, i + 1);
  2214. innerSrc = b.join('.');
  2215. // Traverse each entry in the array setting the properties requested
  2216. if ($.isArray(val)) {
  2217. for (var j = 0, jLen = val.length; j < jLen; j++) {
  2218. o = {};
  2219. setData(o, val[j], innerSrc);
  2220. data[a[i]].push(o);
  2221. }
  2222. } else {
  2223. // We've been asked to save data to an array, but it
  2224. // isn't array data to be saved. Best that can be done
  2225. // is to just save the value.
  2226. data[a[i]] = val;
  2227. }
  2228. // The inner call to setData has already traversed through the remainder
  2229. // of the source and has set the data, thus we can exit here
  2230. return;
  2231. } else if (funcNotation) {
  2232. // Function call
  2233. a[i] = a[i].replace(__reFn, '');
  2234. data = data[a[i]](val);
  2235. }
  2236. // If the nested object doesn't currently exist - since we are
  2237. // trying to set the value - create it
  2238. if (data[a[i]] === null || data[a[i]] === undefined) {
  2239. data[a[i]] = {};
  2240. }
  2241. data = data[a[i]];
  2242. }
  2243. // Last item in the input - i.e, the actual set
  2244. if (aLast.match(__reFn)) {
  2245. // Function call
  2246. data = data[aLast.replace(__reFn, '')](val);
  2247. } else {
  2248. // If array notation is used, we just want to strip it and use the property name
  2249. // and assign the value. If it isn't used, then we get the result we want anyway
  2250. data[aLast.replace(__reArray, '')] = val;
  2251. }
  2252. };
  2253. return function(data, val) { // meta is also passed in, but not used
  2254. return setData(data, val, mSource);
  2255. };
  2256. } else {
  2257. /* Array or flat object mapping */
  2258. return function(data, val) { // meta is also passed in, but not used
  2259. data[mSource] = val;
  2260. };
  2261. }
  2262. }
  2263. /**
  2264. * Return an array with the full table data
  2265. * @param {object} oSettings dataTables settings object
  2266. * @returns array {array} aData Master data array
  2267. * @memberof DataTable#oApi
  2268. */
  2269. function _fnGetDataMaster(settings) {
  2270. return _pluck(settings.aoData, '_aData');
  2271. }
  2272. /**
  2273. * Nuke the table
  2274. * @param {object} oSettings dataTables settings object
  2275. * @memberof DataTable#oApi
  2276. */
  2277. function _fnClearTable(settings) {
  2278. settings.aoData.length = 0;
  2279. settings.aiDisplayMaster.length = 0;
  2280. settings.aiDisplay.length = 0;
  2281. settings.aIds = {};
  2282. }
  2283. /**
  2284. * Take an array of integers (index array) and remove a target integer (value - not
  2285. * the key!)
  2286. * @param {array} a Index array to target
  2287. * @param {int} iTarget value to find
  2288. * @memberof DataTable#oApi
  2289. */
  2290. function _fnDeleteIndex(a, iTarget, splice) {
  2291. var iTargetIndex = -1;
  2292. for (var i = 0, iLen = a.length; i < iLen; i++) {
  2293. if (a[i] == iTarget) {
  2294. iTargetIndex = i;
  2295. } else if (a[i] > iTarget) {
  2296. a[i]--;
  2297. }
  2298. }
  2299. if (iTargetIndex != -1 && splice === undefined) {
  2300. a.splice(iTargetIndex, 1);
  2301. }
  2302. }
  2303. /**
  2304. * Mark cached data as invalid such that a re-read of the data will occur when
  2305. * the cached data is next requested. Also update from the data source object.
  2306. *
  2307. * @param {object} settings DataTables settings object
  2308. * @param {int} rowIdx Row index to invalidate
  2309. * @param {string} [src] Source to invalidate from: undefined, 'auto', 'dom'
  2310. * or 'data'
  2311. * @param {int} [colIdx] Column index to invalidate. If undefined the whole
  2312. * row will be invalidated
  2313. * @memberof DataTable#oApi
  2314. *
  2315. * @todo For the modularisation of v1.11 this will need to become a callback, so
  2316. * the sort and filter methods can subscribe to it. That will required
  2317. * initialisation options for sorting, which is why it is not already baked in
  2318. */
  2319. function _fnInvalidate(settings, rowIdx, src, colIdx) {
  2320. var row = settings.aoData[rowIdx];
  2321. var i, ien;
  2322. var cellWrite = function(cell, col) {
  2323. // This is very frustrating, but in IE if you just write directly
  2324. // to innerHTML, and elements that are overwritten are GC'ed,
  2325. // even if there is a reference to them elsewhere
  2326. while (cell.childNodes.length) {
  2327. cell.removeChild(cell.firstChild);
  2328. }
  2329. cell.innerHTML = _fnGetCellData(settings, rowIdx, col, 'display');
  2330. };
  2331. // Are we reading last data from DOM or the data object?
  2332. if (src === 'dom' || ((!src || src === 'auto') && row.src === 'dom')) {
  2333. // Read the data from the DOM
  2334. row._aData = _fnGetRowElements(
  2335. settings, row, colIdx, colIdx === undefined ? undefined : row._aData
  2336. )
  2337. .data;
  2338. } else {
  2339. // Reading from data object, update the DOM
  2340. var cells = row.anCells;
  2341. if (cells) {
  2342. if (colIdx !== undefined) {
  2343. cellWrite(cells[colIdx], colIdx);
  2344. } else {
  2345. for (i = 0, ien = cells.length; i < ien; i++) {
  2346. cellWrite(cells[i], i);
  2347. }
  2348. }
  2349. }
  2350. }
  2351. // For both row and cell invalidation, the cached data for sorting and
  2352. // filtering is nulled out
  2353. row._aSortData = null;
  2354. row._aFilterData = null;
  2355. // Invalidate the type for a specific column (if given) or all columns since
  2356. // the data might have changed
  2357. var cols = settings.aoColumns;
  2358. if (colIdx !== undefined) {
  2359. cols[colIdx].sType = null;
  2360. } else {
  2361. for (i = 0, ien = cols.length; i < ien; i++) {
  2362. cols[i].sType = null;
  2363. }
  2364. // Update DataTables special `DT_*` attributes for the row
  2365. _fnRowAttributes(settings, row);
  2366. }
  2367. }
  2368. /**
  2369. * Build a data source object from an HTML row, reading the contents of the
  2370. * cells that are in the row.
  2371. *
  2372. * @param {object} settings DataTables settings object
  2373. * @param {node|object} TR element from which to read data or existing row
  2374. * object from which to re-read the data from the cells
  2375. * @param {int} [colIdx] Optional column index
  2376. * @param {array|object} [d] Data source object. If `colIdx` is given then this
  2377. * parameter should also be given and will be used to write the data into.
  2378. * Only the column in question will be written
  2379. * @returns {object} Object with two parameters: `data` the data read, in
  2380. * document order, and `cells` and array of nodes (they can be useful to the
  2381. * caller, so rather than needing a second traversal to get them, just return
  2382. * them from here).
  2383. * @memberof DataTable#oApi
  2384. */
  2385. function _fnGetRowElements(settings, row, colIdx, d) {
  2386. var
  2387. tds = [],
  2388. td = row.firstChild,
  2389. name, col, o, i = 0,
  2390. contents,
  2391. columns = settings.aoColumns,
  2392. objectRead = settings._rowReadObject;
  2393. // Allow the data object to be passed in, or construct
  2394. d = d !== undefined ?
  2395. d :
  2396. objectRead ? {} : [];
  2397. var attr = function(str, td) {
  2398. if (typeof str === 'string') {
  2399. var idx = str.indexOf('@');
  2400. if (idx !== -1) {
  2401. var attr = str.substring(idx + 1);
  2402. var setter = _fnSetObjectDataFn(str);
  2403. setter(d, td.getAttribute(attr));
  2404. }
  2405. }
  2406. };
  2407. // Read data from a cell and store into the data object
  2408. var cellProcess = function(cell) {
  2409. if (colIdx === undefined || colIdx === i) {
  2410. col = columns[i];
  2411. contents = $.trim(cell.innerHTML);
  2412. if (col && col._bAttrSrc) {
  2413. var setter = _fnSetObjectDataFn(col.mData._);
  2414. setter(d, contents);
  2415. attr(col.mData.sort, cell);
  2416. attr(col.mData.type, cell);
  2417. attr(col.mData.filter, cell);
  2418. } else {
  2419. // Depending on the `data` option for the columns the data can
  2420. // be read to either an object or an array.
  2421. if (objectRead) {
  2422. if (!col._setter) {
  2423. // Cache the setter function
  2424. col._setter = _fnSetObjectDataFn(col.mData);
  2425. }
  2426. col._setter(d, contents);
  2427. } else {
  2428. d[i] = contents;
  2429. }
  2430. }
  2431. }
  2432. i++;
  2433. };
  2434. if (td) {
  2435. // `tr` element was passed in
  2436. while (td) {
  2437. name = td.nodeName.toUpperCase();
  2438. if (name == "TD" || name == "TH") {
  2439. cellProcess(td);
  2440. tds.push(td);
  2441. }
  2442. td = td.nextSibling;
  2443. }
  2444. } else {
  2445. // Existing row object passed in
  2446. tds = row.anCells;
  2447. for (var j = 0, jen = tds.length; j < jen; j++) {
  2448. cellProcess(tds[j]);
  2449. }
  2450. }
  2451. // Read the ID from the DOM if present
  2452. var rowNode = row.firstChild ? row : row.nTr;
  2453. if (rowNode) {
  2454. var id = rowNode.getAttribute('id');
  2455. if (id) {
  2456. _fnSetObjectDataFn(settings.rowId)(d, id);
  2457. }
  2458. }
  2459. return {
  2460. data: d,
  2461. cells: tds
  2462. };
  2463. }
  2464. /**
  2465. * Create a new TR element (and it's TD children) for a row
  2466. * @param {object} oSettings dataTables settings object
  2467. * @param {int} iRow Row to consider
  2468. * @param {node} [nTrIn] TR element to add to the table - optional. If not given,
  2469. * DataTables will create a row automatically
  2470. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  2471. * if nTr is.
  2472. * @memberof DataTable#oApi
  2473. */
  2474. function _fnCreateTr(oSettings, iRow, nTrIn, anTds) {
  2475. var
  2476. row = oSettings.aoData[iRow],
  2477. rowData = row._aData,
  2478. cells = [],
  2479. nTr, nTd, oCol,
  2480. i, iLen;
  2481. if (row.nTr === null) {
  2482. nTr = nTrIn || document.createElement('tr');
  2483. row.nTr = nTr;
  2484. row.anCells = cells;
  2485. /* Use a private property on the node to allow reserve mapping from the node
  2486. * to the aoData array for fast look up
  2487. */
  2488. nTr._DT_RowIndex = iRow;
  2489. /* Special parameters can be given by the data source to be used on the row */
  2490. _fnRowAttributes(oSettings, row);
  2491. /* Process each column */
  2492. for (i = 0, iLen = oSettings.aoColumns.length; i < iLen; i++) {
  2493. oCol = oSettings.aoColumns[i];
  2494. nTd = nTrIn ? anTds[i] : document.createElement(oCol.sCellType);
  2495. nTd._DT_CellIndex = {
  2496. row: iRow,
  2497. column: i
  2498. };
  2499. cells.push(nTd);
  2500. // Need to create the HTML if new, or if a rendering function is defined
  2501. if ((!nTrIn || oCol.mRender || oCol.mData !== i) &&
  2502. (!$.isPlainObject(oCol.mData) || oCol.mData._ !== i + '.display')
  2503. ) {
  2504. nTd.innerHTML = _fnGetCellData(oSettings, iRow, i, 'display');
  2505. }
  2506. /* Add user defined class */
  2507. if (oCol.sClass) {
  2508. nTd.className += ' ' + oCol.sClass;
  2509. }
  2510. // Visibility - add or remove as required
  2511. if (oCol.bVisible && !nTrIn) {
  2512. nTr.appendChild(nTd);
  2513. } else if (!oCol.bVisible && nTrIn) {
  2514. nTd.parentNode.removeChild(nTd);
  2515. }
  2516. if (oCol.fnCreatedCell) {
  2517. oCol.fnCreatedCell.call(oSettings.oInstance,
  2518. nTd, _fnGetCellData(oSettings, iRow, i), rowData, iRow, i
  2519. );
  2520. }
  2521. }
  2522. _fnCallbackFire(oSettings, 'aoRowCreatedCallback', null, [nTr, rowData, iRow]);
  2523. }
  2524. // Remove once webkit bug 131819 and Chromium bug 365619 have been resolved
  2525. // and deployed
  2526. row.nTr.setAttribute('role', 'row');
  2527. }
  2528. /**
  2529. * Add attributes to a row based on the special `DT_*` parameters in a data
  2530. * source object.
  2531. * @param {object} settings DataTables settings object
  2532. * @param {object} DataTables row object for the row to be modified
  2533. * @memberof DataTable#oApi
  2534. */
  2535. function _fnRowAttributes(settings, row) {
  2536. var tr = row.nTr;
  2537. var data = row._aData;
  2538. if (tr) {
  2539. var id = settings.rowIdFn(data);
  2540. if (id) {
  2541. tr.id = id;
  2542. }
  2543. if (data.DT_RowClass) {
  2544. // Remove any classes added by DT_RowClass before
  2545. var a = data.DT_RowClass.split(' ');
  2546. row.__rowc = row.__rowc ?
  2547. _unique(row.__rowc.concat(a)) :
  2548. a;
  2549. $(tr)
  2550. .removeClass(row.__rowc.join(' '))
  2551. .addClass(data.DT_RowClass);
  2552. }
  2553. if (data.DT_RowAttr) {
  2554. $(tr).attr(data.DT_RowAttr);
  2555. }
  2556. if (data.DT_RowData) {
  2557. $(tr).data(data.DT_RowData);
  2558. }
  2559. }
  2560. }
  2561. /**
  2562. * Create the HTML header for the table
  2563. * @param {object} oSettings dataTables settings object
  2564. * @memberof DataTable#oApi
  2565. */
  2566. function _fnBuildHead(oSettings) {
  2567. var i, ien, cell, row, column;
  2568. var thead = oSettings.nTHead;
  2569. var tfoot = oSettings.nTFoot;
  2570. var createHeader = $('th, td', thead).length === 0;
  2571. var classes = oSettings.oClasses;
  2572. var columns = oSettings.aoColumns;
  2573. if (createHeader) {
  2574. row = $('<tr/>').appendTo(thead);
  2575. }
  2576. for (i = 0, ien = columns.length; i < ien; i++) {
  2577. column = columns[i];
  2578. cell = $(column.nTh).addClass(column.sClass);
  2579. if (createHeader) {
  2580. cell.appendTo(row);
  2581. }
  2582. // 1.11 move into sorting
  2583. if (oSettings.oFeatures.bSort) {
  2584. cell.addClass(column.sSortingClass);
  2585. if (column.bSortable !== false) {
  2586. cell
  2587. .attr('tabindex', oSettings.iTabIndex)
  2588. .attr('aria-controls', oSettings.sTableId);
  2589. _fnSortAttachListener(oSettings, column.nTh, i);
  2590. }
  2591. }
  2592. if (column.sTitle != cell[0].innerHTML) {
  2593. cell.html(column.sTitle);
  2594. }
  2595. _fnRenderer(oSettings, 'header')(
  2596. oSettings, cell, column, classes
  2597. );
  2598. }
  2599. if (createHeader) {
  2600. _fnDetectHeader(oSettings.aoHeader, thead);
  2601. }
  2602. /* ARIA role for the rows */
  2603. $(thead).find('>tr').attr('role', 'row');
  2604. /* Deal with the footer - add classes if required */
  2605. $(thead).find('>tr>th, >tr>td').addClass(classes.sHeaderTH);
  2606. $(tfoot).find('>tr>th, >tr>td').addClass(classes.sFooterTH);
  2607. // Cache the footer cells. Note that we only take the cells from the first
  2608. // row in the footer. If there is more than one row the user wants to
  2609. // interact with, they need to use the table().foot() method. Note also this
  2610. // allows cells to be used for multiple columns using colspan
  2611. if (tfoot !== null) {
  2612. var cells = oSettings.aoFooter[0];
  2613. for (i = 0, ien = cells.length; i < ien; i++) {
  2614. column = columns[i];
  2615. column.nTf = cells[i].cell;
  2616. if (column.sClass) {
  2617. $(column.nTf).addClass(column.sClass);
  2618. }
  2619. }
  2620. }
  2621. }
  2622. /**
  2623. * Draw the header (or footer) element based on the column visibility states. The
  2624. * methodology here is to use the layout array from _fnDetectHeader, modified for
  2625. * the instantaneous column visibility, to construct the new layout. The grid is
  2626. * traversed over cell at a time in a rows x columns grid fashion, although each
  2627. * cell insert can cover multiple elements in the grid - which is tracks using the
  2628. * aApplied array. Cell inserts in the grid will only occur where there isn't
  2629. * already a cell in that position.
  2630. * @param {object} oSettings dataTables settings object
  2631. * @param array {objects} aoSource Layout array from _fnDetectHeader
  2632. * @param {boolean} [bIncludeHidden=false] If true then include the hidden columns in the calc,
  2633. * @memberof DataTable#oApi
  2634. */
  2635. function _fnDrawHead(oSettings, aoSource, bIncludeHidden) {
  2636. var i, iLen, j, jLen, k, kLen, n, nLocalTr;
  2637. var aoLocal = [];
  2638. var aApplied = [];
  2639. var iColumns = oSettings.aoColumns.length;
  2640. var iRowspan, iColspan;
  2641. if (!aoSource) {
  2642. return;
  2643. }
  2644. if (bIncludeHidden === undefined) {
  2645. bIncludeHidden = false;
  2646. }
  2647. /* Make a copy of the master layout array, but without the visible columns in it */
  2648. for (i = 0, iLen = aoSource.length; i < iLen; i++) {
  2649. aoLocal[i] = aoSource[i].slice();
  2650. aoLocal[i].nTr = aoSource[i].nTr;
  2651. /* Remove any columns which are currently hidden */
  2652. for (j = iColumns - 1; j >= 0; j--) {
  2653. if (!oSettings.aoColumns[j].bVisible && !bIncludeHidden) {
  2654. aoLocal[i].splice(j, 1);
  2655. }
  2656. }
  2657. /* Prep the applied array - it needs an element for each row */
  2658. aApplied.push([]);
  2659. }
  2660. for (i = 0, iLen = aoLocal.length; i < iLen; i++) {
  2661. nLocalTr = aoLocal[i].nTr;
  2662. /* All cells are going to be replaced, so empty out the row */
  2663. if (nLocalTr) {
  2664. while ((n = nLocalTr.firstChild)) {
  2665. nLocalTr.removeChild(n);
  2666. }
  2667. }
  2668. for (j = 0, jLen = aoLocal[i].length; j < jLen; j++) {
  2669. iRowspan = 1;
  2670. iColspan = 1;
  2671. /* Check to see if there is already a cell (row/colspan) covering our target
  2672. * insert point. If there is, then there is nothing to do.
  2673. */
  2674. if (aApplied[i][j] === undefined) {
  2675. nLocalTr.appendChild(aoLocal[i][j].cell);
  2676. aApplied[i][j] = 1;
  2677. /* Expand the cell to cover as many rows as needed */
  2678. while (aoLocal[i + iRowspan] !== undefined &&
  2679. aoLocal[i][j].cell == aoLocal[i + iRowspan][j].cell) {
  2680. aApplied[i + iRowspan][j] = 1;
  2681. iRowspan++;
  2682. }
  2683. /* Expand the cell to cover as many columns as needed */
  2684. while (aoLocal[i][j + iColspan] !== undefined &&
  2685. aoLocal[i][j].cell == aoLocal[i][j + iColspan].cell) {
  2686. /* Must update the applied array over the rows for the columns */
  2687. for (k = 0; k < iRowspan; k++) {
  2688. aApplied[i + k][j + iColspan] = 1;
  2689. }
  2690. iColspan++;
  2691. }
  2692. /* Do the actual expansion in the DOM */
  2693. $(aoLocal[i][j].cell)
  2694. .attr('rowspan', iRowspan)
  2695. .attr('colspan', iColspan);
  2696. }
  2697. }
  2698. }
  2699. }
  2700. /**
  2701. * Insert the required TR nodes into the table for display
  2702. * @param {object} oSettings dataTables settings object
  2703. * @memberof DataTable#oApi
  2704. */
  2705. function _fnDraw(oSettings) {
  2706. /* Provide a pre-callback function which can be used to cancel the draw is false is returned */
  2707. var aPreDraw = _fnCallbackFire(oSettings, 'aoPreDrawCallback', 'preDraw', [oSettings]);
  2708. if ($.inArray(false, aPreDraw) !== -1) {
  2709. _fnProcessingDisplay(oSettings, false);
  2710. return;
  2711. }
  2712. var i, iLen, n;
  2713. var anRows = [];
  2714. var iRowCount = 0;
  2715. var asStripeClasses = oSettings.asStripeClasses;
  2716. var iStripes = asStripeClasses.length;
  2717. var iOpenRows = oSettings.aoOpenRows.length;
  2718. var oLang = oSettings.oLanguage;
  2719. var iInitDisplayStart = oSettings.iInitDisplayStart;
  2720. var bServerSide = _fnDataSource(oSettings) == 'ssp';
  2721. var aiDisplay = oSettings.aiDisplay;
  2722. oSettings.bDrawing = true;
  2723. /* Check and see if we have an initial draw position from state saving */
  2724. if (iInitDisplayStart !== undefined && iInitDisplayStart !== -1) {
  2725. oSettings._iDisplayStart = bServerSide ?
  2726. iInitDisplayStart :
  2727. iInitDisplayStart >= oSettings.fnRecordsDisplay() ?
  2728. 0 :
  2729. iInitDisplayStart;
  2730. oSettings.iInitDisplayStart = -1;
  2731. }
  2732. var iDisplayStart = oSettings._iDisplayStart;
  2733. var iDisplayEnd = oSettings.fnDisplayEnd();
  2734. /* Server-side processing draw intercept */
  2735. if (oSettings.bDeferLoading) {
  2736. oSettings.bDeferLoading = false;
  2737. oSettings.iDraw++;
  2738. _fnProcessingDisplay(oSettings, false);
  2739. } else if (!bServerSide) {
  2740. oSettings.iDraw++;
  2741. } else if (!oSettings.bDestroying && !_fnAjaxUpdate(oSettings)) {
  2742. return;
  2743. }
  2744. if (aiDisplay.length !== 0) {
  2745. var iStart = bServerSide ? 0 : iDisplayStart;
  2746. var iEnd = bServerSide ? oSettings.aoData.length : iDisplayEnd;
  2747. for (var j = iStart; j < iEnd; j++) {
  2748. var iDataIndex = aiDisplay[j];
  2749. var aoData = oSettings.aoData[iDataIndex];
  2750. if (aoData.nTr === null) {
  2751. _fnCreateTr(oSettings, iDataIndex);
  2752. }
  2753. var nRow = aoData.nTr;
  2754. /* Remove the old striping classes and then add the new one */
  2755. if (iStripes !== 0) {
  2756. var sStripe = asStripeClasses[iRowCount % iStripes];
  2757. if (aoData._sRowStripe != sStripe) {
  2758. $(nRow).removeClass(aoData._sRowStripe).addClass(sStripe);
  2759. aoData._sRowStripe = sStripe;
  2760. }
  2761. }
  2762. // Row callback functions - might want to manipulate the row
  2763. // iRowCount and j are not currently documented. Are they at all
  2764. // useful?
  2765. _fnCallbackFire(oSettings, 'aoRowCallback', null, [nRow, aoData._aData, iRowCount, j]);
  2766. anRows.push(nRow);
  2767. iRowCount++;
  2768. }
  2769. } else {
  2770. /* Table is empty - create a row with an empty message in it */
  2771. var sZero = oLang.sZeroRecords;
  2772. if (oSettings.iDraw == 1 && _fnDataSource(oSettings) == 'ajax') {
  2773. sZero = oLang.sLoadingRecords;
  2774. } else if (oLang.sEmptyTable && oSettings.fnRecordsTotal() === 0) {
  2775. sZero = oLang.sEmptyTable;
  2776. }
  2777. anRows[0] = $('<tr/>', {
  2778. 'class': iStripes ? asStripeClasses[0] : ''
  2779. })
  2780. .append($('<td />', {
  2781. 'valign': 'top',
  2782. 'colSpan': _fnVisbleColumns(oSettings),
  2783. 'class': oSettings.oClasses.sRowEmpty
  2784. }).html(sZero))[0];
  2785. }
  2786. /* Header and footer callbacks */
  2787. _fnCallbackFire(oSettings, 'aoHeaderCallback', 'header', [$(oSettings.nTHead).children('tr')[0],
  2788. _fnGetDataMaster(oSettings), iDisplayStart, iDisplayEnd, aiDisplay
  2789. ]);
  2790. _fnCallbackFire(oSettings, 'aoFooterCallback', 'footer', [$(oSettings.nTFoot).children('tr')[0],
  2791. _fnGetDataMaster(oSettings), iDisplayStart, iDisplayEnd, aiDisplay
  2792. ]);
  2793. var body = $(oSettings.nTBody);
  2794. body.children().detach();
  2795. body.append($(anRows));
  2796. /* Call all required callback functions for the end of a draw */
  2797. _fnCallbackFire(oSettings, 'aoDrawCallback', 'draw', [oSettings]);
  2798. /* Draw is complete, sorting and filtering must be as well */
  2799. oSettings.bSorted = false;
  2800. oSettings.bFiltered = false;
  2801. oSettings.bDrawing = false;
  2802. }
  2803. /**
  2804. * Redraw the table - taking account of the various features which are enabled
  2805. * @param {object} oSettings dataTables settings object
  2806. * @param {boolean} [holdPosition] Keep the current paging position. By default
  2807. * the paging is reset to the first page
  2808. * @memberof DataTable#oApi
  2809. */
  2810. function _fnReDraw(settings, holdPosition) {
  2811. var
  2812. features = settings.oFeatures,
  2813. sort = features.bSort,
  2814. filter = features.bFilter;
  2815. if (sort) {
  2816. _fnSort(settings);
  2817. }
  2818. if (filter) {
  2819. _fnFilterComplete(settings, settings.oPreviousSearch);
  2820. } else {
  2821. // No filtering, so we want to just use the display master
  2822. settings.aiDisplay = settings.aiDisplayMaster.slice();
  2823. }
  2824. if (holdPosition !== true) {
  2825. settings._iDisplayStart = 0;
  2826. }
  2827. // Let any modules know about the draw hold position state (used by
  2828. // scrolling internally)
  2829. settings._drawHold = holdPosition;
  2830. _fnDraw(settings);
  2831. settings._drawHold = false;
  2832. }
  2833. /**
  2834. * Add the options to the page HTML for the table
  2835. * @param {object} oSettings dataTables settings object
  2836. * @memberof DataTable#oApi
  2837. */
  2838. function _fnAddOptionsHtml(oSettings) {
  2839. var classes = oSettings.oClasses;
  2840. var table = $(oSettings.nTable);
  2841. var holding = $('<div/>').insertBefore(table); // Holding element for speed
  2842. var features = oSettings.oFeatures;
  2843. // All DataTables are wrapped in a div
  2844. var insert = $('<div/>', {
  2845. id: oSettings.sTableId + '_wrapper',
  2846. 'class': classes.sWrapper + (oSettings.nTFoot ? '' : ' ' + classes.sNoFooter)
  2847. });
  2848. oSettings.nHolding = holding[0];
  2849. oSettings.nTableWrapper = insert[0];
  2850. oSettings.nTableReinsertBefore = oSettings.nTable.nextSibling;
  2851. /* Loop over the user set positioning and place the elements as needed */
  2852. var aDom = oSettings.sDom.split('');
  2853. var featureNode, cOption, nNewNode, cNext, sAttr, j;
  2854. for (var i = 0; i < aDom.length; i++) {
  2855. featureNode = null;
  2856. cOption = aDom[i];
  2857. if (cOption == '<') {
  2858. /* New container div */
  2859. nNewNode = $('<div/>')[0];
  2860. /* Check to see if we should append an id and/or a class name to the container */
  2861. cNext = aDom[i + 1];
  2862. if (cNext == "'" || cNext == '"') {
  2863. sAttr = "";
  2864. j = 2;
  2865. while (aDom[i + j] != cNext) {
  2866. sAttr += aDom[i + j];
  2867. j++;
  2868. }
  2869. /* Replace jQuery UI constants @todo depreciated */
  2870. if (sAttr == "H") {
  2871. sAttr = classes.sJUIHeader;
  2872. } else if (sAttr == "F") {
  2873. sAttr = classes.sJUIFooter;
  2874. }
  2875. /* The attribute can be in the format of "#id.class", "#id" or "class" This logic
  2876. * breaks the string into parts and applies them as needed
  2877. */
  2878. if (sAttr.indexOf('.') != -1) {
  2879. var aSplit = sAttr.split('.');
  2880. nNewNode.id = aSplit[0].substr(1, aSplit[0].length - 1);
  2881. nNewNode.className = aSplit[1];
  2882. } else if (sAttr.charAt(0) == "#") {
  2883. nNewNode.id = sAttr.substr(1, sAttr.length - 1);
  2884. } else {
  2885. nNewNode.className = sAttr;
  2886. }
  2887. i += j; /* Move along the position array */
  2888. }
  2889. insert.append(nNewNode);
  2890. insert = $(nNewNode);
  2891. } else if (cOption == '>') {
  2892. /* End container div */
  2893. insert = insert.parent();
  2894. }
  2895. // @todo Move options into their own plugins?
  2896. else if (cOption == 'l' && features.bPaginate && features.bLengthChange) {
  2897. /* Length */
  2898. featureNode = _fnFeatureHtmlLength(oSettings);
  2899. } else if (cOption == 'f' && features.bFilter) {
  2900. /* Filter */
  2901. featureNode = _fnFeatureHtmlFilter(oSettings);
  2902. } else if (cOption == 'r' && features.bProcessing) {
  2903. /* pRocessing */
  2904. featureNode = _fnFeatureHtmlProcessing(oSettings);
  2905. } else if (cOption == 't') {
  2906. /* Table */
  2907. featureNode = _fnFeatureHtmlTable(oSettings);
  2908. } else if (cOption == 'i' && features.bInfo) {
  2909. /* Info */
  2910. featureNode = _fnFeatureHtmlInfo(oSettings);
  2911. } else if (cOption == 'p' && features.bPaginate) {
  2912. /* Pagination */
  2913. featureNode = _fnFeatureHtmlPaginate(oSettings);
  2914. } else if (DataTable.ext.feature.length !== 0) {
  2915. /* Plug-in features */
  2916. var aoFeatures = DataTable.ext.feature;
  2917. for (var k = 0, kLen = aoFeatures.length; k < kLen; k++) {
  2918. if (cOption == aoFeatures[k].cFeature) {
  2919. featureNode = aoFeatures[k].fnInit(oSettings);
  2920. break;
  2921. }
  2922. }
  2923. }
  2924. /* Add to the 2D features array */
  2925. if (featureNode) {
  2926. var aanFeatures = oSettings.aanFeatures;
  2927. if (!aanFeatures[cOption]) {
  2928. aanFeatures[cOption] = [];
  2929. }
  2930. aanFeatures[cOption].push(featureNode);
  2931. insert.append(featureNode);
  2932. }
  2933. }
  2934. /* Built our DOM structure - replace the holding div with what we want */
  2935. holding.replaceWith(insert);
  2936. oSettings.nHolding = null;
  2937. }
  2938. /**
  2939. * Use the DOM source to create up an array of header cells. The idea here is to
  2940. * create a layout grid (array) of rows x columns, which contains a reference
  2941. * to the cell that that point in the grid (regardless of col/rowspan), such that
  2942. * any column / row could be removed and the new grid constructed
  2943. * @param array {object} aLayout Array to store the calculated layout in
  2944. * @param {node} nThead The header/footer element for the table
  2945. * @memberof DataTable#oApi
  2946. */
  2947. function _fnDetectHeader(aLayout, nThead) {
  2948. var nTrs = $(nThead).children('tr');
  2949. var nTr, nCell;
  2950. var i, k, l, iLen, jLen, iColShifted, iColumn, iColspan, iRowspan;
  2951. var bUnique;
  2952. var fnShiftCol = function(a, i, j) {
  2953. var k = a[i];
  2954. while (k[j]) {
  2955. j++;
  2956. }
  2957. return j;
  2958. };
  2959. aLayout.splice(0, aLayout.length);
  2960. /* We know how many rows there are in the layout - so prep it */
  2961. for (i = 0, iLen = nTrs.length; i < iLen; i++) {
  2962. aLayout.push([]);
  2963. }
  2964. /* Calculate a layout array */
  2965. for (i = 0, iLen = nTrs.length; i < iLen; i++) {
  2966. nTr = nTrs[i];
  2967. iColumn = 0;
  2968. /* For every cell in the row... */
  2969. nCell = nTr.firstChild;
  2970. while (nCell) {
  2971. if (nCell.nodeName.toUpperCase() == "TD" ||
  2972. nCell.nodeName.toUpperCase() == "TH") {
  2973. /* Get the col and rowspan attributes from the DOM and sanitise them */
  2974. iColspan = nCell.getAttribute('colspan') * 1;
  2975. iRowspan = nCell.getAttribute('rowspan') * 1;
  2976. iColspan = (!iColspan || iColspan === 0 || iColspan === 1) ? 1 : iColspan;
  2977. iRowspan = (!iRowspan || iRowspan === 0 || iRowspan === 1) ? 1 : iRowspan;
  2978. /* There might be colspan cells already in this row, so shift our target
  2979. * accordingly
  2980. */
  2981. iColShifted = fnShiftCol(aLayout, i, iColumn);
  2982. /* Cache calculation for unique columns */
  2983. bUnique = iColspan === 1 ? true : false;
  2984. /* If there is col / rowspan, copy the information into the layout grid */
  2985. for (l = 0; l < iColspan; l++) {
  2986. for (k = 0; k < iRowspan; k++) {
  2987. aLayout[i + k][iColShifted + l] = {
  2988. "cell": nCell,
  2989. "unique": bUnique
  2990. };
  2991. aLayout[i + k].nTr = nTr;
  2992. }
  2993. }
  2994. }
  2995. nCell = nCell.nextSibling;
  2996. }
  2997. }
  2998. }
  2999. /**
  3000. * Get an array of unique th elements, one for each column
  3001. * @param {object} oSettings dataTables settings object
  3002. * @param {node} nHeader automatically detect the layout from this node - optional
  3003. * @param {array} aLayout thead/tfoot layout from _fnDetectHeader - optional
  3004. * @returns array {node} aReturn list of unique th's
  3005. * @memberof DataTable#oApi
  3006. */
  3007. function _fnGetUniqueThs(oSettings, nHeader, aLayout) {
  3008. var aReturn = [];
  3009. if (!aLayout) {
  3010. aLayout = oSettings.aoHeader;
  3011. if (nHeader) {
  3012. aLayout = [];
  3013. _fnDetectHeader(aLayout, nHeader);
  3014. }
  3015. }
  3016. for (var i = 0, iLen = aLayout.length; i < iLen; i++) {
  3017. for (var j = 0, jLen = aLayout[i].length; j < jLen; j++) {
  3018. if (aLayout[i][j].unique &&
  3019. (!aReturn[j] || !oSettings.bSortCellsTop)) {
  3020. aReturn[j] = aLayout[i][j].cell;
  3021. }
  3022. }
  3023. }
  3024. return aReturn;
  3025. }
  3026. /**
  3027. * Create an Ajax call based on the table's settings, taking into account that
  3028. * parameters can have multiple forms, and backwards compatibility.
  3029. *
  3030. * @param {object} oSettings dataTables settings object
  3031. * @param {array} data Data to send to the server, required by
  3032. * DataTables - may be augmented by developer callbacks
  3033. * @param {function} fn Callback function to run when data is obtained
  3034. */
  3035. function _fnBuildAjax(oSettings, data, fn) {
  3036. // Compatibility with 1.9-, allow fnServerData and event to manipulate
  3037. _fnCallbackFire(oSettings, 'aoServerParams', 'serverParams', [data]);
  3038. // Convert to object based for 1.10+ if using the old array scheme which can
  3039. // come from server-side processing or serverParams
  3040. if (data && $.isArray(data)) {
  3041. var tmp = {};
  3042. var rbracket = /(.*?)\[\]$/;
  3043. $.each(data, function(key, val) {
  3044. var match = val.name.match(rbracket);
  3045. if (match) {
  3046. // Support for arrays
  3047. var name = match[0];
  3048. if (!tmp[name]) {
  3049. tmp[name] = [];
  3050. }
  3051. tmp[name].push(val.value);
  3052. } else {
  3053. tmp[val.name] = val.value;
  3054. }
  3055. });
  3056. data = tmp;
  3057. }
  3058. var ajaxData;
  3059. var ajax = oSettings.ajax;
  3060. var instance = oSettings.oInstance;
  3061. var callback = function(json) {
  3062. _fnCallbackFire(oSettings, null, 'xhr', [oSettings, json, oSettings.jqXHR]);
  3063. fn(json);
  3064. };
  3065. if ($.isPlainObject(ajax) && ajax.data) {
  3066. ajaxData = ajax.data;
  3067. var newData = $.isFunction(ajaxData) ?
  3068. ajaxData(data, oSettings) : // fn can manipulate data or return
  3069. ajaxData; // an object object or array to merge
  3070. // If the function returned something, use that alone
  3071. data = $.isFunction(ajaxData) && newData ?
  3072. newData :
  3073. $.extend(true, data, newData);
  3074. // Remove the data property as we've resolved it already and don't want
  3075. // jQuery to do it again (it is restored at the end of the function)
  3076. delete ajax.data;
  3077. }
  3078. var baseAjax = {
  3079. "data": data,
  3080. "success": function(json) {
  3081. var error = json.error || json.sError;
  3082. if (error) {
  3083. _fnLog(oSettings, 0, error);
  3084. }
  3085. oSettings.json = json;
  3086. callback(json);
  3087. },
  3088. "dataType": "json",
  3089. "cache": false,
  3090. "type": oSettings.sServerMethod,
  3091. "error": function(xhr, error, thrown) {
  3092. var ret = _fnCallbackFire(oSettings, null, 'xhr', [oSettings, null, oSettings.jqXHR]);
  3093. if ($.inArray(true, ret) === -1) {
  3094. if (error == "parsererror") {
  3095. _fnLog(oSettings, 0, 'Invalid JSON response', 1);
  3096. } else if (xhr.readyState === 4) {
  3097. _fnLog(oSettings, 0, 'Ajax error', 7);
  3098. }
  3099. }
  3100. _fnProcessingDisplay(oSettings, false);
  3101. }
  3102. };
  3103. // Store the data submitted for the API
  3104. oSettings.oAjaxData = data;
  3105. // Allow plug-ins and external processes to modify the data
  3106. _fnCallbackFire(oSettings, null, 'preXhr', [oSettings, data]);
  3107. if (oSettings.fnServerData) {
  3108. // DataTables 1.9- compatibility
  3109. oSettings.fnServerData.call(instance,
  3110. oSettings.sAjaxSource,
  3111. $.map(data, function(val, key) { // Need to convert back to 1.9 trad format
  3112. return {
  3113. name: key,
  3114. value: val
  3115. };
  3116. }),
  3117. callback,
  3118. oSettings
  3119. );
  3120. } else if (oSettings.sAjaxSource || typeof ajax === 'string') {
  3121. // DataTables 1.9- compatibility
  3122. oSettings.jqXHR = $.ajax($.extend(baseAjax, {
  3123. url: ajax || oSettings.sAjaxSource
  3124. }));
  3125. } else if ($.isFunction(ajax)) {
  3126. // Is a function - let the caller define what needs to be done
  3127. oSettings.jqXHR = ajax.call(instance, data, callback, oSettings);
  3128. } else {
  3129. // Object to extend the base settings
  3130. oSettings.jqXHR = $.ajax($.extend(baseAjax, ajax));
  3131. // Restore for next time around
  3132. ajax.data = ajaxData;
  3133. }
  3134. }
  3135. /**
  3136. * Update the table using an Ajax call
  3137. * @param {object} settings dataTables settings object
  3138. * @returns {boolean} Block the table drawing or not
  3139. * @memberof DataTable#oApi
  3140. */
  3141. function _fnAjaxUpdate(settings) {
  3142. if (settings.bAjaxDataGet) {
  3143. settings.iDraw++;
  3144. _fnProcessingDisplay(settings, true);
  3145. _fnBuildAjax(
  3146. settings,
  3147. _fnAjaxParameters(settings),
  3148. function(json) {
  3149. _fnAjaxUpdateDraw(settings, json);
  3150. }
  3151. );
  3152. return false;
  3153. }
  3154. return true;
  3155. }
  3156. /**
  3157. * Build up the parameters in an object needed for a server-side processing
  3158. * request. Note that this is basically done twice, is different ways - a modern
  3159. * method which is used by default in DataTables 1.10 which uses objects and
  3160. * arrays, or the 1.9- method with is name / value pairs. 1.9 method is used if
  3161. * the sAjaxSource option is used in the initialisation, or the legacyAjax
  3162. * option is set.
  3163. * @param {object} oSettings dataTables settings object
  3164. * @returns {bool} block the table drawing or not
  3165. * @memberof DataTable#oApi
  3166. */
  3167. function _fnAjaxParameters(settings) {
  3168. var
  3169. columns = settings.aoColumns,
  3170. columnCount = columns.length,
  3171. features = settings.oFeatures,
  3172. preSearch = settings.oPreviousSearch,
  3173. preColSearch = settings.aoPreSearchCols,
  3174. i, data = [],
  3175. dataProp, column, columnSearch,
  3176. sort = _fnSortFlatten(settings),
  3177. displayStart = settings._iDisplayStart,
  3178. displayLength = features.bPaginate !== false ?
  3179. settings._iDisplayLength :
  3180. -1;
  3181. var param = function(name, value) {
  3182. data.push({
  3183. 'name': name,
  3184. 'value': value
  3185. });
  3186. };
  3187. // DataTables 1.9- compatible method
  3188. param('sEcho', settings.iDraw);
  3189. param('iColumns', columnCount);
  3190. param('sColumns', _pluck(columns, 'sName').join(','));
  3191. param('iDisplayStart', displayStart);
  3192. param('iDisplayLength', displayLength);
  3193. // DataTables 1.10+ method
  3194. var d = {
  3195. draw: settings.iDraw,
  3196. columns: [],
  3197. order: [],
  3198. start: displayStart,
  3199. length: displayLength,
  3200. search: {
  3201. value: preSearch.sSearch,
  3202. regex: preSearch.bRegex
  3203. }
  3204. };
  3205. for (i = 0; i < columnCount; i++) {
  3206. column = columns[i];
  3207. columnSearch = preColSearch[i];
  3208. dataProp = typeof column.mData == "function" ? 'function' : column.mData;
  3209. d.columns.push({
  3210. data: dataProp,
  3211. name: column.sName,
  3212. searchable: column.bSearchable,
  3213. orderable: column.bSortable,
  3214. search: {
  3215. value: columnSearch.sSearch,
  3216. regex: columnSearch.bRegex
  3217. }
  3218. });
  3219. param("mDataProp_" + i, dataProp);
  3220. if (features.bFilter) {
  3221. param('sSearch_' + i, columnSearch.sSearch);
  3222. param('bRegex_' + i, columnSearch.bRegex);
  3223. param('bSearchable_' + i, column.bSearchable);
  3224. }
  3225. if (features.bSort) {
  3226. param('bSortable_' + i, column.bSortable);
  3227. }
  3228. }
  3229. if (features.bFilter) {
  3230. param('sSearch', preSearch.sSearch);
  3231. param('bRegex', preSearch.bRegex);
  3232. }
  3233. if (features.bSort) {
  3234. $.each(sort, function(i, val) {
  3235. d.order.push({
  3236. column: val.col,
  3237. dir: val.dir
  3238. });
  3239. param('iSortCol_' + i, val.col);
  3240. param('sSortDir_' + i, val.dir);
  3241. });
  3242. param('iSortingCols', sort.length);
  3243. }
  3244. // If the legacy.ajax parameter is null, then we automatically decide which
  3245. // form to use, based on sAjaxSource
  3246. var legacy = DataTable.ext.legacy.ajax;
  3247. if (legacy === null) {
  3248. return settings.sAjaxSource ? data : d;
  3249. }
  3250. // Otherwise, if legacy has been specified then we use that to decide on the
  3251. // form
  3252. return legacy ? data : d;
  3253. }
  3254. /**
  3255. * Data the data from the server (nuking the old) and redraw the table
  3256. * @param {object} oSettings dataTables settings object
  3257. * @param {object} json json data return from the server.
  3258. * @param {string} json.sEcho Tracking flag for DataTables to match requests
  3259. * @param {int} json.iTotalRecords Number of records in the data set, not accounting for filtering
  3260. * @param {int} json.iTotalDisplayRecords Number of records in the data set, accounting for filtering
  3261. * @param {array} json.aaData The data to display on this page
  3262. * @param {string} [json.sColumns] Column ordering (sName, comma separated)
  3263. * @memberof DataTable#oApi
  3264. */
  3265. function _fnAjaxUpdateDraw(settings, json) {
  3266. // v1.10 uses camelCase variables, while 1.9 uses Hungarian notation.
  3267. // Support both
  3268. var compat = function(old, modern) {
  3269. return json[old] !== undefined ? json[old] : json[modern];
  3270. };
  3271. var data = _fnAjaxDataSrc(settings, json);
  3272. var draw = compat('sEcho', 'draw');
  3273. var recordsTotal = compat('iTotalRecords', 'recordsTotal');
  3274. var recordsFiltered = compat('iTotalDisplayRecords', 'recordsFiltered');
  3275. if (draw) {
  3276. // Protect against out of sequence returns
  3277. if (draw * 1 < settings.iDraw) {
  3278. return;
  3279. }
  3280. settings.iDraw = draw * 1;
  3281. }
  3282. _fnClearTable(settings);
  3283. settings._iRecordsTotal = parseInt(recordsTotal, 10);
  3284. settings._iRecordsDisplay = parseInt(recordsFiltered, 10);
  3285. for (var i = 0, ien = data.length; i < ien; i++) {
  3286. _fnAddData(settings, data[i]);
  3287. }
  3288. settings.aiDisplay = settings.aiDisplayMaster.slice();
  3289. settings.bAjaxDataGet = false;
  3290. _fnDraw(settings);
  3291. if (!settings._bInitComplete) {
  3292. _fnInitComplete(settings, json);
  3293. }
  3294. settings.bAjaxDataGet = true;
  3295. _fnProcessingDisplay(settings, false);
  3296. }
  3297. /**
  3298. * Get the data from the JSON data source to use for drawing a table. Using
  3299. * `_fnGetObjectDataFn` allows the data to be sourced from a property of the
  3300. * source object, or from a processing function.
  3301. * @param {object} oSettings dataTables settings object
  3302. * @param {object} json Data source object / array from the server
  3303. * @return {array} Array of data to use
  3304. */
  3305. function _fnAjaxDataSrc(oSettings, json) {
  3306. var dataSrc = $.isPlainObject(oSettings.ajax) && oSettings.ajax.dataSrc !== undefined ?
  3307. oSettings.ajax.dataSrc :
  3308. oSettings.sAjaxDataProp; // Compatibility with 1.9-.
  3309. // Compatibility with 1.9-. In order to read from aaData, check if the
  3310. // default has been changed, if not, check for aaData
  3311. if (dataSrc === 'data') {
  3312. return json.aaData || json[dataSrc];
  3313. }
  3314. return dataSrc !== "" ?
  3315. _fnGetObjectDataFn(dataSrc)(json) :
  3316. json;
  3317. }
  3318. /**
  3319. * Generate the node required for filtering text
  3320. * @returns {node} Filter control element
  3321. * @param {object} oSettings dataTables settings object
  3322. * @memberof DataTable#oApi
  3323. */
  3324. function _fnFeatureHtmlFilter(settings) {
  3325. var classes = settings.oClasses;
  3326. var tableId = settings.sTableId;
  3327. var language = settings.oLanguage;
  3328. var previousSearch = settings.oPreviousSearch;
  3329. var features = settings.aanFeatures;
  3330. var input = '<input type="search" class="' + classes.sFilterInput + '"/>';
  3331. var str = language.sSearch;
  3332. str = str.match(/_INPUT_/) ?
  3333. str.replace('_INPUT_', input) :
  3334. str + input;
  3335. var filter = $('<div/>', {
  3336. 'id': !features.f ? tableId + '_filter' : null,
  3337. 'class': classes.sFilter
  3338. })
  3339. .append($('<label/>').append(str));
  3340. var searchFn = function() {
  3341. /* Update all other filter input elements for the new display */
  3342. var n = features.f;
  3343. var val = !this.value ? "" : this.value; // mental IE8 fix :-(
  3344. /* Now do the filter */
  3345. if (val != previousSearch.sSearch) {
  3346. _fnFilterComplete(settings, {
  3347. "sSearch": val,
  3348. "bRegex": previousSearch.bRegex,
  3349. "bSmart": previousSearch.bSmart,
  3350. "bCaseInsensitive": previousSearch.bCaseInsensitive
  3351. });
  3352. // Need to redraw, without resorting
  3353. settings._iDisplayStart = 0;
  3354. _fnDraw(settings);
  3355. }
  3356. };
  3357. var searchDelay = settings.searchDelay !== null ?
  3358. settings.searchDelay :
  3359. _fnDataSource(settings) === 'ssp' ?
  3360. 400 :
  3361. 0;
  3362. var jqFilter = $('input', filter)
  3363. .val(previousSearch.sSearch)
  3364. .attr('placeholder', language.sSearchPlaceholder)
  3365. .bind(
  3366. 'keyup.DT search.DT input.DT paste.DT cut.DT',
  3367. searchDelay ?
  3368. _fnThrottle(searchFn, searchDelay) :
  3369. searchFn
  3370. )
  3371. .bind('keypress.DT', function(e) {
  3372. /* Prevent form submission */
  3373. if (e.keyCode == 13) {
  3374. return false;
  3375. }
  3376. })
  3377. .attr('aria-controls', tableId);
  3378. // Update the input elements whenever the table is filtered
  3379. $(settings.nTable).on('search.dt.DT', function(ev, s) {
  3380. if (settings === s) {
  3381. // IE9 throws an 'unknown error' if document.activeElement is used
  3382. // inside an iframe or frame...
  3383. try {
  3384. if (jqFilter[0] !== document.activeElement) {
  3385. jqFilter.val(previousSearch.sSearch);
  3386. }
  3387. } catch (e) {}
  3388. }
  3389. });
  3390. return filter[0];
  3391. }
  3392. /**
  3393. * Filter the table using both the global filter and column based filtering
  3394. * @param {object} oSettings dataTables settings object
  3395. * @param {object} oSearch search information
  3396. * @param {int} [iForce] force a research of the master array (1) or not (undefined or 0)
  3397. * @memberof DataTable#oApi
  3398. */
  3399. function _fnFilterComplete(oSettings, oInput, iForce) {
  3400. var oPrevSearch = oSettings.oPreviousSearch;
  3401. var aoPrevSearch = oSettings.aoPreSearchCols;
  3402. var fnSaveFilter = function(oFilter) {
  3403. /* Save the filtering values */
  3404. oPrevSearch.sSearch = oFilter.sSearch;
  3405. oPrevSearch.bRegex = oFilter.bRegex;
  3406. oPrevSearch.bSmart = oFilter.bSmart;
  3407. oPrevSearch.bCaseInsensitive = oFilter.bCaseInsensitive;
  3408. };
  3409. var fnRegex = function(o) {
  3410. // Backwards compatibility with the bEscapeRegex option
  3411. return o.bEscapeRegex !== undefined ? !o.bEscapeRegex : o.bRegex;
  3412. };
  3413. // Resolve any column types that are unknown due to addition or invalidation
  3414. // @todo As per sort - can this be moved into an event handler?
  3415. _fnColumnTypes(oSettings);
  3416. /* In server-side processing all filtering is done by the server, so no point hanging around here */
  3417. if (_fnDataSource(oSettings) != 'ssp') {
  3418. /* Global filter */
  3419. _fnFilter(oSettings, oInput.sSearch, iForce, fnRegex(oInput), oInput.bSmart, oInput.bCaseInsensitive);
  3420. fnSaveFilter(oInput);
  3421. /* Now do the individual column filter */
  3422. for (var i = 0; i < aoPrevSearch.length; i++) {
  3423. _fnFilterColumn(oSettings, aoPrevSearch[i].sSearch, i, fnRegex(aoPrevSearch[i]),
  3424. aoPrevSearch[i].bSmart, aoPrevSearch[i].bCaseInsensitive);
  3425. }
  3426. /* Custom filtering */
  3427. _fnFilterCustom(oSettings);
  3428. } else {
  3429. fnSaveFilter(oInput);
  3430. }
  3431. /* Tell the draw function we have been filtering */
  3432. oSettings.bFiltered = true;
  3433. _fnCallbackFire(oSettings, null, 'search', [oSettings]);
  3434. }
  3435. /**
  3436. * Apply custom filtering functions
  3437. * @param {object} oSettings dataTables settings object
  3438. * @memberof DataTable#oApi
  3439. */
  3440. function _fnFilterCustom(settings) {
  3441. var filters = DataTable.ext.search;
  3442. var displayRows = settings.aiDisplay;
  3443. var row, rowIdx;
  3444. for (var i = 0, ien = filters.length; i < ien; i++) {
  3445. var rows = [];
  3446. // Loop over each row and see if it should be included
  3447. for (var j = 0, jen = displayRows.length; j < jen; j++) {
  3448. rowIdx = displayRows[j];
  3449. row = settings.aoData[rowIdx];
  3450. if (filters[i](settings, row._aFilterData, rowIdx, row._aData, j)) {
  3451. rows.push(rowIdx);
  3452. }
  3453. }
  3454. // So the array reference doesn't break set the results into the
  3455. // existing array
  3456. displayRows.length = 0;
  3457. $.merge(displayRows, rows);
  3458. }
  3459. }
  3460. /**
  3461. * Filter the table on a per-column basis
  3462. * @param {object} oSettings dataTables settings object
  3463. * @param {string} sInput string to filter on
  3464. * @param {int} iColumn column to filter
  3465. * @param {bool} bRegex treat search string as a regular expression or not
  3466. * @param {bool} bSmart use smart filtering or not
  3467. * @param {bool} bCaseInsensitive Do case insenstive matching or not
  3468. * @memberof DataTable#oApi
  3469. */
  3470. function _fnFilterColumn(settings, searchStr, colIdx, regex, smart, caseInsensitive) {
  3471. if (searchStr === '') {
  3472. return;
  3473. }
  3474. var data;
  3475. var display = settings.aiDisplay;
  3476. var rpSearch = _fnFilterCreateSearch(searchStr, regex, smart, caseInsensitive);
  3477. for (var i = display.length - 1; i >= 0; i--) {
  3478. data = settings.aoData[display[i]]._aFilterData[colIdx];
  3479. if (!rpSearch.test(data)) {
  3480. display.splice(i, 1);
  3481. }
  3482. }
  3483. }
  3484. /**
  3485. * Filter the data table based on user input and draw the table
  3486. * @param {object} settings dataTables settings object
  3487. * @param {string} input string to filter on
  3488. * @param {int} force optional - force a research of the master array (1) or not (undefined or 0)
  3489. * @param {bool} regex treat as a regular expression or not
  3490. * @param {bool} smart perform smart filtering or not
  3491. * @param {bool} caseInsensitive Do case insenstive matching or not
  3492. * @memberof DataTable#oApi
  3493. */
  3494. function _fnFilter(settings, input, force, regex, smart, caseInsensitive) {
  3495. var rpSearch = _fnFilterCreateSearch(input, regex, smart, caseInsensitive);
  3496. var prevSearch = settings.oPreviousSearch.sSearch;
  3497. var displayMaster = settings.aiDisplayMaster;
  3498. var display, invalidated, i;
  3499. // Need to take account of custom filtering functions - always filter
  3500. if (DataTable.ext.search.length !== 0) {
  3501. force = true;
  3502. }
  3503. // Check if any of the rows were invalidated
  3504. invalidated = _fnFilterData(settings);
  3505. // If the input is blank - we just want the full data set
  3506. if (input.length <= 0) {
  3507. settings.aiDisplay = displayMaster.slice();
  3508. } else {
  3509. // New search - start from the master array
  3510. if (invalidated ||
  3511. force ||
  3512. prevSearch.length > input.length ||
  3513. input.indexOf(prevSearch) !== 0 ||
  3514. settings.bSorted // On resort, the display master needs to be
  3515. // re-filtered since indexes will have changed
  3516. ) {
  3517. settings.aiDisplay = displayMaster.slice();
  3518. }
  3519. // Search the display array
  3520. display = settings.aiDisplay;
  3521. for (i = display.length - 1; i >= 0; i--) {
  3522. if (!rpSearch.test(settings.aoData[display[i]]._sFilterRow)) {
  3523. display.splice(i, 1);
  3524. }
  3525. }
  3526. }
  3527. }
  3528. /**
  3529. * Build a regular expression object suitable for searching a table
  3530. * @param {string} sSearch string to search for
  3531. * @param {bool} bRegex treat as a regular expression or not
  3532. * @param {bool} bSmart perform smart filtering or not
  3533. * @param {bool} bCaseInsensitive Do case insensitive matching or not
  3534. * @returns {RegExp} constructed object
  3535. * @memberof DataTable#oApi
  3536. */
  3537. function _fnFilterCreateSearch(search, regex, smart, caseInsensitive) {
  3538. search = regex ?
  3539. search :
  3540. _fnEscapeRegex(search);
  3541. if (smart) {
  3542. /* For smart filtering we want to allow the search to work regardless of
  3543. * word order. We also want double quoted text to be preserved, so word
  3544. * order is important - a la google. So this is what we want to
  3545. * generate:
  3546. *
  3547. * ^(?=.*?\bone\b)(?=.*?\btwo three\b)(?=.*?\bfour\b).*$
  3548. */
  3549. var a = $.map(search.match(/"[^"]+"|[^ ]+/g) || [''], function(word) {
  3550. if (word.charAt(0) === '"') {
  3551. var m = word.match(/^"(.*)"$/);
  3552. word = m ? m[1] : word;
  3553. }
  3554. return word.replace('"', '');
  3555. });
  3556. search = '^(?=.*?' + a.join(')(?=.*?') + ').*$';
  3557. }
  3558. return new RegExp(search, caseInsensitive ? 'i' : '');
  3559. }
  3560. /**
  3561. * Escape a string such that it can be used in a regular expression
  3562. * @param {string} sVal string to escape
  3563. * @returns {string} escaped string
  3564. * @memberof DataTable#oApi
  3565. */
  3566. var _fnEscapeRegex = DataTable.util.escapeRegex;
  3567. var __filter_div = $('<div>')[0];
  3568. var __filter_div_textContent = __filter_div.textContent !== undefined;
  3569. // Update the filtering data for each row if needed (by invalidation or first run)
  3570. function _fnFilterData(settings) {
  3571. var columns = settings.aoColumns;
  3572. var column;
  3573. var i, j, ien, jen, filterData, cellData, row;
  3574. var fomatters = DataTable.ext.type.search;
  3575. var wasInvalidated = false;
  3576. for (i = 0, ien = settings.aoData.length; i < ien; i++) {
  3577. row = settings.aoData[i];
  3578. if (!row._aFilterData) {
  3579. filterData = [];
  3580. for (j = 0, jen = columns.length; j < jen; j++) {
  3581. column = columns[j];
  3582. if (column.bSearchable) {
  3583. cellData = _fnGetCellData(settings, i, j, 'filter');
  3584. if (fomatters[column.sType]) {
  3585. cellData = fomatters[column.sType](cellData);
  3586. }
  3587. // Search in DataTables 1.10 is string based. In 1.11 this
  3588. // should be altered to also allow strict type checking.
  3589. if (cellData === null) {
  3590. cellData = '';
  3591. }
  3592. if (typeof cellData !== 'string' && cellData.toString) {
  3593. cellData = cellData.toString();
  3594. }
  3595. } else {
  3596. cellData = '';
  3597. }
  3598. // If it looks like there is an HTML entity in the string,
  3599. // attempt to decode it so sorting works as expected. Note that
  3600. // we could use a single line of jQuery to do this, but the DOM
  3601. // method used here is much faster http://jsperf.com/html-decode
  3602. if (cellData.indexOf && cellData.indexOf('&') !== -1) {
  3603. __filter_div.innerHTML = cellData;
  3604. cellData = __filter_div_textContent ?
  3605. __filter_div.textContent :
  3606. __filter_div.innerText;
  3607. }
  3608. if (cellData.replace) {
  3609. cellData = cellData.replace(/[\r\n]/g, '');
  3610. }
  3611. filterData.push(cellData);
  3612. }
  3613. row._aFilterData = filterData;
  3614. row._sFilterRow = filterData.join(' ');
  3615. wasInvalidated = true;
  3616. }
  3617. }
  3618. return wasInvalidated;
  3619. }
  3620. /**
  3621. * Convert from the internal Hungarian notation to camelCase for external
  3622. * interaction
  3623. * @param {object} obj Object to convert
  3624. * @returns {object} Inverted object
  3625. * @memberof DataTable#oApi
  3626. */
  3627. function _fnSearchToCamel(obj) {
  3628. return {
  3629. search: obj.sSearch,
  3630. smart: obj.bSmart,
  3631. regex: obj.bRegex,
  3632. caseInsensitive: obj.bCaseInsensitive
  3633. };
  3634. }
  3635. /**
  3636. * Convert from camelCase notation to the internal Hungarian. We could use the
  3637. * Hungarian convert function here, but this is cleaner
  3638. * @param {object} obj Object to convert
  3639. * @returns {object} Inverted object
  3640. * @memberof DataTable#oApi
  3641. */
  3642. function _fnSearchToHung(obj) {
  3643. return {
  3644. sSearch: obj.search,
  3645. bSmart: obj.smart,
  3646. bRegex: obj.regex,
  3647. bCaseInsensitive: obj.caseInsensitive
  3648. };
  3649. }
  3650. /**
  3651. * Generate the node required for the info display
  3652. * @param {object} oSettings dataTables settings object
  3653. * @returns {node} Information element
  3654. * @memberof DataTable#oApi
  3655. */
  3656. function _fnFeatureHtmlInfo(settings) {
  3657. var
  3658. tid = settings.sTableId,
  3659. nodes = settings.aanFeatures.i,
  3660. n = $('<div/>', {
  3661. 'class': settings.oClasses.sInfo,
  3662. 'id': !nodes ? tid + '_info' : null
  3663. });
  3664. if (!nodes) {
  3665. // Update display on each draw
  3666. settings.aoDrawCallback.push({
  3667. "fn": _fnUpdateInfo,
  3668. "sName": "information"
  3669. });
  3670. n
  3671. .attr('role', 'status')
  3672. .attr('aria-live', 'polite');
  3673. // Table is described by our info div
  3674. $(settings.nTable).attr('aria-describedby', tid + '_info');
  3675. }
  3676. return n[0];
  3677. }
  3678. /**
  3679. * Update the information elements in the display
  3680. * @param {object} settings dataTables settings object
  3681. * @memberof DataTable#oApi
  3682. */
  3683. function _fnUpdateInfo(settings) {
  3684. /* Show information about the table */
  3685. var nodes = settings.aanFeatures.i;
  3686. if (nodes.length === 0) {
  3687. return;
  3688. }
  3689. var
  3690. lang = settings.oLanguage,
  3691. start = settings._iDisplayStart + 1,
  3692. end = settings.fnDisplayEnd(),
  3693. max = settings.fnRecordsTotal(),
  3694. total = settings.fnRecordsDisplay(),
  3695. out = total ?
  3696. lang.sInfo :
  3697. lang.sInfoEmpty;
  3698. if (total !== max) {
  3699. /* Record set after filtering */
  3700. out += ' ' + lang.sInfoFiltered;
  3701. }
  3702. // Convert the macros
  3703. out += lang.sInfoPostFix;
  3704. out = _fnInfoMacros(settings, out);
  3705. var callback = lang.fnInfoCallback;
  3706. if (callback !== null) {
  3707. out = callback.call(settings.oInstance,
  3708. settings, start, end, max, total, out
  3709. );
  3710. }
  3711. $(nodes).html(out);
  3712. }
  3713. function _fnInfoMacros(settings, str) {
  3714. // When infinite scrolling, we are always starting at 1. _iDisplayStart is used only
  3715. // internally
  3716. var
  3717. formatter = settings.fnFormatNumber,
  3718. start = settings._iDisplayStart + 1,
  3719. len = settings._iDisplayLength,
  3720. vis = settings.fnRecordsDisplay(),
  3721. all = len === -1;
  3722. return str.
  3723. replace(/_START_/g, formatter.call(settings, start)).
  3724. replace(/_END_/g, formatter.call(settings, settings.fnDisplayEnd())).
  3725. replace(/_MAX_/g, formatter.call(settings, settings.fnRecordsTotal())).
  3726. replace(/_TOTAL_/g, formatter.call(settings, vis)).
  3727. replace(/_PAGE_/g, formatter.call(settings, all ? 1 : Math.ceil(start / len))).
  3728. replace(/_PAGES_/g, formatter.call(settings, all ? 1 : Math.ceil(vis / len)));
  3729. }
  3730. /**
  3731. * Draw the table for the first time, adding all required features
  3732. * @param {object} settings dataTables settings object
  3733. * @memberof DataTable#oApi
  3734. */
  3735. function _fnInitialise(settings) {
  3736. var i, iLen, iAjaxStart = settings.iInitDisplayStart;
  3737. var columns = settings.aoColumns,
  3738. column;
  3739. var features = settings.oFeatures;
  3740. var deferLoading = settings.bDeferLoading; // value modified by the draw
  3741. /* Ensure that the table data is fully initialised */
  3742. if (!settings.bInitialised) {
  3743. setTimeout(function() {
  3744. _fnInitialise(settings);
  3745. }, 200);
  3746. return;
  3747. }
  3748. /* Show the display HTML options */
  3749. _fnAddOptionsHtml(settings);
  3750. /* Build and draw the header / footer for the table */
  3751. _fnBuildHead(settings);
  3752. _fnDrawHead(settings, settings.aoHeader);
  3753. _fnDrawHead(settings, settings.aoFooter);
  3754. /* Okay to show that something is going on now */
  3755. _fnProcessingDisplay(settings, true);
  3756. /* Calculate sizes for columns */
  3757. if (features.bAutoWidth) {
  3758. _fnCalculateColumnWidths(settings);
  3759. }
  3760. for (i = 0, iLen = columns.length; i < iLen; i++) {
  3761. column = columns[i];
  3762. if (column.sWidth) {
  3763. column.nTh.style.width = _fnStringToCss(column.sWidth);
  3764. }
  3765. }
  3766. _fnCallbackFire(settings, null, 'preInit', [settings]);
  3767. // If there is default sorting required - let's do it. The sort function
  3768. // will do the drawing for us. Otherwise we draw the table regardless of the
  3769. // Ajax source - this allows the table to look initialised for Ajax sourcing
  3770. // data (show 'loading' message possibly)
  3771. _fnReDraw(settings);
  3772. // Server-side processing init complete is done by _fnAjaxUpdateDraw
  3773. var dataSrc = _fnDataSource(settings);
  3774. if (dataSrc != 'ssp' || deferLoading) {
  3775. // if there is an ajax source load the data
  3776. if (dataSrc == 'ajax') {
  3777. _fnBuildAjax(settings, [], function(json) {
  3778. var aData = _fnAjaxDataSrc(settings, json);
  3779. // Got the data - add it to the table
  3780. for (i = 0; i < aData.length; i++) {
  3781. _fnAddData(settings, aData[i]);
  3782. }
  3783. // Reset the init display for cookie saving. We've already done
  3784. // a filter, and therefore cleared it before. So we need to make
  3785. // it appear 'fresh'
  3786. settings.iInitDisplayStart = iAjaxStart;
  3787. _fnReDraw(settings);
  3788. _fnProcessingDisplay(settings, false);
  3789. _fnInitComplete(settings, json);
  3790. }, settings);
  3791. } else {
  3792. _fnProcessingDisplay(settings, false);
  3793. _fnInitComplete(settings);
  3794. }
  3795. }
  3796. }
  3797. /**
  3798. * Draw the table for the first time, adding all required features
  3799. * @param {object} oSettings dataTables settings object
  3800. * @param {object} [json] JSON from the server that completed the table, if using Ajax source
  3801. * with client-side processing (optional)
  3802. * @memberof DataTable#oApi
  3803. */
  3804. function _fnInitComplete(settings, json) {
  3805. settings._bInitComplete = true;
  3806. // When data was added after the initialisation (data or Ajax) we need to
  3807. // calculate the column sizing
  3808. if (json || settings.oInit.aaData) {
  3809. _fnAdjustColumnSizing(settings);
  3810. }
  3811. _fnCallbackFire(settings, null, 'plugin-init', [settings, json]);
  3812. _fnCallbackFire(settings, 'aoInitComplete', 'init', [settings, json]);
  3813. }
  3814. function _fnLengthChange(settings, val) {
  3815. var len = parseInt(val, 10);
  3816. settings._iDisplayLength = len;
  3817. _fnLengthOverflow(settings);
  3818. // Fire length change event
  3819. _fnCallbackFire(settings, null, 'length', [settings, len]);
  3820. }
  3821. /**
  3822. * Generate the node required for user display length changing
  3823. * @param {object} settings dataTables settings object
  3824. * @returns {node} Display length feature node
  3825. * @memberof DataTable#oApi
  3826. */
  3827. function _fnFeatureHtmlLength(settings) {
  3828. var
  3829. classes = settings.oClasses,
  3830. tableId = settings.sTableId,
  3831. menu = settings.aLengthMenu,
  3832. d2 = $.isArray(menu[0]),
  3833. lengths = d2 ? menu[0] : menu,
  3834. language = d2 ? menu[1] : menu;
  3835. var select = $('<select/>', {
  3836. 'name': tableId + '_length',
  3837. 'aria-controls': tableId,
  3838. 'class': classes.sLengthSelect
  3839. });
  3840. for (var i = 0, ien = lengths.length; i < ien; i++) {
  3841. select[0][i] = new Option(language[i], lengths[i]);
  3842. }
  3843. var div = $('<div><label/></div>').addClass(classes.sLength);
  3844. if (!settings.aanFeatures.l) {
  3845. div[0].id = tableId + '_length';
  3846. }
  3847. div.children().append(
  3848. settings.oLanguage.sLengthMenu.replace('_MENU_', select[0].outerHTML)
  3849. );
  3850. // Can't use `select` variable as user might provide their own and the
  3851. // reference is broken by the use of outerHTML
  3852. $('select', div)
  3853. .val(settings._iDisplayLength)
  3854. .bind('change.DT', function(e) {
  3855. _fnLengthChange(settings, $(this).val());
  3856. _fnDraw(settings);
  3857. });
  3858. // Update node value whenever anything changes the table's length
  3859. $(settings.nTable).bind('length.dt.DT', function(e, s, len) {
  3860. if (settings === s) {
  3861. $('select', div).val(len);
  3862. }
  3863. });
  3864. return div[0];
  3865. }
  3866. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  3867. * Note that most of the paging logic is done in
  3868. * DataTable.ext.pager
  3869. */
  3870. /**
  3871. * Generate the node required for default pagination
  3872. * @param {object} oSettings dataTables settings object
  3873. * @returns {node} Pagination feature node
  3874. * @memberof DataTable#oApi
  3875. */
  3876. function _fnFeatureHtmlPaginate(settings) {
  3877. var
  3878. type = settings.sPaginationType,
  3879. plugin = DataTable.ext.pager[type],
  3880. modern = typeof plugin === 'function',
  3881. redraw = function(settings) {
  3882. _fnDraw(settings);
  3883. },
  3884. node = $('<div/>').addClass(settings.oClasses.sPaging + type)[0],
  3885. features = settings.aanFeatures;
  3886. if (!modern) {
  3887. plugin.fnInit(settings, node, redraw);
  3888. }
  3889. /* Add a draw callback for the pagination on first instance, to update the paging display */
  3890. if (!features.p) {
  3891. node.id = settings.sTableId + '_paginate';
  3892. settings.aoDrawCallback.push({
  3893. "fn": function(settings) {
  3894. if (modern) {
  3895. var
  3896. start = settings._iDisplayStart,
  3897. len = settings._iDisplayLength,
  3898. visRecords = settings.fnRecordsDisplay(),
  3899. all = len === -1,
  3900. page = all ? 0 : Math.ceil(start / len),
  3901. pages = all ? 1 : Math.ceil(visRecords / len),
  3902. buttons = plugin(page, pages),
  3903. i, ien;
  3904. for (i = 0, ien = features.p.length; i < ien; i++) {
  3905. _fnRenderer(settings, 'pageButton')(
  3906. settings, features.p[i], i, buttons, page, pages
  3907. );
  3908. }
  3909. } else {
  3910. plugin.fnUpdate(settings, redraw);
  3911. }
  3912. },
  3913. "sName": "pagination"
  3914. });
  3915. }
  3916. return node;
  3917. }
  3918. /**
  3919. * Alter the display settings to change the page
  3920. * @param {object} settings DataTables settings object
  3921. * @param {string|int} action Paging action to take: "first", "previous",
  3922. * "next" or "last" or page number to jump to (integer)
  3923. * @param [bool] redraw Automatically draw the update or not
  3924. * @returns {bool} true page has changed, false - no change
  3925. * @memberof DataTable#oApi
  3926. */
  3927. function _fnPageChange(settings, action, redraw) {
  3928. var
  3929. start = settings._iDisplayStart,
  3930. len = settings._iDisplayLength,
  3931. records = settings.fnRecordsDisplay();
  3932. if (records === 0 || len === -1) {
  3933. start = 0;
  3934. } else if (typeof action === "number") {
  3935. start = action * len;
  3936. if (start > records) {
  3937. start = 0;
  3938. }
  3939. } else if (action == "first") {
  3940. start = 0;
  3941. } else if (action == "previous") {
  3942. start = len >= 0 ?
  3943. start - len :
  3944. 0;
  3945. if (start < 0) {
  3946. start = 0;
  3947. }
  3948. } else if (action == "next") {
  3949. if (start + len < records) {
  3950. start += len;
  3951. }
  3952. } else if (action == "last") {
  3953. start = Math.floor((records - 1) / len) * len;
  3954. } else {
  3955. _fnLog(settings, 0, "Unknown paging action: " + action, 5);
  3956. }
  3957. var changed = settings._iDisplayStart !== start;
  3958. settings._iDisplayStart = start;
  3959. if (changed) {
  3960. _fnCallbackFire(settings, null, 'page', [settings]);
  3961. if (redraw) {
  3962. _fnDraw(settings);
  3963. }
  3964. }
  3965. return changed;
  3966. }
  3967. /**
  3968. * Generate the node required for the processing node
  3969. * @param {object} settings dataTables settings object
  3970. * @returns {node} Processing element
  3971. * @memberof DataTable#oApi
  3972. */
  3973. function _fnFeatureHtmlProcessing(settings) {
  3974. return $('<div/>', {
  3975. 'id': !settings.aanFeatures.r ? settings.sTableId + '_processing' : null,
  3976. 'class': settings.oClasses.sProcessing
  3977. })
  3978. .html(settings.oLanguage.sProcessing)
  3979. .insertBefore(settings.nTable)[0];
  3980. }
  3981. /**
  3982. * Display or hide the processing indicator
  3983. * @param {object} settings dataTables settings object
  3984. * @param {bool} show Show the processing indicator (true) or not (false)
  3985. * @memberof DataTable#oApi
  3986. */
  3987. function _fnProcessingDisplay(settings, show) {
  3988. if (settings.oFeatures.bProcessing) {
  3989. $(settings.aanFeatures.r).css('display', show ? 'block' : 'none');
  3990. }
  3991. _fnCallbackFire(settings, null, 'processing', [settings, show]);
  3992. }
  3993. /**
  3994. * Add any control elements for the table - specifically scrolling
  3995. * @param {object} settings dataTables settings object
  3996. * @returns {node} Node to add to the DOM
  3997. * @memberof DataTable#oApi
  3998. */
  3999. function _fnFeatureHtmlTable(settings) {
  4000. var table = $(settings.nTable);
  4001. // Add the ARIA grid role to the table
  4002. table.attr('role', 'grid');
  4003. // Scrolling from here on in
  4004. var scroll = settings.oScroll;
  4005. if (scroll.sX === '' && scroll.sY === '') {
  4006. return settings.nTable;
  4007. }
  4008. var scrollX = scroll.sX;
  4009. var scrollY = scroll.sY;
  4010. var classes = settings.oClasses;
  4011. var caption = table.children('caption');
  4012. var captionSide = caption.length ? caption[0]._captionSide : null;
  4013. var headerClone = $(table[0].cloneNode(false));
  4014. var footerClone = $(table[0].cloneNode(false));
  4015. var footer = table.children('tfoot');
  4016. var _div = '<div/>';
  4017. var size = function(s) {
  4018. return !s ? null : _fnStringToCss(s);
  4019. };
  4020. if (!footer.length) {
  4021. footer = null;
  4022. }
  4023. /*
  4024. * The HTML structure that we want to generate in this function is:
  4025. * div - scroller
  4026. * div - scroll head
  4027. * div - scroll head inner
  4028. * table - scroll head table
  4029. * thead - thead
  4030. * div - scroll body
  4031. * table - table (master table)
  4032. * thead - thead clone for sizing
  4033. * tbody - tbody
  4034. * div - scroll foot
  4035. * div - scroll foot inner
  4036. * table - scroll foot table
  4037. * tfoot - tfoot
  4038. */
  4039. var scroller = $(_div, {
  4040. 'class': classes.sScrollWrapper
  4041. })
  4042. .append(
  4043. $(_div, {
  4044. 'class': classes.sScrollHead
  4045. })
  4046. .css({
  4047. overflow: 'hidden',
  4048. position: 'relative',
  4049. border: 0,
  4050. width: scrollX ? size(scrollX) : '100%'
  4051. })
  4052. .append(
  4053. $(_div, {
  4054. 'class': classes.sScrollHeadInner
  4055. })
  4056. .css({
  4057. 'box-sizing': 'content-box',
  4058. width: scroll.sXInner || '100%'
  4059. })
  4060. .append(
  4061. headerClone
  4062. .removeAttr('id')
  4063. .css('margin-left', 0)
  4064. .append(captionSide === 'top' ? caption : null)
  4065. .append(
  4066. table.children('thead')
  4067. )
  4068. )
  4069. )
  4070. )
  4071. .append(
  4072. $(_div, {
  4073. 'class': classes.sScrollBody
  4074. })
  4075. .css({
  4076. position: 'relative',
  4077. overflow: 'auto',
  4078. width: size(scrollX)
  4079. })
  4080. .append(table)
  4081. );
  4082. if (footer) {
  4083. scroller.append(
  4084. $(_div, {
  4085. 'class': classes.sScrollFoot
  4086. })
  4087. .css({
  4088. overflow: 'hidden',
  4089. border: 0,
  4090. width: scrollX ? size(scrollX) : '100%'
  4091. })
  4092. .append(
  4093. $(_div, {
  4094. 'class': classes.sScrollFootInner
  4095. })
  4096. .append(
  4097. footerClone
  4098. .removeAttr('id')
  4099. .css('margin-left', 0)
  4100. .append(captionSide === 'bottom' ? caption : null)
  4101. .append(
  4102. table.children('tfoot')
  4103. )
  4104. )
  4105. )
  4106. );
  4107. }
  4108. var children = scroller.children();
  4109. var scrollHead = children[0];
  4110. var scrollBody = children[1];
  4111. var scrollFoot = footer ? children[2] : null;
  4112. // When the body is scrolled, then we also want to scroll the headers
  4113. if (scrollX) {
  4114. $(scrollBody).on('scroll.DT', function(e) {
  4115. var scrollLeft = this.scrollLeft;
  4116. scrollHead.scrollLeft = scrollLeft;
  4117. if (footer) {
  4118. scrollFoot.scrollLeft = scrollLeft;
  4119. }
  4120. });
  4121. }
  4122. $(scrollBody).css(
  4123. scrollY && scroll.bCollapse ? 'max-height' : 'height',
  4124. scrollY
  4125. );
  4126. settings.nScrollHead = scrollHead;
  4127. settings.nScrollBody = scrollBody;
  4128. settings.nScrollFoot = scrollFoot;
  4129. // On redraw - align columns
  4130. settings.aoDrawCallback.push({
  4131. "fn": _fnScrollDraw,
  4132. "sName": "scrolling"
  4133. });
  4134. return scroller[0];
  4135. }
  4136. /**
  4137. * Update the header, footer and body tables for resizing - i.e. column
  4138. * alignment.
  4139. *
  4140. * Welcome to the most horrible function DataTables. The process that this
  4141. * function follows is basically:
  4142. * 1. Re-create the table inside the scrolling div
  4143. * 2. Take live measurements from the DOM
  4144. * 3. Apply the measurements to align the columns
  4145. * 4. Clean up
  4146. *
  4147. * @param {object} settings dataTables settings object
  4148. * @memberof DataTable#oApi
  4149. */
  4150. function _fnScrollDraw(settings) {
  4151. // Given that this is such a monster function, a lot of variables are use
  4152. // to try and keep the minimised size as small as possible
  4153. var
  4154. scroll = settings.oScroll,
  4155. scrollX = scroll.sX,
  4156. scrollXInner = scroll.sXInner,
  4157. scrollY = scroll.sY,
  4158. barWidth = scroll.iBarWidth,
  4159. divHeader = $(settings.nScrollHead),
  4160. divHeaderStyle = divHeader[0].style,
  4161. divHeaderInner = divHeader.children('div'),
  4162. divHeaderInnerStyle = divHeaderInner[0].style,
  4163. divHeaderTable = divHeaderInner.children('table'),
  4164. divBodyEl = settings.nScrollBody,
  4165. divBody = $(divBodyEl),
  4166. divBodyStyle = divBodyEl.style,
  4167. divFooter = $(settings.nScrollFoot),
  4168. divFooterInner = divFooter.children('div'),
  4169. divFooterTable = divFooterInner.children('table'),
  4170. header = $(settings.nTHead),
  4171. table = $(settings.nTable),
  4172. tableEl = table[0],
  4173. tableStyle = tableEl.style,
  4174. footer = settings.nTFoot ? $(settings.nTFoot) : null,
  4175. browser = settings.oBrowser,
  4176. ie67 = browser.bScrollOversize,
  4177. dtHeaderCells = _pluck(settings.aoColumns, 'nTh'),
  4178. headerTrgEls, footerTrgEls,
  4179. headerSrcEls, footerSrcEls,
  4180. headerCopy, footerCopy,
  4181. headerWidths = [],
  4182. footerWidths = [],
  4183. headerContent = [],
  4184. footerContent = [],
  4185. idx, correction, sanityWidth,
  4186. zeroOut = function(nSizer) {
  4187. var style = nSizer.style;
  4188. style.paddingTop = "0";
  4189. style.paddingBottom = "0";
  4190. style.borderTopWidth = "0";
  4191. style.borderBottomWidth = "0";
  4192. style.height = 0;
  4193. };
  4194. // If the scrollbar visibility has changed from the last draw, we need to
  4195. // adjust the column sizes as the table width will have changed to account
  4196. // for the scrollbar
  4197. var scrollBarVis = divBodyEl.scrollHeight > divBodyEl.clientHeight;
  4198. if (settings.scrollBarVis !== scrollBarVis && settings.scrollBarVis !== undefined) {
  4199. settings.scrollBarVis = scrollBarVis;
  4200. _fnAdjustColumnSizing(settings);
  4201. return; // adjust column sizing will call this function again
  4202. } else {
  4203. settings.scrollBarVis = scrollBarVis;
  4204. }
  4205. /*
  4206. * 1. Re-create the table inside the scrolling div
  4207. */
  4208. // Remove the old minimised thead and tfoot elements in the inner table
  4209. table.children('thead, tfoot').remove();
  4210. if (footer) {
  4211. footerCopy = footer.clone().prependTo(table);
  4212. footerTrgEls = footer.find('tr'); // the original tfoot is in its own table and must be sized
  4213. footerSrcEls = footerCopy.find('tr');
  4214. }
  4215. // Clone the current header and footer elements and then place it into the inner table
  4216. headerCopy = header.clone().prependTo(table);
  4217. headerTrgEls = header.find('tr'); // original header is in its own table
  4218. headerSrcEls = headerCopy.find('tr');
  4219. headerCopy.find('th, td').removeAttr('tabindex');
  4220. /*
  4221. * 2. Take live measurements from the DOM - do not alter the DOM itself!
  4222. */
  4223. // Remove old sizing and apply the calculated column widths
  4224. // Get the unique column headers in the newly created (cloned) header. We want to apply the
  4225. // calculated sizes to this header
  4226. if (!scrollX) {
  4227. divBodyStyle.width = '100%';
  4228. divHeader[0].style.width = '100%';
  4229. }
  4230. $.each(_fnGetUniqueThs(settings, headerCopy), function(i, el) {
  4231. idx = _fnVisibleToColumnIndex(settings, i);
  4232. el.style.width = settings.aoColumns[idx].sWidth;
  4233. });
  4234. if (footer) {
  4235. _fnApplyToChildren(function(n) {
  4236. n.style.width = "";
  4237. }, footerSrcEls);
  4238. }
  4239. // Size the table as a whole
  4240. sanityWidth = table.outerWidth();
  4241. if (scrollX === "") {
  4242. // No x scrolling
  4243. tableStyle.width = "100%";
  4244. // IE7 will make the width of the table when 100% include the scrollbar
  4245. // - which is shouldn't. When there is a scrollbar we need to take this
  4246. // into account.
  4247. if (ie67 && (table.find('tbody').height() > divBodyEl.offsetHeight ||
  4248. divBody.css('overflow-y') == "scroll")) {
  4249. tableStyle.width = _fnStringToCss(table.outerWidth() - barWidth);
  4250. }
  4251. // Recalculate the sanity width
  4252. sanityWidth = table.outerWidth();
  4253. } else if (scrollXInner !== "") {
  4254. // legacy x scroll inner has been given - use it
  4255. tableStyle.width = _fnStringToCss(scrollXInner);
  4256. // Recalculate the sanity width
  4257. sanityWidth = table.outerWidth();
  4258. }
  4259. // Hidden header should have zero height, so remove padding and borders. Then
  4260. // set the width based on the real headers
  4261. // Apply all styles in one pass
  4262. _fnApplyToChildren(zeroOut, headerSrcEls);
  4263. // Read all widths in next pass
  4264. _fnApplyToChildren(function(nSizer) {
  4265. headerContent.push(nSizer.innerHTML);
  4266. headerWidths.push(_fnStringToCss($(nSizer).css('width')));
  4267. }, headerSrcEls);
  4268. // Apply all widths in final pass
  4269. _fnApplyToChildren(function(nToSize, i) {
  4270. // Only apply widths to the DataTables detected header cells - this
  4271. // prevents complex headers from having contradictory sizes applied
  4272. if ($.inArray(nToSize, dtHeaderCells) !== -1) {
  4273. nToSize.style.width = headerWidths[i];
  4274. }
  4275. }, headerTrgEls);
  4276. $(headerSrcEls).height(0);
  4277. /* Same again with the footer if we have one */
  4278. if (footer) {
  4279. _fnApplyToChildren(zeroOut, footerSrcEls);
  4280. _fnApplyToChildren(function(nSizer) {
  4281. footerContent.push(nSizer.innerHTML);
  4282. footerWidths.push(_fnStringToCss($(nSizer).css('width')));
  4283. }, footerSrcEls);
  4284. _fnApplyToChildren(function(nToSize, i) {
  4285. nToSize.style.width = footerWidths[i];
  4286. }, footerTrgEls);
  4287. $(footerSrcEls).height(0);
  4288. }
  4289. /*
  4290. * 3. Apply the measurements
  4291. */
  4292. // "Hide" the header and footer that we used for the sizing. We need to keep
  4293. // the content of the cell so that the width applied to the header and body
  4294. // both match, but we want to hide it completely. We want to also fix their
  4295. // width to what they currently are
  4296. _fnApplyToChildren(function(nSizer, i) {
  4297. nSizer.innerHTML = '<div class="dataTables_sizing" style="height:0;overflow:hidden;">' + headerContent[i] + '</div>';
  4298. nSizer.style.width = headerWidths[i];
  4299. }, headerSrcEls);
  4300. if (footer) {
  4301. _fnApplyToChildren(function(nSizer, i) {
  4302. nSizer.innerHTML = '<div class="dataTables_sizing" style="height:0;overflow:hidden;">' + footerContent[i] + '</div>';
  4303. nSizer.style.width = footerWidths[i];
  4304. }, footerSrcEls);
  4305. }
  4306. // Sanity check that the table is of a sensible width. If not then we are going to get
  4307. // misalignment - try to prevent this by not allowing the table to shrink below its min width
  4308. if (table.outerWidth() < sanityWidth) {
  4309. // The min width depends upon if we have a vertical scrollbar visible or not */
  4310. correction = ((divBodyEl.scrollHeight > divBodyEl.offsetHeight ||
  4311. divBody.css('overflow-y') == "scroll")) ?
  4312. sanityWidth + barWidth :
  4313. sanityWidth;
  4314. // IE6/7 are a law unto themselves...
  4315. if (ie67 && (divBodyEl.scrollHeight >
  4316. divBodyEl.offsetHeight || divBody.css('overflow-y') == "scroll")) {
  4317. tableStyle.width = _fnStringToCss(correction - barWidth);
  4318. }
  4319. // And give the user a warning that we've stopped the table getting too small
  4320. if (scrollX === "" || scrollXInner !== "") {
  4321. _fnLog(settings, 1, 'Possible column misalignment', 6);
  4322. }
  4323. } else {
  4324. correction = '100%';
  4325. }
  4326. // Apply to the container elements
  4327. divBodyStyle.width = _fnStringToCss(correction);
  4328. divHeaderStyle.width = _fnStringToCss(correction);
  4329. if (footer) {
  4330. settings.nScrollFoot.style.width = _fnStringToCss(correction);
  4331. }
  4332. /*
  4333. * 4. Clean up
  4334. */
  4335. if (!scrollY) {
  4336. /* IE7< puts a vertical scrollbar in place (when it shouldn't be) due to subtracting
  4337. * the scrollbar height from the visible display, rather than adding it on. We need to
  4338. * set the height in order to sort this. Don't want to do it in any other browsers.
  4339. */
  4340. if (ie67) {
  4341. divBodyStyle.height = _fnStringToCss(tableEl.offsetHeight + barWidth);
  4342. }
  4343. }
  4344. /* Finally set the width's of the header and footer tables */
  4345. var iOuterWidth = table.outerWidth();
  4346. divHeaderTable[0].style.width = _fnStringToCss(iOuterWidth);
  4347. divHeaderInnerStyle.width = _fnStringToCss(iOuterWidth);
  4348. // Figure out if there are scrollbar present - if so then we need a the header and footer to
  4349. // provide a bit more space to allow "overflow" scrolling (i.e. past the scrollbar)
  4350. var bScrolling = table.height() > divBodyEl.clientHeight || divBody.css('overflow-y') == "scroll";
  4351. var padding = 'padding' + (browser.bScrollbarLeft ? 'Left' : 'Right');
  4352. divHeaderInnerStyle[padding] = bScrolling ? barWidth + "px" : "0px";
  4353. if (footer) {
  4354. divFooterTable[0].style.width = _fnStringToCss(iOuterWidth);
  4355. divFooterInner[0].style.width = _fnStringToCss(iOuterWidth);
  4356. divFooterInner[0].style[padding] = bScrolling ? barWidth + "px" : "0px";
  4357. }
  4358. // Correct DOM ordering for colgroup - comes before the thead
  4359. table.children('colgroup').insertBefore(table.children('thead'));
  4360. /* Adjust the position of the header in case we loose the y-scrollbar */
  4361. divBody.scroll();
  4362. // If sorting or filtering has occurred, jump the scrolling back to the top
  4363. // only if we aren't holding the position
  4364. if ((settings.bSorted || settings.bFiltered) && !settings._drawHold) {
  4365. divBodyEl.scrollTop = 0;
  4366. }
  4367. }
  4368. /**
  4369. * Apply a given function to the display child nodes of an element array (typically
  4370. * TD children of TR rows
  4371. * @param {function} fn Method to apply to the objects
  4372. * @param array {nodes} an1 List of elements to look through for display children
  4373. * @param array {nodes} an2 Another list (identical structure to the first) - optional
  4374. * @memberof DataTable#oApi
  4375. */
  4376. function _fnApplyToChildren(fn, an1, an2) {
  4377. var index = 0,
  4378. i = 0,
  4379. iLen = an1.length;
  4380. var nNode1, nNode2;
  4381. while (i < iLen) {
  4382. nNode1 = an1[i].firstChild;
  4383. nNode2 = an2 ? an2[i].firstChild : null;
  4384. while (nNode1) {
  4385. if (nNode1.nodeType === 1) {
  4386. if (an2) {
  4387. fn(nNode1, nNode2, index);
  4388. } else {
  4389. fn(nNode1, index);
  4390. }
  4391. index++;
  4392. }
  4393. nNode1 = nNode1.nextSibling;
  4394. nNode2 = an2 ? nNode2.nextSibling : null;
  4395. }
  4396. i++;
  4397. }
  4398. }
  4399. var __re_html_remove = /<.*?>/g;
  4400. /**
  4401. * Calculate the width of columns for the table
  4402. * @param {object} oSettings dataTables settings object
  4403. * @memberof DataTable#oApi
  4404. */
  4405. function _fnCalculateColumnWidths(oSettings) {
  4406. var
  4407. table = oSettings.nTable,
  4408. columns = oSettings.aoColumns,
  4409. scroll = oSettings.oScroll,
  4410. scrollY = scroll.sY,
  4411. scrollX = scroll.sX,
  4412. scrollXInner = scroll.sXInner,
  4413. columnCount = columns.length,
  4414. visibleColumns = _fnGetColumns(oSettings, 'bVisible'),
  4415. headerCells = $('th', oSettings.nTHead),
  4416. tableWidthAttr = table.getAttribute('width'), // from DOM element
  4417. tableContainer = table.parentNode,
  4418. userInputs = false,
  4419. i, column, columnIdx, width, outerWidth,
  4420. browser = oSettings.oBrowser,
  4421. ie67 = browser.bScrollOversize;
  4422. var styleWidth = table.style.width;
  4423. if (styleWidth && styleWidth.indexOf('%') !== -1) {
  4424. tableWidthAttr = styleWidth;
  4425. }
  4426. /* Convert any user input sizes into pixel sizes */
  4427. for (i = 0; i < visibleColumns.length; i++) {
  4428. column = columns[visibleColumns[i]];
  4429. if (column.sWidth !== null) {
  4430. column.sWidth = _fnConvertToWidth(column.sWidthOrig, tableContainer);
  4431. userInputs = true;
  4432. }
  4433. }
  4434. /* If the number of columns in the DOM equals the number that we have to
  4435. * process in DataTables, then we can use the offsets that are created by
  4436. * the web- browser. No custom sizes can be set in order for this to happen,
  4437. * nor scrolling used
  4438. */
  4439. if (ie67 || !userInputs && !scrollX && !scrollY &&
  4440. columnCount == _fnVisbleColumns(oSettings) &&
  4441. columnCount == headerCells.length
  4442. ) {
  4443. for (i = 0; i < columnCount; i++) {
  4444. var colIdx = _fnVisibleToColumnIndex(oSettings, i);
  4445. if (colIdx !== null) {
  4446. columns[colIdx].sWidth = _fnStringToCss(headerCells.eq(i).width());
  4447. }
  4448. }
  4449. } else {
  4450. // Otherwise construct a single row, worst case, table with the widest
  4451. // node in the data, assign any user defined widths, then insert it into
  4452. // the DOM and allow the browser to do all the hard work of calculating
  4453. // table widths
  4454. var tmpTable = $(table).clone() // don't use cloneNode - IE8 will remove events on the main table
  4455. .css('visibility', 'hidden')
  4456. .removeAttr('id');
  4457. // Clean up the table body
  4458. tmpTable.find('tbody tr').remove();
  4459. var tr = $('<tr/>').appendTo(tmpTable.find('tbody'));
  4460. // Clone the table header and footer - we can't use the header / footer
  4461. // from the cloned table, since if scrolling is active, the table's
  4462. // real header and footer are contained in different table tags
  4463. tmpTable.find('thead, tfoot').remove();
  4464. tmpTable
  4465. .append($(oSettings.nTHead).clone())
  4466. .append($(oSettings.nTFoot).clone());
  4467. // Remove any assigned widths from the footer (from scrolling)
  4468. tmpTable.find('tfoot th, tfoot td').css('width', '');
  4469. // Apply custom sizing to the cloned header
  4470. headerCells = _fnGetUniqueThs(oSettings, tmpTable.find('thead')[0]);
  4471. for (i = 0; i < visibleColumns.length; i++) {
  4472. column = columns[visibleColumns[i]];
  4473. headerCells[i].style.width = column.sWidthOrig !== null && column.sWidthOrig !== '' ?
  4474. _fnStringToCss(column.sWidthOrig) :
  4475. '';
  4476. // For scrollX we need to force the column width otherwise the
  4477. // browser will collapse it. If this width is smaller than the
  4478. // width the column requires, then it will have no effect
  4479. if (column.sWidthOrig && scrollX) {
  4480. $(headerCells[i]).append($('<div/>').css({
  4481. width: column.sWidthOrig,
  4482. margin: 0,
  4483. padding: 0,
  4484. border: 0,
  4485. height: 1
  4486. }));
  4487. }
  4488. }
  4489. // Find the widest cell for each column and put it into the table
  4490. if (oSettings.aoData.length) {
  4491. for (i = 0; i < visibleColumns.length; i++) {
  4492. columnIdx = visibleColumns[i];
  4493. column = columns[columnIdx];
  4494. $(_fnGetWidestNode(oSettings, columnIdx))
  4495. .clone(false)
  4496. .append(column.sContentPadding)
  4497. .appendTo(tr);
  4498. }
  4499. }
  4500. // Tidy the temporary table - remove name attributes so there aren't
  4501. // duplicated in the dom (radio elements for example)
  4502. $('[name]', tmpTable).removeAttr('name');
  4503. // Table has been built, attach to the document so we can work with it.
  4504. // A holding element is used, positioned at the top of the container
  4505. // with minimal height, so it has no effect on if the container scrolls
  4506. // or not. Otherwise it might trigger scrolling when it actually isn't
  4507. // needed
  4508. var holder = $('<div/>').css(scrollX || scrollY ? {
  4509. position: 'absolute',
  4510. top: 0,
  4511. left: 0,
  4512. height: 1,
  4513. right: 0,
  4514. overflow: 'hidden'
  4515. } : {})
  4516. .append(tmpTable)
  4517. .appendTo(tableContainer);
  4518. // When scrolling (X or Y) we want to set the width of the table as
  4519. // appropriate. However, when not scrolling leave the table width as it
  4520. // is. This results in slightly different, but I think correct behaviour
  4521. if (scrollX && scrollXInner) {
  4522. tmpTable.width(scrollXInner);
  4523. } else if (scrollX) {
  4524. tmpTable.css('width', 'auto');
  4525. tmpTable.removeAttr('width');
  4526. // If there is no width attribute or style, then allow the table to
  4527. // collapse
  4528. if (tmpTable.width() < tableContainer.clientWidth && tableWidthAttr) {
  4529. tmpTable.width(tableContainer.clientWidth);
  4530. }
  4531. } else if (scrollY) {
  4532. tmpTable.width(tableContainer.clientWidth);
  4533. } else if (tableWidthAttr) {
  4534. tmpTable.width(tableWidthAttr);
  4535. }
  4536. // Get the width of each column in the constructed table - we need to
  4537. // know the inner width (so it can be assigned to the other table's
  4538. // cells) and the outer width so we can calculate the full width of the
  4539. // table. This is safe since DataTables requires a unique cell for each
  4540. // column, but if ever a header can span multiple columns, this will
  4541. // need to be modified.
  4542. var total = 0;
  4543. for (i = 0; i < visibleColumns.length; i++) {
  4544. var cell = $(headerCells[i]);
  4545. var border = cell.outerWidth() - cell.width();
  4546. // Use getBounding... where possible (not IE8-) because it can give
  4547. // sub-pixel accuracy, which we then want to round up!
  4548. var bounding = browser.bBounding ?
  4549. Math.ceil(headerCells[i].getBoundingClientRect().width) :
  4550. cell.outerWidth();
  4551. // Total is tracked to remove any sub-pixel errors as the outerWidth
  4552. // of the table might not equal the total given here (IE!).
  4553. total += bounding;
  4554. // Width for each column to use
  4555. columns[visibleColumns[i]].sWidth = _fnStringToCss(bounding - border);
  4556. }
  4557. table.style.width = _fnStringToCss(total);
  4558. // Finished with the table - ditch it
  4559. holder.remove();
  4560. }
  4561. // If there is a width attr, we want to attach an event listener which
  4562. // allows the table sizing to automatically adjust when the window is
  4563. // resized. Use the width attr rather than CSS, since we can't know if the
  4564. // CSS is a relative value or absolute - DOM read is always px.
  4565. if (tableWidthAttr) {
  4566. table.style.width = _fnStringToCss(tableWidthAttr);
  4567. }
  4568. if ((tableWidthAttr || scrollX) && !oSettings._reszEvt) {
  4569. var bindResize = function() {
  4570. $(window).bind('resize.DT-' + oSettings.sInstance, _fnThrottle(function() {
  4571. _fnAdjustColumnSizing(oSettings);
  4572. }));
  4573. };
  4574. // IE6/7 will crash if we bind a resize event handler on page load.
  4575. // To be removed in 1.11 which drops IE6/7 support
  4576. if (ie67) {
  4577. setTimeout(bindResize, 1000);
  4578. } else {
  4579. bindResize();
  4580. }
  4581. oSettings._reszEvt = true;
  4582. }
  4583. }
  4584. /**
  4585. * Throttle the calls to a function. Arguments and context are maintained for
  4586. * the throttled function
  4587. * @param {function} fn Function to be called
  4588. * @param {int} [freq=200] call frequency in mS
  4589. * @returns {function} wrapped function
  4590. * @memberof DataTable#oApi
  4591. */
  4592. var _fnThrottle = DataTable.util.throttle;
  4593. /**
  4594. * Convert a CSS unit width to pixels (e.g. 2em)
  4595. * @param {string} width width to be converted
  4596. * @param {node} parent parent to get the with for (required for relative widths) - optional
  4597. * @returns {int} width in pixels
  4598. * @memberof DataTable#oApi
  4599. */
  4600. function _fnConvertToWidth(width, parent) {
  4601. if (!width) {
  4602. return 0;
  4603. }
  4604. var n = $('<div/>')
  4605. .css('width', _fnStringToCss(width))
  4606. .appendTo(parent || document.body);
  4607. var val = n[0].offsetWidth;
  4608. n.remove();
  4609. return val;
  4610. }
  4611. /**
  4612. * Get the widest node
  4613. * @param {object} settings dataTables settings object
  4614. * @param {int} colIdx column of interest
  4615. * @returns {node} widest table node
  4616. * @memberof DataTable#oApi
  4617. */
  4618. function _fnGetWidestNode(settings, colIdx) {
  4619. var idx = _fnGetMaxLenString(settings, colIdx);
  4620. if (idx < 0) {
  4621. return null;
  4622. }
  4623. var data = settings.aoData[idx];
  4624. return !data.nTr ? // Might not have been created when deferred rendering
  4625. $('<td/>').html(_fnGetCellData(settings, idx, colIdx, 'display'))[0] :
  4626. data.anCells[colIdx];
  4627. }
  4628. /**
  4629. * Get the maximum strlen for each data column
  4630. * @param {object} settings dataTables settings object
  4631. * @param {int} colIdx column of interest
  4632. * @returns {string} max string length for each column
  4633. * @memberof DataTable#oApi
  4634. */
  4635. function _fnGetMaxLenString(settings, colIdx) {
  4636. var s, max = -1,
  4637. maxIdx = -1;
  4638. for (var i = 0, ien = settings.aoData.length; i < ien; i++) {
  4639. s = _fnGetCellData(settings, i, colIdx, 'display') + '';
  4640. s = s.replace(__re_html_remove, '');
  4641. s = s.replace(/&nbsp;/g, ' ');
  4642. if (s.length > max) {
  4643. max = s.length;
  4644. maxIdx = i;
  4645. }
  4646. }
  4647. return maxIdx;
  4648. }
  4649. /**
  4650. * Append a CSS unit (only if required) to a string
  4651. * @param {string} value to css-ify
  4652. * @returns {string} value with css unit
  4653. * @memberof DataTable#oApi
  4654. */
  4655. function _fnStringToCss(s) {
  4656. if (s === null) {
  4657. return '0px';
  4658. }
  4659. if (typeof s == 'number') {
  4660. return s < 0 ?
  4661. '0px' :
  4662. s + 'px';
  4663. }
  4664. // Check it has a unit character already
  4665. return s.match(/\d$/) ?
  4666. s + 'px' :
  4667. s;
  4668. }
  4669. function _fnSortFlatten(settings) {
  4670. var
  4671. i, iLen, k, kLen,
  4672. aSort = [],
  4673. aiOrig = [],
  4674. aoColumns = settings.aoColumns,
  4675. aDataSort, iCol, sType, srcCol,
  4676. fixed = settings.aaSortingFixed,
  4677. fixedObj = $.isPlainObject(fixed),
  4678. nestedSort = [],
  4679. add = function(a) {
  4680. if (a.length && !$.isArray(a[0])) {
  4681. // 1D array
  4682. nestedSort.push(a);
  4683. } else {
  4684. // 2D array
  4685. $.merge(nestedSort, a);
  4686. }
  4687. };
  4688. // Build the sort array, with pre-fix and post-fix options if they have been
  4689. // specified
  4690. if ($.isArray(fixed)) {
  4691. add(fixed);
  4692. }
  4693. if (fixedObj && fixed.pre) {
  4694. add(fixed.pre);
  4695. }
  4696. add(settings.aaSorting);
  4697. if (fixedObj && fixed.post) {
  4698. add(fixed.post);
  4699. }
  4700. for (i = 0; i < nestedSort.length; i++) {
  4701. srcCol = nestedSort[i][0];
  4702. aDataSort = aoColumns[srcCol].aDataSort;
  4703. for (k = 0, kLen = aDataSort.length; k < kLen; k++) {
  4704. iCol = aDataSort[k];
  4705. sType = aoColumns[iCol].sType || 'string';
  4706. if (nestedSort[i]._idx === undefined) {
  4707. nestedSort[i]._idx = $.inArray(nestedSort[i][1], aoColumns[iCol].asSorting);
  4708. }
  4709. aSort.push({
  4710. src: srcCol,
  4711. col: iCol,
  4712. dir: nestedSort[i][1],
  4713. index: nestedSort[i]._idx,
  4714. type: sType,
  4715. formatter: DataTable.ext.type.order[sType + "-pre"]
  4716. });
  4717. }
  4718. }
  4719. return aSort;
  4720. }
  4721. /**
  4722. * Change the order of the table
  4723. * @param {object} oSettings dataTables settings object
  4724. * @memberof DataTable#oApi
  4725. * @todo This really needs split up!
  4726. */
  4727. function _fnSort(oSettings) {
  4728. var
  4729. i, ien, iLen, j, jLen, k, kLen,
  4730. sDataType, nTh,
  4731. aiOrig = [],
  4732. oExtSort = DataTable.ext.type.order,
  4733. aoData = oSettings.aoData,
  4734. aoColumns = oSettings.aoColumns,
  4735. aDataSort, data, iCol, sType, oSort,
  4736. formatters = 0,
  4737. sortCol,
  4738. displayMaster = oSettings.aiDisplayMaster,
  4739. aSort;
  4740. // Resolve any column types that are unknown due to addition or invalidation
  4741. // @todo Can this be moved into a 'data-ready' handler which is called when
  4742. // data is going to be used in the table?
  4743. _fnColumnTypes(oSettings);
  4744. aSort = _fnSortFlatten(oSettings);
  4745. for (i = 0, ien = aSort.length; i < ien; i++) {
  4746. sortCol = aSort[i];
  4747. // Track if we can use the fast sort algorithm
  4748. if (sortCol.formatter) {
  4749. formatters++;
  4750. }
  4751. // Load the data needed for the sort, for each cell
  4752. _fnSortData(oSettings, sortCol.col);
  4753. }
  4754. /* No sorting required if server-side or no sorting array */
  4755. if (_fnDataSource(oSettings) != 'ssp' && aSort.length !== 0) {
  4756. // Create a value - key array of the current row positions such that we can use their
  4757. // current position during the sort, if values match, in order to perform stable sorting
  4758. for (i = 0, iLen = displayMaster.length; i < iLen; i++) {
  4759. aiOrig[displayMaster[i]] = i;
  4760. }
  4761. /* Do the sort - here we want multi-column sorting based on a given data source (column)
  4762. * and sorting function (from oSort) in a certain direction. It's reasonably complex to
  4763. * follow on it's own, but this is what we want (example two column sorting):
  4764. * fnLocalSorting = function(a,b){
  4765. * var iTest;
  4766. * iTest = oSort['string-asc']('data11', 'data12');
  4767. * if (iTest !== 0)
  4768. * return iTest;
  4769. * iTest = oSort['numeric-desc']('data21', 'data22');
  4770. * if (iTest !== 0)
  4771. * return iTest;
  4772. * return oSort['numeric-asc']( aiOrig[a], aiOrig[b] );
  4773. * }
  4774. * Basically we have a test for each sorting column, if the data in that column is equal,
  4775. * test the next column. If all columns match, then we use a numeric sort on the row
  4776. * positions in the original data array to provide a stable sort.
  4777. *
  4778. * Note - I know it seems excessive to have two sorting methods, but the first is around
  4779. * 15% faster, so the second is only maintained for backwards compatibility with sorting
  4780. * methods which do not have a pre-sort formatting function.
  4781. */
  4782. if (formatters === aSort.length) {
  4783. // All sort types have formatting functions
  4784. displayMaster.sort(function(a, b) {
  4785. var
  4786. x, y, k, test, sort,
  4787. len = aSort.length,
  4788. dataA = aoData[a]._aSortData,
  4789. dataB = aoData[b]._aSortData;
  4790. for (k = 0; k < len; k++) {
  4791. sort = aSort[k];
  4792. x = dataA[sort.col];
  4793. y = dataB[sort.col];
  4794. test = x < y ? -1 : x > y ? 1 : 0;
  4795. if (test !== 0) {
  4796. return sort.dir === 'asc' ? test : -test;
  4797. }
  4798. }
  4799. x = aiOrig[a];
  4800. y = aiOrig[b];
  4801. return x < y ? -1 : x > y ? 1 : 0;
  4802. });
  4803. } else {
  4804. // Depreciated - remove in 1.11 (providing a plug-in option)
  4805. // Not all sort types have formatting methods, so we have to call their sorting
  4806. // methods.
  4807. displayMaster.sort(function(a, b) {
  4808. var
  4809. x, y, k, l, test, sort, fn,
  4810. len = aSort.length,
  4811. dataA = aoData[a]._aSortData,
  4812. dataB = aoData[b]._aSortData;
  4813. for (k = 0; k < len; k++) {
  4814. sort = aSort[k];
  4815. x = dataA[sort.col];
  4816. y = dataB[sort.col];
  4817. fn = oExtSort[sort.type + "-" + sort.dir] || oExtSort["string-" + sort.dir];
  4818. test = fn(x, y);
  4819. if (test !== 0) {
  4820. return test;
  4821. }
  4822. }
  4823. x = aiOrig[a];
  4824. y = aiOrig[b];
  4825. return x < y ? -1 : x > y ? 1 : 0;
  4826. });
  4827. }
  4828. }
  4829. /* Tell the draw function that we have sorted the data */
  4830. oSettings.bSorted = true;
  4831. }
  4832. function _fnSortAria(settings) {
  4833. var label;
  4834. var nextSort;
  4835. var columns = settings.aoColumns;
  4836. var aSort = _fnSortFlatten(settings);
  4837. var oAria = settings.oLanguage.oAria;
  4838. // ARIA attributes - need to loop all columns, to update all (removing old
  4839. // attributes as needed)
  4840. for (var i = 0, iLen = columns.length; i < iLen; i++) {
  4841. var col = columns[i];
  4842. var asSorting = col.asSorting;
  4843. var sTitle = col.sTitle.replace(/<.*?>/g, "");
  4844. var th = col.nTh;
  4845. // IE7 is throwing an error when setting these properties with jQuery's
  4846. // attr() and removeAttr() methods...
  4847. th.removeAttribute('aria-sort');
  4848. /* In ARIA only the first sorting column can be marked as sorting - no multi-sort option */
  4849. if (col.bSortable) {
  4850. if (aSort.length > 0 && aSort[0].col == i) {
  4851. th.setAttribute('aria-sort', aSort[0].dir == "asc" ? "ascending" : "descending");
  4852. nextSort = asSorting[aSort[0].index + 1] || asSorting[0];
  4853. } else {
  4854. nextSort = asSorting[0];
  4855. }
  4856. label = sTitle + (nextSort === "asc" ?
  4857. oAria.sSortAscending :
  4858. oAria.sSortDescending
  4859. );
  4860. } else {
  4861. label = sTitle;
  4862. }
  4863. th.setAttribute('aria-label', label);
  4864. }
  4865. }
  4866. /**
  4867. * Function to run on user sort request
  4868. * @param {object} settings dataTables settings object
  4869. * @param {node} attachTo node to attach the handler to
  4870. * @param {int} colIdx column sorting index
  4871. * @param {boolean} [append=false] Append the requested sort to the existing
  4872. * sort if true (i.e. multi-column sort)
  4873. * @param {function} [callback] callback function
  4874. * @memberof DataTable#oApi
  4875. */
  4876. function _fnSortListener(settings, colIdx, append, callback) {
  4877. var col = settings.aoColumns[colIdx];
  4878. var sorting = settings.aaSorting;
  4879. var asSorting = col.asSorting;
  4880. var nextSortIdx;
  4881. var next = function(a, overflow) {
  4882. var idx = a._idx;
  4883. if (idx === undefined) {
  4884. idx = $.inArray(a[1], asSorting);
  4885. }
  4886. return idx + 1 < asSorting.length ?
  4887. idx + 1 :
  4888. overflow ?
  4889. null :
  4890. 0;
  4891. };
  4892. // Convert to 2D array if needed
  4893. if (typeof sorting[0] === 'number') {
  4894. sorting = settings.aaSorting = [sorting];
  4895. }
  4896. // If appending the sort then we are multi-column sorting
  4897. if (append && settings.oFeatures.bSortMulti) {
  4898. // Are we already doing some kind of sort on this column?
  4899. var sortIdx = $.inArray(colIdx, _pluck(sorting, '0'));
  4900. if (sortIdx !== -1) {
  4901. // Yes, modify the sort
  4902. nextSortIdx = next(sorting[sortIdx], true);
  4903. if (nextSortIdx === null && sorting.length === 1) {
  4904. nextSortIdx = 0; // can't remove sorting completely
  4905. }
  4906. if (nextSortIdx === null) {
  4907. sorting.splice(sortIdx, 1);
  4908. } else {
  4909. sorting[sortIdx][1] = asSorting[nextSortIdx];
  4910. sorting[sortIdx]._idx = nextSortIdx;
  4911. }
  4912. } else {
  4913. // No sort on this column yet
  4914. sorting.push([colIdx, asSorting[0], 0]);
  4915. sorting[sorting.length - 1]._idx = 0;
  4916. }
  4917. } else if (sorting.length && sorting[0][0] == colIdx) {
  4918. // Single column - already sorting on this column, modify the sort
  4919. nextSortIdx = next(sorting[0]);
  4920. sorting.length = 1;
  4921. sorting[0][1] = asSorting[nextSortIdx];
  4922. sorting[0]._idx = nextSortIdx;
  4923. } else {
  4924. // Single column - sort only on this column
  4925. sorting.length = 0;
  4926. sorting.push([colIdx, asSorting[0]]);
  4927. sorting[0]._idx = 0;
  4928. }
  4929. // Run the sort by calling a full redraw
  4930. _fnReDraw(settings);
  4931. // callback used for async user interaction
  4932. if (typeof callback == 'function') {
  4933. callback(settings);
  4934. }
  4935. }
  4936. /**
  4937. * Attach a sort handler (click) to a node
  4938. * @param {object} settings dataTables settings object
  4939. * @param {node} attachTo node to attach the handler to
  4940. * @param {int} colIdx column sorting index
  4941. * @param {function} [callback] callback function
  4942. * @memberof DataTable#oApi
  4943. */
  4944. function _fnSortAttachListener(settings, attachTo, colIdx, callback) {
  4945. var col = settings.aoColumns[colIdx];
  4946. _fnBindAction(attachTo, {}, function(e) {
  4947. /* If the column is not sortable - don't to anything */
  4948. if (col.bSortable === false) {
  4949. return;
  4950. }
  4951. // If processing is enabled use a timeout to allow the processing
  4952. // display to be shown - otherwise to it synchronously
  4953. if (settings.oFeatures.bProcessing) {
  4954. _fnProcessingDisplay(settings, true);
  4955. setTimeout(function() {
  4956. _fnSortListener(settings, colIdx, e.shiftKey, callback);
  4957. // In server-side processing, the draw callback will remove the
  4958. // processing display
  4959. if (_fnDataSource(settings) !== 'ssp') {
  4960. _fnProcessingDisplay(settings, false);
  4961. }
  4962. }, 0);
  4963. } else {
  4964. _fnSortListener(settings, colIdx, e.shiftKey, callback);
  4965. }
  4966. });
  4967. }
  4968. /**
  4969. * Set the sorting classes on table's body, Note: it is safe to call this function
  4970. * when bSort and bSortClasses are false
  4971. * @param {object} oSettings dataTables settings object
  4972. * @memberof DataTable#oApi
  4973. */
  4974. function _fnSortingClasses(settings) {
  4975. var oldSort = settings.aLastSort;
  4976. var sortClass = settings.oClasses.sSortColumn;
  4977. var sort = _fnSortFlatten(settings);
  4978. var features = settings.oFeatures;
  4979. var i, ien, colIdx;
  4980. if (features.bSort && features.bSortClasses) {
  4981. // Remove old sorting classes
  4982. for (i = 0, ien = oldSort.length; i < ien; i++) {
  4983. colIdx = oldSort[i].src;
  4984. // Remove column sorting
  4985. $(_pluck(settings.aoData, 'anCells', colIdx))
  4986. .removeClass(sortClass + (i < 2 ? i + 1 : 3));
  4987. }
  4988. // Add new column sorting
  4989. for (i = 0, ien = sort.length; i < ien; i++) {
  4990. colIdx = sort[i].src;
  4991. $(_pluck(settings.aoData, 'anCells', colIdx))
  4992. .addClass(sortClass + (i < 2 ? i + 1 : 3));
  4993. }
  4994. }
  4995. settings.aLastSort = sort;
  4996. }
  4997. // Get the data to sort a column, be it from cache, fresh (populating the
  4998. // cache), or from a sort formatter
  4999. function _fnSortData(settings, idx) {
  5000. // Custom sorting function - provided by the sort data type
  5001. var column = settings.aoColumns[idx];
  5002. var customSort = DataTable.ext.order[column.sSortDataType];
  5003. var customData;
  5004. if (customSort) {
  5005. customData = customSort.call(settings.oInstance, settings, idx,
  5006. _fnColumnIndexToVisible(settings, idx)
  5007. );
  5008. }
  5009. // Use / populate cache
  5010. var row, cellData;
  5011. var formatter = DataTable.ext.type.order[column.sType + "-pre"];
  5012. for (var i = 0, ien = settings.aoData.length; i < ien; i++) {
  5013. row = settings.aoData[i];
  5014. if (!row._aSortData) {
  5015. row._aSortData = [];
  5016. }
  5017. if (!row._aSortData[idx] || customSort) {
  5018. cellData = customSort ?
  5019. customData[i] : // If there was a custom sort function, use data from there
  5020. _fnGetCellData(settings, i, idx, 'sort');
  5021. row._aSortData[idx] = formatter ?
  5022. formatter(cellData) :
  5023. cellData;
  5024. }
  5025. }
  5026. }
  5027. /**
  5028. * Save the state of a table
  5029. * @param {object} oSettings dataTables settings object
  5030. * @memberof DataTable#oApi
  5031. */
  5032. function _fnSaveState(settings) {
  5033. if (!settings.oFeatures.bStateSave || settings.bDestroying) {
  5034. return;
  5035. }
  5036. /* Store the interesting variables */
  5037. var state = {
  5038. time: +new Date(),
  5039. start: settings._iDisplayStart,
  5040. length: settings._iDisplayLength,
  5041. order: $.extend(true, [], settings.aaSorting),
  5042. search: _fnSearchToCamel(settings.oPreviousSearch),
  5043. columns: $.map(settings.aoColumns, function(col, i) {
  5044. return {
  5045. visible: col.bVisible,
  5046. search: _fnSearchToCamel(settings.aoPreSearchCols[i])
  5047. };
  5048. })
  5049. };
  5050. _fnCallbackFire(settings, "aoStateSaveParams", 'stateSaveParams', [settings, state]);
  5051. settings.oSavedState = state;
  5052. settings.fnStateSaveCallback.call(settings.oInstance, settings, state);
  5053. }
  5054. /**
  5055. * Attempt to load a saved table state
  5056. * @param {object} oSettings dataTables settings object
  5057. * @param {object} oInit DataTables init object so we can override settings
  5058. * @memberof DataTable#oApi
  5059. */
  5060. function _fnLoadState(settings, oInit) {
  5061. var i, ien;
  5062. var columns = settings.aoColumns;
  5063. if (!settings.oFeatures.bStateSave) {
  5064. return;
  5065. }
  5066. var state = settings.fnStateLoadCallback.call(settings.oInstance, settings);
  5067. if (!state || !state.time) {
  5068. return;
  5069. }
  5070. /* Allow custom and plug-in manipulation functions to alter the saved data set and
  5071. * cancelling of loading by returning false
  5072. */
  5073. var abStateLoad = _fnCallbackFire(settings, 'aoStateLoadParams', 'stateLoadParams', [settings, state]);
  5074. if ($.inArray(false, abStateLoad) !== -1) {
  5075. return;
  5076. }
  5077. /* Reject old data */
  5078. var duration = settings.iStateDuration;
  5079. if (duration > 0 && state.time < +new Date() - (duration * 1000)) {
  5080. return;
  5081. }
  5082. // Number of columns have changed - all bets are off, no restore of settings
  5083. if (columns.length !== state.columns.length) {
  5084. return;
  5085. }
  5086. // Store the saved state so it might be accessed at any time
  5087. settings.oLoadedState = $.extend(true, {}, state);
  5088. // Restore key features - todo - for 1.11 this needs to be done by
  5089. // subscribed events
  5090. if (state.start !== undefined) {
  5091. settings._iDisplayStart = state.start;
  5092. settings.iInitDisplayStart = state.start;
  5093. }
  5094. if (state.length !== undefined) {
  5095. settings._iDisplayLength = state.length;
  5096. }
  5097. // Order
  5098. if (state.order !== undefined) {
  5099. settings.aaSorting = [];
  5100. $.each(state.order, function(i, col) {
  5101. settings.aaSorting.push(col[0] >= columns.length ? [0, col[1]] :
  5102. col
  5103. );
  5104. });
  5105. }
  5106. // Search
  5107. if (state.search !== undefined) {
  5108. $.extend(settings.oPreviousSearch, _fnSearchToHung(state.search));
  5109. }
  5110. // Columns
  5111. for (i = 0, ien = state.columns.length; i < ien; i++) {
  5112. var col = state.columns[i];
  5113. // Visibility
  5114. if (col.visible !== undefined) {
  5115. columns[i].bVisible = col.visible;
  5116. }
  5117. // Search
  5118. if (col.search !== undefined) {
  5119. $.extend(settings.aoPreSearchCols[i], _fnSearchToHung(col.search));
  5120. }
  5121. }
  5122. _fnCallbackFire(settings, 'aoStateLoaded', 'stateLoaded', [settings, state]);
  5123. }
  5124. /**
  5125. * Return the settings object for a particular table
  5126. * @param {node} table table we are using as a dataTable
  5127. * @returns {object} Settings object - or null if not found
  5128. * @memberof DataTable#oApi
  5129. */
  5130. function _fnSettingsFromNode(table) {
  5131. var settings = DataTable.settings;
  5132. var idx = $.inArray(table, _pluck(settings, 'nTable'));
  5133. return idx !== -1 ?
  5134. settings[idx] :
  5135. null;
  5136. }
  5137. /**
  5138. * Log an error message
  5139. * @param {object} settings dataTables settings object
  5140. * @param {int} level log error messages, or display them to the user
  5141. * @param {string} msg error message
  5142. * @param {int} tn Technical note id to get more information about the error.
  5143. * @memberof DataTable#oApi
  5144. */
  5145. function _fnLog(settings, level, msg, tn) {
  5146. msg = 'DataTables warning: ' +
  5147. (settings ? 'table id=' + settings.sTableId + ' - ' : '') + msg;
  5148. if (tn) {
  5149. msg += '. For more information about this error, please see ' +
  5150. 'http://datatables.net/tn/' + tn;
  5151. }
  5152. if (!level) {
  5153. // Backwards compatibility pre 1.10
  5154. var ext = DataTable.ext;
  5155. var type = ext.sErrMode || ext.errMode;
  5156. if (settings) {
  5157. _fnCallbackFire(settings, null, 'error', [settings, tn, msg]);
  5158. }
  5159. if (type == 'alert') {
  5160. alert(msg);
  5161. } else if (type == 'throw') {
  5162. throw new Error(msg);
  5163. } else if (typeof type == 'function') {
  5164. type(settings, tn, msg);
  5165. }
  5166. } else if (window.console && console.log) {
  5167. console.log(msg);
  5168. }
  5169. }
  5170. /**
  5171. * See if a property is defined on one object, if so assign it to the other object
  5172. * @param {object} ret target object
  5173. * @param {object} src source object
  5174. * @param {string} name property
  5175. * @param {string} [mappedName] name to map too - optional, name used if not given
  5176. * @memberof DataTable#oApi
  5177. */
  5178. function _fnMap(ret, src, name, mappedName) {
  5179. if ($.isArray(name)) {
  5180. $.each(name, function(i, val) {
  5181. if ($.isArray(val)) {
  5182. _fnMap(ret, src, val[0], val[1]);
  5183. } else {
  5184. _fnMap(ret, src, val);
  5185. }
  5186. });
  5187. return;
  5188. }
  5189. if (mappedName === undefined) {
  5190. mappedName = name;
  5191. }
  5192. if (src[name] !== undefined) {
  5193. ret[mappedName] = src[name];
  5194. }
  5195. }
  5196. /**
  5197. * Extend objects - very similar to jQuery.extend, but deep copy objects, and
  5198. * shallow copy arrays. The reason we need to do this, is that we don't want to
  5199. * deep copy array init values (such as aaSorting) since the dev wouldn't be
  5200. * able to override them, but we do want to deep copy arrays.
  5201. * @param {object} out Object to extend
  5202. * @param {object} extender Object from which the properties will be applied to
  5203. * out
  5204. * @param {boolean} breakRefs If true, then arrays will be sliced to take an
  5205. * independent copy with the exception of the `data` or `aaData` parameters
  5206. * if they are present. This is so you can pass in a collection to
  5207. * DataTables and have that used as your data source without breaking the
  5208. * references
  5209. * @returns {object} out Reference, just for convenience - out === the return.
  5210. * @memberof DataTable#oApi
  5211. * @todo This doesn't take account of arrays inside the deep copied objects.
  5212. */
  5213. function _fnExtend(out, extender, breakRefs) {
  5214. var val;
  5215. for (var prop in extender) {
  5216. if (extender.hasOwnProperty(prop)) {
  5217. val = extender[prop];
  5218. if ($.isPlainObject(val)) {
  5219. if (!$.isPlainObject(out[prop])) {
  5220. out[prop] = {};
  5221. }
  5222. $.extend(true, out[prop], val);
  5223. } else if (breakRefs && prop !== 'data' && prop !== 'aaData' && $.isArray(val)) {
  5224. out[prop] = val.slice();
  5225. } else {
  5226. out[prop] = val;
  5227. }
  5228. }
  5229. }
  5230. return out;
  5231. }
  5232. /**
  5233. * Bind an event handers to allow a click or return key to activate the callback.
  5234. * This is good for accessibility since a return on the keyboard will have the
  5235. * same effect as a click, if the element has focus.
  5236. * @param {element} n Element to bind the action to
  5237. * @param {object} oData Data object to pass to the triggered function
  5238. * @param {function} fn Callback function for when the event is triggered
  5239. * @memberof DataTable#oApi
  5240. */
  5241. function _fnBindAction(n, oData, fn) {
  5242. $(n)
  5243. .bind('click.DT', oData, function(e) {
  5244. n.blur(); // Remove focus outline for mouse users
  5245. fn(e);
  5246. })
  5247. .bind('keypress.DT', oData, function(e) {
  5248. if (e.which === 13) {
  5249. e.preventDefault();
  5250. fn(e);
  5251. }
  5252. })
  5253. .bind('selectstart.DT', function() {
  5254. /* Take the brutal approach to cancelling text selection */
  5255. return false;
  5256. });
  5257. }
  5258. /**
  5259. * Register a callback function. Easily allows a callback function to be added to
  5260. * an array store of callback functions that can then all be called together.
  5261. * @param {object} oSettings dataTables settings object
  5262. * @param {string} sStore Name of the array storage for the callbacks in oSettings
  5263. * @param {function} fn Function to be called back
  5264. * @param {string} sName Identifying name for the callback (i.e. a label)
  5265. * @memberof DataTable#oApi
  5266. */
  5267. function _fnCallbackReg(oSettings, sStore, fn, sName) {
  5268. if (fn) {
  5269. oSettings[sStore].push({
  5270. "fn": fn,
  5271. "sName": sName
  5272. });
  5273. }
  5274. }
  5275. /**
  5276. * Fire callback functions and trigger events. Note that the loop over the
  5277. * callback array store is done backwards! Further note that you do not want to
  5278. * fire off triggers in time sensitive applications (for example cell creation)
  5279. * as its slow.
  5280. * @param {object} settings dataTables settings object
  5281. * @param {string} callbackArr Name of the array storage for the callbacks in
  5282. * oSettings
  5283. * @param {string} eventName Name of the jQuery custom event to trigger. If
  5284. * null no trigger is fired
  5285. * @param {array} args Array of arguments to pass to the callback function /
  5286. * trigger
  5287. * @memberof DataTable#oApi
  5288. */
  5289. function _fnCallbackFire(settings, callbackArr, eventName, args) {
  5290. var ret = [];
  5291. if (callbackArr) {
  5292. ret = $.map(settings[callbackArr].slice().reverse(), function(val, i) {
  5293. return val.fn.apply(settings.oInstance, args);
  5294. });
  5295. }
  5296. if (eventName !== null) {
  5297. var e = $.Event(eventName + '.dt');
  5298. $(settings.nTable).trigger(e, args);
  5299. ret.push(e.result);
  5300. }
  5301. return ret;
  5302. }
  5303. function _fnLengthOverflow(settings) {
  5304. var
  5305. start = settings._iDisplayStart,
  5306. end = settings.fnDisplayEnd(),
  5307. len = settings._iDisplayLength;
  5308. /* If we have space to show extra rows (backing up from the end point - then do so */
  5309. if (start >= end) {
  5310. start = end - len;
  5311. }
  5312. // Keep the start record on the current page
  5313. start -= (start % len);
  5314. if (len === -1 || start < 0) {
  5315. start = 0;
  5316. }
  5317. settings._iDisplayStart = start;
  5318. }
  5319. function _fnRenderer(settings, type) {
  5320. var renderer = settings.renderer;
  5321. var host = DataTable.ext.renderer[type];
  5322. if ($.isPlainObject(renderer) && renderer[type]) {
  5323. // Specific renderer for this type. If available use it, otherwise use
  5324. // the default.
  5325. return host[renderer[type]] || host._;
  5326. } else if (typeof renderer === 'string') {
  5327. // Common renderer - if there is one available for this type use it,
  5328. // otherwise use the default
  5329. return host[renderer] || host._;
  5330. }
  5331. // Use the default
  5332. return host._;
  5333. }
  5334. /**
  5335. * Detect the data source being used for the table. Used to simplify the code
  5336. * a little (ajax) and to make it compress a little smaller.
  5337. *
  5338. * @param {object} settings dataTables settings object
  5339. * @returns {string} Data source
  5340. * @memberof DataTable#oApi
  5341. */
  5342. function _fnDataSource(settings) {
  5343. if (settings.oFeatures.bServerSide) {
  5344. return 'ssp';
  5345. } else if (settings.ajax || settings.sAjaxSource) {
  5346. return 'ajax';
  5347. }
  5348. return 'dom';
  5349. }
  5350. /**
  5351. * Computed structure of the DataTables API, defined by the options passed to
  5352. * `DataTable.Api.register()` when building the API.
  5353. *
  5354. * The structure is built in order to speed creation and extension of the Api
  5355. * objects since the extensions are effectively pre-parsed.
  5356. *
  5357. * The array is an array of objects with the following structure, where this
  5358. * base array represents the Api prototype base:
  5359. *
  5360. * [
  5361. * {
  5362. * name: 'data' -- string - Property name
  5363. * val: function () {}, -- function - Api method (or undefined if just an object
  5364. * methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  5365. * propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  5366. * },
  5367. * {
  5368. * name: 'row'
  5369. * val: {},
  5370. * methodExt: [ ... ],
  5371. * propExt: [
  5372. * {
  5373. * name: 'data'
  5374. * val: function () {},
  5375. * methodExt: [ ... ],
  5376. * propExt: [ ... ]
  5377. * },
  5378. * ...
  5379. * ]
  5380. * }
  5381. * ]
  5382. *
  5383. * @type {Array}
  5384. * @ignore
  5385. */
  5386. var __apiStruct = [];
  5387. /**
  5388. * `Array.prototype` reference.
  5389. *
  5390. * @type object
  5391. * @ignore
  5392. */
  5393. var __arrayProto = Array.prototype;
  5394. /**
  5395. * Abstraction for `context` parameter of the `Api` constructor to allow it to
  5396. * take several different forms for ease of use.
  5397. *
  5398. * Each of the input parameter types will be converted to a DataTables settings
  5399. * object where possible.
  5400. *
  5401. * @param {string|node|jQuery|object} mixed DataTable identifier. Can be one
  5402. * of:
  5403. *
  5404. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5405. * with be found and used.
  5406. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5407. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5408. * * `object` - DataTables settings object
  5409. * * `DataTables.Api` - API instance
  5410. * @return {array|null} Matching DataTables settings objects. `null` or
  5411. * `undefined` is returned if no matching DataTable is found.
  5412. * @ignore
  5413. */
  5414. var _toSettings = function(mixed) {
  5415. var idx, jq;
  5416. var settings = DataTable.settings;
  5417. var tables = $.map(settings, function(el, i) {
  5418. return el.nTable;
  5419. });
  5420. if (!mixed) {
  5421. return [];
  5422. } else if (mixed.nTable && mixed.oApi) {
  5423. // DataTables settings object
  5424. return [mixed];
  5425. } else if (mixed.nodeName && mixed.nodeName.toLowerCase() === 'table') {
  5426. // Table node
  5427. idx = $.inArray(mixed, tables);
  5428. return idx !== -1 ? [settings[idx]] : null;
  5429. } else if (mixed && typeof mixed.settings === 'function') {
  5430. return mixed.settings().toArray();
  5431. } else if (typeof mixed === 'string') {
  5432. // jQuery selector
  5433. jq = $(mixed);
  5434. } else if (mixed instanceof $) {
  5435. // jQuery object (also DataTables instance)
  5436. jq = mixed;
  5437. }
  5438. if (jq) {
  5439. return jq.map(function(i) {
  5440. idx = $.inArray(this, tables);
  5441. return idx !== -1 ? settings[idx] : null;
  5442. }).toArray();
  5443. }
  5444. };
  5445. /**
  5446. * DataTables API class - used to control and interface with one or more
  5447. * DataTables enhanced tables.
  5448. *
  5449. * The API class is heavily based on jQuery, presenting a chainable interface
  5450. * that you can use to interact with tables. Each instance of the API class has
  5451. * a "context" - i.e. the tables that it will operate on. This could be a single
  5452. * table, all tables on a page or a sub-set thereof.
  5453. *
  5454. * Additionally the API is designed to allow you to easily work with the data in
  5455. * the tables, retrieving and manipulating it as required. This is done by
  5456. * presenting the API class as an array like interface. The contents of the
  5457. * array depend upon the actions requested by each method (for example
  5458. * `rows().nodes()` will return an array of nodes, while `rows().data()` will
  5459. * return an array of objects or arrays depending upon your table's
  5460. * configuration). The API object has a number of array like methods (`push`,
  5461. * `pop`, `reverse` etc) as well as additional helper methods (`each`, `pluck`,
  5462. * `unique` etc) to assist your working with the data held in a table.
  5463. *
  5464. * Most methods (those which return an Api instance) are chainable, which means
  5465. * the return from a method call also has all of the methods available that the
  5466. * top level object had. For example, these two calls are equivalent:
  5467. *
  5468. * // Not chained
  5469. * api.row.add( {...} );
  5470. * api.draw();
  5471. *
  5472. * // Chained
  5473. * api.row.add( {...} ).draw();
  5474. *
  5475. * @class DataTable.Api
  5476. * @param {array|object|string|jQuery} context DataTable identifier. This is
  5477. * used to define which DataTables enhanced tables this API will operate on.
  5478. * Can be one of:
  5479. *
  5480. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5481. * with be found and used.
  5482. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5483. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5484. * * `object` - DataTables settings object
  5485. * @param {array} [data] Data to initialise the Api instance with.
  5486. *
  5487. * @example
  5488. * // Direct initialisation during DataTables construction
  5489. * var api = $('#example').DataTable();
  5490. *
  5491. * @example
  5492. * // Initialisation using a DataTables jQuery object
  5493. * var api = $('#example').dataTable().api();
  5494. *
  5495. * @example
  5496. * // Initialisation as a constructor
  5497. * var api = new $.fn.DataTable.Api( 'table.dataTable' );
  5498. */
  5499. _Api = function(context, data) {
  5500. if (!(this instanceof _Api)) {
  5501. return new _Api(context, data);
  5502. }
  5503. var settings = [];
  5504. var ctxSettings = function(o) {
  5505. var a = _toSettings(o);
  5506. if (a) {
  5507. settings = settings.concat(a);
  5508. }
  5509. };
  5510. if ($.isArray(context)) {
  5511. for (var i = 0, ien = context.length; i < ien; i++) {
  5512. ctxSettings(context[i]);
  5513. }
  5514. } else {
  5515. ctxSettings(context);
  5516. }
  5517. // Remove duplicates
  5518. this.context = _unique(settings);
  5519. // Initial data
  5520. if (data) {
  5521. $.merge(this, data);
  5522. }
  5523. // selector
  5524. this.selector = {
  5525. rows: null,
  5526. cols: null,
  5527. opts: null
  5528. };
  5529. _Api.extend(this, this, __apiStruct);
  5530. };
  5531. DataTable.Api = _Api;
  5532. // Don't destroy the existing prototype, just extend it. Required for jQuery 2's
  5533. // isPlainObject.
  5534. $.extend(_Api.prototype, {
  5535. any: function() {
  5536. return this.count() !== 0;
  5537. },
  5538. concat: __arrayProto.concat,
  5539. context: [], // array of table settings objects
  5540. count: function() {
  5541. return this.flatten().length;
  5542. },
  5543. each: function(fn) {
  5544. for (var i = 0, ien = this.length; i < ien; i++) {
  5545. fn.call(this, this[i], i, this);
  5546. }
  5547. return this;
  5548. },
  5549. eq: function(idx) {
  5550. var ctx = this.context;
  5551. return ctx.length > idx ?
  5552. new _Api(ctx[idx], this[idx]) :
  5553. null;
  5554. },
  5555. filter: function(fn) {
  5556. var a = [];
  5557. if (__arrayProto.filter) {
  5558. a = __arrayProto.filter.call(this, fn, this);
  5559. } else {
  5560. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  5561. for (var i = 0, ien = this.length; i < ien; i++) {
  5562. if (fn.call(this, this[i], i, this)) {
  5563. a.push(this[i]);
  5564. }
  5565. }
  5566. }
  5567. return new _Api(this.context, a);
  5568. },
  5569. flatten: function() {
  5570. var a = [];
  5571. return new _Api(this.context, a.concat.apply(a, this.toArray()));
  5572. },
  5573. join: __arrayProto.join,
  5574. indexOf: __arrayProto.indexOf || function(obj, start) {
  5575. for (var i = (start || 0), ien = this.length; i < ien; i++) {
  5576. if (this[i] === obj) {
  5577. return i;
  5578. }
  5579. }
  5580. return -1;
  5581. },
  5582. iterator: function(flatten, type, fn, alwaysNew) {
  5583. var
  5584. a = [],
  5585. ret,
  5586. i, ien, j, jen,
  5587. context = this.context,
  5588. rows, items, item,
  5589. selector = this.selector;
  5590. // Argument shifting
  5591. if (typeof flatten === 'string') {
  5592. alwaysNew = fn;
  5593. fn = type;
  5594. type = flatten;
  5595. flatten = false;
  5596. }
  5597. for (i = 0, ien = context.length; i < ien; i++) {
  5598. var apiInst = new _Api(context[i]);
  5599. if (type === 'table') {
  5600. ret = fn.call(apiInst, context[i], i);
  5601. if (ret !== undefined) {
  5602. a.push(ret);
  5603. }
  5604. } else if (type === 'columns' || type === 'rows') {
  5605. // this has same length as context - one entry for each table
  5606. ret = fn.call(apiInst, context[i], this[i], i);
  5607. if (ret !== undefined) {
  5608. a.push(ret);
  5609. }
  5610. } else if (type === 'column' || type === 'column-rows' || type === 'row' || type === 'cell') {
  5611. // columns and rows share the same structure.
  5612. // 'this' is an array of column indexes for each context
  5613. items = this[i];
  5614. if (type === 'column-rows') {
  5615. rows = _selector_row_indexes(context[i], selector.opts);
  5616. }
  5617. for (j = 0, jen = items.length; j < jen; j++) {
  5618. item = items[j];
  5619. if (type === 'cell') {
  5620. ret = fn.call(apiInst, context[i], item.row, item.column, i, j);
  5621. } else {
  5622. ret = fn.call(apiInst, context[i], item, i, j, rows);
  5623. }
  5624. if (ret !== undefined) {
  5625. a.push(ret);
  5626. }
  5627. }
  5628. }
  5629. }
  5630. if (a.length || alwaysNew) {
  5631. var api = new _Api(context, flatten ? a.concat.apply([], a) : a);
  5632. var apiSelector = api.selector;
  5633. apiSelector.rows = selector.rows;
  5634. apiSelector.cols = selector.cols;
  5635. apiSelector.opts = selector.opts;
  5636. return api;
  5637. }
  5638. return this;
  5639. },
  5640. lastIndexOf: __arrayProto.lastIndexOf || function(obj, start) {
  5641. // Bit cheeky...
  5642. return this.indexOf.apply(this.toArray.reverse(), arguments);
  5643. },
  5644. length: 0,
  5645. map: function(fn) {
  5646. var a = [];
  5647. if (__arrayProto.map) {
  5648. a = __arrayProto.map.call(this, fn, this);
  5649. } else {
  5650. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  5651. for (var i = 0, ien = this.length; i < ien; i++) {
  5652. a.push(fn.call(this, this[i], i));
  5653. }
  5654. }
  5655. return new _Api(this.context, a);
  5656. },
  5657. pluck: function(prop) {
  5658. return this.map(function(el) {
  5659. return el[prop];
  5660. });
  5661. },
  5662. pop: __arrayProto.pop,
  5663. push: __arrayProto.push,
  5664. // Does not return an API instance
  5665. reduce: __arrayProto.reduce || function(fn, init) {
  5666. return _fnReduce(this, fn, init, 0, this.length, 1);
  5667. },
  5668. reduceRight: __arrayProto.reduceRight || function(fn, init) {
  5669. return _fnReduce(this, fn, init, this.length - 1, -1, -1);
  5670. },
  5671. reverse: __arrayProto.reverse,
  5672. // Object with rows, columns and opts
  5673. selector: null,
  5674. shift: __arrayProto.shift,
  5675. sort: __arrayProto.sort, // ? name - order?
  5676. splice: __arrayProto.splice,
  5677. toArray: function() {
  5678. return __arrayProto.slice.call(this);
  5679. },
  5680. to$: function() {
  5681. return $(this);
  5682. },
  5683. toJQuery: function() {
  5684. return $(this);
  5685. },
  5686. unique: function() {
  5687. return new _Api(this.context, _unique(this));
  5688. },
  5689. unshift: __arrayProto.unshift
  5690. });
  5691. _Api.extend = function(scope, obj, ext) {
  5692. // Only extend API instances and static properties of the API
  5693. if (!ext.length || !obj || (!(obj instanceof _Api) && !obj.__dt_wrapper)) {
  5694. return;
  5695. }
  5696. var
  5697. i, ien,
  5698. j, jen,
  5699. struct, inner,
  5700. methodScoping = function(scope, fn, struc) {
  5701. return function() {
  5702. var ret = fn.apply(scope, arguments);
  5703. // Method extension
  5704. _Api.extend(ret, ret, struc.methodExt);
  5705. return ret;
  5706. };
  5707. };
  5708. for (i = 0, ien = ext.length; i < ien; i++) {
  5709. struct = ext[i];
  5710. // Value
  5711. obj[struct.name] = typeof struct.val === 'function' ?
  5712. methodScoping(scope, struct.val, struct) :
  5713. $.isPlainObject(struct.val) ? {} :
  5714. struct.val;
  5715. obj[struct.name].__dt_wrapper = true;
  5716. // Property extension
  5717. _Api.extend(scope, obj[struct.name], struct.propExt);
  5718. }
  5719. };
  5720. // @todo - Is there need for an augment function?
  5721. // _Api.augment = function ( inst, name )
  5722. // {
  5723. // // Find src object in the structure from the name
  5724. // var parts = name.split('.');
  5725. // _Api.extend( inst, obj );
  5726. // };
  5727. // [
  5728. // {
  5729. // name: 'data' -- string - Property name
  5730. // val: function () {}, -- function - Api method (or undefined if just an object
  5731. // methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  5732. // propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  5733. // },
  5734. // {
  5735. // name: 'row'
  5736. // val: {},
  5737. // methodExt: [ ... ],
  5738. // propExt: [
  5739. // {
  5740. // name: 'data'
  5741. // val: function () {},
  5742. // methodExt: [ ... ],
  5743. // propExt: [ ... ]
  5744. // },
  5745. // ...
  5746. // ]
  5747. // }
  5748. // ]
  5749. _Api.register = _api_register = function(name, val) {
  5750. if ($.isArray(name)) {
  5751. for (var j = 0, jen = name.length; j < jen; j++) {
  5752. _Api.register(name[j], val);
  5753. }
  5754. return;
  5755. }
  5756. var
  5757. i, ien,
  5758. heir = name.split('.'),
  5759. struct = __apiStruct,
  5760. key, method;
  5761. var find = function(src, name) {
  5762. for (var i = 0, ien = src.length; i < ien; i++) {
  5763. if (src[i].name === name) {
  5764. return src[i];
  5765. }
  5766. }
  5767. return null;
  5768. };
  5769. for (i = 0, ien = heir.length; i < ien; i++) {
  5770. method = heir[i].indexOf('()') !== -1;
  5771. key = method ?
  5772. heir[i].replace('()', '') :
  5773. heir[i];
  5774. var src = find(struct, key);
  5775. if (!src) {
  5776. src = {
  5777. name: key,
  5778. val: {},
  5779. methodExt: [],
  5780. propExt: []
  5781. };
  5782. struct.push(src);
  5783. }
  5784. if (i === ien - 1) {
  5785. src.val = val;
  5786. } else {
  5787. struct = method ?
  5788. src.methodExt :
  5789. src.propExt;
  5790. }
  5791. }
  5792. };
  5793. _Api.registerPlural = _api_registerPlural = function(pluralName, singularName, val) {
  5794. _Api.register(pluralName, val);
  5795. _Api.register(singularName, function() {
  5796. var ret = val.apply(this, arguments);
  5797. if (ret === this) {
  5798. // Returned item is the API instance that was passed in, return it
  5799. return this;
  5800. } else if (ret instanceof _Api) {
  5801. // New API instance returned, want the value from the first item
  5802. // in the returned array for the singular result.
  5803. return ret.length ?
  5804. $.isArray(ret[0]) ?
  5805. new _Api(ret.context, ret[0]) : // Array results are 'enhanced'
  5806. ret[0] :
  5807. undefined;
  5808. }
  5809. // Non-API return - just fire it back
  5810. return ret;
  5811. });
  5812. };
  5813. /**
  5814. * Selector for HTML tables. Apply the given selector to the give array of
  5815. * DataTables settings objects.
  5816. *
  5817. * @param {string|integer} [selector] jQuery selector string or integer
  5818. * @param {array} Array of DataTables settings objects to be filtered
  5819. * @return {array}
  5820. * @ignore
  5821. */
  5822. var __table_selector = function(selector, a) {
  5823. // Integer is used to pick out a table by index
  5824. if (typeof selector === 'number') {
  5825. return [a[selector]];
  5826. }
  5827. // Perform a jQuery selector on the table nodes
  5828. var nodes = $.map(a, function(el, i) {
  5829. return el.nTable;
  5830. });
  5831. return $(nodes)
  5832. .filter(selector)
  5833. .map(function(i) {
  5834. // Need to translate back from the table node to the settings
  5835. var idx = $.inArray(this, nodes);
  5836. return a[idx];
  5837. })
  5838. .toArray();
  5839. };
  5840. /**
  5841. * Context selector for the API's context (i.e. the tables the API instance
  5842. * refers to.
  5843. *
  5844. * @name DataTable.Api#tables
  5845. * @param {string|integer} [selector] Selector to pick which tables the iterator
  5846. * should operate on. If not given, all tables in the current context are
  5847. * used. This can be given as a jQuery selector (for example `':gt(0)'`) to
  5848. * select multiple tables or as an integer to select a single table.
  5849. * @returns {DataTable.Api} Returns a new API instance if a selector is given.
  5850. */
  5851. _api_register('tables()', function(selector) {
  5852. // A new instance is created if there was a selector specified
  5853. return selector ?
  5854. new _Api(__table_selector(selector, this.context)) :
  5855. this;
  5856. });
  5857. _api_register('table()', function(selector) {
  5858. var tables = this.tables(selector);
  5859. var ctx = tables.context;
  5860. // Truncate to the first matched table
  5861. return ctx.length ?
  5862. new _Api(ctx[0]) :
  5863. tables;
  5864. });
  5865. _api_registerPlural('tables().nodes()', 'table().node()', function() {
  5866. return this.iterator('table', function(ctx) {
  5867. return ctx.nTable;
  5868. }, 1);
  5869. });
  5870. _api_registerPlural('tables().body()', 'table().body()', function() {
  5871. return this.iterator('table', function(ctx) {
  5872. return ctx.nTBody;
  5873. }, 1);
  5874. });
  5875. _api_registerPlural('tables().header()', 'table().header()', function() {
  5876. return this.iterator('table', function(ctx) {
  5877. return ctx.nTHead;
  5878. }, 1);
  5879. });
  5880. _api_registerPlural('tables().footer()', 'table().footer()', function() {
  5881. return this.iterator('table', function(ctx) {
  5882. return ctx.nTFoot;
  5883. }, 1);
  5884. });
  5885. _api_registerPlural('tables().containers()', 'table().container()', function() {
  5886. return this.iterator('table', function(ctx) {
  5887. return ctx.nTableWrapper;
  5888. }, 1);
  5889. });
  5890. /**
  5891. * Redraw the tables in the current context.
  5892. */
  5893. _api_register('draw()', function(paging) {
  5894. return this.iterator('table', function(settings) {
  5895. if (paging === 'page') {
  5896. _fnDraw(settings);
  5897. } else {
  5898. if (typeof paging === 'string') {
  5899. paging = paging === 'full-hold' ?
  5900. false :
  5901. true;
  5902. }
  5903. _fnReDraw(settings, paging === false);
  5904. }
  5905. });
  5906. });
  5907. /**
  5908. * Get the current page index.
  5909. *
  5910. * @return {integer} Current page index (zero based)
  5911. */
  5912. /**
  5913. * Set the current page.
  5914. *
  5915. * Note that if you attempt to show a page which does not exist, DataTables will
  5916. * not throw an error, but rather reset the paging.
  5917. *
  5918. * @param {integer|string} action The paging action to take. This can be one of:
  5919. * * `integer` - The page index to jump to
  5920. * * `string` - An action to take:
  5921. * * `first` - Jump to first page.
  5922. * * `next` - Jump to the next page
  5923. * * `previous` - Jump to previous page
  5924. * * `last` - Jump to the last page.
  5925. * @returns {DataTables.Api} this
  5926. */
  5927. _api_register('page()', function(action) {
  5928. if (action === undefined) {
  5929. return this.page.info().page; // not an expensive call
  5930. }
  5931. // else, have an action to take on all tables
  5932. return this.iterator('table', function(settings) {
  5933. _fnPageChange(settings, action);
  5934. });
  5935. });
  5936. /**
  5937. * Paging information for the first table in the current context.
  5938. *
  5939. * If you require paging information for another table, use the `table()` method
  5940. * with a suitable selector.
  5941. *
  5942. * @return {object} Object with the following properties set:
  5943. * * `page` - Current page index (zero based - i.e. the first page is `0`)
  5944. * * `pages` - Total number of pages
  5945. * * `start` - Display index for the first record shown on the current page
  5946. * * `end` - Display index for the last record shown on the current page
  5947. * * `length` - Display length (number of records). Note that generally `start
  5948. * + length = end`, but this is not always true, for example if there are
  5949. * only 2 records to show on the final page, with a length of 10.
  5950. * * `recordsTotal` - Full data set length
  5951. * * `recordsDisplay` - Data set length once the current filtering criterion
  5952. * are applied.
  5953. */
  5954. _api_register('page.info()', function(action) {
  5955. if (this.context.length === 0) {
  5956. return undefined;
  5957. }
  5958. var
  5959. settings = this.context[0],
  5960. start = settings._iDisplayStart,
  5961. len = settings.oFeatures.bPaginate ? settings._iDisplayLength : -1,
  5962. visRecords = settings.fnRecordsDisplay(),
  5963. all = len === -1;
  5964. return {
  5965. "page": all ? 0 : Math.floor(start / len),
  5966. "pages": all ? 1 : Math.ceil(visRecords / len),
  5967. "start": start,
  5968. "end": settings.fnDisplayEnd(),
  5969. "length": len,
  5970. "recordsTotal": settings.fnRecordsTotal(),
  5971. "recordsDisplay": visRecords,
  5972. "serverSide": _fnDataSource(settings) === 'ssp'
  5973. };
  5974. });
  5975. /**
  5976. * Get the current page length.
  5977. *
  5978. * @return {integer} Current page length. Note `-1` indicates that all records
  5979. * are to be shown.
  5980. */
  5981. /**
  5982. * Set the current page length.
  5983. *
  5984. * @param {integer} Page length to set. Use `-1` to show all records.
  5985. * @returns {DataTables.Api} this
  5986. */
  5987. _api_register('page.len()', function(len) {
  5988. // Note that we can't call this function 'length()' because `length`
  5989. // is a Javascript property of functions which defines how many arguments
  5990. // the function expects.
  5991. if (len === undefined) {
  5992. return this.context.length !== 0 ?
  5993. this.context[0]._iDisplayLength :
  5994. undefined;
  5995. }
  5996. // else, set the page length
  5997. return this.iterator('table', function(settings) {
  5998. _fnLengthChange(settings, len);
  5999. });
  6000. });
  6001. var __reload = function(settings, holdPosition, callback) {
  6002. // Use the draw event to trigger a callback
  6003. if (callback) {
  6004. var api = new _Api(settings);
  6005. api.one('draw', function() {
  6006. callback(api.ajax.json());
  6007. });
  6008. }
  6009. if (_fnDataSource(settings) == 'ssp') {
  6010. _fnReDraw(settings, holdPosition);
  6011. } else {
  6012. _fnProcessingDisplay(settings, true);
  6013. // Cancel an existing request
  6014. var xhr = settings.jqXHR;
  6015. if (xhr && xhr.readyState !== 4) {
  6016. xhr.abort();
  6017. }
  6018. // Trigger xhr
  6019. _fnBuildAjax(settings, [], function(json) {
  6020. _fnClearTable(settings);
  6021. var data = _fnAjaxDataSrc(settings, json);
  6022. for (var i = 0, ien = data.length; i < ien; i++) {
  6023. _fnAddData(settings, data[i]);
  6024. }
  6025. _fnReDraw(settings, holdPosition);
  6026. _fnProcessingDisplay(settings, false);
  6027. });
  6028. }
  6029. };
  6030. /**
  6031. * Get the JSON response from the last Ajax request that DataTables made to the
  6032. * server. Note that this returns the JSON from the first table in the current
  6033. * context.
  6034. *
  6035. * @return {object} JSON received from the server.
  6036. */
  6037. _api_register('ajax.json()', function() {
  6038. var ctx = this.context;
  6039. if (ctx.length > 0) {
  6040. return ctx[0].json;
  6041. }
  6042. // else return undefined;
  6043. });
  6044. /**
  6045. * Get the data submitted in the last Ajax request
  6046. */
  6047. _api_register('ajax.params()', function() {
  6048. var ctx = this.context;
  6049. if (ctx.length > 0) {
  6050. return ctx[0].oAjaxData;
  6051. }
  6052. // else return undefined;
  6053. });
  6054. /**
  6055. * Reload tables from the Ajax data source. Note that this function will
  6056. * automatically re-draw the table when the remote data has been loaded.
  6057. *
  6058. * @param {boolean} [reset=true] Reset (default) or hold the current paging
  6059. * position. A full re-sort and re-filter is performed when this method is
  6060. * called, which is why the pagination reset is the default action.
  6061. * @returns {DataTables.Api} this
  6062. */
  6063. _api_register('ajax.reload()', function(callback, resetPaging) {
  6064. return this.iterator('table', function(settings) {
  6065. __reload(settings, resetPaging === false, callback);
  6066. });
  6067. });
  6068. /**
  6069. * Get the current Ajax URL. Note that this returns the URL from the first
  6070. * table in the current context.
  6071. *
  6072. * @return {string} Current Ajax source URL
  6073. */
  6074. /**
  6075. * Set the Ajax URL. Note that this will set the URL for all tables in the
  6076. * current context.
  6077. *
  6078. * @param {string} url URL to set.
  6079. * @returns {DataTables.Api} this
  6080. */
  6081. _api_register('ajax.url()', function(url) {
  6082. var ctx = this.context;
  6083. if (url === undefined) {
  6084. // get
  6085. if (ctx.length === 0) {
  6086. return undefined;
  6087. }
  6088. ctx = ctx[0];
  6089. return ctx.ajax ?
  6090. $.isPlainObject(ctx.ajax) ?
  6091. ctx.ajax.url :
  6092. ctx.ajax :
  6093. ctx.sAjaxSource;
  6094. }
  6095. // set
  6096. return this.iterator('table', function(settings) {
  6097. if ($.isPlainObject(settings.ajax)) {
  6098. settings.ajax.url = url;
  6099. } else {
  6100. settings.ajax = url;
  6101. }
  6102. // No need to consider sAjaxSource here since DataTables gives priority
  6103. // to `ajax` over `sAjaxSource`. So setting `ajax` here, renders any
  6104. // value of `sAjaxSource` redundant.
  6105. });
  6106. });
  6107. /**
  6108. * Load data from the newly set Ajax URL. Note that this method is only
  6109. * available when `ajax.url()` is used to set a URL. Additionally, this method
  6110. * has the same effect as calling `ajax.reload()` but is provided for
  6111. * convenience when setting a new URL. Like `ajax.reload()` it will
  6112. * automatically redraw the table once the remote data has been loaded.
  6113. *
  6114. * @returns {DataTables.Api} this
  6115. */
  6116. _api_register('ajax.url().load()', function(callback, resetPaging) {
  6117. // Same as a reload, but makes sense to present it for easy access after a
  6118. // url change
  6119. return this.iterator('table', function(ctx) {
  6120. __reload(ctx, resetPaging === false, callback);
  6121. });
  6122. });
  6123. var _selector_run = function(type, selector, selectFn, settings, opts) {
  6124. var
  6125. out = [],
  6126. res,
  6127. a, i, ien, j, jen,
  6128. selectorType = typeof selector;
  6129. // Can't just check for isArray here, as an API or jQuery instance might be
  6130. // given with their array like look
  6131. if (!selector || selectorType === 'string' || selectorType === 'function' || selector.length === undefined) {
  6132. selector = [selector];
  6133. }
  6134. for (i = 0, ien = selector.length; i < ien; i++) {
  6135. a = selector[i] && selector[i].split ?
  6136. selector[i].split(',') : [selector[i]];
  6137. for (j = 0, jen = a.length; j < jen; j++) {
  6138. res = selectFn(typeof a[j] === 'string' ? $.trim(a[j]) : a[j]);
  6139. if (res && res.length) {
  6140. out = out.concat(res);
  6141. }
  6142. }
  6143. }
  6144. // selector extensions
  6145. var ext = _ext.selector[type];
  6146. if (ext.length) {
  6147. for (i = 0, ien = ext.length; i < ien; i++) {
  6148. out = ext[i](settings, opts, out);
  6149. }
  6150. }
  6151. return _unique(out);
  6152. };
  6153. var _selector_opts = function(opts) {
  6154. if (!opts) {
  6155. opts = {};
  6156. }
  6157. // Backwards compatibility for 1.9- which used the terminology filter rather
  6158. // than search
  6159. if (opts.filter && opts.search === undefined) {
  6160. opts.search = opts.filter;
  6161. }
  6162. return $.extend({
  6163. search: 'none',
  6164. order: 'current',
  6165. page: 'all'
  6166. }, opts);
  6167. };
  6168. var _selector_first = function(inst) {
  6169. // Reduce the API instance to the first item found
  6170. for (var i = 0, ien = inst.length; i < ien; i++) {
  6171. if (inst[i].length > 0) {
  6172. // Assign the first element to the first item in the instance
  6173. // and truncate the instance and context
  6174. inst[0] = inst[i];
  6175. inst[0].length = 1;
  6176. inst.length = 1;
  6177. inst.context = [inst.context[i]];
  6178. return inst;
  6179. }
  6180. }
  6181. // Not found - return an empty instance
  6182. inst.length = 0;
  6183. return inst;
  6184. };
  6185. var _selector_row_indexes = function(settings, opts) {
  6186. var
  6187. i, ien, tmp, a = [],
  6188. displayFiltered = settings.aiDisplay,
  6189. displayMaster = settings.aiDisplayMaster;
  6190. var
  6191. search = opts.search, // none, applied, removed
  6192. order = opts.order, // applied, current, index (original - compatibility with 1.9)
  6193. page = opts.page; // all, current
  6194. if (_fnDataSource(settings) == 'ssp') {
  6195. // In server-side processing mode, most options are irrelevant since
  6196. // rows not shown don't exist and the index order is the applied order
  6197. // Removed is a special case - for consistency just return an empty
  6198. // array
  6199. return search === 'removed' ? [] :
  6200. _range(0, displayMaster.length);
  6201. } else if (page == 'current') {
  6202. // Current page implies that order=current and fitler=applied, since it is
  6203. // fairly senseless otherwise, regardless of what order and search actually
  6204. // are
  6205. for (i = settings._iDisplayStart, ien = settings.fnDisplayEnd(); i < ien; i++) {
  6206. a.push(displayFiltered[i]);
  6207. }
  6208. } else if (order == 'current' || order == 'applied') {
  6209. a = search == 'none' ?
  6210. displayMaster.slice() : // no search
  6211. search == 'applied' ?
  6212. displayFiltered.slice() : // applied search
  6213. $.map(displayMaster, function(el, i) { // removed search
  6214. return $.inArray(el, displayFiltered) === -1 ? el : null;
  6215. });
  6216. } else if (order == 'index' || order == 'original') {
  6217. for (i = 0, ien = settings.aoData.length; i < ien; i++) {
  6218. if (search == 'none') {
  6219. a.push(i);
  6220. } else { // applied | removed
  6221. tmp = $.inArray(i, displayFiltered);
  6222. if ((tmp === -1 && search == 'removed') ||
  6223. (tmp >= 0 && search == 'applied')) {
  6224. a.push(i);
  6225. }
  6226. }
  6227. }
  6228. }
  6229. return a;
  6230. };
  6231. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6232. * Rows
  6233. *
  6234. * {} - no selector - use all available rows
  6235. * {integer} - row aoData index
  6236. * {node} - TR node
  6237. * {string} - jQuery selector to apply to the TR elements
  6238. * {array} - jQuery array of nodes, or simply an array of TR nodes
  6239. *
  6240. */
  6241. var __row_selector = function(settings, selector, opts) {
  6242. var run = function(sel) {
  6243. var selInt = _intVal(sel);
  6244. var i, ien;
  6245. // Short cut - selector is a number and no options provided (default is
  6246. // all records, so no need to check if the index is in there, since it
  6247. // must be - dev error if the index doesn't exist).
  6248. if (selInt !== null && !opts) {
  6249. return [selInt];
  6250. }
  6251. var rows = _selector_row_indexes(settings, opts);
  6252. if (selInt !== null && $.inArray(selInt, rows) !== -1) {
  6253. // Selector - integer
  6254. return [selInt];
  6255. } else if (!sel) {
  6256. // Selector - none
  6257. return rows;
  6258. }
  6259. // Selector - function
  6260. if (typeof sel === 'function') {
  6261. return $.map(rows, function(idx) {
  6262. var row = settings.aoData[idx];
  6263. return sel(idx, row._aData, row.nTr) ? idx : null;
  6264. });
  6265. }
  6266. // Get nodes in the order from the `rows` array with null values removed
  6267. var nodes = _removeEmpty(
  6268. _pluck_order(settings.aoData, rows, 'nTr')
  6269. );
  6270. // Selector - node
  6271. if (sel.nodeName) {
  6272. if (sel._DT_RowIndex !== undefined) {
  6273. return [sel._DT_RowIndex]; // Property added by DT for fast lookup
  6274. } else if (sel._DT_CellIndex) {
  6275. return [sel._DT_CellIndex.row];
  6276. } else {
  6277. var host = $(sel).closest('*[data-dt-row]');
  6278. return host.length ? [host.data('dt-row')] : [];
  6279. }
  6280. }
  6281. // ID selector. Want to always be able to select rows by id, regardless
  6282. // of if the tr element has been created or not, so can't rely upon
  6283. // jQuery here - hence a custom implementation. This does not match
  6284. // Sizzle's fast selector or HTML4 - in HTML5 the ID can be anything,
  6285. // but to select it using a CSS selector engine (like Sizzle or
  6286. // querySelect) it would need to need to be escaped for some characters.
  6287. // DataTables simplifies this for row selectors since you can select
  6288. // only a row. A # indicates an id any anything that follows is the id -
  6289. // unescaped.
  6290. if (typeof sel === 'string' && sel.charAt(0) === '#') {
  6291. // get row index from id
  6292. var rowObj = settings.aIds[sel.replace(/^#/, '')];
  6293. if (rowObj !== undefined) {
  6294. return [rowObj.idx];
  6295. }
  6296. // need to fall through to jQuery in case there is DOM id that
  6297. // matches
  6298. }
  6299. // Selector - jQuery selector string, array of nodes or jQuery object/
  6300. // As jQuery's .filter() allows jQuery objects to be passed in filter,
  6301. // it also allows arrays, so this will cope with all three options
  6302. return $(nodes)
  6303. .filter(sel)
  6304. .map(function() {
  6305. return this._DT_RowIndex;
  6306. })
  6307. .toArray();
  6308. };
  6309. return _selector_run('row', selector, run, settings, opts);
  6310. };
  6311. _api_register('rows()', function(selector, opts) {
  6312. // argument shifting
  6313. if (selector === undefined) {
  6314. selector = '';
  6315. } else if ($.isPlainObject(selector)) {
  6316. opts = selector;
  6317. selector = '';
  6318. }
  6319. opts = _selector_opts(opts);
  6320. var inst = this.iterator('table', function(settings) {
  6321. return __row_selector(settings, selector, opts);
  6322. }, 1);
  6323. // Want argument shifting here and in __row_selector?
  6324. inst.selector.rows = selector;
  6325. inst.selector.opts = opts;
  6326. return inst;
  6327. });
  6328. _api_register('rows().nodes()', function() {
  6329. return this.iterator('row', function(settings, row) {
  6330. return settings.aoData[row].nTr || undefined;
  6331. }, 1);
  6332. });
  6333. _api_register('rows().data()', function() {
  6334. return this.iterator(true, 'rows', function(settings, rows) {
  6335. return _pluck_order(settings.aoData, rows, '_aData');
  6336. }, 1);
  6337. });
  6338. _api_registerPlural('rows().cache()', 'row().cache()', function(type) {
  6339. return this.iterator('row', function(settings, row) {
  6340. var r = settings.aoData[row];
  6341. return type === 'search' ? r._aFilterData : r._aSortData;
  6342. }, 1);
  6343. });
  6344. _api_registerPlural('rows().invalidate()', 'row().invalidate()', function(src) {
  6345. return this.iterator('row', function(settings, row) {
  6346. _fnInvalidate(settings, row, src);
  6347. });
  6348. });
  6349. _api_registerPlural('rows().indexes()', 'row().index()', function() {
  6350. return this.iterator('row', function(settings, row) {
  6351. return row;
  6352. }, 1);
  6353. });
  6354. _api_registerPlural('rows().ids()', 'row().id()', function(hash) {
  6355. var a = [];
  6356. var context = this.context;
  6357. // `iterator` will drop undefined values, but in this case we want them
  6358. for (var i = 0, ien = context.length; i < ien; i++) {
  6359. for (var j = 0, jen = this[i].length; j < jen; j++) {
  6360. var id = context[i].rowIdFn(context[i].aoData[this[i][j]]._aData);
  6361. a.push((hash === true ? '#' : '') + id);
  6362. }
  6363. }
  6364. return new _Api(context, a);
  6365. });
  6366. _api_registerPlural('rows().remove()', 'row().remove()', function() {
  6367. var that = this;
  6368. this.iterator('row', function(settings, row, thatIdx) {
  6369. var data = settings.aoData;
  6370. var rowData = data[row];
  6371. var i, ien, j, jen;
  6372. var loopRow, loopCells;
  6373. data.splice(row, 1);
  6374. // Update the cached indexes
  6375. for (i = 0, ien = data.length; i < ien; i++) {
  6376. loopRow = data[i];
  6377. loopCells = loopRow.anCells;
  6378. // Rows
  6379. if (loopRow.nTr !== null) {
  6380. loopRow.nTr._DT_RowIndex = i;
  6381. }
  6382. // Cells
  6383. if (loopCells !== null) {
  6384. for (j = 0, jen = loopCells.length; j < jen; j++) {
  6385. loopCells[j]._DT_CellIndex.row = i;
  6386. }
  6387. }
  6388. }
  6389. // Delete from the display arrays
  6390. _fnDeleteIndex(settings.aiDisplayMaster, row);
  6391. _fnDeleteIndex(settings.aiDisplay, row);
  6392. _fnDeleteIndex(that[thatIdx], row, false); // maintain local indexes
  6393. // Check for an 'overflow' they case for displaying the table
  6394. _fnLengthOverflow(settings);
  6395. // Remove the row's ID reference if there is one
  6396. var id = settings.rowIdFn(rowData._aData);
  6397. if (id !== undefined) {
  6398. delete settings.aIds[id];
  6399. }
  6400. });
  6401. this.iterator('table', function(settings) {
  6402. for (var i = 0, ien = settings.aoData.length; i < ien; i++) {
  6403. settings.aoData[i].idx = i;
  6404. }
  6405. });
  6406. return this;
  6407. });
  6408. _api_register('rows.add()', function(rows) {
  6409. var newRows = this.iterator('table', function(settings) {
  6410. var row, i, ien;
  6411. var out = [];
  6412. for (i = 0, ien = rows.length; i < ien; i++) {
  6413. row = rows[i];
  6414. if (row.nodeName && row.nodeName.toUpperCase() === 'TR') {
  6415. out.push(_fnAddTr(settings, row)[0]);
  6416. } else {
  6417. out.push(_fnAddData(settings, row));
  6418. }
  6419. }
  6420. return out;
  6421. }, 1);
  6422. // Return an Api.rows() extended instance, so rows().nodes() etc can be used
  6423. var modRows = this.rows(-1);
  6424. modRows.pop();
  6425. $.merge(modRows, newRows);
  6426. return modRows;
  6427. });
  6428. /**
  6429. *
  6430. */
  6431. _api_register('row()', function(selector, opts) {
  6432. return _selector_first(this.rows(selector, opts));
  6433. });
  6434. _api_register('row().data()', function(data) {
  6435. var ctx = this.context;
  6436. if (data === undefined) {
  6437. // Get
  6438. return ctx.length && this.length ?
  6439. ctx[0].aoData[this[0]]._aData :
  6440. undefined;
  6441. }
  6442. // Set
  6443. ctx[0].aoData[this[0]]._aData = data;
  6444. // Automatically invalidate
  6445. _fnInvalidate(ctx[0], this[0], 'data');
  6446. return this;
  6447. });
  6448. _api_register('row().node()', function() {
  6449. var ctx = this.context;
  6450. return ctx.length && this.length ?
  6451. ctx[0].aoData[this[0]].nTr || null :
  6452. null;
  6453. });
  6454. _api_register('row.add()', function(row) {
  6455. // Allow a jQuery object to be passed in - only a single row is added from
  6456. // it though - the first element in the set
  6457. if (row instanceof $ && row.length) {
  6458. row = row[0];
  6459. }
  6460. var rows = this.iterator('table', function(settings) {
  6461. if (row.nodeName && row.nodeName.toUpperCase() === 'TR') {
  6462. return _fnAddTr(settings, row)[0];
  6463. }
  6464. return _fnAddData(settings, row);
  6465. });
  6466. // Return an Api.rows() extended instance, with the newly added row selected
  6467. return this.row(rows[0]);
  6468. });
  6469. var __details_add = function(ctx, row, data, klass) {
  6470. // Convert to array of TR elements
  6471. var rows = [];
  6472. var addRow = function(r, k) {
  6473. // Recursion to allow for arrays of jQuery objects
  6474. if ($.isArray(r) || r instanceof $) {
  6475. for (var i = 0, ien = r.length; i < ien; i++) {
  6476. addRow(r[i], k);
  6477. }
  6478. return;
  6479. }
  6480. // If we get a TR element, then just add it directly - up to the dev
  6481. // to add the correct number of columns etc
  6482. if (r.nodeName && r.nodeName.toLowerCase() === 'tr') {
  6483. rows.push(r);
  6484. } else {
  6485. // Otherwise create a row with a wrapper
  6486. var created = $('<tr><td/></tr>').addClass(k);
  6487. $('td', created)
  6488. .addClass(k)
  6489. .html(r)[0].colSpan = _fnVisbleColumns(ctx);
  6490. rows.push(created[0]);
  6491. }
  6492. };
  6493. addRow(data, klass);
  6494. if (row._details) {
  6495. row._details.remove();
  6496. }
  6497. row._details = $(rows);
  6498. // If the children were already shown, that state should be retained
  6499. if (row._detailsShow) {
  6500. row._details.insertAfter(row.nTr);
  6501. }
  6502. };
  6503. var __details_remove = function(api, idx) {
  6504. var ctx = api.context;
  6505. if (ctx.length) {
  6506. var row = ctx[0].aoData[idx !== undefined ? idx : api[0]];
  6507. if (row && row._details) {
  6508. row._details.remove();
  6509. row._detailsShow = undefined;
  6510. row._details = undefined;
  6511. }
  6512. }
  6513. };
  6514. var __details_display = function(api, show) {
  6515. var ctx = api.context;
  6516. if (ctx.length && api.length) {
  6517. var row = ctx[0].aoData[api[0]];
  6518. if (row._details) {
  6519. row._detailsShow = show;
  6520. if (show) {
  6521. row._details.insertAfter(row.nTr);
  6522. } else {
  6523. row._details.detach();
  6524. }
  6525. __details_events(ctx[0]);
  6526. }
  6527. }
  6528. };
  6529. var __details_events = function(settings) {
  6530. var api = new _Api(settings);
  6531. var namespace = '.dt.DT_details';
  6532. var drawEvent = 'draw' + namespace;
  6533. var colvisEvent = 'column-visibility' + namespace;
  6534. var destroyEvent = 'destroy' + namespace;
  6535. var data = settings.aoData;
  6536. api.off(drawEvent + ' ' + colvisEvent + ' ' + destroyEvent);
  6537. if (_pluck(data, '_details').length > 0) {
  6538. // On each draw, insert the required elements into the document
  6539. api.on(drawEvent, function(e, ctx) {
  6540. if (settings !== ctx) {
  6541. return;
  6542. }
  6543. api.rows({
  6544. page: 'current'
  6545. }).eq(0).each(function(idx) {
  6546. // Internal data grab
  6547. var row = data[idx];
  6548. if (row._detailsShow) {
  6549. row._details.insertAfter(row.nTr);
  6550. }
  6551. });
  6552. });
  6553. // Column visibility change - update the colspan
  6554. api.on(colvisEvent, function(e, ctx, idx, vis) {
  6555. if (settings !== ctx) {
  6556. return;
  6557. }
  6558. // Update the colspan for the details rows (note, only if it already has
  6559. // a colspan)
  6560. var row, visible = _fnVisbleColumns(ctx);
  6561. for (var i = 0, ien = data.length; i < ien; i++) {
  6562. row = data[i];
  6563. if (row._details) {
  6564. row._details.children('td[colspan]').attr('colspan', visible);
  6565. }
  6566. }
  6567. });
  6568. // Table destroyed - nuke any child rows
  6569. api.on(destroyEvent, function(e, ctx) {
  6570. if (settings !== ctx) {
  6571. return;
  6572. }
  6573. for (var i = 0, ien = data.length; i < ien; i++) {
  6574. if (data[i]._details) {
  6575. __details_remove(api, i);
  6576. }
  6577. }
  6578. });
  6579. }
  6580. };
  6581. // Strings for the method names to help minification
  6582. var _emp = '';
  6583. var _child_obj = _emp + 'row().child';
  6584. var _child_mth = _child_obj + '()';
  6585. // data can be:
  6586. // tr
  6587. // string
  6588. // jQuery or array of any of the above
  6589. _api_register(_child_mth, function(data, klass) {
  6590. var ctx = this.context;
  6591. if (data === undefined) {
  6592. // get
  6593. return ctx.length && this.length ?
  6594. ctx[0].aoData[this[0]]._details :
  6595. undefined;
  6596. } else if (data === true) {
  6597. // show
  6598. this.child.show();
  6599. } else if (data === false) {
  6600. // remove
  6601. __details_remove(this);
  6602. } else if (ctx.length && this.length) {
  6603. // set
  6604. __details_add(ctx[0], ctx[0].aoData[this[0]], data, klass);
  6605. }
  6606. return this;
  6607. });
  6608. _api_register([
  6609. _child_obj + '.show()',
  6610. _child_mth + '.show()' // only when `child()` was called with parameters (without
  6611. ], function(show) { // it returns an object and this method is not executed)
  6612. __details_display(this, true);
  6613. return this;
  6614. });
  6615. _api_register([
  6616. _child_obj + '.hide()',
  6617. _child_mth + '.hide()' // only when `child()` was called with parameters (without
  6618. ], function() { // it returns an object and this method is not executed)
  6619. __details_display(this, false);
  6620. return this;
  6621. });
  6622. _api_register([
  6623. _child_obj + '.remove()',
  6624. _child_mth + '.remove()' // only when `child()` was called with parameters (without
  6625. ], function() { // it returns an object and this method is not executed)
  6626. __details_remove(this);
  6627. return this;
  6628. });
  6629. _api_register(_child_obj + '.isShown()', function() {
  6630. var ctx = this.context;
  6631. if (ctx.length && this.length) {
  6632. // _detailsShown as false or undefined will fall through to return false
  6633. return ctx[0].aoData[this[0]]._detailsShow || false;
  6634. }
  6635. return false;
  6636. });
  6637. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6638. * Columns
  6639. *
  6640. * {integer} - column index (>=0 count from left, <0 count from right)
  6641. * "{integer}:visIdx" - visible column index (i.e. translate to column index) (>=0 count from left, <0 count from right)
  6642. * "{integer}:visible" - alias for {integer}:visIdx (>=0 count from left, <0 count from right)
  6643. * "{string}:name" - column name
  6644. * "{string}" - jQuery selector on column header nodes
  6645. *
  6646. */
  6647. // can be an array of these items, comma separated list, or an array of comma
  6648. // separated lists
  6649. var __re_column_selector = /^(.+):(name|visIdx|visible)$/;
  6650. // r1 and r2 are redundant - but it means that the parameters match for the
  6651. // iterator callback in columns().data()
  6652. var __columnData = function(settings, column, r1, r2, rows) {
  6653. var a = [];
  6654. for (var row = 0, ien = rows.length; row < ien; row++) {
  6655. a.push(_fnGetCellData(settings, rows[row], column));
  6656. }
  6657. return a;
  6658. };
  6659. var __column_selector = function(settings, selector, opts) {
  6660. var
  6661. columns = settings.aoColumns,
  6662. names = _pluck(columns, 'sName'),
  6663. nodes = _pluck(columns, 'nTh');
  6664. var run = function(s) {
  6665. var selInt = _intVal(s);
  6666. // Selector - all
  6667. if (s === '') {
  6668. return _range(columns.length);
  6669. }
  6670. // Selector - index
  6671. if (selInt !== null) {
  6672. return [selInt >= 0 ?
  6673. selInt : // Count from left
  6674. columns.length + selInt // Count from right (+ because its a negative value)
  6675. ];
  6676. }
  6677. // Selector = function
  6678. if (typeof s === 'function') {
  6679. var rows = _selector_row_indexes(settings, opts);
  6680. return $.map(columns, function(col, idx) {
  6681. return s(
  6682. idx,
  6683. __columnData(settings, idx, 0, 0, rows),
  6684. nodes[idx]
  6685. ) ? idx : null;
  6686. });
  6687. }
  6688. // jQuery or string selector
  6689. var match = typeof s === 'string' ?
  6690. s.match(__re_column_selector) :
  6691. '';
  6692. if (match) {
  6693. switch (match[2]) {
  6694. case 'visIdx':
  6695. case 'visible':
  6696. var idx = parseInt(match[1], 10);
  6697. // Visible index given, convert to column index
  6698. if (idx < 0) {
  6699. // Counting from the right
  6700. var visColumns = $.map(columns, function(col, i) {
  6701. return col.bVisible ? i : null;
  6702. });
  6703. return [visColumns[visColumns.length + idx]];
  6704. }
  6705. // Counting from the left
  6706. return [_fnVisibleToColumnIndex(settings, idx)];
  6707. case 'name':
  6708. // match by name. `names` is column index complete and in order
  6709. return $.map(names, function(name, i) {
  6710. return name === match[1] ? i : null;
  6711. });
  6712. default:
  6713. return [];
  6714. }
  6715. }
  6716. // Cell in the table body
  6717. if (s.nodeName && s._DT_CellIndex) {
  6718. return [s._DT_CellIndex.column];
  6719. }
  6720. // jQuery selector on the TH elements for the columns
  6721. var jqResult = $(nodes)
  6722. .filter(s)
  6723. .map(function() {
  6724. return $.inArray(this, nodes); // `nodes` is column index complete and in order
  6725. })
  6726. .toArray();
  6727. if (jqResult.length || !s.nodeName) {
  6728. return jqResult;
  6729. }
  6730. // Otherwise a node which might have a `dt-column` data attribute, or be
  6731. // a child or such an element
  6732. var host = $(s).closest('*[data-dt-column]');
  6733. return host.length ? [host.data('dt-column')] : [];
  6734. };
  6735. return _selector_run('column', selector, run, settings, opts);
  6736. };
  6737. var __setColumnVis = function(settings, column, vis) {
  6738. var
  6739. cols = settings.aoColumns,
  6740. col = cols[column],
  6741. data = settings.aoData,
  6742. row, cells, i, ien, tr;
  6743. // Get
  6744. if (vis === undefined) {
  6745. return col.bVisible;
  6746. }
  6747. // Set
  6748. // No change
  6749. if (col.bVisible === vis) {
  6750. return;
  6751. }
  6752. if (vis) {
  6753. // Insert column
  6754. // Need to decide if we should use appendChild or insertBefore
  6755. var insertBefore = $.inArray(true, _pluck(cols, 'bVisible'), column + 1);
  6756. for (i = 0, ien = data.length; i < ien; i++) {
  6757. tr = data[i].nTr;
  6758. cells = data[i].anCells;
  6759. if (tr) {
  6760. // insertBefore can act like appendChild if 2nd arg is null
  6761. tr.insertBefore(cells[column], cells[insertBefore] || null);
  6762. }
  6763. }
  6764. } else {
  6765. // Remove column
  6766. $(_pluck(settings.aoData, 'anCells', column)).detach();
  6767. }
  6768. // Common actions
  6769. col.bVisible = vis;
  6770. _fnDrawHead(settings, settings.aoHeader);
  6771. _fnDrawHead(settings, settings.aoFooter);
  6772. _fnSaveState(settings);
  6773. };
  6774. _api_register('columns()', function(selector, opts) {
  6775. // argument shifting
  6776. if (selector === undefined) {
  6777. selector = '';
  6778. } else if ($.isPlainObject(selector)) {
  6779. opts = selector;
  6780. selector = '';
  6781. }
  6782. opts = _selector_opts(opts);
  6783. var inst = this.iterator('table', function(settings) {
  6784. return __column_selector(settings, selector, opts);
  6785. }, 1);
  6786. // Want argument shifting here and in _row_selector?
  6787. inst.selector.cols = selector;
  6788. inst.selector.opts = opts;
  6789. return inst;
  6790. });
  6791. _api_registerPlural('columns().header()', 'column().header()', function(selector, opts) {
  6792. return this.iterator('column', function(settings, column) {
  6793. return settings.aoColumns[column].nTh;
  6794. }, 1);
  6795. });
  6796. _api_registerPlural('columns().footer()', 'column().footer()', function(selector, opts) {
  6797. return this.iterator('column', function(settings, column) {
  6798. return settings.aoColumns[column].nTf;
  6799. }, 1);
  6800. });
  6801. _api_registerPlural('columns().data()', 'column().data()', function() {
  6802. return this.iterator('column-rows', __columnData, 1);
  6803. });
  6804. _api_registerPlural('columns().dataSrc()', 'column().dataSrc()', function() {
  6805. return this.iterator('column', function(settings, column) {
  6806. return settings.aoColumns[column].mData;
  6807. }, 1);
  6808. });
  6809. _api_registerPlural('columns().cache()', 'column().cache()', function(type) {
  6810. return this.iterator('column-rows', function(settings, column, i, j, rows) {
  6811. return _pluck_order(settings.aoData, rows,
  6812. type === 'search' ? '_aFilterData' : '_aSortData', column
  6813. );
  6814. }, 1);
  6815. });
  6816. _api_registerPlural('columns().nodes()', 'column().nodes()', function() {
  6817. return this.iterator('column-rows', function(settings, column, i, j, rows) {
  6818. return _pluck_order(settings.aoData, rows, 'anCells', column);
  6819. }, 1);
  6820. });
  6821. _api_registerPlural('columns().visible()', 'column().visible()', function(vis, calc) {
  6822. var ret = this.iterator('column', function(settings, column) {
  6823. if (vis === undefined) {
  6824. return settings.aoColumns[column].bVisible;
  6825. } // else
  6826. __setColumnVis(settings, column, vis);
  6827. });
  6828. // Group the column visibility changes
  6829. if (vis !== undefined) {
  6830. // Second loop once the first is done for events
  6831. this.iterator('column', function(settings, column) {
  6832. _fnCallbackFire(settings, null, 'column-visibility', [settings, column, vis, calc]);
  6833. });
  6834. if (calc === undefined || calc) {
  6835. this.columns.adjust();
  6836. }
  6837. }
  6838. return ret;
  6839. });
  6840. _api_registerPlural('columns().indexes()', 'column().index()', function(type) {
  6841. return this.iterator('column', function(settings, column) {
  6842. return type === 'visible' ?
  6843. _fnColumnIndexToVisible(settings, column) :
  6844. column;
  6845. }, 1);
  6846. });
  6847. _api_register('columns.adjust()', function() {
  6848. return this.iterator('table', function(settings) {
  6849. _fnAdjustColumnSizing(settings);
  6850. }, 1);
  6851. });
  6852. _api_register('column.index()', function(type, idx) {
  6853. if (this.context.length !== 0) {
  6854. var ctx = this.context[0];
  6855. if (type === 'fromVisible' || type === 'toData') {
  6856. return _fnVisibleToColumnIndex(ctx, idx);
  6857. } else if (type === 'fromData' || type === 'toVisible') {
  6858. return _fnColumnIndexToVisible(ctx, idx);
  6859. }
  6860. }
  6861. });
  6862. _api_register('column()', function(selector, opts) {
  6863. return _selector_first(this.columns(selector, opts));
  6864. });
  6865. var __cell_selector = function(settings, selector, opts) {
  6866. var data = settings.aoData;
  6867. var rows = _selector_row_indexes(settings, opts);
  6868. var cells = _removeEmpty(_pluck_order(data, rows, 'anCells'));
  6869. var allCells = $([].concat.apply([], cells));
  6870. var row;
  6871. var columns = settings.aoColumns.length;
  6872. var a, i, ien, j, o, host;
  6873. var run = function(s) {
  6874. var fnSelector = typeof s === 'function';
  6875. if (s === null || s === undefined || fnSelector) {
  6876. // All cells and function selectors
  6877. a = [];
  6878. for (i = 0, ien = rows.length; i < ien; i++) {
  6879. row = rows[i];
  6880. for (j = 0; j < columns; j++) {
  6881. o = {
  6882. row: row,
  6883. column: j
  6884. };
  6885. if (fnSelector) {
  6886. // Selector - function
  6887. host = data[row];
  6888. if (s(o, _fnGetCellData(settings, row, j), host.anCells ? host.anCells[j] : null)) {
  6889. a.push(o);
  6890. }
  6891. } else {
  6892. // Selector - all
  6893. a.push(o);
  6894. }
  6895. }
  6896. }
  6897. return a;
  6898. }
  6899. // Selector - index
  6900. if ($.isPlainObject(s)) {
  6901. return [s];
  6902. }
  6903. // Selector - jQuery filtered cells
  6904. var jqResult = allCells
  6905. .filter(s)
  6906. .map(function(i, el) {
  6907. return { // use a new object, in case someone changes the values
  6908. row: el._DT_CellIndex.row,
  6909. column: el._DT_CellIndex.column
  6910. };
  6911. })
  6912. .toArray();
  6913. if (jqResult.length || !s.nodeName) {
  6914. return jqResult;
  6915. }
  6916. // Otherwise the selector is a node, and there is one last option - the
  6917. // element might be a child of an element which has dt-row and dt-column
  6918. // data attributes
  6919. host = $(s).closest('*[data-dt-row]');
  6920. return host.length ? [{
  6921. row: host.data('dt-row'),
  6922. column: host.data('dt-column')
  6923. }] : [];
  6924. };
  6925. return _selector_run('cell', selector, run, settings, opts);
  6926. };
  6927. _api_register('cells()', function(rowSelector, columnSelector, opts) {
  6928. // Argument shifting
  6929. if ($.isPlainObject(rowSelector)) {
  6930. // Indexes
  6931. if (rowSelector.row === undefined) {
  6932. // Selector options in first parameter
  6933. opts = rowSelector;
  6934. rowSelector = null;
  6935. } else {
  6936. // Cell index objects in first parameter
  6937. opts = columnSelector;
  6938. columnSelector = null;
  6939. }
  6940. }
  6941. if ($.isPlainObject(columnSelector)) {
  6942. opts = columnSelector;
  6943. columnSelector = null;
  6944. }
  6945. // Cell selector
  6946. if (columnSelector === null || columnSelector === undefined) {
  6947. return this.iterator('table', function(settings) {
  6948. return __cell_selector(settings, rowSelector, _selector_opts(opts));
  6949. });
  6950. }
  6951. // Row + column selector
  6952. var columns = this.columns(columnSelector, opts);
  6953. var rows = this.rows(rowSelector, opts);
  6954. var a, i, ien, j, jen;
  6955. var cells = this.iterator('table', function(settings, idx) {
  6956. a = [];
  6957. for (i = 0, ien = rows[idx].length; i < ien; i++) {
  6958. for (j = 0, jen = columns[idx].length; j < jen; j++) {
  6959. a.push({
  6960. row: rows[idx][i],
  6961. column: columns[idx][j]
  6962. });
  6963. }
  6964. }
  6965. return a;
  6966. }, 1);
  6967. $.extend(cells.selector, {
  6968. cols: columnSelector,
  6969. rows: rowSelector,
  6970. opts: opts
  6971. });
  6972. return cells;
  6973. });
  6974. _api_registerPlural('cells().nodes()', 'cell().node()', function() {
  6975. return this.iterator('cell', function(settings, row, column) {
  6976. var data = settings.aoData[row];
  6977. return data && data.anCells ?
  6978. data.anCells[column] :
  6979. undefined;
  6980. }, 1);
  6981. });
  6982. _api_register('cells().data()', function() {
  6983. return this.iterator('cell', function(settings, row, column) {
  6984. return _fnGetCellData(settings, row, column);
  6985. }, 1);
  6986. });
  6987. _api_registerPlural('cells().cache()', 'cell().cache()', function(type) {
  6988. type = type === 'search' ? '_aFilterData' : '_aSortData';
  6989. return this.iterator('cell', function(settings, row, column) {
  6990. return settings.aoData[row][type][column];
  6991. }, 1);
  6992. });
  6993. _api_registerPlural('cells().render()', 'cell().render()', function(type) {
  6994. return this.iterator('cell', function(settings, row, column) {
  6995. return _fnGetCellData(settings, row, column, type);
  6996. }, 1);
  6997. });
  6998. _api_registerPlural('cells().indexes()', 'cell().index()', function() {
  6999. return this.iterator('cell', function(settings, row, column) {
  7000. return {
  7001. row: row,
  7002. column: column,
  7003. columnVisible: _fnColumnIndexToVisible(settings, column)
  7004. };
  7005. }, 1);
  7006. });
  7007. _api_registerPlural('cells().invalidate()', 'cell().invalidate()', function(src) {
  7008. return this.iterator('cell', function(settings, row, column) {
  7009. _fnInvalidate(settings, row, src, column);
  7010. });
  7011. });
  7012. _api_register('cell()', function(rowSelector, columnSelector, opts) {
  7013. return _selector_first(this.cells(rowSelector, columnSelector, opts));
  7014. });
  7015. _api_register('cell().data()', function(data) {
  7016. var ctx = this.context;
  7017. var cell = this[0];
  7018. if (data === undefined) {
  7019. // Get
  7020. return ctx.length && cell.length ?
  7021. _fnGetCellData(ctx[0], cell[0].row, cell[0].column) :
  7022. undefined;
  7023. }
  7024. // Set
  7025. _fnSetCellData(ctx[0], cell[0].row, cell[0].column, data);
  7026. _fnInvalidate(ctx[0], cell[0].row, 'data', cell[0].column);
  7027. return this;
  7028. });
  7029. /**
  7030. * Get current ordering (sorting) that has been applied to the table.
  7031. *
  7032. * @returns {array} 2D array containing the sorting information for the first
  7033. * table in the current context. Each element in the parent array represents
  7034. * a column being sorted upon (i.e. multi-sorting with two columns would have
  7035. * 2 inner arrays). The inner arrays may have 2 or 3 elements. The first is
  7036. * the column index that the sorting condition applies to, the second is the
  7037. * direction of the sort (`desc` or `asc`) and, optionally, the third is the
  7038. * index of the sorting order from the `column.sorting` initialisation array.
  7039. */
  7040. /**
  7041. * Set the ordering for the table.
  7042. *
  7043. * @param {integer} order Column index to sort upon.
  7044. * @param {string} direction Direction of the sort to be applied (`asc` or `desc`)
  7045. * @returns {DataTables.Api} this
  7046. */
  7047. /**
  7048. * Set the ordering for the table.
  7049. *
  7050. * @param {array} order 1D array of sorting information to be applied.
  7051. * @param {array} [...] Optional additional sorting conditions
  7052. * @returns {DataTables.Api} this
  7053. */
  7054. /**
  7055. * Set the ordering for the table.
  7056. *
  7057. * @param {array} order 2D array of sorting information to be applied.
  7058. * @returns {DataTables.Api} this
  7059. */
  7060. _api_register('order()', function(order, dir) {
  7061. var ctx = this.context;
  7062. if (order === undefined) {
  7063. // get
  7064. return ctx.length !== 0 ?
  7065. ctx[0].aaSorting :
  7066. undefined;
  7067. }
  7068. // set
  7069. if (typeof order === 'number') {
  7070. // Simple column / direction passed in
  7071. order = [
  7072. [order, dir]
  7073. ];
  7074. } else if (order.length && !$.isArray(order[0])) {
  7075. // Arguments passed in (list of 1D arrays)
  7076. order = Array.prototype.slice.call(arguments);
  7077. }
  7078. // otherwise a 2D array was passed in
  7079. return this.iterator('table', function(settings) {
  7080. settings.aaSorting = order.slice();
  7081. });
  7082. });
  7083. /**
  7084. * Attach a sort listener to an element for a given column
  7085. *
  7086. * @param {node|jQuery|string} node Identifier for the element(s) to attach the
  7087. * listener to. This can take the form of a single DOM node, a jQuery
  7088. * collection of nodes or a jQuery selector which will identify the node(s).
  7089. * @param {integer} column the column that a click on this node will sort on
  7090. * @param {function} [callback] callback function when sort is run
  7091. * @returns {DataTables.Api} this
  7092. */
  7093. _api_register('order.listener()', function(node, column, callback) {
  7094. return this.iterator('table', function(settings) {
  7095. _fnSortAttachListener(settings, node, column, callback);
  7096. });
  7097. });
  7098. _api_register('order.fixed()', function(set) {
  7099. if (!set) {
  7100. var ctx = this.context;
  7101. var fixed = ctx.length ?
  7102. ctx[0].aaSortingFixed :
  7103. undefined;
  7104. return $.isArray(fixed) ? {
  7105. pre: fixed
  7106. } :
  7107. fixed;
  7108. }
  7109. return this.iterator('table', function(settings) {
  7110. settings.aaSortingFixed = $.extend(true, {}, set);
  7111. });
  7112. });
  7113. // Order by the selected column(s)
  7114. _api_register([
  7115. 'columns().order()',
  7116. 'column().order()'
  7117. ], function(dir) {
  7118. var that = this;
  7119. return this.iterator('table', function(settings, i) {
  7120. var sort = [];
  7121. $.each(that[i], function(j, col) {
  7122. sort.push([col, dir]);
  7123. });
  7124. settings.aaSorting = sort;
  7125. });
  7126. });
  7127. _api_register('search()', function(input, regex, smart, caseInsen) {
  7128. var ctx = this.context;
  7129. if (input === undefined) {
  7130. // get
  7131. return ctx.length !== 0 ?
  7132. ctx[0].oPreviousSearch.sSearch :
  7133. undefined;
  7134. }
  7135. // set
  7136. return this.iterator('table', function(settings) {
  7137. if (!settings.oFeatures.bFilter) {
  7138. return;
  7139. }
  7140. _fnFilterComplete(settings, $.extend({}, settings.oPreviousSearch, {
  7141. "sSearch": input + "",
  7142. "bRegex": regex === null ? false : regex,
  7143. "bSmart": smart === null ? true : smart,
  7144. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7145. }), 1);
  7146. });
  7147. });
  7148. _api_registerPlural(
  7149. 'columns().search()',
  7150. 'column().search()',
  7151. function(input, regex, smart, caseInsen) {
  7152. return this.iterator('column', function(settings, column) {
  7153. var preSearch = settings.aoPreSearchCols;
  7154. if (input === undefined) {
  7155. // get
  7156. return preSearch[column].sSearch;
  7157. }
  7158. // set
  7159. if (!settings.oFeatures.bFilter) {
  7160. return;
  7161. }
  7162. $.extend(preSearch[column], {
  7163. "sSearch": input + "",
  7164. "bRegex": regex === null ? false : regex,
  7165. "bSmart": smart === null ? true : smart,
  7166. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7167. });
  7168. _fnFilterComplete(settings, settings.oPreviousSearch, 1);
  7169. });
  7170. }
  7171. );
  7172. /*
  7173. * State API methods
  7174. */
  7175. _api_register('state()', function() {
  7176. return this.context.length ?
  7177. this.context[0].oSavedState :
  7178. null;
  7179. });
  7180. _api_register('state.clear()', function() {
  7181. return this.iterator('table', function(settings) {
  7182. // Save an empty object
  7183. settings.fnStateSaveCallback.call(settings.oInstance, settings, {});
  7184. });
  7185. });
  7186. _api_register('state.loaded()', function() {
  7187. return this.context.length ?
  7188. this.context[0].oLoadedState :
  7189. null;
  7190. });
  7191. _api_register('state.save()', function() {
  7192. return this.iterator('table', function(settings) {
  7193. _fnSaveState(settings);
  7194. });
  7195. });
  7196. /**
  7197. * Provide a common method for plug-ins to check the version of DataTables being
  7198. * used, in order to ensure compatibility.
  7199. *
  7200. * @param {string} version Version string to check for, in the format "X.Y.Z".
  7201. * Note that the formats "X" and "X.Y" are also acceptable.
  7202. * @returns {boolean} true if this version of DataTables is greater or equal to
  7203. * the required version, or false if this version of DataTales is not
  7204. * suitable
  7205. * @static
  7206. * @dtopt API-Static
  7207. *
  7208. * @example
  7209. * alert( $.fn.dataTable.versionCheck( '1.9.0' ) );
  7210. */
  7211. DataTable.versionCheck = DataTable.fnVersionCheck = function(version) {
  7212. var aThis = DataTable.version.split('.');
  7213. var aThat = version.split('.');
  7214. var iThis, iThat;
  7215. for (var i = 0, iLen = aThat.length; i < iLen; i++) {
  7216. iThis = parseInt(aThis[i], 10) || 0;
  7217. iThat = parseInt(aThat[i], 10) || 0;
  7218. // Parts are the same, keep comparing
  7219. if (iThis === iThat) {
  7220. continue;
  7221. }
  7222. // Parts are different, return immediately
  7223. return iThis > iThat;
  7224. }
  7225. return true;
  7226. };
  7227. /**
  7228. * Check if a `<table>` node is a DataTable table already or not.
  7229. *
  7230. * @param {node|jquery|string} table Table node, jQuery object or jQuery
  7231. * selector for the table to test. Note that if more than more than one
  7232. * table is passed on, only the first will be checked
  7233. * @returns {boolean} true the table given is a DataTable, or false otherwise
  7234. * @static
  7235. * @dtopt API-Static
  7236. *
  7237. * @example
  7238. * if ( ! $.fn.DataTable.isDataTable( '#example' ) ) {
  7239. * $('#example').dataTable();
  7240. * }
  7241. */
  7242. DataTable.isDataTable = DataTable.fnIsDataTable = function(table) {
  7243. var t = $(table).get(0);
  7244. var is = false;
  7245. $.each(DataTable.settings, function(i, o) {
  7246. var head = o.nScrollHead ? $('table', o.nScrollHead)[0] : null;
  7247. var foot = o.nScrollFoot ? $('table', o.nScrollFoot)[0] : null;
  7248. if (o.nTable === t || head === t || foot === t) {
  7249. is = true;
  7250. }
  7251. });
  7252. return is;
  7253. };
  7254. /**
  7255. * Get all DataTable tables that have been initialised - optionally you can
  7256. * select to get only currently visible tables.
  7257. *
  7258. * @param {boolean} [visible=false] Flag to indicate if you want all (default)
  7259. * or visible tables only.
  7260. * @returns {array} Array of `table` nodes (not DataTable instances) which are
  7261. * DataTables
  7262. * @static
  7263. * @dtopt API-Static
  7264. *
  7265. * @example
  7266. * $.each( $.fn.dataTable.tables(true), function () {
  7267. * $(table).DataTable().columns.adjust();
  7268. * } );
  7269. */
  7270. DataTable.tables = DataTable.fnTables = function(visible) {
  7271. var api = false;
  7272. if ($.isPlainObject(visible)) {
  7273. api = visible.api;
  7274. visible = visible.visible;
  7275. }
  7276. var a = $.map(DataTable.settings, function(o) {
  7277. if (!visible || (visible && $(o.nTable).is(':visible'))) {
  7278. return o.nTable;
  7279. }
  7280. });
  7281. return api ?
  7282. new _Api(a) :
  7283. a;
  7284. };
  7285. /**
  7286. * Convert from camel case parameters to Hungarian notation. This is made public
  7287. * for the extensions to provide the same ability as DataTables core to accept
  7288. * either the 1.9 style Hungarian notation, or the 1.10+ style camelCase
  7289. * parameters.
  7290. *
  7291. * @param {object} src The model object which holds all parameters that can be
  7292. * mapped.
  7293. * @param {object} user The object to convert from camel case to Hungarian.
  7294. * @param {boolean} force When set to `true`, properties which already have a
  7295. * Hungarian value in the `user` object will be overwritten. Otherwise they
  7296. * won't be.
  7297. */
  7298. DataTable.camelToHungarian = _fnCamelToHungarian;
  7299. /**
  7300. *
  7301. */
  7302. _api_register('$()', function(selector, opts) {
  7303. var
  7304. rows = this.rows(opts).nodes(), // Get all rows
  7305. jqRows = $(rows);
  7306. return $([].concat(
  7307. jqRows.filter(selector).toArray(),
  7308. jqRows.find(selector).toArray()
  7309. ));
  7310. });
  7311. // jQuery functions to operate on the tables
  7312. $.each(['on', 'one', 'off'], function(i, key) {
  7313. _api_register(key + '()', function( /* event, handler */ ) {
  7314. var args = Array.prototype.slice.call(arguments);
  7315. // Add the `dt` namespace automatically if it isn't already present
  7316. if (!args[0].match(/\.dt\b/)) {
  7317. args[0] += '.dt';
  7318. }
  7319. var inst = $(this.tables().nodes());
  7320. inst[key].apply(inst, args);
  7321. return this;
  7322. });
  7323. });
  7324. _api_register('clear()', function() {
  7325. return this.iterator('table', function(settings) {
  7326. _fnClearTable(settings);
  7327. });
  7328. });
  7329. _api_register('settings()', function() {
  7330. return new _Api(this.context, this.context);
  7331. });
  7332. _api_register('init()', function() {
  7333. var ctx = this.context;
  7334. return ctx.length ? ctx[0].oInit : null;
  7335. });
  7336. _api_register('data()', function() {
  7337. return this.iterator('table', function(settings) {
  7338. return _pluck(settings.aoData, '_aData');
  7339. }).flatten();
  7340. });
  7341. _api_register('destroy()', function(remove) {
  7342. remove = remove || false;
  7343. return this.iterator('table', function(settings) {
  7344. var orig = settings.nTableWrapper.parentNode;
  7345. var classes = settings.oClasses;
  7346. var table = settings.nTable;
  7347. var tbody = settings.nTBody;
  7348. var thead = settings.nTHead;
  7349. var tfoot = settings.nTFoot;
  7350. var jqTable = $(table);
  7351. var jqTbody = $(tbody);
  7352. var jqWrapper = $(settings.nTableWrapper);
  7353. var rows = $.map(settings.aoData, function(r) {
  7354. return r.nTr;
  7355. });
  7356. var i, ien;
  7357. // Flag to note that the table is currently being destroyed - no action
  7358. // should be taken
  7359. settings.bDestroying = true;
  7360. // Fire off the destroy callbacks for plug-ins etc
  7361. _fnCallbackFire(settings, "aoDestroyCallback", "destroy", [settings]);
  7362. // If not being removed from the document, make all columns visible
  7363. if (!remove) {
  7364. new _Api(settings).columns().visible(true);
  7365. }
  7366. // Blitz all `DT` namespaced events (these are internal events, the
  7367. // lowercase, `dt` events are user subscribed and they are responsible
  7368. // for removing them
  7369. jqWrapper.unbind('.DT').find(':not(tbody *)').unbind('.DT');
  7370. $(window).unbind('.DT-' + settings.sInstance);
  7371. // When scrolling we had to break the table up - restore it
  7372. if (table != thead.parentNode) {
  7373. jqTable.children('thead').detach();
  7374. jqTable.append(thead);
  7375. }
  7376. if (tfoot && table != tfoot.parentNode) {
  7377. jqTable.children('tfoot').detach();
  7378. jqTable.append(tfoot);
  7379. }
  7380. settings.aaSorting = [];
  7381. settings.aaSortingFixed = [];
  7382. _fnSortingClasses(settings);
  7383. $(rows).removeClass(settings.asStripeClasses.join(' '));
  7384. $('th, td', thead).removeClass(classes.sSortable + ' ' +
  7385. classes.sSortableAsc + ' ' + classes.sSortableDesc + ' ' + classes.sSortableNone
  7386. );
  7387. if (settings.bJUI) {
  7388. $('th span.' + classes.sSortIcon + ', td span.' + classes.sSortIcon, thead).detach();
  7389. $('th, td', thead).each(function() {
  7390. var wrapper = $('div.' + classes.sSortJUIWrapper, this);
  7391. $(this).append(wrapper.contents());
  7392. wrapper.detach();
  7393. });
  7394. }
  7395. // Add the TR elements back into the table in their original order
  7396. jqTbody.children().detach();
  7397. jqTbody.append(rows);
  7398. // Remove the DataTables generated nodes, events and classes
  7399. var removedMethod = remove ? 'remove' : 'detach';
  7400. jqTable[removedMethod]();
  7401. jqWrapper[removedMethod]();
  7402. // If we need to reattach the table to the document
  7403. if (!remove && orig) {
  7404. // insertBefore acts like appendChild if !arg[1]
  7405. orig.insertBefore(table, settings.nTableReinsertBefore);
  7406. // Restore the width of the original table - was read from the style property,
  7407. // so we can restore directly to that
  7408. jqTable
  7409. .css('width', settings.sDestroyWidth)
  7410. .removeClass(classes.sTable);
  7411. // If the were originally stripe classes - then we add them back here.
  7412. // Note this is not fool proof (for example if not all rows had stripe
  7413. // classes - but it's a good effort without getting carried away
  7414. ien = settings.asDestroyStripes.length;
  7415. if (ien) {
  7416. jqTbody.children().each(function(i) {
  7417. $(this).addClass(settings.asDestroyStripes[i % ien]);
  7418. });
  7419. }
  7420. }
  7421. /* Remove the settings object from the settings array */
  7422. var idx = $.inArray(settings, DataTable.settings);
  7423. if (idx !== -1) {
  7424. DataTable.settings.splice(idx, 1);
  7425. }
  7426. });
  7427. });
  7428. // Add the `every()` method for rows, columns and cells in a compact form
  7429. $.each(['column', 'row', 'cell'], function(i, type) {
  7430. _api_register(type + 's().every()', function(fn) {
  7431. var opts = this.selector.opts;
  7432. var api = this;
  7433. return this.iterator(type, function(settings, arg1, arg2, arg3, arg4) {
  7434. // Rows and columns:
  7435. // arg1 - index
  7436. // arg2 - table counter
  7437. // arg3 - loop counter
  7438. // arg4 - undefined
  7439. // Cells:
  7440. // arg1 - row index
  7441. // arg2 - column index
  7442. // arg3 - table counter
  7443. // arg4 - loop counter
  7444. fn.call(
  7445. api[type](
  7446. arg1,
  7447. type === 'cell' ? arg2 : opts,
  7448. type === 'cell' ? opts : undefined
  7449. ),
  7450. arg1, arg2, arg3, arg4
  7451. );
  7452. });
  7453. });
  7454. });
  7455. // i18n method for extensions to be able to use the language object from the
  7456. // DataTable
  7457. _api_register('i18n()', function(token, def, plural) {
  7458. var ctx = this.context[0];
  7459. var resolved = _fnGetObjectDataFn(token)(ctx.oLanguage);
  7460. if (resolved === undefined) {
  7461. resolved = def;
  7462. }
  7463. if (plural !== undefined && $.isPlainObject(resolved)) {
  7464. resolved = resolved[plural] !== undefined ?
  7465. resolved[plural] :
  7466. resolved._;
  7467. }
  7468. return resolved.replace('%d', plural); // nb: plural might be undefined,
  7469. });
  7470. /**
  7471. * Version string for plug-ins to check compatibility. Allowed format is
  7472. * `a.b.c-d` where: a:int, b:int, c:int, d:string(dev|beta|alpha). `d` is used
  7473. * only for non-release builds. See http://semver.org/ for more information.
  7474. * @member
  7475. * @type string
  7476. * @default Version number
  7477. */
  7478. DataTable.version = "1.10.12";
  7479. /**
  7480. * Private data store, containing all of the settings objects that are
  7481. * created for the tables on a given page.
  7482. *
  7483. * Note that the `DataTable.settings` object is aliased to
  7484. * `jQuery.fn.dataTableExt` through which it may be accessed and
  7485. * manipulated, or `jQuery.fn.dataTable.settings`.
  7486. * @member
  7487. * @type array
  7488. * @default []
  7489. * @private
  7490. */
  7491. DataTable.settings = [];
  7492. /**
  7493. * Object models container, for the various models that DataTables has
  7494. * available to it. These models define the objects that are used to hold
  7495. * the active state and configuration of the table.
  7496. * @namespace
  7497. */
  7498. DataTable.models = {};
  7499. /**
  7500. * Template object for the way in which DataTables holds information about
  7501. * search information for the global filter and individual column filters.
  7502. * @namespace
  7503. */
  7504. DataTable.models.oSearch = {
  7505. /**
  7506. * Flag to indicate if the filtering should be case insensitive or not
  7507. * @type boolean
  7508. * @default true
  7509. */
  7510. "bCaseInsensitive": true,
  7511. /**
  7512. * Applied search term
  7513. * @type string
  7514. * @default <i>Empty string</i>
  7515. */
  7516. "sSearch": "",
  7517. /**
  7518. * Flag to indicate if the search term should be interpreted as a
  7519. * regular expression (true) or not (false) and therefore and special
  7520. * regex characters escaped.
  7521. * @type boolean
  7522. * @default false
  7523. */
  7524. "bRegex": false,
  7525. /**
  7526. * Flag to indicate if DataTables is to use its smart filtering or not.
  7527. * @type boolean
  7528. * @default true
  7529. */
  7530. "bSmart": true
  7531. };
  7532. /**
  7533. * Template object for the way in which DataTables holds information about
  7534. * each individual row. This is the object format used for the settings
  7535. * aoData array.
  7536. * @namespace
  7537. */
  7538. DataTable.models.oRow = {
  7539. /**
  7540. * TR element for the row
  7541. * @type node
  7542. * @default null
  7543. */
  7544. "nTr": null,
  7545. /**
  7546. * Array of TD elements for each row. This is null until the row has been
  7547. * created.
  7548. * @type array nodes
  7549. * @default []
  7550. */
  7551. "anCells": null,
  7552. /**
  7553. * Data object from the original data source for the row. This is either
  7554. * an array if using the traditional form of DataTables, or an object if
  7555. * using mData options. The exact type will depend on the passed in
  7556. * data from the data source, or will be an array if using DOM a data
  7557. * source.
  7558. * @type array|object
  7559. * @default []
  7560. */
  7561. "_aData": [],
  7562. /**
  7563. * Sorting data cache - this array is ostensibly the same length as the
  7564. * number of columns (although each index is generated only as it is
  7565. * needed), and holds the data that is used for sorting each column in the
  7566. * row. We do this cache generation at the start of the sort in order that
  7567. * the formatting of the sort data need be done only once for each cell
  7568. * per sort. This array should not be read from or written to by anything
  7569. * other than the master sorting methods.
  7570. * @type array
  7571. * @default null
  7572. * @private
  7573. */
  7574. "_aSortData": null,
  7575. /**
  7576. * Per cell filtering data cache. As per the sort data cache, used to
  7577. * increase the performance of the filtering in DataTables
  7578. * @type array
  7579. * @default null
  7580. * @private
  7581. */
  7582. "_aFilterData": null,
  7583. /**
  7584. * Filtering data cache. This is the same as the cell filtering cache, but
  7585. * in this case a string rather than an array. This is easily computed with
  7586. * a join on `_aFilterData`, but is provided as a cache so the join isn't
  7587. * needed on every search (memory traded for performance)
  7588. * @type array
  7589. * @default null
  7590. * @private
  7591. */
  7592. "_sFilterRow": null,
  7593. /**
  7594. * Cache of the class name that DataTables has applied to the row, so we
  7595. * can quickly look at this variable rather than needing to do a DOM check
  7596. * on className for the nTr property.
  7597. * @type string
  7598. * @default <i>Empty string</i>
  7599. * @private
  7600. */
  7601. "_sRowStripe": "",
  7602. /**
  7603. * Denote if the original data source was from the DOM, or the data source
  7604. * object. This is used for invalidating data, so DataTables can
  7605. * automatically read data from the original source, unless uninstructed
  7606. * otherwise.
  7607. * @type string
  7608. * @default null
  7609. * @private
  7610. */
  7611. "src": null,
  7612. /**
  7613. * Index in the aoData array. This saves an indexOf lookup when we have the
  7614. * object, but want to know the index
  7615. * @type integer
  7616. * @default -1
  7617. * @private
  7618. */
  7619. "idx": -1
  7620. };
  7621. /**
  7622. * Template object for the column information object in DataTables. This object
  7623. * is held in the settings aoColumns array and contains all the information that
  7624. * DataTables needs about each individual column.
  7625. *
  7626. * Note that this object is related to {@link DataTable.defaults.column}
  7627. * but this one is the internal data store for DataTables's cache of columns.
  7628. * It should NOT be manipulated outside of DataTables. Any configuration should
  7629. * be done through the initialisation options.
  7630. * @namespace
  7631. */
  7632. DataTable.models.oColumn = {
  7633. /**
  7634. * Column index. This could be worked out on-the-fly with $.inArray, but it
  7635. * is faster to just hold it as a variable
  7636. * @type integer
  7637. * @default null
  7638. */
  7639. "idx": null,
  7640. /**
  7641. * A list of the columns that sorting should occur on when this column
  7642. * is sorted. That this property is an array allows multi-column sorting
  7643. * to be defined for a column (for example first name / last name columns
  7644. * would benefit from this). The values are integers pointing to the
  7645. * columns to be sorted on (typically it will be a single integer pointing
  7646. * at itself, but that doesn't need to be the case).
  7647. * @type array
  7648. */
  7649. "aDataSort": null,
  7650. /**
  7651. * Define the sorting directions that are applied to the column, in sequence
  7652. * as the column is repeatedly sorted upon - i.e. the first value is used
  7653. * as the sorting direction when the column if first sorted (clicked on).
  7654. * Sort it again (click again) and it will move on to the next index.
  7655. * Repeat until loop.
  7656. * @type array
  7657. */
  7658. "asSorting": null,
  7659. /**
  7660. * Flag to indicate if the column is searchable, and thus should be included
  7661. * in the filtering or not.
  7662. * @type boolean
  7663. */
  7664. "bSearchable": null,
  7665. /**
  7666. * Flag to indicate if the column is sortable or not.
  7667. * @type boolean
  7668. */
  7669. "bSortable": null,
  7670. /**
  7671. * Flag to indicate if the column is currently visible in the table or not
  7672. * @type boolean
  7673. */
  7674. "bVisible": null,
  7675. /**
  7676. * Store for manual type assignment using the `column.type` option. This
  7677. * is held in store so we can manipulate the column's `sType` property.
  7678. * @type string
  7679. * @default null
  7680. * @private
  7681. */
  7682. "_sManualType": null,
  7683. /**
  7684. * Flag to indicate if HTML5 data attributes should be used as the data
  7685. * source for filtering or sorting. True is either are.
  7686. * @type boolean
  7687. * @default false
  7688. * @private
  7689. */
  7690. "_bAttrSrc": false,
  7691. /**
  7692. * Developer definable function that is called whenever a cell is created (Ajax source,
  7693. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  7694. * allowing you to modify the DOM element (add background colour for example) when the
  7695. * element is available.
  7696. * @type function
  7697. * @param {element} nTd The TD node that has been created
  7698. * @param {*} sData The Data for the cell
  7699. * @param {array|object} oData The data for the whole row
  7700. * @param {int} iRow The row index for the aoData data store
  7701. * @default null
  7702. */
  7703. "fnCreatedCell": null,
  7704. /**
  7705. * Function to get data from a cell in a column. You should <b>never</b>
  7706. * access data directly through _aData internally in DataTables - always use
  7707. * the method attached to this property. It allows mData to function as
  7708. * required. This function is automatically assigned by the column
  7709. * initialisation method
  7710. * @type function
  7711. * @param {array|object} oData The data array/object for the array
  7712. * (i.e. aoData[]._aData)
  7713. * @param {string} sSpecific The specific data type you want to get -
  7714. * 'display', 'type' 'filter' 'sort'
  7715. * @returns {*} The data for the cell from the given row's data
  7716. * @default null
  7717. */
  7718. "fnGetData": null,
  7719. /**
  7720. * Function to set data for a cell in the column. You should <b>never</b>
  7721. * set the data directly to _aData internally in DataTables - always use
  7722. * this method. It allows mData to function as required. This function
  7723. * is automatically assigned by the column initialisation method
  7724. * @type function
  7725. * @param {array|object} oData The data array/object for the array
  7726. * (i.e. aoData[]._aData)
  7727. * @param {*} sValue Value to set
  7728. * @default null
  7729. */
  7730. "fnSetData": null,
  7731. /**
  7732. * Property to read the value for the cells in the column from the data
  7733. * source array / object. If null, then the default content is used, if a
  7734. * function is given then the return from the function is used.
  7735. * @type function|int|string|null
  7736. * @default null
  7737. */
  7738. "mData": null,
  7739. /**
  7740. * Partner property to mData which is used (only when defined) to get
  7741. * the data - i.e. it is basically the same as mData, but without the
  7742. * 'set' option, and also the data fed to it is the result from mData.
  7743. * This is the rendering method to match the data method of mData.
  7744. * @type function|int|string|null
  7745. * @default null
  7746. */
  7747. "mRender": null,
  7748. /**
  7749. * Unique header TH/TD element for this column - this is what the sorting
  7750. * listener is attached to (if sorting is enabled.)
  7751. * @type node
  7752. * @default null
  7753. */
  7754. "nTh": null,
  7755. /**
  7756. * Unique footer TH/TD element for this column (if there is one). Not used
  7757. * in DataTables as such, but can be used for plug-ins to reference the
  7758. * footer for each column.
  7759. * @type node
  7760. * @default null
  7761. */
  7762. "nTf": null,
  7763. /**
  7764. * The class to apply to all TD elements in the table's TBODY for the column
  7765. * @type string
  7766. * @default null
  7767. */
  7768. "sClass": null,
  7769. /**
  7770. * When DataTables calculates the column widths to assign to each column,
  7771. * it finds the longest string in each column and then constructs a
  7772. * temporary table and reads the widths from that. The problem with this
  7773. * is that "mmm" is much wider then "iiii", but the latter is a longer
  7774. * string - thus the calculation can go wrong (doing it properly and putting
  7775. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  7776. * a "work around" we provide this option. It will append its value to the
  7777. * text that is found to be the longest string for the column - i.e. padding.
  7778. * @type string
  7779. */
  7780. "sContentPadding": null,
  7781. /**
  7782. * Allows a default value to be given for a column's data, and will be used
  7783. * whenever a null data source is encountered (this can be because mData
  7784. * is set to null, or because the data source itself is null).
  7785. * @type string
  7786. * @default null
  7787. */
  7788. "sDefaultContent": null,
  7789. /**
  7790. * Name for the column, allowing reference to the column by name as well as
  7791. * by index (needs a lookup to work by name).
  7792. * @type string
  7793. */
  7794. "sName": null,
  7795. /**
  7796. * Custom sorting data type - defines which of the available plug-ins in
  7797. * afnSortData the custom sorting will use - if any is defined.
  7798. * @type string
  7799. * @default std
  7800. */
  7801. "sSortDataType": 'std',
  7802. /**
  7803. * Class to be applied to the header element when sorting on this column
  7804. * @type string
  7805. * @default null
  7806. */
  7807. "sSortingClass": null,
  7808. /**
  7809. * Class to be applied to the header element when sorting on this column -
  7810. * when jQuery UI theming is used.
  7811. * @type string
  7812. * @default null
  7813. */
  7814. "sSortingClassJUI": null,
  7815. /**
  7816. * Title of the column - what is seen in the TH element (nTh).
  7817. * @type string
  7818. */
  7819. "sTitle": null,
  7820. /**
  7821. * Column sorting and filtering type
  7822. * @type string
  7823. * @default null
  7824. */
  7825. "sType": null,
  7826. /**
  7827. * Width of the column
  7828. * @type string
  7829. * @default null
  7830. */
  7831. "sWidth": null,
  7832. /**
  7833. * Width of the column when it was first "encountered"
  7834. * @type string
  7835. * @default null
  7836. */
  7837. "sWidthOrig": null
  7838. };
  7839. /*
  7840. * Developer note: The properties of the object below are given in Hungarian
  7841. * notation, that was used as the interface for DataTables prior to v1.10, however
  7842. * from v1.10 onwards the primary interface is camel case. In order to avoid
  7843. * breaking backwards compatibility utterly with this change, the Hungarian
  7844. * version is still, internally the primary interface, but is is not documented
  7845. * - hence the @name tags in each doc comment. This allows a Javascript function
  7846. * to create a map from Hungarian notation to camel case (going the other direction
  7847. * would require each property to be listed, which would at around 3K to the size
  7848. * of DataTables, while this method is about a 0.5K hit.
  7849. *
  7850. * Ultimately this does pave the way for Hungarian notation to be dropped
  7851. * completely, but that is a massive amount of work and will break current
  7852. * installs (therefore is on-hold until v2).
  7853. */
  7854. /**
  7855. * Initialisation options that can be given to DataTables at initialisation
  7856. * time.
  7857. * @namespace
  7858. */
  7859. DataTable.defaults = {
  7860. /**
  7861. * An array of data to use for the table, passed in at initialisation which
  7862. * will be used in preference to any data which is already in the DOM. This is
  7863. * particularly useful for constructing tables purely in Javascript, for
  7864. * example with a custom Ajax call.
  7865. * @type array
  7866. * @default null
  7867. *
  7868. * @dtopt Option
  7869. * @name DataTable.defaults.data
  7870. *
  7871. * @example
  7872. * // Using a 2D array data source
  7873. * $(document).ready( function () {
  7874. * $('#example').dataTable( {
  7875. * "data": [
  7876. * ['Trident', 'Internet Explorer 4.0', 'Win 95+', 4, 'X'],
  7877. * ['Trident', 'Internet Explorer 5.0', 'Win 95+', 5, 'C'],
  7878. * ],
  7879. * "columns": [
  7880. * { "title": "Engine" },
  7881. * { "title": "Browser" },
  7882. * { "title": "Platform" },
  7883. * { "title": "Version" },
  7884. * { "title": "Grade" }
  7885. * ]
  7886. * } );
  7887. * } );
  7888. *
  7889. * @example
  7890. * // Using an array of objects as a data source (`data`)
  7891. * $(document).ready( function () {
  7892. * $('#example').dataTable( {
  7893. * "data": [
  7894. * {
  7895. * "engine": "Trident",
  7896. * "browser": "Internet Explorer 4.0",
  7897. * "platform": "Win 95+",
  7898. * "version": 4,
  7899. * "grade": "X"
  7900. * },
  7901. * {
  7902. * "engine": "Trident",
  7903. * "browser": "Internet Explorer 5.0",
  7904. * "platform": "Win 95+",
  7905. * "version": 5,
  7906. * "grade": "C"
  7907. * }
  7908. * ],
  7909. * "columns": [
  7910. * { "title": "Engine", "data": "engine" },
  7911. * { "title": "Browser", "data": "browser" },
  7912. * { "title": "Platform", "data": "platform" },
  7913. * { "title": "Version", "data": "version" },
  7914. * { "title": "Grade", "data": "grade" }
  7915. * ]
  7916. * } );
  7917. * } );
  7918. */
  7919. "aaData": null,
  7920. /**
  7921. * If ordering is enabled, then DataTables will perform a first pass sort on
  7922. * initialisation. You can define which column(s) the sort is performed
  7923. * upon, and the sorting direction, with this variable. The `sorting` array
  7924. * should contain an array for each column to be sorted initially containing
  7925. * the column's index and a direction string ('asc' or 'desc').
  7926. * @type array
  7927. * @default [[0,'asc']]
  7928. *
  7929. * @dtopt Option
  7930. * @name DataTable.defaults.order
  7931. *
  7932. * @example
  7933. * // Sort by 3rd column first, and then 4th column
  7934. * $(document).ready( function() {
  7935. * $('#example').dataTable( {
  7936. * "order": [[2,'asc'], [3,'desc']]
  7937. * } );
  7938. * } );
  7939. *
  7940. * // No initial sorting
  7941. * $(document).ready( function() {
  7942. * $('#example').dataTable( {
  7943. * "order": []
  7944. * } );
  7945. * } );
  7946. */
  7947. "aaSorting": [
  7948. [0, 'asc']
  7949. ],
  7950. /**
  7951. * This parameter is basically identical to the `sorting` parameter, but
  7952. * cannot be overridden by user interaction with the table. What this means
  7953. * is that you could have a column (visible or hidden) which the sorting
  7954. * will always be forced on first - any sorting after that (from the user)
  7955. * will then be performed as required. This can be useful for grouping rows
  7956. * together.
  7957. * @type array
  7958. * @default null
  7959. *
  7960. * @dtopt Option
  7961. * @name DataTable.defaults.orderFixed
  7962. *
  7963. * @example
  7964. * $(document).ready( function() {
  7965. * $('#example').dataTable( {
  7966. * "orderFixed": [[0,'asc']]
  7967. * } );
  7968. * } )
  7969. */
  7970. "aaSortingFixed": [],
  7971. /**
  7972. * DataTables can be instructed to load data to display in the table from a
  7973. * Ajax source. This option defines how that Ajax call is made and where to.
  7974. *
  7975. * The `ajax` property has three different modes of operation, depending on
  7976. * how it is defined. These are:
  7977. *
  7978. * * `string` - Set the URL from where the data should be loaded from.
  7979. * * `object` - Define properties for `jQuery.ajax`.
  7980. * * `function` - Custom data get function
  7981. *
  7982. * `string`
  7983. * --------
  7984. *
  7985. * As a string, the `ajax` property simply defines the URL from which
  7986. * DataTables will load data.
  7987. *
  7988. * `object`
  7989. * --------
  7990. *
  7991. * As an object, the parameters in the object are passed to
  7992. * [jQuery.ajax](http://api.jquery.com/jQuery.ajax/) allowing fine control
  7993. * of the Ajax request. DataTables has a number of default parameters which
  7994. * you can override using this option. Please refer to the jQuery
  7995. * documentation for a full description of the options available, although
  7996. * the following parameters provide additional options in DataTables or
  7997. * require special consideration:
  7998. *
  7999. * * `data` - As with jQuery, `data` can be provided as an object, but it
  8000. * can also be used as a function to manipulate the data DataTables sends
  8001. * to the server. The function takes a single parameter, an object of
  8002. * parameters with the values that DataTables has readied for sending. An
  8003. * object may be returned which will be merged into the DataTables
  8004. * defaults, or you can add the items to the object that was passed in and
  8005. * not return anything from the function. This supersedes `fnServerParams`
  8006. * from DataTables 1.9-.
  8007. *
  8008. * * `dataSrc` - By default DataTables will look for the property `data` (or
  8009. * `aaData` for compatibility with DataTables 1.9-) when obtaining data
  8010. * from an Ajax source or for server-side processing - this parameter
  8011. * allows that property to be changed. You can use Javascript dotted
  8012. * object notation to get a data source for multiple levels of nesting, or
  8013. * it my be used as a function. As a function it takes a single parameter,
  8014. * the JSON returned from the server, which can be manipulated as
  8015. * required, with the returned value being that used by DataTables as the
  8016. * data source for the table. This supersedes `sAjaxDataProp` from
  8017. * DataTables 1.9-.
  8018. *
  8019. * * `success` - Should not be overridden it is used internally in
  8020. * DataTables. To manipulate / transform the data returned by the server
  8021. * use `ajax.dataSrc`, or use `ajax` as a function (see below).
  8022. *
  8023. * `function`
  8024. * ----------
  8025. *
  8026. * As a function, making the Ajax call is left up to yourself allowing
  8027. * complete control of the Ajax request. Indeed, if desired, a method other
  8028. * than Ajax could be used to obtain the required data, such as Web storage
  8029. * or an AIR database.
  8030. *
  8031. * The function is given four parameters and no return is required. The
  8032. * parameters are:
  8033. *
  8034. * 1. _object_ - Data to send to the server
  8035. * 2. _function_ - Callback function that must be executed when the required
  8036. * data has been obtained. That data should be passed into the callback
  8037. * as the only parameter
  8038. * 3. _object_ - DataTables settings object for the table
  8039. *
  8040. * Note that this supersedes `fnServerData` from DataTables 1.9-.
  8041. *
  8042. * @type string|object|function
  8043. * @default null
  8044. *
  8045. * @dtopt Option
  8046. * @name DataTable.defaults.ajax
  8047. * @since 1.10.0
  8048. *
  8049. * @example
  8050. * // Get JSON data from a file via Ajax.
  8051. * // Note DataTables expects data in the form `{ data: [ ...data... ] }` by default).
  8052. * $('#example').dataTable( {
  8053. * "ajax": "data.json"
  8054. * } );
  8055. *
  8056. * @example
  8057. * // Get JSON data from a file via Ajax, using `dataSrc` to change
  8058. * // `data` to `tableData` (i.e. `{ tableData: [ ...data... ] }`)
  8059. * $('#example').dataTable( {
  8060. * "ajax": {
  8061. * "url": "data.json",
  8062. * "dataSrc": "tableData"
  8063. * }
  8064. * } );
  8065. *
  8066. * @example
  8067. * // Get JSON data from a file via Ajax, using `dataSrc` to read data
  8068. * // from a plain array rather than an array in an object
  8069. * $('#example').dataTable( {
  8070. * "ajax": {
  8071. * "url": "data.json",
  8072. * "dataSrc": ""
  8073. * }
  8074. * } );
  8075. *
  8076. * @example
  8077. * // Manipulate the data returned from the server - add a link to data
  8078. * // (note this can, should, be done using `render` for the column - this
  8079. * // is just a simple example of how the data can be manipulated).
  8080. * $('#example').dataTable( {
  8081. * "ajax": {
  8082. * "url": "data.json",
  8083. * "dataSrc": function ( json ) {
  8084. * for ( var i=0, ien=json.length ; i<ien ; i++ ) {
  8085. * json[i][0] = '<a href="/message/'+json[i][0]+'>View message</a>';
  8086. * }
  8087. * return json;
  8088. * }
  8089. * }
  8090. * } );
  8091. *
  8092. * @example
  8093. * // Add data to the request
  8094. * $('#example').dataTable( {
  8095. * "ajax": {
  8096. * "url": "data.json",
  8097. * "data": function ( d ) {
  8098. * return {
  8099. * "extra_search": $('#extra').val()
  8100. * };
  8101. * }
  8102. * }
  8103. * } );
  8104. *
  8105. * @example
  8106. * // Send request as POST
  8107. * $('#example').dataTable( {
  8108. * "ajax": {
  8109. * "url": "data.json",
  8110. * "type": "POST"
  8111. * }
  8112. * } );
  8113. *
  8114. * @example
  8115. * // Get the data from localStorage (could interface with a form for
  8116. * // adding, editing and removing rows).
  8117. * $('#example').dataTable( {
  8118. * "ajax": function (data, callback, settings) {
  8119. * callback(
  8120. * JSON.parse( localStorage.getItem('dataTablesData') )
  8121. * );
  8122. * }
  8123. * } );
  8124. */
  8125. "ajax": null,
  8126. /**
  8127. * This parameter allows you to readily specify the entries in the length drop
  8128. * down menu that DataTables shows when pagination is enabled. It can be
  8129. * either a 1D array of options which will be used for both the displayed
  8130. * option and the value, or a 2D array which will use the array in the first
  8131. * position as the value, and the array in the second position as the
  8132. * displayed options (useful for language strings such as 'All').
  8133. *
  8134. * Note that the `pageLength` property will be automatically set to the
  8135. * first value given in this array, unless `pageLength` is also provided.
  8136. * @type array
  8137. * @default [ 10, 25, 50, 100 ]
  8138. *
  8139. * @dtopt Option
  8140. * @name DataTable.defaults.lengthMenu
  8141. *
  8142. * @example
  8143. * $(document).ready( function() {
  8144. * $('#example').dataTable( {
  8145. * "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
  8146. * } );
  8147. * } );
  8148. */
  8149. "aLengthMenu": [10, 25, 50, 100],
  8150. /**
  8151. * The `columns` option in the initialisation parameter allows you to define
  8152. * details about the way individual columns behave. For a full list of
  8153. * column options that can be set, please see
  8154. * {@link DataTable.defaults.column}. Note that if you use `columns` to
  8155. * define your columns, you must have an entry in the array for every single
  8156. * column that you have in your table (these can be null if you don't which
  8157. * to specify any options).
  8158. * @member
  8159. *
  8160. * @name DataTable.defaults.column
  8161. */
  8162. "aoColumns": null,
  8163. /**
  8164. * Very similar to `columns`, `columnDefs` allows you to target a specific
  8165. * column, multiple columns, or all columns, using the `targets` property of
  8166. * each object in the array. This allows great flexibility when creating
  8167. * tables, as the `columnDefs` arrays can be of any length, targeting the
  8168. * columns you specifically want. `columnDefs` may use any of the column
  8169. * options available: {@link DataTable.defaults.column}, but it _must_
  8170. * have `targets` defined in each object in the array. Values in the `targets`
  8171. * array may be:
  8172. * <ul>
  8173. * <li>a string - class name will be matched on the TH for the column</li>
  8174. * <li>0 or a positive integer - column index counting from the left</li>
  8175. * <li>a negative integer - column index counting from the right</li>
  8176. * <li>the string "_all" - all columns (i.e. assign a default)</li>
  8177. * </ul>
  8178. * @member
  8179. *
  8180. * @name DataTable.defaults.columnDefs
  8181. */
  8182. "aoColumnDefs": null,
  8183. /**
  8184. * Basically the same as `search`, this parameter defines the individual column
  8185. * filtering state at initialisation time. The array must be of the same size
  8186. * as the number of columns, and each element be an object with the parameters
  8187. * `search` and `escapeRegex` (the latter is optional). 'null' is also
  8188. * accepted and the default will be used.
  8189. * @type array
  8190. * @default []
  8191. *
  8192. * @dtopt Option
  8193. * @name DataTable.defaults.searchCols
  8194. *
  8195. * @example
  8196. * $(document).ready( function() {
  8197. * $('#example').dataTable( {
  8198. * "searchCols": [
  8199. * null,
  8200. * { "search": "My filter" },
  8201. * null,
  8202. * { "search": "^[0-9]", "escapeRegex": false }
  8203. * ]
  8204. * } );
  8205. * } )
  8206. */
  8207. "aoSearchCols": [],
  8208. /**
  8209. * An array of CSS classes that should be applied to displayed rows. This
  8210. * array may be of any length, and DataTables will apply each class
  8211. * sequentially, looping when required.
  8212. * @type array
  8213. * @default null <i>Will take the values determined by the `oClasses.stripe*`
  8214. * options</i>
  8215. *
  8216. * @dtopt Option
  8217. * @name DataTable.defaults.stripeClasses
  8218. *
  8219. * @example
  8220. * $(document).ready( function() {
  8221. * $('#example').dataTable( {
  8222. * "stripeClasses": [ 'strip1', 'strip2', 'strip3' ]
  8223. * } );
  8224. * } )
  8225. */
  8226. "asStripeClasses": null,
  8227. /**
  8228. * Enable or disable automatic column width calculation. This can be disabled
  8229. * as an optimisation (it takes some time to calculate the widths) if the
  8230. * tables widths are passed in using `columns`.
  8231. * @type boolean
  8232. * @default true
  8233. *
  8234. * @dtopt Features
  8235. * @name DataTable.defaults.autoWidth
  8236. *
  8237. * @example
  8238. * $(document).ready( function () {
  8239. * $('#example').dataTable( {
  8240. * "autoWidth": false
  8241. * } );
  8242. * } );
  8243. */
  8244. "bAutoWidth": true,
  8245. /**
  8246. * Deferred rendering can provide DataTables with a huge speed boost when you
  8247. * are using an Ajax or JS data source for the table. This option, when set to
  8248. * true, will cause DataTables to defer the creation of the table elements for
  8249. * each row until they are needed for a draw - saving a significant amount of
  8250. * time.
  8251. * @type boolean
  8252. * @default false
  8253. *
  8254. * @dtopt Features
  8255. * @name DataTable.defaults.deferRender
  8256. *
  8257. * @example
  8258. * $(document).ready( function() {
  8259. * $('#example').dataTable( {
  8260. * "ajax": "sources/arrays.txt",
  8261. * "deferRender": true
  8262. * } );
  8263. * } );
  8264. */
  8265. "bDeferRender": false,
  8266. /**
  8267. * Replace a DataTable which matches the given selector and replace it with
  8268. * one which has the properties of the new initialisation object passed. If no
  8269. * table matches the selector, then the new DataTable will be constructed as
  8270. * per normal.
  8271. * @type boolean
  8272. * @default false
  8273. *
  8274. * @dtopt Options
  8275. * @name DataTable.defaults.destroy
  8276. *
  8277. * @example
  8278. * $(document).ready( function() {
  8279. * $('#example').dataTable( {
  8280. * "srollY": "200px",
  8281. * "paginate": false
  8282. * } );
  8283. *
  8284. * // Some time later....
  8285. * $('#example').dataTable( {
  8286. * "filter": false,
  8287. * "destroy": true
  8288. * } );
  8289. * } );
  8290. */
  8291. "bDestroy": false,
  8292. /**
  8293. * Enable or disable filtering of data. Filtering in DataTables is "smart" in
  8294. * that it allows the end user to input multiple words (space separated) and
  8295. * will match a row containing those words, even if not in the order that was
  8296. * specified (this allow matching across multiple columns). Note that if you
  8297. * wish to use filtering in DataTables this must remain 'true' - to remove the
  8298. * default filtering input box and retain filtering abilities, please use
  8299. * {@link DataTable.defaults.dom}.
  8300. * @type boolean
  8301. * @default true
  8302. *
  8303. * @dtopt Features
  8304. * @name DataTable.defaults.searching
  8305. *
  8306. * @example
  8307. * $(document).ready( function () {
  8308. * $('#example').dataTable( {
  8309. * "searching": false
  8310. * } );
  8311. * } );
  8312. */
  8313. "bFilter": true,
  8314. /**
  8315. * Enable or disable the table information display. This shows information
  8316. * about the data that is currently visible on the page, including information
  8317. * about filtered data if that action is being performed.
  8318. * @type boolean
  8319. * @default true
  8320. *
  8321. * @dtopt Features
  8322. * @name DataTable.defaults.info
  8323. *
  8324. * @example
  8325. * $(document).ready( function () {
  8326. * $('#example').dataTable( {
  8327. * "info": false
  8328. * } );
  8329. * } );
  8330. */
  8331. "bInfo": true,
  8332. /**
  8333. * Enable jQuery UI ThemeRoller support (required as ThemeRoller requires some
  8334. * slightly different and additional mark-up from what DataTables has
  8335. * traditionally used).
  8336. * @type boolean
  8337. * @default false
  8338. *
  8339. * @dtopt Features
  8340. * @name DataTable.defaults.jQueryUI
  8341. *
  8342. * @example
  8343. * $(document).ready( function() {
  8344. * $('#example').dataTable( {
  8345. * "jQueryUI": true
  8346. * } );
  8347. * } );
  8348. */
  8349. "bJQueryUI": false,
  8350. /**
  8351. * Allows the end user to select the size of a formatted page from a select
  8352. * menu (sizes are 10, 25, 50 and 100). Requires pagination (`paginate`).
  8353. * @type boolean
  8354. * @default true
  8355. *
  8356. * @dtopt Features
  8357. * @name DataTable.defaults.lengthChange
  8358. *
  8359. * @example
  8360. * $(document).ready( function () {
  8361. * $('#example').dataTable( {
  8362. * "lengthChange": false
  8363. * } );
  8364. * } );
  8365. */
  8366. "bLengthChange": true,
  8367. /**
  8368. * Enable or disable pagination.
  8369. * @type boolean
  8370. * @default true
  8371. *
  8372. * @dtopt Features
  8373. * @name DataTable.defaults.paging
  8374. *
  8375. * @example
  8376. * $(document).ready( function () {
  8377. * $('#example').dataTable( {
  8378. * "paging": false
  8379. * } );
  8380. * } );
  8381. */
  8382. "bPaginate": true,
  8383. /**
  8384. * Enable or disable the display of a 'processing' indicator when the table is
  8385. * being processed (e.g. a sort). This is particularly useful for tables with
  8386. * large amounts of data where it can take a noticeable amount of time to sort
  8387. * the entries.
  8388. * @type boolean
  8389. * @default false
  8390. *
  8391. * @dtopt Features
  8392. * @name DataTable.defaults.processing
  8393. *
  8394. * @example
  8395. * $(document).ready( function () {
  8396. * $('#example').dataTable( {
  8397. * "processing": true
  8398. * } );
  8399. * } );
  8400. */
  8401. "bProcessing": false,
  8402. /**
  8403. * Retrieve the DataTables object for the given selector. Note that if the
  8404. * table has already been initialised, this parameter will cause DataTables
  8405. * to simply return the object that has already been set up - it will not take
  8406. * account of any changes you might have made to the initialisation object
  8407. * passed to DataTables (setting this parameter to true is an acknowledgement
  8408. * that you understand this). `destroy` can be used to reinitialise a table if
  8409. * you need.
  8410. * @type boolean
  8411. * @default false
  8412. *
  8413. * @dtopt Options
  8414. * @name DataTable.defaults.retrieve
  8415. *
  8416. * @example
  8417. * $(document).ready( function() {
  8418. * initTable();
  8419. * tableActions();
  8420. * } );
  8421. *
  8422. * function initTable ()
  8423. * {
  8424. * return $('#example').dataTable( {
  8425. * "scrollY": "200px",
  8426. * "paginate": false,
  8427. * "retrieve": true
  8428. * } );
  8429. * }
  8430. *
  8431. * function tableActions ()
  8432. * {
  8433. * var table = initTable();
  8434. * // perform API operations with oTable
  8435. * }
  8436. */
  8437. "bRetrieve": false,
  8438. /**
  8439. * When vertical (y) scrolling is enabled, DataTables will force the height of
  8440. * the table's viewport to the given height at all times (useful for layout).
  8441. * However, this can look odd when filtering data down to a small data set,
  8442. * and the footer is left "floating" further down. This parameter (when
  8443. * enabled) will cause DataTables to collapse the table's viewport down when
  8444. * the result set will fit within the given Y height.
  8445. * @type boolean
  8446. * @default false
  8447. *
  8448. * @dtopt Options
  8449. * @name DataTable.defaults.scrollCollapse
  8450. *
  8451. * @example
  8452. * $(document).ready( function() {
  8453. * $('#example').dataTable( {
  8454. * "scrollY": "200",
  8455. * "scrollCollapse": true
  8456. * } );
  8457. * } );
  8458. */
  8459. "bScrollCollapse": false,
  8460. /**
  8461. * Configure DataTables to use server-side processing. Note that the
  8462. * `ajax` parameter must also be given in order to give DataTables a
  8463. * source to obtain the required data for each draw.
  8464. * @type boolean
  8465. * @default false
  8466. *
  8467. * @dtopt Features
  8468. * @dtopt Server-side
  8469. * @name DataTable.defaults.serverSide
  8470. *
  8471. * @example
  8472. * $(document).ready( function () {
  8473. * $('#example').dataTable( {
  8474. * "serverSide": true,
  8475. * "ajax": "xhr.php"
  8476. * } );
  8477. * } );
  8478. */
  8479. "bServerSide": false,
  8480. /**
  8481. * Enable or disable sorting of columns. Sorting of individual columns can be
  8482. * disabled by the `sortable` option for each column.
  8483. * @type boolean
  8484. * @default true
  8485. *
  8486. * @dtopt Features
  8487. * @name DataTable.defaults.ordering
  8488. *
  8489. * @example
  8490. * $(document).ready( function () {
  8491. * $('#example').dataTable( {
  8492. * "ordering": false
  8493. * } );
  8494. * } );
  8495. */
  8496. "bSort": true,
  8497. /**
  8498. * Enable or display DataTables' ability to sort multiple columns at the
  8499. * same time (activated by shift-click by the user).
  8500. * @type boolean
  8501. * @default true
  8502. *
  8503. * @dtopt Options
  8504. * @name DataTable.defaults.orderMulti
  8505. *
  8506. * @example
  8507. * // Disable multiple column sorting ability
  8508. * $(document).ready( function () {
  8509. * $('#example').dataTable( {
  8510. * "orderMulti": false
  8511. * } );
  8512. * } );
  8513. */
  8514. "bSortMulti": true,
  8515. /**
  8516. * Allows control over whether DataTables should use the top (true) unique
  8517. * cell that is found for a single column, or the bottom (false - default).
  8518. * This is useful when using complex headers.
  8519. * @type boolean
  8520. * @default false
  8521. *
  8522. * @dtopt Options
  8523. * @name DataTable.defaults.orderCellsTop
  8524. *
  8525. * @example
  8526. * $(document).ready( function() {
  8527. * $('#example').dataTable( {
  8528. * "orderCellsTop": true
  8529. * } );
  8530. * } );
  8531. */
  8532. "bSortCellsTop": false,
  8533. /**
  8534. * Enable or disable the addition of the classes `sorting\_1`, `sorting\_2` and
  8535. * `sorting\_3` to the columns which are currently being sorted on. This is
  8536. * presented as a feature switch as it can increase processing time (while
  8537. * classes are removed and added) so for large data sets you might want to
  8538. * turn this off.
  8539. * @type boolean
  8540. * @default true
  8541. *
  8542. * @dtopt Features
  8543. * @name DataTable.defaults.orderClasses
  8544. *
  8545. * @example
  8546. * $(document).ready( function () {
  8547. * $('#example').dataTable( {
  8548. * "orderClasses": false
  8549. * } );
  8550. * } );
  8551. */
  8552. "bSortClasses": true,
  8553. /**
  8554. * Enable or disable state saving. When enabled HTML5 `localStorage` will be
  8555. * used to save table display information such as pagination information,
  8556. * display length, filtering and sorting. As such when the end user reloads
  8557. * the page the display display will match what thy had previously set up.
  8558. *
  8559. * Due to the use of `localStorage` the default state saving is not supported
  8560. * in IE6 or 7. If state saving is required in those browsers, use
  8561. * `stateSaveCallback` to provide a storage solution such as cookies.
  8562. * @type boolean
  8563. * @default false
  8564. *
  8565. * @dtopt Features
  8566. * @name DataTable.defaults.stateSave
  8567. *
  8568. * @example
  8569. * $(document).ready( function () {
  8570. * $('#example').dataTable( {
  8571. * "stateSave": true
  8572. * } );
  8573. * } );
  8574. */
  8575. "bStateSave": false,
  8576. /**
  8577. * This function is called when a TR element is created (and all TD child
  8578. * elements have been inserted), or registered if using a DOM source, allowing
  8579. * manipulation of the TR element (adding classes etc).
  8580. * @type function
  8581. * @param {node} row "TR" element for the current row
  8582. * @param {array} data Raw data array for this row
  8583. * @param {int} dataIndex The index of this row in the internal aoData array
  8584. *
  8585. * @dtopt Callbacks
  8586. * @name DataTable.defaults.createdRow
  8587. *
  8588. * @example
  8589. * $(document).ready( function() {
  8590. * $('#example').dataTable( {
  8591. * "createdRow": function( row, data, dataIndex ) {
  8592. * // Bold the grade for all 'A' grade browsers
  8593. * if ( data[4] == "A" )
  8594. * {
  8595. * $('td:eq(4)', row).html( '<b>A</b>' );
  8596. * }
  8597. * }
  8598. * } );
  8599. * } );
  8600. */
  8601. "fnCreatedRow": null,
  8602. /**
  8603. * This function is called on every 'draw' event, and allows you to
  8604. * dynamically modify any aspect you want about the created DOM.
  8605. * @type function
  8606. * @param {object} settings DataTables settings object
  8607. *
  8608. * @dtopt Callbacks
  8609. * @name DataTable.defaults.drawCallback
  8610. *
  8611. * @example
  8612. * $(document).ready( function() {
  8613. * $('#example').dataTable( {
  8614. * "drawCallback": function( settings ) {
  8615. * alert( 'DataTables has redrawn the table' );
  8616. * }
  8617. * } );
  8618. * } );
  8619. */
  8620. "fnDrawCallback": null,
  8621. /**
  8622. * Identical to fnHeaderCallback() but for the table footer this function
  8623. * allows you to modify the table footer on every 'draw' event.
  8624. * @type function
  8625. * @param {node} foot "TR" element for the footer
  8626. * @param {array} data Full table data (as derived from the original HTML)
  8627. * @param {int} start Index for the current display starting point in the
  8628. * display array
  8629. * @param {int} end Index for the current display ending point in the
  8630. * display array
  8631. * @param {array int} display Index array to translate the visual position
  8632. * to the full data array
  8633. *
  8634. * @dtopt Callbacks
  8635. * @name DataTable.defaults.footerCallback
  8636. *
  8637. * @example
  8638. * $(document).ready( function() {
  8639. * $('#example').dataTable( {
  8640. * "footerCallback": function( tfoot, data, start, end, display ) {
  8641. * tfoot.getElementsByTagName('th')[0].innerHTML = "Starting index is "+start;
  8642. * }
  8643. * } );
  8644. * } )
  8645. */
  8646. "fnFooterCallback": null,
  8647. /**
  8648. * When rendering large numbers in the information element for the table
  8649. * (i.e. "Showing 1 to 10 of 57 entries") DataTables will render large numbers
  8650. * to have a comma separator for the 'thousands' units (e.g. 1 million is
  8651. * rendered as "1,000,000") to help readability for the end user. This
  8652. * function will override the default method DataTables uses.
  8653. * @type function
  8654. * @member
  8655. * @param {int} toFormat number to be formatted
  8656. * @returns {string} formatted string for DataTables to show the number
  8657. *
  8658. * @dtopt Callbacks
  8659. * @name DataTable.defaults.formatNumber
  8660. *
  8661. * @example
  8662. * // Format a number using a single quote for the separator (note that
  8663. * // this can also be done with the language.thousands option)
  8664. * $(document).ready( function() {
  8665. * $('#example').dataTable( {
  8666. * "formatNumber": function ( toFormat ) {
  8667. * return toFormat.toString().replace(
  8668. * /\B(?=(\d{3})+(?!\d))/g, "'"
  8669. * );
  8670. * };
  8671. * } );
  8672. * } );
  8673. */
  8674. "fnFormatNumber": function(toFormat) {
  8675. return toFormat.toString().replace(
  8676. /\B(?=(\d{3})+(?!\d))/g,
  8677. this.oLanguage.sThousands
  8678. );
  8679. },
  8680. /**
  8681. * This function is called on every 'draw' event, and allows you to
  8682. * dynamically modify the header row. This can be used to calculate and
  8683. * display useful information about the table.
  8684. * @type function
  8685. * @param {node} head "TR" element for the header
  8686. * @param {array} data Full table data (as derived from the original HTML)
  8687. * @param {int} start Index for the current display starting point in the
  8688. * display array
  8689. * @param {int} end Index for the current display ending point in the
  8690. * display array
  8691. * @param {array int} display Index array to translate the visual position
  8692. * to the full data array
  8693. *
  8694. * @dtopt Callbacks
  8695. * @name DataTable.defaults.headerCallback
  8696. *
  8697. * @example
  8698. * $(document).ready( function() {
  8699. * $('#example').dataTable( {
  8700. * "fheaderCallback": function( head, data, start, end, display ) {
  8701. * head.getElementsByTagName('th')[0].innerHTML = "Displaying "+(end-start)+" records";
  8702. * }
  8703. * } );
  8704. * } )
  8705. */
  8706. "fnHeaderCallback": null,
  8707. /**
  8708. * The information element can be used to convey information about the current
  8709. * state of the table. Although the internationalisation options presented by
  8710. * DataTables are quite capable of dealing with most customisations, there may
  8711. * be times where you wish to customise the string further. This callback
  8712. * allows you to do exactly that.
  8713. * @type function
  8714. * @param {object} oSettings DataTables settings object
  8715. * @param {int} start Starting position in data for the draw
  8716. * @param {int} end End position in data for the draw
  8717. * @param {int} max Total number of rows in the table (regardless of
  8718. * filtering)
  8719. * @param {int} total Total number of rows in the data set, after filtering
  8720. * @param {string} pre The string that DataTables has formatted using it's
  8721. * own rules
  8722. * @returns {string} The string to be displayed in the information element.
  8723. *
  8724. * @dtopt Callbacks
  8725. * @name DataTable.defaults.infoCallback
  8726. *
  8727. * @example
  8728. * $('#example').dataTable( {
  8729. * "infoCallback": function( settings, start, end, max, total, pre ) {
  8730. * return start +" to "+ end;
  8731. * }
  8732. * } );
  8733. */
  8734. "fnInfoCallback": null,
  8735. /**
  8736. * Called when the table has been initialised. Normally DataTables will
  8737. * initialise sequentially and there will be no need for this function,
  8738. * however, this does not hold true when using external language information
  8739. * since that is obtained using an async XHR call.
  8740. * @type function
  8741. * @param {object} settings DataTables settings object
  8742. * @param {object} json The JSON object request from the server - only
  8743. * present if client-side Ajax sourced data is used
  8744. *
  8745. * @dtopt Callbacks
  8746. * @name DataTable.defaults.initComplete
  8747. *
  8748. * @example
  8749. * $(document).ready( function() {
  8750. * $('#example').dataTable( {
  8751. * "initComplete": function(settings, json) {
  8752. * alert( 'DataTables has finished its initialisation.' );
  8753. * }
  8754. * } );
  8755. * } )
  8756. */
  8757. "fnInitComplete": null,
  8758. /**
  8759. * Called at the very start of each table draw and can be used to cancel the
  8760. * draw by returning false, any other return (including undefined) results in
  8761. * the full draw occurring).
  8762. * @type function
  8763. * @param {object} settings DataTables settings object
  8764. * @returns {boolean} False will cancel the draw, anything else (including no
  8765. * return) will allow it to complete.
  8766. *
  8767. * @dtopt Callbacks
  8768. * @name DataTable.defaults.preDrawCallback
  8769. *
  8770. * @example
  8771. * $(document).ready( function() {
  8772. * $('#example').dataTable( {
  8773. * "preDrawCallback": function( settings ) {
  8774. * if ( $('#test').val() == 1 ) {
  8775. * return false;
  8776. * }
  8777. * }
  8778. * } );
  8779. * } );
  8780. */
  8781. "fnPreDrawCallback": null,
  8782. /**
  8783. * This function allows you to 'post process' each row after it have been
  8784. * generated for each table draw, but before it is rendered on screen. This
  8785. * function might be used for setting the row class name etc.
  8786. * @type function
  8787. * @param {node} row "TR" element for the current row
  8788. * @param {array} data Raw data array for this row
  8789. * @param {int} displayIndex The display index for the current table draw
  8790. * @param {int} displayIndexFull The index of the data in the full list of
  8791. * rows (after filtering)
  8792. *
  8793. * @dtopt Callbacks
  8794. * @name DataTable.defaults.rowCallback
  8795. *
  8796. * @example
  8797. * $(document).ready( function() {
  8798. * $('#example').dataTable( {
  8799. * "rowCallback": function( row, data, displayIndex, displayIndexFull ) {
  8800. * // Bold the grade for all 'A' grade browsers
  8801. * if ( data[4] == "A" ) {
  8802. * $('td:eq(4)', row).html( '<b>A</b>' );
  8803. * }
  8804. * }
  8805. * } );
  8806. * } );
  8807. */
  8808. "fnRowCallback": null,
  8809. /**
  8810. * __Deprecated__ The functionality provided by this parameter has now been
  8811. * superseded by that provided through `ajax`, which should be used instead.
  8812. *
  8813. * This parameter allows you to override the default function which obtains
  8814. * the data from the server so something more suitable for your application.
  8815. * For example you could use POST data, or pull information from a Gears or
  8816. * AIR database.
  8817. * @type function
  8818. * @member
  8819. * @param {string} source HTTP source to obtain the data from (`ajax`)
  8820. * @param {array} data A key/value pair object containing the data to send
  8821. * to the server
  8822. * @param {function} callback to be called on completion of the data get
  8823. * process that will draw the data on the page.
  8824. * @param {object} settings DataTables settings object
  8825. *
  8826. * @dtopt Callbacks
  8827. * @dtopt Server-side
  8828. * @name DataTable.defaults.serverData
  8829. *
  8830. * @deprecated 1.10. Please use `ajax` for this functionality now.
  8831. */
  8832. "fnServerData": null,
  8833. /**
  8834. * __Deprecated__ The functionality provided by this parameter has now been
  8835. * superseded by that provided through `ajax`, which should be used instead.
  8836. *
  8837. * It is often useful to send extra data to the server when making an Ajax
  8838. * request - for example custom filtering information, and this callback
  8839. * function makes it trivial to send extra information to the server. The
  8840. * passed in parameter is the data set that has been constructed by
  8841. * DataTables, and you can add to this or modify it as you require.
  8842. * @type function
  8843. * @param {array} data Data array (array of objects which are name/value
  8844. * pairs) that has been constructed by DataTables and will be sent to the
  8845. * server. In the case of Ajax sourced data with server-side processing
  8846. * this will be an empty array, for server-side processing there will be a
  8847. * significant number of parameters!
  8848. * @returns {undefined} Ensure that you modify the data array passed in,
  8849. * as this is passed by reference.
  8850. *
  8851. * @dtopt Callbacks
  8852. * @dtopt Server-side
  8853. * @name DataTable.defaults.serverParams
  8854. *
  8855. * @deprecated 1.10. Please use `ajax` for this functionality now.
  8856. */
  8857. "fnServerParams": null,
  8858. /**
  8859. * Load the table state. With this function you can define from where, and how, the
  8860. * state of a table is loaded. By default DataTables will load from `localStorage`
  8861. * but you might wish to use a server-side database or cookies.
  8862. * @type function
  8863. * @member
  8864. * @param {object} settings DataTables settings object
  8865. * @return {object} The DataTables state object to be loaded
  8866. *
  8867. * @dtopt Callbacks
  8868. * @name DataTable.defaults.stateLoadCallback
  8869. *
  8870. * @example
  8871. * $(document).ready( function() {
  8872. * $('#example').dataTable( {
  8873. * "stateSave": true,
  8874. * "stateLoadCallback": function (settings) {
  8875. * var o;
  8876. *
  8877. * // Send an Ajax request to the server to get the data. Note that
  8878. * // this is a synchronous request.
  8879. * $.ajax( {
  8880. * "url": "/state_load",
  8881. * "async": false,
  8882. * "dataType": "json",
  8883. * "success": function (json) {
  8884. * o = json;
  8885. * }
  8886. * } );
  8887. *
  8888. * return o;
  8889. * }
  8890. * } );
  8891. * } );
  8892. */
  8893. "fnStateLoadCallback": function(settings) {
  8894. try {
  8895. return JSON.parse(
  8896. (settings.iStateDuration === -1 ? sessionStorage : localStorage).getItem(
  8897. 'DataTables_' + settings.sInstance + '_' + location.pathname
  8898. )
  8899. );
  8900. } catch (e) {}
  8901. },
  8902. /**
  8903. * Callback which allows modification of the saved state prior to loading that state.
  8904. * This callback is called when the table is loading state from the stored data, but
  8905. * prior to the settings object being modified by the saved state. Note that for
  8906. * plug-in authors, you should use the `stateLoadParams` event to load parameters for
  8907. * a plug-in.
  8908. * @type function
  8909. * @param {object} settings DataTables settings object
  8910. * @param {object} data The state object that is to be loaded
  8911. *
  8912. * @dtopt Callbacks
  8913. * @name DataTable.defaults.stateLoadParams
  8914. *
  8915. * @example
  8916. * // Remove a saved filter, so filtering is never loaded
  8917. * $(document).ready( function() {
  8918. * $('#example').dataTable( {
  8919. * "stateSave": true,
  8920. * "stateLoadParams": function (settings, data) {
  8921. * data.oSearch.sSearch = "";
  8922. * }
  8923. * } );
  8924. * } );
  8925. *
  8926. * @example
  8927. * // Disallow state loading by returning false
  8928. * $(document).ready( function() {
  8929. * $('#example').dataTable( {
  8930. * "stateSave": true,
  8931. * "stateLoadParams": function (settings, data) {
  8932. * return false;
  8933. * }
  8934. * } );
  8935. * } );
  8936. */
  8937. "fnStateLoadParams": null,
  8938. /**
  8939. * Callback that is called when the state has been loaded from the state saving method
  8940. * and the DataTables settings object has been modified as a result of the loaded state.
  8941. * @type function
  8942. * @param {object} settings DataTables settings object
  8943. * @param {object} data The state object that was loaded
  8944. *
  8945. * @dtopt Callbacks
  8946. * @name DataTable.defaults.stateLoaded
  8947. *
  8948. * @example
  8949. * // Show an alert with the filtering value that was saved
  8950. * $(document).ready( function() {
  8951. * $('#example').dataTable( {
  8952. * "stateSave": true,
  8953. * "stateLoaded": function (settings, data) {
  8954. * alert( 'Saved filter was: '+data.oSearch.sSearch );
  8955. * }
  8956. * } );
  8957. * } );
  8958. */
  8959. "fnStateLoaded": null,
  8960. /**
  8961. * Save the table state. This function allows you to define where and how the state
  8962. * information for the table is stored By default DataTables will use `localStorage`
  8963. * but you might wish to use a server-side database or cookies.
  8964. * @type function
  8965. * @member
  8966. * @param {object} settings DataTables settings object
  8967. * @param {object} data The state object to be saved
  8968. *
  8969. * @dtopt Callbacks
  8970. * @name DataTable.defaults.stateSaveCallback
  8971. *
  8972. * @example
  8973. * $(document).ready( function() {
  8974. * $('#example').dataTable( {
  8975. * "stateSave": true,
  8976. * "stateSaveCallback": function (settings, data) {
  8977. * // Send an Ajax request to the server with the state object
  8978. * $.ajax( {
  8979. * "url": "/state_save",
  8980. * "data": data,
  8981. * "dataType": "json",
  8982. * "method": "POST"
  8983. * "success": function () {}
  8984. * } );
  8985. * }
  8986. * } );
  8987. * } );
  8988. */
  8989. "fnStateSaveCallback": function(settings, data) {
  8990. try {
  8991. (settings.iStateDuration === -1 ? sessionStorage : localStorage).setItem(
  8992. 'DataTables_' + settings.sInstance + '_' + location.pathname,
  8993. JSON.stringify(data)
  8994. );
  8995. } catch (e) {}
  8996. },
  8997. /**
  8998. * Callback which allows modification of the state to be saved. Called when the table
  8999. * has changed state a new state save is required. This method allows modification of
  9000. * the state saving object prior to actually doing the save, including addition or
  9001. * other state properties or modification. Note that for plug-in authors, you should
  9002. * use the `stateSaveParams` event to save parameters for a plug-in.
  9003. * @type function
  9004. * @param {object} settings DataTables settings object
  9005. * @param {object} data The state object to be saved
  9006. *
  9007. * @dtopt Callbacks
  9008. * @name DataTable.defaults.stateSaveParams
  9009. *
  9010. * @example
  9011. * // Remove a saved filter, so filtering is never saved
  9012. * $(document).ready( function() {
  9013. * $('#example').dataTable( {
  9014. * "stateSave": true,
  9015. * "stateSaveParams": function (settings, data) {
  9016. * data.oSearch.sSearch = "";
  9017. * }
  9018. * } );
  9019. * } );
  9020. */
  9021. "fnStateSaveParams": null,
  9022. /**
  9023. * Duration for which the saved state information is considered valid. After this period
  9024. * has elapsed the state will be returned to the default.
  9025. * Value is given in seconds.
  9026. * @type int
  9027. * @default 7200 <i>(2 hours)</i>
  9028. *
  9029. * @dtopt Options
  9030. * @name DataTable.defaults.stateDuration
  9031. *
  9032. * @example
  9033. * $(document).ready( function() {
  9034. * $('#example').dataTable( {
  9035. * "stateDuration": 60*60*24; // 1 day
  9036. * } );
  9037. * } )
  9038. */
  9039. "iStateDuration": 7200,
  9040. /**
  9041. * When enabled DataTables will not make a request to the server for the first
  9042. * page draw - rather it will use the data already on the page (no sorting etc
  9043. * will be applied to it), thus saving on an XHR at load time. `deferLoading`
  9044. * is used to indicate that deferred loading is required, but it is also used
  9045. * to tell DataTables how many records there are in the full table (allowing
  9046. * the information element and pagination to be displayed correctly). In the case
  9047. * where a filtering is applied to the table on initial load, this can be
  9048. * indicated by giving the parameter as an array, where the first element is
  9049. * the number of records available after filtering and the second element is the
  9050. * number of records without filtering (allowing the table information element
  9051. * to be shown correctly).
  9052. * @type int | array
  9053. * @default null
  9054. *
  9055. * @dtopt Options
  9056. * @name DataTable.defaults.deferLoading
  9057. *
  9058. * @example
  9059. * // 57 records available in the table, no filtering applied
  9060. * $(document).ready( function() {
  9061. * $('#example').dataTable( {
  9062. * "serverSide": true,
  9063. * "ajax": "scripts/server_processing.php",
  9064. * "deferLoading": 57
  9065. * } );
  9066. * } );
  9067. *
  9068. * @example
  9069. * // 57 records after filtering, 100 without filtering (an initial filter applied)
  9070. * $(document).ready( function() {
  9071. * $('#example').dataTable( {
  9072. * "serverSide": true,
  9073. * "ajax": "scripts/server_processing.php",
  9074. * "deferLoading": [ 57, 100 ],
  9075. * "search": {
  9076. * "search": "my_filter"
  9077. * }
  9078. * } );
  9079. * } );
  9080. */
  9081. "iDeferLoading": null,
  9082. /**
  9083. * Number of rows to display on a single page when using pagination. If
  9084. * feature enabled (`lengthChange`) then the end user will be able to override
  9085. * this to a custom setting using a pop-up menu.
  9086. * @type int
  9087. * @default 10
  9088. *
  9089. * @dtopt Options
  9090. * @name DataTable.defaults.pageLength
  9091. *
  9092. * @example
  9093. * $(document).ready( function() {
  9094. * $('#example').dataTable( {
  9095. * "pageLength": 50
  9096. * } );
  9097. * } )
  9098. */
  9099. "iDisplayLength": 10,
  9100. /**
  9101. * Define the starting point for data display when using DataTables with
  9102. * pagination. Note that this parameter is the number of records, rather than
  9103. * the page number, so if you have 10 records per page and want to start on
  9104. * the third page, it should be "20".
  9105. * @type int
  9106. * @default 0
  9107. *
  9108. * @dtopt Options
  9109. * @name DataTable.defaults.displayStart
  9110. *
  9111. * @example
  9112. * $(document).ready( function() {
  9113. * $('#example').dataTable( {
  9114. * "displayStart": 20
  9115. * } );
  9116. * } )
  9117. */
  9118. "iDisplayStart": 0,
  9119. /**
  9120. * By default DataTables allows keyboard navigation of the table (sorting, paging,
  9121. * and filtering) by adding a `tabindex` attribute to the required elements. This
  9122. * allows you to tab through the controls and press the enter key to activate them.
  9123. * The tabindex is default 0, meaning that the tab follows the flow of the document.
  9124. * You can overrule this using this parameter if you wish. Use a value of -1 to
  9125. * disable built-in keyboard navigation.
  9126. * @type int
  9127. * @default 0
  9128. *
  9129. * @dtopt Options
  9130. * @name DataTable.defaults.tabIndex
  9131. *
  9132. * @example
  9133. * $(document).ready( function() {
  9134. * $('#example').dataTable( {
  9135. * "tabIndex": 1
  9136. * } );
  9137. * } );
  9138. */
  9139. "iTabIndex": 0,
  9140. /**
  9141. * Classes that DataTables assigns to the various components and features
  9142. * that it adds to the HTML table. This allows classes to be configured
  9143. * during initialisation in addition to through the static
  9144. * {@link DataTable.ext.oStdClasses} object).
  9145. * @namespace
  9146. * @name DataTable.defaults.classes
  9147. */
  9148. "oClasses": {},
  9149. /**
  9150. * All strings that DataTables uses in the user interface that it creates
  9151. * are defined in this object, allowing you to modified them individually or
  9152. * completely replace them all as required.
  9153. * @namespace
  9154. * @name DataTable.defaults.language
  9155. */
  9156. "oLanguage": {
  9157. /**
  9158. * Strings that are used for WAI-ARIA labels and controls only (these are not
  9159. * actually visible on the page, but will be read by screenreaders, and thus
  9160. * must be internationalised as well).
  9161. * @namespace
  9162. * @name DataTable.defaults.language.aria
  9163. */
  9164. "oAria": {
  9165. /**
  9166. * ARIA label that is added to the table headers when the column may be
  9167. * sorted ascending by activing the column (click or return when focused).
  9168. * Note that the column header is prefixed to this string.
  9169. * @type string
  9170. * @default : activate to sort column ascending
  9171. *
  9172. * @dtopt Language
  9173. * @name DataTable.defaults.language.aria.sortAscending
  9174. *
  9175. * @example
  9176. * $(document).ready( function() {
  9177. * $('#example').dataTable( {
  9178. * "language": {
  9179. * "aria": {
  9180. * "sortAscending": " - click/return to sort ascending"
  9181. * }
  9182. * }
  9183. * } );
  9184. * } );
  9185. */
  9186. "sSortAscending": ": activate to sort column ascending",
  9187. /**
  9188. * ARIA label that is added to the table headers when the column may be
  9189. * sorted descending by activing the column (click or return when focused).
  9190. * Note that the column header is prefixed to this string.
  9191. * @type string
  9192. * @default : activate to sort column ascending
  9193. *
  9194. * @dtopt Language
  9195. * @name DataTable.defaults.language.aria.sortDescending
  9196. *
  9197. * @example
  9198. * $(document).ready( function() {
  9199. * $('#example').dataTable( {
  9200. * "language": {
  9201. * "aria": {
  9202. * "sortDescending": " - click/return to sort descending"
  9203. * }
  9204. * }
  9205. * } );
  9206. * } );
  9207. */
  9208. "sSortDescending": ": activate to sort column descending"
  9209. },
  9210. /**
  9211. * Pagination string used by DataTables for the built-in pagination
  9212. * control types.
  9213. * @namespace
  9214. * @name DataTable.defaults.language.paginate
  9215. */
  9216. "oPaginate": {
  9217. /**
  9218. * Text to use when using the 'full_numbers' type of pagination for the
  9219. * button to take the user to the first page.
  9220. * @type string
  9221. * @default First
  9222. *
  9223. * @dtopt Language
  9224. * @name DataTable.defaults.language.paginate.first
  9225. *
  9226. * @example
  9227. * $(document).ready( function() {
  9228. * $('#example').dataTable( {
  9229. * "language": {
  9230. * "paginate": {
  9231. * "first": "First page"
  9232. * }
  9233. * }
  9234. * } );
  9235. * } );
  9236. */
  9237. "sFirst": "First",
  9238. /**
  9239. * Text to use when using the 'full_numbers' type of pagination for the
  9240. * button to take the user to the last page.
  9241. * @type string
  9242. * @default Last
  9243. *
  9244. * @dtopt Language
  9245. * @name DataTable.defaults.language.paginate.last
  9246. *
  9247. * @example
  9248. * $(document).ready( function() {
  9249. * $('#example').dataTable( {
  9250. * "language": {
  9251. * "paginate": {
  9252. * "last": "Last page"
  9253. * }
  9254. * }
  9255. * } );
  9256. * } );
  9257. */
  9258. "sLast": "Last",
  9259. /**
  9260. * Text to use for the 'next' pagination button (to take the user to the
  9261. * next page).
  9262. * @type string
  9263. * @default Next
  9264. *
  9265. * @dtopt Language
  9266. * @name DataTable.defaults.language.paginate.next
  9267. *
  9268. * @example
  9269. * $(document).ready( function() {
  9270. * $('#example').dataTable( {
  9271. * "language": {
  9272. * "paginate": {
  9273. * "next": "Next page"
  9274. * }
  9275. * }
  9276. * } );
  9277. * } );
  9278. */
  9279. "sNext": "Next",
  9280. /**
  9281. * Text to use for the 'previous' pagination button (to take the user to
  9282. * the previous page).
  9283. * @type string
  9284. * @default Previous
  9285. *
  9286. * @dtopt Language
  9287. * @name DataTable.defaults.language.paginate.previous
  9288. *
  9289. * @example
  9290. * $(document).ready( function() {
  9291. * $('#example').dataTable( {
  9292. * "language": {
  9293. * "paginate": {
  9294. * "previous": "Previous page"
  9295. * }
  9296. * }
  9297. * } );
  9298. * } );
  9299. */
  9300. "sPrevious": "Previous"
  9301. },
  9302. /**
  9303. * This string is shown in preference to `zeroRecords` when the table is
  9304. * empty of data (regardless of filtering). Note that this is an optional
  9305. * parameter - if it is not given, the value of `zeroRecords` will be used
  9306. * instead (either the default or given value).
  9307. * @type string
  9308. * @default No data available in table
  9309. *
  9310. * @dtopt Language
  9311. * @name DataTable.defaults.language.emptyTable
  9312. *
  9313. * @example
  9314. * $(document).ready( function() {
  9315. * $('#example').dataTable( {
  9316. * "language": {
  9317. * "emptyTable": "No data available in table"
  9318. * }
  9319. * } );
  9320. * } );
  9321. */
  9322. "sEmptyTable": "No data available in table",
  9323. /**
  9324. * This string gives information to the end user about the information
  9325. * that is current on display on the page. The following tokens can be
  9326. * used in the string and will be dynamically replaced as the table
  9327. * display updates. This tokens can be placed anywhere in the string, or
  9328. * removed as needed by the language requires:
  9329. *
  9330. * * `\_START\_` - Display index of the first record on the current page
  9331. * * `\_END\_` - Display index of the last record on the current page
  9332. * * `\_TOTAL\_` - Number of records in the table after filtering
  9333. * * `\_MAX\_` - Number of records in the table without filtering
  9334. * * `\_PAGE\_` - Current page number
  9335. * * `\_PAGES\_` - Total number of pages of data in the table
  9336. *
  9337. * @type string
  9338. * @default Showing _START_ to _END_ of _TOTAL_ entries
  9339. *
  9340. * @dtopt Language
  9341. * @name DataTable.defaults.language.info
  9342. *
  9343. * @example
  9344. * $(document).ready( function() {
  9345. * $('#example').dataTable( {
  9346. * "language": {
  9347. * "info": "Showing page _PAGE_ of _PAGES_"
  9348. * }
  9349. * } );
  9350. * } );
  9351. */
  9352. "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
  9353. /**
  9354. * Display information string for when the table is empty. Typically the
  9355. * format of this string should match `info`.
  9356. * @type string
  9357. * @default Showing 0 to 0 of 0 entries
  9358. *
  9359. * @dtopt Language
  9360. * @name DataTable.defaults.language.infoEmpty
  9361. *
  9362. * @example
  9363. * $(document).ready( function() {
  9364. * $('#example').dataTable( {
  9365. * "language": {
  9366. * "infoEmpty": "No entries to show"
  9367. * }
  9368. * } );
  9369. * } );
  9370. */
  9371. "sInfoEmpty": "Showing 0 to 0 of 0 entries",
  9372. /**
  9373. * When a user filters the information in a table, this string is appended
  9374. * to the information (`info`) to give an idea of how strong the filtering
  9375. * is. The variable _MAX_ is dynamically updated.
  9376. * @type string
  9377. * @default (filtered from _MAX_ total entries)
  9378. *
  9379. * @dtopt Language
  9380. * @name DataTable.defaults.language.infoFiltered
  9381. *
  9382. * @example
  9383. * $(document).ready( function() {
  9384. * $('#example').dataTable( {
  9385. * "language": {
  9386. * "infoFiltered": " - filtering from _MAX_ records"
  9387. * }
  9388. * } );
  9389. * } );
  9390. */
  9391. "sInfoFiltered": "(filtered from _MAX_ total entries)",
  9392. /**
  9393. * If can be useful to append extra information to the info string at times,
  9394. * and this variable does exactly that. This information will be appended to
  9395. * the `info` (`infoEmpty` and `infoFiltered` in whatever combination they are
  9396. * being used) at all times.
  9397. * @type string
  9398. * @default <i>Empty string</i>
  9399. *
  9400. * @dtopt Language
  9401. * @name DataTable.defaults.language.infoPostFix
  9402. *
  9403. * @example
  9404. * $(document).ready( function() {
  9405. * $('#example').dataTable( {
  9406. * "language": {
  9407. * "infoPostFix": "All records shown are derived from real information."
  9408. * }
  9409. * } );
  9410. * } );
  9411. */
  9412. "sInfoPostFix": "",
  9413. /**
  9414. * This decimal place operator is a little different from the other
  9415. * language options since DataTables doesn't output floating point
  9416. * numbers, so it won't ever use this for display of a number. Rather,
  9417. * what this parameter does is modify the sort methods of the table so
  9418. * that numbers which are in a format which has a character other than
  9419. * a period (`.`) as a decimal place will be sorted numerically.
  9420. *
  9421. * Note that numbers with different decimal places cannot be shown in
  9422. * the same table and still be sortable, the table must be consistent.
  9423. * However, multiple different tables on the page can use different
  9424. * decimal place characters.
  9425. * @type string
  9426. * @default
  9427. *
  9428. * @dtopt Language
  9429. * @name DataTable.defaults.language.decimal
  9430. *
  9431. * @example
  9432. * $(document).ready( function() {
  9433. * $('#example').dataTable( {
  9434. * "language": {
  9435. * "decimal": ","
  9436. * "thousands": "."
  9437. * }
  9438. * } );
  9439. * } );
  9440. */
  9441. "sDecimal": "",
  9442. /**
  9443. * DataTables has a build in number formatter (`formatNumber`) which is
  9444. * used to format large numbers that are used in the table information.
  9445. * By default a comma is used, but this can be trivially changed to any
  9446. * character you wish with this parameter.
  9447. * @type string
  9448. * @default ,
  9449. *
  9450. * @dtopt Language
  9451. * @name DataTable.defaults.language.thousands
  9452. *
  9453. * @example
  9454. * $(document).ready( function() {
  9455. * $('#example').dataTable( {
  9456. * "language": {
  9457. * "thousands": "'"
  9458. * }
  9459. * } );
  9460. * } );
  9461. */
  9462. "sThousands": ",",
  9463. /**
  9464. * Detail the action that will be taken when the drop down menu for the
  9465. * pagination length option is changed. The '_MENU_' variable is replaced
  9466. * with a default select list of 10, 25, 50 and 100, and can be replaced
  9467. * with a custom select box if required.
  9468. * @type string
  9469. * @default Show _MENU_ entries
  9470. *
  9471. * @dtopt Language
  9472. * @name DataTable.defaults.language.lengthMenu
  9473. *
  9474. * @example
  9475. * // Language change only
  9476. * $(document).ready( function() {
  9477. * $('#example').dataTable( {
  9478. * "language": {
  9479. * "lengthMenu": "Display _MENU_ records"
  9480. * }
  9481. * } );
  9482. * } );
  9483. *
  9484. * @example
  9485. * // Language and options change
  9486. * $(document).ready( function() {
  9487. * $('#example').dataTable( {
  9488. * "language": {
  9489. * "lengthMenu": 'Display <select>'+
  9490. * '<option value="10">10</option>'+
  9491. * '<option value="20">20</option>'+
  9492. * '<option value="30">30</option>'+
  9493. * '<option value="40">40</option>'+
  9494. * '<option value="50">50</option>'+
  9495. * '<option value="-1">All</option>'+
  9496. * '</select> records'
  9497. * }
  9498. * } );
  9499. * } );
  9500. */
  9501. "sLengthMenu": "Show _MENU_ entries",
  9502. /**
  9503. * When using Ajax sourced data and during the first draw when DataTables is
  9504. * gathering the data, this message is shown in an empty row in the table to
  9505. * indicate to the end user the the data is being loaded. Note that this
  9506. * parameter is not used when loading data by server-side processing, just
  9507. * Ajax sourced data with client-side processing.
  9508. * @type string
  9509. * @default Loading...
  9510. *
  9511. * @dtopt Language
  9512. * @name DataTable.defaults.language.loadingRecords
  9513. *
  9514. * @example
  9515. * $(document).ready( function() {
  9516. * $('#example').dataTable( {
  9517. * "language": {
  9518. * "loadingRecords": "Please wait - loading..."
  9519. * }
  9520. * } );
  9521. * } );
  9522. */
  9523. "sLoadingRecords": "Loading...",
  9524. /**
  9525. * Text which is displayed when the table is processing a user action
  9526. * (usually a sort command or similar).
  9527. * @type string
  9528. * @default Processing...
  9529. *
  9530. * @dtopt Language
  9531. * @name DataTable.defaults.language.processing
  9532. *
  9533. * @example
  9534. * $(document).ready( function() {
  9535. * $('#example').dataTable( {
  9536. * "language": {
  9537. * "processing": "DataTables is currently busy"
  9538. * }
  9539. * } );
  9540. * } );
  9541. */
  9542. "sProcessing": "Processing...",
  9543. /**
  9544. * Details the actions that will be taken when the user types into the
  9545. * filtering input text box. The variable "_INPUT_", if used in the string,
  9546. * is replaced with the HTML text box for the filtering input allowing
  9547. * control over where it appears in the string. If "_INPUT_" is not given
  9548. * then the input box is appended to the string automatically.
  9549. * @type string
  9550. * @default Search:
  9551. *
  9552. * @dtopt Language
  9553. * @name DataTable.defaults.language.search
  9554. *
  9555. * @example
  9556. * // Input text box will be appended at the end automatically
  9557. * $(document).ready( function() {
  9558. * $('#example').dataTable( {
  9559. * "language": {
  9560. * "search": "Filter records:"
  9561. * }
  9562. * } );
  9563. * } );
  9564. *
  9565. * @example
  9566. * // Specify where the filter should appear
  9567. * $(document).ready( function() {
  9568. * $('#example').dataTable( {
  9569. * "language": {
  9570. * "search": "Apply filter _INPUT_ to table"
  9571. * }
  9572. * } );
  9573. * } );
  9574. */
  9575. "sSearch": "Search:",
  9576. /**
  9577. * Assign a `placeholder` attribute to the search `input` element
  9578. * @type string
  9579. * @default
  9580. *
  9581. * @dtopt Language
  9582. * @name DataTable.defaults.language.searchPlaceholder
  9583. */
  9584. "sSearchPlaceholder": "",
  9585. /**
  9586. * All of the language information can be stored in a file on the
  9587. * server-side, which DataTables will look up if this parameter is passed.
  9588. * It must store the URL of the language file, which is in a JSON format,
  9589. * and the object has the same properties as the oLanguage object in the
  9590. * initialiser object (i.e. the above parameters). Please refer to one of
  9591. * the example language files to see how this works in action.
  9592. * @type string
  9593. * @default <i>Empty string - i.e. disabled</i>
  9594. *
  9595. * @dtopt Language
  9596. * @name DataTable.defaults.language.url
  9597. *
  9598. * @example
  9599. * $(document).ready( function() {
  9600. * $('#example').dataTable( {
  9601. * "language": {
  9602. * "url": "http://www.sprymedia.co.uk/dataTables/lang.txt"
  9603. * }
  9604. * } );
  9605. * } );
  9606. */
  9607. "sUrl": "",
  9608. /**
  9609. * Text shown inside the table records when the is no information to be
  9610. * displayed after filtering. `emptyTable` is shown when there is simply no
  9611. * information in the table at all (regardless of filtering).
  9612. * @type string
  9613. * @default No matching records found
  9614. *
  9615. * @dtopt Language
  9616. * @name DataTable.defaults.language.zeroRecords
  9617. *
  9618. * @example
  9619. * $(document).ready( function() {
  9620. * $('#example').dataTable( {
  9621. * "language": {
  9622. * "zeroRecords": "No records to display"
  9623. * }
  9624. * } );
  9625. * } );
  9626. */
  9627. "sZeroRecords": "No matching records found"
  9628. },
  9629. /**
  9630. * This parameter allows you to have define the global filtering state at
  9631. * initialisation time. As an object the `search` parameter must be
  9632. * defined, but all other parameters are optional. When `regex` is true,
  9633. * the search string will be treated as a regular expression, when false
  9634. * (default) it will be treated as a straight string. When `smart`
  9635. * DataTables will use it's smart filtering methods (to word match at
  9636. * any point in the data), when false this will not be done.
  9637. * @namespace
  9638. * @extends DataTable.models.oSearch
  9639. *
  9640. * @dtopt Options
  9641. * @name DataTable.defaults.search
  9642. *
  9643. * @example
  9644. * $(document).ready( function() {
  9645. * $('#example').dataTable( {
  9646. * "search": {"search": "Initial search"}
  9647. * } );
  9648. * } )
  9649. */
  9650. "oSearch": $.extend({}, DataTable.models.oSearch),
  9651. /**
  9652. * __Deprecated__ The functionality provided by this parameter has now been
  9653. * superseded by that provided through `ajax`, which should be used instead.
  9654. *
  9655. * By default DataTables will look for the property `data` (or `aaData` for
  9656. * compatibility with DataTables 1.9-) when obtaining data from an Ajax
  9657. * source or for server-side processing - this parameter allows that
  9658. * property to be changed. You can use Javascript dotted object notation to
  9659. * get a data source for multiple levels of nesting.
  9660. * @type string
  9661. * @default data
  9662. *
  9663. * @dtopt Options
  9664. * @dtopt Server-side
  9665. * @name DataTable.defaults.ajaxDataProp
  9666. *
  9667. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9668. */
  9669. "sAjaxDataProp": "data",
  9670. /**
  9671. * __Deprecated__ The functionality provided by this parameter has now been
  9672. * superseded by that provided through `ajax`, which should be used instead.
  9673. *
  9674. * You can instruct DataTables to load data from an external
  9675. * source using this parameter (use aData if you want to pass data in you
  9676. * already have). Simply provide a url a JSON object can be obtained from.
  9677. * @type string
  9678. * @default null
  9679. *
  9680. * @dtopt Options
  9681. * @dtopt Server-side
  9682. * @name DataTable.defaults.ajaxSource
  9683. *
  9684. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9685. */
  9686. "sAjaxSource": null,
  9687. /**
  9688. * This initialisation variable allows you to specify exactly where in the
  9689. * DOM you want DataTables to inject the various controls it adds to the page
  9690. * (for example you might want the pagination controls at the top of the
  9691. * table). DIV elements (with or without a custom class) can also be added to
  9692. * aid styling. The follow syntax is used:
  9693. * <ul>
  9694. * <li>The following options are allowed:
  9695. * <ul>
  9696. * <li>'l' - Length changing</li>
  9697. * <li>'f' - Filtering input</li>
  9698. * <li>'t' - The table!</li>
  9699. * <li>'i' - Information</li>
  9700. * <li>'p' - Pagination</li>
  9701. * <li>'r' - pRocessing</li>
  9702. * </ul>
  9703. * </li>
  9704. * <li>The following constants are allowed:
  9705. * <ul>
  9706. * <li>'H' - jQueryUI theme "header" classes ('fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix')</li>
  9707. * <li>'F' - jQueryUI theme "footer" classes ('fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix')</li>
  9708. * </ul>
  9709. * </li>
  9710. * <li>The following syntax is expected:
  9711. * <ul>
  9712. * <li>'&lt;' and '&gt;' - div elements</li>
  9713. * <li>'&lt;"class" and '&gt;' - div with a class</li>
  9714. * <li>'&lt;"#id" and '&gt;' - div with an ID</li>
  9715. * </ul>
  9716. * </li>
  9717. * <li>Examples:
  9718. * <ul>
  9719. * <li>'&lt;"wrapper"flipt&gt;'</li>
  9720. * <li>'&lt;lf&lt;t&gt;ip&gt;'</li>
  9721. * </ul>
  9722. * </li>
  9723. * </ul>
  9724. * @type string
  9725. * @default lfrtip <i>(when `jQueryUI` is false)</i> <b>or</b>
  9726. * <"H"lfr>t<"F"ip> <i>(when `jQueryUI` is true)</i>
  9727. *
  9728. * @dtopt Options
  9729. * @name DataTable.defaults.dom
  9730. *
  9731. * @example
  9732. * $(document).ready( function() {
  9733. * $('#example').dataTable( {
  9734. * "dom": '&lt;"top"i&gt;rt&lt;"bottom"flp&gt;&lt;"clear"&gt;'
  9735. * } );
  9736. * } );
  9737. */
  9738. "sDom": "lfrtip",
  9739. /**
  9740. * Search delay option. This will throttle full table searches that use the
  9741. * DataTables provided search input element (it does not effect calls to
  9742. * `dt-api search()`, providing a delay before the search is made.
  9743. * @type integer
  9744. * @default 0
  9745. *
  9746. * @dtopt Options
  9747. * @name DataTable.defaults.searchDelay
  9748. *
  9749. * @example
  9750. * $(document).ready( function() {
  9751. * $('#example').dataTable( {
  9752. * "searchDelay": 200
  9753. * } );
  9754. * } )
  9755. */
  9756. "searchDelay": null,
  9757. /**
  9758. * DataTables features four different built-in options for the buttons to
  9759. * display for pagination control:
  9760. *
  9761. * * `simple` - 'Previous' and 'Next' buttons only
  9762. * * 'simple_numbers` - 'Previous' and 'Next' buttons, plus page numbers
  9763. * * `full` - 'First', 'Previous', 'Next' and 'Last' buttons
  9764. * * `full_numbers` - 'First', 'Previous', 'Next' and 'Last' buttons, plus
  9765. * page numbers
  9766. *
  9767. * Further methods can be added using {@link DataTable.ext.oPagination}.
  9768. * @type string
  9769. * @default simple_numbers
  9770. *
  9771. * @dtopt Options
  9772. * @name DataTable.defaults.pagingType
  9773. *
  9774. * @example
  9775. * $(document).ready( function() {
  9776. * $('#example').dataTable( {
  9777. * "pagingType": "full_numbers"
  9778. * } );
  9779. * } )
  9780. */
  9781. "sPaginationType": "simple_numbers",
  9782. /**
  9783. * Enable horizontal scrolling. When a table is too wide to fit into a
  9784. * certain layout, or you have a large number of columns in the table, you
  9785. * can enable x-scrolling to show the table in a viewport, which can be
  9786. * scrolled. This property can be `true` which will allow the table to
  9787. * scroll horizontally when needed, or any CSS unit, or a number (in which
  9788. * case it will be treated as a pixel measurement). Setting as simply `true`
  9789. * is recommended.
  9790. * @type boolean|string
  9791. * @default <i>blank string - i.e. disabled</i>
  9792. *
  9793. * @dtopt Features
  9794. * @name DataTable.defaults.scrollX
  9795. *
  9796. * @example
  9797. * $(document).ready( function() {
  9798. * $('#example').dataTable( {
  9799. * "scrollX": true,
  9800. * "scrollCollapse": true
  9801. * } );
  9802. * } );
  9803. */
  9804. "sScrollX": "",
  9805. /**
  9806. * This property can be used to force a DataTable to use more width than it
  9807. * might otherwise do when x-scrolling is enabled. For example if you have a
  9808. * table which requires to be well spaced, this parameter is useful for
  9809. * "over-sizing" the table, and thus forcing scrolling. This property can by
  9810. * any CSS unit, or a number (in which case it will be treated as a pixel
  9811. * measurement).
  9812. * @type string
  9813. * @default <i>blank string - i.e. disabled</i>
  9814. *
  9815. * @dtopt Options
  9816. * @name DataTable.defaults.scrollXInner
  9817. *
  9818. * @example
  9819. * $(document).ready( function() {
  9820. * $('#example').dataTable( {
  9821. * "scrollX": "100%",
  9822. * "scrollXInner": "110%"
  9823. * } );
  9824. * } );
  9825. */
  9826. "sScrollXInner": "",
  9827. /**
  9828. * Enable vertical scrolling. Vertical scrolling will constrain the DataTable
  9829. * to the given height, and enable scrolling for any data which overflows the
  9830. * current viewport. This can be used as an alternative to paging to display
  9831. * a lot of data in a small area (although paging and scrolling can both be
  9832. * enabled at the same time). This property can be any CSS unit, or a number
  9833. * (in which case it will be treated as a pixel measurement).
  9834. * @type string
  9835. * @default <i>blank string - i.e. disabled</i>
  9836. *
  9837. * @dtopt Features
  9838. * @name DataTable.defaults.scrollY
  9839. *
  9840. * @example
  9841. * $(document).ready( function() {
  9842. * $('#example').dataTable( {
  9843. * "scrollY": "200px",
  9844. * "paginate": false
  9845. * } );
  9846. * } );
  9847. */
  9848. "sScrollY": "",
  9849. /**
  9850. * __Deprecated__ The functionality provided by this parameter has now been
  9851. * superseded by that provided through `ajax`, which should be used instead.
  9852. *
  9853. * Set the HTTP method that is used to make the Ajax call for server-side
  9854. * processing or Ajax sourced data.
  9855. * @type string
  9856. * @default GET
  9857. *
  9858. * @dtopt Options
  9859. * @dtopt Server-side
  9860. * @name DataTable.defaults.serverMethod
  9861. *
  9862. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9863. */
  9864. "sServerMethod": "GET",
  9865. /**
  9866. * DataTables makes use of renderers when displaying HTML elements for
  9867. * a table. These renderers can be added or modified by plug-ins to
  9868. * generate suitable mark-up for a site. For example the Bootstrap
  9869. * integration plug-in for DataTables uses a paging button renderer to
  9870. * display pagination buttons in the mark-up required by Bootstrap.
  9871. *
  9872. * For further information about the renderers available see
  9873. * DataTable.ext.renderer
  9874. * @type string|object
  9875. * @default null
  9876. *
  9877. * @name DataTable.defaults.renderer
  9878. *
  9879. */
  9880. "renderer": null,
  9881. /**
  9882. * Set the data property name that DataTables should use to get a row's id
  9883. * to set as the `id` property in the node.
  9884. * @type string
  9885. * @default DT_RowId
  9886. *
  9887. * @name DataTable.defaults.rowId
  9888. */
  9889. "rowId": "DT_RowId"
  9890. };
  9891. _fnHungarianMap(DataTable.defaults);
  9892. /*
  9893. * Developer note - See note in model.defaults.js about the use of Hungarian
  9894. * notation and camel case.
  9895. */
  9896. /**
  9897. * Column options that can be given to DataTables at initialisation time.
  9898. * @namespace
  9899. */
  9900. DataTable.defaults.column = {
  9901. /**
  9902. * Define which column(s) an order will occur on for this column. This
  9903. * allows a column's ordering to take multiple columns into account when
  9904. * doing a sort or use the data from a different column. For example first
  9905. * name / last name columns make sense to do a multi-column sort over the
  9906. * two columns.
  9907. * @type array|int
  9908. * @default null <i>Takes the value of the column index automatically</i>
  9909. *
  9910. * @name DataTable.defaults.column.orderData
  9911. * @dtopt Columns
  9912. *
  9913. * @example
  9914. * // Using `columnDefs`
  9915. * $(document).ready( function() {
  9916. * $('#example').dataTable( {
  9917. * "columnDefs": [
  9918. * { "orderData": [ 0, 1 ], "targets": [ 0 ] },
  9919. * { "orderData": [ 1, 0 ], "targets": [ 1 ] },
  9920. * { "orderData": 2, "targets": [ 2 ] }
  9921. * ]
  9922. * } );
  9923. * } );
  9924. *
  9925. * @example
  9926. * // Using `columns`
  9927. * $(document).ready( function() {
  9928. * $('#example').dataTable( {
  9929. * "columns": [
  9930. * { "orderData": [ 0, 1 ] },
  9931. * { "orderData": [ 1, 0 ] },
  9932. * { "orderData": 2 },
  9933. * null,
  9934. * null
  9935. * ]
  9936. * } );
  9937. * } );
  9938. */
  9939. "aDataSort": null,
  9940. "iDataSort": -1,
  9941. /**
  9942. * You can control the default ordering direction, and even alter the
  9943. * behaviour of the sort handler (i.e. only allow ascending ordering etc)
  9944. * using this parameter.
  9945. * @type array
  9946. * @default [ 'asc', 'desc' ]
  9947. *
  9948. * @name DataTable.defaults.column.orderSequence
  9949. * @dtopt Columns
  9950. *
  9951. * @example
  9952. * // Using `columnDefs`
  9953. * $(document).ready( function() {
  9954. * $('#example').dataTable( {
  9955. * "columnDefs": [
  9956. * { "orderSequence": [ "asc" ], "targets": [ 1 ] },
  9957. * { "orderSequence": [ "desc", "asc", "asc" ], "targets": [ 2 ] },
  9958. * { "orderSequence": [ "desc" ], "targets": [ 3 ] }
  9959. * ]
  9960. * } );
  9961. * } );
  9962. *
  9963. * @example
  9964. * // Using `columns`
  9965. * $(document).ready( function() {
  9966. * $('#example').dataTable( {
  9967. * "columns": [
  9968. * null,
  9969. * { "orderSequence": [ "asc" ] },
  9970. * { "orderSequence": [ "desc", "asc", "asc" ] },
  9971. * { "orderSequence": [ "desc" ] },
  9972. * null
  9973. * ]
  9974. * } );
  9975. * } );
  9976. */
  9977. "asSorting": ['asc', 'desc'],
  9978. /**
  9979. * Enable or disable filtering on the data in this column.
  9980. * @type boolean
  9981. * @default true
  9982. *
  9983. * @name DataTable.defaults.column.searchable
  9984. * @dtopt Columns
  9985. *
  9986. * @example
  9987. * // Using `columnDefs`
  9988. * $(document).ready( function() {
  9989. * $('#example').dataTable( {
  9990. * "columnDefs": [
  9991. * { "searchable": false, "targets": [ 0 ] }
  9992. * ] } );
  9993. * } );
  9994. *
  9995. * @example
  9996. * // Using `columns`
  9997. * $(document).ready( function() {
  9998. * $('#example').dataTable( {
  9999. * "columns": [
  10000. * { "searchable": false },
  10001. * null,
  10002. * null,
  10003. * null,
  10004. * null
  10005. * ] } );
  10006. * } );
  10007. */
  10008. "bSearchable": true,
  10009. /**
  10010. * Enable or disable ordering on this column.
  10011. * @type boolean
  10012. * @default true
  10013. *
  10014. * @name DataTable.defaults.column.orderable
  10015. * @dtopt Columns
  10016. *
  10017. * @example
  10018. * // Using `columnDefs`
  10019. * $(document).ready( function() {
  10020. * $('#example').dataTable( {
  10021. * "columnDefs": [
  10022. * { "orderable": false, "targets": [ 0 ] }
  10023. * ] } );
  10024. * } );
  10025. *
  10026. * @example
  10027. * // Using `columns`
  10028. * $(document).ready( function() {
  10029. * $('#example').dataTable( {
  10030. * "columns": [
  10031. * { "orderable": false },
  10032. * null,
  10033. * null,
  10034. * null,
  10035. * null
  10036. * ] } );
  10037. * } );
  10038. */
  10039. "bSortable": true,
  10040. /**
  10041. * Enable or disable the display of this column.
  10042. * @type boolean
  10043. * @default true
  10044. *
  10045. * @name DataTable.defaults.column.visible
  10046. * @dtopt Columns
  10047. *
  10048. * @example
  10049. * // Using `columnDefs`
  10050. * $(document).ready( function() {
  10051. * $('#example').dataTable( {
  10052. * "columnDefs": [
  10053. * { "visible": false, "targets": [ 0 ] }
  10054. * ] } );
  10055. * } );
  10056. *
  10057. * @example
  10058. * // Using `columns`
  10059. * $(document).ready( function() {
  10060. * $('#example').dataTable( {
  10061. * "columns": [
  10062. * { "visible": false },
  10063. * null,
  10064. * null,
  10065. * null,
  10066. * null
  10067. * ] } );
  10068. * } );
  10069. */
  10070. "bVisible": true,
  10071. /**
  10072. * Developer definable function that is called whenever a cell is created (Ajax source,
  10073. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  10074. * allowing you to modify the DOM element (add background colour for example) when the
  10075. * element is available.
  10076. * @type function
  10077. * @param {element} td The TD node that has been created
  10078. * @param {*} cellData The Data for the cell
  10079. * @param {array|object} rowData The data for the whole row
  10080. * @param {int} row The row index for the aoData data store
  10081. * @param {int} col The column index for aoColumns
  10082. *
  10083. * @name DataTable.defaults.column.createdCell
  10084. * @dtopt Columns
  10085. *
  10086. * @example
  10087. * $(document).ready( function() {
  10088. * $('#example').dataTable( {
  10089. * "columnDefs": [ {
  10090. * "targets": [3],
  10091. * "createdCell": function (td, cellData, rowData, row, col) {
  10092. * if ( cellData == "1.7" ) {
  10093. * $(td).css('color', 'blue')
  10094. * }
  10095. * }
  10096. * } ]
  10097. * });
  10098. * } );
  10099. */
  10100. "fnCreatedCell": null,
  10101. /**
  10102. * This parameter has been replaced by `data` in DataTables to ensure naming
  10103. * consistency. `dataProp` can still be used, as there is backwards
  10104. * compatibility in DataTables for this option, but it is strongly
  10105. * recommended that you use `data` in preference to `dataProp`.
  10106. * @name DataTable.defaults.column.dataProp
  10107. */
  10108. /**
  10109. * This property can be used to read data from any data source property,
  10110. * including deeply nested objects / properties. `data` can be given in a
  10111. * number of different ways which effect its behaviour:
  10112. *
  10113. * * `integer` - treated as an array index for the data source. This is the
  10114. * default that DataTables uses (incrementally increased for each column).
  10115. * * `string` - read an object property from the data source. There are
  10116. * three 'special' options that can be used in the string to alter how
  10117. * DataTables reads the data from the source object:
  10118. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10119. * Javascript to read from nested objects, so to can the options
  10120. * specified in `data`. For example: `browser.version` or
  10121. * `browser.name`. If your object parameter name contains a period, use
  10122. * `\\` to escape it - i.e. `first\\.name`.
  10123. * * `[]` - Array notation. DataTables can automatically combine data
  10124. * from and array source, joining the data with the characters provided
  10125. * between the two brackets. For example: `name[, ]` would provide a
  10126. * comma-space separated list from the source array. If no characters
  10127. * are provided between the brackets, the original array source is
  10128. * returned.
  10129. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10130. * execute a function of the name given. For example: `browser()` for a
  10131. * simple function on the data source, `browser.version()` for a
  10132. * function in a nested property or even `browser().version` to get an
  10133. * object property if the function called returns an object. Note that
  10134. * function notation is recommended for use in `render` rather than
  10135. * `data` as it is much simpler to use as a renderer.
  10136. * * `null` - use the original data source for the row rather than plucking
  10137. * data directly from it. This action has effects on two other
  10138. * initialisation options:
  10139. * * `defaultContent` - When null is given as the `data` option and
  10140. * `defaultContent` is specified for the column, the value defined by
  10141. * `defaultContent` will be used for the cell.
  10142. * * `render` - When null is used for the `data` option and the `render`
  10143. * option is specified for the column, the whole data source for the
  10144. * row is used for the renderer.
  10145. * * `function` - the function given will be executed whenever DataTables
  10146. * needs to set or get the data for a cell in the column. The function
  10147. * takes three parameters:
  10148. * * Parameters:
  10149. * * `{array|object}` The data source for the row
  10150. * * `{string}` The type call data requested - this will be 'set' when
  10151. * setting data or 'filter', 'display', 'type', 'sort' or undefined
  10152. * when gathering data. Note that when `undefined` is given for the
  10153. * type DataTables expects to get the raw data for the object back<
  10154. * * `{*}` Data to set when the second parameter is 'set'.
  10155. * * Return:
  10156. * * The return value from the function is not required when 'set' is
  10157. * the type of call, but otherwise the return is what will be used
  10158. * for the data requested.
  10159. *
  10160. * Note that `data` is a getter and setter option. If you just require
  10161. * formatting of data for output, you will likely want to use `render` which
  10162. * is simply a getter and thus simpler to use.
  10163. *
  10164. * Note that prior to DataTables 1.9.2 `data` was called `mDataProp`. The
  10165. * name change reflects the flexibility of this property and is consistent
  10166. * with the naming of mRender. If 'mDataProp' is given, then it will still
  10167. * be used by DataTables, as it automatically maps the old name to the new
  10168. * if required.
  10169. *
  10170. * @type string|int|function|null
  10171. * @default null <i>Use automatically calculated column index</i>
  10172. *
  10173. * @name DataTable.defaults.column.data
  10174. * @dtopt Columns
  10175. *
  10176. * @example
  10177. * // Read table data from objects
  10178. * // JSON structure for each row:
  10179. * // {
  10180. * // "engine": {value},
  10181. * // "browser": {value},
  10182. * // "platform": {value},
  10183. * // "version": {value},
  10184. * // "grade": {value}
  10185. * // }
  10186. * $(document).ready( function() {
  10187. * $('#example').dataTable( {
  10188. * "ajaxSource": "sources/objects.txt",
  10189. * "columns": [
  10190. * { "data": "engine" },
  10191. * { "data": "browser" },
  10192. * { "data": "platform" },
  10193. * { "data": "version" },
  10194. * { "data": "grade" }
  10195. * ]
  10196. * } );
  10197. * } );
  10198. *
  10199. * @example
  10200. * // Read information from deeply nested objects
  10201. * // JSON structure for each row:
  10202. * // {
  10203. * // "engine": {value},
  10204. * // "browser": {value},
  10205. * // "platform": {
  10206. * // "inner": {value}
  10207. * // },
  10208. * // "details": [
  10209. * // {value}, {value}
  10210. * // ]
  10211. * // }
  10212. * $(document).ready( function() {
  10213. * $('#example').dataTable( {
  10214. * "ajaxSource": "sources/deep.txt",
  10215. * "columns": [
  10216. * { "data": "engine" },
  10217. * { "data": "browser" },
  10218. * { "data": "platform.inner" },
  10219. * { "data": "platform.details.0" },
  10220. * { "data": "platform.details.1" }
  10221. * ]
  10222. * } );
  10223. * } );
  10224. *
  10225. * @example
  10226. * // Using `data` as a function to provide different information for
  10227. * // sorting, filtering and display. In this case, currency (price)
  10228. * $(document).ready( function() {
  10229. * $('#example').dataTable( {
  10230. * "columnDefs": [ {
  10231. * "targets": [ 0 ],
  10232. * "data": function ( source, type, val ) {
  10233. * if (type === 'set') {
  10234. * source.price = val;
  10235. * // Store the computed dislay and filter values for efficiency
  10236. * source.price_display = val=="" ? "" : "$"+numberFormat(val);
  10237. * source.price_filter = val=="" ? "" : "$"+numberFormat(val)+" "+val;
  10238. * return;
  10239. * }
  10240. * else if (type === 'display') {
  10241. * return source.price_display;
  10242. * }
  10243. * else if (type === 'filter') {
  10244. * return source.price_filter;
  10245. * }
  10246. * // 'sort', 'type' and undefined all just use the integer
  10247. * return source.price;
  10248. * }
  10249. * } ]
  10250. * } );
  10251. * } );
  10252. *
  10253. * @example
  10254. * // Using default content
  10255. * $(document).ready( function() {
  10256. * $('#example').dataTable( {
  10257. * "columnDefs": [ {
  10258. * "targets": [ 0 ],
  10259. * "data": null,
  10260. * "defaultContent": "Click to edit"
  10261. * } ]
  10262. * } );
  10263. * } );
  10264. *
  10265. * @example
  10266. * // Using array notation - outputting a list from an array
  10267. * $(document).ready( function() {
  10268. * $('#example').dataTable( {
  10269. * "columnDefs": [ {
  10270. * "targets": [ 0 ],
  10271. * "data": "name[, ]"
  10272. * } ]
  10273. * } );
  10274. * } );
  10275. *
  10276. */
  10277. "mData": null,
  10278. /**
  10279. * This property is the rendering partner to `data` and it is suggested that
  10280. * when you want to manipulate data for display (including filtering,
  10281. * sorting etc) without altering the underlying data for the table, use this
  10282. * property. `render` can be considered to be the the read only companion to
  10283. * `data` which is read / write (then as such more complex). Like `data`
  10284. * this option can be given in a number of different ways to effect its
  10285. * behaviour:
  10286. *
  10287. * * `integer` - treated as an array index for the data source. This is the
  10288. * default that DataTables uses (incrementally increased for each column).
  10289. * * `string` - read an object property from the data source. There are
  10290. * three 'special' options that can be used in the string to alter how
  10291. * DataTables reads the data from the source object:
  10292. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10293. * Javascript to read from nested objects, so to can the options
  10294. * specified in `data`. For example: `browser.version` or
  10295. * `browser.name`. If your object parameter name contains a period, use
  10296. * `\\` to escape it - i.e. `first\\.name`.
  10297. * * `[]` - Array notation. DataTables can automatically combine data
  10298. * from and array source, joining the data with the characters provided
  10299. * between the two brackets. For example: `name[, ]` would provide a
  10300. * comma-space separated list from the source array. If no characters
  10301. * are provided between the brackets, the original array source is
  10302. * returned.
  10303. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10304. * execute a function of the name given. For example: `browser()` for a
  10305. * simple function on the data source, `browser.version()` for a
  10306. * function in a nested property or even `browser().version` to get an
  10307. * object property if the function called returns an object.
  10308. * * `object` - use different data for the different data types requested by
  10309. * DataTables ('filter', 'display', 'type' or 'sort'). The property names
  10310. * of the object is the data type the property refers to and the value can
  10311. * defined using an integer, string or function using the same rules as
  10312. * `render` normally does. Note that an `_` option _must_ be specified.
  10313. * This is the default value to use if you haven't specified a value for
  10314. * the data type requested by DataTables.
  10315. * * `function` - the function given will be executed whenever DataTables
  10316. * needs to set or get the data for a cell in the column. The function
  10317. * takes three parameters:
  10318. * * Parameters:
  10319. * * {array|object} The data source for the row (based on `data`)
  10320. * * {string} The type call data requested - this will be 'filter',
  10321. * 'display', 'type' or 'sort'.
  10322. * * {array|object} The full data source for the row (not based on
  10323. * `data`)
  10324. * * Return:
  10325. * * The return value from the function is what will be used for the
  10326. * data requested.
  10327. *
  10328. * @type string|int|function|object|null
  10329. * @default null Use the data source value.
  10330. *
  10331. * @name DataTable.defaults.column.render
  10332. * @dtopt Columns
  10333. *
  10334. * @example
  10335. * // Create a comma separated list from an array of objects
  10336. * $(document).ready( function() {
  10337. * $('#example').dataTable( {
  10338. * "ajaxSource": "sources/deep.txt",
  10339. * "columns": [
  10340. * { "data": "engine" },
  10341. * { "data": "browser" },
  10342. * {
  10343. * "data": "platform",
  10344. * "render": "[, ].name"
  10345. * }
  10346. * ]
  10347. * } );
  10348. * } );
  10349. *
  10350. * @example
  10351. * // Execute a function to obtain data
  10352. * $(document).ready( function() {
  10353. * $('#example').dataTable( {
  10354. * "columnDefs": [ {
  10355. * "targets": [ 0 ],
  10356. * "data": null, // Use the full data source object for the renderer's source
  10357. * "render": "browserName()"
  10358. * } ]
  10359. * } );
  10360. * } );
  10361. *
  10362. * @example
  10363. * // As an object, extracting different data for the different types
  10364. * // This would be used with a data source such as:
  10365. * // { "phone": 5552368, "phone_filter": "5552368 555-2368", "phone_display": "555-2368" }
  10366. * // Here the `phone` integer is used for sorting and type detection, while `phone_filter`
  10367. * // (which has both forms) is used for filtering for if a user inputs either format, while
  10368. * // the formatted phone number is the one that is shown in the table.
  10369. * $(document).ready( function() {
  10370. * $('#example').dataTable( {
  10371. * "columnDefs": [ {
  10372. * "targets": [ 0 ],
  10373. * "data": null, // Use the full data source object for the renderer's source
  10374. * "render": {
  10375. * "_": "phone",
  10376. * "filter": "phone_filter",
  10377. * "display": "phone_display"
  10378. * }
  10379. * } ]
  10380. * } );
  10381. * } );
  10382. *
  10383. * @example
  10384. * // Use as a function to create a link from the data source
  10385. * $(document).ready( function() {
  10386. * $('#example').dataTable( {
  10387. * "columnDefs": [ {
  10388. * "targets": [ 0 ],
  10389. * "data": "download_link",
  10390. * "render": function ( data, type, full ) {
  10391. * return '<a href="'+data+'">Download</a>';
  10392. * }
  10393. * } ]
  10394. * } );
  10395. * } );
  10396. */
  10397. "mRender": null,
  10398. /**
  10399. * Change the cell type created for the column - either TD cells or TH cells. This
  10400. * can be useful as TH cells have semantic meaning in the table body, allowing them
  10401. * to act as a header for a row (you may wish to add scope='row' to the TH elements).
  10402. * @type string
  10403. * @default td
  10404. *
  10405. * @name DataTable.defaults.column.cellType
  10406. * @dtopt Columns
  10407. *
  10408. * @example
  10409. * // Make the first column use TH cells
  10410. * $(document).ready( function() {
  10411. * $('#example').dataTable( {
  10412. * "columnDefs": [ {
  10413. * "targets": [ 0 ],
  10414. * "cellType": "th"
  10415. * } ]
  10416. * } );
  10417. * } );
  10418. */
  10419. "sCellType": "td",
  10420. /**
  10421. * Class to give to each cell in this column.
  10422. * @type string
  10423. * @default <i>Empty string</i>
  10424. *
  10425. * @name DataTable.defaults.column.class
  10426. * @dtopt Columns
  10427. *
  10428. * @example
  10429. * // Using `columnDefs`
  10430. * $(document).ready( function() {
  10431. * $('#example').dataTable( {
  10432. * "columnDefs": [
  10433. * { "class": "my_class", "targets": [ 0 ] }
  10434. * ]
  10435. * } );
  10436. * } );
  10437. *
  10438. * @example
  10439. * // Using `columns`
  10440. * $(document).ready( function() {
  10441. * $('#example').dataTable( {
  10442. * "columns": [
  10443. * { "class": "my_class" },
  10444. * null,
  10445. * null,
  10446. * null,
  10447. * null
  10448. * ]
  10449. * } );
  10450. * } );
  10451. */
  10452. "sClass": "",
  10453. /**
  10454. * When DataTables calculates the column widths to assign to each column,
  10455. * it finds the longest string in each column and then constructs a
  10456. * temporary table and reads the widths from that. The problem with this
  10457. * is that "mmm" is much wider then "iiii", but the latter is a longer
  10458. * string - thus the calculation can go wrong (doing it properly and putting
  10459. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  10460. * a "work around" we provide this option. It will append its value to the
  10461. * text that is found to be the longest string for the column - i.e. padding.
  10462. * Generally you shouldn't need this!
  10463. * @type string
  10464. * @default <i>Empty string<i>
  10465. *
  10466. * @name DataTable.defaults.column.contentPadding
  10467. * @dtopt Columns
  10468. *
  10469. * @example
  10470. * // Using `columns`
  10471. * $(document).ready( function() {
  10472. * $('#example').dataTable( {
  10473. * "columns": [
  10474. * null,
  10475. * null,
  10476. * null,
  10477. * {
  10478. * "contentPadding": "mmm"
  10479. * }
  10480. * ]
  10481. * } );
  10482. * } );
  10483. */
  10484. "sContentPadding": "",
  10485. /**
  10486. * Allows a default value to be given for a column's data, and will be used
  10487. * whenever a null data source is encountered (this can be because `data`
  10488. * is set to null, or because the data source itself is null).
  10489. * @type string
  10490. * @default null
  10491. *
  10492. * @name DataTable.defaults.column.defaultContent
  10493. * @dtopt Columns
  10494. *
  10495. * @example
  10496. * // Using `columnDefs`
  10497. * $(document).ready( function() {
  10498. * $('#example').dataTable( {
  10499. * "columnDefs": [
  10500. * {
  10501. * "data": null,
  10502. * "defaultContent": "Edit",
  10503. * "targets": [ -1 ]
  10504. * }
  10505. * ]
  10506. * } );
  10507. * } );
  10508. *
  10509. * @example
  10510. * // Using `columns`
  10511. * $(document).ready( function() {
  10512. * $('#example').dataTable( {
  10513. * "columns": [
  10514. * null,
  10515. * null,
  10516. * null,
  10517. * {
  10518. * "data": null,
  10519. * "defaultContent": "Edit"
  10520. * }
  10521. * ]
  10522. * } );
  10523. * } );
  10524. */
  10525. "sDefaultContent": null,
  10526. /**
  10527. * This parameter is only used in DataTables' server-side processing. It can
  10528. * be exceptionally useful to know what columns are being displayed on the
  10529. * client side, and to map these to database fields. When defined, the names
  10530. * also allow DataTables to reorder information from the server if it comes
  10531. * back in an unexpected order (i.e. if you switch your columns around on the
  10532. * client-side, your server-side code does not also need updating).
  10533. * @type string
  10534. * @default <i>Empty string</i>
  10535. *
  10536. * @name DataTable.defaults.column.name
  10537. * @dtopt Columns
  10538. *
  10539. * @example
  10540. * // Using `columnDefs`
  10541. * $(document).ready( function() {
  10542. * $('#example').dataTable( {
  10543. * "columnDefs": [
  10544. * { "name": "engine", "targets": [ 0 ] },
  10545. * { "name": "browser", "targets": [ 1 ] },
  10546. * { "name": "platform", "targets": [ 2 ] },
  10547. * { "name": "version", "targets": [ 3 ] },
  10548. * { "name": "grade", "targets": [ 4 ] }
  10549. * ]
  10550. * } );
  10551. * } );
  10552. *
  10553. * @example
  10554. * // Using `columns`
  10555. * $(document).ready( function() {
  10556. * $('#example').dataTable( {
  10557. * "columns": [
  10558. * { "name": "engine" },
  10559. * { "name": "browser" },
  10560. * { "name": "platform" },
  10561. * { "name": "version" },
  10562. * { "name": "grade" }
  10563. * ]
  10564. * } );
  10565. * } );
  10566. */
  10567. "sName": "",
  10568. /**
  10569. * Defines a data source type for the ordering which can be used to read
  10570. * real-time information from the table (updating the internally cached
  10571. * version) prior to ordering. This allows ordering to occur on user
  10572. * editable elements such as form inputs.
  10573. * @type string
  10574. * @default std
  10575. *
  10576. * @name DataTable.defaults.column.orderDataType
  10577. * @dtopt Columns
  10578. *
  10579. * @example
  10580. * // Using `columnDefs`
  10581. * $(document).ready( function() {
  10582. * $('#example').dataTable( {
  10583. * "columnDefs": [
  10584. * { "orderDataType": "dom-text", "targets": [ 2, 3 ] },
  10585. * { "type": "numeric", "targets": [ 3 ] },
  10586. * { "orderDataType": "dom-select", "targets": [ 4 ] },
  10587. * { "orderDataType": "dom-checkbox", "targets": [ 5 ] }
  10588. * ]
  10589. * } );
  10590. * } );
  10591. *
  10592. * @example
  10593. * // Using `columns`
  10594. * $(document).ready( function() {
  10595. * $('#example').dataTable( {
  10596. * "columns": [
  10597. * null,
  10598. * null,
  10599. * { "orderDataType": "dom-text" },
  10600. * { "orderDataType": "dom-text", "type": "numeric" },
  10601. * { "orderDataType": "dom-select" },
  10602. * { "orderDataType": "dom-checkbox" }
  10603. * ]
  10604. * } );
  10605. * } );
  10606. */
  10607. "sSortDataType": "std",
  10608. /**
  10609. * The title of this column.
  10610. * @type string
  10611. * @default null <i>Derived from the 'TH' value for this column in the
  10612. * original HTML table.</i>
  10613. *
  10614. * @name DataTable.defaults.column.title
  10615. * @dtopt Columns
  10616. *
  10617. * @example
  10618. * // Using `columnDefs`
  10619. * $(document).ready( function() {
  10620. * $('#example').dataTable( {
  10621. * "columnDefs": [
  10622. * { "title": "My column title", "targets": [ 0 ] }
  10623. * ]
  10624. * } );
  10625. * } );
  10626. *
  10627. * @example
  10628. * // Using `columns`
  10629. * $(document).ready( function() {
  10630. * $('#example').dataTable( {
  10631. * "columns": [
  10632. * { "title": "My column title" },
  10633. * null,
  10634. * null,
  10635. * null,
  10636. * null
  10637. * ]
  10638. * } );
  10639. * } );
  10640. */
  10641. "sTitle": null,
  10642. /**
  10643. * The type allows you to specify how the data for this column will be
  10644. * ordered. Four types (string, numeric, date and html (which will strip
  10645. * HTML tags before ordering)) are currently available. Note that only date
  10646. * formats understood by Javascript's Date() object will be accepted as type
  10647. * date. For example: "Mar 26, 2008 5:03 PM". May take the values: 'string',
  10648. * 'numeric', 'date' or 'html' (by default). Further types can be adding
  10649. * through plug-ins.
  10650. * @type string
  10651. * @default null <i>Auto-detected from raw data</i>
  10652. *
  10653. * @name DataTable.defaults.column.type
  10654. * @dtopt Columns
  10655. *
  10656. * @example
  10657. * // Using `columnDefs`
  10658. * $(document).ready( function() {
  10659. * $('#example').dataTable( {
  10660. * "columnDefs": [
  10661. * { "type": "html", "targets": [ 0 ] }
  10662. * ]
  10663. * } );
  10664. * } );
  10665. *
  10666. * @example
  10667. * // Using `columns`
  10668. * $(document).ready( function() {
  10669. * $('#example').dataTable( {
  10670. * "columns": [
  10671. * { "type": "html" },
  10672. * null,
  10673. * null,
  10674. * null,
  10675. * null
  10676. * ]
  10677. * } );
  10678. * } );
  10679. */
  10680. "sType": null,
  10681. /**
  10682. * Defining the width of the column, this parameter may take any CSS value
  10683. * (3em, 20px etc). DataTables applies 'smart' widths to columns which have not
  10684. * been given a specific width through this interface ensuring that the table
  10685. * remains readable.
  10686. * @type string
  10687. * @default null <i>Automatic</i>
  10688. *
  10689. * @name DataTable.defaults.column.width
  10690. * @dtopt Columns
  10691. *
  10692. * @example
  10693. * // Using `columnDefs`
  10694. * $(document).ready( function() {
  10695. * $('#example').dataTable( {
  10696. * "columnDefs": [
  10697. * { "width": "20%", "targets": [ 0 ] }
  10698. * ]
  10699. * } );
  10700. * } );
  10701. *
  10702. * @example
  10703. * // Using `columns`
  10704. * $(document).ready( function() {
  10705. * $('#example').dataTable( {
  10706. * "columns": [
  10707. * { "width": "20%" },
  10708. * null,
  10709. * null,
  10710. * null,
  10711. * null
  10712. * ]
  10713. * } );
  10714. * } );
  10715. */
  10716. "sWidth": null
  10717. };
  10718. _fnHungarianMap(DataTable.defaults.column);
  10719. /**
  10720. * DataTables settings object - this holds all the information needed for a
  10721. * given table, including configuration, data and current application of the
  10722. * table options. DataTables does not have a single instance for each DataTable
  10723. * with the settings attached to that instance, but rather instances of the
  10724. * DataTable "class" are created on-the-fly as needed (typically by a
  10725. * $().dataTable() call) and the settings object is then applied to that
  10726. * instance.
  10727. *
  10728. * Note that this object is related to {@link DataTable.defaults} but this
  10729. * one is the internal data store for DataTables's cache of columns. It should
  10730. * NOT be manipulated outside of DataTables. Any configuration should be done
  10731. * through the initialisation options.
  10732. * @namespace
  10733. * @todo Really should attach the settings object to individual instances so we
  10734. * don't need to create new instances on each $().dataTable() call (if the
  10735. * table already exists). It would also save passing oSettings around and
  10736. * into every single function. However, this is a very significant
  10737. * architecture change for DataTables and will almost certainly break
  10738. * backwards compatibility with older installations. This is something that
  10739. * will be done in 2.0.
  10740. */
  10741. DataTable.models.oSettings = {
  10742. /**
  10743. * Primary features of DataTables and their enablement state.
  10744. * @namespace
  10745. */
  10746. "oFeatures": {
  10747. /**
  10748. * Flag to say if DataTables should automatically try to calculate the
  10749. * optimum table and columns widths (true) or not (false).
  10750. * Note that this parameter will be set by the initialisation routine. To
  10751. * set a default use {@link DataTable.defaults}.
  10752. * @type boolean
  10753. */
  10754. "bAutoWidth": null,
  10755. /**
  10756. * Delay the creation of TR and TD elements until they are actually
  10757. * needed by a driven page draw. This can give a significant speed
  10758. * increase for Ajax source and Javascript source data, but makes no
  10759. * difference at all fro DOM and server-side processing tables.
  10760. * Note that this parameter will be set by the initialisation routine. To
  10761. * set a default use {@link DataTable.defaults}.
  10762. * @type boolean
  10763. */
  10764. "bDeferRender": null,
  10765. /**
  10766. * Enable filtering on the table or not. Note that if this is disabled
  10767. * then there is no filtering at all on the table, including fnFilter.
  10768. * To just remove the filtering input use sDom and remove the 'f' option.
  10769. * Note that this parameter will be set by the initialisation routine. To
  10770. * set a default use {@link DataTable.defaults}.
  10771. * @type boolean
  10772. */
  10773. "bFilter": null,
  10774. /**
  10775. * Table information element (the 'Showing x of y records' div) enable
  10776. * flag.
  10777. * Note that this parameter will be set by the initialisation routine. To
  10778. * set a default use {@link DataTable.defaults}.
  10779. * @type boolean
  10780. */
  10781. "bInfo": null,
  10782. /**
  10783. * Present a user control allowing the end user to change the page size
  10784. * when pagination is enabled.
  10785. * Note that this parameter will be set by the initialisation routine. To
  10786. * set a default use {@link DataTable.defaults}.
  10787. * @type boolean
  10788. */
  10789. "bLengthChange": null,
  10790. /**
  10791. * Pagination enabled or not. Note that if this is disabled then length
  10792. * changing must also be disabled.
  10793. * Note that this parameter will be set by the initialisation routine. To
  10794. * set a default use {@link DataTable.defaults}.
  10795. * @type boolean
  10796. */
  10797. "bPaginate": null,
  10798. /**
  10799. * Processing indicator enable flag whenever DataTables is enacting a
  10800. * user request - typically an Ajax request for server-side processing.
  10801. * Note that this parameter will be set by the initialisation routine. To
  10802. * set a default use {@link DataTable.defaults}.
  10803. * @type boolean
  10804. */
  10805. "bProcessing": null,
  10806. /**
  10807. * Server-side processing enabled flag - when enabled DataTables will
  10808. * get all data from the server for every draw - there is no filtering,
  10809. * sorting or paging done on the client-side.
  10810. * Note that this parameter will be set by the initialisation routine. To
  10811. * set a default use {@link DataTable.defaults}.
  10812. * @type boolean
  10813. */
  10814. "bServerSide": null,
  10815. /**
  10816. * Sorting enablement flag.
  10817. * Note that this parameter will be set by the initialisation routine. To
  10818. * set a default use {@link DataTable.defaults}.
  10819. * @type boolean
  10820. */
  10821. "bSort": null,
  10822. /**
  10823. * Multi-column sorting
  10824. * Note that this parameter will be set by the initialisation routine. To
  10825. * set a default use {@link DataTable.defaults}.
  10826. * @type boolean
  10827. */
  10828. "bSortMulti": null,
  10829. /**
  10830. * Apply a class to the columns which are being sorted to provide a
  10831. * visual highlight or not. This can slow things down when enabled since
  10832. * there is a lot of DOM interaction.
  10833. * Note that this parameter will be set by the initialisation routine. To
  10834. * set a default use {@link DataTable.defaults}.
  10835. * @type boolean
  10836. */
  10837. "bSortClasses": null,
  10838. /**
  10839. * State saving enablement flag.
  10840. * Note that this parameter will be set by the initialisation routine. To
  10841. * set a default use {@link DataTable.defaults}.
  10842. * @type boolean
  10843. */
  10844. "bStateSave": null
  10845. },
  10846. /**
  10847. * Scrolling settings for a table.
  10848. * @namespace
  10849. */
  10850. "oScroll": {
  10851. /**
  10852. * When the table is shorter in height than sScrollY, collapse the
  10853. * table container down to the height of the table (when true).
  10854. * Note that this parameter will be set by the initialisation routine. To
  10855. * set a default use {@link DataTable.defaults}.
  10856. * @type boolean
  10857. */
  10858. "bCollapse": null,
  10859. /**
  10860. * Width of the scrollbar for the web-browser's platform. Calculated
  10861. * during table initialisation.
  10862. * @type int
  10863. * @default 0
  10864. */
  10865. "iBarWidth": 0,
  10866. /**
  10867. * Viewport width for horizontal scrolling. Horizontal scrolling is
  10868. * disabled if an empty string.
  10869. * Note that this parameter will be set by the initialisation routine. To
  10870. * set a default use {@link DataTable.defaults}.
  10871. * @type string
  10872. */
  10873. "sX": null,
  10874. /**
  10875. * Width to expand the table to when using x-scrolling. Typically you
  10876. * should not need to use this.
  10877. * Note that this parameter will be set by the initialisation routine. To
  10878. * set a default use {@link DataTable.defaults}.
  10879. * @type string
  10880. * @deprecated
  10881. */
  10882. "sXInner": null,
  10883. /**
  10884. * Viewport height for vertical scrolling. Vertical scrolling is disabled
  10885. * if an empty string.
  10886. * Note that this parameter will be set by the initialisation routine. To
  10887. * set a default use {@link DataTable.defaults}.
  10888. * @type string
  10889. */
  10890. "sY": null
  10891. },
  10892. /**
  10893. * Language information for the table.
  10894. * @namespace
  10895. * @extends DataTable.defaults.oLanguage
  10896. */
  10897. "oLanguage": {
  10898. /**
  10899. * Information callback function. See
  10900. * {@link DataTable.defaults.fnInfoCallback}
  10901. * @type function
  10902. * @default null
  10903. */
  10904. "fnInfoCallback": null
  10905. },
  10906. /**
  10907. * Browser support parameters
  10908. * @namespace
  10909. */
  10910. "oBrowser": {
  10911. /**
  10912. * Indicate if the browser incorrectly calculates width:100% inside a
  10913. * scrolling element (IE6/7)
  10914. * @type boolean
  10915. * @default false
  10916. */
  10917. "bScrollOversize": false,
  10918. /**
  10919. * Determine if the vertical scrollbar is on the right or left of the
  10920. * scrolling container - needed for rtl language layout, although not
  10921. * all browsers move the scrollbar (Safari).
  10922. * @type boolean
  10923. * @default false
  10924. */
  10925. "bScrollbarLeft": false,
  10926. /**
  10927. * Flag for if `getBoundingClientRect` is fully supported or not
  10928. * @type boolean
  10929. * @default false
  10930. */
  10931. "bBounding": false,
  10932. /**
  10933. * Browser scrollbar width
  10934. * @type integer
  10935. * @default 0
  10936. */
  10937. "barWidth": 0
  10938. },
  10939. "ajax": null,
  10940. /**
  10941. * Array referencing the nodes which are used for the features. The
  10942. * parameters of this object match what is allowed by sDom - i.e.
  10943. * <ul>
  10944. * <li>'l' - Length changing</li>
  10945. * <li>'f' - Filtering input</li>
  10946. * <li>'t' - The table!</li>
  10947. * <li>'i' - Information</li>
  10948. * <li>'p' - Pagination</li>
  10949. * <li>'r' - pRocessing</li>
  10950. * </ul>
  10951. * @type array
  10952. * @default []
  10953. */
  10954. "aanFeatures": [],
  10955. /**
  10956. * Store data information - see {@link DataTable.models.oRow} for detailed
  10957. * information.
  10958. * @type array
  10959. * @default []
  10960. */
  10961. "aoData": [],
  10962. /**
  10963. * Array of indexes which are in the current display (after filtering etc)
  10964. * @type array
  10965. * @default []
  10966. */
  10967. "aiDisplay": [],
  10968. /**
  10969. * Array of indexes for display - no filtering
  10970. * @type array
  10971. * @default []
  10972. */
  10973. "aiDisplayMaster": [],
  10974. /**
  10975. * Map of row ids to data indexes
  10976. * @type object
  10977. * @default {}
  10978. */
  10979. "aIds": {},
  10980. /**
  10981. * Store information about each column that is in use
  10982. * @type array
  10983. * @default []
  10984. */
  10985. "aoColumns": [],
  10986. /**
  10987. * Store information about the table's header
  10988. * @type array
  10989. * @default []
  10990. */
  10991. "aoHeader": [],
  10992. /**
  10993. * Store information about the table's footer
  10994. * @type array
  10995. * @default []
  10996. */
  10997. "aoFooter": [],
  10998. /**
  10999. * Store the applied global search information in case we want to force a
  11000. * research or compare the old search to a new one.
  11001. * Note that this parameter will be set by the initialisation routine. To
  11002. * set a default use {@link DataTable.defaults}.
  11003. * @namespace
  11004. * @extends DataTable.models.oSearch
  11005. */
  11006. "oPreviousSearch": {},
  11007. /**
  11008. * Store the applied search for each column - see
  11009. * {@link DataTable.models.oSearch} for the format that is used for the
  11010. * filtering information for each column.
  11011. * @type array
  11012. * @default []
  11013. */
  11014. "aoPreSearchCols": [],
  11015. /**
  11016. * Sorting that is applied to the table. Note that the inner arrays are
  11017. * used in the following manner:
  11018. * <ul>
  11019. * <li>Index 0 - column number</li>
  11020. * <li>Index 1 - current sorting direction</li>
  11021. * </ul>
  11022. * Note that this parameter will be set by the initialisation routine. To
  11023. * set a default use {@link DataTable.defaults}.
  11024. * @type array
  11025. * @todo These inner arrays should really be objects
  11026. */
  11027. "aaSorting": null,
  11028. /**
  11029. * Sorting that is always applied to the table (i.e. prefixed in front of
  11030. * aaSorting).
  11031. * Note that this parameter will be set by the initialisation routine. To
  11032. * set a default use {@link DataTable.defaults}.
  11033. * @type array
  11034. * @default []
  11035. */
  11036. "aaSortingFixed": [],
  11037. /**
  11038. * Classes to use for the striping of a table.
  11039. * Note that this parameter will be set by the initialisation routine. To
  11040. * set a default use {@link DataTable.defaults}.
  11041. * @type array
  11042. * @default []
  11043. */
  11044. "asStripeClasses": null,
  11045. /**
  11046. * If restoring a table - we should restore its striping classes as well
  11047. * @type array
  11048. * @default []
  11049. */
  11050. "asDestroyStripes": [],
  11051. /**
  11052. * If restoring a table - we should restore its width
  11053. * @type int
  11054. * @default 0
  11055. */
  11056. "sDestroyWidth": 0,
  11057. /**
  11058. * Callback functions array for every time a row is inserted (i.e. on a draw).
  11059. * @type array
  11060. * @default []
  11061. */
  11062. "aoRowCallback": [],
  11063. /**
  11064. * Callback functions for the header on each draw.
  11065. * @type array
  11066. * @default []
  11067. */
  11068. "aoHeaderCallback": [],
  11069. /**
  11070. * Callback function for the footer on each draw.
  11071. * @type array
  11072. * @default []
  11073. */
  11074. "aoFooterCallback": [],
  11075. /**
  11076. * Array of callback functions for draw callback functions
  11077. * @type array
  11078. * @default []
  11079. */
  11080. "aoDrawCallback": [],
  11081. /**
  11082. * Array of callback functions for row created function
  11083. * @type array
  11084. * @default []
  11085. */
  11086. "aoRowCreatedCallback": [],
  11087. /**
  11088. * Callback functions for just before the table is redrawn. A return of
  11089. * false will be used to cancel the draw.
  11090. * @type array
  11091. * @default []
  11092. */
  11093. "aoPreDrawCallback": [],
  11094. /**
  11095. * Callback functions for when the table has been initialised.
  11096. * @type array
  11097. * @default []
  11098. */
  11099. "aoInitComplete": [],
  11100. /**
  11101. * Callbacks for modifying the settings to be stored for state saving, prior to
  11102. * saving state.
  11103. * @type array
  11104. * @default []
  11105. */
  11106. "aoStateSaveParams": [],
  11107. /**
  11108. * Callbacks for modifying the settings that have been stored for state saving
  11109. * prior to using the stored values to restore the state.
  11110. * @type array
  11111. * @default []
  11112. */
  11113. "aoStateLoadParams": [],
  11114. /**
  11115. * Callbacks for operating on the settings object once the saved state has been
  11116. * loaded
  11117. * @type array
  11118. * @default []
  11119. */
  11120. "aoStateLoaded": [],
  11121. /**
  11122. * Cache the table ID for quick access
  11123. * @type string
  11124. * @default <i>Empty string</i>
  11125. */
  11126. "sTableId": "",
  11127. /**
  11128. * The TABLE node for the main table
  11129. * @type node
  11130. * @default null
  11131. */
  11132. "nTable": null,
  11133. /**
  11134. * Permanent ref to the thead element
  11135. * @type node
  11136. * @default null
  11137. */
  11138. "nTHead": null,
  11139. /**
  11140. * Permanent ref to the tfoot element - if it exists
  11141. * @type node
  11142. * @default null
  11143. */
  11144. "nTFoot": null,
  11145. /**
  11146. * Permanent ref to the tbody element
  11147. * @type node
  11148. * @default null
  11149. */
  11150. "nTBody": null,
  11151. /**
  11152. * Cache the wrapper node (contains all DataTables controlled elements)
  11153. * @type node
  11154. * @default null
  11155. */
  11156. "nTableWrapper": null,
  11157. /**
  11158. * Indicate if when using server-side processing the loading of data
  11159. * should be deferred until the second draw.
  11160. * Note that this parameter will be set by the initialisation routine. To
  11161. * set a default use {@link DataTable.defaults}.
  11162. * @type boolean
  11163. * @default false
  11164. */
  11165. "bDeferLoading": false,
  11166. /**
  11167. * Indicate if all required information has been read in
  11168. * @type boolean
  11169. * @default false
  11170. */
  11171. "bInitialised": false,
  11172. /**
  11173. * Information about open rows. Each object in the array has the parameters
  11174. * 'nTr' and 'nParent'
  11175. * @type array
  11176. * @default []
  11177. */
  11178. "aoOpenRows": [],
  11179. /**
  11180. * Dictate the positioning of DataTables' control elements - see
  11181. * {@link DataTable.model.oInit.sDom}.
  11182. * Note that this parameter will be set by the initialisation routine. To
  11183. * set a default use {@link DataTable.defaults}.
  11184. * @type string
  11185. * @default null
  11186. */
  11187. "sDom": null,
  11188. /**
  11189. * Search delay (in mS)
  11190. * @type integer
  11191. * @default null
  11192. */
  11193. "searchDelay": null,
  11194. /**
  11195. * Which type of pagination should be used.
  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. * @default two_button
  11200. */
  11201. "sPaginationType": "two_button",
  11202. /**
  11203. * The state duration (for `stateSave`) in seconds.
  11204. * Note that this parameter will be set by the initialisation routine. To
  11205. * set a default use {@link DataTable.defaults}.
  11206. * @type int
  11207. * @default 0
  11208. */
  11209. "iStateDuration": 0,
  11210. /**
  11211. * Array of callback functions for state saving. Each array element is an
  11212. * object with the following parameters:
  11213. * <ul>
  11214. * <li>function:fn - function to call. Takes two parameters, oSettings
  11215. * and the JSON string to save that has been thus far created. Returns
  11216. * a JSON string to be inserted into a json object
  11217. * (i.e. '"param": [ 0, 1, 2]')</li>
  11218. * <li>string:sName - name of callback</li>
  11219. * </ul>
  11220. * @type array
  11221. * @default []
  11222. */
  11223. "aoStateSave": [],
  11224. /**
  11225. * Array of callback functions for state loading. Each array element is an
  11226. * object with the following parameters:
  11227. * <ul>
  11228. * <li>function:fn - function to call. Takes two parameters, oSettings
  11229. * and the object stored. May return false to cancel state loading</li>
  11230. * <li>string:sName - name of callback</li>
  11231. * </ul>
  11232. * @type array
  11233. * @default []
  11234. */
  11235. "aoStateLoad": [],
  11236. /**
  11237. * State that was saved. Useful for back reference
  11238. * @type object
  11239. * @default null
  11240. */
  11241. "oSavedState": null,
  11242. /**
  11243. * State that was loaded. Useful for back reference
  11244. * @type object
  11245. * @default null
  11246. */
  11247. "oLoadedState": null,
  11248. /**
  11249. * Source url for AJAX data for the table.
  11250. * Note that this parameter will be set by the initialisation routine. To
  11251. * set a default use {@link DataTable.defaults}.
  11252. * @type string
  11253. * @default null
  11254. */
  11255. "sAjaxSource": null,
  11256. /**
  11257. * Property from a given object from which to read the table data from. This
  11258. * can be an empty string (when not server-side processing), in which case
  11259. * it is assumed an an array is given directly.
  11260. * Note that this parameter will be set by the initialisation routine. To
  11261. * set a default use {@link DataTable.defaults}.
  11262. * @type string
  11263. */
  11264. "sAjaxDataProp": null,
  11265. /**
  11266. * Note if draw should be blocked while getting data
  11267. * @type boolean
  11268. * @default true
  11269. */
  11270. "bAjaxDataGet": true,
  11271. /**
  11272. * The last jQuery XHR object that was used for server-side data gathering.
  11273. * This can be used for working with the XHR information in one of the
  11274. * callbacks
  11275. * @type object
  11276. * @default null
  11277. */
  11278. "jqXHR": null,
  11279. /**
  11280. * JSON returned from the server in the last Ajax request
  11281. * @type object
  11282. * @default undefined
  11283. */
  11284. "json": undefined,
  11285. /**
  11286. * Data submitted as part of the last Ajax request
  11287. * @type object
  11288. * @default undefined
  11289. */
  11290. "oAjaxData": undefined,
  11291. /**
  11292. * Function to get the server-side data.
  11293. * Note that this parameter will be set by the initialisation routine. To
  11294. * set a default use {@link DataTable.defaults}.
  11295. * @type function
  11296. */
  11297. "fnServerData": null,
  11298. /**
  11299. * Functions which are called prior to sending an Ajax request so extra
  11300. * parameters can easily be sent to the server
  11301. * @type array
  11302. * @default []
  11303. */
  11304. "aoServerParams": [],
  11305. /**
  11306. * Send the XHR HTTP method - GET or POST (could be PUT or DELETE if
  11307. * required).
  11308. * Note that this parameter will be set by the initialisation routine. To
  11309. * set a default use {@link DataTable.defaults}.
  11310. * @type string
  11311. */
  11312. "sServerMethod": null,
  11313. /**
  11314. * Format numbers for display.
  11315. * Note that this parameter will be set by the initialisation routine. To
  11316. * set a default use {@link DataTable.defaults}.
  11317. * @type function
  11318. */
  11319. "fnFormatNumber": null,
  11320. /**
  11321. * List of options that can be used for the user selectable length menu.
  11322. * Note that this parameter will be set by the initialisation routine. To
  11323. * set a default use {@link DataTable.defaults}.
  11324. * @type array
  11325. * @default []
  11326. */
  11327. "aLengthMenu": null,
  11328. /**
  11329. * Counter for the draws that the table does. Also used as a tracker for
  11330. * server-side processing
  11331. * @type int
  11332. * @default 0
  11333. */
  11334. "iDraw": 0,
  11335. /**
  11336. * Indicate if a redraw is being done - useful for Ajax
  11337. * @type boolean
  11338. * @default false
  11339. */
  11340. "bDrawing": false,
  11341. /**
  11342. * Draw index (iDraw) of the last error when parsing the returned data
  11343. * @type int
  11344. * @default -1
  11345. */
  11346. "iDrawError": -1,
  11347. /**
  11348. * Paging display length
  11349. * @type int
  11350. * @default 10
  11351. */
  11352. "_iDisplayLength": 10,
  11353. /**
  11354. * Paging start point - aiDisplay index
  11355. * @type int
  11356. * @default 0
  11357. */
  11358. "_iDisplayStart": 0,
  11359. /**
  11360. * Server-side processing - number of records in the result set
  11361. * (i.e. before filtering), Use fnRecordsTotal rather than
  11362. * this property to get the value of the number of records, regardless of
  11363. * the server-side processing setting.
  11364. * @type int
  11365. * @default 0
  11366. * @private
  11367. */
  11368. "_iRecordsTotal": 0,
  11369. /**
  11370. * Server-side processing - number of records in the current display set
  11371. * (i.e. after filtering). Use fnRecordsDisplay rather than
  11372. * this property to get the value of the number of records, regardless of
  11373. * the server-side processing setting.
  11374. * @type boolean
  11375. * @default 0
  11376. * @private
  11377. */
  11378. "_iRecordsDisplay": 0,
  11379. /**
  11380. * Flag to indicate if jQuery UI marking and classes should be used.
  11381. * Note that this parameter will be set by the initialisation routine. To
  11382. * set a default use {@link DataTable.defaults}.
  11383. * @type boolean
  11384. */
  11385. "bJUI": null,
  11386. /**
  11387. * The classes to use for the table
  11388. * @type object
  11389. * @default {}
  11390. */
  11391. "oClasses": {},
  11392. /**
  11393. * Flag attached to the settings object so you can check in the draw
  11394. * callback if filtering has been done in the draw. Deprecated in favour of
  11395. * events.
  11396. * @type boolean
  11397. * @default false
  11398. * @deprecated
  11399. */
  11400. "bFiltered": false,
  11401. /**
  11402. * Flag attached to the settings object so you can check in the draw
  11403. * callback if sorting has been done in the draw. Deprecated in favour of
  11404. * events.
  11405. * @type boolean
  11406. * @default false
  11407. * @deprecated
  11408. */
  11409. "bSorted": false,
  11410. /**
  11411. * Indicate that if multiple rows are in the header and there is more than
  11412. * one unique cell per column, if the top one (true) or bottom one (false)
  11413. * should be used for sorting / title by DataTables.
  11414. * Note that this parameter will be set by the initialisation routine. To
  11415. * set a default use {@link DataTable.defaults}.
  11416. * @type boolean
  11417. */
  11418. "bSortCellsTop": null,
  11419. /**
  11420. * Initialisation object that is used for the table
  11421. * @type object
  11422. * @default null
  11423. */
  11424. "oInit": null,
  11425. /**
  11426. * Destroy callback functions - for plug-ins to attach themselves to the
  11427. * destroy so they can clean up markup and events.
  11428. * @type array
  11429. * @default []
  11430. */
  11431. "aoDestroyCallback": [],
  11432. /**
  11433. * Get the number of records in the current record set, before filtering
  11434. * @type function
  11435. */
  11436. "fnRecordsTotal": function() {
  11437. return _fnDataSource(this) == 'ssp' ?
  11438. this._iRecordsTotal * 1 :
  11439. this.aiDisplayMaster.length;
  11440. },
  11441. /**
  11442. * Get the number of records in the current record set, after filtering
  11443. * @type function
  11444. */
  11445. "fnRecordsDisplay": function() {
  11446. return _fnDataSource(this) == 'ssp' ?
  11447. this._iRecordsDisplay * 1 :
  11448. this.aiDisplay.length;
  11449. },
  11450. /**
  11451. * Get the display end point - aiDisplay index
  11452. * @type function
  11453. */
  11454. "fnDisplayEnd": function() {
  11455. var
  11456. len = this._iDisplayLength,
  11457. start = this._iDisplayStart,
  11458. calc = start + len,
  11459. records = this.aiDisplay.length,
  11460. features = this.oFeatures,
  11461. paginate = features.bPaginate;
  11462. if (features.bServerSide) {
  11463. return paginate === false || len === -1 ?
  11464. start + records :
  11465. Math.min(start + len, this._iRecordsDisplay);
  11466. } else {
  11467. return !paginate || calc > records || len === -1 ?
  11468. records :
  11469. calc;
  11470. }
  11471. },
  11472. /**
  11473. * The DataTables object for this table
  11474. * @type object
  11475. * @default null
  11476. */
  11477. "oInstance": null,
  11478. /**
  11479. * Unique identifier for each instance of the DataTables object. If there
  11480. * is an ID on the table node, then it takes that value, otherwise an
  11481. * incrementing internal counter is used.
  11482. * @type string
  11483. * @default null
  11484. */
  11485. "sInstance": null,
  11486. /**
  11487. * tabindex attribute value that is added to DataTables control elements, allowing
  11488. * keyboard navigation of the table and its controls.
  11489. */
  11490. "iTabIndex": 0,
  11491. /**
  11492. * DIV container for the footer scrolling table if scrolling
  11493. */
  11494. "nScrollHead": null,
  11495. /**
  11496. * DIV container for the footer scrolling table if scrolling
  11497. */
  11498. "nScrollFoot": null,
  11499. /**
  11500. * Last applied sort
  11501. * @type array
  11502. * @default []
  11503. */
  11504. "aLastSort": [],
  11505. /**
  11506. * Stored plug-in instances
  11507. * @type object
  11508. * @default {}
  11509. */
  11510. "oPlugins": {},
  11511. /**
  11512. * Function used to get a row's id from the row's data
  11513. * @type function
  11514. * @default null
  11515. */
  11516. "rowIdFn": null,
  11517. /**
  11518. * Data location where to store a row's id
  11519. * @type string
  11520. * @default null
  11521. */
  11522. "rowId": null
  11523. };
  11524. /**
  11525. * Extension object for DataTables that is used to provide all extension
  11526. * options.
  11527. *
  11528. * Note that the `DataTable.ext` object is available through
  11529. * `jQuery.fn.dataTable.ext` where it may be accessed and manipulated. It is
  11530. * also aliased to `jQuery.fn.dataTableExt` for historic reasons.
  11531. * @namespace
  11532. * @extends DataTable.models.ext
  11533. */
  11534. /**
  11535. * DataTables extensions
  11536. *
  11537. * This namespace acts as a collection area for plug-ins that can be used to
  11538. * extend DataTables capabilities. Indeed many of the build in methods
  11539. * use this method to provide their own capabilities (sorting methods for
  11540. * example).
  11541. *
  11542. * Note that this namespace is aliased to `jQuery.fn.dataTableExt` for legacy
  11543. * reasons
  11544. *
  11545. * @namespace
  11546. */
  11547. DataTable.ext = _ext = {
  11548. /**
  11549. * Buttons. For use with the Buttons extension for DataTables. This is
  11550. * defined here so other extensions can define buttons regardless of load
  11551. * order. It is _not_ used by DataTables core.
  11552. *
  11553. * @type object
  11554. * @default {}
  11555. */
  11556. buttons: {},
  11557. /**
  11558. * Element class names
  11559. *
  11560. * @type object
  11561. * @default {}
  11562. */
  11563. classes: {},
  11564. /**
  11565. * DataTables build type (expanded by the download builder)
  11566. *
  11567. * @type string
  11568. */
  11569. builder: "-source-",
  11570. /**
  11571. * Error reporting.
  11572. *
  11573. * How should DataTables report an error. Can take the value 'alert',
  11574. * 'throw', 'none' or a function.
  11575. *
  11576. * @type string|function
  11577. * @default alert
  11578. */
  11579. errMode: "alert",
  11580. /**
  11581. * Feature plug-ins.
  11582. *
  11583. * This is an array of objects which describe the feature plug-ins that are
  11584. * available to DataTables. These feature plug-ins are then available for
  11585. * use through the `dom` initialisation option.
  11586. *
  11587. * Each feature plug-in is described by an object which must have the
  11588. * following properties:
  11589. *
  11590. * * `fnInit` - function that is used to initialise the plug-in,
  11591. * * `cFeature` - a character so the feature can be enabled by the `dom`
  11592. * instillation option. This is case sensitive.
  11593. *
  11594. * The `fnInit` function has the following input parameters:
  11595. *
  11596. * 1. `{object}` DataTables settings object: see
  11597. * {@link DataTable.models.oSettings}
  11598. *
  11599. * And the following return is expected:
  11600. *
  11601. * * {node|null} The element which contains your feature. Note that the
  11602. * return may also be void if your plug-in does not require to inject any
  11603. * DOM elements into DataTables control (`dom`) - for example this might
  11604. * be useful when developing a plug-in which allows table control via
  11605. * keyboard entry
  11606. *
  11607. * @type array
  11608. *
  11609. * @example
  11610. * $.fn.dataTable.ext.features.push( {
  11611. * "fnInit": function( oSettings ) {
  11612. * return new TableTools( { "oDTSettings": oSettings } );
  11613. * },
  11614. * "cFeature": "T"
  11615. * } );
  11616. */
  11617. feature: [],
  11618. /**
  11619. * Row searching.
  11620. *
  11621. * This method of searching is complimentary to the default type based
  11622. * searching, and a lot more comprehensive as it allows you complete control
  11623. * over the searching logic. Each element in this array is a function
  11624. * (parameters described below) that is called for every row in the table,
  11625. * and your logic decides if it should be included in the searching data set
  11626. * or not.
  11627. *
  11628. * Searching functions have the following input parameters:
  11629. *
  11630. * 1. `{object}` DataTables settings object: see
  11631. * {@link DataTable.models.oSettings}
  11632. * 2. `{array|object}` Data for the row to be processed (same as the
  11633. * original format that was passed in as the data source, or an array
  11634. * from a DOM data source
  11635. * 3. `{int}` Row index ({@link DataTable.models.oSettings.aoData}), which
  11636. * can be useful to retrieve the `TR` element if you need DOM interaction.
  11637. *
  11638. * And the following return is expected:
  11639. *
  11640. * * {boolean} Include the row in the searched result set (true) or not
  11641. * (false)
  11642. *
  11643. * Note that as with the main search ability in DataTables, technically this
  11644. * is "filtering", since it is subtractive. However, for consistency in
  11645. * naming we call it searching here.
  11646. *
  11647. * @type array
  11648. * @default []
  11649. *
  11650. * @example
  11651. * // The following example shows custom search being applied to the
  11652. * // fourth column (i.e. the data[3] index) based on two input values
  11653. * // from the end-user, matching the data in a certain range.
  11654. * $.fn.dataTable.ext.search.push(
  11655. * function( settings, data, dataIndex ) {
  11656. * var min = document.getElementById('min').value * 1;
  11657. * var max = document.getElementById('max').value * 1;
  11658. * var version = data[3] == "-" ? 0 : data[3]*1;
  11659. *
  11660. * if ( min == "" && max == "" ) {
  11661. * return true;
  11662. * }
  11663. * else if ( min == "" && version < max ) {
  11664. * return true;
  11665. * }
  11666. * else if ( min < version && "" == max ) {
  11667. * return true;
  11668. * }
  11669. * else if ( min < version && version < max ) {
  11670. * return true;
  11671. * }
  11672. * return false;
  11673. * }
  11674. * );
  11675. */
  11676. search: [],
  11677. /**
  11678. * Selector extensions
  11679. *
  11680. * The `selector` option can be used to extend the options available for the
  11681. * selector modifier options (`selector-modifier` object data type) that
  11682. * each of the three built in selector types offer (row, column and cell +
  11683. * their plural counterparts). For example the Select extension uses this
  11684. * mechanism to provide an option to select only rows, columns and cells
  11685. * that have been marked as selected by the end user (`{selected: true}`),
  11686. * which can be used in conjunction with the existing built in selector
  11687. * options.
  11688. *
  11689. * Each property is an array to which functions can be pushed. The functions
  11690. * take three attributes:
  11691. *
  11692. * * Settings object for the host table
  11693. * * Options object (`selector-modifier` object type)
  11694. * * Array of selected item indexes
  11695. *
  11696. * The return is an array of the resulting item indexes after the custom
  11697. * selector has been applied.
  11698. *
  11699. * @type object
  11700. */
  11701. selector: {
  11702. cell: [],
  11703. column: [],
  11704. row: []
  11705. },
  11706. /**
  11707. * Internal functions, exposed for used in plug-ins.
  11708. *
  11709. * Please note that you should not need to use the internal methods for
  11710. * anything other than a plug-in (and even then, try to avoid if possible).
  11711. * The internal function may change between releases.
  11712. *
  11713. * @type object
  11714. * @default {}
  11715. */
  11716. internal: {},
  11717. /**
  11718. * Legacy configuration options. Enable and disable legacy options that
  11719. * are available in DataTables.
  11720. *
  11721. * @type object
  11722. */
  11723. legacy: {
  11724. /**
  11725. * Enable / disable DataTables 1.9 compatible server-side processing
  11726. * requests
  11727. *
  11728. * @type boolean
  11729. * @default null
  11730. */
  11731. ajax: null
  11732. },
  11733. /**
  11734. * Pagination plug-in methods.
  11735. *
  11736. * Each entry in this object is a function and defines which buttons should
  11737. * be shown by the pagination rendering method that is used for the table:
  11738. * {@link DataTable.ext.renderer.pageButton}. The renderer addresses how the
  11739. * buttons are displayed in the document, while the functions here tell it
  11740. * what buttons to display. This is done by returning an array of button
  11741. * descriptions (what each button will do).
  11742. *
  11743. * Pagination types (the four built in options and any additional plug-in
  11744. * options defined here) can be used through the `paginationType`
  11745. * initialisation parameter.
  11746. *
  11747. * The functions defined take two parameters:
  11748. *
  11749. * 1. `{int} page` The current page index
  11750. * 2. `{int} pages` The number of pages in the table
  11751. *
  11752. * Each function is expected to return an array where each element of the
  11753. * array can be one of:
  11754. *
  11755. * * `first` - Jump to first page when activated
  11756. * * `last` - Jump to last page when activated
  11757. * * `previous` - Show previous page when activated
  11758. * * `next` - Show next page when activated
  11759. * * `{int}` - Show page of the index given
  11760. * * `{array}` - A nested array containing the above elements to add a
  11761. * containing 'DIV' element (might be useful for styling).
  11762. *
  11763. * Note that DataTables v1.9- used this object slightly differently whereby
  11764. * an object with two functions would be defined for each plug-in. That
  11765. * ability is still supported by DataTables 1.10+ to provide backwards
  11766. * compatibility, but this option of use is now decremented and no longer
  11767. * documented in DataTables 1.10+.
  11768. *
  11769. * @type object
  11770. * @default {}
  11771. *
  11772. * @example
  11773. * // Show previous, next and current page buttons only
  11774. * $.fn.dataTableExt.oPagination.current = function ( page, pages ) {
  11775. * return [ 'previous', page, 'next' ];
  11776. * };
  11777. */
  11778. pager: {},
  11779. renderer: {
  11780. pageButton: {},
  11781. header: {}
  11782. },
  11783. /**
  11784. * Ordering plug-ins - custom data source
  11785. *
  11786. * The extension options for ordering of data available here is complimentary
  11787. * to the default type based ordering that DataTables typically uses. It
  11788. * allows much greater control over the the data that is being used to
  11789. * order a column, but is necessarily therefore more complex.
  11790. *
  11791. * This type of ordering is useful if you want to do ordering based on data
  11792. * live from the DOM (for example the contents of an 'input' element) rather
  11793. * than just the static string that DataTables knows of.
  11794. *
  11795. * The way these plug-ins work is that you create an array of the values you
  11796. * wish to be ordering for the column in question and then return that
  11797. * array. The data in the array much be in the index order of the rows in
  11798. * the table (not the currently ordering order!). Which order data gathering
  11799. * function is run here depends on the `dt-init columns.orderDataType`
  11800. * parameter that is used for the column (if any).
  11801. *
  11802. * The functions defined take two parameters:
  11803. *
  11804. * 1. `{object}` DataTables settings object: see
  11805. * {@link DataTable.models.oSettings}
  11806. * 2. `{int}` Target column index
  11807. *
  11808. * Each function is expected to return an array:
  11809. *
  11810. * * `{array}` Data for the column to be ordering upon
  11811. *
  11812. * @type array
  11813. *
  11814. * @example
  11815. * // Ordering using `input` node values
  11816. * $.fn.dataTable.ext.order['dom-text'] = function ( settings, col )
  11817. * {
  11818. * return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
  11819. * return $('input', td).val();
  11820. * } );
  11821. * }
  11822. */
  11823. order: {},
  11824. /**
  11825. * Type based plug-ins.
  11826. *
  11827. * Each column in DataTables has a type assigned to it, either by automatic
  11828. * detection or by direct assignment using the `type` option for the column.
  11829. * The type of a column will effect how it is ordering and search (plug-ins
  11830. * can also make use of the column type if required).
  11831. *
  11832. * @namespace
  11833. */
  11834. type: {
  11835. /**
  11836. * Type detection functions.
  11837. *
  11838. * The functions defined in this object are used to automatically detect
  11839. * a column's type, making initialisation of DataTables super easy, even
  11840. * when complex data is in the table.
  11841. *
  11842. * The functions defined take two parameters:
  11843. *
  11844. * 1. `{*}` Data from the column cell to be analysed
  11845. * 2. `{settings}` DataTables settings object. This can be used to
  11846. * perform context specific type detection - for example detection
  11847. * based on language settings such as using a comma for a decimal
  11848. * place. Generally speaking the options from the settings will not
  11849. * be required
  11850. *
  11851. * Each function is expected to return:
  11852. *
  11853. * * `{string|null}` Data type detected, or null if unknown (and thus
  11854. * pass it on to the other type detection functions.
  11855. *
  11856. * @type array
  11857. *
  11858. * @example
  11859. * // Currency type detection plug-in:
  11860. * $.fn.dataTable.ext.type.detect.push(
  11861. * function ( data, settings ) {
  11862. * // Check the numeric part
  11863. * if ( ! $.isNumeric( data.substring(1) ) ) {
  11864. * return null;
  11865. * }
  11866. *
  11867. * // Check prefixed by currency
  11868. * if ( data.charAt(0) == '$' || data.charAt(0) == '&pound;' ) {
  11869. * return 'currency';
  11870. * }
  11871. * return null;
  11872. * }
  11873. * );
  11874. */
  11875. detect: [],
  11876. /**
  11877. * Type based search formatting.
  11878. *
  11879. * The type based searching functions can be used to pre-format the
  11880. * data to be search on. For example, it can be used to strip HTML
  11881. * tags or to de-format telephone numbers for numeric only searching.
  11882. *
  11883. * Note that is a search is not defined for a column of a given type,
  11884. * no search formatting will be performed.
  11885. *
  11886. * Pre-processing of searching data plug-ins - When you assign the sType
  11887. * for a column (or have it automatically detected for you by DataTables
  11888. * or a type detection plug-in), you will typically be using this for
  11889. * custom sorting, but it can also be used to provide custom searching
  11890. * by allowing you to pre-processing the data and returning the data in
  11891. * the format that should be searched upon. This is done by adding
  11892. * functions this object with a parameter name which matches the sType
  11893. * for that target column. This is the corollary of <i>afnSortData</i>
  11894. * for searching data.
  11895. *
  11896. * The functions defined take a single parameter:
  11897. *
  11898. * 1. `{*}` Data from the column cell to be prepared for searching
  11899. *
  11900. * Each function is expected to return:
  11901. *
  11902. * * `{string|null}` Formatted string that will be used for the searching.
  11903. *
  11904. * @type object
  11905. * @default {}
  11906. *
  11907. * @example
  11908. * $.fn.dataTable.ext.type.search['title-numeric'] = function ( d ) {
  11909. * return d.replace(/\n/g," ").replace( /<.*?>/g, "" );
  11910. * }
  11911. */
  11912. search: {},
  11913. /**
  11914. * Type based ordering.
  11915. *
  11916. * The column type tells DataTables what ordering to apply to the table
  11917. * when a column is sorted upon. The order for each type that is defined,
  11918. * is defined by the functions available in this object.
  11919. *
  11920. * Each ordering option can be described by three properties added to
  11921. * this object:
  11922. *
  11923. * * `{type}-pre` - Pre-formatting function
  11924. * * `{type}-asc` - Ascending order function
  11925. * * `{type}-desc` - Descending order function
  11926. *
  11927. * All three can be used together, only `{type}-pre` or only
  11928. * `{type}-asc` and `{type}-desc` together. It is generally recommended
  11929. * that only `{type}-pre` is used, as this provides the optimal
  11930. * implementation in terms of speed, although the others are provided
  11931. * for compatibility with existing Javascript sort functions.
  11932. *
  11933. * `{type}-pre`: Functions defined take a single parameter:
  11934. *
  11935. * 1. `{*}` Data from the column cell to be prepared for ordering
  11936. *
  11937. * And return:
  11938. *
  11939. * * `{*}` Data to be sorted upon
  11940. *
  11941. * `{type}-asc` and `{type}-desc`: Functions are typical Javascript sort
  11942. * functions, taking two parameters:
  11943. *
  11944. * 1. `{*}` Data to compare to the second parameter
  11945. * 2. `{*}` Data to compare to the first parameter
  11946. *
  11947. * And returning:
  11948. *
  11949. * * `{*}` Ordering match: <0 if first parameter should be sorted lower
  11950. * than the second parameter, ===0 if the two parameters are equal and
  11951. * >0 if the first parameter should be sorted height than the second
  11952. * parameter.
  11953. *
  11954. * @type object
  11955. * @default {}
  11956. *
  11957. * @example
  11958. * // Numeric ordering of formatted numbers with a pre-formatter
  11959. * $.extend( $.fn.dataTable.ext.type.order, {
  11960. * "string-pre": function(x) {
  11961. * a = (a === "-" || a === "") ? 0 : a.replace( /[^\d\-\.]/g, "" );
  11962. * return parseFloat( a );
  11963. * }
  11964. * } );
  11965. *
  11966. * @example
  11967. * // Case-sensitive string ordering, with no pre-formatting method
  11968. * $.extend( $.fn.dataTable.ext.order, {
  11969. * "string-case-asc": function(x,y) {
  11970. * return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  11971. * },
  11972. * "string-case-desc": function(x,y) {
  11973. * return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  11974. * }
  11975. * } );
  11976. */
  11977. order: {}
  11978. },
  11979. /**
  11980. * Unique DataTables instance counter
  11981. *
  11982. * @type int
  11983. * @private
  11984. */
  11985. _unique: 0,
  11986. //
  11987. // Depreciated
  11988. // The following properties are retained for backwards compatiblity only.
  11989. // The should not be used in new projects and will be removed in a future
  11990. // version
  11991. //
  11992. /**
  11993. * Version check function.
  11994. * @type function
  11995. * @depreciated Since 1.10
  11996. */
  11997. fnVersionCheck: DataTable.fnVersionCheck,
  11998. /**
  11999. * Index for what 'this' index API functions should use
  12000. * @type int
  12001. * @deprecated Since v1.10
  12002. */
  12003. iApiIndex: 0,
  12004. /**
  12005. * jQuery UI class container
  12006. * @type object
  12007. * @deprecated Since v1.10
  12008. */
  12009. oJUIClasses: {},
  12010. /**
  12011. * Software version
  12012. * @type string
  12013. * @deprecated Since v1.10
  12014. */
  12015. sVersion: DataTable.version
  12016. };
  12017. //
  12018. // Backwards compatibility. Alias to pre 1.10 Hungarian notation counter parts
  12019. //
  12020. $.extend(_ext, {
  12021. afnFiltering: _ext.search,
  12022. aTypes: _ext.type.detect,
  12023. ofnSearch: _ext.type.search,
  12024. oSort: _ext.type.order,
  12025. afnSortData: _ext.order,
  12026. aoFeatures: _ext.feature,
  12027. oApi: _ext.internal,
  12028. oStdClasses: _ext.classes,
  12029. oPagination: _ext.pager
  12030. });
  12031. $.extend(DataTable.ext.classes, {
  12032. "sTable": "dataTable",
  12033. "sNoFooter": "no-footer",
  12034. /* Paging buttons */
  12035. "sPageButton": "paginate_button",
  12036. "sPageButtonActive": "current",
  12037. "sPageButtonDisabled": "disabled",
  12038. /* Striping classes */
  12039. "sStripeOdd": "odd",
  12040. "sStripeEven": "even",
  12041. /* Empty row */
  12042. "sRowEmpty": "dataTables_empty",
  12043. /* Features */
  12044. "sWrapper": "dataTables_wrapper",
  12045. "sFilter": "dataTables_filter",
  12046. "sInfo": "dataTables_info",
  12047. "sPaging": "dataTables_paginate paging_",
  12048. /* Note that the type is postfixed */
  12049. "sLength": "dataTables_length",
  12050. "sProcessing": "dataTables_processing",
  12051. /* Sorting */
  12052. "sSortAsc": "sorting_asc",
  12053. "sSortDesc": "sorting_desc",
  12054. "sSortable": "sorting",
  12055. /* Sortable in both directions */
  12056. "sSortableAsc": "sorting_asc_disabled",
  12057. "sSortableDesc": "sorting_desc_disabled",
  12058. "sSortableNone": "sorting_disabled",
  12059. "sSortColumn": "sorting_",
  12060. /* Note that an int is postfixed for the sorting order */
  12061. /* Filtering */
  12062. "sFilterInput": "",
  12063. /* Page length */
  12064. "sLengthSelect": "",
  12065. /* Scrolling */
  12066. "sScrollWrapper": "dataTables_scroll",
  12067. "sScrollHead": "dataTables_scrollHead",
  12068. "sScrollHeadInner": "dataTables_scrollHeadInner",
  12069. "sScrollBody": "dataTables_scrollBody",
  12070. "sScrollFoot": "dataTables_scrollFoot",
  12071. "sScrollFootInner": "dataTables_scrollFootInner",
  12072. /* Misc */
  12073. "sHeaderTH": "",
  12074. "sFooterTH": "",
  12075. // Deprecated
  12076. "sSortJUIAsc": "",
  12077. "sSortJUIDesc": "",
  12078. "sSortJUI": "",
  12079. "sSortJUIAscAllowed": "",
  12080. "sSortJUIDescAllowed": "",
  12081. "sSortJUIWrapper": "",
  12082. "sSortIcon": "",
  12083. "sJUIHeader": "",
  12084. "sJUIFooter": ""
  12085. });
  12086. (function() {
  12087. // Reused strings for better compression. Closure compiler appears to have a
  12088. // weird edge case where it is trying to expand strings rather than use the
  12089. // variable version. This results in about 200 bytes being added, for very
  12090. // little preference benefit since it this run on script load only.
  12091. var _empty = '';
  12092. _empty = '';
  12093. var _stateDefault = _empty + 'ui-state-default';
  12094. var _sortIcon = _empty + 'css_right ui-icon ui-icon-';
  12095. var _headerFooter = _empty + 'fg-toolbar ui-toolbar ui-widget-header ui-helper-clearfix';
  12096. $.extend(DataTable.ext.oJUIClasses, DataTable.ext.classes, {
  12097. /* Full numbers paging buttons */
  12098. "sPageButton": "fg-button ui-button " + _stateDefault,
  12099. "sPageButtonActive": "ui-state-disabled",
  12100. "sPageButtonDisabled": "ui-state-disabled",
  12101. /* Features */
  12102. "sPaging": "dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi " +
  12103. "ui-buttonset-multi paging_",
  12104. /* Note that the type is postfixed */
  12105. /* Sorting */
  12106. "sSortAsc": _stateDefault + " sorting_asc",
  12107. "sSortDesc": _stateDefault + " sorting_desc",
  12108. "sSortable": _stateDefault + " sorting",
  12109. "sSortableAsc": _stateDefault + " sorting_asc_disabled",
  12110. "sSortableDesc": _stateDefault + " sorting_desc_disabled",
  12111. "sSortableNone": _stateDefault + " sorting_disabled",
  12112. "sSortJUIAsc": _sortIcon + "triangle-1-n",
  12113. "sSortJUIDesc": _sortIcon + "triangle-1-s",
  12114. "sSortJUI": _sortIcon + "carat-2-n-s",
  12115. "sSortJUIAscAllowed": _sortIcon + "carat-1-n",
  12116. "sSortJUIDescAllowed": _sortIcon + "carat-1-s",
  12117. "sSortJUIWrapper": "DataTables_sort_wrapper",
  12118. "sSortIcon": "DataTables_sort_icon",
  12119. /* Scrolling */
  12120. "sScrollHead": "dataTables_scrollHead " + _stateDefault,
  12121. "sScrollFoot": "dataTables_scrollFoot " + _stateDefault,
  12122. /* Misc */
  12123. "sHeaderTH": _stateDefault,
  12124. "sFooterTH": _stateDefault,
  12125. "sJUIHeader": _headerFooter + " ui-corner-tl ui-corner-tr",
  12126. "sJUIFooter": _headerFooter + " ui-corner-bl ui-corner-br"
  12127. });
  12128. }());
  12129. var extPagination = DataTable.ext.pager;
  12130. function _numbers(page, pages) {
  12131. var
  12132. numbers = [],
  12133. buttons = extPagination.numbers_length,
  12134. half = Math.floor(buttons / 2),
  12135. i = 1;
  12136. if (pages <= buttons) {
  12137. numbers = _range(0, pages);
  12138. } else if (page <= half) {
  12139. numbers = _range(0, buttons - 2);
  12140. numbers.push('ellipsis');
  12141. numbers.push(pages - 1);
  12142. } else if (page >= pages - 1 - half) {
  12143. numbers = _range(pages - (buttons - 2), pages);
  12144. numbers.splice(0, 0, 'ellipsis'); // no unshift in ie6
  12145. numbers.splice(0, 0, 0);
  12146. } else {
  12147. numbers = _range(page - half + 2, page + half - 1);
  12148. numbers.push('ellipsis');
  12149. numbers.push(pages - 1);
  12150. numbers.splice(0, 0, 'ellipsis');
  12151. numbers.splice(0, 0, 0);
  12152. }
  12153. numbers.DT_el = 'span';
  12154. return numbers;
  12155. }
  12156. $.extend(extPagination, {
  12157. simple: function(page, pages) {
  12158. return ['previous', 'next'];
  12159. },
  12160. full: function(page, pages) {
  12161. return ['first', 'previous', 'next', 'last'];
  12162. },
  12163. numbers: function(page, pages) {
  12164. return [_numbers(page, pages)];
  12165. },
  12166. simple_numbers: function(page, pages) {
  12167. return ['previous', _numbers(page, pages), 'next'];
  12168. },
  12169. full_numbers: function(page, pages) {
  12170. return ['first', 'previous', _numbers(page, pages), 'next', 'last'];
  12171. },
  12172. // For testing and plug-ins to use
  12173. _numbers: _numbers,
  12174. // Number of number buttons (including ellipsis) to show. _Must be odd!_
  12175. numbers_length: 7
  12176. });
  12177. $.extend(true, DataTable.ext.renderer, {
  12178. pageButton: {
  12179. _: function(settings, host, idx, buttons, page, pages) {
  12180. var classes = settings.oClasses;
  12181. var lang = settings.oLanguage.oPaginate;
  12182. var aria = settings.oLanguage.oAria.paginate || {};
  12183. var btnDisplay, btnClass, counter = 0;
  12184. var attach = function(container, buttons) {
  12185. var i, ien, node, button;
  12186. var clickHandler = function(e) {
  12187. _fnPageChange(settings, e.data.action, true);
  12188. };
  12189. for (i = 0, ien = buttons.length; i < ien; i++) {
  12190. button = buttons[i];
  12191. if ($.isArray(button)) {
  12192. var inner = $('<' + (button.DT_el || 'div') + '/>')
  12193. .appendTo(container);
  12194. attach(inner, button);
  12195. } else {
  12196. btnDisplay = null;
  12197. btnClass = '';
  12198. switch (button) {
  12199. case 'ellipsis':
  12200. container.append('<span class="ellipsis">&#x2026;</span>');
  12201. break;
  12202. case 'first':
  12203. btnDisplay = lang.sFirst;
  12204. btnClass = button + (page > 0 ?
  12205. '' : ' ' + classes.sPageButtonDisabled);
  12206. break;
  12207. case 'previous':
  12208. btnDisplay = lang.sPrevious;
  12209. btnClass = button + (page > 0 ?
  12210. '' : ' ' + classes.sPageButtonDisabled);
  12211. break;
  12212. case 'next':
  12213. btnDisplay = lang.sNext;
  12214. btnClass = button + (page < pages - 1 ?
  12215. '' : ' ' + classes.sPageButtonDisabled);
  12216. break;
  12217. case 'last':
  12218. btnDisplay = lang.sLast;
  12219. btnClass = button + (page < pages - 1 ?
  12220. '' : ' ' + classes.sPageButtonDisabled);
  12221. break;
  12222. default:
  12223. btnDisplay = button + 1;
  12224. btnClass = page === button ?
  12225. classes.sPageButtonActive : '';
  12226. break;
  12227. }
  12228. if (btnDisplay !== null) {
  12229. node = $('<a>', {
  12230. 'class': classes.sPageButton + ' ' + btnClass,
  12231. 'aria-controls': settings.sTableId,
  12232. 'aria-label': aria[button],
  12233. 'data-dt-idx': counter,
  12234. 'tabindex': settings.iTabIndex,
  12235. 'id': idx === 0 && typeof button === 'string' ?
  12236. settings.sTableId + '_' + button : null
  12237. })
  12238. .html(btnDisplay)
  12239. .appendTo(container);
  12240. _fnBindAction(
  12241. node, {
  12242. action: button
  12243. }, clickHandler
  12244. );
  12245. counter++;
  12246. }
  12247. }
  12248. }
  12249. };
  12250. // IE9 throws an 'unknown error' if document.activeElement is used
  12251. // inside an iframe or frame. Try / catch the error. Not good for
  12252. // accessibility, but neither are frames.
  12253. var activeEl;
  12254. try {
  12255. // Because this approach is destroying and recreating the paging
  12256. // elements, focus is lost on the select button which is bad for
  12257. // accessibility. So we want to restore focus once the draw has
  12258. // completed
  12259. activeEl = $(host).find(document.activeElement).data('dt-idx');
  12260. } catch (e) {}
  12261. attach($(host).empty(), buttons);
  12262. if (activeEl) {
  12263. $(host).find('[data-dt-idx=' + activeEl + ']').focus();
  12264. }
  12265. }
  12266. }
  12267. });
  12268. // Built in type detection. See model.ext.aTypes for information about
  12269. // what is required from this methods.
  12270. $.extend(DataTable.ext.type.detect, [
  12271. // Plain numbers - first since V8 detects some plain numbers as dates
  12272. // e.g. Date.parse('55') (but not all, e.g. Date.parse('22')...).
  12273. function(d, settings) {
  12274. var decimal = settings.oLanguage.sDecimal;
  12275. return _isNumber(d, decimal) ? 'num' + decimal : null;
  12276. },
  12277. // Dates (only those recognised by the browser's Date.parse)
  12278. function(d, settings) {
  12279. // V8 will remove any unknown characters at the start and end of the
  12280. // expression, leading to false matches such as `$245.12` or `10%` being
  12281. // a valid date. See forum thread 18941 for detail.
  12282. if (d && !(d instanceof Date) && (!_re_date_start.test(d) || !_re_date_end.test(d))) {
  12283. return null;
  12284. }
  12285. var parsed = Date.parse(d);
  12286. return (parsed !== null && !isNaN(parsed)) || _empty(d) ? 'date' : null;
  12287. },
  12288. // Formatted numbers
  12289. function(d, settings) {
  12290. var decimal = settings.oLanguage.sDecimal;
  12291. return _isNumber(d, decimal, true) ? 'num-fmt' + decimal : null;
  12292. },
  12293. // HTML numeric
  12294. function(d, settings) {
  12295. var decimal = settings.oLanguage.sDecimal;
  12296. return _htmlNumeric(d, decimal) ? 'html-num' + decimal : null;
  12297. },
  12298. // HTML numeric, formatted
  12299. function(d, settings) {
  12300. var decimal = settings.oLanguage.sDecimal;
  12301. return _htmlNumeric(d, decimal, true) ? 'html-num-fmt' + decimal : null;
  12302. },
  12303. // HTML (this is strict checking - there must be html)
  12304. function(d, settings) {
  12305. return _empty(d) || (typeof d === 'string' && d.indexOf('<') !== -1) ?
  12306. 'html' : null;
  12307. }
  12308. ]);
  12309. // Filter formatting functions. See model.ext.ofnSearch for information about
  12310. // what is required from these methods.
  12311. //
  12312. // Note that additional search methods are added for the html numbers and
  12313. // html formatted numbers by `_addNumericSort()` when we know what the decimal
  12314. // place is
  12315. $.extend(DataTable.ext.type.search, {
  12316. html: function(data) {
  12317. return _empty(data) ?
  12318. data :
  12319. typeof data === 'string' ?
  12320. data
  12321. .replace(_re_new_lines, " ")
  12322. .replace(_re_html, "") :
  12323. '';
  12324. },
  12325. string: function(data) {
  12326. return _empty(data) ?
  12327. data :
  12328. typeof data === 'string' ?
  12329. data.replace(_re_new_lines, " ") :
  12330. data;
  12331. }
  12332. });
  12333. var __numericReplace = function(d, decimalPlace, re1, re2) {
  12334. if (d !== 0 && (!d || d === '-')) {
  12335. return -Infinity;
  12336. }
  12337. // If a decimal place other than `.` is used, it needs to be given to the
  12338. // function so we can detect it and replace with a `.` which is the only
  12339. // decimal place Javascript recognises - it is not locale aware.
  12340. if (decimalPlace) {
  12341. d = _numToDecimal(d, decimalPlace);
  12342. }
  12343. if (d.replace) {
  12344. if (re1) {
  12345. d = d.replace(re1, '');
  12346. }
  12347. if (re2) {
  12348. d = d.replace(re2, '');
  12349. }
  12350. }
  12351. return d * 1;
  12352. };
  12353. // Add the numeric 'deformatting' functions for sorting and search. This is done
  12354. // in a function to provide an easy ability for the language options to add
  12355. // additional methods if a non-period decimal place is used.
  12356. function _addNumericSort(decimalPlace) {
  12357. $.each({
  12358. // Plain numbers
  12359. "num": function(d) {
  12360. return __numericReplace(d, decimalPlace);
  12361. },
  12362. // Formatted numbers
  12363. "num-fmt": function(d) {
  12364. return __numericReplace(d, decimalPlace, _re_formatted_numeric);
  12365. },
  12366. // HTML numeric
  12367. "html-num": function(d) {
  12368. return __numericReplace(d, decimalPlace, _re_html);
  12369. },
  12370. // HTML numeric, formatted
  12371. "html-num-fmt": function(d) {
  12372. return __numericReplace(d, decimalPlace, _re_html, _re_formatted_numeric);
  12373. }
  12374. },
  12375. function(key, fn) {
  12376. // Add the ordering method
  12377. _ext.type.order[key + decimalPlace + '-pre'] = fn;
  12378. // For HTML types add a search formatter that will strip the HTML
  12379. if (key.match(/^html\-/)) {
  12380. _ext.type.search[key + decimalPlace] = _ext.type.search.html;
  12381. }
  12382. }
  12383. );
  12384. }
  12385. // Default sort methods
  12386. $.extend(_ext.type.order, {
  12387. // Dates
  12388. "date-pre": function(d) {
  12389. return Date.parse(d) || 0;
  12390. },
  12391. // html
  12392. "html-pre": function(a) {
  12393. return _empty(a) ?
  12394. '' :
  12395. a.replace ?
  12396. a.replace(/<.*?>/g, "").toLowerCase() :
  12397. a + '';
  12398. },
  12399. // string
  12400. "string-pre": function(a) {
  12401. // This is a little complex, but faster than always calling toString,
  12402. // http://jsperf.com/tostring-v-check
  12403. return _empty(a) ?
  12404. '' :
  12405. typeof a === 'string' ?
  12406. a.toLowerCase() :
  12407. !a.toString ?
  12408. '' :
  12409. a.toString();
  12410. },
  12411. // string-asc and -desc are retained only for compatibility with the old
  12412. // sort methods
  12413. "string-asc": function(x, y) {
  12414. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12415. },
  12416. "string-desc": function(x, y) {
  12417. return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12418. }
  12419. });
  12420. // Numeric sorting types - order doesn't matter here
  12421. _addNumericSort('');
  12422. $.extend(true, DataTable.ext.renderer, {
  12423. header: {
  12424. _: function(settings, cell, column, classes) {
  12425. // No additional mark-up required
  12426. // Attach a sort listener to update on sort - note that using the
  12427. // `DT` namespace will allow the event to be removed automatically
  12428. // on destroy, while the `dt` namespaced event is the one we are
  12429. // listening for
  12430. $(settings.nTable).on('order.dt.DT', function(e, ctx, sorting, columns) {
  12431. if (settings !== ctx) { // need to check this this is the host
  12432. return; // table, not a nested one
  12433. }
  12434. var colIdx = column.idx;
  12435. cell
  12436. .removeClass(
  12437. column.sSortingClass + ' ' +
  12438. classes.sSortAsc + ' ' +
  12439. classes.sSortDesc
  12440. )
  12441. .addClass(columns[colIdx] == 'asc' ?
  12442. classes.sSortAsc : columns[colIdx] == 'desc' ?
  12443. classes.sSortDesc :
  12444. column.sSortingClass
  12445. );
  12446. });
  12447. },
  12448. jqueryui: function(settings, cell, column, classes) {
  12449. $('<div/>')
  12450. .addClass(classes.sSortJUIWrapper)
  12451. .append(cell.contents())
  12452. .append($('<span/>')
  12453. .addClass(classes.sSortIcon + ' ' + column.sSortingClassJUI)
  12454. )
  12455. .appendTo(cell);
  12456. // Attach a sort listener to update on sort
  12457. $(settings.nTable).on('order.dt.DT', function(e, ctx, sorting, columns) {
  12458. if (settings !== ctx) {
  12459. return;
  12460. }
  12461. var colIdx = column.idx;
  12462. cell
  12463. .removeClass(classes.sSortAsc + " " + classes.sSortDesc)
  12464. .addClass(columns[colIdx] == 'asc' ?
  12465. classes.sSortAsc : columns[colIdx] == 'desc' ?
  12466. classes.sSortDesc :
  12467. column.sSortingClass
  12468. );
  12469. cell
  12470. .find('span.' + classes.sSortIcon)
  12471. .removeClass(
  12472. classes.sSortJUIAsc + " " +
  12473. classes.sSortJUIDesc + " " +
  12474. classes.sSortJUI + " " +
  12475. classes.sSortJUIAscAllowed + " " +
  12476. classes.sSortJUIDescAllowed
  12477. )
  12478. .addClass(columns[colIdx] == 'asc' ?
  12479. classes.sSortJUIAsc : columns[colIdx] == 'desc' ?
  12480. classes.sSortJUIDesc :
  12481. column.sSortingClassJUI
  12482. );
  12483. });
  12484. }
  12485. }
  12486. });
  12487. /*
  12488. * Public helper functions. These aren't used internally by DataTables, or
  12489. * called by any of the options passed into DataTables, but they can be used
  12490. * externally by developers working with DataTables. They are helper functions
  12491. * to make working with DataTables a little bit easier.
  12492. */
  12493. var __htmlEscapeEntities = function(d) {
  12494. return typeof d === 'string' ?
  12495. d.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;') :
  12496. d;
  12497. };
  12498. /**
  12499. * Helpers for `columns.render`.
  12500. *
  12501. * The options defined here can be used with the `columns.render` initialisation
  12502. * option to provide a display renderer. The following functions are defined:
  12503. *
  12504. * * `number` - Will format numeric data (defined by `columns.data`) for
  12505. * display, retaining the original unformatted data for sorting and filtering.
  12506. * It takes 5 parameters:
  12507. * * `string` - Thousands grouping separator
  12508. * * `string` - Decimal point indicator
  12509. * * `integer` - Number of decimal points to show
  12510. * * `string` (optional) - Prefix.
  12511. * * `string` (optional) - Postfix (/suffix).
  12512. * * `text` - Escape HTML to help prevent XSS attacks. It has no optional
  12513. * parameters.
  12514. *
  12515. * @example
  12516. * // Column definition using the number renderer
  12517. * {
  12518. * data: "salary",
  12519. * render: $.fn.dataTable.render.number( '\'', '.', 0, '$' )
  12520. * }
  12521. *
  12522. * @namespace
  12523. */
  12524. DataTable.render = {
  12525. number: function(thousands, decimal, precision, prefix, postfix) {
  12526. return {
  12527. display: function(d) {
  12528. if (typeof d !== 'number' && typeof d !== 'string') {
  12529. return d;
  12530. }
  12531. var negative = d < 0 ? '-' : '';
  12532. var flo = parseFloat(d);
  12533. // If NaN then there isn't much formatting that we can do - just
  12534. // return immediately, escaping any HTML (this was supposed to
  12535. // be a number after all)
  12536. if (isNaN(flo)) {
  12537. return __htmlEscapeEntities(d);
  12538. }
  12539. d = Math.abs(flo);
  12540. var intPart = parseInt(d, 10);
  12541. var floatPart = precision ?
  12542. decimal + (d - intPart).toFixed(precision).substring(2) :
  12543. '';
  12544. return negative + (prefix || '') +
  12545. intPart.toString().replace(
  12546. /\B(?=(\d{3})+(?!\d))/g, thousands
  12547. ) +
  12548. floatPart +
  12549. (postfix || '');
  12550. }
  12551. };
  12552. },
  12553. text: function() {
  12554. return {
  12555. display: __htmlEscapeEntities
  12556. };
  12557. }
  12558. };
  12559. /*
  12560. * This is really a good bit rubbish this method of exposing the internal methods
  12561. * publicly... - To be fixed in 2.0 using methods on the prototype
  12562. */
  12563. /**
  12564. * Create a wrapper function for exporting an internal functions to an external API.
  12565. * @param {string} fn API function name
  12566. * @returns {function} wrapped function
  12567. * @memberof DataTable#internal
  12568. */
  12569. function _fnExternApiFunc(fn) {
  12570. return function() {
  12571. var args = [_fnSettingsFromNode(this[DataTable.ext.iApiIndex])].concat(
  12572. Array.prototype.slice.call(arguments)
  12573. );
  12574. return DataTable.ext.internal[fn].apply(this, args);
  12575. };
  12576. }
  12577. /**
  12578. * Reference to internal functions for use by plug-in developers. Note that
  12579. * these methods are references to internal functions and are considered to be
  12580. * private. If you use these methods, be aware that they are liable to change
  12581. * between versions.
  12582. * @namespace
  12583. */
  12584. $.extend(DataTable.ext.internal, {
  12585. _fnExternApiFunc: _fnExternApiFunc,
  12586. _fnBuildAjax: _fnBuildAjax,
  12587. _fnAjaxUpdate: _fnAjaxUpdate,
  12588. _fnAjaxParameters: _fnAjaxParameters,
  12589. _fnAjaxUpdateDraw: _fnAjaxUpdateDraw,
  12590. _fnAjaxDataSrc: _fnAjaxDataSrc,
  12591. _fnAddColumn: _fnAddColumn,
  12592. _fnColumnOptions: _fnColumnOptions,
  12593. _fnAdjustColumnSizing: _fnAdjustColumnSizing,
  12594. _fnVisibleToColumnIndex: _fnVisibleToColumnIndex,
  12595. _fnColumnIndexToVisible: _fnColumnIndexToVisible,
  12596. _fnVisbleColumns: _fnVisbleColumns,
  12597. _fnGetColumns: _fnGetColumns,
  12598. _fnColumnTypes: _fnColumnTypes,
  12599. _fnApplyColumnDefs: _fnApplyColumnDefs,
  12600. _fnHungarianMap: _fnHungarianMap,
  12601. _fnCamelToHungarian: _fnCamelToHungarian,
  12602. _fnLanguageCompat: _fnLanguageCompat,
  12603. _fnBrowserDetect: _fnBrowserDetect,
  12604. _fnAddData: _fnAddData,
  12605. _fnAddTr: _fnAddTr,
  12606. _fnNodeToDataIndex: _fnNodeToDataIndex,
  12607. _fnNodeToColumnIndex: _fnNodeToColumnIndex,
  12608. _fnGetCellData: _fnGetCellData,
  12609. _fnSetCellData: _fnSetCellData,
  12610. _fnSplitObjNotation: _fnSplitObjNotation,
  12611. _fnGetObjectDataFn: _fnGetObjectDataFn,
  12612. _fnSetObjectDataFn: _fnSetObjectDataFn,
  12613. _fnGetDataMaster: _fnGetDataMaster,
  12614. _fnClearTable: _fnClearTable,
  12615. _fnDeleteIndex: _fnDeleteIndex,
  12616. _fnInvalidate: _fnInvalidate,
  12617. _fnGetRowElements: _fnGetRowElements,
  12618. _fnCreateTr: _fnCreateTr,
  12619. _fnBuildHead: _fnBuildHead,
  12620. _fnDrawHead: _fnDrawHead,
  12621. _fnDraw: _fnDraw,
  12622. _fnReDraw: _fnReDraw,
  12623. _fnAddOptionsHtml: _fnAddOptionsHtml,
  12624. _fnDetectHeader: _fnDetectHeader,
  12625. _fnGetUniqueThs: _fnGetUniqueThs,
  12626. _fnFeatureHtmlFilter: _fnFeatureHtmlFilter,
  12627. _fnFilterComplete: _fnFilterComplete,
  12628. _fnFilterCustom: _fnFilterCustom,
  12629. _fnFilterColumn: _fnFilterColumn,
  12630. _fnFilter: _fnFilter,
  12631. _fnFilterCreateSearch: _fnFilterCreateSearch,
  12632. _fnEscapeRegex: _fnEscapeRegex,
  12633. _fnFilterData: _fnFilterData,
  12634. _fnFeatureHtmlInfo: _fnFeatureHtmlInfo,
  12635. _fnUpdateInfo: _fnUpdateInfo,
  12636. _fnInfoMacros: _fnInfoMacros,
  12637. _fnInitialise: _fnInitialise,
  12638. _fnInitComplete: _fnInitComplete,
  12639. _fnLengthChange: _fnLengthChange,
  12640. _fnFeatureHtmlLength: _fnFeatureHtmlLength,
  12641. _fnFeatureHtmlPaginate: _fnFeatureHtmlPaginate,
  12642. _fnPageChange: _fnPageChange,
  12643. _fnFeatureHtmlProcessing: _fnFeatureHtmlProcessing,
  12644. _fnProcessingDisplay: _fnProcessingDisplay,
  12645. _fnFeatureHtmlTable: _fnFeatureHtmlTable,
  12646. _fnScrollDraw: _fnScrollDraw,
  12647. _fnApplyToChildren: _fnApplyToChildren,
  12648. _fnCalculateColumnWidths: _fnCalculateColumnWidths,
  12649. _fnThrottle: _fnThrottle,
  12650. _fnConvertToWidth: _fnConvertToWidth,
  12651. _fnGetWidestNode: _fnGetWidestNode,
  12652. _fnGetMaxLenString: _fnGetMaxLenString,
  12653. _fnStringToCss: _fnStringToCss,
  12654. _fnSortFlatten: _fnSortFlatten,
  12655. _fnSort: _fnSort,
  12656. _fnSortAria: _fnSortAria,
  12657. _fnSortListener: _fnSortListener,
  12658. _fnSortAttachListener: _fnSortAttachListener,
  12659. _fnSortingClasses: _fnSortingClasses,
  12660. _fnSortData: _fnSortData,
  12661. _fnSaveState: _fnSaveState,
  12662. _fnLoadState: _fnLoadState,
  12663. _fnSettingsFromNode: _fnSettingsFromNode,
  12664. _fnLog: _fnLog,
  12665. _fnMap: _fnMap,
  12666. _fnBindAction: _fnBindAction,
  12667. _fnCallbackReg: _fnCallbackReg,
  12668. _fnCallbackFire: _fnCallbackFire,
  12669. _fnLengthOverflow: _fnLengthOverflow,
  12670. _fnRenderer: _fnRenderer,
  12671. _fnDataSource: _fnDataSource,
  12672. _fnRowAttributes: _fnRowAttributes,
  12673. _fnCalculateEnd: function() {} // Used by a lot of plug-ins, but redundant
  12674. // in 1.10, so this dead-end function is
  12675. // added to prevent errors
  12676. });
  12677. // jQuery access
  12678. $.fn.dataTable = DataTable;
  12679. // Provide access to the host jQuery object (circular reference)
  12680. DataTable.$ = $;
  12681. // Legacy aliases
  12682. $.fn.dataTableSettings = DataTable.settings;
  12683. $.fn.dataTableExt = DataTable.ext;
  12684. // With a capital `D` we return a DataTables API instance rather than a
  12685. // jQuery object
  12686. $.fn.DataTable = function(opts) {
  12687. return $(this).dataTable(opts).api();
  12688. };
  12689. // All properties that are available to $.fn.dataTable should also be
  12690. // available on $.fn.DataTable
  12691. $.each(DataTable, function(prop, val) {
  12692. $.fn.DataTable[prop] = val;
  12693. });
  12694. // Information about events fired by DataTables - for documentation.
  12695. /**
  12696. * Draw event, fired whenever the table is redrawn on the page, at the same
  12697. * point as fnDrawCallback. This may be useful for binding events or
  12698. * performing calculations when the table is altered at all.
  12699. * @name DataTable#draw.dt
  12700. * @event
  12701. * @param {event} e jQuery event object
  12702. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12703. */
  12704. /**
  12705. * Search event, fired when the searching applied to the table (using the
  12706. * built-in global search, or column filters) is altered.
  12707. * @name DataTable#search.dt
  12708. * @event
  12709. * @param {event} e jQuery event object
  12710. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12711. */
  12712. /**
  12713. * Page change event, fired when the paging of the table is altered.
  12714. * @name DataTable#page.dt
  12715. * @event
  12716. * @param {event} e jQuery event object
  12717. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12718. */
  12719. /**
  12720. * Order event, fired when the ordering applied to the table is altered.
  12721. * @name DataTable#order.dt
  12722. * @event
  12723. * @param {event} e jQuery event object
  12724. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12725. */
  12726. /**
  12727. * DataTables initialisation complete event, fired when the table is fully
  12728. * drawn, including Ajax data loaded, if Ajax data is required.
  12729. * @name DataTable#init.dt
  12730. * @event
  12731. * @param {event} e jQuery event object
  12732. * @param {object} oSettings DataTables settings object
  12733. * @param {object} json The JSON object request from the server - only
  12734. * present if client-side Ajax sourced data is used</li></ol>
  12735. */
  12736. /**
  12737. * State save event, fired when the table has changed state a new state save
  12738. * is required. This event allows modification of the state saving object
  12739. * prior to actually doing the save, including addition or other state
  12740. * properties (for plug-ins) or modification of a DataTables core property.
  12741. * @name DataTable#stateSaveParams.dt
  12742. * @event
  12743. * @param {event} e jQuery event object
  12744. * @param {object} oSettings DataTables settings object
  12745. * @param {object} json The state information to be saved
  12746. */
  12747. /**
  12748. * State load event, fired when the table is loading state from the stored
  12749. * data, but prior to the settings object being modified by the saved state
  12750. * - allowing modification of the saved state is required or loading of
  12751. * state for a plug-in.
  12752. * @name DataTable#stateLoadParams.dt
  12753. * @event
  12754. * @param {event} e jQuery event object
  12755. * @param {object} oSettings DataTables settings object
  12756. * @param {object} json The saved state information
  12757. */
  12758. /**
  12759. * State loaded event, fired when state has been loaded from stored data and
  12760. * the settings object has been modified by the loaded data.
  12761. * @name DataTable#stateLoaded.dt
  12762. * @event
  12763. * @param {event} e jQuery event object
  12764. * @param {object} oSettings DataTables settings object
  12765. * @param {object} json The saved state information
  12766. */
  12767. /**
  12768. * Processing event, fired when DataTables is doing some kind of processing
  12769. * (be it, order, searcg or anything else). It can be used to indicate to
  12770. * the end user that there is something happening, or that something has
  12771. * finished.
  12772. * @name DataTable#processing.dt
  12773. * @event
  12774. * @param {event} e jQuery event object
  12775. * @param {object} oSettings DataTables settings object
  12776. * @param {boolean} bShow Flag for if DataTables is doing processing or not
  12777. */
  12778. /**
  12779. * Ajax (XHR) event, fired whenever an Ajax request is completed from a
  12780. * request to made to the server for new data. This event is called before
  12781. * DataTables processed the returned data, so it can also be used to pre-
  12782. * process the data returned from the server, if needed.
  12783. *
  12784. * Note that this trigger is called in `fnServerData`, if you override
  12785. * `fnServerData` and which to use this event, you need to trigger it in you
  12786. * success function.
  12787. * @name DataTable#xhr.dt
  12788. * @event
  12789. * @param {event} e jQuery event object
  12790. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12791. * @param {object} json JSON returned from the server
  12792. *
  12793. * @example
  12794. * // Use a custom property returned from the server in another DOM element
  12795. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  12796. * $('#status').html( json.status );
  12797. * } );
  12798. *
  12799. * @example
  12800. * // Pre-process the data returned from the server
  12801. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  12802. * for ( var i=0, ien=json.aaData.length ; i<ien ; i++ ) {
  12803. * json.aaData[i].sum = json.aaData[i].one + json.aaData[i].two;
  12804. * }
  12805. * // Note no return - manipulate the data directly in the JSON object.
  12806. * } );
  12807. */
  12808. /**
  12809. * Destroy event, fired when the DataTable is destroyed by calling fnDestroy
  12810. * or passing the bDestroy:true parameter in the initialisation object. This
  12811. * can be used to remove bound events, added DOM nodes, etc.
  12812. * @name DataTable#destroy.dt
  12813. * @event
  12814. * @param {event} e jQuery event object
  12815. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12816. */
  12817. /**
  12818. * Page length change event, fired when number of records to show on each
  12819. * page (the length) is changed.
  12820. * @name DataTable#length.dt
  12821. * @event
  12822. * @param {event} e jQuery event object
  12823. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12824. * @param {integer} len New length
  12825. */
  12826. /**
  12827. * Column sizing has changed.
  12828. * @name DataTable#column-sizing.dt
  12829. * @event
  12830. * @param {event} e jQuery event object
  12831. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12832. */
  12833. /**
  12834. * Column visibility has changed.
  12835. * @name DataTable#column-visibility.dt
  12836. * @event
  12837. * @param {event} e jQuery event object
  12838. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12839. * @param {int} column Column index
  12840. * @param {bool} vis `false` if column now hidden, or `true` if visible
  12841. */
  12842. return $.fn.dataTable;
  12843. }));
  12844. /*! DataTables Bootstrap 3 integration
  12845. * ©2011-2015 SpryMedia Ltd - datatables.net/license
  12846. */
  12847. /**
  12848. * DataTables integration for Bootstrap 3. This requires Bootstrap 3 and
  12849. * DataTables 1.10 or newer.
  12850. *
  12851. * This file sets the defaults and adds options to DataTables to style its
  12852. * controls using Bootstrap. See http://datatables.net/manual/styling/bootstrap
  12853. * for further information.
  12854. */
  12855. (function(factory) {
  12856. if (typeof define === 'function' && define.amd) {
  12857. // AMD
  12858. define(['jquery', 'datatables.net'], function($) {
  12859. return factory($, window, document);
  12860. });
  12861. } else if (typeof exports === 'object') {
  12862. // CommonJS
  12863. module.exports = function(root, $) {
  12864. if (!root) {
  12865. root = window;
  12866. }
  12867. if (!$ || !$.fn.dataTable) {
  12868. // Require DataTables, which attaches to jQuery, including
  12869. // jQuery if needed and have a $ property so we can access the
  12870. // jQuery object that is used
  12871. $ = require('datatables.net')(root, $).$;
  12872. }
  12873. return factory($, root, root.document);
  12874. };
  12875. } else {
  12876. // Browser
  12877. factory(jQuery, window, document);
  12878. }
  12879. }(function($, window, document, undefined) {
  12880. 'use strict';
  12881. var DataTable = $.fn.dataTable;
  12882. /* Set the defaults for DataTables initialisation */
  12883. $.extend(true, DataTable.defaults, {
  12884. dom: "<'row'<'col-sm-6'l><'col-sm-6'f>>" +
  12885. "<'row'<'col-sm-12'tr>>" +
  12886. "<'row'<'col-sm-5'i><'col-sm-7'p>>",
  12887. renderer: 'bootstrap'
  12888. });
  12889. /* Default class modification */
  12890. $.extend(DataTable.ext.classes, {
  12891. sWrapper: "dataTables_wrapper form-inline dt-bootstrap",
  12892. sFilterInput: "form-control input-sm",
  12893. sLengthSelect: "form-control input-sm",
  12894. sProcessing: "dataTables_processing panel panel-default"
  12895. });
  12896. /* Bootstrap paging button renderer */
  12897. DataTable.ext.renderer.pageButton.bootstrap = function(settings, host, idx, buttons, page, pages) {
  12898. var api = new DataTable.Api(settings);
  12899. var classes = settings.oClasses;
  12900. var lang = settings.oLanguage.oPaginate;
  12901. var aria = settings.oLanguage.oAria.paginate || {};
  12902. var btnDisplay, btnClass, counter = 0;
  12903. var attach = function(container, buttons) {
  12904. var i, ien, node, button;
  12905. var clickHandler = function(e) {
  12906. e.preventDefault();
  12907. if (!$(e.currentTarget).hasClass('disabled') && api.page() != e.data.action) {
  12908. api.page(e.data.action).draw('page');
  12909. }
  12910. };
  12911. for (i = 0, ien = buttons.length; i < ien; i++) {
  12912. button = buttons[i];
  12913. if ($.isArray(button)) {
  12914. attach(container, button);
  12915. } else {
  12916. btnDisplay = '';
  12917. btnClass = '';
  12918. switch (button) {
  12919. case 'ellipsis':
  12920. btnDisplay = '&#x2026;';
  12921. btnClass = 'disabled';
  12922. break;
  12923. case 'first':
  12924. btnDisplay = lang.sFirst;
  12925. btnClass = button + (page > 0 ?
  12926. '' : ' disabled');
  12927. break;
  12928. case 'previous':
  12929. btnDisplay = lang.sPrevious;
  12930. btnClass = button + (page > 0 ?
  12931. '' : ' disabled');
  12932. break;
  12933. case 'next':
  12934. btnDisplay = lang.sNext;
  12935. btnClass = button + (page < pages - 1 ?
  12936. '' : ' disabled');
  12937. break;
  12938. case 'last':
  12939. btnDisplay = lang.sLast;
  12940. btnClass = button + (page < pages - 1 ?
  12941. '' : ' disabled');
  12942. break;
  12943. default:
  12944. btnDisplay = button + 1;
  12945. btnClass = page === button ?
  12946. 'active' : '';
  12947. break;
  12948. }
  12949. if (btnDisplay) {
  12950. node = $('<li>', {
  12951. 'class': classes.sPageButton + ' ' + btnClass,
  12952. 'id': idx === 0 && typeof button === 'string' ?
  12953. settings.sTableId + '_' + button : null
  12954. })
  12955. .append($('<a>', {
  12956. 'href': '#',
  12957. 'aria-controls': settings.sTableId,
  12958. 'aria-label': aria[button],
  12959. 'data-dt-idx': counter,
  12960. 'tabindex': settings.iTabIndex
  12961. })
  12962. .html(btnDisplay)
  12963. )
  12964. .appendTo(container);
  12965. settings.oApi._fnBindAction(
  12966. node, {
  12967. action: button
  12968. }, clickHandler
  12969. );
  12970. counter++;
  12971. }
  12972. }
  12973. }
  12974. };
  12975. // IE9 throws an 'unknown error' if document.activeElement is used
  12976. // inside an iframe or frame.
  12977. var activeEl;
  12978. try {
  12979. // Because this approach is destroying and recreating the paging
  12980. // elements, focus is lost on the select button which is bad for
  12981. // accessibility. So we want to restore focus once the draw has
  12982. // completed
  12983. activeEl = $(host).find(document.activeElement).data('dt-idx');
  12984. } catch (e) {}
  12985. attach(
  12986. $(host).empty().html('<ul class="pagination"/>').children('ul'),
  12987. buttons
  12988. );
  12989. if (activeEl) {
  12990. $(host).find('[data-dt-idx=' + activeEl + ']').focus();
  12991. }
  12992. };
  12993. return DataTable;
  12994. }));
  12995. /*!
  12996. Responsive 2.1.0
  12997. 2014-2016 SpryMedia Ltd - datatables.net/license
  12998. */
  12999. (function(c) {
  13000. "function" === typeof define && define.amd ? define(["jquery", "datatables.net"], function(l) {
  13001. return c(l, window, document)
  13002. }) : "object" === typeof exports ? module.exports = function(l, k) {
  13003. l || (l = window);
  13004. if (!k || !k.fn.dataTable) k = require("datatables.net")(l, k).$;
  13005. return c(k, l, l.document)
  13006. } : c(jQuery, window, document)
  13007. })(function(c, l, k, p) {
  13008. var m = c.fn.dataTable,
  13009. j = function(a, b) {
  13010. if (!m.versionCheck || !m.versionCheck("1.10.3")) throw "DataTables Responsive requires DataTables 1.10.3 or newer";
  13011. this.s = {
  13012. dt: new m.Api(a),
  13013. columns: [],
  13014. current: []
  13015. };
  13016. this.s.dt.settings()[0].responsive || (b && "string" === typeof b.details ? b.details = {
  13017. type: b.details
  13018. } : b && !1 === b.details ? b.details = {
  13019. type: !1
  13020. } : b && !0 === b.details && (b.details = {
  13021. type: "inline"
  13022. }), this.c = c.extend(!0, {}, j.defaults, m.defaults.responsive, b), a.responsive = this, this._constructor())
  13023. };
  13024. c.extend(j.prototype, {
  13025. _constructor: function() {
  13026. var a = this,
  13027. b = this.s.dt,
  13028. d = b.settings()[0],
  13029. e = c(l).width();
  13030. b.settings()[0]._responsive = this;
  13031. c(l).on("resize.dtr orientationchange.dtr", m.util.throttle(function() {
  13032. var b =
  13033. c(l).width();
  13034. b !== e && (a._resize(), e = b)
  13035. }));
  13036. d.oApi._fnCallbackReg(d, "aoRowCreatedCallback", function(e) {
  13037. -1 !== c.inArray(!1, a.s.current) && c("td, th", e).each(function(e) {
  13038. e = b.column.index("toData", e);
  13039. !1 === a.s.current[e] && c(this).css("display", "none")
  13040. })
  13041. });
  13042. b.on("destroy.dtr", function() {
  13043. b.off(".dtr");
  13044. c(b.table().body()).off(".dtr");
  13045. c(l).off("resize.dtr orientationchange.dtr");
  13046. c.each(a.s.current, function(b, e) {
  13047. !1 === e && a._setColumnVis(b, !0)
  13048. })
  13049. });
  13050. this.c.breakpoints.sort(function(a, b) {
  13051. return a.width < b.width ? 1 : a.width >
  13052. b.width ? -1 : 0
  13053. });
  13054. this._classLogic();
  13055. this._resizeAuto();
  13056. d = this.c.details;
  13057. !1 !== d.type && (a._detailsInit(), b.on("column-visibility.dtr", function() {
  13058. a._classLogic();
  13059. a._resizeAuto();
  13060. a._resize()
  13061. }), b.on("draw.dtr", function() {
  13062. a._redrawChildren()
  13063. }), c(b.table().node()).addClass("dtr-" + d.type));
  13064. b.on("column-reorder.dtr", function() {
  13065. a._classLogic();
  13066. a._resizeAuto();
  13067. a._resize()
  13068. });
  13069. b.on("column-sizing.dtr", function() {
  13070. a._resizeAuto();
  13071. a._resize()
  13072. });
  13073. b.on("init.dtr", function() {
  13074. a._resizeAuto();
  13075. a._resize();
  13076. c.inArray(false,
  13077. a.s.current) && b.columns.adjust()
  13078. });
  13079. this._resize()
  13080. },
  13081. _columnsVisiblity: function(a) {
  13082. var b = this.s.dt,
  13083. d = this.s.columns,
  13084. e, f, g = d.map(function(a, b) {
  13085. return {
  13086. columnIdx: b,
  13087. priority: a.priority
  13088. }
  13089. }).sort(function(a, b) {
  13090. return a.priority !== b.priority ? a.priority - b.priority : a.columnIdx - b.columnIdx
  13091. }),
  13092. h = c.map(d, function(b) {
  13093. return b.auto && null === b.minWidth ? !1 : !0 === b.auto ? "-" : -1 !== c.inArray(a, b.includeIn)
  13094. }),
  13095. n = 0;
  13096. e = 0;
  13097. for (f = h.length; e < f; e++) !0 === h[e] && (n += d[e].minWidth);
  13098. e = b.settings()[0].oScroll;
  13099. e = e.sY || e.sX ? e.iBarWidth : 0;
  13100. b =
  13101. b.table().container().offsetWidth - e - n;
  13102. e = 0;
  13103. for (f = h.length; e < f; e++) d[e].control && (b -= d[e].minWidth);
  13104. n = !1;
  13105. e = 0;
  13106. for (f = g.length; e < f; e++) {
  13107. var i = g[e].columnIdx;
  13108. "-" === h[i] && (!d[i].control && d[i].minWidth) && (n || 0 > b - d[i].minWidth ? (n = !0, h[i] = !1) : h[i] = !0, b -= d[i].minWidth)
  13109. }
  13110. g = !1;
  13111. e = 0;
  13112. for (f = d.length; e < f; e++)
  13113. if (!d[e].control && !d[e].never && !h[e]) {
  13114. g = !0;
  13115. break
  13116. }
  13117. e = 0;
  13118. for (f = d.length; e < f; e++) d[e].control && (h[e] = g); - 1 === c.inArray(!0, h) && (h[0] = !0);
  13119. return h
  13120. },
  13121. _classLogic: function() {
  13122. var a = this,
  13123. b = this.c.breakpoints,
  13124. d = this.s.dt,
  13125. e =
  13126. d.columns().eq(0).map(function(a) {
  13127. var b = this.column(a),
  13128. e = b.header().className,
  13129. a = d.settings()[0].aoColumns[a].responsivePriority;
  13130. a === p && (b = c(b.header()).data("priority"), a = b !== p ? 1 * b : 1E4);
  13131. return {
  13132. className: e,
  13133. includeIn: [],
  13134. auto: !1,
  13135. control: !1,
  13136. never: e.match(/\bnever\b/) ? !0 : !1,
  13137. priority: a
  13138. }
  13139. }),
  13140. f = function(a, b) {
  13141. var d = e[a].includeIn; - 1 === c.inArray(b, d) && d.push(b)
  13142. },
  13143. g = function(c, d, i, g) {
  13144. if (i)
  13145. if ("max-" === i) {
  13146. g = a._find(d).width;
  13147. d = 0;
  13148. for (i = b.length; d < i; d++) b[d].width <= g && f(c, b[d].name)
  13149. } else if ("min-" === i) {
  13150. g = a._find(d).width;
  13151. d = 0;
  13152. for (i = b.length; d < i; d++) b[d].width >= g && f(c, b[d].name)
  13153. } else {
  13154. if ("not-" === i) {
  13155. d = 0;
  13156. for (i = b.length; d < i; d++) - 1 === b[d].name.indexOf(g) && f(c, b[d].name)
  13157. }
  13158. } else e[c].includeIn.push(d)
  13159. };
  13160. e.each(function(a, e) {
  13161. for (var d = a.className.split(" "), f = !1, j = 0, l = d.length; j < l; j++) {
  13162. var k = c.trim(d[j]);
  13163. if ("all" === k) {
  13164. f = !0;
  13165. a.includeIn = c.map(b, function(a) {
  13166. return a.name
  13167. });
  13168. return
  13169. }
  13170. if ("none" === k || a.never) {
  13171. f = !0;
  13172. return
  13173. }
  13174. if ("control" === k) {
  13175. f = !0;
  13176. a.control = !0;
  13177. return
  13178. }
  13179. c.each(b, function(a, b) {
  13180. var d = b.name.split("-"),
  13181. c = k.match(RegExp("(min\\-|max\\-|not\\-)?(" +
  13182. d[0] + ")(\\-[_a-zA-Z0-9])?"));
  13183. c && (f = !0, c[2] === d[0] && c[3] === "-" + d[1] ? g(e, b.name, c[1], c[2] + c[3]) : c[2] === d[0] && !c[3] && g(e, b.name, c[1], c[2]))
  13184. })
  13185. }
  13186. f || (a.auto = !0)
  13187. });
  13188. this.s.columns = e
  13189. },
  13190. _detailsDisplay: function(a, b) {
  13191. var d = this,
  13192. e = this.s.dt,
  13193. f = this.c.details;
  13194. if (f && !1 !== f.type) {
  13195. var g = f.display(a, b, function() {
  13196. return f.renderer(e, a[0], d._detailsObj(a[0]))
  13197. });
  13198. (!0 === g || !1 === g) && c(e.table().node()).triggerHandler("responsive-display.dt", [e, a, g, b])
  13199. }
  13200. },
  13201. _detailsInit: function() {
  13202. var a = this,
  13203. b = this.s.dt,
  13204. d = this.c.details;
  13205. "inline" ===
  13206. d.type && (d.target = "td:first-child, th:first-child");
  13207. b.on("draw.dtr", function() {
  13208. a._tabIndexes()
  13209. });
  13210. a._tabIndexes();
  13211. c(b.table().body()).on("keyup.dtr", "td, th", function(a) {
  13212. a.keyCode === 13 && c(this).data("dtr-keyboard") && c(this).click()
  13213. });
  13214. var e = d.target;
  13215. c(b.table().body()).on("click.dtr mousedown.dtr mouseup.dtr", "string" === typeof e ? e : "td, th", function(d) {
  13216. if (c(b.table().node()).hasClass("collapsed") && b.row(c(this).closest("tr")).length) {
  13217. if (typeof e === "number") {
  13218. var g = e < 0 ? b.columns().eq(0).length + e : e;
  13219. if (b.cell(this).index().column !==
  13220. g) return
  13221. }
  13222. g = b.row(c(this).closest("tr"));
  13223. d.type === "click" ? a._detailsDisplay(g, false) : d.type === "mousedown" ? c(this).css("outline", "none") : d.type === "mouseup" && c(this).blur().css("outline", "")
  13224. }
  13225. })
  13226. },
  13227. _detailsObj: function(a) {
  13228. var b = this,
  13229. d = this.s.dt;
  13230. return c.map(this.s.columns, function(e, c) {
  13231. if (!e.never && !e.control) return {
  13232. title: d.settings()[0].aoColumns[c].sTitle,
  13233. data: d.cell(a, c).render(b.c.orthogonal),
  13234. hidden: d.column(c).visible() && !b.s.current[c],
  13235. columnIndex: c,
  13236. rowIndex: a
  13237. }
  13238. })
  13239. },
  13240. _find: function(a) {
  13241. for (var b = this.c.breakpoints,
  13242. d = 0, c = b.length; d < c; d++)
  13243. if (b[d].name === a) return b[d]
  13244. },
  13245. _redrawChildren: function() {
  13246. var a = this,
  13247. b = this.s.dt;
  13248. b.rows({
  13249. page: "current"
  13250. }).iterator("row", function(c, e) {
  13251. b.row(e);
  13252. a._detailsDisplay(b.row(e), !0)
  13253. })
  13254. },
  13255. _resize: function() {
  13256. var a = this,
  13257. b = this.s.dt,
  13258. d = c(l).width(),
  13259. e = this.c.breakpoints,
  13260. f = e[0].name,
  13261. g = this.s.columns,
  13262. h, j = this.s.current.slice();
  13263. for (h = e.length - 1; 0 <= h; h--)
  13264. if (d <= e[h].width) {
  13265. f = e[h].name;
  13266. break
  13267. }
  13268. var i = this._columnsVisiblity(f);
  13269. this.s.current = i;
  13270. e = !1;
  13271. h = 0;
  13272. for (d = g.length; h < d; h++)
  13273. if (!1 === i[h] && !g[h].never &&
  13274. !g[h].control) {
  13275. e = !0;
  13276. break
  13277. }
  13278. c(b.table().node()).toggleClass("collapsed", e);
  13279. var k = !1;
  13280. b.columns().eq(0).each(function(b, c) {
  13281. i[c] !== j[c] && (k = !0, a._setColumnVis(b, i[c]))
  13282. });
  13283. k && (this._redrawChildren(), c(b.table().node()).trigger("responsive-resize.dt", [b, this.s.current]))
  13284. },
  13285. _resizeAuto: function() {
  13286. var a = this.s.dt,
  13287. b = this.s.columns;
  13288. if (this.c.auto && -1 !== c.inArray(!0, c.map(b, function(a) {
  13289. return a.auto
  13290. }))) {
  13291. a.table().node();
  13292. var d = a.table().node().cloneNode(!1),
  13293. e = c(a.table().header().cloneNode(!1)).appendTo(d),
  13294. f = c(a.table().body()).clone(!1, !1).empty().appendTo(d),
  13295. g = a.columns().header().filter(function(b) {
  13296. return a.column(b).visible()
  13297. }).to$().clone(!1).css("display", "table-cell");
  13298. c(f).append(c(a.rows({
  13299. page: "current"
  13300. }).nodes()).clone(!1)).find("th, td").css("display", "");
  13301. if (f = a.table().footer()) {
  13302. var f = c(f.cloneNode(!1)).appendTo(d),
  13303. h = a.columns().footer().filter(function(b) {
  13304. return a.column(b).visible()
  13305. }).to$().clone(!1).css("display", "table-cell");
  13306. c("<tr/>").append(h).appendTo(f)
  13307. }
  13308. c("<tr/>").append(g).appendTo(e);
  13309. "inline" === this.c.details.type &&
  13310. c(d).addClass("dtr-inline collapsed");
  13311. c(d).find("[name]").removeAttr("name");
  13312. d = c("<div/>").css({
  13313. width: 1,
  13314. height: 1,
  13315. overflow: "hidden"
  13316. }).append(d);
  13317. d.insertBefore(a.table().node());
  13318. g.each(function(c) {
  13319. c = a.column.index("fromVisible", c);
  13320. b[c].minWidth = this.offsetWidth || 0
  13321. });
  13322. d.remove()
  13323. }
  13324. },
  13325. _setColumnVis: function(a, b) {
  13326. var d = this.s.dt,
  13327. e = b ? "" : "none";
  13328. c(d.column(a).header()).css("display", e);
  13329. c(d.column(a).footer()).css("display", e);
  13330. d.column(a).nodes().to$().css("display", e)
  13331. },
  13332. _tabIndexes: function() {
  13333. var a = this.s.dt,
  13334. b = a.cells({
  13335. page: "current"
  13336. }).nodes().to$(),
  13337. d = a.settings()[0],
  13338. e = this.c.details.target;
  13339. b.filter("[data-dtr-keyboard]").removeData("[data-dtr-keyboard]");
  13340. c("number" === typeof e ? ":eq(" + e + ")" : e, a.rows({
  13341. page: "current"
  13342. }).nodes()).attr("tabIndex", d.iTabIndex).data("dtr-keyboard", 1)
  13343. }
  13344. });
  13345. j.breakpoints = [{
  13346. name: "desktop",
  13347. width: Infinity
  13348. }, {
  13349. name: "tablet-l",
  13350. width: 1024
  13351. }, {
  13352. name: "tablet-p",
  13353. width: 768
  13354. }, {
  13355. name: "mobile-l",
  13356. width: 480
  13357. }, {
  13358. name: "mobile-p",
  13359. width: 320
  13360. }];
  13361. j.display = {
  13362. childRow: function(a, b, d) {
  13363. if (b) {
  13364. if (c(a.node()).hasClass("parent")) return a.child(d(),
  13365. "child").show(), !0
  13366. } else {
  13367. if (a.child.isShown()) return a.child(!1), c(a.node()).removeClass("parent"), !1;
  13368. a.child(d(), "child").show();
  13369. c(a.node()).addClass("parent");
  13370. return !0
  13371. }
  13372. },
  13373. childRowImmediate: function(a, b, d) {
  13374. if (!b && a.child.isShown() || !a.responsive.hasHidden()) return a.child(!1), c(a.node()).removeClass("parent"), !1;
  13375. a.child(d(), "child").show();
  13376. c(a.node()).addClass("parent");
  13377. return !0
  13378. },
  13379. modal: function(a) {
  13380. return function(b, d, e) {
  13381. if (d) c("div.dtr-modal-content").empty().append(e());
  13382. else {
  13383. var f = function() {
  13384. g.remove();
  13385. c(k).off("keypress.dtr")
  13386. },
  13387. g = c('<div class="dtr-modal"/>').append(c('<div class="dtr-modal-display"/>').append(c('<div class="dtr-modal-content"/>').append(e())).append(c('<div class="dtr-modal-close">&times;</div>').click(function() {
  13388. f()
  13389. }))).append(c('<div class="dtr-modal-background"/>').click(function() {
  13390. f()
  13391. })).appendTo("body");
  13392. c(k).on("keyup.dtr", function(a) {
  13393. 27 === a.keyCode && (a.stopPropagation(), f())
  13394. })
  13395. }
  13396. a && a.header && c("div.dtr-modal-content").prepend("<h2>" + a.header(b) + "</h2>")
  13397. }
  13398. }
  13399. };
  13400. j.renderer = {
  13401. listHidden: function() {
  13402. return function(a,
  13403. b, d) {
  13404. return (a = c.map(d, function(a) {
  13405. return a.hidden ? '<li data-dtr-index="' + a.columnIndex + '" data-dt-row="' + a.rowIndex + '" data-dt-column="' + a.columnIndex + '"><span class="dtr-title">' + a.title + '</span> <span class="dtr-data">' + a.data + "</span></li>" : ""
  13406. }).join("")) ? c('<ul data-dtr-index="' + b + '"/>').append(a) : !1
  13407. }
  13408. },
  13409. tableAll: function(a) {
  13410. a = c.extend({
  13411. tableClass: ""
  13412. }, a);
  13413. return function(b, d, e) {
  13414. b = c.map(e, function(a) {
  13415. return '<tr data-dt-row="' + a.rowIndex + '" data-dt-column="' + a.columnIndex + '"><td>' + a.title + ":</td> <td>" +
  13416. a.data + "</td></tr>"
  13417. }).join("");
  13418. return c('<table class="' + a.tableClass + '" width="100%"/>').append(b)
  13419. }
  13420. }
  13421. };
  13422. j.defaults = {
  13423. breakpoints: j.breakpoints,
  13424. auto: !0,
  13425. details: {
  13426. display: j.display.childRow,
  13427. renderer: j.renderer.listHidden(),
  13428. target: 0,
  13429. type: "inline"
  13430. },
  13431. orthogonal: "display"
  13432. };
  13433. var o = c.fn.dataTable.Api;
  13434. o.register("responsive()", function() {
  13435. return this
  13436. });
  13437. o.register("responsive.index()", function(a) {
  13438. a = c(a);
  13439. return {
  13440. column: a.data("dtr-index"),
  13441. row: a.parent().data("dtr-index")
  13442. }
  13443. });
  13444. o.register("responsive.rebuild()", function() {
  13445. return this.iterator("table",
  13446. function(a) {
  13447. a._responsive && a._responsive._classLogic()
  13448. })
  13449. });
  13450. o.register("responsive.recalc()", function() {
  13451. return this.iterator("table", function(a) {
  13452. a._responsive && (a._responsive._resizeAuto(), a._responsive._resize())
  13453. })
  13454. });
  13455. o.register("responsive.hasHidden()", function() {
  13456. var a = this.context[0];
  13457. return a._responsive ? -1 !== c.inArray(!1, a._responsive.s.current) : !1
  13458. });
  13459. j.version = "2.1.0";
  13460. c.fn.dataTable.Responsive = j;
  13461. c.fn.DataTable.Responsive = j;
  13462. c(k).on("preInit.dt.dtr", function(a, b) {
  13463. if ("dt" === a.namespace && (c(b.nTable).hasClass("responsive") ||
  13464. c(b.nTable).hasClass("dt-responsive") || b.oInit.responsive || m.defaults.responsive)) {
  13465. var d = b.oInit.responsive;
  13466. !1 !== d && new j(b, c.isPlainObject(d) ? d : {})
  13467. }
  13468. });
  13469. return j
  13470. });