jquery.dataTables.js 425 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840
  1. /*! DataTables 1.10.4
  2. * ©2008-2014 SpryMedia Ltd - datatables.net/license
  3. */
  4. /**
  5. * @summary DataTables
  6. * @description Paginate, search and order HTML tables
  7. * @version 1.10.4
  8. * @file jquery.dataTables.js
  9. * @author SpryMedia Ltd (www.sprymedia.co.uk)
  10. * @contact www.sprymedia.co.uk/contact
  11. * @copyright Copyright 2008-2014 SpryMedia Ltd.
  12. *
  13. * This source file is free software, available under the following license:
  14. * MIT license - http://datatables.net/license
  15. *
  16. * This source file is distributed in the hope that it will be useful, but
  17. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  18. * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.
  19. *
  20. * For details please refer to: http://www.datatables.net
  21. */
  22. /*jslint evil: true, undef: true, browser: true */
  23. /*globals $,require,jQuery,define,_selector_run,_selector_opts,_selector_first,_selector_row_indexes,_ext,_Api,_api_register,_api_registerPlural,_re_new_lines,_re_html,_re_formatted_numeric,_re_escape_regex,_empty,_intVal,_numToDecimal,_isNumber,_isHtml,_htmlNumeric,_pluck,_pluck_order,_range,_stripHtml,_unique,_fnBuildAjax,_fnAjaxUpdate,_fnAjaxParameters,_fnAjaxUpdateDraw,_fnAjaxDataSrc,_fnAddColumn,_fnColumnOptions,_fnAdjustColumnSizing,_fnVisibleToColumnIndex,_fnColumnIndexToVisible,_fnVisbleColumns,_fnGetColumns,_fnColumnTypes,_fnApplyColumnDefs,_fnHungarianMap,_fnCamelToHungarian,_fnLanguageCompat,_fnBrowserDetect,_fnAddData,_fnAddTr,_fnNodeToDataIndex,_fnNodeToColumnIndex,_fnGetCellData,_fnSetCellData,_fnSplitObjNotation,_fnGetObjectDataFn,_fnSetObjectDataFn,_fnGetDataMaster,_fnClearTable,_fnDeleteIndex,_fnInvalidate,_fnGetRowElements,_fnCreateTr,_fnBuildHead,_fnDrawHead,_fnDraw,_fnReDraw,_fnAddOptionsHtml,_fnDetectHeader,_fnGetUniqueThs,_fnFeatureHtmlFilter,_fnFilterComplete,_fnFilterCustom,_fnFilterColumn,_fnFilter,_fnFilterCreateSearch,_fnEscapeRegex,_fnFilterData,_fnFeatureHtmlInfo,_fnUpdateInfo,_fnInfoMacros,_fnInitialise,_fnInitComplete,_fnLengthChange,_fnFeatureHtmlLength,_fnFeatureHtmlPaginate,_fnPageChange,_fnFeatureHtmlProcessing,_fnProcessingDisplay,_fnFeatureHtmlTable,_fnScrollDraw,_fnApplyToChildren,_fnCalculateColumnWidths,_fnThrottle,_fnConvertToWidth,_fnScrollingWidthAdjust,_fnGetWidestNode,_fnGetMaxLenString,_fnStringToCss,_fnScrollBarWidth,_fnSortFlatten,_fnSort,_fnSortAria,_fnSortListener,_fnSortAttachListener,_fnSortingClasses,_fnSortData,_fnSaveState,_fnLoadState,_fnSettingsFromNode,_fnLog,_fnMap,_fnBindAction,_fnCallbackReg,_fnCallbackFire,_fnLengthOverflow,_fnRenderer,_fnDataSource,_fnRowAttributes*/
  24. (/** @lends <global> */function( window, document, undefined ) {
  25. (function( factory ) {
  26. "use strict";
  27. if ( typeof define === 'function' && define.amd ) {
  28. // Define as an AMD module if possible
  29. define( 'datatables', ['jquery'], factory );
  30. }
  31. else if ( typeof exports === 'object' ) {
  32. // Node/CommonJS
  33. factory( require( 'jquery' ) );
  34. }
  35. else if ( jQuery && !jQuery.fn.dataTable ) {
  36. // Define using browser globals otherwise
  37. // Prevent multiple instantiations if the script is loaded twice
  38. factory( jQuery );
  39. }
  40. }
  41. (/** @lends <global> */function( $ ) {
  42. "use strict";
  43. /**
  44. * DataTables is a plug-in for the jQuery Javascript library. It is a highly
  45. * flexible tool, based upon the foundations of progressive enhancement,
  46. * which will add advanced interaction controls to any HTML table. For a
  47. * full list of features please refer to
  48. * [DataTables.net](href="http://datatables.net).
  49. *
  50. * Note that the `DataTable` object is not a global variable but is aliased
  51. * to `jQuery.fn.DataTable` and `jQuery.fn.dataTable` through which it may
  52. * be accessed.
  53. *
  54. * @class
  55. * @param {object} [init={}] Configuration object for DataTables. Options
  56. * are defined by {@link DataTable.defaults}
  57. * @requires jQuery 1.7+
  58. *
  59. * @example
  60. * // Basic initialisation
  61. * $(document).ready( function {
  62. * $('#example').dataTable();
  63. * } );
  64. *
  65. * @example
  66. * // Initialisation with configuration options - in this case, disable
  67. * // pagination and sorting.
  68. * $(document).ready( function {
  69. * $('#example').dataTable( {
  70. * "paginate": false,
  71. * "sort": false
  72. * } );
  73. * } );
  74. */
  75. var DataTable;
  76. /*
  77. * It is useful to have variables which are scoped locally so only the
  78. * DataTables functions can access them and they don't leak into global space.
  79. * At the same time these functions are often useful over multiple files in the
  80. * core and API, so we list, or at least document, all variables which are used
  81. * by DataTables as private variables here. This also ensures that there is no
  82. * clashing of variable names and that they can easily referenced for reuse.
  83. */
  84. // Defined else where
  85. // _selector_run
  86. // _selector_opts
  87. // _selector_first
  88. // _selector_row_indexes
  89. var _ext; // DataTable.ext
  90. var _Api; // DataTable.Api
  91. var _api_register; // DataTable.Api.register
  92. var _api_registerPlural; // DataTable.Api.registerPlural
  93. var _re_dic = {};
  94. var _re_new_lines = /[\r\n]/g;
  95. var _re_html = /<.*?>/g;
  96. var _re_date_start = /^[\w\+\-]/;
  97. var _re_date_end = /[\w\+\-]$/;
  98. // Escape regular expression special characters
  99. var _re_escape_regex = new RegExp( '(\\' + [ '/', '.', '*', '+', '?', '|', '(', ')', '[', ']', '{', '}', '\\', '$', '^', '-' ].join('|\\') + ')', 'g' );
  100. // U+2009 is thin space and U+202F is narrow no-break space, both used in many
  101. // standards as thousands separators
  102. var _re_formatted_numeric = /[',$£€¥%\u2009\u202F]/g;
  103. var _empty = function ( d ) {
  104. return !d || d === true || d === '-' ? true : false;
  105. };
  106. var _intVal = function ( s ) {
  107. var integer = parseInt( s, 10 );
  108. return !isNaN(integer) && isFinite(s) ? integer : null;
  109. };
  110. // Convert from a formatted number with characters other than `.` as the
  111. // decimal place, to a Javascript number
  112. var _numToDecimal = function ( num, decimalPoint ) {
  113. // Cache created regular expressions for speed as this function is called often
  114. if ( ! _re_dic[ decimalPoint ] ) {
  115. _re_dic[ decimalPoint ] = new RegExp( _fnEscapeRegex( decimalPoint ), 'g' );
  116. }
  117. return typeof num === 'string' && decimalPoint !== '.' ?
  118. num.replace( /\./g, '' ).replace( _re_dic[ decimalPoint ], '.' ) :
  119. num;
  120. };
  121. var _isNumber = function ( d, decimalPoint, formatted ) {
  122. var strType = typeof d === 'string';
  123. if ( decimalPoint && strType ) {
  124. d = _numToDecimal( d, decimalPoint );
  125. }
  126. if ( formatted && strType ) {
  127. d = d.replace( _re_formatted_numeric, '' );
  128. }
  129. return _empty( d ) || (!isNaN( parseFloat(d) ) && isFinite( d ));
  130. };
  131. // A string without HTML in it can be considered to be HTML still
  132. var _isHtml = function ( d ) {
  133. return _empty( d ) || typeof d === 'string';
  134. };
  135. var _htmlNumeric = function ( d, decimalPoint, formatted ) {
  136. if ( _empty( d ) ) {
  137. return true;
  138. }
  139. var html = _isHtml( d );
  140. return ! html ?
  141. null :
  142. _isNumber( _stripHtml( d ), decimalPoint, formatted ) ?
  143. true :
  144. null;
  145. };
  146. var _pluck = function ( a, prop, prop2 ) {
  147. var out = [];
  148. var i=0, ien=a.length;
  149. // Could have the test in the loop for slightly smaller code, but speed
  150. // is essential here
  151. if ( prop2 !== undefined ) {
  152. for ( ; i<ien ; i++ ) {
  153. if ( a[i] && a[i][ prop ] ) {
  154. out.push( a[i][ prop ][ prop2 ] );
  155. }
  156. }
  157. }
  158. else {
  159. for ( ; i<ien ; i++ ) {
  160. if ( a[i] ) {
  161. out.push( a[i][ prop ] );
  162. }
  163. }
  164. }
  165. return out;
  166. };
  167. // Basically the same as _pluck, but rather than looping over `a` we use `order`
  168. // as the indexes to pick from `a`
  169. var _pluck_order = function ( a, order, prop, prop2 )
  170. {
  171. var out = [];
  172. var i=0, ien=order.length;
  173. // Could have the test in the loop for slightly smaller code, but speed
  174. // is essential here
  175. if ( prop2 !== undefined ) {
  176. for ( ; i<ien ; i++ ) {
  177. if ( a[ order[i] ][ prop ] ) {
  178. out.push( a[ order[i] ][ prop ][ prop2 ] );
  179. }
  180. }
  181. }
  182. else {
  183. for ( ; i<ien ; i++ ) {
  184. out.push( a[ order[i] ][ prop ] );
  185. }
  186. }
  187. return out;
  188. };
  189. var _range = function ( len, start )
  190. {
  191. var out = [];
  192. var end;
  193. if ( start === undefined ) {
  194. start = 0;
  195. end = len;
  196. }
  197. else {
  198. end = start;
  199. start = len;
  200. }
  201. for ( var i=start ; i<end ; i++ ) {
  202. out.push( i );
  203. }
  204. return out;
  205. };
  206. var _removeEmpty = function ( a )
  207. {
  208. var out = [];
  209. for ( var i=0, ien=a.length ; i<ien ; i++ ) {
  210. if ( a[i] ) { // careful - will remove all falsy values!
  211. out.push( a[i] );
  212. }
  213. }
  214. return out;
  215. };
  216. var _stripHtml = function ( d ) {
  217. return d.replace( _re_html, '' );
  218. };
  219. /**
  220. * Find the unique elements in a source array.
  221. *
  222. * @param {array} src Source array
  223. * @return {array} Array of unique items
  224. * @ignore
  225. */
  226. var _unique = function ( src )
  227. {
  228. // A faster unique method is to use object keys to identify used values,
  229. // but this doesn't work with arrays or objects, which we must also
  230. // consider. See jsperf.com/compare-array-unique-versions/4 for more
  231. // information.
  232. var
  233. out = [],
  234. val,
  235. i, ien=src.length,
  236. j, k=0;
  237. again: for ( i=0 ; i<ien ; i++ ) {
  238. val = src[i];
  239. for ( j=0 ; j<k ; j++ ) {
  240. if ( out[j] === val ) {
  241. continue again;
  242. }
  243. }
  244. out.push( val );
  245. k++;
  246. }
  247. return out;
  248. };
  249. /**
  250. * Create a mapping object that allows camel case parameters to be looked up
  251. * for their Hungarian counterparts. The mapping is stored in a private
  252. * parameter called `_hungarianMap` which can be accessed on the source object.
  253. * @param {object} o
  254. * @memberof DataTable#oApi
  255. */
  256. function _fnHungarianMap ( o )
  257. {
  258. var
  259. hungarian = 'a aa ai ao as b fn i m o s ',
  260. match,
  261. newKey,
  262. map = {};
  263. $.each( o, function (key, val) {
  264. match = key.match(/^([^A-Z]+?)([A-Z])/);
  265. if ( match && hungarian.indexOf(match[1]+' ') !== -1 )
  266. {
  267. newKey = key.replace( match[0], match[2].toLowerCase() );
  268. map[ newKey ] = key;
  269. if ( match[1] === 'o' )
  270. {
  271. _fnHungarianMap( o[key] );
  272. }
  273. }
  274. } );
  275. o._hungarianMap = map;
  276. }
  277. /**
  278. * Convert from camel case parameters to Hungarian, based on a Hungarian map
  279. * created by _fnHungarianMap.
  280. * @param {object} src The model object which holds all parameters that can be
  281. * mapped.
  282. * @param {object} user The object to convert from camel case to Hungarian.
  283. * @param {boolean} force When set to `true`, properties which already have a
  284. * Hungarian value in the `user` object will be overwritten. Otherwise they
  285. * won't be.
  286. * @memberof DataTable#oApi
  287. */
  288. function _fnCamelToHungarian ( src, user, force )
  289. {
  290. if ( ! src._hungarianMap ) {
  291. _fnHungarianMap( src );
  292. }
  293. var hungarianKey;
  294. $.each( user, function (key, val) {
  295. hungarianKey = src._hungarianMap[ key ];
  296. if ( hungarianKey !== undefined && (force || user[hungarianKey] === undefined) )
  297. {
  298. // For objects, we need to buzz down into the object to copy parameters
  299. if ( hungarianKey.charAt(0) === 'o' )
  300. {
  301. // Copy the camelCase options over to the hungarian
  302. if ( ! user[ hungarianKey ] ) {
  303. user[ hungarianKey ] = {};
  304. }
  305. $.extend( true, user[hungarianKey], user[key] );
  306. _fnCamelToHungarian( src[hungarianKey], user[hungarianKey], force );
  307. }
  308. else {
  309. user[hungarianKey] = user[ key ];
  310. }
  311. }
  312. } );
  313. }
  314. /**
  315. * Language compatibility - when certain options are given, and others aren't, we
  316. * need to duplicate the values over, in order to provide backwards compatibility
  317. * with older language files.
  318. * @param {object} oSettings dataTables settings object
  319. * @memberof DataTable#oApi
  320. */
  321. function _fnLanguageCompat( lang )
  322. {
  323. var defaults = DataTable.defaults.oLanguage;
  324. var zeroRecords = lang.sZeroRecords;
  325. /* Backwards compatibility - if there is no sEmptyTable given, then use the same as
  326. * sZeroRecords - assuming that is given.
  327. */
  328. if ( ! lang.sEmptyTable && zeroRecords &&
  329. defaults.sEmptyTable === "No data available in table" )
  330. {
  331. _fnMap( lang, lang, 'sZeroRecords', 'sEmptyTable' );
  332. }
  333. /* Likewise with loading records */
  334. if ( ! lang.sLoadingRecords && zeroRecords &&
  335. defaults.sLoadingRecords === "Loading..." )
  336. {
  337. _fnMap( lang, lang, 'sZeroRecords', 'sLoadingRecords' );
  338. }
  339. // Old parameter name of the thousands separator mapped onto the new
  340. if ( lang.sInfoThousands ) {
  341. lang.sThousands = lang.sInfoThousands;
  342. }
  343. var decimal = lang.sDecimal;
  344. if ( decimal ) {
  345. _addNumericSort( decimal );
  346. }
  347. }
  348. /**
  349. * Map one parameter onto another
  350. * @param {object} o Object to map
  351. * @param {*} knew The new parameter name
  352. * @param {*} old The old parameter name
  353. */
  354. var _fnCompatMap = function ( o, knew, old ) {
  355. if ( o[ knew ] !== undefined ) {
  356. o[ old ] = o[ knew ];
  357. }
  358. };
  359. /**
  360. * Provide backwards compatibility for the main DT options. Note that the new
  361. * options are mapped onto the old parameters, so this is an external interface
  362. * change only.
  363. * @param {object} init Object to map
  364. */
  365. function _fnCompatOpts ( init )
  366. {
  367. _fnCompatMap( init, 'ordering', 'bSort' );
  368. _fnCompatMap( init, 'orderMulti', 'bSortMulti' );
  369. _fnCompatMap( init, 'orderClasses', 'bSortClasses' );
  370. _fnCompatMap( init, 'orderCellsTop', 'bSortCellsTop' );
  371. _fnCompatMap( init, 'order', 'aaSorting' );
  372. _fnCompatMap( init, 'orderFixed', 'aaSortingFixed' );
  373. _fnCompatMap( init, 'paging', 'bPaginate' );
  374. _fnCompatMap( init, 'pagingType', 'sPaginationType' );
  375. _fnCompatMap( init, 'pageLength', 'iDisplayLength' );
  376. _fnCompatMap( init, 'searching', 'bFilter' );
  377. // Column search objects are in an array, so it needs to be converted
  378. // element by element
  379. var searchCols = init.aoSearchCols;
  380. if ( searchCols ) {
  381. for ( var i=0, ien=searchCols.length ; i<ien ; i++ ) {
  382. if ( searchCols[i] ) {
  383. _fnCamelToHungarian( DataTable.models.oSearch, searchCols[i] );
  384. }
  385. }
  386. }
  387. }
  388. /**
  389. * Provide backwards compatibility for column options. Note that the new options
  390. * are mapped onto the old parameters, so this is an external interface change
  391. * only.
  392. * @param {object} init Object to map
  393. */
  394. function _fnCompatCols ( init )
  395. {
  396. _fnCompatMap( init, 'orderable', 'bSortable' );
  397. _fnCompatMap( init, 'orderData', 'aDataSort' );
  398. _fnCompatMap( init, 'orderSequence', 'asSorting' );
  399. _fnCompatMap( init, 'orderDataType', 'sortDataType' );
  400. }
  401. /**
  402. * Browser feature detection for capabilities, quirks
  403. * @param {object} settings dataTables settings object
  404. * @memberof DataTable#oApi
  405. */
  406. function _fnBrowserDetect( settings )
  407. {
  408. var browser = settings.oBrowser;
  409. // Scrolling feature / quirks detection
  410. var n = $('<div/>')
  411. .css( {
  412. position: 'absolute',
  413. top: 0,
  414. left: 0,
  415. height: 1,
  416. width: 1,
  417. overflow: 'hidden'
  418. } )
  419. .append(
  420. $('<div/>')
  421. .css( {
  422. position: 'absolute',
  423. top: 1,
  424. left: 1,
  425. width: 100,
  426. overflow: 'scroll'
  427. } )
  428. .append(
  429. $('<div class="test"/>')
  430. .css( {
  431. width: '100%',
  432. height: 10
  433. } )
  434. )
  435. )
  436. .appendTo( 'body' );
  437. var test = n.find('.test');
  438. // IE6/7 will oversize a width 100% element inside a scrolling element, to
  439. // include the width of the scrollbar, while other browsers ensure the inner
  440. // element is contained without forcing scrolling
  441. browser.bScrollOversize = test[0].offsetWidth === 100;
  442. // In rtl text layout, some browsers (most, but not all) will place the
  443. // scrollbar on the left, rather than the right.
  444. browser.bScrollbarLeft = test.offset().left !== 1;
  445. n.remove();
  446. }
  447. /**
  448. * Array.prototype reduce[Right] method, used for browsers which don't support
  449. * JS 1.6. Done this way to reduce code size, since we iterate either way
  450. * @param {object} settings dataTables settings object
  451. * @memberof DataTable#oApi
  452. */
  453. function _fnReduce ( that, fn, init, start, end, inc )
  454. {
  455. var
  456. i = start,
  457. value,
  458. isSet = false;
  459. if ( init !== undefined ) {
  460. value = init;
  461. isSet = true;
  462. }
  463. while ( i !== end ) {
  464. if ( ! that.hasOwnProperty(i) ) {
  465. continue;
  466. }
  467. value = isSet ?
  468. fn( value, that[i], i, that ) :
  469. that[i];
  470. isSet = true;
  471. i += inc;
  472. }
  473. return value;
  474. }
  475. /**
  476. * Add a column to the list used for the table with default values
  477. * @param {object} oSettings dataTables settings object
  478. * @param {node} nTh The th element for this column
  479. * @memberof DataTable#oApi
  480. */
  481. function _fnAddColumn( oSettings, nTh )
  482. {
  483. // Add column to aoColumns array
  484. var oDefaults = DataTable.defaults.column;
  485. var iCol = oSettings.aoColumns.length;
  486. var oCol = $.extend( {}, DataTable.models.oColumn, oDefaults, {
  487. "nTh": nTh ? nTh : document.createElement('th'),
  488. "sTitle": oDefaults.sTitle ? oDefaults.sTitle : nTh ? nTh.innerHTML : '',
  489. "aDataSort": oDefaults.aDataSort ? oDefaults.aDataSort : [iCol],
  490. "mData": oDefaults.mData ? oDefaults.mData : iCol,
  491. idx: iCol
  492. } );
  493. oSettings.aoColumns.push( oCol );
  494. // Add search object for column specific search. Note that the `searchCols[ iCol ]`
  495. // passed into extend can be undefined. This allows the user to give a default
  496. // with only some of the parameters defined, and also not give a default
  497. var searchCols = oSettings.aoPreSearchCols;
  498. searchCols[ iCol ] = $.extend( {}, DataTable.models.oSearch, searchCols[ iCol ] );
  499. // Use the default column options function to initialise classes etc
  500. _fnColumnOptions( oSettings, iCol, null );
  501. }
  502. /**
  503. * Apply options for a column
  504. * @param {object} oSettings dataTables settings object
  505. * @param {int} iCol column index to consider
  506. * @param {object} oOptions object with sType, bVisible and bSearchable etc
  507. * @memberof DataTable#oApi
  508. */
  509. function _fnColumnOptions( oSettings, iCol, oOptions )
  510. {
  511. var oCol = oSettings.aoColumns[ iCol ];
  512. var oClasses = oSettings.oClasses;
  513. var th = $(oCol.nTh);
  514. // Try to get width information from the DOM. We can't get it from CSS
  515. // as we'd need to parse the CSS stylesheet. `width` option can override
  516. if ( ! oCol.sWidthOrig ) {
  517. // Width attribute
  518. oCol.sWidthOrig = th.attr('width') || null;
  519. // Style attribute
  520. var t = (th.attr('style') || '').match(/width:\s*(\d+[pxem%]+)/);
  521. if ( t ) {
  522. oCol.sWidthOrig = t[1];
  523. }
  524. }
  525. /* User specified column options */
  526. if ( oOptions !== undefined && oOptions !== null )
  527. {
  528. // Backwards compatibility
  529. _fnCompatCols( oOptions );
  530. // Map camel case parameters to their Hungarian counterparts
  531. _fnCamelToHungarian( DataTable.defaults.column, oOptions );
  532. /* Backwards compatibility for mDataProp */
  533. if ( oOptions.mDataProp !== undefined && !oOptions.mData )
  534. {
  535. oOptions.mData = oOptions.mDataProp;
  536. }
  537. if ( oOptions.sType )
  538. {
  539. oCol._sManualType = oOptions.sType;
  540. }
  541. // `class` is a reserved word in Javascript, so we need to provide
  542. // the ability to use a valid name for the camel case input
  543. if ( oOptions.className && ! oOptions.sClass )
  544. {
  545. oOptions.sClass = oOptions.className;
  546. }
  547. $.extend( oCol, oOptions );
  548. _fnMap( oCol, oOptions, "sWidth", "sWidthOrig" );
  549. /* iDataSort to be applied (backwards compatibility), but aDataSort will take
  550. * priority if defined
  551. */
  552. if ( typeof oOptions.iDataSort === 'number' )
  553. {
  554. oCol.aDataSort = [ oOptions.iDataSort ];
  555. }
  556. _fnMap( oCol, oOptions, "aDataSort" );
  557. }
  558. /* Cache the data get and set functions for speed */
  559. var mDataSrc = oCol.mData;
  560. var mData = _fnGetObjectDataFn( mDataSrc );
  561. var mRender = oCol.mRender ? _fnGetObjectDataFn( oCol.mRender ) : null;
  562. var attrTest = function( src ) {
  563. return typeof src === 'string' && src.indexOf('@') !== -1;
  564. };
  565. oCol._bAttrSrc = $.isPlainObject( mDataSrc ) && (
  566. attrTest(mDataSrc.sort) || attrTest(mDataSrc.type) || attrTest(mDataSrc.filter)
  567. );
  568. oCol.fnGetData = function (rowData, type, meta) {
  569. var innerData = mData( rowData, type, undefined, meta );
  570. return mRender && type ?
  571. mRender( innerData, type, rowData, meta ) :
  572. innerData;
  573. };
  574. oCol.fnSetData = function ( rowData, val, meta ) {
  575. return _fnSetObjectDataFn( mDataSrc )( rowData, val, meta );
  576. };
  577. // Indicate if DataTables should read DOM data as an object or array
  578. // Used in _fnGetRowElements
  579. if ( typeof mDataSrc !== 'number' ) {
  580. oSettings._rowReadObject = true;
  581. }
  582. /* Feature sorting overrides column specific when off */
  583. if ( !oSettings.oFeatures.bSort )
  584. {
  585. oCol.bSortable = false;
  586. th.addClass( oClasses.sSortableNone ); // Have to add class here as order event isn't called
  587. }
  588. /* Check that the class assignment is correct for sorting */
  589. var bAsc = $.inArray('asc', oCol.asSorting) !== -1;
  590. var bDesc = $.inArray('desc', oCol.asSorting) !== -1;
  591. if ( !oCol.bSortable || (!bAsc && !bDesc) )
  592. {
  593. oCol.sSortingClass = oClasses.sSortableNone;
  594. oCol.sSortingClassJUI = "";
  595. }
  596. else if ( bAsc && !bDesc )
  597. {
  598. oCol.sSortingClass = oClasses.sSortableAsc;
  599. oCol.sSortingClassJUI = oClasses.sSortJUIAscAllowed;
  600. }
  601. else if ( !bAsc && bDesc )
  602. {
  603. oCol.sSortingClass = oClasses.sSortableDesc;
  604. oCol.sSortingClassJUI = oClasses.sSortJUIDescAllowed;
  605. }
  606. else
  607. {
  608. oCol.sSortingClass = oClasses.sSortable;
  609. oCol.sSortingClassJUI = oClasses.sSortJUI;
  610. }
  611. }
  612. /**
  613. * Adjust the table column widths for new data. Note: you would probably want to
  614. * do a redraw after calling this function!
  615. * @param {object} settings dataTables settings object
  616. * @memberof DataTable#oApi
  617. */
  618. function _fnAdjustColumnSizing ( settings )
  619. {
  620. /* Not interested in doing column width calculation if auto-width is disabled */
  621. if ( settings.oFeatures.bAutoWidth !== false )
  622. {
  623. var columns = settings.aoColumns;
  624. _fnCalculateColumnWidths( settings );
  625. for ( var i=0 , iLen=columns.length ; i<iLen ; i++ )
  626. {
  627. columns[i].nTh.style.width = columns[i].sWidth;
  628. }
  629. }
  630. var scroll = settings.oScroll;
  631. if ( scroll.sY !== '' || scroll.sX !== '')
  632. {
  633. _fnScrollDraw( settings );
  634. }
  635. _fnCallbackFire( settings, null, 'column-sizing', [settings] );
  636. }
  637. /**
  638. * Covert the index of a visible column to the index in the data array (take account
  639. * of hidden columns)
  640. * @param {object} oSettings dataTables settings object
  641. * @param {int} iMatch Visible column index to lookup
  642. * @returns {int} i the data index
  643. * @memberof DataTable#oApi
  644. */
  645. function _fnVisibleToColumnIndex( oSettings, iMatch )
  646. {
  647. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  648. return typeof aiVis[iMatch] === 'number' ?
  649. aiVis[iMatch] :
  650. null;
  651. }
  652. /**
  653. * Covert the index of an index in the data array and convert it to the visible
  654. * column index (take account of hidden columns)
  655. * @param {int} iMatch Column index to lookup
  656. * @param {object} oSettings dataTables settings object
  657. * @returns {int} i the data index
  658. * @memberof DataTable#oApi
  659. */
  660. function _fnColumnIndexToVisible( oSettings, iMatch )
  661. {
  662. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  663. var iPos = $.inArray( iMatch, aiVis );
  664. return iPos !== -1 ? iPos : null;
  665. }
  666. /**
  667. * Get the number of visible columns
  668. * @param {object} oSettings dataTables settings object
  669. * @returns {int} i the number of visible columns
  670. * @memberof DataTable#oApi
  671. */
  672. function _fnVisbleColumns( oSettings )
  673. {
  674. return _fnGetColumns( oSettings, 'bVisible' ).length;
  675. }
  676. /**
  677. * Get an array of column indexes that match a given property
  678. * @param {object} oSettings dataTables settings object
  679. * @param {string} sParam Parameter in aoColumns to look for - typically
  680. * bVisible or bSearchable
  681. * @returns {array} Array of indexes with matched properties
  682. * @memberof DataTable#oApi
  683. */
  684. function _fnGetColumns( oSettings, sParam )
  685. {
  686. var a = [];
  687. $.map( oSettings.aoColumns, function(val, i) {
  688. if ( val[sParam] ) {
  689. a.push( i );
  690. }
  691. } );
  692. return a;
  693. }
  694. /**
  695. * Calculate the 'type' of a column
  696. * @param {object} settings dataTables settings object
  697. * @memberof DataTable#oApi
  698. */
  699. function _fnColumnTypes ( settings )
  700. {
  701. var columns = settings.aoColumns;
  702. var data = settings.aoData;
  703. var types = DataTable.ext.type.detect;
  704. var i, ien, j, jen, k, ken;
  705. var col, cell, detectedType, cache;
  706. // For each column, spin over the
  707. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  708. col = columns[i];
  709. cache = [];
  710. if ( ! col.sType && col._sManualType ) {
  711. col.sType = col._sManualType;
  712. }
  713. else if ( ! col.sType ) {
  714. for ( j=0, jen=types.length ; j<jen ; j++ ) {
  715. for ( k=0, ken=data.length ; k<ken ; k++ ) {
  716. // Use a cache array so we only need to get the type data
  717. // from the formatter once (when using multiple detectors)
  718. if ( cache[k] === undefined ) {
  719. cache[k] = _fnGetCellData( settings, k, i, 'type' );
  720. }
  721. detectedType = types[j]( cache[k], settings );
  722. // If null, then this type can't apply to this column, so
  723. // rather than testing all cells, break out. There is an
  724. // exception for the last type which is `html`. We need to
  725. // scan all rows since it is possible to mix string and HTML
  726. // types
  727. if ( ! detectedType && j !== types.length-1 ) {
  728. break;
  729. }
  730. // Only a single match is needed for html type since it is
  731. // bottom of the pile and very similar to string
  732. if ( detectedType === 'html' ) {
  733. break;
  734. }
  735. }
  736. // Type is valid for all data points in the column - use this
  737. // type
  738. if ( detectedType ) {
  739. col.sType = detectedType;
  740. break;
  741. }
  742. }
  743. // Fall back - if no type was detected, always use string
  744. if ( ! col.sType ) {
  745. col.sType = 'string';
  746. }
  747. }
  748. }
  749. }
  750. /**
  751. * Take the column definitions and static columns arrays and calculate how
  752. * they relate to column indexes. The callback function will then apply the
  753. * definition found for a column to a suitable configuration object.
  754. * @param {object} oSettings dataTables settings object
  755. * @param {array} aoColDefs The aoColumnDefs array that is to be applied
  756. * @param {array} aoCols The aoColumns array that defines columns individually
  757. * @param {function} fn Callback function - takes two parameters, the calculated
  758. * column index and the definition for that column.
  759. * @memberof DataTable#oApi
  760. */
  761. function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, fn )
  762. {
  763. var i, iLen, j, jLen, k, kLen, def;
  764. var columns = oSettings.aoColumns;
  765. // Column definitions with aTargets
  766. if ( aoColDefs )
  767. {
  768. /* Loop over the definitions array - loop in reverse so first instance has priority */
  769. for ( i=aoColDefs.length-1 ; i>=0 ; i-- )
  770. {
  771. def = aoColDefs[i];
  772. /* Each definition can target multiple columns, as it is an array */
  773. var aTargets = def.targets !== undefined ?
  774. def.targets :
  775. def.aTargets;
  776. if ( ! $.isArray( aTargets ) )
  777. {
  778. aTargets = [ aTargets ];
  779. }
  780. for ( j=0, jLen=aTargets.length ; j<jLen ; j++ )
  781. {
  782. if ( typeof aTargets[j] === 'number' && aTargets[j] >= 0 )
  783. {
  784. /* Add columns that we don't yet know about */
  785. while( columns.length <= aTargets[j] )
  786. {
  787. _fnAddColumn( oSettings );
  788. }
  789. /* Integer, basic index */
  790. fn( aTargets[j], def );
  791. }
  792. else if ( typeof aTargets[j] === 'number' && aTargets[j] < 0 )
  793. {
  794. /* Negative integer, right to left column counting */
  795. fn( columns.length+aTargets[j], def );
  796. }
  797. else if ( typeof aTargets[j] === 'string' )
  798. {
  799. /* Class name matching on TH element */
  800. for ( k=0, kLen=columns.length ; k<kLen ; k++ )
  801. {
  802. if ( aTargets[j] == "_all" ||
  803. $(columns[k].nTh).hasClass( aTargets[j] ) )
  804. {
  805. fn( k, def );
  806. }
  807. }
  808. }
  809. }
  810. }
  811. }
  812. // Statically defined columns array
  813. if ( aoCols )
  814. {
  815. for ( i=0, iLen=aoCols.length ; i<iLen ; i++ )
  816. {
  817. fn( i, aoCols[i] );
  818. }
  819. }
  820. }
  821. /**
  822. * Add a data array to the table, creating DOM node etc. This is the parallel to
  823. * _fnGatherData, but for adding rows from a Javascript source, rather than a
  824. * DOM source.
  825. * @param {object} oSettings dataTables settings object
  826. * @param {array} aData data array to be added
  827. * @param {node} [nTr] TR element to add to the table - optional. If not given,
  828. * DataTables will create a row automatically
  829. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  830. * if nTr is.
  831. * @returns {int} >=0 if successful (index of new aoData entry), -1 if failed
  832. * @memberof DataTable#oApi
  833. */
  834. function _fnAddData ( oSettings, aDataIn, nTr, anTds )
  835. {
  836. /* Create the object for storing information about this new row */
  837. var iRow = oSettings.aoData.length;
  838. var oData = $.extend( true, {}, DataTable.models.oRow, {
  839. src: nTr ? 'dom' : 'data'
  840. } );
  841. oData._aData = aDataIn;
  842. oSettings.aoData.push( oData );
  843. /* Create the cells */
  844. var nTd, sThisType;
  845. var columns = oSettings.aoColumns;
  846. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  847. {
  848. // When working with a row, the data source object must be populated. In
  849. // all other cases, the data source object is already populated, so we
  850. // don't overwrite it, which might break bindings etc
  851. if ( nTr ) {
  852. _fnSetCellData( oSettings, iRow, i, _fnGetCellData( oSettings, iRow, i ) );
  853. }
  854. columns[i].sType = null;
  855. }
  856. /* Add to the display array */
  857. oSettings.aiDisplayMaster.push( iRow );
  858. /* Create the DOM information, or register it if already present */
  859. if ( nTr || ! oSettings.oFeatures.bDeferRender )
  860. {
  861. _fnCreateTr( oSettings, iRow, nTr, anTds );
  862. }
  863. return iRow;
  864. }
  865. /**
  866. * Add one or more TR elements to the table. Generally we'd expect to
  867. * use this for reading data from a DOM sourced table, but it could be
  868. * used for an TR element. Note that if a TR is given, it is used (i.e.
  869. * it is not cloned).
  870. * @param {object} settings dataTables settings object
  871. * @param {array|node|jQuery} trs The TR element(s) to add to the table
  872. * @returns {array} Array of indexes for the added rows
  873. * @memberof DataTable#oApi
  874. */
  875. function _fnAddTr( settings, trs )
  876. {
  877. var row;
  878. // Allow an individual node to be passed in
  879. if ( ! (trs instanceof $) ) {
  880. trs = $(trs);
  881. }
  882. return trs.map( function (i, el) {
  883. row = _fnGetRowElements( settings, el );
  884. return _fnAddData( settings, row.data, el, row.cells );
  885. } );
  886. }
  887. /**
  888. * Take a TR element and convert it to an index in aoData
  889. * @param {object} oSettings dataTables settings object
  890. * @param {node} n the TR element to find
  891. * @returns {int} index if the node is found, null if not
  892. * @memberof DataTable#oApi
  893. */
  894. function _fnNodeToDataIndex( oSettings, n )
  895. {
  896. return (n._DT_RowIndex!==undefined) ? n._DT_RowIndex : null;
  897. }
  898. /**
  899. * Take a TD element and convert it into a column data index (not the visible index)
  900. * @param {object} oSettings dataTables settings object
  901. * @param {int} iRow The row number the TD/TH can be found in
  902. * @param {node} n The TD/TH element to find
  903. * @returns {int} index if the node is found, -1 if not
  904. * @memberof DataTable#oApi
  905. */
  906. function _fnNodeToColumnIndex( oSettings, iRow, n )
  907. {
  908. return $.inArray( n, oSettings.aoData[ iRow ].anCells );
  909. }
  910. /**
  911. * Get the data for a given cell from the internal cache, taking into account data mapping
  912. * @param {object} settings dataTables settings object
  913. * @param {int} rowIdx aoData row id
  914. * @param {int} colIdx Column index
  915. * @param {string} type data get type ('display', 'type' 'filter' 'sort')
  916. * @returns {*} Cell data
  917. * @memberof DataTable#oApi
  918. */
  919. function _fnGetCellData( settings, rowIdx, colIdx, type )
  920. {
  921. var draw = settings.iDraw;
  922. var col = settings.aoColumns[colIdx];
  923. var rowData = settings.aoData[rowIdx]._aData;
  924. var defaultContent = col.sDefaultContent;
  925. var cellData = col.fnGetData( rowData, type, {
  926. settings: settings,
  927. row: rowIdx,
  928. col: colIdx
  929. } );
  930. if ( cellData === undefined ) {
  931. if ( settings.iDrawError != draw && defaultContent === null ) {
  932. _fnLog( settings, 0, "Requested unknown parameter "+
  933. (typeof col.mData=='function' ? '{function}' : "'"+col.mData+"'")+
  934. " for row "+rowIdx, 4 );
  935. settings.iDrawError = draw;
  936. }
  937. return defaultContent;
  938. }
  939. /* When the data source is null, we can use default column data */
  940. if ( (cellData === rowData || cellData === null) && defaultContent !== null ) {
  941. cellData = defaultContent;
  942. }
  943. else if ( typeof cellData === 'function' ) {
  944. // If the data source is a function, then we run it and use the return,
  945. // executing in the scope of the data object (for instances)
  946. return cellData.call( rowData );
  947. }
  948. if ( cellData === null && type == 'display' ) {
  949. return '';
  950. }
  951. return cellData;
  952. }
  953. /**
  954. * Set the value for a specific cell, into the internal data cache
  955. * @param {object} settings dataTables settings object
  956. * @param {int} rowIdx aoData row id
  957. * @param {int} colIdx Column index
  958. * @param {*} val Value to set
  959. * @memberof DataTable#oApi
  960. */
  961. function _fnSetCellData( settings, rowIdx, colIdx, val )
  962. {
  963. var col = settings.aoColumns[colIdx];
  964. var rowData = settings.aoData[rowIdx]._aData;
  965. col.fnSetData( rowData, val, {
  966. settings: settings,
  967. row: rowIdx,
  968. col: colIdx
  969. } );
  970. }
  971. // Private variable that is used to match action syntax in the data property object
  972. var __reArray = /\[.*?\]$/;
  973. var __reFn = /\(\)$/;
  974. /**
  975. * Split string on periods, taking into account escaped periods
  976. * @param {string} str String to split
  977. * @return {array} Split string
  978. */
  979. function _fnSplitObjNotation( str )
  980. {
  981. return $.map( str.match(/(\\.|[^\.])+/g), function ( s ) {
  982. return s.replace(/\\./g, '.');
  983. } );
  984. }
  985. /**
  986. * Return a function that can be used to get data from a source object, taking
  987. * into account the ability to use nested objects as a source
  988. * @param {string|int|function} mSource The data source for the object
  989. * @returns {function} Data get function
  990. * @memberof DataTable#oApi
  991. */
  992. function _fnGetObjectDataFn( mSource )
  993. {
  994. if ( $.isPlainObject( mSource ) )
  995. {
  996. /* Build an object of get functions, and wrap them in a single call */
  997. var o = {};
  998. $.each( mSource, function (key, val) {
  999. if ( val ) {
  1000. o[key] = _fnGetObjectDataFn( val );
  1001. }
  1002. } );
  1003. return function (data, type, row, meta) {
  1004. var t = o[type] || o._;
  1005. return t !== undefined ?
  1006. t(data, type, row, meta) :
  1007. data;
  1008. };
  1009. }
  1010. else if ( mSource === null )
  1011. {
  1012. /* Give an empty string for rendering / sorting etc */
  1013. return function (data) { // type, row and meta also passed, but not used
  1014. return data;
  1015. };
  1016. }
  1017. else if ( typeof mSource === 'function' )
  1018. {
  1019. return function (data, type, row, meta) {
  1020. return mSource( data, type, row, meta );
  1021. };
  1022. }
  1023. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  1024. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  1025. {
  1026. /* If there is a . in the source string then the data source is in a
  1027. * nested object so we loop over the data for each level to get the next
  1028. * level down. On each loop we test for undefined, and if found immediately
  1029. * return. This allows entire objects to be missing and sDefaultContent to
  1030. * be used if defined, rather than throwing an error
  1031. */
  1032. var fetchData = function (data, type, src) {
  1033. var arrayNotation, funcNotation, out, innerSrc;
  1034. if ( src !== "" )
  1035. {
  1036. var a = _fnSplitObjNotation( src );
  1037. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  1038. {
  1039. // Check if we are dealing with special notation
  1040. arrayNotation = a[i].match(__reArray);
  1041. funcNotation = a[i].match(__reFn);
  1042. if ( arrayNotation )
  1043. {
  1044. // Array notation
  1045. a[i] = a[i].replace(__reArray, '');
  1046. // Condition allows simply [] to be passed in
  1047. if ( a[i] !== "" ) {
  1048. data = data[ a[i] ];
  1049. }
  1050. out = [];
  1051. // Get the remainder of the nested object to get
  1052. a.splice( 0, i+1 );
  1053. innerSrc = a.join('.');
  1054. // Traverse each entry in the array getting the properties requested
  1055. for ( var j=0, jLen=data.length ; j<jLen ; j++ ) {
  1056. out.push( fetchData( data[j], type, innerSrc ) );
  1057. }
  1058. // If a string is given in between the array notation indicators, that
  1059. // is used to join the strings together, otherwise an array is returned
  1060. var join = arrayNotation[0].substring(1, arrayNotation[0].length-1);
  1061. data = (join==="") ? out : out.join(join);
  1062. // The inner call to fetchData has already traversed through the remainder
  1063. // of the source requested, so we exit from the loop
  1064. break;
  1065. }
  1066. else if ( funcNotation )
  1067. {
  1068. // Function call
  1069. a[i] = a[i].replace(__reFn, '');
  1070. data = data[ a[i] ]();
  1071. continue;
  1072. }
  1073. if ( data === null || data[ a[i] ] === undefined )
  1074. {
  1075. return undefined;
  1076. }
  1077. data = data[ a[i] ];
  1078. }
  1079. }
  1080. return data;
  1081. };
  1082. return function (data, type) { // row and meta also passed, but not used
  1083. return fetchData( data, type, mSource );
  1084. };
  1085. }
  1086. else
  1087. {
  1088. /* Array or flat object mapping */
  1089. return function (data, type) { // row and meta also passed, but not used
  1090. return data[mSource];
  1091. };
  1092. }
  1093. }
  1094. /**
  1095. * Return a function that can be used to set data from a source object, taking
  1096. * into account the ability to use nested objects as a source
  1097. * @param {string|int|function} mSource The data source for the object
  1098. * @returns {function} Data set function
  1099. * @memberof DataTable#oApi
  1100. */
  1101. function _fnSetObjectDataFn( mSource )
  1102. {
  1103. if ( $.isPlainObject( mSource ) )
  1104. {
  1105. /* Unlike get, only the underscore (global) option is used for for
  1106. * setting data since we don't know the type here. This is why an object
  1107. * option is not documented for `mData` (which is read/write), but it is
  1108. * for `mRender` which is read only.
  1109. */
  1110. return _fnSetObjectDataFn( mSource._ );
  1111. }
  1112. else if ( mSource === null )
  1113. {
  1114. /* Nothing to do when the data source is null */
  1115. return function () {};
  1116. }
  1117. else if ( typeof mSource === 'function' )
  1118. {
  1119. return function (data, val, meta) {
  1120. mSource( data, 'set', val, meta );
  1121. };
  1122. }
  1123. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  1124. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  1125. {
  1126. /* Like the get, we need to get data from a nested object */
  1127. var setData = function (data, val, src) {
  1128. var a = _fnSplitObjNotation( src ), b;
  1129. var aLast = a[a.length-1];
  1130. var arrayNotation, funcNotation, o, innerSrc;
  1131. for ( var i=0, iLen=a.length-1 ; i<iLen ; i++ )
  1132. {
  1133. // Check if we are dealing with an array notation request
  1134. arrayNotation = a[i].match(__reArray);
  1135. funcNotation = a[i].match(__reFn);
  1136. if ( arrayNotation )
  1137. {
  1138. a[i] = a[i].replace(__reArray, '');
  1139. data[ a[i] ] = [];
  1140. // Get the remainder of the nested object to set so we can recurse
  1141. b = a.slice();
  1142. b.splice( 0, i+1 );
  1143. innerSrc = b.join('.');
  1144. // Traverse each entry in the array setting the properties requested
  1145. for ( var j=0, jLen=val.length ; j<jLen ; j++ )
  1146. {
  1147. o = {};
  1148. setData( o, val[j], innerSrc );
  1149. data[ a[i] ].push( o );
  1150. }
  1151. // The inner call to setData has already traversed through the remainder
  1152. // of the source and has set the data, thus we can exit here
  1153. return;
  1154. }
  1155. else if ( funcNotation )
  1156. {
  1157. // Function call
  1158. a[i] = a[i].replace(__reFn, '');
  1159. data = data[ a[i] ]( val );
  1160. }
  1161. // If the nested object doesn't currently exist - since we are
  1162. // trying to set the value - create it
  1163. if ( data[ a[i] ] === null || data[ a[i] ] === undefined )
  1164. {
  1165. data[ a[i] ] = {};
  1166. }
  1167. data = data[ a[i] ];
  1168. }
  1169. // Last item in the input - i.e, the actual set
  1170. if ( aLast.match(__reFn ) )
  1171. {
  1172. // Function call
  1173. data = data[ aLast.replace(__reFn, '') ]( val );
  1174. }
  1175. else
  1176. {
  1177. // If array notation is used, we just want to strip it and use the property name
  1178. // and assign the value. If it isn't used, then we get the result we want anyway
  1179. data[ aLast.replace(__reArray, '') ] = val;
  1180. }
  1181. };
  1182. return function (data, val) { // meta is also passed in, but not used
  1183. return setData( data, val, mSource );
  1184. };
  1185. }
  1186. else
  1187. {
  1188. /* Array or flat object mapping */
  1189. return function (data, val) { // meta is also passed in, but not used
  1190. data[mSource] = val;
  1191. };
  1192. }
  1193. }
  1194. /**
  1195. * Return an array with the full table data
  1196. * @param {object} oSettings dataTables settings object
  1197. * @returns array {array} aData Master data array
  1198. * @memberof DataTable#oApi
  1199. */
  1200. function _fnGetDataMaster ( settings )
  1201. {
  1202. return _pluck( settings.aoData, '_aData' );
  1203. }
  1204. /**
  1205. * Nuke the table
  1206. * @param {object} oSettings dataTables settings object
  1207. * @memberof DataTable#oApi
  1208. */
  1209. function _fnClearTable( settings )
  1210. {
  1211. settings.aoData.length = 0;
  1212. settings.aiDisplayMaster.length = 0;
  1213. settings.aiDisplay.length = 0;
  1214. }
  1215. /**
  1216. * Take an array of integers (index array) and remove a target integer (value - not
  1217. * the key!)
  1218. * @param {array} a Index array to target
  1219. * @param {int} iTarget value to find
  1220. * @memberof DataTable#oApi
  1221. */
  1222. function _fnDeleteIndex( a, iTarget, splice )
  1223. {
  1224. var iTargetIndex = -1;
  1225. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  1226. {
  1227. if ( a[i] == iTarget )
  1228. {
  1229. iTargetIndex = i;
  1230. }
  1231. else if ( a[i] > iTarget )
  1232. {
  1233. a[i]--;
  1234. }
  1235. }
  1236. if ( iTargetIndex != -1 && splice === undefined )
  1237. {
  1238. a.splice( iTargetIndex, 1 );
  1239. }
  1240. }
  1241. /**
  1242. * Mark cached data as invalid such that a re-read of the data will occur when
  1243. * the cached data is next requested. Also update from the data source object.
  1244. *
  1245. * @param {object} settings DataTables settings object
  1246. * @param {int} rowIdx Row index to invalidate
  1247. * @param {string} [src] Source to invalidate from: undefined, 'auto', 'dom'
  1248. * or 'data'
  1249. * @param {int} [colIdx] Column index to invalidate. If undefined the whole
  1250. * row will be invalidated
  1251. * @memberof DataTable#oApi
  1252. *
  1253. * @todo For the modularisation of v1.11 this will need to become a callback, so
  1254. * the sort and filter methods can subscribe to it. That will required
  1255. * initialisation options for sorting, which is why it is not already baked in
  1256. */
  1257. function _fnInvalidate( settings, rowIdx, src, colIdx )
  1258. {
  1259. var row = settings.aoData[ rowIdx ];
  1260. var i, ien;
  1261. var cellWrite = function ( cell, col ) {
  1262. // This is very frustrating, but in IE if you just write directly
  1263. // to innerHTML, and elements that are overwritten are GC'ed,
  1264. // even if there is a reference to them elsewhere
  1265. while ( cell.childNodes.length ) {
  1266. cell.removeChild( cell.firstChild );
  1267. }
  1268. cell.innerHTML = _fnGetCellData( settings, rowIdx, col, 'display' );
  1269. };
  1270. // Are we reading last data from DOM or the data object?
  1271. if ( src === 'dom' || ((! src || src === 'auto') && row.src === 'dom') ) {
  1272. // Read the data from the DOM
  1273. row._aData = _fnGetRowElements(
  1274. settings, row, colIdx, colIdx === undefined ? undefined : row._aData
  1275. )
  1276. .data;
  1277. }
  1278. else {
  1279. // Reading from data object, update the DOM
  1280. var cells = row.anCells;
  1281. if ( cells ) {
  1282. if ( colIdx !== undefined ) {
  1283. cellWrite( cells[colIdx], colIdx );
  1284. }
  1285. else {
  1286. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  1287. cellWrite( cells[i], i );
  1288. }
  1289. }
  1290. }
  1291. }
  1292. // For both row and cell invalidation, the cached data for sorting and
  1293. // filtering is nulled out
  1294. row._aSortData = null;
  1295. row._aFilterData = null;
  1296. // Invalidate the type for a specific column (if given) or all columns since
  1297. // the data might have changed
  1298. var cols = settings.aoColumns;
  1299. if ( colIdx !== undefined ) {
  1300. cols[ colIdx ].sType = null;
  1301. }
  1302. else {
  1303. for ( i=0, ien=cols.length ; i<ien ; i++ ) {
  1304. cols[i].sType = null;
  1305. }
  1306. // Update DataTables special `DT_*` attributes for the row
  1307. _fnRowAttributes( row );
  1308. }
  1309. }
  1310. /**
  1311. * Build a data source object from an HTML row, reading the contents of the
  1312. * cells that are in the row.
  1313. *
  1314. * @param {object} settings DataTables settings object
  1315. * @param {node|object} TR element from which to read data or existing row
  1316. * object from which to re-read the data from the cells
  1317. * @param {int} [colIdx] Optional column index
  1318. * @param {array|object} [d] Data source object. If `colIdx` is given then this
  1319. * parameter should also be given and will be used to write the data into.
  1320. * Only the column in question will be written
  1321. * @returns {object} Object with two parameters: `data` the data read, in
  1322. * document order, and `cells` and array of nodes (they can be useful to the
  1323. * caller, so rather than needing a second traversal to get them, just return
  1324. * them from here).
  1325. * @memberof DataTable#oApi
  1326. */
  1327. function _fnGetRowElements( settings, row, colIdx, d )
  1328. {
  1329. var
  1330. tds = [],
  1331. td = row.firstChild,
  1332. name, col, o, i=0, contents,
  1333. columns = settings.aoColumns,
  1334. objectRead = settings._rowReadObject;
  1335. // Allow the data object to be passed in, or construct
  1336. d = d || objectRead ? {} : [];
  1337. var attr = function ( str, td ) {
  1338. if ( typeof str === 'string' ) {
  1339. var idx = str.indexOf('@');
  1340. if ( idx !== -1 ) {
  1341. var attr = str.substring( idx+1 );
  1342. var setter = _fnSetObjectDataFn( str );
  1343. setter( d, td.getAttribute( attr ) );
  1344. }
  1345. }
  1346. };
  1347. // Read data from a cell and store into the data object
  1348. var cellProcess = function ( cell ) {
  1349. if ( colIdx === undefined || colIdx === i ) {
  1350. col = columns[i];
  1351. contents = $.trim(cell.innerHTML);
  1352. if ( col && col._bAttrSrc ) {
  1353. var setter = _fnSetObjectDataFn( col.mData._ );
  1354. setter( d, contents );
  1355. attr( col.mData.sort, cell );
  1356. attr( col.mData.type, cell );
  1357. attr( col.mData.filter, cell );
  1358. }
  1359. else {
  1360. // Depending on the `data` option for the columns the data can
  1361. // be read to either an object or an array.
  1362. if ( objectRead ) {
  1363. if ( ! col._setter ) {
  1364. // Cache the setter function
  1365. col._setter = _fnSetObjectDataFn( col.mData );
  1366. }
  1367. col._setter( d, contents );
  1368. }
  1369. else {
  1370. d[i] = contents;
  1371. }
  1372. }
  1373. }
  1374. i++;
  1375. };
  1376. if ( td ) {
  1377. // `tr` element was passed in
  1378. while ( td ) {
  1379. name = td.nodeName.toUpperCase();
  1380. if ( name == "TD" || name == "TH" ) {
  1381. cellProcess( td );
  1382. tds.push( td );
  1383. }
  1384. td = td.nextSibling;
  1385. }
  1386. }
  1387. else {
  1388. // Existing row object passed in
  1389. tds = row.anCells;
  1390. for ( var j=0, jen=tds.length ; j<jen ; j++ ) {
  1391. cellProcess( tds[j] );
  1392. }
  1393. }
  1394. return {
  1395. data: d,
  1396. cells: tds
  1397. };
  1398. }
  1399. /**
  1400. * Create a new TR element (and it's TD children) for a row
  1401. * @param {object} oSettings dataTables settings object
  1402. * @param {int} iRow Row to consider
  1403. * @param {node} [nTrIn] TR element to add to the table - optional. If not given,
  1404. * DataTables will create a row automatically
  1405. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  1406. * if nTr is.
  1407. * @memberof DataTable#oApi
  1408. */
  1409. function _fnCreateTr ( oSettings, iRow, nTrIn, anTds )
  1410. {
  1411. var
  1412. row = oSettings.aoData[iRow],
  1413. rowData = row._aData,
  1414. cells = [],
  1415. nTr, nTd, oCol,
  1416. i, iLen;
  1417. if ( row.nTr === null )
  1418. {
  1419. nTr = nTrIn || document.createElement('tr');
  1420. row.nTr = nTr;
  1421. row.anCells = cells;
  1422. /* Use a private property on the node to allow reserve mapping from the node
  1423. * to the aoData array for fast look up
  1424. */
  1425. nTr._DT_RowIndex = iRow;
  1426. /* Special parameters can be given by the data source to be used on the row */
  1427. _fnRowAttributes( row );
  1428. /* Process each column */
  1429. for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
  1430. {
  1431. oCol = oSettings.aoColumns[i];
  1432. nTd = nTrIn ? anTds[i] : document.createElement( oCol.sCellType );
  1433. cells.push( nTd );
  1434. // Need to create the HTML if new, or if a rendering function is defined
  1435. if ( !nTrIn || oCol.mRender || oCol.mData !== i )
  1436. {
  1437. nTd.innerHTML = _fnGetCellData( oSettings, iRow, i, 'display' );
  1438. }
  1439. /* Add user defined class */
  1440. if ( oCol.sClass )
  1441. {
  1442. nTd.className += ' '+oCol.sClass;
  1443. }
  1444. // Visibility - add or remove as required
  1445. if ( oCol.bVisible && ! nTrIn )
  1446. {
  1447. nTr.appendChild( nTd );
  1448. }
  1449. else if ( ! oCol.bVisible && nTrIn )
  1450. {
  1451. nTd.parentNode.removeChild( nTd );
  1452. }
  1453. if ( oCol.fnCreatedCell )
  1454. {
  1455. oCol.fnCreatedCell.call( oSettings.oInstance,
  1456. nTd, _fnGetCellData( oSettings, iRow, i ), rowData, iRow, i
  1457. );
  1458. }
  1459. }
  1460. _fnCallbackFire( oSettings, 'aoRowCreatedCallback', null, [nTr, rowData, iRow] );
  1461. }
  1462. // Remove once webkit bug 131819 and Chromium bug 365619 have been resolved
  1463. // and deployed
  1464. row.nTr.setAttribute( 'role', 'row' );
  1465. }
  1466. /**
  1467. * Add attributes to a row based on the special `DT_*` parameters in a data
  1468. * source object.
  1469. * @param {object} DataTables row object for the row to be modified
  1470. * @memberof DataTable#oApi
  1471. */
  1472. function _fnRowAttributes( row )
  1473. {
  1474. var tr = row.nTr;
  1475. var data = row._aData;
  1476. if ( tr ) {
  1477. if ( data.DT_RowId ) {
  1478. tr.id = data.DT_RowId;
  1479. }
  1480. if ( data.DT_RowClass ) {
  1481. // Remove any classes added by DT_RowClass before
  1482. var a = data.DT_RowClass.split(' ');
  1483. row.__rowc = row.__rowc ?
  1484. _unique( row.__rowc.concat( a ) ) :
  1485. a;
  1486. $(tr)
  1487. .removeClass( row.__rowc.join(' ') )
  1488. .addClass( data.DT_RowClass );
  1489. }
  1490. if ( data.DT_RowData ) {
  1491. $(tr).data( data.DT_RowData );
  1492. }
  1493. }
  1494. }
  1495. /**
  1496. * Create the HTML header for the table
  1497. * @param {object} oSettings dataTables settings object
  1498. * @memberof DataTable#oApi
  1499. */
  1500. function _fnBuildHead( oSettings )
  1501. {
  1502. var i, ien, cell, row, column;
  1503. var thead = oSettings.nTHead;
  1504. var tfoot = oSettings.nTFoot;
  1505. var createHeader = $('th, td', thead).length === 0;
  1506. var classes = oSettings.oClasses;
  1507. var columns = oSettings.aoColumns;
  1508. if ( createHeader ) {
  1509. row = $('<tr/>').appendTo( thead );
  1510. }
  1511. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  1512. column = columns[i];
  1513. cell = $( column.nTh ).addClass( column.sClass );
  1514. if ( createHeader ) {
  1515. cell.appendTo( row );
  1516. }
  1517. // 1.11 move into sorting
  1518. if ( oSettings.oFeatures.bSort ) {
  1519. cell.addClass( column.sSortingClass );
  1520. if ( column.bSortable !== false ) {
  1521. cell
  1522. .attr( 'tabindex', oSettings.iTabIndex )
  1523. .attr( 'aria-controls', oSettings.sTableId );
  1524. _fnSortAttachListener( oSettings, column.nTh, i );
  1525. }
  1526. }
  1527. if ( column.sTitle != cell.html() ) {
  1528. cell.html( column.sTitle );
  1529. }
  1530. _fnRenderer( oSettings, 'header' )(
  1531. oSettings, cell, column, classes
  1532. );
  1533. }
  1534. if ( createHeader ) {
  1535. _fnDetectHeader( oSettings.aoHeader, thead );
  1536. }
  1537. /* ARIA role for the rows */
  1538. $(thead).find('>tr').attr('role', 'row');
  1539. /* Deal with the footer - add classes if required */
  1540. $(thead).find('>tr>th, >tr>td').addClass( classes.sHeaderTH );
  1541. $(tfoot).find('>tr>th, >tr>td').addClass( classes.sFooterTH );
  1542. // Cache the footer cells. Note that we only take the cells from the first
  1543. // row in the footer. If there is more than one row the user wants to
  1544. // interact with, they need to use the table().foot() method. Note also this
  1545. // allows cells to be used for multiple columns using colspan
  1546. if ( tfoot !== null ) {
  1547. var cells = oSettings.aoFooter[0];
  1548. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  1549. column = columns[i];
  1550. column.nTf = cells[i].cell;
  1551. if ( column.sClass ) {
  1552. $(column.nTf).addClass( column.sClass );
  1553. }
  1554. }
  1555. }
  1556. }
  1557. /**
  1558. * Draw the header (or footer) element based on the column visibility states. The
  1559. * methodology here is to use the layout array from _fnDetectHeader, modified for
  1560. * the instantaneous column visibility, to construct the new layout. The grid is
  1561. * traversed over cell at a time in a rows x columns grid fashion, although each
  1562. * cell insert can cover multiple elements in the grid - which is tracks using the
  1563. * aApplied array. Cell inserts in the grid will only occur where there isn't
  1564. * already a cell in that position.
  1565. * @param {object} oSettings dataTables settings object
  1566. * @param array {objects} aoSource Layout array from _fnDetectHeader
  1567. * @param {boolean} [bIncludeHidden=false] If true then include the hidden columns in the calc,
  1568. * @memberof DataTable#oApi
  1569. */
  1570. function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
  1571. {
  1572. var i, iLen, j, jLen, k, kLen, n, nLocalTr;
  1573. var aoLocal = [];
  1574. var aApplied = [];
  1575. var iColumns = oSettings.aoColumns.length;
  1576. var iRowspan, iColspan;
  1577. if ( ! aoSource )
  1578. {
  1579. return;
  1580. }
  1581. if ( bIncludeHidden === undefined )
  1582. {
  1583. bIncludeHidden = false;
  1584. }
  1585. /* Make a copy of the master layout array, but without the visible columns in it */
  1586. for ( i=0, iLen=aoSource.length ; i<iLen ; i++ )
  1587. {
  1588. aoLocal[i] = aoSource[i].slice();
  1589. aoLocal[i].nTr = aoSource[i].nTr;
  1590. /* Remove any columns which are currently hidden */
  1591. for ( j=iColumns-1 ; j>=0 ; j-- )
  1592. {
  1593. if ( !oSettings.aoColumns[j].bVisible && !bIncludeHidden )
  1594. {
  1595. aoLocal[i].splice( j, 1 );
  1596. }
  1597. }
  1598. /* Prep the applied array - it needs an element for each row */
  1599. aApplied.push( [] );
  1600. }
  1601. for ( i=0, iLen=aoLocal.length ; i<iLen ; i++ )
  1602. {
  1603. nLocalTr = aoLocal[i].nTr;
  1604. /* All cells are going to be replaced, so empty out the row */
  1605. if ( nLocalTr )
  1606. {
  1607. while( (n = nLocalTr.firstChild) )
  1608. {
  1609. nLocalTr.removeChild( n );
  1610. }
  1611. }
  1612. for ( j=0, jLen=aoLocal[i].length ; j<jLen ; j++ )
  1613. {
  1614. iRowspan = 1;
  1615. iColspan = 1;
  1616. /* Check to see if there is already a cell (row/colspan) covering our target
  1617. * insert point. If there is, then there is nothing to do.
  1618. */
  1619. if ( aApplied[i][j] === undefined )
  1620. {
  1621. nLocalTr.appendChild( aoLocal[i][j].cell );
  1622. aApplied[i][j] = 1;
  1623. /* Expand the cell to cover as many rows as needed */
  1624. while ( aoLocal[i+iRowspan] !== undefined &&
  1625. aoLocal[i][j].cell == aoLocal[i+iRowspan][j].cell )
  1626. {
  1627. aApplied[i+iRowspan][j] = 1;
  1628. iRowspan++;
  1629. }
  1630. /* Expand the cell to cover as many columns as needed */
  1631. while ( aoLocal[i][j+iColspan] !== undefined &&
  1632. aoLocal[i][j].cell == aoLocal[i][j+iColspan].cell )
  1633. {
  1634. /* Must update the applied array over the rows for the columns */
  1635. for ( k=0 ; k<iRowspan ; k++ )
  1636. {
  1637. aApplied[i+k][j+iColspan] = 1;
  1638. }
  1639. iColspan++;
  1640. }
  1641. /* Do the actual expansion in the DOM */
  1642. $(aoLocal[i][j].cell)
  1643. .attr('rowspan', iRowspan)
  1644. .attr('colspan', iColspan);
  1645. }
  1646. }
  1647. }
  1648. }
  1649. /**
  1650. * Insert the required TR nodes into the table for display
  1651. * @param {object} oSettings dataTables settings object
  1652. * @memberof DataTable#oApi
  1653. */
  1654. function _fnDraw( oSettings )
  1655. {
  1656. /* Provide a pre-callback function which can be used to cancel the draw is false is returned */
  1657. var aPreDraw = _fnCallbackFire( oSettings, 'aoPreDrawCallback', 'preDraw', [oSettings] );
  1658. if ( $.inArray( false, aPreDraw ) !== -1 )
  1659. {
  1660. _fnProcessingDisplay( oSettings, false );
  1661. return;
  1662. }
  1663. var i, iLen, n;
  1664. var anRows = [];
  1665. var iRowCount = 0;
  1666. var asStripeClasses = oSettings.asStripeClasses;
  1667. var iStripes = asStripeClasses.length;
  1668. var iOpenRows = oSettings.aoOpenRows.length;
  1669. var oLang = oSettings.oLanguage;
  1670. var iInitDisplayStart = oSettings.iInitDisplayStart;
  1671. var bServerSide = _fnDataSource( oSettings ) == 'ssp';
  1672. var aiDisplay = oSettings.aiDisplay;
  1673. oSettings.bDrawing = true;
  1674. /* Check and see if we have an initial draw position from state saving */
  1675. if ( iInitDisplayStart !== undefined && iInitDisplayStart !== -1 )
  1676. {
  1677. oSettings._iDisplayStart = bServerSide ?
  1678. iInitDisplayStart :
  1679. iInitDisplayStart >= oSettings.fnRecordsDisplay() ?
  1680. 0 :
  1681. iInitDisplayStart;
  1682. oSettings.iInitDisplayStart = -1;
  1683. }
  1684. var iDisplayStart = oSettings._iDisplayStart;
  1685. var iDisplayEnd = oSettings.fnDisplayEnd();
  1686. /* Server-side processing draw intercept */
  1687. if ( oSettings.bDeferLoading )
  1688. {
  1689. oSettings.bDeferLoading = false;
  1690. oSettings.iDraw++;
  1691. _fnProcessingDisplay( oSettings, false );
  1692. }
  1693. else if ( !bServerSide )
  1694. {
  1695. oSettings.iDraw++;
  1696. }
  1697. else if ( !oSettings.bDestroying && !_fnAjaxUpdate( oSettings ) )
  1698. {
  1699. return;
  1700. }
  1701. if ( aiDisplay.length !== 0 )
  1702. {
  1703. var iStart = bServerSide ? 0 : iDisplayStart;
  1704. var iEnd = bServerSide ? oSettings.aoData.length : iDisplayEnd;
  1705. for ( var j=iStart ; j<iEnd ; j++ )
  1706. {
  1707. var iDataIndex = aiDisplay[j];
  1708. var aoData = oSettings.aoData[ iDataIndex ];
  1709. if ( aoData.nTr === null )
  1710. {
  1711. _fnCreateTr( oSettings, iDataIndex );
  1712. }
  1713. var nRow = aoData.nTr;
  1714. /* Remove the old striping classes and then add the new one */
  1715. if ( iStripes !== 0 )
  1716. {
  1717. var sStripe = asStripeClasses[ iRowCount % iStripes ];
  1718. if ( aoData._sRowStripe != sStripe )
  1719. {
  1720. $(nRow).removeClass( aoData._sRowStripe ).addClass( sStripe );
  1721. aoData._sRowStripe = sStripe;
  1722. }
  1723. }
  1724. // Row callback functions - might want to manipulate the row
  1725. // iRowCount and j are not currently documented. Are they at all
  1726. // useful?
  1727. _fnCallbackFire( oSettings, 'aoRowCallback', null,
  1728. [nRow, aoData._aData, iRowCount, j] );
  1729. anRows.push( nRow );
  1730. iRowCount++;
  1731. }
  1732. }
  1733. else
  1734. {
  1735. /* Table is empty - create a row with an empty message in it */
  1736. var sZero = oLang.sZeroRecords;
  1737. if ( oSettings.iDraw == 1 && _fnDataSource( oSettings ) == 'ajax' )
  1738. {
  1739. sZero = oLang.sLoadingRecords;
  1740. }
  1741. else if ( oLang.sEmptyTable && oSettings.fnRecordsTotal() === 0 )
  1742. {
  1743. sZero = oLang.sEmptyTable;
  1744. }
  1745. anRows[ 0 ] = $( '<tr/>', { 'class': iStripes ? asStripeClasses[0] : '' } )
  1746. .append( $('<td />', {
  1747. 'valign': 'top',
  1748. 'colSpan': _fnVisbleColumns( oSettings ),
  1749. 'class': oSettings.oClasses.sRowEmpty
  1750. } ).html( sZero ) )[0];
  1751. }
  1752. /* Header and footer callbacks */
  1753. _fnCallbackFire( oSettings, 'aoHeaderCallback', 'header', [ $(oSettings.nTHead).children('tr')[0],
  1754. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  1755. _fnCallbackFire( oSettings, 'aoFooterCallback', 'footer', [ $(oSettings.nTFoot).children('tr')[0],
  1756. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  1757. var body = $(oSettings.nTBody);
  1758. body.children().detach();
  1759. body.append( $(anRows) );
  1760. /* Call all required callback functions for the end of a draw */
  1761. _fnCallbackFire( oSettings, 'aoDrawCallback', 'draw', [oSettings] );
  1762. /* Draw is complete, sorting and filtering must be as well */
  1763. oSettings.bSorted = false;
  1764. oSettings.bFiltered = false;
  1765. oSettings.bDrawing = false;
  1766. }
  1767. /**
  1768. * Redraw the table - taking account of the various features which are enabled
  1769. * @param {object} oSettings dataTables settings object
  1770. * @param {boolean} [holdPosition] Keep the current paging position. By default
  1771. * the paging is reset to the first page
  1772. * @memberof DataTable#oApi
  1773. */
  1774. function _fnReDraw( settings, holdPosition )
  1775. {
  1776. var
  1777. features = settings.oFeatures,
  1778. sort = features.bSort,
  1779. filter = features.bFilter;
  1780. if ( sort ) {
  1781. _fnSort( settings );
  1782. }
  1783. if ( filter ) {
  1784. _fnFilterComplete( settings, settings.oPreviousSearch );
  1785. }
  1786. else {
  1787. // No filtering, so we want to just use the display master
  1788. settings.aiDisplay = settings.aiDisplayMaster.slice();
  1789. }
  1790. if ( holdPosition !== true ) {
  1791. settings._iDisplayStart = 0;
  1792. }
  1793. // Let any modules know about the draw hold position state (used by
  1794. // scrolling internally)
  1795. settings._drawHold = holdPosition;
  1796. _fnDraw( settings );
  1797. settings._drawHold = false;
  1798. }
  1799. /**
  1800. * Add the options to the page HTML for the table
  1801. * @param {object} oSettings dataTables settings object
  1802. * @memberof DataTable#oApi
  1803. */
  1804. function _fnAddOptionsHtml ( oSettings )
  1805. {
  1806. var classes = oSettings.oClasses;
  1807. var table = $(oSettings.nTable);
  1808. var holding = $('<div/>').insertBefore( table ); // Holding element for speed
  1809. var features = oSettings.oFeatures;
  1810. // All DataTables are wrapped in a div
  1811. var insert = $('<div/>', {
  1812. id: oSettings.sTableId+'_wrapper',
  1813. 'class': classes.sWrapper + (oSettings.nTFoot ? '' : ' '+classes.sNoFooter)
  1814. } );
  1815. oSettings.nHolding = holding[0];
  1816. oSettings.nTableWrapper = insert[0];
  1817. oSettings.nTableReinsertBefore = oSettings.nTable.nextSibling;
  1818. /* Loop over the user set positioning and place the elements as needed */
  1819. var aDom = oSettings.sDom.split('');
  1820. var featureNode, cOption, nNewNode, cNext, sAttr, j;
  1821. for ( var i=0 ; i<aDom.length ; i++ )
  1822. {
  1823. featureNode = null;
  1824. cOption = aDom[i];
  1825. if ( cOption == '<' )
  1826. {
  1827. /* New container div */
  1828. nNewNode = $('<div/>')[0];
  1829. /* Check to see if we should append an id and/or a class name to the container */
  1830. cNext = aDom[i+1];
  1831. if ( cNext == "'" || cNext == '"' )
  1832. {
  1833. sAttr = "";
  1834. j = 2;
  1835. while ( aDom[i+j] != cNext )
  1836. {
  1837. sAttr += aDom[i+j];
  1838. j++;
  1839. }
  1840. /* Replace jQuery UI constants @todo depreciated */
  1841. if ( sAttr == "H" )
  1842. {
  1843. sAttr = classes.sJUIHeader;
  1844. }
  1845. else if ( sAttr == "F" )
  1846. {
  1847. sAttr = classes.sJUIFooter;
  1848. }
  1849. /* The attribute can be in the format of "#id.class", "#id" or "class" This logic
  1850. * breaks the string into parts and applies them as needed
  1851. */
  1852. if ( sAttr.indexOf('.') != -1 )
  1853. {
  1854. var aSplit = sAttr.split('.');
  1855. nNewNode.id = aSplit[0].substr(1, aSplit[0].length-1);
  1856. nNewNode.className = aSplit[1];
  1857. }
  1858. else if ( sAttr.charAt(0) == "#" )
  1859. {
  1860. nNewNode.id = sAttr.substr(1, sAttr.length-1);
  1861. }
  1862. else
  1863. {
  1864. nNewNode.className = sAttr;
  1865. }
  1866. i += j; /* Move along the position array */
  1867. }
  1868. insert.append( nNewNode );
  1869. insert = $(nNewNode);
  1870. }
  1871. else if ( cOption == '>' )
  1872. {
  1873. /* End container div */
  1874. insert = insert.parent();
  1875. }
  1876. // @todo Move options into their own plugins?
  1877. else if ( cOption == 'l' && features.bPaginate && features.bLengthChange )
  1878. {
  1879. /* Length */
  1880. featureNode = _fnFeatureHtmlLength( oSettings );
  1881. }
  1882. else if ( cOption == 'f' && features.bFilter )
  1883. {
  1884. /* Filter */
  1885. featureNode = _fnFeatureHtmlFilter( oSettings );
  1886. }
  1887. else if ( cOption == 'r' && features.bProcessing )
  1888. {
  1889. /* pRocessing */
  1890. featureNode = _fnFeatureHtmlProcessing( oSettings );
  1891. }
  1892. else if ( cOption == 't' )
  1893. {
  1894. /* Table */
  1895. featureNode = _fnFeatureHtmlTable( oSettings );
  1896. }
  1897. else if ( cOption == 'i' && features.bInfo )
  1898. {
  1899. /* Info */
  1900. featureNode = _fnFeatureHtmlInfo( oSettings );
  1901. }
  1902. else if ( cOption == 'p' && features.bPaginate )
  1903. {
  1904. /* Pagination */
  1905. featureNode = _fnFeatureHtmlPaginate( oSettings );
  1906. }
  1907. else if ( DataTable.ext.feature.length !== 0 )
  1908. {
  1909. /* Plug-in features */
  1910. var aoFeatures = DataTable.ext.feature;
  1911. for ( var k=0, kLen=aoFeatures.length ; k<kLen ; k++ )
  1912. {
  1913. if ( cOption == aoFeatures[k].cFeature )
  1914. {
  1915. featureNode = aoFeatures[k].fnInit( oSettings );
  1916. break;
  1917. }
  1918. }
  1919. }
  1920. /* Add to the 2D features array */
  1921. if ( featureNode )
  1922. {
  1923. var aanFeatures = oSettings.aanFeatures;
  1924. if ( ! aanFeatures[cOption] )
  1925. {
  1926. aanFeatures[cOption] = [];
  1927. }
  1928. aanFeatures[cOption].push( featureNode );
  1929. insert.append( featureNode );
  1930. }
  1931. }
  1932. /* Built our DOM structure - replace the holding div with what we want */
  1933. holding.replaceWith( insert );
  1934. }
  1935. /**
  1936. * Use the DOM source to create up an array of header cells. The idea here is to
  1937. * create a layout grid (array) of rows x columns, which contains a reference
  1938. * to the cell that that point in the grid (regardless of col/rowspan), such that
  1939. * any column / row could be removed and the new grid constructed
  1940. * @param array {object} aLayout Array to store the calculated layout in
  1941. * @param {node} nThead The header/footer element for the table
  1942. * @memberof DataTable#oApi
  1943. */
  1944. function _fnDetectHeader ( aLayout, nThead )
  1945. {
  1946. var nTrs = $(nThead).children('tr');
  1947. var nTr, nCell;
  1948. var i, k, l, iLen, jLen, iColShifted, iColumn, iColspan, iRowspan;
  1949. var bUnique;
  1950. var fnShiftCol = function ( a, i, j ) {
  1951. var k = a[i];
  1952. while ( k[j] ) {
  1953. j++;
  1954. }
  1955. return j;
  1956. };
  1957. aLayout.splice( 0, aLayout.length );
  1958. /* We know how many rows there are in the layout - so prep it */
  1959. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  1960. {
  1961. aLayout.push( [] );
  1962. }
  1963. /* Calculate a layout array */
  1964. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  1965. {
  1966. nTr = nTrs[i];
  1967. iColumn = 0;
  1968. /* For every cell in the row... */
  1969. nCell = nTr.firstChild;
  1970. while ( nCell ) {
  1971. if ( nCell.nodeName.toUpperCase() == "TD" ||
  1972. nCell.nodeName.toUpperCase() == "TH" )
  1973. {
  1974. /* Get the col and rowspan attributes from the DOM and sanitise them */
  1975. iColspan = nCell.getAttribute('colspan') * 1;
  1976. iRowspan = nCell.getAttribute('rowspan') * 1;
  1977. iColspan = (!iColspan || iColspan===0 || iColspan===1) ? 1 : iColspan;
  1978. iRowspan = (!iRowspan || iRowspan===0 || iRowspan===1) ? 1 : iRowspan;
  1979. /* There might be colspan cells already in this row, so shift our target
  1980. * accordingly
  1981. */
  1982. iColShifted = fnShiftCol( aLayout, i, iColumn );
  1983. /* Cache calculation for unique columns */
  1984. bUnique = iColspan === 1 ? true : false;
  1985. /* If there is col / rowspan, copy the information into the layout grid */
  1986. for ( l=0 ; l<iColspan ; l++ )
  1987. {
  1988. for ( k=0 ; k<iRowspan ; k++ )
  1989. {
  1990. aLayout[i+k][iColShifted+l] = {
  1991. "cell": nCell,
  1992. "unique": bUnique
  1993. };
  1994. aLayout[i+k].nTr = nTr;
  1995. }
  1996. }
  1997. }
  1998. nCell = nCell.nextSibling;
  1999. }
  2000. }
  2001. }
  2002. /**
  2003. * Get an array of unique th elements, one for each column
  2004. * @param {object} oSettings dataTables settings object
  2005. * @param {node} nHeader automatically detect the layout from this node - optional
  2006. * @param {array} aLayout thead/tfoot layout from _fnDetectHeader - optional
  2007. * @returns array {node} aReturn list of unique th's
  2008. * @memberof DataTable#oApi
  2009. */
  2010. function _fnGetUniqueThs ( oSettings, nHeader, aLayout )
  2011. {
  2012. var aReturn = [];
  2013. if ( !aLayout )
  2014. {
  2015. aLayout = oSettings.aoHeader;
  2016. if ( nHeader )
  2017. {
  2018. aLayout = [];
  2019. _fnDetectHeader( aLayout, nHeader );
  2020. }
  2021. }
  2022. for ( var i=0, iLen=aLayout.length ; i<iLen ; i++ )
  2023. {
  2024. for ( var j=0, jLen=aLayout[i].length ; j<jLen ; j++ )
  2025. {
  2026. if ( aLayout[i][j].unique &&
  2027. (!aReturn[j] || !oSettings.bSortCellsTop) )
  2028. {
  2029. aReturn[j] = aLayout[i][j].cell;
  2030. }
  2031. }
  2032. }
  2033. return aReturn;
  2034. }
  2035. /**
  2036. * Create an Ajax call based on the table's settings, taking into account that
  2037. * parameters can have multiple forms, and backwards compatibility.
  2038. *
  2039. * @param {object} oSettings dataTables settings object
  2040. * @param {array} data Data to send to the server, required by
  2041. * DataTables - may be augmented by developer callbacks
  2042. * @param {function} fn Callback function to run when data is obtained
  2043. */
  2044. function _fnBuildAjax( oSettings, data, fn )
  2045. {
  2046. // Compatibility with 1.9-, allow fnServerData and event to manipulate
  2047. _fnCallbackFire( oSettings, 'aoServerParams', 'serverParams', [data] );
  2048. // Convert to object based for 1.10+ if using the old array scheme which can
  2049. // come from server-side processing or serverParams
  2050. if ( data && $.isArray(data) ) {
  2051. var tmp = {};
  2052. var rbracket = /(.*?)\[\]$/;
  2053. $.each( data, function (key, val) {
  2054. var match = val.name.match(rbracket);
  2055. if ( match ) {
  2056. // Support for arrays
  2057. var name = match[0];
  2058. if ( ! tmp[ name ] ) {
  2059. tmp[ name ] = [];
  2060. }
  2061. tmp[ name ].push( val.value );
  2062. }
  2063. else {
  2064. tmp[val.name] = val.value;
  2065. }
  2066. } );
  2067. data = tmp;
  2068. }
  2069. var ajaxData;
  2070. var ajax = oSettings.ajax;
  2071. var instance = oSettings.oInstance;
  2072. if ( $.isPlainObject( ajax ) && ajax.data )
  2073. {
  2074. ajaxData = ajax.data;
  2075. var newData = $.isFunction( ajaxData ) ?
  2076. ajaxData( data ) : // fn can manipulate data or return an object
  2077. ajaxData; // object or array to merge
  2078. // If the function returned an object, use that alone
  2079. data = $.isFunction( ajaxData ) && newData ?
  2080. newData :
  2081. $.extend( true, data, newData );
  2082. // Remove the data property as we've resolved it already and don't want
  2083. // jQuery to do it again (it is restored at the end of the function)
  2084. delete ajax.data;
  2085. }
  2086. var baseAjax = {
  2087. "data": data,
  2088. "success": function (json) {
  2089. var error = json.error || json.sError;
  2090. if ( error ) {
  2091. oSettings.oApi._fnLog( oSettings, 0, error );
  2092. }
  2093. oSettings.json = json;
  2094. _fnCallbackFire( oSettings, null, 'xhr', [oSettings, json] );
  2095. fn( json );
  2096. },
  2097. "dataType": "json",
  2098. "cache": false,
  2099. "type": oSettings.sServerMethod,
  2100. "error": function (xhr, error, thrown) {
  2101. var log = oSettings.oApi._fnLog;
  2102. if ( error == "parsererror" ) {
  2103. log( oSettings, 0, 'Invalid JSON response', 1 );
  2104. }
  2105. else if ( xhr.readyState === 4 ) {
  2106. log( oSettings, 0, 'Ajax error', 7 );
  2107. }
  2108. _fnProcessingDisplay( oSettings, false );
  2109. }
  2110. };
  2111. // Store the data submitted for the API
  2112. oSettings.oAjaxData = data;
  2113. // Allow plug-ins and external processes to modify the data
  2114. _fnCallbackFire( oSettings, null, 'preXhr', [oSettings, data] );
  2115. if ( oSettings.fnServerData )
  2116. {
  2117. // DataTables 1.9- compatibility
  2118. oSettings.fnServerData.call( instance,
  2119. oSettings.sAjaxSource,
  2120. $.map( data, function (val, key) { // Need to convert back to 1.9 trad format
  2121. return { name: key, value: val };
  2122. } ),
  2123. fn,
  2124. oSettings
  2125. );
  2126. }
  2127. else if ( oSettings.sAjaxSource || typeof ajax === 'string' )
  2128. {
  2129. // DataTables 1.9- compatibility
  2130. oSettings.jqXHR = $.ajax( $.extend( baseAjax, {
  2131. url: ajax || oSettings.sAjaxSource
  2132. } ) );
  2133. }
  2134. else if ( $.isFunction( ajax ) )
  2135. {
  2136. // Is a function - let the caller define what needs to be done
  2137. oSettings.jqXHR = ajax.call( instance, data, fn, oSettings );
  2138. }
  2139. else
  2140. {
  2141. // Object to extend the base settings
  2142. oSettings.jqXHR = $.ajax( $.extend( baseAjax, ajax ) );
  2143. // Restore for next time around
  2144. ajax.data = ajaxData;
  2145. }
  2146. }
  2147. /**
  2148. * Update the table using an Ajax call
  2149. * @param {object} settings dataTables settings object
  2150. * @returns {boolean} Block the table drawing or not
  2151. * @memberof DataTable#oApi
  2152. */
  2153. function _fnAjaxUpdate( settings )
  2154. {
  2155. if ( settings.bAjaxDataGet ) {
  2156. settings.iDraw++;
  2157. _fnProcessingDisplay( settings, true );
  2158. _fnBuildAjax(
  2159. settings,
  2160. _fnAjaxParameters( settings ),
  2161. function(json) {
  2162. _fnAjaxUpdateDraw( settings, json );
  2163. }
  2164. );
  2165. return false;
  2166. }
  2167. return true;
  2168. }
  2169. /**
  2170. * Build up the parameters in an object needed for a server-side processing
  2171. * request. Note that this is basically done twice, is different ways - a modern
  2172. * method which is used by default in DataTables 1.10 which uses objects and
  2173. * arrays, or the 1.9- method with is name / value pairs. 1.9 method is used if
  2174. * the sAjaxSource option is used in the initialisation, or the legacyAjax
  2175. * option is set.
  2176. * @param {object} oSettings dataTables settings object
  2177. * @returns {bool} block the table drawing or not
  2178. * @memberof DataTable#oApi
  2179. */
  2180. function _fnAjaxParameters( settings )
  2181. {
  2182. var
  2183. columns = settings.aoColumns,
  2184. columnCount = columns.length,
  2185. features = settings.oFeatures,
  2186. preSearch = settings.oPreviousSearch,
  2187. preColSearch = settings.aoPreSearchCols,
  2188. i, data = [], dataProp, column, columnSearch,
  2189. sort = _fnSortFlatten( settings ),
  2190. displayStart = settings._iDisplayStart,
  2191. displayLength = features.bPaginate !== false ?
  2192. settings._iDisplayLength :
  2193. -1;
  2194. var param = function ( name, value ) {
  2195. data.push( { 'name': name, 'value': value } );
  2196. };
  2197. // DataTables 1.9- compatible method
  2198. param( 'sEcho', settings.iDraw );
  2199. param( 'iColumns', columnCount );
  2200. param( 'sColumns', _pluck( columns, 'sName' ).join(',') );
  2201. param( 'iDisplayStart', displayStart );
  2202. param( 'iDisplayLength', displayLength );
  2203. // DataTables 1.10+ method
  2204. var d = {
  2205. draw: settings.iDraw,
  2206. columns: [],
  2207. order: [],
  2208. start: displayStart,
  2209. length: displayLength,
  2210. search: {
  2211. value: preSearch.sSearch,
  2212. regex: preSearch.bRegex
  2213. }
  2214. };
  2215. for ( i=0 ; i<columnCount ; i++ ) {
  2216. column = columns[i];
  2217. columnSearch = preColSearch[i];
  2218. dataProp = typeof column.mData=="function" ? 'function' : column.mData ;
  2219. d.columns.push( {
  2220. data: dataProp,
  2221. name: column.sName,
  2222. searchable: column.bSearchable,
  2223. orderable: column.bSortable,
  2224. search: {
  2225. value: columnSearch.sSearch,
  2226. regex: columnSearch.bRegex
  2227. }
  2228. } );
  2229. param( "mDataProp_"+i, dataProp );
  2230. if ( features.bFilter ) {
  2231. param( 'sSearch_'+i, columnSearch.sSearch );
  2232. param( 'bRegex_'+i, columnSearch.bRegex );
  2233. param( 'bSearchable_'+i, column.bSearchable );
  2234. }
  2235. if ( features.bSort ) {
  2236. param( 'bSortable_'+i, column.bSortable );
  2237. }
  2238. }
  2239. if ( features.bFilter ) {
  2240. param( 'sSearch', preSearch.sSearch );
  2241. param( 'bRegex', preSearch.bRegex );
  2242. }
  2243. if ( features.bSort ) {
  2244. $.each( sort, function ( i, val ) {
  2245. d.order.push( { column: val.col, dir: val.dir } );
  2246. param( 'iSortCol_'+i, val.col );
  2247. param( 'sSortDir_'+i, val.dir );
  2248. } );
  2249. param( 'iSortingCols', sort.length );
  2250. }
  2251. // If the legacy.ajax parameter is null, then we automatically decide which
  2252. // form to use, based on sAjaxSource
  2253. var legacy = DataTable.ext.legacy.ajax;
  2254. if ( legacy === null ) {
  2255. return settings.sAjaxSource ? data : d;
  2256. }
  2257. // Otherwise, if legacy has been specified then we use that to decide on the
  2258. // form
  2259. return legacy ? data : d;
  2260. }
  2261. /**
  2262. * Data the data from the server (nuking the old) and redraw the table
  2263. * @param {object} oSettings dataTables settings object
  2264. * @param {object} json json data return from the server.
  2265. * @param {string} json.sEcho Tracking flag for DataTables to match requests
  2266. * @param {int} json.iTotalRecords Number of records in the data set, not accounting for filtering
  2267. * @param {int} json.iTotalDisplayRecords Number of records in the data set, accounting for filtering
  2268. * @param {array} json.aaData The data to display on this page
  2269. * @param {string} [json.sColumns] Column ordering (sName, comma separated)
  2270. * @memberof DataTable#oApi
  2271. */
  2272. function _fnAjaxUpdateDraw ( settings, json )
  2273. {
  2274. // v1.10 uses camelCase variables, while 1.9 uses Hungarian notation.
  2275. // Support both
  2276. var compat = function ( old, modern ) {
  2277. return json[old] !== undefined ? json[old] : json[modern];
  2278. };
  2279. var draw = compat( 'sEcho', 'draw' );
  2280. var recordsTotal = compat( 'iTotalRecords', 'recordsTotal' );
  2281. var recordsFiltered = compat( 'iTotalDisplayRecords', 'recordsFiltered' );
  2282. if ( draw ) {
  2283. // Protect against out of sequence returns
  2284. if ( draw*1 < settings.iDraw ) {
  2285. return;
  2286. }
  2287. settings.iDraw = draw * 1;
  2288. }
  2289. _fnClearTable( settings );
  2290. settings._iRecordsTotal = parseInt(recordsTotal, 10);
  2291. settings._iRecordsDisplay = parseInt(recordsFiltered, 10);
  2292. var data = _fnAjaxDataSrc( settings, json );
  2293. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  2294. _fnAddData( settings, data[i] );
  2295. }
  2296. settings.aiDisplay = settings.aiDisplayMaster.slice();
  2297. settings.bAjaxDataGet = false;
  2298. _fnDraw( settings );
  2299. if ( ! settings._bInitComplete ) {
  2300. _fnInitComplete( settings, json );
  2301. }
  2302. settings.bAjaxDataGet = true;
  2303. _fnProcessingDisplay( settings, false );
  2304. }
  2305. /**
  2306. * Get the data from the JSON data source to use for drawing a table. Using
  2307. * `_fnGetObjectDataFn` allows the data to be sourced from a property of the
  2308. * source object, or from a processing function.
  2309. * @param {object} oSettings dataTables settings object
  2310. * @param {object} json Data source object / array from the server
  2311. * @return {array} Array of data to use
  2312. */
  2313. function _fnAjaxDataSrc ( oSettings, json )
  2314. {
  2315. var dataSrc = $.isPlainObject( oSettings.ajax ) && oSettings.ajax.dataSrc !== undefined ?
  2316. oSettings.ajax.dataSrc :
  2317. oSettings.sAjaxDataProp; // Compatibility with 1.9-.
  2318. // Compatibility with 1.9-. In order to read from aaData, check if the
  2319. // default has been changed, if not, check for aaData
  2320. if ( dataSrc === 'data' ) {
  2321. return json.aaData || json[dataSrc];
  2322. }
  2323. return dataSrc !== "" ?
  2324. _fnGetObjectDataFn( dataSrc )( json ) :
  2325. json;
  2326. }
  2327. /**
  2328. * Generate the node required for filtering text
  2329. * @returns {node} Filter control element
  2330. * @param {object} oSettings dataTables settings object
  2331. * @memberof DataTable#oApi
  2332. */
  2333. function _fnFeatureHtmlFilter ( settings )
  2334. {
  2335. var classes = settings.oClasses;
  2336. var tableId = settings.sTableId;
  2337. var language = settings.oLanguage;
  2338. var previousSearch = settings.oPreviousSearch;
  2339. var features = settings.aanFeatures;
  2340. var input = '<input type="search" class="'+classes.sFilterInput+'"/>';
  2341. var str = language.sSearch;
  2342. str = str.match(/_INPUT_/) ?
  2343. str.replace('_INPUT_', input) :
  2344. str+input;
  2345. var filter = $('<div/>', {
  2346. 'id': ! features.f ? tableId+'_filter' : null,
  2347. 'class': classes.sFilter
  2348. } )
  2349. .append( $('<label/>' ).append( str ) );
  2350. var searchFn = function() {
  2351. /* Update all other filter input elements for the new display */
  2352. var n = features.f;
  2353. var val = !this.value ? "" : this.value; // mental IE8 fix :-(
  2354. /* Now do the filter */
  2355. if ( val != previousSearch.sSearch ) {
  2356. _fnFilterComplete( settings, {
  2357. "sSearch": val,
  2358. "bRegex": previousSearch.bRegex,
  2359. "bSmart": previousSearch.bSmart ,
  2360. "bCaseInsensitive": previousSearch.bCaseInsensitive
  2361. } );
  2362. // Need to redraw, without resorting
  2363. settings._iDisplayStart = 0;
  2364. _fnDraw( settings );
  2365. }
  2366. };
  2367. var searchDelay = settings.searchDelay !== null ?
  2368. settings.searchDelay :
  2369. _fnDataSource( settings ) === 'ssp' ?
  2370. 400 :
  2371. 0;
  2372. var jqFilter = $('input', filter)
  2373. .val( previousSearch.sSearch )
  2374. .attr( 'placeholder', language.sSearchPlaceholder )
  2375. .bind(
  2376. 'keyup.DT search.DT input.DT paste.DT cut.DT',
  2377. searchDelay ?
  2378. _fnThrottle( searchFn, searchDelay ) :
  2379. searchFn
  2380. )
  2381. .bind( 'keypress.DT', function(e) {
  2382. /* Prevent form submission */
  2383. if ( e.keyCode == 13 ) {
  2384. return false;
  2385. }
  2386. } )
  2387. .attr('aria-controls', tableId);
  2388. // Update the input elements whenever the table is filtered
  2389. $(settings.nTable).on( 'search.dt.DT', function ( ev, s ) {
  2390. if ( settings === s ) {
  2391. // IE9 throws an 'unknown error' if document.activeElement is used
  2392. // inside an iframe or frame...
  2393. try {
  2394. if ( jqFilter[0] !== document.activeElement ) {
  2395. jqFilter.val( previousSearch.sSearch );
  2396. }
  2397. }
  2398. catch ( e ) {}
  2399. }
  2400. } );
  2401. return filter[0];
  2402. }
  2403. /**
  2404. * Filter the table using both the global filter and column based filtering
  2405. * @param {object} oSettings dataTables settings object
  2406. * @param {object} oSearch search information
  2407. * @param {int} [iForce] force a research of the master array (1) or not (undefined or 0)
  2408. * @memberof DataTable#oApi
  2409. */
  2410. function _fnFilterComplete ( oSettings, oInput, iForce )
  2411. {
  2412. var oPrevSearch = oSettings.oPreviousSearch;
  2413. var aoPrevSearch = oSettings.aoPreSearchCols;
  2414. var fnSaveFilter = function ( oFilter ) {
  2415. /* Save the filtering values */
  2416. oPrevSearch.sSearch = oFilter.sSearch;
  2417. oPrevSearch.bRegex = oFilter.bRegex;
  2418. oPrevSearch.bSmart = oFilter.bSmart;
  2419. oPrevSearch.bCaseInsensitive = oFilter.bCaseInsensitive;
  2420. };
  2421. var fnRegex = function ( o ) {
  2422. // Backwards compatibility with the bEscapeRegex option
  2423. return o.bEscapeRegex !== undefined ? !o.bEscapeRegex : o.bRegex;
  2424. };
  2425. // Resolve any column types that are unknown due to addition or invalidation
  2426. // @todo As per sort - can this be moved into an event handler?
  2427. _fnColumnTypes( oSettings );
  2428. /* In server-side processing all filtering is done by the server, so no point hanging around here */
  2429. if ( _fnDataSource( oSettings ) != 'ssp' )
  2430. {
  2431. /* Global filter */
  2432. _fnFilter( oSettings, oInput.sSearch, iForce, fnRegex(oInput), oInput.bSmart, oInput.bCaseInsensitive );
  2433. fnSaveFilter( oInput );
  2434. /* Now do the individual column filter */
  2435. for ( var i=0 ; i<aoPrevSearch.length ; i++ )
  2436. {
  2437. _fnFilterColumn( oSettings, aoPrevSearch[i].sSearch, i, fnRegex(aoPrevSearch[i]),
  2438. aoPrevSearch[i].bSmart, aoPrevSearch[i].bCaseInsensitive );
  2439. }
  2440. /* Custom filtering */
  2441. _fnFilterCustom( oSettings );
  2442. }
  2443. else
  2444. {
  2445. fnSaveFilter( oInput );
  2446. }
  2447. /* Tell the draw function we have been filtering */
  2448. oSettings.bFiltered = true;
  2449. _fnCallbackFire( oSettings, null, 'search', [oSettings] );
  2450. }
  2451. /**
  2452. * Apply custom filtering functions
  2453. * @param {object} oSettings dataTables settings object
  2454. * @memberof DataTable#oApi
  2455. */
  2456. function _fnFilterCustom( settings )
  2457. {
  2458. var filters = DataTable.ext.search;
  2459. var displayRows = settings.aiDisplay;
  2460. var row, rowIdx;
  2461. for ( var i=0, ien=filters.length ; i<ien ; i++ ) {
  2462. var rows = [];
  2463. // Loop over each row and see if it should be included
  2464. for ( var j=0, jen=displayRows.length ; j<jen ; j++ ) {
  2465. rowIdx = displayRows[ j ];
  2466. row = settings.aoData[ rowIdx ];
  2467. if ( filters[i]( settings, row._aFilterData, rowIdx, row._aData, j ) ) {
  2468. rows.push( rowIdx );
  2469. }
  2470. }
  2471. // So the array reference doesn't break set the results into the
  2472. // existing array
  2473. displayRows.length = 0;
  2474. displayRows.push.apply( displayRows, rows );
  2475. }
  2476. }
  2477. /**
  2478. * Filter the table on a per-column basis
  2479. * @param {object} oSettings dataTables settings object
  2480. * @param {string} sInput string to filter on
  2481. * @param {int} iColumn column to filter
  2482. * @param {bool} bRegex treat search string as a regular expression or not
  2483. * @param {bool} bSmart use smart filtering or not
  2484. * @param {bool} bCaseInsensitive Do case insenstive matching or not
  2485. * @memberof DataTable#oApi
  2486. */
  2487. function _fnFilterColumn ( settings, searchStr, colIdx, regex, smart, caseInsensitive )
  2488. {
  2489. if ( searchStr === '' ) {
  2490. return;
  2491. }
  2492. var data;
  2493. var display = settings.aiDisplay;
  2494. var rpSearch = _fnFilterCreateSearch( searchStr, regex, smart, caseInsensitive );
  2495. for ( var i=display.length-1 ; i>=0 ; i-- ) {
  2496. data = settings.aoData[ display[i] ]._aFilterData[ colIdx ];
  2497. if ( ! rpSearch.test( data ) ) {
  2498. display.splice( i, 1 );
  2499. }
  2500. }
  2501. }
  2502. /**
  2503. * Filter the data table based on user input and draw the table
  2504. * @param {object} settings dataTables settings object
  2505. * @param {string} input string to filter on
  2506. * @param {int} force optional - force a research of the master array (1) or not (undefined or 0)
  2507. * @param {bool} regex treat as a regular expression or not
  2508. * @param {bool} smart perform smart filtering or not
  2509. * @param {bool} caseInsensitive Do case insenstive matching or not
  2510. * @memberof DataTable#oApi
  2511. */
  2512. function _fnFilter( settings, input, force, regex, smart, caseInsensitive )
  2513. {
  2514. var rpSearch = _fnFilterCreateSearch( input, regex, smart, caseInsensitive );
  2515. var prevSearch = settings.oPreviousSearch.sSearch;
  2516. var displayMaster = settings.aiDisplayMaster;
  2517. var display, invalidated, i;
  2518. // Need to take account of custom filtering functions - always filter
  2519. if ( DataTable.ext.search.length !== 0 ) {
  2520. force = true;
  2521. }
  2522. // Check if any of the rows were invalidated
  2523. invalidated = _fnFilterData( settings );
  2524. // If the input is blank - we just want the full data set
  2525. if ( input.length <= 0 ) {
  2526. settings.aiDisplay = displayMaster.slice();
  2527. }
  2528. else {
  2529. // New search - start from the master array
  2530. if ( invalidated ||
  2531. force ||
  2532. prevSearch.length > input.length ||
  2533. input.indexOf(prevSearch) !== 0 ||
  2534. settings.bSorted // On resort, the display master needs to be
  2535. // re-filtered since indexes will have changed
  2536. ) {
  2537. settings.aiDisplay = displayMaster.slice();
  2538. }
  2539. // Search the display array
  2540. display = settings.aiDisplay;
  2541. for ( i=display.length-1 ; i>=0 ; i-- ) {
  2542. if ( ! rpSearch.test( settings.aoData[ display[i] ]._sFilterRow ) ) {
  2543. display.splice( i, 1 );
  2544. }
  2545. }
  2546. }
  2547. }
  2548. /**
  2549. * Build a regular expression object suitable for searching a table
  2550. * @param {string} sSearch string to search for
  2551. * @param {bool} bRegex treat as a regular expression or not
  2552. * @param {bool} bSmart perform smart filtering or not
  2553. * @param {bool} bCaseInsensitive Do case insensitive matching or not
  2554. * @returns {RegExp} constructed object
  2555. * @memberof DataTable#oApi
  2556. */
  2557. function _fnFilterCreateSearch( search, regex, smart, caseInsensitive )
  2558. {
  2559. search = regex ?
  2560. search :
  2561. _fnEscapeRegex( search );
  2562. if ( smart ) {
  2563. /* For smart filtering we want to allow the search to work regardless of
  2564. * word order. We also want double quoted text to be preserved, so word
  2565. * order is important - a la google. So this is what we want to
  2566. * generate:
  2567. *
  2568. * ^(?=.*?\bone\b)(?=.*?\btwo three\b)(?=.*?\bfour\b).*$
  2569. */
  2570. var a = $.map( search.match( /"[^"]+"|[^ ]+/g ) || '', function ( word ) {
  2571. if ( word.charAt(0) === '"' ) {
  2572. var m = word.match( /^"(.*)"$/ );
  2573. word = m ? m[1] : word;
  2574. }
  2575. return word.replace('"', '');
  2576. } );
  2577. search = '^(?=.*?'+a.join( ')(?=.*?' )+').*$';
  2578. }
  2579. return new RegExp( search, caseInsensitive ? 'i' : '' );
  2580. }
  2581. /**
  2582. * Escape a string such that it can be used in a regular expression
  2583. * @param {string} sVal string to escape
  2584. * @returns {string} escaped string
  2585. * @memberof DataTable#oApi
  2586. */
  2587. function _fnEscapeRegex ( sVal )
  2588. {
  2589. return sVal.replace( _re_escape_regex, '\\$1' );
  2590. }
  2591. var __filter_div = $('<div>')[0];
  2592. var __filter_div_textContent = __filter_div.textContent !== undefined;
  2593. // Update the filtering data for each row if needed (by invalidation or first run)
  2594. function _fnFilterData ( settings )
  2595. {
  2596. var columns = settings.aoColumns;
  2597. var column;
  2598. var i, j, ien, jen, filterData, cellData, row;
  2599. var fomatters = DataTable.ext.type.search;
  2600. var wasInvalidated = false;
  2601. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  2602. row = settings.aoData[i];
  2603. if ( ! row._aFilterData ) {
  2604. filterData = [];
  2605. for ( j=0, jen=columns.length ; j<jen ; j++ ) {
  2606. column = columns[j];
  2607. if ( column.bSearchable ) {
  2608. cellData = _fnGetCellData( settings, i, j, 'filter' );
  2609. if ( fomatters[ column.sType ] ) {
  2610. cellData = fomatters[ column.sType ]( cellData );
  2611. }
  2612. // Search in DataTables 1.10 is string based. In 1.11 this
  2613. // should be altered to also allow strict type checking.
  2614. if ( cellData === null ) {
  2615. cellData = '';
  2616. }
  2617. if ( typeof cellData !== 'string' && cellData.toString ) {
  2618. cellData = cellData.toString();
  2619. }
  2620. }
  2621. else {
  2622. cellData = '';
  2623. }
  2624. // If it looks like there is an HTML entity in the string,
  2625. // attempt to decode it so sorting works as expected. Note that
  2626. // we could use a single line of jQuery to do this, but the DOM
  2627. // method used here is much faster http://jsperf.com/html-decode
  2628. if ( cellData.indexOf && cellData.indexOf('&') !== -1 ) {
  2629. __filter_div.innerHTML = cellData;
  2630. cellData = __filter_div_textContent ?
  2631. __filter_div.textContent :
  2632. __filter_div.innerText;
  2633. }
  2634. if ( cellData.replace ) {
  2635. cellData = cellData.replace(/[\r\n]/g, '');
  2636. }
  2637. filterData.push( cellData );
  2638. }
  2639. row._aFilterData = filterData;
  2640. row._sFilterRow = filterData.join(' ');
  2641. wasInvalidated = true;
  2642. }
  2643. }
  2644. return wasInvalidated;
  2645. }
  2646. /**
  2647. * Convert from the internal Hungarian notation to camelCase for external
  2648. * interaction
  2649. * @param {object} obj Object to convert
  2650. * @returns {object} Inverted object
  2651. * @memberof DataTable#oApi
  2652. */
  2653. function _fnSearchToCamel ( obj )
  2654. {
  2655. return {
  2656. search: obj.sSearch,
  2657. smart: obj.bSmart,
  2658. regex: obj.bRegex,
  2659. caseInsensitive: obj.bCaseInsensitive
  2660. };
  2661. }
  2662. /**
  2663. * Convert from camelCase notation to the internal Hungarian. We could use the
  2664. * Hungarian convert function here, but this is cleaner
  2665. * @param {object} obj Object to convert
  2666. * @returns {object} Inverted object
  2667. * @memberof DataTable#oApi
  2668. */
  2669. function _fnSearchToHung ( obj )
  2670. {
  2671. return {
  2672. sSearch: obj.search,
  2673. bSmart: obj.smart,
  2674. bRegex: obj.regex,
  2675. bCaseInsensitive: obj.caseInsensitive
  2676. };
  2677. }
  2678. /**
  2679. * Generate the node required for the info display
  2680. * @param {object} oSettings dataTables settings object
  2681. * @returns {node} Information element
  2682. * @memberof DataTable#oApi
  2683. */
  2684. function _fnFeatureHtmlInfo ( settings )
  2685. {
  2686. var
  2687. tid = settings.sTableId,
  2688. nodes = settings.aanFeatures.i,
  2689. n = $('<div/>', {
  2690. 'class': settings.oClasses.sInfo,
  2691. 'id': ! nodes ? tid+'_info' : null
  2692. } );
  2693. if ( ! nodes ) {
  2694. // Update display on each draw
  2695. settings.aoDrawCallback.push( {
  2696. "fn": _fnUpdateInfo,
  2697. "sName": "information"
  2698. } );
  2699. n
  2700. .attr( 'role', 'status' )
  2701. .attr( 'aria-live', 'polite' );
  2702. // Table is described by our info div
  2703. $(settings.nTable).attr( 'aria-describedby', tid+'_info' );
  2704. }
  2705. return n[0];
  2706. }
  2707. /**
  2708. * Update the information elements in the display
  2709. * @param {object} settings dataTables settings object
  2710. * @memberof DataTable#oApi
  2711. */
  2712. function _fnUpdateInfo ( settings )
  2713. {
  2714. /* Show information about the table */
  2715. var nodes = settings.aanFeatures.i;
  2716. if ( nodes.length === 0 ) {
  2717. return;
  2718. }
  2719. var
  2720. lang = settings.oLanguage,
  2721. start = settings._iDisplayStart+1,
  2722. end = settings.fnDisplayEnd(),
  2723. max = settings.fnRecordsTotal(),
  2724. total = settings.fnRecordsDisplay(),
  2725. out = total ?
  2726. lang.sInfo :
  2727. lang.sInfoEmpty;
  2728. if ( total !== max ) {
  2729. /* Record set after filtering */
  2730. out += ' ' + lang.sInfoFiltered;
  2731. }
  2732. // Convert the macros
  2733. out += lang.sInfoPostFix;
  2734. out = _fnInfoMacros( settings, out );
  2735. var callback = lang.fnInfoCallback;
  2736. if ( callback !== null ) {
  2737. out = callback.call( settings.oInstance,
  2738. settings, start, end, max, total, out
  2739. );
  2740. }
  2741. $(nodes).html( out );
  2742. }
  2743. function _fnInfoMacros ( settings, str )
  2744. {
  2745. // When infinite scrolling, we are always starting at 1. _iDisplayStart is used only
  2746. // internally
  2747. var
  2748. formatter = settings.fnFormatNumber,
  2749. start = settings._iDisplayStart+1,
  2750. len = settings._iDisplayLength,
  2751. vis = settings.fnRecordsDisplay(),
  2752. all = len === -1;
  2753. return str.
  2754. replace(/_START_/g, formatter.call( settings, start ) ).
  2755. replace(/_END_/g, formatter.call( settings, settings.fnDisplayEnd() ) ).
  2756. replace(/_MAX_/g, formatter.call( settings, settings.fnRecordsTotal() ) ).
  2757. replace(/_TOTAL_/g, formatter.call( settings, vis ) ).
  2758. replace(/_PAGE_/g, formatter.call( settings, all ? 1 : Math.ceil( start / len ) ) ).
  2759. replace(/_PAGES_/g, formatter.call( settings, all ? 1 : Math.ceil( vis / len ) ) );
  2760. }
  2761. /**
  2762. * Draw the table for the first time, adding all required features
  2763. * @param {object} settings dataTables settings object
  2764. * @memberof DataTable#oApi
  2765. */
  2766. function _fnInitialise ( settings )
  2767. {
  2768. var i, iLen, iAjaxStart=settings.iInitDisplayStart;
  2769. var columns = settings.aoColumns, column;
  2770. var features = settings.oFeatures;
  2771. /* Ensure that the table data is fully initialised */
  2772. if ( ! settings.bInitialised ) {
  2773. setTimeout( function(){ _fnInitialise( settings ); }, 200 );
  2774. return;
  2775. }
  2776. /* Show the display HTML options */
  2777. _fnAddOptionsHtml( settings );
  2778. /* Build and draw the header / footer for the table */
  2779. _fnBuildHead( settings );
  2780. _fnDrawHead( settings, settings.aoHeader );
  2781. _fnDrawHead( settings, settings.aoFooter );
  2782. /* Okay to show that something is going on now */
  2783. _fnProcessingDisplay( settings, true );
  2784. /* Calculate sizes for columns */
  2785. if ( features.bAutoWidth ) {
  2786. _fnCalculateColumnWidths( settings );
  2787. }
  2788. for ( i=0, iLen=columns.length ; i<iLen ; i++ ) {
  2789. column = columns[i];
  2790. if ( column.sWidth ) {
  2791. column.nTh.style.width = _fnStringToCss( column.sWidth );
  2792. }
  2793. }
  2794. // If there is default sorting required - let's do it. The sort function
  2795. // will do the drawing for us. Otherwise we draw the table regardless of the
  2796. // Ajax source - this allows the table to look initialised for Ajax sourcing
  2797. // data (show 'loading' message possibly)
  2798. _fnReDraw( settings );
  2799. // Server-side processing init complete is done by _fnAjaxUpdateDraw
  2800. var dataSrc = _fnDataSource( settings );
  2801. if ( dataSrc != 'ssp' ) {
  2802. // if there is an ajax source load the data
  2803. if ( dataSrc == 'ajax' ) {
  2804. _fnBuildAjax( settings, [], function(json) {
  2805. var aData = _fnAjaxDataSrc( settings, json );
  2806. // Got the data - add it to the table
  2807. for ( i=0 ; i<aData.length ; i++ ) {
  2808. _fnAddData( settings, aData[i] );
  2809. }
  2810. // Reset the init display for cookie saving. We've already done
  2811. // a filter, and therefore cleared it before. So we need to make
  2812. // it appear 'fresh'
  2813. settings.iInitDisplayStart = iAjaxStart;
  2814. _fnReDraw( settings );
  2815. _fnProcessingDisplay( settings, false );
  2816. _fnInitComplete( settings, json );
  2817. }, settings );
  2818. }
  2819. else {
  2820. _fnProcessingDisplay( settings, false );
  2821. _fnInitComplete( settings );
  2822. }
  2823. }
  2824. }
  2825. /**
  2826. * Draw the table for the first time, adding all required features
  2827. * @param {object} oSettings dataTables settings object
  2828. * @param {object} [json] JSON from the server that completed the table, if using Ajax source
  2829. * with client-side processing (optional)
  2830. * @memberof DataTable#oApi
  2831. */
  2832. function _fnInitComplete ( settings, json )
  2833. {
  2834. settings._bInitComplete = true;
  2835. // On an Ajax load we now have data and therefore want to apply the column
  2836. // sizing
  2837. if ( json ) {
  2838. _fnAdjustColumnSizing( settings );
  2839. }
  2840. _fnCallbackFire( settings, 'aoInitComplete', 'init', [settings, json] );
  2841. }
  2842. function _fnLengthChange ( settings, val )
  2843. {
  2844. var len = parseInt( val, 10 );
  2845. settings._iDisplayLength = len;
  2846. _fnLengthOverflow( settings );
  2847. // Fire length change event
  2848. _fnCallbackFire( settings, null, 'length', [settings, len] );
  2849. }
  2850. /**
  2851. * Generate the node required for user display length changing
  2852. * @param {object} settings dataTables settings object
  2853. * @returns {node} Display length feature node
  2854. * @memberof DataTable#oApi
  2855. */
  2856. function _fnFeatureHtmlLength ( settings )
  2857. {
  2858. var
  2859. classes = settings.oClasses,
  2860. tableId = settings.sTableId,
  2861. menu = settings.aLengthMenu,
  2862. d2 = $.isArray( menu[0] ),
  2863. lengths = d2 ? menu[0] : menu,
  2864. language = d2 ? menu[1] : menu;
  2865. var select = $('<select/>', {
  2866. 'name': tableId+'_length',
  2867. 'aria-controls': tableId,
  2868. 'class': classes.sLengthSelect
  2869. } );
  2870. for ( var i=0, ien=lengths.length ; i<ien ; i++ ) {
  2871. select[0][ i ] = new Option( language[i], lengths[i] );
  2872. }
  2873. var div = $('<div><label/></div>').addClass( classes.sLength );
  2874. if ( ! settings.aanFeatures.l ) {
  2875. div[0].id = tableId+'_length';
  2876. }
  2877. div.children().append(
  2878. settings.oLanguage.sLengthMenu.replace( '_MENU_', select[0].outerHTML )
  2879. );
  2880. // Can't use `select` variable as user might provide their own and the
  2881. // reference is broken by the use of outerHTML
  2882. $('select', div)
  2883. .val( settings._iDisplayLength )
  2884. .bind( 'change.DT', function(e) {
  2885. _fnLengthChange( settings, $(this).val() );
  2886. _fnDraw( settings );
  2887. } );
  2888. // Update node value whenever anything changes the table's length
  2889. $(settings.nTable).bind( 'length.dt.DT', function (e, s, len) {
  2890. if ( settings === s ) {
  2891. $('select', div).val( len );
  2892. }
  2893. } );
  2894. return div[0];
  2895. }
  2896. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  2897. * Note that most of the paging logic is done in
  2898. * DataTable.ext.pager
  2899. */
  2900. /**
  2901. * Generate the node required for default pagination
  2902. * @param {object} oSettings dataTables settings object
  2903. * @returns {node} Pagination feature node
  2904. * @memberof DataTable#oApi
  2905. */
  2906. function _fnFeatureHtmlPaginate ( settings )
  2907. {
  2908. var
  2909. type = settings.sPaginationType,
  2910. plugin = DataTable.ext.pager[ type ],
  2911. modern = typeof plugin === 'function',
  2912. redraw = function( settings ) {
  2913. _fnDraw( settings );
  2914. },
  2915. node = $('<div/>').addClass( settings.oClasses.sPaging + type )[0],
  2916. features = settings.aanFeatures;
  2917. if ( ! modern ) {
  2918. plugin.fnInit( settings, node, redraw );
  2919. }
  2920. /* Add a draw callback for the pagination on first instance, to update the paging display */
  2921. if ( ! features.p )
  2922. {
  2923. node.id = settings.sTableId+'_paginate';
  2924. settings.aoDrawCallback.push( {
  2925. "fn": function( settings ) {
  2926. if ( modern ) {
  2927. var
  2928. start = settings._iDisplayStart,
  2929. len = settings._iDisplayLength,
  2930. visRecords = settings.fnRecordsDisplay(),
  2931. all = len === -1,
  2932. page = all ? 0 : Math.ceil( start / len ),
  2933. pages = all ? 1 : Math.ceil( visRecords / len ),
  2934. buttons = plugin(page, pages),
  2935. i, ien;
  2936. for ( i=0, ien=features.p.length ; i<ien ; i++ ) {
  2937. _fnRenderer( settings, 'pageButton' )(
  2938. settings, features.p[i], i, buttons, page, pages
  2939. );
  2940. }
  2941. }
  2942. else {
  2943. plugin.fnUpdate( settings, redraw );
  2944. }
  2945. },
  2946. "sName": "pagination"
  2947. } );
  2948. }
  2949. return node;
  2950. }
  2951. /**
  2952. * Alter the display settings to change the page
  2953. * @param {object} settings DataTables settings object
  2954. * @param {string|int} action Paging action to take: "first", "previous",
  2955. * "next" or "last" or page number to jump to (integer)
  2956. * @param [bool] redraw Automatically draw the update or not
  2957. * @returns {bool} true page has changed, false - no change
  2958. * @memberof DataTable#oApi
  2959. */
  2960. function _fnPageChange ( settings, action, redraw )
  2961. {
  2962. var
  2963. start = settings._iDisplayStart,
  2964. len = settings._iDisplayLength,
  2965. records = settings.fnRecordsDisplay();
  2966. if ( records === 0 || len === -1 )
  2967. {
  2968. start = 0;
  2969. }
  2970. else if ( typeof action === "number" )
  2971. {
  2972. start = action * len;
  2973. if ( start > records )
  2974. {
  2975. start = 0;
  2976. }
  2977. }
  2978. else if ( action == "first" )
  2979. {
  2980. start = 0;
  2981. }
  2982. else if ( action == "previous" )
  2983. {
  2984. start = len >= 0 ?
  2985. start - len :
  2986. 0;
  2987. if ( start < 0 )
  2988. {
  2989. start = 0;
  2990. }
  2991. }
  2992. else if ( action == "next" )
  2993. {
  2994. if ( start + len < records )
  2995. {
  2996. start += len;
  2997. }
  2998. }
  2999. else if ( action == "last" )
  3000. {
  3001. start = Math.floor( (records-1) / len) * len;
  3002. }
  3003. else
  3004. {
  3005. _fnLog( settings, 0, "Unknown paging action: "+action, 5 );
  3006. }
  3007. var changed = settings._iDisplayStart !== start;
  3008. settings._iDisplayStart = start;
  3009. if ( changed ) {
  3010. _fnCallbackFire( settings, null, 'page', [settings] );
  3011. if ( redraw ) {
  3012. _fnDraw( settings );
  3013. }
  3014. }
  3015. return changed;
  3016. }
  3017. /**
  3018. * Generate the node required for the processing node
  3019. * @param {object} settings dataTables settings object
  3020. * @returns {node} Processing element
  3021. * @memberof DataTable#oApi
  3022. */
  3023. function _fnFeatureHtmlProcessing ( settings )
  3024. {
  3025. return $('<div/>', {
  3026. 'id': ! settings.aanFeatures.r ? settings.sTableId+'_processing' : null,
  3027. 'class': settings.oClasses.sProcessing
  3028. } )
  3029. .html( settings.oLanguage.sProcessing )
  3030. .insertBefore( settings.nTable )[0];
  3031. }
  3032. /**
  3033. * Display or hide the processing indicator
  3034. * @param {object} settings dataTables settings object
  3035. * @param {bool} show Show the processing indicator (true) or not (false)
  3036. * @memberof DataTable#oApi
  3037. */
  3038. function _fnProcessingDisplay ( settings, show )
  3039. {
  3040. if ( settings.oFeatures.bProcessing ) {
  3041. $(settings.aanFeatures.r).css( 'display', show ? 'block' : 'none' );
  3042. }
  3043. _fnCallbackFire( settings, null, 'processing', [settings, show] );
  3044. }
  3045. /**
  3046. * Add any control elements for the table - specifically scrolling
  3047. * @param {object} settings dataTables settings object
  3048. * @returns {node} Node to add to the DOM
  3049. * @memberof DataTable#oApi
  3050. */
  3051. function _fnFeatureHtmlTable ( settings )
  3052. {
  3053. var table = $(settings.nTable);
  3054. // Add the ARIA grid role to the table
  3055. table.attr( 'role', 'grid' );
  3056. // Scrolling from here on in
  3057. var scroll = settings.oScroll;
  3058. if ( scroll.sX === '' && scroll.sY === '' ) {
  3059. return settings.nTable;
  3060. }
  3061. var scrollX = scroll.sX;
  3062. var scrollY = scroll.sY;
  3063. var classes = settings.oClasses;
  3064. var caption = table.children('caption');
  3065. var captionSide = caption.length ? caption[0]._captionSide : null;
  3066. var headerClone = $( table[0].cloneNode(false) );
  3067. var footerClone = $( table[0].cloneNode(false) );
  3068. var footer = table.children('tfoot');
  3069. var _div = '<div/>';
  3070. var size = function ( s ) {
  3071. return !s ? null : _fnStringToCss( s );
  3072. };
  3073. // This is fairly messy, but with x scrolling enabled, if the table has a
  3074. // width attribute, regardless of any width applied using the column width
  3075. // options, the browser will shrink or grow the table as needed to fit into
  3076. // that 100%. That would make the width options useless. So we remove it.
  3077. // This is okay, under the assumption that width:100% is applied to the
  3078. // table in CSS (it is in the default stylesheet) which will set the table
  3079. // width as appropriate (the attribute and css behave differently...)
  3080. if ( scroll.sX && table.attr('width') === '100%' ) {
  3081. table.removeAttr('width');
  3082. }
  3083. if ( ! footer.length ) {
  3084. footer = null;
  3085. }
  3086. /*
  3087. * The HTML structure that we want to generate in this function is:
  3088. * div - scroller
  3089. * div - scroll head
  3090. * div - scroll head inner
  3091. * table - scroll head table
  3092. * thead - thead
  3093. * div - scroll body
  3094. * table - table (master table)
  3095. * thead - thead clone for sizing
  3096. * tbody - tbody
  3097. * div - scroll foot
  3098. * div - scroll foot inner
  3099. * table - scroll foot table
  3100. * tfoot - tfoot
  3101. */
  3102. var scroller = $( _div, { 'class': classes.sScrollWrapper } )
  3103. .append(
  3104. $(_div, { 'class': classes.sScrollHead } )
  3105. .css( {
  3106. overflow: 'hidden',
  3107. position: 'relative',
  3108. border: 0,
  3109. width: scrollX ? size(scrollX) : '100%'
  3110. } )
  3111. .append(
  3112. $(_div, { 'class': classes.sScrollHeadInner } )
  3113. .css( {
  3114. 'box-sizing': 'content-box',
  3115. width: scroll.sXInner || '100%'
  3116. } )
  3117. .append(
  3118. headerClone
  3119. .removeAttr('id')
  3120. .css( 'margin-left', 0 )
  3121. .append( captionSide === 'top' ? caption : null )
  3122. .append(
  3123. table.children('thead')
  3124. )
  3125. )
  3126. )
  3127. )
  3128. .append(
  3129. $(_div, { 'class': classes.sScrollBody } )
  3130. .css( {
  3131. overflow: 'auto',
  3132. height: size( scrollY ),
  3133. width: size( scrollX )
  3134. } )
  3135. .append( table )
  3136. );
  3137. if ( footer ) {
  3138. scroller.append(
  3139. $(_div, { 'class': classes.sScrollFoot } )
  3140. .css( {
  3141. overflow: 'hidden',
  3142. border: 0,
  3143. width: scrollX ? size(scrollX) : '100%'
  3144. } )
  3145. .append(
  3146. $(_div, { 'class': classes.sScrollFootInner } )
  3147. .append(
  3148. footerClone
  3149. .removeAttr('id')
  3150. .css( 'margin-left', 0 )
  3151. .append( captionSide === 'bottom' ? caption : null )
  3152. .append(
  3153. table.children('tfoot')
  3154. )
  3155. )
  3156. )
  3157. );
  3158. }
  3159. var children = scroller.children();
  3160. var scrollHead = children[0];
  3161. var scrollBody = children[1];
  3162. var scrollFoot = footer ? children[2] : null;
  3163. // When the body is scrolled, then we also want to scroll the headers
  3164. if ( scrollX ) {
  3165. $(scrollBody).scroll( function (e) {
  3166. var scrollLeft = this.scrollLeft;
  3167. scrollHead.scrollLeft = scrollLeft;
  3168. if ( footer ) {
  3169. scrollFoot.scrollLeft = scrollLeft;
  3170. }
  3171. } );
  3172. }
  3173. settings.nScrollHead = scrollHead;
  3174. settings.nScrollBody = scrollBody;
  3175. settings.nScrollFoot = scrollFoot;
  3176. // On redraw - align columns
  3177. settings.aoDrawCallback.push( {
  3178. "fn": _fnScrollDraw,
  3179. "sName": "scrolling"
  3180. } );
  3181. return scroller[0];
  3182. }
  3183. /**
  3184. * Update the header, footer and body tables for resizing - i.e. column
  3185. * alignment.
  3186. *
  3187. * Welcome to the most horrible function DataTables. The process that this
  3188. * function follows is basically:
  3189. * 1. Re-create the table inside the scrolling div
  3190. * 2. Take live measurements from the DOM
  3191. * 3. Apply the measurements to align the columns
  3192. * 4. Clean up
  3193. *
  3194. * @param {object} settings dataTables settings object
  3195. * @memberof DataTable#oApi
  3196. */
  3197. function _fnScrollDraw ( settings )
  3198. {
  3199. // Given that this is such a monster function, a lot of variables are use
  3200. // to try and keep the minimised size as small as possible
  3201. var
  3202. scroll = settings.oScroll,
  3203. scrollX = scroll.sX,
  3204. scrollXInner = scroll.sXInner,
  3205. scrollY = scroll.sY,
  3206. barWidth = scroll.iBarWidth,
  3207. divHeader = $(settings.nScrollHead),
  3208. divHeaderStyle = divHeader[0].style,
  3209. divHeaderInner = divHeader.children('div'),
  3210. divHeaderInnerStyle = divHeaderInner[0].style,
  3211. divHeaderTable = divHeaderInner.children('table'),
  3212. divBodyEl = settings.nScrollBody,
  3213. divBody = $(divBodyEl),
  3214. divBodyStyle = divBodyEl.style,
  3215. divFooter = $(settings.nScrollFoot),
  3216. divFooterInner = divFooter.children('div'),
  3217. divFooterTable = divFooterInner.children('table'),
  3218. header = $(settings.nTHead),
  3219. table = $(settings.nTable),
  3220. tableEl = table[0],
  3221. tableStyle = tableEl.style,
  3222. footer = settings.nTFoot ? $(settings.nTFoot) : null,
  3223. browser = settings.oBrowser,
  3224. ie67 = browser.bScrollOversize,
  3225. headerTrgEls, footerTrgEls,
  3226. headerSrcEls, footerSrcEls,
  3227. headerCopy, footerCopy,
  3228. headerWidths=[], footerWidths=[],
  3229. headerContent=[],
  3230. idx, correction, sanityWidth,
  3231. zeroOut = function(nSizer) {
  3232. var style = nSizer.style;
  3233. style.paddingTop = "0";
  3234. style.paddingBottom = "0";
  3235. style.borderTopWidth = "0";
  3236. style.borderBottomWidth = "0";
  3237. style.height = 0;
  3238. };
  3239. /*
  3240. * 1. Re-create the table inside the scrolling div
  3241. */
  3242. // Remove the old minimised thead and tfoot elements in the inner table
  3243. table.children('thead, tfoot').remove();
  3244. // Clone the current header and footer elements and then place it into the inner table
  3245. headerCopy = header.clone().prependTo( table );
  3246. headerTrgEls = header.find('tr'); // original header is in its own table
  3247. headerSrcEls = headerCopy.find('tr');
  3248. headerCopy.find('th, td').removeAttr('tabindex');
  3249. if ( footer ) {
  3250. footerCopy = footer.clone().prependTo( table );
  3251. footerTrgEls = footer.find('tr'); // the original tfoot is in its own table and must be sized
  3252. footerSrcEls = footerCopy.find('tr');
  3253. }
  3254. /*
  3255. * 2. Take live measurements from the DOM - do not alter the DOM itself!
  3256. */
  3257. // Remove old sizing and apply the calculated column widths
  3258. // Get the unique column headers in the newly created (cloned) header. We want to apply the
  3259. // calculated sizes to this header
  3260. if ( ! scrollX )
  3261. {
  3262. divBodyStyle.width = '100%';
  3263. divHeader[0].style.width = '100%';
  3264. }
  3265. $.each( _fnGetUniqueThs( settings, headerCopy ), function ( i, el ) {
  3266. idx = _fnVisibleToColumnIndex( settings, i );
  3267. el.style.width = settings.aoColumns[idx].sWidth;
  3268. } );
  3269. if ( footer ) {
  3270. _fnApplyToChildren( function(n) {
  3271. n.style.width = "";
  3272. }, footerSrcEls );
  3273. }
  3274. // If scroll collapse is enabled, when we put the headers back into the body for sizing, we
  3275. // will end up forcing the scrollbar to appear, making our measurements wrong for when we
  3276. // then hide it (end of this function), so add the header height to the body scroller.
  3277. if ( scroll.bCollapse && scrollY !== "" ) {
  3278. divBodyStyle.height = (divBody[0].offsetHeight + header[0].offsetHeight)+"px";
  3279. }
  3280. // Size the table as a whole
  3281. sanityWidth = table.outerWidth();
  3282. if ( scrollX === "" ) {
  3283. // No x scrolling
  3284. tableStyle.width = "100%";
  3285. // IE7 will make the width of the table when 100% include the scrollbar
  3286. // - which is shouldn't. When there is a scrollbar we need to take this
  3287. // into account.
  3288. if ( ie67 && (table.find('tbody').height() > divBodyEl.offsetHeight ||
  3289. divBody.css('overflow-y') == "scroll")
  3290. ) {
  3291. tableStyle.width = _fnStringToCss( table.outerWidth() - barWidth);
  3292. }
  3293. }
  3294. else
  3295. {
  3296. // x scrolling
  3297. if ( scrollXInner !== "" ) {
  3298. // x scroll inner has been given - use it
  3299. tableStyle.width = _fnStringToCss(scrollXInner);
  3300. }
  3301. else if ( sanityWidth == divBody.width() && divBody.height() < table.height() ) {
  3302. // There is y-scrolling - try to take account of the y scroll bar
  3303. tableStyle.width = _fnStringToCss( sanityWidth-barWidth );
  3304. if ( table.outerWidth() > sanityWidth-barWidth ) {
  3305. // Not possible to take account of it
  3306. tableStyle.width = _fnStringToCss( sanityWidth );
  3307. }
  3308. }
  3309. else {
  3310. // When all else fails
  3311. tableStyle.width = _fnStringToCss( sanityWidth );
  3312. }
  3313. }
  3314. // Recalculate the sanity width - now that we've applied the required width,
  3315. // before it was a temporary variable. This is required because the column
  3316. // width calculation is done before this table DOM is created.
  3317. sanityWidth = table.outerWidth();
  3318. // Hidden header should have zero height, so remove padding and borders. Then
  3319. // set the width based on the real headers
  3320. // Apply all styles in one pass
  3321. _fnApplyToChildren( zeroOut, headerSrcEls );
  3322. // Read all widths in next pass
  3323. _fnApplyToChildren( function(nSizer) {
  3324. headerContent.push( nSizer.innerHTML );
  3325. headerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  3326. }, headerSrcEls );
  3327. // Apply all widths in final pass
  3328. _fnApplyToChildren( function(nToSize, i) {
  3329. nToSize.style.width = headerWidths[i];
  3330. }, headerTrgEls );
  3331. $(headerSrcEls).height(0);
  3332. /* Same again with the footer if we have one */
  3333. if ( footer )
  3334. {
  3335. _fnApplyToChildren( zeroOut, footerSrcEls );
  3336. _fnApplyToChildren( function(nSizer) {
  3337. footerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  3338. }, footerSrcEls );
  3339. _fnApplyToChildren( function(nToSize, i) {
  3340. nToSize.style.width = footerWidths[i];
  3341. }, footerTrgEls );
  3342. $(footerSrcEls).height(0);
  3343. }
  3344. /*
  3345. * 3. Apply the measurements
  3346. */
  3347. // "Hide" the header and footer that we used for the sizing. We need to keep
  3348. // the content of the cell so that the width applied to the header and body
  3349. // both match, but we want to hide it completely. We want to also fix their
  3350. // width to what they currently are
  3351. _fnApplyToChildren( function(nSizer, i) {
  3352. nSizer.innerHTML = '<div class="dataTables_sizing" style="height:0;overflow:hidden;">'+headerContent[i]+'</div>';
  3353. nSizer.style.width = headerWidths[i];
  3354. }, headerSrcEls );
  3355. if ( footer )
  3356. {
  3357. _fnApplyToChildren( function(nSizer, i) {
  3358. nSizer.innerHTML = "";
  3359. nSizer.style.width = footerWidths[i];
  3360. }, footerSrcEls );
  3361. }
  3362. // Sanity check that the table is of a sensible width. If not then we are going to get
  3363. // misalignment - try to prevent this by not allowing the table to shrink below its min width
  3364. if ( table.outerWidth() < sanityWidth )
  3365. {
  3366. // The min width depends upon if we have a vertical scrollbar visible or not */
  3367. correction = ((divBodyEl.scrollHeight > divBodyEl.offsetHeight ||
  3368. divBody.css('overflow-y') == "scroll")) ?
  3369. sanityWidth+barWidth :
  3370. sanityWidth;
  3371. // IE6/7 are a law unto themselves...
  3372. if ( ie67 && (divBodyEl.scrollHeight >
  3373. divBodyEl.offsetHeight || divBody.css('overflow-y') == "scroll")
  3374. ) {
  3375. tableStyle.width = _fnStringToCss( correction-barWidth );
  3376. }
  3377. // And give the user a warning that we've stopped the table getting too small
  3378. if ( scrollX === "" || scrollXInner !== "" ) {
  3379. _fnLog( settings, 1, 'Possible column misalignment', 6 );
  3380. }
  3381. }
  3382. else
  3383. {
  3384. correction = '100%';
  3385. }
  3386. // Apply to the container elements
  3387. divBodyStyle.width = _fnStringToCss( correction );
  3388. divHeaderStyle.width = _fnStringToCss( correction );
  3389. if ( footer ) {
  3390. settings.nScrollFoot.style.width = _fnStringToCss( correction );
  3391. }
  3392. /*
  3393. * 4. Clean up
  3394. */
  3395. if ( ! scrollY ) {
  3396. /* IE7< puts a vertical scrollbar in place (when it shouldn't be) due to subtracting
  3397. * the scrollbar height from the visible display, rather than adding it on. We need to
  3398. * set the height in order to sort this. Don't want to do it in any other browsers.
  3399. */
  3400. if ( ie67 ) {
  3401. divBodyStyle.height = _fnStringToCss( tableEl.offsetHeight+barWidth );
  3402. }
  3403. }
  3404. if ( scrollY && scroll.bCollapse ) {
  3405. divBodyStyle.height = _fnStringToCss( scrollY );
  3406. var iExtra = (scrollX && tableEl.offsetWidth > divBodyEl.offsetWidth) ?
  3407. barWidth :
  3408. 0;
  3409. if ( tableEl.offsetHeight < divBodyEl.offsetHeight ) {
  3410. divBodyStyle.height = _fnStringToCss( tableEl.offsetHeight+iExtra );
  3411. }
  3412. }
  3413. /* Finally set the width's of the header and footer tables */
  3414. var iOuterWidth = table.outerWidth();
  3415. divHeaderTable[0].style.width = _fnStringToCss( iOuterWidth );
  3416. divHeaderInnerStyle.width = _fnStringToCss( iOuterWidth );
  3417. // Figure out if there are scrollbar present - if so then we need a the header and footer to
  3418. // provide a bit more space to allow "overflow" scrolling (i.e. past the scrollbar)
  3419. var bScrolling = table.height() > divBodyEl.clientHeight || divBody.css('overflow-y') == "scroll";
  3420. var padding = 'padding' + (browser.bScrollbarLeft ? 'Left' : 'Right' );
  3421. divHeaderInnerStyle[ padding ] = bScrolling ? barWidth+"px" : "0px";
  3422. if ( footer ) {
  3423. divFooterTable[0].style.width = _fnStringToCss( iOuterWidth );
  3424. divFooterInner[0].style.width = _fnStringToCss( iOuterWidth );
  3425. divFooterInner[0].style[padding] = bScrolling ? barWidth+"px" : "0px";
  3426. }
  3427. /* Adjust the position of the header in case we loose the y-scrollbar */
  3428. divBody.scroll();
  3429. // If sorting or filtering has occurred, jump the scrolling back to the top
  3430. // only if we aren't holding the position
  3431. if ( (settings.bSorted || settings.bFiltered) && ! settings._drawHold ) {
  3432. divBodyEl.scrollTop = 0;
  3433. }
  3434. }
  3435. /**
  3436. * Apply a given function to the display child nodes of an element array (typically
  3437. * TD children of TR rows
  3438. * @param {function} fn Method to apply to the objects
  3439. * @param array {nodes} an1 List of elements to look through for display children
  3440. * @param array {nodes} an2 Another list (identical structure to the first) - optional
  3441. * @memberof DataTable#oApi
  3442. */
  3443. function _fnApplyToChildren( fn, an1, an2 )
  3444. {
  3445. var index=0, i=0, iLen=an1.length;
  3446. var nNode1, nNode2;
  3447. while ( i < iLen ) {
  3448. nNode1 = an1[i].firstChild;
  3449. nNode2 = an2 ? an2[i].firstChild : null;
  3450. while ( nNode1 ) {
  3451. if ( nNode1.nodeType === 1 ) {
  3452. if ( an2 ) {
  3453. fn( nNode1, nNode2, index );
  3454. }
  3455. else {
  3456. fn( nNode1, index );
  3457. }
  3458. index++;
  3459. }
  3460. nNode1 = nNode1.nextSibling;
  3461. nNode2 = an2 ? nNode2.nextSibling : null;
  3462. }
  3463. i++;
  3464. }
  3465. }
  3466. var __re_html_remove = /<.*?>/g;
  3467. /**
  3468. * Calculate the width of columns for the table
  3469. * @param {object} oSettings dataTables settings object
  3470. * @memberof DataTable#oApi
  3471. */
  3472. function _fnCalculateColumnWidths ( oSettings )
  3473. {
  3474. var
  3475. table = oSettings.nTable,
  3476. columns = oSettings.aoColumns,
  3477. scroll = oSettings.oScroll,
  3478. scrollY = scroll.sY,
  3479. scrollX = scroll.sX,
  3480. scrollXInner = scroll.sXInner,
  3481. columnCount = columns.length,
  3482. visibleColumns = _fnGetColumns( oSettings, 'bVisible' ),
  3483. headerCells = $('th', oSettings.nTHead),
  3484. tableWidthAttr = table.getAttribute('width'),
  3485. tableContainer = table.parentNode,
  3486. userInputs = false,
  3487. i, column, columnIdx, width, outerWidth;
  3488. /* Convert any user input sizes into pixel sizes */
  3489. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3490. column = columns[ visibleColumns[i] ];
  3491. if ( column.sWidth !== null ) {
  3492. column.sWidth = _fnConvertToWidth( column.sWidthOrig, tableContainer );
  3493. userInputs = true;
  3494. }
  3495. }
  3496. /* If the number of columns in the DOM equals the number that we have to
  3497. * process in DataTables, then we can use the offsets that are created by
  3498. * the web- browser. No custom sizes can be set in order for this to happen,
  3499. * nor scrolling used
  3500. */
  3501. if ( ! userInputs && ! scrollX && ! scrollY &&
  3502. columnCount == _fnVisbleColumns( oSettings ) &&
  3503. columnCount == headerCells.length
  3504. ) {
  3505. for ( i=0 ; i<columnCount ; i++ ) {
  3506. columns[i].sWidth = _fnStringToCss( headerCells.eq(i).width() );
  3507. }
  3508. }
  3509. else
  3510. {
  3511. // Otherwise construct a single row table with the widest node in the
  3512. // data, assign any user defined widths, then insert it into the DOM and
  3513. // allow the browser to do all the hard work of calculating table widths
  3514. var tmpTable = $(table).clone() // don't use cloneNode - IE8 will remove events on the main table
  3515. .empty()
  3516. .css( 'visibility', 'hidden' )
  3517. .removeAttr( 'id' )
  3518. .append( $(oSettings.nTHead).clone( false ) )
  3519. .append( $(oSettings.nTFoot).clone( false ) )
  3520. .append( $('<tbody><tr/></tbody>') );
  3521. // Remove any assigned widths from the footer (from scrolling)
  3522. tmpTable.find('tfoot th, tfoot td').css('width', '');
  3523. var tr = tmpTable.find( 'tbody tr' );
  3524. // Apply custom sizing to the cloned header
  3525. headerCells = _fnGetUniqueThs( oSettings, tmpTable.find('thead')[0] );
  3526. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3527. column = columns[ visibleColumns[i] ];
  3528. headerCells[i].style.width = column.sWidthOrig !== null && column.sWidthOrig !== '' ?
  3529. _fnStringToCss( column.sWidthOrig ) :
  3530. '';
  3531. }
  3532. // Find the widest cell for each column and put it into the table
  3533. if ( oSettings.aoData.length ) {
  3534. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3535. columnIdx = visibleColumns[i];
  3536. column = columns[ columnIdx ];
  3537. $( _fnGetWidestNode( oSettings, columnIdx ) )
  3538. .clone( false )
  3539. .append( column.sContentPadding )
  3540. .appendTo( tr );
  3541. }
  3542. }
  3543. // Table has been built, attach to the document so we can work with it
  3544. tmpTable.appendTo( tableContainer );
  3545. // When scrolling (X or Y) we want to set the width of the table as
  3546. // appropriate. However, when not scrolling leave the table width as it
  3547. // is. This results in slightly different, but I think correct behaviour
  3548. if ( scrollX && scrollXInner ) {
  3549. tmpTable.width( scrollXInner );
  3550. }
  3551. else if ( scrollX ) {
  3552. tmpTable.css( 'width', 'auto' );
  3553. if ( tmpTable.width() < tableContainer.offsetWidth ) {
  3554. tmpTable.width( tableContainer.offsetWidth );
  3555. }
  3556. }
  3557. else if ( scrollY ) {
  3558. tmpTable.width( tableContainer.offsetWidth );
  3559. }
  3560. else if ( tableWidthAttr ) {
  3561. tmpTable.width( tableWidthAttr );
  3562. }
  3563. // Take into account the y scrollbar
  3564. _fnScrollingWidthAdjust( oSettings, tmpTable[0] );
  3565. // Browsers need a bit of a hand when a width is assigned to any columns
  3566. // when x-scrolling as they tend to collapse the table to the min-width,
  3567. // even if we sent the column widths. So we need to keep track of what
  3568. // the table width should be by summing the user given values, and the
  3569. // automatic values
  3570. if ( scrollX )
  3571. {
  3572. var total = 0;
  3573. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3574. column = columns[ visibleColumns[i] ];
  3575. outerWidth = $(headerCells[i]).outerWidth();
  3576. total += column.sWidthOrig === null ?
  3577. outerWidth :
  3578. parseInt( column.sWidth, 10 ) + outerWidth - $(headerCells[i]).width();
  3579. }
  3580. tmpTable.width( _fnStringToCss( total ) );
  3581. table.style.width = _fnStringToCss( total );
  3582. }
  3583. // Get the width of each column in the constructed table
  3584. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3585. column = columns[ visibleColumns[i] ];
  3586. width = $(headerCells[i]).width();
  3587. if ( width ) {
  3588. column.sWidth = _fnStringToCss( width );
  3589. }
  3590. }
  3591. table.style.width = _fnStringToCss( tmpTable.css('width') );
  3592. // Finished with the table - ditch it
  3593. tmpTable.remove();
  3594. }
  3595. // If there is a width attr, we want to attach an event listener which
  3596. // allows the table sizing to automatically adjust when the window is
  3597. // resized. Use the width attr rather than CSS, since we can't know if the
  3598. // CSS is a relative value or absolute - DOM read is always px.
  3599. if ( tableWidthAttr ) {
  3600. table.style.width = _fnStringToCss( tableWidthAttr );
  3601. }
  3602. if ( (tableWidthAttr || scrollX) && ! oSettings._reszEvt ) {
  3603. $(window).bind('resize.DT-'+oSettings.sInstance, _fnThrottle( function () {
  3604. _fnAdjustColumnSizing( oSettings );
  3605. } ) );
  3606. oSettings._reszEvt = true;
  3607. }
  3608. }
  3609. /**
  3610. * Throttle the calls to a function. Arguments and context are maintained for
  3611. * the throttled function
  3612. * @param {function} fn Function to be called
  3613. * @param {int} [freq=200] call frequency in mS
  3614. * @returns {function} wrapped function
  3615. * @memberof DataTable#oApi
  3616. */
  3617. function _fnThrottle( fn, freq ) {
  3618. var
  3619. frequency = freq !== undefined ? freq : 200,
  3620. last,
  3621. timer;
  3622. return function () {
  3623. var
  3624. that = this,
  3625. now = +new Date(),
  3626. args = arguments;
  3627. if ( last && now < last + frequency ) {
  3628. clearTimeout( timer );
  3629. timer = setTimeout( function () {
  3630. last = undefined;
  3631. fn.apply( that, args );
  3632. }, frequency );
  3633. }
  3634. else if ( last ) {
  3635. last = now;
  3636. fn.apply( that, args );
  3637. }
  3638. else {
  3639. last = now;
  3640. }
  3641. };
  3642. }
  3643. /**
  3644. * Convert a CSS unit width to pixels (e.g. 2em)
  3645. * @param {string} width width to be converted
  3646. * @param {node} parent parent to get the with for (required for relative widths) - optional
  3647. * @returns {int} width in pixels
  3648. * @memberof DataTable#oApi
  3649. */
  3650. function _fnConvertToWidth ( width, parent )
  3651. {
  3652. if ( ! width ) {
  3653. return 0;
  3654. }
  3655. var n = $('<div/>')
  3656. .css( 'width', _fnStringToCss( width ) )
  3657. .appendTo( parent || document.body );
  3658. var val = n[0].offsetWidth;
  3659. n.remove();
  3660. return val;
  3661. }
  3662. /**
  3663. * Adjust a table's width to take account of vertical scroll bar
  3664. * @param {object} oSettings dataTables settings object
  3665. * @param {node} n table node
  3666. * @memberof DataTable#oApi
  3667. */
  3668. function _fnScrollingWidthAdjust ( settings, n )
  3669. {
  3670. var scroll = settings.oScroll;
  3671. if ( scroll.sX || scroll.sY ) {
  3672. // When y-scrolling only, we want to remove the width of the scroll bar
  3673. // so the table + scroll bar will fit into the area available, otherwise
  3674. // we fix the table at its current size with no adjustment
  3675. var correction = ! scroll.sX ? scroll.iBarWidth : 0;
  3676. n.style.width = _fnStringToCss( $(n).outerWidth() - correction );
  3677. }
  3678. }
  3679. /**
  3680. * Get the widest node
  3681. * @param {object} settings dataTables settings object
  3682. * @param {int} colIdx column of interest
  3683. * @returns {node} widest table node
  3684. * @memberof DataTable#oApi
  3685. */
  3686. function _fnGetWidestNode( settings, colIdx )
  3687. {
  3688. var idx = _fnGetMaxLenString( settings, colIdx );
  3689. if ( idx < 0 ) {
  3690. return null;
  3691. }
  3692. var data = settings.aoData[ idx ];
  3693. return ! data.nTr ? // Might not have been created when deferred rendering
  3694. $('<td/>').html( _fnGetCellData( settings, idx, colIdx, 'display' ) )[0] :
  3695. data.anCells[ colIdx ];
  3696. }
  3697. /**
  3698. * Get the maximum strlen for each data column
  3699. * @param {object} settings dataTables settings object
  3700. * @param {int} colIdx column of interest
  3701. * @returns {string} max string length for each column
  3702. * @memberof DataTable#oApi
  3703. */
  3704. function _fnGetMaxLenString( settings, colIdx )
  3705. {
  3706. var s, max=-1, maxIdx = -1;
  3707. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  3708. s = _fnGetCellData( settings, i, colIdx, 'display' )+'';
  3709. s = s.replace( __re_html_remove, '' );
  3710. if ( s.length > max ) {
  3711. max = s.length;
  3712. maxIdx = i;
  3713. }
  3714. }
  3715. return maxIdx;
  3716. }
  3717. /**
  3718. * Append a CSS unit (only if required) to a string
  3719. * @param {string} value to css-ify
  3720. * @returns {string} value with css unit
  3721. * @memberof DataTable#oApi
  3722. */
  3723. function _fnStringToCss( s )
  3724. {
  3725. if ( s === null ) {
  3726. return '0px';
  3727. }
  3728. if ( typeof s == 'number' ) {
  3729. return s < 0 ?
  3730. '0px' :
  3731. s+'px';
  3732. }
  3733. // Check it has a unit character already
  3734. return s.match(/\d$/) ?
  3735. s+'px' :
  3736. s;
  3737. }
  3738. /**
  3739. * Get the width of a scroll bar in this browser being used
  3740. * @returns {int} width in pixels
  3741. * @memberof DataTable#oApi
  3742. */
  3743. function _fnScrollBarWidth ()
  3744. {
  3745. // On first run a static variable is set, since this is only needed once.
  3746. // Subsequent runs will just use the previously calculated value
  3747. if ( ! DataTable.__scrollbarWidth ) {
  3748. var inner = $('<p/>').css( {
  3749. width: '100%',
  3750. height: 200,
  3751. padding: 0
  3752. } )[0];
  3753. var outer = $('<div/>')
  3754. .css( {
  3755. position: 'absolute',
  3756. top: 0,
  3757. left: 0,
  3758. width: 200,
  3759. height: 150,
  3760. padding: 0,
  3761. overflow: 'hidden',
  3762. visibility: 'hidden'
  3763. } )
  3764. .append( inner )
  3765. .appendTo( 'body' );
  3766. var w1 = inner.offsetWidth;
  3767. outer.css( 'overflow', 'scroll' );
  3768. var w2 = inner.offsetWidth;
  3769. if ( w1 === w2 ) {
  3770. w2 = outer[0].clientWidth;
  3771. }
  3772. outer.remove();
  3773. DataTable.__scrollbarWidth = w1 - w2;
  3774. }
  3775. return DataTable.__scrollbarWidth;
  3776. }
  3777. function _fnSortFlatten ( settings )
  3778. {
  3779. var
  3780. i, iLen, k, kLen,
  3781. aSort = [],
  3782. aiOrig = [],
  3783. aoColumns = settings.aoColumns,
  3784. aDataSort, iCol, sType, srcCol,
  3785. fixed = settings.aaSortingFixed,
  3786. fixedObj = $.isPlainObject( fixed ),
  3787. nestedSort = [],
  3788. add = function ( a ) {
  3789. if ( a.length && ! $.isArray( a[0] ) ) {
  3790. // 1D array
  3791. nestedSort.push( a );
  3792. }
  3793. else {
  3794. // 2D array
  3795. nestedSort.push.apply( nestedSort, a );
  3796. }
  3797. };
  3798. // Build the sort array, with pre-fix and post-fix options if they have been
  3799. // specified
  3800. if ( $.isArray( fixed ) ) {
  3801. add( fixed );
  3802. }
  3803. if ( fixedObj && fixed.pre ) {
  3804. add( fixed.pre );
  3805. }
  3806. add( settings.aaSorting );
  3807. if (fixedObj && fixed.post ) {
  3808. add( fixed.post );
  3809. }
  3810. for ( i=0 ; i<nestedSort.length ; i++ )
  3811. {
  3812. srcCol = nestedSort[i][0];
  3813. aDataSort = aoColumns[ srcCol ].aDataSort;
  3814. for ( k=0, kLen=aDataSort.length ; k<kLen ; k++ )
  3815. {
  3816. iCol = aDataSort[k];
  3817. sType = aoColumns[ iCol ].sType || 'string';
  3818. if ( nestedSort[i]._idx === undefined ) {
  3819. nestedSort[i]._idx = $.inArray( nestedSort[i][1], aoColumns[iCol].asSorting );
  3820. }
  3821. aSort.push( {
  3822. src: srcCol,
  3823. col: iCol,
  3824. dir: nestedSort[i][1],
  3825. index: nestedSort[i]._idx,
  3826. type: sType,
  3827. formatter: DataTable.ext.type.order[ sType+"-pre" ]
  3828. } );
  3829. }
  3830. }
  3831. return aSort;
  3832. }
  3833. /**
  3834. * Change the order of the table
  3835. * @param {object} oSettings dataTables settings object
  3836. * @memberof DataTable#oApi
  3837. * @todo This really needs split up!
  3838. */
  3839. function _fnSort ( oSettings )
  3840. {
  3841. var
  3842. i, ien, iLen, j, jLen, k, kLen,
  3843. sDataType, nTh,
  3844. aiOrig = [],
  3845. oExtSort = DataTable.ext.type.order,
  3846. aoData = oSettings.aoData,
  3847. aoColumns = oSettings.aoColumns,
  3848. aDataSort, data, iCol, sType, oSort,
  3849. formatters = 0,
  3850. sortCol,
  3851. displayMaster = oSettings.aiDisplayMaster,
  3852. aSort;
  3853. // Resolve any column types that are unknown due to addition or invalidation
  3854. // @todo Can this be moved into a 'data-ready' handler which is called when
  3855. // data is going to be used in the table?
  3856. _fnColumnTypes( oSettings );
  3857. aSort = _fnSortFlatten( oSettings );
  3858. for ( i=0, ien=aSort.length ; i<ien ; i++ ) {
  3859. sortCol = aSort[i];
  3860. // Track if we can use the fast sort algorithm
  3861. if ( sortCol.formatter ) {
  3862. formatters++;
  3863. }
  3864. // Load the data needed for the sort, for each cell
  3865. _fnSortData( oSettings, sortCol.col );
  3866. }
  3867. /* No sorting required if server-side or no sorting array */
  3868. if ( _fnDataSource( oSettings ) != 'ssp' && aSort.length !== 0 )
  3869. {
  3870. // Create a value - key array of the current row positions such that we can use their
  3871. // current position during the sort, if values match, in order to perform stable sorting
  3872. for ( i=0, iLen=displayMaster.length ; i<iLen ; i++ ) {
  3873. aiOrig[ displayMaster[i] ] = i;
  3874. }
  3875. /* Do the sort - here we want multi-column sorting based on a given data source (column)
  3876. * and sorting function (from oSort) in a certain direction. It's reasonably complex to
  3877. * follow on it's own, but this is what we want (example two column sorting):
  3878. * fnLocalSorting = function(a,b){
  3879. * var iTest;
  3880. * iTest = oSort['string-asc']('data11', 'data12');
  3881. * if (iTest !== 0)
  3882. * return iTest;
  3883. * iTest = oSort['numeric-desc']('data21', 'data22');
  3884. * if (iTest !== 0)
  3885. * return iTest;
  3886. * return oSort['numeric-asc']( aiOrig[a], aiOrig[b] );
  3887. * }
  3888. * Basically we have a test for each sorting column, if the data in that column is equal,
  3889. * test the next column. If all columns match, then we use a numeric sort on the row
  3890. * positions in the original data array to provide a stable sort.
  3891. *
  3892. * Note - I know it seems excessive to have two sorting methods, but the first is around
  3893. * 15% faster, so the second is only maintained for backwards compatibility with sorting
  3894. * methods which do not have a pre-sort formatting function.
  3895. */
  3896. if ( formatters === aSort.length ) {
  3897. // All sort types have formatting functions
  3898. displayMaster.sort( function ( a, b ) {
  3899. var
  3900. x, y, k, test, sort,
  3901. len=aSort.length,
  3902. dataA = aoData[a]._aSortData,
  3903. dataB = aoData[b]._aSortData;
  3904. for ( k=0 ; k<len ; k++ ) {
  3905. sort = aSort[k];
  3906. x = dataA[ sort.col ];
  3907. y = dataB[ sort.col ];
  3908. test = x<y ? -1 : x>y ? 1 : 0;
  3909. if ( test !== 0 ) {
  3910. return sort.dir === 'asc' ? test : -test;
  3911. }
  3912. }
  3913. x = aiOrig[a];
  3914. y = aiOrig[b];
  3915. return x<y ? -1 : x>y ? 1 : 0;
  3916. } );
  3917. }
  3918. else {
  3919. // Depreciated - remove in 1.11 (providing a plug-in option)
  3920. // Not all sort types have formatting methods, so we have to call their sorting
  3921. // methods.
  3922. displayMaster.sort( function ( a, b ) {
  3923. var
  3924. x, y, k, l, test, sort, fn,
  3925. len=aSort.length,
  3926. dataA = aoData[a]._aSortData,
  3927. dataB = aoData[b]._aSortData;
  3928. for ( k=0 ; k<len ; k++ ) {
  3929. sort = aSort[k];
  3930. x = dataA[ sort.col ];
  3931. y = dataB[ sort.col ];
  3932. fn = oExtSort[ sort.type+"-"+sort.dir ] || oExtSort[ "string-"+sort.dir ];
  3933. test = fn( x, y );
  3934. if ( test !== 0 ) {
  3935. return test;
  3936. }
  3937. }
  3938. x = aiOrig[a];
  3939. y = aiOrig[b];
  3940. return x<y ? -1 : x>y ? 1 : 0;
  3941. } );
  3942. }
  3943. }
  3944. /* Tell the draw function that we have sorted the data */
  3945. oSettings.bSorted = true;
  3946. }
  3947. function _fnSortAria ( settings )
  3948. {
  3949. var label;
  3950. var nextSort;
  3951. var columns = settings.aoColumns;
  3952. var aSort = _fnSortFlatten( settings );
  3953. var oAria = settings.oLanguage.oAria;
  3954. // ARIA attributes - need to loop all columns, to update all (removing old
  3955. // attributes as needed)
  3956. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  3957. {
  3958. var col = columns[i];
  3959. var asSorting = col.asSorting;
  3960. var sTitle = col.sTitle.replace( /<.*?>/g, "" );
  3961. var th = col.nTh;
  3962. // IE7 is throwing an error when setting these properties with jQuery's
  3963. // attr() and removeAttr() methods...
  3964. th.removeAttribute('aria-sort');
  3965. /* In ARIA only the first sorting column can be marked as sorting - no multi-sort option */
  3966. if ( col.bSortable ) {
  3967. if ( aSort.length > 0 && aSort[0].col == i ) {
  3968. th.setAttribute('aria-sort', aSort[0].dir=="asc" ? "ascending" : "descending" );
  3969. nextSort = asSorting[ aSort[0].index+1 ] || asSorting[0];
  3970. }
  3971. else {
  3972. nextSort = asSorting[0];
  3973. }
  3974. label = sTitle + ( nextSort === "asc" ?
  3975. oAria.sSortAscending :
  3976. oAria.sSortDescending
  3977. );
  3978. }
  3979. else {
  3980. label = sTitle;
  3981. }
  3982. th.setAttribute('aria-label', label);
  3983. }
  3984. }
  3985. /**
  3986. * Function to run on user sort request
  3987. * @param {object} settings dataTables settings object
  3988. * @param {node} attachTo node to attach the handler to
  3989. * @param {int} colIdx column sorting index
  3990. * @param {boolean} [append=false] Append the requested sort to the existing
  3991. * sort if true (i.e. multi-column sort)
  3992. * @param {function} [callback] callback function
  3993. * @memberof DataTable#oApi
  3994. */
  3995. function _fnSortListener ( settings, colIdx, append, callback )
  3996. {
  3997. var col = settings.aoColumns[ colIdx ];
  3998. var sorting = settings.aaSorting;
  3999. var asSorting = col.asSorting;
  4000. var nextSortIdx;
  4001. var next = function ( a, overflow ) {
  4002. var idx = a._idx;
  4003. if ( idx === undefined ) {
  4004. idx = $.inArray( a[1], asSorting );
  4005. }
  4006. return idx+1 < asSorting.length ?
  4007. idx+1 :
  4008. overflow ?
  4009. null :
  4010. 0;
  4011. };
  4012. // Convert to 2D array if needed
  4013. if ( typeof sorting[0] === 'number' ) {
  4014. sorting = settings.aaSorting = [ sorting ];
  4015. }
  4016. // If appending the sort then we are multi-column sorting
  4017. if ( append && settings.oFeatures.bSortMulti ) {
  4018. // Are we already doing some kind of sort on this column?
  4019. var sortIdx = $.inArray( colIdx, _pluck(sorting, '0') );
  4020. if ( sortIdx !== -1 ) {
  4021. // Yes, modify the sort
  4022. nextSortIdx = next( sorting[sortIdx], true );
  4023. if ( nextSortIdx === null ) {
  4024. sorting.splice( sortIdx, 1 );
  4025. }
  4026. else {
  4027. sorting[sortIdx][1] = asSorting[ nextSortIdx ];
  4028. sorting[sortIdx]._idx = nextSortIdx;
  4029. }
  4030. }
  4031. else {
  4032. // No sort on this column yet
  4033. sorting.push( [ colIdx, asSorting[0], 0 ] );
  4034. sorting[sorting.length-1]._idx = 0;
  4035. }
  4036. }
  4037. else if ( sorting.length && sorting[0][0] == colIdx ) {
  4038. // Single column - already sorting on this column, modify the sort
  4039. nextSortIdx = next( sorting[0] );
  4040. sorting.length = 1;
  4041. sorting[0][1] = asSorting[ nextSortIdx ];
  4042. sorting[0]._idx = nextSortIdx;
  4043. }
  4044. else {
  4045. // Single column - sort only on this column
  4046. sorting.length = 0;
  4047. sorting.push( [ colIdx, asSorting[0] ] );
  4048. sorting[0]._idx = 0;
  4049. }
  4050. // Run the sort by calling a full redraw
  4051. _fnReDraw( settings );
  4052. // callback used for async user interaction
  4053. if ( typeof callback == 'function' ) {
  4054. callback( settings );
  4055. }
  4056. }
  4057. /**
  4058. * Attach a sort handler (click) to a node
  4059. * @param {object} settings dataTables settings object
  4060. * @param {node} attachTo node to attach the handler to
  4061. * @param {int} colIdx column sorting index
  4062. * @param {function} [callback] callback function
  4063. * @memberof DataTable#oApi
  4064. */
  4065. function _fnSortAttachListener ( settings, attachTo, colIdx, callback )
  4066. {
  4067. var col = settings.aoColumns[ colIdx ];
  4068. _fnBindAction( attachTo, {}, function (e) {
  4069. /* If the column is not sortable - don't to anything */
  4070. if ( col.bSortable === false ) {
  4071. return;
  4072. }
  4073. // If processing is enabled use a timeout to allow the processing
  4074. // display to be shown - otherwise to it synchronously
  4075. if ( settings.oFeatures.bProcessing ) {
  4076. _fnProcessingDisplay( settings, true );
  4077. setTimeout( function() {
  4078. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  4079. // In server-side processing, the draw callback will remove the
  4080. // processing display
  4081. if ( _fnDataSource( settings ) !== 'ssp' ) {
  4082. _fnProcessingDisplay( settings, false );
  4083. }
  4084. }, 0 );
  4085. }
  4086. else {
  4087. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  4088. }
  4089. } );
  4090. }
  4091. /**
  4092. * Set the sorting classes on table's body, Note: it is safe to call this function
  4093. * when bSort and bSortClasses are false
  4094. * @param {object} oSettings dataTables settings object
  4095. * @memberof DataTable#oApi
  4096. */
  4097. function _fnSortingClasses( settings )
  4098. {
  4099. var oldSort = settings.aLastSort;
  4100. var sortClass = settings.oClasses.sSortColumn;
  4101. var sort = _fnSortFlatten( settings );
  4102. var features = settings.oFeatures;
  4103. var i, ien, colIdx;
  4104. if ( features.bSort && features.bSortClasses ) {
  4105. // Remove old sorting classes
  4106. for ( i=0, ien=oldSort.length ; i<ien ; i++ ) {
  4107. colIdx = oldSort[i].src;
  4108. // Remove column sorting
  4109. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  4110. .removeClass( sortClass + (i<2 ? i+1 : 3) );
  4111. }
  4112. // Add new column sorting
  4113. for ( i=0, ien=sort.length ; i<ien ; i++ ) {
  4114. colIdx = sort[i].src;
  4115. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  4116. .addClass( sortClass + (i<2 ? i+1 : 3) );
  4117. }
  4118. }
  4119. settings.aLastSort = sort;
  4120. }
  4121. // Get the data to sort a column, be it from cache, fresh (populating the
  4122. // cache), or from a sort formatter
  4123. function _fnSortData( settings, idx )
  4124. {
  4125. // Custom sorting function - provided by the sort data type
  4126. var column = settings.aoColumns[ idx ];
  4127. var customSort = DataTable.ext.order[ column.sSortDataType ];
  4128. var customData;
  4129. if ( customSort ) {
  4130. customData = customSort.call( settings.oInstance, settings, idx,
  4131. _fnColumnIndexToVisible( settings, idx )
  4132. );
  4133. }
  4134. // Use / populate cache
  4135. var row, cellData;
  4136. var formatter = DataTable.ext.type.order[ column.sType+"-pre" ];
  4137. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  4138. row = settings.aoData[i];
  4139. if ( ! row._aSortData ) {
  4140. row._aSortData = [];
  4141. }
  4142. if ( ! row._aSortData[idx] || customSort ) {
  4143. cellData = customSort ?
  4144. customData[i] : // If there was a custom sort function, use data from there
  4145. _fnGetCellData( settings, i, idx, 'sort' );
  4146. row._aSortData[ idx ] = formatter ?
  4147. formatter( cellData ) :
  4148. cellData;
  4149. }
  4150. }
  4151. }
  4152. /**
  4153. * Save the state of a table
  4154. * @param {object} oSettings dataTables settings object
  4155. * @memberof DataTable#oApi
  4156. */
  4157. function _fnSaveState ( settings )
  4158. {
  4159. if ( !settings.oFeatures.bStateSave || settings.bDestroying )
  4160. {
  4161. return;
  4162. }
  4163. /* Store the interesting variables */
  4164. var state = {
  4165. time: +new Date(),
  4166. start: settings._iDisplayStart,
  4167. length: settings._iDisplayLength,
  4168. order: $.extend( true, [], settings.aaSorting ),
  4169. search: _fnSearchToCamel( settings.oPreviousSearch ),
  4170. columns: $.map( settings.aoColumns, function ( col, i ) {
  4171. return {
  4172. visible: col.bVisible,
  4173. search: _fnSearchToCamel( settings.aoPreSearchCols[i] )
  4174. };
  4175. } )
  4176. };
  4177. _fnCallbackFire( settings, "aoStateSaveParams", 'stateSaveParams', [settings, state] );
  4178. settings.oSavedState = state;
  4179. settings.fnStateSaveCallback.call( settings.oInstance, settings, state );
  4180. }
  4181. /**
  4182. * Attempt to load a saved table state
  4183. * @param {object} oSettings dataTables settings object
  4184. * @param {object} oInit DataTables init object so we can override settings
  4185. * @memberof DataTable#oApi
  4186. */
  4187. function _fnLoadState ( settings, oInit )
  4188. {
  4189. var i, ien;
  4190. var columns = settings.aoColumns;
  4191. if ( ! settings.oFeatures.bStateSave ) {
  4192. return;
  4193. }
  4194. var state = settings.fnStateLoadCallback.call( settings.oInstance, settings );
  4195. if ( ! state || ! state.time ) {
  4196. return;
  4197. }
  4198. /* Allow custom and plug-in manipulation functions to alter the saved data set and
  4199. * cancelling of loading by returning false
  4200. */
  4201. var abStateLoad = _fnCallbackFire( settings, 'aoStateLoadParams', 'stateLoadParams', [settings, state] );
  4202. if ( $.inArray( false, abStateLoad ) !== -1 ) {
  4203. return;
  4204. }
  4205. /* Reject old data */
  4206. var duration = settings.iStateDuration;
  4207. if ( duration > 0 && state.time < +new Date() - (duration*1000) ) {
  4208. return;
  4209. }
  4210. // Number of columns have changed - all bets are off, no restore of settings
  4211. if ( columns.length !== state.columns.length ) {
  4212. return;
  4213. }
  4214. // Store the saved state so it might be accessed at any time
  4215. settings.oLoadedState = $.extend( true, {}, state );
  4216. // Restore key features - todo - for 1.11 this needs to be done by
  4217. // subscribed events
  4218. settings._iDisplayStart = state.start;
  4219. settings.iInitDisplayStart = state.start;
  4220. settings._iDisplayLength = state.length;
  4221. settings.aaSorting = [];
  4222. // Order
  4223. $.each( state.order, function ( i, col ) {
  4224. settings.aaSorting.push( col[0] >= columns.length ?
  4225. [ 0, col[1] ] :
  4226. col
  4227. );
  4228. } );
  4229. // Search
  4230. $.extend( settings.oPreviousSearch, _fnSearchToHung( state.search ) );
  4231. // Columns
  4232. for ( i=0, ien=state.columns.length ; i<ien ; i++ ) {
  4233. var col = state.columns[i];
  4234. // Visibility
  4235. columns[i].bVisible = col.visible;
  4236. // Search
  4237. $.extend( settings.aoPreSearchCols[i], _fnSearchToHung( col.search ) );
  4238. }
  4239. _fnCallbackFire( settings, 'aoStateLoaded', 'stateLoaded', [settings, state] );
  4240. }
  4241. /**
  4242. * Return the settings object for a particular table
  4243. * @param {node} table table we are using as a dataTable
  4244. * @returns {object} Settings object - or null if not found
  4245. * @memberof DataTable#oApi
  4246. */
  4247. function _fnSettingsFromNode ( table )
  4248. {
  4249. var settings = DataTable.settings;
  4250. var idx = $.inArray( table, _pluck( settings, 'nTable' ) );
  4251. return idx !== -1 ?
  4252. settings[ idx ] :
  4253. null;
  4254. }
  4255. /**
  4256. * Log an error message
  4257. * @param {object} settings dataTables settings object
  4258. * @param {int} level log error messages, or display them to the user
  4259. * @param {string} msg error message
  4260. * @param {int} tn Technical note id to get more information about the error.
  4261. * @memberof DataTable#oApi
  4262. */
  4263. function _fnLog( settings, level, msg, tn )
  4264. {
  4265. msg = 'DataTables warning: '+
  4266. (settings!==null ? 'table id='+settings.sTableId+' - ' : '')+msg;
  4267. if ( tn ) {
  4268. msg += '. For more information about this error, please see '+
  4269. 'http://datatables.net/tn/'+tn;
  4270. }
  4271. if ( ! level ) {
  4272. // Backwards compatibility pre 1.10
  4273. var ext = DataTable.ext;
  4274. var type = ext.sErrMode || ext.errMode;
  4275. if ( type == 'alert' ) {
  4276. alert( msg );
  4277. }
  4278. else {
  4279. throw new Error(msg);
  4280. }
  4281. }
  4282. else if ( window.console && console.log ) {
  4283. console.log( msg );
  4284. }
  4285. }
  4286. /**
  4287. * See if a property is defined on one object, if so assign it to the other object
  4288. * @param {object} ret target object
  4289. * @param {object} src source object
  4290. * @param {string} name property
  4291. * @param {string} [mappedName] name to map too - optional, name used if not given
  4292. * @memberof DataTable#oApi
  4293. */
  4294. function _fnMap( ret, src, name, mappedName )
  4295. {
  4296. if ( $.isArray( name ) ) {
  4297. $.each( name, function (i, val) {
  4298. if ( $.isArray( val ) ) {
  4299. _fnMap( ret, src, val[0], val[1] );
  4300. }
  4301. else {
  4302. _fnMap( ret, src, val );
  4303. }
  4304. } );
  4305. return;
  4306. }
  4307. if ( mappedName === undefined ) {
  4308. mappedName = name;
  4309. }
  4310. if ( src[name] !== undefined ) {
  4311. ret[mappedName] = src[name];
  4312. }
  4313. }
  4314. /**
  4315. * Extend objects - very similar to jQuery.extend, but deep copy objects, and
  4316. * shallow copy arrays. The reason we need to do this, is that we don't want to
  4317. * deep copy array init values (such as aaSorting) since the dev wouldn't be
  4318. * able to override them, but we do want to deep copy arrays.
  4319. * @param {object} out Object to extend
  4320. * @param {object} extender Object from which the properties will be applied to
  4321. * out
  4322. * @param {boolean} breakRefs If true, then arrays will be sliced to take an
  4323. * independent copy with the exception of the `data` or `aaData` parameters
  4324. * if they are present. This is so you can pass in a collection to
  4325. * DataTables and have that used as your data source without breaking the
  4326. * references
  4327. * @returns {object} out Reference, just for convenience - out === the return.
  4328. * @memberof DataTable#oApi
  4329. * @todo This doesn't take account of arrays inside the deep copied objects.
  4330. */
  4331. function _fnExtend( out, extender, breakRefs )
  4332. {
  4333. var val;
  4334. for ( var prop in extender ) {
  4335. if ( extender.hasOwnProperty(prop) ) {
  4336. val = extender[prop];
  4337. if ( $.isPlainObject( val ) ) {
  4338. if ( ! $.isPlainObject( out[prop] ) ) {
  4339. out[prop] = {};
  4340. }
  4341. $.extend( true, out[prop], val );
  4342. }
  4343. else if ( breakRefs && prop !== 'data' && prop !== 'aaData' && $.isArray(val) ) {
  4344. out[prop] = val.slice();
  4345. }
  4346. else {
  4347. out[prop] = val;
  4348. }
  4349. }
  4350. }
  4351. return out;
  4352. }
  4353. /**
  4354. * Bind an event handers to allow a click or return key to activate the callback.
  4355. * This is good for accessibility since a return on the keyboard will have the
  4356. * same effect as a click, if the element has focus.
  4357. * @param {element} n Element to bind the action to
  4358. * @param {object} oData Data object to pass to the triggered function
  4359. * @param {function} fn Callback function for when the event is triggered
  4360. * @memberof DataTable#oApi
  4361. */
  4362. function _fnBindAction( n, oData, fn )
  4363. {
  4364. $(n)
  4365. .bind( 'click.DT', oData, function (e) {
  4366. n.blur(); // Remove focus outline for mouse users
  4367. fn(e);
  4368. } )
  4369. .bind( 'keypress.DT', oData, function (e){
  4370. if ( e.which === 13 ) {
  4371. e.preventDefault();
  4372. fn(e);
  4373. }
  4374. } )
  4375. .bind( 'selectstart.DT', function () {
  4376. /* Take the brutal approach to cancelling text selection */
  4377. return false;
  4378. } );
  4379. }
  4380. /**
  4381. * Register a callback function. Easily allows a callback function to be added to
  4382. * an array store of callback functions that can then all be called together.
  4383. * @param {object} oSettings dataTables settings object
  4384. * @param {string} sStore Name of the array storage for the callbacks in oSettings
  4385. * @param {function} fn Function to be called back
  4386. * @param {string} sName Identifying name for the callback (i.e. a label)
  4387. * @memberof DataTable#oApi
  4388. */
  4389. function _fnCallbackReg( oSettings, sStore, fn, sName )
  4390. {
  4391. if ( fn )
  4392. {
  4393. oSettings[sStore].push( {
  4394. "fn": fn,
  4395. "sName": sName
  4396. } );
  4397. }
  4398. }
  4399. /**
  4400. * Fire callback functions and trigger events. Note that the loop over the
  4401. * callback array store is done backwards! Further note that you do not want to
  4402. * fire off triggers in time sensitive applications (for example cell creation)
  4403. * as its slow.
  4404. * @param {object} settings dataTables settings object
  4405. * @param {string} callbackArr Name of the array storage for the callbacks in
  4406. * oSettings
  4407. * @param {string} event Name of the jQuery custom event to trigger. If null no
  4408. * trigger is fired
  4409. * @param {array} args Array of arguments to pass to the callback function /
  4410. * trigger
  4411. * @memberof DataTable#oApi
  4412. */
  4413. function _fnCallbackFire( settings, callbackArr, e, args )
  4414. {
  4415. var ret = [];
  4416. if ( callbackArr ) {
  4417. ret = $.map( settings[callbackArr].slice().reverse(), function (val, i) {
  4418. return val.fn.apply( settings.oInstance, args );
  4419. } );
  4420. }
  4421. if ( e !== null ) {
  4422. $(settings.nTable).trigger( e+'.dt', args );
  4423. }
  4424. return ret;
  4425. }
  4426. function _fnLengthOverflow ( settings )
  4427. {
  4428. var
  4429. start = settings._iDisplayStart,
  4430. end = settings.fnDisplayEnd(),
  4431. len = settings._iDisplayLength;
  4432. /* If we have space to show extra rows (backing up from the end point - then do so */
  4433. if ( start >= end )
  4434. {
  4435. start = end - len;
  4436. }
  4437. // Keep the start record on the current page
  4438. start -= (start % len);
  4439. if ( len === -1 || start < 0 )
  4440. {
  4441. start = 0;
  4442. }
  4443. settings._iDisplayStart = start;
  4444. }
  4445. function _fnRenderer( settings, type )
  4446. {
  4447. var renderer = settings.renderer;
  4448. var host = DataTable.ext.renderer[type];
  4449. if ( $.isPlainObject( renderer ) && renderer[type] ) {
  4450. // Specific renderer for this type. If available use it, otherwise use
  4451. // the default.
  4452. return host[renderer[type]] || host._;
  4453. }
  4454. else if ( typeof renderer === 'string' ) {
  4455. // Common renderer - if there is one available for this type use it,
  4456. // otherwise use the default
  4457. return host[renderer] || host._;
  4458. }
  4459. // Use the default
  4460. return host._;
  4461. }
  4462. /**
  4463. * Detect the data source being used for the table. Used to simplify the code
  4464. * a little (ajax) and to make it compress a little smaller.
  4465. *
  4466. * @param {object} settings dataTables settings object
  4467. * @returns {string} Data source
  4468. * @memberof DataTable#oApi
  4469. */
  4470. function _fnDataSource ( settings )
  4471. {
  4472. if ( settings.oFeatures.bServerSide ) {
  4473. return 'ssp';
  4474. }
  4475. else if ( settings.ajax || settings.sAjaxSource ) {
  4476. return 'ajax';
  4477. }
  4478. return 'dom';
  4479. }
  4480. DataTable = function( options )
  4481. {
  4482. /**
  4483. * Perform a jQuery selector action on the table's TR elements (from the tbody) and
  4484. * return the resulting jQuery object.
  4485. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  4486. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  4487. * @param {string} [oOpts.filter=none] Select TR elements that meet the current filter
  4488. * criterion ("applied") or all TR elements (i.e. no filter).
  4489. * @param {string} [oOpts.order=current] Order of the TR elements in the processed array.
  4490. * Can be either 'current', whereby the current sorting of the table is used, or
  4491. * 'original' whereby the original order the data was read into the table is used.
  4492. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  4493. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  4494. * 'current' and filter is 'applied', regardless of what they might be given as.
  4495. * @returns {object} jQuery object, filtered by the given selector.
  4496. * @dtopt API
  4497. * @deprecated Since v1.10
  4498. *
  4499. * @example
  4500. * $(document).ready(function() {
  4501. * var oTable = $('#example').dataTable();
  4502. *
  4503. * // Highlight every second row
  4504. * oTable.$('tr:odd').css('backgroundColor', 'blue');
  4505. * } );
  4506. *
  4507. * @example
  4508. * $(document).ready(function() {
  4509. * var oTable = $('#example').dataTable();
  4510. *
  4511. * // Filter to rows with 'Webkit' in them, add a background colour and then
  4512. * // remove the filter, thus highlighting the 'Webkit' rows only.
  4513. * oTable.fnFilter('Webkit');
  4514. * oTable.$('tr', {"search": "applied"}).css('backgroundColor', 'blue');
  4515. * oTable.fnFilter('');
  4516. * } );
  4517. */
  4518. this.$ = function ( sSelector, oOpts )
  4519. {
  4520. return this.api(true).$( sSelector, oOpts );
  4521. };
  4522. /**
  4523. * Almost identical to $ in operation, but in this case returns the data for the matched
  4524. * rows - as such, the jQuery selector used should match TR row nodes or TD/TH cell nodes
  4525. * rather than any descendants, so the data can be obtained for the row/cell. If matching
  4526. * rows are found, the data returned is the original data array/object that was used to
  4527. * create the row (or a generated array if from a DOM source).
  4528. *
  4529. * This method is often useful in-combination with $ where both functions are given the
  4530. * same parameters and the array indexes will match identically.
  4531. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  4532. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  4533. * @param {string} [oOpts.filter=none] Select elements that meet the current filter
  4534. * criterion ("applied") or all elements (i.e. no filter).
  4535. * @param {string} [oOpts.order=current] Order of the data in the processed array.
  4536. * Can be either 'current', whereby the current sorting of the table is used, or
  4537. * 'original' whereby the original order the data was read into the table is used.
  4538. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  4539. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  4540. * 'current' and filter is 'applied', regardless of what they might be given as.
  4541. * @returns {array} Data for the matched elements. If any elements, as a result of the
  4542. * selector, were not TR, TD or TH elements in the DataTable, they will have a null
  4543. * entry in the array.
  4544. * @dtopt API
  4545. * @deprecated Since v1.10
  4546. *
  4547. * @example
  4548. * $(document).ready(function() {
  4549. * var oTable = $('#example').dataTable();
  4550. *
  4551. * // Get the data from the first row in the table
  4552. * var data = oTable._('tr:first');
  4553. *
  4554. * // Do something useful with the data
  4555. * alert( "First cell is: "+data[0] );
  4556. * } );
  4557. *
  4558. * @example
  4559. * $(document).ready(function() {
  4560. * var oTable = $('#example').dataTable();
  4561. *
  4562. * // Filter to 'Webkit' and get all data for
  4563. * oTable.fnFilter('Webkit');
  4564. * var data = oTable._('tr', {"search": "applied"});
  4565. *
  4566. * // Do something with the data
  4567. * alert( data.length+" rows matched the search" );
  4568. * } );
  4569. */
  4570. this._ = function ( sSelector, oOpts )
  4571. {
  4572. return this.api(true).rows( sSelector, oOpts ).data();
  4573. };
  4574. /**
  4575. * Create a DataTables Api instance, with the currently selected tables for
  4576. * the Api's context.
  4577. * @param {boolean} [traditional=false] Set the API instance's context to be
  4578. * only the table referred to by the `DataTable.ext.iApiIndex` option, as was
  4579. * used in the API presented by DataTables 1.9- (i.e. the traditional mode),
  4580. * or if all tables captured in the jQuery object should be used.
  4581. * @return {DataTables.Api}
  4582. */
  4583. this.api = function ( traditional )
  4584. {
  4585. return traditional ?
  4586. new _Api(
  4587. _fnSettingsFromNode( this[ _ext.iApiIndex ] )
  4588. ) :
  4589. new _Api( this );
  4590. };
  4591. /**
  4592. * Add a single new row or multiple rows of data to the table. Please note
  4593. * that this is suitable for client-side processing only - if you are using
  4594. * server-side processing (i.e. "bServerSide": true), then to add data, you
  4595. * must add it to the data source, i.e. the server-side, through an Ajax call.
  4596. * @param {array|object} data The data to be added to the table. This can be:
  4597. * <ul>
  4598. * <li>1D array of data - add a single row with the data provided</li>
  4599. * <li>2D array of arrays - add multiple rows in a single call</li>
  4600. * <li>object - data object when using <i>mData</i></li>
  4601. * <li>array of objects - multiple data objects when using <i>mData</i></li>
  4602. * </ul>
  4603. * @param {bool} [redraw=true] redraw the table or not
  4604. * @returns {array} An array of integers, representing the list of indexes in
  4605. * <i>aoData</i> ({@link DataTable.models.oSettings}) that have been added to
  4606. * the table.
  4607. * @dtopt API
  4608. * @deprecated Since v1.10
  4609. *
  4610. * @example
  4611. * // Global var for counter
  4612. * var giCount = 2;
  4613. *
  4614. * $(document).ready(function() {
  4615. * $('#example').dataTable();
  4616. * } );
  4617. *
  4618. * function fnClickAddRow() {
  4619. * $('#example').dataTable().fnAddData( [
  4620. * giCount+".1",
  4621. * giCount+".2",
  4622. * giCount+".3",
  4623. * giCount+".4" ]
  4624. * );
  4625. *
  4626. * giCount++;
  4627. * }
  4628. */
  4629. this.fnAddData = function( data, redraw )
  4630. {
  4631. var api = this.api( true );
  4632. /* Check if we want to add multiple rows or not */
  4633. var rows = $.isArray(data) && ( $.isArray(data[0]) || $.isPlainObject(data[0]) ) ?
  4634. api.rows.add( data ) :
  4635. api.row.add( data );
  4636. if ( redraw === undefined || redraw ) {
  4637. api.draw();
  4638. }
  4639. return rows.flatten().toArray();
  4640. };
  4641. /**
  4642. * This function will make DataTables recalculate the column sizes, based on the data
  4643. * contained in the table and the sizes applied to the columns (in the DOM, CSS or
  4644. * through the sWidth parameter). This can be useful when the width of the table's
  4645. * parent element changes (for example a window resize).
  4646. * @param {boolean} [bRedraw=true] Redraw the table or not, you will typically want to
  4647. * @dtopt API
  4648. * @deprecated Since v1.10
  4649. *
  4650. * @example
  4651. * $(document).ready(function() {
  4652. * var oTable = $('#example').dataTable( {
  4653. * "sScrollY": "200px",
  4654. * "bPaginate": false
  4655. * } );
  4656. *
  4657. * $(window).bind('resize', function () {
  4658. * oTable.fnAdjustColumnSizing();
  4659. * } );
  4660. * } );
  4661. */
  4662. this.fnAdjustColumnSizing = function ( bRedraw )
  4663. {
  4664. var api = this.api( true ).columns.adjust();
  4665. var settings = api.settings()[0];
  4666. var scroll = settings.oScroll;
  4667. if ( bRedraw === undefined || bRedraw ) {
  4668. api.draw( false );
  4669. }
  4670. else if ( scroll.sX !== "" || scroll.sY !== "" ) {
  4671. /* If not redrawing, but scrolling, we want to apply the new column sizes anyway */
  4672. _fnScrollDraw( settings );
  4673. }
  4674. };
  4675. /**
  4676. * Quickly and simply clear a table
  4677. * @param {bool} [bRedraw=true] redraw the table or not
  4678. * @dtopt API
  4679. * @deprecated Since v1.10
  4680. *
  4681. * @example
  4682. * $(document).ready(function() {
  4683. * var oTable = $('#example').dataTable();
  4684. *
  4685. * // Immediately 'nuke' the current rows (perhaps waiting for an Ajax callback...)
  4686. * oTable.fnClearTable();
  4687. * } );
  4688. */
  4689. this.fnClearTable = function( bRedraw )
  4690. {
  4691. var api = this.api( true ).clear();
  4692. if ( bRedraw === undefined || bRedraw ) {
  4693. api.draw();
  4694. }
  4695. };
  4696. /**
  4697. * The exact opposite of 'opening' a row, this function will close any rows which
  4698. * are currently 'open'.
  4699. * @param {node} nTr the table row to 'close'
  4700. * @returns {int} 0 on success, or 1 if failed (can't find the row)
  4701. * @dtopt API
  4702. * @deprecated Since v1.10
  4703. *
  4704. * @example
  4705. * $(document).ready(function() {
  4706. * var oTable;
  4707. *
  4708. * // 'open' an information row when a row is clicked on
  4709. * $('#example tbody tr').click( function () {
  4710. * if ( oTable.fnIsOpen(this) ) {
  4711. * oTable.fnClose( this );
  4712. * } else {
  4713. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  4714. * }
  4715. * } );
  4716. *
  4717. * oTable = $('#example').dataTable();
  4718. * } );
  4719. */
  4720. this.fnClose = function( nTr )
  4721. {
  4722. this.api( true ).row( nTr ).child.hide();
  4723. };
  4724. /**
  4725. * Remove a row for the table
  4726. * @param {mixed} target The index of the row from aoData to be deleted, or
  4727. * the TR element you want to delete
  4728. * @param {function|null} [callBack] Callback function
  4729. * @param {bool} [redraw=true] Redraw the table or not
  4730. * @returns {array} The row that was deleted
  4731. * @dtopt API
  4732. * @deprecated Since v1.10
  4733. *
  4734. * @example
  4735. * $(document).ready(function() {
  4736. * var oTable = $('#example').dataTable();
  4737. *
  4738. * // Immediately remove the first row
  4739. * oTable.fnDeleteRow( 0 );
  4740. * } );
  4741. */
  4742. this.fnDeleteRow = function( target, callback, redraw )
  4743. {
  4744. var api = this.api( true );
  4745. var rows = api.rows( target );
  4746. var settings = rows.settings()[0];
  4747. var data = settings.aoData[ rows[0][0] ];
  4748. rows.remove();
  4749. if ( callback ) {
  4750. callback.call( this, settings, data );
  4751. }
  4752. if ( redraw === undefined || redraw ) {
  4753. api.draw();
  4754. }
  4755. return data;
  4756. };
  4757. /**
  4758. * Restore the table to it's original state in the DOM by removing all of DataTables
  4759. * enhancements, alterations to the DOM structure of the table and event listeners.
  4760. * @param {boolean} [remove=false] Completely remove the table from the DOM
  4761. * @dtopt API
  4762. * @deprecated Since v1.10
  4763. *
  4764. * @example
  4765. * $(document).ready(function() {
  4766. * // This example is fairly pointless in reality, but shows how fnDestroy can be used
  4767. * var oTable = $('#example').dataTable();
  4768. * oTable.fnDestroy();
  4769. * } );
  4770. */
  4771. this.fnDestroy = function ( remove )
  4772. {
  4773. this.api( true ).destroy( remove );
  4774. };
  4775. /**
  4776. * Redraw the table
  4777. * @param {bool} [complete=true] Re-filter and resort (if enabled) the table before the draw.
  4778. * @dtopt API
  4779. * @deprecated Since v1.10
  4780. *
  4781. * @example
  4782. * $(document).ready(function() {
  4783. * var oTable = $('#example').dataTable();
  4784. *
  4785. * // Re-draw the table - you wouldn't want to do it here, but it's an example :-)
  4786. * oTable.fnDraw();
  4787. * } );
  4788. */
  4789. this.fnDraw = function( complete )
  4790. {
  4791. // Note that this isn't an exact match to the old call to _fnDraw - it takes
  4792. // into account the new data, but can old position.
  4793. this.api( true ).draw( ! complete );
  4794. };
  4795. /**
  4796. * Filter the input based on data
  4797. * @param {string} sInput String to filter the table on
  4798. * @param {int|null} [iColumn] Column to limit filtering to
  4799. * @param {bool} [bRegex=false] Treat as regular expression or not
  4800. * @param {bool} [bSmart=true] Perform smart filtering or not
  4801. * @param {bool} [bShowGlobal=true] Show the input global filter in it's input box(es)
  4802. * @param {bool} [bCaseInsensitive=true] Do case-insensitive matching (true) or not (false)
  4803. * @dtopt API
  4804. * @deprecated Since v1.10
  4805. *
  4806. * @example
  4807. * $(document).ready(function() {
  4808. * var oTable = $('#example').dataTable();
  4809. *
  4810. * // Sometime later - filter...
  4811. * oTable.fnFilter( 'test string' );
  4812. * } );
  4813. */
  4814. this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal, bCaseInsensitive )
  4815. {
  4816. var api = this.api( true );
  4817. if ( iColumn === null || iColumn === undefined ) {
  4818. api.search( sInput, bRegex, bSmart, bCaseInsensitive );
  4819. }
  4820. else {
  4821. api.column( iColumn ).search( sInput, bRegex, bSmart, bCaseInsensitive );
  4822. }
  4823. api.draw();
  4824. };
  4825. /**
  4826. * Get the data for the whole table, an individual row or an individual cell based on the
  4827. * provided parameters.
  4828. * @param {int|node} [src] A TR row node, TD/TH cell node or an integer. If given as
  4829. * a TR node then the data source for the whole row will be returned. If given as a
  4830. * TD/TH cell node then iCol will be automatically calculated and the data for the
  4831. * cell returned. If given as an integer, then this is treated as the aoData internal
  4832. * data index for the row (see fnGetPosition) and the data for that row used.
  4833. * @param {int} [col] Optional column index that you want the data of.
  4834. * @returns {array|object|string} If mRow is undefined, then the data for all rows is
  4835. * returned. If mRow is defined, just data for that row, and is iCol is
  4836. * defined, only data for the designated cell is returned.
  4837. * @dtopt API
  4838. * @deprecated Since v1.10
  4839. *
  4840. * @example
  4841. * // Row data
  4842. * $(document).ready(function() {
  4843. * oTable = $('#example').dataTable();
  4844. *
  4845. * oTable.$('tr').click( function () {
  4846. * var data = oTable.fnGetData( this );
  4847. * // ... do something with the array / object of data for the row
  4848. * } );
  4849. * } );
  4850. *
  4851. * @example
  4852. * // Individual cell data
  4853. * $(document).ready(function() {
  4854. * oTable = $('#example').dataTable();
  4855. *
  4856. * oTable.$('td').click( function () {
  4857. * var sData = oTable.fnGetData( this );
  4858. * alert( 'The cell clicked on had the value of '+sData );
  4859. * } );
  4860. * } );
  4861. */
  4862. this.fnGetData = function( src, col )
  4863. {
  4864. var api = this.api( true );
  4865. if ( src !== undefined ) {
  4866. var type = src.nodeName ? src.nodeName.toLowerCase() : '';
  4867. return col !== undefined || type == 'td' || type == 'th' ?
  4868. api.cell( src, col ).data() :
  4869. api.row( src ).data() || null;
  4870. }
  4871. return api.data().toArray();
  4872. };
  4873. /**
  4874. * Get an array of the TR nodes that are used in the table's body. Note that you will
  4875. * typically want to use the '$' API method in preference to this as it is more
  4876. * flexible.
  4877. * @param {int} [iRow] Optional row index for the TR element you want
  4878. * @returns {array|node} If iRow is undefined, returns an array of all TR elements
  4879. * in the table's body, or iRow is defined, just the TR element requested.
  4880. * @dtopt API
  4881. * @deprecated Since v1.10
  4882. *
  4883. * @example
  4884. * $(document).ready(function() {
  4885. * var oTable = $('#example').dataTable();
  4886. *
  4887. * // Get the nodes from the table
  4888. * var nNodes = oTable.fnGetNodes( );
  4889. * } );
  4890. */
  4891. this.fnGetNodes = function( iRow )
  4892. {
  4893. var api = this.api( true );
  4894. return iRow !== undefined ?
  4895. api.row( iRow ).node() :
  4896. api.rows().nodes().flatten().toArray();
  4897. };
  4898. /**
  4899. * Get the array indexes of a particular cell from it's DOM element
  4900. * and column index including hidden columns
  4901. * @param {node} node this can either be a TR, TD or TH in the table's body
  4902. * @returns {int} If nNode is given as a TR, then a single index is returned, or
  4903. * if given as a cell, an array of [row index, column index (visible),
  4904. * column index (all)] is given.
  4905. * @dtopt API
  4906. * @deprecated Since v1.10
  4907. *
  4908. * @example
  4909. * $(document).ready(function() {
  4910. * $('#example tbody td').click( function () {
  4911. * // Get the position of the current data from the node
  4912. * var aPos = oTable.fnGetPosition( this );
  4913. *
  4914. * // Get the data array for this row
  4915. * var aData = oTable.fnGetData( aPos[0] );
  4916. *
  4917. * // Update the data array and return the value
  4918. * aData[ aPos[1] ] = 'clicked';
  4919. * this.innerHTML = 'clicked';
  4920. * } );
  4921. *
  4922. * // Init DataTables
  4923. * oTable = $('#example').dataTable();
  4924. * } );
  4925. */
  4926. this.fnGetPosition = function( node )
  4927. {
  4928. var api = this.api( true );
  4929. var nodeName = node.nodeName.toUpperCase();
  4930. if ( nodeName == 'TR' ) {
  4931. return api.row( node ).index();
  4932. }
  4933. else if ( nodeName == 'TD' || nodeName == 'TH' ) {
  4934. var cell = api.cell( node ).index();
  4935. return [
  4936. cell.row,
  4937. cell.columnVisible,
  4938. cell.column
  4939. ];
  4940. }
  4941. return null;
  4942. };
  4943. /**
  4944. * Check to see if a row is 'open' or not.
  4945. * @param {node} nTr the table row to check
  4946. * @returns {boolean} true if the row is currently open, false otherwise
  4947. * @dtopt API
  4948. * @deprecated Since v1.10
  4949. *
  4950. * @example
  4951. * $(document).ready(function() {
  4952. * var oTable;
  4953. *
  4954. * // 'open' an information row when a row is clicked on
  4955. * $('#example tbody tr').click( function () {
  4956. * if ( oTable.fnIsOpen(this) ) {
  4957. * oTable.fnClose( this );
  4958. * } else {
  4959. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  4960. * }
  4961. * } );
  4962. *
  4963. * oTable = $('#example').dataTable();
  4964. * } );
  4965. */
  4966. this.fnIsOpen = function( nTr )
  4967. {
  4968. return this.api( true ).row( nTr ).child.isShown();
  4969. };
  4970. /**
  4971. * This function will place a new row directly after a row which is currently
  4972. * on display on the page, with the HTML contents that is passed into the
  4973. * function. This can be used, for example, to ask for confirmation that a
  4974. * particular record should be deleted.
  4975. * @param {node} nTr The table row to 'open'
  4976. * @param {string|node|jQuery} mHtml The HTML to put into the row
  4977. * @param {string} sClass Class to give the new TD cell
  4978. * @returns {node} The row opened. Note that if the table row passed in as the
  4979. * first parameter, is not found in the table, this method will silently
  4980. * return.
  4981. * @dtopt API
  4982. * @deprecated Since v1.10
  4983. *
  4984. * @example
  4985. * $(document).ready(function() {
  4986. * var oTable;
  4987. *
  4988. * // 'open' an information row when a row is clicked on
  4989. * $('#example tbody tr').click( function () {
  4990. * if ( oTable.fnIsOpen(this) ) {
  4991. * oTable.fnClose( this );
  4992. * } else {
  4993. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  4994. * }
  4995. * } );
  4996. *
  4997. * oTable = $('#example').dataTable();
  4998. * } );
  4999. */
  5000. this.fnOpen = function( nTr, mHtml, sClass )
  5001. {
  5002. return this.api( true )
  5003. .row( nTr )
  5004. .child( mHtml, sClass )
  5005. .show()
  5006. .child()[0];
  5007. };
  5008. /**
  5009. * Change the pagination - provides the internal logic for pagination in a simple API
  5010. * function. With this function you can have a DataTables table go to the next,
  5011. * previous, first or last pages.
  5012. * @param {string|int} mAction Paging action to take: "first", "previous", "next" or "last"
  5013. * or page number to jump to (integer), note that page 0 is the first page.
  5014. * @param {bool} [bRedraw=true] Redraw the table or not
  5015. * @dtopt API
  5016. * @deprecated Since v1.10
  5017. *
  5018. * @example
  5019. * $(document).ready(function() {
  5020. * var oTable = $('#example').dataTable();
  5021. * oTable.fnPageChange( 'next' );
  5022. * } );
  5023. */
  5024. this.fnPageChange = function ( mAction, bRedraw )
  5025. {
  5026. var api = this.api( true ).page( mAction );
  5027. if ( bRedraw === undefined || bRedraw ) {
  5028. api.draw(false);
  5029. }
  5030. };
  5031. /**
  5032. * Show a particular column
  5033. * @param {int} iCol The column whose display should be changed
  5034. * @param {bool} bShow Show (true) or hide (false) the column
  5035. * @param {bool} [bRedraw=true] Redraw the table or not
  5036. * @dtopt API
  5037. * @deprecated Since v1.10
  5038. *
  5039. * @example
  5040. * $(document).ready(function() {
  5041. * var oTable = $('#example').dataTable();
  5042. *
  5043. * // Hide the second column after initialisation
  5044. * oTable.fnSetColumnVis( 1, false );
  5045. * } );
  5046. */
  5047. this.fnSetColumnVis = function ( iCol, bShow, bRedraw )
  5048. {
  5049. var api = this.api( true ).column( iCol ).visible( bShow );
  5050. if ( bRedraw === undefined || bRedraw ) {
  5051. api.columns.adjust().draw();
  5052. }
  5053. };
  5054. /**
  5055. * Get the settings for a particular table for external manipulation
  5056. * @returns {object} DataTables settings object. See
  5057. * {@link DataTable.models.oSettings}
  5058. * @dtopt API
  5059. * @deprecated Since v1.10
  5060. *
  5061. * @example
  5062. * $(document).ready(function() {
  5063. * var oTable = $('#example').dataTable();
  5064. * var oSettings = oTable.fnSettings();
  5065. *
  5066. * // Show an example parameter from the settings
  5067. * alert( oSettings._iDisplayStart );
  5068. * } );
  5069. */
  5070. this.fnSettings = function()
  5071. {
  5072. return _fnSettingsFromNode( this[_ext.iApiIndex] );
  5073. };
  5074. /**
  5075. * Sort the table by a particular column
  5076. * @param {int} iCol the data index to sort on. Note that this will not match the
  5077. * 'display index' if you have hidden data entries
  5078. * @dtopt API
  5079. * @deprecated Since v1.10
  5080. *
  5081. * @example
  5082. * $(document).ready(function() {
  5083. * var oTable = $('#example').dataTable();
  5084. *
  5085. * // Sort immediately with columns 0 and 1
  5086. * oTable.fnSort( [ [0,'asc'], [1,'asc'] ] );
  5087. * } );
  5088. */
  5089. this.fnSort = function( aaSort )
  5090. {
  5091. this.api( true ).order( aaSort ).draw();
  5092. };
  5093. /**
  5094. * Attach a sort listener to an element for a given column
  5095. * @param {node} nNode the element to attach the sort listener to
  5096. * @param {int} iColumn the column that a click on this node will sort on
  5097. * @param {function} [fnCallback] callback function when sort is run
  5098. * @dtopt API
  5099. * @deprecated Since v1.10
  5100. *
  5101. * @example
  5102. * $(document).ready(function() {
  5103. * var oTable = $('#example').dataTable();
  5104. *
  5105. * // Sort on column 1, when 'sorter' is clicked on
  5106. * oTable.fnSortListener( document.getElementById('sorter'), 1 );
  5107. * } );
  5108. */
  5109. this.fnSortListener = function( nNode, iColumn, fnCallback )
  5110. {
  5111. this.api( true ).order.listener( nNode, iColumn, fnCallback );
  5112. };
  5113. /**
  5114. * Update a table cell or row - this method will accept either a single value to
  5115. * update the cell with, an array of values with one element for each column or
  5116. * an object in the same format as the original data source. The function is
  5117. * self-referencing in order to make the multi column updates easier.
  5118. * @param {object|array|string} mData Data to update the cell/row with
  5119. * @param {node|int} mRow TR element you want to update or the aoData index
  5120. * @param {int} [iColumn] The column to update, give as null or undefined to
  5121. * update a whole row.
  5122. * @param {bool} [bRedraw=true] Redraw the table or not
  5123. * @param {bool} [bAction=true] Perform pre-draw actions or not
  5124. * @returns {int} 0 on success, 1 on error
  5125. * @dtopt API
  5126. * @deprecated Since v1.10
  5127. *
  5128. * @example
  5129. * $(document).ready(function() {
  5130. * var oTable = $('#example').dataTable();
  5131. * oTable.fnUpdate( 'Example update', 0, 0 ); // Single cell
  5132. * oTable.fnUpdate( ['a', 'b', 'c', 'd', 'e'], $('tbody tr')[0] ); // Row
  5133. * } );
  5134. */
  5135. this.fnUpdate = function( mData, mRow, iColumn, bRedraw, bAction )
  5136. {
  5137. var api = this.api( true );
  5138. if ( iColumn === undefined || iColumn === null ) {
  5139. api.row( mRow ).data( mData );
  5140. }
  5141. else {
  5142. api.cell( mRow, iColumn ).data( mData );
  5143. }
  5144. if ( bAction === undefined || bAction ) {
  5145. api.columns.adjust();
  5146. }
  5147. if ( bRedraw === undefined || bRedraw ) {
  5148. api.draw();
  5149. }
  5150. return 0;
  5151. };
  5152. /**
  5153. * Provide a common method for plug-ins to check the version of DataTables being used, in order
  5154. * to ensure compatibility.
  5155. * @param {string} sVersion Version string to check for, in the format "X.Y.Z". Note that the
  5156. * formats "X" and "X.Y" are also acceptable.
  5157. * @returns {boolean} true if this version of DataTables is greater or equal to the required
  5158. * version, or false if this version of DataTales is not suitable
  5159. * @method
  5160. * @dtopt API
  5161. * @deprecated Since v1.10
  5162. *
  5163. * @example
  5164. * $(document).ready(function() {
  5165. * var oTable = $('#example').dataTable();
  5166. * alert( oTable.fnVersionCheck( '1.9.0' ) );
  5167. * } );
  5168. */
  5169. this.fnVersionCheck = _ext.fnVersionCheck;
  5170. var _that = this;
  5171. var emptyInit = options === undefined;
  5172. var len = this.length;
  5173. if ( emptyInit ) {
  5174. options = {};
  5175. }
  5176. this.oApi = this.internal = _ext.internal;
  5177. // Extend with old style plug-in API methods
  5178. for ( var fn in DataTable.ext.internal ) {
  5179. if ( fn ) {
  5180. this[fn] = _fnExternApiFunc(fn);
  5181. }
  5182. }
  5183. this.each(function() {
  5184. // For each initialisation we want to give it a clean initialisation
  5185. // object that can be bashed around
  5186. var o = {};
  5187. var oInit = len > 1 ? // optimisation for single table case
  5188. _fnExtend( o, options, true ) :
  5189. options;
  5190. /*global oInit,_that,emptyInit*/
  5191. var i=0, iLen, j, jLen, k, kLen;
  5192. var sId = this.getAttribute( 'id' );
  5193. var bInitHandedOff = false;
  5194. var defaults = DataTable.defaults;
  5195. /* Sanity check */
  5196. if ( this.nodeName.toLowerCase() != 'table' )
  5197. {
  5198. _fnLog( null, 0, 'Non-table node initialisation ('+this.nodeName+')', 2 );
  5199. return;
  5200. }
  5201. /* Backwards compatibility for the defaults */
  5202. _fnCompatOpts( defaults );
  5203. _fnCompatCols( defaults.column );
  5204. /* Convert the camel-case defaults to Hungarian */
  5205. _fnCamelToHungarian( defaults, defaults, true );
  5206. _fnCamelToHungarian( defaults.column, defaults.column, true );
  5207. /* Setting up the initialisation object */
  5208. _fnCamelToHungarian( defaults, oInit );
  5209. /* Check to see if we are re-initialising a table */
  5210. var allSettings = DataTable.settings;
  5211. for ( i=0, iLen=allSettings.length ; i<iLen ; i++ )
  5212. {
  5213. /* Base check on table node */
  5214. if ( allSettings[i].nTable == this )
  5215. {
  5216. var bRetrieve = oInit.bRetrieve !== undefined ? oInit.bRetrieve : defaults.bRetrieve;
  5217. var bDestroy = oInit.bDestroy !== undefined ? oInit.bDestroy : defaults.bDestroy;
  5218. if ( emptyInit || bRetrieve )
  5219. {
  5220. return allSettings[i].oInstance;
  5221. }
  5222. else if ( bDestroy )
  5223. {
  5224. allSettings[i].oInstance.fnDestroy();
  5225. break;
  5226. }
  5227. else
  5228. {
  5229. _fnLog( allSettings[i], 0, 'Cannot reinitialise DataTable', 3 );
  5230. return;
  5231. }
  5232. }
  5233. /* If the element we are initialising has the same ID as a table which was previously
  5234. * initialised, but the table nodes don't match (from before) then we destroy the old
  5235. * instance by simply deleting it. This is under the assumption that the table has been
  5236. * destroyed by other methods. Anyone using non-id selectors will need to do this manually
  5237. */
  5238. if ( allSettings[i].sTableId == this.id )
  5239. {
  5240. allSettings.splice( i, 1 );
  5241. break;
  5242. }
  5243. }
  5244. /* Ensure the table has an ID - required for accessibility */
  5245. if ( sId === null || sId === "" )
  5246. {
  5247. sId = "DataTables_Table_"+(DataTable.ext._unique++);
  5248. this.id = sId;
  5249. }
  5250. /* Create the settings object for this table and set some of the default parameters */
  5251. var oSettings = $.extend( true, {}, DataTable.models.oSettings, {
  5252. "nTable": this,
  5253. "oApi": _that.internal,
  5254. "oInit": oInit,
  5255. "sDestroyWidth": $(this)[0].style.width,
  5256. "sInstance": sId,
  5257. "sTableId": sId
  5258. } );
  5259. allSettings.push( oSettings );
  5260. // Need to add the instance after the instance after the settings object has been added
  5261. // to the settings array, so we can self reference the table instance if more than one
  5262. oSettings.oInstance = (_that.length===1) ? _that : $(this).dataTable();
  5263. // Backwards compatibility, before we apply all the defaults
  5264. _fnCompatOpts( oInit );
  5265. if ( oInit.oLanguage )
  5266. {
  5267. _fnLanguageCompat( oInit.oLanguage );
  5268. }
  5269. // If the length menu is given, but the init display length is not, use the length menu
  5270. if ( oInit.aLengthMenu && ! oInit.iDisplayLength )
  5271. {
  5272. oInit.iDisplayLength = $.isArray( oInit.aLengthMenu[0] ) ?
  5273. oInit.aLengthMenu[0][0] : oInit.aLengthMenu[0];
  5274. }
  5275. // Apply the defaults and init options to make a single init object will all
  5276. // options defined from defaults and instance options.
  5277. oInit = _fnExtend( $.extend( true, {}, defaults ), oInit );
  5278. // Map the initialisation options onto the settings object
  5279. _fnMap( oSettings.oFeatures, oInit, [
  5280. "bPaginate",
  5281. "bLengthChange",
  5282. "bFilter",
  5283. "bSort",
  5284. "bSortMulti",
  5285. "bInfo",
  5286. "bProcessing",
  5287. "bAutoWidth",
  5288. "bSortClasses",
  5289. "bServerSide",
  5290. "bDeferRender"
  5291. ] );
  5292. _fnMap( oSettings, oInit, [
  5293. "asStripeClasses",
  5294. "ajax",
  5295. "fnServerData",
  5296. "fnFormatNumber",
  5297. "sServerMethod",
  5298. "aaSorting",
  5299. "aaSortingFixed",
  5300. "aLengthMenu",
  5301. "sPaginationType",
  5302. "sAjaxSource",
  5303. "sAjaxDataProp",
  5304. "iStateDuration",
  5305. "sDom",
  5306. "bSortCellsTop",
  5307. "iTabIndex",
  5308. "fnStateLoadCallback",
  5309. "fnStateSaveCallback",
  5310. "renderer",
  5311. "searchDelay",
  5312. [ "iCookieDuration", "iStateDuration" ], // backwards compat
  5313. [ "oSearch", "oPreviousSearch" ],
  5314. [ "aoSearchCols", "aoPreSearchCols" ],
  5315. [ "iDisplayLength", "_iDisplayLength" ],
  5316. [ "bJQueryUI", "bJUI" ]
  5317. ] );
  5318. _fnMap( oSettings.oScroll, oInit, [
  5319. [ "sScrollX", "sX" ],
  5320. [ "sScrollXInner", "sXInner" ],
  5321. [ "sScrollY", "sY" ],
  5322. [ "bScrollCollapse", "bCollapse" ]
  5323. ] );
  5324. _fnMap( oSettings.oLanguage, oInit, "fnInfoCallback" );
  5325. /* Callback functions which are array driven */
  5326. _fnCallbackReg( oSettings, 'aoDrawCallback', oInit.fnDrawCallback, 'user' );
  5327. _fnCallbackReg( oSettings, 'aoServerParams', oInit.fnServerParams, 'user' );
  5328. _fnCallbackReg( oSettings, 'aoStateSaveParams', oInit.fnStateSaveParams, 'user' );
  5329. _fnCallbackReg( oSettings, 'aoStateLoadParams', oInit.fnStateLoadParams, 'user' );
  5330. _fnCallbackReg( oSettings, 'aoStateLoaded', oInit.fnStateLoaded, 'user' );
  5331. _fnCallbackReg( oSettings, 'aoRowCallback', oInit.fnRowCallback, 'user' );
  5332. _fnCallbackReg( oSettings, 'aoRowCreatedCallback', oInit.fnCreatedRow, 'user' );
  5333. _fnCallbackReg( oSettings, 'aoHeaderCallback', oInit.fnHeaderCallback, 'user' );
  5334. _fnCallbackReg( oSettings, 'aoFooterCallback', oInit.fnFooterCallback, 'user' );
  5335. _fnCallbackReg( oSettings, 'aoInitComplete', oInit.fnInitComplete, 'user' );
  5336. _fnCallbackReg( oSettings, 'aoPreDrawCallback', oInit.fnPreDrawCallback, 'user' );
  5337. var oClasses = oSettings.oClasses;
  5338. // @todo Remove in 1.11
  5339. if ( oInit.bJQueryUI )
  5340. {
  5341. /* Use the JUI classes object for display. You could clone the oStdClasses object if
  5342. * you want to have multiple tables with multiple independent classes
  5343. */
  5344. $.extend( oClasses, DataTable.ext.oJUIClasses, oInit.oClasses );
  5345. if ( oInit.sDom === defaults.sDom && defaults.sDom === "lfrtip" )
  5346. {
  5347. /* Set the DOM to use a layout suitable for jQuery UI's theming */
  5348. oSettings.sDom = '<"H"lfr>t<"F"ip>';
  5349. }
  5350. if ( ! oSettings.renderer ) {
  5351. oSettings.renderer = 'jqueryui';
  5352. }
  5353. else if ( $.isPlainObject( oSettings.renderer ) && ! oSettings.renderer.header ) {
  5354. oSettings.renderer.header = 'jqueryui';
  5355. }
  5356. }
  5357. else
  5358. {
  5359. $.extend( oClasses, DataTable.ext.classes, oInit.oClasses );
  5360. }
  5361. $(this).addClass( oClasses.sTable );
  5362. /* Calculate the scroll bar width and cache it for use later on */
  5363. if ( oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "" )
  5364. {
  5365. oSettings.oScroll.iBarWidth = _fnScrollBarWidth();
  5366. }
  5367. if ( oSettings.oScroll.sX === true ) { // Easy initialisation of x-scrolling
  5368. oSettings.oScroll.sX = '100%';
  5369. }
  5370. if ( oSettings.iInitDisplayStart === undefined )
  5371. {
  5372. /* Display start point, taking into account the save saving */
  5373. oSettings.iInitDisplayStart = oInit.iDisplayStart;
  5374. oSettings._iDisplayStart = oInit.iDisplayStart;
  5375. }
  5376. if ( oInit.iDeferLoading !== null )
  5377. {
  5378. oSettings.bDeferLoading = true;
  5379. var tmp = $.isArray( oInit.iDeferLoading );
  5380. oSettings._iRecordsDisplay = tmp ? oInit.iDeferLoading[0] : oInit.iDeferLoading;
  5381. oSettings._iRecordsTotal = tmp ? oInit.iDeferLoading[1] : oInit.iDeferLoading;
  5382. }
  5383. /* Language definitions */
  5384. var oLanguage = oSettings.oLanguage;
  5385. $.extend( true, oLanguage, oInit.oLanguage );
  5386. if ( oLanguage.sUrl !== "" )
  5387. {
  5388. /* Get the language definitions from a file - because this Ajax call makes the language
  5389. * get async to the remainder of this function we use bInitHandedOff to indicate that
  5390. * _fnInitialise will be fired by the returned Ajax handler, rather than the constructor
  5391. */
  5392. $.ajax( {
  5393. dataType: 'json',
  5394. url: oLanguage.sUrl,
  5395. success: function ( json ) {
  5396. _fnLanguageCompat( json );
  5397. _fnCamelToHungarian( defaults.oLanguage, json );
  5398. $.extend( true, oLanguage, json );
  5399. _fnInitialise( oSettings );
  5400. },
  5401. error: function () {
  5402. // Error occurred loading language file, continue on as best we can
  5403. _fnInitialise( oSettings );
  5404. }
  5405. } );
  5406. bInitHandedOff = true;
  5407. }
  5408. /*
  5409. * Stripes
  5410. */
  5411. if ( oInit.asStripeClasses === null )
  5412. {
  5413. oSettings.asStripeClasses =[
  5414. oClasses.sStripeOdd,
  5415. oClasses.sStripeEven
  5416. ];
  5417. }
  5418. /* Remove row stripe classes if they are already on the table row */
  5419. var stripeClasses = oSettings.asStripeClasses;
  5420. var rowOne = $('tbody tr:eq(0)', this);
  5421. if ( $.inArray( true, $.map( stripeClasses, function(el, i) {
  5422. return rowOne.hasClass(el);
  5423. } ) ) !== -1 ) {
  5424. $('tbody tr', this).removeClass( stripeClasses.join(' ') );
  5425. oSettings.asDestroyStripes = stripeClasses.slice();
  5426. }
  5427. /*
  5428. * Columns
  5429. * See if we should load columns automatically or use defined ones
  5430. */
  5431. var anThs = [];
  5432. var aoColumnsInit;
  5433. var nThead = this.getElementsByTagName('thead');
  5434. if ( nThead.length !== 0 )
  5435. {
  5436. _fnDetectHeader( oSettings.aoHeader, nThead[0] );
  5437. anThs = _fnGetUniqueThs( oSettings );
  5438. }
  5439. /* If not given a column array, generate one with nulls */
  5440. if ( oInit.aoColumns === null )
  5441. {
  5442. aoColumnsInit = [];
  5443. for ( i=0, iLen=anThs.length ; i<iLen ; i++ )
  5444. {
  5445. aoColumnsInit.push( null );
  5446. }
  5447. }
  5448. else
  5449. {
  5450. aoColumnsInit = oInit.aoColumns;
  5451. }
  5452. /* Add the columns */
  5453. for ( i=0, iLen=aoColumnsInit.length ; i<iLen ; i++ )
  5454. {
  5455. _fnAddColumn( oSettings, anThs ? anThs[i] : null );
  5456. }
  5457. /* Apply the column definitions */
  5458. _fnApplyColumnDefs( oSettings, oInit.aoColumnDefs, aoColumnsInit, function (iCol, oDef) {
  5459. _fnColumnOptions( oSettings, iCol, oDef );
  5460. } );
  5461. /* HTML5 attribute detection - build an mData object automatically if the
  5462. * attributes are found
  5463. */
  5464. if ( rowOne.length ) {
  5465. var a = function ( cell, name ) {
  5466. return cell.getAttribute( 'data-'+name ) ? name : null;
  5467. };
  5468. $.each( _fnGetRowElements( oSettings, rowOne[0] ).cells, function (i, cell) {
  5469. var col = oSettings.aoColumns[i];
  5470. if ( col.mData === i ) {
  5471. var sort = a( cell, 'sort' ) || a( cell, 'order' );
  5472. var filter = a( cell, 'filter' ) || a( cell, 'search' );
  5473. if ( sort !== null || filter !== null ) {
  5474. col.mData = {
  5475. _: i+'.display',
  5476. sort: sort !== null ? i+'.@data-'+sort : undefined,
  5477. type: sort !== null ? i+'.@data-'+sort : undefined,
  5478. filter: filter !== null ? i+'.@data-'+filter : undefined
  5479. };
  5480. _fnColumnOptions( oSettings, i );
  5481. }
  5482. }
  5483. } );
  5484. }
  5485. var features = oSettings.oFeatures;
  5486. /* Must be done after everything which can be overridden by the state saving! */
  5487. if ( oInit.bStateSave )
  5488. {
  5489. features.bStateSave = true;
  5490. _fnLoadState( oSettings, oInit );
  5491. _fnCallbackReg( oSettings, 'aoDrawCallback', _fnSaveState, 'state_save' );
  5492. }
  5493. /*
  5494. * Sorting
  5495. * @todo For modularisation (1.11) this needs to do into a sort start up handler
  5496. */
  5497. // If aaSorting is not defined, then we use the first indicator in asSorting
  5498. // in case that has been altered, so the default sort reflects that option
  5499. if ( oInit.aaSorting === undefined )
  5500. {
  5501. var sorting = oSettings.aaSorting;
  5502. for ( i=0, iLen=sorting.length ; i<iLen ; i++ )
  5503. {
  5504. sorting[i][1] = oSettings.aoColumns[ i ].asSorting[0];
  5505. }
  5506. }
  5507. /* Do a first pass on the sorting classes (allows any size changes to be taken into
  5508. * account, and also will apply sorting disabled classes if disabled
  5509. */
  5510. _fnSortingClasses( oSettings );
  5511. if ( features.bSort )
  5512. {
  5513. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  5514. if ( oSettings.bSorted ) {
  5515. var aSort = _fnSortFlatten( oSettings );
  5516. var sortedColumns = {};
  5517. $.each( aSort, function (i, val) {
  5518. sortedColumns[ val.src ] = val.dir;
  5519. } );
  5520. _fnCallbackFire( oSettings, null, 'order', [oSettings, aSort, sortedColumns] );
  5521. _fnSortAria( oSettings );
  5522. }
  5523. } );
  5524. }
  5525. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  5526. if ( oSettings.bSorted || _fnDataSource( oSettings ) === 'ssp' || features.bDeferRender ) {
  5527. _fnSortingClasses( oSettings );
  5528. }
  5529. }, 'sc' );
  5530. /*
  5531. * Final init
  5532. * Cache the header, body and footer as required, creating them if needed
  5533. */
  5534. /* Browser support detection */
  5535. _fnBrowserDetect( oSettings );
  5536. // Work around for Webkit bug 83867 - store the caption-side before removing from doc
  5537. var captions = $(this).children('caption').each( function () {
  5538. this._captionSide = $(this).css('caption-side');
  5539. } );
  5540. var thead = $(this).children('thead');
  5541. if ( thead.length === 0 )
  5542. {
  5543. thead = $('<thead/>').appendTo(this);
  5544. }
  5545. oSettings.nTHead = thead[0];
  5546. var tbody = $(this).children('tbody');
  5547. if ( tbody.length === 0 )
  5548. {
  5549. tbody = $('<tbody/>').appendTo(this);
  5550. }
  5551. oSettings.nTBody = tbody[0];
  5552. var tfoot = $(this).children('tfoot');
  5553. if ( tfoot.length === 0 && captions.length > 0 && (oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "") )
  5554. {
  5555. // If we are a scrolling table, and no footer has been given, then we need to create
  5556. // a tfoot element for the caption element to be appended to
  5557. tfoot = $('<tfoot/>').appendTo(this);
  5558. }
  5559. if ( tfoot.length === 0 || tfoot.children().length === 0 ) {
  5560. $(this).addClass( oClasses.sNoFooter );
  5561. }
  5562. else if ( tfoot.length > 0 ) {
  5563. oSettings.nTFoot = tfoot[0];
  5564. _fnDetectHeader( oSettings.aoFooter, oSettings.nTFoot );
  5565. }
  5566. /* Check if there is data passing into the constructor */
  5567. if ( oInit.aaData )
  5568. {
  5569. for ( i=0 ; i<oInit.aaData.length ; i++ )
  5570. {
  5571. _fnAddData( oSettings, oInit.aaData[ i ] );
  5572. }
  5573. }
  5574. else if ( oSettings.bDeferLoading || _fnDataSource( oSettings ) == 'dom' )
  5575. {
  5576. /* Grab the data from the page - only do this when deferred loading or no Ajax
  5577. * source since there is no point in reading the DOM data if we are then going
  5578. * to replace it with Ajax data
  5579. */
  5580. _fnAddTr( oSettings, $(oSettings.nTBody).children('tr') );
  5581. }
  5582. /* Copy the data index array */
  5583. oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
  5584. /* Initialisation complete - table can be drawn */
  5585. oSettings.bInitialised = true;
  5586. /* Check if we need to initialise the table (it might not have been handed off to the
  5587. * language processor)
  5588. */
  5589. if ( bInitHandedOff === false )
  5590. {
  5591. _fnInitialise( oSettings );
  5592. }
  5593. } );
  5594. _that = null;
  5595. return this;
  5596. };
  5597. /**
  5598. * Computed structure of the DataTables API, defined by the options passed to
  5599. * `DataTable.Api.register()` when building the API.
  5600. *
  5601. * The structure is built in order to speed creation and extension of the Api
  5602. * objects since the extensions are effectively pre-parsed.
  5603. *
  5604. * The array is an array of objects with the following structure, where this
  5605. * base array represents the Api prototype base:
  5606. *
  5607. * [
  5608. * {
  5609. * name: 'data' -- string - Property name
  5610. * val: function () {}, -- function - Api method (or undefined if just an object
  5611. * methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  5612. * propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  5613. * },
  5614. * {
  5615. * name: 'row'
  5616. * val: {},
  5617. * methodExt: [ ... ],
  5618. * propExt: [
  5619. * {
  5620. * name: 'data'
  5621. * val: function () {},
  5622. * methodExt: [ ... ],
  5623. * propExt: [ ... ]
  5624. * },
  5625. * ...
  5626. * ]
  5627. * }
  5628. * ]
  5629. *
  5630. * @type {Array}
  5631. * @ignore
  5632. */
  5633. var __apiStruct = [];
  5634. /**
  5635. * `Array.prototype` reference.
  5636. *
  5637. * @type object
  5638. * @ignore
  5639. */
  5640. var __arrayProto = Array.prototype;
  5641. /**
  5642. * Abstraction for `context` parameter of the `Api` constructor to allow it to
  5643. * take several different forms for ease of use.
  5644. *
  5645. * Each of the input parameter types will be converted to a DataTables settings
  5646. * object where possible.
  5647. *
  5648. * @param {string|node|jQuery|object} mixed DataTable identifier. Can be one
  5649. * of:
  5650. *
  5651. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5652. * with be found and used.
  5653. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5654. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5655. * * `object` - DataTables settings object
  5656. * * `DataTables.Api` - API instance
  5657. * @return {array|null} Matching DataTables settings objects. `null` or
  5658. * `undefined` is returned if no matching DataTable is found.
  5659. * @ignore
  5660. */
  5661. var _toSettings = function ( mixed )
  5662. {
  5663. var idx, jq;
  5664. var settings = DataTable.settings;
  5665. var tables = $.map( settings, function (el, i) {
  5666. return el.nTable;
  5667. } );
  5668. if ( ! mixed ) {
  5669. return [];
  5670. }
  5671. else if ( mixed.nTable && mixed.oApi ) {
  5672. // DataTables settings object
  5673. return [ mixed ];
  5674. }
  5675. else if ( mixed.nodeName && mixed.nodeName.toLowerCase() === 'table' ) {
  5676. // Table node
  5677. idx = $.inArray( mixed, tables );
  5678. return idx !== -1 ? [ settings[idx] ] : null;
  5679. }
  5680. else if ( mixed && typeof mixed.settings === 'function' ) {
  5681. return mixed.settings().toArray();
  5682. }
  5683. else if ( typeof mixed === 'string' ) {
  5684. // jQuery selector
  5685. jq = $(mixed);
  5686. }
  5687. else if ( mixed instanceof $ ) {
  5688. // jQuery object (also DataTables instance)
  5689. jq = mixed;
  5690. }
  5691. if ( jq ) {
  5692. return jq.map( function(i) {
  5693. idx = $.inArray( this, tables );
  5694. return idx !== -1 ? settings[idx] : null;
  5695. } ).toArray();
  5696. }
  5697. };
  5698. /**
  5699. * DataTables API class - used to control and interface with one or more
  5700. * DataTables enhanced tables.
  5701. *
  5702. * The API class is heavily based on jQuery, presenting a chainable interface
  5703. * that you can use to interact with tables. Each instance of the API class has
  5704. * a "context" - i.e. the tables that it will operate on. This could be a single
  5705. * table, all tables on a page or a sub-set thereof.
  5706. *
  5707. * Additionally the API is designed to allow you to easily work with the data in
  5708. * the tables, retrieving and manipulating it as required. This is done by
  5709. * presenting the API class as an array like interface. The contents of the
  5710. * array depend upon the actions requested by each method (for example
  5711. * `rows().nodes()` will return an array of nodes, while `rows().data()` will
  5712. * return an array of objects or arrays depending upon your table's
  5713. * configuration). The API object has a number of array like methods (`push`,
  5714. * `pop`, `reverse` etc) as well as additional helper methods (`each`, `pluck`,
  5715. * `unique` etc) to assist your working with the data held in a table.
  5716. *
  5717. * Most methods (those which return an Api instance) are chainable, which means
  5718. * the return from a method call also has all of the methods available that the
  5719. * top level object had. For example, these two calls are equivalent:
  5720. *
  5721. * // Not chained
  5722. * api.row.add( {...} );
  5723. * api.draw();
  5724. *
  5725. * // Chained
  5726. * api.row.add( {...} ).draw();
  5727. *
  5728. * @class DataTable.Api
  5729. * @param {array|object|string|jQuery} context DataTable identifier. This is
  5730. * used to define which DataTables enhanced tables this API will operate on.
  5731. * Can be one of:
  5732. *
  5733. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5734. * with be found and used.
  5735. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5736. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5737. * * `object` - DataTables settings object
  5738. * @param {array} [data] Data to initialise the Api instance with.
  5739. *
  5740. * @example
  5741. * // Direct initialisation during DataTables construction
  5742. * var api = $('#example').DataTable();
  5743. *
  5744. * @example
  5745. * // Initialisation using a DataTables jQuery object
  5746. * var api = $('#example').dataTable().api();
  5747. *
  5748. * @example
  5749. * // Initialisation as a constructor
  5750. * var api = new $.fn.DataTable.Api( 'table.dataTable' );
  5751. */
  5752. _Api = function ( context, data )
  5753. {
  5754. if ( ! this instanceof _Api ) {
  5755. throw 'DT API must be constructed as a new object';
  5756. // or should it do the 'new' for the caller?
  5757. // return new _Api.apply( this, arguments );
  5758. }
  5759. var settings = [];
  5760. var ctxSettings = function ( o ) {
  5761. var a = _toSettings( o );
  5762. if ( a ) {
  5763. settings.push.apply( settings, a );
  5764. }
  5765. };
  5766. if ( $.isArray( context ) ) {
  5767. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  5768. ctxSettings( context[i] );
  5769. }
  5770. }
  5771. else {
  5772. ctxSettings( context );
  5773. }
  5774. // Remove duplicates
  5775. this.context = _unique( settings );
  5776. // Initial data
  5777. if ( data ) {
  5778. this.push.apply( this, data.toArray ? data.toArray() : data );
  5779. }
  5780. // selector
  5781. this.selector = {
  5782. rows: null,
  5783. cols: null,
  5784. opts: null
  5785. };
  5786. _Api.extend( this, this, __apiStruct );
  5787. };
  5788. DataTable.Api = _Api;
  5789. _Api.prototype = /** @lends DataTables.Api */{
  5790. /**
  5791. * Return a new Api instance, comprised of the data held in the current
  5792. * instance, join with the other array(s) and/or value(s).
  5793. *
  5794. * An alias for `Array.prototype.concat`.
  5795. *
  5796. * @type method
  5797. * @param {*} value1 Arrays and/or values to concatenate.
  5798. * @param {*} [...] Additional arrays and/or values to concatenate.
  5799. * @returns {DataTables.Api} New API instance, comprising of the combined
  5800. * array.
  5801. */
  5802. concat: __arrayProto.concat,
  5803. context: [], // array of table settings objects
  5804. each: function ( fn )
  5805. {
  5806. for ( var i=0, ien=this.length ; i<ien; i++ ) {
  5807. fn.call( this, this[i], i, this );
  5808. }
  5809. return this;
  5810. },
  5811. eq: function ( idx )
  5812. {
  5813. var ctx = this.context;
  5814. return ctx.length > idx ?
  5815. new _Api( ctx[idx], this[idx] ) :
  5816. null;
  5817. },
  5818. filter: function ( fn )
  5819. {
  5820. var a = [];
  5821. if ( __arrayProto.filter ) {
  5822. a = __arrayProto.filter.call( this, fn, this );
  5823. }
  5824. else {
  5825. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  5826. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  5827. if ( fn.call( this, this[i], i, this ) ) {
  5828. a.push( this[i] );
  5829. }
  5830. }
  5831. }
  5832. return new _Api( this.context, a );
  5833. },
  5834. flatten: function ()
  5835. {
  5836. var a = [];
  5837. return new _Api( this.context, a.concat.apply( a, this.toArray() ) );
  5838. },
  5839. join: __arrayProto.join,
  5840. indexOf: __arrayProto.indexOf || function (obj, start)
  5841. {
  5842. for ( var i=(start || 0), ien=this.length ; i<ien ; i++ ) {
  5843. if ( this[i] === obj ) {
  5844. return i;
  5845. }
  5846. }
  5847. return -1;
  5848. },
  5849. // Note that `alwaysNew` is internal - use iteratorNew externally
  5850. iterator: function ( flatten, type, fn, alwaysNew ) {
  5851. var
  5852. a = [], ret,
  5853. i, ien, j, jen,
  5854. context = this.context,
  5855. rows, items, item,
  5856. selector = this.selector;
  5857. // Argument shifting
  5858. if ( typeof flatten === 'string' ) {
  5859. alwaysNew = fn;
  5860. fn = type;
  5861. type = flatten;
  5862. flatten = false;
  5863. }
  5864. for ( i=0, ien=context.length ; i<ien ; i++ ) {
  5865. var apiInst = new _Api( context[i] );
  5866. if ( type === 'table' ) {
  5867. ret = fn.call( apiInst, context[i], i );
  5868. if ( ret !== undefined ) {
  5869. a.push( ret );
  5870. }
  5871. }
  5872. else if ( type === 'columns' || type === 'rows' ) {
  5873. // this has same length as context - one entry for each table
  5874. ret = fn.call( apiInst, context[i], this[i], i );
  5875. if ( ret !== undefined ) {
  5876. a.push( ret );
  5877. }
  5878. }
  5879. else if ( type === 'column' || type === 'column-rows' || type === 'row' || type === 'cell' ) {
  5880. // columns and rows share the same structure.
  5881. // 'this' is an array of column indexes for each context
  5882. items = this[i];
  5883. if ( type === 'column-rows' ) {
  5884. rows = _selector_row_indexes( context[i], selector.opts );
  5885. }
  5886. for ( j=0, jen=items.length ; j<jen ; j++ ) {
  5887. item = items[j];
  5888. if ( type === 'cell' ) {
  5889. ret = fn.call( apiInst, context[i], item.row, item.column, i, j );
  5890. }
  5891. else {
  5892. ret = fn.call( apiInst, context[i], item, i, j, rows );
  5893. }
  5894. if ( ret !== undefined ) {
  5895. a.push( ret );
  5896. }
  5897. }
  5898. }
  5899. }
  5900. if ( a.length || alwaysNew ) {
  5901. var api = new _Api( context, flatten ? a.concat.apply( [], a ) : a );
  5902. var apiSelector = api.selector;
  5903. apiSelector.rows = selector.rows;
  5904. apiSelector.cols = selector.cols;
  5905. apiSelector.opts = selector.opts;
  5906. return api;
  5907. }
  5908. return this;
  5909. },
  5910. lastIndexOf: __arrayProto.lastIndexOf || function (obj, start)
  5911. {
  5912. // Bit cheeky...
  5913. return this.indexOf.apply( this.toArray.reverse(), arguments );
  5914. },
  5915. length: 0,
  5916. map: function ( fn )
  5917. {
  5918. var a = [];
  5919. if ( __arrayProto.map ) {
  5920. a = __arrayProto.map.call( this, fn, this );
  5921. }
  5922. else {
  5923. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  5924. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  5925. a.push( fn.call( this, this[i], i ) );
  5926. }
  5927. }
  5928. return new _Api( this.context, a );
  5929. },
  5930. pluck: function ( prop )
  5931. {
  5932. return this.map( function ( el ) {
  5933. return el[ prop ];
  5934. } );
  5935. },
  5936. pop: __arrayProto.pop,
  5937. push: __arrayProto.push,
  5938. // Does not return an API instance
  5939. reduce: __arrayProto.reduce || function ( fn, init )
  5940. {
  5941. return _fnReduce( this, fn, init, 0, this.length, 1 );
  5942. },
  5943. reduceRight: __arrayProto.reduceRight || function ( fn, init )
  5944. {
  5945. return _fnReduce( this, fn, init, this.length-1, -1, -1 );
  5946. },
  5947. reverse: __arrayProto.reverse,
  5948. // Object with rows, columns and opts
  5949. selector: null,
  5950. shift: __arrayProto.shift,
  5951. sort: __arrayProto.sort, // ? name - order?
  5952. splice: __arrayProto.splice,
  5953. toArray: function ()
  5954. {
  5955. return __arrayProto.slice.call( this );
  5956. },
  5957. to$: function ()
  5958. {
  5959. return $( this );
  5960. },
  5961. toJQuery: function ()
  5962. {
  5963. return $( this );
  5964. },
  5965. unique: function ()
  5966. {
  5967. return new _Api( this.context, _unique(this) );
  5968. },
  5969. unshift: __arrayProto.unshift
  5970. };
  5971. _Api.extend = function ( scope, obj, ext )
  5972. {
  5973. // Only extend API instances and static properties of the API
  5974. if ( ! obj || ( ! (obj instanceof _Api) && ! obj.__dt_wrapper ) ) {
  5975. return;
  5976. }
  5977. var
  5978. i, ien,
  5979. j, jen,
  5980. struct, inner,
  5981. methodScoping = function ( scope, fn, struc ) {
  5982. return function () {
  5983. var ret = fn.apply( scope, arguments );
  5984. // Method extension
  5985. _Api.extend( ret, ret, struc.methodExt );
  5986. return ret;
  5987. };
  5988. };
  5989. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  5990. struct = ext[i];
  5991. // Value
  5992. obj[ struct.name ] = typeof struct.val === 'function' ?
  5993. methodScoping( scope, struct.val, struct ) :
  5994. $.isPlainObject( struct.val ) ?
  5995. {} :
  5996. struct.val;
  5997. obj[ struct.name ].__dt_wrapper = true;
  5998. // Property extension
  5999. _Api.extend( scope, obj[ struct.name ], struct.propExt );
  6000. }
  6001. };
  6002. // @todo - Is there need for an augment function?
  6003. // _Api.augment = function ( inst, name )
  6004. // {
  6005. // // Find src object in the structure from the name
  6006. // var parts = name.split('.');
  6007. // _Api.extend( inst, obj );
  6008. // };
  6009. // [
  6010. // {
  6011. // name: 'data' -- string - Property name
  6012. // val: function () {}, -- function - Api method (or undefined if just an object
  6013. // methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  6014. // propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  6015. // },
  6016. // {
  6017. // name: 'row'
  6018. // val: {},
  6019. // methodExt: [ ... ],
  6020. // propExt: [
  6021. // {
  6022. // name: 'data'
  6023. // val: function () {},
  6024. // methodExt: [ ... ],
  6025. // propExt: [ ... ]
  6026. // },
  6027. // ...
  6028. // ]
  6029. // }
  6030. // ]
  6031. _Api.register = _api_register = function ( name, val )
  6032. {
  6033. if ( $.isArray( name ) ) {
  6034. for ( var j=0, jen=name.length ; j<jen ; j++ ) {
  6035. _Api.register( name[j], val );
  6036. }
  6037. return;
  6038. }
  6039. var
  6040. i, ien,
  6041. heir = name.split('.'),
  6042. struct = __apiStruct,
  6043. key, method;
  6044. var find = function ( src, name ) {
  6045. for ( var i=0, ien=src.length ; i<ien ; i++ ) {
  6046. if ( src[i].name === name ) {
  6047. return src[i];
  6048. }
  6049. }
  6050. return null;
  6051. };
  6052. for ( i=0, ien=heir.length ; i<ien ; i++ ) {
  6053. method = heir[i].indexOf('()') !== -1;
  6054. key = method ?
  6055. heir[i].replace('()', '') :
  6056. heir[i];
  6057. var src = find( struct, key );
  6058. if ( ! src ) {
  6059. src = {
  6060. name: key,
  6061. val: {},
  6062. methodExt: [],
  6063. propExt: []
  6064. };
  6065. struct.push( src );
  6066. }
  6067. if ( i === ien-1 ) {
  6068. src.val = val;
  6069. }
  6070. else {
  6071. struct = method ?
  6072. src.methodExt :
  6073. src.propExt;
  6074. }
  6075. }
  6076. };
  6077. _Api.registerPlural = _api_registerPlural = function ( pluralName, singularName, val ) {
  6078. _Api.register( pluralName, val );
  6079. _Api.register( singularName, function () {
  6080. var ret = val.apply( this, arguments );
  6081. if ( ret === this ) {
  6082. // Returned item is the API instance that was passed in, return it
  6083. return this;
  6084. }
  6085. else if ( ret instanceof _Api ) {
  6086. // New API instance returned, want the value from the first item
  6087. // in the returned array for the singular result.
  6088. return ret.length ?
  6089. $.isArray( ret[0] ) ?
  6090. new _Api( ret.context, ret[0] ) : // Array results are 'enhanced'
  6091. ret[0] :
  6092. undefined;
  6093. }
  6094. // Non-API return - just fire it back
  6095. return ret;
  6096. } );
  6097. };
  6098. /**
  6099. * Selector for HTML tables. Apply the given selector to the give array of
  6100. * DataTables settings objects.
  6101. *
  6102. * @param {string|integer} [selector] jQuery selector string or integer
  6103. * @param {array} Array of DataTables settings objects to be filtered
  6104. * @return {array}
  6105. * @ignore
  6106. */
  6107. var __table_selector = function ( selector, a )
  6108. {
  6109. // Integer is used to pick out a table by index
  6110. if ( typeof selector === 'number' ) {
  6111. return [ a[ selector ] ];
  6112. }
  6113. // Perform a jQuery selector on the table nodes
  6114. var nodes = $.map( a, function (el, i) {
  6115. return el.nTable;
  6116. } );
  6117. return $(nodes)
  6118. .filter( selector )
  6119. .map( function (i) {
  6120. // Need to translate back from the table node to the settings
  6121. var idx = $.inArray( this, nodes );
  6122. return a[ idx ];
  6123. } )
  6124. .toArray();
  6125. };
  6126. /**
  6127. * Context selector for the API's context (i.e. the tables the API instance
  6128. * refers to.
  6129. *
  6130. * @name DataTable.Api#tables
  6131. * @param {string|integer} [selector] Selector to pick which tables the iterator
  6132. * should operate on. If not given, all tables in the current context are
  6133. * used. This can be given as a jQuery selector (for example `':gt(0)'`) to
  6134. * select multiple tables or as an integer to select a single table.
  6135. * @returns {DataTable.Api} Returns a new API instance if a selector is given.
  6136. */
  6137. _api_register( 'tables()', function ( selector ) {
  6138. // A new instance is created if there was a selector specified
  6139. return selector ?
  6140. new _Api( __table_selector( selector, this.context ) ) :
  6141. this;
  6142. } );
  6143. _api_register( 'table()', function ( selector ) {
  6144. var tables = this.tables( selector );
  6145. var ctx = tables.context;
  6146. // Truncate to the first matched table
  6147. return ctx.length ?
  6148. new _Api( ctx[0] ) :
  6149. tables;
  6150. } );
  6151. _api_registerPlural( 'tables().nodes()', 'table().node()' , function () {
  6152. return this.iterator( 'table', function ( ctx ) {
  6153. return ctx.nTable;
  6154. }, 1 );
  6155. } );
  6156. _api_registerPlural( 'tables().body()', 'table().body()' , function () {
  6157. return this.iterator( 'table', function ( ctx ) {
  6158. return ctx.nTBody;
  6159. }, 1 );
  6160. } );
  6161. _api_registerPlural( 'tables().header()', 'table().header()' , function () {
  6162. return this.iterator( 'table', function ( ctx ) {
  6163. return ctx.nTHead;
  6164. }, 1 );
  6165. } );
  6166. _api_registerPlural( 'tables().footer()', 'table().footer()' , function () {
  6167. return this.iterator( 'table', function ( ctx ) {
  6168. return ctx.nTFoot;
  6169. }, 1 );
  6170. } );
  6171. _api_registerPlural( 'tables().containers()', 'table().container()' , function () {
  6172. return this.iterator( 'table', function ( ctx ) {
  6173. return ctx.nTableWrapper;
  6174. }, 1 );
  6175. } );
  6176. /**
  6177. * Redraw the tables in the current context.
  6178. *
  6179. * @param {boolean} [reset=true] Reset (default) or hold the current paging
  6180. * position. A full re-sort and re-filter is performed when this method is
  6181. * called, which is why the pagination reset is the default action.
  6182. * @returns {DataTables.Api} this
  6183. */
  6184. _api_register( 'draw()', function ( resetPaging ) {
  6185. return this.iterator( 'table', function ( settings ) {
  6186. _fnReDraw( settings, resetPaging===false );
  6187. } );
  6188. } );
  6189. /**
  6190. * Get the current page index.
  6191. *
  6192. * @return {integer} Current page index (zero based)
  6193. *//**
  6194. * Set the current page.
  6195. *
  6196. * Note that if you attempt to show a page which does not exist, DataTables will
  6197. * not throw an error, but rather reset the paging.
  6198. *
  6199. * @param {integer|string} action The paging action to take. This can be one of:
  6200. * * `integer` - The page index to jump to
  6201. * * `string` - An action to take:
  6202. * * `first` - Jump to first page.
  6203. * * `next` - Jump to the next page
  6204. * * `previous` - Jump to previous page
  6205. * * `last` - Jump to the last page.
  6206. * @returns {DataTables.Api} this
  6207. */
  6208. _api_register( 'page()', function ( action ) {
  6209. if ( action === undefined ) {
  6210. return this.page.info().page; // not an expensive call
  6211. }
  6212. // else, have an action to take on all tables
  6213. return this.iterator( 'table', function ( settings ) {
  6214. _fnPageChange( settings, action );
  6215. } );
  6216. } );
  6217. /**
  6218. * Paging information for the first table in the current context.
  6219. *
  6220. * If you require paging information for another table, use the `table()` method
  6221. * with a suitable selector.
  6222. *
  6223. * @return {object} Object with the following properties set:
  6224. * * `page` - Current page index (zero based - i.e. the first page is `0`)
  6225. * * `pages` - Total number of pages
  6226. * * `start` - Display index for the first record shown on the current page
  6227. * * `end` - Display index for the last record shown on the current page
  6228. * * `length` - Display length (number of records). Note that generally `start
  6229. * + length = end`, but this is not always true, for example if there are
  6230. * only 2 records to show on the final page, with a length of 10.
  6231. * * `recordsTotal` - Full data set length
  6232. * * `recordsDisplay` - Data set length once the current filtering criterion
  6233. * are applied.
  6234. */
  6235. _api_register( 'page.info()', function ( action ) {
  6236. if ( this.context.length === 0 ) {
  6237. return undefined;
  6238. }
  6239. var
  6240. settings = this.context[0],
  6241. start = settings._iDisplayStart,
  6242. len = settings._iDisplayLength,
  6243. visRecords = settings.fnRecordsDisplay(),
  6244. all = len === -1;
  6245. return {
  6246. "page": all ? 0 : Math.floor( start / len ),
  6247. "pages": all ? 1 : Math.ceil( visRecords / len ),
  6248. "start": start,
  6249. "end": settings.fnDisplayEnd(),
  6250. "length": len,
  6251. "recordsTotal": settings.fnRecordsTotal(),
  6252. "recordsDisplay": visRecords
  6253. };
  6254. } );
  6255. /**
  6256. * Get the current page length.
  6257. *
  6258. * @return {integer} Current page length. Note `-1` indicates that all records
  6259. * are to be shown.
  6260. *//**
  6261. * Set the current page length.
  6262. *
  6263. * @param {integer} Page length to set. Use `-1` to show all records.
  6264. * @returns {DataTables.Api} this
  6265. */
  6266. _api_register( 'page.len()', function ( len ) {
  6267. // Note that we can't call this function 'length()' because `length`
  6268. // is a Javascript property of functions which defines how many arguments
  6269. // the function expects.
  6270. if ( len === undefined ) {
  6271. return this.context.length !== 0 ?
  6272. this.context[0]._iDisplayLength :
  6273. undefined;
  6274. }
  6275. // else, set the page length
  6276. return this.iterator( 'table', function ( settings ) {
  6277. _fnLengthChange( settings, len );
  6278. } );
  6279. } );
  6280. var __reload = function ( settings, holdPosition, callback ) {
  6281. if ( _fnDataSource( settings ) == 'ssp' ) {
  6282. _fnReDraw( settings, holdPosition );
  6283. }
  6284. else {
  6285. // Trigger xhr
  6286. _fnProcessingDisplay( settings, true );
  6287. _fnBuildAjax( settings, [], function( json ) {
  6288. _fnClearTable( settings );
  6289. var data = _fnAjaxDataSrc( settings, json );
  6290. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6291. _fnAddData( settings, data[i] );
  6292. }
  6293. _fnReDraw( settings, holdPosition );
  6294. _fnProcessingDisplay( settings, false );
  6295. } );
  6296. }
  6297. // Use the draw event to trigger a callback, regardless of if it is an async
  6298. // or sync draw
  6299. if ( callback ) {
  6300. var api = new _Api( settings );
  6301. api.one( 'draw', function () {
  6302. callback( api.ajax.json() );
  6303. } );
  6304. }
  6305. };
  6306. /**
  6307. * Get the JSON response from the last Ajax request that DataTables made to the
  6308. * server. Note that this returns the JSON from the first table in the current
  6309. * context.
  6310. *
  6311. * @return {object} JSON received from the server.
  6312. */
  6313. _api_register( 'ajax.json()', function () {
  6314. var ctx = this.context;
  6315. if ( ctx.length > 0 ) {
  6316. return ctx[0].json;
  6317. }
  6318. // else return undefined;
  6319. } );
  6320. /**
  6321. * Get the data submitted in the last Ajax request
  6322. */
  6323. _api_register( 'ajax.params()', function () {
  6324. var ctx = this.context;
  6325. if ( ctx.length > 0 ) {
  6326. return ctx[0].oAjaxData;
  6327. }
  6328. // else return undefined;
  6329. } );
  6330. /**
  6331. * Reload tables from the Ajax data source. Note that this function will
  6332. * automatically re-draw the table when the remote data has been loaded.
  6333. *
  6334. * @param {boolean} [reset=true] Reset (default) or hold the current paging
  6335. * position. A full re-sort and re-filter is performed when this method is
  6336. * called, which is why the pagination reset is the default action.
  6337. * @returns {DataTables.Api} this
  6338. */
  6339. _api_register( 'ajax.reload()', function ( callback, resetPaging ) {
  6340. return this.iterator( 'table', function (settings) {
  6341. __reload( settings, resetPaging===false, callback );
  6342. } );
  6343. } );
  6344. /**
  6345. * Get the current Ajax URL. Note that this returns the URL from the first
  6346. * table in the current context.
  6347. *
  6348. * @return {string} Current Ajax source URL
  6349. *//**
  6350. * Set the Ajax URL. Note that this will set the URL for all tables in the
  6351. * current context.
  6352. *
  6353. * @param {string} url URL to set.
  6354. * @returns {DataTables.Api} this
  6355. */
  6356. _api_register( 'ajax.url()', function ( url ) {
  6357. var ctx = this.context;
  6358. if ( url === undefined ) {
  6359. // get
  6360. if ( ctx.length === 0 ) {
  6361. return undefined;
  6362. }
  6363. ctx = ctx[0];
  6364. return ctx.ajax ?
  6365. $.isPlainObject( ctx.ajax ) ?
  6366. ctx.ajax.url :
  6367. ctx.ajax :
  6368. ctx.sAjaxSource;
  6369. }
  6370. // set
  6371. return this.iterator( 'table', function ( settings ) {
  6372. if ( $.isPlainObject( settings.ajax ) ) {
  6373. settings.ajax.url = url;
  6374. }
  6375. else {
  6376. settings.ajax = url;
  6377. }
  6378. // No need to consider sAjaxSource here since DataTables gives priority
  6379. // to `ajax` over `sAjaxSource`. So setting `ajax` here, renders any
  6380. // value of `sAjaxSource` redundant.
  6381. } );
  6382. } );
  6383. /**
  6384. * Load data from the newly set Ajax URL. Note that this method is only
  6385. * available when `ajax.url()` is used to set a URL. Additionally, this method
  6386. * has the same effect as calling `ajax.reload()` but is provided for
  6387. * convenience when setting a new URL. Like `ajax.reload()` it will
  6388. * automatically redraw the table once the remote data has been loaded.
  6389. *
  6390. * @returns {DataTables.Api} this
  6391. */
  6392. _api_register( 'ajax.url().load()', function ( callback, resetPaging ) {
  6393. // Same as a reload, but makes sense to present it for easy access after a
  6394. // url change
  6395. return this.iterator( 'table', function ( ctx ) {
  6396. __reload( ctx, resetPaging===false, callback );
  6397. } );
  6398. } );
  6399. var _selector_run = function ( selector, select )
  6400. {
  6401. var
  6402. out = [], res,
  6403. a, i, ien, j, jen,
  6404. selectorType = typeof selector;
  6405. // Can't just check for isArray here, as an API or jQuery instance might be
  6406. // given with their array like look
  6407. if ( ! selector || selectorType === 'string' || selectorType === 'function' || selector.length === undefined ) {
  6408. selector = [ selector ];
  6409. }
  6410. for ( i=0, ien=selector.length ; i<ien ; i++ ) {
  6411. a = selector[i] && selector[i].split ?
  6412. selector[i].split(',') :
  6413. [ selector[i] ];
  6414. for ( j=0, jen=a.length ; j<jen ; j++ ) {
  6415. res = select( typeof a[j] === 'string' ? $.trim(a[j]) : a[j] );
  6416. if ( res && res.length ) {
  6417. out.push.apply( out, res );
  6418. }
  6419. }
  6420. }
  6421. return out;
  6422. };
  6423. var _selector_opts = function ( opts )
  6424. {
  6425. if ( ! opts ) {
  6426. opts = {};
  6427. }
  6428. // Backwards compatibility for 1.9- which used the terminology filter rather
  6429. // than search
  6430. if ( opts.filter && ! opts.search ) {
  6431. opts.search = opts.filter;
  6432. }
  6433. return {
  6434. search: opts.search || 'none',
  6435. order: opts.order || 'current',
  6436. page: opts.page || 'all'
  6437. };
  6438. };
  6439. var _selector_first = function ( inst )
  6440. {
  6441. // Reduce the API instance to the first item found
  6442. for ( var i=0, ien=inst.length ; i<ien ; i++ ) {
  6443. if ( inst[i].length > 0 ) {
  6444. // Assign the first element to the first item in the instance
  6445. // and truncate the instance and context
  6446. inst[0] = inst[i];
  6447. inst.length = 1;
  6448. inst.context = [ inst.context[i] ];
  6449. return inst;
  6450. }
  6451. }
  6452. // Not found - return an empty instance
  6453. inst.length = 0;
  6454. return inst;
  6455. };
  6456. var _selector_row_indexes = function ( settings, opts )
  6457. {
  6458. var
  6459. i, ien, tmp, a=[],
  6460. displayFiltered = settings.aiDisplay,
  6461. displayMaster = settings.aiDisplayMaster;
  6462. var
  6463. search = opts.search, // none, applied, removed
  6464. order = opts.order, // applied, current, index (original - compatibility with 1.9)
  6465. page = opts.page; // all, current
  6466. if ( _fnDataSource( settings ) == 'ssp' ) {
  6467. // In server-side processing mode, most options are irrelevant since
  6468. // rows not shown don't exist and the index order is the applied order
  6469. // Removed is a special case - for consistency just return an empty
  6470. // array
  6471. return search === 'removed' ?
  6472. [] :
  6473. _range( 0, displayMaster.length );
  6474. }
  6475. else if ( page == 'current' ) {
  6476. // Current page implies that order=current and fitler=applied, since it is
  6477. // fairly senseless otherwise, regardless of what order and search actually
  6478. // are
  6479. for ( i=settings._iDisplayStart, ien=settings.fnDisplayEnd() ; i<ien ; i++ ) {
  6480. a.push( displayFiltered[i] );
  6481. }
  6482. }
  6483. else if ( order == 'current' || order == 'applied' ) {
  6484. a = search == 'none' ?
  6485. displayMaster.slice() : // no search
  6486. search == 'applied' ?
  6487. displayFiltered.slice() : // applied search
  6488. $.map( displayMaster, function (el, i) { // removed search
  6489. return $.inArray( el, displayFiltered ) === -1 ? el : null;
  6490. } );
  6491. }
  6492. else if ( order == 'index' || order == 'original' ) {
  6493. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  6494. if ( search == 'none' ) {
  6495. a.push( i );
  6496. }
  6497. else { // applied | removed
  6498. tmp = $.inArray( i, displayFiltered );
  6499. if ((tmp === -1 && search == 'removed') ||
  6500. (tmp >= 0 && search == 'applied') )
  6501. {
  6502. a.push( i );
  6503. }
  6504. }
  6505. }
  6506. }
  6507. return a;
  6508. };
  6509. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6510. * Rows
  6511. *
  6512. * {} - no selector - use all available rows
  6513. * {integer} - row aoData index
  6514. * {node} - TR node
  6515. * {string} - jQuery selector to apply to the TR elements
  6516. * {array} - jQuery array of nodes, or simply an array of TR nodes
  6517. *
  6518. */
  6519. var __row_selector = function ( settings, selector, opts )
  6520. {
  6521. return _selector_run( selector, function ( sel ) {
  6522. var selInt = _intVal( sel );
  6523. var i, ien;
  6524. // Short cut - selector is a number and no options provided (default is
  6525. // all records, so no need to check if the index is in there, since it
  6526. // must be - dev error if the index doesn't exist).
  6527. if ( selInt !== null && ! opts ) {
  6528. return [ selInt ];
  6529. }
  6530. var rows = _selector_row_indexes( settings, opts );
  6531. if ( selInt !== null && $.inArray( selInt, rows ) !== -1 ) {
  6532. // Selector - integer
  6533. return [ selInt ];
  6534. }
  6535. else if ( ! sel ) {
  6536. // Selector - none
  6537. return rows;
  6538. }
  6539. // Selector - function
  6540. if ( typeof sel === 'function' ) {
  6541. return $.map( rows, function (idx) {
  6542. var row = settings.aoData[ idx ];
  6543. return sel( idx, row._aData, row.nTr ) ? idx : null;
  6544. } );
  6545. }
  6546. // Get nodes in the order from the `rows` array with null values removed
  6547. var nodes = _removeEmpty(
  6548. _pluck_order( settings.aoData, rows, 'nTr' )
  6549. );
  6550. // Selector - node
  6551. if ( sel.nodeName ) {
  6552. if ( $.inArray( sel, nodes ) !== -1 ) {
  6553. return [ sel._DT_RowIndex ]; // sel is a TR node that is in the table
  6554. // and DataTables adds a prop for fast lookup
  6555. }
  6556. }
  6557. // Selector - jQuery selector string, array of nodes or jQuery object/
  6558. // As jQuery's .filter() allows jQuery objects to be passed in filter,
  6559. // it also allows arrays, so this will cope with all three options
  6560. return $(nodes)
  6561. .filter( sel )
  6562. .map( function () {
  6563. return this._DT_RowIndex;
  6564. } )
  6565. .toArray();
  6566. } );
  6567. };
  6568. /**
  6569. *
  6570. */
  6571. _api_register( 'rows()', function ( selector, opts ) {
  6572. // argument shifting
  6573. if ( selector === undefined ) {
  6574. selector = '';
  6575. }
  6576. else if ( $.isPlainObject( selector ) ) {
  6577. opts = selector;
  6578. selector = '';
  6579. }
  6580. opts = _selector_opts( opts );
  6581. var inst = this.iterator( 'table', function ( settings ) {
  6582. return __row_selector( settings, selector, opts );
  6583. }, 1 );
  6584. // Want argument shifting here and in __row_selector?
  6585. inst.selector.rows = selector;
  6586. inst.selector.opts = opts;
  6587. return inst;
  6588. } );
  6589. _api_register( 'rows().nodes()', function () {
  6590. return this.iterator( 'row', function ( settings, row ) {
  6591. return settings.aoData[ row ].nTr || undefined;
  6592. }, 1 );
  6593. } );
  6594. _api_register( 'rows().data()', function () {
  6595. return this.iterator( true, 'rows', function ( settings, rows ) {
  6596. return _pluck_order( settings.aoData, rows, '_aData' );
  6597. }, 1 );
  6598. } );
  6599. _api_registerPlural( 'rows().cache()', 'row().cache()', function ( type ) {
  6600. return this.iterator( 'row', function ( settings, row ) {
  6601. var r = settings.aoData[ row ];
  6602. return type === 'search' ? r._aFilterData : r._aSortData;
  6603. }, 1 );
  6604. } );
  6605. _api_registerPlural( 'rows().invalidate()', 'row().invalidate()', function ( src ) {
  6606. return this.iterator( 'row', function ( settings, row ) {
  6607. _fnInvalidate( settings, row, src );
  6608. } );
  6609. } );
  6610. _api_registerPlural( 'rows().indexes()', 'row().index()', function () {
  6611. return this.iterator( 'row', function ( settings, row ) {
  6612. return row;
  6613. }, 1 );
  6614. } );
  6615. _api_registerPlural( 'rows().remove()', 'row().remove()', function () {
  6616. var that = this;
  6617. return this.iterator( 'row', function ( settings, row, thatIdx ) {
  6618. var data = settings.aoData;
  6619. data.splice( row, 1 );
  6620. // Update the _DT_RowIndex parameter on all rows in the table
  6621. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6622. if ( data[i].nTr !== null ) {
  6623. data[i].nTr._DT_RowIndex = i;
  6624. }
  6625. }
  6626. // Remove the target row from the search array
  6627. var displayIndex = $.inArray( row, settings.aiDisplay );
  6628. // Delete from the display arrays
  6629. _fnDeleteIndex( settings.aiDisplayMaster, row );
  6630. _fnDeleteIndex( settings.aiDisplay, row );
  6631. _fnDeleteIndex( that[ thatIdx ], row, false ); // maintain local indexes
  6632. // Check for an 'overflow' they case for displaying the table
  6633. _fnLengthOverflow( settings );
  6634. } );
  6635. } );
  6636. _api_register( 'rows.add()', function ( rows ) {
  6637. var newRows = this.iterator( 'table', function ( settings ) {
  6638. var row, i, ien;
  6639. var out = [];
  6640. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  6641. row = rows[i];
  6642. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  6643. out.push( _fnAddTr( settings, row )[0] );
  6644. }
  6645. else {
  6646. out.push( _fnAddData( settings, row ) );
  6647. }
  6648. }
  6649. return out;
  6650. }, 1 );
  6651. // Return an Api.rows() extended instance, so rows().nodes() etc can be used
  6652. var modRows = this.rows( -1 );
  6653. modRows.pop();
  6654. modRows.push.apply( modRows, newRows.toArray() );
  6655. return modRows;
  6656. } );
  6657. /**
  6658. *
  6659. */
  6660. _api_register( 'row()', function ( selector, opts ) {
  6661. return _selector_first( this.rows( selector, opts ) );
  6662. } );
  6663. _api_register( 'row().data()', function ( data ) {
  6664. var ctx = this.context;
  6665. if ( data === undefined ) {
  6666. // Get
  6667. return ctx.length && this.length ?
  6668. ctx[0].aoData[ this[0] ]._aData :
  6669. undefined;
  6670. }
  6671. // Set
  6672. ctx[0].aoData[ this[0] ]._aData = data;
  6673. // Automatically invalidate
  6674. _fnInvalidate( ctx[0], this[0], 'data' );
  6675. return this;
  6676. } );
  6677. _api_register( 'row().node()', function () {
  6678. var ctx = this.context;
  6679. return ctx.length && this.length ?
  6680. ctx[0].aoData[ this[0] ].nTr || null :
  6681. null;
  6682. } );
  6683. _api_register( 'row.add()', function ( row ) {
  6684. // Allow a jQuery object to be passed in - only a single row is added from
  6685. // it though - the first element in the set
  6686. if ( row instanceof $ && row.length ) {
  6687. row = row[0];
  6688. }
  6689. var rows = this.iterator( 'table', function ( settings ) {
  6690. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  6691. return _fnAddTr( settings, row )[0];
  6692. }
  6693. return _fnAddData( settings, row );
  6694. } );
  6695. // Return an Api.rows() extended instance, with the newly added row selected
  6696. return this.row( rows[0] );
  6697. } );
  6698. var __details_add = function ( ctx, row, data, klass )
  6699. {
  6700. // Convert to array of TR elements
  6701. var rows = [];
  6702. var addRow = function ( r, k ) {
  6703. // If we get a TR element, then just add it directly - up to the dev
  6704. // to add the correct number of columns etc
  6705. if ( r.nodeName && r.nodeName.toLowerCase() === 'tr' ) {
  6706. rows.push( r );
  6707. }
  6708. else {
  6709. // Otherwise create a row with a wrapper
  6710. var created = $('<tr><td/></tr>').addClass( k );
  6711. $('td', created)
  6712. .addClass( k )
  6713. .html( r )
  6714. [0].colSpan = _fnVisbleColumns( ctx );
  6715. rows.push( created[0] );
  6716. }
  6717. };
  6718. if ( $.isArray( data ) || data instanceof $ ) {
  6719. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6720. addRow( data[i], klass );
  6721. }
  6722. }
  6723. else {
  6724. addRow( data, klass );
  6725. }
  6726. if ( row._details ) {
  6727. row._details.remove();
  6728. }
  6729. row._details = $(rows);
  6730. // If the children were already shown, that state should be retained
  6731. if ( row._detailsShow ) {
  6732. row._details.insertAfter( row.nTr );
  6733. }
  6734. };
  6735. var __details_remove = function ( api, idx )
  6736. {
  6737. var ctx = api.context;
  6738. if ( ctx.length ) {
  6739. var row = ctx[0].aoData[ idx !== undefined ? idx : api[0] ];
  6740. if ( row._details ) {
  6741. row._details.remove();
  6742. row._detailsShow = undefined;
  6743. row._details = undefined;
  6744. }
  6745. }
  6746. };
  6747. var __details_display = function ( api, show ) {
  6748. var ctx = api.context;
  6749. if ( ctx.length && api.length ) {
  6750. var row = ctx[0].aoData[ api[0] ];
  6751. if ( row._details ) {
  6752. row._detailsShow = show;
  6753. if ( show ) {
  6754. row._details.insertAfter( row.nTr );
  6755. }
  6756. else {
  6757. row._details.detach();
  6758. }
  6759. __details_events( ctx[0] );
  6760. }
  6761. }
  6762. };
  6763. var __details_events = function ( settings )
  6764. {
  6765. var api = new _Api( settings );
  6766. var namespace = '.dt.DT_details';
  6767. var drawEvent = 'draw'+namespace;
  6768. var colvisEvent = 'column-visibility'+namespace;
  6769. var destroyEvent = 'destroy'+namespace;
  6770. var data = settings.aoData;
  6771. api.off( drawEvent +' '+ colvisEvent +' '+ destroyEvent );
  6772. if ( _pluck( data, '_details' ).length > 0 ) {
  6773. // On each draw, insert the required elements into the document
  6774. api.on( drawEvent, function ( e, ctx ) {
  6775. if ( settings !== ctx ) {
  6776. return;
  6777. }
  6778. api.rows( {page:'current'} ).eq(0).each( function (idx) {
  6779. // Internal data grab
  6780. var row = data[ idx ];
  6781. if ( row._detailsShow ) {
  6782. row._details.insertAfter( row.nTr );
  6783. }
  6784. } );
  6785. } );
  6786. // Column visibility change - update the colspan
  6787. api.on( colvisEvent, function ( e, ctx, idx, vis ) {
  6788. if ( settings !== ctx ) {
  6789. return;
  6790. }
  6791. // Update the colspan for the details rows (note, only if it already has
  6792. // a colspan)
  6793. var row, visible = _fnVisbleColumns( ctx );
  6794. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6795. row = data[i];
  6796. if ( row._details ) {
  6797. row._details.children('td[colspan]').attr('colspan', visible );
  6798. }
  6799. }
  6800. } );
  6801. // Table destroyed - nuke any child rows
  6802. api.on( destroyEvent, function ( e, ctx ) {
  6803. if ( settings !== ctx ) {
  6804. return;
  6805. }
  6806. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6807. if ( data[i]._details ) {
  6808. __details_remove( api, i );
  6809. }
  6810. }
  6811. } );
  6812. }
  6813. };
  6814. // Strings for the method names to help minification
  6815. var _emp = '';
  6816. var _child_obj = _emp+'row().child';
  6817. var _child_mth = _child_obj+'()';
  6818. // data can be:
  6819. // tr
  6820. // string
  6821. // jQuery or array of any of the above
  6822. _api_register( _child_mth, function ( data, klass ) {
  6823. var ctx = this.context;
  6824. if ( data === undefined ) {
  6825. // get
  6826. return ctx.length && this.length ?
  6827. ctx[0].aoData[ this[0] ]._details :
  6828. undefined;
  6829. }
  6830. else if ( data === true ) {
  6831. // show
  6832. this.child.show();
  6833. }
  6834. else if ( data === false ) {
  6835. // remove
  6836. __details_remove( this );
  6837. }
  6838. else if ( ctx.length && this.length ) {
  6839. // set
  6840. __details_add( ctx[0], ctx[0].aoData[ this[0] ], data, klass );
  6841. }
  6842. return this;
  6843. } );
  6844. _api_register( [
  6845. _child_obj+'.show()',
  6846. _child_mth+'.show()' // only when `child()` was called with parameters (without
  6847. ], function ( show ) { // it returns an object and this method is not executed)
  6848. __details_display( this, true );
  6849. return this;
  6850. } );
  6851. _api_register( [
  6852. _child_obj+'.hide()',
  6853. _child_mth+'.hide()' // only when `child()` was called with parameters (without
  6854. ], function () { // it returns an object and this method is not executed)
  6855. __details_display( this, false );
  6856. return this;
  6857. } );
  6858. _api_register( [
  6859. _child_obj+'.remove()',
  6860. _child_mth+'.remove()' // only when `child()` was called with parameters (without
  6861. ], function () { // it returns an object and this method is not executed)
  6862. __details_remove( this );
  6863. return this;
  6864. } );
  6865. _api_register( _child_obj+'.isShown()', function () {
  6866. var ctx = this.context;
  6867. if ( ctx.length && this.length ) {
  6868. // _detailsShown as false or undefined will fall through to return false
  6869. return ctx[0].aoData[ this[0] ]._detailsShow || false;
  6870. }
  6871. return false;
  6872. } );
  6873. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6874. * Columns
  6875. *
  6876. * {integer} - column index (>=0 count from left, <0 count from right)
  6877. * "{integer}:visIdx" - visible column index (i.e. translate to column index) (>=0 count from left, <0 count from right)
  6878. * "{integer}:visible" - alias for {integer}:visIdx (>=0 count from left, <0 count from right)
  6879. * "{string}:name" - column name
  6880. * "{string}" - jQuery selector on column header nodes
  6881. *
  6882. */
  6883. // can be an array of these items, comma separated list, or an array of comma
  6884. // separated lists
  6885. var __re_column_selector = /^(.+):(name|visIdx|visible)$/;
  6886. // r1 and r2 are redundant - but it means that the parameters match for the
  6887. // iterator callback in columns().data()
  6888. var __columnData = function ( settings, column, r1, r2, rows ) {
  6889. var a = [];
  6890. for ( var row=0, ien=rows.length ; row<ien ; row++ ) {
  6891. a.push( _fnGetCellData( settings, rows[row], column ) );
  6892. }
  6893. return a;
  6894. };
  6895. var __column_selector = function ( settings, selector, opts )
  6896. {
  6897. var
  6898. columns = settings.aoColumns,
  6899. names = _pluck( columns, 'sName' ),
  6900. nodes = _pluck( columns, 'nTh' );
  6901. return _selector_run( selector, function ( s ) {
  6902. var selInt = _intVal( s );
  6903. // Selector - all
  6904. if ( s === '' ) {
  6905. return _range( columns.length );
  6906. }
  6907. // Selector - index
  6908. if ( selInt !== null ) {
  6909. return [ selInt >= 0 ?
  6910. selInt : // Count from left
  6911. columns.length + selInt // Count from right (+ because its a negative value)
  6912. ];
  6913. }
  6914. // Selector = function
  6915. if ( typeof s === 'function' ) {
  6916. var rows = _selector_row_indexes( settings, opts );
  6917. return $.map( columns, function (col, idx) {
  6918. return s(
  6919. idx,
  6920. __columnData( settings, idx, 0, 0, rows ),
  6921. nodes[ idx ]
  6922. ) ? idx : null;
  6923. } );
  6924. }
  6925. // jQuery or string selector
  6926. var match = typeof s === 'string' ?
  6927. s.match( __re_column_selector ) :
  6928. '';
  6929. if ( match ) {
  6930. switch( match[2] ) {
  6931. case 'visIdx':
  6932. case 'visible':
  6933. var idx = parseInt( match[1], 10 );
  6934. // Visible index given, convert to column index
  6935. if ( idx < 0 ) {
  6936. // Counting from the right
  6937. var visColumns = $.map( columns, function (col,i) {
  6938. return col.bVisible ? i : null;
  6939. } );
  6940. return [ visColumns[ visColumns.length + idx ] ];
  6941. }
  6942. // Counting from the left
  6943. return [ _fnVisibleToColumnIndex( settings, idx ) ];
  6944. case 'name':
  6945. // match by name. `names` is column index complete and in order
  6946. return $.map( names, function (name, i) {
  6947. return name === match[1] ? i : null;
  6948. } );
  6949. }
  6950. }
  6951. else {
  6952. // jQuery selector on the TH elements for the columns
  6953. return $( nodes )
  6954. .filter( s )
  6955. .map( function () {
  6956. return $.inArray( this, nodes ); // `nodes` is column index complete and in order
  6957. } )
  6958. .toArray();
  6959. }
  6960. } );
  6961. };
  6962. var __setColumnVis = function ( settings, column, vis, recalc ) {
  6963. var
  6964. cols = settings.aoColumns,
  6965. col = cols[ column ],
  6966. data = settings.aoData,
  6967. row, cells, i, ien, tr;
  6968. // Get
  6969. if ( vis === undefined ) {
  6970. return col.bVisible;
  6971. }
  6972. // Set
  6973. // No change
  6974. if ( col.bVisible === vis ) {
  6975. return;
  6976. }
  6977. if ( vis ) {
  6978. // Insert column
  6979. // Need to decide if we should use appendChild or insertBefore
  6980. var insertBefore = $.inArray( true, _pluck(cols, 'bVisible'), column+1 );
  6981. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  6982. tr = data[i].nTr;
  6983. cells = data[i].anCells;
  6984. if ( tr ) {
  6985. // insertBefore can act like appendChild if 2nd arg is null
  6986. tr.insertBefore( cells[ column ], cells[ insertBefore ] || null );
  6987. }
  6988. }
  6989. }
  6990. else {
  6991. // Remove column
  6992. $( _pluck( settings.aoData, 'anCells', column ) ).detach();
  6993. }
  6994. // Common actions
  6995. col.bVisible = vis;
  6996. _fnDrawHead( settings, settings.aoHeader );
  6997. _fnDrawHead( settings, settings.aoFooter );
  6998. if ( recalc === undefined || recalc ) {
  6999. // Automatically adjust column sizing
  7000. _fnAdjustColumnSizing( settings );
  7001. // Realign columns for scrolling
  7002. if ( settings.oScroll.sX || settings.oScroll.sY ) {
  7003. _fnScrollDraw( settings );
  7004. }
  7005. }
  7006. _fnCallbackFire( settings, null, 'column-visibility', [settings, column, vis] );
  7007. _fnSaveState( settings );
  7008. };
  7009. /**
  7010. *
  7011. */
  7012. _api_register( 'columns()', function ( selector, opts ) {
  7013. // argument shifting
  7014. if ( selector === undefined ) {
  7015. selector = '';
  7016. }
  7017. else if ( $.isPlainObject( selector ) ) {
  7018. opts = selector;
  7019. selector = '';
  7020. }
  7021. opts = _selector_opts( opts );
  7022. var inst = this.iterator( 'table', function ( settings ) {
  7023. return __column_selector( settings, selector, opts );
  7024. }, 1 );
  7025. // Want argument shifting here and in _row_selector?
  7026. inst.selector.cols = selector;
  7027. inst.selector.opts = opts;
  7028. return inst;
  7029. } );
  7030. /**
  7031. *
  7032. */
  7033. _api_registerPlural( 'columns().header()', 'column().header()', function ( selector, opts ) {
  7034. return this.iterator( 'column', function ( settings, column ) {
  7035. return settings.aoColumns[column].nTh;
  7036. }, 1 );
  7037. } );
  7038. /**
  7039. *
  7040. */
  7041. _api_registerPlural( 'columns().footer()', 'column().footer()', function ( selector, opts ) {
  7042. return this.iterator( 'column', function ( settings, column ) {
  7043. return settings.aoColumns[column].nTf;
  7044. }, 1 );
  7045. } );
  7046. /**
  7047. *
  7048. */
  7049. _api_registerPlural( 'columns().data()', 'column().data()', function () {
  7050. return this.iterator( 'column-rows', __columnData, 1 );
  7051. } );
  7052. _api_registerPlural( 'columns().dataSrc()', 'column().dataSrc()', function () {
  7053. return this.iterator( 'column', function ( settings, column ) {
  7054. return settings.aoColumns[column].mData;
  7055. }, 1 );
  7056. } );
  7057. _api_registerPlural( 'columns().cache()', 'column().cache()', function ( type ) {
  7058. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7059. return _pluck_order( settings.aoData, rows,
  7060. type === 'search' ? '_aFilterData' : '_aSortData', column
  7061. );
  7062. }, 1 );
  7063. } );
  7064. _api_registerPlural( 'columns().nodes()', 'column().nodes()', function () {
  7065. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7066. return _pluck_order( settings.aoData, rows, 'anCells', column ) ;
  7067. }, 1 );
  7068. } );
  7069. _api_registerPlural( 'columns().visible()', 'column().visible()', function ( vis, calc ) {
  7070. return this.iterator( 'column', function ( settings, column ) {
  7071. if ( vis === undefined ) {
  7072. return settings.aoColumns[ column ].bVisible;
  7073. } // else
  7074. __setColumnVis( settings, column, vis, calc );
  7075. } );
  7076. } );
  7077. _api_registerPlural( 'columns().indexes()', 'column().index()', function ( type ) {
  7078. return this.iterator( 'column', function ( settings, column ) {
  7079. return type === 'visible' ?
  7080. _fnColumnIndexToVisible( settings, column ) :
  7081. column;
  7082. }, 1 );
  7083. } );
  7084. // _api_register( 'columns().show()', function () {
  7085. // var selector = this.selector;
  7086. // return this.columns( selector.cols, selector.opts ).visible( true );
  7087. // } );
  7088. // _api_register( 'columns().hide()', function () {
  7089. // var selector = this.selector;
  7090. // return this.columns( selector.cols, selector.opts ).visible( false );
  7091. // } );
  7092. _api_register( 'columns.adjust()', function () {
  7093. return this.iterator( 'table', function ( settings ) {
  7094. _fnAdjustColumnSizing( settings );
  7095. }, 1 );
  7096. } );
  7097. // Convert from one column index type, to another type
  7098. _api_register( 'column.index()', function ( type, idx ) {
  7099. if ( this.context.length !== 0 ) {
  7100. var ctx = this.context[0];
  7101. if ( type === 'fromVisible' || type === 'toData' ) {
  7102. return _fnVisibleToColumnIndex( ctx, idx );
  7103. }
  7104. else if ( type === 'fromData' || type === 'toVisible' ) {
  7105. return _fnColumnIndexToVisible( ctx, idx );
  7106. }
  7107. }
  7108. } );
  7109. _api_register( 'column()', function ( selector, opts ) {
  7110. return _selector_first( this.columns( selector, opts ) );
  7111. } );
  7112. var __cell_selector = function ( settings, selector, opts )
  7113. {
  7114. var data = settings.aoData;
  7115. var rows = _selector_row_indexes( settings, opts );
  7116. var cells = _removeEmpty( _pluck_order( data, rows, 'anCells' ) );
  7117. var allCells = $( [].concat.apply([], cells) );
  7118. var row;
  7119. var columns = settings.aoColumns.length;
  7120. var a, i, ien, j, o, host;
  7121. return _selector_run( selector, function ( s ) {
  7122. var fnSelector = typeof s === 'function';
  7123. if ( s === null || s === undefined || fnSelector ) {
  7124. // All cells and function selectors
  7125. a = [];
  7126. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  7127. row = rows[i];
  7128. for ( j=0 ; j<columns ; j++ ) {
  7129. o = {
  7130. row: row,
  7131. column: j
  7132. };
  7133. if ( fnSelector ) {
  7134. // Selector - function
  7135. host = settings.aoData[ row ];
  7136. if ( s( o, _fnGetCellData(settings, row, j), host.anCells[j] ) ) {
  7137. a.push( o );
  7138. }
  7139. }
  7140. else {
  7141. // Selector - all
  7142. a.push( o );
  7143. }
  7144. }
  7145. }
  7146. return a;
  7147. }
  7148. // Selector - index
  7149. if ( $.isPlainObject( s ) ) {
  7150. return [s];
  7151. }
  7152. // Selector - jQuery filtered cells
  7153. return allCells
  7154. .filter( s )
  7155. .map( function (i, el) {
  7156. row = el.parentNode._DT_RowIndex;
  7157. return {
  7158. row: row,
  7159. column: $.inArray( el, data[ row ].anCells )
  7160. };
  7161. } )
  7162. .toArray();
  7163. } );
  7164. };
  7165. _api_register( 'cells()', function ( rowSelector, columnSelector, opts ) {
  7166. // Argument shifting
  7167. if ( $.isPlainObject( rowSelector ) ) {
  7168. // Indexes
  7169. if ( typeof rowSelector.row !== undefined ) {
  7170. opts = columnSelector;
  7171. columnSelector = null;
  7172. }
  7173. else {
  7174. opts = rowSelector;
  7175. rowSelector = null;
  7176. }
  7177. }
  7178. if ( $.isPlainObject( columnSelector ) ) {
  7179. opts = columnSelector;
  7180. columnSelector = null;
  7181. }
  7182. // Cell selector
  7183. if ( columnSelector === null || columnSelector === undefined ) {
  7184. return this.iterator( 'table', function ( settings ) {
  7185. return __cell_selector( settings, rowSelector, _selector_opts( opts ) );
  7186. } );
  7187. }
  7188. // Row + column selector
  7189. var columns = this.columns( columnSelector, opts );
  7190. var rows = this.rows( rowSelector, opts );
  7191. var a, i, ien, j, jen;
  7192. var cells = this.iterator( 'table', function ( settings, idx ) {
  7193. a = [];
  7194. for ( i=0, ien=rows[idx].length ; i<ien ; i++ ) {
  7195. for ( j=0, jen=columns[idx].length ; j<jen ; j++ ) {
  7196. a.push( {
  7197. row: rows[idx][i],
  7198. column: columns[idx][j]
  7199. } );
  7200. }
  7201. }
  7202. return a;
  7203. }, 1 );
  7204. $.extend( cells.selector, {
  7205. cols: columnSelector,
  7206. rows: rowSelector,
  7207. opts: opts
  7208. } );
  7209. return cells;
  7210. } );
  7211. _api_registerPlural( 'cells().nodes()', 'cell().node()', function () {
  7212. return this.iterator( 'cell', function ( settings, row, column ) {
  7213. var cells = settings.aoData[ row ].anCells;
  7214. return cells ?
  7215. cells[ column ] :
  7216. undefined;
  7217. }, 1 );
  7218. } );
  7219. _api_register( 'cells().data()', function () {
  7220. return this.iterator( 'cell', function ( settings, row, column ) {
  7221. return _fnGetCellData( settings, row, column );
  7222. }, 1 );
  7223. } );
  7224. _api_registerPlural( 'cells().cache()', 'cell().cache()', function ( type ) {
  7225. type = type === 'search' ? '_aFilterData' : '_aSortData';
  7226. return this.iterator( 'cell', function ( settings, row, column ) {
  7227. return settings.aoData[ row ][ type ][ column ];
  7228. }, 1 );
  7229. } );
  7230. _api_registerPlural( 'cells().render()', 'cell().render()', function ( type ) {
  7231. return this.iterator( 'cell', function ( settings, row, column ) {
  7232. return _fnGetCellData( settings, row, column, type );
  7233. }, 1 );
  7234. } );
  7235. _api_registerPlural( 'cells().indexes()', 'cell().index()', function () {
  7236. return this.iterator( 'cell', function ( settings, row, column ) {
  7237. return {
  7238. row: row,
  7239. column: column,
  7240. columnVisible: _fnColumnIndexToVisible( settings, column )
  7241. };
  7242. }, 1 );
  7243. } );
  7244. _api_registerPlural( 'cells().invalidate()', 'cell().invalidate()', function ( src ) {
  7245. return this.iterator( 'cell', function ( settings, row, column ) {
  7246. _fnInvalidate( settings, row, src, column );
  7247. } );
  7248. } );
  7249. _api_register( 'cell()', function ( rowSelector, columnSelector, opts ) {
  7250. return _selector_first( this.cells( rowSelector, columnSelector, opts ) );
  7251. } );
  7252. _api_register( 'cell().data()', function ( data ) {
  7253. var ctx = this.context;
  7254. var cell = this[0];
  7255. if ( data === undefined ) {
  7256. // Get
  7257. return ctx.length && cell.length ?
  7258. _fnGetCellData( ctx[0], cell[0].row, cell[0].column ) :
  7259. undefined;
  7260. }
  7261. // Set
  7262. _fnSetCellData( ctx[0], cell[0].row, cell[0].column, data );
  7263. _fnInvalidate( ctx[0], cell[0].row, 'data', cell[0].column );
  7264. return this;
  7265. } );
  7266. /**
  7267. * Get current ordering (sorting) that has been applied to the table.
  7268. *
  7269. * @returns {array} 2D array containing the sorting information for the first
  7270. * table in the current context. Each element in the parent array represents
  7271. * a column being sorted upon (i.e. multi-sorting with two columns would have
  7272. * 2 inner arrays). The inner arrays may have 2 or 3 elements. The first is
  7273. * the column index that the sorting condition applies to, the second is the
  7274. * direction of the sort (`desc` or `asc`) and, optionally, the third is the
  7275. * index of the sorting order from the `column.sorting` initialisation array.
  7276. *//**
  7277. * Set the ordering for the table.
  7278. *
  7279. * @param {integer} order Column index to sort upon.
  7280. * @param {string} direction Direction of the sort to be applied (`asc` or `desc`)
  7281. * @returns {DataTables.Api} this
  7282. *//**
  7283. * Set the ordering for the table.
  7284. *
  7285. * @param {array} order 1D array of sorting information to be applied.
  7286. * @param {array} [...] Optional additional sorting conditions
  7287. * @returns {DataTables.Api} this
  7288. *//**
  7289. * Set the ordering for the table.
  7290. *
  7291. * @param {array} order 2D array of sorting information to be applied.
  7292. * @returns {DataTables.Api} this
  7293. */
  7294. _api_register( 'order()', function ( order, dir ) {
  7295. var ctx = this.context;
  7296. if ( order === undefined ) {
  7297. // get
  7298. return ctx.length !== 0 ?
  7299. ctx[0].aaSorting :
  7300. undefined;
  7301. }
  7302. // set
  7303. if ( typeof order === 'number' ) {
  7304. // Simple column / direction passed in
  7305. order = [ [ order, dir ] ];
  7306. }
  7307. else if ( ! $.isArray( order[0] ) ) {
  7308. // Arguments passed in (list of 1D arrays)
  7309. order = Array.prototype.slice.call( arguments );
  7310. }
  7311. // otherwise a 2D array was passed in
  7312. return this.iterator( 'table', function ( settings ) {
  7313. settings.aaSorting = order.slice();
  7314. } );
  7315. } );
  7316. /**
  7317. * Attach a sort listener to an element for a given column
  7318. *
  7319. * @param {node|jQuery|string} node Identifier for the element(s) to attach the
  7320. * listener to. This can take the form of a single DOM node, a jQuery
  7321. * collection of nodes or a jQuery selector which will identify the node(s).
  7322. * @param {integer} column the column that a click on this node will sort on
  7323. * @param {function} [callback] callback function when sort is run
  7324. * @returns {DataTables.Api} this
  7325. */
  7326. _api_register( 'order.listener()', function ( node, column, callback ) {
  7327. return this.iterator( 'table', function ( settings ) {
  7328. _fnSortAttachListener( settings, node, column, callback );
  7329. } );
  7330. } );
  7331. // Order by the selected column(s)
  7332. _api_register( [
  7333. 'columns().order()',
  7334. 'column().order()'
  7335. ], function ( dir ) {
  7336. var that = this;
  7337. return this.iterator( 'table', function ( settings, i ) {
  7338. var sort = [];
  7339. $.each( that[i], function (j, col) {
  7340. sort.push( [ col, dir ] );
  7341. } );
  7342. settings.aaSorting = sort;
  7343. } );
  7344. } );
  7345. _api_register( 'search()', function ( input, regex, smart, caseInsen ) {
  7346. var ctx = this.context;
  7347. if ( input === undefined ) {
  7348. // get
  7349. return ctx.length !== 0 ?
  7350. ctx[0].oPreviousSearch.sSearch :
  7351. undefined;
  7352. }
  7353. // set
  7354. return this.iterator( 'table', function ( settings ) {
  7355. if ( ! settings.oFeatures.bFilter ) {
  7356. return;
  7357. }
  7358. _fnFilterComplete( settings, $.extend( {}, settings.oPreviousSearch, {
  7359. "sSearch": input+"",
  7360. "bRegex": regex === null ? false : regex,
  7361. "bSmart": smart === null ? true : smart,
  7362. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7363. } ), 1 );
  7364. } );
  7365. } );
  7366. _api_registerPlural(
  7367. 'columns().search()',
  7368. 'column().search()',
  7369. function ( input, regex, smart, caseInsen ) {
  7370. return this.iterator( 'column', function ( settings, column ) {
  7371. var preSearch = settings.aoPreSearchCols;
  7372. if ( input === undefined ) {
  7373. // get
  7374. return preSearch[ column ].sSearch;
  7375. }
  7376. // set
  7377. if ( ! settings.oFeatures.bFilter ) {
  7378. return;
  7379. }
  7380. $.extend( preSearch[ column ], {
  7381. "sSearch": input+"",
  7382. "bRegex": regex === null ? false : regex,
  7383. "bSmart": smart === null ? true : smart,
  7384. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7385. } );
  7386. _fnFilterComplete( settings, settings.oPreviousSearch, 1 );
  7387. } );
  7388. }
  7389. );
  7390. /*
  7391. * State API methods
  7392. */
  7393. _api_register( 'state()', function () {
  7394. return this.context.length ?
  7395. this.context[0].oSavedState :
  7396. null;
  7397. } );
  7398. _api_register( 'state.clear()', function () {
  7399. return this.iterator( 'table', function ( settings ) {
  7400. // Save an empty object
  7401. settings.fnStateSaveCallback.call( settings.oInstance, settings, {} );
  7402. } );
  7403. } );
  7404. _api_register( 'state.loaded()', function () {
  7405. return this.context.length ?
  7406. this.context[0].oLoadedState :
  7407. null;
  7408. } );
  7409. _api_register( 'state.save()', function () {
  7410. return this.iterator( 'table', function ( settings ) {
  7411. _fnSaveState( settings );
  7412. } );
  7413. } );
  7414. /**
  7415. * Provide a common method for plug-ins to check the version of DataTables being
  7416. * used, in order to ensure compatibility.
  7417. *
  7418. * @param {string} version Version string to check for, in the format "X.Y.Z".
  7419. * Note that the formats "X" and "X.Y" are also acceptable.
  7420. * @returns {boolean} true if this version of DataTables is greater or equal to
  7421. * the required version, or false if this version of DataTales is not
  7422. * suitable
  7423. * @static
  7424. * @dtopt API-Static
  7425. *
  7426. * @example
  7427. * alert( $.fn.dataTable.versionCheck( '1.9.0' ) );
  7428. */
  7429. DataTable.versionCheck = DataTable.fnVersionCheck = function( version )
  7430. {
  7431. var aThis = DataTable.version.split('.');
  7432. var aThat = version.split('.');
  7433. var iThis, iThat;
  7434. for ( var i=0, iLen=aThat.length ; i<iLen ; i++ ) {
  7435. iThis = parseInt( aThis[i], 10 ) || 0;
  7436. iThat = parseInt( aThat[i], 10 ) || 0;
  7437. // Parts are the same, keep comparing
  7438. if (iThis === iThat) {
  7439. continue;
  7440. }
  7441. // Parts are different, return immediately
  7442. return iThis > iThat;
  7443. }
  7444. return true;
  7445. };
  7446. /**
  7447. * Check if a `<table>` node is a DataTable table already or not.
  7448. *
  7449. * @param {node|jquery|string} table Table node, jQuery object or jQuery
  7450. * selector for the table to test. Note that if more than more than one
  7451. * table is passed on, only the first will be checked
  7452. * @returns {boolean} true the table given is a DataTable, or false otherwise
  7453. * @static
  7454. * @dtopt API-Static
  7455. *
  7456. * @example
  7457. * if ( ! $.fn.DataTable.isDataTable( '#example' ) ) {
  7458. * $('#example').dataTable();
  7459. * }
  7460. */
  7461. DataTable.isDataTable = DataTable.fnIsDataTable = function ( table )
  7462. {
  7463. var t = $(table).get(0);
  7464. var is = false;
  7465. $.each( DataTable.settings, function (i, o) {
  7466. if ( o.nTable === t || o.nScrollHead === t || o.nScrollFoot === t ) {
  7467. is = true;
  7468. }
  7469. } );
  7470. return is;
  7471. };
  7472. /**
  7473. * Get all DataTable tables that have been initialised - optionally you can
  7474. * select to get only currently visible tables.
  7475. *
  7476. * @param {boolean} [visible=false] Flag to indicate if you want all (default)
  7477. * or visible tables only.
  7478. * @returns {array} Array of `table` nodes (not DataTable instances) which are
  7479. * DataTables
  7480. * @static
  7481. * @dtopt API-Static
  7482. *
  7483. * @example
  7484. * $.each( $.fn.dataTable.tables(true), function () {
  7485. * $(table).DataTable().columns.adjust();
  7486. * } );
  7487. */
  7488. DataTable.tables = DataTable.fnTables = function ( visible )
  7489. {
  7490. return $.map( DataTable.settings, function (o) {
  7491. if ( !visible || (visible && $(o.nTable).is(':visible')) ) {
  7492. return o.nTable;
  7493. }
  7494. } );
  7495. };
  7496. /**
  7497. * DataTables utility methods
  7498. *
  7499. * This namespace provides helper methods that DataTables uses internally to
  7500. * create a DataTable, but which are not exclusively used only for DataTables.
  7501. * These methods can be used by extension authors to save the duplication of
  7502. * code.
  7503. *
  7504. * @namespace
  7505. */
  7506. DataTable.util = {
  7507. /**
  7508. * Throttle the calls to a function. Arguments and context are maintained
  7509. * for the throttled function.
  7510. *
  7511. * @param {function} fn Function to be called
  7512. * @param {integer} freq Call frequency in mS
  7513. * @return {function} Wrapped function
  7514. */
  7515. throttle: _fnThrottle,
  7516. /**
  7517. * Escape a string such that it can be used in a regular expression
  7518. *
  7519. * @param {string} sVal string to escape
  7520. * @returns {string} escaped string
  7521. */
  7522. escapeRegex: _fnEscapeRegex
  7523. };
  7524. /**
  7525. * Convert from camel case parameters to Hungarian notation. This is made public
  7526. * for the extensions to provide the same ability as DataTables core to accept
  7527. * either the 1.9 style Hungarian notation, or the 1.10+ style camelCase
  7528. * parameters.
  7529. *
  7530. * @param {object} src The model object which holds all parameters that can be
  7531. * mapped.
  7532. * @param {object} user The object to convert from camel case to Hungarian.
  7533. * @param {boolean} force When set to `true`, properties which already have a
  7534. * Hungarian value in the `user` object will be overwritten. Otherwise they
  7535. * won't be.
  7536. */
  7537. DataTable.camelToHungarian = _fnCamelToHungarian;
  7538. /**
  7539. *
  7540. */
  7541. _api_register( '$()', function ( selector, opts ) {
  7542. var
  7543. rows = this.rows( opts ).nodes(), // Get all rows
  7544. jqRows = $(rows);
  7545. return $( [].concat(
  7546. jqRows.filter( selector ).toArray(),
  7547. jqRows.find( selector ).toArray()
  7548. ) );
  7549. } );
  7550. // jQuery functions to operate on the tables
  7551. $.each( [ 'on', 'one', 'off' ], function (i, key) {
  7552. _api_register( key+'()', function ( /* event, handler */ ) {
  7553. var args = Array.prototype.slice.call(arguments);
  7554. // Add the `dt` namespace automatically if it isn't already present
  7555. if ( ! args[0].match(/\.dt\b/) ) {
  7556. args[0] += '.dt';
  7557. }
  7558. var inst = $( this.tables().nodes() );
  7559. inst[key].apply( inst, args );
  7560. return this;
  7561. } );
  7562. } );
  7563. _api_register( 'clear()', function () {
  7564. return this.iterator( 'table', function ( settings ) {
  7565. _fnClearTable( settings );
  7566. } );
  7567. } );
  7568. _api_register( 'settings()', function () {
  7569. return new _Api( this.context, this.context );
  7570. } );
  7571. _api_register( 'data()', function () {
  7572. return this.iterator( 'table', function ( settings ) {
  7573. return _pluck( settings.aoData, '_aData' );
  7574. } ).flatten();
  7575. } );
  7576. _api_register( 'destroy()', function ( remove ) {
  7577. remove = remove || false;
  7578. return this.iterator( 'table', function ( settings ) {
  7579. var orig = settings.nTableWrapper.parentNode;
  7580. var classes = settings.oClasses;
  7581. var table = settings.nTable;
  7582. var tbody = settings.nTBody;
  7583. var thead = settings.nTHead;
  7584. var tfoot = settings.nTFoot;
  7585. var jqTable = $(table);
  7586. var jqTbody = $(tbody);
  7587. var jqWrapper = $(settings.nTableWrapper);
  7588. var rows = $.map( settings.aoData, function (r) { return r.nTr; } );
  7589. var i, ien;
  7590. // Flag to note that the table is currently being destroyed - no action
  7591. // should be taken
  7592. settings.bDestroying = true;
  7593. // Fire off the destroy callbacks for plug-ins etc
  7594. _fnCallbackFire( settings, "aoDestroyCallback", "destroy", [settings] );
  7595. // If not being removed from the document, make all columns visible
  7596. if ( ! remove ) {
  7597. new _Api( settings ).columns().visible( true );
  7598. }
  7599. // Blitz all `DT` namespaced events (these are internal events, the
  7600. // lowercase, `dt` events are user subscribed and they are responsible
  7601. // for removing them
  7602. jqWrapper.unbind('.DT').find(':not(tbody *)').unbind('.DT');
  7603. $(window).unbind('.DT-'+settings.sInstance);
  7604. // When scrolling we had to break the table up - restore it
  7605. if ( table != thead.parentNode ) {
  7606. jqTable.children('thead').detach();
  7607. jqTable.append( thead );
  7608. }
  7609. if ( tfoot && table != tfoot.parentNode ) {
  7610. jqTable.children('tfoot').detach();
  7611. jqTable.append( tfoot );
  7612. }
  7613. // Remove the DataTables generated nodes, events and classes
  7614. jqTable.detach();
  7615. jqWrapper.detach();
  7616. settings.aaSorting = [];
  7617. settings.aaSortingFixed = [];
  7618. _fnSortingClasses( settings );
  7619. $( rows ).removeClass( settings.asStripeClasses.join(' ') );
  7620. $('th, td', thead).removeClass( classes.sSortable+' '+
  7621. classes.sSortableAsc+' '+classes.sSortableDesc+' '+classes.sSortableNone
  7622. );
  7623. if ( settings.bJUI ) {
  7624. $('th span.'+classes.sSortIcon+ ', td span.'+classes.sSortIcon, thead).detach();
  7625. $('th, td', thead).each( function () {
  7626. var wrapper = $('div.'+classes.sSortJUIWrapper, this);
  7627. $(this).append( wrapper.contents() );
  7628. wrapper.detach();
  7629. } );
  7630. }
  7631. if ( ! remove && orig ) {
  7632. // insertBefore acts like appendChild if !arg[1]
  7633. orig.insertBefore( table, settings.nTableReinsertBefore );
  7634. }
  7635. // Add the TR elements back into the table in their original order
  7636. jqTbody.children().detach();
  7637. jqTbody.append( rows );
  7638. // Restore the width of the original table - was read from the style property,
  7639. // so we can restore directly to that
  7640. jqTable
  7641. .css( 'width', settings.sDestroyWidth )
  7642. .removeClass( classes.sTable );
  7643. // If the were originally stripe classes - then we add them back here.
  7644. // Note this is not fool proof (for example if not all rows had stripe
  7645. // classes - but it's a good effort without getting carried away
  7646. ien = settings.asDestroyStripes.length;
  7647. if ( ien ) {
  7648. jqTbody.children().each( function (i) {
  7649. $(this).addClass( settings.asDestroyStripes[i % ien] );
  7650. } );
  7651. }
  7652. /* Remove the settings object from the settings array */
  7653. var idx = $.inArray( settings, DataTable.settings );
  7654. if ( idx !== -1 ) {
  7655. DataTable.settings.splice( idx, 1 );
  7656. }
  7657. } );
  7658. } );
  7659. /**
  7660. * Version string for plug-ins to check compatibility. Allowed format is
  7661. * `a.b.c-d` where: a:int, b:int, c:int, d:string(dev|beta|alpha). `d` is used
  7662. * only for non-release builds. See http://semver.org/ for more information.
  7663. * @member
  7664. * @type string
  7665. * @default Version number
  7666. */
  7667. DataTable.version = "1.10.4";
  7668. /**
  7669. * Private data store, containing all of the settings objects that are
  7670. * created for the tables on a given page.
  7671. *
  7672. * Note that the `DataTable.settings` object is aliased to
  7673. * `jQuery.fn.dataTableExt` through which it may be accessed and
  7674. * manipulated, or `jQuery.fn.dataTable.settings`.
  7675. * @member
  7676. * @type array
  7677. * @default []
  7678. * @private
  7679. */
  7680. DataTable.settings = [];
  7681. /**
  7682. * Object models container, for the various models that DataTables has
  7683. * available to it. These models define the objects that are used to hold
  7684. * the active state and configuration of the table.
  7685. * @namespace
  7686. */
  7687. DataTable.models = {};
  7688. /**
  7689. * Template object for the way in which DataTables holds information about
  7690. * search information for the global filter and individual column filters.
  7691. * @namespace
  7692. */
  7693. DataTable.models.oSearch = {
  7694. /**
  7695. * Flag to indicate if the filtering should be case insensitive or not
  7696. * @type boolean
  7697. * @default true
  7698. */
  7699. "bCaseInsensitive": true,
  7700. /**
  7701. * Applied search term
  7702. * @type string
  7703. * @default <i>Empty string</i>
  7704. */
  7705. "sSearch": "",
  7706. /**
  7707. * Flag to indicate if the search term should be interpreted as a
  7708. * regular expression (true) or not (false) and therefore and special
  7709. * regex characters escaped.
  7710. * @type boolean
  7711. * @default false
  7712. */
  7713. "bRegex": false,
  7714. /**
  7715. * Flag to indicate if DataTables is to use its smart filtering or not.
  7716. * @type boolean
  7717. * @default true
  7718. */
  7719. "bSmart": true
  7720. };
  7721. /**
  7722. * Template object for the way in which DataTables holds information about
  7723. * each individual row. This is the object format used for the settings
  7724. * aoData array.
  7725. * @namespace
  7726. */
  7727. DataTable.models.oRow = {
  7728. /**
  7729. * TR element for the row
  7730. * @type node
  7731. * @default null
  7732. */
  7733. "nTr": null,
  7734. /**
  7735. * Array of TD elements for each row. This is null until the row has been
  7736. * created.
  7737. * @type array nodes
  7738. * @default []
  7739. */
  7740. "anCells": null,
  7741. /**
  7742. * Data object from the original data source for the row. This is either
  7743. * an array if using the traditional form of DataTables, or an object if
  7744. * using mData options. The exact type will depend on the passed in
  7745. * data from the data source, or will be an array if using DOM a data
  7746. * source.
  7747. * @type array|object
  7748. * @default []
  7749. */
  7750. "_aData": [],
  7751. /**
  7752. * Sorting data cache - this array is ostensibly the same length as the
  7753. * number of columns (although each index is generated only as it is
  7754. * needed), and holds the data that is used for sorting each column in the
  7755. * row. We do this cache generation at the start of the sort in order that
  7756. * the formatting of the sort data need be done only once for each cell
  7757. * per sort. This array should not be read from or written to by anything
  7758. * other than the master sorting methods.
  7759. * @type array
  7760. * @default null
  7761. * @private
  7762. */
  7763. "_aSortData": null,
  7764. /**
  7765. * Per cell filtering data cache. As per the sort data cache, used to
  7766. * increase the performance of the filtering in DataTables
  7767. * @type array
  7768. * @default null
  7769. * @private
  7770. */
  7771. "_aFilterData": null,
  7772. /**
  7773. * Filtering data cache. This is the same as the cell filtering cache, but
  7774. * in this case a string rather than an array. This is easily computed with
  7775. * a join on `_aFilterData`, but is provided as a cache so the join isn't
  7776. * needed on every search (memory traded for performance)
  7777. * @type array
  7778. * @default null
  7779. * @private
  7780. */
  7781. "_sFilterRow": null,
  7782. /**
  7783. * Cache of the class name that DataTables has applied to the row, so we
  7784. * can quickly look at this variable rather than needing to do a DOM check
  7785. * on className for the nTr property.
  7786. * @type string
  7787. * @default <i>Empty string</i>
  7788. * @private
  7789. */
  7790. "_sRowStripe": "",
  7791. /**
  7792. * Denote if the original data source was from the DOM, or the data source
  7793. * object. This is used for invalidating data, so DataTables can
  7794. * automatically read data from the original source, unless uninstructed
  7795. * otherwise.
  7796. * @type string
  7797. * @default null
  7798. * @private
  7799. */
  7800. "src": null
  7801. };
  7802. /**
  7803. * Template object for the column information object in DataTables. This object
  7804. * is held in the settings aoColumns array and contains all the information that
  7805. * DataTables needs about each individual column.
  7806. *
  7807. * Note that this object is related to {@link DataTable.defaults.column}
  7808. * but this one is the internal data store for DataTables's cache of columns.
  7809. * It should NOT be manipulated outside of DataTables. Any configuration should
  7810. * be done through the initialisation options.
  7811. * @namespace
  7812. */
  7813. DataTable.models.oColumn = {
  7814. /**
  7815. * Column index. This could be worked out on-the-fly with $.inArray, but it
  7816. * is faster to just hold it as a variable
  7817. * @type integer
  7818. * @default null
  7819. */
  7820. "idx": null,
  7821. /**
  7822. * A list of the columns that sorting should occur on when this column
  7823. * is sorted. That this property is an array allows multi-column sorting
  7824. * to be defined for a column (for example first name / last name columns
  7825. * would benefit from this). The values are integers pointing to the
  7826. * columns to be sorted on (typically it will be a single integer pointing
  7827. * at itself, but that doesn't need to be the case).
  7828. * @type array
  7829. */
  7830. "aDataSort": null,
  7831. /**
  7832. * Define the sorting directions that are applied to the column, in sequence
  7833. * as the column is repeatedly sorted upon - i.e. the first value is used
  7834. * as the sorting direction when the column if first sorted (clicked on).
  7835. * Sort it again (click again) and it will move on to the next index.
  7836. * Repeat until loop.
  7837. * @type array
  7838. */
  7839. "asSorting": null,
  7840. /**
  7841. * Flag to indicate if the column is searchable, and thus should be included
  7842. * in the filtering or not.
  7843. * @type boolean
  7844. */
  7845. "bSearchable": null,
  7846. /**
  7847. * Flag to indicate if the column is sortable or not.
  7848. * @type boolean
  7849. */
  7850. "bSortable": null,
  7851. /**
  7852. * Flag to indicate if the column is currently visible in the table or not
  7853. * @type boolean
  7854. */
  7855. "bVisible": null,
  7856. /**
  7857. * Store for manual type assignment using the `column.type` option. This
  7858. * is held in store so we can manipulate the column's `sType` property.
  7859. * @type string
  7860. * @default null
  7861. * @private
  7862. */
  7863. "_sManualType": null,
  7864. /**
  7865. * Flag to indicate if HTML5 data attributes should be used as the data
  7866. * source for filtering or sorting. True is either are.
  7867. * @type boolean
  7868. * @default false
  7869. * @private
  7870. */
  7871. "_bAttrSrc": false,
  7872. /**
  7873. * Developer definable function that is called whenever a cell is created (Ajax source,
  7874. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  7875. * allowing you to modify the DOM element (add background colour for example) when the
  7876. * element is available.
  7877. * @type function
  7878. * @param {element} nTd The TD node that has been created
  7879. * @param {*} sData The Data for the cell
  7880. * @param {array|object} oData The data for the whole row
  7881. * @param {int} iRow The row index for the aoData data store
  7882. * @default null
  7883. */
  7884. "fnCreatedCell": null,
  7885. /**
  7886. * Function to get data from a cell in a column. You should <b>never</b>
  7887. * access data directly through _aData internally in DataTables - always use
  7888. * the method attached to this property. It allows mData to function as
  7889. * required. This function is automatically assigned by the column
  7890. * initialisation method
  7891. * @type function
  7892. * @param {array|object} oData The data array/object for the array
  7893. * (i.e. aoData[]._aData)
  7894. * @param {string} sSpecific The specific data type you want to get -
  7895. * 'display', 'type' 'filter' 'sort'
  7896. * @returns {*} The data for the cell from the given row's data
  7897. * @default null
  7898. */
  7899. "fnGetData": null,
  7900. /**
  7901. * Function to set data for a cell in the column. You should <b>never</b>
  7902. * set the data directly to _aData internally in DataTables - always use
  7903. * this method. It allows mData to function as required. This function
  7904. * is automatically assigned by the column initialisation method
  7905. * @type function
  7906. * @param {array|object} oData The data array/object for the array
  7907. * (i.e. aoData[]._aData)
  7908. * @param {*} sValue Value to set
  7909. * @default null
  7910. */
  7911. "fnSetData": null,
  7912. /**
  7913. * Property to read the value for the cells in the column from the data
  7914. * source array / object. If null, then the default content is used, if a
  7915. * function is given then the return from the function is used.
  7916. * @type function|int|string|null
  7917. * @default null
  7918. */
  7919. "mData": null,
  7920. /**
  7921. * Partner property to mData which is used (only when defined) to get
  7922. * the data - i.e. it is basically the same as mData, but without the
  7923. * 'set' option, and also the data fed to it is the result from mData.
  7924. * This is the rendering method to match the data method of mData.
  7925. * @type function|int|string|null
  7926. * @default null
  7927. */
  7928. "mRender": null,
  7929. /**
  7930. * Unique header TH/TD element for this column - this is what the sorting
  7931. * listener is attached to (if sorting is enabled.)
  7932. * @type node
  7933. * @default null
  7934. */
  7935. "nTh": null,
  7936. /**
  7937. * Unique footer TH/TD element for this column (if there is one). Not used
  7938. * in DataTables as such, but can be used for plug-ins to reference the
  7939. * footer for each column.
  7940. * @type node
  7941. * @default null
  7942. */
  7943. "nTf": null,
  7944. /**
  7945. * The class to apply to all TD elements in the table's TBODY for the column
  7946. * @type string
  7947. * @default null
  7948. */
  7949. "sClass": null,
  7950. /**
  7951. * When DataTables calculates the column widths to assign to each column,
  7952. * it finds the longest string in each column and then constructs a
  7953. * temporary table and reads the widths from that. The problem with this
  7954. * is that "mmm" is much wider then "iiii", but the latter is a longer
  7955. * string - thus the calculation can go wrong (doing it properly and putting
  7956. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  7957. * a "work around" we provide this option. It will append its value to the
  7958. * text that is found to be the longest string for the column - i.e. padding.
  7959. * @type string
  7960. */
  7961. "sContentPadding": null,
  7962. /**
  7963. * Allows a default value to be given for a column's data, and will be used
  7964. * whenever a null data source is encountered (this can be because mData
  7965. * is set to null, or because the data source itself is null).
  7966. * @type string
  7967. * @default null
  7968. */
  7969. "sDefaultContent": null,
  7970. /**
  7971. * Name for the column, allowing reference to the column by name as well as
  7972. * by index (needs a lookup to work by name).
  7973. * @type string
  7974. */
  7975. "sName": null,
  7976. /**
  7977. * Custom sorting data type - defines which of the available plug-ins in
  7978. * afnSortData the custom sorting will use - if any is defined.
  7979. * @type string
  7980. * @default std
  7981. */
  7982. "sSortDataType": 'std',
  7983. /**
  7984. * Class to be applied to the header element when sorting on this column
  7985. * @type string
  7986. * @default null
  7987. */
  7988. "sSortingClass": null,
  7989. /**
  7990. * Class to be applied to the header element when sorting on this column -
  7991. * when jQuery UI theming is used.
  7992. * @type string
  7993. * @default null
  7994. */
  7995. "sSortingClassJUI": null,
  7996. /**
  7997. * Title of the column - what is seen in the TH element (nTh).
  7998. * @type string
  7999. */
  8000. "sTitle": null,
  8001. /**
  8002. * Column sorting and filtering type
  8003. * @type string
  8004. * @default null
  8005. */
  8006. "sType": null,
  8007. /**
  8008. * Width of the column
  8009. * @type string
  8010. * @default null
  8011. */
  8012. "sWidth": null,
  8013. /**
  8014. * Width of the column when it was first "encountered"
  8015. * @type string
  8016. * @default null
  8017. */
  8018. "sWidthOrig": null
  8019. };
  8020. /*
  8021. * Developer note: The properties of the object below are given in Hungarian
  8022. * notation, that was used as the interface for DataTables prior to v1.10, however
  8023. * from v1.10 onwards the primary interface is camel case. In order to avoid
  8024. * breaking backwards compatibility utterly with this change, the Hungarian
  8025. * version is still, internally the primary interface, but is is not documented
  8026. * - hence the @name tags in each doc comment. This allows a Javascript function
  8027. * to create a map from Hungarian notation to camel case (going the other direction
  8028. * would require each property to be listed, which would at around 3K to the size
  8029. * of DataTables, while this method is about a 0.5K hit.
  8030. *
  8031. * Ultimately this does pave the way for Hungarian notation to be dropped
  8032. * completely, but that is a massive amount of work and will break current
  8033. * installs (therefore is on-hold until v2).
  8034. */
  8035. /**
  8036. * Initialisation options that can be given to DataTables at initialisation
  8037. * time.
  8038. * @namespace
  8039. */
  8040. DataTable.defaults = {
  8041. /**
  8042. * An array of data to use for the table, passed in at initialisation which
  8043. * will be used in preference to any data which is already in the DOM. This is
  8044. * particularly useful for constructing tables purely in Javascript, for
  8045. * example with a custom Ajax call.
  8046. * @type array
  8047. * @default null
  8048. *
  8049. * @dtopt Option
  8050. * @name DataTable.defaults.data
  8051. *
  8052. * @example
  8053. * // Using a 2D array data source
  8054. * $(document).ready( function () {
  8055. * $('#example').dataTable( {
  8056. * "data": [
  8057. * ['Trident', 'Internet Explorer 4.0', 'Win 95+', 4, 'X'],
  8058. * ['Trident', 'Internet Explorer 5.0', 'Win 95+', 5, 'C'],
  8059. * ],
  8060. * "columns": [
  8061. * { "title": "Engine" },
  8062. * { "title": "Browser" },
  8063. * { "title": "Platform" },
  8064. * { "title": "Version" },
  8065. * { "title": "Grade" }
  8066. * ]
  8067. * } );
  8068. * } );
  8069. *
  8070. * @example
  8071. * // Using an array of objects as a data source (`data`)
  8072. * $(document).ready( function () {
  8073. * $('#example').dataTable( {
  8074. * "data": [
  8075. * {
  8076. * "engine": "Trident",
  8077. * "browser": "Internet Explorer 4.0",
  8078. * "platform": "Win 95+",
  8079. * "version": 4,
  8080. * "grade": "X"
  8081. * },
  8082. * {
  8083. * "engine": "Trident",
  8084. * "browser": "Internet Explorer 5.0",
  8085. * "platform": "Win 95+",
  8086. * "version": 5,
  8087. * "grade": "C"
  8088. * }
  8089. * ],
  8090. * "columns": [
  8091. * { "title": "Engine", "data": "engine" },
  8092. * { "title": "Browser", "data": "browser" },
  8093. * { "title": "Platform", "data": "platform" },
  8094. * { "title": "Version", "data": "version" },
  8095. * { "title": "Grade", "data": "grade" }
  8096. * ]
  8097. * } );
  8098. * } );
  8099. */
  8100. "aaData": null,
  8101. /**
  8102. * If ordering is enabled, then DataTables will perform a first pass sort on
  8103. * initialisation. You can define which column(s) the sort is performed
  8104. * upon, and the sorting direction, with this variable. The `sorting` array
  8105. * should contain an array for each column to be sorted initially containing
  8106. * the column's index and a direction string ('asc' or 'desc').
  8107. * @type array
  8108. * @default [[0,'asc']]
  8109. *
  8110. * @dtopt Option
  8111. * @name DataTable.defaults.order
  8112. *
  8113. * @example
  8114. * // Sort by 3rd column first, and then 4th column
  8115. * $(document).ready( function() {
  8116. * $('#example').dataTable( {
  8117. * "order": [[2,'asc'], [3,'desc']]
  8118. * } );
  8119. * } );
  8120. *
  8121. * // No initial sorting
  8122. * $(document).ready( function() {
  8123. * $('#example').dataTable( {
  8124. * "order": []
  8125. * } );
  8126. * } );
  8127. */
  8128. "aaSorting": [[0,'asc']],
  8129. /**
  8130. * This parameter is basically identical to the `sorting` parameter, but
  8131. * cannot be overridden by user interaction with the table. What this means
  8132. * is that you could have a column (visible or hidden) which the sorting
  8133. * will always be forced on first - any sorting after that (from the user)
  8134. * will then be performed as required. This can be useful for grouping rows
  8135. * together.
  8136. * @type array
  8137. * @default null
  8138. *
  8139. * @dtopt Option
  8140. * @name DataTable.defaults.orderFixed
  8141. *
  8142. * @example
  8143. * $(document).ready( function() {
  8144. * $('#example').dataTable( {
  8145. * "orderFixed": [[0,'asc']]
  8146. * } );
  8147. * } )
  8148. */
  8149. "aaSortingFixed": [],
  8150. /**
  8151. * DataTables can be instructed to load data to display in the table from a
  8152. * Ajax source. This option defines how that Ajax call is made and where to.
  8153. *
  8154. * The `ajax` property has three different modes of operation, depending on
  8155. * how it is defined. These are:
  8156. *
  8157. * * `string` - Set the URL from where the data should be loaded from.
  8158. * * `object` - Define properties for `jQuery.ajax`.
  8159. * * `function` - Custom data get function
  8160. *
  8161. * `string`
  8162. * --------
  8163. *
  8164. * As a string, the `ajax` property simply defines the URL from which
  8165. * DataTables will load data.
  8166. *
  8167. * `object`
  8168. * --------
  8169. *
  8170. * As an object, the parameters in the object are passed to
  8171. * [jQuery.ajax](http://api.jquery.com/jQuery.ajax/) allowing fine control
  8172. * of the Ajax request. DataTables has a number of default parameters which
  8173. * you can override using this option. Please refer to the jQuery
  8174. * documentation for a full description of the options available, although
  8175. * the following parameters provide additional options in DataTables or
  8176. * require special consideration:
  8177. *
  8178. * * `data` - As with jQuery, `data` can be provided as an object, but it
  8179. * can also be used as a function to manipulate the data DataTables sends
  8180. * to the server. The function takes a single parameter, an object of
  8181. * parameters with the values that DataTables has readied for sending. An
  8182. * object may be returned which will be merged into the DataTables
  8183. * defaults, or you can add the items to the object that was passed in and
  8184. * not return anything from the function. This supersedes `fnServerParams`
  8185. * from DataTables 1.9-.
  8186. *
  8187. * * `dataSrc` - By default DataTables will look for the property `data` (or
  8188. * `aaData` for compatibility with DataTables 1.9-) when obtaining data
  8189. * from an Ajax source or for server-side processing - this parameter
  8190. * allows that property to be changed. You can use Javascript dotted
  8191. * object notation to get a data source for multiple levels of nesting, or
  8192. * it my be used as a function. As a function it takes a single parameter,
  8193. * the JSON returned from the server, which can be manipulated as
  8194. * required, with the returned value being that used by DataTables as the
  8195. * data source for the table. This supersedes `sAjaxDataProp` from
  8196. * DataTables 1.9-.
  8197. *
  8198. * * `success` - Should not be overridden it is used internally in
  8199. * DataTables. To manipulate / transform the data returned by the server
  8200. * use `ajax.dataSrc`, or use `ajax` as a function (see below).
  8201. *
  8202. * `function`
  8203. * ----------
  8204. *
  8205. * As a function, making the Ajax call is left up to yourself allowing
  8206. * complete control of the Ajax request. Indeed, if desired, a method other
  8207. * than Ajax could be used to obtain the required data, such as Web storage
  8208. * or an AIR database.
  8209. *
  8210. * The function is given four parameters and no return is required. The
  8211. * parameters are:
  8212. *
  8213. * 1. _object_ - Data to send to the server
  8214. * 2. _function_ - Callback function that must be executed when the required
  8215. * data has been obtained. That data should be passed into the callback
  8216. * as the only parameter
  8217. * 3. _object_ - DataTables settings object for the table
  8218. *
  8219. * Note that this supersedes `fnServerData` from DataTables 1.9-.
  8220. *
  8221. * @type string|object|function
  8222. * @default null
  8223. *
  8224. * @dtopt Option
  8225. * @name DataTable.defaults.ajax
  8226. * @since 1.10.0
  8227. *
  8228. * @example
  8229. * // Get JSON data from a file via Ajax.
  8230. * // Note DataTables expects data in the form `{ data: [ ...data... ] }` by default).
  8231. * $('#example').dataTable( {
  8232. * "ajax": "data.json"
  8233. * } );
  8234. *
  8235. * @example
  8236. * // Get JSON data from a file via Ajax, using `dataSrc` to change
  8237. * // `data` to `tableData` (i.e. `{ tableData: [ ...data... ] }`)
  8238. * $('#example').dataTable( {
  8239. * "ajax": {
  8240. * "url": "data.json",
  8241. * "dataSrc": "tableData"
  8242. * }
  8243. * } );
  8244. *
  8245. * @example
  8246. * // Get JSON data from a file via Ajax, using `dataSrc` to read data
  8247. * // from a plain array rather than an array in an object
  8248. * $('#example').dataTable( {
  8249. * "ajax": {
  8250. * "url": "data.json",
  8251. * "dataSrc": ""
  8252. * }
  8253. * } );
  8254. *
  8255. * @example
  8256. * // Manipulate the data returned from the server - add a link to data
  8257. * // (note this can, should, be done using `render` for the column - this
  8258. * // is just a simple example of how the data can be manipulated).
  8259. * $('#example').dataTable( {
  8260. * "ajax": {
  8261. * "url": "data.json",
  8262. * "dataSrc": function ( json ) {
  8263. * for ( var i=0, ien=json.length ; i<ien ; i++ ) {
  8264. * json[i][0] = '<a href="/message/'+json[i][0]+'>View message</a>';
  8265. * }
  8266. * return json;
  8267. * }
  8268. * }
  8269. * } );
  8270. *
  8271. * @example
  8272. * // Add data to the request
  8273. * $('#example').dataTable( {
  8274. * "ajax": {
  8275. * "url": "data.json",
  8276. * "data": function ( d ) {
  8277. * return {
  8278. * "extra_search": $('#extra').val()
  8279. * };
  8280. * }
  8281. * }
  8282. * } );
  8283. *
  8284. * @example
  8285. * // Send request as POST
  8286. * $('#example').dataTable( {
  8287. * "ajax": {
  8288. * "url": "data.json",
  8289. * "type": "POST"
  8290. * }
  8291. * } );
  8292. *
  8293. * @example
  8294. * // Get the data from localStorage (could interface with a form for
  8295. * // adding, editing and removing rows).
  8296. * $('#example').dataTable( {
  8297. * "ajax": function (data, callback, settings) {
  8298. * callback(
  8299. * JSON.parse( localStorage.getItem('dataTablesData') )
  8300. * );
  8301. * }
  8302. * } );
  8303. */
  8304. "ajax": null,
  8305. /**
  8306. * This parameter allows you to readily specify the entries in the length drop
  8307. * down menu that DataTables shows when pagination is enabled. It can be
  8308. * either a 1D array of options which will be used for both the displayed
  8309. * option and the value, or a 2D array which will use the array in the first
  8310. * position as the value, and the array in the second position as the
  8311. * displayed options (useful for language strings such as 'All').
  8312. *
  8313. * Note that the `pageLength` property will be automatically set to the
  8314. * first value given in this array, unless `pageLength` is also provided.
  8315. * @type array
  8316. * @default [ 10, 25, 50, 100 ]
  8317. *
  8318. * @dtopt Option
  8319. * @name DataTable.defaults.lengthMenu
  8320. *
  8321. * @example
  8322. * $(document).ready( function() {
  8323. * $('#example').dataTable( {
  8324. * "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
  8325. * } );
  8326. * } );
  8327. */
  8328. "aLengthMenu": [ 10, 25, 50, 100 ],
  8329. /**
  8330. * The `columns` option in the initialisation parameter allows you to define
  8331. * details about the way individual columns behave. For a full list of
  8332. * column options that can be set, please see
  8333. * {@link DataTable.defaults.column}. Note that if you use `columns` to
  8334. * define your columns, you must have an entry in the array for every single
  8335. * column that you have in your table (these can be null if you don't which
  8336. * to specify any options).
  8337. * @member
  8338. *
  8339. * @name DataTable.defaults.column
  8340. */
  8341. "aoColumns": null,
  8342. /**
  8343. * Very similar to `columns`, `columnDefs` allows you to target a specific
  8344. * column, multiple columns, or all columns, using the `targets` property of
  8345. * each object in the array. This allows great flexibility when creating
  8346. * tables, as the `columnDefs` arrays can be of any length, targeting the
  8347. * columns you specifically want. `columnDefs` may use any of the column
  8348. * options available: {@link DataTable.defaults.column}, but it _must_
  8349. * have `targets` defined in each object in the array. Values in the `targets`
  8350. * array may be:
  8351. * <ul>
  8352. * <li>a string - class name will be matched on the TH for the column</li>
  8353. * <li>0 or a positive integer - column index counting from the left</li>
  8354. * <li>a negative integer - column index counting from the right</li>
  8355. * <li>the string "_all" - all columns (i.e. assign a default)</li>
  8356. * </ul>
  8357. * @member
  8358. *
  8359. * @name DataTable.defaults.columnDefs
  8360. */
  8361. "aoColumnDefs": null,
  8362. /**
  8363. * Basically the same as `search`, this parameter defines the individual column
  8364. * filtering state at initialisation time. The array must be of the same size
  8365. * as the number of columns, and each element be an object with the parameters
  8366. * `search` and `escapeRegex` (the latter is optional). 'null' is also
  8367. * accepted and the default will be used.
  8368. * @type array
  8369. * @default []
  8370. *
  8371. * @dtopt Option
  8372. * @name DataTable.defaults.searchCols
  8373. *
  8374. * @example
  8375. * $(document).ready( function() {
  8376. * $('#example').dataTable( {
  8377. * "searchCols": [
  8378. * null,
  8379. * { "search": "My filter" },
  8380. * null,
  8381. * { "search": "^[0-9]", "escapeRegex": false }
  8382. * ]
  8383. * } );
  8384. * } )
  8385. */
  8386. "aoSearchCols": [],
  8387. /**
  8388. * An array of CSS classes that should be applied to displayed rows. This
  8389. * array may be of any length, and DataTables will apply each class
  8390. * sequentially, looping when required.
  8391. * @type array
  8392. * @default null <i>Will take the values determined by the `oClasses.stripe*`
  8393. * options</i>
  8394. *
  8395. * @dtopt Option
  8396. * @name DataTable.defaults.stripeClasses
  8397. *
  8398. * @example
  8399. * $(document).ready( function() {
  8400. * $('#example').dataTable( {
  8401. * "stripeClasses": [ 'strip1', 'strip2', 'strip3' ]
  8402. * } );
  8403. * } )
  8404. */
  8405. "asStripeClasses": null,
  8406. /**
  8407. * Enable or disable automatic column width calculation. This can be disabled
  8408. * as an optimisation (it takes some time to calculate the widths) if the
  8409. * tables widths are passed in using `columns`.
  8410. * @type boolean
  8411. * @default true
  8412. *
  8413. * @dtopt Features
  8414. * @name DataTable.defaults.autoWidth
  8415. *
  8416. * @example
  8417. * $(document).ready( function () {
  8418. * $('#example').dataTable( {
  8419. * "autoWidth": false
  8420. * } );
  8421. * } );
  8422. */
  8423. "bAutoWidth": true,
  8424. /**
  8425. * Deferred rendering can provide DataTables with a huge speed boost when you
  8426. * are using an Ajax or JS data source for the table. This option, when set to
  8427. * true, will cause DataTables to defer the creation of the table elements for
  8428. * each row until they are needed for a draw - saving a significant amount of
  8429. * time.
  8430. * @type boolean
  8431. * @default false
  8432. *
  8433. * @dtopt Features
  8434. * @name DataTable.defaults.deferRender
  8435. *
  8436. * @example
  8437. * $(document).ready( function() {
  8438. * $('#example').dataTable( {
  8439. * "ajax": "sources/arrays.txt",
  8440. * "deferRender": true
  8441. * } );
  8442. * } );
  8443. */
  8444. "bDeferRender": false,
  8445. /**
  8446. * Replace a DataTable which matches the given selector and replace it with
  8447. * one which has the properties of the new initialisation object passed. If no
  8448. * table matches the selector, then the new DataTable will be constructed as
  8449. * per normal.
  8450. * @type boolean
  8451. * @default false
  8452. *
  8453. * @dtopt Options
  8454. * @name DataTable.defaults.destroy
  8455. *
  8456. * @example
  8457. * $(document).ready( function() {
  8458. * $('#example').dataTable( {
  8459. * "srollY": "200px",
  8460. * "paginate": false
  8461. * } );
  8462. *
  8463. * // Some time later....
  8464. * $('#example').dataTable( {
  8465. * "filter": false,
  8466. * "destroy": true
  8467. * } );
  8468. * } );
  8469. */
  8470. "bDestroy": false,
  8471. /**
  8472. * Enable or disable filtering of data. Filtering in DataTables is "smart" in
  8473. * that it allows the end user to input multiple words (space separated) and
  8474. * will match a row containing those words, even if not in the order that was
  8475. * specified (this allow matching across multiple columns). Note that if you
  8476. * wish to use filtering in DataTables this must remain 'true' - to remove the
  8477. * default filtering input box and retain filtering abilities, please use
  8478. * {@link DataTable.defaults.dom}.
  8479. * @type boolean
  8480. * @default true
  8481. *
  8482. * @dtopt Features
  8483. * @name DataTable.defaults.searching
  8484. *
  8485. * @example
  8486. * $(document).ready( function () {
  8487. * $('#example').dataTable( {
  8488. * "searching": false
  8489. * } );
  8490. * } );
  8491. */
  8492. "bFilter": true,
  8493. /**
  8494. * Enable or disable the table information display. This shows information
  8495. * about the data that is currently visible on the page, including information
  8496. * about filtered data if that action is being performed.
  8497. * @type boolean
  8498. * @default true
  8499. *
  8500. * @dtopt Features
  8501. * @name DataTable.defaults.info
  8502. *
  8503. * @example
  8504. * $(document).ready( function () {
  8505. * $('#example').dataTable( {
  8506. * "info": false
  8507. * } );
  8508. * } );
  8509. */
  8510. "bInfo": true,
  8511. /**
  8512. * Enable jQuery UI ThemeRoller support (required as ThemeRoller requires some
  8513. * slightly different and additional mark-up from what DataTables has
  8514. * traditionally used).
  8515. * @type boolean
  8516. * @default false
  8517. *
  8518. * @dtopt Features
  8519. * @name DataTable.defaults.jQueryUI
  8520. *
  8521. * @example
  8522. * $(document).ready( function() {
  8523. * $('#example').dataTable( {
  8524. * "jQueryUI": true
  8525. * } );
  8526. * } );
  8527. */
  8528. "bJQueryUI": false,
  8529. /**
  8530. * Allows the end user to select the size of a formatted page from a select
  8531. * menu (sizes are 10, 25, 50 and 100). Requires pagination (`paginate`).
  8532. * @type boolean
  8533. * @default true
  8534. *
  8535. * @dtopt Features
  8536. * @name DataTable.defaults.lengthChange
  8537. *
  8538. * @example
  8539. * $(document).ready( function () {
  8540. * $('#example').dataTable( {
  8541. * "lengthChange": false
  8542. * } );
  8543. * } );
  8544. */
  8545. "bLengthChange": true,
  8546. /**
  8547. * Enable or disable pagination.
  8548. * @type boolean
  8549. * @default true
  8550. *
  8551. * @dtopt Features
  8552. * @name DataTable.defaults.paging
  8553. *
  8554. * @example
  8555. * $(document).ready( function () {
  8556. * $('#example').dataTable( {
  8557. * "paging": false
  8558. * } );
  8559. * } );
  8560. */
  8561. "bPaginate": true,
  8562. /**
  8563. * Enable or disable the display of a 'processing' indicator when the table is
  8564. * being processed (e.g. a sort). This is particularly useful for tables with
  8565. * large amounts of data where it can take a noticeable amount of time to sort
  8566. * the entries.
  8567. * @type boolean
  8568. * @default false
  8569. *
  8570. * @dtopt Features
  8571. * @name DataTable.defaults.processing
  8572. *
  8573. * @example
  8574. * $(document).ready( function () {
  8575. * $('#example').dataTable( {
  8576. * "processing": true
  8577. * } );
  8578. * } );
  8579. */
  8580. "bProcessing": false,
  8581. /**
  8582. * Retrieve the DataTables object for the given selector. Note that if the
  8583. * table has already been initialised, this parameter will cause DataTables
  8584. * to simply return the object that has already been set up - it will not take
  8585. * account of any changes you might have made to the initialisation object
  8586. * passed to DataTables (setting this parameter to true is an acknowledgement
  8587. * that you understand this). `destroy` can be used to reinitialise a table if
  8588. * you need.
  8589. * @type boolean
  8590. * @default false
  8591. *
  8592. * @dtopt Options
  8593. * @name DataTable.defaults.retrieve
  8594. *
  8595. * @example
  8596. * $(document).ready( function() {
  8597. * initTable();
  8598. * tableActions();
  8599. * } );
  8600. *
  8601. * function initTable ()
  8602. * {
  8603. * return $('#example').dataTable( {
  8604. * "scrollY": "200px",
  8605. * "paginate": false,
  8606. * "retrieve": true
  8607. * } );
  8608. * }
  8609. *
  8610. * function tableActions ()
  8611. * {
  8612. * var table = initTable();
  8613. * // perform API operations with oTable
  8614. * }
  8615. */
  8616. "bRetrieve": false,
  8617. /**
  8618. * When vertical (y) scrolling is enabled, DataTables will force the height of
  8619. * the table's viewport to the given height at all times (useful for layout).
  8620. * However, this can look odd when filtering data down to a small data set,
  8621. * and the footer is left "floating" further down. This parameter (when
  8622. * enabled) will cause DataTables to collapse the table's viewport down when
  8623. * the result set will fit within the given Y height.
  8624. * @type boolean
  8625. * @default false
  8626. *
  8627. * @dtopt Options
  8628. * @name DataTable.defaults.scrollCollapse
  8629. *
  8630. * @example
  8631. * $(document).ready( function() {
  8632. * $('#example').dataTable( {
  8633. * "scrollY": "200",
  8634. * "scrollCollapse": true
  8635. * } );
  8636. * } );
  8637. */
  8638. "bScrollCollapse": false,
  8639. /**
  8640. * Configure DataTables to use server-side processing. Note that the
  8641. * `ajax` parameter must also be given in order to give DataTables a
  8642. * source to obtain the required data for each draw.
  8643. * @type boolean
  8644. * @default false
  8645. *
  8646. * @dtopt Features
  8647. * @dtopt Server-side
  8648. * @name DataTable.defaults.serverSide
  8649. *
  8650. * @example
  8651. * $(document).ready( function () {
  8652. * $('#example').dataTable( {
  8653. * "serverSide": true,
  8654. * "ajax": "xhr.php"
  8655. * } );
  8656. * } );
  8657. */
  8658. "bServerSide": false,
  8659. /**
  8660. * Enable or disable sorting of columns. Sorting of individual columns can be
  8661. * disabled by the `sortable` option for each column.
  8662. * @type boolean
  8663. * @default true
  8664. *
  8665. * @dtopt Features
  8666. * @name DataTable.defaults.ordering
  8667. *
  8668. * @example
  8669. * $(document).ready( function () {
  8670. * $('#example').dataTable( {
  8671. * "ordering": false
  8672. * } );
  8673. * } );
  8674. */
  8675. "bSort": true,
  8676. /**
  8677. * Enable or display DataTables' ability to sort multiple columns at the
  8678. * same time (activated by shift-click by the user).
  8679. * @type boolean
  8680. * @default true
  8681. *
  8682. * @dtopt Options
  8683. * @name DataTable.defaults.orderMulti
  8684. *
  8685. * @example
  8686. * // Disable multiple column sorting ability
  8687. * $(document).ready( function () {
  8688. * $('#example').dataTable( {
  8689. * "orderMulti": false
  8690. * } );
  8691. * } );
  8692. */
  8693. "bSortMulti": true,
  8694. /**
  8695. * Allows control over whether DataTables should use the top (true) unique
  8696. * cell that is found for a single column, or the bottom (false - default).
  8697. * This is useful when using complex headers.
  8698. * @type boolean
  8699. * @default false
  8700. *
  8701. * @dtopt Options
  8702. * @name DataTable.defaults.orderCellsTop
  8703. *
  8704. * @example
  8705. * $(document).ready( function() {
  8706. * $('#example').dataTable( {
  8707. * "orderCellsTop": true
  8708. * } );
  8709. * } );
  8710. */
  8711. "bSortCellsTop": false,
  8712. /**
  8713. * Enable or disable the addition of the classes `sorting\_1`, `sorting\_2` and
  8714. * `sorting\_3` to the columns which are currently being sorted on. This is
  8715. * presented as a feature switch as it can increase processing time (while
  8716. * classes are removed and added) so for large data sets you might want to
  8717. * turn this off.
  8718. * @type boolean
  8719. * @default true
  8720. *
  8721. * @dtopt Features
  8722. * @name DataTable.defaults.orderClasses
  8723. *
  8724. * @example
  8725. * $(document).ready( function () {
  8726. * $('#example').dataTable( {
  8727. * "orderClasses": false
  8728. * } );
  8729. * } );
  8730. */
  8731. "bSortClasses": true,
  8732. /**
  8733. * Enable or disable state saving. When enabled HTML5 `localStorage` will be
  8734. * used to save table display information such as pagination information,
  8735. * display length, filtering and sorting. As such when the end user reloads
  8736. * the page the display display will match what thy had previously set up.
  8737. *
  8738. * Due to the use of `localStorage` the default state saving is not supported
  8739. * in IE6 or 7. If state saving is required in those browsers, use
  8740. * `stateSaveCallback` to provide a storage solution such as cookies.
  8741. * @type boolean
  8742. * @default false
  8743. *
  8744. * @dtopt Features
  8745. * @name DataTable.defaults.stateSave
  8746. *
  8747. * @example
  8748. * $(document).ready( function () {
  8749. * $('#example').dataTable( {
  8750. * "stateSave": true
  8751. * } );
  8752. * } );
  8753. */
  8754. "bStateSave": false,
  8755. /**
  8756. * This function is called when a TR element is created (and all TD child
  8757. * elements have been inserted), or registered if using a DOM source, allowing
  8758. * manipulation of the TR element (adding classes etc).
  8759. * @type function
  8760. * @param {node} row "TR" element for the current row
  8761. * @param {array} data Raw data array for this row
  8762. * @param {int} dataIndex The index of this row in the internal aoData array
  8763. *
  8764. * @dtopt Callbacks
  8765. * @name DataTable.defaults.createdRow
  8766. *
  8767. * @example
  8768. * $(document).ready( function() {
  8769. * $('#example').dataTable( {
  8770. * "createdRow": function( row, data, dataIndex ) {
  8771. * // Bold the grade for all 'A' grade browsers
  8772. * if ( data[4] == "A" )
  8773. * {
  8774. * $('td:eq(4)', row).html( '<b>A</b>' );
  8775. * }
  8776. * }
  8777. * } );
  8778. * } );
  8779. */
  8780. "fnCreatedRow": null,
  8781. /**
  8782. * This function is called on every 'draw' event, and allows you to
  8783. * dynamically modify any aspect you want about the created DOM.
  8784. * @type function
  8785. * @param {object} settings DataTables settings object
  8786. *
  8787. * @dtopt Callbacks
  8788. * @name DataTable.defaults.drawCallback
  8789. *
  8790. * @example
  8791. * $(document).ready( function() {
  8792. * $('#example').dataTable( {
  8793. * "drawCallback": function( settings ) {
  8794. * alert( 'DataTables has redrawn the table' );
  8795. * }
  8796. * } );
  8797. * } );
  8798. */
  8799. "fnDrawCallback": null,
  8800. /**
  8801. * Identical to fnHeaderCallback() but for the table footer this function
  8802. * allows you to modify the table footer on every 'draw' event.
  8803. * @type function
  8804. * @param {node} foot "TR" element for the footer
  8805. * @param {array} data Full table data (as derived from the original HTML)
  8806. * @param {int} start Index for the current display starting point in the
  8807. * display array
  8808. * @param {int} end Index for the current display ending point in the
  8809. * display array
  8810. * @param {array int} display Index array to translate the visual position
  8811. * to the full data array
  8812. *
  8813. * @dtopt Callbacks
  8814. * @name DataTable.defaults.footerCallback
  8815. *
  8816. * @example
  8817. * $(document).ready( function() {
  8818. * $('#example').dataTable( {
  8819. * "footerCallback": function( tfoot, data, start, end, display ) {
  8820. * tfoot.getElementsByTagName('th')[0].innerHTML = "Starting index is "+start;
  8821. * }
  8822. * } );
  8823. * } )
  8824. */
  8825. "fnFooterCallback": null,
  8826. /**
  8827. * When rendering large numbers in the information element for the table
  8828. * (i.e. "Showing 1 to 10 of 57 entries") DataTables will render large numbers
  8829. * to have a comma separator for the 'thousands' units (e.g. 1 million is
  8830. * rendered as "1,000,000") to help readability for the end user. This
  8831. * function will override the default method DataTables uses.
  8832. * @type function
  8833. * @member
  8834. * @param {int} toFormat number to be formatted
  8835. * @returns {string} formatted string for DataTables to show the number
  8836. *
  8837. * @dtopt Callbacks
  8838. * @name DataTable.defaults.formatNumber
  8839. *
  8840. * @example
  8841. * // Format a number using a single quote for the separator (note that
  8842. * // this can also be done with the language.thousands option)
  8843. * $(document).ready( function() {
  8844. * $('#example').dataTable( {
  8845. * "formatNumber": function ( toFormat ) {
  8846. * return toFormat.toString().replace(
  8847. * /\B(?=(\d{3})+(?!\d))/g, "'"
  8848. * );
  8849. * };
  8850. * } );
  8851. * } );
  8852. */
  8853. "fnFormatNumber": function ( toFormat ) {
  8854. return toFormat.toString().replace(
  8855. /\B(?=(\d{3})+(?!\d))/g,
  8856. this.oLanguage.sThousands
  8857. );
  8858. },
  8859. /**
  8860. * This function is called on every 'draw' event, and allows you to
  8861. * dynamically modify the header row. This can be used to calculate and
  8862. * display useful information about the table.
  8863. * @type function
  8864. * @param {node} head "TR" element for the header
  8865. * @param {array} data Full table data (as derived from the original HTML)
  8866. * @param {int} start Index for the current display starting point in the
  8867. * display array
  8868. * @param {int} end Index for the current display ending point in the
  8869. * display array
  8870. * @param {array int} display Index array to translate the visual position
  8871. * to the full data array
  8872. *
  8873. * @dtopt Callbacks
  8874. * @name DataTable.defaults.headerCallback
  8875. *
  8876. * @example
  8877. * $(document).ready( function() {
  8878. * $('#example').dataTable( {
  8879. * "fheaderCallback": function( head, data, start, end, display ) {
  8880. * head.getElementsByTagName('th')[0].innerHTML = "Displaying "+(end-start)+" records";
  8881. * }
  8882. * } );
  8883. * } )
  8884. */
  8885. "fnHeaderCallback": null,
  8886. /**
  8887. * The information element can be used to convey information about the current
  8888. * state of the table. Although the internationalisation options presented by
  8889. * DataTables are quite capable of dealing with most customisations, there may
  8890. * be times where you wish to customise the string further. This callback
  8891. * allows you to do exactly that.
  8892. * @type function
  8893. * @param {object} oSettings DataTables settings object
  8894. * @param {int} start Starting position in data for the draw
  8895. * @param {int} end End position in data for the draw
  8896. * @param {int} max Total number of rows in the table (regardless of
  8897. * filtering)
  8898. * @param {int} total Total number of rows in the data set, after filtering
  8899. * @param {string} pre The string that DataTables has formatted using it's
  8900. * own rules
  8901. * @returns {string} The string to be displayed in the information element.
  8902. *
  8903. * @dtopt Callbacks
  8904. * @name DataTable.defaults.infoCallback
  8905. *
  8906. * @example
  8907. * $('#example').dataTable( {
  8908. * "infoCallback": function( settings, start, end, max, total, pre ) {
  8909. * return start +" to "+ end;
  8910. * }
  8911. * } );
  8912. */
  8913. "fnInfoCallback": null,
  8914. /**
  8915. * Called when the table has been initialised. Normally DataTables will
  8916. * initialise sequentially and there will be no need for this function,
  8917. * however, this does not hold true when using external language information
  8918. * since that is obtained using an async XHR call.
  8919. * @type function
  8920. * @param {object} settings DataTables settings object
  8921. * @param {object} json The JSON object request from the server - only
  8922. * present if client-side Ajax sourced data is used
  8923. *
  8924. * @dtopt Callbacks
  8925. * @name DataTable.defaults.initComplete
  8926. *
  8927. * @example
  8928. * $(document).ready( function() {
  8929. * $('#example').dataTable( {
  8930. * "initComplete": function(settings, json) {
  8931. * alert( 'DataTables has finished its initialisation.' );
  8932. * }
  8933. * } );
  8934. * } )
  8935. */
  8936. "fnInitComplete": null,
  8937. /**
  8938. * Called at the very start of each table draw and can be used to cancel the
  8939. * draw by returning false, any other return (including undefined) results in
  8940. * the full draw occurring).
  8941. * @type function
  8942. * @param {object} settings DataTables settings object
  8943. * @returns {boolean} False will cancel the draw, anything else (including no
  8944. * return) will allow it to complete.
  8945. *
  8946. * @dtopt Callbacks
  8947. * @name DataTable.defaults.preDrawCallback
  8948. *
  8949. * @example
  8950. * $(document).ready( function() {
  8951. * $('#example').dataTable( {
  8952. * "preDrawCallback": function( settings ) {
  8953. * if ( $('#test').val() == 1 ) {
  8954. * return false;
  8955. * }
  8956. * }
  8957. * } );
  8958. * } );
  8959. */
  8960. "fnPreDrawCallback": null,
  8961. /**
  8962. * This function allows you to 'post process' each row after it have been
  8963. * generated for each table draw, but before it is rendered on screen. This
  8964. * function might be used for setting the row class name etc.
  8965. * @type function
  8966. * @param {node} row "TR" element for the current row
  8967. * @param {array} data Raw data array for this row
  8968. * @param {int} displayIndex The display index for the current table draw
  8969. * @param {int} displayIndexFull The index of the data in the full list of
  8970. * rows (after filtering)
  8971. *
  8972. * @dtopt Callbacks
  8973. * @name DataTable.defaults.rowCallback
  8974. *
  8975. * @example
  8976. * $(document).ready( function() {
  8977. * $('#example').dataTable( {
  8978. * "rowCallback": function( row, data, displayIndex, displayIndexFull ) {
  8979. * // Bold the grade for all 'A' grade browsers
  8980. * if ( data[4] == "A" ) {
  8981. * $('td:eq(4)', row).html( '<b>A</b>' );
  8982. * }
  8983. * }
  8984. * } );
  8985. * } );
  8986. */
  8987. "fnRowCallback": null,
  8988. /**
  8989. * __Deprecated__ The functionality provided by this parameter has now been
  8990. * superseded by that provided through `ajax`, which should be used instead.
  8991. *
  8992. * This parameter allows you to override the default function which obtains
  8993. * the data from the server so something more suitable for your application.
  8994. * For example you could use POST data, or pull information from a Gears or
  8995. * AIR database.
  8996. * @type function
  8997. * @member
  8998. * @param {string} source HTTP source to obtain the data from (`ajax`)
  8999. * @param {array} data A key/value pair object containing the data to send
  9000. * to the server
  9001. * @param {function} callback to be called on completion of the data get
  9002. * process that will draw the data on the page.
  9003. * @param {object} settings DataTables settings object
  9004. *
  9005. * @dtopt Callbacks
  9006. * @dtopt Server-side
  9007. * @name DataTable.defaults.serverData
  9008. *
  9009. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9010. */
  9011. "fnServerData": null,
  9012. /**
  9013. * __Deprecated__ The functionality provided by this parameter has now been
  9014. * superseded by that provided through `ajax`, which should be used instead.
  9015. *
  9016. * It is often useful to send extra data to the server when making an Ajax
  9017. * request - for example custom filtering information, and this callback
  9018. * function makes it trivial to send extra information to the server. The
  9019. * passed in parameter is the data set that has been constructed by
  9020. * DataTables, and you can add to this or modify it as you require.
  9021. * @type function
  9022. * @param {array} data Data array (array of objects which are name/value
  9023. * pairs) that has been constructed by DataTables and will be sent to the
  9024. * server. In the case of Ajax sourced data with server-side processing
  9025. * this will be an empty array, for server-side processing there will be a
  9026. * significant number of parameters!
  9027. * @returns {undefined} Ensure that you modify the data array passed in,
  9028. * as this is passed by reference.
  9029. *
  9030. * @dtopt Callbacks
  9031. * @dtopt Server-side
  9032. * @name DataTable.defaults.serverParams
  9033. *
  9034. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9035. */
  9036. "fnServerParams": null,
  9037. /**
  9038. * Load the table state. With this function you can define from where, and how, the
  9039. * state of a table is loaded. By default DataTables will load from `localStorage`
  9040. * but you might wish to use a server-side database or cookies.
  9041. * @type function
  9042. * @member
  9043. * @param {object} settings DataTables settings object
  9044. * @return {object} The DataTables state object to be loaded
  9045. *
  9046. * @dtopt Callbacks
  9047. * @name DataTable.defaults.stateLoadCallback
  9048. *
  9049. * @example
  9050. * $(document).ready( function() {
  9051. * $('#example').dataTable( {
  9052. * "stateSave": true,
  9053. * "stateLoadCallback": function (settings) {
  9054. * var o;
  9055. *
  9056. * // Send an Ajax request to the server to get the data. Note that
  9057. * // this is a synchronous request.
  9058. * $.ajax( {
  9059. * "url": "/state_load",
  9060. * "async": false,
  9061. * "dataType": "json",
  9062. * "success": function (json) {
  9063. * o = json;
  9064. * }
  9065. * } );
  9066. *
  9067. * return o;
  9068. * }
  9069. * } );
  9070. * } );
  9071. */
  9072. "fnStateLoadCallback": function ( settings ) {
  9073. try {
  9074. return JSON.parse(
  9075. (settings.iStateDuration === -1 ? sessionStorage : localStorage).getItem(
  9076. 'DataTables_'+settings.sInstance+'_'+location.pathname
  9077. )
  9078. );
  9079. } catch (e) {}
  9080. },
  9081. /**
  9082. * Callback which allows modification of the saved state prior to loading that state.
  9083. * This callback is called when the table is loading state from the stored data, but
  9084. * prior to the settings object being modified by the saved state. Note that for
  9085. * plug-in authors, you should use the `stateLoadParams` event to load parameters for
  9086. * a plug-in.
  9087. * @type function
  9088. * @param {object} settings DataTables settings object
  9089. * @param {object} data The state object that is to be loaded
  9090. *
  9091. * @dtopt Callbacks
  9092. * @name DataTable.defaults.stateLoadParams
  9093. *
  9094. * @example
  9095. * // Remove a saved filter, so filtering is never loaded
  9096. * $(document).ready( function() {
  9097. * $('#example').dataTable( {
  9098. * "stateSave": true,
  9099. * "stateLoadParams": function (settings, data) {
  9100. * data.oSearch.sSearch = "";
  9101. * }
  9102. * } );
  9103. * } );
  9104. *
  9105. * @example
  9106. * // Disallow state loading by returning false
  9107. * $(document).ready( function() {
  9108. * $('#example').dataTable( {
  9109. * "stateSave": true,
  9110. * "stateLoadParams": function (settings, data) {
  9111. * return false;
  9112. * }
  9113. * } );
  9114. * } );
  9115. */
  9116. "fnStateLoadParams": null,
  9117. /**
  9118. * Callback that is called when the state has been loaded from the state saving method
  9119. * and the DataTables settings object has been modified as a result of the loaded state.
  9120. * @type function
  9121. * @param {object} settings DataTables settings object
  9122. * @param {object} data The state object that was loaded
  9123. *
  9124. * @dtopt Callbacks
  9125. * @name DataTable.defaults.stateLoaded
  9126. *
  9127. * @example
  9128. * // Show an alert with the filtering value that was saved
  9129. * $(document).ready( function() {
  9130. * $('#example').dataTable( {
  9131. * "stateSave": true,
  9132. * "stateLoaded": function (settings, data) {
  9133. * alert( 'Saved filter was: '+data.oSearch.sSearch );
  9134. * }
  9135. * } );
  9136. * } );
  9137. */
  9138. "fnStateLoaded": null,
  9139. /**
  9140. * Save the table state. This function allows you to define where and how the state
  9141. * information for the table is stored By default DataTables will use `localStorage`
  9142. * but you might wish to use a server-side database or cookies.
  9143. * @type function
  9144. * @member
  9145. * @param {object} settings DataTables settings object
  9146. * @param {object} data The state object to be saved
  9147. *
  9148. * @dtopt Callbacks
  9149. * @name DataTable.defaults.stateSaveCallback
  9150. *
  9151. * @example
  9152. * $(document).ready( function() {
  9153. * $('#example').dataTable( {
  9154. * "stateSave": true,
  9155. * "stateSaveCallback": function (settings, data) {
  9156. * // Send an Ajax request to the server with the state object
  9157. * $.ajax( {
  9158. * "url": "/state_save",
  9159. * "data": data,
  9160. * "dataType": "json",
  9161. * "method": "POST"
  9162. * "success": function () {}
  9163. * } );
  9164. * }
  9165. * } );
  9166. * } );
  9167. */
  9168. "fnStateSaveCallback": function ( settings, data ) {
  9169. try {
  9170. (settings.iStateDuration === -1 ? sessionStorage : localStorage).setItem(
  9171. 'DataTables_'+settings.sInstance+'_'+location.pathname,
  9172. JSON.stringify( data )
  9173. );
  9174. } catch (e) {}
  9175. },
  9176. /**
  9177. * Callback which allows modification of the state to be saved. Called when the table
  9178. * has changed state a new state save is required. This method allows modification of
  9179. * the state saving object prior to actually doing the save, including addition or
  9180. * other state properties or modification. Note that for plug-in authors, you should
  9181. * use the `stateSaveParams` event to save parameters for a plug-in.
  9182. * @type function
  9183. * @param {object} settings DataTables settings object
  9184. * @param {object} data The state object to be saved
  9185. *
  9186. * @dtopt Callbacks
  9187. * @name DataTable.defaults.stateSaveParams
  9188. *
  9189. * @example
  9190. * // Remove a saved filter, so filtering is never saved
  9191. * $(document).ready( function() {
  9192. * $('#example').dataTable( {
  9193. * "stateSave": true,
  9194. * "stateSaveParams": function (settings, data) {
  9195. * data.oSearch.sSearch = "";
  9196. * }
  9197. * } );
  9198. * } );
  9199. */
  9200. "fnStateSaveParams": null,
  9201. /**
  9202. * Duration for which the saved state information is considered valid. After this period
  9203. * has elapsed the state will be returned to the default.
  9204. * Value is given in seconds.
  9205. * @type int
  9206. * @default 7200 <i>(2 hours)</i>
  9207. *
  9208. * @dtopt Options
  9209. * @name DataTable.defaults.stateDuration
  9210. *
  9211. * @example
  9212. * $(document).ready( function() {
  9213. * $('#example').dataTable( {
  9214. * "stateDuration": 60*60*24; // 1 day
  9215. * } );
  9216. * } )
  9217. */
  9218. "iStateDuration": 7200,
  9219. /**
  9220. * When enabled DataTables will not make a request to the server for the first
  9221. * page draw - rather it will use the data already on the page (no sorting etc
  9222. * will be applied to it), thus saving on an XHR at load time. `deferLoading`
  9223. * is used to indicate that deferred loading is required, but it is also used
  9224. * to tell DataTables how many records there are in the full table (allowing
  9225. * the information element and pagination to be displayed correctly). In the case
  9226. * where a filtering is applied to the table on initial load, this can be
  9227. * indicated by giving the parameter as an array, where the first element is
  9228. * the number of records available after filtering and the second element is the
  9229. * number of records without filtering (allowing the table information element
  9230. * to be shown correctly).
  9231. * @type int | array
  9232. * @default null
  9233. *
  9234. * @dtopt Options
  9235. * @name DataTable.defaults.deferLoading
  9236. *
  9237. * @example
  9238. * // 57 records available in the table, no filtering applied
  9239. * $(document).ready( function() {
  9240. * $('#example').dataTable( {
  9241. * "serverSide": true,
  9242. * "ajax": "scripts/server_processing.php",
  9243. * "deferLoading": 57
  9244. * } );
  9245. * } );
  9246. *
  9247. * @example
  9248. * // 57 records after filtering, 100 without filtering (an initial filter applied)
  9249. * $(document).ready( function() {
  9250. * $('#example').dataTable( {
  9251. * "serverSide": true,
  9252. * "ajax": "scripts/server_processing.php",
  9253. * "deferLoading": [ 57, 100 ],
  9254. * "search": {
  9255. * "search": "my_filter"
  9256. * }
  9257. * } );
  9258. * } );
  9259. */
  9260. "iDeferLoading": null,
  9261. /**
  9262. * Number of rows to display on a single page when using pagination. If
  9263. * feature enabled (`lengthChange`) then the end user will be able to override
  9264. * this to a custom setting using a pop-up menu.
  9265. * @type int
  9266. * @default 10
  9267. *
  9268. * @dtopt Options
  9269. * @name DataTable.defaults.pageLength
  9270. *
  9271. * @example
  9272. * $(document).ready( function() {
  9273. * $('#example').dataTable( {
  9274. * "pageLength": 50
  9275. * } );
  9276. * } )
  9277. */
  9278. "iDisplayLength": 10,
  9279. /**
  9280. * Define the starting point for data display when using DataTables with
  9281. * pagination. Note that this parameter is the number of records, rather than
  9282. * the page number, so if you have 10 records per page and want to start on
  9283. * the third page, it should be "20".
  9284. * @type int
  9285. * @default 0
  9286. *
  9287. * @dtopt Options
  9288. * @name DataTable.defaults.displayStart
  9289. *
  9290. * @example
  9291. * $(document).ready( function() {
  9292. * $('#example').dataTable( {
  9293. * "displayStart": 20
  9294. * } );
  9295. * } )
  9296. */
  9297. "iDisplayStart": 0,
  9298. /**
  9299. * By default DataTables allows keyboard navigation of the table (sorting, paging,
  9300. * and filtering) by adding a `tabindex` attribute to the required elements. This
  9301. * allows you to tab through the controls and press the enter key to activate them.
  9302. * The tabindex is default 0, meaning that the tab follows the flow of the document.
  9303. * You can overrule this using this parameter if you wish. Use a value of -1 to
  9304. * disable built-in keyboard navigation.
  9305. * @type int
  9306. * @default 0
  9307. *
  9308. * @dtopt Options
  9309. * @name DataTable.defaults.tabIndex
  9310. *
  9311. * @example
  9312. * $(document).ready( function() {
  9313. * $('#example').dataTable( {
  9314. * "tabIndex": 1
  9315. * } );
  9316. * } );
  9317. */
  9318. "iTabIndex": 0,
  9319. /**
  9320. * Classes that DataTables assigns to the various components and features
  9321. * that it adds to the HTML table. This allows classes to be configured
  9322. * during initialisation in addition to through the static
  9323. * {@link DataTable.ext.oStdClasses} object).
  9324. * @namespace
  9325. * @name DataTable.defaults.classes
  9326. */
  9327. "oClasses": {},
  9328. /**
  9329. * All strings that DataTables uses in the user interface that it creates
  9330. * are defined in this object, allowing you to modified them individually or
  9331. * completely replace them all as required.
  9332. * @namespace
  9333. * @name DataTable.defaults.language
  9334. */
  9335. "oLanguage": {
  9336. /**
  9337. * Strings that are used for WAI-ARIA labels and controls only (these are not
  9338. * actually visible on the page, but will be read by screenreaders, and thus
  9339. * must be internationalised as well).
  9340. * @namespace
  9341. * @name DataTable.defaults.language.aria
  9342. */
  9343. "oAria": {
  9344. /**
  9345. * ARIA label that is added to the table headers when the column may be
  9346. * sorted ascending by activing the column (click or return when focused).
  9347. * Note that the column header is prefixed to this string.
  9348. * @type string
  9349. * @default : activate to sort column ascending
  9350. *
  9351. * @dtopt Language
  9352. * @name DataTable.defaults.language.aria.sortAscending
  9353. *
  9354. * @example
  9355. * $(document).ready( function() {
  9356. * $('#example').dataTable( {
  9357. * "language": {
  9358. * "aria": {
  9359. * "sortAscending": " - click/return to sort ascending"
  9360. * }
  9361. * }
  9362. * } );
  9363. * } );
  9364. */
  9365. "sSortAscending": ": activate to sort column ascending",
  9366. /**
  9367. * ARIA label that is added to the table headers when the column may be
  9368. * sorted descending by activing the column (click or return when focused).
  9369. * Note that the column header is prefixed to this string.
  9370. * @type string
  9371. * @default : activate to sort column ascending
  9372. *
  9373. * @dtopt Language
  9374. * @name DataTable.defaults.language.aria.sortDescending
  9375. *
  9376. * @example
  9377. * $(document).ready( function() {
  9378. * $('#example').dataTable( {
  9379. * "language": {
  9380. * "aria": {
  9381. * "sortDescending": " - click/return to sort descending"
  9382. * }
  9383. * }
  9384. * } );
  9385. * } );
  9386. */
  9387. "sSortDescending": ": activate to sort column descending"
  9388. },
  9389. /**
  9390. * Pagination string used by DataTables for the built-in pagination
  9391. * control types.
  9392. * @namespace
  9393. * @name DataTable.defaults.language.paginate
  9394. */
  9395. "oPaginate": {
  9396. /**
  9397. * Text to use when using the 'full_numbers' type of pagination for the
  9398. * button to take the user to the first page.
  9399. * @type string
  9400. * @default First
  9401. *
  9402. * @dtopt Language
  9403. * @name DataTable.defaults.language.paginate.first
  9404. *
  9405. * @example
  9406. * $(document).ready( function() {
  9407. * $('#example').dataTable( {
  9408. * "language": {
  9409. * "paginate": {
  9410. * "first": "First page"
  9411. * }
  9412. * }
  9413. * } );
  9414. * } );
  9415. */
  9416. "sFirst": "First",
  9417. /**
  9418. * Text to use when using the 'full_numbers' type of pagination for the
  9419. * button to take the user to the last page.
  9420. * @type string
  9421. * @default Last
  9422. *
  9423. * @dtopt Language
  9424. * @name DataTable.defaults.language.paginate.last
  9425. *
  9426. * @example
  9427. * $(document).ready( function() {
  9428. * $('#example').dataTable( {
  9429. * "language": {
  9430. * "paginate": {
  9431. * "last": "Last page"
  9432. * }
  9433. * }
  9434. * } );
  9435. * } );
  9436. */
  9437. "sLast": "Last",
  9438. /**
  9439. * Text to use for the 'next' pagination button (to take the user to the
  9440. * next page).
  9441. * @type string
  9442. * @default Next
  9443. *
  9444. * @dtopt Language
  9445. * @name DataTable.defaults.language.paginate.next
  9446. *
  9447. * @example
  9448. * $(document).ready( function() {
  9449. * $('#example').dataTable( {
  9450. * "language": {
  9451. * "paginate": {
  9452. * "next": "Next page"
  9453. * }
  9454. * }
  9455. * } );
  9456. * } );
  9457. */
  9458. "sNext": "Next",
  9459. /**
  9460. * Text to use for the 'previous' pagination button (to take the user to
  9461. * the previous page).
  9462. * @type string
  9463. * @default Previous
  9464. *
  9465. * @dtopt Language
  9466. * @name DataTable.defaults.language.paginate.previous
  9467. *
  9468. * @example
  9469. * $(document).ready( function() {
  9470. * $('#example').dataTable( {
  9471. * "language": {
  9472. * "paginate": {
  9473. * "previous": "Previous page"
  9474. * }
  9475. * }
  9476. * } );
  9477. * } );
  9478. */
  9479. "sPrevious": "Previous"
  9480. },
  9481. /**
  9482. * This string is shown in preference to `zeroRecords` when the table is
  9483. * empty of data (regardless of filtering). Note that this is an optional
  9484. * parameter - if it is not given, the value of `zeroRecords` will be used
  9485. * instead (either the default or given value).
  9486. * @type string
  9487. * @default No data available in table
  9488. *
  9489. * @dtopt Language
  9490. * @name DataTable.defaults.language.emptyTable
  9491. *
  9492. * @example
  9493. * $(document).ready( function() {
  9494. * $('#example').dataTable( {
  9495. * "language": {
  9496. * "emptyTable": "No data available in table"
  9497. * }
  9498. * } );
  9499. * } );
  9500. */
  9501. "sEmptyTable": "No data available in table",
  9502. /**
  9503. * This string gives information to the end user about the information
  9504. * that is current on display on the page. The following tokens can be
  9505. * used in the string and will be dynamically replaced as the table
  9506. * display updates. This tokens can be placed anywhere in the string, or
  9507. * removed as needed by the language requires:
  9508. *
  9509. * * `\_START\_` - Display index of the first record on the current page
  9510. * * `\_END\_` - Display index of the last record on the current page
  9511. * * `\_TOTAL\_` - Number of records in the table after filtering
  9512. * * `\_MAX\_` - Number of records in the table without filtering
  9513. * * `\_PAGE\_` - Current page number
  9514. * * `\_PAGES\_` - Total number of pages of data in the table
  9515. *
  9516. * @type string
  9517. * @default Showing _START_ to _END_ of _TOTAL_ entries
  9518. *
  9519. * @dtopt Language
  9520. * @name DataTable.defaults.language.info
  9521. *
  9522. * @example
  9523. * $(document).ready( function() {
  9524. * $('#example').dataTable( {
  9525. * "language": {
  9526. * "info": "Showing page _PAGE_ of _PAGES_"
  9527. * }
  9528. * } );
  9529. * } );
  9530. */
  9531. "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
  9532. /**
  9533. * Display information string for when the table is empty. Typically the
  9534. * format of this string should match `info`.
  9535. * @type string
  9536. * @default Showing 0 to 0 of 0 entries
  9537. *
  9538. * @dtopt Language
  9539. * @name DataTable.defaults.language.infoEmpty
  9540. *
  9541. * @example
  9542. * $(document).ready( function() {
  9543. * $('#example').dataTable( {
  9544. * "language": {
  9545. * "infoEmpty": "No entries to show"
  9546. * }
  9547. * } );
  9548. * } );
  9549. */
  9550. "sInfoEmpty": "Showing 0 to 0 of 0 entries",
  9551. /**
  9552. * When a user filters the information in a table, this string is appended
  9553. * to the information (`info`) to give an idea of how strong the filtering
  9554. * is. The variable _MAX_ is dynamically updated.
  9555. * @type string
  9556. * @default (filtered from _MAX_ total entries)
  9557. *
  9558. * @dtopt Language
  9559. * @name DataTable.defaults.language.infoFiltered
  9560. *
  9561. * @example
  9562. * $(document).ready( function() {
  9563. * $('#example').dataTable( {
  9564. * "language": {
  9565. * "infoFiltered": " - filtering from _MAX_ records"
  9566. * }
  9567. * } );
  9568. * } );
  9569. */
  9570. "sInfoFiltered": "(filtered from _MAX_ total entries)",
  9571. /**
  9572. * If can be useful to append extra information to the info string at times,
  9573. * and this variable does exactly that. This information will be appended to
  9574. * the `info` (`infoEmpty` and `infoFiltered` in whatever combination they are
  9575. * being used) at all times.
  9576. * @type string
  9577. * @default <i>Empty string</i>
  9578. *
  9579. * @dtopt Language
  9580. * @name DataTable.defaults.language.infoPostFix
  9581. *
  9582. * @example
  9583. * $(document).ready( function() {
  9584. * $('#example').dataTable( {
  9585. * "language": {
  9586. * "infoPostFix": "All records shown are derived from real information."
  9587. * }
  9588. * } );
  9589. * } );
  9590. */
  9591. "sInfoPostFix": "",
  9592. /**
  9593. * This decimal place operator is a little different from the other
  9594. * language options since DataTables doesn't output floating point
  9595. * numbers, so it won't ever use this for display of a number. Rather,
  9596. * what this parameter does is modify the sort methods of the table so
  9597. * that numbers which are in a format which has a character other than
  9598. * a period (`.`) as a decimal place will be sorted numerically.
  9599. *
  9600. * Note that numbers with different decimal places cannot be shown in
  9601. * the same table and still be sortable, the table must be consistent.
  9602. * However, multiple different tables on the page can use different
  9603. * decimal place characters.
  9604. * @type string
  9605. * @default
  9606. *
  9607. * @dtopt Language
  9608. * @name DataTable.defaults.language.decimal
  9609. *
  9610. * @example
  9611. * $(document).ready( function() {
  9612. * $('#example').dataTable( {
  9613. * "language": {
  9614. * "decimal": ","
  9615. * "thousands": "."
  9616. * }
  9617. * } );
  9618. * } );
  9619. */
  9620. "sDecimal": "",
  9621. /**
  9622. * DataTables has a build in number formatter (`formatNumber`) which is
  9623. * used to format large numbers that are used in the table information.
  9624. * By default a comma is used, but this can be trivially changed to any
  9625. * character you wish with this parameter.
  9626. * @type string
  9627. * @default ,
  9628. *
  9629. * @dtopt Language
  9630. * @name DataTable.defaults.language.thousands
  9631. *
  9632. * @example
  9633. * $(document).ready( function() {
  9634. * $('#example').dataTable( {
  9635. * "language": {
  9636. * "thousands": "'"
  9637. * }
  9638. * } );
  9639. * } );
  9640. */
  9641. "sThousands": ",",
  9642. /**
  9643. * Detail the action that will be taken when the drop down menu for the
  9644. * pagination length option is changed. The '_MENU_' variable is replaced
  9645. * with a default select list of 10, 25, 50 and 100, and can be replaced
  9646. * with a custom select box if required.
  9647. * @type string
  9648. * @default Show _MENU_ entries
  9649. *
  9650. * @dtopt Language
  9651. * @name DataTable.defaults.language.lengthMenu
  9652. *
  9653. * @example
  9654. * // Language change only
  9655. * $(document).ready( function() {
  9656. * $('#example').dataTable( {
  9657. * "language": {
  9658. * "lengthMenu": "Display _MENU_ records"
  9659. * }
  9660. * } );
  9661. * } );
  9662. *
  9663. * @example
  9664. * // Language and options change
  9665. * $(document).ready( function() {
  9666. * $('#example').dataTable( {
  9667. * "language": {
  9668. * "lengthMenu": 'Display <select>'+
  9669. * '<option value="10">10</option>'+
  9670. * '<option value="20">20</option>'+
  9671. * '<option value="30">30</option>'+
  9672. * '<option value="40">40</option>'+
  9673. * '<option value="50">50</option>'+
  9674. * '<option value="-1">All</option>'+
  9675. * '</select> records'
  9676. * }
  9677. * } );
  9678. * } );
  9679. */
  9680. "sLengthMenu": "Show _MENU_ entries",
  9681. /**
  9682. * When using Ajax sourced data and during the first draw when DataTables is
  9683. * gathering the data, this message is shown in an empty row in the table to
  9684. * indicate to the end user the the data is being loaded. Note that this
  9685. * parameter is not used when loading data by server-side processing, just
  9686. * Ajax sourced data with client-side processing.
  9687. * @type string
  9688. * @default Loading...
  9689. *
  9690. * @dtopt Language
  9691. * @name DataTable.defaults.language.loadingRecords
  9692. *
  9693. * @example
  9694. * $(document).ready( function() {
  9695. * $('#example').dataTable( {
  9696. * "language": {
  9697. * "loadingRecords": "Please wait - loading..."
  9698. * }
  9699. * } );
  9700. * } );
  9701. */
  9702. "sLoadingRecords": "Loading...",
  9703. /**
  9704. * Text which is displayed when the table is processing a user action
  9705. * (usually a sort command or similar).
  9706. * @type string
  9707. * @default Processing...
  9708. *
  9709. * @dtopt Language
  9710. * @name DataTable.defaults.language.processing
  9711. *
  9712. * @example
  9713. * $(document).ready( function() {
  9714. * $('#example').dataTable( {
  9715. * "language": {
  9716. * "processing": "DataTables is currently busy"
  9717. * }
  9718. * } );
  9719. * } );
  9720. */
  9721. "sProcessing": "Processing...",
  9722. /**
  9723. * Details the actions that will be taken when the user types into the
  9724. * filtering input text box. The variable "_INPUT_", if used in the string,
  9725. * is replaced with the HTML text box for the filtering input allowing
  9726. * control over where it appears in the string. If "_INPUT_" is not given
  9727. * then the input box is appended to the string automatically.
  9728. * @type string
  9729. * @default Search:
  9730. *
  9731. * @dtopt Language
  9732. * @name DataTable.defaults.language.search
  9733. *
  9734. * @example
  9735. * // Input text box will be appended at the end automatically
  9736. * $(document).ready( function() {
  9737. * $('#example').dataTable( {
  9738. * "language": {
  9739. * "search": "Filter records:"
  9740. * }
  9741. * } );
  9742. * } );
  9743. *
  9744. * @example
  9745. * // Specify where the filter should appear
  9746. * $(document).ready( function() {
  9747. * $('#example').dataTable( {
  9748. * "language": {
  9749. * "search": "Apply filter _INPUT_ to table"
  9750. * }
  9751. * } );
  9752. * } );
  9753. */
  9754. "sSearch": "Search:",
  9755. /**
  9756. * Assign a `placeholder` attribute to the search `input` element
  9757. * @type string
  9758. * @default
  9759. *
  9760. * @dtopt Language
  9761. * @name DataTable.defaults.language.searchPlaceholder
  9762. */
  9763. "sSearchPlaceholder": "",
  9764. /**
  9765. * All of the language information can be stored in a file on the
  9766. * server-side, which DataTables will look up if this parameter is passed.
  9767. * It must store the URL of the language file, which is in a JSON format,
  9768. * and the object has the same properties as the oLanguage object in the
  9769. * initialiser object (i.e. the above parameters). Please refer to one of
  9770. * the example language files to see how this works in action.
  9771. * @type string
  9772. * @default <i>Empty string - i.e. disabled</i>
  9773. *
  9774. * @dtopt Language
  9775. * @name DataTable.defaults.language.url
  9776. *
  9777. * @example
  9778. * $(document).ready( function() {
  9779. * $('#example').dataTable( {
  9780. * "language": {
  9781. * "url": "http://www.sprymedia.co.uk/dataTables/lang.txt"
  9782. * }
  9783. * } );
  9784. * } );
  9785. */
  9786. "sUrl": "",
  9787. /**
  9788. * Text shown inside the table records when the is no information to be
  9789. * displayed after filtering. `emptyTable` is shown when there is simply no
  9790. * information in the table at all (regardless of filtering).
  9791. * @type string
  9792. * @default No matching records found
  9793. *
  9794. * @dtopt Language
  9795. * @name DataTable.defaults.language.zeroRecords
  9796. *
  9797. * @example
  9798. * $(document).ready( function() {
  9799. * $('#example').dataTable( {
  9800. * "language": {
  9801. * "zeroRecords": "No records to display"
  9802. * }
  9803. * } );
  9804. * } );
  9805. */
  9806. "sZeroRecords": "No matching records found"
  9807. },
  9808. /**
  9809. * This parameter allows you to have define the global filtering state at
  9810. * initialisation time. As an object the `search` parameter must be
  9811. * defined, but all other parameters are optional. When `regex` is true,
  9812. * the search string will be treated as a regular expression, when false
  9813. * (default) it will be treated as a straight string. When `smart`
  9814. * DataTables will use it's smart filtering methods (to word match at
  9815. * any point in the data), when false this will not be done.
  9816. * @namespace
  9817. * @extends DataTable.models.oSearch
  9818. *
  9819. * @dtopt Options
  9820. * @name DataTable.defaults.search
  9821. *
  9822. * @example
  9823. * $(document).ready( function() {
  9824. * $('#example').dataTable( {
  9825. * "search": {"search": "Initial search"}
  9826. * } );
  9827. * } )
  9828. */
  9829. "oSearch": $.extend( {}, DataTable.models.oSearch ),
  9830. /**
  9831. * __Deprecated__ The functionality provided by this parameter has now been
  9832. * superseded by that provided through `ajax`, which should be used instead.
  9833. *
  9834. * By default DataTables will look for the property `data` (or `aaData` for
  9835. * compatibility with DataTables 1.9-) when obtaining data from an Ajax
  9836. * source or for server-side processing - this parameter allows that
  9837. * property to be changed. You can use Javascript dotted object notation to
  9838. * get a data source for multiple levels of nesting.
  9839. * @type string
  9840. * @default data
  9841. *
  9842. * @dtopt Options
  9843. * @dtopt Server-side
  9844. * @name DataTable.defaults.ajaxDataProp
  9845. *
  9846. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9847. */
  9848. "sAjaxDataProp": "data",
  9849. /**
  9850. * __Deprecated__ The functionality provided by this parameter has now been
  9851. * superseded by that provided through `ajax`, which should be used instead.
  9852. *
  9853. * You can instruct DataTables to load data from an external
  9854. * source using this parameter (use aData if you want to pass data in you
  9855. * already have). Simply provide a url a JSON object can be obtained from.
  9856. * @type string
  9857. * @default null
  9858. *
  9859. * @dtopt Options
  9860. * @dtopt Server-side
  9861. * @name DataTable.defaults.ajaxSource
  9862. *
  9863. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9864. */
  9865. "sAjaxSource": null,
  9866. /**
  9867. * This initialisation variable allows you to specify exactly where in the
  9868. * DOM you want DataTables to inject the various controls it adds to the page
  9869. * (for example you might want the pagination controls at the top of the
  9870. * table). DIV elements (with or without a custom class) can also be added to
  9871. * aid styling. The follow syntax is used:
  9872. * <ul>
  9873. * <li>The following options are allowed:
  9874. * <ul>
  9875. * <li>'l' - Length changing</li>
  9876. * <li>'f' - Filtering input</li>
  9877. * <li>'t' - The table!</li>
  9878. * <li>'i' - Information</li>
  9879. * <li>'p' - Pagination</li>
  9880. * <li>'r' - pRocessing</li>
  9881. * </ul>
  9882. * </li>
  9883. * <li>The following constants are allowed:
  9884. * <ul>
  9885. * <li>'H' - jQueryUI theme "header" classes ('fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix')</li>
  9886. * <li>'F' - jQueryUI theme "footer" classes ('fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix')</li>
  9887. * </ul>
  9888. * </li>
  9889. * <li>The following syntax is expected:
  9890. * <ul>
  9891. * <li>'&lt;' and '&gt;' - div elements</li>
  9892. * <li>'&lt;"class" and '&gt;' - div with a class</li>
  9893. * <li>'&lt;"#id" and '&gt;' - div with an ID</li>
  9894. * </ul>
  9895. * </li>
  9896. * <li>Examples:
  9897. * <ul>
  9898. * <li>'&lt;"wrapper"flipt&gt;'</li>
  9899. * <li>'&lt;lf&lt;t&gt;ip&gt;'</li>
  9900. * </ul>
  9901. * </li>
  9902. * </ul>
  9903. * @type string
  9904. * @default lfrtip <i>(when `jQueryUI` is false)</i> <b>or</b>
  9905. * <"H"lfr>t<"F"ip> <i>(when `jQueryUI` is true)</i>
  9906. *
  9907. * @dtopt Options
  9908. * @name DataTable.defaults.dom
  9909. *
  9910. * @example
  9911. * $(document).ready( function() {
  9912. * $('#example').dataTable( {
  9913. * "dom": '&lt;"top"i&gt;rt&lt;"bottom"flp&gt;&lt;"clear"&gt;'
  9914. * } );
  9915. * } );
  9916. */
  9917. "sDom": "lfrtip",
  9918. /**
  9919. * Search delay option. This will throttle full table searches that use the
  9920. * DataTables provided search input element (it does not effect calls to
  9921. * `dt-api search()`, providing a delay before the search is made.
  9922. * @type integer
  9923. * @default 0
  9924. *
  9925. * @dtopt Options
  9926. * @name DataTable.defaults.searchDelay
  9927. *
  9928. * @example
  9929. * $(document).ready( function() {
  9930. * $('#example').dataTable( {
  9931. * "searchDelay": 200
  9932. * } );
  9933. * } )
  9934. */
  9935. "searchDelay": null,
  9936. /**
  9937. * DataTables features four different built-in options for the buttons to
  9938. * display for pagination control:
  9939. *
  9940. * * `simple` - 'Previous' and 'Next' buttons only
  9941. * * 'simple_numbers` - 'Previous' and 'Next' buttons, plus page numbers
  9942. * * `full` - 'First', 'Previous', 'Next' and 'Last' buttons
  9943. * * `full_numbers` - 'First', 'Previous', 'Next' and 'Last' buttons, plus
  9944. * page numbers
  9945. *
  9946. * Further methods can be added using {@link DataTable.ext.oPagination}.
  9947. * @type string
  9948. * @default simple_numbers
  9949. *
  9950. * @dtopt Options
  9951. * @name DataTable.defaults.pagingType
  9952. *
  9953. * @example
  9954. * $(document).ready( function() {
  9955. * $('#example').dataTable( {
  9956. * "pagingType": "full_numbers"
  9957. * } );
  9958. * } )
  9959. */
  9960. "sPaginationType": "simple_numbers",
  9961. /**
  9962. * Enable horizontal scrolling. When a table is too wide to fit into a
  9963. * certain layout, or you have a large number of columns in the table, you
  9964. * can enable x-scrolling to show the table in a viewport, which can be
  9965. * scrolled. This property can be `true` which will allow the table to
  9966. * scroll horizontally when needed, or any CSS unit, or a number (in which
  9967. * case it will be treated as a pixel measurement). Setting as simply `true`
  9968. * is recommended.
  9969. * @type boolean|string
  9970. * @default <i>blank string - i.e. disabled</i>
  9971. *
  9972. * @dtopt Features
  9973. * @name DataTable.defaults.scrollX
  9974. *
  9975. * @example
  9976. * $(document).ready( function() {
  9977. * $('#example').dataTable( {
  9978. * "scrollX": true,
  9979. * "scrollCollapse": true
  9980. * } );
  9981. * } );
  9982. */
  9983. "sScrollX": "",
  9984. /**
  9985. * This property can be used to force a DataTable to use more width than it
  9986. * might otherwise do when x-scrolling is enabled. For example if you have a
  9987. * table which requires to be well spaced, this parameter is useful for
  9988. * "over-sizing" the table, and thus forcing scrolling. This property can by
  9989. * any CSS unit, or a number (in which case it will be treated as a pixel
  9990. * measurement).
  9991. * @type string
  9992. * @default <i>blank string - i.e. disabled</i>
  9993. *
  9994. * @dtopt Options
  9995. * @name DataTable.defaults.scrollXInner
  9996. *
  9997. * @example
  9998. * $(document).ready( function() {
  9999. * $('#example').dataTable( {
  10000. * "scrollX": "100%",
  10001. * "scrollXInner": "110%"
  10002. * } );
  10003. * } );
  10004. */
  10005. "sScrollXInner": "",
  10006. /**
  10007. * Enable vertical scrolling. Vertical scrolling will constrain the DataTable
  10008. * to the given height, and enable scrolling for any data which overflows the
  10009. * current viewport. This can be used as an alternative to paging to display
  10010. * a lot of data in a small area (although paging and scrolling can both be
  10011. * enabled at the same time). This property can be any CSS unit, or a number
  10012. * (in which case it will be treated as a pixel measurement).
  10013. * @type string
  10014. * @default <i>blank string - i.e. disabled</i>
  10015. *
  10016. * @dtopt Features
  10017. * @name DataTable.defaults.scrollY
  10018. *
  10019. * @example
  10020. * $(document).ready( function() {
  10021. * $('#example').dataTable( {
  10022. * "scrollY": "200px",
  10023. * "paginate": false
  10024. * } );
  10025. * } );
  10026. */
  10027. "sScrollY": "",
  10028. /**
  10029. * __Deprecated__ The functionality provided by this parameter has now been
  10030. * superseded by that provided through `ajax`, which should be used instead.
  10031. *
  10032. * Set the HTTP method that is used to make the Ajax call for server-side
  10033. * processing or Ajax sourced data.
  10034. * @type string
  10035. * @default GET
  10036. *
  10037. * @dtopt Options
  10038. * @dtopt Server-side
  10039. * @name DataTable.defaults.serverMethod
  10040. *
  10041. * @deprecated 1.10. Please use `ajax` for this functionality now.
  10042. */
  10043. "sServerMethod": "GET",
  10044. /**
  10045. * DataTables makes use of renderers when displaying HTML elements for
  10046. * a table. These renderers can be added or modified by plug-ins to
  10047. * generate suitable mark-up for a site. For example the Bootstrap
  10048. * integration plug-in for DataTables uses a paging button renderer to
  10049. * display pagination buttons in the mark-up required by Bootstrap.
  10050. *
  10051. * For further information about the renderers available see
  10052. * DataTable.ext.renderer
  10053. * @type string|object
  10054. * @default null
  10055. *
  10056. * @name DataTable.defaults.renderer
  10057. *
  10058. */
  10059. "renderer": null
  10060. };
  10061. _fnHungarianMap( DataTable.defaults );
  10062. /*
  10063. * Developer note - See note in model.defaults.js about the use of Hungarian
  10064. * notation and camel case.
  10065. */
  10066. /**
  10067. * Column options that can be given to DataTables at initialisation time.
  10068. * @namespace
  10069. */
  10070. DataTable.defaults.column = {
  10071. /**
  10072. * Define which column(s) an order will occur on for this column. This
  10073. * allows a column's ordering to take multiple columns into account when
  10074. * doing a sort or use the data from a different column. For example first
  10075. * name / last name columns make sense to do a multi-column sort over the
  10076. * two columns.
  10077. * @type array|int
  10078. * @default null <i>Takes the value of the column index automatically</i>
  10079. *
  10080. * @name DataTable.defaults.column.orderData
  10081. * @dtopt Columns
  10082. *
  10083. * @example
  10084. * // Using `columnDefs`
  10085. * $(document).ready( function() {
  10086. * $('#example').dataTable( {
  10087. * "columnDefs": [
  10088. * { "orderData": [ 0, 1 ], "targets": [ 0 ] },
  10089. * { "orderData": [ 1, 0 ], "targets": [ 1 ] },
  10090. * { "orderData": 2, "targets": [ 2 ] }
  10091. * ]
  10092. * } );
  10093. * } );
  10094. *
  10095. * @example
  10096. * // Using `columns`
  10097. * $(document).ready( function() {
  10098. * $('#example').dataTable( {
  10099. * "columns": [
  10100. * { "orderData": [ 0, 1 ] },
  10101. * { "orderData": [ 1, 0 ] },
  10102. * { "orderData": 2 },
  10103. * null,
  10104. * null
  10105. * ]
  10106. * } );
  10107. * } );
  10108. */
  10109. "aDataSort": null,
  10110. "iDataSort": -1,
  10111. /**
  10112. * You can control the default ordering direction, and even alter the
  10113. * behaviour of the sort handler (i.e. only allow ascending ordering etc)
  10114. * using this parameter.
  10115. * @type array
  10116. * @default [ 'asc', 'desc' ]
  10117. *
  10118. * @name DataTable.defaults.column.orderSequence
  10119. * @dtopt Columns
  10120. *
  10121. * @example
  10122. * // Using `columnDefs`
  10123. * $(document).ready( function() {
  10124. * $('#example').dataTable( {
  10125. * "columnDefs": [
  10126. * { "orderSequence": [ "asc" ], "targets": [ 1 ] },
  10127. * { "orderSequence": [ "desc", "asc", "asc" ], "targets": [ 2 ] },
  10128. * { "orderSequence": [ "desc" ], "targets": [ 3 ] }
  10129. * ]
  10130. * } );
  10131. * } );
  10132. *
  10133. * @example
  10134. * // Using `columns`
  10135. * $(document).ready( function() {
  10136. * $('#example').dataTable( {
  10137. * "columns": [
  10138. * null,
  10139. * { "orderSequence": [ "asc" ] },
  10140. * { "orderSequence": [ "desc", "asc", "asc" ] },
  10141. * { "orderSequence": [ "desc" ] },
  10142. * null
  10143. * ]
  10144. * } );
  10145. * } );
  10146. */
  10147. "asSorting": [ 'asc', 'desc' ],
  10148. /**
  10149. * Enable or disable filtering on the data in this column.
  10150. * @type boolean
  10151. * @default true
  10152. *
  10153. * @name DataTable.defaults.column.searchable
  10154. * @dtopt Columns
  10155. *
  10156. * @example
  10157. * // Using `columnDefs`
  10158. * $(document).ready( function() {
  10159. * $('#example').dataTable( {
  10160. * "columnDefs": [
  10161. * { "searchable": false, "targets": [ 0 ] }
  10162. * ] } );
  10163. * } );
  10164. *
  10165. * @example
  10166. * // Using `columns`
  10167. * $(document).ready( function() {
  10168. * $('#example').dataTable( {
  10169. * "columns": [
  10170. * { "searchable": false },
  10171. * null,
  10172. * null,
  10173. * null,
  10174. * null
  10175. * ] } );
  10176. * } );
  10177. */
  10178. "bSearchable": true,
  10179. /**
  10180. * Enable or disable ordering on this column.
  10181. * @type boolean
  10182. * @default true
  10183. *
  10184. * @name DataTable.defaults.column.orderable
  10185. * @dtopt Columns
  10186. *
  10187. * @example
  10188. * // Using `columnDefs`
  10189. * $(document).ready( function() {
  10190. * $('#example').dataTable( {
  10191. * "columnDefs": [
  10192. * { "orderable": false, "targets": [ 0 ] }
  10193. * ] } );
  10194. * } );
  10195. *
  10196. * @example
  10197. * // Using `columns`
  10198. * $(document).ready( function() {
  10199. * $('#example').dataTable( {
  10200. * "columns": [
  10201. * { "orderable": false },
  10202. * null,
  10203. * null,
  10204. * null,
  10205. * null
  10206. * ] } );
  10207. * } );
  10208. */
  10209. "bSortable": true,
  10210. /**
  10211. * Enable or disable the display of this column.
  10212. * @type boolean
  10213. * @default true
  10214. *
  10215. * @name DataTable.defaults.column.visible
  10216. * @dtopt Columns
  10217. *
  10218. * @example
  10219. * // Using `columnDefs`
  10220. * $(document).ready( function() {
  10221. * $('#example').dataTable( {
  10222. * "columnDefs": [
  10223. * { "visible": false, "targets": [ 0 ] }
  10224. * ] } );
  10225. * } );
  10226. *
  10227. * @example
  10228. * // Using `columns`
  10229. * $(document).ready( function() {
  10230. * $('#example').dataTable( {
  10231. * "columns": [
  10232. * { "visible": false },
  10233. * null,
  10234. * null,
  10235. * null,
  10236. * null
  10237. * ] } );
  10238. * } );
  10239. */
  10240. "bVisible": true,
  10241. /**
  10242. * Developer definable function that is called whenever a cell is created (Ajax source,
  10243. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  10244. * allowing you to modify the DOM element (add background colour for example) when the
  10245. * element is available.
  10246. * @type function
  10247. * @param {element} td The TD node that has been created
  10248. * @param {*} cellData The Data for the cell
  10249. * @param {array|object} rowData The data for the whole row
  10250. * @param {int} row The row index for the aoData data store
  10251. * @param {int} col The column index for aoColumns
  10252. *
  10253. * @name DataTable.defaults.column.createdCell
  10254. * @dtopt Columns
  10255. *
  10256. * @example
  10257. * $(document).ready( function() {
  10258. * $('#example').dataTable( {
  10259. * "columnDefs": [ {
  10260. * "targets": [3],
  10261. * "createdCell": function (td, cellData, rowData, row, col) {
  10262. * if ( cellData == "1.7" ) {
  10263. * $(td).css('color', 'blue')
  10264. * }
  10265. * }
  10266. * } ]
  10267. * });
  10268. * } );
  10269. */
  10270. "fnCreatedCell": null,
  10271. /**
  10272. * This parameter has been replaced by `data` in DataTables to ensure naming
  10273. * consistency. `dataProp` can still be used, as there is backwards
  10274. * compatibility in DataTables for this option, but it is strongly
  10275. * recommended that you use `data` in preference to `dataProp`.
  10276. * @name DataTable.defaults.column.dataProp
  10277. */
  10278. /**
  10279. * This property can be used to read data from any data source property,
  10280. * including deeply nested objects / properties. `data` can be given in a
  10281. * number of different ways which effect its behaviour:
  10282. *
  10283. * * `integer` - treated as an array index for the data source. This is the
  10284. * default that DataTables uses (incrementally increased for each column).
  10285. * * `string` - read an object property from the data source. There are
  10286. * three 'special' options that can be used in the string to alter how
  10287. * DataTables reads the data from the source object:
  10288. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10289. * Javascript to read from nested objects, so to can the options
  10290. * specified in `data`. For example: `browser.version` or
  10291. * `browser.name`. If your object parameter name contains a period, use
  10292. * `\\` to escape it - i.e. `first\\.name`.
  10293. * * `[]` - Array notation. DataTables can automatically combine data
  10294. * from and array source, joining the data with the characters provided
  10295. * between the two brackets. For example: `name[, ]` would provide a
  10296. * comma-space separated list from the source array. If no characters
  10297. * are provided between the brackets, the original array source is
  10298. * returned.
  10299. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10300. * execute a function of the name given. For example: `browser()` for a
  10301. * simple function on the data source, `browser.version()` for a
  10302. * function in a nested property or even `browser().version` to get an
  10303. * object property if the function called returns an object. Note that
  10304. * function notation is recommended for use in `render` rather than
  10305. * `data` as it is much simpler to use as a renderer.
  10306. * * `null` - use the original data source for the row rather than plucking
  10307. * data directly from it. This action has effects on two other
  10308. * initialisation options:
  10309. * * `defaultContent` - When null is given as the `data` option and
  10310. * `defaultContent` is specified for the column, the value defined by
  10311. * `defaultContent` will be used for the cell.
  10312. * * `render` - When null is used for the `data` option and the `render`
  10313. * option is specified for the column, the whole data source for the
  10314. * row is used for the renderer.
  10315. * * `function` - the function given will be executed whenever DataTables
  10316. * needs to set or get the data for a cell in the column. The function
  10317. * takes three parameters:
  10318. * * Parameters:
  10319. * * `{array|object}` The data source for the row
  10320. * * `{string}` The type call data requested - this will be 'set' when
  10321. * setting data or 'filter', 'display', 'type', 'sort' or undefined
  10322. * when gathering data. Note that when `undefined` is given for the
  10323. * type DataTables expects to get the raw data for the object back<
  10324. * * `{*}` Data to set when the second parameter is 'set'.
  10325. * * Return:
  10326. * * The return value from the function is not required when 'set' is
  10327. * the type of call, but otherwise the return is what will be used
  10328. * for the data requested.
  10329. *
  10330. * Note that `data` is a getter and setter option. If you just require
  10331. * formatting of data for output, you will likely want to use `render` which
  10332. * is simply a getter and thus simpler to use.
  10333. *
  10334. * Note that prior to DataTables 1.9.2 `data` was called `mDataProp`. The
  10335. * name change reflects the flexibility of this property and is consistent
  10336. * with the naming of mRender. If 'mDataProp' is given, then it will still
  10337. * be used by DataTables, as it automatically maps the old name to the new
  10338. * if required.
  10339. *
  10340. * @type string|int|function|null
  10341. * @default null <i>Use automatically calculated column index</i>
  10342. *
  10343. * @name DataTable.defaults.column.data
  10344. * @dtopt Columns
  10345. *
  10346. * @example
  10347. * // Read table data from objects
  10348. * // JSON structure for each row:
  10349. * // {
  10350. * // "engine": {value},
  10351. * // "browser": {value},
  10352. * // "platform": {value},
  10353. * // "version": {value},
  10354. * // "grade": {value}
  10355. * // }
  10356. * $(document).ready( function() {
  10357. * $('#example').dataTable( {
  10358. * "ajaxSource": "sources/objects.txt",
  10359. * "columns": [
  10360. * { "data": "engine" },
  10361. * { "data": "browser" },
  10362. * { "data": "platform" },
  10363. * { "data": "version" },
  10364. * { "data": "grade" }
  10365. * ]
  10366. * } );
  10367. * } );
  10368. *
  10369. * @example
  10370. * // Read information from deeply nested objects
  10371. * // JSON structure for each row:
  10372. * // {
  10373. * // "engine": {value},
  10374. * // "browser": {value},
  10375. * // "platform": {
  10376. * // "inner": {value}
  10377. * // },
  10378. * // "details": [
  10379. * // {value}, {value}
  10380. * // ]
  10381. * // }
  10382. * $(document).ready( function() {
  10383. * $('#example').dataTable( {
  10384. * "ajaxSource": "sources/deep.txt",
  10385. * "columns": [
  10386. * { "data": "engine" },
  10387. * { "data": "browser" },
  10388. * { "data": "platform.inner" },
  10389. * { "data": "platform.details.0" },
  10390. * { "data": "platform.details.1" }
  10391. * ]
  10392. * } );
  10393. * } );
  10394. *
  10395. * @example
  10396. * // Using `data` as a function to provide different information for
  10397. * // sorting, filtering and display. In this case, currency (price)
  10398. * $(document).ready( function() {
  10399. * $('#example').dataTable( {
  10400. * "columnDefs": [ {
  10401. * "targets": [ 0 ],
  10402. * "data": function ( source, type, val ) {
  10403. * if (type === 'set') {
  10404. * source.price = val;
  10405. * // Store the computed dislay and filter values for efficiency
  10406. * source.price_display = val=="" ? "" : "$"+numberFormat(val);
  10407. * source.price_filter = val=="" ? "" : "$"+numberFormat(val)+" "+val;
  10408. * return;
  10409. * }
  10410. * else if (type === 'display') {
  10411. * return source.price_display;
  10412. * }
  10413. * else if (type === 'filter') {
  10414. * return source.price_filter;
  10415. * }
  10416. * // 'sort', 'type' and undefined all just use the integer
  10417. * return source.price;
  10418. * }
  10419. * } ]
  10420. * } );
  10421. * } );
  10422. *
  10423. * @example
  10424. * // Using default content
  10425. * $(document).ready( function() {
  10426. * $('#example').dataTable( {
  10427. * "columnDefs": [ {
  10428. * "targets": [ 0 ],
  10429. * "data": null,
  10430. * "defaultContent": "Click to edit"
  10431. * } ]
  10432. * } );
  10433. * } );
  10434. *
  10435. * @example
  10436. * // Using array notation - outputting a list from an array
  10437. * $(document).ready( function() {
  10438. * $('#example').dataTable( {
  10439. * "columnDefs": [ {
  10440. * "targets": [ 0 ],
  10441. * "data": "name[, ]"
  10442. * } ]
  10443. * } );
  10444. * } );
  10445. *
  10446. */
  10447. "mData": null,
  10448. /**
  10449. * This property is the rendering partner to `data` and it is suggested that
  10450. * when you want to manipulate data for display (including filtering,
  10451. * sorting etc) without altering the underlying data for the table, use this
  10452. * property. `render` can be considered to be the the read only companion to
  10453. * `data` which is read / write (then as such more complex). Like `data`
  10454. * this option can be given in a number of different ways to effect its
  10455. * behaviour:
  10456. *
  10457. * * `integer` - treated as an array index for the data source. This is the
  10458. * default that DataTables uses (incrementally increased for each column).
  10459. * * `string` - read an object property from the data source. There are
  10460. * three 'special' options that can be used in the string to alter how
  10461. * DataTables reads the data from the source object:
  10462. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10463. * Javascript to read from nested objects, so to can the options
  10464. * specified in `data`. For example: `browser.version` or
  10465. * `browser.name`. If your object parameter name contains a period, use
  10466. * `\\` to escape it - i.e. `first\\.name`.
  10467. * * `[]` - Array notation. DataTables can automatically combine data
  10468. * from and array source, joining the data with the characters provided
  10469. * between the two brackets. For example: `name[, ]` would provide a
  10470. * comma-space separated list from the source array. If no characters
  10471. * are provided between the brackets, the original array source is
  10472. * returned.
  10473. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10474. * execute a function of the name given. For example: `browser()` for a
  10475. * simple function on the data source, `browser.version()` for a
  10476. * function in a nested property or even `browser().version` to get an
  10477. * object property if the function called returns an object.
  10478. * * `object` - use different data for the different data types requested by
  10479. * DataTables ('filter', 'display', 'type' or 'sort'). The property names
  10480. * of the object is the data type the property refers to and the value can
  10481. * defined using an integer, string or function using the same rules as
  10482. * `render` normally does. Note that an `_` option _must_ be specified.
  10483. * This is the default value to use if you haven't specified a value for
  10484. * the data type requested by DataTables.
  10485. * * `function` - the function given will be executed whenever DataTables
  10486. * needs to set or get the data for a cell in the column. The function
  10487. * takes three parameters:
  10488. * * Parameters:
  10489. * * {array|object} The data source for the row (based on `data`)
  10490. * * {string} The type call data requested - this will be 'filter',
  10491. * 'display', 'type' or 'sort'.
  10492. * * {array|object} The full data source for the row (not based on
  10493. * `data`)
  10494. * * Return:
  10495. * * The return value from the function is what will be used for the
  10496. * data requested.
  10497. *
  10498. * @type string|int|function|object|null
  10499. * @default null Use the data source value.
  10500. *
  10501. * @name DataTable.defaults.column.render
  10502. * @dtopt Columns
  10503. *
  10504. * @example
  10505. * // Create a comma separated list from an array of objects
  10506. * $(document).ready( function() {
  10507. * $('#example').dataTable( {
  10508. * "ajaxSource": "sources/deep.txt",
  10509. * "columns": [
  10510. * { "data": "engine" },
  10511. * { "data": "browser" },
  10512. * {
  10513. * "data": "platform",
  10514. * "render": "[, ].name"
  10515. * }
  10516. * ]
  10517. * } );
  10518. * } );
  10519. *
  10520. * @example
  10521. * // Execute a function to obtain data
  10522. * $(document).ready( function() {
  10523. * $('#example').dataTable( {
  10524. * "columnDefs": [ {
  10525. * "targets": [ 0 ],
  10526. * "data": null, // Use the full data source object for the renderer's source
  10527. * "render": "browserName()"
  10528. * } ]
  10529. * } );
  10530. * } );
  10531. *
  10532. * @example
  10533. * // As an object, extracting different data for the different types
  10534. * // This would be used with a data source such as:
  10535. * // { "phone": 5552368, "phone_filter": "5552368 555-2368", "phone_display": "555-2368" }
  10536. * // Here the `phone` integer is used for sorting and type detection, while `phone_filter`
  10537. * // (which has both forms) is used for filtering for if a user inputs either format, while
  10538. * // the formatted phone number is the one that is shown in the table.
  10539. * $(document).ready( function() {
  10540. * $('#example').dataTable( {
  10541. * "columnDefs": [ {
  10542. * "targets": [ 0 ],
  10543. * "data": null, // Use the full data source object for the renderer's source
  10544. * "render": {
  10545. * "_": "phone",
  10546. * "filter": "phone_filter",
  10547. * "display": "phone_display"
  10548. * }
  10549. * } ]
  10550. * } );
  10551. * } );
  10552. *
  10553. * @example
  10554. * // Use as a function to create a link from the data source
  10555. * $(document).ready( function() {
  10556. * $('#example').dataTable( {
  10557. * "columnDefs": [ {
  10558. * "targets": [ 0 ],
  10559. * "data": "download_link",
  10560. * "render": function ( data, type, full ) {
  10561. * return '<a href="'+data+'">Download</a>';
  10562. * }
  10563. * } ]
  10564. * } );
  10565. * } );
  10566. */
  10567. "mRender": null,
  10568. /**
  10569. * Change the cell type created for the column - either TD cells or TH cells. This
  10570. * can be useful as TH cells have semantic meaning in the table body, allowing them
  10571. * to act as a header for a row (you may wish to add scope='row' to the TH elements).
  10572. * @type string
  10573. * @default td
  10574. *
  10575. * @name DataTable.defaults.column.cellType
  10576. * @dtopt Columns
  10577. *
  10578. * @example
  10579. * // Make the first column use TH cells
  10580. * $(document).ready( function() {
  10581. * $('#example').dataTable( {
  10582. * "columnDefs": [ {
  10583. * "targets": [ 0 ],
  10584. * "cellType": "th"
  10585. * } ]
  10586. * } );
  10587. * } );
  10588. */
  10589. "sCellType": "td",
  10590. /**
  10591. * Class to give to each cell in this column.
  10592. * @type string
  10593. * @default <i>Empty string</i>
  10594. *
  10595. * @name DataTable.defaults.column.class
  10596. * @dtopt Columns
  10597. *
  10598. * @example
  10599. * // Using `columnDefs`
  10600. * $(document).ready( function() {
  10601. * $('#example').dataTable( {
  10602. * "columnDefs": [
  10603. * { "class": "my_class", "targets": [ 0 ] }
  10604. * ]
  10605. * } );
  10606. * } );
  10607. *
  10608. * @example
  10609. * // Using `columns`
  10610. * $(document).ready( function() {
  10611. * $('#example').dataTable( {
  10612. * "columns": [
  10613. * { "class": "my_class" },
  10614. * null,
  10615. * null,
  10616. * null,
  10617. * null
  10618. * ]
  10619. * } );
  10620. * } );
  10621. */
  10622. "sClass": "",
  10623. /**
  10624. * When DataTables calculates the column widths to assign to each column,
  10625. * it finds the longest string in each column and then constructs a
  10626. * temporary table and reads the widths from that. The problem with this
  10627. * is that "mmm" is much wider then "iiii", but the latter is a longer
  10628. * string - thus the calculation can go wrong (doing it properly and putting
  10629. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  10630. * a "work around" we provide this option. It will append its value to the
  10631. * text that is found to be the longest string for the column - i.e. padding.
  10632. * Generally you shouldn't need this!
  10633. * @type string
  10634. * @default <i>Empty string<i>
  10635. *
  10636. * @name DataTable.defaults.column.contentPadding
  10637. * @dtopt Columns
  10638. *
  10639. * @example
  10640. * // Using `columns`
  10641. * $(document).ready( function() {
  10642. * $('#example').dataTable( {
  10643. * "columns": [
  10644. * null,
  10645. * null,
  10646. * null,
  10647. * {
  10648. * "contentPadding": "mmm"
  10649. * }
  10650. * ]
  10651. * } );
  10652. * } );
  10653. */
  10654. "sContentPadding": "",
  10655. /**
  10656. * Allows a default value to be given for a column's data, and will be used
  10657. * whenever a null data source is encountered (this can be because `data`
  10658. * is set to null, or because the data source itself is null).
  10659. * @type string
  10660. * @default null
  10661. *
  10662. * @name DataTable.defaults.column.defaultContent
  10663. * @dtopt Columns
  10664. *
  10665. * @example
  10666. * // Using `columnDefs`
  10667. * $(document).ready( function() {
  10668. * $('#example').dataTable( {
  10669. * "columnDefs": [
  10670. * {
  10671. * "data": null,
  10672. * "defaultContent": "Edit",
  10673. * "targets": [ -1 ]
  10674. * }
  10675. * ]
  10676. * } );
  10677. * } );
  10678. *
  10679. * @example
  10680. * // Using `columns`
  10681. * $(document).ready( function() {
  10682. * $('#example').dataTable( {
  10683. * "columns": [
  10684. * null,
  10685. * null,
  10686. * null,
  10687. * {
  10688. * "data": null,
  10689. * "defaultContent": "Edit"
  10690. * }
  10691. * ]
  10692. * } );
  10693. * } );
  10694. */
  10695. "sDefaultContent": null,
  10696. /**
  10697. * This parameter is only used in DataTables' server-side processing. It can
  10698. * be exceptionally useful to know what columns are being displayed on the
  10699. * client side, and to map these to database fields. When defined, the names
  10700. * also allow DataTables to reorder information from the server if it comes
  10701. * back in an unexpected order (i.e. if you switch your columns around on the
  10702. * client-side, your server-side code does not also need updating).
  10703. * @type string
  10704. * @default <i>Empty string</i>
  10705. *
  10706. * @name DataTable.defaults.column.name
  10707. * @dtopt Columns
  10708. *
  10709. * @example
  10710. * // Using `columnDefs`
  10711. * $(document).ready( function() {
  10712. * $('#example').dataTable( {
  10713. * "columnDefs": [
  10714. * { "name": "engine", "targets": [ 0 ] },
  10715. * { "name": "browser", "targets": [ 1 ] },
  10716. * { "name": "platform", "targets": [ 2 ] },
  10717. * { "name": "version", "targets": [ 3 ] },
  10718. * { "name": "grade", "targets": [ 4 ] }
  10719. * ]
  10720. * } );
  10721. * } );
  10722. *
  10723. * @example
  10724. * // Using `columns`
  10725. * $(document).ready( function() {
  10726. * $('#example').dataTable( {
  10727. * "columns": [
  10728. * { "name": "engine" },
  10729. * { "name": "browser" },
  10730. * { "name": "platform" },
  10731. * { "name": "version" },
  10732. * { "name": "grade" }
  10733. * ]
  10734. * } );
  10735. * } );
  10736. */
  10737. "sName": "",
  10738. /**
  10739. * Defines a data source type for the ordering which can be used to read
  10740. * real-time information from the table (updating the internally cached
  10741. * version) prior to ordering. This allows ordering to occur on user
  10742. * editable elements such as form inputs.
  10743. * @type string
  10744. * @default std
  10745. *
  10746. * @name DataTable.defaults.column.orderDataType
  10747. * @dtopt Columns
  10748. *
  10749. * @example
  10750. * // Using `columnDefs`
  10751. * $(document).ready( function() {
  10752. * $('#example').dataTable( {
  10753. * "columnDefs": [
  10754. * { "orderDataType": "dom-text", "targets": [ 2, 3 ] },
  10755. * { "type": "numeric", "targets": [ 3 ] },
  10756. * { "orderDataType": "dom-select", "targets": [ 4 ] },
  10757. * { "orderDataType": "dom-checkbox", "targets": [ 5 ] }
  10758. * ]
  10759. * } );
  10760. * } );
  10761. *
  10762. * @example
  10763. * // Using `columns`
  10764. * $(document).ready( function() {
  10765. * $('#example').dataTable( {
  10766. * "columns": [
  10767. * null,
  10768. * null,
  10769. * { "orderDataType": "dom-text" },
  10770. * { "orderDataType": "dom-text", "type": "numeric" },
  10771. * { "orderDataType": "dom-select" },
  10772. * { "orderDataType": "dom-checkbox" }
  10773. * ]
  10774. * } );
  10775. * } );
  10776. */
  10777. "sSortDataType": "std",
  10778. /**
  10779. * The title of this column.
  10780. * @type string
  10781. * @default null <i>Derived from the 'TH' value for this column in the
  10782. * original HTML table.</i>
  10783. *
  10784. * @name DataTable.defaults.column.title
  10785. * @dtopt Columns
  10786. *
  10787. * @example
  10788. * // Using `columnDefs`
  10789. * $(document).ready( function() {
  10790. * $('#example').dataTable( {
  10791. * "columnDefs": [
  10792. * { "title": "My column title", "targets": [ 0 ] }
  10793. * ]
  10794. * } );
  10795. * } );
  10796. *
  10797. * @example
  10798. * // Using `columns`
  10799. * $(document).ready( function() {
  10800. * $('#example').dataTable( {
  10801. * "columns": [
  10802. * { "title": "My column title" },
  10803. * null,
  10804. * null,
  10805. * null,
  10806. * null
  10807. * ]
  10808. * } );
  10809. * } );
  10810. */
  10811. "sTitle": null,
  10812. /**
  10813. * The type allows you to specify how the data for this column will be
  10814. * ordered. Four types (string, numeric, date and html (which will strip
  10815. * HTML tags before ordering)) are currently available. Note that only date
  10816. * formats understood by Javascript's Date() object will be accepted as type
  10817. * date. For example: "Mar 26, 2008 5:03 PM". May take the values: 'string',
  10818. * 'numeric', 'date' or 'html' (by default). Further types can be adding
  10819. * through plug-ins.
  10820. * @type string
  10821. * @default null <i>Auto-detected from raw data</i>
  10822. *
  10823. * @name DataTable.defaults.column.type
  10824. * @dtopt Columns
  10825. *
  10826. * @example
  10827. * // Using `columnDefs`
  10828. * $(document).ready( function() {
  10829. * $('#example').dataTable( {
  10830. * "columnDefs": [
  10831. * { "type": "html", "targets": [ 0 ] }
  10832. * ]
  10833. * } );
  10834. * } );
  10835. *
  10836. * @example
  10837. * // Using `columns`
  10838. * $(document).ready( function() {
  10839. * $('#example').dataTable( {
  10840. * "columns": [
  10841. * { "type": "html" },
  10842. * null,
  10843. * null,
  10844. * null,
  10845. * null
  10846. * ]
  10847. * } );
  10848. * } );
  10849. */
  10850. "sType": null,
  10851. /**
  10852. * Defining the width of the column, this parameter may take any CSS value
  10853. * (3em, 20px etc). DataTables applies 'smart' widths to columns which have not
  10854. * been given a specific width through this interface ensuring that the table
  10855. * remains readable.
  10856. * @type string
  10857. * @default null <i>Automatic</i>
  10858. *
  10859. * @name DataTable.defaults.column.width
  10860. * @dtopt Columns
  10861. *
  10862. * @example
  10863. * // Using `columnDefs`
  10864. * $(document).ready( function() {
  10865. * $('#example').dataTable( {
  10866. * "columnDefs": [
  10867. * { "width": "20%", "targets": [ 0 ] }
  10868. * ]
  10869. * } );
  10870. * } );
  10871. *
  10872. * @example
  10873. * // Using `columns`
  10874. * $(document).ready( function() {
  10875. * $('#example').dataTable( {
  10876. * "columns": [
  10877. * { "width": "20%" },
  10878. * null,
  10879. * null,
  10880. * null,
  10881. * null
  10882. * ]
  10883. * } );
  10884. * } );
  10885. */
  10886. "sWidth": null
  10887. };
  10888. _fnHungarianMap( DataTable.defaults.column );
  10889. /**
  10890. * DataTables settings object - this holds all the information needed for a
  10891. * given table, including configuration, data and current application of the
  10892. * table options. DataTables does not have a single instance for each DataTable
  10893. * with the settings attached to that instance, but rather instances of the
  10894. * DataTable "class" are created on-the-fly as needed (typically by a
  10895. * $().dataTable() call) and the settings object is then applied to that
  10896. * instance.
  10897. *
  10898. * Note that this object is related to {@link DataTable.defaults} but this
  10899. * one is the internal data store for DataTables's cache of columns. It should
  10900. * NOT be manipulated outside of DataTables. Any configuration should be done
  10901. * through the initialisation options.
  10902. * @namespace
  10903. * @todo Really should attach the settings object to individual instances so we
  10904. * don't need to create new instances on each $().dataTable() call (if the
  10905. * table already exists). It would also save passing oSettings around and
  10906. * into every single function. However, this is a very significant
  10907. * architecture change for DataTables and will almost certainly break
  10908. * backwards compatibility with older installations. This is something that
  10909. * will be done in 2.0.
  10910. */
  10911. DataTable.models.oSettings = {
  10912. /**
  10913. * Primary features of DataTables and their enablement state.
  10914. * @namespace
  10915. */
  10916. "oFeatures": {
  10917. /**
  10918. * Flag to say if DataTables should automatically try to calculate the
  10919. * optimum table and columns widths (true) or not (false).
  10920. * Note that this parameter will be set by the initialisation routine. To
  10921. * set a default use {@link DataTable.defaults}.
  10922. * @type boolean
  10923. */
  10924. "bAutoWidth": null,
  10925. /**
  10926. * Delay the creation of TR and TD elements until they are actually
  10927. * needed by a driven page draw. This can give a significant speed
  10928. * increase for Ajax source and Javascript source data, but makes no
  10929. * difference at all fro DOM and server-side processing tables.
  10930. * Note that this parameter will be set by the initialisation routine. To
  10931. * set a default use {@link DataTable.defaults}.
  10932. * @type boolean
  10933. */
  10934. "bDeferRender": null,
  10935. /**
  10936. * Enable filtering on the table or not. Note that if this is disabled
  10937. * then there is no filtering at all on the table, including fnFilter.
  10938. * To just remove the filtering input use sDom and remove the 'f' option.
  10939. * Note that this parameter will be set by the initialisation routine. To
  10940. * set a default use {@link DataTable.defaults}.
  10941. * @type boolean
  10942. */
  10943. "bFilter": null,
  10944. /**
  10945. * Table information element (the 'Showing x of y records' div) enable
  10946. * flag.
  10947. * Note that this parameter will be set by the initialisation routine. To
  10948. * set a default use {@link DataTable.defaults}.
  10949. * @type boolean
  10950. */
  10951. "bInfo": null,
  10952. /**
  10953. * Present a user control allowing the end user to change the page size
  10954. * when pagination is enabled.
  10955. * Note that this parameter will be set by the initialisation routine. To
  10956. * set a default use {@link DataTable.defaults}.
  10957. * @type boolean
  10958. */
  10959. "bLengthChange": null,
  10960. /**
  10961. * Pagination enabled or not. Note that if this is disabled then length
  10962. * changing must also be disabled.
  10963. * Note that this parameter will be set by the initialisation routine. To
  10964. * set a default use {@link DataTable.defaults}.
  10965. * @type boolean
  10966. */
  10967. "bPaginate": null,
  10968. /**
  10969. * Processing indicator enable flag whenever DataTables is enacting a
  10970. * user request - typically an Ajax request for server-side processing.
  10971. * Note that this parameter will be set by the initialisation routine. To
  10972. * set a default use {@link DataTable.defaults}.
  10973. * @type boolean
  10974. */
  10975. "bProcessing": null,
  10976. /**
  10977. * Server-side processing enabled flag - when enabled DataTables will
  10978. * get all data from the server for every draw - there is no filtering,
  10979. * sorting or paging done on the client-side.
  10980. * Note that this parameter will be set by the initialisation routine. To
  10981. * set a default use {@link DataTable.defaults}.
  10982. * @type boolean
  10983. */
  10984. "bServerSide": null,
  10985. /**
  10986. * Sorting enablement flag.
  10987. * Note that this parameter will be set by the initialisation routine. To
  10988. * set a default use {@link DataTable.defaults}.
  10989. * @type boolean
  10990. */
  10991. "bSort": null,
  10992. /**
  10993. * Multi-column sorting
  10994. * Note that this parameter will be set by the initialisation routine. To
  10995. * set a default use {@link DataTable.defaults}.
  10996. * @type boolean
  10997. */
  10998. "bSortMulti": null,
  10999. /**
  11000. * Apply a class to the columns which are being sorted to provide a
  11001. * visual highlight or not. This can slow things down when enabled since
  11002. * there is a lot of DOM interaction.
  11003. * Note that this parameter will be set by the initialisation routine. To
  11004. * set a default use {@link DataTable.defaults}.
  11005. * @type boolean
  11006. */
  11007. "bSortClasses": null,
  11008. /**
  11009. * State saving enablement flag.
  11010. * Note that this parameter will be set by the initialisation routine. To
  11011. * set a default use {@link DataTable.defaults}.
  11012. * @type boolean
  11013. */
  11014. "bStateSave": null
  11015. },
  11016. /**
  11017. * Scrolling settings for a table.
  11018. * @namespace
  11019. */
  11020. "oScroll": {
  11021. /**
  11022. * When the table is shorter in height than sScrollY, collapse the
  11023. * table container down to the height of the table (when true).
  11024. * Note that this parameter will be set by the initialisation routine. To
  11025. * set a default use {@link DataTable.defaults}.
  11026. * @type boolean
  11027. */
  11028. "bCollapse": null,
  11029. /**
  11030. * Width of the scrollbar for the web-browser's platform. Calculated
  11031. * during table initialisation.
  11032. * @type int
  11033. * @default 0
  11034. */
  11035. "iBarWidth": 0,
  11036. /**
  11037. * Viewport width for horizontal scrolling. Horizontal scrolling is
  11038. * disabled if an empty string.
  11039. * Note that this parameter will be set by the initialisation routine. To
  11040. * set a default use {@link DataTable.defaults}.
  11041. * @type string
  11042. */
  11043. "sX": null,
  11044. /**
  11045. * Width to expand the table to when using x-scrolling. Typically you
  11046. * should not need to use this.
  11047. * Note that this parameter will be set by the initialisation routine. To
  11048. * set a default use {@link DataTable.defaults}.
  11049. * @type string
  11050. * @deprecated
  11051. */
  11052. "sXInner": null,
  11053. /**
  11054. * Viewport height for vertical scrolling. Vertical scrolling is disabled
  11055. * if an empty string.
  11056. * Note that this parameter will be set by the initialisation routine. To
  11057. * set a default use {@link DataTable.defaults}.
  11058. * @type string
  11059. */
  11060. "sY": null
  11061. },
  11062. /**
  11063. * Language information for the table.
  11064. * @namespace
  11065. * @extends DataTable.defaults.oLanguage
  11066. */
  11067. "oLanguage": {
  11068. /**
  11069. * Information callback function. See
  11070. * {@link DataTable.defaults.fnInfoCallback}
  11071. * @type function
  11072. * @default null
  11073. */
  11074. "fnInfoCallback": null
  11075. },
  11076. /**
  11077. * Browser support parameters
  11078. * @namespace
  11079. */
  11080. "oBrowser": {
  11081. /**
  11082. * Indicate if the browser incorrectly calculates width:100% inside a
  11083. * scrolling element (IE6/7)
  11084. * @type boolean
  11085. * @default false
  11086. */
  11087. "bScrollOversize": false,
  11088. /**
  11089. * Determine if the vertical scrollbar is on the right or left of the
  11090. * scrolling container - needed for rtl language layout, although not
  11091. * all browsers move the scrollbar (Safari).
  11092. * @type boolean
  11093. * @default false
  11094. */
  11095. "bScrollbarLeft": false
  11096. },
  11097. "ajax": null,
  11098. /**
  11099. * Array referencing the nodes which are used for the features. The
  11100. * parameters of this object match what is allowed by sDom - i.e.
  11101. * <ul>
  11102. * <li>'l' - Length changing</li>
  11103. * <li>'f' - Filtering input</li>
  11104. * <li>'t' - The table!</li>
  11105. * <li>'i' - Information</li>
  11106. * <li>'p' - Pagination</li>
  11107. * <li>'r' - pRocessing</li>
  11108. * </ul>
  11109. * @type array
  11110. * @default []
  11111. */
  11112. "aanFeatures": [],
  11113. /**
  11114. * Store data information - see {@link DataTable.models.oRow} for detailed
  11115. * information.
  11116. * @type array
  11117. * @default []
  11118. */
  11119. "aoData": [],
  11120. /**
  11121. * Array of indexes which are in the current display (after filtering etc)
  11122. * @type array
  11123. * @default []
  11124. */
  11125. "aiDisplay": [],
  11126. /**
  11127. * Array of indexes for display - no filtering
  11128. * @type array
  11129. * @default []
  11130. */
  11131. "aiDisplayMaster": [],
  11132. /**
  11133. * Store information about each column that is in use
  11134. * @type array
  11135. * @default []
  11136. */
  11137. "aoColumns": [],
  11138. /**
  11139. * Store information about the table's header
  11140. * @type array
  11141. * @default []
  11142. */
  11143. "aoHeader": [],
  11144. /**
  11145. * Store information about the table's footer
  11146. * @type array
  11147. * @default []
  11148. */
  11149. "aoFooter": [],
  11150. /**
  11151. * Store the applied global search information in case we want to force a
  11152. * research or compare the old search to a new one.
  11153. * Note that this parameter will be set by the initialisation routine. To
  11154. * set a default use {@link DataTable.defaults}.
  11155. * @namespace
  11156. * @extends DataTable.models.oSearch
  11157. */
  11158. "oPreviousSearch": {},
  11159. /**
  11160. * Store the applied search for each column - see
  11161. * {@link DataTable.models.oSearch} for the format that is used for the
  11162. * filtering information for each column.
  11163. * @type array
  11164. * @default []
  11165. */
  11166. "aoPreSearchCols": [],
  11167. /**
  11168. * Sorting that is applied to the table. Note that the inner arrays are
  11169. * used in the following manner:
  11170. * <ul>
  11171. * <li>Index 0 - column number</li>
  11172. * <li>Index 1 - current sorting direction</li>
  11173. * </ul>
  11174. * Note that this parameter will be set by the initialisation routine. To
  11175. * set a default use {@link DataTable.defaults}.
  11176. * @type array
  11177. * @todo These inner arrays should really be objects
  11178. */
  11179. "aaSorting": null,
  11180. /**
  11181. * Sorting that is always applied to the table (i.e. prefixed in front of
  11182. * aaSorting).
  11183. * Note that this parameter will be set by the initialisation routine. To
  11184. * set a default use {@link DataTable.defaults}.
  11185. * @type array
  11186. * @default []
  11187. */
  11188. "aaSortingFixed": [],
  11189. /**
  11190. * Classes to use for the striping of a table.
  11191. * Note that this parameter will be set by the initialisation routine. To
  11192. * set a default use {@link DataTable.defaults}.
  11193. * @type array
  11194. * @default []
  11195. */
  11196. "asStripeClasses": null,
  11197. /**
  11198. * If restoring a table - we should restore its striping classes as well
  11199. * @type array
  11200. * @default []
  11201. */
  11202. "asDestroyStripes": [],
  11203. /**
  11204. * If restoring a table - we should restore its width
  11205. * @type int
  11206. * @default 0
  11207. */
  11208. "sDestroyWidth": 0,
  11209. /**
  11210. * Callback functions array for every time a row is inserted (i.e. on a draw).
  11211. * @type array
  11212. * @default []
  11213. */
  11214. "aoRowCallback": [],
  11215. /**
  11216. * Callback functions for the header on each draw.
  11217. * @type array
  11218. * @default []
  11219. */
  11220. "aoHeaderCallback": [],
  11221. /**
  11222. * Callback function for the footer on each draw.
  11223. * @type array
  11224. * @default []
  11225. */
  11226. "aoFooterCallback": [],
  11227. /**
  11228. * Array of callback functions for draw callback functions
  11229. * @type array
  11230. * @default []
  11231. */
  11232. "aoDrawCallback": [],
  11233. /**
  11234. * Array of callback functions for row created function
  11235. * @type array
  11236. * @default []
  11237. */
  11238. "aoRowCreatedCallback": [],
  11239. /**
  11240. * Callback functions for just before the table is redrawn. A return of
  11241. * false will be used to cancel the draw.
  11242. * @type array
  11243. * @default []
  11244. */
  11245. "aoPreDrawCallback": [],
  11246. /**
  11247. * Callback functions for when the table has been initialised.
  11248. * @type array
  11249. * @default []
  11250. */
  11251. "aoInitComplete": [],
  11252. /**
  11253. * Callbacks for modifying the settings to be stored for state saving, prior to
  11254. * saving state.
  11255. * @type array
  11256. * @default []
  11257. */
  11258. "aoStateSaveParams": [],
  11259. /**
  11260. * Callbacks for modifying the settings that have been stored for state saving
  11261. * prior to using the stored values to restore the state.
  11262. * @type array
  11263. * @default []
  11264. */
  11265. "aoStateLoadParams": [],
  11266. /**
  11267. * Callbacks for operating on the settings object once the saved state has been
  11268. * loaded
  11269. * @type array
  11270. * @default []
  11271. */
  11272. "aoStateLoaded": [],
  11273. /**
  11274. * Cache the table ID for quick access
  11275. * @type string
  11276. * @default <i>Empty string</i>
  11277. */
  11278. "sTableId": "",
  11279. /**
  11280. * The TABLE node for the main table
  11281. * @type node
  11282. * @default null
  11283. */
  11284. "nTable": null,
  11285. /**
  11286. * Permanent ref to the thead element
  11287. * @type node
  11288. * @default null
  11289. */
  11290. "nTHead": null,
  11291. /**
  11292. * Permanent ref to the tfoot element - if it exists
  11293. * @type node
  11294. * @default null
  11295. */
  11296. "nTFoot": null,
  11297. /**
  11298. * Permanent ref to the tbody element
  11299. * @type node
  11300. * @default null
  11301. */
  11302. "nTBody": null,
  11303. /**
  11304. * Cache the wrapper node (contains all DataTables controlled elements)
  11305. * @type node
  11306. * @default null
  11307. */
  11308. "nTableWrapper": null,
  11309. /**
  11310. * Indicate if when using server-side processing the loading of data
  11311. * should be deferred until the second draw.
  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. * @default false
  11316. */
  11317. "bDeferLoading": false,
  11318. /**
  11319. * Indicate if all required information has been read in
  11320. * @type boolean
  11321. * @default false
  11322. */
  11323. "bInitialised": false,
  11324. /**
  11325. * Information about open rows. Each object in the array has the parameters
  11326. * 'nTr' and 'nParent'
  11327. * @type array
  11328. * @default []
  11329. */
  11330. "aoOpenRows": [],
  11331. /**
  11332. * Dictate the positioning of DataTables' control elements - see
  11333. * {@link DataTable.model.oInit.sDom}.
  11334. * Note that this parameter will be set by the initialisation routine. To
  11335. * set a default use {@link DataTable.defaults}.
  11336. * @type string
  11337. * @default null
  11338. */
  11339. "sDom": null,
  11340. /**
  11341. * Search delay (in mS)
  11342. * @type integer
  11343. * @default null
  11344. */
  11345. "searchDelay": null,
  11346. /**
  11347. * Which type of pagination should be used.
  11348. * Note that this parameter will be set by the initialisation routine. To
  11349. * set a default use {@link DataTable.defaults}.
  11350. * @type string
  11351. * @default two_button
  11352. */
  11353. "sPaginationType": "two_button",
  11354. /**
  11355. * The state duration (for `stateSave`) in seconds.
  11356. * Note that this parameter will be set by the initialisation routine. To
  11357. * set a default use {@link DataTable.defaults}.
  11358. * @type int
  11359. * @default 0
  11360. */
  11361. "iStateDuration": 0,
  11362. /**
  11363. * Array of callback functions for state saving. Each array element is an
  11364. * object with the following parameters:
  11365. * <ul>
  11366. * <li>function:fn - function to call. Takes two parameters, oSettings
  11367. * and the JSON string to save that has been thus far created. Returns
  11368. * a JSON string to be inserted into a json object
  11369. * (i.e. '"param": [ 0, 1, 2]')</li>
  11370. * <li>string:sName - name of callback</li>
  11371. * </ul>
  11372. * @type array
  11373. * @default []
  11374. */
  11375. "aoStateSave": [],
  11376. /**
  11377. * Array of callback functions for state loading. Each array element is an
  11378. * object with the following parameters:
  11379. * <ul>
  11380. * <li>function:fn - function to call. Takes two parameters, oSettings
  11381. * and the object stored. May return false to cancel state loading</li>
  11382. * <li>string:sName - name of callback</li>
  11383. * </ul>
  11384. * @type array
  11385. * @default []
  11386. */
  11387. "aoStateLoad": [],
  11388. /**
  11389. * State that was saved. Useful for back reference
  11390. * @type object
  11391. * @default null
  11392. */
  11393. "oSavedState": null,
  11394. /**
  11395. * State that was loaded. Useful for back reference
  11396. * @type object
  11397. * @default null
  11398. */
  11399. "oLoadedState": null,
  11400. /**
  11401. * Source url for AJAX data for the table.
  11402. * Note that this parameter will be set by the initialisation routine. To
  11403. * set a default use {@link DataTable.defaults}.
  11404. * @type string
  11405. * @default null
  11406. */
  11407. "sAjaxSource": null,
  11408. /**
  11409. * Property from a given object from which to read the table data from. This
  11410. * can be an empty string (when not server-side processing), in which case
  11411. * it is assumed an an array is given directly.
  11412. * Note that this parameter will be set by the initialisation routine. To
  11413. * set a default use {@link DataTable.defaults}.
  11414. * @type string
  11415. */
  11416. "sAjaxDataProp": null,
  11417. /**
  11418. * Note if draw should be blocked while getting data
  11419. * @type boolean
  11420. * @default true
  11421. */
  11422. "bAjaxDataGet": true,
  11423. /**
  11424. * The last jQuery XHR object that was used for server-side data gathering.
  11425. * This can be used for working with the XHR information in one of the
  11426. * callbacks
  11427. * @type object
  11428. * @default null
  11429. */
  11430. "jqXHR": null,
  11431. /**
  11432. * JSON returned from the server in the last Ajax request
  11433. * @type object
  11434. * @default undefined
  11435. */
  11436. "json": undefined,
  11437. /**
  11438. * Data submitted as part of the last Ajax request
  11439. * @type object
  11440. * @default undefined
  11441. */
  11442. "oAjaxData": undefined,
  11443. /**
  11444. * Function to get the server-side data.
  11445. * Note that this parameter will be set by the initialisation routine. To
  11446. * set a default use {@link DataTable.defaults}.
  11447. * @type function
  11448. */
  11449. "fnServerData": null,
  11450. /**
  11451. * Functions which are called prior to sending an Ajax request so extra
  11452. * parameters can easily be sent to the server
  11453. * @type array
  11454. * @default []
  11455. */
  11456. "aoServerParams": [],
  11457. /**
  11458. * Send the XHR HTTP method - GET or POST (could be PUT or DELETE if
  11459. * required).
  11460. * Note that this parameter will be set by the initialisation routine. To
  11461. * set a default use {@link DataTable.defaults}.
  11462. * @type string
  11463. */
  11464. "sServerMethod": null,
  11465. /**
  11466. * Format numbers for display.
  11467. * Note that this parameter will be set by the initialisation routine. To
  11468. * set a default use {@link DataTable.defaults}.
  11469. * @type function
  11470. */
  11471. "fnFormatNumber": null,
  11472. /**
  11473. * List of options that can be used for the user selectable length menu.
  11474. * Note that this parameter will be set by the initialisation routine. To
  11475. * set a default use {@link DataTable.defaults}.
  11476. * @type array
  11477. * @default []
  11478. */
  11479. "aLengthMenu": null,
  11480. /**
  11481. * Counter for the draws that the table does. Also used as a tracker for
  11482. * server-side processing
  11483. * @type int
  11484. * @default 0
  11485. */
  11486. "iDraw": 0,
  11487. /**
  11488. * Indicate if a redraw is being done - useful for Ajax
  11489. * @type boolean
  11490. * @default false
  11491. */
  11492. "bDrawing": false,
  11493. /**
  11494. * Draw index (iDraw) of the last error when parsing the returned data
  11495. * @type int
  11496. * @default -1
  11497. */
  11498. "iDrawError": -1,
  11499. /**
  11500. * Paging display length
  11501. * @type int
  11502. * @default 10
  11503. */
  11504. "_iDisplayLength": 10,
  11505. /**
  11506. * Paging start point - aiDisplay index
  11507. * @type int
  11508. * @default 0
  11509. */
  11510. "_iDisplayStart": 0,
  11511. /**
  11512. * Server-side processing - number of records in the result set
  11513. * (i.e. before filtering), Use fnRecordsTotal rather than
  11514. * this property to get the value of the number of records, regardless of
  11515. * the server-side processing setting.
  11516. * @type int
  11517. * @default 0
  11518. * @private
  11519. */
  11520. "_iRecordsTotal": 0,
  11521. /**
  11522. * Server-side processing - number of records in the current display set
  11523. * (i.e. after filtering). Use fnRecordsDisplay rather than
  11524. * this property to get the value of the number of records, regardless of
  11525. * the server-side processing setting.
  11526. * @type boolean
  11527. * @default 0
  11528. * @private
  11529. */
  11530. "_iRecordsDisplay": 0,
  11531. /**
  11532. * Flag to indicate if jQuery UI marking and classes should be used.
  11533. * Note that this parameter will be set by the initialisation routine. To
  11534. * set a default use {@link DataTable.defaults}.
  11535. * @type boolean
  11536. */
  11537. "bJUI": null,
  11538. /**
  11539. * The classes to use for the table
  11540. * @type object
  11541. * @default {}
  11542. */
  11543. "oClasses": {},
  11544. /**
  11545. * Flag attached to the settings object so you can check in the draw
  11546. * callback if filtering has been done in the draw. Deprecated in favour of
  11547. * events.
  11548. * @type boolean
  11549. * @default false
  11550. * @deprecated
  11551. */
  11552. "bFiltered": false,
  11553. /**
  11554. * Flag attached to the settings object so you can check in the draw
  11555. * callback if sorting has been done in the draw. Deprecated in favour of
  11556. * events.
  11557. * @type boolean
  11558. * @default false
  11559. * @deprecated
  11560. */
  11561. "bSorted": false,
  11562. /**
  11563. * Indicate that if multiple rows are in the header and there is more than
  11564. * one unique cell per column, if the top one (true) or bottom one (false)
  11565. * should be used for sorting / title by DataTables.
  11566. * Note that this parameter will be set by the initialisation routine. To
  11567. * set a default use {@link DataTable.defaults}.
  11568. * @type boolean
  11569. */
  11570. "bSortCellsTop": null,
  11571. /**
  11572. * Initialisation object that is used for the table
  11573. * @type object
  11574. * @default null
  11575. */
  11576. "oInit": null,
  11577. /**
  11578. * Destroy callback functions - for plug-ins to attach themselves to the
  11579. * destroy so they can clean up markup and events.
  11580. * @type array
  11581. * @default []
  11582. */
  11583. "aoDestroyCallback": [],
  11584. /**
  11585. * Get the number of records in the current record set, before filtering
  11586. * @type function
  11587. */
  11588. "fnRecordsTotal": function ()
  11589. {
  11590. return _fnDataSource( this ) == 'ssp' ?
  11591. this._iRecordsTotal * 1 :
  11592. this.aiDisplayMaster.length;
  11593. },
  11594. /**
  11595. * Get the number of records in the current record set, after filtering
  11596. * @type function
  11597. */
  11598. "fnRecordsDisplay": function ()
  11599. {
  11600. return _fnDataSource( this ) == 'ssp' ?
  11601. this._iRecordsDisplay * 1 :
  11602. this.aiDisplay.length;
  11603. },
  11604. /**
  11605. * Get the display end point - aiDisplay index
  11606. * @type function
  11607. */
  11608. "fnDisplayEnd": function ()
  11609. {
  11610. var
  11611. len = this._iDisplayLength,
  11612. start = this._iDisplayStart,
  11613. calc = start + len,
  11614. records = this.aiDisplay.length,
  11615. features = this.oFeatures,
  11616. paginate = features.bPaginate;
  11617. if ( features.bServerSide ) {
  11618. return paginate === false || len === -1 ?
  11619. start + records :
  11620. Math.min( start+len, this._iRecordsDisplay );
  11621. }
  11622. else {
  11623. return ! paginate || calc>records || len===-1 ?
  11624. records :
  11625. calc;
  11626. }
  11627. },
  11628. /**
  11629. * The DataTables object for this table
  11630. * @type object
  11631. * @default null
  11632. */
  11633. "oInstance": null,
  11634. /**
  11635. * Unique identifier for each instance of the DataTables object. If there
  11636. * is an ID on the table node, then it takes that value, otherwise an
  11637. * incrementing internal counter is used.
  11638. * @type string
  11639. * @default null
  11640. */
  11641. "sInstance": null,
  11642. /**
  11643. * tabindex attribute value that is added to DataTables control elements, allowing
  11644. * keyboard navigation of the table and its controls.
  11645. */
  11646. "iTabIndex": 0,
  11647. /**
  11648. * DIV container for the footer scrolling table if scrolling
  11649. */
  11650. "nScrollHead": null,
  11651. /**
  11652. * DIV container for the footer scrolling table if scrolling
  11653. */
  11654. "nScrollFoot": null,
  11655. /**
  11656. * Last applied sort
  11657. * @type array
  11658. * @default []
  11659. */
  11660. "aLastSort": [],
  11661. /**
  11662. * Stored plug-in instances
  11663. * @type object
  11664. * @default {}
  11665. */
  11666. "oPlugins": {}
  11667. };
  11668. /**
  11669. * Extension object for DataTables that is used to provide all extension
  11670. * options.
  11671. *
  11672. * Note that the `DataTable.ext` object is available through
  11673. * `jQuery.fn.dataTable.ext` where it may be accessed and manipulated. It is
  11674. * also aliased to `jQuery.fn.dataTableExt` for historic reasons.
  11675. * @namespace
  11676. * @extends DataTable.models.ext
  11677. */
  11678. /**
  11679. * DataTables extensions
  11680. *
  11681. * This namespace acts as a collection area for plug-ins that can be used to
  11682. * extend DataTables capabilities. Indeed many of the build in methods
  11683. * use this method to provide their own capabilities (sorting methods for
  11684. * example).
  11685. *
  11686. * Note that this namespace is aliased to `jQuery.fn.dataTableExt` for legacy
  11687. * reasons
  11688. *
  11689. * @namespace
  11690. */
  11691. DataTable.ext = _ext = {
  11692. /**
  11693. * Element class names
  11694. *
  11695. * @type object
  11696. * @default {}
  11697. */
  11698. classes: {},
  11699. /**
  11700. * Error reporting.
  11701. *
  11702. * How should DataTables report an error. Can take the value 'alert' or
  11703. * 'throw'
  11704. *
  11705. * @type string
  11706. * @default alert
  11707. */
  11708. errMode: "alert",
  11709. /**
  11710. * Feature plug-ins.
  11711. *
  11712. * This is an array of objects which describe the feature plug-ins that are
  11713. * available to DataTables. These feature plug-ins are then available for
  11714. * use through the `dom` initialisation option.
  11715. *
  11716. * Each feature plug-in is described by an object which must have the
  11717. * following properties:
  11718. *
  11719. * * `fnInit` - function that is used to initialise the plug-in,
  11720. * * `cFeature` - a character so the feature can be enabled by the `dom`
  11721. * instillation option. This is case sensitive.
  11722. *
  11723. * The `fnInit` function has the following input parameters:
  11724. *
  11725. * 1. `{object}` DataTables settings object: see
  11726. * {@link DataTable.models.oSettings}
  11727. *
  11728. * And the following return is expected:
  11729. *
  11730. * * {node|null} The element which contains your feature. Note that the
  11731. * return may also be void if your plug-in does not require to inject any
  11732. * DOM elements into DataTables control (`dom`) - for example this might
  11733. * be useful when developing a plug-in which allows table control via
  11734. * keyboard entry
  11735. *
  11736. * @type array
  11737. *
  11738. * @example
  11739. * $.fn.dataTable.ext.features.push( {
  11740. * "fnInit": function( oSettings ) {
  11741. * return new TableTools( { "oDTSettings": oSettings } );
  11742. * },
  11743. * "cFeature": "T"
  11744. * } );
  11745. */
  11746. feature: [],
  11747. /**
  11748. * Row searching.
  11749. *
  11750. * This method of searching is complimentary to the default type based
  11751. * searching, and a lot more comprehensive as it allows you complete control
  11752. * over the searching logic. Each element in this array is a function
  11753. * (parameters described below) that is called for every row in the table,
  11754. * and your logic decides if it should be included in the searching data set
  11755. * or not.
  11756. *
  11757. * Searching functions have the following input parameters:
  11758. *
  11759. * 1. `{object}` DataTables settings object: see
  11760. * {@link DataTable.models.oSettings}
  11761. * 2. `{array|object}` Data for the row to be processed (same as the
  11762. * original format that was passed in as the data source, or an array
  11763. * from a DOM data source
  11764. * 3. `{int}` Row index ({@link DataTable.models.oSettings.aoData}), which
  11765. * can be useful to retrieve the `TR` element if you need DOM interaction.
  11766. *
  11767. * And the following return is expected:
  11768. *
  11769. * * {boolean} Include the row in the searched result set (true) or not
  11770. * (false)
  11771. *
  11772. * Note that as with the main search ability in DataTables, technically this
  11773. * is "filtering", since it is subtractive. However, for consistency in
  11774. * naming we call it searching here.
  11775. *
  11776. * @type array
  11777. * @default []
  11778. *
  11779. * @example
  11780. * // The following example shows custom search being applied to the
  11781. * // fourth column (i.e. the data[3] index) based on two input values
  11782. * // from the end-user, matching the data in a certain range.
  11783. * $.fn.dataTable.ext.search.push(
  11784. * function( settings, data, dataIndex ) {
  11785. * var min = document.getElementById('min').value * 1;
  11786. * var max = document.getElementById('max').value * 1;
  11787. * var version = data[3] == "-" ? 0 : data[3]*1;
  11788. *
  11789. * if ( min == "" && max == "" ) {
  11790. * return true;
  11791. * }
  11792. * else if ( min == "" && version < max ) {
  11793. * return true;
  11794. * }
  11795. * else if ( min < version && "" == max ) {
  11796. * return true;
  11797. * }
  11798. * else if ( min < version && version < max ) {
  11799. * return true;
  11800. * }
  11801. * return false;
  11802. * }
  11803. * );
  11804. */
  11805. search: [],
  11806. /**
  11807. * Internal functions, exposed for used in plug-ins.
  11808. *
  11809. * Please note that you should not need to use the internal methods for
  11810. * anything other than a plug-in (and even then, try to avoid if possible).
  11811. * The internal function may change between releases.
  11812. *
  11813. * @type object
  11814. * @default {}
  11815. */
  11816. internal: {},
  11817. /**
  11818. * Legacy configuration options. Enable and disable legacy options that
  11819. * are available in DataTables.
  11820. *
  11821. * @type object
  11822. */
  11823. legacy: {
  11824. /**
  11825. * Enable / disable DataTables 1.9 compatible server-side processing
  11826. * requests
  11827. *
  11828. * @type boolean
  11829. * @default null
  11830. */
  11831. ajax: null
  11832. },
  11833. /**
  11834. * Pagination plug-in methods.
  11835. *
  11836. * Each entry in this object is a function and defines which buttons should
  11837. * be shown by the pagination rendering method that is used for the table:
  11838. * {@link DataTable.ext.renderer.pageButton}. The renderer addresses how the
  11839. * buttons are displayed in the document, while the functions here tell it
  11840. * what buttons to display. This is done by returning an array of button
  11841. * descriptions (what each button will do).
  11842. *
  11843. * Pagination types (the four built in options and any additional plug-in
  11844. * options defined here) can be used through the `paginationType`
  11845. * initialisation parameter.
  11846. *
  11847. * The functions defined take two parameters:
  11848. *
  11849. * 1. `{int} page` The current page index
  11850. * 2. `{int} pages` The number of pages in the table
  11851. *
  11852. * Each function is expected to return an array where each element of the
  11853. * array can be one of:
  11854. *
  11855. * * `first` - Jump to first page when activated
  11856. * * `last` - Jump to last page when activated
  11857. * * `previous` - Show previous page when activated
  11858. * * `next` - Show next page when activated
  11859. * * `{int}` - Show page of the index given
  11860. * * `{array}` - A nested array containing the above elements to add a
  11861. * containing 'DIV' element (might be useful for styling).
  11862. *
  11863. * Note that DataTables v1.9- used this object slightly differently whereby
  11864. * an object with two functions would be defined for each plug-in. That
  11865. * ability is still supported by DataTables 1.10+ to provide backwards
  11866. * compatibility, but this option of use is now decremented and no longer
  11867. * documented in DataTables 1.10+.
  11868. *
  11869. * @type object
  11870. * @default {}
  11871. *
  11872. * @example
  11873. * // Show previous, next and current page buttons only
  11874. * $.fn.dataTableExt.oPagination.current = function ( page, pages ) {
  11875. * return [ 'previous', page, 'next' ];
  11876. * };
  11877. */
  11878. pager: {},
  11879. renderer: {
  11880. pageButton: {},
  11881. header: {}
  11882. },
  11883. /**
  11884. * Ordering plug-ins - custom data source
  11885. *
  11886. * The extension options for ordering of data available here is complimentary
  11887. * to the default type based ordering that DataTables typically uses. It
  11888. * allows much greater control over the the data that is being used to
  11889. * order a column, but is necessarily therefore more complex.
  11890. *
  11891. * This type of ordering is useful if you want to do ordering based on data
  11892. * live from the DOM (for example the contents of an 'input' element) rather
  11893. * than just the static string that DataTables knows of.
  11894. *
  11895. * The way these plug-ins work is that you create an array of the values you
  11896. * wish to be ordering for the column in question and then return that
  11897. * array. The data in the array much be in the index order of the rows in
  11898. * the table (not the currently ordering order!). Which order data gathering
  11899. * function is run here depends on the `dt-init columns.orderDataType`
  11900. * parameter that is used for the column (if any).
  11901. *
  11902. * The functions defined take two parameters:
  11903. *
  11904. * 1. `{object}` DataTables settings object: see
  11905. * {@link DataTable.models.oSettings}
  11906. * 2. `{int}` Target column index
  11907. *
  11908. * Each function is expected to return an array:
  11909. *
  11910. * * `{array}` Data for the column to be ordering upon
  11911. *
  11912. * @type array
  11913. *
  11914. * @example
  11915. * // Ordering using `input` node values
  11916. * $.fn.dataTable.ext.order['dom-text'] = function ( settings, col )
  11917. * {
  11918. * return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
  11919. * return $('input', td).val();
  11920. * } );
  11921. * }
  11922. */
  11923. order: {},
  11924. /**
  11925. * Type based plug-ins.
  11926. *
  11927. * Each column in DataTables has a type assigned to it, either by automatic
  11928. * detection or by direct assignment using the `type` option for the column.
  11929. * The type of a column will effect how it is ordering and search (plug-ins
  11930. * can also make use of the column type if required).
  11931. *
  11932. * @namespace
  11933. */
  11934. type: {
  11935. /**
  11936. * Type detection functions.
  11937. *
  11938. * The functions defined in this object are used to automatically detect
  11939. * a column's type, making initialisation of DataTables super easy, even
  11940. * when complex data is in the table.
  11941. *
  11942. * The functions defined take two parameters:
  11943. *
  11944. * 1. `{*}` Data from the column cell to be analysed
  11945. * 2. `{settings}` DataTables settings object. This can be used to
  11946. * perform context specific type detection - for example detection
  11947. * based on language settings such as using a comma for a decimal
  11948. * place. Generally speaking the options from the settings will not
  11949. * be required
  11950. *
  11951. * Each function is expected to return:
  11952. *
  11953. * * `{string|null}` Data type detected, or null if unknown (and thus
  11954. * pass it on to the other type detection functions.
  11955. *
  11956. * @type array
  11957. *
  11958. * @example
  11959. * // Currency type detection plug-in:
  11960. * $.fn.dataTable.ext.type.detect.push(
  11961. * function ( data, settings ) {
  11962. * // Check the numeric part
  11963. * if ( ! $.isNumeric( data.substring(1) ) ) {
  11964. * return null;
  11965. * }
  11966. *
  11967. * // Check prefixed by currency
  11968. * if ( data.charAt(0) == '$' || data.charAt(0) == '&pound;' ) {
  11969. * return 'currency';
  11970. * }
  11971. * return null;
  11972. * }
  11973. * );
  11974. */
  11975. detect: [],
  11976. /**
  11977. * Type based search formatting.
  11978. *
  11979. * The type based searching functions can be used to pre-format the
  11980. * data to be search on. For example, it can be used to strip HTML
  11981. * tags or to de-format telephone numbers for numeric only searching.
  11982. *
  11983. * Note that is a search is not defined for a column of a given type,
  11984. * no search formatting will be performed.
  11985. *
  11986. * Pre-processing of searching data plug-ins - When you assign the sType
  11987. * for a column (or have it automatically detected for you by DataTables
  11988. * or a type detection plug-in), you will typically be using this for
  11989. * custom sorting, but it can also be used to provide custom searching
  11990. * by allowing you to pre-processing the data and returning the data in
  11991. * the format that should be searched upon. This is done by adding
  11992. * functions this object with a parameter name which matches the sType
  11993. * for that target column. This is the corollary of <i>afnSortData</i>
  11994. * for searching data.
  11995. *
  11996. * The functions defined take a single parameter:
  11997. *
  11998. * 1. `{*}` Data from the column cell to be prepared for searching
  11999. *
  12000. * Each function is expected to return:
  12001. *
  12002. * * `{string|null}` Formatted string that will be used for the searching.
  12003. *
  12004. * @type object
  12005. * @default {}
  12006. *
  12007. * @example
  12008. * $.fn.dataTable.ext.type.search['title-numeric'] = function ( d ) {
  12009. * return d.replace(/\n/g," ").replace( /<.*?>/g, "" );
  12010. * }
  12011. */
  12012. search: {},
  12013. /**
  12014. * Type based ordering.
  12015. *
  12016. * The column type tells DataTables what ordering to apply to the table
  12017. * when a column is sorted upon. The order for each type that is defined,
  12018. * is defined by the functions available in this object.
  12019. *
  12020. * Each ordering option can be described by three properties added to
  12021. * this object:
  12022. *
  12023. * * `{type}-pre` - Pre-formatting function
  12024. * * `{type}-asc` - Ascending order function
  12025. * * `{type}-desc` - Descending order function
  12026. *
  12027. * All three can be used together, only `{type}-pre` or only
  12028. * `{type}-asc` and `{type}-desc` together. It is generally recommended
  12029. * that only `{type}-pre` is used, as this provides the optimal
  12030. * implementation in terms of speed, although the others are provided
  12031. * for compatibility with existing Javascript sort functions.
  12032. *
  12033. * `{type}-pre`: Functions defined take a single parameter:
  12034. *
  12035. * 1. `{*}` Data from the column cell to be prepared for ordering
  12036. *
  12037. * And return:
  12038. *
  12039. * * `{*}` Data to be sorted upon
  12040. *
  12041. * `{type}-asc` and `{type}-desc`: Functions are typical Javascript sort
  12042. * functions, taking two parameters:
  12043. *
  12044. * 1. `{*}` Data to compare to the second parameter
  12045. * 2. `{*}` Data to compare to the first parameter
  12046. *
  12047. * And returning:
  12048. *
  12049. * * `{*}` Ordering match: <0 if first parameter should be sorted lower
  12050. * than the second parameter, ===0 if the two parameters are equal and
  12051. * >0 if the first parameter should be sorted height than the second
  12052. * parameter.
  12053. *
  12054. * @type object
  12055. * @default {}
  12056. *
  12057. * @example
  12058. * // Numeric ordering of formatted numbers with a pre-formatter
  12059. * $.extend( $.fn.dataTable.ext.type.order, {
  12060. * "string-pre": function(x) {
  12061. * a = (a === "-" || a === "") ? 0 : a.replace( /[^\d\-\.]/g, "" );
  12062. * return parseFloat( a );
  12063. * }
  12064. * } );
  12065. *
  12066. * @example
  12067. * // Case-sensitive string ordering, with no pre-formatting method
  12068. * $.extend( $.fn.dataTable.ext.order, {
  12069. * "string-case-asc": function(x,y) {
  12070. * return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12071. * },
  12072. * "string-case-desc": function(x,y) {
  12073. * return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12074. * }
  12075. * } );
  12076. */
  12077. order: {}
  12078. },
  12079. /**
  12080. * Unique DataTables instance counter
  12081. *
  12082. * @type int
  12083. * @private
  12084. */
  12085. _unique: 0,
  12086. //
  12087. // Depreciated
  12088. // The following properties are retained for backwards compatiblity only.
  12089. // The should not be used in new projects and will be removed in a future
  12090. // version
  12091. //
  12092. /**
  12093. * Version check function.
  12094. * @type function
  12095. * @depreciated Since 1.10
  12096. */
  12097. fnVersionCheck: DataTable.fnVersionCheck,
  12098. /**
  12099. * Index for what 'this' index API functions should use
  12100. * @type int
  12101. * @deprecated Since v1.10
  12102. */
  12103. iApiIndex: 0,
  12104. /**
  12105. * jQuery UI class container
  12106. * @type object
  12107. * @deprecated Since v1.10
  12108. */
  12109. oJUIClasses: {},
  12110. /**
  12111. * Software version
  12112. * @type string
  12113. * @deprecated Since v1.10
  12114. */
  12115. sVersion: DataTable.version
  12116. };
  12117. //
  12118. // Backwards compatibility. Alias to pre 1.10 Hungarian notation counter parts
  12119. //
  12120. $.extend( _ext, {
  12121. afnFiltering: _ext.search,
  12122. aTypes: _ext.type.detect,
  12123. ofnSearch: _ext.type.search,
  12124. oSort: _ext.type.order,
  12125. afnSortData: _ext.order,
  12126. aoFeatures: _ext.feature,
  12127. oApi: _ext.internal,
  12128. oStdClasses: _ext.classes,
  12129. oPagination: _ext.pager
  12130. } );
  12131. $.extend( DataTable.ext.classes, {
  12132. "sTable": "dataTable",
  12133. "sNoFooter": "no-footer",
  12134. /* Paging buttons */
  12135. "sPageButton": "paginate_button",
  12136. "sPageButtonActive": "current",
  12137. "sPageButtonDisabled": "disabled",
  12138. /* Striping classes */
  12139. "sStripeOdd": "odd",
  12140. "sStripeEven": "even",
  12141. /* Empty row */
  12142. "sRowEmpty": "dataTables_empty",
  12143. /* Features */
  12144. "sWrapper": "dataTables_wrapper",
  12145. "sFilter": "dataTables_filter",
  12146. "sInfo": "dataTables_info",
  12147. "sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */
  12148. "sLength": "dataTables_length",
  12149. "sProcessing": "dataTables_processing",
  12150. /* Sorting */
  12151. "sSortAsc": "sorting_asc",
  12152. "sSortDesc": "sorting_desc",
  12153. "sSortable": "sorting", /* Sortable in both directions */
  12154. "sSortableAsc": "sorting_asc_disabled",
  12155. "sSortableDesc": "sorting_desc_disabled",
  12156. "sSortableNone": "sorting_disabled",
  12157. "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
  12158. /* Filtering */
  12159. "sFilterInput": "",
  12160. /* Page length */
  12161. "sLengthSelect": "",
  12162. /* Scrolling */
  12163. "sScrollWrapper": "dataTables_scroll",
  12164. "sScrollHead": "dataTables_scrollHead",
  12165. "sScrollHeadInner": "dataTables_scrollHeadInner",
  12166. "sScrollBody": "dataTables_scrollBody",
  12167. "sScrollFoot": "dataTables_scrollFoot",
  12168. "sScrollFootInner": "dataTables_scrollFootInner",
  12169. /* Misc */
  12170. "sHeaderTH": "",
  12171. "sFooterTH": "",
  12172. // Deprecated
  12173. "sSortJUIAsc": "",
  12174. "sSortJUIDesc": "",
  12175. "sSortJUI": "",
  12176. "sSortJUIAscAllowed": "",
  12177. "sSortJUIDescAllowed": "",
  12178. "sSortJUIWrapper": "",
  12179. "sSortIcon": "",
  12180. "sJUIHeader": "",
  12181. "sJUIFooter": ""
  12182. } );
  12183. (function() {
  12184. // Reused strings for better compression. Closure compiler appears to have a
  12185. // weird edge case where it is trying to expand strings rather than use the
  12186. // variable version. This results in about 200 bytes being added, for very
  12187. // little preference benefit since it this run on script load only.
  12188. var _empty = '';
  12189. _empty = '';
  12190. var _stateDefault = _empty + 'ui-state-default';
  12191. var _sortIcon = _empty + 'css_right ui-icon ui-icon-';
  12192. var _headerFooter = _empty + 'fg-toolbar ui-toolbar ui-widget-header ui-helper-clearfix';
  12193. $.extend( DataTable.ext.oJUIClasses, DataTable.ext.classes, {
  12194. /* Full numbers paging buttons */
  12195. "sPageButton": "fg-button ui-button "+_stateDefault,
  12196. "sPageButtonActive": "ui-state-disabled",
  12197. "sPageButtonDisabled": "ui-state-disabled",
  12198. /* Features */
  12199. "sPaging": "dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi "+
  12200. "ui-buttonset-multi paging_", /* Note that the type is postfixed */
  12201. /* Sorting */
  12202. "sSortAsc": _stateDefault+" sorting_asc",
  12203. "sSortDesc": _stateDefault+" sorting_desc",
  12204. "sSortable": _stateDefault+" sorting",
  12205. "sSortableAsc": _stateDefault+" sorting_asc_disabled",
  12206. "sSortableDesc": _stateDefault+" sorting_desc_disabled",
  12207. "sSortableNone": _stateDefault+" sorting_disabled",
  12208. "sSortJUIAsc": _sortIcon+"triangle-1-n",
  12209. "sSortJUIDesc": _sortIcon+"triangle-1-s",
  12210. "sSortJUI": _sortIcon+"carat-2-n-s",
  12211. "sSortJUIAscAllowed": _sortIcon+"carat-1-n",
  12212. "sSortJUIDescAllowed": _sortIcon+"carat-1-s",
  12213. "sSortJUIWrapper": "DataTables_sort_wrapper",
  12214. "sSortIcon": "DataTables_sort_icon",
  12215. /* Scrolling */
  12216. "sScrollHead": "dataTables_scrollHead "+_stateDefault,
  12217. "sScrollFoot": "dataTables_scrollFoot "+_stateDefault,
  12218. /* Misc */
  12219. "sHeaderTH": _stateDefault,
  12220. "sFooterTH": _stateDefault,
  12221. "sJUIHeader": _headerFooter+" ui-corner-tl ui-corner-tr",
  12222. "sJUIFooter": _headerFooter+" ui-corner-bl ui-corner-br"
  12223. } );
  12224. }());
  12225. var extPagination = DataTable.ext.pager;
  12226. function _numbers ( page, pages ) {
  12227. var
  12228. numbers = [],
  12229. buttons = extPagination.numbers_length,
  12230. half = Math.floor( buttons / 2 ),
  12231. i = 1;
  12232. if ( pages <= buttons ) {
  12233. numbers = _range( 0, pages );
  12234. }
  12235. else if ( page <= half ) {
  12236. numbers = _range( 0, buttons-2 );
  12237. numbers.push( 'ellipsis' );
  12238. numbers.push( pages-1 );
  12239. }
  12240. else if ( page >= pages - 1 - half ) {
  12241. numbers = _range( pages-(buttons-2), pages );
  12242. numbers.splice( 0, 0, 'ellipsis' ); // no unshift in ie6
  12243. numbers.splice( 0, 0, 0 );
  12244. }
  12245. else {
  12246. numbers = _range( page-1, page+2 );
  12247. numbers.push( 'ellipsis' );
  12248. numbers.push( pages-1 );
  12249. numbers.splice( 0, 0, 'ellipsis' );
  12250. numbers.splice( 0, 0, 0 );
  12251. }
  12252. numbers.DT_el = 'span';
  12253. return numbers;
  12254. }
  12255. $.extend( extPagination, {
  12256. simple: function ( page, pages ) {
  12257. return [ 'previous', 'next' ];
  12258. },
  12259. full: function ( page, pages ) {
  12260. return [ 'first', 'previous', 'next', 'last' ];
  12261. },
  12262. simple_numbers: function ( page, pages ) {
  12263. return [ 'previous', _numbers(page, pages), 'next' ];
  12264. },
  12265. full_numbers: function ( page, pages ) {
  12266. return [ 'first', 'previous', _numbers(page, pages), 'next', 'last' ];
  12267. },
  12268. // For testing and plug-ins to use
  12269. _numbers: _numbers,
  12270. numbers_length: 7
  12271. } );
  12272. $.extend( true, DataTable.ext.renderer, {
  12273. pageButton: {
  12274. _: function ( settings, host, idx, buttons, page, pages ) {
  12275. var classes = settings.oClasses;
  12276. var lang = settings.oLanguage.oPaginate;
  12277. var btnDisplay, btnClass, counter=0;
  12278. var attach = function( container, buttons ) {
  12279. var i, ien, node, button;
  12280. var clickHandler = function ( e ) {
  12281. _fnPageChange( settings, e.data.action, true );
  12282. };
  12283. for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
  12284. button = buttons[i];
  12285. if ( $.isArray( button ) ) {
  12286. var inner = $( '<'+(button.DT_el || 'div')+'/>' )
  12287. .appendTo( container );
  12288. attach( inner, button );
  12289. }
  12290. else {
  12291. btnDisplay = '';
  12292. btnClass = '';
  12293. switch ( button ) {
  12294. case 'ellipsis':
  12295. container.append('<span>&hellip;</span>');
  12296. break;
  12297. case 'first':
  12298. btnDisplay = lang.sFirst;
  12299. btnClass = button + (page > 0 ?
  12300. '' : ' '+classes.sPageButtonDisabled);
  12301. break;
  12302. case 'previous':
  12303. btnDisplay = lang.sPrevious;
  12304. btnClass = button + (page > 0 ?
  12305. '' : ' '+classes.sPageButtonDisabled);
  12306. break;
  12307. case 'next':
  12308. btnDisplay = lang.sNext;
  12309. btnClass = button + (page < pages-1 ?
  12310. '' : ' '+classes.sPageButtonDisabled);
  12311. break;
  12312. case 'last':
  12313. btnDisplay = lang.sLast;
  12314. btnClass = button + (page < pages-1 ?
  12315. '' : ' '+classes.sPageButtonDisabled);
  12316. break;
  12317. default:
  12318. btnDisplay = button + 1;
  12319. btnClass = page === button ?
  12320. classes.sPageButtonActive : '';
  12321. break;
  12322. }
  12323. if ( btnDisplay ) {
  12324. node = $('<a>', {
  12325. 'class': classes.sPageButton+' '+btnClass,
  12326. 'aria-controls': settings.sTableId,
  12327. 'data-dt-idx': counter,
  12328. 'tabindex': settings.iTabIndex,
  12329. 'id': idx === 0 && typeof button === 'string' ?
  12330. settings.sTableId +'_'+ button :
  12331. null
  12332. } )
  12333. .html( btnDisplay )
  12334. .appendTo( container );
  12335. _fnBindAction(
  12336. node, {action: button}, clickHandler
  12337. );
  12338. counter++;
  12339. }
  12340. }
  12341. }
  12342. };
  12343. // IE9 throws an 'unknown error' if document.activeElement is used
  12344. // inside an iframe or frame. Try / catch the error. Not good for
  12345. // accessibility, but neither are frames.
  12346. try {
  12347. // Because this approach is destroying and recreating the paging
  12348. // elements, focus is lost on the select button which is bad for
  12349. // accessibility. So we want to restore focus once the draw has
  12350. // completed
  12351. var activeEl = $(document.activeElement).data('dt-idx');
  12352. attach( $(host).empty(), buttons );
  12353. if ( activeEl !== null ) {
  12354. $(host).find( '[data-dt-idx='+activeEl+']' ).focus();
  12355. }
  12356. }
  12357. catch (e) {}
  12358. }
  12359. }
  12360. } );
  12361. // Built in type detection. See model.ext.aTypes for information about
  12362. // what is required from this methods.
  12363. $.extend( DataTable.ext.type.detect, [
  12364. // Plain numbers - first since V8 detects some plain numbers as dates
  12365. // e.g. Date.parse('55') (but not all, e.g. Date.parse('22')...).
  12366. function ( d, settings )
  12367. {
  12368. var decimal = settings.oLanguage.sDecimal;
  12369. return _isNumber( d, decimal ) ? 'num'+decimal : null;
  12370. },
  12371. // Dates (only those recognised by the browser's Date.parse)
  12372. function ( d, settings )
  12373. {
  12374. // V8 will remove any unknown characters at the start and end of the
  12375. // expression, leading to false matches such as `$245.12` or `10%` being
  12376. // a valid date. See forum thread 18941 for detail.
  12377. if ( d && !(d instanceof Date) && ( ! _re_date_start.test(d) || ! _re_date_end.test(d) ) ) {
  12378. return null;
  12379. }
  12380. var parsed = Date.parse(d);
  12381. return (parsed !== null && !isNaN(parsed)) || _empty(d) ? 'date' : null;
  12382. },
  12383. // Formatted numbers
  12384. function ( d, settings )
  12385. {
  12386. var decimal = settings.oLanguage.sDecimal;
  12387. return _isNumber( d, decimal, true ) ? 'num-fmt'+decimal : null;
  12388. },
  12389. // HTML numeric
  12390. function ( d, settings )
  12391. {
  12392. var decimal = settings.oLanguage.sDecimal;
  12393. return _htmlNumeric( d, decimal ) ? 'html-num'+decimal : null;
  12394. },
  12395. // HTML numeric, formatted
  12396. function ( d, settings )
  12397. {
  12398. var decimal = settings.oLanguage.sDecimal;
  12399. return _htmlNumeric( d, decimal, true ) ? 'html-num-fmt'+decimal : null;
  12400. },
  12401. // HTML (this is strict checking - there must be html)
  12402. function ( d, settings )
  12403. {
  12404. return _empty( d ) || (typeof d === 'string' && d.indexOf('<') !== -1) ?
  12405. 'html' : null;
  12406. }
  12407. ] );
  12408. // Filter formatting functions. See model.ext.ofnSearch for information about
  12409. // what is required from these methods.
  12410. //
  12411. // Note that additional search methods are added for the html numbers and
  12412. // html formatted numbers by `_addNumericSort()` when we know what the decimal
  12413. // place is
  12414. $.extend( DataTable.ext.type.search, {
  12415. html: function ( data ) {
  12416. return _empty(data) ?
  12417. data :
  12418. typeof data === 'string' ?
  12419. data
  12420. .replace( _re_new_lines, " " )
  12421. .replace( _re_html, "" ) :
  12422. '';
  12423. },
  12424. string: function ( data ) {
  12425. return _empty(data) ?
  12426. data :
  12427. typeof data === 'string' ?
  12428. data.replace( _re_new_lines, " " ) :
  12429. data;
  12430. }
  12431. } );
  12432. var __numericReplace = function ( d, decimalPlace, re1, re2 ) {
  12433. if ( d !== 0 && (!d || d === '-') ) {
  12434. return -Infinity;
  12435. }
  12436. // If a decimal place other than `.` is used, it needs to be given to the
  12437. // function so we can detect it and replace with a `.` which is the only
  12438. // decimal place Javascript recognises - it is not locale aware.
  12439. if ( decimalPlace ) {
  12440. d = _numToDecimal( d, decimalPlace );
  12441. }
  12442. if ( d.replace ) {
  12443. if ( re1 ) {
  12444. d = d.replace( re1, '' );
  12445. }
  12446. if ( re2 ) {
  12447. d = d.replace( re2, '' );
  12448. }
  12449. }
  12450. return d * 1;
  12451. };
  12452. // Add the numeric 'deformatting' functions for sorting and search. This is done
  12453. // in a function to provide an easy ability for the language options to add
  12454. // additional methods if a non-period decimal place is used.
  12455. function _addNumericSort ( decimalPlace ) {
  12456. $.each(
  12457. {
  12458. // Plain numbers
  12459. "num": function ( d ) {
  12460. return __numericReplace( d, decimalPlace );
  12461. },
  12462. // Formatted numbers
  12463. "num-fmt": function ( d ) {
  12464. return __numericReplace( d, decimalPlace, _re_formatted_numeric );
  12465. },
  12466. // HTML numeric
  12467. "html-num": function ( d ) {
  12468. return __numericReplace( d, decimalPlace, _re_html );
  12469. },
  12470. // HTML numeric, formatted
  12471. "html-num-fmt": function ( d ) {
  12472. return __numericReplace( d, decimalPlace, _re_html, _re_formatted_numeric );
  12473. }
  12474. },
  12475. function ( key, fn ) {
  12476. // Add the ordering method
  12477. _ext.type.order[ key+decimalPlace+'-pre' ] = fn;
  12478. // For HTML types add a search formatter that will strip the HTML
  12479. if ( key.match(/^html\-/) ) {
  12480. _ext.type.search[ key+decimalPlace ] = _ext.type.search.html;
  12481. }
  12482. }
  12483. );
  12484. }
  12485. // Default sort methods
  12486. $.extend( _ext.type.order, {
  12487. // Dates
  12488. "date-pre": function ( d ) {
  12489. return Date.parse( d ) || 0;
  12490. },
  12491. // html
  12492. "html-pre": function ( a ) {
  12493. return _empty(a) ?
  12494. '' :
  12495. a.replace ?
  12496. a.replace( /<.*?>/g, "" ).toLowerCase() :
  12497. a+'';
  12498. },
  12499. // string
  12500. "string-pre": function ( a ) {
  12501. // This is a little complex, but faster than always calling toString,
  12502. // http://jsperf.com/tostring-v-check
  12503. return _empty(a) ?
  12504. '' :
  12505. typeof a === 'string' ?
  12506. a.toLowerCase() :
  12507. ! a.toString ?
  12508. '' :
  12509. a.toString();
  12510. },
  12511. // string-asc and -desc are retained only for compatibility with the old
  12512. // sort methods
  12513. "string-asc": function ( x, y ) {
  12514. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12515. },
  12516. "string-desc": function ( x, y ) {
  12517. return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12518. }
  12519. } );
  12520. // Numeric sorting types - order doesn't matter here
  12521. _addNumericSort( '' );
  12522. $.extend( true, DataTable.ext.renderer, {
  12523. header: {
  12524. _: function ( settings, cell, column, classes ) {
  12525. // No additional mark-up required
  12526. // Attach a sort listener to update on sort - note that using the
  12527. // `DT` namespace will allow the event to be removed automatically
  12528. // on destroy, while the `dt` namespaced event is the one we are
  12529. // listening for
  12530. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  12531. if ( settings !== ctx ) { // need to check this this is the host
  12532. return; // table, not a nested one
  12533. }
  12534. var colIdx = column.idx;
  12535. cell
  12536. .removeClass(
  12537. column.sSortingClass +' '+
  12538. classes.sSortAsc +' '+
  12539. classes.sSortDesc
  12540. )
  12541. .addClass( columns[ colIdx ] == 'asc' ?
  12542. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  12543. classes.sSortDesc :
  12544. column.sSortingClass
  12545. );
  12546. } );
  12547. },
  12548. jqueryui: function ( settings, cell, column, classes ) {
  12549. $('<div/>')
  12550. .addClass( classes.sSortJUIWrapper )
  12551. .append( cell.contents() )
  12552. .append( $('<span/>')
  12553. .addClass( classes.sSortIcon+' '+column.sSortingClassJUI )
  12554. )
  12555. .appendTo( cell );
  12556. // Attach a sort listener to update on sort
  12557. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  12558. if ( settings !== ctx ) {
  12559. return;
  12560. }
  12561. var colIdx = column.idx;
  12562. cell
  12563. .removeClass( classes.sSortAsc +" "+classes.sSortDesc )
  12564. .addClass( columns[ colIdx ] == 'asc' ?
  12565. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  12566. classes.sSortDesc :
  12567. column.sSortingClass
  12568. );
  12569. cell
  12570. .find( 'span.'+classes.sSortIcon )
  12571. .removeClass(
  12572. classes.sSortJUIAsc +" "+
  12573. classes.sSortJUIDesc +" "+
  12574. classes.sSortJUI +" "+
  12575. classes.sSortJUIAscAllowed +" "+
  12576. classes.sSortJUIDescAllowed
  12577. )
  12578. .addClass( columns[ colIdx ] == 'asc' ?
  12579. classes.sSortJUIAsc : columns[ colIdx ] == 'desc' ?
  12580. classes.sSortJUIDesc :
  12581. column.sSortingClassJUI
  12582. );
  12583. } );
  12584. }
  12585. }
  12586. } );
  12587. /*
  12588. * Public helper functions. These aren't used internally by DataTables, or
  12589. * called by any of the options passed into DataTables, but they can be used
  12590. * externally by developers working with DataTables. They are helper functions
  12591. * to make working with DataTables a little bit easier.
  12592. */
  12593. /**
  12594. * Helpers for `columns.render`.
  12595. *
  12596. * The options defined here can be used with the `columns.render` initialisation
  12597. * option to provide a display renderer. The following functions are defined:
  12598. *
  12599. * * `number` - Will format numeric data (defined by `columns.data`) for
  12600. * display, retaining the original unformatted data for sorting and filtering.
  12601. * It takes 4 parameters:
  12602. * * `string` - Thousands grouping separator
  12603. * * `string` - Decimal point indicator
  12604. * * `integer` - Number of decimal points to show
  12605. * * `string` (optional) - Prefix.
  12606. *
  12607. * @example
  12608. * // Column definition using the number renderer
  12609. * {
  12610. * data: "salary",
  12611. * render: $.fn.dataTable.render.number( '\'', '.', 0, '$' )
  12612. * }
  12613. *
  12614. * @namespace
  12615. */
  12616. DataTable.render = {
  12617. number: function ( thousands, decimal, precision, prefix ) {
  12618. return {
  12619. display: function ( d ) {
  12620. var negative = d < 0 ? '-' : '';
  12621. d = Math.abs( parseFloat( d ) );
  12622. var intPart = parseInt( d, 10 );
  12623. var floatPart = precision ?
  12624. decimal+(d - intPart).toFixed( precision ).substring( 2 ):
  12625. '';
  12626. return negative + (prefix||'') +
  12627. intPart.toString().replace(
  12628. /\B(?=(\d{3})+(?!\d))/g, thousands
  12629. ) +
  12630. floatPart;
  12631. }
  12632. };
  12633. }
  12634. };
  12635. /*
  12636. * This is really a good bit rubbish this method of exposing the internal methods
  12637. * publicly... - To be fixed in 2.0 using methods on the prototype
  12638. */
  12639. /**
  12640. * Create a wrapper function for exporting an internal functions to an external API.
  12641. * @param {string} fn API function name
  12642. * @returns {function} wrapped function
  12643. * @memberof DataTable#internal
  12644. */
  12645. function _fnExternApiFunc (fn)
  12646. {
  12647. return function() {
  12648. var args = [_fnSettingsFromNode( this[DataTable.ext.iApiIndex] )].concat(
  12649. Array.prototype.slice.call(arguments)
  12650. );
  12651. return DataTable.ext.internal[fn].apply( this, args );
  12652. };
  12653. }
  12654. /**
  12655. * Reference to internal functions for use by plug-in developers. Note that
  12656. * these methods are references to internal functions and are considered to be
  12657. * private. If you use these methods, be aware that they are liable to change
  12658. * between versions.
  12659. * @namespace
  12660. */
  12661. $.extend( DataTable.ext.internal, {
  12662. _fnExternApiFunc: _fnExternApiFunc,
  12663. _fnBuildAjax: _fnBuildAjax,
  12664. _fnAjaxUpdate: _fnAjaxUpdate,
  12665. _fnAjaxParameters: _fnAjaxParameters,
  12666. _fnAjaxUpdateDraw: _fnAjaxUpdateDraw,
  12667. _fnAjaxDataSrc: _fnAjaxDataSrc,
  12668. _fnAddColumn: _fnAddColumn,
  12669. _fnColumnOptions: _fnColumnOptions,
  12670. _fnAdjustColumnSizing: _fnAdjustColumnSizing,
  12671. _fnVisibleToColumnIndex: _fnVisibleToColumnIndex,
  12672. _fnColumnIndexToVisible: _fnColumnIndexToVisible,
  12673. _fnVisbleColumns: _fnVisbleColumns,
  12674. _fnGetColumns: _fnGetColumns,
  12675. _fnColumnTypes: _fnColumnTypes,
  12676. _fnApplyColumnDefs: _fnApplyColumnDefs,
  12677. _fnHungarianMap: _fnHungarianMap,
  12678. _fnCamelToHungarian: _fnCamelToHungarian,
  12679. _fnLanguageCompat: _fnLanguageCompat,
  12680. _fnBrowserDetect: _fnBrowserDetect,
  12681. _fnAddData: _fnAddData,
  12682. _fnAddTr: _fnAddTr,
  12683. _fnNodeToDataIndex: _fnNodeToDataIndex,
  12684. _fnNodeToColumnIndex: _fnNodeToColumnIndex,
  12685. _fnGetCellData: _fnGetCellData,
  12686. _fnSetCellData: _fnSetCellData,
  12687. _fnSplitObjNotation: _fnSplitObjNotation,
  12688. _fnGetObjectDataFn: _fnGetObjectDataFn,
  12689. _fnSetObjectDataFn: _fnSetObjectDataFn,
  12690. _fnGetDataMaster: _fnGetDataMaster,
  12691. _fnClearTable: _fnClearTable,
  12692. _fnDeleteIndex: _fnDeleteIndex,
  12693. _fnInvalidate: _fnInvalidate,
  12694. _fnGetRowElements: _fnGetRowElements,
  12695. _fnCreateTr: _fnCreateTr,
  12696. _fnBuildHead: _fnBuildHead,
  12697. _fnDrawHead: _fnDrawHead,
  12698. _fnDraw: _fnDraw,
  12699. _fnReDraw: _fnReDraw,
  12700. _fnAddOptionsHtml: _fnAddOptionsHtml,
  12701. _fnDetectHeader: _fnDetectHeader,
  12702. _fnGetUniqueThs: _fnGetUniqueThs,
  12703. _fnFeatureHtmlFilter: _fnFeatureHtmlFilter,
  12704. _fnFilterComplete: _fnFilterComplete,
  12705. _fnFilterCustom: _fnFilterCustom,
  12706. _fnFilterColumn: _fnFilterColumn,
  12707. _fnFilter: _fnFilter,
  12708. _fnFilterCreateSearch: _fnFilterCreateSearch,
  12709. _fnEscapeRegex: _fnEscapeRegex,
  12710. _fnFilterData: _fnFilterData,
  12711. _fnFeatureHtmlInfo: _fnFeatureHtmlInfo,
  12712. _fnUpdateInfo: _fnUpdateInfo,
  12713. _fnInfoMacros: _fnInfoMacros,
  12714. _fnInitialise: _fnInitialise,
  12715. _fnInitComplete: _fnInitComplete,
  12716. _fnLengthChange: _fnLengthChange,
  12717. _fnFeatureHtmlLength: _fnFeatureHtmlLength,
  12718. _fnFeatureHtmlPaginate: _fnFeatureHtmlPaginate,
  12719. _fnPageChange: _fnPageChange,
  12720. _fnFeatureHtmlProcessing: _fnFeatureHtmlProcessing,
  12721. _fnProcessingDisplay: _fnProcessingDisplay,
  12722. _fnFeatureHtmlTable: _fnFeatureHtmlTable,
  12723. _fnScrollDraw: _fnScrollDraw,
  12724. _fnApplyToChildren: _fnApplyToChildren,
  12725. _fnCalculateColumnWidths: _fnCalculateColumnWidths,
  12726. _fnThrottle: _fnThrottle,
  12727. _fnConvertToWidth: _fnConvertToWidth,
  12728. _fnScrollingWidthAdjust: _fnScrollingWidthAdjust,
  12729. _fnGetWidestNode: _fnGetWidestNode,
  12730. _fnGetMaxLenString: _fnGetMaxLenString,
  12731. _fnStringToCss: _fnStringToCss,
  12732. _fnScrollBarWidth: _fnScrollBarWidth,
  12733. _fnSortFlatten: _fnSortFlatten,
  12734. _fnSort: _fnSort,
  12735. _fnSortAria: _fnSortAria,
  12736. _fnSortListener: _fnSortListener,
  12737. _fnSortAttachListener: _fnSortAttachListener,
  12738. _fnSortingClasses: _fnSortingClasses,
  12739. _fnSortData: _fnSortData,
  12740. _fnSaveState: _fnSaveState,
  12741. _fnLoadState: _fnLoadState,
  12742. _fnSettingsFromNode: _fnSettingsFromNode,
  12743. _fnLog: _fnLog,
  12744. _fnMap: _fnMap,
  12745. _fnBindAction: _fnBindAction,
  12746. _fnCallbackReg: _fnCallbackReg,
  12747. _fnCallbackFire: _fnCallbackFire,
  12748. _fnLengthOverflow: _fnLengthOverflow,
  12749. _fnRenderer: _fnRenderer,
  12750. _fnDataSource: _fnDataSource,
  12751. _fnRowAttributes: _fnRowAttributes,
  12752. _fnCalculateEnd: function () {} // Used by a lot of plug-ins, but redundant
  12753. // in 1.10, so this dead-end function is
  12754. // added to prevent errors
  12755. } );
  12756. // jQuery access
  12757. $.fn.dataTable = DataTable;
  12758. // Legacy aliases
  12759. $.fn.dataTableSettings = DataTable.settings;
  12760. $.fn.dataTableExt = DataTable.ext;
  12761. // With a capital `D` we return a DataTables API instance rather than a
  12762. // jQuery object
  12763. $.fn.DataTable = function ( opts ) {
  12764. return $(this).dataTable( opts ).api();
  12765. };
  12766. // All properties that are available to $.fn.dataTable should also be
  12767. // available on $.fn.DataTable
  12768. $.each( DataTable, function ( prop, val ) {
  12769. $.fn.DataTable[ prop ] = val;
  12770. } );
  12771. // Information about events fired by DataTables - for documentation.
  12772. /**
  12773. * Draw event, fired whenever the table is redrawn on the page, at the same
  12774. * point as fnDrawCallback. This may be useful for binding events or
  12775. * performing calculations when the table is altered at all.
  12776. * @name DataTable#draw.dt
  12777. * @event
  12778. * @param {event} e jQuery event object
  12779. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12780. */
  12781. /**
  12782. * Search event, fired when the searching applied to the table (using the
  12783. * built-in global search, or column filters) is altered.
  12784. * @name DataTable#search.dt
  12785. * @event
  12786. * @param {event} e jQuery event object
  12787. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12788. */
  12789. /**
  12790. * Page change event, fired when the paging of the table is altered.
  12791. * @name DataTable#page.dt
  12792. * @event
  12793. * @param {event} e jQuery event object
  12794. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12795. */
  12796. /**
  12797. * Order event, fired when the ordering applied to the table is altered.
  12798. * @name DataTable#order.dt
  12799. * @event
  12800. * @param {event} e jQuery event object
  12801. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12802. */
  12803. /**
  12804. * DataTables initialisation complete event, fired when the table is fully
  12805. * drawn, including Ajax data loaded, if Ajax data is required.
  12806. * @name DataTable#init.dt
  12807. * @event
  12808. * @param {event} e jQuery event object
  12809. * @param {object} oSettings DataTables settings object
  12810. * @param {object} json The JSON object request from the server - only
  12811. * present if client-side Ajax sourced data is used</li></ol>
  12812. */
  12813. /**
  12814. * State save event, fired when the table has changed state a new state save
  12815. * is required. This event allows modification of the state saving object
  12816. * prior to actually doing the save, including addition or other state
  12817. * properties (for plug-ins) or modification of a DataTables core property.
  12818. * @name DataTable#stateSaveParams.dt
  12819. * @event
  12820. * @param {event} e jQuery event object
  12821. * @param {object} oSettings DataTables settings object
  12822. * @param {object} json The state information to be saved
  12823. */
  12824. /**
  12825. * State load event, fired when the table is loading state from the stored
  12826. * data, but prior to the settings object being modified by the saved state
  12827. * - allowing modification of the saved state is required or loading of
  12828. * state for a plug-in.
  12829. * @name DataTable#stateLoadParams.dt
  12830. * @event
  12831. * @param {event} e jQuery event object
  12832. * @param {object} oSettings DataTables settings object
  12833. * @param {object} json The saved state information
  12834. */
  12835. /**
  12836. * State loaded event, fired when state has been loaded from stored data and
  12837. * the settings object has been modified by the loaded data.
  12838. * @name DataTable#stateLoaded.dt
  12839. * @event
  12840. * @param {event} e jQuery event object
  12841. * @param {object} oSettings DataTables settings object
  12842. * @param {object} json The saved state information
  12843. */
  12844. /**
  12845. * Processing event, fired when DataTables is doing some kind of processing
  12846. * (be it, order, searcg or anything else). It can be used to indicate to
  12847. * the end user that there is something happening, or that something has
  12848. * finished.
  12849. * @name DataTable#processing.dt
  12850. * @event
  12851. * @param {event} e jQuery event object
  12852. * @param {object} oSettings DataTables settings object
  12853. * @param {boolean} bShow Flag for if DataTables is doing processing or not
  12854. */
  12855. /**
  12856. * Ajax (XHR) event, fired whenever an Ajax request is completed from a
  12857. * request to made to the server for new data. This event is called before
  12858. * DataTables processed the returned data, so it can also be used to pre-
  12859. * process the data returned from the server, if needed.
  12860. *
  12861. * Note that this trigger is called in `fnServerData`, if you override
  12862. * `fnServerData` and which to use this event, you need to trigger it in you
  12863. * success function.
  12864. * @name DataTable#xhr.dt
  12865. * @event
  12866. * @param {event} e jQuery event object
  12867. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12868. * @param {object} json JSON returned from the server
  12869. *
  12870. * @example
  12871. * // Use a custom property returned from the server in another DOM element
  12872. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  12873. * $('#status').html( json.status );
  12874. * } );
  12875. *
  12876. * @example
  12877. * // Pre-process the data returned from the server
  12878. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  12879. * for ( var i=0, ien=json.aaData.length ; i<ien ; i++ ) {
  12880. * json.aaData[i].sum = json.aaData[i].one + json.aaData[i].two;
  12881. * }
  12882. * // Note no return - manipulate the data directly in the JSON object.
  12883. * } );
  12884. */
  12885. /**
  12886. * Destroy event, fired when the DataTable is destroyed by calling fnDestroy
  12887. * or passing the bDestroy:true parameter in the initialisation object. This
  12888. * can be used to remove bound events, added DOM nodes, etc.
  12889. * @name DataTable#destroy.dt
  12890. * @event
  12891. * @param {event} e jQuery event object
  12892. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12893. */
  12894. /**
  12895. * Page length change event, fired when number of records to show on each
  12896. * page (the length) is changed.
  12897. * @name DataTable#length.dt
  12898. * @event
  12899. * @param {event} e jQuery event object
  12900. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12901. * @param {integer} len New length
  12902. */
  12903. /**
  12904. * Column sizing has changed.
  12905. * @name DataTable#column-sizing.dt
  12906. * @event
  12907. * @param {event} e jQuery event object
  12908. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12909. */
  12910. /**
  12911. * Column visibility has changed.
  12912. * @name DataTable#column-visibility.dt
  12913. * @event
  12914. * @param {event} e jQuery event object
  12915. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12916. * @param {int} column Column index
  12917. * @param {bool} vis `false` if column now hidden, or `true` if visible
  12918. */
  12919. return $.fn.dataTable;
  12920. }));
  12921. }(window, document));