jquery.dataTables.js 439 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344
  1. /*! DataTables 1.10.15
  2. * ©2008-2017 SpryMedia Ltd - datatables.net/license
  3. */
  4. /**
  5. * @summary DataTables
  6. * @description Paginate, search and order HTML tables
  7. * @version 1.10.15
  8. * @file jquery.dataTables.js
  9. * @author SpryMedia Ltd
  10. * @contact www.datatables.net
  11. * @copyright Copyright 2008-2017 SpryMedia Ltd.
  12. *
  13. * This source file is free software, available under the following license:
  14. * MIT license - http://datatables.net/license
  15. *
  16. * This source file is distributed in the hope that it will be useful, but
  17. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  18. * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
  19. *
  20. * For details please refer to: http://www.datatables.net
  21. */
  22. /*jslint evil: true, undef: true, browser: true */
  23. /*globals $,require,jQuery,define,_selector_run,_selector_opts,_selector_first,_selector_row_indexes,_ext,_Api,_api_register,_api_registerPlural,_re_new_lines,_re_html,_re_formatted_numeric,_re_escape_regex,_empty,_intVal,_numToDecimal,_isNumber,_isHtml,_htmlNumeric,_pluck,_pluck_order,_range,_stripHtml,_unique,_fnBuildAjax,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnAjaxDataSrc,_fnAddColumn,_fnColumnOptions,_fnAdjustColumnSizing,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnVisbleColumns,_fnGetColumns,_fnColumnTypes,_fnApplyColumnDefs,_fnHungarianMap,_fnCamelToHungarian,_fnLanguageCompat,_fnBrowserDetect,_fnAddData,_fnAddTr,_fnNodeToDataIndex,_fnNodeToColumnIndex,_fnGetCellData,_fnSetCellData,_fnSplitObjNotation,_fnGetObjectDataFn,_fnSetObjectDataFn,_fnGetDataMaster,_fnClearTable,_fnDeleteIndex,_fnInvalidate,_fnGetRowElements,_fnCreateTr,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAddOptionsHtml,_fnDetectHeader,_fnGetUniqueThs,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnFilterCreateSearch,_fnEscapeRegex,_fnFilterData,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnInfoMacros,_fnInitialise,_fnInitComplete,_fnLengthChange,_fnFeatureHtmlLength,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnFeatureHtmlTable,_fnScrollDraw,_fnApplyToChildren,_fnCalculateColumnWidths,_fnThrottle,_fnConvertToWidth,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnSortFlatten,_fnSort,_fnSortAria,_fnSortListener,_fnSortAttachListener,_fnSortingClasses,_fnSortData,_fnSaveState,_fnLoadState,_fnSettingsFromNode,_fnLog,_fnMap,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnLengthOverflow,_fnRenderer,_fnDataSource,_fnRowAttributes*/
  24. (function( factory ) {
  25. "use strict";
  26. if ( typeof define === 'function' && define.amd ) {
  27. // AMD
  28. define( ['jquery'], function ( $ ) {
  29. return factory( $, window, document );
  30. } );
  31. }
  32. else if ( typeof exports === 'object' ) {
  33. // CommonJS
  34. module.exports = function (root, $) {
  35. if ( ! root ) {
  36. // CommonJS environments without a window global must pass a
  37. // root. This will give an error otherwise
  38. root = window;
  39. }
  40. if ( ! $ ) {
  41. $ = typeof window !== 'undefined' ? // jQuery's factory checks for a global window
  42. require('jquery') :
  43. require('jquery')( root );
  44. }
  45. return factory( $, root, root.document );
  46. };
  47. }
  48. else {
  49. // Browser
  50. factory( jQuery, window, document );
  51. }
  52. }
  53. (function( $, window, document, undefined ) {
  54. "use strict";
  55. /**
  56. * DataTables is a plug-in for the jQuery Javascript library. It is a highly
  57. * flexible tool, based upon the foundations of progressive enhancement,
  58. * which will add advanced interaction controls to any HTML table. For a
  59. * full list of features please refer to
  60. * [DataTables.net](href="http://datatables.net).
  61. *
  62. * Note that the `DataTable` object is not a global variable but is aliased
  63. * to `jQuery.fn.DataTable` and `jQuery.fn.dataTable` through which it may
  64. * be accessed.
  65. *
  66. * @class
  67. * @param {object} [init={}] Configuration object for DataTables. Options
  68. * are defined by {@link DataTable.defaults}
  69. * @requires jQuery 1.7+
  70. *
  71. * @example
  72. * // Basic initialisation
  73. * $(document).ready( function {
  74. * $('#example').dataTable();
  75. * } );
  76. *
  77. * @example
  78. * // Initialisation with configuration options - in this case, disable
  79. * // pagination and sorting.
  80. * $(document).ready( function {
  81. * $('#example').dataTable( {
  82. * "paginate": false,
  83. * "sort": false
  84. * } );
  85. * } );
  86. */
  87. var DataTable = function ( options )
  88. {
  89. /**
  90. * Perform a jQuery selector action on the table's TR elements (from the tbody) and
  91. * return the resulting jQuery object.
  92. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  93. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  94. * @param {string} [oOpts.filter=none] Select TR elements that meet the current filter
  95. * criterion ("applied") or all TR elements (i.e. no filter).
  96. * @param {string} [oOpts.order=current] Order of the TR elements in the processed array.
  97. * Can be either 'current', whereby the current sorting of the table is used, or
  98. * 'original' whereby the original order the data was read into the table is used.
  99. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  100. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  101. * 'current' and filter is 'applied', regardless of what they might be given as.
  102. * @returns {object} jQuery object, filtered by the given selector.
  103. * @dtopt API
  104. * @deprecated Since v1.10
  105. *
  106. * @example
  107. * $(document).ready(function() {
  108. * var oTable = $('#example').dataTable();
  109. *
  110. * // Highlight every second row
  111. * oTable.$('tr:odd').css('backgroundColor', 'blue');
  112. * } );
  113. *
  114. * @example
  115. * $(document).ready(function() {
  116. * var oTable = $('#example').dataTable();
  117. *
  118. * // Filter to rows with 'Webkit' in them, add a background colour and then
  119. * // remove the filter, thus highlighting the 'Webkit' rows only.
  120. * oTable.fnFilter('Webkit');
  121. * oTable.$('tr', {"search": "applied"}).css('backgroundColor', 'blue');
  122. * oTable.fnFilter('');
  123. * } );
  124. */
  125. this.$ = function ( sSelector, oOpts )
  126. {
  127. return this.api(true).$( sSelector, oOpts );
  128. };
  129. /**
  130. * Almost identical to $ in operation, but in this case returns the data for the matched
  131. * rows - as such, the jQuery selector used should match TR row nodes or TD/TH cell nodes
  132. * rather than any descendants, so the data can be obtained for the row/cell. If matching
  133. * rows are found, the data returned is the original data array/object that was used to
  134. * create the row (or a generated array if from a DOM source).
  135. *
  136. * This method is often useful in-combination with $ where both functions are given the
  137. * same parameters and the array indexes will match identically.
  138. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  139. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  140. * @param {string} [oOpts.filter=none] Select elements that meet the current filter
  141. * criterion ("applied") or all elements (i.e. no filter).
  142. * @param {string} [oOpts.order=current] Order of the data in the processed array.
  143. * Can be either 'current', whereby the current sorting of the table is used, or
  144. * 'original' whereby the original order the data was read into the table is used.
  145. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  146. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  147. * 'current' and filter is 'applied', regardless of what they might be given as.
  148. * @returns {array} Data for the matched elements. If any elements, as a result of the
  149. * selector, were not TR, TD or TH elements in the DataTable, they will have a null
  150. * entry in the array.
  151. * @dtopt API
  152. * @deprecated Since v1.10
  153. *
  154. * @example
  155. * $(document).ready(function() {
  156. * var oTable = $('#example').dataTable();
  157. *
  158. * // Get the data from the first row in the table
  159. * var data = oTable._('tr:first');
  160. *
  161. * // Do something useful with the data
  162. * alert( "First cell is: "+data[0] );
  163. * } );
  164. *
  165. * @example
  166. * $(document).ready(function() {
  167. * var oTable = $('#example').dataTable();
  168. *
  169. * // Filter to 'Webkit' and get all data for
  170. * oTable.fnFilter('Webkit');
  171. * var data = oTable._('tr', {"search": "applied"});
  172. *
  173. * // Do something with the data
  174. * alert( data.length+" rows matched the search" );
  175. * } );
  176. */
  177. this._ = function ( sSelector, oOpts )
  178. {
  179. return this.api(true).rows( sSelector, oOpts ).data();
  180. };
  181. /**
  182. * Create a DataTables Api instance, with the currently selected tables for
  183. * the Api's context.
  184. * @param {boolean} [traditional=false] Set the API instance's context to be
  185. * only the table referred to by the `DataTable.ext.iApiIndex` option, as was
  186. * used in the API presented by DataTables 1.9- (i.e. the traditional mode),
  187. * or if all tables captured in the jQuery object should be used.
  188. * @return {DataTables.Api}
  189. */
  190. this.api = function ( traditional )
  191. {
  192. return traditional ?
  193. new _Api(
  194. _fnSettingsFromNode( this[ _ext.iApiIndex ] )
  195. ) :
  196. new _Api( this );
  197. };
  198. /**
  199. * Add a single new row or multiple rows of data to the table. Please note
  200. * that this is suitable for client-side processing only - if you are using
  201. * server-side processing (i.e. "bServerSide": true), then to add data, you
  202. * must add it to the data source, i.e. the server-side, through an Ajax call.
  203. * @param {array|object} data The data to be added to the table. This can be:
  204. * <ul>
  205. * <li>1D array of data - add a single row with the data provided</li>
  206. * <li>2D array of arrays - add multiple rows in a single call</li>
  207. * <li>object - data object when using <i>mData</i></li>
  208. * <li>array of objects - multiple data objects when using <i>mData</i></li>
  209. * </ul>
  210. * @param {bool} [redraw=true] redraw the table or not
  211. * @returns {array} An array of integers, representing the list of indexes in
  212. * <i>aoData</i> ({@link DataTable.models.oSettings}) that have been added to
  213. * the table.
  214. * @dtopt API
  215. * @deprecated Since v1.10
  216. *
  217. * @example
  218. * // Global var for counter
  219. * var giCount = 2;
  220. *
  221. * $(document).ready(function() {
  222. * $('#example').dataTable();
  223. * } );
  224. *
  225. * function fnClickAddRow() {
  226. * $('#example').dataTable().fnAddData( [
  227. * giCount+".1",
  228. * giCount+".2",
  229. * giCount+".3",
  230. * giCount+".4" ]
  231. * );
  232. *
  233. * giCount++;
  234. * }
  235. */
  236. this.fnAddData = function( data, redraw )
  237. {
  238. var api = this.api( true );
  239. /* Check if we want to add multiple rows or not */
  240. var rows = $.isArray(data) && ( $.isArray(data[0]) || $.isPlainObject(data[0]) ) ?
  241. api.rows.add( data ) :
  242. api.row.add( data );
  243. if ( redraw === undefined || redraw ) {
  244. api.draw();
  245. }
  246. return rows.flatten().toArray();
  247. };
  248. /**
  249. * This function will make DataTables recalculate the column sizes, based on the data
  250. * contained in the table and the sizes applied to the columns (in the DOM, CSS or
  251. * through the sWidth parameter). This can be useful when the width of the table's
  252. * parent element changes (for example a window resize).
  253. * @param {boolean} [bRedraw=true] Redraw the table or not, you will typically want to
  254. * @dtopt API
  255. * @deprecated Since v1.10
  256. *
  257. * @example
  258. * $(document).ready(function() {
  259. * var oTable = $('#example').dataTable( {
  260. * "sScrollY": "200px",
  261. * "bPaginate": false
  262. * } );
  263. *
  264. * $(window).on('resize', function () {
  265. * oTable.fnAdjustColumnSizing();
  266. * } );
  267. * } );
  268. */
  269. this.fnAdjustColumnSizing = function ( bRedraw )
  270. {
  271. var api = this.api( true ).columns.adjust();
  272. var settings = api.settings()[0];
  273. var scroll = settings.oScroll;
  274. if ( bRedraw === undefined || bRedraw ) {
  275. api.draw( false );
  276. }
  277. else if ( scroll.sX !== "" || scroll.sY !== "" ) {
  278. /* If not redrawing, but scrolling, we want to apply the new column sizes anyway */
  279. _fnScrollDraw( settings );
  280. }
  281. };
  282. /**
  283. * Quickly and simply clear a table
  284. * @param {bool} [bRedraw=true] redraw the table or not
  285. * @dtopt API
  286. * @deprecated Since v1.10
  287. *
  288. * @example
  289. * $(document).ready(function() {
  290. * var oTable = $('#example').dataTable();
  291. *
  292. * // Immediately 'nuke' the current rows (perhaps waiting for an Ajax callback...)
  293. * oTable.fnClearTable();
  294. * } );
  295. */
  296. this.fnClearTable = function( bRedraw )
  297. {
  298. var api = this.api( true ).clear();
  299. if ( bRedraw === undefined || bRedraw ) {
  300. api.draw();
  301. }
  302. };
  303. /**
  304. * The exact opposite of 'opening' a row, this function will close any rows which
  305. * are currently 'open'.
  306. * @param {node} nTr the table row to 'close'
  307. * @returns {int} 0 on success, or 1 if failed (can't find the row)
  308. * @dtopt API
  309. * @deprecated Since v1.10
  310. *
  311. * @example
  312. * $(document).ready(function() {
  313. * var oTable;
  314. *
  315. * // 'open' an information row when a row is clicked on
  316. * $('#example tbody tr').click( function () {
  317. * if ( oTable.fnIsOpen(this) ) {
  318. * oTable.fnClose( this );
  319. * } else {
  320. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  321. * }
  322. * } );
  323. *
  324. * oTable = $('#example').dataTable();
  325. * } );
  326. */
  327. this.fnClose = function( nTr )
  328. {
  329. this.api( true ).row( nTr ).child.hide();
  330. };
  331. /**
  332. * Remove a row for the table
  333. * @param {mixed} target The index of the row from aoData to be deleted, or
  334. * the TR element you want to delete
  335. * @param {function|null} [callBack] Callback function
  336. * @param {bool} [redraw=true] Redraw the table or not
  337. * @returns {array} The row that was deleted
  338. * @dtopt API
  339. * @deprecated Since v1.10
  340. *
  341. * @example
  342. * $(document).ready(function() {
  343. * var oTable = $('#example').dataTable();
  344. *
  345. * // Immediately remove the first row
  346. * oTable.fnDeleteRow( 0 );
  347. * } );
  348. */
  349. this.fnDeleteRow = function( target, callback, redraw )
  350. {
  351. var api = this.api( true );
  352. var rows = api.rows( target );
  353. var settings = rows.settings()[0];
  354. var data = settings.aoData[ rows[0][0] ];
  355. rows.remove();
  356. if ( callback ) {
  357. callback.call( this, settings, data );
  358. }
  359. if ( redraw === undefined || redraw ) {
  360. api.draw();
  361. }
  362. return data;
  363. };
  364. /**
  365. * Restore the table to it's original state in the DOM by removing all of DataTables
  366. * enhancements, alterations to the DOM structure of the table and event listeners.
  367. * @param {boolean} [remove=false] Completely remove the table from the DOM
  368. * @dtopt API
  369. * @deprecated Since v1.10
  370. *
  371. * @example
  372. * $(document).ready(function() {
  373. * // This example is fairly pointless in reality, but shows how fnDestroy can be used
  374. * var oTable = $('#example').dataTable();
  375. * oTable.fnDestroy();
  376. * } );
  377. */
  378. this.fnDestroy = function ( remove )
  379. {
  380. this.api( true ).destroy( remove );
  381. };
  382. /**
  383. * Redraw the table
  384. * @param {bool} [complete=true] Re-filter and resort (if enabled) the table before the draw.
  385. * @dtopt API
  386. * @deprecated Since v1.10
  387. *
  388. * @example
  389. * $(document).ready(function() {
  390. * var oTable = $('#example').dataTable();
  391. *
  392. * // Re-draw the table - you wouldn't want to do it here, but it's an example :-)
  393. * oTable.fnDraw();
  394. * } );
  395. */
  396. this.fnDraw = function( complete )
  397. {
  398. // Note that this isn't an exact match to the old call to _fnDraw - it takes
  399. // into account the new data, but can hold position.
  400. this.api( true ).draw( complete );
  401. };
  402. /**
  403. * Filter the input based on data
  404. * @param {string} sInput String to filter the table on
  405. * @param {int|null} [iColumn] Column to limit filtering to
  406. * @param {bool} [bRegex=false] Treat as regular expression or not
  407. * @param {bool} [bSmart=true] Perform smart filtering or not
  408. * @param {bool} [bShowGlobal=true] Show the input global filter in it's input box(es)
  409. * @param {bool} [bCaseInsensitive=true] Do case-insensitive matching (true) or not (false)
  410. * @dtopt API
  411. * @deprecated Since v1.10
  412. *
  413. * @example
  414. * $(document).ready(function() {
  415. * var oTable = $('#example').dataTable();
  416. *
  417. * // Sometime later - filter...
  418. * oTable.fnFilter( 'test string' );
  419. * } );
  420. */
  421. this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal, bCaseInsensitive )
  422. {
  423. var api = this.api( true );
  424. if ( iColumn === null || iColumn === undefined ) {
  425. api.search( sInput, bRegex, bSmart, bCaseInsensitive );
  426. }
  427. else {
  428. api.column( iColumn ).search( sInput, bRegex, bSmart, bCaseInsensitive );
  429. }
  430. api.draw();
  431. };
  432. /**
  433. * Get the data for the whole table, an individual row or an individual cell based on the
  434. * provided parameters.
  435. * @param {int|node} [src] A TR row node, TD/TH cell node or an integer. If given as
  436. * a TR node then the data source for the whole row will be returned. If given as a
  437. * TD/TH cell node then iCol will be automatically calculated and the data for the
  438. * cell returned. If given as an integer, then this is treated as the aoData internal
  439. * data index for the row (see fnGetPosition) and the data for that row used.
  440. * @param {int} [col] Optional column index that you want the data of.
  441. * @returns {array|object|string} If mRow is undefined, then the data for all rows is
  442. * returned. If mRow is defined, just data for that row, and is iCol is
  443. * defined, only data for the designated cell is returned.
  444. * @dtopt API
  445. * @deprecated Since v1.10
  446. *
  447. * @example
  448. * // Row data
  449. * $(document).ready(function() {
  450. * oTable = $('#example').dataTable();
  451. *
  452. * oTable.$('tr').click( function () {
  453. * var data = oTable.fnGetData( this );
  454. * // ... do something with the array / object of data for the row
  455. * } );
  456. * } );
  457. *
  458. * @example
  459. * // Individual cell data
  460. * $(document).ready(function() {
  461. * oTable = $('#example').dataTable();
  462. *
  463. * oTable.$('td').click( function () {
  464. * var sData = oTable.fnGetData( this );
  465. * alert( 'The cell clicked on had the value of '+sData );
  466. * } );
  467. * } );
  468. */
  469. this.fnGetData = function( src, col )
  470. {
  471. var api = this.api( true );
  472. if ( src !== undefined ) {
  473. var type = src.nodeName ? src.nodeName.toLowerCase() : '';
  474. return col !== undefined || type == 'td' || type == 'th' ?
  475. api.cell( src, col ).data() :
  476. api.row( src ).data() || null;
  477. }
  478. return api.data().toArray();
  479. };
  480. /**
  481. * Get an array of the TR nodes that are used in the table's body. Note that you will
  482. * typically want to use the '$' API method in preference to this as it is more
  483. * flexible.
  484. * @param {int} [iRow] Optional row index for the TR element you want
  485. * @returns {array|node} If iRow is undefined, returns an array of all TR elements
  486. * in the table's body, or iRow is defined, just the TR element requested.
  487. * @dtopt API
  488. * @deprecated Since v1.10
  489. *
  490. * @example
  491. * $(document).ready(function() {
  492. * var oTable = $('#example').dataTable();
  493. *
  494. * // Get the nodes from the table
  495. * var nNodes = oTable.fnGetNodes( );
  496. * } );
  497. */
  498. this.fnGetNodes = function( iRow )
  499. {
  500. var api = this.api( true );
  501. return iRow !== undefined ?
  502. api.row( iRow ).node() :
  503. api.rows().nodes().flatten().toArray();
  504. };
  505. /**
  506. * Get the array indexes of a particular cell from it's DOM element
  507. * and column index including hidden columns
  508. * @param {node} node this can either be a TR, TD or TH in the table's body
  509. * @returns {int} If nNode is given as a TR, then a single index is returned, or
  510. * if given as a cell, an array of [row index, column index (visible),
  511. * column index (all)] is given.
  512. * @dtopt API
  513. * @deprecated Since v1.10
  514. *
  515. * @example
  516. * $(document).ready(function() {
  517. * $('#example tbody td').click( function () {
  518. * // Get the position of the current data from the node
  519. * var aPos = oTable.fnGetPosition( this );
  520. *
  521. * // Get the data array for this row
  522. * var aData = oTable.fnGetData( aPos[0] );
  523. *
  524. * // Update the data array and return the value
  525. * aData[ aPos[1] ] = 'clicked';
  526. * this.innerHTML = 'clicked';
  527. * } );
  528. *
  529. * // Init DataTables
  530. * oTable = $('#example').dataTable();
  531. * } );
  532. */
  533. this.fnGetPosition = function( node )
  534. {
  535. var api = this.api( true );
  536. var nodeName = node.nodeName.toUpperCase();
  537. if ( nodeName == 'TR' ) {
  538. return api.row( node ).index();
  539. }
  540. else if ( nodeName == 'TD' || nodeName == 'TH' ) {
  541. var cell = api.cell( node ).index();
  542. return [
  543. cell.row,
  544. cell.columnVisible,
  545. cell.column
  546. ];
  547. }
  548. return null;
  549. };
  550. /**
  551. * Check to see if a row is 'open' or not.
  552. * @param {node} nTr the table row to check
  553. * @returns {boolean} true if the row is currently open, false otherwise
  554. * @dtopt API
  555. * @deprecated Since v1.10
  556. *
  557. * @example
  558. * $(document).ready(function() {
  559. * var oTable;
  560. *
  561. * // 'open' an information row when a row is clicked on
  562. * $('#example tbody tr').click( function () {
  563. * if ( oTable.fnIsOpen(this) ) {
  564. * oTable.fnClose( this );
  565. * } else {
  566. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  567. * }
  568. * } );
  569. *
  570. * oTable = $('#example').dataTable();
  571. * } );
  572. */
  573. this.fnIsOpen = function( nTr )
  574. {
  575. return this.api( true ).row( nTr ).child.isShown();
  576. };
  577. /**
  578. * This function will place a new row directly after a row which is currently
  579. * on display on the page, with the HTML contents that is passed into the
  580. * function. This can be used, for example, to ask for confirmation that a
  581. * particular record should be deleted.
  582. * @param {node} nTr The table row to 'open'
  583. * @param {string|node|jQuery} mHtml The HTML to put into the row
  584. * @param {string} sClass Class to give the new TD cell
  585. * @returns {node} The row opened. Note that if the table row passed in as the
  586. * first parameter, is not found in the table, this method will silently
  587. * return.
  588. * @dtopt API
  589. * @deprecated Since v1.10
  590. *
  591. * @example
  592. * $(document).ready(function() {
  593. * var oTable;
  594. *
  595. * // 'open' an information row when a row is clicked on
  596. * $('#example tbody tr').click( function () {
  597. * if ( oTable.fnIsOpen(this) ) {
  598. * oTable.fnClose( this );
  599. * } else {
  600. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  601. * }
  602. * } );
  603. *
  604. * oTable = $('#example').dataTable();
  605. * } );
  606. */
  607. this.fnOpen = function( nTr, mHtml, sClass )
  608. {
  609. return this.api( true )
  610. .row( nTr )
  611. .child( mHtml, sClass )
  612. .show()
  613. .child()[0];
  614. };
  615. /**
  616. * Change the pagination - provides the internal logic for pagination in a simple API
  617. * function. With this function you can have a DataTables table go to the next,
  618. * previous, first or last pages.
  619. * @param {string|int} mAction Paging action to take: "first", "previous", "next" or "last"
  620. * or page number to jump to (integer), note that page 0 is the first page.
  621. * @param {bool} [bRedraw=true] Redraw the table or not
  622. * @dtopt API
  623. * @deprecated Since v1.10
  624. *
  625. * @example
  626. * $(document).ready(function() {
  627. * var oTable = $('#example').dataTable();
  628. * oTable.fnPageChange( 'next' );
  629. * } );
  630. */
  631. this.fnPageChange = function ( mAction, bRedraw )
  632. {
  633. var api = this.api( true ).page( mAction );
  634. if ( bRedraw === undefined || bRedraw ) {
  635. api.draw(false);
  636. }
  637. };
  638. /**
  639. * Show a particular column
  640. * @param {int} iCol The column whose display should be changed
  641. * @param {bool} bShow Show (true) or hide (false) the column
  642. * @param {bool} [bRedraw=true] Redraw the table or not
  643. * @dtopt API
  644. * @deprecated Since v1.10
  645. *
  646. * @example
  647. * $(document).ready(function() {
  648. * var oTable = $('#example').dataTable();
  649. *
  650. * // Hide the second column after initialisation
  651. * oTable.fnSetColumnVis( 1, false );
  652. * } );
  653. */
  654. this.fnSetColumnVis = function ( iCol, bShow, bRedraw )
  655. {
  656. var api = this.api( true ).column( iCol ).visible( bShow );
  657. if ( bRedraw === undefined || bRedraw ) {
  658. api.columns.adjust().draw();
  659. }
  660. };
  661. /**
  662. * Get the settings for a particular table for external manipulation
  663. * @returns {object} DataTables settings object. See
  664. * {@link DataTable.models.oSettings}
  665. * @dtopt API
  666. * @deprecated Since v1.10
  667. *
  668. * @example
  669. * $(document).ready(function() {
  670. * var oTable = $('#example').dataTable();
  671. * var oSettings = oTable.fnSettings();
  672. *
  673. * // Show an example parameter from the settings
  674. * alert( oSettings._iDisplayStart );
  675. * } );
  676. */
  677. this.fnSettings = function()
  678. {
  679. return _fnSettingsFromNode( this[_ext.iApiIndex] );
  680. };
  681. /**
  682. * Sort the table by a particular column
  683. * @param {int} iCol the data index to sort on. Note that this will not match the
  684. * 'display index' if you have hidden data entries
  685. * @dtopt API
  686. * @deprecated Since v1.10
  687. *
  688. * @example
  689. * $(document).ready(function() {
  690. * var oTable = $('#example').dataTable();
  691. *
  692. * // Sort immediately with columns 0 and 1
  693. * oTable.fnSort( [ [0,'asc'], [1,'asc'] ] );
  694. * } );
  695. */
  696. this.fnSort = function( aaSort )
  697. {
  698. this.api( true ).order( aaSort ).draw();
  699. };
  700. /**
  701. * Attach a sort listener to an element for a given column
  702. * @param {node} nNode the element to attach the sort listener to
  703. * @param {int} iColumn the column that a click on this node will sort on
  704. * @param {function} [fnCallback] callback function when sort is run
  705. * @dtopt API
  706. * @deprecated Since v1.10
  707. *
  708. * @example
  709. * $(document).ready(function() {
  710. * var oTable = $('#example').dataTable();
  711. *
  712. * // Sort on column 1, when 'sorter' is clicked on
  713. * oTable.fnSortListener( document.getElementById('sorter'), 1 );
  714. * } );
  715. */
  716. this.fnSortListener = function( nNode, iColumn, fnCallback )
  717. {
  718. this.api( true ).order.listener( nNode, iColumn, fnCallback );
  719. };
  720. /**
  721. * Update a table cell or row - this method will accept either a single value to
  722. * update the cell with, an array of values with one element for each column or
  723. * an object in the same format as the original data source. The function is
  724. * self-referencing in order to make the multi column updates easier.
  725. * @param {object|array|string} mData Data to update the cell/row with
  726. * @param {node|int} mRow TR element you want to update or the aoData index
  727. * @param {int} [iColumn] The column to update, give as null or undefined to
  728. * update a whole row.
  729. * @param {bool} [bRedraw=true] Redraw the table or not
  730. * @param {bool} [bAction=true] Perform pre-draw actions or not
  731. * @returns {int} 0 on success, 1 on error
  732. * @dtopt API
  733. * @deprecated Since v1.10
  734. *
  735. * @example
  736. * $(document).ready(function() {
  737. * var oTable = $('#example').dataTable();
  738. * oTable.fnUpdate( 'Example update', 0, 0 ); // Single cell
  739. * oTable.fnUpdate( ['a', 'b', 'c', 'd', 'e'], $('tbody tr')[0] ); // Row
  740. * } );
  741. */
  742. this.fnUpdate = function( mData, mRow, iColumn, bRedraw, bAction )
  743. {
  744. var api = this.api( true );
  745. if ( iColumn === undefined || iColumn === null ) {
  746. api.row( mRow ).data( mData );
  747. }
  748. else {
  749. api.cell( mRow, iColumn ).data( mData );
  750. }
  751. if ( bAction === undefined || bAction ) {
  752. api.columns.adjust();
  753. }
  754. if ( bRedraw === undefined || bRedraw ) {
  755. api.draw();
  756. }
  757. return 0;
  758. };
  759. /**
  760. * Provide a common method for plug-ins to check the version of DataTables being used, in order
  761. * to ensure compatibility.
  762. * @param {string} sVersion Version string to check for, in the format "X.Y.Z". Note that the
  763. * formats "X" and "X.Y" are also acceptable.
  764. * @returns {boolean} true if this version of DataTables is greater or equal to the required
  765. * version, or false if this version of DataTales is not suitable
  766. * @method
  767. * @dtopt API
  768. * @deprecated Since v1.10
  769. *
  770. * @example
  771. * $(document).ready(function() {
  772. * var oTable = $('#example').dataTable();
  773. * alert( oTable.fnVersionCheck( '1.9.0' ) );
  774. * } );
  775. */
  776. this.fnVersionCheck = _ext.fnVersionCheck;
  777. var _that = this;
  778. var emptyInit = options === undefined;
  779. var len = this.length;
  780. if ( emptyInit ) {
  781. options = {};
  782. }
  783. this.oApi = this.internal = _ext.internal;
  784. // Extend with old style plug-in API methods
  785. for ( var fn in DataTable.ext.internal ) {
  786. if ( fn ) {
  787. this[fn] = _fnExternApiFunc(fn);
  788. }
  789. }
  790. this.each(function() {
  791. // For each initialisation we want to give it a clean initialisation
  792. // object that can be bashed around
  793. var o = {};
  794. var oInit = len > 1 ? // optimisation for single table case
  795. _fnExtend( o, options, true ) :
  796. options;
  797. /*global oInit,_that,emptyInit*/
  798. var i=0, iLen, j, jLen, k, kLen;
  799. var sId = this.getAttribute( 'id' );
  800. var bInitHandedOff = false;
  801. var defaults = DataTable.defaults;
  802. var $this = $(this);
  803. /* Sanity check */
  804. if ( this.nodeName.toLowerCase() != 'table' )
  805. {
  806. _fnLog( null, 0, 'Non-table node initialisation ('+this.nodeName+')', 2 );
  807. return;
  808. }
  809. /* Backwards compatibility for the defaults */
  810. _fnCompatOpts( defaults );
  811. _fnCompatCols( defaults.column );
  812. /* Convert the camel-case defaults to Hungarian */
  813. _fnCamelToHungarian( defaults, defaults, true );
  814. _fnCamelToHungarian( defaults.column, defaults.column, true );
  815. /* Setting up the initialisation object */
  816. _fnCamelToHungarian( defaults, $.extend( oInit, $this.data() ) );
  817. /* Check to see if we are re-initialising a table */
  818. var allSettings = DataTable.settings;
  819. for ( i=0, iLen=allSettings.length ; i<iLen ; i++ )
  820. {
  821. var s = allSettings[i];
  822. /* Base check on table node */
  823. if ( s.nTable == this || s.nTHead.parentNode == this || (s.nTFoot && s.nTFoot.parentNode == this) )
  824. {
  825. var bRetrieve = oInit.bRetrieve !== undefined ? oInit.bRetrieve : defaults.bRetrieve;
  826. var bDestroy = oInit.bDestroy !== undefined ? oInit.bDestroy : defaults.bDestroy;
  827. if ( emptyInit || bRetrieve )
  828. {
  829. return s.oInstance;
  830. }
  831. else if ( bDestroy )
  832. {
  833. s.oInstance.fnDestroy();
  834. break;
  835. }
  836. else
  837. {
  838. _fnLog( s, 0, 'Cannot reinitialise DataTable', 3 );
  839. return;
  840. }
  841. }
  842. /* If the element we are initialising has the same ID as a table which was previously
  843. * initialised, but the table nodes don't match (from before) then we destroy the old
  844. * instance by simply deleting it. This is under the assumption that the table has been
  845. * destroyed by other methods. Anyone using non-id selectors will need to do this manually
  846. */
  847. if ( s.sTableId == this.id )
  848. {
  849. allSettings.splice( i, 1 );
  850. break;
  851. }
  852. }
  853. /* Ensure the table has an ID - required for accessibility */
  854. if ( sId === null || sId === "" )
  855. {
  856. sId = "DataTables_Table_"+(DataTable.ext._unique++);
  857. this.id = sId;
  858. }
  859. /* Create the settings object for this table and set some of the default parameters */
  860. var oSettings = $.extend( true, {}, DataTable.models.oSettings, {
  861. "sDestroyWidth": $this[0].style.width,
  862. "sInstance": sId,
  863. "sTableId": sId
  864. } );
  865. oSettings.nTable = this;
  866. oSettings.oApi = _that.internal;
  867. oSettings.oInit = oInit;
  868. allSettings.push( oSettings );
  869. // Need to add the instance after the instance after the settings object has been added
  870. // to the settings array, so we can self reference the table instance if more than one
  871. oSettings.oInstance = (_that.length===1) ? _that : $this.dataTable();
  872. // Backwards compatibility, before we apply all the defaults
  873. _fnCompatOpts( oInit );
  874. if ( oInit.oLanguage )
  875. {
  876. _fnLanguageCompat( oInit.oLanguage );
  877. }
  878. // If the length menu is given, but the init display length is not, use the length menu
  879. if ( oInit.aLengthMenu && ! oInit.iDisplayLength )
  880. {
  881. oInit.iDisplayLength = $.isArray( oInit.aLengthMenu[0] ) ?
  882. oInit.aLengthMenu[0][0] : oInit.aLengthMenu[0];
  883. }
  884. // Apply the defaults and init options to make a single init object will all
  885. // options defined from defaults and instance options.
  886. oInit = _fnExtend( $.extend( true, {}, defaults ), oInit );
  887. // Map the initialisation options onto the settings object
  888. _fnMap( oSettings.oFeatures, oInit, [
  889. "bPaginate",
  890. "bLengthChange",
  891. "bFilter",
  892. "bSort",
  893. "bSortMulti",
  894. "bInfo",
  895. "bProcessing",
  896. "bAutoWidth",
  897. "bSortClasses",
  898. "bServerSide",
  899. "bDeferRender"
  900. ] );
  901. _fnMap( oSettings, oInit, [
  902. "asStripeClasses",
  903. "ajax",
  904. "fnServerData",
  905. "fnFormatNumber",
  906. "sServerMethod",
  907. "aaSorting",
  908. "aaSortingFixed",
  909. "aLengthMenu",
  910. "sPaginationType",
  911. "sAjaxSource",
  912. "sAjaxDataProp",
  913. "iStateDuration",
  914. "sDom",
  915. "bSortCellsTop",
  916. "iTabIndex",
  917. "fnStateLoadCallback",
  918. "fnStateSaveCallback",
  919. "renderer",
  920. "searchDelay",
  921. "rowId",
  922. [ "iCookieDuration", "iStateDuration" ], // backwards compat
  923. [ "oSearch", "oPreviousSearch" ],
  924. [ "aoSearchCols", "aoPreSearchCols" ],
  925. [ "iDisplayLength", "_iDisplayLength" ],
  926. [ "bJQueryUI", "bJUI" ]
  927. ] );
  928. _fnMap( oSettings.oScroll, oInit, [
  929. [ "sScrollX", "sX" ],
  930. [ "sScrollXInner", "sXInner" ],
  931. [ "sScrollY", "sY" ],
  932. [ "bScrollCollapse", "bCollapse" ]
  933. ] );
  934. _fnMap( oSettings.oLanguage, oInit, "fnInfoCallback" );
  935. /* Callback functions which are array driven */
  936. _fnCallbackReg( oSettings, 'aoDrawCallback', oInit.fnDrawCallback, 'user' );
  937. _fnCallbackReg( oSettings, 'aoServerParams', oInit.fnServerParams, 'user' );
  938. _fnCallbackReg( oSettings, 'aoStateSaveParams', oInit.fnStateSaveParams, 'user' );
  939. _fnCallbackReg( oSettings, 'aoStateLoadParams', oInit.fnStateLoadParams, 'user' );
  940. _fnCallbackReg( oSettings, 'aoStateLoaded', oInit.fnStateLoaded, 'user' );
  941. _fnCallbackReg( oSettings, 'aoRowCallback', oInit.fnRowCallback, 'user' );
  942. _fnCallbackReg( oSettings, 'aoRowCreatedCallback', oInit.fnCreatedRow, 'user' );
  943. _fnCallbackReg( oSettings, 'aoHeaderCallback', oInit.fnHeaderCallback, 'user' );
  944. _fnCallbackReg( oSettings, 'aoFooterCallback', oInit.fnFooterCallback, 'user' );
  945. _fnCallbackReg( oSettings, 'aoInitComplete', oInit.fnInitComplete, 'user' );
  946. _fnCallbackReg( oSettings, 'aoPreDrawCallback', oInit.fnPreDrawCallback, 'user' );
  947. oSettings.rowIdFn = _fnGetObjectDataFn( oInit.rowId );
  948. /* Browser support detection */
  949. _fnBrowserDetect( oSettings );
  950. var oClasses = oSettings.oClasses;
  951. // @todo Remove in 1.11
  952. if ( oInit.bJQueryUI )
  953. {
  954. /* Use the JUI classes object for display. You could clone the oStdClasses object if
  955. * you want to have multiple tables with multiple independent classes
  956. */
  957. $.extend( oClasses, DataTable.ext.oJUIClasses, oInit.oClasses );
  958. if ( oInit.sDom === defaults.sDom && defaults.sDom === "lfrtip" )
  959. {
  960. /* Set the DOM to use a layout suitable for jQuery UI's theming */
  961. oSettings.sDom = '<"H"lfr>t<"F"ip>';
  962. }
  963. if ( ! oSettings.renderer ) {
  964. oSettings.renderer = 'jqueryui';
  965. }
  966. else if ( $.isPlainObject( oSettings.renderer ) && ! oSettings.renderer.header ) {
  967. oSettings.renderer.header = 'jqueryui';
  968. }
  969. }
  970. else
  971. {
  972. $.extend( oClasses, DataTable.ext.classes, oInit.oClasses );
  973. }
  974. $this.addClass( oClasses.sTable );
  975. if ( oSettings.iInitDisplayStart === undefined )
  976. {
  977. /* Display start point, taking into account the save saving */
  978. oSettings.iInitDisplayStart = oInit.iDisplayStart;
  979. oSettings._iDisplayStart = oInit.iDisplayStart;
  980. }
  981. if ( oInit.iDeferLoading !== null )
  982. {
  983. oSettings.bDeferLoading = true;
  984. var tmp = $.isArray( oInit.iDeferLoading );
  985. oSettings._iRecordsDisplay = tmp ? oInit.iDeferLoading[0] : oInit.iDeferLoading;
  986. oSettings._iRecordsTotal = tmp ? oInit.iDeferLoading[1] : oInit.iDeferLoading;
  987. }
  988. /* Language definitions */
  989. var oLanguage = oSettings.oLanguage;
  990. $.extend( true, oLanguage, oInit.oLanguage );
  991. if ( oLanguage.sUrl )
  992. {
  993. /* Get the language definitions from a file - because this Ajax call makes the language
  994. * get async to the remainder of this function we use bInitHandedOff to indicate that
  995. * _fnInitialise will be fired by the returned Ajax handler, rather than the constructor
  996. */
  997. $.ajax( {
  998. dataType: 'json',
  999. url: oLanguage.sUrl,
  1000. success: function ( json ) {
  1001. _fnLanguageCompat( json );
  1002. _fnCamelToHungarian( defaults.oLanguage, json );
  1003. $.extend( true, oLanguage, json );
  1004. _fnInitialise( oSettings );
  1005. },
  1006. error: function () {
  1007. // Error occurred loading language file, continue on as best we can
  1008. _fnInitialise( oSettings );
  1009. }
  1010. } );
  1011. bInitHandedOff = true;
  1012. }
  1013. /*
  1014. * Stripes
  1015. */
  1016. if ( oInit.asStripeClasses === null )
  1017. {
  1018. oSettings.asStripeClasses =[
  1019. oClasses.sStripeOdd,
  1020. oClasses.sStripeEven
  1021. ];
  1022. }
  1023. /* Remove row stripe classes if they are already on the table row */
  1024. var stripeClasses = oSettings.asStripeClasses;
  1025. var rowOne = $this.children('tbody').find('tr').eq(0);
  1026. if ( $.inArray( true, $.map( stripeClasses, function(el, i) {
  1027. return rowOne.hasClass(el);
  1028. } ) ) !== -1 ) {
  1029. $('tbody tr', this).removeClass( stripeClasses.join(' ') );
  1030. oSettings.asDestroyStripes = stripeClasses.slice();
  1031. }
  1032. /*
  1033. * Columns
  1034. * See if we should load columns automatically or use defined ones
  1035. */
  1036. var anThs = [];
  1037. var aoColumnsInit;
  1038. var nThead = this.getElementsByTagName('thead');
  1039. if ( nThead.length !== 0 )
  1040. {
  1041. _fnDetectHeader( oSettings.aoHeader, nThead[0] );
  1042. anThs = _fnGetUniqueThs( oSettings );
  1043. }
  1044. /* If not given a column array, generate one with nulls */
  1045. if ( oInit.aoColumns === null )
  1046. {
  1047. aoColumnsInit = [];
  1048. for ( i=0, iLen=anThs.length ; i<iLen ; i++ )
  1049. {
  1050. aoColumnsInit.push( null );
  1051. }
  1052. }
  1053. else
  1054. {
  1055. aoColumnsInit = oInit.aoColumns;
  1056. }
  1057. /* Add the columns */
  1058. for ( i=0, iLen=aoColumnsInit.length ; i<iLen ; i++ )
  1059. {
  1060. _fnAddColumn( oSettings, anThs ? anThs[i] : null );
  1061. }
  1062. /* Apply the column definitions */
  1063. _fnApplyColumnDefs( oSettings, oInit.aoColumnDefs, aoColumnsInit, function (iCol, oDef) {
  1064. _fnColumnOptions( oSettings, iCol, oDef );
  1065. } );
  1066. /* HTML5 attribute detection - build an mData object automatically if the
  1067. * attributes are found
  1068. */
  1069. if ( rowOne.length ) {
  1070. var a = function ( cell, name ) {
  1071. return cell.getAttribute( 'data-'+name ) !== null ? name : null;
  1072. };
  1073. $( rowOne[0] ).children('th, td').each( function (i, cell) {
  1074. var col = oSettings.aoColumns[i];
  1075. if ( col.mData === i ) {
  1076. var sort = a( cell, 'sort' ) || a( cell, 'order' );
  1077. var filter = a( cell, 'filter' ) || a( cell, 'search' );
  1078. if ( sort !== null || filter !== null ) {
  1079. col.mData = {
  1080. _: i+'.display',
  1081. sort: sort !== null ? i+'.@data-'+sort : undefined,
  1082. type: sort !== null ? i+'.@data-'+sort : undefined,
  1083. filter: filter !== null ? i+'.@data-'+filter : undefined
  1084. };
  1085. _fnColumnOptions( oSettings, i );
  1086. }
  1087. }
  1088. } );
  1089. }
  1090. var features = oSettings.oFeatures;
  1091. var loadedInit = function () {
  1092. /*
  1093. * Sorting
  1094. * @todo For modularisation (1.11) this needs to do into a sort start up handler
  1095. */
  1096. // If aaSorting is not defined, then we use the first indicator in asSorting
  1097. // in case that has been altered, so the default sort reflects that option
  1098. if ( oInit.aaSorting === undefined ) {
  1099. var sorting = oSettings.aaSorting;
  1100. for ( i=0, iLen=sorting.length ; i<iLen ; i++ ) {
  1101. sorting[i][1] = oSettings.aoColumns[ i ].asSorting[0];
  1102. }
  1103. }
  1104. /* Do a first pass on the sorting classes (allows any size changes to be taken into
  1105. * account, and also will apply sorting disabled classes if disabled
  1106. */
  1107. _fnSortingClasses( oSettings );
  1108. if ( features.bSort ) {
  1109. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  1110. if ( oSettings.bSorted ) {
  1111. var aSort = _fnSortFlatten( oSettings );
  1112. var sortedColumns = {};
  1113. $.each( aSort, function (i, val) {
  1114. sortedColumns[ val.src ] = val.dir;
  1115. } );
  1116. _fnCallbackFire( oSettings, null, 'order', [oSettings, aSort, sortedColumns] );
  1117. _fnSortAria( oSettings );
  1118. }
  1119. } );
  1120. }
  1121. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  1122. if ( oSettings.bSorted || _fnDataSource( oSettings ) === 'ssp' || features.bDeferRender ) {
  1123. _fnSortingClasses( oSettings );
  1124. }
  1125. }, 'sc' );
  1126. /*
  1127. * Final init
  1128. * Cache the header, body and footer as required, creating them if needed
  1129. */
  1130. // Work around for Webkit bug 83867 - store the caption-side before removing from doc
  1131. var captions = $this.children('caption').each( function () {
  1132. this._captionSide = $(this).css('caption-side');
  1133. } );
  1134. var thead = $this.children('thead');
  1135. if ( thead.length === 0 ) {
  1136. thead = $('<thead/>').appendTo($this);
  1137. }
  1138. oSettings.nTHead = thead[0];
  1139. var tbody = $this.children('tbody');
  1140. if ( tbody.length === 0 ) {
  1141. tbody = $('<tbody/>').appendTo($this);
  1142. }
  1143. oSettings.nTBody = tbody[0];
  1144. var tfoot = $this.children('tfoot');
  1145. if ( tfoot.length === 0 && captions.length > 0 && (oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "") ) {
  1146. // If we are a scrolling table, and no footer has been given, then we need to create
  1147. // a tfoot element for the caption element to be appended to
  1148. tfoot = $('<tfoot/>').appendTo($this);
  1149. }
  1150. if ( tfoot.length === 0 || tfoot.children().length === 0 ) {
  1151. $this.addClass( oClasses.sNoFooter );
  1152. }
  1153. else if ( tfoot.length > 0 ) {
  1154. oSettings.nTFoot = tfoot[0];
  1155. _fnDetectHeader( oSettings.aoFooter, oSettings.nTFoot );
  1156. }
  1157. /* Check if there is data passing into the constructor */
  1158. if ( oInit.aaData ) {
  1159. for ( i=0 ; i<oInit.aaData.length ; i++ ) {
  1160. _fnAddData( oSettings, oInit.aaData[ i ] );
  1161. }
  1162. }
  1163. else if ( oSettings.bDeferLoading || _fnDataSource( oSettings ) == 'dom' ) {
  1164. /* Grab the data from the page - only do this when deferred loading or no Ajax
  1165. * source since there is no point in reading the DOM data if we are then going
  1166. * to replace it with Ajax data
  1167. */
  1168. _fnAddTr( oSettings, $(oSettings.nTBody).children('tr') );
  1169. }
  1170. /* Copy the data index array */
  1171. oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
  1172. /* Initialisation complete - table can be drawn */
  1173. oSettings.bInitialised = true;
  1174. /* Check if we need to initialise the table (it might not have been handed off to the
  1175. * language processor)
  1176. */
  1177. if ( bInitHandedOff === false ) {
  1178. _fnInitialise( oSettings );
  1179. }
  1180. };
  1181. /* Must be done after everything which can be overridden by the state saving! */
  1182. if ( oInit.bStateSave )
  1183. {
  1184. features.bStateSave = true;
  1185. _fnCallbackReg( oSettings, 'aoDrawCallback', _fnSaveState, 'state_save' );
  1186. _fnLoadState( oSettings, oInit, loadedInit );
  1187. }
  1188. else {
  1189. loadedInit();
  1190. }
  1191. } );
  1192. _that = null;
  1193. return this;
  1194. };
  1195. /*
  1196. * It is useful to have variables which are scoped locally so only the
  1197. * DataTables functions can access them and they don't leak into global space.
  1198. * At the same time these functions are often useful over multiple files in the
  1199. * core and API, so we list, or at least document, all variables which are used
  1200. * by DataTables as private variables here. This also ensures that there is no
  1201. * clashing of variable names and that they can easily referenced for reuse.
  1202. */
  1203. // Defined else where
  1204. // _selector_run
  1205. // _selector_opts
  1206. // _selector_first
  1207. // _selector_row_indexes
  1208. var _ext; // DataTable.ext
  1209. var _Api; // DataTable.Api
  1210. var _api_register; // DataTable.Api.register
  1211. var _api_registerPlural; // DataTable.Api.registerPlural
  1212. var _re_dic = {};
  1213. var _re_new_lines = /[\r\n]/g;
  1214. var _re_html = /<.*?>/g;
  1215. // This is not strict ISO8601 - Date.parse() is quite lax, although
  1216. // implementations differ between browsers.
  1217. var _re_date = /^\d{2,4}[\.\/\-]\d{1,2}[\.\/\-]\d{1,2}([T ]{1}\d{1,2}[:\.]\d{2}([\.:]\d{2})?)?$/;
  1218. // Escape regular expression special characters
  1219. var _re_escape_regex = new RegExp( '(\\' + [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^', '-' ].join('|\\') + ')', 'g' );
  1220. // http://en.wikipedia.org/wiki/Foreign_exchange_market
  1221. // - \u20BD - Russian ruble.
  1222. // - \u20a9 - South Korean Won
  1223. // - \u20BA - Turkish Lira
  1224. // - \u20B9 - Indian Rupee
  1225. // - R - Brazil (R$) and South Africa
  1226. // - fr - Swiss Franc
  1227. // - kr - Swedish krona, Norwegian krone and Danish krone
  1228. // - \u2009 is thin space and \u202F is narrow no-break space, both used in many
  1229. // standards as thousands separators.
  1230. var _re_formatted_numeric = /[',$£€¥%\u2009\u202F\u20BD\u20a9\u20BArfk]/gi;
  1231. var _empty = function ( d ) {
  1232. return !d || d === true || d === '-' ? true : false;
  1233. };
  1234. var _intVal = function ( s ) {
  1235. var integer = parseInt( s, 10 );
  1236. return !isNaN(integer) && isFinite(s) ? integer : null;
  1237. };
  1238. // Convert from a formatted number with characters other than `.` as the
  1239. // decimal place, to a Javascript number
  1240. var _numToDecimal = function ( num, decimalPoint ) {
  1241. // Cache created regular expressions for speed as this function is called often
  1242. if ( ! _re_dic[ decimalPoint ] ) {
  1243. _re_dic[ decimalPoint ] = new RegExp( _fnEscapeRegex( decimalPoint ), 'g' );
  1244. }
  1245. return typeof num === 'string' && decimalPoint !== '.' ?
  1246. num.replace( /\./g, '' ).replace( _re_dic[ decimalPoint ], '.' ) :
  1247. num;
  1248. };
  1249. var _isNumber = function ( d, decimalPoint, formatted ) {
  1250. var strType = typeof d === 'string';
  1251. // If empty return immediately so there must be a number if it is a
  1252. // formatted string (this stops the string "k", or "kr", etc being detected
  1253. // as a formatted number for currency
  1254. if ( _empty( d ) ) {
  1255. return true;
  1256. }
  1257. if ( decimalPoint && strType ) {
  1258. d = _numToDecimal( d, decimalPoint );
  1259. }
  1260. if ( formatted && strType ) {
  1261. d = d.replace( _re_formatted_numeric, '' );
  1262. }
  1263. return !isNaN( parseFloat(d) ) && isFinite( d );
  1264. };
  1265. // A string without HTML in it can be considered to be HTML still
  1266. var _isHtml = function ( d ) {
  1267. return _empty( d ) || typeof d === 'string';
  1268. };
  1269. var _htmlNumeric = function ( d, decimalPoint, formatted ) {
  1270. if ( _empty( d ) ) {
  1271. return true;
  1272. }
  1273. var html = _isHtml( d );
  1274. return ! html ?
  1275. null :
  1276. _isNumber( _stripHtml( d ), decimalPoint, formatted ) ?
  1277. true :
  1278. null;
  1279. };
  1280. var _pluck = function ( a, prop, prop2 ) {
  1281. var out = [];
  1282. var i=0, ien=a.length;
  1283. // Could have the test in the loop for slightly smaller code, but speed
  1284. // is essential here
  1285. if ( prop2 !== undefined ) {
  1286. for ( ; i<ien ; i++ ) {
  1287. if ( a[i] && a[i][ prop ] ) {
  1288. out.push( a[i][ prop ][ prop2 ] );
  1289. }
  1290. }
  1291. }
  1292. else {
  1293. for ( ; i<ien ; i++ ) {
  1294. if ( a[i] ) {
  1295. out.push( a[i][ prop ] );
  1296. }
  1297. }
  1298. }
  1299. return out;
  1300. };
  1301. // Basically the same as _pluck, but rather than looping over `a` we use `order`
  1302. // as the indexes to pick from `a`
  1303. var _pluck_order = function ( a, order, prop, prop2 )
  1304. {
  1305. var out = [];
  1306. var i=0, ien=order.length;
  1307. // Could have the test in the loop for slightly smaller code, but speed
  1308. // is essential here
  1309. if ( prop2 !== undefined ) {
  1310. for ( ; i<ien ; i++ ) {
  1311. if ( a[ order[i] ][ prop ] ) {
  1312. out.push( a[ order[i] ][ prop ][ prop2 ] );
  1313. }
  1314. }
  1315. }
  1316. else {
  1317. for ( ; i<ien ; i++ ) {
  1318. out.push( a[ order[i] ][ prop ] );
  1319. }
  1320. }
  1321. return out;
  1322. };
  1323. var _range = function ( len, start )
  1324. {
  1325. var out = [];
  1326. var end;
  1327. if ( start === undefined ) {
  1328. start = 0;
  1329. end = len;
  1330. }
  1331. else {
  1332. end = start;
  1333. start = len;
  1334. }
  1335. for ( var i=start ; i<end ; i++ ) {
  1336. out.push( i );
  1337. }
  1338. return out;
  1339. };
  1340. var _removeEmpty = function ( a )
  1341. {
  1342. var out = [];
  1343. for ( var i=0, ien=a.length ; i<ien ; i++ ) {
  1344. if ( a[i] ) { // careful - will remove all falsy values!
  1345. out.push( a[i] );
  1346. }
  1347. }
  1348. return out;
  1349. };
  1350. var _stripHtml = function ( d ) {
  1351. return d.replace( _re_html, '' );
  1352. };
  1353. /**
  1354. * Determine if all values in the array are unique. This means we can short
  1355. * cut the _unique method at the cost of a single loop. A sorted array is used
  1356. * to easily check the values.
  1357. *
  1358. * @param {array} src Source array
  1359. * @return {boolean} true if all unique, false otherwise
  1360. * @ignore
  1361. */
  1362. var _areAllUnique = function ( src ) {
  1363. if ( src.length < 2 ) {
  1364. return true;
  1365. }
  1366. var sorted = src.slice().sort();
  1367. var last = sorted[0];
  1368. for ( var i=1, ien=sorted.length ; i<ien ; i++ ) {
  1369. if ( sorted[i] === last ) {
  1370. return false;
  1371. }
  1372. last = sorted[i];
  1373. }
  1374. return true;
  1375. };
  1376. /**
  1377. * Find the unique elements in a source array.
  1378. *
  1379. * @param {array} src Source array
  1380. * @return {array} Array of unique items
  1381. * @ignore
  1382. */
  1383. var _unique = function ( src )
  1384. {
  1385. if ( _areAllUnique( src ) ) {
  1386. return src.slice();
  1387. }
  1388. // A faster unique method is to use object keys to identify used values,
  1389. // but this doesn't work with arrays or objects, which we must also
  1390. // consider. See jsperf.com/compare-array-unique-versions/4 for more
  1391. // information.
  1392. var
  1393. out = [],
  1394. val,
  1395. i, ien=src.length,
  1396. j, k=0;
  1397. again: for ( i=0 ; i<ien ; i++ ) {
  1398. val = src[i];
  1399. for ( j=0 ; j<k ; j++ ) {
  1400. if ( out[j] === val ) {
  1401. continue again;
  1402. }
  1403. }
  1404. out.push( val );
  1405. k++;
  1406. }
  1407. return out;
  1408. };
  1409. /**
  1410. * DataTables utility methods
  1411. *
  1412. * This namespace provides helper methods that DataTables uses internally to
  1413. * create a DataTable, but which are not exclusively used only for DataTables.
  1414. * These methods can be used by extension authors to save the duplication of
  1415. * code.
  1416. *
  1417. * @namespace
  1418. */
  1419. DataTable.util = {
  1420. /**
  1421. * Throttle the calls to a function. Arguments and context are maintained
  1422. * for the throttled function.
  1423. *
  1424. * @param {function} fn Function to be called
  1425. * @param {integer} freq Call frequency in mS
  1426. * @return {function} Wrapped function
  1427. */
  1428. throttle: function ( fn, freq ) {
  1429. var
  1430. frequency = freq !== undefined ? freq : 200,
  1431. last,
  1432. timer;
  1433. return function () {
  1434. var
  1435. that = this,
  1436. now = +new Date(),
  1437. args = arguments;
  1438. if ( last && now < last + frequency ) {
  1439. clearTimeout( timer );
  1440. timer = setTimeout( function () {
  1441. last = undefined;
  1442. fn.apply( that, args );
  1443. }, frequency );
  1444. }
  1445. else {
  1446. last = now;
  1447. fn.apply( that, args );
  1448. }
  1449. };
  1450. },
  1451. /**
  1452. * Escape a string such that it can be used in a regular expression
  1453. *
  1454. * @param {string} val string to escape
  1455. * @returns {string} escaped string
  1456. */
  1457. escapeRegex: function ( val ) {
  1458. return val.replace( _re_escape_regex, '\\$1' );
  1459. }
  1460. };
  1461. /**
  1462. * Create a mapping object that allows camel case parameters to be looked up
  1463. * for their Hungarian counterparts. The mapping is stored in a private
  1464. * parameter called `_hungarianMap` which can be accessed on the source object.
  1465. * @param {object} o
  1466. * @memberof DataTable#oApi
  1467. */
  1468. function _fnHungarianMap ( o )
  1469. {
  1470. var
  1471. hungarian = 'a aa ai ao as b fn i m o s ',
  1472. match,
  1473. newKey,
  1474. map = {};
  1475. $.each( o, function (key, val) {
  1476. match = key.match(/^([^A-Z]+?)([A-Z])/);
  1477. if ( match && hungarian.indexOf(match[1]+' ') !== -1 )
  1478. {
  1479. newKey = key.replace( match[0], match[2].toLowerCase() );
  1480. map[ newKey ] = key;
  1481. if ( match[1] === 'o' )
  1482. {
  1483. _fnHungarianMap( o[key] );
  1484. }
  1485. }
  1486. } );
  1487. o._hungarianMap = map;
  1488. }
  1489. /**
  1490. * Convert from camel case parameters to Hungarian, based on a Hungarian map
  1491. * created by _fnHungarianMap.
  1492. * @param {object} src The model object which holds all parameters that can be
  1493. * mapped.
  1494. * @param {object} user The object to convert from camel case to Hungarian.
  1495. * @param {boolean} force When set to `true`, properties which already have a
  1496. * Hungarian value in the `user` object will be overwritten. Otherwise they
  1497. * won't be.
  1498. * @memberof DataTable#oApi
  1499. */
  1500. function _fnCamelToHungarian ( src, user, force )
  1501. {
  1502. if ( ! src._hungarianMap ) {
  1503. _fnHungarianMap( src );
  1504. }
  1505. var hungarianKey;
  1506. $.each( user, function (key, val) {
  1507. hungarianKey = src._hungarianMap[ key ];
  1508. if ( hungarianKey !== undefined && (force || user[hungarianKey] === undefined) )
  1509. {
  1510. // For objects, we need to buzz down into the object to copy parameters
  1511. if ( hungarianKey.charAt(0) === 'o' )
  1512. {
  1513. // Copy the camelCase options over to the hungarian
  1514. if ( ! user[ hungarianKey ] ) {
  1515. user[ hungarianKey ] = {};
  1516. }
  1517. $.extend( true, user[hungarianKey], user[key] );
  1518. _fnCamelToHungarian( src[hungarianKey], user[hungarianKey], force );
  1519. }
  1520. else {
  1521. user[hungarianKey] = user[ key ];
  1522. }
  1523. }
  1524. } );
  1525. }
  1526. /**
  1527. * Language compatibility - when certain options are given, and others aren't, we
  1528. * need to duplicate the values over, in order to provide backwards compatibility
  1529. * with older language files.
  1530. * @param {object} oSettings dataTables settings object
  1531. * @memberof DataTable#oApi
  1532. */
  1533. function _fnLanguageCompat( lang )
  1534. {
  1535. var defaults = DataTable.defaults.oLanguage;
  1536. var zeroRecords = lang.sZeroRecords;
  1537. /* Backwards compatibility - if there is no sEmptyTable given, then use the same as
  1538. * sZeroRecords - assuming that is given.
  1539. */
  1540. if ( ! lang.sEmptyTable && zeroRecords &&
  1541. defaults.sEmptyTable === "No data available in table" )
  1542. {
  1543. _fnMap( lang, lang, 'sZeroRecords', 'sEmptyTable' );
  1544. }
  1545. /* Likewise with loading records */
  1546. if ( ! lang.sLoadingRecords && zeroRecords &&
  1547. defaults.sLoadingRecords === "Loading..." )
  1548. {
  1549. _fnMap( lang, lang, 'sZeroRecords', 'sLoadingRecords' );
  1550. }
  1551. // Old parameter name of the thousands separator mapped onto the new
  1552. if ( lang.sInfoThousands ) {
  1553. lang.sThousands = lang.sInfoThousands;
  1554. }
  1555. var decimal = lang.sDecimal;
  1556. if ( decimal ) {
  1557. _addNumericSort( decimal );
  1558. }
  1559. }
  1560. /**
  1561. * Map one parameter onto another
  1562. * @param {object} o Object to map
  1563. * @param {*} knew The new parameter name
  1564. * @param {*} old The old parameter name
  1565. */
  1566. var _fnCompatMap = function ( o, knew, old ) {
  1567. if ( o[ knew ] !== undefined ) {
  1568. o[ old ] = o[ knew ];
  1569. }
  1570. };
  1571. /**
  1572. * Provide backwards compatibility for the main DT options. Note that the new
  1573. * options are mapped onto the old parameters, so this is an external interface
  1574. * change only.
  1575. * @param {object} init Object to map
  1576. */
  1577. function _fnCompatOpts ( init )
  1578. {
  1579. _fnCompatMap( init, 'ordering', 'bSort' );
  1580. _fnCompatMap( init, 'orderMulti', 'bSortMulti' );
  1581. _fnCompatMap( init, 'orderClasses', 'bSortClasses' );
  1582. _fnCompatMap( init, 'orderCellsTop', 'bSortCellsTop' );
  1583. _fnCompatMap( init, 'order', 'aaSorting' );
  1584. _fnCompatMap( init, 'orderFixed', 'aaSortingFixed' );
  1585. _fnCompatMap( init, 'paging', 'bPaginate' );
  1586. _fnCompatMap( init, 'pagingType', 'sPaginationType' );
  1587. _fnCompatMap( init, 'pageLength', 'iDisplayLength' );
  1588. _fnCompatMap( init, 'searching', 'bFilter' );
  1589. // Boolean initialisation of x-scrolling
  1590. if ( typeof init.sScrollX === 'boolean' ) {
  1591. init.sScrollX = init.sScrollX ? '100%' : '';
  1592. }
  1593. if ( typeof init.scrollX === 'boolean' ) {
  1594. init.scrollX = init.scrollX ? '100%' : '';
  1595. }
  1596. // Column search objects are in an array, so it needs to be converted
  1597. // element by element
  1598. var searchCols = init.aoSearchCols;
  1599. if ( searchCols ) {
  1600. for ( var i=0, ien=searchCols.length ; i<ien ; i++ ) {
  1601. if ( searchCols[i] ) {
  1602. _fnCamelToHungarian( DataTable.models.oSearch, searchCols[i] );
  1603. }
  1604. }
  1605. }
  1606. }
  1607. /**
  1608. * Provide backwards compatibility for column options. Note that the new options
  1609. * are mapped onto the old parameters, so this is an external interface change
  1610. * only.
  1611. * @param {object} init Object to map
  1612. */
  1613. function _fnCompatCols ( init )
  1614. {
  1615. _fnCompatMap( init, 'orderable', 'bSortable' );
  1616. _fnCompatMap( init, 'orderData', 'aDataSort' );
  1617. _fnCompatMap( init, 'orderSequence', 'asSorting' );
  1618. _fnCompatMap( init, 'orderDataType', 'sortDataType' );
  1619. // orderData can be given as an integer
  1620. var dataSort = init.aDataSort;
  1621. if ( typeof dataSort === 'number' && ! $.isArray( dataSort ) ) {
  1622. init.aDataSort = [ dataSort ];
  1623. }
  1624. }
  1625. /**
  1626. * Browser feature detection for capabilities, quirks
  1627. * @param {object} settings dataTables settings object
  1628. * @memberof DataTable#oApi
  1629. */
  1630. function _fnBrowserDetect( settings )
  1631. {
  1632. // We don't need to do this every time DataTables is constructed, the values
  1633. // calculated are specific to the browser and OS configuration which we
  1634. // don't expect to change between initialisations
  1635. if ( ! DataTable.__browser ) {
  1636. var browser = {};
  1637. DataTable.__browser = browser;
  1638. // Scrolling feature / quirks detection
  1639. var n = $('<div/>')
  1640. .css( {
  1641. position: 'fixed',
  1642. top: 0,
  1643. left: $(window).scrollLeft()*-1, // allow for scrolling
  1644. height: 1,
  1645. width: 1,
  1646. overflow: 'hidden'
  1647. } )
  1648. .append(
  1649. $('<div/>')
  1650. .css( {
  1651. position: 'absolute',
  1652. top: 1,
  1653. left: 1,
  1654. width: 100,
  1655. overflow: 'scroll'
  1656. } )
  1657. .append(
  1658. $('<div/>')
  1659. .css( {
  1660. width: '100%',
  1661. height: 10
  1662. } )
  1663. )
  1664. )
  1665. .appendTo( 'body' );
  1666. var outer = n.children();
  1667. var inner = outer.children();
  1668. // Numbers below, in order, are:
  1669. // inner.offsetWidth, inner.clientWidth, outer.offsetWidth, outer.clientWidth
  1670. //
  1671. // IE6 XP: 100 100 100 83
  1672. // IE7 Vista: 100 100 100 83
  1673. // IE 8+ Windows: 83 83 100 83
  1674. // Evergreen Windows: 83 83 100 83
  1675. // Evergreen Mac with scrollbars: 85 85 100 85
  1676. // Evergreen Mac without scrollbars: 100 100 100 100
  1677. // Get scrollbar width
  1678. browser.barWidth = outer[0].offsetWidth - outer[0].clientWidth;
  1679. // IE6/7 will oversize a width 100% element inside a scrolling element, to
  1680. // include the width of the scrollbar, while other browsers ensure the inner
  1681. // element is contained without forcing scrolling
  1682. browser.bScrollOversize = inner[0].offsetWidth === 100 && outer[0].clientWidth !== 100;
  1683. // In rtl text layout, some browsers (most, but not all) will place the
  1684. // scrollbar on the left, rather than the right.
  1685. browser.bScrollbarLeft = Math.round( inner.offset().left ) !== 1;
  1686. // IE8- don't provide height and width for getBoundingClientRect
  1687. browser.bBounding = n[0].getBoundingClientRect().width ? true : false;
  1688. n.remove();
  1689. }
  1690. $.extend( settings.oBrowser, DataTable.__browser );
  1691. settings.oScroll.iBarWidth = DataTable.__browser.barWidth;
  1692. }
  1693. /**
  1694. * Array.prototype reduce[Right] method, used for browsers which don't support
  1695. * JS 1.6. Done this way to reduce code size, since we iterate either way
  1696. * @param {object} settings dataTables settings object
  1697. * @memberof DataTable#oApi
  1698. */
  1699. function _fnReduce ( that, fn, init, start, end, inc )
  1700. {
  1701. var
  1702. i = start,
  1703. value,
  1704. isSet = false;
  1705. if ( init !== undefined ) {
  1706. value = init;
  1707. isSet = true;
  1708. }
  1709. while ( i !== end ) {
  1710. if ( ! that.hasOwnProperty(i) ) {
  1711. continue;
  1712. }
  1713. value = isSet ?
  1714. fn( value, that[i], i, that ) :
  1715. that[i];
  1716. isSet = true;
  1717. i += inc;
  1718. }
  1719. return value;
  1720. }
  1721. /**
  1722. * Add a column to the list used for the table with default values
  1723. * @param {object} oSettings dataTables settings object
  1724. * @param {node} nTh The th element for this column
  1725. * @memberof DataTable#oApi
  1726. */
  1727. function _fnAddColumn( oSettings, nTh )
  1728. {
  1729. // Add column to aoColumns array
  1730. var oDefaults = DataTable.defaults.column;
  1731. var iCol = oSettings.aoColumns.length;
  1732. var oCol = $.extend( {}, DataTable.models.oColumn, oDefaults, {
  1733. "nTh": nTh ? nTh : document.createElement('th'),
  1734. "sTitle": oDefaults.sTitle ? oDefaults.sTitle : nTh ? nTh.innerHTML : '',
  1735. "aDataSort": oDefaults.aDataSort ? oDefaults.aDataSort : [iCol],
  1736. "mData": oDefaults.mData ? oDefaults.mData : iCol,
  1737. idx: iCol
  1738. } );
  1739. oSettings.aoColumns.push( oCol );
  1740. // Add search object for column specific search. Note that the `searchCols[ iCol ]`
  1741. // passed into extend can be undefined. This allows the user to give a default
  1742. // with only some of the parameters defined, and also not give a default
  1743. var searchCols = oSettings.aoPreSearchCols;
  1744. searchCols[ iCol ] = $.extend( {}, DataTable.models.oSearch, searchCols[ iCol ] );
  1745. // Use the default column options function to initialise classes etc
  1746. _fnColumnOptions( oSettings, iCol, $(nTh).data() );
  1747. }
  1748. /**
  1749. * Apply options for a column
  1750. * @param {object} oSettings dataTables settings object
  1751. * @param {int} iCol column index to consider
  1752. * @param {object} oOptions object with sType, bVisible and bSearchable etc
  1753. * @memberof DataTable#oApi
  1754. */
  1755. function _fnColumnOptions( oSettings, iCol, oOptions )
  1756. {
  1757. var oCol = oSettings.aoColumns[ iCol ];
  1758. var oClasses = oSettings.oClasses;
  1759. var th = $(oCol.nTh);
  1760. // Try to get width information from the DOM. We can't get it from CSS
  1761. // as we'd need to parse the CSS stylesheet. `width` option can override
  1762. if ( ! oCol.sWidthOrig ) {
  1763. // Width attribute
  1764. oCol.sWidthOrig = th.attr('width') || null;
  1765. // Style attribute
  1766. var t = (th.attr('style') || '').match(/width:\s*(\d+[pxem%]+)/);
  1767. if ( t ) {
  1768. oCol.sWidthOrig = t[1];
  1769. }
  1770. }
  1771. /* User specified column options */
  1772. if ( oOptions !== undefined && oOptions !== null )
  1773. {
  1774. // Backwards compatibility
  1775. _fnCompatCols( oOptions );
  1776. // Map camel case parameters to their Hungarian counterparts
  1777. _fnCamelToHungarian( DataTable.defaults.column, oOptions );
  1778. /* Backwards compatibility for mDataProp */
  1779. if ( oOptions.mDataProp !== undefined && !oOptions.mData )
  1780. {
  1781. oOptions.mData = oOptions.mDataProp;
  1782. }
  1783. if ( oOptions.sType )
  1784. {
  1785. oCol._sManualType = oOptions.sType;
  1786. }
  1787. // `class` is a reserved word in Javascript, so we need to provide
  1788. // the ability to use a valid name for the camel case input
  1789. if ( oOptions.className && ! oOptions.sClass )
  1790. {
  1791. oOptions.sClass = oOptions.className;
  1792. }
  1793. $.extend( oCol, oOptions );
  1794. _fnMap( oCol, oOptions, "sWidth", "sWidthOrig" );
  1795. /* iDataSort to be applied (backwards compatibility), but aDataSort will take
  1796. * priority if defined
  1797. */
  1798. if ( oOptions.iDataSort !== undefined )
  1799. {
  1800. oCol.aDataSort = [ oOptions.iDataSort ];
  1801. }
  1802. _fnMap( oCol, oOptions, "aDataSort" );
  1803. }
  1804. /* Cache the data get and set functions for speed */
  1805. var mDataSrc = oCol.mData;
  1806. var mData = _fnGetObjectDataFn( mDataSrc );
  1807. var mRender = oCol.mRender ? _fnGetObjectDataFn( oCol.mRender ) : null;
  1808. var attrTest = function( src ) {
  1809. return typeof src === 'string' && src.indexOf('@') !== -1;
  1810. };
  1811. oCol._bAttrSrc = $.isPlainObject( mDataSrc ) && (
  1812. attrTest(mDataSrc.sort) || attrTest(mDataSrc.type) || attrTest(mDataSrc.filter)
  1813. );
  1814. oCol._setter = null;
  1815. oCol.fnGetData = function (rowData, type, meta) {
  1816. var innerData = mData( rowData, type, undefined, meta );
  1817. return mRender && type ?
  1818. mRender( innerData, type, rowData, meta ) :
  1819. innerData;
  1820. };
  1821. oCol.fnSetData = function ( rowData, val, meta ) {
  1822. return _fnSetObjectDataFn( mDataSrc )( rowData, val, meta );
  1823. };
  1824. // Indicate if DataTables should read DOM data as an object or array
  1825. // Used in _fnGetRowElements
  1826. if ( typeof mDataSrc !== 'number' ) {
  1827. oSettings._rowReadObject = true;
  1828. }
  1829. /* Feature sorting overrides column specific when off */
  1830. if ( !oSettings.oFeatures.bSort )
  1831. {
  1832. oCol.bSortable = false;
  1833. th.addClass( oClasses.sSortableNone ); // Have to add class here as order event isn't called
  1834. }
  1835. /* Check that the class assignment is correct for sorting */
  1836. var bAsc = $.inArray('asc', oCol.asSorting) !== -1;
  1837. var bDesc = $.inArray('desc', oCol.asSorting) !== -1;
  1838. if ( !oCol.bSortable || (!bAsc && !bDesc) )
  1839. {
  1840. oCol.sSortingClass = oClasses.sSortableNone;
  1841. oCol.sSortingClassJUI = "";
  1842. }
  1843. else if ( bAsc && !bDesc )
  1844. {
  1845. oCol.sSortingClass = oClasses.sSortableAsc;
  1846. oCol.sSortingClassJUI = oClasses.sSortJUIAscAllowed;
  1847. }
  1848. else if ( !bAsc && bDesc )
  1849. {
  1850. oCol.sSortingClass = oClasses.sSortableDesc;
  1851. oCol.sSortingClassJUI = oClasses.sSortJUIDescAllowed;
  1852. }
  1853. else
  1854. {
  1855. oCol.sSortingClass = oClasses.sSortable;
  1856. oCol.sSortingClassJUI = oClasses.sSortJUI;
  1857. }
  1858. }
  1859. /**
  1860. * Adjust the table column widths for new data. Note: you would probably want to
  1861. * do a redraw after calling this function!
  1862. * @param {object} settings dataTables settings object
  1863. * @memberof DataTable#oApi
  1864. */
  1865. function _fnAdjustColumnSizing ( settings )
  1866. {
  1867. /* Not interested in doing column width calculation if auto-width is disabled */
  1868. if ( settings.oFeatures.bAutoWidth !== false )
  1869. {
  1870. var columns = settings.aoColumns;
  1871. _fnCalculateColumnWidths( settings );
  1872. for ( var i=0 , iLen=columns.length ; i<iLen ; i++ )
  1873. {
  1874. columns[i].nTh.style.width = columns[i].sWidth;
  1875. }
  1876. }
  1877. var scroll = settings.oScroll;
  1878. if ( scroll.sY !== '' || scroll.sX !== '')
  1879. {
  1880. _fnScrollDraw( settings );
  1881. }
  1882. _fnCallbackFire( settings, null, 'column-sizing', [settings] );
  1883. }
  1884. /**
  1885. * Covert the index of a visible column to the index in the data array (take account
  1886. * of hidden columns)
  1887. * @param {object} oSettings dataTables settings object
  1888. * @param {int} iMatch Visible column index to lookup
  1889. * @returns {int} i the data index
  1890. * @memberof DataTable#oApi
  1891. */
  1892. function _fnVisibleToColumnIndex( oSettings, iMatch )
  1893. {
  1894. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  1895. return typeof aiVis[iMatch] === 'number' ?
  1896. aiVis[iMatch] :
  1897. null;
  1898. }
  1899. /**
  1900. * Covert the index of an index in the data array and convert it to the visible
  1901. * column index (take account of hidden columns)
  1902. * @param {int} iMatch Column index to lookup
  1903. * @param {object} oSettings dataTables settings object
  1904. * @returns {int} i the data index
  1905. * @memberof DataTable#oApi
  1906. */
  1907. function _fnColumnIndexToVisible( oSettings, iMatch )
  1908. {
  1909. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  1910. var iPos = $.inArray( iMatch, aiVis );
  1911. return iPos !== -1 ? iPos : null;
  1912. }
  1913. /**
  1914. * Get the number of visible columns
  1915. * @param {object} oSettings dataTables settings object
  1916. * @returns {int} i the number of visible columns
  1917. * @memberof DataTable#oApi
  1918. */
  1919. function _fnVisbleColumns( oSettings )
  1920. {
  1921. var vis = 0;
  1922. // No reduce in IE8, use a loop for now
  1923. $.each( oSettings.aoColumns, function ( i, col ) {
  1924. if ( col.bVisible && $(col.nTh).css('display') !== 'none' ) {
  1925. vis++;
  1926. }
  1927. } );
  1928. return vis;
  1929. }
  1930. /**
  1931. * Get an array of column indexes that match a given property
  1932. * @param {object} oSettings dataTables settings object
  1933. * @param {string} sParam Parameter in aoColumns to look for - typically
  1934. * bVisible or bSearchable
  1935. * @returns {array} Array of indexes with matched properties
  1936. * @memberof DataTable#oApi
  1937. */
  1938. function _fnGetColumns( oSettings, sParam )
  1939. {
  1940. var a = [];
  1941. $.map( oSettings.aoColumns, function(val, i) {
  1942. if ( val[sParam] ) {
  1943. a.push( i );
  1944. }
  1945. } );
  1946. return a;
  1947. }
  1948. /**
  1949. * Calculate the 'type' of a column
  1950. * @param {object} settings dataTables settings object
  1951. * @memberof DataTable#oApi
  1952. */
  1953. function _fnColumnTypes ( settings )
  1954. {
  1955. var columns = settings.aoColumns;
  1956. var data = settings.aoData;
  1957. var types = DataTable.ext.type.detect;
  1958. var i, ien, j, jen, k, ken;
  1959. var col, cell, detectedType, cache;
  1960. // For each column, spin over the
  1961. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  1962. col = columns[i];
  1963. cache = [];
  1964. if ( ! col.sType && col._sManualType ) {
  1965. col.sType = col._sManualType;
  1966. }
  1967. else if ( ! col.sType ) {
  1968. for ( j=0, jen=types.length ; j<jen ; j++ ) {
  1969. for ( k=0, ken=data.length ; k<ken ; k++ ) {
  1970. // Use a cache array so we only need to get the type data
  1971. // from the formatter once (when using multiple detectors)
  1972. if ( cache[k] === undefined ) {
  1973. cache[k] = _fnGetCellData( settings, k, i, 'type' );
  1974. }
  1975. detectedType = types[j]( cache[k], settings );
  1976. // If null, then this type can't apply to this column, so
  1977. // rather than testing all cells, break out. There is an
  1978. // exception for the last type which is `html`. We need to
  1979. // scan all rows since it is possible to mix string and HTML
  1980. // types
  1981. if ( ! detectedType && j !== types.length-1 ) {
  1982. break;
  1983. }
  1984. // Only a single match is needed for html type since it is
  1985. // bottom of the pile and very similar to string
  1986. if ( detectedType === 'html' ) {
  1987. break;
  1988. }
  1989. }
  1990. // Type is valid for all data points in the column - use this
  1991. // type
  1992. if ( detectedType ) {
  1993. col.sType = detectedType;
  1994. break;
  1995. }
  1996. }
  1997. // Fall back - if no type was detected, always use string
  1998. if ( ! col.sType ) {
  1999. col.sType = 'string';
  2000. }
  2001. }
  2002. }
  2003. }
  2004. /**
  2005. * Take the column definitions and static columns arrays and calculate how
  2006. * they relate to column indexes. The callback function will then apply the
  2007. * definition found for a column to a suitable configuration object.
  2008. * @param {object} oSettings dataTables settings object
  2009. * @param {array} aoColDefs The aoColumnDefs array that is to be applied
  2010. * @param {array} aoCols The aoColumns array that defines columns individually
  2011. * @param {function} fn Callback function - takes two parameters, the calculated
  2012. * column index and the definition for that column.
  2013. * @memberof DataTable#oApi
  2014. */
  2015. function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, fn )
  2016. {
  2017. var i, iLen, j, jLen, k, kLen, def;
  2018. var columns = oSettings.aoColumns;
  2019. // Column definitions with aTargets
  2020. if ( aoColDefs )
  2021. {
  2022. /* Loop over the definitions array - loop in reverse so first instance has priority */
  2023. for ( i=aoColDefs.length-1 ; i>=0 ; i-- )
  2024. {
  2025. def = aoColDefs[i];
  2026. /* Each definition can target multiple columns, as it is an array */
  2027. var aTargets = def.targets !== undefined ?
  2028. def.targets :
  2029. def.aTargets;
  2030. if ( ! $.isArray( aTargets ) )
  2031. {
  2032. aTargets = [ aTargets ];
  2033. }
  2034. for ( j=0, jLen=aTargets.length ; j<jLen ; j++ )
  2035. {
  2036. if ( typeof aTargets[j] === 'number' && aTargets[j] >= 0 )
  2037. {
  2038. /* Add columns that we don't yet know about */
  2039. while( columns.length <= aTargets[j] )
  2040. {
  2041. _fnAddColumn( oSettings );
  2042. }
  2043. /* Integer, basic index */
  2044. fn( aTargets[j], def );
  2045. }
  2046. else if ( typeof aTargets[j] === 'number' && aTargets[j] < 0 )
  2047. {
  2048. /* Negative integer, right to left column counting */
  2049. fn( columns.length+aTargets[j], def );
  2050. }
  2051. else if ( typeof aTargets[j] === 'string' )
  2052. {
  2053. /* Class name matching on TH element */
  2054. for ( k=0, kLen=columns.length ; k<kLen ; k++ )
  2055. {
  2056. if ( aTargets[j] == "_all" ||
  2057. $(columns[k].nTh).hasClass( aTargets[j] ) )
  2058. {
  2059. fn( k, def );
  2060. }
  2061. }
  2062. }
  2063. }
  2064. }
  2065. }
  2066. // Statically defined columns array
  2067. if ( aoCols )
  2068. {
  2069. for ( i=0, iLen=aoCols.length ; i<iLen ; i++ )
  2070. {
  2071. fn( i, aoCols[i] );
  2072. }
  2073. }
  2074. }
  2075. /**
  2076. * Add a data array to the table, creating DOM node etc. This is the parallel to
  2077. * _fnGatherData, but for adding rows from a Javascript source, rather than a
  2078. * DOM source.
  2079. * @param {object} oSettings dataTables settings object
  2080. * @param {array} aData data array to be added
  2081. * @param {node} [nTr] TR element to add to the table - optional. If not given,
  2082. * DataTables will create a row automatically
  2083. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  2084. * if nTr is.
  2085. * @returns {int} >=0 if successful (index of new aoData entry), -1 if failed
  2086. * @memberof DataTable#oApi
  2087. */
  2088. function _fnAddData ( oSettings, aDataIn, nTr, anTds )
  2089. {
  2090. /* Create the object for storing information about this new row */
  2091. var iRow = oSettings.aoData.length;
  2092. var oData = $.extend( true, {}, DataTable.models.oRow, {
  2093. src: nTr ? 'dom' : 'data',
  2094. idx: iRow
  2095. } );
  2096. oData._aData = aDataIn;
  2097. oSettings.aoData.push( oData );
  2098. /* Create the cells */
  2099. var nTd, sThisType;
  2100. var columns = oSettings.aoColumns;
  2101. // Invalidate the column types as the new data needs to be revalidated
  2102. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  2103. {
  2104. columns[i].sType = null;
  2105. }
  2106. /* Add to the display array */
  2107. oSettings.aiDisplayMaster.push( iRow );
  2108. var id = oSettings.rowIdFn( aDataIn );
  2109. if ( id !== undefined ) {
  2110. oSettings.aIds[ id ] = oData;
  2111. }
  2112. /* Create the DOM information, or register it if already present */
  2113. if ( nTr || ! oSettings.oFeatures.bDeferRender )
  2114. {
  2115. _fnCreateTr( oSettings, iRow, nTr, anTds );
  2116. }
  2117. return iRow;
  2118. }
  2119. /**
  2120. * Add one or more TR elements to the table. Generally we'd expect to
  2121. * use this for reading data from a DOM sourced table, but it could be
  2122. * used for an TR element. Note that if a TR is given, it is used (i.e.
  2123. * it is not cloned).
  2124. * @param {object} settings dataTables settings object
  2125. * @param {array|node|jQuery} trs The TR element(s) to add to the table
  2126. * @returns {array} Array of indexes for the added rows
  2127. * @memberof DataTable#oApi
  2128. */
  2129. function _fnAddTr( settings, trs )
  2130. {
  2131. var row;
  2132. // Allow an individual node to be passed in
  2133. if ( ! (trs instanceof $) ) {
  2134. trs = $(trs);
  2135. }
  2136. return trs.map( function (i, el) {
  2137. row = _fnGetRowElements( settings, el );
  2138. return _fnAddData( settings, row.data, el, row.cells );
  2139. } );
  2140. }
  2141. /**
  2142. * Take a TR element and convert it to an index in aoData
  2143. * @param {object} oSettings dataTables settings object
  2144. * @param {node} n the TR element to find
  2145. * @returns {int} index if the node is found, null if not
  2146. * @memberof DataTable#oApi
  2147. */
  2148. function _fnNodeToDataIndex( oSettings, n )
  2149. {
  2150. return (n._DT_RowIndex!==undefined) ? n._DT_RowIndex : null;
  2151. }
  2152. /**
  2153. * Take a TD element and convert it into a column data index (not the visible index)
  2154. * @param {object} oSettings dataTables settings object
  2155. * @param {int} iRow The row number the TD/TH can be found in
  2156. * @param {node} n The TD/TH element to find
  2157. * @returns {int} index if the node is found, -1 if not
  2158. * @memberof DataTable#oApi
  2159. */
  2160. function _fnNodeToColumnIndex( oSettings, iRow, n )
  2161. {
  2162. return $.inArray( n, oSettings.aoData[ iRow ].anCells );
  2163. }
  2164. /**
  2165. * Get the data for a given cell from the internal cache, taking into account data mapping
  2166. * @param {object} settings dataTables settings object
  2167. * @param {int} rowIdx aoData row id
  2168. * @param {int} colIdx Column index
  2169. * @param {string} type data get type ('display', 'type' 'filter' 'sort')
  2170. * @returns {*} Cell data
  2171. * @memberof DataTable#oApi
  2172. */
  2173. function _fnGetCellData( settings, rowIdx, colIdx, type )
  2174. {
  2175. var draw = settings.iDraw;
  2176. var col = settings.aoColumns[colIdx];
  2177. var rowData = settings.aoData[rowIdx]._aData;
  2178. var defaultContent = col.sDefaultContent;
  2179. var cellData = col.fnGetData( rowData, type, {
  2180. settings: settings,
  2181. row: rowIdx,
  2182. col: colIdx
  2183. } );
  2184. if ( cellData === undefined ) {
  2185. if ( settings.iDrawError != draw && defaultContent === null ) {
  2186. _fnLog( settings, 0, "Requested unknown parameter "+
  2187. (typeof col.mData=='function' ? '{function}' : "'"+col.mData+"'")+
  2188. " for row "+rowIdx+", column "+colIdx, 4 );
  2189. settings.iDrawError = draw;
  2190. }
  2191. return defaultContent;
  2192. }
  2193. // When the data source is null and a specific data type is requested (i.e.
  2194. // not the original data), we can use default column data
  2195. if ( (cellData === rowData || cellData === null) && defaultContent !== null && type !== undefined ) {
  2196. cellData = defaultContent;
  2197. }
  2198. else if ( typeof cellData === 'function' ) {
  2199. // If the data source is a function, then we run it and use the return,
  2200. // executing in the scope of the data object (for instances)
  2201. return cellData.call( rowData );
  2202. }
  2203. if ( cellData === null && type == 'display' ) {
  2204. return '';
  2205. }
  2206. return cellData;
  2207. }
  2208. /**
  2209. * Set the value for a specific cell, into the internal data cache
  2210. * @param {object} settings dataTables settings object
  2211. * @param {int} rowIdx aoData row id
  2212. * @param {int} colIdx Column index
  2213. * @param {*} val Value to set
  2214. * @memberof DataTable#oApi
  2215. */
  2216. function _fnSetCellData( settings, rowIdx, colIdx, val )
  2217. {
  2218. var col = settings.aoColumns[colIdx];
  2219. var rowData = settings.aoData[rowIdx]._aData;
  2220. col.fnSetData( rowData, val, {
  2221. settings: settings,
  2222. row: rowIdx,
  2223. col: colIdx
  2224. } );
  2225. }
  2226. // Private variable that is used to match action syntax in the data property object
  2227. var __reArray = /\[.*?\]$/;
  2228. var __reFn = /\(\)$/;
  2229. /**
  2230. * Split string on periods, taking into account escaped periods
  2231. * @param {string} str String to split
  2232. * @return {array} Split string
  2233. */
  2234. function _fnSplitObjNotation( str )
  2235. {
  2236. return $.map( str.match(/(\\.|[^\.])+/g) || [''], function ( s ) {
  2237. return s.replace(/\\\./g, '.');
  2238. } );
  2239. }
  2240. /**
  2241. * Return a function that can be used to get data from a source object, taking
  2242. * into account the ability to use nested objects as a source
  2243. * @param {string|int|function} mSource The data source for the object
  2244. * @returns {function} Data get function
  2245. * @memberof DataTable#oApi
  2246. */
  2247. function _fnGetObjectDataFn( mSource )
  2248. {
  2249. if ( $.isPlainObject( mSource ) )
  2250. {
  2251. /* Build an object of get functions, and wrap them in a single call */
  2252. var o = {};
  2253. $.each( mSource, function (key, val) {
  2254. if ( val ) {
  2255. o[key] = _fnGetObjectDataFn( val );
  2256. }
  2257. } );
  2258. return function (data, type, row, meta) {
  2259. var t = o[type] || o._;
  2260. return t !== undefined ?
  2261. t(data, type, row, meta) :
  2262. data;
  2263. };
  2264. }
  2265. else if ( mSource === null )
  2266. {
  2267. /* Give an empty string for rendering / sorting etc */
  2268. return function (data) { // type, row and meta also passed, but not used
  2269. return data;
  2270. };
  2271. }
  2272. else if ( typeof mSource === 'function' )
  2273. {
  2274. return function (data, type, row, meta) {
  2275. return mSource( data, type, row, meta );
  2276. };
  2277. }
  2278. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  2279. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  2280. {
  2281. /* If there is a . in the source string then the data source is in a
  2282. * nested object so we loop over the data for each level to get the next
  2283. * level down. On each loop we test for undefined, and if found immediately
  2284. * return. This allows entire objects to be missing and sDefaultContent to
  2285. * be used if defined, rather than throwing an error
  2286. */
  2287. var fetchData = function (data, type, src) {
  2288. var arrayNotation, funcNotation, out, innerSrc;
  2289. if ( src !== "" )
  2290. {
  2291. var a = _fnSplitObjNotation( src );
  2292. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  2293. {
  2294. // Check if we are dealing with special notation
  2295. arrayNotation = a[i].match(__reArray);
  2296. funcNotation = a[i].match(__reFn);
  2297. if ( arrayNotation )
  2298. {
  2299. // Array notation
  2300. a[i] = a[i].replace(__reArray, '');
  2301. // Condition allows simply [] to be passed in
  2302. if ( a[i] !== "" ) {
  2303. data = data[ a[i] ];
  2304. }
  2305. out = [];
  2306. // Get the remainder of the nested object to get
  2307. a.splice( 0, i+1 );
  2308. innerSrc = a.join('.');
  2309. // Traverse each entry in the array getting the properties requested
  2310. if ( $.isArray( data ) ) {
  2311. for ( var j=0, jLen=data.length ; j<jLen ; j++ ) {
  2312. out.push( fetchData( data[j], type, innerSrc ) );
  2313. }
  2314. }
  2315. // If a string is given in between the array notation indicators, that
  2316. // is used to join the strings together, otherwise an array is returned
  2317. var join = arrayNotation[0].substring(1, arrayNotation[0].length-1);
  2318. data = (join==="") ? out : out.join(join);
  2319. // The inner call to fetchData has already traversed through the remainder
  2320. // of the source requested, so we exit from the loop
  2321. break;
  2322. }
  2323. else if ( funcNotation )
  2324. {
  2325. // Function call
  2326. a[i] = a[i].replace(__reFn, '');
  2327. data = data[ a[i] ]();
  2328. continue;
  2329. }
  2330. if ( data === null || data[ a[i] ] === undefined )
  2331. {
  2332. return undefined;
  2333. }
  2334. data = data[ a[i] ];
  2335. }
  2336. }
  2337. return data;
  2338. };
  2339. return function (data, type) { // row and meta also passed, but not used
  2340. return fetchData( data, type, mSource );
  2341. };
  2342. }
  2343. else
  2344. {
  2345. /* Array or flat object mapping */
  2346. return function (data, type) { // row and meta also passed, but not used
  2347. return data[mSource];
  2348. };
  2349. }
  2350. }
  2351. /**
  2352. * Return a function that can be used to set data from a source object, taking
  2353. * into account the ability to use nested objects as a source
  2354. * @param {string|int|function} mSource The data source for the object
  2355. * @returns {function} Data set function
  2356. * @memberof DataTable#oApi
  2357. */
  2358. function _fnSetObjectDataFn( mSource )
  2359. {
  2360. if ( $.isPlainObject( mSource ) )
  2361. {
  2362. /* Unlike get, only the underscore (global) option is used for for
  2363. * setting data since we don't know the type here. This is why an object
  2364. * option is not documented for `mData` (which is read/write), but it is
  2365. * for `mRender` which is read only.
  2366. */
  2367. return _fnSetObjectDataFn( mSource._ );
  2368. }
  2369. else if ( mSource === null )
  2370. {
  2371. /* Nothing to do when the data source is null */
  2372. return function () {};
  2373. }
  2374. else if ( typeof mSource === 'function' )
  2375. {
  2376. return function (data, val, meta) {
  2377. mSource( data, 'set', val, meta );
  2378. };
  2379. }
  2380. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  2381. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  2382. {
  2383. /* Like the get, we need to get data from a nested object */
  2384. var setData = function (data, val, src) {
  2385. var a = _fnSplitObjNotation( src ), b;
  2386. var aLast = a[a.length-1];
  2387. var arrayNotation, funcNotation, o, innerSrc;
  2388. for ( var i=0, iLen=a.length-1 ; i<iLen ; i++ )
  2389. {
  2390. // Check if we are dealing with an array notation request
  2391. arrayNotation = a[i].match(__reArray);
  2392. funcNotation = a[i].match(__reFn);
  2393. if ( arrayNotation )
  2394. {
  2395. a[i] = a[i].replace(__reArray, '');
  2396. data[ a[i] ] = [];
  2397. // Get the remainder of the nested object to set so we can recurse
  2398. b = a.slice();
  2399. b.splice( 0, i+1 );
  2400. innerSrc = b.join('.');
  2401. // Traverse each entry in the array setting the properties requested
  2402. if ( $.isArray( val ) )
  2403. {
  2404. for ( var j=0, jLen=val.length ; j<jLen ; j++ )
  2405. {
  2406. o = {};
  2407. setData( o, val[j], innerSrc );
  2408. data[ a[i] ].push( o );
  2409. }
  2410. }
  2411. else
  2412. {
  2413. // We've been asked to save data to an array, but it
  2414. // isn't array data to be saved. Best that can be done
  2415. // is to just save the value.
  2416. data[ a[i] ] = val;
  2417. }
  2418. // The inner call to setData has already traversed through the remainder
  2419. // of the source and has set the data, thus we can exit here
  2420. return;
  2421. }
  2422. else if ( funcNotation )
  2423. {
  2424. // Function call
  2425. a[i] = a[i].replace(__reFn, '');
  2426. data = data[ a[i] ]( val );
  2427. }
  2428. // If the nested object doesn't currently exist - since we are
  2429. // trying to set the value - create it
  2430. if ( data[ a[i] ] === null || data[ a[i] ] === undefined )
  2431. {
  2432. data[ a[i] ] = {};
  2433. }
  2434. data = data[ a[i] ];
  2435. }
  2436. // Last item in the input - i.e, the actual set
  2437. if ( aLast.match(__reFn ) )
  2438. {
  2439. // Function call
  2440. data = data[ aLast.replace(__reFn, '') ]( val );
  2441. }
  2442. else
  2443. {
  2444. // If array notation is used, we just want to strip it and use the property name
  2445. // and assign the value. If it isn't used, then we get the result we want anyway
  2446. data[ aLast.replace(__reArray, '') ] = val;
  2447. }
  2448. };
  2449. return function (data, val) { // meta is also passed in, but not used
  2450. return setData( data, val, mSource );
  2451. };
  2452. }
  2453. else
  2454. {
  2455. /* Array or flat object mapping */
  2456. return function (data, val) { // meta is also passed in, but not used
  2457. data[mSource] = val;
  2458. };
  2459. }
  2460. }
  2461. /**
  2462. * Return an array with the full table data
  2463. * @param {object} oSettings dataTables settings object
  2464. * @returns array {array} aData Master data array
  2465. * @memberof DataTable#oApi
  2466. */
  2467. function _fnGetDataMaster ( settings )
  2468. {
  2469. return _pluck( settings.aoData, '_aData' );
  2470. }
  2471. /**
  2472. * Nuke the table
  2473. * @param {object} oSettings dataTables settings object
  2474. * @memberof DataTable#oApi
  2475. */
  2476. function _fnClearTable( settings )
  2477. {
  2478. settings.aoData.length = 0;
  2479. settings.aiDisplayMaster.length = 0;
  2480. settings.aiDisplay.length = 0;
  2481. settings.aIds = {};
  2482. }
  2483. /**
  2484. * Take an array of integers (index array) and remove a target integer (value - not
  2485. * the key!)
  2486. * @param {array} a Index array to target
  2487. * @param {int} iTarget value to find
  2488. * @memberof DataTable#oApi
  2489. */
  2490. function _fnDeleteIndex( a, iTarget, splice )
  2491. {
  2492. var iTargetIndex = -1;
  2493. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  2494. {
  2495. if ( a[i] == iTarget )
  2496. {
  2497. iTargetIndex = i;
  2498. }
  2499. else if ( a[i] > iTarget )
  2500. {
  2501. a[i]--;
  2502. }
  2503. }
  2504. if ( iTargetIndex != -1 && splice === undefined )
  2505. {
  2506. a.splice( iTargetIndex, 1 );
  2507. }
  2508. }
  2509. /**
  2510. * Mark cached data as invalid such that a re-read of the data will occur when
  2511. * the cached data is next requested. Also update from the data source object.
  2512. *
  2513. * @param {object} settings DataTables settings object
  2514. * @param {int} rowIdx Row index to invalidate
  2515. * @param {string} [src] Source to invalidate from: undefined, 'auto', 'dom'
  2516. * or 'data'
  2517. * @param {int} [colIdx] Column index to invalidate. If undefined the whole
  2518. * row will be invalidated
  2519. * @memberof DataTable#oApi
  2520. *
  2521. * @todo For the modularisation of v1.11 this will need to become a callback, so
  2522. * the sort and filter methods can subscribe to it. That will required
  2523. * initialisation options for sorting, which is why it is not already baked in
  2524. */
  2525. function _fnInvalidate( settings, rowIdx, src, colIdx )
  2526. {
  2527. var row = settings.aoData[ rowIdx ];
  2528. var i, ien;
  2529. var cellWrite = function ( cell, col ) {
  2530. // This is very frustrating, but in IE if you just write directly
  2531. // to innerHTML, and elements that are overwritten are GC'ed,
  2532. // even if there is a reference to them elsewhere
  2533. while ( cell.childNodes.length ) {
  2534. cell.removeChild( cell.firstChild );
  2535. }
  2536. cell.innerHTML = _fnGetCellData( settings, rowIdx, col, 'display' );
  2537. };
  2538. // Are we reading last data from DOM or the data object?
  2539. if ( src === 'dom' || ((! src || src === 'auto') && row.src === 'dom') ) {
  2540. // Read the data from the DOM
  2541. row._aData = _fnGetRowElements(
  2542. settings, row, colIdx, colIdx === undefined ? undefined : row._aData
  2543. )
  2544. .data;
  2545. }
  2546. else {
  2547. // Reading from data object, update the DOM
  2548. var cells = row.anCells;
  2549. if ( cells ) {
  2550. if ( colIdx !== undefined ) {
  2551. cellWrite( cells[colIdx], colIdx );
  2552. }
  2553. else {
  2554. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  2555. cellWrite( cells[i], i );
  2556. }
  2557. }
  2558. }
  2559. }
  2560. // For both row and cell invalidation, the cached data for sorting and
  2561. // filtering is nulled out
  2562. row._aSortData = null;
  2563. row._aFilterData = null;
  2564. // Invalidate the type for a specific column (if given) or all columns since
  2565. // the data might have changed
  2566. var cols = settings.aoColumns;
  2567. if ( colIdx !== undefined ) {
  2568. cols[ colIdx ].sType = null;
  2569. }
  2570. else {
  2571. for ( i=0, ien=cols.length ; i<ien ; i++ ) {
  2572. cols[i].sType = null;
  2573. }
  2574. // Update DataTables special `DT_*` attributes for the row
  2575. _fnRowAttributes( settings, row );
  2576. }
  2577. }
  2578. /**
  2579. * Build a data source object from an HTML row, reading the contents of the
  2580. * cells that are in the row.
  2581. *
  2582. * @param {object} settings DataTables settings object
  2583. * @param {node|object} TR element from which to read data or existing row
  2584. * object from which to re-read the data from the cells
  2585. * @param {int} [colIdx] Optional column index
  2586. * @param {array|object} [d] Data source object. If `colIdx` is given then this
  2587. * parameter should also be given and will be used to write the data into.
  2588. * Only the column in question will be written
  2589. * @returns {object} Object with two parameters: `data` the data read, in
  2590. * document order, and `cells` and array of nodes (they can be useful to the
  2591. * caller, so rather than needing a second traversal to get them, just return
  2592. * them from here).
  2593. * @memberof DataTable#oApi
  2594. */
  2595. function _fnGetRowElements( settings, row, colIdx, d )
  2596. {
  2597. var
  2598. tds = [],
  2599. td = row.firstChild,
  2600. name, col, o, i=0, contents,
  2601. columns = settings.aoColumns,
  2602. objectRead = settings._rowReadObject;
  2603. // Allow the data object to be passed in, or construct
  2604. d = d !== undefined ?
  2605. d :
  2606. objectRead ?
  2607. {} :
  2608. [];
  2609. var attr = function ( str, td ) {
  2610. if ( typeof str === 'string' ) {
  2611. var idx = str.indexOf('@');
  2612. if ( idx !== -1 ) {
  2613. var attr = str.substring( idx+1 );
  2614. var setter = _fnSetObjectDataFn( str );
  2615. setter( d, td.getAttribute( attr ) );
  2616. }
  2617. }
  2618. };
  2619. // Read data from a cell and store into the data object
  2620. var cellProcess = function ( cell ) {
  2621. if ( colIdx === undefined || colIdx === i ) {
  2622. col = columns[i];
  2623. contents = $.trim(cell.innerHTML);
  2624. if ( col && col._bAttrSrc ) {
  2625. var setter = _fnSetObjectDataFn( col.mData._ );
  2626. setter( d, contents );
  2627. attr( col.mData.sort, cell );
  2628. attr( col.mData.type, cell );
  2629. attr( col.mData.filter, cell );
  2630. }
  2631. else {
  2632. // Depending on the `data` option for the columns the data can
  2633. // be read to either an object or an array.
  2634. if ( objectRead ) {
  2635. if ( ! col._setter ) {
  2636. // Cache the setter function
  2637. col._setter = _fnSetObjectDataFn( col.mData );
  2638. }
  2639. col._setter( d, contents );
  2640. }
  2641. else {
  2642. d[i] = contents;
  2643. }
  2644. }
  2645. }
  2646. i++;
  2647. };
  2648. if ( td ) {
  2649. // `tr` element was passed in
  2650. while ( td ) {
  2651. name = td.nodeName.toUpperCase();
  2652. if ( name == "TD" || name == "TH" ) {
  2653. cellProcess( td );
  2654. tds.push( td );
  2655. }
  2656. td = td.nextSibling;
  2657. }
  2658. }
  2659. else {
  2660. // Existing row object passed in
  2661. tds = row.anCells;
  2662. for ( var j=0, jen=tds.length ; j<jen ; j++ ) {
  2663. cellProcess( tds[j] );
  2664. }
  2665. }
  2666. // Read the ID from the DOM if present
  2667. var rowNode = row.firstChild ? row : row.nTr;
  2668. if ( rowNode ) {
  2669. var id = rowNode.getAttribute( 'id' );
  2670. if ( id ) {
  2671. _fnSetObjectDataFn( settings.rowId )( d, id );
  2672. }
  2673. }
  2674. return {
  2675. data: d,
  2676. cells: tds
  2677. };
  2678. }
  2679. /**
  2680. * Create a new TR element (and it's TD children) for a row
  2681. * @param {object} oSettings dataTables settings object
  2682. * @param {int} iRow Row to consider
  2683. * @param {node} [nTrIn] TR element to add to the table - optional. If not given,
  2684. * DataTables will create a row automatically
  2685. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  2686. * if nTr is.
  2687. * @memberof DataTable#oApi
  2688. */
  2689. function _fnCreateTr ( oSettings, iRow, nTrIn, anTds )
  2690. {
  2691. var
  2692. row = oSettings.aoData[iRow],
  2693. rowData = row._aData,
  2694. cells = [],
  2695. nTr, nTd, oCol,
  2696. i, iLen;
  2697. if ( row.nTr === null )
  2698. {
  2699. nTr = nTrIn || document.createElement('tr');
  2700. row.nTr = nTr;
  2701. row.anCells = cells;
  2702. /* Use a private property on the node to allow reserve mapping from the node
  2703. * to the aoData array for fast look up
  2704. */
  2705. nTr._DT_RowIndex = iRow;
  2706. /* Special parameters can be given by the data source to be used on the row */
  2707. _fnRowAttributes( oSettings, row );
  2708. /* Process each column */
  2709. for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
  2710. {
  2711. oCol = oSettings.aoColumns[i];
  2712. nTd = nTrIn ? anTds[i] : document.createElement( oCol.sCellType );
  2713. nTd._DT_CellIndex = {
  2714. row: iRow,
  2715. column: i
  2716. };
  2717. cells.push( nTd );
  2718. // Need to create the HTML if new, or if a rendering function is defined
  2719. if ( (!nTrIn || oCol.mRender || oCol.mData !== i) &&
  2720. (!$.isPlainObject(oCol.mData) || oCol.mData._ !== i+'.display')
  2721. ) {
  2722. nTd.innerHTML = _fnGetCellData( oSettings, iRow, i, 'display' );
  2723. }
  2724. /* Add user defined class */
  2725. if ( oCol.sClass )
  2726. {
  2727. nTd.className += ' '+oCol.sClass;
  2728. }
  2729. // Visibility - add or remove as required
  2730. if ( oCol.bVisible && ! nTrIn )
  2731. {
  2732. nTr.appendChild( nTd );
  2733. }
  2734. else if ( ! oCol.bVisible && nTrIn )
  2735. {
  2736. nTd.parentNode.removeChild( nTd );
  2737. }
  2738. if ( oCol.fnCreatedCell )
  2739. {
  2740. oCol.fnCreatedCell.call( oSettings.oInstance,
  2741. nTd, _fnGetCellData( oSettings, iRow, i ), rowData, iRow, i
  2742. );
  2743. }
  2744. }
  2745. _fnCallbackFire( oSettings, 'aoRowCreatedCallback', null, [nTr, rowData, iRow] );
  2746. }
  2747. // Remove once webkit bug 131819 and Chromium bug 365619 have been resolved
  2748. // and deployed
  2749. row.nTr.setAttribute( 'role', 'row' );
  2750. }
  2751. /**
  2752. * Add attributes to a row based on the special `DT_*` parameters in a data
  2753. * source object.
  2754. * @param {object} settings DataTables settings object
  2755. * @param {object} DataTables row object for the row to be modified
  2756. * @memberof DataTable#oApi
  2757. */
  2758. function _fnRowAttributes( settings, row )
  2759. {
  2760. var tr = row.nTr;
  2761. var data = row._aData;
  2762. if ( tr ) {
  2763. var id = settings.rowIdFn( data );
  2764. if ( id ) {
  2765. tr.id = id;
  2766. }
  2767. if ( data.DT_RowClass ) {
  2768. // Remove any classes added by DT_RowClass before
  2769. var a = data.DT_RowClass.split(' ');
  2770. row.__rowc = row.__rowc ?
  2771. _unique( row.__rowc.concat( a ) ) :
  2772. a;
  2773. $(tr)
  2774. .removeClass( row.__rowc.join(' ') )
  2775. .addClass( data.DT_RowClass );
  2776. }
  2777. if ( data.DT_RowAttr ) {
  2778. $(tr).attr( data.DT_RowAttr );
  2779. }
  2780. if ( data.DT_RowData ) {
  2781. $(tr).data( data.DT_RowData );
  2782. }
  2783. }
  2784. }
  2785. /**
  2786. * Create the HTML header for the table
  2787. * @param {object} oSettings dataTables settings object
  2788. * @memberof DataTable#oApi
  2789. */
  2790. function _fnBuildHead( oSettings )
  2791. {
  2792. var i, ien, cell, row, column;
  2793. var thead = oSettings.nTHead;
  2794. var tfoot = oSettings.nTFoot;
  2795. var createHeader = $('th, td', thead).length === 0;
  2796. var classes = oSettings.oClasses;
  2797. var columns = oSettings.aoColumns;
  2798. if ( createHeader ) {
  2799. row = $('<tr/>').appendTo( thead );
  2800. }
  2801. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  2802. column = columns[i];
  2803. cell = $( column.nTh ).addClass( column.sClass );
  2804. if ( createHeader ) {
  2805. cell.appendTo( row );
  2806. }
  2807. // 1.11 move into sorting
  2808. if ( oSettings.oFeatures.bSort ) {
  2809. cell.addClass( column.sSortingClass );
  2810. if ( column.bSortable !== false ) {
  2811. cell
  2812. .attr( 'tabindex', oSettings.iTabIndex )
  2813. .attr( 'aria-controls', oSettings.sTableId );
  2814. _fnSortAttachListener( oSettings, column.nTh, i );
  2815. }
  2816. }
  2817. if ( column.sTitle != cell[0].innerHTML ) {
  2818. cell.html( column.sTitle );
  2819. }
  2820. _fnRenderer( oSettings, 'header' )(
  2821. oSettings, cell, column, classes
  2822. );
  2823. }
  2824. if ( createHeader ) {
  2825. _fnDetectHeader( oSettings.aoHeader, thead );
  2826. }
  2827. /* ARIA role for the rows */
  2828. $(thead).find('>tr').attr('role', 'row');
  2829. /* Deal with the footer - add classes if required */
  2830. $(thead).find('>tr>th, >tr>td').addClass( classes.sHeaderTH );
  2831. $(tfoot).find('>tr>th, >tr>td').addClass( classes.sFooterTH );
  2832. // Cache the footer cells. Note that we only take the cells from the first
  2833. // row in the footer. If there is more than one row the user wants to
  2834. // interact with, they need to use the table().foot() method. Note also this
  2835. // allows cells to be used for multiple columns using colspan
  2836. if ( tfoot !== null ) {
  2837. var cells = oSettings.aoFooter[0];
  2838. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  2839. column = columns[i];
  2840. column.nTf = cells[i].cell;
  2841. if ( column.sClass ) {
  2842. $(column.nTf).addClass( column.sClass );
  2843. }
  2844. }
  2845. }
  2846. }
  2847. /**
  2848. * Draw the header (or footer) element based on the column visibility states. The
  2849. * methodology here is to use the layout array from _fnDetectHeader, modified for
  2850. * the instantaneous column visibility, to construct the new layout. The grid is
  2851. * traversed over cell at a time in a rows x columns grid fashion, although each
  2852. * cell insert can cover multiple elements in the grid - which is tracks using the
  2853. * aApplied array. Cell inserts in the grid will only occur where there isn't
  2854. * already a cell in that position.
  2855. * @param {object} oSettings dataTables settings object
  2856. * @param array {objects} aoSource Layout array from _fnDetectHeader
  2857. * @param {boolean} [bIncludeHidden=false] If true then include the hidden columns in the calc,
  2858. * @memberof DataTable#oApi
  2859. */
  2860. function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
  2861. {
  2862. var i, iLen, j, jLen, k, kLen, n, nLocalTr;
  2863. var aoLocal = [];
  2864. var aApplied = [];
  2865. var iColumns = oSettings.aoColumns.length;
  2866. var iRowspan, iColspan;
  2867. if ( ! aoSource )
  2868. {
  2869. return;
  2870. }
  2871. if ( bIncludeHidden === undefined )
  2872. {
  2873. bIncludeHidden = false;
  2874. }
  2875. /* Make a copy of the master layout array, but without the visible columns in it */
  2876. for ( i=0, iLen=aoSource.length ; i<iLen ; i++ )
  2877. {
  2878. aoLocal[i] = aoSource[i].slice();
  2879. aoLocal[i].nTr = aoSource[i].nTr;
  2880. /* Remove any columns which are currently hidden */
  2881. for ( j=iColumns-1 ; j>=0 ; j-- )
  2882. {
  2883. if ( !oSettings.aoColumns[j].bVisible && !bIncludeHidden )
  2884. {
  2885. aoLocal[i].splice( j, 1 );
  2886. }
  2887. }
  2888. /* Prep the applied array - it needs an element for each row */
  2889. aApplied.push( [] );
  2890. }
  2891. for ( i=0, iLen=aoLocal.length ; i<iLen ; i++ )
  2892. {
  2893. nLocalTr = aoLocal[i].nTr;
  2894. /* All cells are going to be replaced, so empty out the row */
  2895. if ( nLocalTr )
  2896. {
  2897. while( (n = nLocalTr.firstChild) )
  2898. {
  2899. nLocalTr.removeChild( n );
  2900. }
  2901. }
  2902. for ( j=0, jLen=aoLocal[i].length ; j<jLen ; j++ )
  2903. {
  2904. iRowspan = 1;
  2905. iColspan = 1;
  2906. /* Check to see if there is already a cell (row/colspan) covering our target
  2907. * insert point. If there is, then there is nothing to do.
  2908. */
  2909. if ( aApplied[i][j] === undefined )
  2910. {
  2911. nLocalTr.appendChild( aoLocal[i][j].cell );
  2912. aApplied[i][j] = 1;
  2913. /* Expand the cell to cover as many rows as needed */
  2914. while ( aoLocal[i+iRowspan] !== undefined &&
  2915. aoLocal[i][j].cell == aoLocal[i+iRowspan][j].cell )
  2916. {
  2917. aApplied[i+iRowspan][j] = 1;
  2918. iRowspan++;
  2919. }
  2920. /* Expand the cell to cover as many columns as needed */
  2921. while ( aoLocal[i][j+iColspan] !== undefined &&
  2922. aoLocal[i][j].cell == aoLocal[i][j+iColspan].cell )
  2923. {
  2924. /* Must update the applied array over the rows for the columns */
  2925. for ( k=0 ; k<iRowspan ; k++ )
  2926. {
  2927. aApplied[i+k][j+iColspan] = 1;
  2928. }
  2929. iColspan++;
  2930. }
  2931. /* Do the actual expansion in the DOM */
  2932. $(aoLocal[i][j].cell)
  2933. .attr('rowspan', iRowspan)
  2934. .attr('colspan', iColspan);
  2935. }
  2936. }
  2937. }
  2938. }
  2939. /**
  2940. * Insert the required TR nodes into the table for display
  2941. * @param {object} oSettings dataTables settings object
  2942. * @memberof DataTable#oApi
  2943. */
  2944. function _fnDraw( oSettings )
  2945. {
  2946. /* Provide a pre-callback function which can be used to cancel the draw is false is returned */
  2947. var aPreDraw = _fnCallbackFire( oSettings, 'aoPreDrawCallback', 'preDraw', [oSettings] );
  2948. if ( $.inArray( false, aPreDraw ) !== -1 )
  2949. {
  2950. _fnProcessingDisplay( oSettings, false );
  2951. return;
  2952. }
  2953. var i, iLen, n;
  2954. var anRows = [];
  2955. var iRowCount = 0;
  2956. var asStripeClasses = oSettings.asStripeClasses;
  2957. var iStripes = asStripeClasses.length;
  2958. var iOpenRows = oSettings.aoOpenRows.length;
  2959. var oLang = oSettings.oLanguage;
  2960. var iInitDisplayStart = oSettings.iInitDisplayStart;
  2961. var bServerSide = _fnDataSource( oSettings ) == 'ssp';
  2962. var aiDisplay = oSettings.aiDisplay;
  2963. oSettings.bDrawing = true;
  2964. /* Check and see if we have an initial draw position from state saving */
  2965. if ( iInitDisplayStart !== undefined && iInitDisplayStart !== -1 )
  2966. {
  2967. oSettings._iDisplayStart = bServerSide ?
  2968. iInitDisplayStart :
  2969. iInitDisplayStart >= oSettings.fnRecordsDisplay() ?
  2970. 0 :
  2971. iInitDisplayStart;
  2972. oSettings.iInitDisplayStart = -1;
  2973. }
  2974. var iDisplayStart = oSettings._iDisplayStart;
  2975. var iDisplayEnd = oSettings.fnDisplayEnd();
  2976. /* Server-side processing draw intercept */
  2977. if ( oSettings.bDeferLoading )
  2978. {
  2979. oSettings.bDeferLoading = false;
  2980. oSettings.iDraw++;
  2981. _fnProcessingDisplay( oSettings, false );
  2982. }
  2983. else if ( !bServerSide )
  2984. {
  2985. oSettings.iDraw++;
  2986. }
  2987. else if ( !oSettings.bDestroying && !_fnAjaxUpdate( oSettings ) )
  2988. {
  2989. return;
  2990. }
  2991. if ( aiDisplay.length !== 0 )
  2992. {
  2993. var iStart = bServerSide ? 0 : iDisplayStart;
  2994. var iEnd = bServerSide ? oSettings.aoData.length : iDisplayEnd;
  2995. for ( var j=iStart ; j<iEnd ; j++ )
  2996. {
  2997. var iDataIndex = aiDisplay[j];
  2998. var aoData = oSettings.aoData[ iDataIndex ];
  2999. if ( aoData.nTr === null )
  3000. {
  3001. _fnCreateTr( oSettings, iDataIndex );
  3002. }
  3003. var nRow = aoData.nTr;
  3004. /* Remove the old striping classes and then add the new one */
  3005. if ( iStripes !== 0 )
  3006. {
  3007. var sStripe = asStripeClasses[ iRowCount % iStripes ];
  3008. if ( aoData._sRowStripe != sStripe )
  3009. {
  3010. $(nRow).removeClass( aoData._sRowStripe ).addClass( sStripe );
  3011. aoData._sRowStripe = sStripe;
  3012. }
  3013. }
  3014. // Row callback functions - might want to manipulate the row
  3015. // iRowCount and j are not currently documented. Are they at all
  3016. // useful?
  3017. _fnCallbackFire( oSettings, 'aoRowCallback', null,
  3018. [nRow, aoData._aData, iRowCount, j] );
  3019. anRows.push( nRow );
  3020. iRowCount++;
  3021. }
  3022. }
  3023. else
  3024. {
  3025. /* Table is empty - create a row with an empty message in it */
  3026. var sZero = oLang.sZeroRecords;
  3027. if ( oSettings.iDraw == 1 && _fnDataSource( oSettings ) == 'ajax' )
  3028. {
  3029. sZero = oLang.sLoadingRecords;
  3030. }
  3031. else if ( oLang.sEmptyTable && oSettings.fnRecordsTotal() === 0 )
  3032. {
  3033. sZero = oLang.sEmptyTable;
  3034. }
  3035. anRows[ 0 ] = $( '<tr/>', { 'class': iStripes ? asStripeClasses[0] : '' } )
  3036. .append( $('<td />', {
  3037. 'valign': 'top',
  3038. 'colSpan': _fnVisbleColumns( oSettings ),
  3039. 'class': oSettings.oClasses.sRowEmpty
  3040. } ).html( sZero ) )[0];
  3041. }
  3042. /* Header and footer callbacks */
  3043. _fnCallbackFire( oSettings, 'aoHeaderCallback', 'header', [ $(oSettings.nTHead).children('tr')[0],
  3044. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  3045. _fnCallbackFire( oSettings, 'aoFooterCallback', 'footer', [ $(oSettings.nTFoot).children('tr')[0],
  3046. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  3047. var body = $(oSettings.nTBody);
  3048. body.children().detach();
  3049. body.append( $(anRows) );
  3050. /* Call all required callback functions for the end of a draw */
  3051. _fnCallbackFire( oSettings, 'aoDrawCallback', 'draw', [oSettings] );
  3052. /* Draw is complete, sorting and filtering must be as well */
  3053. oSettings.bSorted = false;
  3054. oSettings.bFiltered = false;
  3055. oSettings.bDrawing = false;
  3056. }
  3057. /**
  3058. * Redraw the table - taking account of the various features which are enabled
  3059. * @param {object} oSettings dataTables settings object
  3060. * @param {boolean} [holdPosition] Keep the current paging position. By default
  3061. * the paging is reset to the first page
  3062. * @memberof DataTable#oApi
  3063. */
  3064. function _fnReDraw( settings, holdPosition )
  3065. {
  3066. var
  3067. features = settings.oFeatures,
  3068. sort = features.bSort,
  3069. filter = features.bFilter;
  3070. if ( sort ) {
  3071. _fnSort( settings );
  3072. }
  3073. if ( filter ) {
  3074. _fnFilterComplete( settings, settings.oPreviousSearch );
  3075. }
  3076. else {
  3077. // No filtering, so we want to just use the display master
  3078. settings.aiDisplay = settings.aiDisplayMaster.slice();
  3079. }
  3080. if ( holdPosition !== true ) {
  3081. settings._iDisplayStart = 0;
  3082. }
  3083. // Let any modules know about the draw hold position state (used by
  3084. // scrolling internally)
  3085. settings._drawHold = holdPosition;
  3086. _fnDraw( settings );
  3087. settings._drawHold = false;
  3088. }
  3089. /**
  3090. * Add the options to the page HTML for the table
  3091. * @param {object} oSettings dataTables settings object
  3092. * @memberof DataTable#oApi
  3093. */
  3094. function _fnAddOptionsHtml ( oSettings )
  3095. {
  3096. var classes = oSettings.oClasses;
  3097. var table = $(oSettings.nTable);
  3098. var holding = $('<div/>').insertBefore( table ); // Holding element for speed
  3099. var features = oSettings.oFeatures;
  3100. // All DataTables are wrapped in a div
  3101. var insert = $('<div/>', {
  3102. id: oSettings.sTableId+'_wrapper',
  3103. 'class': classes.sWrapper + (oSettings.nTFoot ? '' : ' '+classes.sNoFooter)
  3104. } );
  3105. oSettings.nHolding = holding[0];
  3106. oSettings.nTableWrapper = insert[0];
  3107. oSettings.nTableReinsertBefore = oSettings.nTable.nextSibling;
  3108. /* Loop over the user set positioning and place the elements as needed */
  3109. var aDom = oSettings.sDom.split('');
  3110. var featureNode, cOption, nNewNode, cNext, sAttr, j;
  3111. for ( var i=0 ; i<aDom.length ; i++ )
  3112. {
  3113. featureNode = null;
  3114. cOption = aDom[i];
  3115. if ( cOption == '<' )
  3116. {
  3117. /* New container div */
  3118. nNewNode = $('<div/>')[0];
  3119. /* Check to see if we should append an id and/or a class name to the container */
  3120. cNext = aDom[i+1];
  3121. if ( cNext == "'" || cNext == '"' )
  3122. {
  3123. sAttr = "";
  3124. j = 2;
  3125. while ( aDom[i+j] != cNext )
  3126. {
  3127. sAttr += aDom[i+j];
  3128. j++;
  3129. }
  3130. /* Replace jQuery UI constants @todo depreciated */
  3131. if ( sAttr == "H" )
  3132. {
  3133. sAttr = classes.sJUIHeader;
  3134. }
  3135. else if ( sAttr == "F" )
  3136. {
  3137. sAttr = classes.sJUIFooter;
  3138. }
  3139. /* The attribute can be in the format of "#id.class", "#id" or "class" This logic
  3140. * breaks the string into parts and applies them as needed
  3141. */
  3142. if ( sAttr.indexOf('.') != -1 )
  3143. {
  3144. var aSplit = sAttr.split('.');
  3145. nNewNode.id = aSplit[0].substr(1, aSplit[0].length-1);
  3146. nNewNode.className = aSplit[1];
  3147. }
  3148. else if ( sAttr.charAt(0) == "#" )
  3149. {
  3150. nNewNode.id = sAttr.substr(1, sAttr.length-1);
  3151. }
  3152. else
  3153. {
  3154. nNewNode.className = sAttr;
  3155. }
  3156. i += j; /* Move along the position array */
  3157. }
  3158. insert.append( nNewNode );
  3159. insert = $(nNewNode);
  3160. }
  3161. else if ( cOption == '>' )
  3162. {
  3163. /* End container div */
  3164. insert = insert.parent();
  3165. }
  3166. // @todo Move options into their own plugins?
  3167. else if ( cOption == 'l' && features.bPaginate && features.bLengthChange )
  3168. {
  3169. /* Length */
  3170. featureNode = _fnFeatureHtmlLength( oSettings );
  3171. }
  3172. else if ( cOption == 'f' && features.bFilter )
  3173. {
  3174. /* Filter */
  3175. featureNode = _fnFeatureHtmlFilter( oSettings );
  3176. }
  3177. else if ( cOption == 'r' && features.bProcessing )
  3178. {
  3179. /* pRocessing */
  3180. featureNode = _fnFeatureHtmlProcessing( oSettings );
  3181. }
  3182. else if ( cOption == 't' )
  3183. {
  3184. /* Table */
  3185. featureNode = _fnFeatureHtmlTable( oSettings );
  3186. }
  3187. else if ( cOption == 'i' && features.bInfo )
  3188. {
  3189. /* Info */
  3190. featureNode = _fnFeatureHtmlInfo( oSettings );
  3191. }
  3192. else if ( cOption == 'p' && features.bPaginate )
  3193. {
  3194. /* Pagination */
  3195. featureNode = _fnFeatureHtmlPaginate( oSettings );
  3196. }
  3197. else if ( DataTable.ext.feature.length !== 0 )
  3198. {
  3199. /* Plug-in features */
  3200. var aoFeatures = DataTable.ext.feature;
  3201. for ( var k=0, kLen=aoFeatures.length ; k<kLen ; k++ )
  3202. {
  3203. if ( cOption == aoFeatures[k].cFeature )
  3204. {
  3205. featureNode = aoFeatures[k].fnInit( oSettings );
  3206. break;
  3207. }
  3208. }
  3209. }
  3210. /* Add to the 2D features array */
  3211. if ( featureNode )
  3212. {
  3213. var aanFeatures = oSettings.aanFeatures;
  3214. if ( ! aanFeatures[cOption] )
  3215. {
  3216. aanFeatures[cOption] = [];
  3217. }
  3218. aanFeatures[cOption].push( featureNode );
  3219. insert.append( featureNode );
  3220. }
  3221. }
  3222. /* Built our DOM structure - replace the holding div with what we want */
  3223. holding.replaceWith( insert );
  3224. oSettings.nHolding = null;
  3225. }
  3226. /**
  3227. * Use the DOM source to create up an array of header cells. The idea here is to
  3228. * create a layout grid (array) of rows x columns, which contains a reference
  3229. * to the cell that that point in the grid (regardless of col/rowspan), such that
  3230. * any column / row could be removed and the new grid constructed
  3231. * @param array {object} aLayout Array to store the calculated layout in
  3232. * @param {node} nThead The header/footer element for the table
  3233. * @memberof DataTable#oApi
  3234. */
  3235. function _fnDetectHeader ( aLayout, nThead )
  3236. {
  3237. var nTrs = $(nThead).children('tr');
  3238. var nTr, nCell;
  3239. var i, k, l, iLen, jLen, iColShifted, iColumn, iColspan, iRowspan;
  3240. var bUnique;
  3241. var fnShiftCol = function ( a, i, j ) {
  3242. var k = a[i];
  3243. while ( k[j] ) {
  3244. j++;
  3245. }
  3246. return j;
  3247. };
  3248. aLayout.splice( 0, aLayout.length );
  3249. /* We know how many rows there are in the layout - so prep it */
  3250. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  3251. {
  3252. aLayout.push( [] );
  3253. }
  3254. /* Calculate a layout array */
  3255. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  3256. {
  3257. nTr = nTrs[i];
  3258. iColumn = 0;
  3259. /* For every cell in the row... */
  3260. nCell = nTr.firstChild;
  3261. while ( nCell ) {
  3262. if ( nCell.nodeName.toUpperCase() == "TD" ||
  3263. nCell.nodeName.toUpperCase() == "TH" )
  3264. {
  3265. /* Get the col and rowspan attributes from the DOM and sanitise them */
  3266. iColspan = nCell.getAttribute('colspan') * 1;
  3267. iRowspan = nCell.getAttribute('rowspan') * 1;
  3268. iColspan = (!iColspan || iColspan===0 || iColspan===1) ? 1 : iColspan;
  3269. iRowspan = (!iRowspan || iRowspan===0 || iRowspan===1) ? 1 : iRowspan;
  3270. /* There might be colspan cells already in this row, so shift our target
  3271. * accordingly
  3272. */
  3273. iColShifted = fnShiftCol( aLayout, i, iColumn );
  3274. /* Cache calculation for unique columns */
  3275. bUnique = iColspan === 1 ? true : false;
  3276. /* If there is col / rowspan, copy the information into the layout grid */
  3277. for ( l=0 ; l<iColspan ; l++ )
  3278. {
  3279. for ( k=0 ; k<iRowspan ; k++ )
  3280. {
  3281. aLayout[i+k][iColShifted+l] = {
  3282. "cell": nCell,
  3283. "unique": bUnique
  3284. };
  3285. aLayout[i+k].nTr = nTr;
  3286. }
  3287. }
  3288. }
  3289. nCell = nCell.nextSibling;
  3290. }
  3291. }
  3292. }
  3293. /**
  3294. * Get an array of unique th elements, one for each column
  3295. * @param {object} oSettings dataTables settings object
  3296. * @param {node} nHeader automatically detect the layout from this node - optional
  3297. * @param {array} aLayout thead/tfoot layout from _fnDetectHeader - optional
  3298. * @returns array {node} aReturn list of unique th's
  3299. * @memberof DataTable#oApi
  3300. */
  3301. function _fnGetUniqueThs ( oSettings, nHeader, aLayout )
  3302. {
  3303. var aReturn = [];
  3304. if ( !aLayout )
  3305. {
  3306. aLayout = oSettings.aoHeader;
  3307. if ( nHeader )
  3308. {
  3309. aLayout = [];
  3310. _fnDetectHeader( aLayout, nHeader );
  3311. }
  3312. }
  3313. for ( var i=0, iLen=aLayout.length ; i<iLen ; i++ )
  3314. {
  3315. for ( var j=0, jLen=aLayout[i].length ; j<jLen ; j++ )
  3316. {
  3317. if ( aLayout[i][j].unique &&
  3318. (!aReturn[j] || !oSettings.bSortCellsTop) )
  3319. {
  3320. aReturn[j] = aLayout[i][j].cell;
  3321. }
  3322. }
  3323. }
  3324. return aReturn;
  3325. }
  3326. /**
  3327. * Create an Ajax call based on the table's settings, taking into account that
  3328. * parameters can have multiple forms, and backwards compatibility.
  3329. *
  3330. * @param {object} oSettings dataTables settings object
  3331. * @param {array} data Data to send to the server, required by
  3332. * DataTables - may be augmented by developer callbacks
  3333. * @param {function} fn Callback function to run when data is obtained
  3334. */
  3335. function _fnBuildAjax( oSettings, data, fn )
  3336. {
  3337. // Compatibility with 1.9-, allow fnServerData and event to manipulate
  3338. _fnCallbackFire( oSettings, 'aoServerParams', 'serverParams', [data] );
  3339. // Convert to object based for 1.10+ if using the old array scheme which can
  3340. // come from server-side processing or serverParams
  3341. if ( data && $.isArray(data) ) {
  3342. var tmp = {};
  3343. var rbracket = /(.*?)\[\]$/;
  3344. $.each( data, function (key, val) {
  3345. var match = val.name.match(rbracket);
  3346. if ( match ) {
  3347. // Support for arrays
  3348. var name = match[0];
  3349. if ( ! tmp[ name ] ) {
  3350. tmp[ name ] = [];
  3351. }
  3352. tmp[ name ].push( val.value );
  3353. }
  3354. else {
  3355. tmp[val.name] = val.value;
  3356. }
  3357. } );
  3358. data = tmp;
  3359. }
  3360. var ajaxData;
  3361. var ajax = oSettings.ajax;
  3362. var instance = oSettings.oInstance;
  3363. var callback = function ( json ) {
  3364. _fnCallbackFire( oSettings, null, 'xhr', [oSettings, json, oSettings.jqXHR] );
  3365. fn( json );
  3366. };
  3367. if ( $.isPlainObject( ajax ) && ajax.data )
  3368. {
  3369. ajaxData = ajax.data;
  3370. var newData = $.isFunction( ajaxData ) ?
  3371. ajaxData( data, oSettings ) : // fn can manipulate data or return
  3372. ajaxData; // an object object or array to merge
  3373. // If the function returned something, use that alone
  3374. data = $.isFunction( ajaxData ) && newData ?
  3375. newData :
  3376. $.extend( true, data, newData );
  3377. // Remove the data property as we've resolved it already and don't want
  3378. // jQuery to do it again (it is restored at the end of the function)
  3379. delete ajax.data;
  3380. }
  3381. var baseAjax = {
  3382. "data": data,
  3383. "success": function (json) {
  3384. var error = json.error || json.sError;
  3385. if ( error ) {
  3386. _fnLog( oSettings, 0, error );
  3387. }
  3388. oSettings.json = json;
  3389. callback( json );
  3390. },
  3391. "dataType": "json",
  3392. "cache": false,
  3393. "type": oSettings.sServerMethod,
  3394. "error": function (xhr, error, thrown) {
  3395. var ret = _fnCallbackFire( oSettings, null, 'xhr', [oSettings, null, oSettings.jqXHR] );
  3396. if ( $.inArray( true, ret ) === -1 ) {
  3397. if ( error == "parsererror" ) {
  3398. _fnLog( oSettings, 0, 'Invalid JSON response', 1 );
  3399. }
  3400. else if ( xhr.readyState === 4 ) {
  3401. _fnLog( oSettings, 0, 'Ajax error', 7 );
  3402. }
  3403. }
  3404. _fnProcessingDisplay( oSettings, false );
  3405. }
  3406. };
  3407. // Store the data submitted for the API
  3408. oSettings.oAjaxData = data;
  3409. // Allow plug-ins and external processes to modify the data
  3410. _fnCallbackFire( oSettings, null, 'preXhr', [oSettings, data] );
  3411. if ( oSettings.fnServerData )
  3412. {
  3413. // DataTables 1.9- compatibility
  3414. oSettings.fnServerData.call( instance,
  3415. oSettings.sAjaxSource,
  3416. $.map( data, function (val, key) { // Need to convert back to 1.9 trad format
  3417. return { name: key, value: val };
  3418. } ),
  3419. callback,
  3420. oSettings
  3421. );
  3422. }
  3423. else if ( oSettings.sAjaxSource || typeof ajax === 'string' )
  3424. {
  3425. // DataTables 1.9- compatibility
  3426. oSettings.jqXHR = $.ajax( $.extend( baseAjax, {
  3427. url: ajax || oSettings.sAjaxSource
  3428. } ) );
  3429. }
  3430. else if ( $.isFunction( ajax ) )
  3431. {
  3432. // Is a function - let the caller define what needs to be done
  3433. oSettings.jqXHR = ajax.call( instance, data, callback, oSettings );
  3434. }
  3435. else
  3436. {
  3437. // Object to extend the base settings
  3438. oSettings.jqXHR = $.ajax( $.extend( baseAjax, ajax ) );
  3439. // Restore for next time around
  3440. ajax.data = ajaxData;
  3441. }
  3442. }
  3443. /**
  3444. * Update the table using an Ajax call
  3445. * @param {object} settings dataTables settings object
  3446. * @returns {boolean} Block the table drawing or not
  3447. * @memberof DataTable#oApi
  3448. */
  3449. function _fnAjaxUpdate( settings )
  3450. {
  3451. if ( settings.bAjaxDataGet ) {
  3452. settings.iDraw++;
  3453. _fnProcessingDisplay( settings, true );
  3454. _fnBuildAjax(
  3455. settings,
  3456. _fnAjaxParameters( settings ),
  3457. function(json) {
  3458. _fnAjaxUpdateDraw( settings, json );
  3459. }
  3460. );
  3461. return false;
  3462. }
  3463. return true;
  3464. }
  3465. /**
  3466. * Build up the parameters in an object needed for a server-side processing
  3467. * request. Note that this is basically done twice, is different ways - a modern
  3468. * method which is used by default in DataTables 1.10 which uses objects and
  3469. * arrays, or the 1.9- method with is name / value pairs. 1.9 method is used if
  3470. * the sAjaxSource option is used in the initialisation, or the legacyAjax
  3471. * option is set.
  3472. * @param {object} oSettings dataTables settings object
  3473. * @returns {bool} block the table drawing or not
  3474. * @memberof DataTable#oApi
  3475. */
  3476. function _fnAjaxParameters( settings )
  3477. {
  3478. var
  3479. columns = settings.aoColumns,
  3480. columnCount = columns.length,
  3481. features = settings.oFeatures,
  3482. preSearch = settings.oPreviousSearch,
  3483. preColSearch = settings.aoPreSearchCols,
  3484. i, data = [], dataProp, column, columnSearch,
  3485. sort = _fnSortFlatten( settings ),
  3486. displayStart = settings._iDisplayStart,
  3487. displayLength = features.bPaginate !== false ?
  3488. settings._iDisplayLength :
  3489. -1;
  3490. var param = function ( name, value ) {
  3491. data.push( { 'name': name, 'value': value } );
  3492. };
  3493. // DataTables 1.9- compatible method
  3494. param( 'sEcho', settings.iDraw );
  3495. param( 'iColumns', columnCount );
  3496. param( 'sColumns', _pluck( columns, 'sName' ).join(',') );
  3497. param( 'iDisplayStart', displayStart );
  3498. param( 'iDisplayLength', displayLength );
  3499. // DataTables 1.10+ method
  3500. var d = {
  3501. draw: settings.iDraw,
  3502. columns: [],
  3503. order: [],
  3504. start: displayStart,
  3505. length: displayLength,
  3506. search: {
  3507. value: preSearch.sSearch,
  3508. regex: preSearch.bRegex
  3509. }
  3510. };
  3511. for ( i=0 ; i<columnCount ; i++ ) {
  3512. column = columns[i];
  3513. columnSearch = preColSearch[i];
  3514. dataProp = typeof column.mData=="function" ? 'function' : column.mData ;
  3515. d.columns.push( {
  3516. data: dataProp,
  3517. name: column.sName,
  3518. searchable: column.bSearchable,
  3519. orderable: column.bSortable,
  3520. search: {
  3521. value: columnSearch.sSearch,
  3522. regex: columnSearch.bRegex
  3523. }
  3524. } );
  3525. param( "mDataProp_"+i, dataProp );
  3526. if ( features.bFilter ) {
  3527. param( 'sSearch_'+i, columnSearch.sSearch );
  3528. param( 'bRegex_'+i, columnSearch.bRegex );
  3529. param( 'bSearchable_'+i, column.bSearchable );
  3530. }
  3531. if ( features.bSort ) {
  3532. param( 'bSortable_'+i, column.bSortable );
  3533. }
  3534. }
  3535. if ( features.bFilter ) {
  3536. param( 'sSearch', preSearch.sSearch );
  3537. param( 'bRegex', preSearch.bRegex );
  3538. }
  3539. if ( features.bSort ) {
  3540. $.each( sort, function ( i, val ) {
  3541. d.order.push( { column: val.col, dir: val.dir } );
  3542. param( 'iSortCol_'+i, val.col );
  3543. param( 'sSortDir_'+i, val.dir );
  3544. } );
  3545. param( 'iSortingCols', sort.length );
  3546. }
  3547. // If the legacy.ajax parameter is null, then we automatically decide which
  3548. // form to use, based on sAjaxSource
  3549. var legacy = DataTable.ext.legacy.ajax;
  3550. if ( legacy === null ) {
  3551. return settings.sAjaxSource ? data : d;
  3552. }
  3553. // Otherwise, if legacy has been specified then we use that to decide on the
  3554. // form
  3555. return legacy ? data : d;
  3556. }
  3557. /**
  3558. * Data the data from the server (nuking the old) and redraw the table
  3559. * @param {object} oSettings dataTables settings object
  3560. * @param {object} json json data return from the server.
  3561. * @param {string} json.sEcho Tracking flag for DataTables to match requests
  3562. * @param {int} json.iTotalRecords Number of records in the data set, not accounting for filtering
  3563. * @param {int} json.iTotalDisplayRecords Number of records in the data set, accounting for filtering
  3564. * @param {array} json.aaData The data to display on this page
  3565. * @param {string} [json.sColumns] Column ordering (sName, comma separated)
  3566. * @memberof DataTable#oApi
  3567. */
  3568. function _fnAjaxUpdateDraw ( settings, json )
  3569. {
  3570. // v1.10 uses camelCase variables, while 1.9 uses Hungarian notation.
  3571. // Support both
  3572. var compat = function ( old, modern ) {
  3573. return json[old] !== undefined ? json[old] : json[modern];
  3574. };
  3575. var data = _fnAjaxDataSrc( settings, json );
  3576. var draw = compat( 'sEcho', 'draw' );
  3577. var recordsTotal = compat( 'iTotalRecords', 'recordsTotal' );
  3578. var recordsFiltered = compat( 'iTotalDisplayRecords', 'recordsFiltered' );
  3579. if ( draw ) {
  3580. // Protect against out of sequence returns
  3581. if ( draw*1 < settings.iDraw ) {
  3582. return;
  3583. }
  3584. settings.iDraw = draw * 1;
  3585. }
  3586. _fnClearTable( settings );
  3587. settings._iRecordsTotal = parseInt(recordsTotal, 10);
  3588. settings._iRecordsDisplay = parseInt(recordsFiltered, 10);
  3589. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  3590. _fnAddData( settings, data[i] );
  3591. }
  3592. settings.aiDisplay = settings.aiDisplayMaster.slice();
  3593. settings.bAjaxDataGet = false;
  3594. _fnDraw( settings );
  3595. if ( ! settings._bInitComplete ) {
  3596. _fnInitComplete( settings, json );
  3597. }
  3598. settings.bAjaxDataGet = true;
  3599. _fnProcessingDisplay( settings, false );
  3600. }
  3601. /**
  3602. * Get the data from the JSON data source to use for drawing a table. Using
  3603. * `_fnGetObjectDataFn` allows the data to be sourced from a property of the
  3604. * source object, or from a processing function.
  3605. * @param {object} oSettings dataTables settings object
  3606. * @param {object} json Data source object / array from the server
  3607. * @return {array} Array of data to use
  3608. */
  3609. function _fnAjaxDataSrc ( oSettings, json )
  3610. {
  3611. var dataSrc = $.isPlainObject( oSettings.ajax ) && oSettings.ajax.dataSrc !== undefined ?
  3612. oSettings.ajax.dataSrc :
  3613. oSettings.sAjaxDataProp; // Compatibility with 1.9-.
  3614. // Compatibility with 1.9-. In order to read from aaData, check if the
  3615. // default has been changed, if not, check for aaData
  3616. if ( dataSrc === 'data' ) {
  3617. return json.aaData || json[dataSrc];
  3618. }
  3619. return dataSrc !== "" ?
  3620. _fnGetObjectDataFn( dataSrc )( json ) :
  3621. json;
  3622. }
  3623. /**
  3624. * Generate the node required for filtering text
  3625. * @returns {node} Filter control element
  3626. * @param {object} oSettings dataTables settings object
  3627. * @memberof DataTable#oApi
  3628. */
  3629. function _fnFeatureHtmlFilter ( settings )
  3630. {
  3631. var classes = settings.oClasses;
  3632. var tableId = settings.sTableId;
  3633. var language = settings.oLanguage;
  3634. var previousSearch = settings.oPreviousSearch;
  3635. var features = settings.aanFeatures;
  3636. var input = '<input type="search" class="'+classes.sFilterInput+'"/>';
  3637. var str = language.sSearch;
  3638. str = str.match(/_INPUT_/) ?
  3639. str.replace('_INPUT_', input) :
  3640. str+input;
  3641. var filter = $('<div/>', {
  3642. 'id': ! features.f ? tableId+'_filter' : null,
  3643. 'class': classes.sFilter
  3644. } )
  3645. .append( $('<label/>' ).append( str ) );
  3646. var searchFn = function() {
  3647. /* Update all other filter input elements for the new display */
  3648. var n = features.f;
  3649. var val = !this.value ? "" : this.value; // mental IE8 fix :-(
  3650. /* Now do the filter */
  3651. if ( val != previousSearch.sSearch ) {
  3652. _fnFilterComplete( settings, {
  3653. "sSearch": val,
  3654. "bRegex": previousSearch.bRegex,
  3655. "bSmart": previousSearch.bSmart ,
  3656. "bCaseInsensitive": previousSearch.bCaseInsensitive
  3657. } );
  3658. // Need to redraw, without resorting
  3659. settings._iDisplayStart = 0;
  3660. _fnDraw( settings );
  3661. }
  3662. };
  3663. var searchDelay = settings.searchDelay !== null ?
  3664. settings.searchDelay :
  3665. _fnDataSource( settings ) === 'ssp' ?
  3666. 400 :
  3667. 0;
  3668. var jqFilter = $('input', filter)
  3669. .val( previousSearch.sSearch )
  3670. .attr( 'placeholder', language.sSearchPlaceholder )
  3671. .on(
  3672. 'keyup.DT search.DT input.DT paste.DT cut.DT',
  3673. searchDelay ?
  3674. _fnThrottle( searchFn, searchDelay ) :
  3675. searchFn
  3676. )
  3677. .on( 'keypress.DT', function(e) {
  3678. /* Prevent form submission */
  3679. if ( e.keyCode == 13 ) {
  3680. return false;
  3681. }
  3682. } )
  3683. .attr('aria-controls', tableId);
  3684. // Update the input elements whenever the table is filtered
  3685. $(settings.nTable).on( 'search.dt.DT', function ( ev, s ) {
  3686. if ( settings === s ) {
  3687. // IE9 throws an 'unknown error' if document.activeElement is used
  3688. // inside an iframe or frame...
  3689. try {
  3690. if ( jqFilter[0] !== document.activeElement ) {
  3691. jqFilter.val( previousSearch.sSearch );
  3692. }
  3693. }
  3694. catch ( e ) {}
  3695. }
  3696. } );
  3697. return filter[0];
  3698. }
  3699. /**
  3700. * Filter the table using both the global filter and column based filtering
  3701. * @param {object} oSettings dataTables settings object
  3702. * @param {object} oSearch search information
  3703. * @param {int} [iForce] force a research of the master array (1) or not (undefined or 0)
  3704. * @memberof DataTable#oApi
  3705. */
  3706. function _fnFilterComplete ( oSettings, oInput, iForce )
  3707. {
  3708. var oPrevSearch = oSettings.oPreviousSearch;
  3709. var aoPrevSearch = oSettings.aoPreSearchCols;
  3710. var fnSaveFilter = function ( oFilter ) {
  3711. /* Save the filtering values */
  3712. oPrevSearch.sSearch = oFilter.sSearch;
  3713. oPrevSearch.bRegex = oFilter.bRegex;
  3714. oPrevSearch.bSmart = oFilter.bSmart;
  3715. oPrevSearch.bCaseInsensitive = oFilter.bCaseInsensitive;
  3716. };
  3717. var fnRegex = function ( o ) {
  3718. // Backwards compatibility with the bEscapeRegex option
  3719. return o.bEscapeRegex !== undefined ? !o.bEscapeRegex : o.bRegex;
  3720. };
  3721. // Resolve any column types that are unknown due to addition or invalidation
  3722. // @todo As per sort - can this be moved into an event handler?
  3723. _fnColumnTypes( oSettings );
  3724. /* In server-side processing all filtering is done by the server, so no point hanging around here */
  3725. if ( _fnDataSource( oSettings ) != 'ssp' )
  3726. {
  3727. /* Global filter */
  3728. _fnFilter( oSettings, oInput.sSearch, iForce, fnRegex(oInput), oInput.bSmart, oInput.bCaseInsensitive );
  3729. fnSaveFilter( oInput );
  3730. /* Now do the individual column filter */
  3731. for ( var i=0 ; i<aoPrevSearch.length ; i++ )
  3732. {
  3733. _fnFilterColumn( oSettings, aoPrevSearch[i].sSearch, i, fnRegex(aoPrevSearch[i]),
  3734. aoPrevSearch[i].bSmart, aoPrevSearch[i].bCaseInsensitive );
  3735. }
  3736. /* Custom filtering */
  3737. _fnFilterCustom( oSettings );
  3738. }
  3739. else
  3740. {
  3741. fnSaveFilter( oInput );
  3742. }
  3743. /* Tell the draw function we have been filtering */
  3744. oSettings.bFiltered = true;
  3745. _fnCallbackFire( oSettings, null, 'search', [oSettings] );
  3746. }
  3747. /**
  3748. * Apply custom filtering functions
  3749. * @param {object} oSettings dataTables settings object
  3750. * @memberof DataTable#oApi
  3751. */
  3752. function _fnFilterCustom( settings )
  3753. {
  3754. var filters = DataTable.ext.search;
  3755. var displayRows = settings.aiDisplay;
  3756. var row, rowIdx;
  3757. for ( var i=0, ien=filters.length ; i<ien ; i++ ) {
  3758. var rows = [];
  3759. // Loop over each row and see if it should be included
  3760. for ( var j=0, jen=displayRows.length ; j<jen ; j++ ) {
  3761. rowIdx = displayRows[ j ];
  3762. row = settings.aoData[ rowIdx ];
  3763. if ( filters[i]( settings, row._aFilterData, rowIdx, row._aData, j ) ) {
  3764. rows.push( rowIdx );
  3765. }
  3766. }
  3767. // So the array reference doesn't break set the results into the
  3768. // existing array
  3769. displayRows.length = 0;
  3770. $.merge( displayRows, rows );
  3771. }
  3772. }
  3773. /**
  3774. * Filter the table on a per-column basis
  3775. * @param {object} oSettings dataTables settings object
  3776. * @param {string} sInput string to filter on
  3777. * @param {int} iColumn column to filter
  3778. * @param {bool} bRegex treat search string as a regular expression or not
  3779. * @param {bool} bSmart use smart filtering or not
  3780. * @param {bool} bCaseInsensitive Do case insenstive matching or not
  3781. * @memberof DataTable#oApi
  3782. */
  3783. function _fnFilterColumn ( settings, searchStr, colIdx, regex, smart, caseInsensitive )
  3784. {
  3785. if ( searchStr === '' ) {
  3786. return;
  3787. }
  3788. var data;
  3789. var out = [];
  3790. var display = settings.aiDisplay;
  3791. var rpSearch = _fnFilterCreateSearch( searchStr, regex, smart, caseInsensitive );
  3792. for ( var i=0 ; i<display.length ; i++ ) {
  3793. data = settings.aoData[ display[i] ]._aFilterData[ colIdx ];
  3794. if ( rpSearch.test( data ) ) {
  3795. out.push( display[i] );
  3796. }
  3797. }
  3798. settings.aiDisplay = out;
  3799. }
  3800. /**
  3801. * Filter the data table based on user input and draw the table
  3802. * @param {object} settings dataTables settings object
  3803. * @param {string} input string to filter on
  3804. * @param {int} force optional - force a research of the master array (1) or not (undefined or 0)
  3805. * @param {bool} regex treat as a regular expression or not
  3806. * @param {bool} smart perform smart filtering or not
  3807. * @param {bool} caseInsensitive Do case insenstive matching or not
  3808. * @memberof DataTable#oApi
  3809. */
  3810. function _fnFilter( settings, input, force, regex, smart, caseInsensitive )
  3811. {
  3812. var rpSearch = _fnFilterCreateSearch( input, regex, smart, caseInsensitive );
  3813. var prevSearch = settings.oPreviousSearch.sSearch;
  3814. var displayMaster = settings.aiDisplayMaster;
  3815. var display, invalidated, i;
  3816. var filtered = [];
  3817. // Need to take account of custom filtering functions - always filter
  3818. if ( DataTable.ext.search.length !== 0 ) {
  3819. force = true;
  3820. }
  3821. // Check if any of the rows were invalidated
  3822. invalidated = _fnFilterData( settings );
  3823. // If the input is blank - we just want the full data set
  3824. if ( input.length <= 0 ) {
  3825. settings.aiDisplay = displayMaster.slice();
  3826. }
  3827. else {
  3828. // New search - start from the master array
  3829. if ( invalidated ||
  3830. force ||
  3831. prevSearch.length > input.length ||
  3832. input.indexOf(prevSearch) !== 0 ||
  3833. settings.bSorted // On resort, the display master needs to be
  3834. // re-filtered since indexes will have changed
  3835. ) {
  3836. settings.aiDisplay = displayMaster.slice();
  3837. }
  3838. // Search the display array
  3839. display = settings.aiDisplay;
  3840. for ( i=0 ; i<display.length ; i++ ) {
  3841. if ( rpSearch.test( settings.aoData[ display[i] ]._sFilterRow ) ) {
  3842. filtered.push( display[i] );
  3843. }
  3844. }
  3845. settings.aiDisplay = filtered;
  3846. }
  3847. }
  3848. /**
  3849. * Build a regular expression object suitable for searching a table
  3850. * @param {string} sSearch string to search for
  3851. * @param {bool} bRegex treat as a regular expression or not
  3852. * @param {bool} bSmart perform smart filtering or not
  3853. * @param {bool} bCaseInsensitive Do case insensitive matching or not
  3854. * @returns {RegExp} constructed object
  3855. * @memberof DataTable#oApi
  3856. */
  3857. function _fnFilterCreateSearch( search, regex, smart, caseInsensitive )
  3858. {
  3859. search = regex ?
  3860. search :
  3861. _fnEscapeRegex( search );
  3862. if ( smart ) {
  3863. /* For smart filtering we want to allow the search to work regardless of
  3864. * word order. We also want double quoted text to be preserved, so word
  3865. * order is important - a la google. So this is what we want to
  3866. * generate:
  3867. *
  3868. * ^(?=.*?\bone\b)(?=.*?\btwo three\b)(?=.*?\bfour\b).*$
  3869. */
  3870. var a = $.map( search.match( /"[^"]+"|[^ ]+/g ) || [''], function ( word ) {
  3871. if ( word.charAt(0) === '"' ) {
  3872. var m = word.match( /^"(.*)"$/ );
  3873. word = m ? m[1] : word;
  3874. }
  3875. return word.replace('"', '');
  3876. } );
  3877. search = '^(?=.*?'+a.join( ')(?=.*?' )+').*$';
  3878. }
  3879. return new RegExp( search, caseInsensitive ? 'i' : '' );
  3880. }
  3881. /**
  3882. * Escape a string such that it can be used in a regular expression
  3883. * @param {string} sVal string to escape
  3884. * @returns {string} escaped string
  3885. * @memberof DataTable#oApi
  3886. */
  3887. var _fnEscapeRegex = DataTable.util.escapeRegex;
  3888. var __filter_div = $('<div>')[0];
  3889. var __filter_div_textContent = __filter_div.textContent !== undefined;
  3890. // Update the filtering data for each row if needed (by invalidation or first run)
  3891. function _fnFilterData ( settings )
  3892. {
  3893. var columns = settings.aoColumns;
  3894. var column;
  3895. var i, j, ien, jen, filterData, cellData, row;
  3896. var fomatters = DataTable.ext.type.search;
  3897. var wasInvalidated = false;
  3898. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  3899. row = settings.aoData[i];
  3900. if ( ! row._aFilterData ) {
  3901. filterData = [];
  3902. for ( j=0, jen=columns.length ; j<jen ; j++ ) {
  3903. column = columns[j];
  3904. if ( column.bSearchable ) {
  3905. cellData = _fnGetCellData( settings, i, j, 'filter' );
  3906. if ( fomatters[ column.sType ] ) {
  3907. cellData = fomatters[ column.sType ]( cellData );
  3908. }
  3909. // Search in DataTables 1.10 is string based. In 1.11 this
  3910. // should be altered to also allow strict type checking.
  3911. if ( cellData === null ) {
  3912. cellData = '';
  3913. }
  3914. if ( typeof cellData !== 'string' && cellData.toString ) {
  3915. cellData = cellData.toString();
  3916. }
  3917. }
  3918. else {
  3919. cellData = '';
  3920. }
  3921. // If it looks like there is an HTML entity in the string,
  3922. // attempt to decode it so sorting works as expected. Note that
  3923. // we could use a single line of jQuery to do this, but the DOM
  3924. // method used here is much faster http://jsperf.com/html-decode
  3925. if ( cellData.indexOf && cellData.indexOf('&') !== -1 ) {
  3926. __filter_div.innerHTML = cellData;
  3927. cellData = __filter_div_textContent ?
  3928. __filter_div.textContent :
  3929. __filter_div.innerText;
  3930. }
  3931. if ( cellData.replace ) {
  3932. cellData = cellData.replace(/[\r\n]/g, '');
  3933. }
  3934. filterData.push( cellData );
  3935. }
  3936. row._aFilterData = filterData;
  3937. row._sFilterRow = filterData.join(' ');
  3938. wasInvalidated = true;
  3939. }
  3940. }
  3941. return wasInvalidated;
  3942. }
  3943. /**
  3944. * Convert from the internal Hungarian notation to camelCase for external
  3945. * interaction
  3946. * @param {object} obj Object to convert
  3947. * @returns {object} Inverted object
  3948. * @memberof DataTable#oApi
  3949. */
  3950. function _fnSearchToCamel ( obj )
  3951. {
  3952. return {
  3953. search: obj.sSearch,
  3954. smart: obj.bSmart,
  3955. regex: obj.bRegex,
  3956. caseInsensitive: obj.bCaseInsensitive
  3957. };
  3958. }
  3959. /**
  3960. * Convert from camelCase notation to the internal Hungarian. We could use the
  3961. * Hungarian convert function here, but this is cleaner
  3962. * @param {object} obj Object to convert
  3963. * @returns {object} Inverted object
  3964. * @memberof DataTable#oApi
  3965. */
  3966. function _fnSearchToHung ( obj )
  3967. {
  3968. return {
  3969. sSearch: obj.search,
  3970. bSmart: obj.smart,
  3971. bRegex: obj.regex,
  3972. bCaseInsensitive: obj.caseInsensitive
  3973. };
  3974. }
  3975. /**
  3976. * Generate the node required for the info display
  3977. * @param {object} oSettings dataTables settings object
  3978. * @returns {node} Information element
  3979. * @memberof DataTable#oApi
  3980. */
  3981. function _fnFeatureHtmlInfo ( settings )
  3982. {
  3983. var
  3984. tid = settings.sTableId,
  3985. nodes = settings.aanFeatures.i,
  3986. n = $('<div/>', {
  3987. 'class': settings.oClasses.sInfo,
  3988. 'id': ! nodes ? tid+'_info' : null
  3989. } );
  3990. if ( ! nodes ) {
  3991. // Update display on each draw
  3992. settings.aoDrawCallback.push( {
  3993. "fn": _fnUpdateInfo,
  3994. "sName": "information"
  3995. } );
  3996. n
  3997. .attr( 'role', 'status' )
  3998. .attr( 'aria-live', 'polite' );
  3999. // Table is described by our info div
  4000. $(settings.nTable).attr( 'aria-describedby', tid+'_info' );
  4001. }
  4002. return n[0];
  4003. }
  4004. /**
  4005. * Update the information elements in the display
  4006. * @param {object} settings dataTables settings object
  4007. * @memberof DataTable#oApi
  4008. */
  4009. function _fnUpdateInfo ( settings )
  4010. {
  4011. /* Show information about the table */
  4012. var nodes = settings.aanFeatures.i;
  4013. if ( nodes.length === 0 ) {
  4014. return;
  4015. }
  4016. var
  4017. lang = settings.oLanguage,
  4018. start = settings._iDisplayStart+1,
  4019. end = settings.fnDisplayEnd(),
  4020. max = settings.fnRecordsTotal(),
  4021. total = settings.fnRecordsDisplay(),
  4022. out = total ?
  4023. lang.sInfo :
  4024. lang.sInfoEmpty;
  4025. if ( total !== max ) {
  4026. /* Record set after filtering */
  4027. out += ' ' + lang.sInfoFiltered;
  4028. }
  4029. // Convert the macros
  4030. out += lang.sInfoPostFix;
  4031. out = _fnInfoMacros( settings, out );
  4032. var callback = lang.fnInfoCallback;
  4033. if ( callback !== null ) {
  4034. out = callback.call( settings.oInstance,
  4035. settings, start, end, max, total, out
  4036. );
  4037. }
  4038. $(nodes).html( out );
  4039. }
  4040. function _fnInfoMacros ( settings, str )
  4041. {
  4042. // When infinite scrolling, we are always starting at 1. _iDisplayStart is used only
  4043. // internally
  4044. var
  4045. formatter = settings.fnFormatNumber,
  4046. start = settings._iDisplayStart+1,
  4047. len = settings._iDisplayLength,
  4048. vis = settings.fnRecordsDisplay(),
  4049. all = len === -1;
  4050. return str.
  4051. replace(/_START_/g, formatter.call( settings, start ) ).
  4052. replace(/_END_/g, formatter.call( settings, settings.fnDisplayEnd() ) ).
  4053. replace(/_MAX_/g, formatter.call( settings, settings.fnRecordsTotal() ) ).
  4054. replace(/_TOTAL_/g, formatter.call( settings, vis ) ).
  4055. replace(/_PAGE_/g, formatter.call( settings, all ? 1 : Math.ceil( start / len ) ) ).
  4056. replace(/_PAGES_/g, formatter.call( settings, all ? 1 : Math.ceil( vis / len ) ) );
  4057. }
  4058. /**
  4059. * Draw the table for the first time, adding all required features
  4060. * @param {object} settings dataTables settings object
  4061. * @memberof DataTable#oApi
  4062. */
  4063. function _fnInitialise ( settings )
  4064. {
  4065. var i, iLen, iAjaxStart=settings.iInitDisplayStart;
  4066. var columns = settings.aoColumns, column;
  4067. var features = settings.oFeatures;
  4068. var deferLoading = settings.bDeferLoading; // value modified by the draw
  4069. /* Ensure that the table data is fully initialised */
  4070. if ( ! settings.bInitialised ) {
  4071. setTimeout( function(){ _fnInitialise( settings ); }, 200 );
  4072. return;
  4073. }
  4074. /* Show the display HTML options */
  4075. _fnAddOptionsHtml( settings );
  4076. /* Build and draw the header / footer for the table */
  4077. _fnBuildHead( settings );
  4078. _fnDrawHead( settings, settings.aoHeader );
  4079. _fnDrawHead( settings, settings.aoFooter );
  4080. /* Okay to show that something is going on now */
  4081. _fnProcessingDisplay( settings, true );
  4082. /* Calculate sizes for columns */
  4083. if ( features.bAutoWidth ) {
  4084. _fnCalculateColumnWidths( settings );
  4085. }
  4086. for ( i=0, iLen=columns.length ; i<iLen ; i++ ) {
  4087. column = columns[i];
  4088. if ( column.sWidth ) {
  4089. column.nTh.style.width = _fnStringToCss( column.sWidth );
  4090. }
  4091. }
  4092. _fnCallbackFire( settings, null, 'preInit', [settings] );
  4093. // If there is default sorting required - let's do it. The sort function
  4094. // will do the drawing for us. Otherwise we draw the table regardless of the
  4095. // Ajax source - this allows the table to look initialised for Ajax sourcing
  4096. // data (show 'loading' message possibly)
  4097. _fnReDraw( settings );
  4098. // Server-side processing init complete is done by _fnAjaxUpdateDraw
  4099. var dataSrc = _fnDataSource( settings );
  4100. if ( dataSrc != 'ssp' || deferLoading ) {
  4101. // if there is an ajax source load the data
  4102. if ( dataSrc == 'ajax' ) {
  4103. _fnBuildAjax( settings, [], function(json) {
  4104. var aData = _fnAjaxDataSrc( settings, json );
  4105. // Got the data - add it to the table
  4106. for ( i=0 ; i<aData.length ; i++ ) {
  4107. _fnAddData( settings, aData[i] );
  4108. }
  4109. // Reset the init display for cookie saving. We've already done
  4110. // a filter, and therefore cleared it before. So we need to make
  4111. // it appear 'fresh'
  4112. settings.iInitDisplayStart = iAjaxStart;
  4113. _fnReDraw( settings );
  4114. _fnProcessingDisplay( settings, false );
  4115. _fnInitComplete( settings, json );
  4116. }, settings );
  4117. }
  4118. else {
  4119. _fnProcessingDisplay( settings, false );
  4120. _fnInitComplete( settings );
  4121. }
  4122. }
  4123. }
  4124. /**
  4125. * Draw the table for the first time, adding all required features
  4126. * @param {object} oSettings dataTables settings object
  4127. * @param {object} [json] JSON from the server that completed the table, if using Ajax source
  4128. * with client-side processing (optional)
  4129. * @memberof DataTable#oApi
  4130. */
  4131. function _fnInitComplete ( settings, json )
  4132. {
  4133. settings._bInitComplete = true;
  4134. // When data was added after the initialisation (data or Ajax) we need to
  4135. // calculate the column sizing
  4136. if ( json || settings.oInit.aaData ) {
  4137. _fnAdjustColumnSizing( settings );
  4138. }
  4139. _fnCallbackFire( settings, null, 'plugin-init', [settings, json] );
  4140. _fnCallbackFire( settings, 'aoInitComplete', 'init', [settings, json] );
  4141. }
  4142. function _fnLengthChange ( settings, val )
  4143. {
  4144. var len = parseInt( val, 10 );
  4145. settings._iDisplayLength = len;
  4146. _fnLengthOverflow( settings );
  4147. // Fire length change event
  4148. _fnCallbackFire( settings, null, 'length', [settings, len] );
  4149. }
  4150. /**
  4151. * Generate the node required for user display length changing
  4152. * @param {object} settings dataTables settings object
  4153. * @returns {node} Display length feature node
  4154. * @memberof DataTable#oApi
  4155. */
  4156. function _fnFeatureHtmlLength ( settings )
  4157. {
  4158. var
  4159. classes = settings.oClasses,
  4160. tableId = settings.sTableId,
  4161. menu = settings.aLengthMenu,
  4162. d2 = $.isArray( menu[0] ),
  4163. lengths = d2 ? menu[0] : menu,
  4164. language = d2 ? menu[1] : menu;
  4165. var select = $('<select/>', {
  4166. 'name': tableId+'_length',
  4167. 'aria-controls': tableId,
  4168. 'class': classes.sLengthSelect
  4169. } );
  4170. for ( var i=0, ien=lengths.length ; i<ien ; i++ ) {
  4171. select[0][ i ] = new Option( language[i], lengths[i] );
  4172. }
  4173. var div = $('<div><label/></div>').addClass( classes.sLength );
  4174. if ( ! settings.aanFeatures.l ) {
  4175. div[0].id = tableId+'_length';
  4176. }
  4177. div.children().append(
  4178. settings.oLanguage.sLengthMenu.replace( '_MENU_', select[0].outerHTML )
  4179. );
  4180. // Can't use `select` variable as user might provide their own and the
  4181. // reference is broken by the use of outerHTML
  4182. $('select', div)
  4183. .val( settings._iDisplayLength )
  4184. .on( 'change.DT', function(e) {
  4185. _fnLengthChange( settings, $(this).val() );
  4186. _fnDraw( settings );
  4187. } );
  4188. // Update node value whenever anything changes the table's length
  4189. $(settings.nTable).on( 'length.dt.DT', function (e, s, len) {
  4190. if ( settings === s ) {
  4191. $('select', div).val( len );
  4192. }
  4193. } );
  4194. return div[0];
  4195. }
  4196. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  4197. * Note that most of the paging logic is done in
  4198. * DataTable.ext.pager
  4199. */
  4200. /**
  4201. * Generate the node required for default pagination
  4202. * @param {object} oSettings dataTables settings object
  4203. * @returns {node} Pagination feature node
  4204. * @memberof DataTable#oApi
  4205. */
  4206. function _fnFeatureHtmlPaginate ( settings )
  4207. {
  4208. var
  4209. type = settings.sPaginationType,
  4210. plugin = DataTable.ext.pager[ type ],
  4211. modern = typeof plugin === 'function',
  4212. redraw = function( settings ) {
  4213. _fnDraw( settings );
  4214. },
  4215. node = $('<div/>').addClass( settings.oClasses.sPaging + type )[0],
  4216. features = settings.aanFeatures;
  4217. if ( ! modern ) {
  4218. plugin.fnInit( settings, node, redraw );
  4219. }
  4220. /* Add a draw callback for the pagination on first instance, to update the paging display */
  4221. if ( ! features.p )
  4222. {
  4223. node.id = settings.sTableId+'_paginate';
  4224. settings.aoDrawCallback.push( {
  4225. "fn": function( settings ) {
  4226. if ( modern ) {
  4227. var
  4228. start = settings._iDisplayStart,
  4229. len = settings._iDisplayLength,
  4230. visRecords = settings.fnRecordsDisplay(),
  4231. all = len === -1,
  4232. page = all ? 0 : Math.ceil( start / len ),
  4233. pages = all ? 1 : Math.ceil( visRecords / len ),
  4234. buttons = plugin(page, pages),
  4235. i, ien;
  4236. for ( i=0, ien=features.p.length ; i<ien ; i++ ) {
  4237. _fnRenderer( settings, 'pageButton' )(
  4238. settings, features.p[i], i, buttons, page, pages
  4239. );
  4240. }
  4241. }
  4242. else {
  4243. plugin.fnUpdate( settings, redraw );
  4244. }
  4245. },
  4246. "sName": "pagination"
  4247. } );
  4248. }
  4249. return node;
  4250. }
  4251. /**
  4252. * Alter the display settings to change the page
  4253. * @param {object} settings DataTables settings object
  4254. * @param {string|int} action Paging action to take: "first", "previous",
  4255. * "next" or "last" or page number to jump to (integer)
  4256. * @param [bool] redraw Automatically draw the update or not
  4257. * @returns {bool} true page has changed, false - no change
  4258. * @memberof DataTable#oApi
  4259. */
  4260. function _fnPageChange ( settings, action, redraw )
  4261. {
  4262. var
  4263. start = settings._iDisplayStart,
  4264. len = settings._iDisplayLength,
  4265. records = settings.fnRecordsDisplay();
  4266. if ( records === 0 || len === -1 )
  4267. {
  4268. start = 0;
  4269. }
  4270. else if ( typeof action === "number" )
  4271. {
  4272. start = action * len;
  4273. if ( start > records )
  4274. {
  4275. start = 0;
  4276. }
  4277. }
  4278. else if ( action == "first" )
  4279. {
  4280. start = 0;
  4281. }
  4282. else if ( action == "previous" )
  4283. {
  4284. start = len >= 0 ?
  4285. start - len :
  4286. 0;
  4287. if ( start < 0 )
  4288. {
  4289. start = 0;
  4290. }
  4291. }
  4292. else if ( action == "next" )
  4293. {
  4294. if ( start + len < records )
  4295. {
  4296. start += len;
  4297. }
  4298. }
  4299. else if ( action == "last" )
  4300. {
  4301. start = Math.floor( (records-1) / len) * len;
  4302. }
  4303. else
  4304. {
  4305. _fnLog( settings, 0, "Unknown paging action: "+action, 5 );
  4306. }
  4307. var changed = settings._iDisplayStart !== start;
  4308. settings._iDisplayStart = start;
  4309. if ( changed ) {
  4310. _fnCallbackFire( settings, null, 'page', [settings] );
  4311. if ( redraw ) {
  4312. _fnDraw( settings );
  4313. }
  4314. }
  4315. return changed;
  4316. }
  4317. /**
  4318. * Generate the node required for the processing node
  4319. * @param {object} settings dataTables settings object
  4320. * @returns {node} Processing element
  4321. * @memberof DataTable#oApi
  4322. */
  4323. function _fnFeatureHtmlProcessing ( settings )
  4324. {
  4325. return $('<div/>', {
  4326. 'id': ! settings.aanFeatures.r ? settings.sTableId+'_processing' : null,
  4327. 'class': settings.oClasses.sProcessing
  4328. } )
  4329. .html( settings.oLanguage.sProcessing )
  4330. .insertBefore( settings.nTable )[0];
  4331. }
  4332. /**
  4333. * Display or hide the processing indicator
  4334. * @param {object} settings dataTables settings object
  4335. * @param {bool} show Show the processing indicator (true) or not (false)
  4336. * @memberof DataTable#oApi
  4337. */
  4338. function _fnProcessingDisplay ( settings, show )
  4339. {
  4340. if ( settings.oFeatures.bProcessing ) {
  4341. $(settings.aanFeatures.r).css( 'display', show ? 'block' : 'none' );
  4342. }
  4343. _fnCallbackFire( settings, null, 'processing', [settings, show] );
  4344. }
  4345. /**
  4346. * Add any control elements for the table - specifically scrolling
  4347. * @param {object} settings dataTables settings object
  4348. * @returns {node} Node to add to the DOM
  4349. * @memberof DataTable#oApi
  4350. */
  4351. function _fnFeatureHtmlTable ( settings )
  4352. {
  4353. var table = $(settings.nTable);
  4354. // Add the ARIA grid role to the table
  4355. table.attr( 'role', 'grid' );
  4356. // Scrolling from here on in
  4357. var scroll = settings.oScroll;
  4358. if ( scroll.sX === '' && scroll.sY === '' ) {
  4359. return settings.nTable;
  4360. }
  4361. var scrollX = scroll.sX;
  4362. var scrollY = scroll.sY;
  4363. var classes = settings.oClasses;
  4364. var caption = table.children('caption');
  4365. var captionSide = caption.length ? caption[0]._captionSide : null;
  4366. var headerClone = $( table[0].cloneNode(false) );
  4367. var footerClone = $( table[0].cloneNode(false) );
  4368. var footer = table.children('tfoot');
  4369. var _div = '<div/>';
  4370. var size = function ( s ) {
  4371. return !s ? null : _fnStringToCss( s );
  4372. };
  4373. if ( ! footer.length ) {
  4374. footer = null;
  4375. }
  4376. /*
  4377. * The HTML structure that we want to generate in this function is:
  4378. * div - scroller
  4379. * div - scroll head
  4380. * div - scroll head inner
  4381. * table - scroll head table
  4382. * thead - thead
  4383. * div - scroll body
  4384. * table - table (master table)
  4385. * thead - thead clone for sizing
  4386. * tbody - tbody
  4387. * div - scroll foot
  4388. * div - scroll foot inner
  4389. * table - scroll foot table
  4390. * tfoot - tfoot
  4391. */
  4392. var scroller = $( _div, { 'class': classes.sScrollWrapper } )
  4393. .append(
  4394. $(_div, { 'class': classes.sScrollHead } )
  4395. .css( {
  4396. overflow: 'hidden',
  4397. position: 'relative',
  4398. border: 0,
  4399. width: scrollX ? size(scrollX) : '100%'
  4400. } )
  4401. .append(
  4402. $(_div, { 'class': classes.sScrollHeadInner } )
  4403. .css( {
  4404. 'box-sizing': 'content-box',
  4405. width: scroll.sXInner || '100%'
  4406. } )
  4407. .append(
  4408. headerClone
  4409. .removeAttr('id')
  4410. .css( 'margin-left', 0 )
  4411. .append( captionSide === 'top' ? caption : null )
  4412. .append(
  4413. table.children('thead')
  4414. )
  4415. )
  4416. )
  4417. )
  4418. .append(
  4419. $(_div, { 'class': classes.sScrollBody } )
  4420. .css( {
  4421. position: 'relative',
  4422. overflow: 'auto',
  4423. width: size( scrollX )
  4424. } )
  4425. .append( table )
  4426. );
  4427. if ( footer ) {
  4428. scroller.append(
  4429. $(_div, { 'class': classes.sScrollFoot } )
  4430. .css( {
  4431. overflow: 'hidden',
  4432. border: 0,
  4433. width: scrollX ? size(scrollX) : '100%'
  4434. } )
  4435. .append(
  4436. $(_div, { 'class': classes.sScrollFootInner } )
  4437. .append(
  4438. footerClone
  4439. .removeAttr('id')
  4440. .css( 'margin-left', 0 )
  4441. .append( captionSide === 'bottom' ? caption : null )
  4442. .append(
  4443. table.children('tfoot')
  4444. )
  4445. )
  4446. )
  4447. );
  4448. }
  4449. var children = scroller.children();
  4450. var scrollHead = children[0];
  4451. var scrollBody = children[1];
  4452. var scrollFoot = footer ? children[2] : null;
  4453. // When the body is scrolled, then we also want to scroll the headers
  4454. if ( scrollX ) {
  4455. $(scrollBody).on( 'scroll.DT', function (e) {
  4456. var scrollLeft = this.scrollLeft;
  4457. scrollHead.scrollLeft = scrollLeft;
  4458. if ( footer ) {
  4459. scrollFoot.scrollLeft = scrollLeft;
  4460. }
  4461. } );
  4462. }
  4463. $(scrollBody).css(
  4464. scrollY && scroll.bCollapse ? 'max-height' : 'height',
  4465. scrollY
  4466. );
  4467. settings.nScrollHead = scrollHead;
  4468. settings.nScrollBody = scrollBody;
  4469. settings.nScrollFoot = scrollFoot;
  4470. // On redraw - align columns
  4471. settings.aoDrawCallback.push( {
  4472. "fn": _fnScrollDraw,
  4473. "sName": "scrolling"
  4474. } );
  4475. return scroller[0];
  4476. }
  4477. /**
  4478. * Update the header, footer and body tables for resizing - i.e. column
  4479. * alignment.
  4480. *
  4481. * Welcome to the most horrible function DataTables. The process that this
  4482. * function follows is basically:
  4483. * 1. Re-create the table inside the scrolling div
  4484. * 2. Take live measurements from the DOM
  4485. * 3. Apply the measurements to align the columns
  4486. * 4. Clean up
  4487. *
  4488. * @param {object} settings dataTables settings object
  4489. * @memberof DataTable#oApi
  4490. */
  4491. function _fnScrollDraw ( settings )
  4492. {
  4493. // Given that this is such a monster function, a lot of variables are use
  4494. // to try and keep the minimised size as small as possible
  4495. var
  4496. scroll = settings.oScroll,
  4497. scrollX = scroll.sX,
  4498. scrollXInner = scroll.sXInner,
  4499. scrollY = scroll.sY,
  4500. barWidth = scroll.iBarWidth,
  4501. divHeader = $(settings.nScrollHead),
  4502. divHeaderStyle = divHeader[0].style,
  4503. divHeaderInner = divHeader.children('div'),
  4504. divHeaderInnerStyle = divHeaderInner[0].style,
  4505. divHeaderTable = divHeaderInner.children('table'),
  4506. divBodyEl = settings.nScrollBody,
  4507. divBody = $(divBodyEl),
  4508. divBodyStyle = divBodyEl.style,
  4509. divFooter = $(settings.nScrollFoot),
  4510. divFooterInner = divFooter.children('div'),
  4511. divFooterTable = divFooterInner.children('table'),
  4512. header = $(settings.nTHead),
  4513. table = $(settings.nTable),
  4514. tableEl = table[0],
  4515. tableStyle = tableEl.style,
  4516. footer = settings.nTFoot ? $(settings.nTFoot) : null,
  4517. browser = settings.oBrowser,
  4518. ie67 = browser.bScrollOversize,
  4519. dtHeaderCells = _pluck( settings.aoColumns, 'nTh' ),
  4520. headerTrgEls, footerTrgEls,
  4521. headerSrcEls, footerSrcEls,
  4522. headerCopy, footerCopy,
  4523. headerWidths=[], footerWidths=[],
  4524. headerContent=[], footerContent=[],
  4525. idx, correction, sanityWidth,
  4526. zeroOut = function(nSizer) {
  4527. var style = nSizer.style;
  4528. style.paddingTop = "0";
  4529. style.paddingBottom = "0";
  4530. style.borderTopWidth = "0";
  4531. style.borderBottomWidth = "0";
  4532. style.height = 0;
  4533. };
  4534. // If the scrollbar visibility has changed from the last draw, we need to
  4535. // adjust the column sizes as the table width will have changed to account
  4536. // for the scrollbar
  4537. var scrollBarVis = divBodyEl.scrollHeight > divBodyEl.clientHeight;
  4538. if ( settings.scrollBarVis !== scrollBarVis && settings.scrollBarVis !== undefined ) {
  4539. settings.scrollBarVis = scrollBarVis;
  4540. _fnAdjustColumnSizing( settings );
  4541. return; // adjust column sizing will call this function again
  4542. }
  4543. else {
  4544. settings.scrollBarVis = scrollBarVis;
  4545. }
  4546. /*
  4547. * 1. Re-create the table inside the scrolling div
  4548. */
  4549. // Remove the old minimised thead and tfoot elements in the inner table
  4550. table.children('thead, tfoot').remove();
  4551. if ( footer ) {
  4552. footerCopy = footer.clone().prependTo( table );
  4553. footerTrgEls = footer.find('tr'); // the original tfoot is in its own table and must be sized
  4554. footerSrcEls = footerCopy.find('tr');
  4555. }
  4556. // Clone the current header and footer elements and then place it into the inner table
  4557. headerCopy = header.clone().prependTo( table );
  4558. headerTrgEls = header.find('tr'); // original header is in its own table
  4559. headerSrcEls = headerCopy.find('tr');
  4560. headerCopy.find('th, td').removeAttr('tabindex');
  4561. /*
  4562. * 2. Take live measurements from the DOM - do not alter the DOM itself!
  4563. */
  4564. // Remove old sizing and apply the calculated column widths
  4565. // Get the unique column headers in the newly created (cloned) header. We want to apply the
  4566. // calculated sizes to this header
  4567. if ( ! scrollX )
  4568. {
  4569. divBodyStyle.width = '100%';
  4570. divHeader[0].style.width = '100%';
  4571. }
  4572. $.each( _fnGetUniqueThs( settings, headerCopy ), function ( i, el ) {
  4573. idx = _fnVisibleToColumnIndex( settings, i );
  4574. el.style.width = settings.aoColumns[idx].sWidth;
  4575. } );
  4576. if ( footer ) {
  4577. _fnApplyToChildren( function(n) {
  4578. n.style.width = "";
  4579. }, footerSrcEls );
  4580. }
  4581. // Size the table as a whole
  4582. sanityWidth = table.outerWidth();
  4583. if ( scrollX === "" ) {
  4584. // No x scrolling
  4585. tableStyle.width = "100%";
  4586. // IE7 will make the width of the table when 100% include the scrollbar
  4587. // - which is shouldn't. When there is a scrollbar we need to take this
  4588. // into account.
  4589. if ( ie67 && (table.find('tbody').height() > divBodyEl.offsetHeight ||
  4590. divBody.css('overflow-y') == "scroll")
  4591. ) {
  4592. tableStyle.width = _fnStringToCss( table.outerWidth() - barWidth);
  4593. }
  4594. // Recalculate the sanity width
  4595. sanityWidth = table.outerWidth();
  4596. }
  4597. else if ( scrollXInner !== "" ) {
  4598. // legacy x scroll inner has been given - use it
  4599. tableStyle.width = _fnStringToCss(scrollXInner);
  4600. // Recalculate the sanity width
  4601. sanityWidth = table.outerWidth();
  4602. }
  4603. // Hidden header should have zero height, so remove padding and borders. Then
  4604. // set the width based on the real headers
  4605. // Apply all styles in one pass
  4606. _fnApplyToChildren( zeroOut, headerSrcEls );
  4607. // Read all widths in next pass
  4608. _fnApplyToChildren( function(nSizer) {
  4609. headerContent.push( nSizer.innerHTML );
  4610. headerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  4611. }, headerSrcEls );
  4612. // Apply all widths in final pass
  4613. _fnApplyToChildren( function(nToSize, i) {
  4614. // Only apply widths to the DataTables detected header cells - this
  4615. // prevents complex headers from having contradictory sizes applied
  4616. if ( $.inArray( nToSize, dtHeaderCells ) !== -1 ) {
  4617. nToSize.style.width = headerWidths[i];
  4618. }
  4619. }, headerTrgEls );
  4620. $(headerSrcEls).height(0);
  4621. /* Same again with the footer if we have one */
  4622. if ( footer )
  4623. {
  4624. _fnApplyToChildren( zeroOut, footerSrcEls );
  4625. _fnApplyToChildren( function(nSizer) {
  4626. footerContent.push( nSizer.innerHTML );
  4627. footerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  4628. }, footerSrcEls );
  4629. _fnApplyToChildren( function(nToSize, i) {
  4630. nToSize.style.width = footerWidths[i];
  4631. }, footerTrgEls );
  4632. $(footerSrcEls).height(0);
  4633. }
  4634. /*
  4635. * 3. Apply the measurements
  4636. */
  4637. // "Hide" the header and footer that we used for the sizing. We need to keep
  4638. // the content of the cell so that the width applied to the header and body
  4639. // both match, but we want to hide it completely. We want to also fix their
  4640. // width to what they currently are
  4641. _fnApplyToChildren( function(nSizer, i) {
  4642. nSizer.innerHTML = '<div class="dataTables_sizing" style="height:0;overflow:hidden;">'+headerContent[i]+'</div>';
  4643. nSizer.style.width = headerWidths[i];
  4644. }, headerSrcEls );
  4645. if ( footer )
  4646. {
  4647. _fnApplyToChildren( function(nSizer, i) {
  4648. nSizer.innerHTML = '<div class="dataTables_sizing" style="height:0;overflow:hidden;">'+footerContent[i]+'</div>';
  4649. nSizer.style.width = footerWidths[i];
  4650. }, footerSrcEls );
  4651. }
  4652. // Sanity check that the table is of a sensible width. If not then we are going to get
  4653. // misalignment - try to prevent this by not allowing the table to shrink below its min width
  4654. if ( table.outerWidth() < sanityWidth )
  4655. {
  4656. // The min width depends upon if we have a vertical scrollbar visible or not */
  4657. correction = ((divBodyEl.scrollHeight > divBodyEl.offsetHeight ||
  4658. divBody.css('overflow-y') == "scroll")) ?
  4659. sanityWidth+barWidth :
  4660. sanityWidth;
  4661. // IE6/7 are a law unto themselves...
  4662. if ( ie67 && (divBodyEl.scrollHeight >
  4663. divBodyEl.offsetHeight || divBody.css('overflow-y') == "scroll")
  4664. ) {
  4665. tableStyle.width = _fnStringToCss( correction-barWidth );
  4666. }
  4667. // And give the user a warning that we've stopped the table getting too small
  4668. if ( scrollX === "" || scrollXInner !== "" ) {
  4669. _fnLog( settings, 1, 'Possible column misalignment', 6 );
  4670. }
  4671. }
  4672. else
  4673. {
  4674. correction = '100%';
  4675. }
  4676. // Apply to the container elements
  4677. divBodyStyle.width = _fnStringToCss( correction );
  4678. divHeaderStyle.width = _fnStringToCss( correction );
  4679. if ( footer ) {
  4680. settings.nScrollFoot.style.width = _fnStringToCss( correction );
  4681. }
  4682. /*
  4683. * 4. Clean up
  4684. */
  4685. if ( ! scrollY ) {
  4686. /* IE7< puts a vertical scrollbar in place (when it shouldn't be) due to subtracting
  4687. * the scrollbar height from the visible display, rather than adding it on. We need to
  4688. * set the height in order to sort this. Don't want to do it in any other browsers.
  4689. */
  4690. if ( ie67 ) {
  4691. divBodyStyle.height = _fnStringToCss( tableEl.offsetHeight+barWidth );
  4692. }
  4693. }
  4694. /* Finally set the width's of the header and footer tables */
  4695. var iOuterWidth = table.outerWidth();
  4696. divHeaderTable[0].style.width = _fnStringToCss( iOuterWidth );
  4697. divHeaderInnerStyle.width = _fnStringToCss( iOuterWidth );
  4698. // Figure out if there are scrollbar present - if so then we need a the header and footer to
  4699. // provide a bit more space to allow "overflow" scrolling (i.e. past the scrollbar)
  4700. var bScrolling = table.height() > divBodyEl.clientHeight || divBody.css('overflow-y') == "scroll";
  4701. var padding = 'padding' + (browser.bScrollbarLeft ? 'Left' : 'Right' );
  4702. divHeaderInnerStyle[ padding ] = bScrolling ? barWidth+"px" : "0px";
  4703. if ( footer ) {
  4704. divFooterTable[0].style.width = _fnStringToCss( iOuterWidth );
  4705. divFooterInner[0].style.width = _fnStringToCss( iOuterWidth );
  4706. divFooterInner[0].style[padding] = bScrolling ? barWidth+"px" : "0px";
  4707. }
  4708. // Correct DOM ordering for colgroup - comes before the thead
  4709. table.children('colgroup').insertBefore( table.children('thead') );
  4710. /* Adjust the position of the header in case we loose the y-scrollbar */
  4711. divBody.scroll();
  4712. // If sorting or filtering has occurred, jump the scrolling back to the top
  4713. // only if we aren't holding the position
  4714. if ( (settings.bSorted || settings.bFiltered) && ! settings._drawHold ) {
  4715. divBodyEl.scrollTop = 0;
  4716. }
  4717. }
  4718. /**
  4719. * Apply a given function to the display child nodes of an element array (typically
  4720. * TD children of TR rows
  4721. * @param {function} fn Method to apply to the objects
  4722. * @param array {nodes} an1 List of elements to look through for display children
  4723. * @param array {nodes} an2 Another list (identical structure to the first) - optional
  4724. * @memberof DataTable#oApi
  4725. */
  4726. function _fnApplyToChildren( fn, an1, an2 )
  4727. {
  4728. var index=0, i=0, iLen=an1.length;
  4729. var nNode1, nNode2;
  4730. while ( i < iLen ) {
  4731. nNode1 = an1[i].firstChild;
  4732. nNode2 = an2 ? an2[i].firstChild : null;
  4733. while ( nNode1 ) {
  4734. if ( nNode1.nodeType === 1 ) {
  4735. if ( an2 ) {
  4736. fn( nNode1, nNode2, index );
  4737. }
  4738. else {
  4739. fn( nNode1, index );
  4740. }
  4741. index++;
  4742. }
  4743. nNode1 = nNode1.nextSibling;
  4744. nNode2 = an2 ? nNode2.nextSibling : null;
  4745. }
  4746. i++;
  4747. }
  4748. }
  4749. var __re_html_remove = /<.*?>/g;
  4750. /**
  4751. * Calculate the width of columns for the table
  4752. * @param {object} oSettings dataTables settings object
  4753. * @memberof DataTable#oApi
  4754. */
  4755. function _fnCalculateColumnWidths ( oSettings )
  4756. {
  4757. var
  4758. table = oSettings.nTable,
  4759. columns = oSettings.aoColumns,
  4760. scroll = oSettings.oScroll,
  4761. scrollY = scroll.sY,
  4762. scrollX = scroll.sX,
  4763. scrollXInner = scroll.sXInner,
  4764. columnCount = columns.length,
  4765. visibleColumns = _fnGetColumns( oSettings, 'bVisible' ),
  4766. headerCells = $('th', oSettings.nTHead),
  4767. tableWidthAttr = table.getAttribute('width'), // from DOM element
  4768. tableContainer = table.parentNode,
  4769. userInputs = false,
  4770. i, column, columnIdx, width, outerWidth,
  4771. browser = oSettings.oBrowser,
  4772. ie67 = browser.bScrollOversize;
  4773. var styleWidth = table.style.width;
  4774. if ( styleWidth && styleWidth.indexOf('%') !== -1 ) {
  4775. tableWidthAttr = styleWidth;
  4776. }
  4777. /* Convert any user input sizes into pixel sizes */
  4778. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4779. column = columns[ visibleColumns[i] ];
  4780. if ( column.sWidth !== null ) {
  4781. column.sWidth = _fnConvertToWidth( column.sWidthOrig, tableContainer );
  4782. userInputs = true;
  4783. }
  4784. }
  4785. /* If the number of columns in the DOM equals the number that we have to
  4786. * process in DataTables, then we can use the offsets that are created by
  4787. * the web- browser. No custom sizes can be set in order for this to happen,
  4788. * nor scrolling used
  4789. */
  4790. if ( ie67 || ! userInputs && ! scrollX && ! scrollY &&
  4791. columnCount == _fnVisbleColumns( oSettings ) &&
  4792. columnCount == headerCells.length
  4793. ) {
  4794. for ( i=0 ; i<columnCount ; i++ ) {
  4795. var colIdx = _fnVisibleToColumnIndex( oSettings, i );
  4796. if ( colIdx !== null ) {
  4797. columns[ colIdx ].sWidth = _fnStringToCss( headerCells.eq(i).width() );
  4798. }
  4799. }
  4800. }
  4801. else
  4802. {
  4803. // Otherwise construct a single row, worst case, table with the widest
  4804. // node in the data, assign any user defined widths, then insert it into
  4805. // the DOM and allow the browser to do all the hard work of calculating
  4806. // table widths
  4807. var tmpTable = $(table).clone() // don't use cloneNode - IE8 will remove events on the main table
  4808. .css( 'visibility', 'hidden' )
  4809. .removeAttr( 'id' );
  4810. // Clean up the table body
  4811. tmpTable.find('tbody tr').remove();
  4812. var tr = $('<tr/>').appendTo( tmpTable.find('tbody') );
  4813. // Clone the table header and footer - we can't use the header / footer
  4814. // from the cloned table, since if scrolling is active, the table's
  4815. // real header and footer are contained in different table tags
  4816. tmpTable.find('thead, tfoot').remove();
  4817. tmpTable
  4818. .append( $(oSettings.nTHead).clone() )
  4819. .append( $(oSettings.nTFoot).clone() );
  4820. // Remove any assigned widths from the footer (from scrolling)
  4821. tmpTable.find('tfoot th, tfoot td').css('width', '');
  4822. // Apply custom sizing to the cloned header
  4823. headerCells = _fnGetUniqueThs( oSettings, tmpTable.find('thead')[0] );
  4824. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4825. column = columns[ visibleColumns[i] ];
  4826. headerCells[i].style.width = column.sWidthOrig !== null && column.sWidthOrig !== '' ?
  4827. _fnStringToCss( column.sWidthOrig ) :
  4828. '';
  4829. // For scrollX we need to force the column width otherwise the
  4830. // browser will collapse it. If this width is smaller than the
  4831. // width the column requires, then it will have no effect
  4832. if ( column.sWidthOrig && scrollX ) {
  4833. $( headerCells[i] ).append( $('<div/>').css( {
  4834. width: column.sWidthOrig,
  4835. margin: 0,
  4836. padding: 0,
  4837. border: 0,
  4838. height: 1
  4839. } ) );
  4840. }
  4841. }
  4842. // Find the widest cell for each column and put it into the table
  4843. if ( oSettings.aoData.length ) {
  4844. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4845. columnIdx = visibleColumns[i];
  4846. column = columns[ columnIdx ];
  4847. $( _fnGetWidestNode( oSettings, columnIdx ) )
  4848. .clone( false )
  4849. .append( column.sContentPadding )
  4850. .appendTo( tr );
  4851. }
  4852. }
  4853. // Tidy the temporary table - remove name attributes so there aren't
  4854. // duplicated in the dom (radio elements for example)
  4855. $('[name]', tmpTable).removeAttr('name');
  4856. // Table has been built, attach to the document so we can work with it.
  4857. // A holding element is used, positioned at the top of the container
  4858. // with minimal height, so it has no effect on if the container scrolls
  4859. // or not. Otherwise it might trigger scrolling when it actually isn't
  4860. // needed
  4861. var holder = $('<div/>').css( scrollX || scrollY ?
  4862. {
  4863. position: 'absolute',
  4864. top: 0,
  4865. left: 0,
  4866. height: 1,
  4867. right: 0,
  4868. overflow: 'hidden'
  4869. } :
  4870. {}
  4871. )
  4872. .append( tmpTable )
  4873. .appendTo( tableContainer );
  4874. // When scrolling (X or Y) we want to set the width of the table as
  4875. // appropriate. However, when not scrolling leave the table width as it
  4876. // is. This results in slightly different, but I think correct behaviour
  4877. if ( scrollX && scrollXInner ) {
  4878. tmpTable.width( scrollXInner );
  4879. }
  4880. else if ( scrollX ) {
  4881. tmpTable.css( 'width', 'auto' );
  4882. tmpTable.removeAttr('width');
  4883. // If there is no width attribute or style, then allow the table to
  4884. // collapse
  4885. if ( tmpTable.width() < tableContainer.clientWidth && tableWidthAttr ) {
  4886. tmpTable.width( tableContainer.clientWidth );
  4887. }
  4888. }
  4889. else if ( scrollY ) {
  4890. tmpTable.width( tableContainer.clientWidth );
  4891. }
  4892. else if ( tableWidthAttr ) {
  4893. tmpTable.width( tableWidthAttr );
  4894. }
  4895. // Get the width of each column in the constructed table - we need to
  4896. // know the inner width (so it can be assigned to the other table's
  4897. // cells) and the outer width so we can calculate the full width of the
  4898. // table. This is safe since DataTables requires a unique cell for each
  4899. // column, but if ever a header can span multiple columns, this will
  4900. // need to be modified.
  4901. var total = 0;
  4902. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  4903. var cell = $(headerCells[i]);
  4904. var border = cell.outerWidth() - cell.width();
  4905. // Use getBounding... where possible (not IE8-) because it can give
  4906. // sub-pixel accuracy, which we then want to round up!
  4907. var bounding = browser.bBounding ?
  4908. Math.ceil( headerCells[i].getBoundingClientRect().width ) :
  4909. cell.outerWidth();
  4910. // Total is tracked to remove any sub-pixel errors as the outerWidth
  4911. // of the table might not equal the total given here (IE!).
  4912. total += bounding;
  4913. // Width for each column to use
  4914. columns[ visibleColumns[i] ].sWidth = _fnStringToCss( bounding - border );
  4915. }
  4916. table.style.width = _fnStringToCss( total );
  4917. // Finished with the table - ditch it
  4918. holder.remove();
  4919. }
  4920. // If there is a width attr, we want to attach an event listener which
  4921. // allows the table sizing to automatically adjust when the window is
  4922. // resized. Use the width attr rather than CSS, since we can't know if the
  4923. // CSS is a relative value or absolute - DOM read is always px.
  4924. if ( tableWidthAttr ) {
  4925. table.style.width = _fnStringToCss( tableWidthAttr );
  4926. }
  4927. if ( (tableWidthAttr || scrollX) && ! oSettings._reszEvt ) {
  4928. var bindResize = function () {
  4929. $(window).on('resize.DT-'+oSettings.sInstance, _fnThrottle( function () {
  4930. _fnAdjustColumnSizing( oSettings );
  4931. } ) );
  4932. };
  4933. // IE6/7 will crash if we bind a resize event handler on page load.
  4934. // To be removed in 1.11 which drops IE6/7 support
  4935. if ( ie67 ) {
  4936. setTimeout( bindResize, 1000 );
  4937. }
  4938. else {
  4939. bindResize();
  4940. }
  4941. oSettings._reszEvt = true;
  4942. }
  4943. }
  4944. /**
  4945. * Throttle the calls to a function. Arguments and context are maintained for
  4946. * the throttled function
  4947. * @param {function} fn Function to be called
  4948. * @param {int} [freq=200] call frequency in mS
  4949. * @returns {function} wrapped function
  4950. * @memberof DataTable#oApi
  4951. */
  4952. var _fnThrottle = DataTable.util.throttle;
  4953. /**
  4954. * Convert a CSS unit width to pixels (e.g. 2em)
  4955. * @param {string} width width to be converted
  4956. * @param {node} parent parent to get the with for (required for relative widths) - optional
  4957. * @returns {int} width in pixels
  4958. * @memberof DataTable#oApi
  4959. */
  4960. function _fnConvertToWidth ( width, parent )
  4961. {
  4962. if ( ! width ) {
  4963. return 0;
  4964. }
  4965. var n = $('<div/>')
  4966. .css( 'width', _fnStringToCss( width ) )
  4967. .appendTo( parent || document.body );
  4968. var val = n[0].offsetWidth;
  4969. n.remove();
  4970. return val;
  4971. }
  4972. /**
  4973. * Get the widest node
  4974. * @param {object} settings dataTables settings object
  4975. * @param {int} colIdx column of interest
  4976. * @returns {node} widest table node
  4977. * @memberof DataTable#oApi
  4978. */
  4979. function _fnGetWidestNode( settings, colIdx )
  4980. {
  4981. var idx = _fnGetMaxLenString( settings, colIdx );
  4982. if ( idx < 0 ) {
  4983. return null;
  4984. }
  4985. var data = settings.aoData[ idx ];
  4986. return ! data.nTr ? // Might not have been created when deferred rendering
  4987. $('<td/>').html( _fnGetCellData( settings, idx, colIdx, 'display' ) )[0] :
  4988. data.anCells[ colIdx ];
  4989. }
  4990. /**
  4991. * Get the maximum strlen for each data column
  4992. * @param {object} settings dataTables settings object
  4993. * @param {int} colIdx column of interest
  4994. * @returns {string} max string length for each column
  4995. * @memberof DataTable#oApi
  4996. */
  4997. function _fnGetMaxLenString( settings, colIdx )
  4998. {
  4999. var s, max=-1, maxIdx = -1;
  5000. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  5001. s = _fnGetCellData( settings, i, colIdx, 'display' )+'';
  5002. s = s.replace( __re_html_remove, '' );
  5003. s = s.replace( /&nbsp;/g, ' ' );
  5004. if ( s.length > max ) {
  5005. max = s.length;
  5006. maxIdx = i;
  5007. }
  5008. }
  5009. return maxIdx;
  5010. }
  5011. /**
  5012. * Append a CSS unit (only if required) to a string
  5013. * @param {string} value to css-ify
  5014. * @returns {string} value with css unit
  5015. * @memberof DataTable#oApi
  5016. */
  5017. function _fnStringToCss( s )
  5018. {
  5019. if ( s === null ) {
  5020. return '0px';
  5021. }
  5022. if ( typeof s == 'number' ) {
  5023. return s < 0 ?
  5024. '0px' :
  5025. s+'px';
  5026. }
  5027. // Check it has a unit character already
  5028. return s.match(/\d$/) ?
  5029. s+'px' :
  5030. s;
  5031. }
  5032. function _fnSortFlatten ( settings )
  5033. {
  5034. var
  5035. i, iLen, k, kLen,
  5036. aSort = [],
  5037. aiOrig = [],
  5038. aoColumns = settings.aoColumns,
  5039. aDataSort, iCol, sType, srcCol,
  5040. fixed = settings.aaSortingFixed,
  5041. fixedObj = $.isPlainObject( fixed ),
  5042. nestedSort = [],
  5043. add = function ( a ) {
  5044. if ( a.length && ! $.isArray( a[0] ) ) {
  5045. // 1D array
  5046. nestedSort.push( a );
  5047. }
  5048. else {
  5049. // 2D array
  5050. $.merge( nestedSort, a );
  5051. }
  5052. };
  5053. // Build the sort array, with pre-fix and post-fix options if they have been
  5054. // specified
  5055. if ( $.isArray( fixed ) ) {
  5056. add( fixed );
  5057. }
  5058. if ( fixedObj && fixed.pre ) {
  5059. add( fixed.pre );
  5060. }
  5061. add( settings.aaSorting );
  5062. if (fixedObj && fixed.post ) {
  5063. add( fixed.post );
  5064. }
  5065. for ( i=0 ; i<nestedSort.length ; i++ )
  5066. {
  5067. srcCol = nestedSort[i][0];
  5068. aDataSort = aoColumns[ srcCol ].aDataSort;
  5069. for ( k=0, kLen=aDataSort.length ; k<kLen ; k++ )
  5070. {
  5071. iCol = aDataSort[k];
  5072. sType = aoColumns[ iCol ].sType || 'string';
  5073. if ( nestedSort[i]._idx === undefined ) {
  5074. nestedSort[i]._idx = $.inArray( nestedSort[i][1], aoColumns[iCol].asSorting );
  5075. }
  5076. aSort.push( {
  5077. src: srcCol,
  5078. col: iCol,
  5079. dir: nestedSort[i][1],
  5080. index: nestedSort[i]._idx,
  5081. type: sType,
  5082. formatter: DataTable.ext.type.order[ sType+"-pre" ]
  5083. } );
  5084. }
  5085. }
  5086. return aSort;
  5087. }
  5088. /**
  5089. * Change the order of the table
  5090. * @param {object} oSettings dataTables settings object
  5091. * @memberof DataTable#oApi
  5092. * @todo This really needs split up!
  5093. */
  5094. function _fnSort ( oSettings )
  5095. {
  5096. var
  5097. i, ien, iLen, j, jLen, k, kLen,
  5098. sDataType, nTh,
  5099. aiOrig = [],
  5100. oExtSort = DataTable.ext.type.order,
  5101. aoData = oSettings.aoData,
  5102. aoColumns = oSettings.aoColumns,
  5103. aDataSort, data, iCol, sType, oSort,
  5104. formatters = 0,
  5105. sortCol,
  5106. displayMaster = oSettings.aiDisplayMaster,
  5107. aSort;
  5108. // Resolve any column types that are unknown due to addition or invalidation
  5109. // @todo Can this be moved into a 'data-ready' handler which is called when
  5110. // data is going to be used in the table?
  5111. _fnColumnTypes( oSettings );
  5112. aSort = _fnSortFlatten( oSettings );
  5113. for ( i=0, ien=aSort.length ; i<ien ; i++ ) {
  5114. sortCol = aSort[i];
  5115. // Track if we can use the fast sort algorithm
  5116. if ( sortCol.formatter ) {
  5117. formatters++;
  5118. }
  5119. // Load the data needed for the sort, for each cell
  5120. _fnSortData( oSettings, sortCol.col );
  5121. }
  5122. /* No sorting required if server-side or no sorting array */
  5123. if ( _fnDataSource( oSettings ) != 'ssp' && aSort.length !== 0 )
  5124. {
  5125. // Create a value - key array of the current row positions such that we can use their
  5126. // current position during the sort, if values match, in order to perform stable sorting
  5127. for ( i=0, iLen=displayMaster.length ; i<iLen ; i++ ) {
  5128. aiOrig[ displayMaster[i] ] = i;
  5129. }
  5130. /* Do the sort - here we want multi-column sorting based on a given data source (column)
  5131. * and sorting function (from oSort) in a certain direction. It's reasonably complex to
  5132. * follow on it's own, but this is what we want (example two column sorting):
  5133. * fnLocalSorting = function(a,b){
  5134. * var iTest;
  5135. * iTest = oSort['string-asc']('data11', 'data12');
  5136. * if (iTest !== 0)
  5137. * return iTest;
  5138. * iTest = oSort['numeric-desc']('data21', 'data22');
  5139. * if (iTest !== 0)
  5140. * return iTest;
  5141. * return oSort['numeric-asc']( aiOrig[a], aiOrig[b] );
  5142. * }
  5143. * Basically we have a test for each sorting column, if the data in that column is equal,
  5144. * test the next column. If all columns match, then we use a numeric sort on the row
  5145. * positions in the original data array to provide a stable sort.
  5146. *
  5147. * Note - I know it seems excessive to have two sorting methods, but the first is around
  5148. * 15% faster, so the second is only maintained for backwards compatibility with sorting
  5149. * methods which do not have a pre-sort formatting function.
  5150. */
  5151. if ( formatters === aSort.length ) {
  5152. // All sort types have formatting functions
  5153. displayMaster.sort( function ( a, b ) {
  5154. var
  5155. x, y, k, test, sort,
  5156. len=aSort.length,
  5157. dataA = aoData[a]._aSortData,
  5158. dataB = aoData[b]._aSortData;
  5159. for ( k=0 ; k<len ; k++ ) {
  5160. sort = aSort[k];
  5161. x = dataA[ sort.col ];
  5162. y = dataB[ sort.col ];
  5163. test = x<y ? -1 : x>y ? 1 : 0;
  5164. if ( test !== 0 ) {
  5165. return sort.dir === 'asc' ? test : -test;
  5166. }
  5167. }
  5168. x = aiOrig[a];
  5169. y = aiOrig[b];
  5170. return x<y ? -1 : x>y ? 1 : 0;
  5171. } );
  5172. }
  5173. else {
  5174. // Depreciated - remove in 1.11 (providing a plug-in option)
  5175. // Not all sort types have formatting methods, so we have to call their sorting
  5176. // methods.
  5177. displayMaster.sort( function ( a, b ) {
  5178. var
  5179. x, y, k, l, test, sort, fn,
  5180. len=aSort.length,
  5181. dataA = aoData[a]._aSortData,
  5182. dataB = aoData[b]._aSortData;
  5183. for ( k=0 ; k<len ; k++ ) {
  5184. sort = aSort[k];
  5185. x = dataA[ sort.col ];
  5186. y = dataB[ sort.col ];
  5187. fn = oExtSort[ sort.type+"-"+sort.dir ] || oExtSort[ "string-"+sort.dir ];
  5188. test = fn( x, y );
  5189. if ( test !== 0 ) {
  5190. return test;
  5191. }
  5192. }
  5193. x = aiOrig[a];
  5194. y = aiOrig[b];
  5195. return x<y ? -1 : x>y ? 1 : 0;
  5196. } );
  5197. }
  5198. }
  5199. /* Tell the draw function that we have sorted the data */
  5200. oSettings.bSorted = true;
  5201. }
  5202. function _fnSortAria ( settings )
  5203. {
  5204. var label;
  5205. var nextSort;
  5206. var columns = settings.aoColumns;
  5207. var aSort = _fnSortFlatten( settings );
  5208. var oAria = settings.oLanguage.oAria;
  5209. // ARIA attributes - need to loop all columns, to update all (removing old
  5210. // attributes as needed)
  5211. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  5212. {
  5213. var col = columns[i];
  5214. var asSorting = col.asSorting;
  5215. var sTitle = col.sTitle.replace( /<.*?>/g, "" );
  5216. var th = col.nTh;
  5217. // IE7 is throwing an error when setting these properties with jQuery's
  5218. // attr() and removeAttr() methods...
  5219. th.removeAttribute('aria-sort');
  5220. /* In ARIA only the first sorting column can be marked as sorting - no multi-sort option */
  5221. if ( col.bSortable ) {
  5222. if ( aSort.length > 0 && aSort[0].col == i ) {
  5223. th.setAttribute('aria-sort', aSort[0].dir=="asc" ? "ascending" : "descending" );
  5224. nextSort = asSorting[ aSort[0].index+1 ] || asSorting[0];
  5225. }
  5226. else {
  5227. nextSort = asSorting[0];
  5228. }
  5229. label = sTitle + ( nextSort === "asc" ?
  5230. oAria.sSortAscending :
  5231. oAria.sSortDescending
  5232. );
  5233. }
  5234. else {
  5235. label = sTitle;
  5236. }
  5237. th.setAttribute('aria-label', label);
  5238. }
  5239. }
  5240. /**
  5241. * Function to run on user sort request
  5242. * @param {object} settings dataTables settings object
  5243. * @param {node} attachTo node to attach the handler to
  5244. * @param {int} colIdx column sorting index
  5245. * @param {boolean} [append=false] Append the requested sort to the existing
  5246. * sort if true (i.e. multi-column sort)
  5247. * @param {function} [callback] callback function
  5248. * @memberof DataTable#oApi
  5249. */
  5250. function _fnSortListener ( settings, colIdx, append, callback )
  5251. {
  5252. var col = settings.aoColumns[ colIdx ];
  5253. var sorting = settings.aaSorting;
  5254. var asSorting = col.asSorting;
  5255. var nextSortIdx;
  5256. var next = function ( a, overflow ) {
  5257. var idx = a._idx;
  5258. if ( idx === undefined ) {
  5259. idx = $.inArray( a[1], asSorting );
  5260. }
  5261. return idx+1 < asSorting.length ?
  5262. idx+1 :
  5263. overflow ?
  5264. null :
  5265. 0;
  5266. };
  5267. // Convert to 2D array if needed
  5268. if ( typeof sorting[0] === 'number' ) {
  5269. sorting = settings.aaSorting = [ sorting ];
  5270. }
  5271. // If appending the sort then we are multi-column sorting
  5272. if ( append && settings.oFeatures.bSortMulti ) {
  5273. // Are we already doing some kind of sort on this column?
  5274. var sortIdx = $.inArray( colIdx, _pluck(sorting, '0') );
  5275. if ( sortIdx !== -1 ) {
  5276. // Yes, modify the sort
  5277. nextSortIdx = next( sorting[sortIdx], true );
  5278. if ( nextSortIdx === null && sorting.length === 1 ) {
  5279. nextSortIdx = 0; // can't remove sorting completely
  5280. }
  5281. if ( nextSortIdx === null ) {
  5282. sorting.splice( sortIdx, 1 );
  5283. }
  5284. else {
  5285. sorting[sortIdx][1] = asSorting[ nextSortIdx ];
  5286. sorting[sortIdx]._idx = nextSortIdx;
  5287. }
  5288. }
  5289. else {
  5290. // No sort on this column yet
  5291. sorting.push( [ colIdx, asSorting[0], 0 ] );
  5292. sorting[sorting.length-1]._idx = 0;
  5293. }
  5294. }
  5295. else if ( sorting.length && sorting[0][0] == colIdx ) {
  5296. // Single column - already sorting on this column, modify the sort
  5297. nextSortIdx = next( sorting[0] );
  5298. sorting.length = 1;
  5299. sorting[0][1] = asSorting[ nextSortIdx ];
  5300. sorting[0]._idx = nextSortIdx;
  5301. }
  5302. else {
  5303. // Single column - sort only on this column
  5304. sorting.length = 0;
  5305. sorting.push( [ colIdx, asSorting[0] ] );
  5306. sorting[0]._idx = 0;
  5307. }
  5308. // Run the sort by calling a full redraw
  5309. _fnReDraw( settings );
  5310. // callback used for async user interaction
  5311. if ( typeof callback == 'function' ) {
  5312. callback( settings );
  5313. }
  5314. }
  5315. /**
  5316. * Attach a sort handler (click) to a node
  5317. * @param {object} settings dataTables settings object
  5318. * @param {node} attachTo node to attach the handler to
  5319. * @param {int} colIdx column sorting index
  5320. * @param {function} [callback] callback function
  5321. * @memberof DataTable#oApi
  5322. */
  5323. function _fnSortAttachListener ( settings, attachTo, colIdx, callback )
  5324. {
  5325. var col = settings.aoColumns[ colIdx ];
  5326. _fnBindAction( attachTo, {}, function (e) {
  5327. /* If the column is not sortable - don't to anything */
  5328. if ( col.bSortable === false ) {
  5329. return;
  5330. }
  5331. // If processing is enabled use a timeout to allow the processing
  5332. // display to be shown - otherwise to it synchronously
  5333. if ( settings.oFeatures.bProcessing ) {
  5334. _fnProcessingDisplay( settings, true );
  5335. setTimeout( function() {
  5336. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  5337. // In server-side processing, the draw callback will remove the
  5338. // processing display
  5339. if ( _fnDataSource( settings ) !== 'ssp' ) {
  5340. _fnProcessingDisplay( settings, false );
  5341. }
  5342. }, 0 );
  5343. }
  5344. else {
  5345. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  5346. }
  5347. } );
  5348. }
  5349. /**
  5350. * Set the sorting classes on table's body, Note: it is safe to call this function
  5351. * when bSort and bSortClasses are false
  5352. * @param {object} oSettings dataTables settings object
  5353. * @memberof DataTable#oApi
  5354. */
  5355. function _fnSortingClasses( settings )
  5356. {
  5357. var oldSort = settings.aLastSort;
  5358. var sortClass = settings.oClasses.sSortColumn;
  5359. var sort = _fnSortFlatten( settings );
  5360. var features = settings.oFeatures;
  5361. var i, ien, colIdx;
  5362. if ( features.bSort && features.bSortClasses ) {
  5363. // Remove old sorting classes
  5364. for ( i=0, ien=oldSort.length ; i<ien ; i++ ) {
  5365. colIdx = oldSort[i].src;
  5366. // Remove column sorting
  5367. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  5368. .removeClass( sortClass + (i<2 ? i+1 : 3) );
  5369. }
  5370. // Add new column sorting
  5371. for ( i=0, ien=sort.length ; i<ien ; i++ ) {
  5372. colIdx = sort[i].src;
  5373. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  5374. .addClass( sortClass + (i<2 ? i+1 : 3) );
  5375. }
  5376. }
  5377. settings.aLastSort = sort;
  5378. }
  5379. // Get the data to sort a column, be it from cache, fresh (populating the
  5380. // cache), or from a sort formatter
  5381. function _fnSortData( settings, idx )
  5382. {
  5383. // Custom sorting function - provided by the sort data type
  5384. var column = settings.aoColumns[ idx ];
  5385. var customSort = DataTable.ext.order[ column.sSortDataType ];
  5386. var customData;
  5387. if ( customSort ) {
  5388. customData = customSort.call( settings.oInstance, settings, idx,
  5389. _fnColumnIndexToVisible( settings, idx )
  5390. );
  5391. }
  5392. // Use / populate cache
  5393. var row, cellData;
  5394. var formatter = DataTable.ext.type.order[ column.sType+"-pre" ];
  5395. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  5396. row = settings.aoData[i];
  5397. if ( ! row._aSortData ) {
  5398. row._aSortData = [];
  5399. }
  5400. if ( ! row._aSortData[idx] || customSort ) {
  5401. cellData = customSort ?
  5402. customData[i] : // If there was a custom sort function, use data from there
  5403. _fnGetCellData( settings, i, idx, 'sort' );
  5404. row._aSortData[ idx ] = formatter ?
  5405. formatter( cellData ) :
  5406. cellData;
  5407. }
  5408. }
  5409. }
  5410. /**
  5411. * Save the state of a table
  5412. * @param {object} oSettings dataTables settings object
  5413. * @memberof DataTable#oApi
  5414. */
  5415. function _fnSaveState ( settings )
  5416. {
  5417. if ( !settings.oFeatures.bStateSave || settings.bDestroying )
  5418. {
  5419. return;
  5420. }
  5421. /* Store the interesting variables */
  5422. var state = {
  5423. time: +new Date(),
  5424. start: settings._iDisplayStart,
  5425. length: settings._iDisplayLength,
  5426. order: $.extend( true, [], settings.aaSorting ),
  5427. search: _fnSearchToCamel( settings.oPreviousSearch ),
  5428. columns: $.map( settings.aoColumns, function ( col, i ) {
  5429. return {
  5430. visible: col.bVisible,
  5431. search: _fnSearchToCamel( settings.aoPreSearchCols[i] )
  5432. };
  5433. } )
  5434. };
  5435. _fnCallbackFire( settings, "aoStateSaveParams", 'stateSaveParams', [settings, state] );
  5436. settings.oSavedState = state;
  5437. settings.fnStateSaveCallback.call( settings.oInstance, settings, state );
  5438. }
  5439. /**
  5440. * Attempt to load a saved table state
  5441. * @param {object} oSettings dataTables settings object
  5442. * @param {object} oInit DataTables init object so we can override settings
  5443. * @param {function} callback Callback to execute when the state has been loaded
  5444. * @memberof DataTable#oApi
  5445. */
  5446. function _fnLoadState ( settings, oInit, callback )
  5447. {
  5448. var i, ien;
  5449. var columns = settings.aoColumns;
  5450. var loaded = function ( s ) {
  5451. if ( ! s || ! s.time ) {
  5452. callback();
  5453. return;
  5454. }
  5455. // Allow custom and plug-in manipulation functions to alter the saved data set and
  5456. // cancelling of loading by returning false
  5457. var abStateLoad = _fnCallbackFire( settings, 'aoStateLoadParams', 'stateLoadParams', [settings, s] );
  5458. if ( $.inArray( false, abStateLoad ) !== -1 ) {
  5459. callback();
  5460. return;
  5461. }
  5462. // Reject old data
  5463. var duration = settings.iStateDuration;
  5464. if ( duration > 0 && s.time < +new Date() - (duration*1000) ) {
  5465. callback();
  5466. return;
  5467. }
  5468. // Number of columns have changed - all bets are off, no restore of settings
  5469. if ( s.columns && columns.length !== s.columns.length ) {
  5470. callback();
  5471. return;
  5472. }
  5473. // Store the saved state so it might be accessed at any time
  5474. settings.oLoadedState = $.extend( true, {}, s );
  5475. // Restore key features - todo - for 1.11 this needs to be done by
  5476. // subscribed events
  5477. if ( s.start !== undefined ) {
  5478. settings._iDisplayStart = s.start;
  5479. settings.iInitDisplayStart = s.start;
  5480. }
  5481. if ( s.length !== undefined ) {
  5482. settings._iDisplayLength = s.length;
  5483. }
  5484. // Order
  5485. if ( s.order !== undefined ) {
  5486. settings.aaSorting = [];
  5487. $.each( s.order, function ( i, col ) {
  5488. settings.aaSorting.push( col[0] >= columns.length ?
  5489. [ 0, col[1] ] :
  5490. col
  5491. );
  5492. } );
  5493. }
  5494. // Search
  5495. if ( s.search !== undefined ) {
  5496. $.extend( settings.oPreviousSearch, _fnSearchToHung( s.search ) );
  5497. }
  5498. // Columns
  5499. //
  5500. if ( s.columns ) {
  5501. for ( i=0, ien=s.columns.length ; i<ien ; i++ ) {
  5502. var col = s.columns[i];
  5503. // Visibility
  5504. if ( col.visible !== undefined ) {
  5505. columns[i].bVisible = col.visible;
  5506. }
  5507. // Search
  5508. if ( col.search !== undefined ) {
  5509. $.extend( settings.aoPreSearchCols[i], _fnSearchToHung( col.search ) );
  5510. }
  5511. }
  5512. }
  5513. _fnCallbackFire( settings, 'aoStateLoaded', 'stateLoaded', [settings, s] );
  5514. callback();
  5515. }
  5516. if ( ! settings.oFeatures.bStateSave ) {
  5517. callback();
  5518. return;
  5519. }
  5520. var state = settings.fnStateLoadCallback.call( settings.oInstance, settings, loaded );
  5521. if ( state !== undefined ) {
  5522. loaded( state );
  5523. }
  5524. // otherwise, wait for the loaded callback to be executed
  5525. }
  5526. /**
  5527. * Return the settings object for a particular table
  5528. * @param {node} table table we are using as a dataTable
  5529. * @returns {object} Settings object - or null if not found
  5530. * @memberof DataTable#oApi
  5531. */
  5532. function _fnSettingsFromNode ( table )
  5533. {
  5534. var settings = DataTable.settings;
  5535. var idx = $.inArray( table, _pluck( settings, 'nTable' ) );
  5536. return idx !== -1 ?
  5537. settings[ idx ] :
  5538. null;
  5539. }
  5540. /**
  5541. * Log an error message
  5542. * @param {object} settings dataTables settings object
  5543. * @param {int} level log error messages, or display them to the user
  5544. * @param {string} msg error message
  5545. * @param {int} tn Technical note id to get more information about the error.
  5546. * @memberof DataTable#oApi
  5547. */
  5548. function _fnLog( settings, level, msg, tn )
  5549. {
  5550. msg = 'DataTables warning: '+
  5551. (settings ? 'table id='+settings.sTableId+' - ' : '')+msg;
  5552. if ( tn ) {
  5553. msg += '. For more information about this error, please see '+
  5554. 'http://datatables.net/tn/'+tn;
  5555. }
  5556. if ( ! level ) {
  5557. // Backwards compatibility pre 1.10
  5558. var ext = DataTable.ext;
  5559. var type = ext.sErrMode || ext.errMode;
  5560. if ( settings ) {
  5561. _fnCallbackFire( settings, null, 'error', [ settings, tn, msg ] );
  5562. }
  5563. if ( type == 'alert' ) {
  5564. alert( msg );
  5565. }
  5566. else if ( type == 'throw' ) {
  5567. throw new Error(msg);
  5568. }
  5569. else if ( typeof type == 'function' ) {
  5570. type( settings, tn, msg );
  5571. }
  5572. }
  5573. else if ( window.console && console.log ) {
  5574. console.log( msg );
  5575. }
  5576. }
  5577. /**
  5578. * See if a property is defined on one object, if so assign it to the other object
  5579. * @param {object} ret target object
  5580. * @param {object} src source object
  5581. * @param {string} name property
  5582. * @param {string} [mappedName] name to map too - optional, name used if not given
  5583. * @memberof DataTable#oApi
  5584. */
  5585. function _fnMap( ret, src, name, mappedName )
  5586. {
  5587. if ( $.isArray( name ) ) {
  5588. $.each( name, function (i, val) {
  5589. if ( $.isArray( val ) ) {
  5590. _fnMap( ret, src, val[0], val[1] );
  5591. }
  5592. else {
  5593. _fnMap( ret, src, val );
  5594. }
  5595. } );
  5596. return;
  5597. }
  5598. if ( mappedName === undefined ) {
  5599. mappedName = name;
  5600. }
  5601. if ( src[name] !== undefined ) {
  5602. ret[mappedName] = src[name];
  5603. }
  5604. }
  5605. /**
  5606. * Extend objects - very similar to jQuery.extend, but deep copy objects, and
  5607. * shallow copy arrays. The reason we need to do this, is that we don't want to
  5608. * deep copy array init values (such as aaSorting) since the dev wouldn't be
  5609. * able to override them, but we do want to deep copy arrays.
  5610. * @param {object} out Object to extend
  5611. * @param {object} extender Object from which the properties will be applied to
  5612. * out
  5613. * @param {boolean} breakRefs If true, then arrays will be sliced to take an
  5614. * independent copy with the exception of the `data` or `aaData` parameters
  5615. * if they are present. This is so you can pass in a collection to
  5616. * DataTables and have that used as your data source without breaking the
  5617. * references
  5618. * @returns {object} out Reference, just for convenience - out === the return.
  5619. * @memberof DataTable#oApi
  5620. * @todo This doesn't take account of arrays inside the deep copied objects.
  5621. */
  5622. function _fnExtend( out, extender, breakRefs )
  5623. {
  5624. var val;
  5625. for ( var prop in extender ) {
  5626. if ( extender.hasOwnProperty(prop) ) {
  5627. val = extender[prop];
  5628. if ( $.isPlainObject( val ) ) {
  5629. if ( ! $.isPlainObject( out[prop] ) ) {
  5630. out[prop] = {};
  5631. }
  5632. $.extend( true, out[prop], val );
  5633. }
  5634. else if ( breakRefs && prop !== 'data' && prop !== 'aaData' && $.isArray(val) ) {
  5635. out[prop] = val.slice();
  5636. }
  5637. else {
  5638. out[prop] = val;
  5639. }
  5640. }
  5641. }
  5642. return out;
  5643. }
  5644. /**
  5645. * Bind an event handers to allow a click or return key to activate the callback.
  5646. * This is good for accessibility since a return on the keyboard will have the
  5647. * same effect as a click, if the element has focus.
  5648. * @param {element} n Element to bind the action to
  5649. * @param {object} oData Data object to pass to the triggered function
  5650. * @param {function} fn Callback function for when the event is triggered
  5651. * @memberof DataTable#oApi
  5652. */
  5653. function _fnBindAction( n, oData, fn )
  5654. {
  5655. $(n)
  5656. .on( 'click.DT', oData, function (e) {
  5657. n.blur(); // Remove focus outline for mouse users
  5658. fn(e);
  5659. } )
  5660. .on( 'keypress.DT', oData, function (e){
  5661. if ( e.which === 13 ) {
  5662. e.preventDefault();
  5663. fn(e);
  5664. }
  5665. } )
  5666. .on( 'selectstart.DT', function () {
  5667. /* Take the brutal approach to cancelling text selection */
  5668. return false;
  5669. } );
  5670. }
  5671. /**
  5672. * Register a callback function. Easily allows a callback function to be added to
  5673. * an array store of callback functions that can then all be called together.
  5674. * @param {object} oSettings dataTables settings object
  5675. * @param {string} sStore Name of the array storage for the callbacks in oSettings
  5676. * @param {function} fn Function to be called back
  5677. * @param {string} sName Identifying name for the callback (i.e. a label)
  5678. * @memberof DataTable#oApi
  5679. */
  5680. function _fnCallbackReg( oSettings, sStore, fn, sName )
  5681. {
  5682. if ( fn )
  5683. {
  5684. oSettings[sStore].push( {
  5685. "fn": fn,
  5686. "sName": sName
  5687. } );
  5688. }
  5689. }
  5690. /**
  5691. * Fire callback functions and trigger events. Note that the loop over the
  5692. * callback array store is done backwards! Further note that you do not want to
  5693. * fire off triggers in time sensitive applications (for example cell creation)
  5694. * as its slow.
  5695. * @param {object} settings dataTables settings object
  5696. * @param {string} callbackArr Name of the array storage for the callbacks in
  5697. * oSettings
  5698. * @param {string} eventName Name of the jQuery custom event to trigger. If
  5699. * null no trigger is fired
  5700. * @param {array} args Array of arguments to pass to the callback function /
  5701. * trigger
  5702. * @memberof DataTable#oApi
  5703. */
  5704. function _fnCallbackFire( settings, callbackArr, eventName, args )
  5705. {
  5706. var ret = [];
  5707. if ( callbackArr ) {
  5708. ret = $.map( settings[callbackArr].slice().reverse(), function (val, i) {
  5709. return val.fn.apply( settings.oInstance, args );
  5710. } );
  5711. }
  5712. if ( eventName !== null ) {
  5713. var e = $.Event( eventName+'.dt' );
  5714. $(settings.nTable).trigger( e, args );
  5715. ret.push( e.result );
  5716. }
  5717. return ret;
  5718. }
  5719. function _fnLengthOverflow ( settings )
  5720. {
  5721. var
  5722. start = settings._iDisplayStart,
  5723. end = settings.fnDisplayEnd(),
  5724. len = settings._iDisplayLength;
  5725. /* If we have space to show extra rows (backing up from the end point - then do so */
  5726. if ( start >= end )
  5727. {
  5728. start = end - len;
  5729. }
  5730. // Keep the start record on the current page
  5731. start -= (start % len);
  5732. if ( len === -1 || start < 0 )
  5733. {
  5734. start = 0;
  5735. }
  5736. settings._iDisplayStart = start;
  5737. }
  5738. function _fnRenderer( settings, type )
  5739. {
  5740. var renderer = settings.renderer;
  5741. var host = DataTable.ext.renderer[type];
  5742. if ( $.isPlainObject( renderer ) && renderer[type] ) {
  5743. // Specific renderer for this type. If available use it, otherwise use
  5744. // the default.
  5745. return host[renderer[type]] || host._;
  5746. }
  5747. else if ( typeof renderer === 'string' ) {
  5748. // Common renderer - if there is one available for this type use it,
  5749. // otherwise use the default
  5750. return host[renderer] || host._;
  5751. }
  5752. // Use the default
  5753. return host._;
  5754. }
  5755. /**
  5756. * Detect the data source being used for the table. Used to simplify the code
  5757. * a little (ajax) and to make it compress a little smaller.
  5758. *
  5759. * @param {object} settings dataTables settings object
  5760. * @returns {string} Data source
  5761. * @memberof DataTable#oApi
  5762. */
  5763. function _fnDataSource ( settings )
  5764. {
  5765. if ( settings.oFeatures.bServerSide ) {
  5766. return 'ssp';
  5767. }
  5768. else if ( settings.ajax || settings.sAjaxSource ) {
  5769. return 'ajax';
  5770. }
  5771. return 'dom';
  5772. }
  5773. /**
  5774. * Computed structure of the DataTables API, defined by the options passed to
  5775. * `DataTable.Api.register()` when building the API.
  5776. *
  5777. * The structure is built in order to speed creation and extension of the Api
  5778. * objects since the extensions are effectively pre-parsed.
  5779. *
  5780. * The array is an array of objects with the following structure, where this
  5781. * base array represents the Api prototype base:
  5782. *
  5783. * [
  5784. * {
  5785. * name: 'data' -- string - Property name
  5786. * val: function () {}, -- function - Api method (or undefined if just an object
  5787. * methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  5788. * propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  5789. * },
  5790. * {
  5791. * name: 'row'
  5792. * val: {},
  5793. * methodExt: [ ... ],
  5794. * propExt: [
  5795. * {
  5796. * name: 'data'
  5797. * val: function () {},
  5798. * methodExt: [ ... ],
  5799. * propExt: [ ... ]
  5800. * },
  5801. * ...
  5802. * ]
  5803. * }
  5804. * ]
  5805. *
  5806. * @type {Array}
  5807. * @ignore
  5808. */
  5809. var __apiStruct = [];
  5810. /**
  5811. * `Array.prototype` reference.
  5812. *
  5813. * @type object
  5814. * @ignore
  5815. */
  5816. var __arrayProto = Array.prototype;
  5817. /**
  5818. * Abstraction for `context` parameter of the `Api` constructor to allow it to
  5819. * take several different forms for ease of use.
  5820. *
  5821. * Each of the input parameter types will be converted to a DataTables settings
  5822. * object where possible.
  5823. *
  5824. * @param {string|node|jQuery|object} mixed DataTable identifier. Can be one
  5825. * of:
  5826. *
  5827. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5828. * with be found and used.
  5829. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5830. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5831. * * `object` - DataTables settings object
  5832. * * `DataTables.Api` - API instance
  5833. * @return {array|null} Matching DataTables settings objects. `null` or
  5834. * `undefined` is returned if no matching DataTable is found.
  5835. * @ignore
  5836. */
  5837. var _toSettings = function ( mixed )
  5838. {
  5839. var idx, jq;
  5840. var settings = DataTable.settings;
  5841. var tables = $.map( settings, function (el, i) {
  5842. return el.nTable;
  5843. } );
  5844. if ( ! mixed ) {
  5845. return [];
  5846. }
  5847. else if ( mixed.nTable && mixed.oApi ) {
  5848. // DataTables settings object
  5849. return [ mixed ];
  5850. }
  5851. else if ( mixed.nodeName && mixed.nodeName.toLowerCase() === 'table' ) {
  5852. // Table node
  5853. idx = $.inArray( mixed, tables );
  5854. return idx !== -1 ? [ settings[idx] ] : null;
  5855. }
  5856. else if ( mixed && typeof mixed.settings === 'function' ) {
  5857. return mixed.settings().toArray();
  5858. }
  5859. else if ( typeof mixed === 'string' ) {
  5860. // jQuery selector
  5861. jq = $(mixed);
  5862. }
  5863. else if ( mixed instanceof $ ) {
  5864. // jQuery object (also DataTables instance)
  5865. jq = mixed;
  5866. }
  5867. if ( jq ) {
  5868. return jq.map( function(i) {
  5869. idx = $.inArray( this, tables );
  5870. return idx !== -1 ? settings[idx] : null;
  5871. } ).toArray();
  5872. }
  5873. };
  5874. /**
  5875. * DataTables API class - used to control and interface with one or more
  5876. * DataTables enhanced tables.
  5877. *
  5878. * The API class is heavily based on jQuery, presenting a chainable interface
  5879. * that you can use to interact with tables. Each instance of the API class has
  5880. * a "context" - i.e. the tables that it will operate on. This could be a single
  5881. * table, all tables on a page or a sub-set thereof.
  5882. *
  5883. * Additionally the API is designed to allow you to easily work with the data in
  5884. * the tables, retrieving and manipulating it as required. This is done by
  5885. * presenting the API class as an array like interface. The contents of the
  5886. * array depend upon the actions requested by each method (for example
  5887. * `rows().nodes()` will return an array of nodes, while `rows().data()` will
  5888. * return an array of objects or arrays depending upon your table's
  5889. * configuration). The API object has a number of array like methods (`push`,
  5890. * `pop`, `reverse` etc) as well as additional helper methods (`each`, `pluck`,
  5891. * `unique` etc) to assist your working with the data held in a table.
  5892. *
  5893. * Most methods (those which return an Api instance) are chainable, which means
  5894. * the return from a method call also has all of the methods available that the
  5895. * top level object had. For example, these two calls are equivalent:
  5896. *
  5897. * // Not chained
  5898. * api.row.add( {...} );
  5899. * api.draw();
  5900. *
  5901. * // Chained
  5902. * api.row.add( {...} ).draw();
  5903. *
  5904. * @class DataTable.Api
  5905. * @param {array|object|string|jQuery} context DataTable identifier. This is
  5906. * used to define which DataTables enhanced tables this API will operate on.
  5907. * Can be one of:
  5908. *
  5909. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5910. * with be found and used.
  5911. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5912. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5913. * * `object` - DataTables settings object
  5914. * @param {array} [data] Data to initialise the Api instance with.
  5915. *
  5916. * @example
  5917. * // Direct initialisation during DataTables construction
  5918. * var api = $('#example').DataTable();
  5919. *
  5920. * @example
  5921. * // Initialisation using a DataTables jQuery object
  5922. * var api = $('#example').dataTable().api();
  5923. *
  5924. * @example
  5925. * // Initialisation as a constructor
  5926. * var api = new $.fn.DataTable.Api( 'table.dataTable' );
  5927. */
  5928. _Api = function ( context, data )
  5929. {
  5930. if ( ! (this instanceof _Api) ) {
  5931. return new _Api( context, data );
  5932. }
  5933. var settings = [];
  5934. var ctxSettings = function ( o ) {
  5935. var a = _toSettings( o );
  5936. if ( a ) {
  5937. settings = settings.concat( a );
  5938. }
  5939. };
  5940. if ( $.isArray( context ) ) {
  5941. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  5942. ctxSettings( context[i] );
  5943. }
  5944. }
  5945. else {
  5946. ctxSettings( context );
  5947. }
  5948. // Remove duplicates
  5949. this.context = _unique( settings );
  5950. // Initial data
  5951. if ( data ) {
  5952. $.merge( this, data );
  5953. }
  5954. // selector
  5955. this.selector = {
  5956. rows: null,
  5957. cols: null,
  5958. opts: null
  5959. };
  5960. _Api.extend( this, this, __apiStruct );
  5961. };
  5962. DataTable.Api = _Api;
  5963. // Don't destroy the existing prototype, just extend it. Required for jQuery 2's
  5964. // isPlainObject.
  5965. $.extend( _Api.prototype, {
  5966. any: function ()
  5967. {
  5968. return this.count() !== 0;
  5969. },
  5970. concat: __arrayProto.concat,
  5971. context: [], // array of table settings objects
  5972. count: function ()
  5973. {
  5974. return this.flatten().length;
  5975. },
  5976. each: function ( fn )
  5977. {
  5978. for ( var i=0, ien=this.length ; i<ien; i++ ) {
  5979. fn.call( this, this[i], i, this );
  5980. }
  5981. return this;
  5982. },
  5983. eq: function ( idx )
  5984. {
  5985. var ctx = this.context;
  5986. return ctx.length > idx ?
  5987. new _Api( ctx[idx], this[idx] ) :
  5988. null;
  5989. },
  5990. filter: function ( fn )
  5991. {
  5992. var a = [];
  5993. if ( __arrayProto.filter ) {
  5994. a = __arrayProto.filter.call( this, fn, this );
  5995. }
  5996. else {
  5997. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  5998. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  5999. if ( fn.call( this, this[i], i, this ) ) {
  6000. a.push( this[i] );
  6001. }
  6002. }
  6003. }
  6004. return new _Api( this.context, a );
  6005. },
  6006. flatten: function ()
  6007. {
  6008. var a = [];
  6009. return new _Api( this.context, a.concat.apply( a, this.toArray() ) );
  6010. },
  6011. join: __arrayProto.join,
  6012. indexOf: __arrayProto.indexOf || function (obj, start)
  6013. {
  6014. for ( var i=(start || 0), ien=this.length ; i<ien ; i++ ) {
  6015. if ( this[i] === obj ) {
  6016. return i;
  6017. }
  6018. }
  6019. return -1;
  6020. },
  6021. iterator: function ( flatten, type, fn, alwaysNew ) {
  6022. var
  6023. a = [], ret,
  6024. i, ien, j, jen,
  6025. context = this.context,
  6026. rows, items, item,
  6027. selector = this.selector;
  6028. // Argument shifting
  6029. if ( typeof flatten === 'string' ) {
  6030. alwaysNew = fn;
  6031. fn = type;
  6032. type = flatten;
  6033. flatten = false;
  6034. }
  6035. for ( i=0, ien=context.length ; i<ien ; i++ ) {
  6036. var apiInst = new _Api( context[i] );
  6037. if ( type === 'table' ) {
  6038. ret = fn.call( apiInst, context[i], i );
  6039. if ( ret !== undefined ) {
  6040. a.push( ret );
  6041. }
  6042. }
  6043. else if ( type === 'columns' || type === 'rows' ) {
  6044. // this has same length as context - one entry for each table
  6045. ret = fn.call( apiInst, context[i], this[i], i );
  6046. if ( ret !== undefined ) {
  6047. a.push( ret );
  6048. }
  6049. }
  6050. else if ( type === 'column' || type === 'column-rows' || type === 'row' || type === 'cell' ) {
  6051. // columns and rows share the same structure.
  6052. // 'this' is an array of column indexes for each context
  6053. items = this[i];
  6054. if ( type === 'column-rows' ) {
  6055. rows = _selector_row_indexes( context[i], selector.opts );
  6056. }
  6057. for ( j=0, jen=items.length ; j<jen ; j++ ) {
  6058. item = items[j];
  6059. if ( type === 'cell' ) {
  6060. ret = fn.call( apiInst, context[i], item.row, item.column, i, j );
  6061. }
  6062. else {
  6063. ret = fn.call( apiInst, context[i], item, i, j, rows );
  6064. }
  6065. if ( ret !== undefined ) {
  6066. a.push( ret );
  6067. }
  6068. }
  6069. }
  6070. }
  6071. if ( a.length || alwaysNew ) {
  6072. var api = new _Api( context, flatten ? a.concat.apply( [], a ) : a );
  6073. var apiSelector = api.selector;
  6074. apiSelector.rows = selector.rows;
  6075. apiSelector.cols = selector.cols;
  6076. apiSelector.opts = selector.opts;
  6077. return api;
  6078. }
  6079. return this;
  6080. },
  6081. lastIndexOf: __arrayProto.lastIndexOf || function (obj, start)
  6082. {
  6083. // Bit cheeky...
  6084. return this.indexOf.apply( this.toArray.reverse(), arguments );
  6085. },
  6086. length: 0,
  6087. map: function ( fn )
  6088. {
  6089. var a = [];
  6090. if ( __arrayProto.map ) {
  6091. a = __arrayProto.map.call( this, fn, this );
  6092. }
  6093. else {
  6094. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  6095. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  6096. a.push( fn.call( this, this[i], i ) );
  6097. }
  6098. }
  6099. return new _Api( this.context, a );
  6100. },
  6101. pluck: function ( prop )
  6102. {
  6103. return this.map( function ( el ) {
  6104. return el[ prop ];
  6105. } );
  6106. },
  6107. pop: __arrayProto.pop,
  6108. push: __arrayProto.push,
  6109. // Does not return an API instance
  6110. reduce: __arrayProto.reduce || function ( fn, init )
  6111. {
  6112. return _fnReduce( this, fn, init, 0, this.length, 1 );
  6113. },
  6114. reduceRight: __arrayProto.reduceRight || function ( fn, init )
  6115. {
  6116. return _fnReduce( this, fn, init, this.length-1, -1, -1 );
  6117. },
  6118. reverse: __arrayProto.reverse,
  6119. // Object with rows, columns and opts
  6120. selector: null,
  6121. shift: __arrayProto.shift,
  6122. slice: function () {
  6123. return new _Api( this.context, this );
  6124. },
  6125. sort: __arrayProto.sort, // ? name - order?
  6126. splice: __arrayProto.splice,
  6127. toArray: function ()
  6128. {
  6129. return __arrayProto.slice.call( this );
  6130. },
  6131. to$: function ()
  6132. {
  6133. return $( this );
  6134. },
  6135. toJQuery: function ()
  6136. {
  6137. return $( this );
  6138. },
  6139. unique: function ()
  6140. {
  6141. return new _Api( this.context, _unique(this) );
  6142. },
  6143. unshift: __arrayProto.unshift
  6144. } );
  6145. _Api.extend = function ( scope, obj, ext )
  6146. {
  6147. // Only extend API instances and static properties of the API
  6148. if ( ! ext.length || ! obj || ( ! (obj instanceof _Api) && ! obj.__dt_wrapper ) ) {
  6149. return;
  6150. }
  6151. var
  6152. i, ien,
  6153. j, jen,
  6154. struct, inner,
  6155. methodScoping = function ( scope, fn, struc ) {
  6156. return function () {
  6157. var ret = fn.apply( scope, arguments );
  6158. // Method extension
  6159. _Api.extend( ret, ret, struc.methodExt );
  6160. return ret;
  6161. };
  6162. };
  6163. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  6164. struct = ext[i];
  6165. // Value
  6166. obj[ struct.name ] = typeof struct.val === 'function' ?
  6167. methodScoping( scope, struct.val, struct ) :
  6168. $.isPlainObject( struct.val ) ?
  6169. {} :
  6170. struct.val;
  6171. obj[ struct.name ].__dt_wrapper = true;
  6172. // Property extension
  6173. _Api.extend( scope, obj[ struct.name ], struct.propExt );
  6174. }
  6175. };
  6176. // @todo - Is there need for an augment function?
  6177. // _Api.augment = function ( inst, name )
  6178. // {
  6179. // // Find src object in the structure from the name
  6180. // var parts = name.split('.');
  6181. // _Api.extend( inst, obj );
  6182. // };
  6183. // [
  6184. // {
  6185. // name: 'data' -- string - Property name
  6186. // val: function () {}, -- function - Api method (or undefined if just an object
  6187. // methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  6188. // propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  6189. // },
  6190. // {
  6191. // name: 'row'
  6192. // val: {},
  6193. // methodExt: [ ... ],
  6194. // propExt: [
  6195. // {
  6196. // name: 'data'
  6197. // val: function () {},
  6198. // methodExt: [ ... ],
  6199. // propExt: [ ... ]
  6200. // },
  6201. // ...
  6202. // ]
  6203. // }
  6204. // ]
  6205. _Api.register = _api_register = function ( name, val )
  6206. {
  6207. if ( $.isArray( name ) ) {
  6208. for ( var j=0, jen=name.length ; j<jen ; j++ ) {
  6209. _Api.register( name[j], val );
  6210. }
  6211. return;
  6212. }
  6213. var
  6214. i, ien,
  6215. heir = name.split('.'),
  6216. struct = __apiStruct,
  6217. key, method;
  6218. var find = function ( src, name ) {
  6219. for ( var i=0, ien=src.length ; i<ien ; i++ ) {
  6220. if ( src[i].name === name ) {
  6221. return src[i];
  6222. }
  6223. }
  6224. return null;
  6225. };
  6226. for ( i=0, ien=heir.length ; i<ien ; i++ ) {
  6227. method = heir[i].indexOf('()') !== -1;
  6228. key = method ?
  6229. heir[i].replace('()', '') :
  6230. heir[i];
  6231. var src = find( struct, key );
  6232. if ( ! src ) {
  6233. src = {
  6234. name: key,
  6235. val: {},
  6236. methodExt: [],
  6237. propExt: []
  6238. };
  6239. struct.push( src );
  6240. }
  6241. if ( i === ien-1 ) {
  6242. src.val = val;
  6243. }
  6244. else {
  6245. struct = method ?
  6246. src.methodExt :
  6247. src.propExt;
  6248. }
  6249. }
  6250. };
  6251. _Api.registerPlural = _api_registerPlural = function ( pluralName, singularName, val ) {
  6252. _Api.register( pluralName, val );
  6253. _Api.register( singularName, function () {
  6254. var ret = val.apply( this, arguments );
  6255. if ( ret === this ) {
  6256. // Returned item is the API instance that was passed in, return it
  6257. return this;
  6258. }
  6259. else if ( ret instanceof _Api ) {
  6260. // New API instance returned, want the value from the first item
  6261. // in the returned array for the singular result.
  6262. return ret.length ?
  6263. $.isArray( ret[0] ) ?
  6264. new _Api( ret.context, ret[0] ) : // Array results are 'enhanced'
  6265. ret[0] :
  6266. undefined;
  6267. }
  6268. // Non-API return - just fire it back
  6269. return ret;
  6270. } );
  6271. };
  6272. /**
  6273. * Selector for HTML tables. Apply the given selector to the give array of
  6274. * DataTables settings objects.
  6275. *
  6276. * @param {string|integer} [selector] jQuery selector string or integer
  6277. * @param {array} Array of DataTables settings objects to be filtered
  6278. * @return {array}
  6279. * @ignore
  6280. */
  6281. var __table_selector = function ( selector, a )
  6282. {
  6283. // Integer is used to pick out a table by index
  6284. if ( typeof selector === 'number' ) {
  6285. return [ a[ selector ] ];
  6286. }
  6287. // Perform a jQuery selector on the table nodes
  6288. var nodes = $.map( a, function (el, i) {
  6289. return el.nTable;
  6290. } );
  6291. return $(nodes)
  6292. .filter( selector )
  6293. .map( function (i) {
  6294. // Need to translate back from the table node to the settings
  6295. var idx = $.inArray( this, nodes );
  6296. return a[ idx ];
  6297. } )
  6298. .toArray();
  6299. };
  6300. /**
  6301. * Context selector for the API's context (i.e. the tables the API instance
  6302. * refers to.
  6303. *
  6304. * @name DataTable.Api#tables
  6305. * @param {string|integer} [selector] Selector to pick which tables the iterator
  6306. * should operate on. If not given, all tables in the current context are
  6307. * used. This can be given as a jQuery selector (for example `':gt(0)'`) to
  6308. * select multiple tables or as an integer to select a single table.
  6309. * @returns {DataTable.Api} Returns a new API instance if a selector is given.
  6310. */
  6311. _api_register( 'tables()', function ( selector ) {
  6312. // A new instance is created if there was a selector specified
  6313. return selector ?
  6314. new _Api( __table_selector( selector, this.context ) ) :
  6315. this;
  6316. } );
  6317. _api_register( 'table()', function ( selector ) {
  6318. var tables = this.tables( selector );
  6319. var ctx = tables.context;
  6320. // Truncate to the first matched table
  6321. return ctx.length ?
  6322. new _Api( ctx[0] ) :
  6323. tables;
  6324. } );
  6325. _api_registerPlural( 'tables().nodes()', 'table().node()' , function () {
  6326. return this.iterator( 'table', function ( ctx ) {
  6327. return ctx.nTable;
  6328. }, 1 );
  6329. } );
  6330. _api_registerPlural( 'tables().body()', 'table().body()' , function () {
  6331. return this.iterator( 'table', function ( ctx ) {
  6332. return ctx.nTBody;
  6333. }, 1 );
  6334. } );
  6335. _api_registerPlural( 'tables().header()', 'table().header()' , function () {
  6336. return this.iterator( 'table', function ( ctx ) {
  6337. return ctx.nTHead;
  6338. }, 1 );
  6339. } );
  6340. _api_registerPlural( 'tables().footer()', 'table().footer()' , function () {
  6341. return this.iterator( 'table', function ( ctx ) {
  6342. return ctx.nTFoot;
  6343. }, 1 );
  6344. } );
  6345. _api_registerPlural( 'tables().containers()', 'table().container()' , function () {
  6346. return this.iterator( 'table', function ( ctx ) {
  6347. return ctx.nTableWrapper;
  6348. }, 1 );
  6349. } );
  6350. /**
  6351. * Redraw the tables in the current context.
  6352. */
  6353. _api_register( 'draw()', function ( paging ) {
  6354. return this.iterator( 'table', function ( settings ) {
  6355. if ( paging === 'page' ) {
  6356. _fnDraw( settings );
  6357. }
  6358. else {
  6359. if ( typeof paging === 'string' ) {
  6360. paging = paging === 'full-hold' ?
  6361. false :
  6362. true;
  6363. }
  6364. _fnReDraw( settings, paging===false );
  6365. }
  6366. } );
  6367. } );
  6368. /**
  6369. * Get the current page index.
  6370. *
  6371. * @return {integer} Current page index (zero based)
  6372. *//**
  6373. * Set the current page.
  6374. *
  6375. * Note that if you attempt to show a page which does not exist, DataTables will
  6376. * not throw an error, but rather reset the paging.
  6377. *
  6378. * @param {integer|string} action The paging action to take. This can be one of:
  6379. * * `integer` - The page index to jump to
  6380. * * `string` - An action to take:
  6381. * * `first` - Jump to first page.
  6382. * * `next` - Jump to the next page
  6383. * * `previous` - Jump to previous page
  6384. * * `last` - Jump to the last page.
  6385. * @returns {DataTables.Api} this
  6386. */
  6387. _api_register( 'page()', function ( action ) {
  6388. if ( action === undefined ) {
  6389. return this.page.info().page; // not an expensive call
  6390. }
  6391. // else, have an action to take on all tables
  6392. return this.iterator( 'table', function ( settings ) {
  6393. _fnPageChange( settings, action );
  6394. } );
  6395. } );
  6396. /**
  6397. * Paging information for the first table in the current context.
  6398. *
  6399. * If you require paging information for another table, use the `table()` method
  6400. * with a suitable selector.
  6401. *
  6402. * @return {object} Object with the following properties set:
  6403. * * `page` - Current page index (zero based - i.e. the first page is `0`)
  6404. * * `pages` - Total number of pages
  6405. * * `start` - Display index for the first record shown on the current page
  6406. * * `end` - Display index for the last record shown on the current page
  6407. * * `length` - Display length (number of records). Note that generally `start
  6408. * + length = end`, but this is not always true, for example if there are
  6409. * only 2 records to show on the final page, with a length of 10.
  6410. * * `recordsTotal` - Full data set length
  6411. * * `recordsDisplay` - Data set length once the current filtering criterion
  6412. * are applied.
  6413. */
  6414. _api_register( 'page.info()', function ( action ) {
  6415. if ( this.context.length === 0 ) {
  6416. return undefined;
  6417. }
  6418. var
  6419. settings = this.context[0],
  6420. start = settings._iDisplayStart,
  6421. len = settings.oFeatures.bPaginate ? settings._iDisplayLength : -1,
  6422. visRecords = settings.fnRecordsDisplay(),
  6423. all = len === -1;
  6424. return {
  6425. "page": all ? 0 : Math.floor( start / len ),
  6426. "pages": all ? 1 : Math.ceil( visRecords / len ),
  6427. "start": start,
  6428. "end": settings.fnDisplayEnd(),
  6429. "length": len,
  6430. "recordsTotal": settings.fnRecordsTotal(),
  6431. "recordsDisplay": visRecords,
  6432. "serverSide": _fnDataSource( settings ) === 'ssp'
  6433. };
  6434. } );
  6435. /**
  6436. * Get the current page length.
  6437. *
  6438. * @return {integer} Current page length. Note `-1` indicates that all records
  6439. * are to be shown.
  6440. *//**
  6441. * Set the current page length.
  6442. *
  6443. * @param {integer} Page length to set. Use `-1` to show all records.
  6444. * @returns {DataTables.Api} this
  6445. */
  6446. _api_register( 'page.len()', function ( len ) {
  6447. // Note that we can't call this function 'length()' because `length`
  6448. // is a Javascript property of functions which defines how many arguments
  6449. // the function expects.
  6450. if ( len === undefined ) {
  6451. return this.context.length !== 0 ?
  6452. this.context[0]._iDisplayLength :
  6453. undefined;
  6454. }
  6455. // else, set the page length
  6456. return this.iterator( 'table', function ( settings ) {
  6457. _fnLengthChange( settings, len );
  6458. } );
  6459. } );
  6460. var __reload = function ( settings, holdPosition, callback ) {
  6461. // Use the draw event to trigger a callback
  6462. if ( callback ) {
  6463. var api = new _Api( settings );
  6464. api.one( 'draw', function () {
  6465. callback( api.ajax.json() );
  6466. } );
  6467. }
  6468. if ( _fnDataSource( settings ) == 'ssp' ) {
  6469. _fnReDraw( settings, holdPosition );
  6470. }
  6471. else {
  6472. _fnProcessingDisplay( settings, true );
  6473. // Cancel an existing request
  6474. var xhr = settings.jqXHR;
  6475. if ( xhr && xhr.readyState !== 4 ) {
  6476. xhr.abort();
  6477. }
  6478. // Trigger xhr
  6479. _fnBuildAjax( settings, [], function( json ) {
  6480. _fnClearTable( settings );
  6481. var data = _fnAjaxDataSrc( settings, json );
  6482. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6483. _fnAddData( settings, data[i] );
  6484. }
  6485. _fnReDraw( settings, holdPosition );
  6486. _fnProcessingDisplay( settings, false );
  6487. } );
  6488. }
  6489. };
  6490. /**
  6491. * Get the JSON response from the last Ajax request that DataTables made to the
  6492. * server. Note that this returns the JSON from the first table in the current
  6493. * context.
  6494. *
  6495. * @return {object} JSON received from the server.
  6496. */
  6497. _api_register( 'ajax.json()', function () {
  6498. var ctx = this.context;
  6499. if ( ctx.length > 0 ) {
  6500. return ctx[0].json;
  6501. }
  6502. // else return undefined;
  6503. } );
  6504. /**
  6505. * Get the data submitted in the last Ajax request
  6506. */
  6507. _api_register( 'ajax.params()', function () {
  6508. var ctx = this.context;
  6509. if ( ctx.length > 0 ) {
  6510. return ctx[0].oAjaxData;
  6511. }
  6512. // else return undefined;
  6513. } );
  6514. /**
  6515. * Reload tables from the Ajax data source. Note that this function will
  6516. * automatically re-draw the table when the remote data has been loaded.
  6517. *
  6518. * @param {boolean} [reset=true] Reset (default) or hold the current paging
  6519. * position. A full re-sort and re-filter is performed when this method is
  6520. * called, which is why the pagination reset is the default action.
  6521. * @returns {DataTables.Api} this
  6522. */
  6523. _api_register( 'ajax.reload()', function ( callback, resetPaging ) {
  6524. return this.iterator( 'table', function (settings) {
  6525. __reload( settings, resetPaging===false, callback );
  6526. } );
  6527. } );
  6528. /**
  6529. * Get the current Ajax URL. Note that this returns the URL from the first
  6530. * table in the current context.
  6531. *
  6532. * @return {string} Current Ajax source URL
  6533. *//**
  6534. * Set the Ajax URL. Note that this will set the URL for all tables in the
  6535. * current context.
  6536. *
  6537. * @param {string} url URL to set.
  6538. * @returns {DataTables.Api} this
  6539. */
  6540. _api_register( 'ajax.url()', function ( url ) {
  6541. var ctx = this.context;
  6542. if ( url === undefined ) {
  6543. // get
  6544. if ( ctx.length === 0 ) {
  6545. return undefined;
  6546. }
  6547. ctx = ctx[0];
  6548. return ctx.ajax ?
  6549. $.isPlainObject( ctx.ajax ) ?
  6550. ctx.ajax.url :
  6551. ctx.ajax :
  6552. ctx.sAjaxSource;
  6553. }
  6554. // set
  6555. return this.iterator( 'table', function ( settings ) {
  6556. if ( $.isPlainObject( settings.ajax ) ) {
  6557. settings.ajax.url = url;
  6558. }
  6559. else {
  6560. settings.ajax = url;
  6561. }
  6562. // No need to consider sAjaxSource here since DataTables gives priority
  6563. // to `ajax` over `sAjaxSource`. So setting `ajax` here, renders any
  6564. // value of `sAjaxSource` redundant.
  6565. } );
  6566. } );
  6567. /**
  6568. * Load data from the newly set Ajax URL. Note that this method is only
  6569. * available when `ajax.url()` is used to set a URL. Additionally, this method
  6570. * has the same effect as calling `ajax.reload()` but is provided for
  6571. * convenience when setting a new URL. Like `ajax.reload()` it will
  6572. * automatically redraw the table once the remote data has been loaded.
  6573. *
  6574. * @returns {DataTables.Api} this
  6575. */
  6576. _api_register( 'ajax.url().load()', function ( callback, resetPaging ) {
  6577. // Same as a reload, but makes sense to present it for easy access after a
  6578. // url change
  6579. return this.iterator( 'table', function ( ctx ) {
  6580. __reload( ctx, resetPaging===false, callback );
  6581. } );
  6582. } );
  6583. var _selector_run = function ( type, selector, selectFn, settings, opts )
  6584. {
  6585. var
  6586. out = [], res,
  6587. a, i, ien, j, jen,
  6588. selectorType = typeof selector;
  6589. // Can't just check for isArray here, as an API or jQuery instance might be
  6590. // given with their array like look
  6591. if ( ! selector || selectorType === 'string' || selectorType === 'function' || selector.length === undefined ) {
  6592. selector = [ selector ];
  6593. }
  6594. for ( i=0, ien=selector.length ; i<ien ; i++ ) {
  6595. // Only split on simple strings - complex expressions will be jQuery selectors
  6596. a = selector[i] && selector[i].split && ! selector[i].match(/[\[\(:]/) ?
  6597. selector[i].split(',') :
  6598. [ selector[i] ];
  6599. for ( j=0, jen=a.length ; j<jen ; j++ ) {
  6600. res = selectFn( typeof a[j] === 'string' ? $.trim(a[j]) : a[j] );
  6601. if ( res && res.length ) {
  6602. out = out.concat( res );
  6603. }
  6604. }
  6605. }
  6606. // selector extensions
  6607. var ext = _ext.selector[ type ];
  6608. if ( ext.length ) {
  6609. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  6610. out = ext[i]( settings, opts, out );
  6611. }
  6612. }
  6613. return _unique( out );
  6614. };
  6615. var _selector_opts = function ( opts )
  6616. {
  6617. if ( ! opts ) {
  6618. opts = {};
  6619. }
  6620. // Backwards compatibility for 1.9- which used the terminology filter rather
  6621. // than search
  6622. if ( opts.filter && opts.search === undefined ) {
  6623. opts.search = opts.filter;
  6624. }
  6625. return $.extend( {
  6626. search: 'none',
  6627. order: 'current',
  6628. page: 'all'
  6629. }, opts );
  6630. };
  6631. var _selector_first = function ( inst )
  6632. {
  6633. // Reduce the API instance to the first item found
  6634. for ( var i=0, ien=inst.length ; i<ien ; i++ ) {
  6635. if ( inst[i].length > 0 ) {
  6636. // Assign the first element to the first item in the instance
  6637. // and truncate the instance and context
  6638. inst[0] = inst[i];
  6639. inst[0].length = 1;
  6640. inst.length = 1;
  6641. inst.context = [ inst.context[i] ];
  6642. return inst;
  6643. }
  6644. }
  6645. // Not found - return an empty instance
  6646. inst.length = 0;
  6647. return inst;
  6648. };
  6649. var _selector_row_indexes = function ( settings, opts )
  6650. {
  6651. var
  6652. i, ien, tmp, a=[],
  6653. displayFiltered = settings.aiDisplay,
  6654. displayMaster = settings.aiDisplayMaster;
  6655. var
  6656. search = opts.search, // none, applied, removed
  6657. order = opts.order, // applied, current, index (original - compatibility with 1.9)
  6658. page = opts.page; // all, current
  6659. if ( _fnDataSource( settings ) == 'ssp' ) {
  6660. // In server-side processing mode, most options are irrelevant since
  6661. // rows not shown don't exist and the index order is the applied order
  6662. // Removed is a special case - for consistency just return an empty
  6663. // array
  6664. return search === 'removed' ?
  6665. [] :
  6666. _range( 0, displayMaster.length );
  6667. }
  6668. else if ( page == 'current' ) {
  6669. // Current page implies that order=current and fitler=applied, since it is
  6670. // fairly senseless otherwise, regardless of what order and search actually
  6671. // are
  6672. for ( i=settings._iDisplayStart, ien=settings.fnDisplayEnd() ; i<ien ; i++ ) {
  6673. a.push( displayFiltered[i] );
  6674. }
  6675. }
  6676. else if ( order == 'current' || order == 'applied' ) {
  6677. a = search == 'none' ?
  6678. displayMaster.slice() : // no search
  6679. search == 'applied' ?
  6680. displayFiltered.slice() : // applied search
  6681. $.map( displayMaster, function (el, i) { // removed search
  6682. return $.inArray( el, displayFiltered ) === -1 ? el : null;
  6683. } );
  6684. }
  6685. else if ( order == 'index' || order == 'original' ) {
  6686. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  6687. if ( search == 'none' ) {
  6688. a.push( i );
  6689. }
  6690. else { // applied | removed
  6691. tmp = $.inArray( i, displayFiltered );
  6692. if ((tmp === -1 && search == 'removed') ||
  6693. (tmp >= 0 && search == 'applied') )
  6694. {
  6695. a.push( i );
  6696. }
  6697. }
  6698. }
  6699. }
  6700. return a;
  6701. };
  6702. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6703. * Rows
  6704. *
  6705. * {} - no selector - use all available rows
  6706. * {integer} - row aoData index
  6707. * {node} - TR node
  6708. * {string} - jQuery selector to apply to the TR elements
  6709. * {array} - jQuery array of nodes, or simply an array of TR nodes
  6710. *
  6711. */
  6712. var __row_selector = function ( settings, selector, opts )
  6713. {
  6714. var rows;
  6715. var run = function ( sel ) {
  6716. var selInt = _intVal( sel );
  6717. var i, ien;
  6718. // Short cut - selector is a number and no options provided (default is
  6719. // all records, so no need to check if the index is in there, since it
  6720. // must be - dev error if the index doesn't exist).
  6721. if ( selInt !== null && ! opts ) {
  6722. return [ selInt ];
  6723. }
  6724. if ( ! rows ) {
  6725. rows = _selector_row_indexes( settings, opts );
  6726. }
  6727. if ( selInt !== null && $.inArray( selInt, rows ) !== -1 ) {
  6728. // Selector - integer
  6729. return [ selInt ];
  6730. }
  6731. else if ( sel === null || sel === undefined || sel === '' ) {
  6732. // Selector - none
  6733. return rows;
  6734. }
  6735. // Selector - function
  6736. if ( typeof sel === 'function' ) {
  6737. return $.map( rows, function (idx) {
  6738. var row = settings.aoData[ idx ];
  6739. return sel( idx, row._aData, row.nTr ) ? idx : null;
  6740. } );
  6741. }
  6742. // Get nodes in the order from the `rows` array with null values removed
  6743. var nodes = _removeEmpty(
  6744. _pluck_order( settings.aoData, rows, 'nTr' )
  6745. );
  6746. // Selector - node
  6747. if ( sel.nodeName ) {
  6748. if ( sel._DT_RowIndex !== undefined ) {
  6749. return [ sel._DT_RowIndex ]; // Property added by DT for fast lookup
  6750. }
  6751. else if ( sel._DT_CellIndex ) {
  6752. return [ sel._DT_CellIndex.row ];
  6753. }
  6754. else {
  6755. var host = $(sel).closest('*[data-dt-row]');
  6756. return host.length ?
  6757. [ host.data('dt-row') ] :
  6758. [];
  6759. }
  6760. }
  6761. // ID selector. Want to always be able to select rows by id, regardless
  6762. // of if the tr element has been created or not, so can't rely upon
  6763. // jQuery here - hence a custom implementation. This does not match
  6764. // Sizzle's fast selector or HTML4 - in HTML5 the ID can be anything,
  6765. // but to select it using a CSS selector engine (like Sizzle or
  6766. // querySelect) it would need to need to be escaped for some characters.
  6767. // DataTables simplifies this for row selectors since you can select
  6768. // only a row. A # indicates an id any anything that follows is the id -
  6769. // unescaped.
  6770. if ( typeof sel === 'string' && sel.charAt(0) === '#' ) {
  6771. // get row index from id
  6772. var rowObj = settings.aIds[ sel.replace( /^#/, '' ) ];
  6773. if ( rowObj !== undefined ) {
  6774. return [ rowObj.idx ];
  6775. }
  6776. // need to fall through to jQuery in case there is DOM id that
  6777. // matches
  6778. }
  6779. // Selector - jQuery selector string, array of nodes or jQuery object/
  6780. // As jQuery's .filter() allows jQuery objects to be passed in filter,
  6781. // it also allows arrays, so this will cope with all three options
  6782. return $(nodes)
  6783. .filter( sel )
  6784. .map( function () {
  6785. return this._DT_RowIndex;
  6786. } )
  6787. .toArray();
  6788. };
  6789. return _selector_run( 'row', selector, run, settings, opts );
  6790. };
  6791. _api_register( 'rows()', function ( selector, opts ) {
  6792. // argument shifting
  6793. if ( selector === undefined ) {
  6794. selector = '';
  6795. }
  6796. else if ( $.isPlainObject( selector ) ) {
  6797. opts = selector;
  6798. selector = '';
  6799. }
  6800. opts = _selector_opts( opts );
  6801. var inst = this.iterator( 'table', function ( settings ) {
  6802. return __row_selector( settings, selector, opts );
  6803. }, 1 );
  6804. // Want argument shifting here and in __row_selector?
  6805. inst.selector.rows = selector;
  6806. inst.selector.opts = opts;
  6807. return inst;
  6808. } );
  6809. _api_register( 'rows().nodes()', function () {
  6810. return this.iterator( 'row', function ( settings, row ) {
  6811. return settings.aoData[ row ].nTr || undefined;
  6812. }, 1 );
  6813. } );
  6814. _api_register( 'rows().data()', function () {
  6815. return this.iterator( true, 'rows', function ( settings, rows ) {
  6816. return _pluck_order( settings.aoData, rows, '_aData' );
  6817. }, 1 );
  6818. } );
  6819. _api_registerPlural( 'rows().cache()', 'row().cache()', function ( type ) {
  6820. return this.iterator( 'row', function ( settings, row ) {
  6821. var r = settings.aoData[ row ];
  6822. return type === 'search' ? r._aFilterData : r._aSortData;
  6823. }, 1 );
  6824. } );
  6825. _api_registerPlural( 'rows().invalidate()', 'row().invalidate()', function ( src ) {
  6826. return this.iterator( 'row', function ( settings, row ) {
  6827. _fnInvalidate( settings, row, src );
  6828. } );
  6829. } );
  6830. _api_registerPlural( 'rows().indexes()', 'row().index()', function () {
  6831. return this.iterator( 'row', function ( settings, row ) {
  6832. return row;
  6833. }, 1 );
  6834. } );
  6835. _api_registerPlural( 'rows().ids()', 'row().id()', function ( hash ) {
  6836. var a = [];
  6837. var context = this.context;
  6838. // `iterator` will drop undefined values, but in this case we want them
  6839. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  6840. for ( var j=0, jen=this[i].length ; j<jen ; j++ ) {
  6841. var id = context[i].rowIdFn( context[i].aoData[ this[i][j] ]._aData );
  6842. a.push( (hash === true ? '#' : '' )+ id );
  6843. }
  6844. }
  6845. return new _Api( context, a );
  6846. } );
  6847. _api_registerPlural( 'rows().remove()', 'row().remove()', function () {
  6848. var that = this;
  6849. this.iterator( 'row', function ( settings, row, thatIdx ) {
  6850. var data = settings.aoData;
  6851. var rowData = data[ row ];
  6852. var i, ien, j, jen;
  6853. var loopRow, loopCells;
  6854. data.splice( row, 1 );
  6855. // Update the cached indexes
  6856. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  6857. loopRow = data[i];
  6858. loopCells = loopRow.anCells;
  6859. // Rows
  6860. if ( loopRow.nTr !== null ) {
  6861. loopRow.nTr._DT_RowIndex = i;
  6862. }
  6863. // Cells
  6864. if ( loopCells !== null ) {
  6865. for ( j=0, jen=loopCells.length ; j<jen ; j++ ) {
  6866. loopCells[j]._DT_CellIndex.row = i;
  6867. }
  6868. }
  6869. }
  6870. // Delete from the display arrays
  6871. _fnDeleteIndex( settings.aiDisplayMaster, row );
  6872. _fnDeleteIndex( settings.aiDisplay, row );
  6873. _fnDeleteIndex( that[ thatIdx ], row, false ); // maintain local indexes
  6874. // Check for an 'overflow' they case for displaying the table
  6875. _fnLengthOverflow( settings );
  6876. // Remove the row's ID reference if there is one
  6877. var id = settings.rowIdFn( rowData._aData );
  6878. if ( id !== undefined ) {
  6879. delete settings.aIds[ id ];
  6880. }
  6881. } );
  6882. this.iterator( 'table', function ( settings ) {
  6883. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  6884. settings.aoData[i].idx = i;
  6885. }
  6886. } );
  6887. return this;
  6888. } );
  6889. _api_register( 'rows.add()', function ( rows ) {
  6890. var newRows = this.iterator( 'table', function ( settings ) {
  6891. var row, i, ien;
  6892. var out = [];
  6893. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  6894. row = rows[i];
  6895. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  6896. out.push( _fnAddTr( settings, row )[0] );
  6897. }
  6898. else {
  6899. out.push( _fnAddData( settings, row ) );
  6900. }
  6901. }
  6902. return out;
  6903. }, 1 );
  6904. // Return an Api.rows() extended instance, so rows().nodes() etc can be used
  6905. var modRows = this.rows( -1 );
  6906. modRows.pop();
  6907. $.merge( modRows, newRows );
  6908. return modRows;
  6909. } );
  6910. /**
  6911. *
  6912. */
  6913. _api_register( 'row()', function ( selector, opts ) {
  6914. return _selector_first( this.rows( selector, opts ) );
  6915. } );
  6916. _api_register( 'row().data()', function ( data ) {
  6917. var ctx = this.context;
  6918. if ( data === undefined ) {
  6919. // Get
  6920. return ctx.length && this.length ?
  6921. ctx[0].aoData[ this[0] ]._aData :
  6922. undefined;
  6923. }
  6924. // Set
  6925. ctx[0].aoData[ this[0] ]._aData = data;
  6926. // Automatically invalidate
  6927. _fnInvalidate( ctx[0], this[0], 'data' );
  6928. return this;
  6929. } );
  6930. _api_register( 'row().node()', function () {
  6931. var ctx = this.context;
  6932. return ctx.length && this.length ?
  6933. ctx[0].aoData[ this[0] ].nTr || null :
  6934. null;
  6935. } );
  6936. _api_register( 'row.add()', function ( row ) {
  6937. // Allow a jQuery object to be passed in - only a single row is added from
  6938. // it though - the first element in the set
  6939. if ( row instanceof $ && row.length ) {
  6940. row = row[0];
  6941. }
  6942. var rows = this.iterator( 'table', function ( settings ) {
  6943. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  6944. return _fnAddTr( settings, row )[0];
  6945. }
  6946. return _fnAddData( settings, row );
  6947. } );
  6948. // Return an Api.rows() extended instance, with the newly added row selected
  6949. return this.row( rows[0] );
  6950. } );
  6951. var __details_add = function ( ctx, row, data, klass )
  6952. {
  6953. // Convert to array of TR elements
  6954. var rows = [];
  6955. var addRow = function ( r, k ) {
  6956. // Recursion to allow for arrays of jQuery objects
  6957. if ( $.isArray( r ) || r instanceof $ ) {
  6958. for ( var i=0, ien=r.length ; i<ien ; i++ ) {
  6959. addRow( r[i], k );
  6960. }
  6961. return;
  6962. }
  6963. // If we get a TR element, then just add it directly - up to the dev
  6964. // to add the correct number of columns etc
  6965. if ( r.nodeName && r.nodeName.toLowerCase() === 'tr' ) {
  6966. rows.push( r );
  6967. }
  6968. else {
  6969. // Otherwise create a row with a wrapper
  6970. var created = $('<tr><td/></tr>').addClass( k );
  6971. $('td', created)
  6972. .addClass( k )
  6973. .html( r )
  6974. [0].colSpan = _fnVisbleColumns( ctx );
  6975. rows.push( created[0] );
  6976. }
  6977. };
  6978. addRow( data, klass );
  6979. if ( row._details ) {
  6980. row._details.detach();
  6981. }
  6982. row._details = $(rows);
  6983. // If the children were already shown, that state should be retained
  6984. if ( row._detailsShow ) {
  6985. row._details.insertAfter( row.nTr );
  6986. }
  6987. };
  6988. var __details_remove = function ( api, idx )
  6989. {
  6990. var ctx = api.context;
  6991. if ( ctx.length ) {
  6992. var row = ctx[0].aoData[ idx !== undefined ? idx : api[0] ];
  6993. if ( row && row._details ) {
  6994. row._details.remove();
  6995. row._detailsShow = undefined;
  6996. row._details = undefined;
  6997. }
  6998. }
  6999. };
  7000. var __details_display = function ( api, show ) {
  7001. var ctx = api.context;
  7002. if ( ctx.length && api.length ) {
  7003. var row = ctx[0].aoData[ api[0] ];
  7004. if ( row._details ) {
  7005. row._detailsShow = show;
  7006. if ( show ) {
  7007. row._details.insertAfter( row.nTr );
  7008. }
  7009. else {
  7010. row._details.detach();
  7011. }
  7012. __details_events( ctx[0] );
  7013. }
  7014. }
  7015. };
  7016. var __details_events = function ( settings )
  7017. {
  7018. var api = new _Api( settings );
  7019. var namespace = '.dt.DT_details';
  7020. var drawEvent = 'draw'+namespace;
  7021. var colvisEvent = 'column-visibility'+namespace;
  7022. var destroyEvent = 'destroy'+namespace;
  7023. var data = settings.aoData;
  7024. api.off( drawEvent +' '+ colvisEvent +' '+ destroyEvent );
  7025. if ( _pluck( data, '_details' ).length > 0 ) {
  7026. // On each draw, insert the required elements into the document
  7027. api.on( drawEvent, function ( e, ctx ) {
  7028. if ( settings !== ctx ) {
  7029. return;
  7030. }
  7031. api.rows( {page:'current'} ).eq(0).each( function (idx) {
  7032. // Internal data grab
  7033. var row = data[ idx ];
  7034. if ( row._detailsShow ) {
  7035. row._details.insertAfter( row.nTr );
  7036. }
  7037. } );
  7038. } );
  7039. // Column visibility change - update the colspan
  7040. api.on( colvisEvent, function ( e, ctx, idx, vis ) {
  7041. if ( settings !== ctx ) {
  7042. return;
  7043. }
  7044. // Update the colspan for the details rows (note, only if it already has
  7045. // a colspan)
  7046. var row, visible = _fnVisbleColumns( ctx );
  7047. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  7048. row = data[i];
  7049. if ( row._details ) {
  7050. row._details.children('td[colspan]').attr('colspan', visible );
  7051. }
  7052. }
  7053. } );
  7054. // Table destroyed - nuke any child rows
  7055. api.on( destroyEvent, function ( e, ctx ) {
  7056. if ( settings !== ctx ) {
  7057. return;
  7058. }
  7059. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  7060. if ( data[i]._details ) {
  7061. __details_remove( api, i );
  7062. }
  7063. }
  7064. } );
  7065. }
  7066. };
  7067. // Strings for the method names to help minification
  7068. var _emp = '';
  7069. var _child_obj = _emp+'row().child';
  7070. var _child_mth = _child_obj+'()';
  7071. // data can be:
  7072. // tr
  7073. // string
  7074. // jQuery or array of any of the above
  7075. _api_register( _child_mth, function ( data, klass ) {
  7076. var ctx = this.context;
  7077. if ( data === undefined ) {
  7078. // get
  7079. return ctx.length && this.length ?
  7080. ctx[0].aoData[ this[0] ]._details :
  7081. undefined;
  7082. }
  7083. else if ( data === true ) {
  7084. // show
  7085. this.child.show();
  7086. }
  7087. else if ( data === false ) {
  7088. // remove
  7089. __details_remove( this );
  7090. }
  7091. else if ( ctx.length && this.length ) {
  7092. // set
  7093. __details_add( ctx[0], ctx[0].aoData[ this[0] ], data, klass );
  7094. }
  7095. return this;
  7096. } );
  7097. _api_register( [
  7098. _child_obj+'.show()',
  7099. _child_mth+'.show()' // only when `child()` was called with parameters (without
  7100. ], function ( show ) { // it returns an object and this method is not executed)
  7101. __details_display( this, true );
  7102. return this;
  7103. } );
  7104. _api_register( [
  7105. _child_obj+'.hide()',
  7106. _child_mth+'.hide()' // only when `child()` was called with parameters (without
  7107. ], function () { // it returns an object and this method is not executed)
  7108. __details_display( this, false );
  7109. return this;
  7110. } );
  7111. _api_register( [
  7112. _child_obj+'.remove()',
  7113. _child_mth+'.remove()' // only when `child()` was called with parameters (without
  7114. ], function () { // it returns an object and this method is not executed)
  7115. __details_remove( this );
  7116. return this;
  7117. } );
  7118. _api_register( _child_obj+'.isShown()', function () {
  7119. var ctx = this.context;
  7120. if ( ctx.length && this.length ) {
  7121. // _detailsShown as false or undefined will fall through to return false
  7122. return ctx[0].aoData[ this[0] ]._detailsShow || false;
  7123. }
  7124. return false;
  7125. } );
  7126. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  7127. * Columns
  7128. *
  7129. * {integer} - column index (>=0 count from left, <0 count from right)
  7130. * "{integer}:visIdx" - visible column index (i.e. translate to column index) (>=0 count from left, <0 count from right)
  7131. * "{integer}:visible" - alias for {integer}:visIdx (>=0 count from left, <0 count from right)
  7132. * "{string}:name" - column name
  7133. * "{string}" - jQuery selector on column header nodes
  7134. *
  7135. */
  7136. // can be an array of these items, comma separated list, or an array of comma
  7137. // separated lists
  7138. var __re_column_selector = /^([^:]+):(name|visIdx|visible)$/;
  7139. // r1 and r2 are redundant - but it means that the parameters match for the
  7140. // iterator callback in columns().data()
  7141. var __columnData = function ( settings, column, r1, r2, rows ) {
  7142. var a = [];
  7143. for ( var row=0, ien=rows.length ; row<ien ; row++ ) {
  7144. a.push( _fnGetCellData( settings, rows[row], column ) );
  7145. }
  7146. return a;
  7147. };
  7148. var __column_selector = function ( settings, selector, opts )
  7149. {
  7150. var
  7151. columns = settings.aoColumns,
  7152. names = _pluck( columns, 'sName' ),
  7153. nodes = _pluck( columns, 'nTh' );
  7154. var run = function ( s ) {
  7155. var selInt = _intVal( s );
  7156. // Selector - all
  7157. if ( s === '' ) {
  7158. return _range( columns.length );
  7159. }
  7160. // Selector - index
  7161. if ( selInt !== null ) {
  7162. return [ selInt >= 0 ?
  7163. selInt : // Count from left
  7164. columns.length + selInt // Count from right (+ because its a negative value)
  7165. ];
  7166. }
  7167. // Selector = function
  7168. if ( typeof s === 'function' ) {
  7169. var rows = _selector_row_indexes( settings, opts );
  7170. return $.map( columns, function (col, idx) {
  7171. return s(
  7172. idx,
  7173. __columnData( settings, idx, 0, 0, rows ),
  7174. nodes[ idx ]
  7175. ) ? idx : null;
  7176. } );
  7177. }
  7178. // jQuery or string selector
  7179. var match = typeof s === 'string' ?
  7180. s.match( __re_column_selector ) :
  7181. '';
  7182. if ( match ) {
  7183. switch( match[2] ) {
  7184. case 'visIdx':
  7185. case 'visible':
  7186. var idx = parseInt( match[1], 10 );
  7187. // Visible index given, convert to column index
  7188. if ( idx < 0 ) {
  7189. // Counting from the right
  7190. var visColumns = $.map( columns, function (col,i) {
  7191. return col.bVisible ? i : null;
  7192. } );
  7193. return [ visColumns[ visColumns.length + idx ] ];
  7194. }
  7195. // Counting from the left
  7196. return [ _fnVisibleToColumnIndex( settings, idx ) ];
  7197. case 'name':
  7198. // match by name. `names` is column index complete and in order
  7199. return $.map( names, function (name, i) {
  7200. return name === match[1] ? i : null;
  7201. } );
  7202. default:
  7203. return [];
  7204. }
  7205. }
  7206. // Cell in the table body
  7207. if ( s.nodeName && s._DT_CellIndex ) {
  7208. return [ s._DT_CellIndex.column ];
  7209. }
  7210. // jQuery selector on the TH elements for the columns
  7211. var jqResult = $( nodes )
  7212. .filter( s )
  7213. .map( function () {
  7214. return $.inArray( this, nodes ); // `nodes` is column index complete and in order
  7215. } )
  7216. .toArray();
  7217. if ( jqResult.length || ! s.nodeName ) {
  7218. return jqResult;
  7219. }
  7220. // Otherwise a node which might have a `dt-column` data attribute, or be
  7221. // a child or such an element
  7222. var host = $(s).closest('*[data-dt-column]');
  7223. return host.length ?
  7224. [ host.data('dt-column') ] :
  7225. [];
  7226. };
  7227. return _selector_run( 'column', selector, run, settings, opts );
  7228. };
  7229. var __setColumnVis = function ( settings, column, vis ) {
  7230. var
  7231. cols = settings.aoColumns,
  7232. col = cols[ column ],
  7233. data = settings.aoData,
  7234. row, cells, i, ien, tr;
  7235. // Get
  7236. if ( vis === undefined ) {
  7237. return col.bVisible;
  7238. }
  7239. // Set
  7240. // No change
  7241. if ( col.bVisible === vis ) {
  7242. return;
  7243. }
  7244. if ( vis ) {
  7245. // Insert column
  7246. // Need to decide if we should use appendChild or insertBefore
  7247. var insertBefore = $.inArray( true, _pluck(cols, 'bVisible'), column+1 );
  7248. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  7249. tr = data[i].nTr;
  7250. cells = data[i].anCells;
  7251. if ( tr ) {
  7252. // insertBefore can act like appendChild if 2nd arg is null
  7253. tr.insertBefore( cells[ column ], cells[ insertBefore ] || null );
  7254. }
  7255. }
  7256. }
  7257. else {
  7258. // Remove column
  7259. $( _pluck( settings.aoData, 'anCells', column ) ).detach();
  7260. }
  7261. // Common actions
  7262. col.bVisible = vis;
  7263. _fnDrawHead( settings, settings.aoHeader );
  7264. _fnDrawHead( settings, settings.aoFooter );
  7265. _fnSaveState( settings );
  7266. };
  7267. _api_register( 'columns()', function ( selector, opts ) {
  7268. // argument shifting
  7269. if ( selector === undefined ) {
  7270. selector = '';
  7271. }
  7272. else if ( $.isPlainObject( selector ) ) {
  7273. opts = selector;
  7274. selector = '';
  7275. }
  7276. opts = _selector_opts( opts );
  7277. var inst = this.iterator( 'table', function ( settings ) {
  7278. return __column_selector( settings, selector, opts );
  7279. }, 1 );
  7280. // Want argument shifting here and in _row_selector?
  7281. inst.selector.cols = selector;
  7282. inst.selector.opts = opts;
  7283. return inst;
  7284. } );
  7285. _api_registerPlural( 'columns().header()', 'column().header()', function ( selector, opts ) {
  7286. return this.iterator( 'column', function ( settings, column ) {
  7287. return settings.aoColumns[column].nTh;
  7288. }, 1 );
  7289. } );
  7290. _api_registerPlural( 'columns().footer()', 'column().footer()', function ( selector, opts ) {
  7291. return this.iterator( 'column', function ( settings, column ) {
  7292. return settings.aoColumns[column].nTf;
  7293. }, 1 );
  7294. } );
  7295. _api_registerPlural( 'columns().data()', 'column().data()', function () {
  7296. return this.iterator( 'column-rows', __columnData, 1 );
  7297. } );
  7298. _api_registerPlural( 'columns().dataSrc()', 'column().dataSrc()', function () {
  7299. return this.iterator( 'column', function ( settings, column ) {
  7300. return settings.aoColumns[column].mData;
  7301. }, 1 );
  7302. } );
  7303. _api_registerPlural( 'columns().cache()', 'column().cache()', function ( type ) {
  7304. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7305. return _pluck_order( settings.aoData, rows,
  7306. type === 'search' ? '_aFilterData' : '_aSortData', column
  7307. );
  7308. }, 1 );
  7309. } );
  7310. _api_registerPlural( 'columns().nodes()', 'column().nodes()', function () {
  7311. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7312. return _pluck_order( settings.aoData, rows, 'anCells', column ) ;
  7313. }, 1 );
  7314. } );
  7315. _api_registerPlural( 'columns().visible()', 'column().visible()', function ( vis, calc ) {
  7316. var ret = this.iterator( 'column', function ( settings, column ) {
  7317. if ( vis === undefined ) {
  7318. return settings.aoColumns[ column ].bVisible;
  7319. } // else
  7320. __setColumnVis( settings, column, vis );
  7321. } );
  7322. // Group the column visibility changes
  7323. if ( vis !== undefined ) {
  7324. // Second loop once the first is done for events
  7325. this.iterator( 'column', function ( settings, column ) {
  7326. _fnCallbackFire( settings, null, 'column-visibility', [settings, column, vis, calc] );
  7327. } );
  7328. if ( calc === undefined || calc ) {
  7329. this.columns.adjust();
  7330. }
  7331. }
  7332. return ret;
  7333. } );
  7334. _api_registerPlural( 'columns().indexes()', 'column().index()', function ( type ) {
  7335. return this.iterator( 'column', function ( settings, column ) {
  7336. return type === 'visible' ?
  7337. _fnColumnIndexToVisible( settings, column ) :
  7338. column;
  7339. }, 1 );
  7340. } );
  7341. _api_register( 'columns.adjust()', function () {
  7342. return this.iterator( 'table', function ( settings ) {
  7343. _fnAdjustColumnSizing( settings );
  7344. }, 1 );
  7345. } );
  7346. _api_register( 'column.index()', function ( type, idx ) {
  7347. if ( this.context.length !== 0 ) {
  7348. var ctx = this.context[0];
  7349. if ( type === 'fromVisible' || type === 'toData' ) {
  7350. return _fnVisibleToColumnIndex( ctx, idx );
  7351. }
  7352. else if ( type === 'fromData' || type === 'toVisible' ) {
  7353. return _fnColumnIndexToVisible( ctx, idx );
  7354. }
  7355. }
  7356. } );
  7357. _api_register( 'column()', function ( selector, opts ) {
  7358. return _selector_first( this.columns( selector, opts ) );
  7359. } );
  7360. var __cell_selector = function ( settings, selector, opts )
  7361. {
  7362. var data = settings.aoData;
  7363. var rows = _selector_row_indexes( settings, opts );
  7364. var cells = _removeEmpty( _pluck_order( data, rows, 'anCells' ) );
  7365. var allCells = $( [].concat.apply([], cells) );
  7366. var row;
  7367. var columns = settings.aoColumns.length;
  7368. var a, i, ien, j, o, host;
  7369. var run = function ( s ) {
  7370. var fnSelector = typeof s === 'function';
  7371. if ( s === null || s === undefined || fnSelector ) {
  7372. // All cells and function selectors
  7373. a = [];
  7374. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  7375. row = rows[i];
  7376. for ( j=0 ; j<columns ; j++ ) {
  7377. o = {
  7378. row: row,
  7379. column: j
  7380. };
  7381. if ( fnSelector ) {
  7382. // Selector - function
  7383. host = data[ row ];
  7384. if ( s( o, _fnGetCellData(settings, row, j), host.anCells ? host.anCells[j] : null ) ) {
  7385. a.push( o );
  7386. }
  7387. }
  7388. else {
  7389. // Selector - all
  7390. a.push( o );
  7391. }
  7392. }
  7393. }
  7394. return a;
  7395. }
  7396. // Selector - index
  7397. if ( $.isPlainObject( s ) ) {
  7398. return [s];
  7399. }
  7400. // Selector - jQuery filtered cells
  7401. var jqResult = allCells
  7402. .filter( s )
  7403. .map( function (i, el) {
  7404. return { // use a new object, in case someone changes the values
  7405. row: el._DT_CellIndex.row,
  7406. column: el._DT_CellIndex.column
  7407. };
  7408. } )
  7409. .toArray();
  7410. if ( jqResult.length || ! s.nodeName ) {
  7411. return jqResult;
  7412. }
  7413. // Otherwise the selector is a node, and there is one last option - the
  7414. // element might be a child of an element which has dt-row and dt-column
  7415. // data attributes
  7416. host = $(s).closest('*[data-dt-row]');
  7417. return host.length ?
  7418. [ {
  7419. row: host.data('dt-row'),
  7420. column: host.data('dt-column')
  7421. } ] :
  7422. [];
  7423. };
  7424. return _selector_run( 'cell', selector, run, settings, opts );
  7425. };
  7426. _api_register( 'cells()', function ( rowSelector, columnSelector, opts ) {
  7427. // Argument shifting
  7428. if ( $.isPlainObject( rowSelector ) ) {
  7429. // Indexes
  7430. if ( rowSelector.row === undefined ) {
  7431. // Selector options in first parameter
  7432. opts = rowSelector;
  7433. rowSelector = null;
  7434. }
  7435. else {
  7436. // Cell index objects in first parameter
  7437. opts = columnSelector;
  7438. columnSelector = null;
  7439. }
  7440. }
  7441. if ( $.isPlainObject( columnSelector ) ) {
  7442. opts = columnSelector;
  7443. columnSelector = null;
  7444. }
  7445. // Cell selector
  7446. if ( columnSelector === null || columnSelector === undefined ) {
  7447. return this.iterator( 'table', function ( settings ) {
  7448. return __cell_selector( settings, rowSelector, _selector_opts( opts ) );
  7449. } );
  7450. }
  7451. // Row + column selector
  7452. var columns = this.columns( columnSelector, opts );
  7453. var rows = this.rows( rowSelector, opts );
  7454. var a, i, ien, j, jen;
  7455. var cells = this.iterator( 'table', function ( settings, idx ) {
  7456. a = [];
  7457. for ( i=0, ien=rows[idx].length ; i<ien ; i++ ) {
  7458. for ( j=0, jen=columns[idx].length ; j<jen ; j++ ) {
  7459. a.push( {
  7460. row: rows[idx][i],
  7461. column: columns[idx][j]
  7462. } );
  7463. }
  7464. }
  7465. return a;
  7466. }, 1 );
  7467. $.extend( cells.selector, {
  7468. cols: columnSelector,
  7469. rows: rowSelector,
  7470. opts: opts
  7471. } );
  7472. return cells;
  7473. } );
  7474. _api_registerPlural( 'cells().nodes()', 'cell().node()', function () {
  7475. return this.iterator( 'cell', function ( settings, row, column ) {
  7476. var data = settings.aoData[ row ];
  7477. return data && data.anCells ?
  7478. data.anCells[ column ] :
  7479. undefined;
  7480. }, 1 );
  7481. } );
  7482. _api_register( 'cells().data()', function () {
  7483. return this.iterator( 'cell', function ( settings, row, column ) {
  7484. return _fnGetCellData( settings, row, column );
  7485. }, 1 );
  7486. } );
  7487. _api_registerPlural( 'cells().cache()', 'cell().cache()', function ( type ) {
  7488. type = type === 'search' ? '_aFilterData' : '_aSortData';
  7489. return this.iterator( 'cell', function ( settings, row, column ) {
  7490. return settings.aoData[ row ][ type ][ column ];
  7491. }, 1 );
  7492. } );
  7493. _api_registerPlural( 'cells().render()', 'cell().render()', function ( type ) {
  7494. return this.iterator( 'cell', function ( settings, row, column ) {
  7495. return _fnGetCellData( settings, row, column, type );
  7496. }, 1 );
  7497. } );
  7498. _api_registerPlural( 'cells().indexes()', 'cell().index()', function () {
  7499. return this.iterator( 'cell', function ( settings, row, column ) {
  7500. return {
  7501. row: row,
  7502. column: column,
  7503. columnVisible: _fnColumnIndexToVisible( settings, column )
  7504. };
  7505. }, 1 );
  7506. } );
  7507. _api_registerPlural( 'cells().invalidate()', 'cell().invalidate()', function ( src ) {
  7508. return this.iterator( 'cell', function ( settings, row, column ) {
  7509. _fnInvalidate( settings, row, src, column );
  7510. } );
  7511. } );
  7512. _api_register( 'cell()', function ( rowSelector, columnSelector, opts ) {
  7513. return _selector_first( this.cells( rowSelector, columnSelector, opts ) );
  7514. } );
  7515. _api_register( 'cell().data()', function ( data ) {
  7516. var ctx = this.context;
  7517. var cell = this[0];
  7518. if ( data === undefined ) {
  7519. // Get
  7520. return ctx.length && cell.length ?
  7521. _fnGetCellData( ctx[0], cell[0].row, cell[0].column ) :
  7522. undefined;
  7523. }
  7524. // Set
  7525. _fnSetCellData( ctx[0], cell[0].row, cell[0].column, data );
  7526. _fnInvalidate( ctx[0], cell[0].row, 'data', cell[0].column );
  7527. return this;
  7528. } );
  7529. /**
  7530. * Get current ordering (sorting) that has been applied to the table.
  7531. *
  7532. * @returns {array} 2D array containing the sorting information for the first
  7533. * table in the current context. Each element in the parent array represents
  7534. * a column being sorted upon (i.e. multi-sorting with two columns would have
  7535. * 2 inner arrays). The inner arrays may have 2 or 3 elements. The first is
  7536. * the column index that the sorting condition applies to, the second is the
  7537. * direction of the sort (`desc` or `asc`) and, optionally, the third is the
  7538. * index of the sorting order from the `column.sorting` initialisation array.
  7539. *//**
  7540. * Set the ordering for the table.
  7541. *
  7542. * @param {integer} order Column index to sort upon.
  7543. * @param {string} direction Direction of the sort to be applied (`asc` or `desc`)
  7544. * @returns {DataTables.Api} this
  7545. *//**
  7546. * Set the ordering for the table.
  7547. *
  7548. * @param {array} order 1D array of sorting information to be applied.
  7549. * @param {array} [...] Optional additional sorting conditions
  7550. * @returns {DataTables.Api} this
  7551. *//**
  7552. * Set the ordering for the table.
  7553. *
  7554. * @param {array} order 2D array of sorting information to be applied.
  7555. * @returns {DataTables.Api} this
  7556. */
  7557. _api_register( 'order()', function ( order, dir ) {
  7558. var ctx = this.context;
  7559. if ( order === undefined ) {
  7560. // get
  7561. return ctx.length !== 0 ?
  7562. ctx[0].aaSorting :
  7563. undefined;
  7564. }
  7565. // set
  7566. if ( typeof order === 'number' ) {
  7567. // Simple column / direction passed in
  7568. order = [ [ order, dir ] ];
  7569. }
  7570. else if ( order.length && ! $.isArray( order[0] ) ) {
  7571. // Arguments passed in (list of 1D arrays)
  7572. order = Array.prototype.slice.call( arguments );
  7573. }
  7574. // otherwise a 2D array was passed in
  7575. return this.iterator( 'table', function ( settings ) {
  7576. settings.aaSorting = order.slice();
  7577. } );
  7578. } );
  7579. /**
  7580. * Attach a sort listener to an element for a given column
  7581. *
  7582. * @param {node|jQuery|string} node Identifier for the element(s) to attach the
  7583. * listener to. This can take the form of a single DOM node, a jQuery
  7584. * collection of nodes or a jQuery selector which will identify the node(s).
  7585. * @param {integer} column the column that a click on this node will sort on
  7586. * @param {function} [callback] callback function when sort is run
  7587. * @returns {DataTables.Api} this
  7588. */
  7589. _api_register( 'order.listener()', function ( node, column, callback ) {
  7590. return this.iterator( 'table', function ( settings ) {
  7591. _fnSortAttachListener( settings, node, column, callback );
  7592. } );
  7593. } );
  7594. _api_register( 'order.fixed()', function ( set ) {
  7595. if ( ! set ) {
  7596. var ctx = this.context;
  7597. var fixed = ctx.length ?
  7598. ctx[0].aaSortingFixed :
  7599. undefined;
  7600. return $.isArray( fixed ) ?
  7601. { pre: fixed } :
  7602. fixed;
  7603. }
  7604. return this.iterator( 'table', function ( settings ) {
  7605. settings.aaSortingFixed = $.extend( true, {}, set );
  7606. } );
  7607. } );
  7608. // Order by the selected column(s)
  7609. _api_register( [
  7610. 'columns().order()',
  7611. 'column().order()'
  7612. ], function ( dir ) {
  7613. var that = this;
  7614. return this.iterator( 'table', function ( settings, i ) {
  7615. var sort = [];
  7616. $.each( that[i], function (j, col) {
  7617. sort.push( [ col, dir ] );
  7618. } );
  7619. settings.aaSorting = sort;
  7620. } );
  7621. } );
  7622. _api_register( 'search()', function ( input, regex, smart, caseInsen ) {
  7623. var ctx = this.context;
  7624. if ( input === undefined ) {
  7625. // get
  7626. return ctx.length !== 0 ?
  7627. ctx[0].oPreviousSearch.sSearch :
  7628. undefined;
  7629. }
  7630. // set
  7631. return this.iterator( 'table', function ( settings ) {
  7632. if ( ! settings.oFeatures.bFilter ) {
  7633. return;
  7634. }
  7635. _fnFilterComplete( settings, $.extend( {}, settings.oPreviousSearch, {
  7636. "sSearch": input+"",
  7637. "bRegex": regex === null ? false : regex,
  7638. "bSmart": smart === null ? true : smart,
  7639. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7640. } ), 1 );
  7641. } );
  7642. } );
  7643. _api_registerPlural(
  7644. 'columns().search()',
  7645. 'column().search()',
  7646. function ( input, regex, smart, caseInsen ) {
  7647. return this.iterator( 'column', function ( settings, column ) {
  7648. var preSearch = settings.aoPreSearchCols;
  7649. if ( input === undefined ) {
  7650. // get
  7651. return preSearch[ column ].sSearch;
  7652. }
  7653. // set
  7654. if ( ! settings.oFeatures.bFilter ) {
  7655. return;
  7656. }
  7657. $.extend( preSearch[ column ], {
  7658. "sSearch": input+"",
  7659. "bRegex": regex === null ? false : regex,
  7660. "bSmart": smart === null ? true : smart,
  7661. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7662. } );
  7663. _fnFilterComplete( settings, settings.oPreviousSearch, 1 );
  7664. } );
  7665. }
  7666. );
  7667. /*
  7668. * State API methods
  7669. */
  7670. _api_register( 'state()', function () {
  7671. return this.context.length ?
  7672. this.context[0].oSavedState :
  7673. null;
  7674. } );
  7675. _api_register( 'state.clear()', function () {
  7676. return this.iterator( 'table', function ( settings ) {
  7677. // Save an empty object
  7678. settings.fnStateSaveCallback.call( settings.oInstance, settings, {} );
  7679. } );
  7680. } );
  7681. _api_register( 'state.loaded()', function () {
  7682. return this.context.length ?
  7683. this.context[0].oLoadedState :
  7684. null;
  7685. } );
  7686. _api_register( 'state.save()', function () {
  7687. return this.iterator( 'table', function ( settings ) {
  7688. _fnSaveState( settings );
  7689. } );
  7690. } );
  7691. /**
  7692. * Provide a common method for plug-ins to check the version of DataTables being
  7693. * used, in order to ensure compatibility.
  7694. *
  7695. * @param {string} version Version string to check for, in the format "X.Y.Z".
  7696. * Note that the formats "X" and "X.Y" are also acceptable.
  7697. * @returns {boolean} true if this version of DataTables is greater or equal to
  7698. * the required version, or false if this version of DataTales is not
  7699. * suitable
  7700. * @static
  7701. * @dtopt API-Static
  7702. *
  7703. * @example
  7704. * alert( $.fn.dataTable.versionCheck( '1.9.0' ) );
  7705. */
  7706. DataTable.versionCheck = DataTable.fnVersionCheck = function( version )
  7707. {
  7708. var aThis = DataTable.version.split('.');
  7709. var aThat = version.split('.');
  7710. var iThis, iThat;
  7711. for ( var i=0, iLen=aThat.length ; i<iLen ; i++ ) {
  7712. iThis = parseInt( aThis[i], 10 ) || 0;
  7713. iThat = parseInt( aThat[i], 10 ) || 0;
  7714. // Parts are the same, keep comparing
  7715. if (iThis === iThat) {
  7716. continue;
  7717. }
  7718. // Parts are different, return immediately
  7719. return iThis > iThat;
  7720. }
  7721. return true;
  7722. };
  7723. /**
  7724. * Check if a `<table>` node is a DataTable table already or not.
  7725. *
  7726. * @param {node|jquery|string} table Table node, jQuery object or jQuery
  7727. * selector for the table to test. Note that if more than more than one
  7728. * table is passed on, only the first will be checked
  7729. * @returns {boolean} true the table given is a DataTable, or false otherwise
  7730. * @static
  7731. * @dtopt API-Static
  7732. *
  7733. * @example
  7734. * if ( ! $.fn.DataTable.isDataTable( '#example' ) ) {
  7735. * $('#example').dataTable();
  7736. * }
  7737. */
  7738. DataTable.isDataTable = DataTable.fnIsDataTable = function ( table )
  7739. {
  7740. var t = $(table).get(0);
  7741. var is = false;
  7742. if ( table instanceof DataTable.Api ) {
  7743. return true;
  7744. }
  7745. $.each( DataTable.settings, function (i, o) {
  7746. var head = o.nScrollHead ? $('table', o.nScrollHead)[0] : null;
  7747. var foot = o.nScrollFoot ? $('table', o.nScrollFoot)[0] : null;
  7748. if ( o.nTable === t || head === t || foot === t ) {
  7749. is = true;
  7750. }
  7751. } );
  7752. return is;
  7753. };
  7754. /**
  7755. * Get all DataTable tables that have been initialised - optionally you can
  7756. * select to get only currently visible tables.
  7757. *
  7758. * @param {boolean} [visible=false] Flag to indicate if you want all (default)
  7759. * or visible tables only.
  7760. * @returns {array} Array of `table` nodes (not DataTable instances) which are
  7761. * DataTables
  7762. * @static
  7763. * @dtopt API-Static
  7764. *
  7765. * @example
  7766. * $.each( $.fn.dataTable.tables(true), function () {
  7767. * $(table).DataTable().columns.adjust();
  7768. * } );
  7769. */
  7770. DataTable.tables = DataTable.fnTables = function ( visible )
  7771. {
  7772. var api = false;
  7773. if ( $.isPlainObject( visible ) ) {
  7774. api = visible.api;
  7775. visible = visible.visible;
  7776. }
  7777. var a = $.map( DataTable.settings, function (o) {
  7778. if ( !visible || (visible && $(o.nTable).is(':visible')) ) {
  7779. return o.nTable;
  7780. }
  7781. } );
  7782. return api ?
  7783. new _Api( a ) :
  7784. a;
  7785. };
  7786. /**
  7787. * Convert from camel case parameters to Hungarian notation. This is made public
  7788. * for the extensions to provide the same ability as DataTables core to accept
  7789. * either the 1.9 style Hungarian notation, or the 1.10+ style camelCase
  7790. * parameters.
  7791. *
  7792. * @param {object} src The model object which holds all parameters that can be
  7793. * mapped.
  7794. * @param {object} user The object to convert from camel case to Hungarian.
  7795. * @param {boolean} force When set to `true`, properties which already have a
  7796. * Hungarian value in the `user` object will be overwritten. Otherwise they
  7797. * won't be.
  7798. */
  7799. DataTable.camelToHungarian = _fnCamelToHungarian;
  7800. /**
  7801. *
  7802. */
  7803. _api_register( '$()', function ( selector, opts ) {
  7804. var
  7805. rows = this.rows( opts ).nodes(), // Get all rows
  7806. jqRows = $(rows);
  7807. return $( [].concat(
  7808. jqRows.filter( selector ).toArray(),
  7809. jqRows.find( selector ).toArray()
  7810. ) );
  7811. } );
  7812. // jQuery functions to operate on the tables
  7813. $.each( [ 'on', 'one', 'off' ], function (i, key) {
  7814. _api_register( key+'()', function ( /* event, handler */ ) {
  7815. var args = Array.prototype.slice.call(arguments);
  7816. // Add the `dt` namespace automatically if it isn't already present
  7817. args[0] = $.map( args[0].split( /\s/ ), function ( e ) {
  7818. return ! e.match(/\.dt\b/) ?
  7819. e+'.dt' :
  7820. e;
  7821. } ).join( ' ' );
  7822. var inst = $( this.tables().nodes() );
  7823. inst[key].apply( inst, args );
  7824. return this;
  7825. } );
  7826. } );
  7827. _api_register( 'clear()', function () {
  7828. return this.iterator( 'table', function ( settings ) {
  7829. _fnClearTable( settings );
  7830. } );
  7831. } );
  7832. _api_register( 'settings()', function () {
  7833. return new _Api( this.context, this.context );
  7834. } );
  7835. _api_register( 'init()', function () {
  7836. var ctx = this.context;
  7837. return ctx.length ? ctx[0].oInit : null;
  7838. } );
  7839. _api_register( 'data()', function () {
  7840. return this.iterator( 'table', function ( settings ) {
  7841. return _pluck( settings.aoData, '_aData' );
  7842. } ).flatten();
  7843. } );
  7844. _api_register( 'destroy()', function ( remove ) {
  7845. remove = remove || false;
  7846. return this.iterator( 'table', function ( settings ) {
  7847. var orig = settings.nTableWrapper.parentNode;
  7848. var classes = settings.oClasses;
  7849. var table = settings.nTable;
  7850. var tbody = settings.nTBody;
  7851. var thead = settings.nTHead;
  7852. var tfoot = settings.nTFoot;
  7853. var jqTable = $(table);
  7854. var jqTbody = $(tbody);
  7855. var jqWrapper = $(settings.nTableWrapper);
  7856. var rows = $.map( settings.aoData, function (r) { return r.nTr; } );
  7857. var i, ien;
  7858. // Flag to note that the table is currently being destroyed - no action
  7859. // should be taken
  7860. settings.bDestroying = true;
  7861. // Fire off the destroy callbacks for plug-ins etc
  7862. _fnCallbackFire( settings, "aoDestroyCallback", "destroy", [settings] );
  7863. // If not being removed from the document, make all columns visible
  7864. if ( ! remove ) {
  7865. new _Api( settings ).columns().visible( true );
  7866. }
  7867. // Blitz all `DT` namespaced events (these are internal events, the
  7868. // lowercase, `dt` events are user subscribed and they are responsible
  7869. // for removing them
  7870. jqWrapper.off('.DT').find(':not(tbody *)').off('.DT');
  7871. $(window).off('.DT-'+settings.sInstance);
  7872. // When scrolling we had to break the table up - restore it
  7873. if ( table != thead.parentNode ) {
  7874. jqTable.children('thead').detach();
  7875. jqTable.append( thead );
  7876. }
  7877. if ( tfoot && table != tfoot.parentNode ) {
  7878. jqTable.children('tfoot').detach();
  7879. jqTable.append( tfoot );
  7880. }
  7881. settings.aaSorting = [];
  7882. settings.aaSortingFixed = [];
  7883. _fnSortingClasses( settings );
  7884. $( rows ).removeClass( settings.asStripeClasses.join(' ') );
  7885. $('th, td', thead).removeClass( classes.sSortable+' '+
  7886. classes.sSortableAsc+' '+classes.sSortableDesc+' '+classes.sSortableNone
  7887. );
  7888. if ( settings.bJUI ) {
  7889. $('th span.'+classes.sSortIcon+ ', td span.'+classes.sSortIcon, thead).detach();
  7890. $('th, td', thead).each( function () {
  7891. var wrapper = $('div.'+classes.sSortJUIWrapper, this);
  7892. $(this).append( wrapper.contents() );
  7893. wrapper.detach();
  7894. } );
  7895. }
  7896. // Add the TR elements back into the table in their original order
  7897. jqTbody.children().detach();
  7898. jqTbody.append( rows );
  7899. // Remove the DataTables generated nodes, events and classes
  7900. var removedMethod = remove ? 'remove' : 'detach';
  7901. jqTable[ removedMethod ]();
  7902. jqWrapper[ removedMethod ]();
  7903. // If we need to reattach the table to the document
  7904. if ( ! remove && orig ) {
  7905. // insertBefore acts like appendChild if !arg[1]
  7906. orig.insertBefore( table, settings.nTableReinsertBefore );
  7907. // Restore the width of the original table - was read from the style property,
  7908. // so we can restore directly to that
  7909. jqTable
  7910. .css( 'width', settings.sDestroyWidth )
  7911. .removeClass( classes.sTable );
  7912. // If the were originally stripe classes - then we add them back here.
  7913. // Note this is not fool proof (for example if not all rows had stripe
  7914. // classes - but it's a good effort without getting carried away
  7915. ien = settings.asDestroyStripes.length;
  7916. if ( ien ) {
  7917. jqTbody.children().each( function (i) {
  7918. $(this).addClass( settings.asDestroyStripes[i % ien] );
  7919. } );
  7920. }
  7921. }
  7922. /* Remove the settings object from the settings array */
  7923. var idx = $.inArray( settings, DataTable.settings );
  7924. if ( idx !== -1 ) {
  7925. DataTable.settings.splice( idx, 1 );
  7926. }
  7927. } );
  7928. } );
  7929. // Add the `every()` method for rows, columns and cells in a compact form
  7930. $.each( [ 'column', 'row', 'cell' ], function ( i, type ) {
  7931. _api_register( type+'s().every()', function ( fn ) {
  7932. var opts = this.selector.opts;
  7933. var api = this;
  7934. return this.iterator( type, function ( settings, arg1, arg2, arg3, arg4 ) {
  7935. // Rows and columns:
  7936. // arg1 - index
  7937. // arg2 - table counter
  7938. // arg3 - loop counter
  7939. // arg4 - undefined
  7940. // Cells:
  7941. // arg1 - row index
  7942. // arg2 - column index
  7943. // arg3 - table counter
  7944. // arg4 - loop counter
  7945. fn.call(
  7946. api[ type ](
  7947. arg1,
  7948. type==='cell' ? arg2 : opts,
  7949. type==='cell' ? opts : undefined
  7950. ),
  7951. arg1, arg2, arg3, arg4
  7952. );
  7953. } );
  7954. } );
  7955. } );
  7956. // i18n method for extensions to be able to use the language object from the
  7957. // DataTable
  7958. _api_register( 'i18n()', function ( token, def, plural ) {
  7959. var ctx = this.context[0];
  7960. var resolved = _fnGetObjectDataFn( token )( ctx.oLanguage );
  7961. if ( resolved === undefined ) {
  7962. resolved = def;
  7963. }
  7964. if ( plural !== undefined && $.isPlainObject( resolved ) ) {
  7965. resolved = resolved[ plural ] !== undefined ?
  7966. resolved[ plural ] :
  7967. resolved._;
  7968. }
  7969. return resolved.replace( '%d', plural ); // nb: plural might be undefined,
  7970. } );
  7971. /**
  7972. * Version string for plug-ins to check compatibility. Allowed format is
  7973. * `a.b.c-d` where: a:int, b:int, c:int, d:string(dev|beta|alpha). `d` is used
  7974. * only for non-release builds. See http://semver.org/ for more information.
  7975. * @member
  7976. * @type string
  7977. * @default Version number
  7978. */
  7979. DataTable.version = "1.10.15";
  7980. /**
  7981. * Private data store, containing all of the settings objects that are
  7982. * created for the tables on a given page.
  7983. *
  7984. * Note that the `DataTable.settings` object is aliased to
  7985. * `jQuery.fn.dataTableExt` through which it may be accessed and
  7986. * manipulated, or `jQuery.fn.dataTable.settings`.
  7987. * @member
  7988. * @type array
  7989. * @default []
  7990. * @private
  7991. */
  7992. DataTable.settings = [];
  7993. /**
  7994. * Object models container, for the various models that DataTables has
  7995. * available to it. These models define the objects that are used to hold
  7996. * the active state and configuration of the table.
  7997. * @namespace
  7998. */
  7999. DataTable.models = {};
  8000. /**
  8001. * Template object for the way in which DataTables holds information about
  8002. * search information for the global filter and individual column filters.
  8003. * @namespace
  8004. */
  8005. DataTable.models.oSearch = {
  8006. /**
  8007. * Flag to indicate if the filtering should be case insensitive or not
  8008. * @type boolean
  8009. * @default true
  8010. */
  8011. "bCaseInsensitive": true,
  8012. /**
  8013. * Applied search term
  8014. * @type string
  8015. * @default <i>Empty string</i>
  8016. */
  8017. "sSearch": "",
  8018. /**
  8019. * Flag to indicate if the search term should be interpreted as a
  8020. * regular expression (true) or not (false) and therefore and special
  8021. * regex characters escaped.
  8022. * @type boolean
  8023. * @default false
  8024. */
  8025. "bRegex": false,
  8026. /**
  8027. * Flag to indicate if DataTables is to use its smart filtering or not.
  8028. * @type boolean
  8029. * @default true
  8030. */
  8031. "bSmart": true
  8032. };
  8033. /**
  8034. * Template object for the way in which DataTables holds information about
  8035. * each individual row. This is the object format used for the settings
  8036. * aoData array.
  8037. * @namespace
  8038. */
  8039. DataTable.models.oRow = {
  8040. /**
  8041. * TR element for the row
  8042. * @type node
  8043. * @default null
  8044. */
  8045. "nTr": null,
  8046. /**
  8047. * Array of TD elements for each row. This is null until the row has been
  8048. * created.
  8049. * @type array nodes
  8050. * @default []
  8051. */
  8052. "anCells": null,
  8053. /**
  8054. * Data object from the original data source for the row. This is either
  8055. * an array if using the traditional form of DataTables, or an object if
  8056. * using mData options. The exact type will depend on the passed in
  8057. * data from the data source, or will be an array if using DOM a data
  8058. * source.
  8059. * @type array|object
  8060. * @default []
  8061. */
  8062. "_aData": [],
  8063. /**
  8064. * Sorting data cache - this array is ostensibly the same length as the
  8065. * number of columns (although each index is generated only as it is
  8066. * needed), and holds the data that is used for sorting each column in the
  8067. * row. We do this cache generation at the start of the sort in order that
  8068. * the formatting of the sort data need be done only once for each cell
  8069. * per sort. This array should not be read from or written to by anything
  8070. * other than the master sorting methods.
  8071. * @type array
  8072. * @default null
  8073. * @private
  8074. */
  8075. "_aSortData": null,
  8076. /**
  8077. * Per cell filtering data cache. As per the sort data cache, used to
  8078. * increase the performance of the filtering in DataTables
  8079. * @type array
  8080. * @default null
  8081. * @private
  8082. */
  8083. "_aFilterData": null,
  8084. /**
  8085. * Filtering data cache. This is the same as the cell filtering cache, but
  8086. * in this case a string rather than an array. This is easily computed with
  8087. * a join on `_aFilterData`, but is provided as a cache so the join isn't
  8088. * needed on every search (memory traded for performance)
  8089. * @type array
  8090. * @default null
  8091. * @private
  8092. */
  8093. "_sFilterRow": null,
  8094. /**
  8095. * Cache of the class name that DataTables has applied to the row, so we
  8096. * can quickly look at this variable rather than needing to do a DOM check
  8097. * on className for the nTr property.
  8098. * @type string
  8099. * @default <i>Empty string</i>
  8100. * @private
  8101. */
  8102. "_sRowStripe": "",
  8103. /**
  8104. * Denote if the original data source was from the DOM, or the data source
  8105. * object. This is used for invalidating data, so DataTables can
  8106. * automatically read data from the original source, unless uninstructed
  8107. * otherwise.
  8108. * @type string
  8109. * @default null
  8110. * @private
  8111. */
  8112. "src": null,
  8113. /**
  8114. * Index in the aoData array. This saves an indexOf lookup when we have the
  8115. * object, but want to know the index
  8116. * @type integer
  8117. * @default -1
  8118. * @private
  8119. */
  8120. "idx": -1
  8121. };
  8122. /**
  8123. * Template object for the column information object in DataTables. This object
  8124. * is held in the settings aoColumns array and contains all the information that
  8125. * DataTables needs about each individual column.
  8126. *
  8127. * Note that this object is related to {@link DataTable.defaults.column}
  8128. * but this one is the internal data store for DataTables's cache of columns.
  8129. * It should NOT be manipulated outside of DataTables. Any configuration should
  8130. * be done through the initialisation options.
  8131. * @namespace
  8132. */
  8133. DataTable.models.oColumn = {
  8134. /**
  8135. * Column index. This could be worked out on-the-fly with $.inArray, but it
  8136. * is faster to just hold it as a variable
  8137. * @type integer
  8138. * @default null
  8139. */
  8140. "idx": null,
  8141. /**
  8142. * A list of the columns that sorting should occur on when this column
  8143. * is sorted. That this property is an array allows multi-column sorting
  8144. * to be defined for a column (for example first name / last name columns
  8145. * would benefit from this). The values are integers pointing to the
  8146. * columns to be sorted on (typically it will be a single integer pointing
  8147. * at itself, but that doesn't need to be the case).
  8148. * @type array
  8149. */
  8150. "aDataSort": null,
  8151. /**
  8152. * Define the sorting directions that are applied to the column, in sequence
  8153. * as the column is repeatedly sorted upon - i.e. the first value is used
  8154. * as the sorting direction when the column if first sorted (clicked on).
  8155. * Sort it again (click again) and it will move on to the next index.
  8156. * Repeat until loop.
  8157. * @type array
  8158. */
  8159. "asSorting": null,
  8160. /**
  8161. * Flag to indicate if the column is searchable, and thus should be included
  8162. * in the filtering or not.
  8163. * @type boolean
  8164. */
  8165. "bSearchable": null,
  8166. /**
  8167. * Flag to indicate if the column is sortable or not.
  8168. * @type boolean
  8169. */
  8170. "bSortable": null,
  8171. /**
  8172. * Flag to indicate if the column is currently visible in the table or not
  8173. * @type boolean
  8174. */
  8175. "bVisible": null,
  8176. /**
  8177. * Store for manual type assignment using the `column.type` option. This
  8178. * is held in store so we can manipulate the column's `sType` property.
  8179. * @type string
  8180. * @default null
  8181. * @private
  8182. */
  8183. "_sManualType": null,
  8184. /**
  8185. * Flag to indicate if HTML5 data attributes should be used as the data
  8186. * source for filtering or sorting. True is either are.
  8187. * @type boolean
  8188. * @default false
  8189. * @private
  8190. */
  8191. "_bAttrSrc": false,
  8192. /**
  8193. * Developer definable function that is called whenever a cell is created (Ajax source,
  8194. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  8195. * allowing you to modify the DOM element (add background colour for example) when the
  8196. * element is available.
  8197. * @type function
  8198. * @param {element} nTd The TD node that has been created
  8199. * @param {*} sData The Data for the cell
  8200. * @param {array|object} oData The data for the whole row
  8201. * @param {int} iRow The row index for the aoData data store
  8202. * @default null
  8203. */
  8204. "fnCreatedCell": null,
  8205. /**
  8206. * Function to get data from a cell in a column. You should <b>never</b>
  8207. * access data directly through _aData internally in DataTables - always use
  8208. * the method attached to this property. It allows mData to function as
  8209. * required. This function is automatically assigned by the column
  8210. * initialisation method
  8211. * @type function
  8212. * @param {array|object} oData The data array/object for the array
  8213. * (i.e. aoData[]._aData)
  8214. * @param {string} sSpecific The specific data type you want to get -
  8215. * 'display', 'type' 'filter' 'sort'
  8216. * @returns {*} The data for the cell from the given row's data
  8217. * @default null
  8218. */
  8219. "fnGetData": null,
  8220. /**
  8221. * Function to set data for a cell in the column. You should <b>never</b>
  8222. * set the data directly to _aData internally in DataTables - always use
  8223. * this method. It allows mData to function as required. This function
  8224. * is automatically assigned by the column initialisation method
  8225. * @type function
  8226. * @param {array|object} oData The data array/object for the array
  8227. * (i.e. aoData[]._aData)
  8228. * @param {*} sValue Value to set
  8229. * @default null
  8230. */
  8231. "fnSetData": null,
  8232. /**
  8233. * Property to read the value for the cells in the column from the data
  8234. * source array / object. If null, then the default content is used, if a
  8235. * function is given then the return from the function is used.
  8236. * @type function|int|string|null
  8237. * @default null
  8238. */
  8239. "mData": null,
  8240. /**
  8241. * Partner property to mData which is used (only when defined) to get
  8242. * the data - i.e. it is basically the same as mData, but without the
  8243. * 'set' option, and also the data fed to it is the result from mData.
  8244. * This is the rendering method to match the data method of mData.
  8245. * @type function|int|string|null
  8246. * @default null
  8247. */
  8248. "mRender": null,
  8249. /**
  8250. * Unique header TH/TD element for this column - this is what the sorting
  8251. * listener is attached to (if sorting is enabled.)
  8252. * @type node
  8253. * @default null
  8254. */
  8255. "nTh": null,
  8256. /**
  8257. * Unique footer TH/TD element for this column (if there is one). Not used
  8258. * in DataTables as such, but can be used for plug-ins to reference the
  8259. * footer for each column.
  8260. * @type node
  8261. * @default null
  8262. */
  8263. "nTf": null,
  8264. /**
  8265. * The class to apply to all TD elements in the table's TBODY for the column
  8266. * @type string
  8267. * @default null
  8268. */
  8269. "sClass": null,
  8270. /**
  8271. * When DataTables calculates the column widths to assign to each column,
  8272. * it finds the longest string in each column and then constructs a
  8273. * temporary table and reads the widths from that. The problem with this
  8274. * is that "mmm" is much wider then "iiii", but the latter is a longer
  8275. * string - thus the calculation can go wrong (doing it properly and putting
  8276. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  8277. * a "work around" we provide this option. It will append its value to the
  8278. * text that is found to be the longest string for the column - i.e. padding.
  8279. * @type string
  8280. */
  8281. "sContentPadding": null,
  8282. /**
  8283. * Allows a default value to be given for a column's data, and will be used
  8284. * whenever a null data source is encountered (this can be because mData
  8285. * is set to null, or because the data source itself is null).
  8286. * @type string
  8287. * @default null
  8288. */
  8289. "sDefaultContent": null,
  8290. /**
  8291. * Name for the column, allowing reference to the column by name as well as
  8292. * by index (needs a lookup to work by name).
  8293. * @type string
  8294. */
  8295. "sName": null,
  8296. /**
  8297. * Custom sorting data type - defines which of the available plug-ins in
  8298. * afnSortData the custom sorting will use - if any is defined.
  8299. * @type string
  8300. * @default std
  8301. */
  8302. "sSortDataType": 'std',
  8303. /**
  8304. * Class to be applied to the header element when sorting on this column
  8305. * @type string
  8306. * @default null
  8307. */
  8308. "sSortingClass": null,
  8309. /**
  8310. * Class to be applied to the header element when sorting on this column -
  8311. * when jQuery UI theming is used.
  8312. * @type string
  8313. * @default null
  8314. */
  8315. "sSortingClassJUI": null,
  8316. /**
  8317. * Title of the column - what is seen in the TH element (nTh).
  8318. * @type string
  8319. */
  8320. "sTitle": null,
  8321. /**
  8322. * Column sorting and filtering type
  8323. * @type string
  8324. * @default null
  8325. */
  8326. "sType": null,
  8327. /**
  8328. * Width of the column
  8329. * @type string
  8330. * @default null
  8331. */
  8332. "sWidth": null,
  8333. /**
  8334. * Width of the column when it was first "encountered"
  8335. * @type string
  8336. * @default null
  8337. */
  8338. "sWidthOrig": null
  8339. };
  8340. /*
  8341. * Developer note: The properties of the object below are given in Hungarian
  8342. * notation, that was used as the interface for DataTables prior to v1.10, however
  8343. * from v1.10 onwards the primary interface is camel case. In order to avoid
  8344. * breaking backwards compatibility utterly with this change, the Hungarian
  8345. * version is still, internally the primary interface, but is is not documented
  8346. * - hence the @name tags in each doc comment. This allows a Javascript function
  8347. * to create a map from Hungarian notation to camel case (going the other direction
  8348. * would require each property to be listed, which would at around 3K to the size
  8349. * of DataTables, while this method is about a 0.5K hit.
  8350. *
  8351. * Ultimately this does pave the way for Hungarian notation to be dropped
  8352. * completely, but that is a massive amount of work and will break current
  8353. * installs (therefore is on-hold until v2).
  8354. */
  8355. /**
  8356. * Initialisation options that can be given to DataTables at initialisation
  8357. * time.
  8358. * @namespace
  8359. */
  8360. DataTable.defaults = {
  8361. /**
  8362. * An array of data to use for the table, passed in at initialisation which
  8363. * will be used in preference to any data which is already in the DOM. This is
  8364. * particularly useful for constructing tables purely in Javascript, for
  8365. * example with a custom Ajax call.
  8366. * @type array
  8367. * @default null
  8368. *
  8369. * @dtopt Option
  8370. * @name DataTable.defaults.data
  8371. *
  8372. * @example
  8373. * // Using a 2D array data source
  8374. * $(document).ready( function () {
  8375. * $('#example').dataTable( {
  8376. * "data": [
  8377. * ['Trident', 'Internet Explorer 4.0', 'Win 95+', 4, 'X'],
  8378. * ['Trident', 'Internet Explorer 5.0', 'Win 95+', 5, 'C'],
  8379. * ],
  8380. * "columns": [
  8381. * { "title": "Engine" },
  8382. * { "title": "Browser" },
  8383. * { "title": "Platform" },
  8384. * { "title": "Version" },
  8385. * { "title": "Grade" }
  8386. * ]
  8387. * } );
  8388. * } );
  8389. *
  8390. * @example
  8391. * // Using an array of objects as a data source (`data`)
  8392. * $(document).ready( function () {
  8393. * $('#example').dataTable( {
  8394. * "data": [
  8395. * {
  8396. * "engine": "Trident",
  8397. * "browser": "Internet Explorer 4.0",
  8398. * "platform": "Win 95+",
  8399. * "version": 4,
  8400. * "grade": "X"
  8401. * },
  8402. * {
  8403. * "engine": "Trident",
  8404. * "browser": "Internet Explorer 5.0",
  8405. * "platform": "Win 95+",
  8406. * "version": 5,
  8407. * "grade": "C"
  8408. * }
  8409. * ],
  8410. * "columns": [
  8411. * { "title": "Engine", "data": "engine" },
  8412. * { "title": "Browser", "data": "browser" },
  8413. * { "title": "Platform", "data": "platform" },
  8414. * { "title": "Version", "data": "version" },
  8415. * { "title": "Grade", "data": "grade" }
  8416. * ]
  8417. * } );
  8418. * } );
  8419. */
  8420. "aaData": null,
  8421. /**
  8422. * If ordering is enabled, then DataTables will perform a first pass sort on
  8423. * initialisation. You can define which column(s) the sort is performed
  8424. * upon, and the sorting direction, with this variable. The `sorting` array
  8425. * should contain an array for each column to be sorted initially containing
  8426. * the column's index and a direction string ('asc' or 'desc').
  8427. * @type array
  8428. * @default [[0,'asc']]
  8429. *
  8430. * @dtopt Option
  8431. * @name DataTable.defaults.order
  8432. *
  8433. * @example
  8434. * // Sort by 3rd column first, and then 4th column
  8435. * $(document).ready( function() {
  8436. * $('#example').dataTable( {
  8437. * "order": [[2,'asc'], [3,'desc']]
  8438. * } );
  8439. * } );
  8440. *
  8441. * // No initial sorting
  8442. * $(document).ready( function() {
  8443. * $('#example').dataTable( {
  8444. * "order": []
  8445. * } );
  8446. * } );
  8447. */
  8448. "aaSorting": [[0,'asc']],
  8449. /**
  8450. * This parameter is basically identical to the `sorting` parameter, but
  8451. * cannot be overridden by user interaction with the table. What this means
  8452. * is that you could have a column (visible or hidden) which the sorting
  8453. * will always be forced on first - any sorting after that (from the user)
  8454. * will then be performed as required. This can be useful for grouping rows
  8455. * together.
  8456. * @type array
  8457. * @default null
  8458. *
  8459. * @dtopt Option
  8460. * @name DataTable.defaults.orderFixed
  8461. *
  8462. * @example
  8463. * $(document).ready( function() {
  8464. * $('#example').dataTable( {
  8465. * "orderFixed": [[0,'asc']]
  8466. * } );
  8467. * } )
  8468. */
  8469. "aaSortingFixed": [],
  8470. /**
  8471. * DataTables can be instructed to load data to display in the table from a
  8472. * Ajax source. This option defines how that Ajax call is made and where to.
  8473. *
  8474. * The `ajax` property has three different modes of operation, depending on
  8475. * how it is defined. These are:
  8476. *
  8477. * * `string` - Set the URL from where the data should be loaded from.
  8478. * * `object` - Define properties for `jQuery.ajax`.
  8479. * * `function` - Custom data get function
  8480. *
  8481. * `string`
  8482. * --------
  8483. *
  8484. * As a string, the `ajax` property simply defines the URL from which
  8485. * DataTables will load data.
  8486. *
  8487. * `object`
  8488. * --------
  8489. *
  8490. * As an object, the parameters in the object are passed to
  8491. * [jQuery.ajax](http://api.jquery.com/jQuery.ajax/) allowing fine control
  8492. * of the Ajax request. DataTables has a number of default parameters which
  8493. * you can override using this option. Please refer to the jQuery
  8494. * documentation for a full description of the options available, although
  8495. * the following parameters provide additional options in DataTables or
  8496. * require special consideration:
  8497. *
  8498. * * `data` - As with jQuery, `data` can be provided as an object, but it
  8499. * can also be used as a function to manipulate the data DataTables sends
  8500. * to the server. The function takes a single parameter, an object of
  8501. * parameters with the values that DataTables has readied for sending. An
  8502. * object may be returned which will be merged into the DataTables
  8503. * defaults, or you can add the items to the object that was passed in and
  8504. * not return anything from the function. This supersedes `fnServerParams`
  8505. * from DataTables 1.9-.
  8506. *
  8507. * * `dataSrc` - By default DataTables will look for the property `data` (or
  8508. * `aaData` for compatibility with DataTables 1.9-) when obtaining data
  8509. * from an Ajax source or for server-side processing - this parameter
  8510. * allows that property to be changed. You can use Javascript dotted
  8511. * object notation to get a data source for multiple levels of nesting, or
  8512. * it my be used as a function. As a function it takes a single parameter,
  8513. * the JSON returned from the server, which can be manipulated as
  8514. * required, with the returned value being that used by DataTables as the
  8515. * data source for the table. This supersedes `sAjaxDataProp` from
  8516. * DataTables 1.9-.
  8517. *
  8518. * * `success` - Should not be overridden it is used internally in
  8519. * DataTables. To manipulate / transform the data returned by the server
  8520. * use `ajax.dataSrc`, or use `ajax` as a function (see below).
  8521. *
  8522. * `function`
  8523. * ----------
  8524. *
  8525. * As a function, making the Ajax call is left up to yourself allowing
  8526. * complete control of the Ajax request. Indeed, if desired, a method other
  8527. * than Ajax could be used to obtain the required data, such as Web storage
  8528. * or an AIR database.
  8529. *
  8530. * The function is given four parameters and no return is required. The
  8531. * parameters are:
  8532. *
  8533. * 1. _object_ - Data to send to the server
  8534. * 2. _function_ - Callback function that must be executed when the required
  8535. * data has been obtained. That data should be passed into the callback
  8536. * as the only parameter
  8537. * 3. _object_ - DataTables settings object for the table
  8538. *
  8539. * Note that this supersedes `fnServerData` from DataTables 1.9-.
  8540. *
  8541. * @type string|object|function
  8542. * @default null
  8543. *
  8544. * @dtopt Option
  8545. * @name DataTable.defaults.ajax
  8546. * @since 1.10.0
  8547. *
  8548. * @example
  8549. * // Get JSON data from a file via Ajax.
  8550. * // Note DataTables expects data in the form `{ data: [ ...data... ] }` by default).
  8551. * $('#example').dataTable( {
  8552. * "ajax": "data.json"
  8553. * } );
  8554. *
  8555. * @example
  8556. * // Get JSON data from a file via Ajax, using `dataSrc` to change
  8557. * // `data` to `tableData` (i.e. `{ tableData: [ ...data... ] }`)
  8558. * $('#example').dataTable( {
  8559. * "ajax": {
  8560. * "url": "data.json",
  8561. * "dataSrc": "tableData"
  8562. * }
  8563. * } );
  8564. *
  8565. * @example
  8566. * // Get JSON data from a file via Ajax, using `dataSrc` to read data
  8567. * // from a plain array rather than an array in an object
  8568. * $('#example').dataTable( {
  8569. * "ajax": {
  8570. * "url": "data.json",
  8571. * "dataSrc": ""
  8572. * }
  8573. * } );
  8574. *
  8575. * @example
  8576. * // Manipulate the data returned from the server - add a link to data
  8577. * // (note this can, should, be done using `render` for the column - this
  8578. * // is just a simple example of how the data can be manipulated).
  8579. * $('#example').dataTable( {
  8580. * "ajax": {
  8581. * "url": "data.json",
  8582. * "dataSrc": function ( json ) {
  8583. * for ( var i=0, ien=json.length ; i<ien ; i++ ) {
  8584. * json[i][0] = '<a href="/message/'+json[i][0]+'>View message</a>';
  8585. * }
  8586. * return json;
  8587. * }
  8588. * }
  8589. * } );
  8590. *
  8591. * @example
  8592. * // Add data to the request
  8593. * $('#example').dataTable( {
  8594. * "ajax": {
  8595. * "url": "data.json",
  8596. * "data": function ( d ) {
  8597. * return {
  8598. * "extra_search": $('#extra').val()
  8599. * };
  8600. * }
  8601. * }
  8602. * } );
  8603. *
  8604. * @example
  8605. * // Send request as POST
  8606. * $('#example').dataTable( {
  8607. * "ajax": {
  8608. * "url": "data.json",
  8609. * "type": "POST"
  8610. * }
  8611. * } );
  8612. *
  8613. * @example
  8614. * // Get the data from localStorage (could interface with a form for
  8615. * // adding, editing and removing rows).
  8616. * $('#example').dataTable( {
  8617. * "ajax": function (data, callback, settings) {
  8618. * callback(
  8619. * JSON.parse( localStorage.getItem('dataTablesData') )
  8620. * );
  8621. * }
  8622. * } );
  8623. */
  8624. "ajax": null,
  8625. /**
  8626. * This parameter allows you to readily specify the entries in the length drop
  8627. * down menu that DataTables shows when pagination is enabled. It can be
  8628. * either a 1D array of options which will be used for both the displayed
  8629. * option and the value, or a 2D array which will use the array in the first
  8630. * position as the value, and the array in the second position as the
  8631. * displayed options (useful for language strings such as 'All').
  8632. *
  8633. * Note that the `pageLength` property will be automatically set to the
  8634. * first value given in this array, unless `pageLength` is also provided.
  8635. * @type array
  8636. * @default [ 10, 25, 50, 100 ]
  8637. *
  8638. * @dtopt Option
  8639. * @name DataTable.defaults.lengthMenu
  8640. *
  8641. * @example
  8642. * $(document).ready( function() {
  8643. * $('#example').dataTable( {
  8644. * "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
  8645. * } );
  8646. * } );
  8647. */
  8648. "aLengthMenu": [ 10, 25, 50, 100 ],
  8649. /**
  8650. * The `columns` option in the initialisation parameter allows you to define
  8651. * details about the way individual columns behave. For a full list of
  8652. * column options that can be set, please see
  8653. * {@link DataTable.defaults.column}. Note that if you use `columns` to
  8654. * define your columns, you must have an entry in the array for every single
  8655. * column that you have in your table (these can be null if you don't which
  8656. * to specify any options).
  8657. * @member
  8658. *
  8659. * @name DataTable.defaults.column
  8660. */
  8661. "aoColumns": null,
  8662. /**
  8663. * Very similar to `columns`, `columnDefs` allows you to target a specific
  8664. * column, multiple columns, or all columns, using the `targets` property of
  8665. * each object in the array. This allows great flexibility when creating
  8666. * tables, as the `columnDefs` arrays can be of any length, targeting the
  8667. * columns you specifically want. `columnDefs` may use any of the column
  8668. * options available: {@link DataTable.defaults.column}, but it _must_
  8669. * have `targets` defined in each object in the array. Values in the `targets`
  8670. * array may be:
  8671. * <ul>
  8672. * <li>a string - class name will be matched on the TH for the column</li>
  8673. * <li>0 or a positive integer - column index counting from the left</li>
  8674. * <li>a negative integer - column index counting from the right</li>
  8675. * <li>the string "_all" - all columns (i.e. assign a default)</li>
  8676. * </ul>
  8677. * @member
  8678. *
  8679. * @name DataTable.defaults.columnDefs
  8680. */
  8681. "aoColumnDefs": null,
  8682. /**
  8683. * Basically the same as `search`, this parameter defines the individual column
  8684. * filtering state at initialisation time. The array must be of the same size
  8685. * as the number of columns, and each element be an object with the parameters
  8686. * `search` and `escapeRegex` (the latter is optional). 'null' is also
  8687. * accepted and the default will be used.
  8688. * @type array
  8689. * @default []
  8690. *
  8691. * @dtopt Option
  8692. * @name DataTable.defaults.searchCols
  8693. *
  8694. * @example
  8695. * $(document).ready( function() {
  8696. * $('#example').dataTable( {
  8697. * "searchCols": [
  8698. * null,
  8699. * { "search": "My filter" },
  8700. * null,
  8701. * { "search": "^[0-9]", "escapeRegex": false }
  8702. * ]
  8703. * } );
  8704. * } )
  8705. */
  8706. "aoSearchCols": [],
  8707. /**
  8708. * An array of CSS classes that should be applied to displayed rows. This
  8709. * array may be of any length, and DataTables will apply each class
  8710. * sequentially, looping when required.
  8711. * @type array
  8712. * @default null <i>Will take the values determined by the `oClasses.stripe*`
  8713. * options</i>
  8714. *
  8715. * @dtopt Option
  8716. * @name DataTable.defaults.stripeClasses
  8717. *
  8718. * @example
  8719. * $(document).ready( function() {
  8720. * $('#example').dataTable( {
  8721. * "stripeClasses": [ 'strip1', 'strip2', 'strip3' ]
  8722. * } );
  8723. * } )
  8724. */
  8725. "asStripeClasses": null,
  8726. /**
  8727. * Enable or disable automatic column width calculation. This can be disabled
  8728. * as an optimisation (it takes some time to calculate the widths) if the
  8729. * tables widths are passed in using `columns`.
  8730. * @type boolean
  8731. * @default true
  8732. *
  8733. * @dtopt Features
  8734. * @name DataTable.defaults.autoWidth
  8735. *
  8736. * @example
  8737. * $(document).ready( function () {
  8738. * $('#example').dataTable( {
  8739. * "autoWidth": false
  8740. * } );
  8741. * } );
  8742. */
  8743. "bAutoWidth": true,
  8744. /**
  8745. * Deferred rendering can provide DataTables with a huge speed boost when you
  8746. * are using an Ajax or JS data source for the table. This option, when set to
  8747. * true, will cause DataTables to defer the creation of the table elements for
  8748. * each row until they are needed for a draw - saving a significant amount of
  8749. * time.
  8750. * @type boolean
  8751. * @default false
  8752. *
  8753. * @dtopt Features
  8754. * @name DataTable.defaults.deferRender
  8755. *
  8756. * @example
  8757. * $(document).ready( function() {
  8758. * $('#example').dataTable( {
  8759. * "ajax": "sources/arrays.txt",
  8760. * "deferRender": true
  8761. * } );
  8762. * } );
  8763. */
  8764. "bDeferRender": false,
  8765. /**
  8766. * Replace a DataTable which matches the given selector and replace it with
  8767. * one which has the properties of the new initialisation object passed. If no
  8768. * table matches the selector, then the new DataTable will be constructed as
  8769. * per normal.
  8770. * @type boolean
  8771. * @default false
  8772. *
  8773. * @dtopt Options
  8774. * @name DataTable.defaults.destroy
  8775. *
  8776. * @example
  8777. * $(document).ready( function() {
  8778. * $('#example').dataTable( {
  8779. * "srollY": "200px",
  8780. * "paginate": false
  8781. * } );
  8782. *
  8783. * // Some time later....
  8784. * $('#example').dataTable( {
  8785. * "filter": false,
  8786. * "destroy": true
  8787. * } );
  8788. * } );
  8789. */
  8790. "bDestroy": false,
  8791. /**
  8792. * Enable or disable filtering of data. Filtering in DataTables is "smart" in
  8793. * that it allows the end user to input multiple words (space separated) and
  8794. * will match a row containing those words, even if not in the order that was
  8795. * specified (this allow matching across multiple columns). Note that if you
  8796. * wish to use filtering in DataTables this must remain 'true' - to remove the
  8797. * default filtering input box and retain filtering abilities, please use
  8798. * {@link DataTable.defaults.dom}.
  8799. * @type boolean
  8800. * @default true
  8801. *
  8802. * @dtopt Features
  8803. * @name DataTable.defaults.searching
  8804. *
  8805. * @example
  8806. * $(document).ready( function () {
  8807. * $('#example').dataTable( {
  8808. * "searching": false
  8809. * } );
  8810. * } );
  8811. */
  8812. "bFilter": true,
  8813. /**
  8814. * Enable or disable the table information display. This shows information
  8815. * about the data that is currently visible on the page, including information
  8816. * about filtered data if that action is being performed.
  8817. * @type boolean
  8818. * @default true
  8819. *
  8820. * @dtopt Features
  8821. * @name DataTable.defaults.info
  8822. *
  8823. * @example
  8824. * $(document).ready( function () {
  8825. * $('#example').dataTable( {
  8826. * "info": false
  8827. * } );
  8828. * } );
  8829. */
  8830. "bInfo": true,
  8831. /**
  8832. * Enable jQuery UI ThemeRoller support (required as ThemeRoller requires some
  8833. * slightly different and additional mark-up from what DataTables has
  8834. * traditionally used).
  8835. * @type boolean
  8836. * @default false
  8837. *
  8838. * @dtopt Features
  8839. * @name DataTable.defaults.jQueryUI
  8840. *
  8841. * @example
  8842. * $(document).ready( function() {
  8843. * $('#example').dataTable( {
  8844. * "jQueryUI": true
  8845. * } );
  8846. * } );
  8847. */
  8848. "bJQueryUI": false,
  8849. /**
  8850. * Allows the end user to select the size of a formatted page from a select
  8851. * menu (sizes are 10, 25, 50 and 100). Requires pagination (`paginate`).
  8852. * @type boolean
  8853. * @default true
  8854. *
  8855. * @dtopt Features
  8856. * @name DataTable.defaults.lengthChange
  8857. *
  8858. * @example
  8859. * $(document).ready( function () {
  8860. * $('#example').dataTable( {
  8861. * "lengthChange": false
  8862. * } );
  8863. * } );
  8864. */
  8865. "bLengthChange": true,
  8866. /**
  8867. * Enable or disable pagination.
  8868. * @type boolean
  8869. * @default true
  8870. *
  8871. * @dtopt Features
  8872. * @name DataTable.defaults.paging
  8873. *
  8874. * @example
  8875. * $(document).ready( function () {
  8876. * $('#example').dataTable( {
  8877. * "paging": false
  8878. * } );
  8879. * } );
  8880. */
  8881. "bPaginate": true,
  8882. /**
  8883. * Enable or disable the display of a 'processing' indicator when the table is
  8884. * being processed (e.g. a sort). This is particularly useful for tables with
  8885. * large amounts of data where it can take a noticeable amount of time to sort
  8886. * the entries.
  8887. * @type boolean
  8888. * @default false
  8889. *
  8890. * @dtopt Features
  8891. * @name DataTable.defaults.processing
  8892. *
  8893. * @example
  8894. * $(document).ready( function () {
  8895. * $('#example').dataTable( {
  8896. * "processing": true
  8897. * } );
  8898. * } );
  8899. */
  8900. "bProcessing": false,
  8901. /**
  8902. * Retrieve the DataTables object for the given selector. Note that if the
  8903. * table has already been initialised, this parameter will cause DataTables
  8904. * to simply return the object that has already been set up - it will not take
  8905. * account of any changes you might have made to the initialisation object
  8906. * passed to DataTables (setting this parameter to true is an acknowledgement
  8907. * that you understand this). `destroy` can be used to reinitialise a table if
  8908. * you need.
  8909. * @type boolean
  8910. * @default false
  8911. *
  8912. * @dtopt Options
  8913. * @name DataTable.defaults.retrieve
  8914. *
  8915. * @example
  8916. * $(document).ready( function() {
  8917. * initTable();
  8918. * tableActions();
  8919. * } );
  8920. *
  8921. * function initTable ()
  8922. * {
  8923. * return $('#example').dataTable( {
  8924. * "scrollY": "200px",
  8925. * "paginate": false,
  8926. * "retrieve": true
  8927. * } );
  8928. * }
  8929. *
  8930. * function tableActions ()
  8931. * {
  8932. * var table = initTable();
  8933. * // perform API operations with oTable
  8934. * }
  8935. */
  8936. "bRetrieve": false,
  8937. /**
  8938. * When vertical (y) scrolling is enabled, DataTables will force the height of
  8939. * the table's viewport to the given height at all times (useful for layout).
  8940. * However, this can look odd when filtering data down to a small data set,
  8941. * and the footer is left "floating" further down. This parameter (when
  8942. * enabled) will cause DataTables to collapse the table's viewport down when
  8943. * the result set will fit within the given Y height.
  8944. * @type boolean
  8945. * @default false
  8946. *
  8947. * @dtopt Options
  8948. * @name DataTable.defaults.scrollCollapse
  8949. *
  8950. * @example
  8951. * $(document).ready( function() {
  8952. * $('#example').dataTable( {
  8953. * "scrollY": "200",
  8954. * "scrollCollapse": true
  8955. * } );
  8956. * } );
  8957. */
  8958. "bScrollCollapse": false,
  8959. /**
  8960. * Configure DataTables to use server-side processing. Note that the
  8961. * `ajax` parameter must also be given in order to give DataTables a
  8962. * source to obtain the required data for each draw.
  8963. * @type boolean
  8964. * @default false
  8965. *
  8966. * @dtopt Features
  8967. * @dtopt Server-side
  8968. * @name DataTable.defaults.serverSide
  8969. *
  8970. * @example
  8971. * $(document).ready( function () {
  8972. * $('#example').dataTable( {
  8973. * "serverSide": true,
  8974. * "ajax": "xhr.php"
  8975. * } );
  8976. * } );
  8977. */
  8978. "bServerSide": false,
  8979. /**
  8980. * Enable or disable sorting of columns. Sorting of individual columns can be
  8981. * disabled by the `sortable` option for each column.
  8982. * @type boolean
  8983. * @default true
  8984. *
  8985. * @dtopt Features
  8986. * @name DataTable.defaults.ordering
  8987. *
  8988. * @example
  8989. * $(document).ready( function () {
  8990. * $('#example').dataTable( {
  8991. * "ordering": false
  8992. * } );
  8993. * } );
  8994. */
  8995. "bSort": true,
  8996. /**
  8997. * Enable or display DataTables' ability to sort multiple columns at the
  8998. * same time (activated by shift-click by the user).
  8999. * @type boolean
  9000. * @default true
  9001. *
  9002. * @dtopt Options
  9003. * @name DataTable.defaults.orderMulti
  9004. *
  9005. * @example
  9006. * // Disable multiple column sorting ability
  9007. * $(document).ready( function () {
  9008. * $('#example').dataTable( {
  9009. * "orderMulti": false
  9010. * } );
  9011. * } );
  9012. */
  9013. "bSortMulti": true,
  9014. /**
  9015. * Allows control over whether DataTables should use the top (true) unique
  9016. * cell that is found for a single column, or the bottom (false - default).
  9017. * This is useful when using complex headers.
  9018. * @type boolean
  9019. * @default false
  9020. *
  9021. * @dtopt Options
  9022. * @name DataTable.defaults.orderCellsTop
  9023. *
  9024. * @example
  9025. * $(document).ready( function() {
  9026. * $('#example').dataTable( {
  9027. * "orderCellsTop": true
  9028. * } );
  9029. * } );
  9030. */
  9031. "bSortCellsTop": false,
  9032. /**
  9033. * Enable or disable the addition of the classes `sorting\_1`, `sorting\_2` and
  9034. * `sorting\_3` to the columns which are currently being sorted on. This is
  9035. * presented as a feature switch as it can increase processing time (while
  9036. * classes are removed and added) so for large data sets you might want to
  9037. * turn this off.
  9038. * @type boolean
  9039. * @default true
  9040. *
  9041. * @dtopt Features
  9042. * @name DataTable.defaults.orderClasses
  9043. *
  9044. * @example
  9045. * $(document).ready( function () {
  9046. * $('#example').dataTable( {
  9047. * "orderClasses": false
  9048. * } );
  9049. * } );
  9050. */
  9051. "bSortClasses": true,
  9052. /**
  9053. * Enable or disable state saving. When enabled HTML5 `localStorage` will be
  9054. * used to save table display information such as pagination information,
  9055. * display length, filtering and sorting. As such when the end user reloads
  9056. * the page the display display will match what thy had previously set up.
  9057. *
  9058. * Due to the use of `localStorage` the default state saving is not supported
  9059. * in IE6 or 7. If state saving is required in those browsers, use
  9060. * `stateSaveCallback` to provide a storage solution such as cookies.
  9061. * @type boolean
  9062. * @default false
  9063. *
  9064. * @dtopt Features
  9065. * @name DataTable.defaults.stateSave
  9066. *
  9067. * @example
  9068. * $(document).ready( function () {
  9069. * $('#example').dataTable( {
  9070. * "stateSave": true
  9071. * } );
  9072. * } );
  9073. */
  9074. "bStateSave": false,
  9075. /**
  9076. * This function is called when a TR element is created (and all TD child
  9077. * elements have been inserted), or registered if using a DOM source, allowing
  9078. * manipulation of the TR element (adding classes etc).
  9079. * @type function
  9080. * @param {node} row "TR" element for the current row
  9081. * @param {array} data Raw data array for this row
  9082. * @param {int} dataIndex The index of this row in the internal aoData array
  9083. *
  9084. * @dtopt Callbacks
  9085. * @name DataTable.defaults.createdRow
  9086. *
  9087. * @example
  9088. * $(document).ready( function() {
  9089. * $('#example').dataTable( {
  9090. * "createdRow": function( row, data, dataIndex ) {
  9091. * // Bold the grade for all 'A' grade browsers
  9092. * if ( data[4] == "A" )
  9093. * {
  9094. * $('td:eq(4)', row).html( '<b>A</b>' );
  9095. * }
  9096. * }
  9097. * } );
  9098. * } );
  9099. */
  9100. "fnCreatedRow": null,
  9101. /**
  9102. * This function is called on every 'draw' event, and allows you to
  9103. * dynamically modify any aspect you want about the created DOM.
  9104. * @type function
  9105. * @param {object} settings DataTables settings object
  9106. *
  9107. * @dtopt Callbacks
  9108. * @name DataTable.defaults.drawCallback
  9109. *
  9110. * @example
  9111. * $(document).ready( function() {
  9112. * $('#example').dataTable( {
  9113. * "drawCallback": function( settings ) {
  9114. * alert( 'DataTables has redrawn the table' );
  9115. * }
  9116. * } );
  9117. * } );
  9118. */
  9119. "fnDrawCallback": null,
  9120. /**
  9121. * Identical to fnHeaderCallback() but for the table footer this function
  9122. * allows you to modify the table footer on every 'draw' event.
  9123. * @type function
  9124. * @param {node} foot "TR" element for the footer
  9125. * @param {array} data Full table data (as derived from the original HTML)
  9126. * @param {int} start Index for the current display starting point in the
  9127. * display array
  9128. * @param {int} end Index for the current display ending point in the
  9129. * display array
  9130. * @param {array int} display Index array to translate the visual position
  9131. * to the full data array
  9132. *
  9133. * @dtopt Callbacks
  9134. * @name DataTable.defaults.footerCallback
  9135. *
  9136. * @example
  9137. * $(document).ready( function() {
  9138. * $('#example').dataTable( {
  9139. * "footerCallback": function( tfoot, data, start, end, display ) {
  9140. * tfoot.getElementsByTagName('th')[0].innerHTML = "Starting index is "+start;
  9141. * }
  9142. * } );
  9143. * } )
  9144. */
  9145. "fnFooterCallback": null,
  9146. /**
  9147. * When rendering large numbers in the information element for the table
  9148. * (i.e. "Showing 1 to 10 of 57 entries") DataTables will render large numbers
  9149. * to have a comma separator for the 'thousands' units (e.g. 1 million is
  9150. * rendered as "1,000,000") to help readability for the end user. This
  9151. * function will override the default method DataTables uses.
  9152. * @type function
  9153. * @member
  9154. * @param {int} toFormat number to be formatted
  9155. * @returns {string} formatted string for DataTables to show the number
  9156. *
  9157. * @dtopt Callbacks
  9158. * @name DataTable.defaults.formatNumber
  9159. *
  9160. * @example
  9161. * // Format a number using a single quote for the separator (note that
  9162. * // this can also be done with the language.thousands option)
  9163. * $(document).ready( function() {
  9164. * $('#example').dataTable( {
  9165. * "formatNumber": function ( toFormat ) {
  9166. * return toFormat.toString().replace(
  9167. * /\B(?=(\d{3})+(?!\d))/g, "'"
  9168. * );
  9169. * };
  9170. * } );
  9171. * } );
  9172. */
  9173. "fnFormatNumber": function ( toFormat ) {
  9174. return toFormat.toString().replace(
  9175. /\B(?=(\d{3})+(?!\d))/g,
  9176. this.oLanguage.sThousands
  9177. );
  9178. },
  9179. /**
  9180. * This function is called on every 'draw' event, and allows you to
  9181. * dynamically modify the header row. This can be used to calculate and
  9182. * display useful information about the table.
  9183. * @type function
  9184. * @param {node} head "TR" element for the header
  9185. * @param {array} data Full table data (as derived from the original HTML)
  9186. * @param {int} start Index for the current display starting point in the
  9187. * display array
  9188. * @param {int} end Index for the current display ending point in the
  9189. * display array
  9190. * @param {array int} display Index array to translate the visual position
  9191. * to the full data array
  9192. *
  9193. * @dtopt Callbacks
  9194. * @name DataTable.defaults.headerCallback
  9195. *
  9196. * @example
  9197. * $(document).ready( function() {
  9198. * $('#example').dataTable( {
  9199. * "fheaderCallback": function( head, data, start, end, display ) {
  9200. * head.getElementsByTagName('th')[0].innerHTML = "Displaying "+(end-start)+" records";
  9201. * }
  9202. * } );
  9203. * } )
  9204. */
  9205. "fnHeaderCallback": null,
  9206. /**
  9207. * The information element can be used to convey information about the current
  9208. * state of the table. Although the internationalisation options presented by
  9209. * DataTables are quite capable of dealing with most customisations, there may
  9210. * be times where you wish to customise the string further. This callback
  9211. * allows you to do exactly that.
  9212. * @type function
  9213. * @param {object} oSettings DataTables settings object
  9214. * @param {int} start Starting position in data for the draw
  9215. * @param {int} end End position in data for the draw
  9216. * @param {int} max Total number of rows in the table (regardless of
  9217. * filtering)
  9218. * @param {int} total Total number of rows in the data set, after filtering
  9219. * @param {string} pre The string that DataTables has formatted using it's
  9220. * own rules
  9221. * @returns {string} The string to be displayed in the information element.
  9222. *
  9223. * @dtopt Callbacks
  9224. * @name DataTable.defaults.infoCallback
  9225. *
  9226. * @example
  9227. * $('#example').dataTable( {
  9228. * "infoCallback": function( settings, start, end, max, total, pre ) {
  9229. * return start +" to "+ end;
  9230. * }
  9231. * } );
  9232. */
  9233. "fnInfoCallback": null,
  9234. /**
  9235. * Called when the table has been initialised. Normally DataTables will
  9236. * initialise sequentially and there will be no need for this function,
  9237. * however, this does not hold true when using external language information
  9238. * since that is obtained using an async XHR call.
  9239. * @type function
  9240. * @param {object} settings DataTables settings object
  9241. * @param {object} json The JSON object request from the server - only
  9242. * present if client-side Ajax sourced data is used
  9243. *
  9244. * @dtopt Callbacks
  9245. * @name DataTable.defaults.initComplete
  9246. *
  9247. * @example
  9248. * $(document).ready( function() {
  9249. * $('#example').dataTable( {
  9250. * "initComplete": function(settings, json) {
  9251. * alert( 'DataTables has finished its initialisation.' );
  9252. * }
  9253. * } );
  9254. * } )
  9255. */
  9256. "fnInitComplete": null,
  9257. /**
  9258. * Called at the very start of each table draw and can be used to cancel the
  9259. * draw by returning false, any other return (including undefined) results in
  9260. * the full draw occurring).
  9261. * @type function
  9262. * @param {object} settings DataTables settings object
  9263. * @returns {boolean} False will cancel the draw, anything else (including no
  9264. * return) will allow it to complete.
  9265. *
  9266. * @dtopt Callbacks
  9267. * @name DataTable.defaults.preDrawCallback
  9268. *
  9269. * @example
  9270. * $(document).ready( function() {
  9271. * $('#example').dataTable( {
  9272. * "preDrawCallback": function( settings ) {
  9273. * if ( $('#test').val() == 1 ) {
  9274. * return false;
  9275. * }
  9276. * }
  9277. * } );
  9278. * } );
  9279. */
  9280. "fnPreDrawCallback": null,
  9281. /**
  9282. * This function allows you to 'post process' each row after it have been
  9283. * generated for each table draw, but before it is rendered on screen. This
  9284. * function might be used for setting the row class name etc.
  9285. * @type function
  9286. * @param {node} row "TR" element for the current row
  9287. * @param {array} data Raw data array for this row
  9288. * @param {int} displayIndex The display index for the current table draw
  9289. * @param {int} displayIndexFull The index of the data in the full list of
  9290. * rows (after filtering)
  9291. *
  9292. * @dtopt Callbacks
  9293. * @name DataTable.defaults.rowCallback
  9294. *
  9295. * @example
  9296. * $(document).ready( function() {
  9297. * $('#example').dataTable( {
  9298. * "rowCallback": function( row, data, displayIndex, displayIndexFull ) {
  9299. * // Bold the grade for all 'A' grade browsers
  9300. * if ( data[4] == "A" ) {
  9301. * $('td:eq(4)', row).html( '<b>A</b>' );
  9302. * }
  9303. * }
  9304. * } );
  9305. * } );
  9306. */
  9307. "fnRowCallback": null,
  9308. /**
  9309. * __Deprecated__ The functionality provided by this parameter has now been
  9310. * superseded by that provided through `ajax`, which should be used instead.
  9311. *
  9312. * This parameter allows you to override the default function which obtains
  9313. * the data from the server so something more suitable for your application.
  9314. * For example you could use POST data, or pull information from a Gears or
  9315. * AIR database.
  9316. * @type function
  9317. * @member
  9318. * @param {string} source HTTP source to obtain the data from (`ajax`)
  9319. * @param {array} data A key/value pair object containing the data to send
  9320. * to the server
  9321. * @param {function} callback to be called on completion of the data get
  9322. * process that will draw the data on the page.
  9323. * @param {object} settings DataTables settings object
  9324. *
  9325. * @dtopt Callbacks
  9326. * @dtopt Server-side
  9327. * @name DataTable.defaults.serverData
  9328. *
  9329. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9330. */
  9331. "fnServerData": null,
  9332. /**
  9333. * __Deprecated__ The functionality provided by this parameter has now been
  9334. * superseded by that provided through `ajax`, which should be used instead.
  9335. *
  9336. * It is often useful to send extra data to the server when making an Ajax
  9337. * request - for example custom filtering information, and this callback
  9338. * function makes it trivial to send extra information to the server. The
  9339. * passed in parameter is the data set that has been constructed by
  9340. * DataTables, and you can add to this or modify it as you require.
  9341. * @type function
  9342. * @param {array} data Data array (array of objects which are name/value
  9343. * pairs) that has been constructed by DataTables and will be sent to the
  9344. * server. In the case of Ajax sourced data with server-side processing
  9345. * this will be an empty array, for server-side processing there will be a
  9346. * significant number of parameters!
  9347. * @returns {undefined} Ensure that you modify the data array passed in,
  9348. * as this is passed by reference.
  9349. *
  9350. * @dtopt Callbacks
  9351. * @dtopt Server-side
  9352. * @name DataTable.defaults.serverParams
  9353. *
  9354. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9355. */
  9356. "fnServerParams": null,
  9357. /**
  9358. * Load the table state. With this function you can define from where, and how, the
  9359. * state of a table is loaded. By default DataTables will load from `localStorage`
  9360. * but you might wish to use a server-side database or cookies.
  9361. * @type function
  9362. * @member
  9363. * @param {object} settings DataTables settings object
  9364. * @param {object} callback Callback that can be executed when done. It
  9365. * should be passed the loaded state object.
  9366. * @return {object} The DataTables state object to be loaded
  9367. *
  9368. * @dtopt Callbacks
  9369. * @name DataTable.defaults.stateLoadCallback
  9370. *
  9371. * @example
  9372. * $(document).ready( function() {
  9373. * $('#example').dataTable( {
  9374. * "stateSave": true,
  9375. * "stateLoadCallback": function (settings, callback) {
  9376. * $.ajax( {
  9377. * "url": "/state_load",
  9378. * "dataType": "json",
  9379. * "success": function (json) {
  9380. * callback( json );
  9381. * }
  9382. * } );
  9383. * }
  9384. * } );
  9385. * } );
  9386. */
  9387. "fnStateLoadCallback": function ( settings ) {
  9388. try {
  9389. return JSON.parse(
  9390. (settings.iStateDuration === -1 ? sessionStorage : localStorage).getItem(
  9391. 'DataTables_'+settings.sInstance+'_'+location.pathname
  9392. )
  9393. );
  9394. } catch (e) {}
  9395. },
  9396. /**
  9397. * Callback which allows modification of the saved state prior to loading that state.
  9398. * This callback is called when the table is loading state from the stored data, but
  9399. * prior to the settings object being modified by the saved state. Note that for
  9400. * plug-in authors, you should use the `stateLoadParams` event to load parameters for
  9401. * a plug-in.
  9402. * @type function
  9403. * @param {object} settings DataTables settings object
  9404. * @param {object} data The state object that is to be loaded
  9405. *
  9406. * @dtopt Callbacks
  9407. * @name DataTable.defaults.stateLoadParams
  9408. *
  9409. * @example
  9410. * // Remove a saved filter, so filtering is never loaded
  9411. * $(document).ready( function() {
  9412. * $('#example').dataTable( {
  9413. * "stateSave": true,
  9414. * "stateLoadParams": function (settings, data) {
  9415. * data.oSearch.sSearch = "";
  9416. * }
  9417. * } );
  9418. * } );
  9419. *
  9420. * @example
  9421. * // Disallow state loading by returning false
  9422. * $(document).ready( function() {
  9423. * $('#example').dataTable( {
  9424. * "stateSave": true,
  9425. * "stateLoadParams": function (settings, data) {
  9426. * return false;
  9427. * }
  9428. * } );
  9429. * } );
  9430. */
  9431. "fnStateLoadParams": null,
  9432. /**
  9433. * Callback that is called when the state has been loaded from the state saving method
  9434. * and the DataTables settings object has been modified as a result of the loaded state.
  9435. * @type function
  9436. * @param {object} settings DataTables settings object
  9437. * @param {object} data The state object that was loaded
  9438. *
  9439. * @dtopt Callbacks
  9440. * @name DataTable.defaults.stateLoaded
  9441. *
  9442. * @example
  9443. * // Show an alert with the filtering value that was saved
  9444. * $(document).ready( function() {
  9445. * $('#example').dataTable( {
  9446. * "stateSave": true,
  9447. * "stateLoaded": function (settings, data) {
  9448. * alert( 'Saved filter was: '+data.oSearch.sSearch );
  9449. * }
  9450. * } );
  9451. * } );
  9452. */
  9453. "fnStateLoaded": null,
  9454. /**
  9455. * Save the table state. This function allows you to define where and how the state
  9456. * information for the table is stored By default DataTables will use `localStorage`
  9457. * but you might wish to use a server-side database or cookies.
  9458. * @type function
  9459. * @member
  9460. * @param {object} settings DataTables settings object
  9461. * @param {object} data The state object to be saved
  9462. *
  9463. * @dtopt Callbacks
  9464. * @name DataTable.defaults.stateSaveCallback
  9465. *
  9466. * @example
  9467. * $(document).ready( function() {
  9468. * $('#example').dataTable( {
  9469. * "stateSave": true,
  9470. * "stateSaveCallback": function (settings, data) {
  9471. * // Send an Ajax request to the server with the state object
  9472. * $.ajax( {
  9473. * "url": "/state_save",
  9474. * "data": data,
  9475. * "dataType": "json",
  9476. * "method": "POST"
  9477. * "success": function () {}
  9478. * } );
  9479. * }
  9480. * } );
  9481. * } );
  9482. */
  9483. "fnStateSaveCallback": function ( settings, data ) {
  9484. try {
  9485. (settings.iStateDuration === -1 ? sessionStorage : localStorage).setItem(
  9486. 'DataTables_'+settings.sInstance+'_'+location.pathname,
  9487. JSON.stringify( data )
  9488. );
  9489. } catch (e) {}
  9490. },
  9491. /**
  9492. * Callback which allows modification of the state to be saved. Called when the table
  9493. * has changed state a new state save is required. This method allows modification of
  9494. * the state saving object prior to actually doing the save, including addition or
  9495. * other state properties or modification. Note that for plug-in authors, you should
  9496. * use the `stateSaveParams` event to save parameters for a plug-in.
  9497. * @type function
  9498. * @param {object} settings DataTables settings object
  9499. * @param {object} data The state object to be saved
  9500. *
  9501. * @dtopt Callbacks
  9502. * @name DataTable.defaults.stateSaveParams
  9503. *
  9504. * @example
  9505. * // Remove a saved filter, so filtering is never saved
  9506. * $(document).ready( function() {
  9507. * $('#example').dataTable( {
  9508. * "stateSave": true,
  9509. * "stateSaveParams": function (settings, data) {
  9510. * data.oSearch.sSearch = "";
  9511. * }
  9512. * } );
  9513. * } );
  9514. */
  9515. "fnStateSaveParams": null,
  9516. /**
  9517. * Duration for which the saved state information is considered valid. After this period
  9518. * has elapsed the state will be returned to the default.
  9519. * Value is given in seconds.
  9520. * @type int
  9521. * @default 7200 <i>(2 hours)</i>
  9522. *
  9523. * @dtopt Options
  9524. * @name DataTable.defaults.stateDuration
  9525. *
  9526. * @example
  9527. * $(document).ready( function() {
  9528. * $('#example').dataTable( {
  9529. * "stateDuration": 60*60*24; // 1 day
  9530. * } );
  9531. * } )
  9532. */
  9533. "iStateDuration": 7200,
  9534. /**
  9535. * When enabled DataTables will not make a request to the server for the first
  9536. * page draw - rather it will use the data already on the page (no sorting etc
  9537. * will be applied to it), thus saving on an XHR at load time. `deferLoading`
  9538. * is used to indicate that deferred loading is required, but it is also used
  9539. * to tell DataTables how many records there are in the full table (allowing
  9540. * the information element and pagination to be displayed correctly). In the case
  9541. * where a filtering is applied to the table on initial load, this can be
  9542. * indicated by giving the parameter as an array, where the first element is
  9543. * the number of records available after filtering and the second element is the
  9544. * number of records without filtering (allowing the table information element
  9545. * to be shown correctly).
  9546. * @type int | array
  9547. * @default null
  9548. *
  9549. * @dtopt Options
  9550. * @name DataTable.defaults.deferLoading
  9551. *
  9552. * @example
  9553. * // 57 records available in the table, no filtering applied
  9554. * $(document).ready( function() {
  9555. * $('#example').dataTable( {
  9556. * "serverSide": true,
  9557. * "ajax": "scripts/server_processing.php",
  9558. * "deferLoading": 57
  9559. * } );
  9560. * } );
  9561. *
  9562. * @example
  9563. * // 57 records after filtering, 100 without filtering (an initial filter applied)
  9564. * $(document).ready( function() {
  9565. * $('#example').dataTable( {
  9566. * "serverSide": true,
  9567. * "ajax": "scripts/server_processing.php",
  9568. * "deferLoading": [ 57, 100 ],
  9569. * "search": {
  9570. * "search": "my_filter"
  9571. * }
  9572. * } );
  9573. * } );
  9574. */
  9575. "iDeferLoading": null,
  9576. /**
  9577. * Number of rows to display on a single page when using pagination. If
  9578. * feature enabled (`lengthChange`) then the end user will be able to override
  9579. * this to a custom setting using a pop-up menu.
  9580. * @type int
  9581. * @default 10
  9582. *
  9583. * @dtopt Options
  9584. * @name DataTable.defaults.pageLength
  9585. *
  9586. * @example
  9587. * $(document).ready( function() {
  9588. * $('#example').dataTable( {
  9589. * "pageLength": 50
  9590. * } );
  9591. * } )
  9592. */
  9593. "iDisplayLength": 10,
  9594. /**
  9595. * Define the starting point for data display when using DataTables with
  9596. * pagination. Note that this parameter is the number of records, rather than
  9597. * the page number, so if you have 10 records per page and want to start on
  9598. * the third page, it should be "20".
  9599. * @type int
  9600. * @default 0
  9601. *
  9602. * @dtopt Options
  9603. * @name DataTable.defaults.displayStart
  9604. *
  9605. * @example
  9606. * $(document).ready( function() {
  9607. * $('#example').dataTable( {
  9608. * "displayStart": 20
  9609. * } );
  9610. * } )
  9611. */
  9612. "iDisplayStart": 0,
  9613. /**
  9614. * By default DataTables allows keyboard navigation of the table (sorting, paging,
  9615. * and filtering) by adding a `tabindex` attribute to the required elements. This
  9616. * allows you to tab through the controls and press the enter key to activate them.
  9617. * The tabindex is default 0, meaning that the tab follows the flow of the document.
  9618. * You can overrule this using this parameter if you wish. Use a value of -1 to
  9619. * disable built-in keyboard navigation.
  9620. * @type int
  9621. * @default 0
  9622. *
  9623. * @dtopt Options
  9624. * @name DataTable.defaults.tabIndex
  9625. *
  9626. * @example
  9627. * $(document).ready( function() {
  9628. * $('#example').dataTable( {
  9629. * "tabIndex": 1
  9630. * } );
  9631. * } );
  9632. */
  9633. "iTabIndex": 0,
  9634. /**
  9635. * Classes that DataTables assigns to the various components and features
  9636. * that it adds to the HTML table. This allows classes to be configured
  9637. * during initialisation in addition to through the static
  9638. * {@link DataTable.ext.oStdClasses} object).
  9639. * @namespace
  9640. * @name DataTable.defaults.classes
  9641. */
  9642. "oClasses": {},
  9643. /**
  9644. * All strings that DataTables uses in the user interface that it creates
  9645. * are defined in this object, allowing you to modified them individually or
  9646. * completely replace them all as required.
  9647. * @namespace
  9648. * @name DataTable.defaults.language
  9649. */
  9650. "oLanguage": {
  9651. /**
  9652. * Strings that are used for WAI-ARIA labels and controls only (these are not
  9653. * actually visible on the page, but will be read by screenreaders, and thus
  9654. * must be internationalised as well).
  9655. * @namespace
  9656. * @name DataTable.defaults.language.aria
  9657. */
  9658. "oAria": {
  9659. /**
  9660. * ARIA label that is added to the table headers when the column may be
  9661. * sorted ascending by activing the column (click or return when focused).
  9662. * Note that the column header is prefixed to this string.
  9663. * @type string
  9664. * @default : activate to sort column ascending
  9665. *
  9666. * @dtopt Language
  9667. * @name DataTable.defaults.language.aria.sortAscending
  9668. *
  9669. * @example
  9670. * $(document).ready( function() {
  9671. * $('#example').dataTable( {
  9672. * "language": {
  9673. * "aria": {
  9674. * "sortAscending": " - click/return to sort ascending"
  9675. * }
  9676. * }
  9677. * } );
  9678. * } );
  9679. */
  9680. "sSortAscending": ": activate to sort column ascending",
  9681. /**
  9682. * ARIA label that is added to the table headers when the column may be
  9683. * sorted descending by activing the column (click or return when focused).
  9684. * Note that the column header is prefixed to this string.
  9685. * @type string
  9686. * @default : activate to sort column ascending
  9687. *
  9688. * @dtopt Language
  9689. * @name DataTable.defaults.language.aria.sortDescending
  9690. *
  9691. * @example
  9692. * $(document).ready( function() {
  9693. * $('#example').dataTable( {
  9694. * "language": {
  9695. * "aria": {
  9696. * "sortDescending": " - click/return to sort descending"
  9697. * }
  9698. * }
  9699. * } );
  9700. * } );
  9701. */
  9702. "sSortDescending": ": activate to sort column descending"
  9703. },
  9704. /**
  9705. * Pagination string used by DataTables for the built-in pagination
  9706. * control types.
  9707. * @namespace
  9708. * @name DataTable.defaults.language.paginate
  9709. */
  9710. "oPaginate": {
  9711. /**
  9712. * Text to use when using the 'full_numbers' type of pagination for the
  9713. * button to take the user to the first page.
  9714. * @type string
  9715. * @default First
  9716. *
  9717. * @dtopt Language
  9718. * @name DataTable.defaults.language.paginate.first
  9719. *
  9720. * @example
  9721. * $(document).ready( function() {
  9722. * $('#example').dataTable( {
  9723. * "language": {
  9724. * "paginate": {
  9725. * "first": "First page"
  9726. * }
  9727. * }
  9728. * } );
  9729. * } );
  9730. */
  9731. "sFirst": "First",
  9732. /**
  9733. * Text to use when using the 'full_numbers' type of pagination for the
  9734. * button to take the user to the last page.
  9735. * @type string
  9736. * @default Last
  9737. *
  9738. * @dtopt Language
  9739. * @name DataTable.defaults.language.paginate.last
  9740. *
  9741. * @example
  9742. * $(document).ready( function() {
  9743. * $('#example').dataTable( {
  9744. * "language": {
  9745. * "paginate": {
  9746. * "last": "Last page"
  9747. * }
  9748. * }
  9749. * } );
  9750. * } );
  9751. */
  9752. "sLast": "Last",
  9753. /**
  9754. * Text to use for the 'next' pagination button (to take the user to the
  9755. * next page).
  9756. * @type string
  9757. * @default Next
  9758. *
  9759. * @dtopt Language
  9760. * @name DataTable.defaults.language.paginate.next
  9761. *
  9762. * @example
  9763. * $(document).ready( function() {
  9764. * $('#example').dataTable( {
  9765. * "language": {
  9766. * "paginate": {
  9767. * "next": "Next page"
  9768. * }
  9769. * }
  9770. * } );
  9771. * } );
  9772. */
  9773. "sNext": "Next",
  9774. /**
  9775. * Text to use for the 'previous' pagination button (to take the user to
  9776. * the previous page).
  9777. * @type string
  9778. * @default Previous
  9779. *
  9780. * @dtopt Language
  9781. * @name DataTable.defaults.language.paginate.previous
  9782. *
  9783. * @example
  9784. * $(document).ready( function() {
  9785. * $('#example').dataTable( {
  9786. * "language": {
  9787. * "paginate": {
  9788. * "previous": "Previous page"
  9789. * }
  9790. * }
  9791. * } );
  9792. * } );
  9793. */
  9794. "sPrevious": "Previous"
  9795. },
  9796. /**
  9797. * This string is shown in preference to `zeroRecords` when the table is
  9798. * empty of data (regardless of filtering). Note that this is an optional
  9799. * parameter - if it is not given, the value of `zeroRecords` will be used
  9800. * instead (either the default or given value).
  9801. * @type string
  9802. * @default No data available in table
  9803. *
  9804. * @dtopt Language
  9805. * @name DataTable.defaults.language.emptyTable
  9806. *
  9807. * @example
  9808. * $(document).ready( function() {
  9809. * $('#example').dataTable( {
  9810. * "language": {
  9811. * "emptyTable": "No data available in table"
  9812. * }
  9813. * } );
  9814. * } );
  9815. */
  9816. "sEmptyTable": "No data available in table",
  9817. /**
  9818. * This string gives information to the end user about the information
  9819. * that is current on display on the page. The following tokens can be
  9820. * used in the string and will be dynamically replaced as the table
  9821. * display updates. This tokens can be placed anywhere in the string, or
  9822. * removed as needed by the language requires:
  9823. *
  9824. * * `\_START\_` - Display index of the first record on the current page
  9825. * * `\_END\_` - Display index of the last record on the current page
  9826. * * `\_TOTAL\_` - Number of records in the table after filtering
  9827. * * `\_MAX\_` - Number of records in the table without filtering
  9828. * * `\_PAGE\_` - Current page number
  9829. * * `\_PAGES\_` - Total number of pages of data in the table
  9830. *
  9831. * @type string
  9832. * @default Showing _START_ to _END_ of _TOTAL_ entries
  9833. *
  9834. * @dtopt Language
  9835. * @name DataTable.defaults.language.info
  9836. *
  9837. * @example
  9838. * $(document).ready( function() {
  9839. * $('#example').dataTable( {
  9840. * "language": {
  9841. * "info": "Showing page _PAGE_ of _PAGES_"
  9842. * }
  9843. * } );
  9844. * } );
  9845. */
  9846. "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
  9847. /**
  9848. * Display information string for when the table is empty. Typically the
  9849. * format of this string should match `info`.
  9850. * @type string
  9851. * @default Showing 0 to 0 of 0 entries
  9852. *
  9853. * @dtopt Language
  9854. * @name DataTable.defaults.language.infoEmpty
  9855. *
  9856. * @example
  9857. * $(document).ready( function() {
  9858. * $('#example').dataTable( {
  9859. * "language": {
  9860. * "infoEmpty": "No entries to show"
  9861. * }
  9862. * } );
  9863. * } );
  9864. */
  9865. "sInfoEmpty": "Showing 0 to 0 of 0 entries",
  9866. /**
  9867. * When a user filters the information in a table, this string is appended
  9868. * to the information (`info`) to give an idea of how strong the filtering
  9869. * is. The variable _MAX_ is dynamically updated.
  9870. * @type string
  9871. * @default (filtered from _MAX_ total entries)
  9872. *
  9873. * @dtopt Language
  9874. * @name DataTable.defaults.language.infoFiltered
  9875. *
  9876. * @example
  9877. * $(document).ready( function() {
  9878. * $('#example').dataTable( {
  9879. * "language": {
  9880. * "infoFiltered": " - filtering from _MAX_ records"
  9881. * }
  9882. * } );
  9883. * } );
  9884. */
  9885. "sInfoFiltered": "(filtered from _MAX_ total entries)",
  9886. /**
  9887. * If can be useful to append extra information to the info string at times,
  9888. * and this variable does exactly that. This information will be appended to
  9889. * the `info` (`infoEmpty` and `infoFiltered` in whatever combination they are
  9890. * being used) at all times.
  9891. * @type string
  9892. * @default <i>Empty string</i>
  9893. *
  9894. * @dtopt Language
  9895. * @name DataTable.defaults.language.infoPostFix
  9896. *
  9897. * @example
  9898. * $(document).ready( function() {
  9899. * $('#example').dataTable( {
  9900. * "language": {
  9901. * "infoPostFix": "All records shown are derived from real information."
  9902. * }
  9903. * } );
  9904. * } );
  9905. */
  9906. "sInfoPostFix": "",
  9907. /**
  9908. * This decimal place operator is a little different from the other
  9909. * language options since DataTables doesn't output floating point
  9910. * numbers, so it won't ever use this for display of a number. Rather,
  9911. * what this parameter does is modify the sort methods of the table so
  9912. * that numbers which are in a format which has a character other than
  9913. * a period (`.`) as a decimal place will be sorted numerically.
  9914. *
  9915. * Note that numbers with different decimal places cannot be shown in
  9916. * the same table and still be sortable, the table must be consistent.
  9917. * However, multiple different tables on the page can use different
  9918. * decimal place characters.
  9919. * @type string
  9920. * @default
  9921. *
  9922. * @dtopt Language
  9923. * @name DataTable.defaults.language.decimal
  9924. *
  9925. * @example
  9926. * $(document).ready( function() {
  9927. * $('#example').dataTable( {
  9928. * "language": {
  9929. * "decimal": ","
  9930. * "thousands": "."
  9931. * }
  9932. * } );
  9933. * } );
  9934. */
  9935. "sDecimal": "",
  9936. /**
  9937. * DataTables has a build in number formatter (`formatNumber`) which is
  9938. * used to format large numbers that are used in the table information.
  9939. * By default a comma is used, but this can be trivially changed to any
  9940. * character you wish with this parameter.
  9941. * @type string
  9942. * @default ,
  9943. *
  9944. * @dtopt Language
  9945. * @name DataTable.defaults.language.thousands
  9946. *
  9947. * @example
  9948. * $(document).ready( function() {
  9949. * $('#example').dataTable( {
  9950. * "language": {
  9951. * "thousands": "'"
  9952. * }
  9953. * } );
  9954. * } );
  9955. */
  9956. "sThousands": ",",
  9957. /**
  9958. * Detail the action that will be taken when the drop down menu for the
  9959. * pagination length option is changed. The '_MENU_' variable is replaced
  9960. * with a default select list of 10, 25, 50 and 100, and can be replaced
  9961. * with a custom select box if required.
  9962. * @type string
  9963. * @default Show _MENU_ entries
  9964. *
  9965. * @dtopt Language
  9966. * @name DataTable.defaults.language.lengthMenu
  9967. *
  9968. * @example
  9969. * // Language change only
  9970. * $(document).ready( function() {
  9971. * $('#example').dataTable( {
  9972. * "language": {
  9973. * "lengthMenu": "Display _MENU_ records"
  9974. * }
  9975. * } );
  9976. * } );
  9977. *
  9978. * @example
  9979. * // Language and options change
  9980. * $(document).ready( function() {
  9981. * $('#example').dataTable( {
  9982. * "language": {
  9983. * "lengthMenu": 'Display <select>'+
  9984. * '<option value="10">10</option>'+
  9985. * '<option value="20">20</option>'+
  9986. * '<option value="30">30</option>'+
  9987. * '<option value="40">40</option>'+
  9988. * '<option value="50">50</option>'+
  9989. * '<option value="-1">All</option>'+
  9990. * '</select> records'
  9991. * }
  9992. * } );
  9993. * } );
  9994. */
  9995. "sLengthMenu": "Show _MENU_ entries",
  9996. /**
  9997. * When using Ajax sourced data and during the first draw when DataTables is
  9998. * gathering the data, this message is shown in an empty row in the table to
  9999. * indicate to the end user the the data is being loaded. Note that this
  10000. * parameter is not used when loading data by server-side processing, just
  10001. * Ajax sourced data with client-side processing.
  10002. * @type string
  10003. * @default Loading...
  10004. *
  10005. * @dtopt Language
  10006. * @name DataTable.defaults.language.loadingRecords
  10007. *
  10008. * @example
  10009. * $(document).ready( function() {
  10010. * $('#example').dataTable( {
  10011. * "language": {
  10012. * "loadingRecords": "Please wait - loading..."
  10013. * }
  10014. * } );
  10015. * } );
  10016. */
  10017. "sLoadingRecords": "Loading...",
  10018. /**
  10019. * Text which is displayed when the table is processing a user action
  10020. * (usually a sort command or similar).
  10021. * @type string
  10022. * @default Processing...
  10023. *
  10024. * @dtopt Language
  10025. * @name DataTable.defaults.language.processing
  10026. *
  10027. * @example
  10028. * $(document).ready( function() {
  10029. * $('#example').dataTable( {
  10030. * "language": {
  10031. * "processing": "DataTables is currently busy"
  10032. * }
  10033. * } );
  10034. * } );
  10035. */
  10036. "sProcessing": "Processing...",
  10037. /**
  10038. * Details the actions that will be taken when the user types into the
  10039. * filtering input text box. The variable "_INPUT_", if used in the string,
  10040. * is replaced with the HTML text box for the filtering input allowing
  10041. * control over where it appears in the string. If "_INPUT_" is not given
  10042. * then the input box is appended to the string automatically.
  10043. * @type string
  10044. * @default Search:
  10045. *
  10046. * @dtopt Language
  10047. * @name DataTable.defaults.language.search
  10048. *
  10049. * @example
  10050. * // Input text box will be appended at the end automatically
  10051. * $(document).ready( function() {
  10052. * $('#example').dataTable( {
  10053. * "language": {
  10054. * "search": "Filter records:"
  10055. * }
  10056. * } );
  10057. * } );
  10058. *
  10059. * @example
  10060. * // Specify where the filter should appear
  10061. * $(document).ready( function() {
  10062. * $('#example').dataTable( {
  10063. * "language": {
  10064. * "search": "Apply filter _INPUT_ to table"
  10065. * }
  10066. * } );
  10067. * } );
  10068. */
  10069. "sSearch": "Search:",
  10070. /**
  10071. * Assign a `placeholder` attribute to the search `input` element
  10072. * @type string
  10073. * @default
  10074. *
  10075. * @dtopt Language
  10076. * @name DataTable.defaults.language.searchPlaceholder
  10077. */
  10078. "sSearchPlaceholder": "",
  10079. /**
  10080. * All of the language information can be stored in a file on the
  10081. * server-side, which DataTables will look up if this parameter is passed.
  10082. * It must store the URL of the language file, which is in a JSON format,
  10083. * and the object has the same properties as the oLanguage object in the
  10084. * initialiser object (i.e. the above parameters). Please refer to one of
  10085. * the example language files to see how this works in action.
  10086. * @type string
  10087. * @default <i>Empty string - i.e. disabled</i>
  10088. *
  10089. * @dtopt Language
  10090. * @name DataTable.defaults.language.url
  10091. *
  10092. * @example
  10093. * $(document).ready( function() {
  10094. * $('#example').dataTable( {
  10095. * "language": {
  10096. * "url": "http://www.sprymedia.co.uk/dataTables/lang.txt"
  10097. * }
  10098. * } );
  10099. * } );
  10100. */
  10101. "sUrl": "",
  10102. /**
  10103. * Text shown inside the table records when the is no information to be
  10104. * displayed after filtering. `emptyTable` is shown when there is simply no
  10105. * information in the table at all (regardless of filtering).
  10106. * @type string
  10107. * @default No matching records found
  10108. *
  10109. * @dtopt Language
  10110. * @name DataTable.defaults.language.zeroRecords
  10111. *
  10112. * @example
  10113. * $(document).ready( function() {
  10114. * $('#example').dataTable( {
  10115. * "language": {
  10116. * "zeroRecords": "No records to display"
  10117. * }
  10118. * } );
  10119. * } );
  10120. */
  10121. "sZeroRecords": "No matching records found"
  10122. },
  10123. /**
  10124. * This parameter allows you to have define the global filtering state at
  10125. * initialisation time. As an object the `search` parameter must be
  10126. * defined, but all other parameters are optional. When `regex` is true,
  10127. * the search string will be treated as a regular expression, when false
  10128. * (default) it will be treated as a straight string. When `smart`
  10129. * DataTables will use it's smart filtering methods (to word match at
  10130. * any point in the data), when false this will not be done.
  10131. * @namespace
  10132. * @extends DataTable.models.oSearch
  10133. *
  10134. * @dtopt Options
  10135. * @name DataTable.defaults.search
  10136. *
  10137. * @example
  10138. * $(document).ready( function() {
  10139. * $('#example').dataTable( {
  10140. * "search": {"search": "Initial search"}
  10141. * } );
  10142. * } )
  10143. */
  10144. "oSearch": $.extend( {}, DataTable.models.oSearch ),
  10145. /**
  10146. * __Deprecated__ The functionality provided by this parameter has now been
  10147. * superseded by that provided through `ajax`, which should be used instead.
  10148. *
  10149. * By default DataTables will look for the property `data` (or `aaData` for
  10150. * compatibility with DataTables 1.9-) when obtaining data from an Ajax
  10151. * source or for server-side processing - this parameter allows that
  10152. * property to be changed. You can use Javascript dotted object notation to
  10153. * get a data source for multiple levels of nesting.
  10154. * @type string
  10155. * @default data
  10156. *
  10157. * @dtopt Options
  10158. * @dtopt Server-side
  10159. * @name DataTable.defaults.ajaxDataProp
  10160. *
  10161. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10162. */
  10163. "sAjaxDataProp": "data",
  10164. /**
  10165. * __Deprecated__ The functionality provided by this parameter has now been
  10166. * superseded by that provided through `ajax`, which should be used instead.
  10167. *
  10168. * You can instruct DataTables to load data from an external
  10169. * source using this parameter (use aData if you want to pass data in you
  10170. * already have). Simply provide a url a JSON object can be obtained from.
  10171. * @type string
  10172. * @default null
  10173. *
  10174. * @dtopt Options
  10175. * @dtopt Server-side
  10176. * @name DataTable.defaults.ajaxSource
  10177. *
  10178. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10179. */
  10180. "sAjaxSource": null,
  10181. /**
  10182. * This initialisation variable allows you to specify exactly where in the
  10183. * DOM you want DataTables to inject the various controls it adds to the page
  10184. * (for example you might want the pagination controls at the top of the
  10185. * table). DIV elements (with or without a custom class) can also be added to
  10186. * aid styling. The follow syntax is used:
  10187. * <ul>
  10188. * <li>The following options are allowed:
  10189. * <ul>
  10190. * <li>'l' - Length changing</li>
  10191. * <li>'f' - Filtering input</li>
  10192. * <li>'t' - The table!</li>
  10193. * <li>'i' - Information</li>
  10194. * <li>'p' - Pagination</li>
  10195. * <li>'r' - pRocessing</li>
  10196. * </ul>
  10197. * </li>
  10198. * <li>The following constants are allowed:
  10199. * <ul>
  10200. * <li>'H' - jQueryUI theme "header" classes ('fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix')</li>
  10201. * <li>'F' - jQueryUI theme "footer" classes ('fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix')</li>
  10202. * </ul>
  10203. * </li>
  10204. * <li>The following syntax is expected:
  10205. * <ul>
  10206. * <li>'&lt;' and '&gt;' - div elements</li>
  10207. * <li>'&lt;"class" and '&gt;' - div with a class</li>
  10208. * <li>'&lt;"#id" and '&gt;' - div with an ID</li>
  10209. * </ul>
  10210. * </li>
  10211. * <li>Examples:
  10212. * <ul>
  10213. * <li>'&lt;"wrapper"flipt&gt;'</li>
  10214. * <li>'&lt;lf&lt;t&gt;ip&gt;'</li>
  10215. * </ul>
  10216. * </li>
  10217. * </ul>
  10218. * @type string
  10219. * @default lfrtip <i>(when `jQueryUI` is false)</i> <b>or</b>
  10220. * <"H"lfr>t<"F"ip> <i>(when `jQueryUI` is true)</i>
  10221. *
  10222. * @dtopt Options
  10223. * @name DataTable.defaults.dom
  10224. *
  10225. * @example
  10226. * $(document).ready( function() {
  10227. * $('#example').dataTable( {
  10228. * "dom": '&lt;"top"i&gt;rt&lt;"bottom"flp&gt;&lt;"clear"&gt;'
  10229. * } );
  10230. * } );
  10231. */
  10232. "sDom": "lfrtip",
  10233. /**
  10234. * Search delay option. This will throttle full table searches that use the
  10235. * DataTables provided search input element (it does not effect calls to
  10236. * `dt-api search()`, providing a delay before the search is made.
  10237. * @type integer
  10238. * @default 0
  10239. *
  10240. * @dtopt Options
  10241. * @name DataTable.defaults.searchDelay
  10242. *
  10243. * @example
  10244. * $(document).ready( function() {
  10245. * $('#example').dataTable( {
  10246. * "searchDelay": 200
  10247. * } );
  10248. * } )
  10249. */
  10250. "searchDelay": null,
  10251. /**
  10252. * DataTables features six different built-in options for the buttons to
  10253. * display for pagination control:
  10254. *
  10255. * * `numbers` - Page number buttons only
  10256. * * `simple` - 'Previous' and 'Next' buttons only
  10257. * * 'simple_numbers` - 'Previous' and 'Next' buttons, plus page numbers
  10258. * * `full` - 'First', 'Previous', 'Next' and 'Last' buttons
  10259. * * `full_numbers` - 'First', 'Previous', 'Next' and 'Last' buttons, plus page numbers
  10260. * * `first_last_numbers` - 'First' and 'Last' buttons, plus page numbers
  10261. *
  10262. * Further methods can be added using {@link DataTable.ext.oPagination}.
  10263. * @type string
  10264. * @default simple_numbers
  10265. *
  10266. * @dtopt Options
  10267. * @name DataTable.defaults.pagingType
  10268. *
  10269. * @example
  10270. * $(document).ready( function() {
  10271. * $('#example').dataTable( {
  10272. * "pagingType": "full_numbers"
  10273. * } );
  10274. * } )
  10275. */
  10276. "sPaginationType": "simple_numbers",
  10277. /**
  10278. * Enable horizontal scrolling. When a table is too wide to fit into a
  10279. * certain layout, or you have a large number of columns in the table, you
  10280. * can enable x-scrolling to show the table in a viewport, which can be
  10281. * scrolled. This property can be `true` which will allow the table to
  10282. * scroll horizontally when needed, or any CSS unit, or a number (in which
  10283. * case it will be treated as a pixel measurement). Setting as simply `true`
  10284. * is recommended.
  10285. * @type boolean|string
  10286. * @default <i>blank string - i.e. disabled</i>
  10287. *
  10288. * @dtopt Features
  10289. * @name DataTable.defaults.scrollX
  10290. *
  10291. * @example
  10292. * $(document).ready( function() {
  10293. * $('#example').dataTable( {
  10294. * "scrollX": true,
  10295. * "scrollCollapse": true
  10296. * } );
  10297. * } );
  10298. */
  10299. "sScrollX": "",
  10300. /**
  10301. * This property can be used to force a DataTable to use more width than it
  10302. * might otherwise do when x-scrolling is enabled. For example if you have a
  10303. * table which requires to be well spaced, this parameter is useful for
  10304. * "over-sizing" the table, and thus forcing scrolling. This property can by
  10305. * any CSS unit, or a number (in which case it will be treated as a pixel
  10306. * measurement).
  10307. * @type string
  10308. * @default <i>blank string - i.e. disabled</i>
  10309. *
  10310. * @dtopt Options
  10311. * @name DataTable.defaults.scrollXInner
  10312. *
  10313. * @example
  10314. * $(document).ready( function() {
  10315. * $('#example').dataTable( {
  10316. * "scrollX": "100%",
  10317. * "scrollXInner": "110%"
  10318. * } );
  10319. * } );
  10320. */
  10321. "sScrollXInner": "",
  10322. /**
  10323. * Enable vertical scrolling. Vertical scrolling will constrain the DataTable
  10324. * to the given height, and enable scrolling for any data which overflows the
  10325. * current viewport. This can be used as an alternative to paging to display
  10326. * a lot of data in a small area (although paging and scrolling can both be
  10327. * enabled at the same time). This property can be any CSS unit, or a number
  10328. * (in which case it will be treated as a pixel measurement).
  10329. * @type string
  10330. * @default <i>blank string - i.e. disabled</i>
  10331. *
  10332. * @dtopt Features
  10333. * @name DataTable.defaults.scrollY
  10334. *
  10335. * @example
  10336. * $(document).ready( function() {
  10337. * $('#example').dataTable( {
  10338. * "scrollY": "200px",
  10339. * "paginate": false
  10340. * } );
  10341. * } );
  10342. */
  10343. "sScrollY": "",
  10344. /**
  10345. * __Deprecated__ The functionality provided by this parameter has now been
  10346. * superseded by that provided through `ajax`, which should be used instead.
  10347. *
  10348. * Set the HTTP method that is used to make the Ajax call for server-side
  10349. * processing or Ajax sourced data.
  10350. * @type string
  10351. * @default GET
  10352. *
  10353. * @dtopt Options
  10354. * @dtopt Server-side
  10355. * @name DataTable.defaults.serverMethod
  10356. *
  10357. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10358. */
  10359. "sServerMethod": "GET",
  10360. /**
  10361. * DataTables makes use of renderers when displaying HTML elements for
  10362. * a table. These renderers can be added or modified by plug-ins to
  10363. * generate suitable mark-up for a site. For example the Bootstrap
  10364. * integration plug-in for DataTables uses a paging button renderer to
  10365. * display pagination buttons in the mark-up required by Bootstrap.
  10366. *
  10367. * For further information about the renderers available see
  10368. * DataTable.ext.renderer
  10369. * @type string|object
  10370. * @default null
  10371. *
  10372. * @name DataTable.defaults.renderer
  10373. *
  10374. */
  10375. "renderer": null,
  10376. /**
  10377. * Set the data property name that DataTables should use to get a row's id
  10378. * to set as the `id` property in the node.
  10379. * @type string
  10380. * @default DT_RowId
  10381. *
  10382. * @name DataTable.defaults.rowId
  10383. */
  10384. "rowId": "DT_RowId"
  10385. };
  10386. _fnHungarianMap( DataTable.defaults );
  10387. /*
  10388. * Developer note - See note in model.defaults.js about the use of Hungarian
  10389. * notation and camel case.
  10390. */
  10391. /**
  10392. * Column options that can be given to DataTables at initialisation time.
  10393. * @namespace
  10394. */
  10395. DataTable.defaults.column = {
  10396. /**
  10397. * Define which column(s) an order will occur on for this column. This
  10398. * allows a column's ordering to take multiple columns into account when
  10399. * doing a sort or use the data from a different column. For example first
  10400. * name / last name columns make sense to do a multi-column sort over the
  10401. * two columns.
  10402. * @type array|int
  10403. * @default null <i>Takes the value of the column index automatically</i>
  10404. *
  10405. * @name DataTable.defaults.column.orderData
  10406. * @dtopt Columns
  10407. *
  10408. * @example
  10409. * // Using `columnDefs`
  10410. * $(document).ready( function() {
  10411. * $('#example').dataTable( {
  10412. * "columnDefs": [
  10413. * { "orderData": [ 0, 1 ], "targets": [ 0 ] },
  10414. * { "orderData": [ 1, 0 ], "targets": [ 1 ] },
  10415. * { "orderData": 2, "targets": [ 2 ] }
  10416. * ]
  10417. * } );
  10418. * } );
  10419. *
  10420. * @example
  10421. * // Using `columns`
  10422. * $(document).ready( function() {
  10423. * $('#example').dataTable( {
  10424. * "columns": [
  10425. * { "orderData": [ 0, 1 ] },
  10426. * { "orderData": [ 1, 0 ] },
  10427. * { "orderData": 2 },
  10428. * null,
  10429. * null
  10430. * ]
  10431. * } );
  10432. * } );
  10433. */
  10434. "aDataSort": null,
  10435. "iDataSort": -1,
  10436. /**
  10437. * You can control the default ordering direction, and even alter the
  10438. * behaviour of the sort handler (i.e. only allow ascending ordering etc)
  10439. * using this parameter.
  10440. * @type array
  10441. * @default [ 'asc', 'desc' ]
  10442. *
  10443. * @name DataTable.defaults.column.orderSequence
  10444. * @dtopt Columns
  10445. *
  10446. * @example
  10447. * // Using `columnDefs`
  10448. * $(document).ready( function() {
  10449. * $('#example').dataTable( {
  10450. * "columnDefs": [
  10451. * { "orderSequence": [ "asc" ], "targets": [ 1 ] },
  10452. * { "orderSequence": [ "desc", "asc", "asc" ], "targets": [ 2 ] },
  10453. * { "orderSequence": [ "desc" ], "targets": [ 3 ] }
  10454. * ]
  10455. * } );
  10456. * } );
  10457. *
  10458. * @example
  10459. * // Using `columns`
  10460. * $(document).ready( function() {
  10461. * $('#example').dataTable( {
  10462. * "columns": [
  10463. * null,
  10464. * { "orderSequence": [ "asc" ] },
  10465. * { "orderSequence": [ "desc", "asc", "asc" ] },
  10466. * { "orderSequence": [ "desc" ] },
  10467. * null
  10468. * ]
  10469. * } );
  10470. * } );
  10471. */
  10472. "asSorting": [ 'asc', 'desc' ],
  10473. /**
  10474. * Enable or disable filtering on the data in this column.
  10475. * @type boolean
  10476. * @default true
  10477. *
  10478. * @name DataTable.defaults.column.searchable
  10479. * @dtopt Columns
  10480. *
  10481. * @example
  10482. * // Using `columnDefs`
  10483. * $(document).ready( function() {
  10484. * $('#example').dataTable( {
  10485. * "columnDefs": [
  10486. * { "searchable": false, "targets": [ 0 ] }
  10487. * ] } );
  10488. * } );
  10489. *
  10490. * @example
  10491. * // Using `columns`
  10492. * $(document).ready( function() {
  10493. * $('#example').dataTable( {
  10494. * "columns": [
  10495. * { "searchable": false },
  10496. * null,
  10497. * null,
  10498. * null,
  10499. * null
  10500. * ] } );
  10501. * } );
  10502. */
  10503. "bSearchable": true,
  10504. /**
  10505. * Enable or disable ordering on this column.
  10506. * @type boolean
  10507. * @default true
  10508. *
  10509. * @name DataTable.defaults.column.orderable
  10510. * @dtopt Columns
  10511. *
  10512. * @example
  10513. * // Using `columnDefs`
  10514. * $(document).ready( function() {
  10515. * $('#example').dataTable( {
  10516. * "columnDefs": [
  10517. * { "orderable": false, "targets": [ 0 ] }
  10518. * ] } );
  10519. * } );
  10520. *
  10521. * @example
  10522. * // Using `columns`
  10523. * $(document).ready( function() {
  10524. * $('#example').dataTable( {
  10525. * "columns": [
  10526. * { "orderable": false },
  10527. * null,
  10528. * null,
  10529. * null,
  10530. * null
  10531. * ] } );
  10532. * } );
  10533. */
  10534. "bSortable": true,
  10535. /**
  10536. * Enable or disable the display of this column.
  10537. * @type boolean
  10538. * @default true
  10539. *
  10540. * @name DataTable.defaults.column.visible
  10541. * @dtopt Columns
  10542. *
  10543. * @example
  10544. * // Using `columnDefs`
  10545. * $(document).ready( function() {
  10546. * $('#example').dataTable( {
  10547. * "columnDefs": [
  10548. * { "visible": false, "targets": [ 0 ] }
  10549. * ] } );
  10550. * } );
  10551. *
  10552. * @example
  10553. * // Using `columns`
  10554. * $(document).ready( function() {
  10555. * $('#example').dataTable( {
  10556. * "columns": [
  10557. * { "visible": false },
  10558. * null,
  10559. * null,
  10560. * null,
  10561. * null
  10562. * ] } );
  10563. * } );
  10564. */
  10565. "bVisible": true,
  10566. /**
  10567. * Developer definable function that is called whenever a cell is created (Ajax source,
  10568. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  10569. * allowing you to modify the DOM element (add background colour for example) when the
  10570. * element is available.
  10571. * @type function
  10572. * @param {element} td The TD node that has been created
  10573. * @param {*} cellData The Data for the cell
  10574. * @param {array|object} rowData The data for the whole row
  10575. * @param {int} row The row index for the aoData data store
  10576. * @param {int} col The column index for aoColumns
  10577. *
  10578. * @name DataTable.defaults.column.createdCell
  10579. * @dtopt Columns
  10580. *
  10581. * @example
  10582. * $(document).ready( function() {
  10583. * $('#example').dataTable( {
  10584. * "columnDefs": [ {
  10585. * "targets": [3],
  10586. * "createdCell": function (td, cellData, rowData, row, col) {
  10587. * if ( cellData == "1.7" ) {
  10588. * $(td).css('color', 'blue')
  10589. * }
  10590. * }
  10591. * } ]
  10592. * });
  10593. * } );
  10594. */
  10595. "fnCreatedCell": null,
  10596. /**
  10597. * This parameter has been replaced by `data` in DataTables to ensure naming
  10598. * consistency. `dataProp` can still be used, as there is backwards
  10599. * compatibility in DataTables for this option, but it is strongly
  10600. * recommended that you use `data` in preference to `dataProp`.
  10601. * @name DataTable.defaults.column.dataProp
  10602. */
  10603. /**
  10604. * This property can be used to read data from any data source property,
  10605. * including deeply nested objects / properties. `data` can be given in a
  10606. * number of different ways which effect its behaviour:
  10607. *
  10608. * * `integer` - treated as an array index for the data source. This is the
  10609. * default that DataTables uses (incrementally increased for each column).
  10610. * * `string` - read an object property from the data source. There are
  10611. * three 'special' options that can be used in the string to alter how
  10612. * DataTables reads the data from the source object:
  10613. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10614. * Javascript to read from nested objects, so to can the options
  10615. * specified in `data`. For example: `browser.version` or
  10616. * `browser.name`. If your object parameter name contains a period, use
  10617. * `\\` to escape it - i.e. `first\\.name`.
  10618. * * `[]` - Array notation. DataTables can automatically combine data
  10619. * from and array source, joining the data with the characters provided
  10620. * between the two brackets. For example: `name[, ]` would provide a
  10621. * comma-space separated list from the source array. If no characters
  10622. * are provided between the brackets, the original array source is
  10623. * returned.
  10624. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10625. * execute a function of the name given. For example: `browser()` for a
  10626. * simple function on the data source, `browser.version()` for a
  10627. * function in a nested property or even `browser().version` to get an
  10628. * object property if the function called returns an object. Note that
  10629. * function notation is recommended for use in `render` rather than
  10630. * `data` as it is much simpler to use as a renderer.
  10631. * * `null` - use the original data source for the row rather than plucking
  10632. * data directly from it. This action has effects on two other
  10633. * initialisation options:
  10634. * * `defaultContent` - When null is given as the `data` option and
  10635. * `defaultContent` is specified for the column, the value defined by
  10636. * `defaultContent` will be used for the cell.
  10637. * * `render` - When null is used for the `data` option and the `render`
  10638. * option is specified for the column, the whole data source for the
  10639. * row is used for the renderer.
  10640. * * `function` - the function given will be executed whenever DataTables
  10641. * needs to set or get the data for a cell in the column. The function
  10642. * takes three parameters:
  10643. * * Parameters:
  10644. * * `{array|object}` The data source for the row
  10645. * * `{string}` The type call data requested - this will be 'set' when
  10646. * setting data or 'filter', 'display', 'type', 'sort' or undefined
  10647. * when gathering data. Note that when `undefined` is given for the
  10648. * type DataTables expects to get the raw data for the object back<
  10649. * * `{*}` Data to set when the second parameter is 'set'.
  10650. * * Return:
  10651. * * The return value from the function is not required when 'set' is
  10652. * the type of call, but otherwise the return is what will be used
  10653. * for the data requested.
  10654. *
  10655. * Note that `data` is a getter and setter option. If you just require
  10656. * formatting of data for output, you will likely want to use `render` which
  10657. * is simply a getter and thus simpler to use.
  10658. *
  10659. * Note that prior to DataTables 1.9.2 `data` was called `mDataProp`. The
  10660. * name change reflects the flexibility of this property and is consistent
  10661. * with the naming of mRender. If 'mDataProp' is given, then it will still
  10662. * be used by DataTables, as it automatically maps the old name to the new
  10663. * if required.
  10664. *
  10665. * @type string|int|function|null
  10666. * @default null <i>Use automatically calculated column index</i>
  10667. *
  10668. * @name DataTable.defaults.column.data
  10669. * @dtopt Columns
  10670. *
  10671. * @example
  10672. * // Read table data from objects
  10673. * // JSON structure for each row:
  10674. * // {
  10675. * // "engine": {value},
  10676. * // "browser": {value},
  10677. * // "platform": {value},
  10678. * // "version": {value},
  10679. * // "grade": {value}
  10680. * // }
  10681. * $(document).ready( function() {
  10682. * $('#example').dataTable( {
  10683. * "ajaxSource": "sources/objects.txt",
  10684. * "columns": [
  10685. * { "data": "engine" },
  10686. * { "data": "browser" },
  10687. * { "data": "platform" },
  10688. * { "data": "version" },
  10689. * { "data": "grade" }
  10690. * ]
  10691. * } );
  10692. * } );
  10693. *
  10694. * @example
  10695. * // Read information from deeply nested objects
  10696. * // JSON structure for each row:
  10697. * // {
  10698. * // "engine": {value},
  10699. * // "browser": {value},
  10700. * // "platform": {
  10701. * // "inner": {value}
  10702. * // },
  10703. * // "details": [
  10704. * // {value}, {value}
  10705. * // ]
  10706. * // }
  10707. * $(document).ready( function() {
  10708. * $('#example').dataTable( {
  10709. * "ajaxSource": "sources/deep.txt",
  10710. * "columns": [
  10711. * { "data": "engine" },
  10712. * { "data": "browser" },
  10713. * { "data": "platform.inner" },
  10714. * { "data": "platform.details.0" },
  10715. * { "data": "platform.details.1" }
  10716. * ]
  10717. * } );
  10718. * } );
  10719. *
  10720. * @example
  10721. * // Using `data` as a function to provide different information for
  10722. * // sorting, filtering and display. In this case, currency (price)
  10723. * $(document).ready( function() {
  10724. * $('#example').dataTable( {
  10725. * "columnDefs": [ {
  10726. * "targets": [ 0 ],
  10727. * "data": function ( source, type, val ) {
  10728. * if (type === 'set') {
  10729. * source.price = val;
  10730. * // Store the computed dislay and filter values for efficiency
  10731. * source.price_display = val=="" ? "" : "$"+numberFormat(val);
  10732. * source.price_filter = val=="" ? "" : "$"+numberFormat(val)+" "+val;
  10733. * return;
  10734. * }
  10735. * else if (type === 'display') {
  10736. * return source.price_display;
  10737. * }
  10738. * else if (type === 'filter') {
  10739. * return source.price_filter;
  10740. * }
  10741. * // 'sort', 'type' and undefined all just use the integer
  10742. * return source.price;
  10743. * }
  10744. * } ]
  10745. * } );
  10746. * } );
  10747. *
  10748. * @example
  10749. * // Using default content
  10750. * $(document).ready( function() {
  10751. * $('#example').dataTable( {
  10752. * "columnDefs": [ {
  10753. * "targets": [ 0 ],
  10754. * "data": null,
  10755. * "defaultContent": "Click to edit"
  10756. * } ]
  10757. * } );
  10758. * } );
  10759. *
  10760. * @example
  10761. * // Using array notation - outputting a list from an array
  10762. * $(document).ready( function() {
  10763. * $('#example').dataTable( {
  10764. * "columnDefs": [ {
  10765. * "targets": [ 0 ],
  10766. * "data": "name[, ]"
  10767. * } ]
  10768. * } );
  10769. * } );
  10770. *
  10771. */
  10772. "mData": null,
  10773. /**
  10774. * This property is the rendering partner to `data` and it is suggested that
  10775. * when you want to manipulate data for display (including filtering,
  10776. * sorting etc) without altering the underlying data for the table, use this
  10777. * property. `render` can be considered to be the the read only companion to
  10778. * `data` which is read / write (then as such more complex). Like `data`
  10779. * this option can be given in a number of different ways to effect its
  10780. * behaviour:
  10781. *
  10782. * * `integer` - treated as an array index for the data source. This is the
  10783. * default that DataTables uses (incrementally increased for each column).
  10784. * * `string` - read an object property from the data source. There are
  10785. * three 'special' options that can be used in the string to alter how
  10786. * DataTables reads the data from the source object:
  10787. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10788. * Javascript to read from nested objects, so to can the options
  10789. * specified in `data`. For example: `browser.version` or
  10790. * `browser.name`. If your object parameter name contains a period, use
  10791. * `\\` to escape it - i.e. `first\\.name`.
  10792. * * `[]` - Array notation. DataTables can automatically combine data
  10793. * from and array source, joining the data with the characters provided
  10794. * between the two brackets. For example: `name[, ]` would provide a
  10795. * comma-space separated list from the source array. If no characters
  10796. * are provided between the brackets, the original array source is
  10797. * returned.
  10798. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10799. * execute a function of the name given. For example: `browser()` for a
  10800. * simple function on the data source, `browser.version()` for a
  10801. * function in a nested property or even `browser().version` to get an
  10802. * object property if the function called returns an object.
  10803. * * `object` - use different data for the different data types requested by
  10804. * DataTables ('filter', 'display', 'type' or 'sort'). The property names
  10805. * of the object is the data type the property refers to and the value can
  10806. * defined using an integer, string or function using the same rules as
  10807. * `render` normally does. Note that an `_` option _must_ be specified.
  10808. * This is the default value to use if you haven't specified a value for
  10809. * the data type requested by DataTables.
  10810. * * `function` - the function given will be executed whenever DataTables
  10811. * needs to set or get the data for a cell in the column. The function
  10812. * takes three parameters:
  10813. * * Parameters:
  10814. * * {array|object} The data source for the row (based on `data`)
  10815. * * {string} The type call data requested - this will be 'filter',
  10816. * 'display', 'type' or 'sort'.
  10817. * * {array|object} The full data source for the row (not based on
  10818. * `data`)
  10819. * * Return:
  10820. * * The return value from the function is what will be used for the
  10821. * data requested.
  10822. *
  10823. * @type string|int|function|object|null
  10824. * @default null Use the data source value.
  10825. *
  10826. * @name DataTable.defaults.column.render
  10827. * @dtopt Columns
  10828. *
  10829. * @example
  10830. * // Create a comma separated list from an array of objects
  10831. * $(document).ready( function() {
  10832. * $('#example').dataTable( {
  10833. * "ajaxSource": "sources/deep.txt",
  10834. * "columns": [
  10835. * { "data": "engine" },
  10836. * { "data": "browser" },
  10837. * {
  10838. * "data": "platform",
  10839. * "render": "[, ].name"
  10840. * }
  10841. * ]
  10842. * } );
  10843. * } );
  10844. *
  10845. * @example
  10846. * // Execute a function to obtain data
  10847. * $(document).ready( function() {
  10848. * $('#example').dataTable( {
  10849. * "columnDefs": [ {
  10850. * "targets": [ 0 ],
  10851. * "data": null, // Use the full data source object for the renderer's source
  10852. * "render": "browserName()"
  10853. * } ]
  10854. * } );
  10855. * } );
  10856. *
  10857. * @example
  10858. * // As an object, extracting different data for the different types
  10859. * // This would be used with a data source such as:
  10860. * // { "phone": 5552368, "phone_filter": "5552368 555-2368", "phone_display": "555-2368" }
  10861. * // Here the `phone` integer is used for sorting and type detection, while `phone_filter`
  10862. * // (which has both forms) is used for filtering for if a user inputs either format, while
  10863. * // the formatted phone number is the one that is shown in the table.
  10864. * $(document).ready( function() {
  10865. * $('#example').dataTable( {
  10866. * "columnDefs": [ {
  10867. * "targets": [ 0 ],
  10868. * "data": null, // Use the full data source object for the renderer's source
  10869. * "render": {
  10870. * "_": "phone",
  10871. * "filter": "phone_filter",
  10872. * "display": "phone_display"
  10873. * }
  10874. * } ]
  10875. * } );
  10876. * } );
  10877. *
  10878. * @example
  10879. * // Use as a function to create a link from the data source
  10880. * $(document).ready( function() {
  10881. * $('#example').dataTable( {
  10882. * "columnDefs": [ {
  10883. * "targets": [ 0 ],
  10884. * "data": "download_link",
  10885. * "render": function ( data, type, full ) {
  10886. * return '<a href="'+data+'">Download</a>';
  10887. * }
  10888. * } ]
  10889. * } );
  10890. * } );
  10891. */
  10892. "mRender": null,
  10893. /**
  10894. * Change the cell type created for the column - either TD cells or TH cells. This
  10895. * can be useful as TH cells have semantic meaning in the table body, allowing them
  10896. * to act as a header for a row (you may wish to add scope='row' to the TH elements).
  10897. * @type string
  10898. * @default td
  10899. *
  10900. * @name DataTable.defaults.column.cellType
  10901. * @dtopt Columns
  10902. *
  10903. * @example
  10904. * // Make the first column use TH cells
  10905. * $(document).ready( function() {
  10906. * $('#example').dataTable( {
  10907. * "columnDefs": [ {
  10908. * "targets": [ 0 ],
  10909. * "cellType": "th"
  10910. * } ]
  10911. * } );
  10912. * } );
  10913. */
  10914. "sCellType": "td",
  10915. /**
  10916. * Class to give to each cell in this column.
  10917. * @type string
  10918. * @default <i>Empty string</i>
  10919. *
  10920. * @name DataTable.defaults.column.class
  10921. * @dtopt Columns
  10922. *
  10923. * @example
  10924. * // Using `columnDefs`
  10925. * $(document).ready( function() {
  10926. * $('#example').dataTable( {
  10927. * "columnDefs": [
  10928. * { "class": "my_class", "targets": [ 0 ] }
  10929. * ]
  10930. * } );
  10931. * } );
  10932. *
  10933. * @example
  10934. * // Using `columns`
  10935. * $(document).ready( function() {
  10936. * $('#example').dataTable( {
  10937. * "columns": [
  10938. * { "class": "my_class" },
  10939. * null,
  10940. * null,
  10941. * null,
  10942. * null
  10943. * ]
  10944. * } );
  10945. * } );
  10946. */
  10947. "sClass": "",
  10948. /**
  10949. * When DataTables calculates the column widths to assign to each column,
  10950. * it finds the longest string in each column and then constructs a
  10951. * temporary table and reads the widths from that. The problem with this
  10952. * is that "mmm" is much wider then "iiii", but the latter is a longer
  10953. * string - thus the calculation can go wrong (doing it properly and putting
  10954. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  10955. * a "work around" we provide this option. It will append its value to the
  10956. * text that is found to be the longest string for the column - i.e. padding.
  10957. * Generally you shouldn't need this!
  10958. * @type string
  10959. * @default <i>Empty string<i>
  10960. *
  10961. * @name DataTable.defaults.column.contentPadding
  10962. * @dtopt Columns
  10963. *
  10964. * @example
  10965. * // Using `columns`
  10966. * $(document).ready( function() {
  10967. * $('#example').dataTable( {
  10968. * "columns": [
  10969. * null,
  10970. * null,
  10971. * null,
  10972. * {
  10973. * "contentPadding": "mmm"
  10974. * }
  10975. * ]
  10976. * } );
  10977. * } );
  10978. */
  10979. "sContentPadding": "",
  10980. /**
  10981. * Allows a default value to be given for a column's data, and will be used
  10982. * whenever a null data source is encountered (this can be because `data`
  10983. * is set to null, or because the data source itself is null).
  10984. * @type string
  10985. * @default null
  10986. *
  10987. * @name DataTable.defaults.column.defaultContent
  10988. * @dtopt Columns
  10989. *
  10990. * @example
  10991. * // Using `columnDefs`
  10992. * $(document).ready( function() {
  10993. * $('#example').dataTable( {
  10994. * "columnDefs": [
  10995. * {
  10996. * "data": null,
  10997. * "defaultContent": "Edit",
  10998. * "targets": [ -1 ]
  10999. * }
  11000. * ]
  11001. * } );
  11002. * } );
  11003. *
  11004. * @example
  11005. * // Using `columns`
  11006. * $(document).ready( function() {
  11007. * $('#example').dataTable( {
  11008. * "columns": [
  11009. * null,
  11010. * null,
  11011. * null,
  11012. * {
  11013. * "data": null,
  11014. * "defaultContent": "Edit"
  11015. * }
  11016. * ]
  11017. * } );
  11018. * } );
  11019. */
  11020. "sDefaultContent": null,
  11021. /**
  11022. * This parameter is only used in DataTables' server-side processing. It can
  11023. * be exceptionally useful to know what columns are being displayed on the
  11024. * client side, and to map these to database fields. When defined, the names
  11025. * also allow DataTables to reorder information from the server if it comes
  11026. * back in an unexpected order (i.e. if you switch your columns around on the
  11027. * client-side, your server-side code does not also need updating).
  11028. * @type string
  11029. * @default <i>Empty string</i>
  11030. *
  11031. * @name DataTable.defaults.column.name
  11032. * @dtopt Columns
  11033. *
  11034. * @example
  11035. * // Using `columnDefs`
  11036. * $(document).ready( function() {
  11037. * $('#example').dataTable( {
  11038. * "columnDefs": [
  11039. * { "name": "engine", "targets": [ 0 ] },
  11040. * { "name": "browser", "targets": [ 1 ] },
  11041. * { "name": "platform", "targets": [ 2 ] },
  11042. * { "name": "version", "targets": [ 3 ] },
  11043. * { "name": "grade", "targets": [ 4 ] }
  11044. * ]
  11045. * } );
  11046. * } );
  11047. *
  11048. * @example
  11049. * // Using `columns`
  11050. * $(document).ready( function() {
  11051. * $('#example').dataTable( {
  11052. * "columns": [
  11053. * { "name": "engine" },
  11054. * { "name": "browser" },
  11055. * { "name": "platform" },
  11056. * { "name": "version" },
  11057. * { "name": "grade" }
  11058. * ]
  11059. * } );
  11060. * } );
  11061. */
  11062. "sName": "",
  11063. /**
  11064. * Defines a data source type for the ordering which can be used to read
  11065. * real-time information from the table (updating the internally cached
  11066. * version) prior to ordering. This allows ordering to occur on user
  11067. * editable elements such as form inputs.
  11068. * @type string
  11069. * @default std
  11070. *
  11071. * @name DataTable.defaults.column.orderDataType
  11072. * @dtopt Columns
  11073. *
  11074. * @example
  11075. * // Using `columnDefs`
  11076. * $(document).ready( function() {
  11077. * $('#example').dataTable( {
  11078. * "columnDefs": [
  11079. * { "orderDataType": "dom-text", "targets": [ 2, 3 ] },
  11080. * { "type": "numeric", "targets": [ 3 ] },
  11081. * { "orderDataType": "dom-select", "targets": [ 4 ] },
  11082. * { "orderDataType": "dom-checkbox", "targets": [ 5 ] }
  11083. * ]
  11084. * } );
  11085. * } );
  11086. *
  11087. * @example
  11088. * // Using `columns`
  11089. * $(document).ready( function() {
  11090. * $('#example').dataTable( {
  11091. * "columns": [
  11092. * null,
  11093. * null,
  11094. * { "orderDataType": "dom-text" },
  11095. * { "orderDataType": "dom-text", "type": "numeric" },
  11096. * { "orderDataType": "dom-select" },
  11097. * { "orderDataType": "dom-checkbox" }
  11098. * ]
  11099. * } );
  11100. * } );
  11101. */
  11102. "sSortDataType": "std",
  11103. /**
  11104. * The title of this column.
  11105. * @type string
  11106. * @default null <i>Derived from the 'TH' value for this column in the
  11107. * original HTML table.</i>
  11108. *
  11109. * @name DataTable.defaults.column.title
  11110. * @dtopt Columns
  11111. *
  11112. * @example
  11113. * // Using `columnDefs`
  11114. * $(document).ready( function() {
  11115. * $('#example').dataTable( {
  11116. * "columnDefs": [
  11117. * { "title": "My column title", "targets": [ 0 ] }
  11118. * ]
  11119. * } );
  11120. * } );
  11121. *
  11122. * @example
  11123. * // Using `columns`
  11124. * $(document).ready( function() {
  11125. * $('#example').dataTable( {
  11126. * "columns": [
  11127. * { "title": "My column title" },
  11128. * null,
  11129. * null,
  11130. * null,
  11131. * null
  11132. * ]
  11133. * } );
  11134. * } );
  11135. */
  11136. "sTitle": null,
  11137. /**
  11138. * The type allows you to specify how the data for this column will be
  11139. * ordered. Four types (string, numeric, date and html (which will strip
  11140. * HTML tags before ordering)) are currently available. Note that only date
  11141. * formats understood by Javascript's Date() object will be accepted as type
  11142. * date. For example: "Mar 26, 2008 5:03 PM". May take the values: 'string',
  11143. * 'numeric', 'date' or 'html' (by default). Further types can be adding
  11144. * through plug-ins.
  11145. * @type string
  11146. * @default null <i>Auto-detected from raw data</i>
  11147. *
  11148. * @name DataTable.defaults.column.type
  11149. * @dtopt Columns
  11150. *
  11151. * @example
  11152. * // Using `columnDefs`
  11153. * $(document).ready( function() {
  11154. * $('#example').dataTable( {
  11155. * "columnDefs": [
  11156. * { "type": "html", "targets": [ 0 ] }
  11157. * ]
  11158. * } );
  11159. * } );
  11160. *
  11161. * @example
  11162. * // Using `columns`
  11163. * $(document).ready( function() {
  11164. * $('#example').dataTable( {
  11165. * "columns": [
  11166. * { "type": "html" },
  11167. * null,
  11168. * null,
  11169. * null,
  11170. * null
  11171. * ]
  11172. * } );
  11173. * } );
  11174. */
  11175. "sType": null,
  11176. /**
  11177. * Defining the width of the column, this parameter may take any CSS value
  11178. * (3em, 20px etc). DataTables applies 'smart' widths to columns which have not
  11179. * been given a specific width through this interface ensuring that the table
  11180. * remains readable.
  11181. * @type string
  11182. * @default null <i>Automatic</i>
  11183. *
  11184. * @name DataTable.defaults.column.width
  11185. * @dtopt Columns
  11186. *
  11187. * @example
  11188. * // Using `columnDefs`
  11189. * $(document).ready( function() {
  11190. * $('#example').dataTable( {
  11191. * "columnDefs": [
  11192. * { "width": "20%", "targets": [ 0 ] }
  11193. * ]
  11194. * } );
  11195. * } );
  11196. *
  11197. * @example
  11198. * // Using `columns`
  11199. * $(document).ready( function() {
  11200. * $('#example').dataTable( {
  11201. * "columns": [
  11202. * { "width": "20%" },
  11203. * null,
  11204. * null,
  11205. * null,
  11206. * null
  11207. * ]
  11208. * } );
  11209. * } );
  11210. */
  11211. "sWidth": null
  11212. };
  11213. _fnHungarianMap( DataTable.defaults.column );
  11214. /**
  11215. * DataTables settings object - this holds all the information needed for a
  11216. * given table, including configuration, data and current application of the
  11217. * table options. DataTables does not have a single instance for each DataTable
  11218. * with the settings attached to that instance, but rather instances of the
  11219. * DataTable "class" are created on-the-fly as needed (typically by a
  11220. * $().dataTable() call) and the settings object is then applied to that
  11221. * instance.
  11222. *
  11223. * Note that this object is related to {@link DataTable.defaults} but this
  11224. * one is the internal data store for DataTables's cache of columns. It should
  11225. * NOT be manipulated outside of DataTables. Any configuration should be done
  11226. * through the initialisation options.
  11227. * @namespace
  11228. * @todo Really should attach the settings object to individual instances so we
  11229. * don't need to create new instances on each $().dataTable() call (if the
  11230. * table already exists). It would also save passing oSettings around and
  11231. * into every single function. However, this is a very significant
  11232. * architecture change for DataTables and will almost certainly break
  11233. * backwards compatibility with older installations. This is something that
  11234. * will be done in 2.0.
  11235. */
  11236. DataTable.models.oSettings = {
  11237. /**
  11238. * Primary features of DataTables and their enablement state.
  11239. * @namespace
  11240. */
  11241. "oFeatures": {
  11242. /**
  11243. * Flag to say if DataTables should automatically try to calculate the
  11244. * optimum table and columns widths (true) or not (false).
  11245. * Note that this parameter will be set by the initialisation routine. To
  11246. * set a default use {@link DataTable.defaults}.
  11247. * @type boolean
  11248. */
  11249. "bAutoWidth": null,
  11250. /**
  11251. * Delay the creation of TR and TD elements until they are actually
  11252. * needed by a driven page draw. This can give a significant speed
  11253. * increase for Ajax source and Javascript source data, but makes no
  11254. * difference at all fro DOM and server-side processing tables.
  11255. * Note that this parameter will be set by the initialisation routine. To
  11256. * set a default use {@link DataTable.defaults}.
  11257. * @type boolean
  11258. */
  11259. "bDeferRender": null,
  11260. /**
  11261. * Enable filtering on the table or not. Note that if this is disabled
  11262. * then there is no filtering at all on the table, including fnFilter.
  11263. * To just remove the filtering input use sDom and remove the 'f' option.
  11264. * Note that this parameter will be set by the initialisation routine. To
  11265. * set a default use {@link DataTable.defaults}.
  11266. * @type boolean
  11267. */
  11268. "bFilter": null,
  11269. /**
  11270. * Table information element (the 'Showing x of y records' div) enable
  11271. * flag.
  11272. * Note that this parameter will be set by the initialisation routine. To
  11273. * set a default use {@link DataTable.defaults}.
  11274. * @type boolean
  11275. */
  11276. "bInfo": null,
  11277. /**
  11278. * Present a user control allowing the end user to change the page size
  11279. * when pagination is enabled.
  11280. * Note that this parameter will be set by the initialisation routine. To
  11281. * set a default use {@link DataTable.defaults}.
  11282. * @type boolean
  11283. */
  11284. "bLengthChange": null,
  11285. /**
  11286. * Pagination enabled or not. Note that if this is disabled then length
  11287. * changing must also be disabled.
  11288. * Note that this parameter will be set by the initialisation routine. To
  11289. * set a default use {@link DataTable.defaults}.
  11290. * @type boolean
  11291. */
  11292. "bPaginate": null,
  11293. /**
  11294. * Processing indicator enable flag whenever DataTables is enacting a
  11295. * user request - typically an Ajax request for server-side processing.
  11296. * Note that this parameter will be set by the initialisation routine. To
  11297. * set a default use {@link DataTable.defaults}.
  11298. * @type boolean
  11299. */
  11300. "bProcessing": null,
  11301. /**
  11302. * Server-side processing enabled flag - when enabled DataTables will
  11303. * get all data from the server for every draw - there is no filtering,
  11304. * sorting or paging done on the client-side.
  11305. * Note that this parameter will be set by the initialisation routine. To
  11306. * set a default use {@link DataTable.defaults}.
  11307. * @type boolean
  11308. */
  11309. "bServerSide": null,
  11310. /**
  11311. * Sorting enablement flag.
  11312. * Note that this parameter will be set by the initialisation routine. To
  11313. * set a default use {@link DataTable.defaults}.
  11314. * @type boolean
  11315. */
  11316. "bSort": null,
  11317. /**
  11318. * Multi-column sorting
  11319. * Note that this parameter will be set by the initialisation routine. To
  11320. * set a default use {@link DataTable.defaults}.
  11321. * @type boolean
  11322. */
  11323. "bSortMulti": null,
  11324. /**
  11325. * Apply a class to the columns which are being sorted to provide a
  11326. * visual highlight or not. This can slow things down when enabled since
  11327. * there is a lot of DOM interaction.
  11328. * Note that this parameter will be set by the initialisation routine. To
  11329. * set a default use {@link DataTable.defaults}.
  11330. * @type boolean
  11331. */
  11332. "bSortClasses": null,
  11333. /**
  11334. * State saving enablement flag.
  11335. * Note that this parameter will be set by the initialisation routine. To
  11336. * set a default use {@link DataTable.defaults}.
  11337. * @type boolean
  11338. */
  11339. "bStateSave": null
  11340. },
  11341. /**
  11342. * Scrolling settings for a table.
  11343. * @namespace
  11344. */
  11345. "oScroll": {
  11346. /**
  11347. * When the table is shorter in height than sScrollY, collapse the
  11348. * table container down to the height of the table (when true).
  11349. * Note that this parameter will be set by the initialisation routine. To
  11350. * set a default use {@link DataTable.defaults}.
  11351. * @type boolean
  11352. */
  11353. "bCollapse": null,
  11354. /**
  11355. * Width of the scrollbar for the web-browser's platform. Calculated
  11356. * during table initialisation.
  11357. * @type int
  11358. * @default 0
  11359. */
  11360. "iBarWidth": 0,
  11361. /**
  11362. * Viewport width for horizontal scrolling. Horizontal scrolling is
  11363. * disabled if an empty string.
  11364. * Note that this parameter will be set by the initialisation routine. To
  11365. * set a default use {@link DataTable.defaults}.
  11366. * @type string
  11367. */
  11368. "sX": null,
  11369. /**
  11370. * Width to expand the table to when using x-scrolling. Typically you
  11371. * should not need to use this.
  11372. * Note that this parameter will be set by the initialisation routine. To
  11373. * set a default use {@link DataTable.defaults}.
  11374. * @type string
  11375. * @deprecated
  11376. */
  11377. "sXInner": null,
  11378. /**
  11379. * Viewport height for vertical scrolling. Vertical scrolling is disabled
  11380. * if an empty string.
  11381. * Note that this parameter will be set by the initialisation routine. To
  11382. * set a default use {@link DataTable.defaults}.
  11383. * @type string
  11384. */
  11385. "sY": null
  11386. },
  11387. /**
  11388. * Language information for the table.
  11389. * @namespace
  11390. * @extends DataTable.defaults.oLanguage
  11391. */
  11392. "oLanguage": {
  11393. /**
  11394. * Information callback function. See
  11395. * {@link DataTable.defaults.fnInfoCallback}
  11396. * @type function
  11397. * @default null
  11398. */
  11399. "fnInfoCallback": null
  11400. },
  11401. /**
  11402. * Browser support parameters
  11403. * @namespace
  11404. */
  11405. "oBrowser": {
  11406. /**
  11407. * Indicate if the browser incorrectly calculates width:100% inside a
  11408. * scrolling element (IE6/7)
  11409. * @type boolean
  11410. * @default false
  11411. */
  11412. "bScrollOversize": false,
  11413. /**
  11414. * Determine if the vertical scrollbar is on the right or left of the
  11415. * scrolling container - needed for rtl language layout, although not
  11416. * all browsers move the scrollbar (Safari).
  11417. * @type boolean
  11418. * @default false
  11419. */
  11420. "bScrollbarLeft": false,
  11421. /**
  11422. * Flag for if `getBoundingClientRect` is fully supported or not
  11423. * @type boolean
  11424. * @default false
  11425. */
  11426. "bBounding": false,
  11427. /**
  11428. * Browser scrollbar width
  11429. * @type integer
  11430. * @default 0
  11431. */
  11432. "barWidth": 0
  11433. },
  11434. "ajax": null,
  11435. /**
  11436. * Array referencing the nodes which are used for the features. The
  11437. * parameters of this object match what is allowed by sDom - i.e.
  11438. * <ul>
  11439. * <li>'l' - Length changing</li>
  11440. * <li>'f' - Filtering input</li>
  11441. * <li>'t' - The table!</li>
  11442. * <li>'i' - Information</li>
  11443. * <li>'p' - Pagination</li>
  11444. * <li>'r' - pRocessing</li>
  11445. * </ul>
  11446. * @type array
  11447. * @default []
  11448. */
  11449. "aanFeatures": [],
  11450. /**
  11451. * Store data information - see {@link DataTable.models.oRow} for detailed
  11452. * information.
  11453. * @type array
  11454. * @default []
  11455. */
  11456. "aoData": [],
  11457. /**
  11458. * Array of indexes which are in the current display (after filtering etc)
  11459. * @type array
  11460. * @default []
  11461. */
  11462. "aiDisplay": [],
  11463. /**
  11464. * Array of indexes for display - no filtering
  11465. * @type array
  11466. * @default []
  11467. */
  11468. "aiDisplayMaster": [],
  11469. /**
  11470. * Map of row ids to data indexes
  11471. * @type object
  11472. * @default {}
  11473. */
  11474. "aIds": {},
  11475. /**
  11476. * Store information about each column that is in use
  11477. * @type array
  11478. * @default []
  11479. */
  11480. "aoColumns": [],
  11481. /**
  11482. * Store information about the table's header
  11483. * @type array
  11484. * @default []
  11485. */
  11486. "aoHeader": [],
  11487. /**
  11488. * Store information about the table's footer
  11489. * @type array
  11490. * @default []
  11491. */
  11492. "aoFooter": [],
  11493. /**
  11494. * Store the applied global search information in case we want to force a
  11495. * research or compare the old search to a new one.
  11496. * Note that this parameter will be set by the initialisation routine. To
  11497. * set a default use {@link DataTable.defaults}.
  11498. * @namespace
  11499. * @extends DataTable.models.oSearch
  11500. */
  11501. "oPreviousSearch": {},
  11502. /**
  11503. * Store the applied search for each column - see
  11504. * {@link DataTable.models.oSearch} for the format that is used for the
  11505. * filtering information for each column.
  11506. * @type array
  11507. * @default []
  11508. */
  11509. "aoPreSearchCols": [],
  11510. /**
  11511. * Sorting that is applied to the table. Note that the inner arrays are
  11512. * used in the following manner:
  11513. * <ul>
  11514. * <li>Index 0 - column number</li>
  11515. * <li>Index 1 - current sorting direction</li>
  11516. * </ul>
  11517. * Note that this parameter will be set by the initialisation routine. To
  11518. * set a default use {@link DataTable.defaults}.
  11519. * @type array
  11520. * @todo These inner arrays should really be objects
  11521. */
  11522. "aaSorting": null,
  11523. /**
  11524. * Sorting that is always applied to the table (i.e. prefixed in front of
  11525. * aaSorting).
  11526. * Note that this parameter will be set by the initialisation routine. To
  11527. * set a default use {@link DataTable.defaults}.
  11528. * @type array
  11529. * @default []
  11530. */
  11531. "aaSortingFixed": [],
  11532. /**
  11533. * Classes to use for the striping of a table.
  11534. * Note that this parameter will be set by the initialisation routine. To
  11535. * set a default use {@link DataTable.defaults}.
  11536. * @type array
  11537. * @default []
  11538. */
  11539. "asStripeClasses": null,
  11540. /**
  11541. * If restoring a table - we should restore its striping classes as well
  11542. * @type array
  11543. * @default []
  11544. */
  11545. "asDestroyStripes": [],
  11546. /**
  11547. * If restoring a table - we should restore its width
  11548. * @type int
  11549. * @default 0
  11550. */
  11551. "sDestroyWidth": 0,
  11552. /**
  11553. * Callback functions array for every time a row is inserted (i.e. on a draw).
  11554. * @type array
  11555. * @default []
  11556. */
  11557. "aoRowCallback": [],
  11558. /**
  11559. * Callback functions for the header on each draw.
  11560. * @type array
  11561. * @default []
  11562. */
  11563. "aoHeaderCallback": [],
  11564. /**
  11565. * Callback function for the footer on each draw.
  11566. * @type array
  11567. * @default []
  11568. */
  11569. "aoFooterCallback": [],
  11570. /**
  11571. * Array of callback functions for draw callback functions
  11572. * @type array
  11573. * @default []
  11574. */
  11575. "aoDrawCallback": [],
  11576. /**
  11577. * Array of callback functions for row created function
  11578. * @type array
  11579. * @default []
  11580. */
  11581. "aoRowCreatedCallback": [],
  11582. /**
  11583. * Callback functions for just before the table is redrawn. A return of
  11584. * false will be used to cancel the draw.
  11585. * @type array
  11586. * @default []
  11587. */
  11588. "aoPreDrawCallback": [],
  11589. /**
  11590. * Callback functions for when the table has been initialised.
  11591. * @type array
  11592. * @default []
  11593. */
  11594. "aoInitComplete": [],
  11595. /**
  11596. * Callbacks for modifying the settings to be stored for state saving, prior to
  11597. * saving state.
  11598. * @type array
  11599. * @default []
  11600. */
  11601. "aoStateSaveParams": [],
  11602. /**
  11603. * Callbacks for modifying the settings that have been stored for state saving
  11604. * prior to using the stored values to restore the state.
  11605. * @type array
  11606. * @default []
  11607. */
  11608. "aoStateLoadParams": [],
  11609. /**
  11610. * Callbacks for operating on the settings object once the saved state has been
  11611. * loaded
  11612. * @type array
  11613. * @default []
  11614. */
  11615. "aoStateLoaded": [],
  11616. /**
  11617. * Cache the table ID for quick access
  11618. * @type string
  11619. * @default <i>Empty string</i>
  11620. */
  11621. "sTableId": "",
  11622. /**
  11623. * The TABLE node for the main table
  11624. * @type node
  11625. * @default null
  11626. */
  11627. "nTable": null,
  11628. /**
  11629. * Permanent ref to the thead element
  11630. * @type node
  11631. * @default null
  11632. */
  11633. "nTHead": null,
  11634. /**
  11635. * Permanent ref to the tfoot element - if it exists
  11636. * @type node
  11637. * @default null
  11638. */
  11639. "nTFoot": null,
  11640. /**
  11641. * Permanent ref to the tbody element
  11642. * @type node
  11643. * @default null
  11644. */
  11645. "nTBody": null,
  11646. /**
  11647. * Cache the wrapper node (contains all DataTables controlled elements)
  11648. * @type node
  11649. * @default null
  11650. */
  11651. "nTableWrapper": null,
  11652. /**
  11653. * Indicate if when using server-side processing the loading of data
  11654. * should be deferred until the second draw.
  11655. * Note that this parameter will be set by the initialisation routine. To
  11656. * set a default use {@link DataTable.defaults}.
  11657. * @type boolean
  11658. * @default false
  11659. */
  11660. "bDeferLoading": false,
  11661. /**
  11662. * Indicate if all required information has been read in
  11663. * @type boolean
  11664. * @default false
  11665. */
  11666. "bInitialised": false,
  11667. /**
  11668. * Information about open rows. Each object in the array has the parameters
  11669. * 'nTr' and 'nParent'
  11670. * @type array
  11671. * @default []
  11672. */
  11673. "aoOpenRows": [],
  11674. /**
  11675. * Dictate the positioning of DataTables' control elements - see
  11676. * {@link DataTable.model.oInit.sDom}.
  11677. * Note that this parameter will be set by the initialisation routine. To
  11678. * set a default use {@link DataTable.defaults}.
  11679. * @type string
  11680. * @default null
  11681. */
  11682. "sDom": null,
  11683. /**
  11684. * Search delay (in mS)
  11685. * @type integer
  11686. * @default null
  11687. */
  11688. "searchDelay": null,
  11689. /**
  11690. * Which type of pagination should be used.
  11691. * Note that this parameter will be set by the initialisation routine. To
  11692. * set a default use {@link DataTable.defaults}.
  11693. * @type string
  11694. * @default two_button
  11695. */
  11696. "sPaginationType": "two_button",
  11697. /**
  11698. * The state duration (for `stateSave`) in seconds.
  11699. * Note that this parameter will be set by the initialisation routine. To
  11700. * set a default use {@link DataTable.defaults}.
  11701. * @type int
  11702. * @default 0
  11703. */
  11704. "iStateDuration": 0,
  11705. /**
  11706. * Array of callback functions for state saving. Each array element is an
  11707. * object with the following parameters:
  11708. * <ul>
  11709. * <li>function:fn - function to call. Takes two parameters, oSettings
  11710. * and the JSON string to save that has been thus far created. Returns
  11711. * a JSON string to be inserted into a json object
  11712. * (i.e. '"param": [ 0, 1, 2]')</li>
  11713. * <li>string:sName - name of callback</li>
  11714. * </ul>
  11715. * @type array
  11716. * @default []
  11717. */
  11718. "aoStateSave": [],
  11719. /**
  11720. * Array of callback functions for state loading. Each array element is an
  11721. * object with the following parameters:
  11722. * <ul>
  11723. * <li>function:fn - function to call. Takes two parameters, oSettings
  11724. * and the object stored. May return false to cancel state loading</li>
  11725. * <li>string:sName - name of callback</li>
  11726. * </ul>
  11727. * @type array
  11728. * @default []
  11729. */
  11730. "aoStateLoad": [],
  11731. /**
  11732. * State that was saved. Useful for back reference
  11733. * @type object
  11734. * @default null
  11735. */
  11736. "oSavedState": null,
  11737. /**
  11738. * State that was loaded. Useful for back reference
  11739. * @type object
  11740. * @default null
  11741. */
  11742. "oLoadedState": null,
  11743. /**
  11744. * Source url for AJAX data for the table.
  11745. * Note that this parameter will be set by the initialisation routine. To
  11746. * set a default use {@link DataTable.defaults}.
  11747. * @type string
  11748. * @default null
  11749. */
  11750. "sAjaxSource": null,
  11751. /**
  11752. * Property from a given object from which to read the table data from. This
  11753. * can be an empty string (when not server-side processing), in which case
  11754. * it is assumed an an array is given directly.
  11755. * Note that this parameter will be set by the initialisation routine. To
  11756. * set a default use {@link DataTable.defaults}.
  11757. * @type string
  11758. */
  11759. "sAjaxDataProp": null,
  11760. /**
  11761. * Note if draw should be blocked while getting data
  11762. * @type boolean
  11763. * @default true
  11764. */
  11765. "bAjaxDataGet": true,
  11766. /**
  11767. * The last jQuery XHR object that was used for server-side data gathering.
  11768. * This can be used for working with the XHR information in one of the
  11769. * callbacks
  11770. * @type object
  11771. * @default null
  11772. */
  11773. "jqXHR": null,
  11774. /**
  11775. * JSON returned from the server in the last Ajax request
  11776. * @type object
  11777. * @default undefined
  11778. */
  11779. "json": undefined,
  11780. /**
  11781. * Data submitted as part of the last Ajax request
  11782. * @type object
  11783. * @default undefined
  11784. */
  11785. "oAjaxData": undefined,
  11786. /**
  11787. * Function to get the server-side data.
  11788. * Note that this parameter will be set by the initialisation routine. To
  11789. * set a default use {@link DataTable.defaults}.
  11790. * @type function
  11791. */
  11792. "fnServerData": null,
  11793. /**
  11794. * Functions which are called prior to sending an Ajax request so extra
  11795. * parameters can easily be sent to the server
  11796. * @type array
  11797. * @default []
  11798. */
  11799. "aoServerParams": [],
  11800. /**
  11801. * Send the XHR HTTP method - GET or POST (could be PUT or DELETE if
  11802. * required).
  11803. * Note that this parameter will be set by the initialisation routine. To
  11804. * set a default use {@link DataTable.defaults}.
  11805. * @type string
  11806. */
  11807. "sServerMethod": null,
  11808. /**
  11809. * Format numbers for display.
  11810. * Note that this parameter will be set by the initialisation routine. To
  11811. * set a default use {@link DataTable.defaults}.
  11812. * @type function
  11813. */
  11814. "fnFormatNumber": null,
  11815. /**
  11816. * List of options that can be used for the user selectable length menu.
  11817. * Note that this parameter will be set by the initialisation routine. To
  11818. * set a default use {@link DataTable.defaults}.
  11819. * @type array
  11820. * @default []
  11821. */
  11822. "aLengthMenu": null,
  11823. /**
  11824. * Counter for the draws that the table does. Also used as a tracker for
  11825. * server-side processing
  11826. * @type int
  11827. * @default 0
  11828. */
  11829. "iDraw": 0,
  11830. /**
  11831. * Indicate if a redraw is being done - useful for Ajax
  11832. * @type boolean
  11833. * @default false
  11834. */
  11835. "bDrawing": false,
  11836. /**
  11837. * Draw index (iDraw) of the last error when parsing the returned data
  11838. * @type int
  11839. * @default -1
  11840. */
  11841. "iDrawError": -1,
  11842. /**
  11843. * Paging display length
  11844. * @type int
  11845. * @default 10
  11846. */
  11847. "_iDisplayLength": 10,
  11848. /**
  11849. * Paging start point - aiDisplay index
  11850. * @type int
  11851. * @default 0
  11852. */
  11853. "_iDisplayStart": 0,
  11854. /**
  11855. * Server-side processing - number of records in the result set
  11856. * (i.e. before filtering), Use fnRecordsTotal rather than
  11857. * this property to get the value of the number of records, regardless of
  11858. * the server-side processing setting.
  11859. * @type int
  11860. * @default 0
  11861. * @private
  11862. */
  11863. "_iRecordsTotal": 0,
  11864. /**
  11865. * Server-side processing - number of records in the current display set
  11866. * (i.e. after filtering). Use fnRecordsDisplay rather than
  11867. * this property to get the value of the number of records, regardless of
  11868. * the server-side processing setting.
  11869. * @type boolean
  11870. * @default 0
  11871. * @private
  11872. */
  11873. "_iRecordsDisplay": 0,
  11874. /**
  11875. * Flag to indicate if jQuery UI marking and classes should be used.
  11876. * Note that this parameter will be set by the initialisation routine. To
  11877. * set a default use {@link DataTable.defaults}.
  11878. * @type boolean
  11879. */
  11880. "bJUI": null,
  11881. /**
  11882. * The classes to use for the table
  11883. * @type object
  11884. * @default {}
  11885. */
  11886. "oClasses": {},
  11887. /**
  11888. * Flag attached to the settings object so you can check in the draw
  11889. * callback if filtering has been done in the draw. Deprecated in favour of
  11890. * events.
  11891. * @type boolean
  11892. * @default false
  11893. * @deprecated
  11894. */
  11895. "bFiltered": false,
  11896. /**
  11897. * Flag attached to the settings object so you can check in the draw
  11898. * callback if sorting has been done in the draw. Deprecated in favour of
  11899. * events.
  11900. * @type boolean
  11901. * @default false
  11902. * @deprecated
  11903. */
  11904. "bSorted": false,
  11905. /**
  11906. * Indicate that if multiple rows are in the header and there is more than
  11907. * one unique cell per column, if the top one (true) or bottom one (false)
  11908. * should be used for sorting / title by DataTables.
  11909. * Note that this parameter will be set by the initialisation routine. To
  11910. * set a default use {@link DataTable.defaults}.
  11911. * @type boolean
  11912. */
  11913. "bSortCellsTop": null,
  11914. /**
  11915. * Initialisation object that is used for the table
  11916. * @type object
  11917. * @default null
  11918. */
  11919. "oInit": null,
  11920. /**
  11921. * Destroy callback functions - for plug-ins to attach themselves to the
  11922. * destroy so they can clean up markup and events.
  11923. * @type array
  11924. * @default []
  11925. */
  11926. "aoDestroyCallback": [],
  11927. /**
  11928. * Get the number of records in the current record set, before filtering
  11929. * @type function
  11930. */
  11931. "fnRecordsTotal": function ()
  11932. {
  11933. return _fnDataSource( this ) == 'ssp' ?
  11934. this._iRecordsTotal * 1 :
  11935. this.aiDisplayMaster.length;
  11936. },
  11937. /**
  11938. * Get the number of records in the current record set, after filtering
  11939. * @type function
  11940. */
  11941. "fnRecordsDisplay": function ()
  11942. {
  11943. return _fnDataSource( this ) == 'ssp' ?
  11944. this._iRecordsDisplay * 1 :
  11945. this.aiDisplay.length;
  11946. },
  11947. /**
  11948. * Get the display end point - aiDisplay index
  11949. * @type function
  11950. */
  11951. "fnDisplayEnd": function ()
  11952. {
  11953. var
  11954. len = this._iDisplayLength,
  11955. start = this._iDisplayStart,
  11956. calc = start + len,
  11957. records = this.aiDisplay.length,
  11958. features = this.oFeatures,
  11959. paginate = features.bPaginate;
  11960. if ( features.bServerSide ) {
  11961. return paginate === false || len === -1 ?
  11962. start + records :
  11963. Math.min( start+len, this._iRecordsDisplay );
  11964. }
  11965. else {
  11966. return ! paginate || calc>records || len===-1 ?
  11967. records :
  11968. calc;
  11969. }
  11970. },
  11971. /**
  11972. * The DataTables object for this table
  11973. * @type object
  11974. * @default null
  11975. */
  11976. "oInstance": null,
  11977. /**
  11978. * Unique identifier for each instance of the DataTables object. If there
  11979. * is an ID on the table node, then it takes that value, otherwise an
  11980. * incrementing internal counter is used.
  11981. * @type string
  11982. * @default null
  11983. */
  11984. "sInstance": null,
  11985. /**
  11986. * tabindex attribute value that is added to DataTables control elements, allowing
  11987. * keyboard navigation of the table and its controls.
  11988. */
  11989. "iTabIndex": 0,
  11990. /**
  11991. * DIV container for the footer scrolling table if scrolling
  11992. */
  11993. "nScrollHead": null,
  11994. /**
  11995. * DIV container for the footer scrolling table if scrolling
  11996. */
  11997. "nScrollFoot": null,
  11998. /**
  11999. * Last applied sort
  12000. * @type array
  12001. * @default []
  12002. */
  12003. "aLastSort": [],
  12004. /**
  12005. * Stored plug-in instances
  12006. * @type object
  12007. * @default {}
  12008. */
  12009. "oPlugins": {},
  12010. /**
  12011. * Function used to get a row's id from the row's data
  12012. * @type function
  12013. * @default null
  12014. */
  12015. "rowIdFn": null,
  12016. /**
  12017. * Data location where to store a row's id
  12018. * @type string
  12019. * @default null
  12020. */
  12021. "rowId": null
  12022. };
  12023. /**
  12024. * Extension object for DataTables that is used to provide all extension
  12025. * options.
  12026. *
  12027. * Note that the `DataTable.ext` object is available through
  12028. * `jQuery.fn.dataTable.ext` where it may be accessed and manipulated. It is
  12029. * also aliased to `jQuery.fn.dataTableExt` for historic reasons.
  12030. * @namespace
  12031. * @extends DataTable.models.ext
  12032. */
  12033. /**
  12034. * DataTables extensions
  12035. *
  12036. * This namespace acts as a collection area for plug-ins that can be used to
  12037. * extend DataTables capabilities. Indeed many of the build in methods
  12038. * use this method to provide their own capabilities (sorting methods for
  12039. * example).
  12040. *
  12041. * Note that this namespace is aliased to `jQuery.fn.dataTableExt` for legacy
  12042. * reasons
  12043. *
  12044. * @namespace
  12045. */
  12046. DataTable.ext = _ext = {
  12047. /**
  12048. * Buttons. For use with the Buttons extension for DataTables. This is
  12049. * defined here so other extensions can define buttons regardless of load
  12050. * order. It is _not_ used by DataTables core.
  12051. *
  12052. * @type object
  12053. * @default {}
  12054. */
  12055. buttons: {},
  12056. /**
  12057. * Element class names
  12058. *
  12059. * @type object
  12060. * @default {}
  12061. */
  12062. classes: {},
  12063. /**
  12064. * DataTables build type (expanded by the download builder)
  12065. *
  12066. * @type string
  12067. */
  12068. builder: "-source-",
  12069. /**
  12070. * Error reporting.
  12071. *
  12072. * How should DataTables report an error. Can take the value 'alert',
  12073. * 'throw', 'none' or a function.
  12074. *
  12075. * @type string|function
  12076. * @default alert
  12077. */
  12078. errMode: "alert",
  12079. /**
  12080. * Feature plug-ins.
  12081. *
  12082. * This is an array of objects which describe the feature plug-ins that are
  12083. * available to DataTables. These feature plug-ins are then available for
  12084. * use through the `dom` initialisation option.
  12085. *
  12086. * Each feature plug-in is described by an object which must have the
  12087. * following properties:
  12088. *
  12089. * * `fnInit` - function that is used to initialise the plug-in,
  12090. * * `cFeature` - a character so the feature can be enabled by the `dom`
  12091. * instillation option. This is case sensitive.
  12092. *
  12093. * The `fnInit` function has the following input parameters:
  12094. *
  12095. * 1. `{object}` DataTables settings object: see
  12096. * {@link DataTable.models.oSettings}
  12097. *
  12098. * And the following return is expected:
  12099. *
  12100. * * {node|null} The element which contains your feature. Note that the
  12101. * return may also be void if your plug-in does not require to inject any
  12102. * DOM elements into DataTables control (`dom`) - for example this might
  12103. * be useful when developing a plug-in which allows table control via
  12104. * keyboard entry
  12105. *
  12106. * @type array
  12107. *
  12108. * @example
  12109. * $.fn.dataTable.ext.features.push( {
  12110. * "fnInit": function( oSettings ) {
  12111. * return new TableTools( { "oDTSettings": oSettings } );
  12112. * },
  12113. * "cFeature": "T"
  12114. * } );
  12115. */
  12116. feature: [],
  12117. /**
  12118. * Row searching.
  12119. *
  12120. * This method of searching is complimentary to the default type based
  12121. * searching, and a lot more comprehensive as it allows you complete control
  12122. * over the searching logic. Each element in this array is a function
  12123. * (parameters described below) that is called for every row in the table,
  12124. * and your logic decides if it should be included in the searching data set
  12125. * or not.
  12126. *
  12127. * Searching functions have the following input parameters:
  12128. *
  12129. * 1. `{object}` DataTables settings object: see
  12130. * {@link DataTable.models.oSettings}
  12131. * 2. `{array|object}` Data for the row to be processed (same as the
  12132. * original format that was passed in as the data source, or an array
  12133. * from a DOM data source
  12134. * 3. `{int}` Row index ({@link DataTable.models.oSettings.aoData}), which
  12135. * can be useful to retrieve the `TR` element if you need DOM interaction.
  12136. *
  12137. * And the following return is expected:
  12138. *
  12139. * * {boolean} Include the row in the searched result set (true) or not
  12140. * (false)
  12141. *
  12142. * Note that as with the main search ability in DataTables, technically this
  12143. * is "filtering", since it is subtractive. However, for consistency in
  12144. * naming we call it searching here.
  12145. *
  12146. * @type array
  12147. * @default []
  12148. *
  12149. * @example
  12150. * // The following example shows custom search being applied to the
  12151. * // fourth column (i.e. the data[3] index) based on two input values
  12152. * // from the end-user, matching the data in a certain range.
  12153. * $.fn.dataTable.ext.search.push(
  12154. * function( settings, data, dataIndex ) {
  12155. * var min = document.getElementById('min').value * 1;
  12156. * var max = document.getElementById('max').value * 1;
  12157. * var version = data[3] == "-" ? 0 : data[3]*1;
  12158. *
  12159. * if ( min == "" && max == "" ) {
  12160. * return true;
  12161. * }
  12162. * else if ( min == "" && version < max ) {
  12163. * return true;
  12164. * }
  12165. * else if ( min < version && "" == max ) {
  12166. * return true;
  12167. * }
  12168. * else if ( min < version && version < max ) {
  12169. * return true;
  12170. * }
  12171. * return false;
  12172. * }
  12173. * );
  12174. */
  12175. search: [],
  12176. /**
  12177. * Selector extensions
  12178. *
  12179. * The `selector` option can be used to extend the options available for the
  12180. * selector modifier options (`selector-modifier` object data type) that
  12181. * each of the three built in selector types offer (row, column and cell +
  12182. * their plural counterparts). For example the Select extension uses this
  12183. * mechanism to provide an option to select only rows, columns and cells
  12184. * that have been marked as selected by the end user (`{selected: true}`),
  12185. * which can be used in conjunction with the existing built in selector
  12186. * options.
  12187. *
  12188. * Each property is an array to which functions can be pushed. The functions
  12189. * take three attributes:
  12190. *
  12191. * * Settings object for the host table
  12192. * * Options object (`selector-modifier` object type)
  12193. * * Array of selected item indexes
  12194. *
  12195. * The return is an array of the resulting item indexes after the custom
  12196. * selector has been applied.
  12197. *
  12198. * @type object
  12199. */
  12200. selector: {
  12201. cell: [],
  12202. column: [],
  12203. row: []
  12204. },
  12205. /**
  12206. * Internal functions, exposed for used in plug-ins.
  12207. *
  12208. * Please note that you should not need to use the internal methods for
  12209. * anything other than a plug-in (and even then, try to avoid if possible).
  12210. * The internal function may change between releases.
  12211. *
  12212. * @type object
  12213. * @default {}
  12214. */
  12215. internal: {},
  12216. /**
  12217. * Legacy configuration options. Enable and disable legacy options that
  12218. * are available in DataTables.
  12219. *
  12220. * @type object
  12221. */
  12222. legacy: {
  12223. /**
  12224. * Enable / disable DataTables 1.9 compatible server-side processing
  12225. * requests
  12226. *
  12227. * @type boolean
  12228. * @default null
  12229. */
  12230. ajax: null
  12231. },
  12232. /**
  12233. * Pagination plug-in methods.
  12234. *
  12235. * Each entry in this object is a function and defines which buttons should
  12236. * be shown by the pagination rendering method that is used for the table:
  12237. * {@link DataTable.ext.renderer.pageButton}. The renderer addresses how the
  12238. * buttons are displayed in the document, while the functions here tell it
  12239. * what buttons to display. This is done by returning an array of button
  12240. * descriptions (what each button will do).
  12241. *
  12242. * Pagination types (the four built in options and any additional plug-in
  12243. * options defined here) can be used through the `paginationType`
  12244. * initialisation parameter.
  12245. *
  12246. * The functions defined take two parameters:
  12247. *
  12248. * 1. `{int} page` The current page index
  12249. * 2. `{int} pages` The number of pages in the table
  12250. *
  12251. * Each function is expected to return an array where each element of the
  12252. * array can be one of:
  12253. *
  12254. * * `first` - Jump to first page when activated
  12255. * * `last` - Jump to last page when activated
  12256. * * `previous` - Show previous page when activated
  12257. * * `next` - Show next page when activated
  12258. * * `{int}` - Show page of the index given
  12259. * * `{array}` - A nested array containing the above elements to add a
  12260. * containing 'DIV' element (might be useful for styling).
  12261. *
  12262. * Note that DataTables v1.9- used this object slightly differently whereby
  12263. * an object with two functions would be defined for each plug-in. That
  12264. * ability is still supported by DataTables 1.10+ to provide backwards
  12265. * compatibility, but this option of use is now decremented and no longer
  12266. * documented in DataTables 1.10+.
  12267. *
  12268. * @type object
  12269. * @default {}
  12270. *
  12271. * @example
  12272. * // Show previous, next and current page buttons only
  12273. * $.fn.dataTableExt.oPagination.current = function ( page, pages ) {
  12274. * return [ 'previous', page, 'next' ];
  12275. * };
  12276. */
  12277. pager: {},
  12278. renderer: {
  12279. pageButton: {},
  12280. header: {}
  12281. },
  12282. /**
  12283. * Ordering plug-ins - custom data source
  12284. *
  12285. * The extension options for ordering of data available here is complimentary
  12286. * to the default type based ordering that DataTables typically uses. It
  12287. * allows much greater control over the the data that is being used to
  12288. * order a column, but is necessarily therefore more complex.
  12289. *
  12290. * This type of ordering is useful if you want to do ordering based on data
  12291. * live from the DOM (for example the contents of an 'input' element) rather
  12292. * than just the static string that DataTables knows of.
  12293. *
  12294. * The way these plug-ins work is that you create an array of the values you
  12295. * wish to be ordering for the column in question and then return that
  12296. * array. The data in the array much be in the index order of the rows in
  12297. * the table (not the currently ordering order!). Which order data gathering
  12298. * function is run here depends on the `dt-init columns.orderDataType`
  12299. * parameter that is used for the column (if any).
  12300. *
  12301. * The functions defined take two parameters:
  12302. *
  12303. * 1. `{object}` DataTables settings object: see
  12304. * {@link DataTable.models.oSettings}
  12305. * 2. `{int}` Target column index
  12306. *
  12307. * Each function is expected to return an array:
  12308. *
  12309. * * `{array}` Data for the column to be ordering upon
  12310. *
  12311. * @type array
  12312. *
  12313. * @example
  12314. * // Ordering using `input` node values
  12315. * $.fn.dataTable.ext.order['dom-text'] = function ( settings, col )
  12316. * {
  12317. * return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
  12318. * return $('input', td).val();
  12319. * } );
  12320. * }
  12321. */
  12322. order: {},
  12323. /**
  12324. * Type based plug-ins.
  12325. *
  12326. * Each column in DataTables has a type assigned to it, either by automatic
  12327. * detection or by direct assignment using the `type` option for the column.
  12328. * The type of a column will effect how it is ordering and search (plug-ins
  12329. * can also make use of the column type if required).
  12330. *
  12331. * @namespace
  12332. */
  12333. type: {
  12334. /**
  12335. * Type detection functions.
  12336. *
  12337. * The functions defined in this object are used to automatically detect
  12338. * a column's type, making initialisation of DataTables super easy, even
  12339. * when complex data is in the table.
  12340. *
  12341. * The functions defined take two parameters:
  12342. *
  12343. * 1. `{*}` Data from the column cell to be analysed
  12344. * 2. `{settings}` DataTables settings object. This can be used to
  12345. * perform context specific type detection - for example detection
  12346. * based on language settings such as using a comma for a decimal
  12347. * place. Generally speaking the options from the settings will not
  12348. * be required
  12349. *
  12350. * Each function is expected to return:
  12351. *
  12352. * * `{string|null}` Data type detected, or null if unknown (and thus
  12353. * pass it on to the other type detection functions.
  12354. *
  12355. * @type array
  12356. *
  12357. * @example
  12358. * // Currency type detection plug-in:
  12359. * $.fn.dataTable.ext.type.detect.push(
  12360. * function ( data, settings ) {
  12361. * // Check the numeric part
  12362. * if ( ! $.isNumeric( data.substring(1) ) ) {
  12363. * return null;
  12364. * }
  12365. *
  12366. * // Check prefixed by currency
  12367. * if ( data.charAt(0) == '$' || data.charAt(0) == '&pound;' ) {
  12368. * return 'currency';
  12369. * }
  12370. * return null;
  12371. * }
  12372. * );
  12373. */
  12374. detect: [],
  12375. /**
  12376. * Type based search formatting.
  12377. *
  12378. * The type based searching functions can be used to pre-format the
  12379. * data to be search on. For example, it can be used to strip HTML
  12380. * tags or to de-format telephone numbers for numeric only searching.
  12381. *
  12382. * Note that is a search is not defined for a column of a given type,
  12383. * no search formatting will be performed.
  12384. *
  12385. * Pre-processing of searching data plug-ins - When you assign the sType
  12386. * for a column (or have it automatically detected for you by DataTables
  12387. * or a type detection plug-in), you will typically be using this for
  12388. * custom sorting, but it can also be used to provide custom searching
  12389. * by allowing you to pre-processing the data and returning the data in
  12390. * the format that should be searched upon. This is done by adding
  12391. * functions this object with a parameter name which matches the sType
  12392. * for that target column. This is the corollary of <i>afnSortData</i>
  12393. * for searching data.
  12394. *
  12395. * The functions defined take a single parameter:
  12396. *
  12397. * 1. `{*}` Data from the column cell to be prepared for searching
  12398. *
  12399. * Each function is expected to return:
  12400. *
  12401. * * `{string|null}` Formatted string that will be used for the searching.
  12402. *
  12403. * @type object
  12404. * @default {}
  12405. *
  12406. * @example
  12407. * $.fn.dataTable.ext.type.search['title-numeric'] = function ( d ) {
  12408. * return d.replace(/\n/g," ").replace( /<.*?>/g, "" );
  12409. * }
  12410. */
  12411. search: {},
  12412. /**
  12413. * Type based ordering.
  12414. *
  12415. * The column type tells DataTables what ordering to apply to the table
  12416. * when a column is sorted upon. The order for each type that is defined,
  12417. * is defined by the functions available in this object.
  12418. *
  12419. * Each ordering option can be described by three properties added to
  12420. * this object:
  12421. *
  12422. * * `{type}-pre` - Pre-formatting function
  12423. * * `{type}-asc` - Ascending order function
  12424. * * `{type}-desc` - Descending order function
  12425. *
  12426. * All three can be used together, only `{type}-pre` or only
  12427. * `{type}-asc` and `{type}-desc` together. It is generally recommended
  12428. * that only `{type}-pre` is used, as this provides the optimal
  12429. * implementation in terms of speed, although the others are provided
  12430. * for compatibility with existing Javascript sort functions.
  12431. *
  12432. * `{type}-pre`: Functions defined take a single parameter:
  12433. *
  12434. * 1. `{*}` Data from the column cell to be prepared for ordering
  12435. *
  12436. * And return:
  12437. *
  12438. * * `{*}` Data to be sorted upon
  12439. *
  12440. * `{type}-asc` and `{type}-desc`: Functions are typical Javascript sort
  12441. * functions, taking two parameters:
  12442. *
  12443. * 1. `{*}` Data to compare to the second parameter
  12444. * 2. `{*}` Data to compare to the first parameter
  12445. *
  12446. * And returning:
  12447. *
  12448. * * `{*}` Ordering match: <0 if first parameter should be sorted lower
  12449. * than the second parameter, ===0 if the two parameters are equal and
  12450. * >0 if the first parameter should be sorted height than the second
  12451. * parameter.
  12452. *
  12453. * @type object
  12454. * @default {}
  12455. *
  12456. * @example
  12457. * // Numeric ordering of formatted numbers with a pre-formatter
  12458. * $.extend( $.fn.dataTable.ext.type.order, {
  12459. * "string-pre": function(x) {
  12460. * a = (a === "-" || a === "") ? 0 : a.replace( /[^\d\-\.]/g, "" );
  12461. * return parseFloat( a );
  12462. * }
  12463. * } );
  12464. *
  12465. * @example
  12466. * // Case-sensitive string ordering, with no pre-formatting method
  12467. * $.extend( $.fn.dataTable.ext.order, {
  12468. * "string-case-asc": function(x,y) {
  12469. * return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12470. * },
  12471. * "string-case-desc": function(x,y) {
  12472. * return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12473. * }
  12474. * } );
  12475. */
  12476. order: {}
  12477. },
  12478. /**
  12479. * Unique DataTables instance counter
  12480. *
  12481. * @type int
  12482. * @private
  12483. */
  12484. _unique: 0,
  12485. //
  12486. // Depreciated
  12487. // The following properties are retained for backwards compatiblity only.
  12488. // The should not be used in new projects and will be removed in a future
  12489. // version
  12490. //
  12491. /**
  12492. * Version check function.
  12493. * @type function
  12494. * @depreciated Since 1.10
  12495. */
  12496. fnVersionCheck: DataTable.fnVersionCheck,
  12497. /**
  12498. * Index for what 'this' index API functions should use
  12499. * @type int
  12500. * @deprecated Since v1.10
  12501. */
  12502. iApiIndex: 0,
  12503. /**
  12504. * jQuery UI class container
  12505. * @type object
  12506. * @deprecated Since v1.10
  12507. */
  12508. oJUIClasses: {},
  12509. /**
  12510. * Software version
  12511. * @type string
  12512. * @deprecated Since v1.10
  12513. */
  12514. sVersion: DataTable.version
  12515. };
  12516. //
  12517. // Backwards compatibility. Alias to pre 1.10 Hungarian notation counter parts
  12518. //
  12519. $.extend( _ext, {
  12520. afnFiltering: _ext.search,
  12521. aTypes: _ext.type.detect,
  12522. ofnSearch: _ext.type.search,
  12523. oSort: _ext.type.order,
  12524. afnSortData: _ext.order,
  12525. aoFeatures: _ext.feature,
  12526. oApi: _ext.internal,
  12527. oStdClasses: _ext.classes,
  12528. oPagination: _ext.pager
  12529. } );
  12530. $.extend( DataTable.ext.classes, {
  12531. "sTable": "dataTable",
  12532. "sNoFooter": "no-footer",
  12533. /* Paging buttons */
  12534. "sPageButton": "paginate_button",
  12535. "sPageButtonActive": "current",
  12536. "sPageButtonDisabled": "disabled",
  12537. /* Striping classes */
  12538. "sStripeOdd": "odd",
  12539. "sStripeEven": "even",
  12540. /* Empty row */
  12541. "sRowEmpty": "dataTables_empty",
  12542. /* Features */
  12543. "sWrapper": "dataTables_wrapper",
  12544. "sFilter": "dataTables_filter",
  12545. "sInfo": "dataTables_info",
  12546. "sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */
  12547. "sLength": "dataTables_length",
  12548. "sProcessing": "dataTables_processing",
  12549. /* Sorting */
  12550. "sSortAsc": "sorting_asc",
  12551. "sSortDesc": "sorting_desc",
  12552. "sSortable": "sorting", /* Sortable in both directions */
  12553. "sSortableAsc": "sorting_asc_disabled",
  12554. "sSortableDesc": "sorting_desc_disabled",
  12555. "sSortableNone": "sorting_disabled",
  12556. "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
  12557. /* Filtering */
  12558. "sFilterInput": "",
  12559. /* Page length */
  12560. "sLengthSelect": "",
  12561. /* Scrolling */
  12562. "sScrollWrapper": "dataTables_scroll",
  12563. "sScrollHead": "dataTables_scrollHead",
  12564. "sScrollHeadInner": "dataTables_scrollHeadInner",
  12565. "sScrollBody": "dataTables_scrollBody",
  12566. "sScrollFoot": "dataTables_scrollFoot",
  12567. "sScrollFootInner": "dataTables_scrollFootInner",
  12568. /* Misc */
  12569. "sHeaderTH": "",
  12570. "sFooterTH": "",
  12571. // Deprecated
  12572. "sSortJUIAsc": "",
  12573. "sSortJUIDesc": "",
  12574. "sSortJUI": "",
  12575. "sSortJUIAscAllowed": "",
  12576. "sSortJUIDescAllowed": "",
  12577. "sSortJUIWrapper": "",
  12578. "sSortIcon": "",
  12579. "sJUIHeader": "",
  12580. "sJUIFooter": ""
  12581. } );
  12582. (function() {
  12583. // Reused strings for better compression. Closure compiler appears to have a
  12584. // weird edge case where it is trying to expand strings rather than use the
  12585. // variable version. This results in about 200 bytes being added, for very
  12586. // little preference benefit since it this run on script load only.
  12587. var _empty = '';
  12588. _empty = '';
  12589. var _stateDefault = _empty + 'ui-state-default';
  12590. var _sortIcon = _empty + 'css_right ui-icon ui-icon-';
  12591. var _headerFooter = _empty + 'fg-toolbar ui-toolbar ui-widget-header ui-helper-clearfix';
  12592. $.extend( DataTable.ext.oJUIClasses, DataTable.ext.classes, {
  12593. /* Full numbers paging buttons */
  12594. "sPageButton": "fg-button ui-button "+_stateDefault,
  12595. "sPageButtonActive": "ui-state-disabled",
  12596. "sPageButtonDisabled": "ui-state-disabled",
  12597. /* Features */
  12598. "sPaging": "dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi "+
  12599. "ui-buttonset-multi paging_", /* Note that the type is postfixed */
  12600. /* Sorting */
  12601. "sSortAsc": _stateDefault+" sorting_asc",
  12602. "sSortDesc": _stateDefault+" sorting_desc",
  12603. "sSortable": _stateDefault+" sorting",
  12604. "sSortableAsc": _stateDefault+" sorting_asc_disabled",
  12605. "sSortableDesc": _stateDefault+" sorting_desc_disabled",
  12606. "sSortableNone": _stateDefault+" sorting_disabled",
  12607. "sSortJUIAsc": _sortIcon+"triangle-1-n",
  12608. "sSortJUIDesc": _sortIcon+"triangle-1-s",
  12609. "sSortJUI": _sortIcon+"carat-2-n-s",
  12610. "sSortJUIAscAllowed": _sortIcon+"carat-1-n",
  12611. "sSortJUIDescAllowed": _sortIcon+"carat-1-s",
  12612. "sSortJUIWrapper": "DataTables_sort_wrapper",
  12613. "sSortIcon": "DataTables_sort_icon",
  12614. /* Scrolling */
  12615. "sScrollHead": "dataTables_scrollHead "+_stateDefault,
  12616. "sScrollFoot": "dataTables_scrollFoot "+_stateDefault,
  12617. /* Misc */
  12618. "sHeaderTH": _stateDefault,
  12619. "sFooterTH": _stateDefault,
  12620. "sJUIHeader": _headerFooter+" ui-corner-tl ui-corner-tr",
  12621. "sJUIFooter": _headerFooter+" ui-corner-bl ui-corner-br"
  12622. } );
  12623. }());
  12624. var extPagination = DataTable.ext.pager;
  12625. function _numbers ( page, pages ) {
  12626. var
  12627. numbers = [],
  12628. buttons = extPagination.numbers_length,
  12629. half = Math.floor( buttons / 2 ),
  12630. i = 1;
  12631. if ( pages <= buttons ) {
  12632. numbers = _range( 0, pages );
  12633. }
  12634. else if ( page <= half ) {
  12635. numbers = _range( 0, buttons-2 );
  12636. numbers.push( 'ellipsis' );
  12637. numbers.push( pages-1 );
  12638. }
  12639. else if ( page >= pages - 1 - half ) {
  12640. numbers = _range( pages-(buttons-2), pages );
  12641. numbers.splice( 0, 0, 'ellipsis' ); // no unshift in ie6
  12642. numbers.splice( 0, 0, 0 );
  12643. }
  12644. else {
  12645. numbers = _range( page-half+2, page+half-1 );
  12646. numbers.push( 'ellipsis' );
  12647. numbers.push( pages-1 );
  12648. numbers.splice( 0, 0, 'ellipsis' );
  12649. numbers.splice( 0, 0, 0 );
  12650. }
  12651. numbers.DT_el = 'span';
  12652. return numbers;
  12653. }
  12654. $.extend( extPagination, {
  12655. simple: function ( page, pages ) {
  12656. return [ 'previous', 'next' ];
  12657. },
  12658. full: function ( page, pages ) {
  12659. return [ 'first', 'previous', 'next', 'last' ];
  12660. },
  12661. numbers: function ( page, pages ) {
  12662. return [ _numbers(page, pages) ];
  12663. },
  12664. simple_numbers: function ( page, pages ) {
  12665. return [ 'previous', _numbers(page, pages), 'next' ];
  12666. },
  12667. full_numbers: function ( page, pages ) {
  12668. return [ 'first', 'previous', _numbers(page, pages), 'next', 'last' ];
  12669. },
  12670. first_last_numbers: function (page, pages) {
  12671. return ['first', _numbers(page, pages), 'last'];
  12672. },
  12673. // For testing and plug-ins to use
  12674. _numbers: _numbers,
  12675. // Number of number buttons (including ellipsis) to show. _Must be odd!_
  12676. numbers_length: 7
  12677. } );
  12678. $.extend( true, DataTable.ext.renderer, {
  12679. pageButton: {
  12680. _: function ( settings, host, idx, buttons, page, pages ) {
  12681. var classes = settings.oClasses;
  12682. var lang = settings.oLanguage.oPaginate;
  12683. var aria = settings.oLanguage.oAria.paginate || {};
  12684. var btnDisplay, btnClass, counter=0;
  12685. var attach = function( container, buttons ) {
  12686. var i, ien, node, button;
  12687. var clickHandler = function ( e ) {
  12688. _fnPageChange( settings, e.data.action, true );
  12689. };
  12690. for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
  12691. button = buttons[i];
  12692. if ( $.isArray( button ) ) {
  12693. var inner = $( '<'+(button.DT_el || 'div')+'/>' )
  12694. .appendTo( container );
  12695. attach( inner, button );
  12696. }
  12697. else {
  12698. btnDisplay = null;
  12699. btnClass = '';
  12700. switch ( button ) {
  12701. case 'ellipsis':
  12702. container.append('<span class="ellipsis">&#x2026;</span>');
  12703. break;
  12704. case 'first':
  12705. btnDisplay = lang.sFirst;
  12706. btnClass = button + (page > 0 ?
  12707. '' : ' '+classes.sPageButtonDisabled);
  12708. break;
  12709. case 'previous':
  12710. btnDisplay = lang.sPrevious;
  12711. btnClass = button + (page > 0 ?
  12712. '' : ' '+classes.sPageButtonDisabled);
  12713. break;
  12714. case 'next':
  12715. btnDisplay = lang.sNext;
  12716. btnClass = button + (page < pages-1 ?
  12717. '' : ' '+classes.sPageButtonDisabled);
  12718. break;
  12719. case 'last':
  12720. btnDisplay = lang.sLast;
  12721. btnClass = button + (page < pages-1 ?
  12722. '' : ' '+classes.sPageButtonDisabled);
  12723. break;
  12724. default:
  12725. btnDisplay = button + 1;
  12726. btnClass = page === button ?
  12727. classes.sPageButtonActive : '';
  12728. break;
  12729. }
  12730. if ( btnDisplay !== null ) {
  12731. node = $('<a>', {
  12732. 'class': classes.sPageButton+' '+btnClass,
  12733. 'aria-controls': settings.sTableId,
  12734. 'aria-label': aria[ button ],
  12735. 'data-dt-idx': counter,
  12736. 'tabindex': settings.iTabIndex,
  12737. 'id': idx === 0 && typeof button === 'string' ?
  12738. settings.sTableId +'_'+ button :
  12739. null
  12740. } )
  12741. .html( btnDisplay )
  12742. .appendTo( container );
  12743. _fnBindAction(
  12744. node, {action: button}, clickHandler
  12745. );
  12746. counter++;
  12747. }
  12748. }
  12749. }
  12750. };
  12751. // IE9 throws an 'unknown error' if document.activeElement is used
  12752. // inside an iframe or frame. Try / catch the error. Not good for
  12753. // accessibility, but neither are frames.
  12754. var activeEl;
  12755. try {
  12756. // Because this approach is destroying and recreating the paging
  12757. // elements, focus is lost on the select button which is bad for
  12758. // accessibility. So we want to restore focus once the draw has
  12759. // completed
  12760. activeEl = $(host).find(document.activeElement).data('dt-idx');
  12761. }
  12762. catch (e) {}
  12763. attach( $(host).empty(), buttons );
  12764. if ( activeEl !== undefined ) {
  12765. $(host).find( '[data-dt-idx='+activeEl+']' ).focus();
  12766. }
  12767. }
  12768. }
  12769. } );
  12770. // Built in type detection. See model.ext.aTypes for information about
  12771. // what is required from this methods.
  12772. $.extend( DataTable.ext.type.detect, [
  12773. // Plain numbers - first since V8 detects some plain numbers as dates
  12774. // e.g. Date.parse('55') (but not all, e.g. Date.parse('22')...).
  12775. function ( d, settings )
  12776. {
  12777. var decimal = settings.oLanguage.sDecimal;
  12778. return _isNumber( d, decimal ) ? 'num'+decimal : null;
  12779. },
  12780. // Dates (only those recognised by the browser's Date.parse)
  12781. function ( d, settings )
  12782. {
  12783. // V8 tries _very_ hard to make a string passed into `Date.parse()`
  12784. // valid, so we need to use a regex to restrict date formats. Use a
  12785. // plug-in for anything other than ISO8601 style strings
  12786. if ( d && !(d instanceof Date) && ! _re_date.test(d) ) {
  12787. return null;
  12788. }
  12789. var parsed = Date.parse(d);
  12790. return (parsed !== null && !isNaN(parsed)) || _empty(d) ? 'date' : null;
  12791. },
  12792. // Formatted numbers
  12793. function ( d, settings )
  12794. {
  12795. var decimal = settings.oLanguage.sDecimal;
  12796. return _isNumber( d, decimal, true ) ? 'num-fmt'+decimal : null;
  12797. },
  12798. // HTML numeric
  12799. function ( d, settings )
  12800. {
  12801. var decimal = settings.oLanguage.sDecimal;
  12802. return _htmlNumeric( d, decimal ) ? 'html-num'+decimal : null;
  12803. },
  12804. // HTML numeric, formatted
  12805. function ( d, settings )
  12806. {
  12807. var decimal = settings.oLanguage.sDecimal;
  12808. return _htmlNumeric( d, decimal, true ) ? 'html-num-fmt'+decimal : null;
  12809. },
  12810. // HTML (this is strict checking - there must be html)
  12811. function ( d, settings )
  12812. {
  12813. return _empty( d ) || (typeof d === 'string' && d.indexOf('<') !== -1) ?
  12814. 'html' : null;
  12815. }
  12816. ] );
  12817. // Filter formatting functions. See model.ext.ofnSearch for information about
  12818. // what is required from these methods.
  12819. //
  12820. // Note that additional search methods are added for the html numbers and
  12821. // html formatted numbers by `_addNumericSort()` when we know what the decimal
  12822. // place is
  12823. $.extend( DataTable.ext.type.search, {
  12824. html: function ( data ) {
  12825. return _empty(data) ?
  12826. data :
  12827. typeof data === 'string' ?
  12828. data
  12829. .replace( _re_new_lines, " " )
  12830. .replace( _re_html, "" ) :
  12831. '';
  12832. },
  12833. string: function ( data ) {
  12834. return _empty(data) ?
  12835. data :
  12836. typeof data === 'string' ?
  12837. data.replace( _re_new_lines, " " ) :
  12838. data;
  12839. }
  12840. } );
  12841. var __numericReplace = function ( d, decimalPlace, re1, re2 ) {
  12842. if ( d !== 0 && (!d || d === '-') ) {
  12843. return -Infinity;
  12844. }
  12845. // If a decimal place other than `.` is used, it needs to be given to the
  12846. // function so we can detect it and replace with a `.` which is the only
  12847. // decimal place Javascript recognises - it is not locale aware.
  12848. if ( decimalPlace ) {
  12849. d = _numToDecimal( d, decimalPlace );
  12850. }
  12851. if ( d.replace ) {
  12852. if ( re1 ) {
  12853. d = d.replace( re1, '' );
  12854. }
  12855. if ( re2 ) {
  12856. d = d.replace( re2, '' );
  12857. }
  12858. }
  12859. return d * 1;
  12860. };
  12861. // Add the numeric 'deformatting' functions for sorting and search. This is done
  12862. // in a function to provide an easy ability for the language options to add
  12863. // additional methods if a non-period decimal place is used.
  12864. function _addNumericSort ( decimalPlace ) {
  12865. $.each(
  12866. {
  12867. // Plain numbers
  12868. "num": function ( d ) {
  12869. return __numericReplace( d, decimalPlace );
  12870. },
  12871. // Formatted numbers
  12872. "num-fmt": function ( d ) {
  12873. return __numericReplace( d, decimalPlace, _re_formatted_numeric );
  12874. },
  12875. // HTML numeric
  12876. "html-num": function ( d ) {
  12877. return __numericReplace( d, decimalPlace, _re_html );
  12878. },
  12879. // HTML numeric, formatted
  12880. "html-num-fmt": function ( d ) {
  12881. return __numericReplace( d, decimalPlace, _re_html, _re_formatted_numeric );
  12882. }
  12883. },
  12884. function ( key, fn ) {
  12885. // Add the ordering method
  12886. _ext.type.order[ key+decimalPlace+'-pre' ] = fn;
  12887. // For HTML types add a search formatter that will strip the HTML
  12888. if ( key.match(/^html\-/) ) {
  12889. _ext.type.search[ key+decimalPlace ] = _ext.type.search.html;
  12890. }
  12891. }
  12892. );
  12893. }
  12894. // Default sort methods
  12895. $.extend( _ext.type.order, {
  12896. // Dates
  12897. "date-pre": function ( d ) {
  12898. return Date.parse( d ) || -Infinity;
  12899. },
  12900. // html
  12901. "html-pre": function ( a ) {
  12902. return _empty(a) ?
  12903. '' :
  12904. a.replace ?
  12905. a.replace( /<.*?>/g, "" ).toLowerCase() :
  12906. a+'';
  12907. },
  12908. // string
  12909. "string-pre": function ( a ) {
  12910. // This is a little complex, but faster than always calling toString,
  12911. // http://jsperf.com/tostring-v-check
  12912. return _empty(a) ?
  12913. '' :
  12914. typeof a === 'string' ?
  12915. a.toLowerCase() :
  12916. ! a.toString ?
  12917. '' :
  12918. a.toString();
  12919. },
  12920. // string-asc and -desc are retained only for compatibility with the old
  12921. // sort methods
  12922. "string-asc": function ( x, y ) {
  12923. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12924. },
  12925. "string-desc": function ( x, y ) {
  12926. return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12927. }
  12928. } );
  12929. // Numeric sorting types - order doesn't matter here
  12930. _addNumericSort( '' );
  12931. $.extend( true, DataTable.ext.renderer, {
  12932. header: {
  12933. _: function ( settings, cell, column, classes ) {
  12934. // No additional mark-up required
  12935. // Attach a sort listener to update on sort - note that using the
  12936. // `DT` namespace will allow the event to be removed automatically
  12937. // on destroy, while the `dt` namespaced event is the one we are
  12938. // listening for
  12939. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  12940. if ( settings !== ctx ) { // need to check this this is the host
  12941. return; // table, not a nested one
  12942. }
  12943. var colIdx = column.idx;
  12944. cell
  12945. .removeClass(
  12946. column.sSortingClass +' '+
  12947. classes.sSortAsc +' '+
  12948. classes.sSortDesc
  12949. )
  12950. .addClass( columns[ colIdx ] == 'asc' ?
  12951. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  12952. classes.sSortDesc :
  12953. column.sSortingClass
  12954. );
  12955. } );
  12956. },
  12957. jqueryui: function ( settings, cell, column, classes ) {
  12958. $('<div/>')
  12959. .addClass( classes.sSortJUIWrapper )
  12960. .append( cell.contents() )
  12961. .append( $('<span/>')
  12962. .addClass( classes.sSortIcon+' '+column.sSortingClassJUI )
  12963. )
  12964. .appendTo( cell );
  12965. // Attach a sort listener to update on sort
  12966. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  12967. if ( settings !== ctx ) {
  12968. return;
  12969. }
  12970. var colIdx = column.idx;
  12971. cell
  12972. .removeClass( classes.sSortAsc +" "+classes.sSortDesc )
  12973. .addClass( columns[ colIdx ] == 'asc' ?
  12974. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  12975. classes.sSortDesc :
  12976. column.sSortingClass
  12977. );
  12978. cell
  12979. .find( 'span.'+classes.sSortIcon )
  12980. .removeClass(
  12981. classes.sSortJUIAsc +" "+
  12982. classes.sSortJUIDesc +" "+
  12983. classes.sSortJUI +" "+
  12984. classes.sSortJUIAscAllowed +" "+
  12985. classes.sSortJUIDescAllowed
  12986. )
  12987. .addClass( columns[ colIdx ] == 'asc' ?
  12988. classes.sSortJUIAsc : columns[ colIdx ] == 'desc' ?
  12989. classes.sSortJUIDesc :
  12990. column.sSortingClassJUI
  12991. );
  12992. } );
  12993. }
  12994. }
  12995. } );
  12996. /*
  12997. * Public helper functions. These aren't used internally by DataTables, or
  12998. * called by any of the options passed into DataTables, but they can be used
  12999. * externally by developers working with DataTables. They are helper functions
  13000. * to make working with DataTables a little bit easier.
  13001. */
  13002. var __htmlEscapeEntities = function ( d ) {
  13003. return typeof d === 'string' ?
  13004. d.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;') :
  13005. d;
  13006. };
  13007. /**
  13008. * Helpers for `columns.render`.
  13009. *
  13010. * The options defined here can be used with the `columns.render` initialisation
  13011. * option to provide a display renderer. The following functions are defined:
  13012. *
  13013. * * `number` - Will format numeric data (defined by `columns.data`) for
  13014. * display, retaining the original unformatted data for sorting and filtering.
  13015. * It takes 5 parameters:
  13016. * * `string` - Thousands grouping separator
  13017. * * `string` - Decimal point indicator
  13018. * * `integer` - Number of decimal points to show
  13019. * * `string` (optional) - Prefix.
  13020. * * `string` (optional) - Postfix (/suffix).
  13021. * * `text` - Escape HTML to help prevent XSS attacks. It has no optional
  13022. * parameters.
  13023. *
  13024. * @example
  13025. * // Column definition using the number renderer
  13026. * {
  13027. * data: "salary",
  13028. * render: $.fn.dataTable.render.number( '\'', '.', 0, '$' )
  13029. * }
  13030. *
  13031. * @namespace
  13032. */
  13033. DataTable.render = {
  13034. number: function ( thousands, decimal, precision, prefix, postfix ) {
  13035. return {
  13036. display: function ( d ) {
  13037. if ( typeof d !== 'number' && typeof d !== 'string' ) {
  13038. return d;
  13039. }
  13040. var negative = d < 0 ? '-' : '';
  13041. var flo = parseFloat( d );
  13042. // If NaN then there isn't much formatting that we can do - just
  13043. // return immediately, escaping any HTML (this was supposed to
  13044. // be a number after all)
  13045. if ( isNaN( flo ) ) {
  13046. return __htmlEscapeEntities( d );
  13047. }
  13048. flo = flo.toFixed( precision );
  13049. d = Math.abs( flo );
  13050. var intPart = parseInt( d, 10 );
  13051. var floatPart = precision ?
  13052. decimal+(d - intPart).toFixed( precision ).substring( 2 ):
  13053. '';
  13054. return negative + (prefix||'') +
  13055. intPart.toString().replace(
  13056. /\B(?=(\d{3})+(?!\d))/g, thousands
  13057. ) +
  13058. floatPart +
  13059. (postfix||'');
  13060. }
  13061. };
  13062. },
  13063. text: function () {
  13064. return {
  13065. display: __htmlEscapeEntities
  13066. };
  13067. }
  13068. };
  13069. /*
  13070. * This is really a good bit rubbish this method of exposing the internal methods
  13071. * publicly... - To be fixed in 2.0 using methods on the prototype
  13072. */
  13073. /**
  13074. * Create a wrapper function for exporting an internal functions to an external API.
  13075. * @param {string} fn API function name
  13076. * @returns {function} wrapped function
  13077. * @memberof DataTable#internal
  13078. */
  13079. function _fnExternApiFunc (fn)
  13080. {
  13081. return function() {
  13082. var args = [_fnSettingsFromNode( this[DataTable.ext.iApiIndex] )].concat(
  13083. Array.prototype.slice.call(arguments)
  13084. );
  13085. return DataTable.ext.internal[fn].apply( this, args );
  13086. };
  13087. }
  13088. /**
  13089. * Reference to internal functions for use by plug-in developers. Note that
  13090. * these methods are references to internal functions and are considered to be
  13091. * private. If you use these methods, be aware that they are liable to change
  13092. * between versions.
  13093. * @namespace
  13094. */
  13095. $.extend( DataTable.ext.internal, {
  13096. _fnExternApiFunc: _fnExternApiFunc,
  13097. _fnBuildAjax: _fnBuildAjax,
  13098. _fnAjaxUpdate: _fnAjaxUpdate,
  13099. _fnAjaxParameters: _fnAjaxParameters,
  13100. _fnAjaxUpdateDraw: _fnAjaxUpdateDraw,
  13101. _fnAjaxDataSrc: _fnAjaxDataSrc,
  13102. _fnAddColumn: _fnAddColumn,
  13103. _fnColumnOptions: _fnColumnOptions,
  13104. _fnAdjustColumnSizing: _fnAdjustColumnSizing,
  13105. _fnVisibleToColumnIndex: _fnVisibleToColumnIndex,
  13106. _fnColumnIndexToVisible: _fnColumnIndexToVisible,
  13107. _fnVisbleColumns: _fnVisbleColumns,
  13108. _fnGetColumns: _fnGetColumns,
  13109. _fnColumnTypes: _fnColumnTypes,
  13110. _fnApplyColumnDefs: _fnApplyColumnDefs,
  13111. _fnHungarianMap: _fnHungarianMap,
  13112. _fnCamelToHungarian: _fnCamelToHungarian,
  13113. _fnLanguageCompat: _fnLanguageCompat,
  13114. _fnBrowserDetect: _fnBrowserDetect,
  13115. _fnAddData: _fnAddData,
  13116. _fnAddTr: _fnAddTr,
  13117. _fnNodeToDataIndex: _fnNodeToDataIndex,
  13118. _fnNodeToColumnIndex: _fnNodeToColumnIndex,
  13119. _fnGetCellData: _fnGetCellData,
  13120. _fnSetCellData: _fnSetCellData,
  13121. _fnSplitObjNotation: _fnSplitObjNotation,
  13122. _fnGetObjectDataFn: _fnGetObjectDataFn,
  13123. _fnSetObjectDataFn: _fnSetObjectDataFn,
  13124. _fnGetDataMaster: _fnGetDataMaster,
  13125. _fnClearTable: _fnClearTable,
  13126. _fnDeleteIndex: _fnDeleteIndex,
  13127. _fnInvalidate: _fnInvalidate,
  13128. _fnGetRowElements: _fnGetRowElements,
  13129. _fnCreateTr: _fnCreateTr,
  13130. _fnBuildHead: _fnBuildHead,
  13131. _fnDrawHead: _fnDrawHead,
  13132. _fnDraw: _fnDraw,
  13133. _fnReDraw: _fnReDraw,
  13134. _fnAddOptionsHtml: _fnAddOptionsHtml,
  13135. _fnDetectHeader: _fnDetectHeader,
  13136. _fnGetUniqueThs: _fnGetUniqueThs,
  13137. _fnFeatureHtmlFilter: _fnFeatureHtmlFilter,
  13138. _fnFilterComplete: _fnFilterComplete,
  13139. _fnFilterCustom: _fnFilterCustom,
  13140. _fnFilterColumn: _fnFilterColumn,
  13141. _fnFilter: _fnFilter,
  13142. _fnFilterCreateSearch: _fnFilterCreateSearch,
  13143. _fnEscapeRegex: _fnEscapeRegex,
  13144. _fnFilterData: _fnFilterData,
  13145. _fnFeatureHtmlInfo: _fnFeatureHtmlInfo,
  13146. _fnUpdateInfo: _fnUpdateInfo,
  13147. _fnInfoMacros: _fnInfoMacros,
  13148. _fnInitialise: _fnInitialise,
  13149. _fnInitComplete: _fnInitComplete,
  13150. _fnLengthChange: _fnLengthChange,
  13151. _fnFeatureHtmlLength: _fnFeatureHtmlLength,
  13152. _fnFeatureHtmlPaginate: _fnFeatureHtmlPaginate,
  13153. _fnPageChange: _fnPageChange,
  13154. _fnFeatureHtmlProcessing: _fnFeatureHtmlProcessing,
  13155. _fnProcessingDisplay: _fnProcessingDisplay,
  13156. _fnFeatureHtmlTable: _fnFeatureHtmlTable,
  13157. _fnScrollDraw: _fnScrollDraw,
  13158. _fnApplyToChildren: _fnApplyToChildren,
  13159. _fnCalculateColumnWidths: _fnCalculateColumnWidths,
  13160. _fnThrottle: _fnThrottle,
  13161. _fnConvertToWidth: _fnConvertToWidth,
  13162. _fnGetWidestNode: _fnGetWidestNode,
  13163. _fnGetMaxLenString: _fnGetMaxLenString,
  13164. _fnStringToCss: _fnStringToCss,
  13165. _fnSortFlatten: _fnSortFlatten,
  13166. _fnSort: _fnSort,
  13167. _fnSortAria: _fnSortAria,
  13168. _fnSortListener: _fnSortListener,
  13169. _fnSortAttachListener: _fnSortAttachListener,
  13170. _fnSortingClasses: _fnSortingClasses,
  13171. _fnSortData: _fnSortData,
  13172. _fnSaveState: _fnSaveState,
  13173. _fnLoadState: _fnLoadState,
  13174. _fnSettingsFromNode: _fnSettingsFromNode,
  13175. _fnLog: _fnLog,
  13176. _fnMap: _fnMap,
  13177. _fnBindAction: _fnBindAction,
  13178. _fnCallbackReg: _fnCallbackReg,
  13179. _fnCallbackFire: _fnCallbackFire,
  13180. _fnLengthOverflow: _fnLengthOverflow,
  13181. _fnRenderer: _fnRenderer,
  13182. _fnDataSource: _fnDataSource,
  13183. _fnRowAttributes: _fnRowAttributes,
  13184. _fnCalculateEnd: function () {} // Used by a lot of plug-ins, but redundant
  13185. // in 1.10, so this dead-end function is
  13186. // added to prevent errors
  13187. } );
  13188. // jQuery access
  13189. $.fn.dataTable = DataTable;
  13190. // Provide access to the host jQuery object (circular reference)
  13191. DataTable.$ = $;
  13192. // Legacy aliases
  13193. $.fn.dataTableSettings = DataTable.settings;
  13194. $.fn.dataTableExt = DataTable.ext;
  13195. // With a capital `D` we return a DataTables API instance rather than a
  13196. // jQuery object
  13197. $.fn.DataTable = function ( opts ) {
  13198. return $(this).dataTable( opts ).api();
  13199. };
  13200. // All properties that are available to $.fn.dataTable should also be
  13201. // available on $.fn.DataTable
  13202. $.each( DataTable, function ( prop, val ) {
  13203. $.fn.DataTable[ prop ] = val;
  13204. } );
  13205. // Information about events fired by DataTables - for documentation.
  13206. /**
  13207. * Draw event, fired whenever the table is redrawn on the page, at the same
  13208. * point as fnDrawCallback. This may be useful for binding events or
  13209. * performing calculations when the table is altered at all.
  13210. * @name DataTable#draw.dt
  13211. * @event
  13212. * @param {event} e jQuery event object
  13213. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13214. */
  13215. /**
  13216. * Search event, fired when the searching applied to the table (using the
  13217. * built-in global search, or column filters) is altered.
  13218. * @name DataTable#search.dt
  13219. * @event
  13220. * @param {event} e jQuery event object
  13221. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13222. */
  13223. /**
  13224. * Page change event, fired when the paging of the table is altered.
  13225. * @name DataTable#page.dt
  13226. * @event
  13227. * @param {event} e jQuery event object
  13228. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13229. */
  13230. /**
  13231. * Order event, fired when the ordering applied to the table is altered.
  13232. * @name DataTable#order.dt
  13233. * @event
  13234. * @param {event} e jQuery event object
  13235. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13236. */
  13237. /**
  13238. * DataTables initialisation complete event, fired when the table is fully
  13239. * drawn, including Ajax data loaded, if Ajax data is required.
  13240. * @name DataTable#init.dt
  13241. * @event
  13242. * @param {event} e jQuery event object
  13243. * @param {object} oSettings DataTables settings object
  13244. * @param {object} json The JSON object request from the server - only
  13245. * present if client-side Ajax sourced data is used</li></ol>
  13246. */
  13247. /**
  13248. * State save event, fired when the table has changed state a new state save
  13249. * is required. This event allows modification of the state saving object
  13250. * prior to actually doing the save, including addition or other state
  13251. * properties (for plug-ins) or modification of a DataTables core property.
  13252. * @name DataTable#stateSaveParams.dt
  13253. * @event
  13254. * @param {event} e jQuery event object
  13255. * @param {object} oSettings DataTables settings object
  13256. * @param {object} json The state information to be saved
  13257. */
  13258. /**
  13259. * State load event, fired when the table is loading state from the stored
  13260. * data, but prior to the settings object being modified by the saved state
  13261. * - allowing modification of the saved state is required or loading of
  13262. * state for a plug-in.
  13263. * @name DataTable#stateLoadParams.dt
  13264. * @event
  13265. * @param {event} e jQuery event object
  13266. * @param {object} oSettings DataTables settings object
  13267. * @param {object} json The saved state information
  13268. */
  13269. /**
  13270. * State loaded event, fired when state has been loaded from stored data and
  13271. * the settings object has been modified by the loaded data.
  13272. * @name DataTable#stateLoaded.dt
  13273. * @event
  13274. * @param {event} e jQuery event object
  13275. * @param {object} oSettings DataTables settings object
  13276. * @param {object} json The saved state information
  13277. */
  13278. /**
  13279. * Processing event, fired when DataTables is doing some kind of processing
  13280. * (be it, order, searcg or anything else). It can be used to indicate to
  13281. * the end user that there is something happening, or that something has
  13282. * finished.
  13283. * @name DataTable#processing.dt
  13284. * @event
  13285. * @param {event} e jQuery event object
  13286. * @param {object} oSettings DataTables settings object
  13287. * @param {boolean} bShow Flag for if DataTables is doing processing or not
  13288. */
  13289. /**
  13290. * Ajax (XHR) event, fired whenever an Ajax request is completed from a
  13291. * request to made to the server for new data. This event is called before
  13292. * DataTables processed the returned data, so it can also be used to pre-
  13293. * process the data returned from the server, if needed.
  13294. *
  13295. * Note that this trigger is called in `fnServerData`, if you override
  13296. * `fnServerData` and which to use this event, you need to trigger it in you
  13297. * success function.
  13298. * @name DataTable#xhr.dt
  13299. * @event
  13300. * @param {event} e jQuery event object
  13301. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13302. * @param {object} json JSON returned from the server
  13303. *
  13304. * @example
  13305. * // Use a custom property returned from the server in another DOM element
  13306. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  13307. * $('#status').html( json.status );
  13308. * } );
  13309. *
  13310. * @example
  13311. * // Pre-process the data returned from the server
  13312. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  13313. * for ( var i=0, ien=json.aaData.length ; i<ien ; i++ ) {
  13314. * json.aaData[i].sum = json.aaData[i].one + json.aaData[i].two;
  13315. * }
  13316. * // Note no return - manipulate the data directly in the JSON object.
  13317. * } );
  13318. */
  13319. /**
  13320. * Destroy event, fired when the DataTable is destroyed by calling fnDestroy
  13321. * or passing the bDestroy:true parameter in the initialisation object. This
  13322. * can be used to remove bound events, added DOM nodes, etc.
  13323. * @name DataTable#destroy.dt
  13324. * @event
  13325. * @param {event} e jQuery event object
  13326. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13327. */
  13328. /**
  13329. * Page length change event, fired when number of records to show on each
  13330. * page (the length) is changed.
  13331. * @name DataTable#length.dt
  13332. * @event
  13333. * @param {event} e jQuery event object
  13334. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13335. * @param {integer} len New length
  13336. */
  13337. /**
  13338. * Column sizing has changed.
  13339. * @name DataTable#column-sizing.dt
  13340. * @event
  13341. * @param {event} e jQuery event object
  13342. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13343. */
  13344. /**
  13345. * Column visibility has changed.
  13346. * @name DataTable#column-visibility.dt
  13347. * @event
  13348. * @param {event} e jQuery event object
  13349. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  13350. * @param {int} column Column index
  13351. * @param {bool} vis `false` if column now hidden, or `true` if visible
  13352. */
  13353. return $.fn.dataTable;
  13354. }));