jquery.dataTables.js 423 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774
  1. /*! DataTables 1.10.3
  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.3
  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,_fnInvalidateRow,_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. out.push( a[ order[i] ][ prop ][ prop2 ] );
  178. }
  179. }
  180. else {
  181. for ( ; i<ien ; i++ ) {
  182. out.push( a[ order[i] ][ prop ] );
  183. }
  184. }
  185. return out;
  186. };
  187. var _range = function ( len, start )
  188. {
  189. var out = [];
  190. var end;
  191. if ( start === undefined ) {
  192. start = 0;
  193. end = len;
  194. }
  195. else {
  196. end = start;
  197. start = len;
  198. }
  199. for ( var i=start ; i<end ; i++ ) {
  200. out.push( i );
  201. }
  202. return out;
  203. };
  204. var _stripHtml = function ( d ) {
  205. return d.replace( _re_html, '' );
  206. };
  207. /**
  208. * Find the unique elements in a source array.
  209. *
  210. * @param {array} src Source array
  211. * @return {array} Array of unique items
  212. * @ignore
  213. */
  214. var _unique = function ( src )
  215. {
  216. // A faster unique method is to use object keys to identify used values,
  217. // but this doesn't work with arrays or objects, which we must also
  218. // consider. See jsperf.com/compare-array-unique-versions/4 for more
  219. // information.
  220. var
  221. out = [],
  222. val,
  223. i, ien=src.length,
  224. j, k=0;
  225. again: for ( i=0 ; i<ien ; i++ ) {
  226. val = src[i];
  227. for ( j=0 ; j<k ; j++ ) {
  228. if ( out[j] === val ) {
  229. continue again;
  230. }
  231. }
  232. out.push( val );
  233. k++;
  234. }
  235. return out;
  236. };
  237. /**
  238. * Create a mapping object that allows camel case parameters to be looked up
  239. * for their Hungarian counterparts. The mapping is stored in a private
  240. * parameter called `_hungarianMap` which can be accessed on the source object.
  241. * @param {object} o
  242. * @memberof DataTable#oApi
  243. */
  244. function _fnHungarianMap ( o )
  245. {
  246. var
  247. hungarian = 'a aa ai ao as b fn i m o s ',
  248. match,
  249. newKey,
  250. map = {};
  251. $.each( o, function (key, val) {
  252. match = key.match(/^([^A-Z]+?)([A-Z])/);
  253. if ( match && hungarian.indexOf(match[1]+' ') !== -1 )
  254. {
  255. newKey = key.replace( match[0], match[2].toLowerCase() );
  256. map[ newKey ] = key;
  257. if ( match[1] === 'o' )
  258. {
  259. _fnHungarianMap( o[key] );
  260. }
  261. }
  262. } );
  263. o._hungarianMap = map;
  264. }
  265. /**
  266. * Convert from camel case parameters to Hungarian, based on a Hungarian map
  267. * created by _fnHungarianMap.
  268. * @param {object} src The model object which holds all parameters that can be
  269. * mapped.
  270. * @param {object} user The object to convert from camel case to Hungarian.
  271. * @param {boolean} force When set to `true`, properties which already have a
  272. * Hungarian value in the `user` object will be overwritten. Otherwise they
  273. * won't be.
  274. * @memberof DataTable#oApi
  275. */
  276. function _fnCamelToHungarian ( src, user, force )
  277. {
  278. if ( ! src._hungarianMap ) {
  279. _fnHungarianMap( src );
  280. }
  281. var hungarianKey;
  282. $.each( user, function (key, val) {
  283. hungarianKey = src._hungarianMap[ key ];
  284. if ( hungarianKey !== undefined && (force || user[hungarianKey] === undefined) )
  285. {
  286. // For objects, we need to buzz down into the object to copy parameters
  287. if ( hungarianKey.charAt(0) === 'o' )
  288. {
  289. // Copy the camelCase options over to the hungarian
  290. if ( ! user[ hungarianKey ] ) {
  291. user[ hungarianKey ] = {};
  292. }
  293. $.extend( true, user[hungarianKey], user[key] );
  294. _fnCamelToHungarian( src[hungarianKey], user[hungarianKey], force );
  295. }
  296. else {
  297. user[hungarianKey] = user[ key ];
  298. }
  299. }
  300. } );
  301. }
  302. /**
  303. * Language compatibility - when certain options are given, and others aren't, we
  304. * need to duplicate the values over, in order to provide backwards compatibility
  305. * with older language files.
  306. * @param {object} oSettings dataTables settings object
  307. * @memberof DataTable#oApi
  308. */
  309. function _fnLanguageCompat( lang )
  310. {
  311. var defaults = DataTable.defaults.oLanguage;
  312. var zeroRecords = lang.sZeroRecords;
  313. /* Backwards compatibility - if there is no sEmptyTable given, then use the same as
  314. * sZeroRecords - assuming that is given.
  315. */
  316. if ( ! lang.sEmptyTable && zeroRecords &&
  317. defaults.sEmptyTable === "No data available in table" )
  318. {
  319. _fnMap( lang, lang, 'sZeroRecords', 'sEmptyTable' );
  320. }
  321. /* Likewise with loading records */
  322. if ( ! lang.sLoadingRecords && zeroRecords &&
  323. defaults.sLoadingRecords === "Loading..." )
  324. {
  325. _fnMap( lang, lang, 'sZeroRecords', 'sLoadingRecords' );
  326. }
  327. // Old parameter name of the thousands separator mapped onto the new
  328. if ( lang.sInfoThousands ) {
  329. lang.sThousands = lang.sInfoThousands;
  330. }
  331. var decimal = lang.sDecimal;
  332. if ( decimal ) {
  333. _addNumericSort( decimal );
  334. }
  335. }
  336. /**
  337. * Map one parameter onto another
  338. * @param {object} o Object to map
  339. * @param {*} knew The new parameter name
  340. * @param {*} old The old parameter name
  341. */
  342. var _fnCompatMap = function ( o, knew, old ) {
  343. if ( o[ knew ] !== undefined ) {
  344. o[ old ] = o[ knew ];
  345. }
  346. };
  347. /**
  348. * Provide backwards compatibility for the main DT options. Note that the new
  349. * options are mapped onto the old parameters, so this is an external interface
  350. * change only.
  351. * @param {object} init Object to map
  352. */
  353. function _fnCompatOpts ( init )
  354. {
  355. _fnCompatMap( init, 'ordering', 'bSort' );
  356. _fnCompatMap( init, 'orderMulti', 'bSortMulti' );
  357. _fnCompatMap( init, 'orderClasses', 'bSortClasses' );
  358. _fnCompatMap( init, 'orderCellsTop', 'bSortCellsTop' );
  359. _fnCompatMap( init, 'order', 'aaSorting' );
  360. _fnCompatMap( init, 'orderFixed', 'aaSortingFixed' );
  361. _fnCompatMap( init, 'paging', 'bPaginate' );
  362. _fnCompatMap( init, 'pagingType', 'sPaginationType' );
  363. _fnCompatMap( init, 'pageLength', 'iDisplayLength' );
  364. _fnCompatMap( init, 'searching', 'bFilter' );
  365. // Column search objects are in an array, so it needs to be converted
  366. // element by element
  367. var searchCols = init.aoSearchCols;
  368. if ( searchCols ) {
  369. for ( var i=0, ien=searchCols.length ; i<ien ; i++ ) {
  370. if ( searchCols[i] ) {
  371. _fnCamelToHungarian( DataTable.models.oSearch, searchCols[i] );
  372. }
  373. }
  374. }
  375. }
  376. /**
  377. * Provide backwards compatibility for column options. Note that the new options
  378. * are mapped onto the old parameters, so this is an external interface change
  379. * only.
  380. * @param {object} init Object to map
  381. */
  382. function _fnCompatCols ( init )
  383. {
  384. _fnCompatMap( init, 'orderable', 'bSortable' );
  385. _fnCompatMap( init, 'orderData', 'aDataSort' );
  386. _fnCompatMap( init, 'orderSequence', 'asSorting' );
  387. _fnCompatMap( init, 'orderDataType', 'sortDataType' );
  388. }
  389. /**
  390. * Browser feature detection for capabilities, quirks
  391. * @param {object} settings dataTables settings object
  392. * @memberof DataTable#oApi
  393. */
  394. function _fnBrowserDetect( settings )
  395. {
  396. var browser = settings.oBrowser;
  397. // Scrolling feature / quirks detection
  398. var n = $('<div/>')
  399. .css( {
  400. position: 'absolute',
  401. top: 0,
  402. left: 0,
  403. height: 1,
  404. width: 1,
  405. overflow: 'hidden'
  406. } )
  407. .append(
  408. $('<div/>')
  409. .css( {
  410. position: 'absolute',
  411. top: 1,
  412. left: 1,
  413. width: 100,
  414. overflow: 'scroll'
  415. } )
  416. .append(
  417. $('<div class="test"/>')
  418. .css( {
  419. width: '100%',
  420. height: 10
  421. } )
  422. )
  423. )
  424. .appendTo( 'body' );
  425. var test = n.find('.test');
  426. // IE6/7 will oversize a width 100% element inside a scrolling element, to
  427. // include the width of the scrollbar, while other browsers ensure the inner
  428. // element is contained without forcing scrolling
  429. browser.bScrollOversize = test[0].offsetWidth === 100;
  430. // In rtl text layout, some browsers (most, but not all) will place the
  431. // scrollbar on the left, rather than the right.
  432. browser.bScrollbarLeft = test.offset().left !== 1;
  433. n.remove();
  434. }
  435. /**
  436. * Array.prototype reduce[Right] method, used for browsers which don't support
  437. * JS 1.6. Done this way to reduce code size, since we iterate either way
  438. * @param {object} settings dataTables settings object
  439. * @memberof DataTable#oApi
  440. */
  441. function _fnReduce ( that, fn, init, start, end, inc )
  442. {
  443. var
  444. i = start,
  445. value,
  446. isSet = false;
  447. if ( init !== undefined ) {
  448. value = init;
  449. isSet = true;
  450. }
  451. while ( i !== end ) {
  452. if ( ! that.hasOwnProperty(i) ) {
  453. continue;
  454. }
  455. value = isSet ?
  456. fn( value, that[i], i, that ) :
  457. that[i];
  458. isSet = true;
  459. i += inc;
  460. }
  461. return value;
  462. }
  463. /**
  464. * Add a column to the list used for the table with default values
  465. * @param {object} oSettings dataTables settings object
  466. * @param {node} nTh The th element for this column
  467. * @memberof DataTable#oApi
  468. */
  469. function _fnAddColumn( oSettings, nTh )
  470. {
  471. // Add column to aoColumns array
  472. var oDefaults = DataTable.defaults.column;
  473. var iCol = oSettings.aoColumns.length;
  474. var oCol = $.extend( {}, DataTable.models.oColumn, oDefaults, {
  475. "nTh": nTh ? nTh : document.createElement('th'),
  476. "sTitle": oDefaults.sTitle ? oDefaults.sTitle : nTh ? nTh.innerHTML : '',
  477. "aDataSort": oDefaults.aDataSort ? oDefaults.aDataSort : [iCol],
  478. "mData": oDefaults.mData ? oDefaults.mData : iCol,
  479. idx: iCol
  480. } );
  481. oSettings.aoColumns.push( oCol );
  482. // Add search object for column specific search. Note that the `searchCols[ iCol ]`
  483. // passed into extend can be undefined. This allows the user to give a default
  484. // with only some of the parameters defined, and also not give a default
  485. var searchCols = oSettings.aoPreSearchCols;
  486. searchCols[ iCol ] = $.extend( {}, DataTable.models.oSearch, searchCols[ iCol ] );
  487. // Use the default column options function to initialise classes etc
  488. _fnColumnOptions( oSettings, iCol, null );
  489. }
  490. /**
  491. * Apply options for a column
  492. * @param {object} oSettings dataTables settings object
  493. * @param {int} iCol column index to consider
  494. * @param {object} oOptions object with sType, bVisible and bSearchable etc
  495. * @memberof DataTable#oApi
  496. */
  497. function _fnColumnOptions( oSettings, iCol, oOptions )
  498. {
  499. var oCol = oSettings.aoColumns[ iCol ];
  500. var oClasses = oSettings.oClasses;
  501. var th = $(oCol.nTh);
  502. // Try to get width information from the DOM. We can't get it from CSS
  503. // as we'd need to parse the CSS stylesheet. `width` option can override
  504. if ( ! oCol.sWidthOrig ) {
  505. // Width attribute
  506. oCol.sWidthOrig = th.attr('width') || null;
  507. // Style attribute
  508. var t = (th.attr('style') || '').match(/width:\s*(\d+[pxem%]+)/);
  509. if ( t ) {
  510. oCol.sWidthOrig = t[1];
  511. }
  512. }
  513. /* User specified column options */
  514. if ( oOptions !== undefined && oOptions !== null )
  515. {
  516. // Backwards compatibility
  517. _fnCompatCols( oOptions );
  518. // Map camel case parameters to their Hungarian counterparts
  519. _fnCamelToHungarian( DataTable.defaults.column, oOptions );
  520. /* Backwards compatibility for mDataProp */
  521. if ( oOptions.mDataProp !== undefined && !oOptions.mData )
  522. {
  523. oOptions.mData = oOptions.mDataProp;
  524. }
  525. if ( oOptions.sType )
  526. {
  527. oCol._sManualType = oOptions.sType;
  528. }
  529. // `class` is a reserved word in Javascript, so we need to provide
  530. // the ability to use a valid name for the camel case input
  531. if ( oOptions.className && ! oOptions.sClass )
  532. {
  533. oOptions.sClass = oOptions.className;
  534. }
  535. $.extend( oCol, oOptions );
  536. _fnMap( oCol, oOptions, "sWidth", "sWidthOrig" );
  537. /* iDataSort to be applied (backwards compatibility), but aDataSort will take
  538. * priority if defined
  539. */
  540. if ( typeof oOptions.iDataSort === 'number' )
  541. {
  542. oCol.aDataSort = [ oOptions.iDataSort ];
  543. }
  544. _fnMap( oCol, oOptions, "aDataSort" );
  545. }
  546. /* Cache the data get and set functions for speed */
  547. var mDataSrc = oCol.mData;
  548. var mData = _fnGetObjectDataFn( mDataSrc );
  549. var mRender = oCol.mRender ? _fnGetObjectDataFn( oCol.mRender ) : null;
  550. var attrTest = function( src ) {
  551. return typeof src === 'string' && src.indexOf('@') !== -1;
  552. };
  553. oCol._bAttrSrc = $.isPlainObject( mDataSrc ) && (
  554. attrTest(mDataSrc.sort) || attrTest(mDataSrc.type) || attrTest(mDataSrc.filter)
  555. );
  556. oCol.fnGetData = function (rowData, type, meta) {
  557. var innerData = mData( rowData, type, undefined, meta );
  558. return mRender && type ?
  559. mRender( innerData, type, rowData, meta ) :
  560. innerData;
  561. };
  562. oCol.fnSetData = function ( rowData, val, meta ) {
  563. return _fnSetObjectDataFn( mDataSrc )( rowData, val, meta );
  564. };
  565. // Indicate if DataTables should read DOM data as an object or array
  566. // Used in _fnGetRowElements
  567. if ( typeof mDataSrc !== 'number' ) {
  568. oSettings._rowReadObject = true;
  569. }
  570. /* Feature sorting overrides column specific when off */
  571. if ( !oSettings.oFeatures.bSort )
  572. {
  573. oCol.bSortable = false;
  574. th.addClass( oClasses.sSortableNone ); // Have to add class here as order event isn't called
  575. }
  576. /* Check that the class assignment is correct for sorting */
  577. var bAsc = $.inArray('asc', oCol.asSorting) !== -1;
  578. var bDesc = $.inArray('desc', oCol.asSorting) !== -1;
  579. if ( !oCol.bSortable || (!bAsc && !bDesc) )
  580. {
  581. oCol.sSortingClass = oClasses.sSortableNone;
  582. oCol.sSortingClassJUI = "";
  583. }
  584. else if ( bAsc && !bDesc )
  585. {
  586. oCol.sSortingClass = oClasses.sSortableAsc;
  587. oCol.sSortingClassJUI = oClasses.sSortJUIAscAllowed;
  588. }
  589. else if ( !bAsc && bDesc )
  590. {
  591. oCol.sSortingClass = oClasses.sSortableDesc;
  592. oCol.sSortingClassJUI = oClasses.sSortJUIDescAllowed;
  593. }
  594. else
  595. {
  596. oCol.sSortingClass = oClasses.sSortable;
  597. oCol.sSortingClassJUI = oClasses.sSortJUI;
  598. }
  599. }
  600. /**
  601. * Adjust the table column widths for new data. Note: you would probably want to
  602. * do a redraw after calling this function!
  603. * @param {object} settings dataTables settings object
  604. * @memberof DataTable#oApi
  605. */
  606. function _fnAdjustColumnSizing ( settings )
  607. {
  608. /* Not interested in doing column width calculation if auto-width is disabled */
  609. if ( settings.oFeatures.bAutoWidth !== false )
  610. {
  611. var columns = settings.aoColumns;
  612. _fnCalculateColumnWidths( settings );
  613. for ( var i=0 , iLen=columns.length ; i<iLen ; i++ )
  614. {
  615. columns[i].nTh.style.width = columns[i].sWidth;
  616. }
  617. }
  618. var scroll = settings.oScroll;
  619. if ( scroll.sY !== '' || scroll.sX !== '')
  620. {
  621. _fnScrollDraw( settings );
  622. }
  623. _fnCallbackFire( settings, null, 'column-sizing', [settings] );
  624. }
  625. /**
  626. * Covert the index of a visible column to the index in the data array (take account
  627. * of hidden columns)
  628. * @param {object} oSettings dataTables settings object
  629. * @param {int} iMatch Visible column index to lookup
  630. * @returns {int} i the data index
  631. * @memberof DataTable#oApi
  632. */
  633. function _fnVisibleToColumnIndex( oSettings, iMatch )
  634. {
  635. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  636. return typeof aiVis[iMatch] === 'number' ?
  637. aiVis[iMatch] :
  638. null;
  639. }
  640. /**
  641. * Covert the index of an index in the data array and convert it to the visible
  642. * column index (take account of hidden columns)
  643. * @param {int} iMatch Column index to lookup
  644. * @param {object} oSettings dataTables settings object
  645. * @returns {int} i the data index
  646. * @memberof DataTable#oApi
  647. */
  648. function _fnColumnIndexToVisible( oSettings, iMatch )
  649. {
  650. var aiVis = _fnGetColumns( oSettings, 'bVisible' );
  651. var iPos = $.inArray( iMatch, aiVis );
  652. return iPos !== -1 ? iPos : null;
  653. }
  654. /**
  655. * Get the number of visible columns
  656. * @param {object} oSettings dataTables settings object
  657. * @returns {int} i the number of visible columns
  658. * @memberof DataTable#oApi
  659. */
  660. function _fnVisbleColumns( oSettings )
  661. {
  662. return _fnGetColumns( oSettings, 'bVisible' ).length;
  663. }
  664. /**
  665. * Get an array of column indexes that match a given property
  666. * @param {object} oSettings dataTables settings object
  667. * @param {string} sParam Parameter in aoColumns to look for - typically
  668. * bVisible or bSearchable
  669. * @returns {array} Array of indexes with matched properties
  670. * @memberof DataTable#oApi
  671. */
  672. function _fnGetColumns( oSettings, sParam )
  673. {
  674. var a = [];
  675. $.map( oSettings.aoColumns, function(val, i) {
  676. if ( val[sParam] ) {
  677. a.push( i );
  678. }
  679. } );
  680. return a;
  681. }
  682. /**
  683. * Calculate the 'type' of a column
  684. * @param {object} settings dataTables settings object
  685. * @memberof DataTable#oApi
  686. */
  687. function _fnColumnTypes ( settings )
  688. {
  689. var columns = settings.aoColumns;
  690. var data = settings.aoData;
  691. var types = DataTable.ext.type.detect;
  692. var i, ien, j, jen, k, ken;
  693. var col, cell, detectedType, cache;
  694. // For each column, spin over the
  695. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  696. col = columns[i];
  697. cache = [];
  698. if ( ! col.sType && col._sManualType ) {
  699. col.sType = col._sManualType;
  700. }
  701. else if ( ! col.sType ) {
  702. for ( j=0, jen=types.length ; j<jen ; j++ ) {
  703. for ( k=0, ken=data.length ; k<ken ; k++ ) {
  704. // Use a cache array so we only need to get the type data
  705. // from the formatter once (when using multiple detectors)
  706. if ( cache[k] === undefined ) {
  707. cache[k] = _fnGetCellData( settings, k, i, 'type' );
  708. }
  709. detectedType = types[j]( cache[k], settings );
  710. // Doesn't match, so break early, since this type can't
  711. // apply to this column. Also, HTML is a special case since
  712. // it is so similar to `string`. Just a single match is
  713. // needed for a column to be html type
  714. if ( ! detectedType || detectedType === 'html' ) {
  715. break;
  716. }
  717. }
  718. // Type is valid for all data points in the column - use this
  719. // type
  720. if ( detectedType ) {
  721. col.sType = detectedType;
  722. break;
  723. }
  724. }
  725. // Fall back - if no type was detected, always use string
  726. if ( ! col.sType ) {
  727. col.sType = 'string';
  728. }
  729. }
  730. }
  731. }
  732. /**
  733. * Take the column definitions and static columns arrays and calculate how
  734. * they relate to column indexes. The callback function will then apply the
  735. * definition found for a column to a suitable configuration object.
  736. * @param {object} oSettings dataTables settings object
  737. * @param {array} aoColDefs The aoColumnDefs array that is to be applied
  738. * @param {array} aoCols The aoColumns array that defines columns individually
  739. * @param {function} fn Callback function - takes two parameters, the calculated
  740. * column index and the definition for that column.
  741. * @memberof DataTable#oApi
  742. */
  743. function _fnApplyColumnDefs( oSettings, aoColDefs, aoCols, fn )
  744. {
  745. var i, iLen, j, jLen, k, kLen, def;
  746. var columns = oSettings.aoColumns;
  747. // Column definitions with aTargets
  748. if ( aoColDefs )
  749. {
  750. /* Loop over the definitions array - loop in reverse so first instance has priority */
  751. for ( i=aoColDefs.length-1 ; i>=0 ; i-- )
  752. {
  753. def = aoColDefs[i];
  754. /* Each definition can target multiple columns, as it is an array */
  755. var aTargets = def.targets !== undefined ?
  756. def.targets :
  757. def.aTargets;
  758. if ( ! $.isArray( aTargets ) )
  759. {
  760. aTargets = [ aTargets ];
  761. }
  762. for ( j=0, jLen=aTargets.length ; j<jLen ; j++ )
  763. {
  764. if ( typeof aTargets[j] === 'number' && aTargets[j] >= 0 )
  765. {
  766. /* Add columns that we don't yet know about */
  767. while( columns.length <= aTargets[j] )
  768. {
  769. _fnAddColumn( oSettings );
  770. }
  771. /* Integer, basic index */
  772. fn( aTargets[j], def );
  773. }
  774. else if ( typeof aTargets[j] === 'number' && aTargets[j] < 0 )
  775. {
  776. /* Negative integer, right to left column counting */
  777. fn( columns.length+aTargets[j], def );
  778. }
  779. else if ( typeof aTargets[j] === 'string' )
  780. {
  781. /* Class name matching on TH element */
  782. for ( k=0, kLen=columns.length ; k<kLen ; k++ )
  783. {
  784. if ( aTargets[j] == "_all" ||
  785. $(columns[k].nTh).hasClass( aTargets[j] ) )
  786. {
  787. fn( k, def );
  788. }
  789. }
  790. }
  791. }
  792. }
  793. }
  794. // Statically defined columns array
  795. if ( aoCols )
  796. {
  797. for ( i=0, iLen=aoCols.length ; i<iLen ; i++ )
  798. {
  799. fn( i, aoCols[i] );
  800. }
  801. }
  802. }
  803. /**
  804. * Add a data array to the table, creating DOM node etc. This is the parallel to
  805. * _fnGatherData, but for adding rows from a Javascript source, rather than a
  806. * DOM source.
  807. * @param {object} oSettings dataTables settings object
  808. * @param {array} aData data array to be added
  809. * @param {node} [nTr] TR element to add to the table - optional. If not given,
  810. * DataTables will create a row automatically
  811. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  812. * if nTr is.
  813. * @returns {int} >=0 if successful (index of new aoData entry), -1 if failed
  814. * @memberof DataTable#oApi
  815. */
  816. function _fnAddData ( oSettings, aDataIn, nTr, anTds )
  817. {
  818. /* Create the object for storing information about this new row */
  819. var iRow = oSettings.aoData.length;
  820. var oData = $.extend( true, {}, DataTable.models.oRow, {
  821. src: nTr ? 'dom' : 'data'
  822. } );
  823. oData._aData = aDataIn;
  824. oSettings.aoData.push( oData );
  825. /* Create the cells */
  826. var nTd, sThisType;
  827. var columns = oSettings.aoColumns;
  828. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  829. {
  830. // When working with a row, the data source object must be populated. In
  831. // all other cases, the data source object is already populated, so we
  832. // don't overwrite it, which might break bindings etc
  833. if ( nTr ) {
  834. _fnSetCellData( oSettings, iRow, i, _fnGetCellData( oSettings, iRow, i ) );
  835. }
  836. columns[i].sType = null;
  837. }
  838. /* Add to the display array */
  839. oSettings.aiDisplayMaster.push( iRow );
  840. /* Create the DOM information, or register it if already present */
  841. if ( nTr || ! oSettings.oFeatures.bDeferRender )
  842. {
  843. _fnCreateTr( oSettings, iRow, nTr, anTds );
  844. }
  845. return iRow;
  846. }
  847. /**
  848. * Add one or more TR elements to the table. Generally we'd expect to
  849. * use this for reading data from a DOM sourced table, but it could be
  850. * used for an TR element. Note that if a TR is given, it is used (i.e.
  851. * it is not cloned).
  852. * @param {object} settings dataTables settings object
  853. * @param {array|node|jQuery} trs The TR element(s) to add to the table
  854. * @returns {array} Array of indexes for the added rows
  855. * @memberof DataTable#oApi
  856. */
  857. function _fnAddTr( settings, trs )
  858. {
  859. var row;
  860. // Allow an individual node to be passed in
  861. if ( ! (trs instanceof $) ) {
  862. trs = $(trs);
  863. }
  864. return trs.map( function (i, el) {
  865. row = _fnGetRowElements( settings, el );
  866. return _fnAddData( settings, row.data, el, row.cells );
  867. } );
  868. }
  869. /**
  870. * Take a TR element and convert it to an index in aoData
  871. * @param {object} oSettings dataTables settings object
  872. * @param {node} n the TR element to find
  873. * @returns {int} index if the node is found, null if not
  874. * @memberof DataTable#oApi
  875. */
  876. function _fnNodeToDataIndex( oSettings, n )
  877. {
  878. return (n._DT_RowIndex!==undefined) ? n._DT_RowIndex : null;
  879. }
  880. /**
  881. * Take a TD element and convert it into a column data index (not the visible index)
  882. * @param {object} oSettings dataTables settings object
  883. * @param {int} iRow The row number the TD/TH can be found in
  884. * @param {node} n The TD/TH element to find
  885. * @returns {int} index if the node is found, -1 if not
  886. * @memberof DataTable#oApi
  887. */
  888. function _fnNodeToColumnIndex( oSettings, iRow, n )
  889. {
  890. return $.inArray( n, oSettings.aoData[ iRow ].anCells );
  891. }
  892. /**
  893. * Get the data for a given cell from the internal cache, taking into account data mapping
  894. * @param {object} settings dataTables settings object
  895. * @param {int} rowIdx aoData row id
  896. * @param {int} colIdx Column index
  897. * @param {string} type data get type ('display', 'type' 'filter' 'sort')
  898. * @returns {*} Cell data
  899. * @memberof DataTable#oApi
  900. */
  901. function _fnGetCellData( settings, rowIdx, colIdx, type )
  902. {
  903. var draw = settings.iDraw;
  904. var col = settings.aoColumns[colIdx];
  905. var rowData = settings.aoData[rowIdx]._aData;
  906. var defaultContent = col.sDefaultContent;
  907. var cellData = col.fnGetData( rowData, type, {
  908. settings: settings,
  909. row: rowIdx,
  910. col: colIdx
  911. } );
  912. if ( cellData === undefined ) {
  913. if ( settings.iDrawError != draw && defaultContent === null ) {
  914. _fnLog( settings, 0, "Requested unknown parameter "+
  915. (typeof col.mData=='function' ? '{function}' : "'"+col.mData+"'")+
  916. " for row "+rowIdx, 4 );
  917. settings.iDrawError = draw;
  918. }
  919. return defaultContent;
  920. }
  921. /* When the data source is null, we can use default column data */
  922. if ( (cellData === rowData || cellData === null) && defaultContent !== null ) {
  923. cellData = defaultContent;
  924. }
  925. else if ( typeof cellData === 'function' ) {
  926. // If the data source is a function, then we run it and use the return,
  927. // executing in the scope of the data object (for instances)
  928. return cellData.call( rowData );
  929. }
  930. if ( cellData === null && type == 'display' ) {
  931. return '';
  932. }
  933. return cellData;
  934. }
  935. /**
  936. * Set the value for a specific cell, into the internal data cache
  937. * @param {object} settings dataTables settings object
  938. * @param {int} rowIdx aoData row id
  939. * @param {int} colIdx Column index
  940. * @param {*} val Value to set
  941. * @memberof DataTable#oApi
  942. */
  943. function _fnSetCellData( settings, rowIdx, colIdx, val )
  944. {
  945. var col = settings.aoColumns[colIdx];
  946. var rowData = settings.aoData[rowIdx]._aData;
  947. col.fnSetData( rowData, val, {
  948. settings: settings,
  949. row: rowIdx,
  950. col: colIdx
  951. } );
  952. }
  953. // Private variable that is used to match action syntax in the data property object
  954. var __reArray = /\[.*?\]$/;
  955. var __reFn = /\(\)$/;
  956. /**
  957. * Split string on periods, taking into account escaped periods
  958. * @param {string} str String to split
  959. * @return {array} Split string
  960. */
  961. function _fnSplitObjNotation( str )
  962. {
  963. return $.map( str.match(/(\\.|[^\.])+/g), function ( s ) {
  964. return s.replace(/\\./g, '.');
  965. } );
  966. }
  967. /**
  968. * Return a function that can be used to get data from a source object, taking
  969. * into account the ability to use nested objects as a source
  970. * @param {string|int|function} mSource The data source for the object
  971. * @returns {function} Data get function
  972. * @memberof DataTable#oApi
  973. */
  974. function _fnGetObjectDataFn( mSource )
  975. {
  976. if ( $.isPlainObject( mSource ) )
  977. {
  978. /* Build an object of get functions, and wrap them in a single call */
  979. var o = {};
  980. $.each( mSource, function (key, val) {
  981. if ( val ) {
  982. o[key] = _fnGetObjectDataFn( val );
  983. }
  984. } );
  985. return function (data, type, row, meta) {
  986. var t = o[type] || o._;
  987. return t !== undefined ?
  988. t(data, type, row, meta) :
  989. data;
  990. };
  991. }
  992. else if ( mSource === null )
  993. {
  994. /* Give an empty string for rendering / sorting etc */
  995. return function (data) { // type, row and meta also passed, but not used
  996. return data;
  997. };
  998. }
  999. else if ( typeof mSource === 'function' )
  1000. {
  1001. return function (data, type, row, meta) {
  1002. return mSource( data, type, row, meta );
  1003. };
  1004. }
  1005. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  1006. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  1007. {
  1008. /* If there is a . in the source string then the data source is in a
  1009. * nested object so we loop over the data for each level to get the next
  1010. * level down. On each loop we test for undefined, and if found immediately
  1011. * return. This allows entire objects to be missing and sDefaultContent to
  1012. * be used if defined, rather than throwing an error
  1013. */
  1014. var fetchData = function (data, type, src) {
  1015. var arrayNotation, funcNotation, out, innerSrc;
  1016. if ( src !== "" )
  1017. {
  1018. var a = _fnSplitObjNotation( src );
  1019. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  1020. {
  1021. // Check if we are dealing with special notation
  1022. arrayNotation = a[i].match(__reArray);
  1023. funcNotation = a[i].match(__reFn);
  1024. if ( arrayNotation )
  1025. {
  1026. // Array notation
  1027. a[i] = a[i].replace(__reArray, '');
  1028. // Condition allows simply [] to be passed in
  1029. if ( a[i] !== "" ) {
  1030. data = data[ a[i] ];
  1031. }
  1032. out = [];
  1033. // Get the remainder of the nested object to get
  1034. a.splice( 0, i+1 );
  1035. innerSrc = a.join('.');
  1036. // Traverse each entry in the array getting the properties requested
  1037. for ( var j=0, jLen=data.length ; j<jLen ; j++ ) {
  1038. out.push( fetchData( data[j], type, innerSrc ) );
  1039. }
  1040. // If a string is given in between the array notation indicators, that
  1041. // is used to join the strings together, otherwise an array is returned
  1042. var join = arrayNotation[0].substring(1, arrayNotation[0].length-1);
  1043. data = (join==="") ? out : out.join(join);
  1044. // The inner call to fetchData has already traversed through the remainder
  1045. // of the source requested, so we exit from the loop
  1046. break;
  1047. }
  1048. else if ( funcNotation )
  1049. {
  1050. // Function call
  1051. a[i] = a[i].replace(__reFn, '');
  1052. data = data[ a[i] ]();
  1053. continue;
  1054. }
  1055. if ( data === null || data[ a[i] ] === undefined )
  1056. {
  1057. return undefined;
  1058. }
  1059. data = data[ a[i] ];
  1060. }
  1061. }
  1062. return data;
  1063. };
  1064. return function (data, type) { // row and meta also passed, but not used
  1065. return fetchData( data, type, mSource );
  1066. };
  1067. }
  1068. else
  1069. {
  1070. /* Array or flat object mapping */
  1071. return function (data, type) { // row and meta also passed, but not used
  1072. return data[mSource];
  1073. };
  1074. }
  1075. }
  1076. /**
  1077. * Return a function that can be used to set data from a source object, taking
  1078. * into account the ability to use nested objects as a source
  1079. * @param {string|int|function} mSource The data source for the object
  1080. * @returns {function} Data set function
  1081. * @memberof DataTable#oApi
  1082. */
  1083. function _fnSetObjectDataFn( mSource )
  1084. {
  1085. if ( $.isPlainObject( mSource ) )
  1086. {
  1087. /* Unlike get, only the underscore (global) option is used for for
  1088. * setting data since we don't know the type here. This is why an object
  1089. * option is not documented for `mData` (which is read/write), but it is
  1090. * for `mRender` which is read only.
  1091. */
  1092. return _fnSetObjectDataFn( mSource._ );
  1093. }
  1094. else if ( mSource === null )
  1095. {
  1096. /* Nothing to do when the data source is null */
  1097. return function () {};
  1098. }
  1099. else if ( typeof mSource === 'function' )
  1100. {
  1101. return function (data, val, meta) {
  1102. mSource( data, 'set', val, meta );
  1103. };
  1104. }
  1105. else if ( typeof mSource === 'string' && (mSource.indexOf('.') !== -1 ||
  1106. mSource.indexOf('[') !== -1 || mSource.indexOf('(') !== -1) )
  1107. {
  1108. /* Like the get, we need to get data from a nested object */
  1109. var setData = function (data, val, src) {
  1110. var a = _fnSplitObjNotation( src ), b;
  1111. var aLast = a[a.length-1];
  1112. var arrayNotation, funcNotation, o, innerSrc;
  1113. for ( var i=0, iLen=a.length-1 ; i<iLen ; i++ )
  1114. {
  1115. // Check if we are dealing with an array notation request
  1116. arrayNotation = a[i].match(__reArray);
  1117. funcNotation = a[i].match(__reFn);
  1118. if ( arrayNotation )
  1119. {
  1120. a[i] = a[i].replace(__reArray, '');
  1121. data[ a[i] ] = [];
  1122. // Get the remainder of the nested object to set so we can recurse
  1123. b = a.slice();
  1124. b.splice( 0, i+1 );
  1125. innerSrc = b.join('.');
  1126. // Traverse each entry in the array setting the properties requested
  1127. for ( var j=0, jLen=val.length ; j<jLen ; j++ )
  1128. {
  1129. o = {};
  1130. setData( o, val[j], innerSrc );
  1131. data[ a[i] ].push( o );
  1132. }
  1133. // The inner call to setData has already traversed through the remainder
  1134. // of the source and has set the data, thus we can exit here
  1135. return;
  1136. }
  1137. else if ( funcNotation )
  1138. {
  1139. // Function call
  1140. a[i] = a[i].replace(__reFn, '');
  1141. data = data[ a[i] ]( val );
  1142. }
  1143. // If the nested object doesn't currently exist - since we are
  1144. // trying to set the value - create it
  1145. if ( data[ a[i] ] === null || data[ a[i] ] === undefined )
  1146. {
  1147. data[ a[i] ] = {};
  1148. }
  1149. data = data[ a[i] ];
  1150. }
  1151. // Last item in the input - i.e, the actual set
  1152. if ( aLast.match(__reFn ) )
  1153. {
  1154. // Function call
  1155. data = data[ aLast.replace(__reFn, '') ]( val );
  1156. }
  1157. else
  1158. {
  1159. // If array notation is used, we just want to strip it and use the property name
  1160. // and assign the value. If it isn't used, then we get the result we want anyway
  1161. data[ aLast.replace(__reArray, '') ] = val;
  1162. }
  1163. };
  1164. return function (data, val) { // meta is also passed in, but not used
  1165. return setData( data, val, mSource );
  1166. };
  1167. }
  1168. else
  1169. {
  1170. /* Array or flat object mapping */
  1171. return function (data, val) { // meta is also passed in, but not used
  1172. data[mSource] = val;
  1173. };
  1174. }
  1175. }
  1176. /**
  1177. * Return an array with the full table data
  1178. * @param {object} oSettings dataTables settings object
  1179. * @returns array {array} aData Master data array
  1180. * @memberof DataTable#oApi
  1181. */
  1182. function _fnGetDataMaster ( settings )
  1183. {
  1184. return _pluck( settings.aoData, '_aData' );
  1185. }
  1186. /**
  1187. * Nuke the table
  1188. * @param {object} oSettings dataTables settings object
  1189. * @memberof DataTable#oApi
  1190. */
  1191. function _fnClearTable( settings )
  1192. {
  1193. settings.aoData.length = 0;
  1194. settings.aiDisplayMaster.length = 0;
  1195. settings.aiDisplay.length = 0;
  1196. }
  1197. /**
  1198. * Take an array of integers (index array) and remove a target integer (value - not
  1199. * the key!)
  1200. * @param {array} a Index array to target
  1201. * @param {int} iTarget value to find
  1202. * @memberof DataTable#oApi
  1203. */
  1204. function _fnDeleteIndex( a, iTarget, splice )
  1205. {
  1206. var iTargetIndex = -1;
  1207. for ( var i=0, iLen=a.length ; i<iLen ; i++ )
  1208. {
  1209. if ( a[i] == iTarget )
  1210. {
  1211. iTargetIndex = i;
  1212. }
  1213. else if ( a[i] > iTarget )
  1214. {
  1215. a[i]--;
  1216. }
  1217. }
  1218. if ( iTargetIndex != -1 && splice === undefined )
  1219. {
  1220. a.splice( iTargetIndex, 1 );
  1221. }
  1222. }
  1223. /**
  1224. * Mark cached data as invalid such that a re-read of the data will occur when
  1225. * the cached data is next requested. Also update from the data source object.
  1226. *
  1227. * @param {object} settings DataTables settings object
  1228. * @param {int} rowIdx Row index to invalidate
  1229. * @memberof DataTable#oApi
  1230. *
  1231. * @yodo For the modularisation of v1.11 this will need to become a callback, so
  1232. * the sort and filter methods can subscribe to it. That will required
  1233. * initialisation options for sorting, which is why it is not already baked in
  1234. */
  1235. function _fnInvalidateRow( settings, rowIdx, src, column )
  1236. {
  1237. var row = settings.aoData[ rowIdx ];
  1238. var i, ien;
  1239. // Are we reading last data from DOM or the data object?
  1240. if ( src === 'dom' || ((! src || src === 'auto') && row.src === 'dom') ) {
  1241. // Read the data from the DOM
  1242. row._aData = _fnGetRowElements( settings, row ).data;
  1243. }
  1244. else {
  1245. // Reading from data object, update the DOM
  1246. var cells = row.anCells;
  1247. var cell;
  1248. if ( cells ) {
  1249. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  1250. cell = cells[i];
  1251. // This is very frustrating, but in IE if you just write directly
  1252. // to innerHTML, and elements that are overwritten are GC'ed,
  1253. // even if there is a reference to them elsewhere
  1254. while ( cell.childNodes.length ) {
  1255. cell.removeChild( cell.firstChild );
  1256. }
  1257. cells[i].innerHTML = _fnGetCellData( settings, rowIdx, i, 'display' );
  1258. }
  1259. }
  1260. }
  1261. row._aSortData = null;
  1262. row._aFilterData = null;
  1263. // Invalidate the type for a specific column (if given) or all columns since
  1264. // the data might have changed
  1265. var cols = settings.aoColumns;
  1266. if ( column !== undefined ) {
  1267. cols[ column ].sType = null;
  1268. }
  1269. else {
  1270. for ( i=0, ien=cols.length ; i<ien ; i++ ) {
  1271. cols[i].sType = null;
  1272. }
  1273. }
  1274. // Update DataTables special `DT_*` attributes for the row
  1275. _fnRowAttributes( row );
  1276. }
  1277. /**
  1278. * Build a data source object from an HTML row, reading the contents of the
  1279. * cells that are in the row.
  1280. *
  1281. * @param {object} settings DataTables settings object
  1282. * @param {node|object} TR element from which to read data or existing row
  1283. * object from which to re-read the data from the cells
  1284. * @returns {object} Object with two parameters: `data` the data read, in
  1285. * document order, and `cells` and array of nodes (they can be useful to the
  1286. * caller, so rather than needing a second traversal to get them, just return
  1287. * them from here).
  1288. * @memberof DataTable#oApi
  1289. */
  1290. function _fnGetRowElements( settings, row )
  1291. {
  1292. var
  1293. tds = [],
  1294. td = row.firstChild,
  1295. name, col, o, i=0, contents,
  1296. columns = settings.aoColumns,
  1297. objectRead = settings._rowReadObject;
  1298. var d = objectRead ? {} : [];
  1299. var attr = function ( str, td ) {
  1300. if ( typeof str === 'string' ) {
  1301. var idx = str.indexOf('@');
  1302. if ( idx !== -1 ) {
  1303. var attr = str.substring( idx+1 );
  1304. var setter = _fnSetObjectDataFn( str );
  1305. setter( d, td.getAttribute( attr ) );
  1306. }
  1307. }
  1308. };
  1309. var cellProcess = function ( cell ) {
  1310. col = columns[i];
  1311. contents = $.trim(cell.innerHTML);
  1312. if ( col && col._bAttrSrc ) {
  1313. var setter = _fnSetObjectDataFn( col.mData._ );
  1314. setter( d, contents );
  1315. attr( col.mData.sort, cell );
  1316. attr( col.mData.type, cell );
  1317. attr( col.mData.filter, cell );
  1318. }
  1319. else {
  1320. // Depending on the `data` option for the columns the data can be
  1321. // read to either an object or an array.
  1322. if ( objectRead ) {
  1323. if ( ! col._setter ) {
  1324. // Cache the setter function
  1325. col._setter = _fnSetObjectDataFn( col.mData );
  1326. }
  1327. col._setter( d, contents );
  1328. }
  1329. else {
  1330. d.push( contents );
  1331. }
  1332. }
  1333. i++;
  1334. };
  1335. if ( td ) {
  1336. // `tr` element passed in
  1337. while ( td ) {
  1338. name = td.nodeName.toUpperCase();
  1339. if ( name == "TD" || name == "TH" ) {
  1340. cellProcess( td );
  1341. tds.push( td );
  1342. }
  1343. td = td.nextSibling;
  1344. }
  1345. }
  1346. else {
  1347. // Existing row object passed in
  1348. tds = row.anCells;
  1349. for ( var j=0, jen=tds.length ; j<jen ; j++ ) {
  1350. cellProcess( tds[j] );
  1351. }
  1352. }
  1353. return {
  1354. data: d,
  1355. cells: tds
  1356. };
  1357. }
  1358. /**
  1359. * Create a new TR element (and it's TD children) for a row
  1360. * @param {object} oSettings dataTables settings object
  1361. * @param {int} iRow Row to consider
  1362. * @param {node} [nTrIn] TR element to add to the table - optional. If not given,
  1363. * DataTables will create a row automatically
  1364. * @param {array} [anTds] Array of TD|TH elements for the row - must be given
  1365. * if nTr is.
  1366. * @memberof DataTable#oApi
  1367. */
  1368. function _fnCreateTr ( oSettings, iRow, nTrIn, anTds )
  1369. {
  1370. var
  1371. row = oSettings.aoData[iRow],
  1372. rowData = row._aData,
  1373. cells = [],
  1374. nTr, nTd, oCol,
  1375. i, iLen;
  1376. if ( row.nTr === null )
  1377. {
  1378. nTr = nTrIn || document.createElement('tr');
  1379. row.nTr = nTr;
  1380. row.anCells = cells;
  1381. /* Use a private property on the node to allow reserve mapping from the node
  1382. * to the aoData array for fast look up
  1383. */
  1384. nTr._DT_RowIndex = iRow;
  1385. /* Special parameters can be given by the data source to be used on the row */
  1386. _fnRowAttributes( row );
  1387. /* Process each column */
  1388. for ( i=0, iLen=oSettings.aoColumns.length ; i<iLen ; i++ )
  1389. {
  1390. oCol = oSettings.aoColumns[i];
  1391. nTd = nTrIn ? anTds[i] : document.createElement( oCol.sCellType );
  1392. cells.push( nTd );
  1393. // Need to create the HTML if new, or if a rendering function is defined
  1394. if ( !nTrIn || oCol.mRender || oCol.mData !== i )
  1395. {
  1396. nTd.innerHTML = _fnGetCellData( oSettings, iRow, i, 'display' );
  1397. }
  1398. /* Add user defined class */
  1399. if ( oCol.sClass )
  1400. {
  1401. nTd.className += ' '+oCol.sClass;
  1402. }
  1403. // Visibility - add or remove as required
  1404. if ( oCol.bVisible && ! nTrIn )
  1405. {
  1406. nTr.appendChild( nTd );
  1407. }
  1408. else if ( ! oCol.bVisible && nTrIn )
  1409. {
  1410. nTd.parentNode.removeChild( nTd );
  1411. }
  1412. if ( oCol.fnCreatedCell )
  1413. {
  1414. oCol.fnCreatedCell.call( oSettings.oInstance,
  1415. nTd, _fnGetCellData( oSettings, iRow, i ), rowData, iRow, i
  1416. );
  1417. }
  1418. }
  1419. _fnCallbackFire( oSettings, 'aoRowCreatedCallback', null, [nTr, rowData, iRow] );
  1420. }
  1421. // Remove once webkit bug 131819 and Chromium bug 365619 have been resolved
  1422. // and deployed
  1423. row.nTr.setAttribute( 'role', 'row' );
  1424. }
  1425. /**
  1426. * Add attributes to a row based on the special `DT_*` parameters in a data
  1427. * source object.
  1428. * @param {object} DataTables row object for the row to be modified
  1429. * @memberof DataTable#oApi
  1430. */
  1431. function _fnRowAttributes( row )
  1432. {
  1433. var tr = row.nTr;
  1434. var data = row._aData;
  1435. if ( tr ) {
  1436. if ( data.DT_RowId ) {
  1437. tr.id = data.DT_RowId;
  1438. }
  1439. if ( data.DT_RowClass ) {
  1440. // Remove any classes added by DT_RowClass before
  1441. var a = data.DT_RowClass.split(' ');
  1442. row.__rowc = row.__rowc ?
  1443. _unique( row.__rowc.concat( a ) ) :
  1444. a;
  1445. $(tr)
  1446. .removeClass( row.__rowc.join(' ') )
  1447. .addClass( data.DT_RowClass );
  1448. }
  1449. //MG changed
  1450. if ( data.DT_RowData ) {
  1451. for(var x in data.DT_RowData)
  1452. {
  1453. $(tr).attr('data-'+x,data.DT_RowData[x]);
  1454. }
  1455. }
  1456. }
  1457. }
  1458. /**
  1459. * Create the HTML header for the table
  1460. * @param {object} oSettings dataTables settings object
  1461. * @memberof DataTable#oApi
  1462. */
  1463. function _fnBuildHead( oSettings )
  1464. {
  1465. var i, ien, cell, row, column;
  1466. var thead = oSettings.nTHead;
  1467. var tfoot = oSettings.nTFoot;
  1468. var createHeader = $('th, td', thead).length === 0;
  1469. var classes = oSettings.oClasses;
  1470. var columns = oSettings.aoColumns;
  1471. if ( createHeader ) {
  1472. row = $('<tr/>').appendTo( thead );
  1473. }
  1474. for ( i=0, ien=columns.length ; i<ien ; i++ ) {
  1475. column = columns[i];
  1476. cell = $( column.nTh ).addClass( column.sClass );
  1477. if ( createHeader ) {
  1478. cell.appendTo( row );
  1479. }
  1480. // 1.11 move into sorting
  1481. if ( oSettings.oFeatures.bSort ) {
  1482. cell.addClass( column.sSortingClass );
  1483. if ( column.bSortable !== false ) {
  1484. cell
  1485. .attr( 'tabindex', oSettings.iTabIndex )
  1486. .attr( 'aria-controls', oSettings.sTableId );
  1487. _fnSortAttachListener( oSettings, column.nTh, i );
  1488. }
  1489. }
  1490. if ( column.sTitle != cell.html() ) {
  1491. cell.html( column.sTitle );
  1492. }
  1493. _fnRenderer( oSettings, 'header' )(
  1494. oSettings, cell, column, classes
  1495. );
  1496. }
  1497. if ( createHeader ) {
  1498. _fnDetectHeader( oSettings.aoHeader, thead );
  1499. }
  1500. /* ARIA role for the rows */
  1501. $(thead).find('>tr').attr('role', 'row');
  1502. /* Deal with the footer - add classes if required */
  1503. $(thead).find('>tr>th, >tr>td').addClass( classes.sHeaderTH );
  1504. $(tfoot).find('>tr>th, >tr>td').addClass( classes.sFooterTH );
  1505. // Cache the footer cells. Note that we only take the cells from the first
  1506. // row in the footer. If there is more than one row the user wants to
  1507. // interact with, they need to use the table().foot() method. Note also this
  1508. // allows cells to be used for multiple columns using colspan
  1509. if ( tfoot !== null ) {
  1510. var cells = oSettings.aoFooter[0];
  1511. for ( i=0, ien=cells.length ; i<ien ; i++ ) {
  1512. column = columns[i];
  1513. column.nTf = cells[i].cell;
  1514. if ( column.sClass ) {
  1515. $(column.nTf).addClass( column.sClass );
  1516. }
  1517. }
  1518. }
  1519. }
  1520. /**
  1521. * Draw the header (or footer) element based on the column visibility states. The
  1522. * methodology here is to use the layout array from _fnDetectHeader, modified for
  1523. * the instantaneous column visibility, to construct the new layout. The grid is
  1524. * traversed over cell at a time in a rows x columns grid fashion, although each
  1525. * cell insert can cover multiple elements in the grid - which is tracks using the
  1526. * aApplied array. Cell inserts in the grid will only occur where there isn't
  1527. * already a cell in that position.
  1528. * @param {object} oSettings dataTables settings object
  1529. * @param array {objects} aoSource Layout array from _fnDetectHeader
  1530. * @param {boolean} [bIncludeHidden=false] If true then include the hidden columns in the calc,
  1531. * @memberof DataTable#oApi
  1532. */
  1533. function _fnDrawHead( oSettings, aoSource, bIncludeHidden )
  1534. {
  1535. var i, iLen, j, jLen, k, kLen, n, nLocalTr;
  1536. var aoLocal = [];
  1537. var aApplied = [];
  1538. var iColumns = oSettings.aoColumns.length;
  1539. var iRowspan, iColspan;
  1540. if ( ! aoSource )
  1541. {
  1542. return;
  1543. }
  1544. if ( bIncludeHidden === undefined )
  1545. {
  1546. bIncludeHidden = false;
  1547. }
  1548. /* Make a copy of the master layout array, but without the visible columns in it */
  1549. for ( i=0, iLen=aoSource.length ; i<iLen ; i++ )
  1550. {
  1551. aoLocal[i] = aoSource[i].slice();
  1552. aoLocal[i].nTr = aoSource[i].nTr;
  1553. /* Remove any columns which are currently hidden */
  1554. for ( j=iColumns-1 ; j>=0 ; j-- )
  1555. {
  1556. if ( !oSettings.aoColumns[j].bVisible && !bIncludeHidden )
  1557. {
  1558. aoLocal[i].splice( j, 1 );
  1559. }
  1560. }
  1561. /* Prep the applied array - it needs an element for each row */
  1562. aApplied.push( [] );
  1563. }
  1564. for ( i=0, iLen=aoLocal.length ; i<iLen ; i++ )
  1565. {
  1566. nLocalTr = aoLocal[i].nTr;
  1567. /* All cells are going to be replaced, so empty out the row */
  1568. if ( nLocalTr )
  1569. {
  1570. while( (n = nLocalTr.firstChild) )
  1571. {
  1572. nLocalTr.removeChild( n );
  1573. }
  1574. }
  1575. for ( j=0, jLen=aoLocal[i].length ; j<jLen ; j++ )
  1576. {
  1577. iRowspan = 1;
  1578. iColspan = 1;
  1579. /* Check to see if there is already a cell (row/colspan) covering our target
  1580. * insert point. If there is, then there is nothing to do.
  1581. */
  1582. if ( aApplied[i][j] === undefined )
  1583. {
  1584. nLocalTr.appendChild( aoLocal[i][j].cell );
  1585. aApplied[i][j] = 1;
  1586. /* Expand the cell to cover as many rows as needed */
  1587. while ( aoLocal[i+iRowspan] !== undefined &&
  1588. aoLocal[i][j].cell == aoLocal[i+iRowspan][j].cell )
  1589. {
  1590. aApplied[i+iRowspan][j] = 1;
  1591. iRowspan++;
  1592. }
  1593. /* Expand the cell to cover as many columns as needed */
  1594. while ( aoLocal[i][j+iColspan] !== undefined &&
  1595. aoLocal[i][j].cell == aoLocal[i][j+iColspan].cell )
  1596. {
  1597. /* Must update the applied array over the rows for the columns */
  1598. for ( k=0 ; k<iRowspan ; k++ )
  1599. {
  1600. aApplied[i+k][j+iColspan] = 1;
  1601. }
  1602. iColspan++;
  1603. }
  1604. /* Do the actual expansion in the DOM */
  1605. $(aoLocal[i][j].cell)
  1606. .attr('rowspan', iRowspan)
  1607. .attr('colspan', iColspan);
  1608. }
  1609. }
  1610. }
  1611. }
  1612. /**
  1613. * Insert the required TR nodes into the table for display
  1614. * @param {object} oSettings dataTables settings object
  1615. * @memberof DataTable#oApi
  1616. */
  1617. function _fnDraw( oSettings )
  1618. {
  1619. /* Provide a pre-callback function which can be used to cancel the draw is false is returned */
  1620. var aPreDraw = _fnCallbackFire( oSettings, 'aoPreDrawCallback', 'preDraw', [oSettings] );
  1621. if ( $.inArray( false, aPreDraw ) !== -1 )
  1622. {
  1623. _fnProcessingDisplay( oSettings, false );
  1624. return;
  1625. }
  1626. var i, iLen, n;
  1627. var anRows = [];
  1628. var iRowCount = 0;
  1629. var asStripeClasses = oSettings.asStripeClasses;
  1630. var iStripes = asStripeClasses.length;
  1631. var iOpenRows = oSettings.aoOpenRows.length;
  1632. var oLang = oSettings.oLanguage;
  1633. var iInitDisplayStart = oSettings.iInitDisplayStart;
  1634. var bServerSide = _fnDataSource( oSettings ) == 'ssp';
  1635. var aiDisplay = oSettings.aiDisplay;
  1636. oSettings.bDrawing = true;
  1637. /* Check and see if we have an initial draw position from state saving */
  1638. if ( iInitDisplayStart !== undefined && iInitDisplayStart !== -1 )
  1639. {
  1640. oSettings._iDisplayStart = bServerSide ?
  1641. iInitDisplayStart :
  1642. iInitDisplayStart >= oSettings.fnRecordsDisplay() ?
  1643. 0 :
  1644. iInitDisplayStart;
  1645. oSettings.iInitDisplayStart = -1;
  1646. }
  1647. var iDisplayStart = oSettings._iDisplayStart;
  1648. var iDisplayEnd = oSettings.fnDisplayEnd();
  1649. /* Server-side processing draw intercept */
  1650. if ( oSettings.bDeferLoading )
  1651. {
  1652. oSettings.bDeferLoading = false;
  1653. oSettings.iDraw++;
  1654. _fnProcessingDisplay( oSettings, false );
  1655. }
  1656. else if ( !bServerSide )
  1657. {
  1658. oSettings.iDraw++;
  1659. }
  1660. else if ( !oSettings.bDestroying && !_fnAjaxUpdate( oSettings ) )
  1661. {
  1662. return;
  1663. }
  1664. if ( aiDisplay.length !== 0 )
  1665. {
  1666. var iStart = bServerSide ? 0 : iDisplayStart;
  1667. var iEnd = bServerSide ? oSettings.aoData.length : iDisplayEnd;
  1668. for ( var j=iStart ; j<iEnd ; j++ )
  1669. {
  1670. var iDataIndex = aiDisplay[j];
  1671. var aoData = oSettings.aoData[ iDataIndex ];
  1672. if ( aoData.nTr === null )
  1673. {
  1674. _fnCreateTr( oSettings, iDataIndex );
  1675. }
  1676. var nRow = aoData.nTr;
  1677. /* Remove the old striping classes and then add the new one */
  1678. if ( iStripes !== 0 )
  1679. {
  1680. var sStripe = asStripeClasses[ iRowCount % iStripes ];
  1681. if ( aoData._sRowStripe != sStripe )
  1682. {
  1683. $(nRow).removeClass( aoData._sRowStripe ).addClass( sStripe );
  1684. aoData._sRowStripe = sStripe;
  1685. }
  1686. }
  1687. // Row callback functions - might want to manipulate the row
  1688. // iRowCount and j are not currently documented. Are they at all
  1689. // useful?
  1690. _fnCallbackFire( oSettings, 'aoRowCallback', null,
  1691. [nRow, aoData._aData, iRowCount, j] );
  1692. anRows.push( nRow );
  1693. iRowCount++;
  1694. }
  1695. }
  1696. else
  1697. {
  1698. /* Table is empty - create a row with an empty message in it */
  1699. var sZero = oLang.sZeroRecords;
  1700. if ( oSettings.iDraw == 1 && _fnDataSource( oSettings ) == 'ajax' )
  1701. {
  1702. sZero = oLang.sLoadingRecords;
  1703. }
  1704. else if ( oLang.sEmptyTable && oSettings.fnRecordsTotal() === 0 )
  1705. {
  1706. sZero = oLang.sEmptyTable;
  1707. }
  1708. anRows[ 0 ] = $( '<tr/>', { 'class': iStripes ? asStripeClasses[0] : '' } )
  1709. .append( $('<td />', {
  1710. 'valign': 'top',
  1711. 'colSpan': _fnVisbleColumns( oSettings ),
  1712. 'class': oSettings.oClasses.sRowEmpty
  1713. } ).html( sZero ) )[0];
  1714. }
  1715. /* Header and footer callbacks */
  1716. _fnCallbackFire( oSettings, 'aoHeaderCallback', 'header', [ $(oSettings.nTHead).children('tr')[0],
  1717. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  1718. _fnCallbackFire( oSettings, 'aoFooterCallback', 'footer', [ $(oSettings.nTFoot).children('tr')[0],
  1719. _fnGetDataMaster( oSettings ), iDisplayStart, iDisplayEnd, aiDisplay ] );
  1720. var body = $(oSettings.nTBody);
  1721. body.children().detach();
  1722. body.append( $(anRows) );
  1723. /* Call all required callback functions for the end of a draw */
  1724. _fnCallbackFire( oSettings, 'aoDrawCallback', 'draw', [oSettings] );
  1725. /* Draw is complete, sorting and filtering must be as well */
  1726. oSettings.bSorted = false;
  1727. oSettings.bFiltered = false;
  1728. oSettings.bDrawing = false;
  1729. }
  1730. /**
  1731. * Redraw the table - taking account of the various features which are enabled
  1732. * @param {object} oSettings dataTables settings object
  1733. * @param {boolean} [holdPosition] Keep the current paging position. By default
  1734. * the paging is reset to the first page
  1735. * @memberof DataTable#oApi
  1736. */
  1737. function _fnReDraw( settings, holdPosition )
  1738. {
  1739. var
  1740. features = settings.oFeatures,
  1741. sort = features.bSort,
  1742. filter = features.bFilter;
  1743. if ( sort ) {
  1744. _fnSort( settings );
  1745. }
  1746. if ( filter ) {
  1747. _fnFilterComplete( settings, settings.oPreviousSearch );
  1748. }
  1749. else {
  1750. // No filtering, so we want to just use the display master
  1751. settings.aiDisplay = settings.aiDisplayMaster.slice();
  1752. }
  1753. if ( holdPosition !== true ) {
  1754. settings._iDisplayStart = 0;
  1755. }
  1756. // Let any modules know about the draw hold position state (used by
  1757. // scrolling internally)
  1758. settings._drawHold = holdPosition;
  1759. _fnDraw( settings );
  1760. settings._drawHold = false;
  1761. }
  1762. /**
  1763. * Add the options to the page HTML for the table
  1764. * @param {object} oSettings dataTables settings object
  1765. * @memberof DataTable#oApi
  1766. */
  1767. function _fnAddOptionsHtml ( oSettings )
  1768. {
  1769. var classes = oSettings.oClasses;
  1770. var table = $(oSettings.nTable);
  1771. var holding = $('<div/>').insertBefore( table ); // Holding element for speed
  1772. var features = oSettings.oFeatures;
  1773. // All DataTables are wrapped in a div
  1774. var insert = $('<div/>', {
  1775. id: oSettings.sTableId+'_wrapper',
  1776. 'class': classes.sWrapper + (oSettings.nTFoot ? '' : ' '+classes.sNoFooter)
  1777. } );
  1778. oSettings.nHolding = holding[0];
  1779. oSettings.nTableWrapper = insert[0];
  1780. oSettings.nTableReinsertBefore = oSettings.nTable.nextSibling;
  1781. /* Loop over the user set positioning and place the elements as needed */
  1782. var aDom = oSettings.sDom.split('');
  1783. var featureNode, cOption, nNewNode, cNext, sAttr, j;
  1784. for ( var i=0 ; i<aDom.length ; i++ )
  1785. {
  1786. featureNode = null;
  1787. cOption = aDom[i];
  1788. if ( cOption == '<' )
  1789. {
  1790. /* New container div */
  1791. nNewNode = $('<div/>')[0];
  1792. /* Check to see if we should append an id and/or a class name to the container */
  1793. cNext = aDom[i+1];
  1794. if ( cNext == "'" || cNext == '"' )
  1795. {
  1796. sAttr = "";
  1797. j = 2;
  1798. while ( aDom[i+j] != cNext )
  1799. {
  1800. sAttr += aDom[i+j];
  1801. j++;
  1802. }
  1803. /* Replace jQuery UI constants @yodo depreciated */
  1804. if ( sAttr == "H" )
  1805. {
  1806. sAttr = classes.sJUIHeader;
  1807. }
  1808. else if ( sAttr == "F" )
  1809. {
  1810. sAttr = classes.sJUIFooter;
  1811. }
  1812. /* The attribute can be in the format of "#id.class", "#id" or "class" This logic
  1813. * breaks the string into parts and applies them as needed
  1814. */
  1815. if ( sAttr.indexOf('.') != -1 )
  1816. {
  1817. var aSplit = sAttr.split('.');
  1818. nNewNode.id = aSplit[0].substr(1, aSplit[0].length-1);
  1819. nNewNode.className = aSplit[1];
  1820. }
  1821. else if ( sAttr.charAt(0) == "#" )
  1822. {
  1823. nNewNode.id = sAttr.substr(1, sAttr.length-1);
  1824. }
  1825. else
  1826. {
  1827. nNewNode.className = sAttr;
  1828. }
  1829. i += j; /* Move along the position array */
  1830. }
  1831. insert.append( nNewNode );
  1832. insert = $(nNewNode);
  1833. }
  1834. else if ( cOption == '>' )
  1835. {
  1836. /* End container div */
  1837. insert = insert.parent();
  1838. }
  1839. // @yodo Move options into their own plugins?
  1840. else if ( cOption == 'l' && features.bPaginate && features.bLengthChange )
  1841. {
  1842. /* Length */
  1843. featureNode = _fnFeatureHtmlLength( oSettings );
  1844. }
  1845. else if ( cOption == 'f' && features.bFilter )
  1846. {
  1847. /* Filter */
  1848. featureNode = _fnFeatureHtmlFilter( oSettings );
  1849. }
  1850. else if ( cOption == 'r' && features.bProcessing )
  1851. {
  1852. /* pRocessing */
  1853. featureNode = _fnFeatureHtmlProcessing( oSettings );
  1854. }
  1855. else if ( cOption == 't' )
  1856. {
  1857. /* Table */
  1858. featureNode = _fnFeatureHtmlTable( oSettings );
  1859. }
  1860. else if ( cOption == 'i' && features.bInfo )
  1861. {
  1862. /* Info */
  1863. featureNode = _fnFeatureHtmlInfo( oSettings );
  1864. }
  1865. else if ( cOption == 'p' && features.bPaginate )
  1866. {
  1867. /* Pagination */
  1868. featureNode = _fnFeatureHtmlPaginate( oSettings );
  1869. }
  1870. else if ( DataTable.ext.feature.length !== 0 )
  1871. {
  1872. /* Plug-in features */
  1873. var aoFeatures = DataTable.ext.feature;
  1874. for ( var k=0, kLen=aoFeatures.length ; k<kLen ; k++ )
  1875. {
  1876. if ( cOption == aoFeatures[k].cFeature )
  1877. {
  1878. featureNode = aoFeatures[k].fnInit( oSettings );
  1879. break;
  1880. }
  1881. }
  1882. }
  1883. /* Add to the 2D features array */
  1884. if ( featureNode )
  1885. {
  1886. var aanFeatures = oSettings.aanFeatures;
  1887. if ( ! aanFeatures[cOption] )
  1888. {
  1889. aanFeatures[cOption] = [];
  1890. }
  1891. aanFeatures[cOption].push( featureNode );
  1892. insert.append( featureNode );
  1893. }
  1894. }
  1895. /* Built our DOM structure - replace the holding div with what we want */
  1896. holding.replaceWith( insert );
  1897. }
  1898. /**
  1899. * Use the DOM source to create up an array of header cells. The idea here is to
  1900. * create a layout grid (array) of rows x columns, which contains a reference
  1901. * to the cell that that point in the grid (regardless of col/rowspan), such that
  1902. * any column / row could be removed and the new grid constructed
  1903. * @param array {object} aLayout Array to store the calculated layout in
  1904. * @param {node} nThead The header/footer element for the table
  1905. * @memberof DataTable#oApi
  1906. */
  1907. function _fnDetectHeader ( aLayout, nThead )
  1908. {
  1909. var nTrs = $(nThead).children('tr');
  1910. var nTr, nCell;
  1911. var i, k, l, iLen, jLen, iColShifted, iColumn, iColspan, iRowspan;
  1912. var bUnique;
  1913. var fnShiftCol = function ( a, i, j ) {
  1914. var k = a[i];
  1915. while ( k[j] ) {
  1916. j++;
  1917. }
  1918. return j;
  1919. };
  1920. aLayout.splice( 0, aLayout.length );
  1921. /* We know how many rows there are in the layout - so prep it */
  1922. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  1923. {
  1924. aLayout.push( [] );
  1925. }
  1926. /* Calculate a layout array */
  1927. for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
  1928. {
  1929. nTr = nTrs[i];
  1930. iColumn = 0;
  1931. /* For every cell in the row... */
  1932. nCell = nTr.firstChild;
  1933. while ( nCell ) {
  1934. if ( nCell.nodeName.toUpperCase() == "TD" ||
  1935. nCell.nodeName.toUpperCase() == "TH" )
  1936. {
  1937. /* Get the col and rowspan attributes from the DOM and sanitise them */
  1938. iColspan = nCell.getAttribute('colspan') * 1;
  1939. iRowspan = nCell.getAttribute('rowspan') * 1;
  1940. iColspan = (!iColspan || iColspan===0 || iColspan===1) ? 1 : iColspan;
  1941. iRowspan = (!iRowspan || iRowspan===0 || iRowspan===1) ? 1 : iRowspan;
  1942. /* There might be colspan cells already in this row, so shift our target
  1943. * accordingly
  1944. */
  1945. iColShifted = fnShiftCol( aLayout, i, iColumn );
  1946. /* Cache calculation for unique columns */
  1947. bUnique = iColspan === 1 ? true : false;
  1948. /* If there is col / rowspan, copy the information into the layout grid */
  1949. for ( l=0 ; l<iColspan ; l++ )
  1950. {
  1951. for ( k=0 ; k<iRowspan ; k++ )
  1952. {
  1953. aLayout[i+k][iColShifted+l] = {
  1954. "cell": nCell,
  1955. "unique": bUnique
  1956. };
  1957. aLayout[i+k].nTr = nTr;
  1958. }
  1959. }
  1960. }
  1961. nCell = nCell.nextSibling;
  1962. }
  1963. }
  1964. }
  1965. /**
  1966. * Get an array of unique th elements, one for each column
  1967. * @param {object} oSettings dataTables settings object
  1968. * @param {node} nHeader automatically detect the layout from this node - optional
  1969. * @param {array} aLayout thead/tfoot layout from _fnDetectHeader - optional
  1970. * @returns array {node} aReturn list of unique th's
  1971. * @memberof DataTable#oApi
  1972. */
  1973. function _fnGetUniqueThs ( oSettings, nHeader, aLayout )
  1974. {
  1975. var aReturn = [];
  1976. if ( !aLayout )
  1977. {
  1978. aLayout = oSettings.aoHeader;
  1979. if ( nHeader )
  1980. {
  1981. aLayout = [];
  1982. _fnDetectHeader( aLayout, nHeader );
  1983. }
  1984. }
  1985. for ( var i=0, iLen=aLayout.length ; i<iLen ; i++ )
  1986. {
  1987. for ( var j=0, jLen=aLayout[i].length ; j<jLen ; j++ )
  1988. {
  1989. if ( aLayout[i][j].unique &&
  1990. (!aReturn[j] || !oSettings.bSortCellsTop) )
  1991. {
  1992. aReturn[j] = aLayout[i][j].cell;
  1993. }
  1994. }
  1995. }
  1996. return aReturn;
  1997. }
  1998. /**
  1999. * Create an Ajax call based on the table's settings, taking into account that
  2000. * parameters can have multiple forms, and backwards compatibility.
  2001. *
  2002. * @param {object} oSettings dataTables settings object
  2003. * @param {array} data Data to send to the server, required by
  2004. * DataTables - may be augmented by developer callbacks
  2005. * @param {function} fn Callback function to run when data is obtained
  2006. */
  2007. function _fnBuildAjax( oSettings, data, fn )
  2008. {
  2009. // Compatibility with 1.9-, allow fnServerData and event to manipulate
  2010. _fnCallbackFire( oSettings, 'aoServerParams', 'serverParams', [data] );
  2011. // Convert to object based for 1.10+ if using the old array scheme which can
  2012. // come from server-side processing or serverParams
  2013. if ( data && $.isArray(data) ) {
  2014. var tmp = {};
  2015. var rbracket = /(.*?)\[\]$/;
  2016. $.each( data, function (key, val) {
  2017. var match = val.name.match(rbracket);
  2018. if ( match ) {
  2019. // Support for arrays
  2020. var name = match[0];
  2021. if ( ! tmp[ name ] ) {
  2022. tmp[ name ] = [];
  2023. }
  2024. tmp[ name ].push( val.value );
  2025. }
  2026. else {
  2027. tmp[val.name] = val.value;
  2028. }
  2029. } );
  2030. data = tmp;
  2031. }
  2032. var ajaxData;
  2033. var ajax = oSettings.ajax;
  2034. var instance = oSettings.oInstance;
  2035. if ( $.isPlainObject( ajax ) && ajax.data )
  2036. {
  2037. ajaxData = ajax.data;
  2038. var newData = $.isFunction( ajaxData ) ?
  2039. ajaxData( data ) : // fn can manipulate data or return an object
  2040. ajaxData; // object or array to merge
  2041. // If the function returned an object, use that alone
  2042. data = $.isFunction( ajaxData ) && newData ?
  2043. newData :
  2044. $.extend( true, data, newData );
  2045. // Remove the data property as we've resolved it already and don't want
  2046. // jQuery to do it again (it is restored at the end of the function)
  2047. delete ajax.data;
  2048. }
  2049. var baseAjax = {
  2050. "data": data,
  2051. "success": function (json) {
  2052. var error = json.error || json.sError;
  2053. if ( error ) {
  2054. oSettings.oApi._fnLog( oSettings, 0, error );
  2055. }
  2056. oSettings.json = json;
  2057. _fnCallbackFire( oSettings, null, 'xhr', [oSettings, json] );
  2058. fn( json );
  2059. },
  2060. "dataType": "json",
  2061. "cache": false,
  2062. "type": oSettings.sServerMethod,
  2063. "error": function (xhr, error, thrown) {
  2064. var log = oSettings.oApi._fnLog;
  2065. if ( error == "parsererror" ) {
  2066. log( oSettings, 0, 'Invalid JSON response', 1 );
  2067. }
  2068. else if ( xhr.readyState === 4 ) {
  2069. log( oSettings, 0, 'Ajax error', 7 );
  2070. }
  2071. _fnProcessingDisplay( oSettings, false );
  2072. }
  2073. };
  2074. // Store the data submitted for the API
  2075. oSettings.oAjaxData = data;
  2076. // Allow plug-ins and external processes to modify the data
  2077. _fnCallbackFire( oSettings, null, 'preXhr', [oSettings, data] );
  2078. if ( oSettings.fnServerData )
  2079. {
  2080. // DataTables 1.9- compatibility
  2081. oSettings.fnServerData.call( instance,
  2082. oSettings.sAjaxSource,
  2083. $.map( data, function (val, key) { // Need to convert back to 1.9 trad format
  2084. return { name: key, value: val };
  2085. } ),
  2086. fn,
  2087. oSettings
  2088. );
  2089. }
  2090. else if ( oSettings.sAjaxSource || typeof ajax === 'string' )
  2091. {
  2092. // DataTables 1.9- compatibility
  2093. oSettings.jqXHR = $.ajax( $.extend( baseAjax, {
  2094. url: ajax || oSettings.sAjaxSource
  2095. } ) );
  2096. }
  2097. else if ( $.isFunction( ajax ) )
  2098. {
  2099. // Is a function - let the caller define what needs to be done
  2100. oSettings.jqXHR = ajax.call( instance, data, fn, oSettings );
  2101. }
  2102. else
  2103. {
  2104. // Object to extend the base settings
  2105. oSettings.jqXHR = $.ajax( $.extend( baseAjax, ajax ) );
  2106. // Restore for next time around
  2107. ajax.data = ajaxData;
  2108. }
  2109. }
  2110. /**
  2111. * Update the table using an Ajax call
  2112. * @param {object} settings dataTables settings object
  2113. * @returns {boolean} Block the table drawing or not
  2114. * @memberof DataTable#oApi
  2115. */
  2116. function _fnAjaxUpdate( settings )
  2117. {
  2118. if ( settings.bAjaxDataGet ) {
  2119. settings.iDraw++;
  2120. _fnProcessingDisplay( settings, true );
  2121. _fnBuildAjax(
  2122. settings,
  2123. _fnAjaxParameters( settings ),
  2124. function(json) {
  2125. _fnAjaxUpdateDraw( settings, json );
  2126. }
  2127. );
  2128. return false;
  2129. }
  2130. return true;
  2131. }
  2132. /**
  2133. * Build up the parameters in an object needed for a server-side processing
  2134. * request. Note that this is basically done twice, is different ways - a modern
  2135. * method which is used by default in DataTables 1.10 which uses objects and
  2136. * arrays, or the 1.9- method with is name / value pairs. 1.9 method is used if
  2137. * the sAjaxSource option is used in the initialisation, or the legacyAjax
  2138. * option is set.
  2139. * @param {object} oSettings dataTables settings object
  2140. * @returns {bool} block the table drawing or not
  2141. * @memberof DataTable#oApi
  2142. */
  2143. function _fnAjaxParameters( settings )
  2144. {
  2145. var
  2146. columns = settings.aoColumns,
  2147. columnCount = columns.length,
  2148. features = settings.oFeatures,
  2149. preSearch = settings.oPreviousSearch,
  2150. preColSearch = settings.aoPreSearchCols,
  2151. i, data = [], dataProp, column, columnSearch,
  2152. sort = _fnSortFlatten( settings ),
  2153. displayStart = settings._iDisplayStart,
  2154. displayLength = features.bPaginate !== false ?
  2155. settings._iDisplayLength :
  2156. -1;
  2157. var param = function ( name, value ) {
  2158. data.push( { 'name': name, 'value': value } );
  2159. };
  2160. // DataTables 1.9- compatible method
  2161. param( 'sEcho', settings.iDraw );
  2162. param( 'iColumns', columnCount );
  2163. param( 'sColumns', _pluck( columns, 'sName' ).join(',') );
  2164. param( 'iDisplayStart', displayStart );
  2165. param( 'iDisplayLength', displayLength );
  2166. // DataTables 1.10+ method
  2167. var d = {
  2168. draw: settings.iDraw,
  2169. columns: [],
  2170. order: [],
  2171. start: displayStart,
  2172. length: displayLength,
  2173. search: {
  2174. value: preSearch.sSearch,
  2175. regex: preSearch.bRegex
  2176. }
  2177. };
  2178. for ( i=0 ; i<columnCount ; i++ ) {
  2179. column = columns[i];
  2180. columnSearch = preColSearch[i];
  2181. dataProp = typeof column.mData=="function" ? 'function' : column.mData ;
  2182. d.columns.push( {
  2183. data: dataProp,
  2184. name: column.sName,
  2185. searchable: column.bSearchable,
  2186. orderable: column.bSortable,
  2187. search: {
  2188. value: columnSearch.sSearch,
  2189. regex: columnSearch.bRegex
  2190. }
  2191. } );
  2192. param( "mDataProp_"+i, dataProp );
  2193. if ( features.bFilter ) {
  2194. param( 'sSearch_'+i, columnSearch.sSearch );
  2195. param( 'bRegex_'+i, columnSearch.bRegex );
  2196. param( 'bSearchable_'+i, column.bSearchable );
  2197. }
  2198. if ( features.bSort ) {
  2199. param( 'bSortable_'+i, column.bSortable );
  2200. }
  2201. }
  2202. if ( features.bFilter ) {
  2203. param( 'sSearch', preSearch.sSearch );
  2204. param( 'bRegex', preSearch.bRegex );
  2205. }
  2206. if ( features.bSort ) {
  2207. $.each( sort, function ( i, val ) {
  2208. d.order.push( { column: val.col, dir: val.dir } );
  2209. param( 'iSortCol_'+i, val.col );
  2210. param( 'sSortDir_'+i, val.dir );
  2211. } );
  2212. param( 'iSortingCols', sort.length );
  2213. }
  2214. // If the legacy.ajax parameter is null, then we automatically decide which
  2215. // form to use, based on sAjaxSource
  2216. var legacy = DataTable.ext.legacy.ajax;
  2217. if ( legacy === null ) {
  2218. return settings.sAjaxSource ? data : d;
  2219. }
  2220. // Otherwise, if legacy has been specified then we use that to decide on the
  2221. // form
  2222. return legacy ? data : d;
  2223. }
  2224. /**
  2225. * Data the data from the server (nuking the old) and redraw the table
  2226. * @param {object} oSettings dataTables settings object
  2227. * @param {object} json json data return from the server.
  2228. * @param {string} json.sEcho Tracking flag for DataTables to match requests
  2229. * @param {int} json.iTotalRecords Number of records in the data set, not accounting for filtering
  2230. * @param {int} json.iTotalDisplayRecords Number of records in the data set, accounting for filtering
  2231. * @param {array} json.aaData The data to display on this page
  2232. * @param {string} [json.sColumns] Column ordering (sName, comma separated)
  2233. * @memberof DataTable#oApi
  2234. */
  2235. function _fnAjaxUpdateDraw ( settings, json )
  2236. {
  2237. // v1.10 uses camelCase variables, while 1.9 uses Hungarian notation.
  2238. // Support both
  2239. var compat = function ( old, modern ) {
  2240. return json[old] !== undefined ? json[old] : json[modern];
  2241. };
  2242. var draw = compat( 'sEcho', 'draw' );
  2243. var recordsTotal = compat( 'iTotalRecords', 'recordsTotal' );
  2244. var rocordsFiltered = compat( 'iTotalDisplayRecords', 'recordsFiltered' );
  2245. if ( draw ) {
  2246. // Protect against out of sequence returns
  2247. if ( draw*1 < settings.iDraw ) {
  2248. return;
  2249. }
  2250. settings.iDraw = draw * 1;
  2251. }
  2252. _fnClearTable( settings );
  2253. settings._iRecordsTotal = parseInt(recordsTotal, 10);
  2254. settings._iRecordsDisplay = parseInt(rocordsFiltered, 10);
  2255. var data = _fnAjaxDataSrc( settings, json );
  2256. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  2257. _fnAddData( settings, data[i] );
  2258. }
  2259. settings.aiDisplay = settings.aiDisplayMaster.slice();
  2260. settings.bAjaxDataGet = false;
  2261. _fnDraw( settings );
  2262. if ( ! settings._bInitComplete ) {
  2263. _fnInitComplete( settings, json );
  2264. }
  2265. settings.bAjaxDataGet = true;
  2266. _fnProcessingDisplay( settings, false );
  2267. }
  2268. /**
  2269. * Get the data from the JSON data source to use for drawing a table. Using
  2270. * `_fnGetObjectDataFn` allows the data to be sourced from a property of the
  2271. * source object, or from a processing function.
  2272. * @param {object} oSettings dataTables settings object
  2273. * @param {object} json Data source object / array from the server
  2274. * @return {array} Array of data to use
  2275. */
  2276. function _fnAjaxDataSrc ( oSettings, json )
  2277. {
  2278. var dataSrc = $.isPlainObject( oSettings.ajax ) && oSettings.ajax.dataSrc !== undefined ?
  2279. oSettings.ajax.dataSrc :
  2280. oSettings.sAjaxDataProp; // Compatibility with 1.9-.
  2281. // Compatibility with 1.9-. In order to read from aaData, check if the
  2282. // default has been changed, if not, check for aaData
  2283. if ( dataSrc === 'data' ) {
  2284. return json.aaData || json[dataSrc];
  2285. }
  2286. return dataSrc !== "" ?
  2287. _fnGetObjectDataFn( dataSrc )( json ) :
  2288. json;
  2289. }
  2290. /**
  2291. * Generate the node required for filtering text
  2292. * @returns {node} Filter control element
  2293. * @param {object} oSettings dataTables settings object
  2294. * @memberof DataTable#oApi
  2295. */
  2296. function _fnFeatureHtmlFilter ( settings )
  2297. {
  2298. var classes = settings.oClasses;
  2299. var tableId = settings.sTableId;
  2300. var language = settings.oLanguage;
  2301. var previousSearch = settings.oPreviousSearch;
  2302. var features = settings.aanFeatures;
  2303. var input = '<input type="search" class="'+classes.sFilterInput+'"/>';
  2304. var str = language.sSearch;
  2305. str = str.match(/_INPUT_/) ?
  2306. str.replace('_INPUT_', input) :
  2307. str+input;
  2308. var filter = $('<div/>', {
  2309. 'id': ! features.f ? tableId+'_filter' : null,
  2310. 'class': classes.sFilter
  2311. } )
  2312. .append( $('<label/>' ).append( str ) );
  2313. var searchFn = function() {
  2314. /* Update all other filter input elements for the new display */
  2315. var n = features.f;
  2316. var val = !this.value ? "" : this.value; // mental IE8 fix :-(
  2317. /* Now do the filter */
  2318. if ( val != previousSearch.sSearch ) {
  2319. _fnFilterComplete( settings, {
  2320. "sSearch": val,
  2321. "bRegex": previousSearch.bRegex,
  2322. "bSmart": previousSearch.bSmart ,
  2323. "bCaseInsensitive": previousSearch.bCaseInsensitive
  2324. } );
  2325. // Need to redraw, without resorting
  2326. settings._iDisplayStart = 0;
  2327. _fnDraw( settings );
  2328. }
  2329. };
  2330. var searchDelay = settings.searchDelay !== null ?
  2331. settings.searchDelay :
  2332. _fnDataSource( settings ) === 'ssp' ?
  2333. 400 :
  2334. 0;
  2335. var jqFilter = $('input', filter)
  2336. .val( previousSearch.sSearch )
  2337. .attr( 'placeholder', language.sSearchPlaceholder )
  2338. .bind(
  2339. 'keyup.DT search.DT input.DT paste.DT cut.DT',
  2340. searchDelay ?
  2341. _fnThrottle( searchFn, searchDelay ) :
  2342. searchFn
  2343. )
  2344. .bind( 'keypress.DT', function(e) {
  2345. /* Prevent form submission */
  2346. if ( e.keyCode == 13 ) {
  2347. return false;
  2348. }
  2349. } )
  2350. .attr('aria-controls', tableId);
  2351. // Update the input elements whenever the table is filtered
  2352. $(settings.nTable).on( 'search.dt.DT', function ( ev, s ) {
  2353. if ( settings === s ) {
  2354. // IE9 throws an 'unknown error' if document.activeElement is used
  2355. // inside an iframe or frame...
  2356. try {
  2357. if ( jqFilter[0] !== document.activeElement ) {
  2358. jqFilter.val( previousSearch.sSearch );
  2359. }
  2360. }
  2361. catch ( e ) {}
  2362. }
  2363. } );
  2364. return filter[0];
  2365. }
  2366. /**
  2367. * Filter the table using both the global filter and column based filtering
  2368. * @param {object} oSettings dataTables settings object
  2369. * @param {object} oSearch search information
  2370. * @param {int} [iForce] force a research of the master array (1) or not (undefined or 0)
  2371. * @memberof DataTable#oApi
  2372. */
  2373. function _fnFilterComplete ( oSettings, oInput, iForce )
  2374. {
  2375. var oPrevSearch = oSettings.oPreviousSearch;
  2376. var aoPrevSearch = oSettings.aoPreSearchCols;
  2377. var fnSaveFilter = function ( oFilter ) {
  2378. /* Save the filtering values */
  2379. oPrevSearch.sSearch = oFilter.sSearch;
  2380. oPrevSearch.bRegex = oFilter.bRegex;
  2381. oPrevSearch.bSmart = oFilter.bSmart;
  2382. oPrevSearch.bCaseInsensitive = oFilter.bCaseInsensitive;
  2383. };
  2384. var fnRegex = function ( o ) {
  2385. // Backwards compatibility with the bEscapeRegex option
  2386. return o.bEscapeRegex !== undefined ? !o.bEscapeRegex : o.bRegex;
  2387. };
  2388. // Resolve any column types that are unknown due to addition or invalidation
  2389. // @yodo As per sort - can this be moved into an event handler?
  2390. _fnColumnTypes( oSettings );
  2391. /* In server-side processing all filtering is done by the server, so no point hanging around here */
  2392. if ( _fnDataSource( oSettings ) != 'ssp' )
  2393. {
  2394. /* Global filter */
  2395. _fnFilter( oSettings, oInput.sSearch, iForce, fnRegex(oInput), oInput.bSmart, oInput.bCaseInsensitive );
  2396. fnSaveFilter( oInput );
  2397. /* Now do the individual column filter */
  2398. for ( var i=0 ; i<aoPrevSearch.length ; i++ )
  2399. {
  2400. _fnFilterColumn( oSettings, aoPrevSearch[i].sSearch, i, fnRegex(aoPrevSearch[i]),
  2401. aoPrevSearch[i].bSmart, aoPrevSearch[i].bCaseInsensitive );
  2402. }
  2403. /* Custom filtering */
  2404. _fnFilterCustom( oSettings );
  2405. }
  2406. else
  2407. {
  2408. fnSaveFilter( oInput );
  2409. }
  2410. /* Tell the draw function we have been filtering */
  2411. oSettings.bFiltered = true;
  2412. _fnCallbackFire( oSettings, null, 'search', [oSettings] );
  2413. }
  2414. /**
  2415. * Apply custom filtering functions
  2416. * @param {object} oSettings dataTables settings object
  2417. * @memberof DataTable#oApi
  2418. */
  2419. function _fnFilterCustom( settings )
  2420. {
  2421. var filters = DataTable.ext.search;
  2422. var displayRows = settings.aiDisplay;
  2423. var row, rowIdx;
  2424. for ( var i=0, ien=filters.length ; i<ien ; i++ ) {
  2425. var rows = [];
  2426. // Loop over each row and see if it should be included
  2427. for ( var j=0, jen=displayRows.length ; j<jen ; j++ ) {
  2428. rowIdx = displayRows[ j ];
  2429. row = settings.aoData[ rowIdx ];
  2430. if ( filters[i]( settings, row._aFilterData, rowIdx, row._aData, j ) ) {
  2431. rows.push( rowIdx );
  2432. }
  2433. }
  2434. // So the array reference doesn't break set the results into the
  2435. // existing array
  2436. displayRows.length = 0;
  2437. displayRows.push.apply( displayRows, rows );
  2438. }
  2439. }
  2440. /**
  2441. * Filter the table on a per-column basis
  2442. * @param {object} oSettings dataTables settings object
  2443. * @param {string} sInput string to filter on
  2444. * @param {int} iColumn column to filter
  2445. * @param {bool} bRegex treat search string as a regular expression or not
  2446. * @param {bool} bSmart use smart filtering or not
  2447. * @param {bool} bCaseInsensitive Do case insenstive matching or not
  2448. * @memberof DataTable#oApi
  2449. */
  2450. function _fnFilterColumn ( settings, searchStr, colIdx, regex, smart, caseInsensitive )
  2451. {
  2452. if ( searchStr === '' ) {
  2453. return;
  2454. }
  2455. var data;
  2456. var display = settings.aiDisplay;
  2457. var rpSearch = _fnFilterCreateSearch( searchStr, regex, smart, caseInsensitive );
  2458. for ( var i=display.length-1 ; i>=0 ; i-- ) {
  2459. data = settings.aoData[ display[i] ]._aFilterData[ colIdx ];
  2460. if ( ! rpSearch.test( data ) ) {
  2461. display.splice( i, 1 );
  2462. }
  2463. }
  2464. }
  2465. /**
  2466. * Filter the data table based on user input and draw the table
  2467. * @param {object} settings dataTables settings object
  2468. * @param {string} input string to filter on
  2469. * @param {int} force optional - force a research of the master array (1) or not (undefined or 0)
  2470. * @param {bool} regex treat as a regular expression or not
  2471. * @param {bool} smart perform smart filtering or not
  2472. * @param {bool} caseInsensitive Do case insenstive matching or not
  2473. * @memberof DataTable#oApi
  2474. */
  2475. function _fnFilter( settings, input, force, regex, smart, caseInsensitive )
  2476. {
  2477. var rpSearch = _fnFilterCreateSearch( input, regex, smart, caseInsensitive );
  2478. var prevSearch = settings.oPreviousSearch.sSearch;
  2479. var displayMaster = settings.aiDisplayMaster;
  2480. var display, invalidated, i;
  2481. // Need to take account of custom filtering functions - always filter
  2482. if ( DataTable.ext.search.length !== 0 ) {
  2483. force = true;
  2484. }
  2485. // Check if any of the rows were invalidated
  2486. invalidated = _fnFilterData( settings );
  2487. // If the input is blank - we just want the full data set
  2488. if ( input.length <= 0 ) {
  2489. settings.aiDisplay = displayMaster.slice();
  2490. }
  2491. else {
  2492. // New search - start from the master array
  2493. if ( invalidated ||
  2494. force ||
  2495. prevSearch.length > input.length ||
  2496. input.indexOf(prevSearch) !== 0 ||
  2497. settings.bSorted // On resort, the display master needs to be
  2498. // re-filtered since indexes will have changed
  2499. ) {
  2500. settings.aiDisplay = displayMaster.slice();
  2501. }
  2502. // Search the display array
  2503. display = settings.aiDisplay;
  2504. for ( i=display.length-1 ; i>=0 ; i-- ) {
  2505. if ( ! rpSearch.test( settings.aoData[ display[i] ]._sFilterRow ) ) {
  2506. display.splice( i, 1 );
  2507. }
  2508. }
  2509. }
  2510. }
  2511. /**
  2512. * Build a regular expression object suitable for searching a table
  2513. * @param {string} sSearch string to search for
  2514. * @param {bool} bRegex treat as a regular expression or not
  2515. * @param {bool} bSmart perform smart filtering or not
  2516. * @param {bool} bCaseInsensitive Do case insensitive matching or not
  2517. * @returns {RegExp} constructed object
  2518. * @memberof DataTable#oApi
  2519. */
  2520. function _fnFilterCreateSearch( search, regex, smart, caseInsensitive )
  2521. {
  2522. search = regex ?
  2523. search :
  2524. _fnEscapeRegex( search );
  2525. if ( smart ) {
  2526. /* For smart filtering we want to allow the search to work regardless of
  2527. * word order. We also want double quoted text to be preserved, so word
  2528. * order is important - a la google. So this is what we want to
  2529. * generate:
  2530. *
  2531. * ^(?=.*?\bone\b)(?=.*?\btwo three\b)(?=.*?\bfour\b).*$
  2532. */
  2533. var a = $.map( search.match( /"[^"]+"|[^ ]+/g ) || '', function ( word ) {
  2534. if ( word.charAt(0) === '"' ) {
  2535. var m = word.match( /^"(.*)"$/ );
  2536. word = m ? m[1] : word;
  2537. }
  2538. return word.replace('"', '');
  2539. } );
  2540. search = '^(?=.*?'+a.join( ')(?=.*?' )+').*$';
  2541. }
  2542. return new RegExp( search, caseInsensitive ? 'i' : '' );
  2543. }
  2544. /**
  2545. * scape a string such that it can be used in a regular expression
  2546. * @param {string} sVal string to escape
  2547. * @returns {string} escaped string
  2548. * @memberof DataTable#oApi
  2549. */
  2550. function _fnEscapeRegex ( sVal )
  2551. {
  2552. return sVal.replace( _re_escape_regex, '\\$1' );
  2553. }
  2554. var __filter_div = $('<div>')[0];
  2555. var __filter_div_textContent = __filter_div.textContent !== undefined;
  2556. // Update the filtering data for each row if needed (by invalidation or first run)
  2557. function _fnFilterData ( settings )
  2558. {
  2559. var columns = settings.aoColumns;
  2560. var column;
  2561. var i, j, ien, jen, filterData, cellData, row;
  2562. var fomatters = DataTable.ext.type.search;
  2563. var wasInvalidated = false;
  2564. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  2565. row = settings.aoData[i];
  2566. if ( ! row._aFilterData ) {
  2567. filterData = [];
  2568. for ( j=0, jen=columns.length ; j<jen ; j++ ) {
  2569. column = columns[j];
  2570. if ( column.bSearchable ) {
  2571. cellData = _fnGetCellData( settings, i, j, 'filter' );
  2572. if ( fomatters[ column.sType ] ) {
  2573. cellData = fomatters[ column.sType ]( cellData );
  2574. }
  2575. // Search in DataTables 1.10 is string based. In 1.11 this
  2576. // should be altered to also allow strict type checking.
  2577. if ( cellData === null ) {
  2578. cellData = '';
  2579. }
  2580. if ( typeof cellData !== 'string' && cellData.toString ) {
  2581. cellData = cellData.toString();
  2582. }
  2583. }
  2584. else {
  2585. cellData = '';
  2586. }
  2587. // If it looks like there is an HTML entity in the string,
  2588. // attempt to decode it so sorting works as expected. Note that
  2589. // we could use a single line of jQuery to do this, but the DOM
  2590. // method used here is much faster http://jsperf.com/html-decode
  2591. if ( cellData.indexOf && cellData.indexOf('&') !== -1 ) {
  2592. __filter_div.innerHTML = cellData;
  2593. cellData = __filter_div_textContent ?
  2594. __filter_div.textContent :
  2595. __filter_div.innerText;
  2596. }
  2597. if ( cellData.replace ) {
  2598. cellData = cellData.replace(/[\r\n]/g, '');
  2599. }
  2600. filterData.push( cellData );
  2601. }
  2602. row._aFilterData = filterData;
  2603. row._sFilterRow = filterData.join(' ');
  2604. wasInvalidated = true;
  2605. }
  2606. }
  2607. return wasInvalidated;
  2608. }
  2609. /**
  2610. * Convert from the internal Hungarian notation to camelCase for external
  2611. * interaction
  2612. * @param {object} obj Object to convert
  2613. * @returns {object} Inverted object
  2614. * @memberof DataTable#oApi
  2615. */
  2616. function _fnSearchToCamel ( obj )
  2617. {
  2618. return {
  2619. search: obj.sSearch,
  2620. smart: obj.bSmart,
  2621. regex: obj.bRegex,
  2622. caseInsensitive: obj.bCaseInsensitive
  2623. };
  2624. }
  2625. /**
  2626. * Convert from camelCase notation to the internal Hungarian. We could use the
  2627. * Hungarian convert function here, but this is cleaner
  2628. * @param {object} obj Object to convert
  2629. * @returns {object} Inverted object
  2630. * @memberof DataTable#oApi
  2631. */
  2632. function _fnSearchToHung ( obj )
  2633. {
  2634. return {
  2635. sSearch: obj.search,
  2636. bSmart: obj.smart,
  2637. bRegex: obj.regex,
  2638. bCaseInsensitive: obj.caseInsensitive
  2639. };
  2640. }
  2641. /**
  2642. * Generate the node required for the info display
  2643. * @param {object} oSettings dataTables settings object
  2644. * @returns {node} Information element
  2645. * @memberof DataTable#oApi
  2646. */
  2647. function _fnFeatureHtmlInfo ( settings )
  2648. {
  2649. var
  2650. tid = settings.sTableId,
  2651. nodes = settings.aanFeatures.i,
  2652. n = $('<div/>', {
  2653. 'class': settings.oClasses.sInfo,
  2654. 'id': ! nodes ? tid+'_info' : null
  2655. } );
  2656. if ( ! nodes ) {
  2657. // Update display on each draw
  2658. settings.aoDrawCallback.push( {
  2659. "fn": _fnUpdateInfo,
  2660. "sName": "information"
  2661. } );
  2662. n
  2663. .attr( 'role', 'status' )
  2664. .attr( 'aria-live', 'polite' );
  2665. // Table is described by our info div
  2666. $(settings.nTable).attr( 'aria-describedby', tid+'_info' );
  2667. }
  2668. return n[0];
  2669. }
  2670. /**
  2671. * Update the information elements in the display
  2672. * @param {object} settings dataTables settings object
  2673. * @memberof DataTable#oApi
  2674. */
  2675. function _fnUpdateInfo ( settings )
  2676. {
  2677. /* Show information about the table */
  2678. var nodes = settings.aanFeatures.i;
  2679. if ( nodes.length === 0 ) {
  2680. return;
  2681. }
  2682. var
  2683. lang = settings.oLanguage,
  2684. start = settings._iDisplayStart+1,
  2685. end = settings.fnDisplayEnd(),
  2686. max = settings.fnRecordsTotal(),
  2687. total = settings.fnRecordsDisplay(),
  2688. out = total ?
  2689. lang.sInfo :
  2690. lang.sInfoEmpty;
  2691. if ( total !== max ) {
  2692. /* Record set after filtering */
  2693. out += ' ' + lang.sInfoFiltered;
  2694. }
  2695. // Convert the macros
  2696. out += lang.sInfoPostFix;
  2697. out = _fnInfoMacros( settings, out );
  2698. var callback = lang.fnInfoCallback;
  2699. if ( callback !== null ) {
  2700. out = callback.call( settings.oInstance,
  2701. settings, start, end, max, total, out
  2702. );
  2703. }
  2704. $(nodes).html( out );
  2705. }
  2706. function _fnInfoMacros ( settings, str )
  2707. {
  2708. // When infinite scrolling, we are always starting at 1. _iDisplayStart is used only
  2709. // internally
  2710. var
  2711. formatter = settings.fnFormatNumber,
  2712. start = settings._iDisplayStart+1,
  2713. len = settings._iDisplayLength,
  2714. vis = settings.fnRecordsDisplay(),
  2715. all = len === -1;
  2716. return str.
  2717. replace(/_START_/g, formatter.call( settings, start ) ).
  2718. replace(/_END_/g, formatter.call( settings, settings.fnDisplayEnd() ) ).
  2719. replace(/_MAX_/g, formatter.call( settings, settings.fnRecordsTotal() ) ).
  2720. replace(/_TOTAL_/g, formatter.call( settings, vis ) ).
  2721. replace(/_PAGE_/g, formatter.call( settings, all ? 1 : Math.ceil( start / len ) ) ).
  2722. replace(/_PAGES_/g, formatter.call( settings, all ? 1 : Math.ceil( vis / len ) ) );
  2723. }
  2724. /**
  2725. * Draw the table for the first time, adding all required features
  2726. * @param {object} settings dataTables settings object
  2727. * @memberof DataTable#oApi
  2728. */
  2729. function _fnInitialise ( settings )
  2730. {
  2731. var i, iLen, iAjaxStart=settings.iInitDisplayStart;
  2732. var columns = settings.aoColumns, column;
  2733. var features = settings.oFeatures;
  2734. /* Ensure that the table data is fully initialised */
  2735. if ( ! settings.bInitialised ) {
  2736. setTimeout( function(){ _fnInitialise( settings ); }, 200 );
  2737. return;
  2738. }
  2739. /* Show the display HTML options */
  2740. _fnAddOptionsHtml( settings );
  2741. /* Build and draw the header / footer for the table */
  2742. _fnBuildHead( settings );
  2743. _fnDrawHead( settings, settings.aoHeader );
  2744. _fnDrawHead( settings, settings.aoFooter );
  2745. /* Okay to show that something is going on now */
  2746. _fnProcessingDisplay( settings, true );
  2747. /* Calculate sizes for columns */
  2748. if ( features.bAutoWidth ) {
  2749. _fnCalculateColumnWidths( settings );
  2750. }
  2751. for ( i=0, iLen=columns.length ; i<iLen ; i++ ) {
  2752. column = columns[i];
  2753. if ( column.sWidth ) {
  2754. column.nTh.style.width = _fnStringToCss( column.sWidth );
  2755. }
  2756. }
  2757. // If there is default sorting required - let's do it. The sort function
  2758. // will do the drawing for us. Otherwise we draw the table regardless of the
  2759. // Ajax source - this allows the table to look initialised for Ajax sourcing
  2760. // data (show 'loading' message possibly)
  2761. _fnReDraw( settings );
  2762. // Server-side processing init complete is done by _fnAjaxUpdateDraw
  2763. var dataSrc = _fnDataSource( settings );
  2764. if ( dataSrc != 'ssp' ) {
  2765. // if there is an ajax source load the data
  2766. if ( dataSrc == 'ajax' ) {
  2767. _fnBuildAjax( settings, [], function(json) {
  2768. var aData = _fnAjaxDataSrc( settings, json );
  2769. // Got the data - add it to the table
  2770. for ( i=0 ; i<aData.length ; i++ ) {
  2771. _fnAddData( settings, aData[i] );
  2772. }
  2773. // Reset the init display for cookie saving. We've already done
  2774. // a filter, and therefore cleared it before. So we need to make
  2775. // it appear 'fresh'
  2776. settings.iInitDisplayStart = iAjaxStart;
  2777. _fnReDraw( settings );
  2778. _fnProcessingDisplay( settings, false );
  2779. _fnInitComplete( settings, json );
  2780. }, settings );
  2781. }
  2782. else {
  2783. _fnProcessingDisplay( settings, false );
  2784. _fnInitComplete( settings );
  2785. }
  2786. }
  2787. }
  2788. /**
  2789. * Draw the table for the first time, adding all required features
  2790. * @param {object} oSettings dataTables settings object
  2791. * @param {object} [json] JSON from the server that completed the table, if using Ajax source
  2792. * with client-side processing (optional)
  2793. * @memberof DataTable#oApi
  2794. */
  2795. function _fnInitComplete ( settings, json )
  2796. {
  2797. settings._bInitComplete = true;
  2798. // On an Ajax load we now have data and therefore want to apply the column
  2799. // sizing
  2800. if ( json ) {
  2801. _fnAdjustColumnSizing( settings );
  2802. }
  2803. _fnCallbackFire( settings, 'aoInitComplete', 'init', [settings, json] );
  2804. }
  2805. function _fnLengthChange ( settings, val )
  2806. {
  2807. var len = parseInt( val, 10 );
  2808. settings._iDisplayLength = len;
  2809. _fnLengthOverflow( settings );
  2810. // Fire length change event
  2811. _fnCallbackFire( settings, null, 'length', [settings, len] );
  2812. }
  2813. /**
  2814. * Generate the node required for user display length changing
  2815. * @param {object} settings dataTables settings object
  2816. * @returns {node} Display length feature node
  2817. * @memberof DataTable#oApi
  2818. */
  2819. function _fnFeatureHtmlLength ( settings )
  2820. {
  2821. var
  2822. classes = settings.oClasses,
  2823. tableId = settings.sTableId,
  2824. menu = settings.aLengthMenu,
  2825. d2 = $.isArray( menu[0] ),
  2826. lengths = d2 ? menu[0] : menu,
  2827. language = d2 ? menu[1] : menu;
  2828. var select = $('<select/>', {
  2829. 'name': tableId+'_length',
  2830. 'aria-controls': tableId,
  2831. 'class': classes.sLengthSelect
  2832. } );
  2833. for ( var i=0, ien=lengths.length ; i<ien ; i++ ) {
  2834. select[0][ i ] = new Option( language[i], lengths[i] );
  2835. }
  2836. var div = $('<div><label/></div>').addClass( classes.sLength );
  2837. if ( ! settings.aanFeatures.l ) {
  2838. div[0].id = tableId+'_length';
  2839. }
  2840. div.children().append(
  2841. settings.oLanguage.sLengthMenu.replace( '_MENU_', select[0].outerHTML )
  2842. );
  2843. // Can't use `select` variable as user might provide their own and the
  2844. // reference is broken by the use of outerHTML
  2845. $('select', div)
  2846. .val( settings._iDisplayLength )
  2847. .bind( 'change.DT', function(e) {
  2848. _fnLengthChange( settings, $(this).val() );
  2849. _fnDraw( settings );
  2850. } );
  2851. // Update node value whenever anything changes the table's length
  2852. $(settings.nTable).bind( 'length.dt.DT', function (e, s, len) {
  2853. if ( settings === s ) {
  2854. $('select', div).val( len );
  2855. }
  2856. } );
  2857. return div[0];
  2858. }
  2859. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  2860. * Note that most of the paging logic is done in
  2861. * DataTable.ext.pager
  2862. */
  2863. /**
  2864. * Generate the node required for default pagination
  2865. * @param {object} oSettings dataTables settings object
  2866. * @returns {node} Pagination feature node
  2867. * @memberof DataTable#oApi
  2868. */
  2869. function _fnFeatureHtmlPaginate ( settings )
  2870. {
  2871. var
  2872. type = settings.sPaginationType,
  2873. plugin = DataTable.ext.pager[ type ],
  2874. modern = typeof plugin === 'function',
  2875. redraw = function( settings ) {
  2876. _fnDraw( settings );
  2877. },
  2878. node = $('<div/>').addClass( settings.oClasses.sPaging + type )[0],
  2879. features = settings.aanFeatures;
  2880. if ( ! modern ) {
  2881. plugin.fnInit( settings, node, redraw );
  2882. }
  2883. /* Add a draw callback for the pagination on first instance, to update the paging display */
  2884. if ( ! features.p )
  2885. {
  2886. node.id = settings.sTableId+'_paginate';
  2887. settings.aoDrawCallback.push( {
  2888. "fn": function( settings ) {
  2889. if ( modern ) {
  2890. var
  2891. start = settings._iDisplayStart,
  2892. len = settings._iDisplayLength,
  2893. visRecords = settings.fnRecordsDisplay(),
  2894. all = len === -1,
  2895. page = all ? 0 : Math.ceil( start / len ),
  2896. pages = all ? 1 : Math.ceil( visRecords / len ),
  2897. buttons = plugin(page, pages),
  2898. i, ien;
  2899. for ( i=0, ien=features.p.length ; i<ien ; i++ ) {
  2900. _fnRenderer( settings, 'pageButton' )(
  2901. settings, features.p[i], i, buttons, page, pages
  2902. );
  2903. }
  2904. }
  2905. else {
  2906. plugin.fnUpdate( settings, redraw );
  2907. }
  2908. },
  2909. "sName": "pagination"
  2910. } );
  2911. }
  2912. return node;
  2913. }
  2914. /**
  2915. * Alter the display settings to change the page
  2916. * @param {object} settings DataTables settings object
  2917. * @param {string|int} action Paging action to take: "first", "previous",
  2918. * "next" or "last" or page number to jump to (integer)
  2919. * @param [bool] redraw Automatically draw the update or not
  2920. * @returns {bool} true page has changed, false - no change
  2921. * @memberof DataTable#oApi
  2922. */
  2923. function _fnPageChange ( settings, action, redraw )
  2924. {
  2925. var
  2926. start = settings._iDisplayStart,
  2927. len = settings._iDisplayLength,
  2928. records = settings.fnRecordsDisplay();
  2929. if ( records === 0 || len === -1 )
  2930. {
  2931. start = 0;
  2932. }
  2933. else if ( typeof action === "number" )
  2934. {
  2935. start = action * len;
  2936. if ( start > records )
  2937. {
  2938. start = 0;
  2939. }
  2940. }
  2941. else if ( action == "first" )
  2942. {
  2943. start = 0;
  2944. }
  2945. else if ( action == "previous" )
  2946. {
  2947. start = len >= 0 ?
  2948. start - len :
  2949. 0;
  2950. if ( start < 0 )
  2951. {
  2952. start = 0;
  2953. }
  2954. }
  2955. else if ( action == "next" )
  2956. {
  2957. if ( start + len < records )
  2958. {
  2959. start += len;
  2960. }
  2961. }
  2962. else if ( action == "last" )
  2963. {
  2964. start = Math.floor( (records-1) / len) * len;
  2965. }
  2966. else
  2967. {
  2968. _fnLog( settings, 0, "Unknown paging action: "+action, 5 );
  2969. }
  2970. var changed = settings._iDisplayStart !== start;
  2971. settings._iDisplayStart = start;
  2972. if ( changed ) {
  2973. _fnCallbackFire( settings, null, 'page', [settings] );
  2974. if ( redraw ) {
  2975. _fnDraw( settings );
  2976. }
  2977. }
  2978. return changed;
  2979. }
  2980. /**
  2981. * Generate the node required for the processing node
  2982. * @param {object} settings dataTables settings object
  2983. * @returns {node} Processing element
  2984. * @memberof DataTable#oApi
  2985. */
  2986. function _fnFeatureHtmlProcessing ( settings )
  2987. {
  2988. return $('<div/>', {
  2989. 'id': ! settings.aanFeatures.r ? settings.sTableId+'_processing' : null,
  2990. 'class': settings.oClasses.sProcessing
  2991. } )
  2992. .html( settings.oLanguage.sProcessing )
  2993. .insertBefore( settings.nTable )[0];
  2994. }
  2995. /**
  2996. * Display or hide the processing indicator
  2997. * @param {object} settings dataTables settings object
  2998. * @param {bool} show Show the processing indicator (true) or not (false)
  2999. * @memberof DataTable#oApi
  3000. */
  3001. function _fnProcessingDisplay ( settings, show )
  3002. {
  3003. if ( settings.oFeatures.bProcessing ) {
  3004. $(settings.aanFeatures.r).css( 'display', show ? 'block' : 'none' );
  3005. }
  3006. _fnCallbackFire( settings, null, 'processing', [settings, show] );
  3007. }
  3008. /**
  3009. * Add any control elements for the table - specifically scrolling
  3010. * @param {object} settings dataTables settings object
  3011. * @returns {node} Node to add to the DOM
  3012. * @memberof DataTable#oApi
  3013. */
  3014. function _fnFeatureHtmlTable ( settings )
  3015. {
  3016. var table = $(settings.nTable);
  3017. // Add the ARIA grid role to the table
  3018. table.attr( 'role', 'grid' );
  3019. // Scrolling from here on in
  3020. var scroll = settings.oScroll;
  3021. if ( scroll.sX === '' && scroll.sY === '' ) {
  3022. return settings.nTable;
  3023. }
  3024. var scrollX = scroll.sX;
  3025. var scrollY = scroll.sY;
  3026. var classes = settings.oClasses;
  3027. var caption = table.children('caption');
  3028. var captionSide = caption.length ? caption[0]._captionSide : null;
  3029. var headerClone = $( table[0].cloneNode(false) );
  3030. var footerClone = $( table[0].cloneNode(false) );
  3031. var footer = table.children('tfoot');
  3032. var _div = '<div/>';
  3033. var size = function ( s ) {
  3034. return !s ? null : _fnStringToCss( s );
  3035. };
  3036. // This is fairly messy, but with x scrolling enabled, if the table has a
  3037. // width attribute, regardless of any width applied using the column width
  3038. // options, the browser will shrink or grow the table as needed to fit into
  3039. // that 100%. That would make the width options useless. So we remove it.
  3040. // This is okay, under the assumption that width:100% is applied to the
  3041. // table in CSS (it is in the default stylesheet) which will set the table
  3042. // width as appropriate (the attribute and css behave differently...)
  3043. if ( scroll.sX && table.attr('width') === '100%' ) {
  3044. table.removeAttr('width');
  3045. }
  3046. if ( ! footer.length ) {
  3047. footer = null;
  3048. }
  3049. /*
  3050. * The HTML structure that we want to generate in this function is:
  3051. * div - scroller
  3052. * div - scroll head
  3053. * div - scroll head inner
  3054. * table - scroll head table
  3055. * thead - thead
  3056. * div - scroll body
  3057. * table - table (master table)
  3058. * thead - thead clone for sizing
  3059. * tbody - tbody
  3060. * div - scroll foot
  3061. * div - scroll foot inner
  3062. * table - scroll foot table
  3063. * tfoot - tfoot
  3064. */
  3065. var scroller = $( _div, { 'class': classes.sScrollWrapper } )
  3066. .append(
  3067. $(_div, { 'class': classes.sScrollHead } )
  3068. .css( {
  3069. overflow: 'hidden',
  3070. position: 'relative',
  3071. border: 0,
  3072. width: scrollX ? size(scrollX) : '100%'
  3073. } )
  3074. .append(
  3075. $(_div, { 'class': classes.sScrollHeadInner } )
  3076. .css( {
  3077. 'box-sizing': 'content-box',
  3078. width: scroll.sXInner || '100%'
  3079. } )
  3080. .append(
  3081. headerClone
  3082. .removeAttr('id')
  3083. .css( 'margin-left', 0 )
  3084. .append(
  3085. table.children('thead')
  3086. )
  3087. )
  3088. )
  3089. .append( captionSide === 'top' ? caption : null )
  3090. )
  3091. .append(
  3092. $(_div, { 'class': classes.sScrollBody } )
  3093. .css( {
  3094. overflow: 'auto',
  3095. height: size( scrollY ),
  3096. width: size( scrollX )
  3097. } )
  3098. .append( table )
  3099. );
  3100. if ( footer ) {
  3101. scroller.append(
  3102. $(_div, { 'class': classes.sScrollFoot } )
  3103. .css( {
  3104. overflow: 'hidden',
  3105. border: 0,
  3106. width: scrollX ? size(scrollX) : '100%'
  3107. } )
  3108. .append(
  3109. $(_div, { 'class': classes.sScrollFootInner } )
  3110. .append(
  3111. footerClone
  3112. .removeAttr('id')
  3113. .css( 'margin-left', 0 )
  3114. .append(
  3115. table.children('tfoot')
  3116. )
  3117. )
  3118. )
  3119. .append( captionSide === 'bottom' ? caption : null )
  3120. );
  3121. }
  3122. var children = scroller.children();
  3123. var scrollHead = children[0];
  3124. var scrollBody = children[1];
  3125. var scrollFoot = footer ? children[2] : null;
  3126. // When the body is scrolled, then we also want to scroll the headers
  3127. if ( scrollX ) {
  3128. $(scrollBody).scroll( function (e) {
  3129. var scrollLeft = this.scrollLeft;
  3130. scrollHead.scrollLeft = scrollLeft;
  3131. if ( footer ) {
  3132. scrollFoot.scrollLeft = scrollLeft;
  3133. }
  3134. } );
  3135. }
  3136. settings.nScrollHead = scrollHead;
  3137. settings.nScrollBody = scrollBody;
  3138. settings.nScrollFoot = scrollFoot;
  3139. // On redraw - align columns
  3140. settings.aoDrawCallback.push( {
  3141. "fn": _fnScrollDraw,
  3142. "sName": "scrolling"
  3143. } );
  3144. return scroller[0];
  3145. }
  3146. /**
  3147. * Update the header, footer and body tables for resizing - i.e. column
  3148. * alignment.
  3149. *
  3150. * Welcome to the most horrible function DataTables. The process that this
  3151. * function follows is basically:
  3152. * 1. Re-create the table inside the scrolling div
  3153. * 2. Take live measurements from the DOM
  3154. * 3. Apply the measurements to align the columns
  3155. * 4. Clean up
  3156. *
  3157. * @param {object} settings dataTables settings object
  3158. * @memberof DataTable#oApi
  3159. */
  3160. function _fnScrollDraw ( settings )
  3161. {
  3162. // Given that this is such a monster function, a lot of variables are use
  3163. // to try and keep the minimised size as small as possible
  3164. var
  3165. scroll = settings.oScroll,
  3166. scrollX = scroll.sX,
  3167. scrollXInner = scroll.sXInner,
  3168. scrollY = scroll.sY,
  3169. barWidth = scroll.iBarWidth,
  3170. divHeader = $(settings.nScrollHead),
  3171. divHeaderStyle = divHeader[0].style,
  3172. divHeaderInner = divHeader.children('div'),
  3173. divHeaderInnerStyle = divHeaderInner[0].style,
  3174. divHeaderTable = divHeaderInner.children('table'),
  3175. divBodyEl = settings.nScrollBody,
  3176. divBody = $(divBodyEl),
  3177. divBodyStyle = divBodyEl.style,
  3178. divFooter = $(settings.nScrollFoot),
  3179. divFooterInner = divFooter.children('div'),
  3180. divFooterTable = divFooterInner.children('table'),
  3181. header = $(settings.nTHead),
  3182. table = $(settings.nTable),
  3183. tableEl = table[0],
  3184. tableStyle = tableEl.style,
  3185. footer = settings.nTFoot ? $(settings.nTFoot) : null,
  3186. browser = settings.oBrowser,
  3187. ie67 = browser.bScrollOversize,
  3188. headerTrgEls, footerTrgEls,
  3189. headerSrcEls, footerSrcEls,
  3190. headerCopy, footerCopy,
  3191. headerWidths=[], footerWidths=[],
  3192. headerContent=[],
  3193. idx, correction, sanityWidth,
  3194. zeroOut = function(nSizer) {
  3195. var style = nSizer.style;
  3196. style.paddingTop = "0";
  3197. style.paddingBottom = "0";
  3198. style.borderTopWidth = "0";
  3199. style.borderBottomWidth = "0";
  3200. style.height = 0;
  3201. };
  3202. /*
  3203. * 1. Re-create the table inside the scrolling div
  3204. */
  3205. // Remove the old minimised thead and tfoot elements in the inner table
  3206. table.children('thead, tfoot').remove();
  3207. // Clone the current header and footer elements and then place it into the inner table
  3208. headerCopy = header.clone().prependTo( table );
  3209. headerTrgEls = header.find('tr'); // original header is in its own table
  3210. headerSrcEls = headerCopy.find('tr');
  3211. headerCopy.find('th, td').removeAttr('tabindex');
  3212. if ( footer ) {
  3213. footerCopy = footer.clone().prependTo( table );
  3214. footerTrgEls = footer.find('tr'); // the original tfoot is in its own table and must be sized
  3215. footerSrcEls = footerCopy.find('tr');
  3216. }
  3217. /*
  3218. * 2. Take live measurements from the DOM - do not alter the DOM itself!
  3219. */
  3220. // Remove old sizing and apply the calculated column widths
  3221. // Get the unique column headers in the newly created (cloned) header. We want to apply the
  3222. // calculated sizes to this header
  3223. if ( ! scrollX )
  3224. {
  3225. divBodyStyle.width = '100%';
  3226. divHeader[0].style.width = '100%';
  3227. }
  3228. $.each( _fnGetUniqueThs( settings, headerCopy ), function ( i, el ) {
  3229. idx = _fnVisibleToColumnIndex( settings, i );
  3230. el.style.width = settings.aoColumns[idx].sWidth;
  3231. } );
  3232. if ( footer ) {
  3233. _fnApplyToChildren( function(n) {
  3234. n.style.width = "";
  3235. }, footerSrcEls );
  3236. }
  3237. // If scroll collapse is enabled, when we put the headers back into the body for sizing, we
  3238. // will end up forcing the scrollbar to appear, making our measurements wrong for when we
  3239. // then hide it (end of this function), so add the header height to the body scroller.
  3240. if ( scroll.bCollapse && scrollY !== "" ) {
  3241. divBodyStyle.height = (divBody[0].offsetHeight + header[0].offsetHeight)+"px";
  3242. }
  3243. // Size the table as a whole
  3244. sanityWidth = table.outerWidth();
  3245. if ( scrollX === "" ) {
  3246. // No x scrolling
  3247. tableStyle.width = "100%";
  3248. // IE7 will make the width of the table when 100% include the scrollbar
  3249. // - which is shouldn't. When there is a scrollbar we need to take this
  3250. // into account.
  3251. if ( ie67 && (table.find('tbody').height() > divBodyEl.offsetHeight ||
  3252. divBody.css('overflow-y') == "scroll")
  3253. ) {
  3254. tableStyle.width = _fnStringToCss( table.outerWidth() - barWidth);
  3255. }
  3256. }
  3257. else
  3258. {
  3259. // x scrolling
  3260. if ( scrollXInner !== "" ) {
  3261. // x scroll inner has been given - use it
  3262. tableStyle.width = _fnStringToCss(scrollXInner);
  3263. }
  3264. else if ( sanityWidth == divBody.width() && divBody.height() < table.height() ) {
  3265. // There is y-scrolling - try to take account of the y scroll bar
  3266. tableStyle.width = _fnStringToCss( sanityWidth-barWidth );
  3267. if ( table.outerWidth() > sanityWidth-barWidth ) {
  3268. // Not possible to take account of it
  3269. tableStyle.width = _fnStringToCss( sanityWidth );
  3270. }
  3271. }
  3272. else {
  3273. // When all else fails
  3274. tableStyle.width = _fnStringToCss( sanityWidth );
  3275. }
  3276. }
  3277. // Recalculate the sanity width - now that we've applied the required width,
  3278. // before it was a temporary variable. This is required because the column
  3279. // width calculation is done before this table DOM is created.
  3280. sanityWidth = table.outerWidth();
  3281. // Hidden header should have zero height, so remove padding and borders. Then
  3282. // set the width based on the real headers
  3283. // Apply all styles in one pass
  3284. _fnApplyToChildren( zeroOut, headerSrcEls );
  3285. // Read all widths in next pass
  3286. _fnApplyToChildren( function(nSizer) {
  3287. headerContent.push( nSizer.innerHTML );
  3288. headerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  3289. }, headerSrcEls );
  3290. // Apply all widths in final pass
  3291. _fnApplyToChildren( function(nToSize, i) {
  3292. nToSize.style.width = headerWidths[i];
  3293. }, headerTrgEls );
  3294. $(headerSrcEls).height(0);
  3295. /* Same again with the footer if we have one */
  3296. if ( footer )
  3297. {
  3298. _fnApplyToChildren( zeroOut, footerSrcEls );
  3299. _fnApplyToChildren( function(nSizer) {
  3300. footerWidths.push( _fnStringToCss( $(nSizer).css('width') ) );
  3301. }, footerSrcEls );
  3302. _fnApplyToChildren( function(nToSize, i) {
  3303. nToSize.style.width = footerWidths[i];
  3304. }, footerTrgEls );
  3305. $(footerSrcEls).height(0);
  3306. }
  3307. /*
  3308. * 3. Apply the measurements
  3309. */
  3310. // "Hide" the header and footer that we used for the sizing. We need to keep
  3311. // the content of the cell so that the width applied to the header and body
  3312. // both match, but we want to hide it completely. We want to also fix their
  3313. // width to what they currently are
  3314. _fnApplyToChildren( function(nSizer, i) {
  3315. nSizer.innerHTML = '<div class="dataTables_sizing" style="height:0;overflow:hidden;">'+headerContent[i]+'</div>';
  3316. nSizer.style.width = headerWidths[i];
  3317. }, headerSrcEls );
  3318. if ( footer )
  3319. {
  3320. _fnApplyToChildren( function(nSizer, i) {
  3321. nSizer.innerHTML = "";
  3322. nSizer.style.width = footerWidths[i];
  3323. }, footerSrcEls );
  3324. }
  3325. // Sanity check that the table is of a sensible width. If not then we are going to get
  3326. // misalignment - try to prevent this by not allowing the table to shrink below its min width
  3327. if ( table.outerWidth() < sanityWidth )
  3328. {
  3329. // The min width depends upon if we have a vertical scrollbar visible or not */
  3330. correction = ((divBodyEl.scrollHeight > divBodyEl.offsetHeight ||
  3331. divBody.css('overflow-y') == "scroll")) ?
  3332. sanityWidth+barWidth :
  3333. sanityWidth;
  3334. // IE6/7 are a law unto themselves...
  3335. if ( ie67 && (divBodyEl.scrollHeight >
  3336. divBodyEl.offsetHeight || divBody.css('overflow-y') == "scroll")
  3337. ) {
  3338. tableStyle.width = _fnStringToCss( correction-barWidth );
  3339. }
  3340. // And give the user a warning that we've stopped the table getting too small
  3341. if ( scrollX === "" || scrollXInner !== "" ) {
  3342. _fnLog( settings, 1, 'Possible column misalignment', 6 );
  3343. }
  3344. }
  3345. else
  3346. {
  3347. correction = '100%';
  3348. }
  3349. // Apply to the container elements
  3350. divBodyStyle.width = _fnStringToCss( correction );
  3351. divHeaderStyle.width = _fnStringToCss( correction );
  3352. if ( footer ) {
  3353. settings.nScrollFoot.style.width = _fnStringToCss( correction );
  3354. }
  3355. /*
  3356. * 4. Clean up
  3357. */
  3358. if ( ! scrollY ) {
  3359. /* IE7< puts a vertical scrollbar in place (when it shouldn't be) due to subtracting
  3360. * the scrollbar height from the visible display, rather than adding it on. We need to
  3361. * set the height in order to sort this. Don't want to do it in any other browsers.
  3362. */
  3363. if ( ie67 ) {
  3364. divBodyStyle.height = _fnStringToCss( tableEl.offsetHeight+barWidth );
  3365. }
  3366. }
  3367. if ( scrollY && scroll.bCollapse ) {
  3368. divBodyStyle.height = _fnStringToCss( scrollY );
  3369. var iExtra = (scrollX && tableEl.offsetWidth > divBodyEl.offsetWidth) ?
  3370. barWidth :
  3371. 0;
  3372. if ( tableEl.offsetHeight < divBodyEl.offsetHeight ) {
  3373. divBodyStyle.height = _fnStringToCss( tableEl.offsetHeight+iExtra );
  3374. }
  3375. }
  3376. /* Finally set the width's of the header and footer tables */
  3377. var iOuterWidth = table.outerWidth();
  3378. divHeaderTable[0].style.width = _fnStringToCss( iOuterWidth );
  3379. divHeaderInnerStyle.width = _fnStringToCss( iOuterWidth );
  3380. // Figure out if there are scrollbar present - if so then we need a the header and footer to
  3381. // provide a bit more space to allow "overflow" scrolling (i.e. past the scrollbar)
  3382. var bScrolling = table.height() > divBodyEl.clientHeight || divBody.css('overflow-y') == "scroll";
  3383. var padding = 'padding' + (browser.bScrollbarLeft ? 'Left' : 'Right' );
  3384. divHeaderInnerStyle[ padding ] = bScrolling ? barWidth+"px" : "0px";
  3385. if ( footer ) {
  3386. divFooterTable[0].style.width = _fnStringToCss( iOuterWidth );
  3387. divFooterInner[0].style.width = _fnStringToCss( iOuterWidth );
  3388. divFooterInner[0].style[padding] = bScrolling ? barWidth+"px" : "0px";
  3389. }
  3390. /* Adjust the position of the header in case we loose the y-scrollbar */
  3391. divBody.scroll();
  3392. // If sorting or filtering has occurred, jump the scrolling back to the top
  3393. // only if we aren't holding the position
  3394. if ( (settings.bSorted || settings.bFiltered) && ! settings._drawHold ) {
  3395. divBodyEl.scrollTop = 0;
  3396. }
  3397. }
  3398. /**
  3399. * Apply a given function to the display child nodes of an element array (typically
  3400. * TD children of TR rows
  3401. * @param {function} fn Method to apply to the objects
  3402. * @param array {nodes} an1 List of elements to look through for display children
  3403. * @param array {nodes} an2 Another list (identical structure to the first) - optional
  3404. * @memberof DataTable#oApi
  3405. */
  3406. function _fnApplyToChildren( fn, an1, an2 )
  3407. {
  3408. var index=0, i=0, iLen=an1.length;
  3409. var nNode1, nNode2;
  3410. while ( i < iLen ) {
  3411. nNode1 = an1[i].firstChild;
  3412. nNode2 = an2 ? an2[i].firstChild : null;
  3413. while ( nNode1 ) {
  3414. if ( nNode1.nodeType === 1 ) {
  3415. if ( an2 ) {
  3416. fn( nNode1, nNode2, index );
  3417. }
  3418. else {
  3419. fn( nNode1, index );
  3420. }
  3421. index++;
  3422. }
  3423. nNode1 = nNode1.nextSibling;
  3424. nNode2 = an2 ? nNode2.nextSibling : null;
  3425. }
  3426. i++;
  3427. }
  3428. }
  3429. var __re_html_remove = /<.*?>/g;
  3430. /**
  3431. * Calculate the width of columns for the table
  3432. * @param {object} oSettings dataTables settings object
  3433. * @memberof DataTable#oApi
  3434. */
  3435. function _fnCalculateColumnWidths ( oSettings )
  3436. {
  3437. var
  3438. table = oSettings.nTable,
  3439. columns = oSettings.aoColumns,
  3440. scroll = oSettings.oScroll,
  3441. scrollY = scroll.sY,
  3442. scrollX = scroll.sX,
  3443. scrollXInner = scroll.sXInner,
  3444. columnCount = columns.length,
  3445. visibleColumns = _fnGetColumns( oSettings, 'bVisible' ),
  3446. headerCells = $('th', oSettings.nTHead),
  3447. tableWidthAttr = table.getAttribute('width'),
  3448. tableContainer = table.parentNode,
  3449. userInputs = false,
  3450. i, column, columnIdx, width, outerWidth;
  3451. /* Convert any user input sizes into pixel sizes */
  3452. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3453. column = columns[ visibleColumns[i] ];
  3454. if ( column.sWidth !== null ) {
  3455. column.sWidth = _fnConvertToWidth( column.sWidthOrig, tableContainer );
  3456. userInputs = true;
  3457. }
  3458. }
  3459. /* If the number of columns in the DOM equals the number that we have to
  3460. * process in DataTables, then we can use the offsets that are created by
  3461. * the web- browser. No custom sizes can be set in order for this to happen,
  3462. * nor scrolling used
  3463. */
  3464. if ( ! userInputs && ! scrollX && ! scrollY &&
  3465. columnCount == _fnVisbleColumns( oSettings ) &&
  3466. columnCount == headerCells.length
  3467. ) {
  3468. for ( i=0 ; i<columnCount ; i++ ) {
  3469. columns[i].sWidth = _fnStringToCss( headerCells.eq(i).width() );
  3470. }
  3471. }
  3472. else
  3473. {
  3474. // Otherwise construct a single row table with the widest node in the
  3475. // data, assign any user defined widths, then insert it into the DOM and
  3476. // allow the browser to do all the hard work of calculating table widths
  3477. var tmpTable = $(table).clone() // don't use cloneNode - IE8 will remove events on the main table
  3478. .empty()
  3479. .css( 'visibility', 'hidden' )
  3480. .removeAttr( 'id' )
  3481. .append( $(oSettings.nTHead).clone( false ) )
  3482. .append( $(oSettings.nTFoot).clone( false ) )
  3483. .append( $('<tbody><tr/></tbody>') );
  3484. // Remove any assigned widths from the footer (from scrolling)
  3485. tmpTable.find('tfoot th, tfoot td').css('width', '');
  3486. var tr = tmpTable.find( 'tbody tr' );
  3487. // Apply custom sizing to the cloned header
  3488. headerCells = _fnGetUniqueThs( oSettings, tmpTable.find('thead')[0] );
  3489. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3490. column = columns[ visibleColumns[i] ];
  3491. headerCells[i].style.width = column.sWidthOrig !== null && column.sWidthOrig !== '' ?
  3492. _fnStringToCss( column.sWidthOrig ) :
  3493. '';
  3494. }
  3495. // Find the widest cell for each column and put it into the table
  3496. if ( oSettings.aoData.length ) {
  3497. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3498. columnIdx = visibleColumns[i];
  3499. column = columns[ columnIdx ];
  3500. $( _fnGetWidestNode( oSettings, columnIdx ) )
  3501. .clone( false )
  3502. .append( column.sContentPadding )
  3503. .appendTo( tr );
  3504. }
  3505. }
  3506. // Table has been built, attach to the document so we can work with it
  3507. tmpTable.appendTo( tableContainer );
  3508. // When scrolling (X or Y) we want to set the width of the table as
  3509. // appropriate. However, when not scrolling leave the table width as it
  3510. // is. This results in slightly different, but I think correct behaviour
  3511. if ( scrollX && scrollXInner ) {
  3512. tmpTable.width( scrollXInner );
  3513. }
  3514. else if ( scrollX ) {
  3515. tmpTable.css( 'width', 'auto' );
  3516. if ( tmpTable.width() < tableContainer.offsetWidth ) {
  3517. tmpTable.width( tableContainer.offsetWidth );
  3518. }
  3519. }
  3520. else if ( scrollY ) {
  3521. tmpTable.width( tableContainer.offsetWidth );
  3522. }
  3523. else if ( tableWidthAttr ) {
  3524. tmpTable.width( tableWidthAttr );
  3525. }
  3526. // Take into account the y scrollbar
  3527. _fnScrollingWidthAdjust( oSettings, tmpTable[0] );
  3528. // Browsers need a bit of a hand when a width is assigned to any columns
  3529. // when x-scrolling as they tend to collapse the table to the min-width,
  3530. // even if we sent the column widths. So we need to keep track of what
  3531. // the table width should be by summing the user given values, and the
  3532. // automatic values
  3533. if ( scrollX )
  3534. {
  3535. var total = 0;
  3536. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3537. column = columns[ visibleColumns[i] ];
  3538. outerWidth = $(headerCells[i]).outerWidth();
  3539. total += column.sWidthOrig === null ?
  3540. outerWidth :
  3541. parseInt( column.sWidth, 10 ) + outerWidth - $(headerCells[i]).width();
  3542. }
  3543. tmpTable.width( _fnStringToCss( total ) );
  3544. table.style.width = _fnStringToCss( total );
  3545. }
  3546. // Get the width of each column in the constructed table
  3547. for ( i=0 ; i<visibleColumns.length ; i++ ) {
  3548. column = columns[ visibleColumns[i] ];
  3549. width = $(headerCells[i]).width();
  3550. if ( width ) {
  3551. column.sWidth = _fnStringToCss( width );
  3552. }
  3553. }
  3554. table.style.width = _fnStringToCss( tmpTable.css('width') );
  3555. // Finished with the table - ditch it
  3556. tmpTable.remove();
  3557. }
  3558. // If there is a width attr, we want to attach an event listener which
  3559. // allows the table sizing to automatically adjust when the window is
  3560. // resized. Use the width attr rather than CSS, since we can't know if the
  3561. // CSS is a relative value or absolute - DOM read is always px.
  3562. if ( tableWidthAttr ) {
  3563. table.style.width = _fnStringToCss( tableWidthAttr );
  3564. }
  3565. if ( (tableWidthAttr || scrollX) && ! oSettings._reszEvt ) {
  3566. $(window).bind('resize.DT-'+oSettings.sInstance, _fnThrottle( function () {
  3567. _fnAdjustColumnSizing( oSettings );
  3568. } ) );
  3569. oSettings._reszEvt = true;
  3570. }
  3571. }
  3572. /**
  3573. * Throttle the calls to a function. Arguments and context are maintained for
  3574. * the throttled function
  3575. * @param {function} fn Function to be called
  3576. * @param {int} [freq=200] call frequency in mS
  3577. * @returns {function} wrapped function
  3578. * @memberof DataTable#oApi
  3579. */
  3580. function _fnThrottle( fn, freq ) {
  3581. var
  3582. frequency = freq !== undefined ? freq : 200,
  3583. last,
  3584. timer;
  3585. return function () {
  3586. var
  3587. that = this,
  3588. now = +new Date(),
  3589. args = arguments;
  3590. if ( last && now < last + frequency ) {
  3591. clearTimeout( timer );
  3592. timer = setTimeout( function () {
  3593. last = undefined;
  3594. fn.apply( that, args );
  3595. }, frequency );
  3596. }
  3597. else if ( last ) {
  3598. last = now;
  3599. fn.apply( that, args );
  3600. }
  3601. else {
  3602. last = now;
  3603. }
  3604. };
  3605. }
  3606. /**
  3607. * Convert a CSS unit width to pixels (e.g. 2em)
  3608. * @param {string} width width to be converted
  3609. * @param {node} parent parent to get the with for (required for relative widths) - optional
  3610. * @returns {int} width in pixels
  3611. * @memberof DataTable#oApi
  3612. */
  3613. function _fnConvertToWidth ( width, parent )
  3614. {
  3615. if ( ! width ) {
  3616. return 0;
  3617. }
  3618. var n = $('<div/>')
  3619. .css( 'width', _fnStringToCss( width ) )
  3620. .appendTo( parent || document.body );
  3621. var val = n[0].offsetWidth;
  3622. n.remove();
  3623. return val;
  3624. }
  3625. /**
  3626. * Adjust a table's width to take account of vertical scroll bar
  3627. * @param {object} oSettings dataTables settings object
  3628. * @param {node} n table node
  3629. * @memberof DataTable#oApi
  3630. */
  3631. function _fnScrollingWidthAdjust ( settings, n )
  3632. {
  3633. var scroll = settings.oScroll;
  3634. if ( scroll.sX || scroll.sY ) {
  3635. // When y-scrolling only, we want to remove the width of the scroll bar
  3636. // so the table + scroll bar will fit into the area available, otherwise
  3637. // we fix the table at its current size with no adjustment
  3638. var correction = ! scroll.sX ? scroll.iBarWidth : 0;
  3639. n.style.width = _fnStringToCss( $(n).outerWidth() - correction );
  3640. }
  3641. }
  3642. /**
  3643. * Get the widest node
  3644. * @param {object} settings dataTables settings object
  3645. * @param {int} colIdx column of interest
  3646. * @returns {node} widest table node
  3647. * @memberof DataTable#oApi
  3648. */
  3649. function _fnGetWidestNode( settings, colIdx )
  3650. {
  3651. var idx = _fnGetMaxLenString( settings, colIdx );
  3652. if ( idx < 0 ) {
  3653. return null;
  3654. }
  3655. var data = settings.aoData[ idx ];
  3656. return ! data.nTr ? // Might not have been created when deferred rendering
  3657. $('<td/>').html( _fnGetCellData( settings, idx, colIdx, 'display' ) )[0] :
  3658. data.anCells[ colIdx ];
  3659. }
  3660. /**
  3661. * Get the maximum strlen for each data column
  3662. * @param {object} settings dataTables settings object
  3663. * @param {int} colIdx column of interest
  3664. * @returns {string} max string length for each column
  3665. * @memberof DataTable#oApi
  3666. */
  3667. function _fnGetMaxLenString( settings, colIdx )
  3668. {
  3669. var s, max=-1, maxIdx = -1;
  3670. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  3671. s = _fnGetCellData( settings, i, colIdx, 'display' )+'';
  3672. s = s.replace( __re_html_remove, '' );
  3673. if ( s.length > max ) {
  3674. max = s.length;
  3675. maxIdx = i;
  3676. }
  3677. }
  3678. return maxIdx;
  3679. }
  3680. /**
  3681. * Append a CSS unit (only if required) to a string
  3682. * @param {string} value to css-ify
  3683. * @returns {string} value with css unit
  3684. * @memberof DataTable#oApi
  3685. */
  3686. function _fnStringToCss( s )
  3687. {
  3688. if ( s === null ) {
  3689. return '0px';
  3690. }
  3691. if ( typeof s == 'number' ) {
  3692. return s < 0 ?
  3693. '0px' :
  3694. s+'px';
  3695. }
  3696. // Check it has a unit character already
  3697. return s.match(/\d$/) ?
  3698. s+'px' :
  3699. s;
  3700. }
  3701. /**
  3702. * Get the width of a scroll bar in this browser being used
  3703. * @returns {int} width in pixels
  3704. * @memberof DataTable#oApi
  3705. */
  3706. function _fnScrollBarWidth ()
  3707. {
  3708. // On first run a static variable is set, since this is only needed once.
  3709. // Subsequent runs will just use the previously calculated value
  3710. if ( ! DataTable.__scrollbarWidth ) {
  3711. var inner = $('<p/>').css( {
  3712. width: '100%',
  3713. height: 200,
  3714. padding: 0
  3715. } )[0];
  3716. var outer = $('<div/>')
  3717. .css( {
  3718. position: 'absolute',
  3719. top: 0,
  3720. left: 0,
  3721. width: 200,
  3722. height: 150,
  3723. padding: 0,
  3724. overflow: 'hidden',
  3725. visibility: 'hidden'
  3726. } )
  3727. .append( inner )
  3728. .appendTo( 'body' );
  3729. var w1 = inner.offsetWidth;
  3730. outer.css( 'overflow', 'scroll' );
  3731. var w2 = inner.offsetWidth;
  3732. if ( w1 === w2 ) {
  3733. w2 = outer[0].clientWidth;
  3734. }
  3735. outer.remove();
  3736. DataTable.__scrollbarWidth = w1 - w2;
  3737. }
  3738. return DataTable.__scrollbarWidth;
  3739. }
  3740. function _fnSortFlatten ( settings )
  3741. {
  3742. var
  3743. i, iLen, k, kLen,
  3744. aSort = [],
  3745. aiOrig = [],
  3746. aoColumns = settings.aoColumns,
  3747. aDataSort, iCol, sType, srcCol,
  3748. fixed = settings.aaSortingFixed,
  3749. fixedObj = $.isPlainObject( fixed ),
  3750. nestedSort = [],
  3751. add = function ( a ) {
  3752. if ( a.length && ! $.isArray( a[0] ) ) {
  3753. // 1D array
  3754. nestedSort.push( a );
  3755. }
  3756. else {
  3757. // 2D array
  3758. nestedSort.push.apply( nestedSort, a );
  3759. }
  3760. };
  3761. // Build the sort array, with pre-fix and post-fix options if they have been
  3762. // specified
  3763. if ( $.isArray( fixed ) ) {
  3764. add( fixed );
  3765. }
  3766. if ( fixedObj && fixed.pre ) {
  3767. add( fixed.pre );
  3768. }
  3769. add( settings.aaSorting );
  3770. if (fixedObj && fixed.post ) {
  3771. add( fixed.post );
  3772. }
  3773. for ( i=0 ; i<nestedSort.length ; i++ )
  3774. {
  3775. srcCol = nestedSort[i][0];
  3776. aDataSort = aoColumns[ srcCol ].aDataSort;
  3777. for ( k=0, kLen=aDataSort.length ; k<kLen ; k++ )
  3778. {
  3779. iCol = aDataSort[k];
  3780. sType = aoColumns[ iCol ].sType || 'string';
  3781. if ( nestedSort[i]._idx === undefined ) {
  3782. nestedSort[i]._idx = $.inArray( nestedSort[i][1], aoColumns[iCol].asSorting );
  3783. }
  3784. aSort.push( {
  3785. src: srcCol,
  3786. col: iCol,
  3787. dir: nestedSort[i][1],
  3788. index: nestedSort[i]._idx,
  3789. type: sType,
  3790. formatter: DataTable.ext.type.order[ sType+"-pre" ]
  3791. } );
  3792. }
  3793. }
  3794. return aSort;
  3795. }
  3796. /**
  3797. * Change the order of the table
  3798. * @param {object} oSettings dataTables settings object
  3799. * @memberof DataTable#oApi
  3800. * @yodo This really needs split up!
  3801. */
  3802. function _fnSort ( oSettings )
  3803. {
  3804. var
  3805. i, ien, iLen, j, jLen, k, kLen,
  3806. sDataType, nTh,
  3807. aiOrig = [],
  3808. oExtSort = DataTable.ext.type.order,
  3809. aoData = oSettings.aoData,
  3810. aoColumns = oSettings.aoColumns,
  3811. aDataSort, data, iCol, sType, oSort,
  3812. formatters = 0,
  3813. sortCol,
  3814. displayMaster = oSettings.aiDisplayMaster,
  3815. aSort;
  3816. // Resolve any column types that are unknown due to addition or invalidation
  3817. // @yodo Can this be moved into a 'data-ready' handler which is called when
  3818. // data is going to be used in the table?
  3819. _fnColumnTypes( oSettings );
  3820. aSort = _fnSortFlatten( oSettings );
  3821. for ( i=0, ien=aSort.length ; i<ien ; i++ ) {
  3822. sortCol = aSort[i];
  3823. // Track if we can use the fast sort algorithm
  3824. if ( sortCol.formatter ) {
  3825. formatters++;
  3826. }
  3827. // Load the data needed for the sort, for each cell
  3828. _fnSortData( oSettings, sortCol.col );
  3829. }
  3830. /* No sorting required if server-side or no sorting array */
  3831. if ( _fnDataSource( oSettings ) != 'ssp' && aSort.length !== 0 )
  3832. {
  3833. // Create a value - key array of the current row positions such that we can use their
  3834. // current position during the sort, if values match, in order to perform stable sorting
  3835. for ( i=0, iLen=displayMaster.length ; i<iLen ; i++ ) {
  3836. aiOrig[ displayMaster[i] ] = i;
  3837. }
  3838. /* Do the sort - here we want multi-column sorting based on a given data source (column)
  3839. * and sorting function (from oSort) in a certain direction. It's reasonably complex to
  3840. * follow on it's own, but this is what we want (example two column sorting):
  3841. * fnLocalSorting = function(a,b){
  3842. * var iTest;
  3843. * iTest = oSort['string-asc']('data11', 'data12');
  3844. * if (iTest !== 0)
  3845. * return iTest;
  3846. * iTest = oSort['numeric-desc']('data21', 'data22');
  3847. * if (iTest !== 0)
  3848. * return iTest;
  3849. * return oSort['numeric-asc']( aiOrig[a], aiOrig[b] );
  3850. * }
  3851. * Basically we have a test for each sorting column, if the data in that column is equal,
  3852. * test the next column. If all columns match, then we use a numeric sort on the row
  3853. * positions in the original data array to provide a stable sort.
  3854. *
  3855. * Note - I know it seems excessive to have two sorting methods, but the first is around
  3856. * 15% faster, so the second is only maintained for backwards compatibility with sorting
  3857. * methods which do not have a pre-sort formatting function.
  3858. */
  3859. if ( formatters === aSort.length ) {
  3860. // All sort types have formatting functions
  3861. displayMaster.sort( function ( a, b ) {
  3862. var
  3863. x, y, k, test, sort,
  3864. len=aSort.length,
  3865. dataA = aoData[a]._aSortData,
  3866. dataB = aoData[b]._aSortData;
  3867. for ( k=0 ; k<len ; k++ ) {
  3868. sort = aSort[k];
  3869. x = dataA[ sort.col ];
  3870. y = dataB[ sort.col ];
  3871. test = x<y ? -1 : x>y ? 1 : 0;
  3872. if ( test !== 0 ) {
  3873. return sort.dir === 'asc' ? test : -test;
  3874. }
  3875. }
  3876. x = aiOrig[a];
  3877. y = aiOrig[b];
  3878. return x<y ? -1 : x>y ? 1 : 0;
  3879. } );
  3880. }
  3881. else {
  3882. // Depreciated - remove in 1.11 (providing a plug-in option)
  3883. // Not all sort types have formatting methods, so we have to call their sorting
  3884. // methods.
  3885. displayMaster.sort( function ( a, b ) {
  3886. var
  3887. x, y, k, l, test, sort, fn,
  3888. len=aSort.length,
  3889. dataA = aoData[a]._aSortData,
  3890. dataB = aoData[b]._aSortData;
  3891. for ( k=0 ; k<len ; k++ ) {
  3892. sort = aSort[k];
  3893. x = dataA[ sort.col ];
  3894. y = dataB[ sort.col ];
  3895. fn = oExtSort[ sort.type+"-"+sort.dir ] || oExtSort[ "string-"+sort.dir ];
  3896. test = fn( x, y );
  3897. if ( test !== 0 ) {
  3898. return test;
  3899. }
  3900. }
  3901. x = aiOrig[a];
  3902. y = aiOrig[b];
  3903. return x<y ? -1 : x>y ? 1 : 0;
  3904. } );
  3905. }
  3906. }
  3907. /* Tell the draw function that we have sorted the data */
  3908. oSettings.bSorted = true;
  3909. }
  3910. function _fnSortAria ( settings )
  3911. {
  3912. var label;
  3913. var nextSort;
  3914. var columns = settings.aoColumns;
  3915. var aSort = _fnSortFlatten( settings );
  3916. var oAria = settings.oLanguage.oAria;
  3917. // ARIA attributes - need to loop all columns, to update all (removing old
  3918. // attributes as needed)
  3919. for ( var i=0, iLen=columns.length ; i<iLen ; i++ )
  3920. {
  3921. var col = columns[i];
  3922. var asSorting = col.asSorting;
  3923. var sTitle = col.sTitle.replace( /<.*?>/g, "" );
  3924. var th = col.nTh;
  3925. // IE7 is throwing an error when setting these properties with jQuery's
  3926. // attr() and removeAttr() methods...
  3927. th.removeAttribute('aria-sort');
  3928. /* In ARIA only the first sorting column can be marked as sorting - no multi-sort option */
  3929. if ( col.bSortable ) {
  3930. if ( aSort.length > 0 && aSort[0].col == i ) {
  3931. th.setAttribute('aria-sort', aSort[0].dir=="asc" ? "ascending" : "descending" );
  3932. nextSort = asSorting[ aSort[0].index+1 ] || asSorting[0];
  3933. }
  3934. else {
  3935. nextSort = asSorting[0];
  3936. }
  3937. label = sTitle + ( nextSort === "asc" ?
  3938. oAria.sSortAscending :
  3939. oAria.sSortDescending
  3940. );
  3941. }
  3942. else {
  3943. label = sTitle;
  3944. }
  3945. th.setAttribute('aria-label', label);
  3946. }
  3947. }
  3948. /**
  3949. * Function to run on user sort request
  3950. * @param {object} settings dataTables settings object
  3951. * @param {node} attachTo node to attach the handler to
  3952. * @param {int} colIdx column sorting index
  3953. * @param {boolean} [append=false] Append the requested sort to the existing
  3954. * sort if true (i.e. multi-column sort)
  3955. * @param {function} [callback] callback function
  3956. * @memberof DataTable#oApi
  3957. */
  3958. function _fnSortListener ( settings, colIdx, append, callback )
  3959. {
  3960. var col = settings.aoColumns[ colIdx ];
  3961. var sorting = settings.aaSorting;
  3962. var asSorting = col.asSorting;
  3963. var nextSortIdx;
  3964. var next = function ( a, overflow ) {
  3965. var idx = a._idx;
  3966. if ( idx === undefined ) {
  3967. idx = $.inArray( a[1], asSorting );
  3968. }
  3969. return idx+1 < asSorting.length ?
  3970. idx+1 :
  3971. overflow ?
  3972. null :
  3973. 0;
  3974. };
  3975. // Convert to 2D array if needed
  3976. if ( typeof sorting[0] === 'number' ) {
  3977. sorting = settings.aaSorting = [ sorting ];
  3978. }
  3979. // If appending the sort then we are multi-column sorting
  3980. if ( append && settings.oFeatures.bSortMulti ) {
  3981. // Are we already doing some kind of sort on this column?
  3982. var sortIdx = $.inArray( colIdx, _pluck(sorting, '0') );
  3983. if ( sortIdx !== -1 ) {
  3984. // Yes, modify the sort
  3985. nextSortIdx = next( sorting[sortIdx], true );
  3986. if ( nextSortIdx === null ) {
  3987. sorting.splice( sortIdx, 1 );
  3988. }
  3989. else {
  3990. sorting[sortIdx][1] = asSorting[ nextSortIdx ];
  3991. sorting[sortIdx]._idx = nextSortIdx;
  3992. }
  3993. }
  3994. else {
  3995. // No sort on this column yet
  3996. sorting.push( [ colIdx, asSorting[0], 0 ] );
  3997. sorting[sorting.length-1]._idx = 0;
  3998. }
  3999. }
  4000. else if ( sorting.length && sorting[0][0] == colIdx ) {
  4001. // Single column - already sorting on this column, modify the sort
  4002. nextSortIdx = next( sorting[0] );
  4003. sorting.length = 1;
  4004. sorting[0][1] = asSorting[ nextSortIdx ];
  4005. sorting[0]._idx = nextSortIdx;
  4006. }
  4007. else {
  4008. // Single column - sort only on this column
  4009. sorting.length = 0;
  4010. sorting.push( [ colIdx, asSorting[0] ] );
  4011. sorting[0]._idx = 0;
  4012. }
  4013. // Run the sort by calling a full redraw
  4014. _fnReDraw( settings );
  4015. // callback used for async user interaction
  4016. if ( typeof callback == 'function' ) {
  4017. callback( settings );
  4018. }
  4019. }
  4020. /**
  4021. * Attach a sort handler (click) to a node
  4022. * @param {object} settings dataTables settings object
  4023. * @param {node} attachTo node to attach the handler to
  4024. * @param {int} colIdx column sorting index
  4025. * @param {function} [callback] callback function
  4026. * @memberof DataTable#oApi
  4027. */
  4028. function _fnSortAttachListener ( settings, attachTo, colIdx, callback )
  4029. {
  4030. var col = settings.aoColumns[ colIdx ];
  4031. _fnBindAction( attachTo, {}, function (e) {
  4032. /* If the column is not sortable - don't to anything */
  4033. if ( col.bSortable === false ) {
  4034. return;
  4035. }
  4036. // If processing is enabled use a timeout to allow the processing
  4037. // display to be shown - otherwise to it synchronously
  4038. if ( settings.oFeatures.bProcessing ) {
  4039. _fnProcessingDisplay( settings, true );
  4040. setTimeout( function() {
  4041. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  4042. // In server-side processing, the draw callback will remove the
  4043. // processing display
  4044. if ( _fnDataSource( settings ) !== 'ssp' ) {
  4045. _fnProcessingDisplay( settings, false );
  4046. }
  4047. }, 0 );
  4048. }
  4049. else {
  4050. _fnSortListener( settings, colIdx, e.shiftKey, callback );
  4051. }
  4052. } );
  4053. }
  4054. /**
  4055. * Set the sorting classes on table's body, Note: it is safe to call this function
  4056. * when bSort and bSortClasses are false
  4057. * @param {object} oSettings dataTables settings object
  4058. * @memberof DataTable#oApi
  4059. */
  4060. function _fnSortingClasses( settings )
  4061. {
  4062. var oldSort = settings.aLastSort;
  4063. var sortClass = settings.oClasses.sSortColumn;
  4064. var sort = _fnSortFlatten( settings );
  4065. var features = settings.oFeatures;
  4066. var i, ien, colIdx;
  4067. if ( features.bSort && features.bSortClasses ) {
  4068. // Remove old sorting classes
  4069. for ( i=0, ien=oldSort.length ; i<ien ; i++ ) {
  4070. colIdx = oldSort[i].src;
  4071. // Remove column sorting
  4072. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  4073. .removeClass( sortClass + (i<2 ? i+1 : 3) );
  4074. }
  4075. // Add new column sorting
  4076. for ( i=0, ien=sort.length ; i<ien ; i++ ) {
  4077. colIdx = sort[i].src;
  4078. $( _pluck( settings.aoData, 'anCells', colIdx ) )
  4079. .addClass( sortClass + (i<2 ? i+1 : 3) );
  4080. }
  4081. }
  4082. settings.aLastSort = sort;
  4083. }
  4084. // Get the data to sort a column, be it from cache, fresh (populating the
  4085. // cache), or from a sort formatter
  4086. function _fnSortData( settings, idx )
  4087. {
  4088. // Custom sorting function - provided by the sort data type
  4089. var column = settings.aoColumns[ idx ];
  4090. var customSort = DataTable.ext.order[ column.sSortDataType ];
  4091. var customData;
  4092. if ( customSort ) {
  4093. customData = customSort.call( settings.oInstance, settings, idx,
  4094. _fnColumnIndexToVisible( settings, idx )
  4095. );
  4096. }
  4097. // Use / populate cache
  4098. var row, cellData;
  4099. var formatter = DataTable.ext.type.order[ column.sType+"-pre" ];
  4100. for ( var i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  4101. row = settings.aoData[i];
  4102. if ( ! row._aSortData ) {
  4103. row._aSortData = [];
  4104. }
  4105. if ( ! row._aSortData[idx] || customSort ) {
  4106. cellData = customSort ?
  4107. customData[i] : // If there was a custom sort function, use data from there
  4108. _fnGetCellData( settings, i, idx, 'sort' );
  4109. row._aSortData[ idx ] = formatter ?
  4110. formatter( cellData ) :
  4111. cellData;
  4112. }
  4113. }
  4114. }
  4115. /**
  4116. * Save the state of a table
  4117. * @param {object} oSettings dataTables settings object
  4118. * @memberof DataTable#oApi
  4119. */
  4120. function _fnSaveState ( settings )
  4121. {
  4122. if ( !settings.oFeatures.bStateSave || settings.bDestroying )
  4123. {
  4124. return;
  4125. }
  4126. /* Store the interesting variables */
  4127. var state = {
  4128. time: +new Date(),
  4129. start: settings._iDisplayStart,
  4130. length: settings._iDisplayLength,
  4131. order: $.extend( true, [], settings.aaSorting ),
  4132. search: _fnSearchToCamel( settings.oPreviousSearch ),
  4133. columns: $.map( settings.aoColumns, function ( col, i ) {
  4134. return {
  4135. visible: col.bVisible,
  4136. search: _fnSearchToCamel( settings.aoPreSearchCols[i] )
  4137. };
  4138. } )
  4139. };
  4140. _fnCallbackFire( settings, "aoStateSaveParams", 'stateSaveParams', [settings, state] );
  4141. settings.oSavedState = state;
  4142. settings.fnStateSaveCallback.call( settings.oInstance, settings, state );
  4143. }
  4144. /**
  4145. * Attempt to load a saved table state
  4146. * @param {object} oSettings dataTables settings object
  4147. * @param {object} oInit DataTables init object so we can override settings
  4148. * @memberof DataTable#oApi
  4149. */
  4150. function _fnLoadState ( settings, oInit )
  4151. {
  4152. var i, ien;
  4153. var columns = settings.aoColumns;
  4154. if ( ! settings.oFeatures.bStateSave ) {
  4155. return;
  4156. }
  4157. var state = settings.fnStateLoadCallback.call( settings.oInstance, settings );
  4158. if ( ! state || ! state.time ) {
  4159. return;
  4160. }
  4161. /* Allow custom and plug-in manipulation functions to alter the saved data set and
  4162. * cancelling of loading by returning false
  4163. */
  4164. var abStateLoad = _fnCallbackFire( settings, 'aoStateLoadParams', 'stateLoadParams', [settings, state] );
  4165. if ( $.inArray( false, abStateLoad ) !== -1 ) {
  4166. return;
  4167. }
  4168. /* Reject old data */
  4169. var duration = settings.iStateDuration;
  4170. if ( duration > 0 && state.time < +new Date() - (duration*1000) ) {
  4171. return;
  4172. }
  4173. // Number of columns have changed - all bets are off, no restore of settings
  4174. if ( columns.length !== state.columns.length ) {
  4175. return;
  4176. }
  4177. // Store the saved state so it might be accessed at any time
  4178. settings.oLoadedState = $.extend( true, {}, state );
  4179. // Restore key features - todo - for 1.11 this needs to be done by
  4180. // subscribed events
  4181. settings._iDisplayStart = state.start;
  4182. settings.iInitDisplayStart = state.start;
  4183. settings._iDisplayLength = state.length;
  4184. settings.aaSorting = [];
  4185. // Order
  4186. $.each( state.order, function ( i, col ) {
  4187. settings.aaSorting.push( col[0] >= columns.length ?
  4188. [ 0, col[1] ] :
  4189. col
  4190. );
  4191. } );
  4192. // Search
  4193. $.extend( settings.oPreviousSearch, _fnSearchToHung( state.search ) );
  4194. // Columns
  4195. for ( i=0, ien=state.columns.length ; i<ien ; i++ ) {
  4196. var col = state.columns[i];
  4197. // Visibility
  4198. columns[i].bVisible = col.visible;
  4199. // Search
  4200. $.extend( settings.aoPreSearchCols[i], _fnSearchToHung( col.search ) );
  4201. }
  4202. _fnCallbackFire( settings, 'aoStateLoaded', 'stateLoaded', [settings, state] );
  4203. }
  4204. /**
  4205. * Return the settings object for a particular table
  4206. * @param {node} table table we are using as a dataTable
  4207. * @returns {object} Settings object - or null if not found
  4208. * @memberof DataTable#oApi
  4209. */
  4210. function _fnSettingsFromNode ( table )
  4211. {
  4212. var settings = DataTable.settings;
  4213. var idx = $.inArray( table, _pluck( settings, 'nTable' ) );
  4214. return idx !== -1 ?
  4215. settings[ idx ] :
  4216. null;
  4217. }
  4218. /**
  4219. * Log an error message
  4220. * @param {object} settings dataTables settings object
  4221. * @param {int} level log error messages, or display them to the user
  4222. * @param {string} msg error message
  4223. * @param {int} tn Technical note id to get more information about the error.
  4224. * @memberof DataTable#oApi
  4225. */
  4226. function _fnLog( settings, level, msg, tn )
  4227. {
  4228. msg = 'DataTables warning: '+
  4229. (settings!==null ? 'table id='+settings.sTableId+' - ' : '')+msg;
  4230. if ( tn ) {
  4231. msg += '. For more information about this error, please see '+
  4232. 'http://datatables.net/tn/'+tn;
  4233. }
  4234. if ( ! level ) {
  4235. // Backwards compatibility pre 1.10
  4236. var ext = DataTable.ext;
  4237. var type = ext.sErrMode || ext.errMode;
  4238. if ( type == 'alert' ) {
  4239. alert( msg );
  4240. }
  4241. else {
  4242. throw new Error(msg);
  4243. }
  4244. }
  4245. else if ( window.console && console.log ) {
  4246. //console.log( msg );
  4247. }
  4248. }
  4249. /**
  4250. * See if a property is defined on one object, if so assign it to the other object
  4251. * @param {object} ret target object
  4252. * @param {object} src source object
  4253. * @param {string} name property
  4254. * @param {string} [mappedName] name to map too - optional, name used if not given
  4255. * @memberof DataTable#oApi
  4256. */
  4257. function _fnMap( ret, src, name, mappedName )
  4258. {
  4259. if ( $.isArray( name ) ) {
  4260. $.each( name, function (i, val) {
  4261. if ( $.isArray( val ) ) {
  4262. _fnMap( ret, src, val[0], val[1] );
  4263. }
  4264. else {
  4265. _fnMap( ret, src, val );
  4266. }
  4267. } );
  4268. return;
  4269. }
  4270. if ( mappedName === undefined ) {
  4271. mappedName = name;
  4272. }
  4273. if ( src[name] !== undefined ) {
  4274. ret[mappedName] = src[name];
  4275. }
  4276. }
  4277. /**
  4278. * Extend objects - very similar to jQuery.extend, but deep copy objects, and
  4279. * shallow copy arrays. The reason we need to do this, is that we don't want to
  4280. * deep copy array init values (such as aaSorting) since the dev wouldn't be
  4281. * able to override them, but we do want to deep copy arrays.
  4282. * @param {object} out Object to extend
  4283. * @param {object} extender Object from which the properties will be applied to
  4284. * out
  4285. * @param {boolean} breakRefs If true, then arrays will be sliced to take an
  4286. * independent copy with the exception of the `data` or `aaData` parameters
  4287. * if they are present. This is so you can pass in a collection to
  4288. * DataTables and have that used as your data source without breaking the
  4289. * references
  4290. * @returns {object} out Reference, just for convenience - out === the return.
  4291. * @memberof DataTable#oApi
  4292. * @yodo This doesn't take account of arrays inside the deep copied objects.
  4293. */
  4294. function _fnExtend( out, extender, breakRefs )
  4295. {
  4296. var val;
  4297. for ( var prop in extender ) {
  4298. if ( extender.hasOwnProperty(prop) ) {
  4299. val = extender[prop];
  4300. if ( $.isPlainObject( val ) ) {
  4301. if ( ! $.isPlainObject( out[prop] ) ) {
  4302. out[prop] = {};
  4303. }
  4304. $.extend( true, out[prop], val );
  4305. }
  4306. else if ( breakRefs && prop !== 'data' && prop !== 'aaData' && $.isArray(val) ) {
  4307. out[prop] = val.slice();
  4308. }
  4309. else {
  4310. out[prop] = val;
  4311. }
  4312. }
  4313. }
  4314. return out;
  4315. }
  4316. /**
  4317. * Bind an event handers to allow a click or return key to activate the callback.
  4318. * This is good for accessibility since a return on the keyboard will have the
  4319. * same effect as a click, if the element has focus.
  4320. * @param {element} n Element to bind the action to
  4321. * @param {object} oData Data object to pass to the triggered function
  4322. * @param {function} fn Callback function for when the event is triggered
  4323. * @memberof DataTable#oApi
  4324. */
  4325. function _fnBindAction( n, oData, fn )
  4326. {
  4327. $(n)
  4328. .bind( 'click.DT', oData, function (e) {
  4329. n.blur(); // Remove focus outline for mouse users
  4330. fn(e);
  4331. } )
  4332. .bind( 'keypress.DT', oData, function (e){
  4333. if ( e.which === 13 ) {
  4334. e.preventDefault();
  4335. fn(e);
  4336. }
  4337. } )
  4338. .bind( 'selectstart.DT', function () {
  4339. /* Take the brutal approach to cancelling text selection */
  4340. return false;
  4341. } );
  4342. }
  4343. /**
  4344. * Register a callback function. Easily allows a callback function to be added to
  4345. * an array store of callback functions that can then all be called together.
  4346. * @param {object} oSettings dataTables settings object
  4347. * @param {string} sStore Name of the array storage for the callbacks in oSettings
  4348. * @param {function} fn Function to be called back
  4349. * @param {string} sName Identifying name for the callback (i.e. a label)
  4350. * @memberof DataTable#oApi
  4351. */
  4352. function _fnCallbackReg( oSettings, sStore, fn, sName )
  4353. {
  4354. if ( fn )
  4355. {
  4356. oSettings[sStore].push( {
  4357. "fn": fn,
  4358. "sName": sName
  4359. } );
  4360. }
  4361. }
  4362. /**
  4363. * Fire callback functions and trigger events. Note that the loop over the
  4364. * callback array store is done backwards! Further note that you do not want to
  4365. * fire off triggers in time sensitive applications (for example cell creation)
  4366. * as its slow.
  4367. * @param {object} settings dataTables settings object
  4368. * @param {string} callbackArr Name of the array storage for the callbacks in
  4369. * oSettings
  4370. * @param {string} event Name of the jQuery custom event to trigger. If null no
  4371. * trigger is fired
  4372. * @param {array} args Array of arguments to pass to the callback function /
  4373. * trigger
  4374. * @memberof DataTable#oApi
  4375. */
  4376. function _fnCallbackFire( settings, callbackArr, e, args )
  4377. {
  4378. var ret = [];
  4379. if ( callbackArr ) {
  4380. ret = $.map( settings[callbackArr].slice().reverse(), function (val, i) {
  4381. return val.fn.apply( settings.oInstance, args );
  4382. } );
  4383. }
  4384. if ( e !== null ) {
  4385. $(settings.nTable).trigger( e+'.dt', args );
  4386. }
  4387. return ret;
  4388. }
  4389. function _fnLengthOverflow ( settings )
  4390. {
  4391. var
  4392. start = settings._iDisplayStart,
  4393. end = settings.fnDisplayEnd(),
  4394. len = settings._iDisplayLength;
  4395. /* If we have space to show extra rows (backing up from the end point - then do so */
  4396. if (start >= end)
  4397. {
  4398. start = end - len;
  4399. }
  4400. if ( len === -1 || start < 0 )
  4401. {
  4402. start = 0;
  4403. }
  4404. settings._iDisplayStart = start;
  4405. }
  4406. function _fnRenderer( settings, type )
  4407. {
  4408. var renderer = settings.renderer;
  4409. var host = DataTable.ext.renderer[type];
  4410. if ( $.isPlainObject( renderer ) && renderer[type] ) {
  4411. // Specific renderer for this type. If available use it, otherwise use
  4412. // the default.
  4413. return host[renderer[type]] || host._;
  4414. }
  4415. else if ( typeof renderer === 'string' ) {
  4416. // Common renderer - if there is one available for this type use it,
  4417. // otherwise use the default
  4418. return host[renderer] || host._;
  4419. }
  4420. // Use the default
  4421. return host._;
  4422. }
  4423. /**
  4424. * Detect the data source being used for the table. Used to simplify the code
  4425. * a little (ajax) and to make it compress a little smaller.
  4426. *
  4427. * @param {object} settings dataTables settings object
  4428. * @returns {string} Data source
  4429. * @memberof DataTable#oApi
  4430. */
  4431. function _fnDataSource ( settings )
  4432. {
  4433. if ( settings.oFeatures.bServerSide ) {
  4434. return 'ssp';
  4435. }
  4436. else if ( settings.ajax || settings.sAjaxSource ) {
  4437. return 'ajax';
  4438. }
  4439. return 'dom';
  4440. }
  4441. DataTable = function( options )
  4442. {
  4443. /**
  4444. * Perform a jQuery selector action on the table's TR elements (from the tbody) and
  4445. * return the resulting jQuery object.
  4446. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  4447. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  4448. * @param {string} [oOpts.filter=none] Select TR elements that meet the current filter
  4449. * criterion ("applied") or all TR elements (i.e. no filter).
  4450. * @param {string} [oOpts.order=current] Order of the TR elements in the processed array.
  4451. * Can be either 'current', whereby the current sorting of the table is used, or
  4452. * 'original' whereby the original order the data was read into the table is used.
  4453. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  4454. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  4455. * 'current' and filter is 'applied', regardless of what they might be given as.
  4456. * @returns {object} jQuery object, filtered by the given selector.
  4457. * @dtopt API
  4458. * @deprecated Since v1.10
  4459. *
  4460. * @example
  4461. * $(document).ready(function() {
  4462. * var oTable = $('#example').dataTable();
  4463. *
  4464. * // Highlight every second row
  4465. * oTable.$('tr:odd').css('backgroundColor', 'blue');
  4466. * } );
  4467. *
  4468. * @example
  4469. * $(document).ready(function() {
  4470. * var oTable = $('#example').dataTable();
  4471. *
  4472. * // Filter to rows with 'Webkit' in them, add a background colour and then
  4473. * // remove the filter, thus highlighting the 'Webkit' rows only.
  4474. * oTable.fnFilter('Webkit');
  4475. * oTable.$('tr', {"search": "applied"}).css('backgroundColor', 'blue');
  4476. * oTable.fnFilter('');
  4477. * } );
  4478. */
  4479. this.$ = function ( sSelector, oOpts )
  4480. {
  4481. return this.api(true).$( sSelector, oOpts );
  4482. };
  4483. /**
  4484. * Almost identical to $ in operation, but in this case returns the data for the matched
  4485. * rows - as such, the jQuery selector used should match TR row nodes or TD/TH cell nodes
  4486. * rather than any descendants, so the data can be obtained for the row/cell. If matching
  4487. * rows are found, the data returned is the original data array/object that was used to
  4488. * create the row (or a generated array if from a DOM source).
  4489. *
  4490. * This method is often useful in-combination with $ where both functions are given the
  4491. * same parameters and the array indexes will match identically.
  4492. * @param {string|node|jQuery} sSelector jQuery selector or node collection to act on
  4493. * @param {object} [oOpts] Optional parameters for modifying the rows to be included
  4494. * @param {string} [oOpts.filter=none] Select elements that meet the current filter
  4495. * criterion ("applied") or all elements (i.e. no filter).
  4496. * @param {string} [oOpts.order=current] Order of the data in the processed array.
  4497. * Can be either 'current', whereby the current sorting of the table is used, or
  4498. * 'original' whereby the original order the data was read into the table is used.
  4499. * @param {string} [oOpts.page=all] Limit the selection to the currently displayed page
  4500. * ("current") or not ("all"). If 'current' is given, then order is assumed to be
  4501. * 'current' and filter is 'applied', regardless of what they might be given as.
  4502. * @returns {array} Data for the matched elements. If any elements, as a result of the
  4503. * selector, were not TR, TD or TH elements in the DataTable, they will have a null
  4504. * entry in the array.
  4505. * @dtopt API
  4506. * @deprecated Since v1.10
  4507. *
  4508. * @example
  4509. * $(document).ready(function() {
  4510. * var oTable = $('#example').dataTable();
  4511. *
  4512. * // Get the data from the first row in the table
  4513. * var data = oTable._('tr:first');
  4514. *
  4515. * // Do something useful with the data
  4516. * alert( "First cell is: "+data[0] );
  4517. * } );
  4518. *
  4519. * @example
  4520. * $(document).ready(function() {
  4521. * var oTable = $('#example').dataTable();
  4522. *
  4523. * // Filter to 'Webkit' and get all data for
  4524. * oTable.fnFilter('Webkit');
  4525. * var data = oTable._('tr', {"search": "applied"});
  4526. *
  4527. * // Do something with the data
  4528. * alert( data.length+" rows matched the search" );
  4529. * } );
  4530. */
  4531. this._ = function ( sSelector, oOpts )
  4532. {
  4533. return this.api(true).rows( sSelector, oOpts ).data();
  4534. };
  4535. /**
  4536. * Create a DataTables Api instance, with the currently selected tables for
  4537. * the Api's context.
  4538. * @param {boolean} [traditional=false] Set the API instance's context to be
  4539. * only the table referred to by the `DataTable.ext.iApiIndex` option, as was
  4540. * used in the API presented by DataTables 1.9- (i.e. the traditional mode),
  4541. * or if all tables captured in the jQuery object should be used.
  4542. * @return {DataTables.Api}
  4543. */
  4544. this.api = function ( traditional )
  4545. {
  4546. return traditional ?
  4547. new _Api(
  4548. _fnSettingsFromNode( this[ _ext.iApiIndex ] )
  4549. ) :
  4550. new _Api( this );
  4551. };
  4552. /**
  4553. * Add a single new row or multiple rows of data to the table. Please note
  4554. * that this is suitable for client-side processing only - if you are using
  4555. * server-side processing (i.e. "bServerSide": true), then to add data, you
  4556. * must add it to the data source, i.e. the server-side, through an Ajax call.
  4557. * @param {array|object} data The data to be added to the table. This can be:
  4558. * <ul>
  4559. * <li>1D array of data - add a single row with the data provided</li>
  4560. * <li>2D array of arrays - add multiple rows in a single call</li>
  4561. * <li>object - data object when using <i>mData</i></li>
  4562. * <li>array of objects - multiple data objects when using <i>mData</i></li>
  4563. * </ul>
  4564. * @param {bool} [redraw=true] redraw the table or not
  4565. * @returns {array} An array of integers, representing the list of indexes in
  4566. * <i>aoData</i> ({@link DataTable.models.oSettings}) that have been added to
  4567. * the table.
  4568. * @dtopt API
  4569. * @deprecated Since v1.10
  4570. *
  4571. * @example
  4572. * // Global var for counter
  4573. * var giCount = 2;
  4574. *
  4575. * $(document).ready(function() {
  4576. * $('#example').dataTable();
  4577. * } );
  4578. *
  4579. * function fnClickAddRow() {
  4580. * $('#example').dataTable().fnAddData( [
  4581. * giCount+".1",
  4582. * giCount+".2",
  4583. * giCount+".3",
  4584. * giCount+".4" ]
  4585. * );
  4586. *
  4587. * giCount++;
  4588. * }
  4589. */
  4590. this.fnAddData = function( data, redraw )
  4591. {
  4592. var api = this.api( true );
  4593. /* Check if we want to add multiple rows or not */
  4594. var rows = $.isArray(data) && ( $.isArray(data[0]) || $.isPlainObject(data[0]) ) ?
  4595. api.rows.add( data ) :
  4596. api.row.add( data );
  4597. if ( redraw === undefined || redraw ) {
  4598. api.draw();
  4599. }
  4600. return rows.flatten().toArray();
  4601. };
  4602. /**
  4603. * This function will make DataTables recalculate the column sizes, based on the data
  4604. * contained in the table and the sizes applied to the columns (in the DOM, CSS or
  4605. * through the sWidth parameter). This can be useful when the width of the table's
  4606. * parent element changes (for example a window resize).
  4607. * @param {boolean} [bRedraw=true] Redraw the table or not, you will typically want to
  4608. * @dtopt API
  4609. * @deprecated Since v1.10
  4610. *
  4611. * @example
  4612. * $(document).ready(function() {
  4613. * var oTable = $('#example').dataTable( {
  4614. * "sScrollY": "200px",
  4615. * "bPaginate": false
  4616. * } );
  4617. *
  4618. * $(window).bind('resize', function () {
  4619. * oTable.fnAdjustColumnSizing();
  4620. * } );
  4621. * } );
  4622. */
  4623. this.fnAdjustColumnSizing = function ( bRedraw )
  4624. {
  4625. var api = this.api( true ).columns.adjust();
  4626. var settings = api.settings()[0];
  4627. var scroll = settings.oScroll;
  4628. if ( bRedraw === undefined || bRedraw ) {
  4629. api.draw( false );
  4630. }
  4631. else if ( scroll.sX !== "" || scroll.sY !== "" ) {
  4632. /* If not redrawing, but scrolling, we want to apply the new column sizes anyway */
  4633. _fnScrollDraw( settings );
  4634. }
  4635. };
  4636. /**
  4637. * Quickly and simply clear a table
  4638. * @param {bool} [bRedraw=true] redraw the table or not
  4639. * @dtopt API
  4640. * @deprecated Since v1.10
  4641. *
  4642. * @example
  4643. * $(document).ready(function() {
  4644. * var oTable = $('#example').dataTable();
  4645. *
  4646. * // Immediately 'nuke' the current rows (perhaps waiting for an Ajax callback...)
  4647. * oTable.fnClearTable();
  4648. * } );
  4649. */
  4650. this.fnClearTable = function( bRedraw )
  4651. {
  4652. var api = this.api( true ).clear();
  4653. if ( bRedraw === undefined || bRedraw ) {
  4654. api.draw();
  4655. }
  4656. };
  4657. /**
  4658. * The exact opposite of 'opening' a row, this function will close any rows which
  4659. * are currently 'open'.
  4660. * @param {node} nTr the table row to 'close'
  4661. * @returns {int} 0 on success, or 1 if failed (can't find the row)
  4662. * @dtopt API
  4663. * @deprecated Since v1.10
  4664. *
  4665. * @example
  4666. * $(document).ready(function() {
  4667. * var oTable;
  4668. *
  4669. * // 'open' an information row when a row is clicked on
  4670. * $('#example tbody tr').click( function () {
  4671. * if ( oTable.fnIsOpen(this) ) {
  4672. * oTable.fnClose( this );
  4673. * } else {
  4674. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  4675. * }
  4676. * } );
  4677. *
  4678. * oTable = $('#example').dataTable();
  4679. * } );
  4680. */
  4681. this.fnClose = function( nTr )
  4682. {
  4683. this.api( true ).row( nTr ).child.hide();
  4684. };
  4685. /**
  4686. * Remove a row for the table
  4687. * @param {mixed} target The index of the row from aoData to be deleted, or
  4688. * the TR element you want to delete
  4689. * @param {function|null} [callBack] Callback function
  4690. * @param {bool} [redraw=true] Redraw the table or not
  4691. * @returns {array} The row that was deleted
  4692. * @dtopt API
  4693. * @deprecated Since v1.10
  4694. *
  4695. * @example
  4696. * $(document).ready(function() {
  4697. * var oTable = $('#example').dataTable();
  4698. *
  4699. * // Immediately remove the first row
  4700. * oTable.fnDeleteRow( 0 );
  4701. * } );
  4702. */
  4703. this.fnDeleteRow = function( target, callback, redraw )
  4704. {
  4705. var api = this.api( true );
  4706. var rows = api.rows( target );
  4707. var settings = rows.settings()[0];
  4708. var data = settings.aoData[ rows[0][0] ];
  4709. rows.remove();
  4710. if ( callback ) {
  4711. callback.call( this, settings, data );
  4712. }
  4713. if ( redraw === undefined || redraw ) {
  4714. api.draw();
  4715. }
  4716. return data;
  4717. };
  4718. /**
  4719. * Restore the table to it's original state in the DOM by removing all of DataTables
  4720. * enhancements, alterations to the DOM structure of the table and event listeners.
  4721. * @param {boolean} [remove=false] Completely remove the table from the DOM
  4722. * @dtopt API
  4723. * @deprecated Since v1.10
  4724. *
  4725. * @example
  4726. * $(document).ready(function() {
  4727. * // This example is fairly pointless in reality, but shows how fnDestroy can be used
  4728. * var oTable = $('#example').dataTable();
  4729. * oTable.fnDestroy();
  4730. * } );
  4731. */
  4732. this.fnDestroy = function ( remove )
  4733. {
  4734. this.api( true ).destroy( remove );
  4735. };
  4736. /**
  4737. * Redraw the table
  4738. * @param {bool} [complete=true] Re-filter and resort (if enabled) the table before the draw.
  4739. * @dtopt API
  4740. * @deprecated Since v1.10
  4741. *
  4742. * @example
  4743. * $(document).ready(function() {
  4744. * var oTable = $('#example').dataTable();
  4745. *
  4746. * // Re-draw the table - you wouldn't want to do it here, but it's an example :-)
  4747. * oTable.fnDraw();
  4748. * } );
  4749. */
  4750. this.fnDraw = function( complete )
  4751. {
  4752. // Note that this isn't an exact match to the old call to _fnDraw - it takes
  4753. // into account the new data, but can old position.
  4754. this.api( true ).draw( ! complete );
  4755. };
  4756. /**
  4757. * Filter the input based on data
  4758. * @param {string} sInput String to filter the table on
  4759. * @param {int|null} [iColumn] Column to limit filtering to
  4760. * @param {bool} [bRegex=false] Treat as regular expression or not
  4761. * @param {bool} [bSmart=true] Perform smart filtering or not
  4762. * @param {bool} [bShowGlobal=true] Show the input global filter in it's input box(es)
  4763. * @param {bool} [bCaseInsensitive=true] Do case-insensitive matching (true) or not (false)
  4764. * @dtopt API
  4765. * @deprecated Since v1.10
  4766. *
  4767. * @example
  4768. * $(document).ready(function() {
  4769. * var oTable = $('#example').dataTable();
  4770. *
  4771. * // Sometime later - filter...
  4772. * oTable.fnFilter( 'test string' );
  4773. * } );
  4774. */
  4775. this.fnFilter = function( sInput, iColumn, bRegex, bSmart, bShowGlobal, bCaseInsensitive )
  4776. {
  4777. var api = this.api( true );
  4778. if ( iColumn === null || iColumn === undefined ) {
  4779. api.search( sInput, bRegex, bSmart, bCaseInsensitive );
  4780. }
  4781. else {
  4782. api.column( iColumn ).search( sInput, bRegex, bSmart, bCaseInsensitive );
  4783. }
  4784. api.draw();
  4785. };
  4786. /**
  4787. * Get the data for the whole table, an individual row or an individual cell based on the
  4788. * provided parameters.
  4789. * @param {int|node} [src] A TR row node, TD/TH cell node or an integer. If given as
  4790. * a TR node then the data source for the whole row will be returned. If given as a
  4791. * TD/TH cell node then iCol will be automatically calculated and the data for the
  4792. * cell returned. If given as an integer, then this is treated as the aoData internal
  4793. * data index for the row (see fnGetPosition) and the data for that row used.
  4794. * @param {int} [col] Optional column index that you want the data of.
  4795. * @returns {array|object|string} If mRow is undefined, then the data for all rows is
  4796. * returned. If mRow is defined, just data for that row, and is iCol is
  4797. * defined, only data for the designated cell is returned.
  4798. * @dtopt API
  4799. * @deprecated Since v1.10
  4800. *
  4801. * @example
  4802. * // Row data
  4803. * $(document).ready(function() {
  4804. * oTable = $('#example').dataTable();
  4805. *
  4806. * oTable.$('tr').click( function () {
  4807. * var data = oTable.fnGetData( this );
  4808. * // ... do something with the array / object of data for the row
  4809. * } );
  4810. * } );
  4811. *
  4812. * @example
  4813. * // Individual cell data
  4814. * $(document).ready(function() {
  4815. * oTable = $('#example').dataTable();
  4816. *
  4817. * oTable.$('td').click( function () {
  4818. * var sData = oTable.fnGetData( this );
  4819. * alert( 'The cell clicked on had the value of '+sData );
  4820. * } );
  4821. * } );
  4822. */
  4823. this.fnGetData = function( src, col )
  4824. {
  4825. var api = this.api( true );
  4826. if ( src !== undefined ) {
  4827. var type = src.nodeName ? src.nodeName.toLowerCase() : '';
  4828. return col !== undefined || type == 'td' || type == 'th' ?
  4829. api.cell( src, col ).data() :
  4830. api.row( src ).data() || null;
  4831. }
  4832. return api.data().toArray();
  4833. };
  4834. /**
  4835. * Get an array of the TR nodes that are used in the table's body. Note that you will
  4836. * typically want to use the '$' API method in preference to this as it is more
  4837. * flexible.
  4838. * @param {int} [iRow] Optional row index for the TR element you want
  4839. * @returns {array|node} If iRow is undefined, returns an array of all TR elements
  4840. * in the table's body, or iRow is defined, just the TR element requested.
  4841. * @dtopt API
  4842. * @deprecated Since v1.10
  4843. *
  4844. * @example
  4845. * $(document).ready(function() {
  4846. * var oTable = $('#example').dataTable();
  4847. *
  4848. * // Get the nodes from the table
  4849. * var nNodes = oTable.fnGetNodes( );
  4850. * } );
  4851. */
  4852. this.fnGetNodes = function( iRow )
  4853. {
  4854. var api = this.api( true );
  4855. return iRow !== undefined ?
  4856. api.row( iRow ).node() :
  4857. api.rows().nodes().flatten().toArray();
  4858. };
  4859. /**
  4860. * Get the array indexes of a particular cell from it's DOM element
  4861. * and column index including hidden columns
  4862. * @param {node} node this can either be a TR, TD or TH in the table's body
  4863. * @returns {int} If nNode is given as a TR, then a single index is returned, or
  4864. * if given as a cell, an array of [row index, column index (visible),
  4865. * column index (all)] is given.
  4866. * @dtopt API
  4867. * @deprecated Since v1.10
  4868. *
  4869. * @example
  4870. * $(document).ready(function() {
  4871. * $('#example tbody td').click( function () {
  4872. * // Get the position of the current data from the node
  4873. * var aPos = oTable.fnGetPosition( this );
  4874. *
  4875. * // Get the data array for this row
  4876. * var aData = oTable.fnGetData( aPos[0] );
  4877. *
  4878. * // Update the data array and return the value
  4879. * aData[ aPos[1] ] = 'clicked';
  4880. * this.innerHTML = 'clicked';
  4881. * } );
  4882. *
  4883. * // Init DataTables
  4884. * oTable = $('#example').dataTable();
  4885. * } );
  4886. */
  4887. this.fnGetPosition = function( node )
  4888. {
  4889. var api = this.api( true );
  4890. var nodeName = node.nodeName.toUpperCase();
  4891. if ( nodeName == 'TR' ) {
  4892. return api.row( node ).index();
  4893. }
  4894. else if ( nodeName == 'TD' || nodeName == 'TH' ) {
  4895. var cell = api.cell( node ).index();
  4896. return [
  4897. cell.row,
  4898. cell.columnVisible,
  4899. cell.column
  4900. ];
  4901. }
  4902. return null;
  4903. };
  4904. /**
  4905. * Check to see if a row is 'open' or not.
  4906. * @param {node} nTr the table row to check
  4907. * @returns {boolean} true if the row is currently open, false otherwise
  4908. * @dtopt API
  4909. * @deprecated Since v1.10
  4910. *
  4911. * @example
  4912. * $(document).ready(function() {
  4913. * var oTable;
  4914. *
  4915. * // 'open' an information row when a row is clicked on
  4916. * $('#example tbody tr').click( function () {
  4917. * if ( oTable.fnIsOpen(this) ) {
  4918. * oTable.fnClose( this );
  4919. * } else {
  4920. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  4921. * }
  4922. * } );
  4923. *
  4924. * oTable = $('#example').dataTable();
  4925. * } );
  4926. */
  4927. this.fnIsOpen = function( nTr )
  4928. {
  4929. return this.api( true ).row( nTr ).child.isShown();
  4930. };
  4931. /**
  4932. * This function will place a new row directly after a row which is currently
  4933. * on display on the page, with the HTML contents that is passed into the
  4934. * function. This can be used, for example, to ask for confirmation that a
  4935. * particular record should be deleted.
  4936. * @param {node} nTr The table row to 'open'
  4937. * @param {string|node|jQuery} mHtml The HTML to put into the row
  4938. * @param {string} sClass Class to give the new TD cell
  4939. * @returns {node} The row opened. Note that if the table row passed in as the
  4940. * first parameter, is not found in the table, this method will silently
  4941. * return.
  4942. * @dtopt API
  4943. * @deprecated Since v1.10
  4944. *
  4945. * @example
  4946. * $(document).ready(function() {
  4947. * var oTable;
  4948. *
  4949. * // 'open' an information row when a row is clicked on
  4950. * $('#example tbody tr').click( function () {
  4951. * if ( oTable.fnIsOpen(this) ) {
  4952. * oTable.fnClose( this );
  4953. * } else {
  4954. * oTable.fnOpen( this, "Temporary row opened", "info_row" );
  4955. * }
  4956. * } );
  4957. *
  4958. * oTable = $('#example').dataTable();
  4959. * } );
  4960. */
  4961. this.fnOpen = function( nTr, mHtml, sClass )
  4962. {
  4963. return this.api( true )
  4964. .row( nTr )
  4965. .child( mHtml, sClass )
  4966. .show()
  4967. .child()[0];
  4968. };
  4969. /**
  4970. * Change the pagination - provides the internal logic for pagination in a simple API
  4971. * function. With this function you can have a DataTables table go to the next,
  4972. * previous, first or last pages.
  4973. * @param {string|int} mAction Paging action to take: "first", "previous", "next" or "last"
  4974. * or page number to jump to (integer), note that page 0 is the first page.
  4975. * @param {bool} [bRedraw=true] Redraw the table or not
  4976. * @dtopt API
  4977. * @deprecated Since v1.10
  4978. *
  4979. * @example
  4980. * $(document).ready(function() {
  4981. * var oTable = $('#example').dataTable();
  4982. * oTable.fnPageChange( 'next' );
  4983. * } );
  4984. */
  4985. this.fnPageChange = function ( mAction, bRedraw )
  4986. {
  4987. var api = this.api( true ).page( mAction );
  4988. if ( bRedraw === undefined || bRedraw ) {
  4989. api.draw(false);
  4990. }
  4991. };
  4992. /**
  4993. * Show a particular column
  4994. * @param {int} iCol The column whose display should be changed
  4995. * @param {bool} bShow Show (true) or hide (false) the column
  4996. * @param {bool} [bRedraw=true] Redraw the table or not
  4997. * @dtopt API
  4998. * @deprecated Since v1.10
  4999. *
  5000. * @example
  5001. * $(document).ready(function() {
  5002. * var oTable = $('#example').dataTable();
  5003. *
  5004. * // Hide the second column after initialisation
  5005. * oTable.fnSetColumnVis( 1, false );
  5006. * } );
  5007. */
  5008. this.fnSetColumnVis = function ( iCol, bShow, bRedraw )
  5009. {
  5010. var api = this.api( true ).column( iCol ).visible( bShow );
  5011. if ( bRedraw === undefined || bRedraw ) {
  5012. api.columns.adjust().draw();
  5013. }
  5014. };
  5015. /**
  5016. * Get the settings for a particular table for external manipulation
  5017. * @returns {object} DataTables settings object. See
  5018. * {@link DataTable.models.oSettings}
  5019. * @dtopt API
  5020. * @deprecated Since v1.10
  5021. *
  5022. * @example
  5023. * $(document).ready(function() {
  5024. * var oTable = $('#example').dataTable();
  5025. * var oSettings = oTable.fnSettings();
  5026. *
  5027. * // Show an example parameter from the settings
  5028. * alert( oSettings._iDisplayStart );
  5029. * } );
  5030. */
  5031. this.fnSettings = function()
  5032. {
  5033. return _fnSettingsFromNode( this[_ext.iApiIndex] );
  5034. };
  5035. /**
  5036. * Sort the table by a particular column
  5037. * @param {int} iCol the data index to sort on. Note that this will not match the
  5038. * 'display index' if you have hidden data entries
  5039. * @dtopt API
  5040. * @deprecated Since v1.10
  5041. *
  5042. * @example
  5043. * $(document).ready(function() {
  5044. * var oTable = $('#example').dataTable();
  5045. *
  5046. * // Sort immediately with columns 0 and 1
  5047. * oTable.fnSort( [ [0,'asc'], [1,'asc'] ] );
  5048. * } );
  5049. */
  5050. this.fnSort = function( aaSort )
  5051. {
  5052. this.api( true ).order( aaSort ).draw();
  5053. };
  5054. /**
  5055. * Attach a sort listener to an element for a given column
  5056. * @param {node} nNode the element to attach the sort listener to
  5057. * @param {int} iColumn the column that a click on this node will sort on
  5058. * @param {function} [fnCallback] callback function when sort is run
  5059. * @dtopt API
  5060. * @deprecated Since v1.10
  5061. *
  5062. * @example
  5063. * $(document).ready(function() {
  5064. * var oTable = $('#example').dataTable();
  5065. *
  5066. * // Sort on column 1, when 'sorter' is clicked on
  5067. * oTable.fnSortListener( document.getElementById('sorter'), 1 );
  5068. * } );
  5069. */
  5070. this.fnSortListener = function( nNode, iColumn, fnCallback )
  5071. {
  5072. this.api( true ).order.listener( nNode, iColumn, fnCallback );
  5073. };
  5074. /**
  5075. * Update a table cell or row - this method will accept either a single value to
  5076. * update the cell with, an array of values with one element for each column or
  5077. * an object in the same format as the original data source. The function is
  5078. * self-referencing in order to make the multi column updates easier.
  5079. * @param {object|array|string} mData Data to update the cell/row with
  5080. * @param {node|int} mRow TR element you want to update or the aoData index
  5081. * @param {int} [iColumn] The column to update, give as null or undefined to
  5082. * update a whole row.
  5083. * @param {bool} [bRedraw=true] Redraw the table or not
  5084. * @param {bool} [bAction=true] Perform pre-draw actions or not
  5085. * @returns {int} 0 on success, 1 on error
  5086. * @dtopt API
  5087. * @deprecated Since v1.10
  5088. *
  5089. * @example
  5090. * $(document).ready(function() {
  5091. * var oTable = $('#example').dataTable();
  5092. * oTable.fnUpdate( 'Example update', 0, 0 ); // Single cell
  5093. * oTable.fnUpdate( ['a', 'b', 'c', 'd', 'e'], $('tbody tr')[0] ); // Row
  5094. * } );
  5095. */
  5096. this.fnUpdate = function( mData, mRow, iColumn, bRedraw, bAction )
  5097. {
  5098. var api = this.api( true );
  5099. if ( iColumn === undefined || iColumn === null ) {
  5100. api.row( mRow ).data( mData );
  5101. }
  5102. else {
  5103. api.cell( mRow, iColumn ).data( mData );
  5104. }
  5105. if ( bAction === undefined || bAction ) {
  5106. api.columns.adjust();
  5107. }
  5108. if ( bRedraw === undefined || bRedraw ) {
  5109. api.draw();
  5110. }
  5111. return 0;
  5112. };
  5113. /**
  5114. * Provide a common method for plug-ins to check the version of DataTables being used, in order
  5115. * to ensure compatibility.
  5116. * @param {string} sVersion Version string to check for, in the format "X.Y.Z". Note that the
  5117. * formats "X" and "X.Y" are also acceptable.
  5118. * @returns {boolean} true if this version of DataTables is greater or equal to the required
  5119. * version, or false if this version of DataTales is not suitable
  5120. * @method
  5121. * @dtopt API
  5122. * @deprecated Since v1.10
  5123. *
  5124. * @example
  5125. * $(document).ready(function() {
  5126. * var oTable = $('#example').dataTable();
  5127. * alert( oTable.fnVersionCheck( '1.9.0' ) );
  5128. * } );
  5129. */
  5130. this.fnVersionCheck = _ext.fnVersionCheck;
  5131. var _that = this;
  5132. var emptyInit = options === undefined;
  5133. var len = this.length;
  5134. if ( emptyInit ) {
  5135. options = {};
  5136. }
  5137. this.oApi = this.internal = _ext.internal;
  5138. // Extend with old style plug-in API methods
  5139. for ( var fn in DataTable.ext.internal ) {
  5140. if ( fn ) {
  5141. this[fn] = _fnExternApiFunc(fn);
  5142. }
  5143. }
  5144. this.each(function() {
  5145. // For each initialisation we want to give it a clean initialisation
  5146. // object that can be bashed around
  5147. var o = {};
  5148. var oInit = len > 1 ? // optimisation for single table case
  5149. _fnExtend( o, options, true ) :
  5150. options;
  5151. /*global oInit,_that,emptyInit*/
  5152. var i=0, iLen, j, jLen, k, kLen;
  5153. var sId = this.getAttribute( 'id' );
  5154. var bInitHandedOff = false;
  5155. var defaults = DataTable.defaults;
  5156. /* Sanity check */
  5157. if ( this.nodeName.toLowerCase() != 'table' )
  5158. {
  5159. _fnLog( null, 0, 'Non-table node initialisation ('+this.nodeName+')', 2 );
  5160. return;
  5161. }
  5162. /* Backwards compatibility for the defaults */
  5163. _fnCompatOpts( defaults );
  5164. _fnCompatCols( defaults.column );
  5165. /* Convert the camel-case defaults to Hungarian */
  5166. _fnCamelToHungarian( defaults, defaults, true );
  5167. _fnCamelToHungarian( defaults.column, defaults.column, true );
  5168. /* Setting up the initialisation object */
  5169. _fnCamelToHungarian( defaults, oInit );
  5170. /* Check to see if we are re-initialising a table */
  5171. var allSettings = DataTable.settings;
  5172. for ( i=0, iLen=allSettings.length ; i<iLen ; i++ )
  5173. {
  5174. /* Base check on table node */
  5175. if ( allSettings[i].nTable == this )
  5176. {
  5177. var bRetrieve = oInit.bRetrieve !== undefined ? oInit.bRetrieve : defaults.bRetrieve;
  5178. var bDestroy = oInit.bDestroy !== undefined ? oInit.bDestroy : defaults.bDestroy;
  5179. if ( emptyInit || bRetrieve )
  5180. {
  5181. return allSettings[i].oInstance;
  5182. }
  5183. else if ( bDestroy )
  5184. {
  5185. allSettings[i].oInstance.fnDestroy();
  5186. break;
  5187. }
  5188. else
  5189. {
  5190. _fnLog( allSettings[i], 0, 'Cannot reinitialise DataTable', 3 );
  5191. return;
  5192. }
  5193. }
  5194. /* If the element we are initialising has the same ID as a table which was previously
  5195. * initialised, but the table nodes don't match (from before) then we destroy the old
  5196. * instance by simply deleting it. This is under the assumption that the table has been
  5197. * destroyed by other methods. Anyone using non-id selectors will need to do this manually
  5198. */
  5199. if ( allSettings[i].sTableId == this.id )
  5200. {
  5201. allSettings.splice( i, 1 );
  5202. break;
  5203. }
  5204. }
  5205. /* Ensure the table has an ID - required for accessibility */
  5206. if ( sId === null || sId === "" )
  5207. {
  5208. sId = "DataTables_Table_"+(DataTable.ext._unique++);
  5209. this.id = sId;
  5210. }
  5211. /* Create the settings object for this table and set some of the default parameters */
  5212. var oSettings = $.extend( true, {}, DataTable.models.oSettings, {
  5213. "nTable": this,
  5214. "oApi": _that.internal,
  5215. "oInit": oInit,
  5216. "sDestroyWidth": $(this)[0].style.width,
  5217. "sInstance": sId,
  5218. "sTableId": sId
  5219. } );
  5220. allSettings.push( oSettings );
  5221. // Need to add the instance after the instance after the settings object has been added
  5222. // to the settings array, so we can self reference the table instance if more than one
  5223. oSettings.oInstance = (_that.length===1) ? _that : $(this).dataTable();
  5224. // Backwards compatibility, before we apply all the defaults
  5225. _fnCompatOpts( oInit );
  5226. if ( oInit.oLanguage )
  5227. {
  5228. _fnLanguageCompat( oInit.oLanguage );
  5229. }
  5230. // If the length menu is given, but the init display length is not, use the length menu
  5231. if ( oInit.aLengthMenu && ! oInit.iDisplayLength )
  5232. {
  5233. oInit.iDisplayLength = $.isArray( oInit.aLengthMenu[0] ) ?
  5234. oInit.aLengthMenu[0][0] : oInit.aLengthMenu[0];
  5235. }
  5236. // Apply the defaults and init options to make a single init object will all
  5237. // options defined from defaults and instance options.
  5238. oInit = _fnExtend( $.extend( true, {}, defaults ), oInit );
  5239. // Map the initialisation options onto the settings object
  5240. _fnMap( oSettings.oFeatures, oInit, [
  5241. "bPaginate",
  5242. "bLengthChange",
  5243. "bFilter",
  5244. "bSort",
  5245. "bSortMulti",
  5246. "bInfo",
  5247. "bProcessing",
  5248. "bAutoWidth",
  5249. "bSortClasses",
  5250. "bServerSide",
  5251. "bDeferRender"
  5252. ] );
  5253. _fnMap( oSettings, oInit, [
  5254. "asStripeClasses",
  5255. "ajax",
  5256. "fnServerData",
  5257. "fnFormatNumber",
  5258. "sServerMethod",
  5259. "aaSorting",
  5260. "aaSortingFixed",
  5261. "aLengthMenu",
  5262. "sPaginationType",
  5263. "sAjaxSource",
  5264. "sAjaxDataProp",
  5265. "iStateDuration",
  5266. "sDom",
  5267. "bSortCellsTop",
  5268. "iTabIndex",
  5269. "fnStateLoadCallback",
  5270. "fnStateSaveCallback",
  5271. "renderer",
  5272. "searchDelay",
  5273. [ "iCookieDuration", "iStateDuration" ], // backwards compat
  5274. [ "oSearch", "oPreviousSearch" ],
  5275. [ "aoSearchCols", "aoPreSearchCols" ],
  5276. [ "iDisplayLength", "_iDisplayLength" ],
  5277. [ "bJQueryUI", "bJUI" ]
  5278. ] );
  5279. _fnMap( oSettings.oScroll, oInit, [
  5280. [ "sScrollX", "sX" ],
  5281. [ "sScrollXInner", "sXInner" ],
  5282. [ "sScrollY", "sY" ],
  5283. [ "bScrollCollapse", "bCollapse" ]
  5284. ] );
  5285. _fnMap( oSettings.oLanguage, oInit, "fnInfoCallback" );
  5286. /* Callback functions which are array driven */
  5287. _fnCallbackReg( oSettings, 'aoDrawCallback', oInit.fnDrawCallback, 'user' );
  5288. _fnCallbackReg( oSettings, 'aoServerParams', oInit.fnServerParams, 'user' );
  5289. _fnCallbackReg( oSettings, 'aoStateSaveParams', oInit.fnStateSaveParams, 'user' );
  5290. _fnCallbackReg( oSettings, 'aoStateLoadParams', oInit.fnStateLoadParams, 'user' );
  5291. _fnCallbackReg( oSettings, 'aoStateLoaded', oInit.fnStateLoaded, 'user' );
  5292. _fnCallbackReg( oSettings, 'aoRowCallback', oInit.fnRowCallback, 'user' );
  5293. _fnCallbackReg( oSettings, 'aoRowCreatedCallback', oInit.fnCreatedRow, 'user' );
  5294. _fnCallbackReg( oSettings, 'aoHeaderCallback', oInit.fnHeaderCallback, 'user' );
  5295. _fnCallbackReg( oSettings, 'aoFooterCallback', oInit.fnFooterCallback, 'user' );
  5296. _fnCallbackReg( oSettings, 'aoInitComplete', oInit.fnInitComplete, 'user' );
  5297. _fnCallbackReg( oSettings, 'aoPreDrawCallback', oInit.fnPreDrawCallback, 'user' );
  5298. var oClasses = oSettings.oClasses;
  5299. // @yodo Remove in 1.11
  5300. if ( oInit.bJQueryUI )
  5301. {
  5302. /* Use the JUI classes object for display. You could clone the oStdClasses object if
  5303. * you want to have multiple tables with multiple independent classes
  5304. */
  5305. $.extend( oClasses, DataTable.ext.oJUIClasses, oInit.oClasses );
  5306. if ( oInit.sDom === defaults.sDom && defaults.sDom === "lfrtip" )
  5307. {
  5308. /* Set the DOM to use a layout suitable for jQuery UI's theming */
  5309. oSettings.sDom = '<"H"lfr>t<"F"ip>';
  5310. }
  5311. if ( ! oSettings.renderer ) {
  5312. oSettings.renderer = 'jqueryui';
  5313. }
  5314. else if ( $.isPlainObject( oSettings.renderer ) && ! oSettings.renderer.header ) {
  5315. oSettings.renderer.header = 'jqueryui';
  5316. }
  5317. }
  5318. else
  5319. {
  5320. $.extend( oClasses, DataTable.ext.classes, oInit.oClasses );
  5321. }
  5322. $(this).addClass( oClasses.sTable );
  5323. /* Calculate the scroll bar width and cache it for use later on */
  5324. if ( oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "" )
  5325. {
  5326. oSettings.oScroll.iBarWidth = _fnScrollBarWidth();
  5327. }
  5328. if ( oSettings.oScroll.sX === true ) { // Easy initialisation of x-scrolling
  5329. oSettings.oScroll.sX = '100%';
  5330. }
  5331. if ( oSettings.iInitDisplayStart === undefined )
  5332. {
  5333. /* Display start point, taking into account the save saving */
  5334. oSettings.iInitDisplayStart = oInit.iDisplayStart;
  5335. oSettings._iDisplayStart = oInit.iDisplayStart;
  5336. }
  5337. if ( oInit.iDeferLoading !== null )
  5338. {
  5339. oSettings.bDeferLoading = true;
  5340. var tmp = $.isArray( oInit.iDeferLoading );
  5341. oSettings._iRecordsDisplay = tmp ? oInit.iDeferLoading[0] : oInit.iDeferLoading;
  5342. oSettings._iRecordsTotal = tmp ? oInit.iDeferLoading[1] : oInit.iDeferLoading;
  5343. }
  5344. /* Language definitions */
  5345. if ( oInit.oLanguage.sUrl !== "" )
  5346. {
  5347. /* Get the language definitions from a file - because this Ajax call makes the language
  5348. * get async to the remainder of this function we use bInitHandedOff to indicate that
  5349. * _fnInitialise will be fired by the returned Ajax handler, rather than the constructor
  5350. */
  5351. oSettings.oLanguage.sUrl = oInit.oLanguage.sUrl;
  5352. $.getJSON( oSettings.oLanguage.sUrl, null, function( json ) {
  5353. _fnLanguageCompat( json );
  5354. _fnCamelToHungarian( defaults.oLanguage, json );
  5355. $.extend( true, oSettings.oLanguage, oInit.oLanguage, json );
  5356. _fnInitialise( oSettings );
  5357. } );
  5358. bInitHandedOff = true;
  5359. }
  5360. else
  5361. {
  5362. $.extend( true, oSettings.oLanguage, oInit.oLanguage );
  5363. }
  5364. /*
  5365. * Stripes
  5366. */
  5367. if ( oInit.asStripeClasses === null )
  5368. {
  5369. oSettings.asStripeClasses =[
  5370. oClasses.sStripeOdd,
  5371. oClasses.sStripeEven
  5372. ];
  5373. }
  5374. /* Remove row stripe classes if they are already on the table row */
  5375. var stripeClasses = oSettings.asStripeClasses;
  5376. var rowOne = $('tbody tr:eq(0)', this);
  5377. if ( $.inArray( true, $.map( stripeClasses, function(el, i) {
  5378. return rowOne.hasClass(el);
  5379. } ) ) !== -1 ) {
  5380. $('tbody tr', this).removeClass( stripeClasses.join(' ') );
  5381. oSettings.asDestroyStripes = stripeClasses.slice();
  5382. }
  5383. /*
  5384. * Columns
  5385. * See if we should load columns automatically or use defined ones
  5386. */
  5387. var anThs = [];
  5388. var aoColumnsInit;
  5389. var nThead = this.getElementsByTagName('thead');
  5390. if ( nThead.length !== 0 )
  5391. {
  5392. _fnDetectHeader( oSettings.aoHeader, nThead[0] );
  5393. anThs = _fnGetUniqueThs( oSettings );
  5394. }
  5395. /* If not given a column array, generate one with nulls */
  5396. if ( oInit.aoColumns === null )
  5397. {
  5398. aoColumnsInit = [];
  5399. for ( i=0, iLen=anThs.length ; i<iLen ; i++ )
  5400. {
  5401. aoColumnsInit.push( null );
  5402. }
  5403. }
  5404. else
  5405. {
  5406. aoColumnsInit = oInit.aoColumns;
  5407. }
  5408. /* Add the columns */
  5409. for ( i=0, iLen=aoColumnsInit.length ; i<iLen ; i++ )
  5410. {
  5411. _fnAddColumn( oSettings, anThs ? anThs[i] : null );
  5412. }
  5413. /* Apply the column definitions */
  5414. _fnApplyColumnDefs( oSettings, oInit.aoColumnDefs, aoColumnsInit, function (iCol, oDef) {
  5415. _fnColumnOptions( oSettings, iCol, oDef );
  5416. } );
  5417. /* HTML5 attribute detection - build an mData object automatically if the
  5418. * attributes are found
  5419. */
  5420. if ( rowOne.length ) {
  5421. var a = function ( cell, name ) {
  5422. return cell.getAttribute( 'data-'+name ) ? name : null;
  5423. };
  5424. $.each( _fnGetRowElements( oSettings, rowOne[0] ).cells, function (i, cell) {
  5425. var col = oSettings.aoColumns[i];
  5426. if ( col.mData === i ) {
  5427. var sort = a( cell, 'sort' ) || a( cell, 'order' );
  5428. var filter = a( cell, 'filter' ) || a( cell, 'search' );
  5429. if ( sort !== null || filter !== null ) {
  5430. col.mData = {
  5431. _: i+'.display',
  5432. sort: sort !== null ? i+'.@data-'+sort : undefined,
  5433. type: sort !== null ? i+'.@data-'+sort : undefined,
  5434. filter: filter !== null ? i+'.@data-'+filter : undefined
  5435. };
  5436. _fnColumnOptions( oSettings, i );
  5437. }
  5438. }
  5439. } );
  5440. }
  5441. var features = oSettings.oFeatures;
  5442. /* Must be done after everything which can be overridden by the state saving! */
  5443. if ( oInit.bStateSave )
  5444. {
  5445. features.bStateSave = true;
  5446. _fnLoadState( oSettings, oInit );
  5447. _fnCallbackReg( oSettings, 'aoDrawCallback', _fnSaveState, 'state_save' );
  5448. }
  5449. /*
  5450. * Sorting
  5451. * @yodo For modularisation (1.11) this needs to do into a sort start up handler
  5452. */
  5453. // If aaSorting is not defined, then we use the first indicator in asSorting
  5454. // in case that has been altered, so the default sort reflects that option
  5455. if ( oInit.aaSorting === undefined )
  5456. {
  5457. var sorting = oSettings.aaSorting;
  5458. for ( i=0, iLen=sorting.length ; i<iLen ; i++ )
  5459. {
  5460. sorting[i][1] = oSettings.aoColumns[ i ].asSorting[0];
  5461. }
  5462. }
  5463. /* Do a first pass on the sorting classes (allows any size changes to be taken into
  5464. * account, and also will apply sorting disabled classes if disabled
  5465. */
  5466. _fnSortingClasses( oSettings );
  5467. if ( features.bSort )
  5468. {
  5469. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  5470. if ( oSettings.bSorted ) {
  5471. var aSort = _fnSortFlatten( oSettings );
  5472. var sortedColumns = {};
  5473. $.each( aSort, function (i, val) {
  5474. sortedColumns[ val.src ] = val.dir;
  5475. } );
  5476. _fnCallbackFire( oSettings, null, 'order', [oSettings, aSort, sortedColumns] );
  5477. _fnSortAria( oSettings );
  5478. }
  5479. } );
  5480. }
  5481. _fnCallbackReg( oSettings, 'aoDrawCallback', function () {
  5482. if ( oSettings.bSorted || _fnDataSource( oSettings ) === 'ssp' || features.bDeferRender ) {
  5483. _fnSortingClasses( oSettings );
  5484. }
  5485. }, 'sc' );
  5486. /*
  5487. * Final init
  5488. * Cache the header, body and footer as required, creating them if needed
  5489. */
  5490. /* Browser support detection */
  5491. _fnBrowserDetect( oSettings );
  5492. // Work around for Webkit bug 83867 - store the caption-side before removing from doc
  5493. var captions = $(this).children('caption').each( function () {
  5494. this._captionSide = $(this).css('caption-side');
  5495. } );
  5496. var thead = $(this).children('thead');
  5497. if ( thead.length === 0 )
  5498. {
  5499. thead = $('<thead/>').appendTo(this);
  5500. }
  5501. oSettings.nTHead = thead[0];
  5502. var tbody = $(this).children('tbody');
  5503. if ( tbody.length === 0 )
  5504. {
  5505. tbody = $('<tbody/>').appendTo(this);
  5506. }
  5507. oSettings.nTBody = tbody[0];
  5508. var tfoot = $(this).children('tfoot');
  5509. if ( tfoot.length === 0 && captions.length > 0 && (oSettings.oScroll.sX !== "" || oSettings.oScroll.sY !== "") )
  5510. {
  5511. // If we are a scrolling table, and no footer has been given, then we need to create
  5512. // a tfoot element for the caption element to be appended to
  5513. tfoot = $('<tfoot/>').appendTo(this);
  5514. }
  5515. if ( tfoot.length === 0 || tfoot.children().length === 0 ) {
  5516. $(this).addClass( oClasses.sNoFooter );
  5517. }
  5518. else if ( tfoot.length > 0 ) {
  5519. oSettings.nTFoot = tfoot[0];
  5520. _fnDetectHeader( oSettings.aoFooter, oSettings.nTFoot );
  5521. }
  5522. /* Check if there is data passing into the constructor */
  5523. if ( oInit.aaData )
  5524. {
  5525. for ( i=0 ; i<oInit.aaData.length ; i++ )
  5526. {
  5527. _fnAddData( oSettings, oInit.aaData[ i ] );
  5528. }
  5529. }
  5530. else if ( oSettings.bDeferLoading || _fnDataSource( oSettings ) == 'dom' )
  5531. {
  5532. /* Grab the data from the page - only do this when deferred loading or no Ajax
  5533. * source since there is no point in reading the DOM data if we are then going
  5534. * to replace it with Ajax data
  5535. */
  5536. _fnAddTr( oSettings, $(oSettings.nTBody).children('tr') );
  5537. }
  5538. /* Copy the data index array */
  5539. oSettings.aiDisplay = oSettings.aiDisplayMaster.slice();
  5540. /* Initialisation complete - table can be drawn */
  5541. oSettings.bInitialised = true;
  5542. /* Check if we need to initialise the table (it might not have been handed off to the
  5543. * language processor)
  5544. */
  5545. if ( bInitHandedOff === false )
  5546. {
  5547. _fnInitialise( oSettings );
  5548. }
  5549. } );
  5550. _that = null;
  5551. return this;
  5552. };
  5553. /**
  5554. * Computed structure of the DataTables API, defined by the options passed to
  5555. * `DataTable.Api.register()` when building the API.
  5556. *
  5557. * The structure is built in order to speed creation and extension of the Api
  5558. * objects since the extensions are effectively pre-parsed.
  5559. *
  5560. * The array is an array of objects with the following structure, where this
  5561. * base array represents the Api prototype base:
  5562. *
  5563. * [
  5564. * {
  5565. * name: 'data' -- string - Property name
  5566. * val: function () {}, -- function - Api method (or undefined if just an object
  5567. * methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  5568. * propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  5569. * },
  5570. * {
  5571. * name: 'row'
  5572. * val: {},
  5573. * methodExt: [ ... ],
  5574. * propExt: [
  5575. * {
  5576. * name: 'data'
  5577. * val: function () {},
  5578. * methodExt: [ ... ],
  5579. * propExt: [ ... ]
  5580. * },
  5581. * ...
  5582. * ]
  5583. * }
  5584. * ]
  5585. *
  5586. * @type {Array}
  5587. * @ignore
  5588. */
  5589. var __apiStruct = [];
  5590. /**
  5591. * `Array.prototype` reference.
  5592. *
  5593. * @type object
  5594. * @ignore
  5595. */
  5596. var __arrayProto = Array.prototype;
  5597. /**
  5598. * Abstraction for `context` parameter of the `Api` constructor to allow it to
  5599. * take several different forms for ease of use.
  5600. *
  5601. * Each of the input parameter types will be converted to a DataTables settings
  5602. * object where possible.
  5603. *
  5604. * @param {string|node|jQuery|object} mixed DataTable identifier. Can be one
  5605. * of:
  5606. *
  5607. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5608. * with be found and used.
  5609. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5610. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5611. * * `object` - DataTables settings object
  5612. * * `DataTables.Api` - API instance
  5613. * @return {array|null} Matching DataTables settings objects. `null` or
  5614. * `undefined` is returned if no matching DataTable is found.
  5615. * @ignore
  5616. */
  5617. var _toSettings = function ( mixed )
  5618. {
  5619. var idx, jq;
  5620. var settings = DataTable.settings;
  5621. var tables = $.map( settings, function (el, i) {
  5622. return el.nTable;
  5623. } );
  5624. if ( ! mixed ) {
  5625. return [];
  5626. }
  5627. else if ( mixed.nTable && mixed.oApi ) {
  5628. // DataTables settings object
  5629. return [ mixed ];
  5630. }
  5631. else if ( mixed.nodeName && mixed.nodeName.toLowerCase() === 'table' ) {
  5632. // Table node
  5633. idx = $.inArray( mixed, tables );
  5634. return idx !== -1 ? [ settings[idx] ] : null;
  5635. }
  5636. else if ( mixed && typeof mixed.settings === 'function' ) {
  5637. return mixed.settings().toArray();
  5638. }
  5639. else if ( typeof mixed === 'string' ) {
  5640. // jQuery selector
  5641. jq = $(mixed);
  5642. }
  5643. else if ( mixed instanceof $ ) {
  5644. // jQuery object (also DataTables instance)
  5645. jq = mixed;
  5646. }
  5647. if ( jq ) {
  5648. return jq.map( function(i) {
  5649. idx = $.inArray( this, tables );
  5650. return idx !== -1 ? settings[idx] : null;
  5651. } ).toArray();
  5652. }
  5653. };
  5654. /**
  5655. * DataTables API class - used to control and interface with one or more
  5656. * DataTables enhanced tables.
  5657. *
  5658. * The API class is heavily based on jQuery, presenting a chainable interface
  5659. * that you can use to interact with tables. Each instance of the API class has
  5660. * a "context" - i.e. the tables that it will operate on. This could be a single
  5661. * table, all tables on a page or a sub-set thereof.
  5662. *
  5663. * Additionally the API is designed to allow you to easily work with the data in
  5664. * the tables, retrieving and manipulating it as required. This is done by
  5665. * presenting the API class as an array like interface. The contents of the
  5666. * array depend upon the actions requested by each method (for example
  5667. * `rows().nodes()` will return an array of nodes, while `rows().data()` will
  5668. * return an array of objects or arrays depending upon your table's
  5669. * configuration). The API object has a number of array like methods (`push`,
  5670. * `pop`, `reverse` etc) as well as additional helper methods (`each`, `pluck`,
  5671. * `unique` etc) to assist your working with the data held in a table.
  5672. *
  5673. * Most methods (those which return an Api instance) are chainable, which means
  5674. * the return from a method call also has all of the methods available that the
  5675. * top level object had. For example, these two calls are equivalent:
  5676. *
  5677. * // Not chained
  5678. * api.row.add( {...} );
  5679. * api.draw();
  5680. *
  5681. * // Chained
  5682. * api.row.add( {...} ).draw();
  5683. *
  5684. * @class DataTable.Api
  5685. * @param {array|object|string|jQuery} context DataTable identifier. This is
  5686. * used to define which DataTables enhanced tables this API will operate on.
  5687. * Can be one of:
  5688. *
  5689. * * `string` - jQuery selector. Any DataTables' matching the given selector
  5690. * with be found and used.
  5691. * * `node` - `TABLE` node which has already been formed into a DataTable.
  5692. * * `jQuery` - A jQuery object of `TABLE` nodes.
  5693. * * `object` - DataTables settings object
  5694. * @param {array} [data] Data to initialise the Api instance with.
  5695. *
  5696. * @example
  5697. * // Direct initialisation during DataTables construction
  5698. * var api = $('#example').DataTable();
  5699. *
  5700. * @example
  5701. * // Initialisation using a DataTables jQuery object
  5702. * var api = $('#example').dataTable().api();
  5703. *
  5704. * @example
  5705. * // Initialisation as a constructor
  5706. * var api = new $.fn.DataTable.Api( 'table.dataTable' );
  5707. */
  5708. _Api = function ( context, data )
  5709. {
  5710. if ( ! this instanceof _Api ) {
  5711. throw 'DT API must be constructed as a new object';
  5712. // or should it do the 'new' for the caller?
  5713. // return new _Api.apply( this, arguments );
  5714. }
  5715. var settings = [];
  5716. var ctxSettings = function ( o ) {
  5717. var a = _toSettings( o );
  5718. if ( a ) {
  5719. settings.push.apply( settings, a );
  5720. }
  5721. };
  5722. if ( $.isArray( context ) ) {
  5723. for ( var i=0, ien=context.length ; i<ien ; i++ ) {
  5724. ctxSettings( context[i] );
  5725. }
  5726. }
  5727. else {
  5728. ctxSettings( context );
  5729. }
  5730. // Remove duplicates
  5731. this.context = _unique( settings );
  5732. // Initial data
  5733. if ( data ) {
  5734. this.push.apply( this, data.toArray ? data.toArray() : data );
  5735. }
  5736. // selector
  5737. this.selector = {
  5738. rows: null,
  5739. cols: null,
  5740. opts: null
  5741. };
  5742. _Api.extend( this, this, __apiStruct );
  5743. };
  5744. DataTable.Api = _Api;
  5745. _Api.prototype = /** @lends DataTables.Api */{
  5746. /**
  5747. * Return a new Api instance, comprised of the data held in the current
  5748. * instance, join with the other array(s) and/or value(s).
  5749. *
  5750. * An alias for `Array.prototype.concat`.
  5751. *
  5752. * @type method
  5753. * @param {*} value1 Arrays and/or values to concatenate.
  5754. * @param {*} [...] Additional arrays and/or values to concatenate.
  5755. * @returns {DataTables.Api} New API instance, comprising of the combined
  5756. * array.
  5757. */
  5758. concat: __arrayProto.concat,
  5759. context: [], // array of table settings objects
  5760. each: function ( fn )
  5761. {
  5762. for ( var i=0, ien=this.length ; i<ien; i++ ) {
  5763. fn.call( this, this[i], i, this );
  5764. }
  5765. return this;
  5766. },
  5767. eq: function ( idx )
  5768. {
  5769. var ctx = this.context;
  5770. return ctx.length > idx ?
  5771. new _Api( ctx[idx], this[idx] ) :
  5772. null;
  5773. },
  5774. filter: function ( fn )
  5775. {
  5776. var a = [];
  5777. if ( __arrayProto.filter ) {
  5778. a = __arrayProto.filter.call( this, fn, this );
  5779. }
  5780. else {
  5781. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  5782. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  5783. if ( fn.call( this, this[i], i, this ) ) {
  5784. a.push( this[i] );
  5785. }
  5786. }
  5787. }
  5788. return new _Api( this.context, a );
  5789. },
  5790. flatten: function ()
  5791. {
  5792. var a = [];
  5793. return new _Api( this.context, a.concat.apply( a, this.toArray() ) );
  5794. },
  5795. join: __arrayProto.join,
  5796. indexOf: __arrayProto.indexOf || function (obj, start)
  5797. {
  5798. for ( var i=(start || 0), ien=this.length ; i<ien ; i++ ) {
  5799. if ( this[i] === obj ) {
  5800. return i;
  5801. }
  5802. }
  5803. return -1;
  5804. },
  5805. // Internal only at the moment - relax?
  5806. iterator: function ( flatten, type, fn ) {
  5807. var
  5808. a = [], ret,
  5809. i, ien, j, jen,
  5810. context = this.context,
  5811. rows, items, item,
  5812. selector = this.selector;
  5813. // Argument shifting
  5814. if ( typeof flatten === 'string' ) {
  5815. fn = type;
  5816. type = flatten;
  5817. flatten = false;
  5818. }
  5819. for ( i=0, ien=context.length ; i<ien ; i++ ) {
  5820. var apiInst = new _Api( context[i] );
  5821. if ( type === 'table' ) {
  5822. ret = fn.call( apiInst, context[i], i );
  5823. if ( ret !== undefined ) {
  5824. a.push( ret );
  5825. }
  5826. }
  5827. else if ( type === 'columns' || type === 'rows' ) {
  5828. // this has same length as context - one entry for each table
  5829. ret = fn.call( apiInst, context[i], this[i], i );
  5830. if ( ret !== undefined ) {
  5831. a.push( ret );
  5832. }
  5833. }
  5834. else if ( type === 'column' || type === 'column-rows' || type === 'row' || type === 'cell' ) {
  5835. // columns and rows share the same structure.
  5836. // 'this' is an array of column indexes for each context
  5837. items = this[i];
  5838. if ( type === 'column-rows' ) {
  5839. rows = _selector_row_indexes( context[i], selector.opts );
  5840. }
  5841. for ( j=0, jen=items.length ; j<jen ; j++ ) {
  5842. item = items[j];
  5843. if ( type === 'cell' ) {
  5844. ret = fn.call( apiInst, context[i], item.row, item.column, i, j );
  5845. }
  5846. else {
  5847. ret = fn.call( apiInst, context[i], item, i, j, rows );
  5848. }
  5849. if ( ret !== undefined ) {
  5850. a.push( ret );
  5851. }
  5852. }
  5853. }
  5854. }
  5855. if ( a.length ) {
  5856. var api = new _Api( context, flatten ? a.concat.apply( [], a ) : a );
  5857. var apiSelector = api.selector;
  5858. apiSelector.rows = selector.rows;
  5859. apiSelector.cols = selector.cols;
  5860. apiSelector.opts = selector.opts;
  5861. return api;
  5862. }
  5863. return this;
  5864. },
  5865. lastIndexOf: __arrayProto.lastIndexOf || function (obj, start)
  5866. {
  5867. // Bit cheeky...
  5868. return this.indexOf.apply( this.toArray.reverse(), arguments );
  5869. },
  5870. length: 0,
  5871. map: function ( fn )
  5872. {
  5873. var a = [];
  5874. if ( __arrayProto.map ) {
  5875. a = __arrayProto.map.call( this, fn, this );
  5876. }
  5877. else {
  5878. // Compatibility for browsers without EMCA-252-5 (JS 1.6)
  5879. for ( var i=0, ien=this.length ; i<ien ; i++ ) {
  5880. a.push( fn.call( this, this[i], i ) );
  5881. }
  5882. }
  5883. return new _Api( this.context, a );
  5884. },
  5885. pluck: function ( prop )
  5886. {
  5887. return this.map( function ( el ) {
  5888. return el[ prop ];
  5889. } );
  5890. },
  5891. pop: __arrayProto.pop,
  5892. push: __arrayProto.push,
  5893. // Does not return an API instance
  5894. reduce: __arrayProto.reduce || function ( fn, init )
  5895. {
  5896. return _fnReduce( this, fn, init, 0, this.length, 1 );
  5897. },
  5898. reduceRight: __arrayProto.reduceRight || function ( fn, init )
  5899. {
  5900. return _fnReduce( this, fn, init, this.length-1, -1, -1 );
  5901. },
  5902. reverse: __arrayProto.reverse,
  5903. // Object with rows, columns and opts
  5904. selector: null,
  5905. shift: __arrayProto.shift,
  5906. sort: __arrayProto.sort, // ? name - order?
  5907. splice: __arrayProto.splice,
  5908. toArray: function ()
  5909. {
  5910. return __arrayProto.slice.call( this );
  5911. },
  5912. to$: function ()
  5913. {
  5914. return $( this );
  5915. },
  5916. toJQuery: function ()
  5917. {
  5918. return $( this );
  5919. },
  5920. unique: function ()
  5921. {
  5922. return new _Api( this.context, _unique(this) );
  5923. },
  5924. unshift: __arrayProto.unshift
  5925. };
  5926. _Api.extend = function ( scope, obj, ext )
  5927. {
  5928. // Only extend API instances and static properties of the API
  5929. if ( ! obj || ( ! (obj instanceof _Api) && ! obj.__dt_wrapper ) ) {
  5930. return;
  5931. }
  5932. var
  5933. i, ien,
  5934. j, jen,
  5935. struct, inner,
  5936. methodScoping = function ( scope, fn, struc ) {
  5937. return function () {
  5938. var ret = fn.apply( scope, arguments );
  5939. // Method extension
  5940. _Api.extend( ret, ret, struc.methodExt );
  5941. return ret;
  5942. };
  5943. };
  5944. for ( i=0, ien=ext.length ; i<ien ; i++ ) {
  5945. struct = ext[i];
  5946. // Value
  5947. obj[ struct.name ] = typeof struct.val === 'function' ?
  5948. methodScoping( scope, struct.val, struct ) :
  5949. $.isPlainObject( struct.val ) ?
  5950. {} :
  5951. struct.val;
  5952. obj[ struct.name ].__dt_wrapper = true;
  5953. // Property extension
  5954. _Api.extend( scope, obj[ struct.name ], struct.propExt );
  5955. }
  5956. };
  5957. // @yodo - Is there need for an augment function?
  5958. // _Api.augment = function ( inst, name )
  5959. // {
  5960. // // Find src object in the structure from the name
  5961. // var parts = name.split('.');
  5962. // _Api.extend( inst, obj );
  5963. // };
  5964. // [
  5965. // {
  5966. // name: 'data' -- string - Property name
  5967. // val: function () {}, -- function - Api method (or undefined if just an object
  5968. // methodExt: [ ... ], -- array - Array of Api object definitions to extend the method result
  5969. // propExt: [ ... ] -- array - Array of Api object definitions to extend the property
  5970. // },
  5971. // {
  5972. // name: 'row'
  5973. // val: {},
  5974. // methodExt: [ ... ],
  5975. // propExt: [
  5976. // {
  5977. // name: 'data'
  5978. // val: function () {},
  5979. // methodExt: [ ... ],
  5980. // propExt: [ ... ]
  5981. // },
  5982. // ...
  5983. // ]
  5984. // }
  5985. // ]
  5986. _Api.register = _api_register = function ( name, val )
  5987. {
  5988. if ( $.isArray( name ) ) {
  5989. for ( var j=0, jen=name.length ; j<jen ; j++ ) {
  5990. _Api.register( name[j], val );
  5991. }
  5992. return;
  5993. }
  5994. var
  5995. i, ien,
  5996. heir = name.split('.'),
  5997. struct = __apiStruct,
  5998. key, method;
  5999. var find = function ( src, name ) {
  6000. for ( var i=0, ien=src.length ; i<ien ; i++ ) {
  6001. if ( src[i].name === name ) {
  6002. return src[i];
  6003. }
  6004. }
  6005. return null;
  6006. };
  6007. for ( i=0, ien=heir.length ; i<ien ; i++ ) {
  6008. method = heir[i].indexOf('()') !== -1;
  6009. key = method ?
  6010. heir[i].replace('()', '') :
  6011. heir[i];
  6012. var src = find( struct, key );
  6013. if ( ! src ) {
  6014. src = {
  6015. name: key,
  6016. val: {},
  6017. methodExt: [],
  6018. propExt: []
  6019. };
  6020. struct.push( src );
  6021. }
  6022. if ( i === ien-1 ) {
  6023. src.val = val;
  6024. }
  6025. else {
  6026. struct = method ?
  6027. src.methodExt :
  6028. src.propExt;
  6029. }
  6030. }
  6031. };
  6032. _Api.registerPlural = _api_registerPlural = function ( pluralName, singularName, val ) {
  6033. _Api.register( pluralName, val );
  6034. _Api.register( singularName, function () {
  6035. var ret = val.apply( this, arguments );
  6036. if ( ret === this ) {
  6037. // Returned item is the API instance that was passed in, return it
  6038. return this;
  6039. }
  6040. else if ( ret instanceof _Api ) {
  6041. // New API instance returned, want the value from the first item
  6042. // in the returned array for the singular result.
  6043. return ret.length ?
  6044. $.isArray( ret[0] ) ?
  6045. new _Api( ret.context, ret[0] ) : // Array results are 'enhanced'
  6046. ret[0] :
  6047. undefined;
  6048. }
  6049. // Non-API return - just fire it back
  6050. return ret;
  6051. } );
  6052. };
  6053. /**
  6054. * Selector for HTML tables. Apply the given selector to the give array of
  6055. * DataTables settings objects.
  6056. *
  6057. * @param {string|integer} [selector] jQuery selector string or integer
  6058. * @param {array} Array of DataTables settings objects to be filtered
  6059. * @return {array}
  6060. * @ignore
  6061. */
  6062. var __table_selector = function ( selector, a )
  6063. {
  6064. // Integer is used to pick out a table by index
  6065. if ( typeof selector === 'number' ) {
  6066. return [ a[ selector ] ];
  6067. }
  6068. // Perform a jQuery selector on the table nodes
  6069. var nodes = $.map( a, function (el, i) {
  6070. return el.nTable;
  6071. } );
  6072. return $(nodes)
  6073. .filter( selector )
  6074. .map( function (i) {
  6075. // Need to translate back from the table node to the settings
  6076. var idx = $.inArray( this, nodes );
  6077. return a[ idx ];
  6078. } )
  6079. .toArray();
  6080. };
  6081. /**
  6082. * Context selector for the API's context (i.e. the tables the API instance
  6083. * refers to.
  6084. *
  6085. * @name DataTable.Api#tables
  6086. * @param {string|integer} [selector] Selector to pick which tables the iterator
  6087. * should operate on. If not given, all tables in the current context are
  6088. * used. This can be given as a jQuery selector (for example `':gt(0)'`) to
  6089. * select multiple tables or as an integer to select a single table.
  6090. * @returns {DataTable.Api} Returns a new API instance if a selector is given.
  6091. */
  6092. _api_register( 'tables()', function ( selector ) {
  6093. // A new instance is created if there was a selector specified
  6094. return selector ?
  6095. new _Api( __table_selector( selector, this.context ) ) :
  6096. this;
  6097. } );
  6098. _api_register( 'table()', function ( selector ) {
  6099. var tables = this.tables( selector );
  6100. var ctx = tables.context;
  6101. // Truncate to the first matched table
  6102. return ctx.length ?
  6103. new _Api( ctx[0] ) :
  6104. tables;
  6105. } );
  6106. _api_registerPlural( 'tables().nodes()', 'table().node()' , function () {
  6107. return this.iterator( 'table', function ( ctx ) {
  6108. return ctx.nTable;
  6109. } );
  6110. } );
  6111. _api_registerPlural( 'tables().body()', 'table().body()' , function () {
  6112. return this.iterator( 'table', function ( ctx ) {
  6113. return ctx.nTBody;
  6114. } );
  6115. } );
  6116. _api_registerPlural( 'tables().header()', 'table().header()' , function () {
  6117. return this.iterator( 'table', function ( ctx ) {
  6118. return ctx.nTHead;
  6119. } );
  6120. } );
  6121. _api_registerPlural( 'tables().footer()', 'table().footer()' , function () {
  6122. return this.iterator( 'table', function ( ctx ) {
  6123. return ctx.nTFoot;
  6124. } );
  6125. } );
  6126. _api_registerPlural( 'tables().containers()', 'table().container()' , function () {
  6127. return this.iterator( 'table', function ( ctx ) {
  6128. return ctx.nTableWrapper;
  6129. } );
  6130. } );
  6131. /**
  6132. * Redraw the tables in the current context.
  6133. *
  6134. * @param {boolean} [reset=true] Reset (default) or hold the current paging
  6135. * position. A full re-sort and re-filter is performed when this method is
  6136. * called, which is why the pagination reset is the default action.
  6137. * @returns {DataTables.Api} this
  6138. */
  6139. _api_register( 'draw()', function ( resetPaging ) {
  6140. return this.iterator( 'table', function ( settings ) {
  6141. _fnReDraw( settings, resetPaging===false );
  6142. } );
  6143. } );
  6144. /**
  6145. * Get the current page index.
  6146. *
  6147. * @return {integer} Current page index (zero based)
  6148. *//**
  6149. * Set the current page.
  6150. *
  6151. * Note that if you attempt to show a page which does not exist, DataTables will
  6152. * not throw an error, but rather reset the paging.
  6153. *
  6154. * @param {integer|string} action The paging action to take. This can be one of:
  6155. * * `integer` - The page index to jump to
  6156. * * `string` - An action to take:
  6157. * * `first` - Jump to first page.
  6158. * * `next` - Jump to the next page
  6159. * * `previous` - Jump to previous page
  6160. * * `last` - Jump to the last page.
  6161. * @returns {DataTables.Api} this
  6162. */
  6163. _api_register( 'page()', function ( action ) {
  6164. if ( action === undefined ) {
  6165. return this.page.info().page; // not an expensive call
  6166. }
  6167. // else, have an action to take on all tables
  6168. return this.iterator( 'table', function ( settings ) {
  6169. _fnPageChange( settings, action );
  6170. } );
  6171. } );
  6172. /**
  6173. * Paging information for the first table in the current context.
  6174. *
  6175. * If you require paging information for another table, use the `table()` method
  6176. * with a suitable selector.
  6177. *
  6178. * @return {object} Object with the following properties set:
  6179. * * `page` - Current page index (zero based - i.e. the first page is `0`)
  6180. * * `pages` - Total number of pages
  6181. * * `start` - Display index for the first record shown on the current page
  6182. * * `end` - Display index for the last record shown on the current page
  6183. * * `length` - Display length (number of records). Note that generally `start
  6184. * + length = end`, but this is not always true, for example if there are
  6185. * only 2 records to show on the final page, with a length of 10.
  6186. * * `recordsTotal` - Full data set length
  6187. * * `recordsDisplay` - Data set length once the current filtering criterion
  6188. * are applied.
  6189. */
  6190. _api_register( 'page.info()', function ( action ) {
  6191. if ( this.context.length === 0 ) {
  6192. return undefined;
  6193. }
  6194. var
  6195. settings = this.context[0],
  6196. start = settings._iDisplayStart,
  6197. len = settings._iDisplayLength,
  6198. visRecords = settings.fnRecordsDisplay(),
  6199. all = len === -1;
  6200. return {
  6201. "page": all ? 0 : Math.floor( start / len ),
  6202. "pages": all ? 1 : Math.ceil( visRecords / len ),
  6203. "start": start,
  6204. "end": settings.fnDisplayEnd(),
  6205. "length": len,
  6206. "recordsTotal": settings.fnRecordsTotal(),
  6207. "recordsDisplay": visRecords
  6208. };
  6209. } );
  6210. /**
  6211. * Get the current page length.
  6212. *
  6213. * @return {integer} Current page length. Note `-1` indicates that all records
  6214. * are to be shown.
  6215. *//**
  6216. * Set the current page length.
  6217. *
  6218. * @param {integer} Page length to set. Use `-1` to show all records.
  6219. * @returns {DataTables.Api} this
  6220. */
  6221. _api_register( 'page.len()', function ( len ) {
  6222. // Note that we can't call this function 'length()' because `length`
  6223. // is a Javascript property of functions which defines how many arguments
  6224. // the function expects.
  6225. if ( len === undefined ) {
  6226. return this.context.length !== 0 ?
  6227. this.context[0]._iDisplayLength :
  6228. undefined;
  6229. }
  6230. // else, set the page length
  6231. return this.iterator( 'table', function ( settings ) {
  6232. _fnLengthChange( settings, len );
  6233. } );
  6234. } );
  6235. var __reload = function ( settings, holdPosition, callback ) {
  6236. if ( _fnDataSource( settings ) == 'ssp' ) {
  6237. _fnReDraw( settings, holdPosition );
  6238. }
  6239. else {
  6240. // Trigger xhr
  6241. _fnProcessingDisplay( settings, true );
  6242. _fnBuildAjax( settings, [], function( json ) {
  6243. _fnClearTable( settings );
  6244. var data = _fnAjaxDataSrc( settings, json );
  6245. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6246. _fnAddData( settings, data[i] );
  6247. }
  6248. _fnReDraw( settings, holdPosition );
  6249. _fnProcessingDisplay( settings, false );
  6250. } );
  6251. }
  6252. // Use the draw event to trigger a callback, regardless of if it is an async
  6253. // or sync draw
  6254. if ( callback ) {
  6255. var api = new _Api( settings );
  6256. api.one( 'draw', function () {
  6257. callback( api.ajax.json() );
  6258. } );
  6259. }
  6260. };
  6261. /**
  6262. * Get the JSON response from the last Ajax request that DataTables made to the
  6263. * server. Note that this returns the JSON from the first table in the current
  6264. * context.
  6265. *
  6266. * @return {object} JSON received from the server.
  6267. */
  6268. _api_register( 'ajax.json()', function () {
  6269. var ctx = this.context;
  6270. if ( ctx.length > 0 ) {
  6271. return ctx[0].json;
  6272. }
  6273. // else return undefined;
  6274. } );
  6275. /**
  6276. * Get the data submitted in the last Ajax request
  6277. */
  6278. _api_register( 'ajax.params()', function () {
  6279. var ctx = this.context;
  6280. if ( ctx.length > 0 ) {
  6281. return ctx[0].oAjaxData;
  6282. }
  6283. // else return undefined;
  6284. } );
  6285. /**
  6286. * Reload tables from the Ajax data source. Note that this function will
  6287. * automatically re-draw the table when the remote data has been loaded.
  6288. *
  6289. * @param {boolean} [reset=true] Reset (default) or hold the current paging
  6290. * position. A full re-sort and re-filter is performed when this method is
  6291. * called, which is why the pagination reset is the default action.
  6292. * @returns {DataTables.Api} this
  6293. */
  6294. _api_register( 'ajax.reload()', function ( callback, resetPaging ) {
  6295. return this.iterator( 'table', function (settings) {
  6296. __reload( settings, resetPaging===false, callback );
  6297. } );
  6298. } );
  6299. /**
  6300. * Get the current Ajax URL. Note that this returns the URL from the first
  6301. * table in the current context.
  6302. *
  6303. * @return {string} Current Ajax source URL
  6304. *//**
  6305. * Set the Ajax URL. Note that this will set the URL for all tables in the
  6306. * current context.
  6307. *
  6308. * @param {string} url URL to set.
  6309. * @returns {DataTables.Api} this
  6310. */
  6311. _api_register( 'ajax.url()', function ( url ) {
  6312. var ctx = this.context;
  6313. if ( url === undefined ) {
  6314. // get
  6315. if ( ctx.length === 0 ) {
  6316. return undefined;
  6317. }
  6318. ctx = ctx[0];
  6319. return ctx.ajax ?
  6320. $.isPlainObject( ctx.ajax ) ?
  6321. ctx.ajax.url :
  6322. ctx.ajax :
  6323. ctx.sAjaxSource;
  6324. }
  6325. // set
  6326. return this.iterator( 'table', function ( settings ) {
  6327. if ( $.isPlainObject( settings.ajax ) ) {
  6328. settings.ajax.url = url;
  6329. }
  6330. else {
  6331. settings.ajax = url;
  6332. }
  6333. // No need to consider sAjaxSource here since DataTables gives priority
  6334. // to `ajax` over `sAjaxSource`. So setting `ajax` here, renders any
  6335. // value of `sAjaxSource` redundant.
  6336. } );
  6337. } );
  6338. /**
  6339. * Load data from the newly set Ajax URL. Note that this method is only
  6340. * available when `ajax.url()` is used to set a URL. Additionally, this method
  6341. * has the same effect as calling `ajax.reload()` but is provided for
  6342. * convenience when setting a new URL. Like `ajax.reload()` it will
  6343. * automatically redraw the table once the remote data has been loaded.
  6344. *
  6345. * @returns {DataTables.Api} this
  6346. */
  6347. _api_register( 'ajax.url().load()', function ( callback, resetPaging ) {
  6348. // Same as a reload, but makes sense to present it for easy access after a
  6349. // url change
  6350. return this.iterator( 'table', function ( ctx ) {
  6351. __reload( ctx, resetPaging===false, callback );
  6352. } );
  6353. } );
  6354. var _selector_run = function ( selector, select )
  6355. {
  6356. var
  6357. out = [], res,
  6358. a, i, ien, j, jen,
  6359. selectorType = typeof selector;
  6360. // Can't just check for isArray here, as an API or jQuery instance might be
  6361. // given with their array like look
  6362. if ( ! selector || selectorType === 'string' || selectorType === 'function' || selector.length === undefined ) {
  6363. selector = [ selector ];
  6364. }
  6365. for ( i=0, ien=selector.length ; i<ien ; i++ ) {
  6366. a = selector[i] && selector[i].split ?
  6367. selector[i].split(',') :
  6368. [ selector[i] ];
  6369. for ( j=0, jen=a.length ; j<jen ; j++ ) {
  6370. res = select( typeof a[j] === 'string' ? $.trim(a[j]) : a[j] );
  6371. if ( res && res.length ) {
  6372. out.push.apply( out, res );
  6373. }
  6374. }
  6375. }
  6376. return out;
  6377. };
  6378. var _selector_opts = function ( opts )
  6379. {
  6380. if ( ! opts ) {
  6381. opts = {};
  6382. }
  6383. // Backwards compatibility for 1.9- which used the terminology filter rather
  6384. // than search
  6385. if ( opts.filter && ! opts.search ) {
  6386. opts.search = opts.filter;
  6387. }
  6388. return {
  6389. search: opts.search || 'none',
  6390. order: opts.order || 'current',
  6391. page: opts.page || 'all'
  6392. };
  6393. };
  6394. var _selector_first = function ( inst )
  6395. {
  6396. // Reduce the API instance to the first item found
  6397. for ( var i=0, ien=inst.length ; i<ien ; i++ ) {
  6398. if ( inst[i].length > 0 ) {
  6399. // Assign the first element to the first item in the instance
  6400. // and truncate the instance and context
  6401. inst[0] = inst[i];
  6402. inst.length = 1;
  6403. inst.context = [ inst.context[i] ];
  6404. return inst;
  6405. }
  6406. }
  6407. // Not found - return an empty instance
  6408. inst.length = 0;
  6409. return inst;
  6410. };
  6411. var _selector_row_indexes = function ( settings, opts )
  6412. {
  6413. var
  6414. i, ien, tmp, a=[],
  6415. displayFiltered = settings.aiDisplay,
  6416. displayMaster = settings.aiDisplayMaster;
  6417. var
  6418. search = opts.search, // none, applied, removed
  6419. order = opts.order, // applied, current, index (original - compatibility with 1.9)
  6420. page = opts.page; // all, current
  6421. if ( _fnDataSource( settings ) == 'ssp' ) {
  6422. // In server-side processing mode, most options are irrelevant since
  6423. // rows not shown don't exist and the index order is the applied order
  6424. // Removed is a special case - for consistency just return an empty
  6425. // array
  6426. return search === 'removed' ?
  6427. [] :
  6428. _range( 0, displayMaster.length );
  6429. }
  6430. else if ( page == 'current' ) {
  6431. // Current page implies that order=current and fitler=applied, since it is
  6432. // fairly senseless otherwise, regardless of what order and search actually
  6433. // are
  6434. for ( i=settings._iDisplayStart, ien=settings.fnDisplayEnd() ; i<ien ; i++ ) {
  6435. a.push( displayFiltered[i] );
  6436. }
  6437. }
  6438. else if ( order == 'current' || order == 'applied' ) {
  6439. a = search == 'none' ?
  6440. displayMaster.slice() : // no search
  6441. search == 'applied' ?
  6442. displayFiltered.slice() : // applied search
  6443. $.map( displayMaster, function (el, i) { // removed search
  6444. return $.inArray( el, displayFiltered ) === -1 ? el : null;
  6445. } );
  6446. }
  6447. else if ( order == 'index' || order == 'original' ) {
  6448. for ( i=0, ien=settings.aoData.length ; i<ien ; i++ ) {
  6449. if ( search == 'none' ) {
  6450. a.push( i );
  6451. }
  6452. else { // applied | removed
  6453. tmp = $.inArray( i, displayFiltered );
  6454. if ((tmp === -1 && search == 'removed') ||
  6455. (tmp >= 0 && search == 'applied') )
  6456. {
  6457. a.push( i );
  6458. }
  6459. }
  6460. }
  6461. }
  6462. return a;
  6463. };
  6464. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6465. * Rows
  6466. *
  6467. * {} - no selector - use all available rows
  6468. * {integer} - row aoData index
  6469. * {node} - TR node
  6470. * {string} - jQuery selector to apply to the TR elements
  6471. * {array} - jQuery array of nodes, or simply an array of TR nodes
  6472. *
  6473. */
  6474. var __row_selector = function ( settings, selector, opts )
  6475. {
  6476. return _selector_run( selector, function ( sel ) {
  6477. var selInt = _intVal( sel );
  6478. var i, ien;
  6479. // Short cut - selector is a number and no options provided (default is
  6480. // all records, so no need to check if the index is in there, since it
  6481. // must be - dev error if the index doesn't exist).
  6482. if ( selInt !== null && ! opts ) {
  6483. return [ selInt ];
  6484. }
  6485. var rows = _selector_row_indexes( settings, opts );
  6486. if ( selInt !== null && $.inArray( selInt, rows ) !== -1 ) {
  6487. // Selector - integer
  6488. return [ selInt ];
  6489. }
  6490. else if ( ! sel ) {
  6491. // Selector - none
  6492. return rows;
  6493. }
  6494. // Get nodes in the order from the `rows` array
  6495. var nodes = _pluck_order( settings.aoData, rows, 'nTr' );
  6496. // Selector - function
  6497. if ( typeof sel === 'function' ) {
  6498. return $.map( rows, function (idx) {
  6499. var row = settings.aoData[ idx ];
  6500. return sel( idx, row._aData, row.nTr ) ? idx : null;
  6501. } );
  6502. }
  6503. // Selector - node
  6504. if ( sel.nodeName ) {
  6505. if ( $.inArray( sel, nodes ) !== -1 ) {
  6506. return [ sel._DT_RowIndex ];// sel is a TR node that is in the table
  6507. // and DataTables adds a prop for fast lookup
  6508. }
  6509. }
  6510. // Selector - jQuery selector string, array of nodes or jQuery object/
  6511. // As jQuery's .filter() allows jQuery objects to be passed in filter,
  6512. // it also allows arrays, so this will cope with all three options
  6513. return $(nodes)
  6514. .filter( sel )
  6515. .map( function () {
  6516. return this._DT_RowIndex;
  6517. } )
  6518. .toArray();
  6519. } );
  6520. };
  6521. /**
  6522. *
  6523. */
  6524. _api_register( 'rows()', function ( selector, opts ) {
  6525. // argument shifting
  6526. if ( selector === undefined ) {
  6527. selector = '';
  6528. }
  6529. else if ( $.isPlainObject( selector ) ) {
  6530. opts = selector;
  6531. selector = '';
  6532. }
  6533. opts = _selector_opts( opts );
  6534. var inst = this.iterator( 'table', function ( settings ) {
  6535. return __row_selector( settings, selector, opts );
  6536. } );
  6537. // Want argument shifting here and in __row_selector?
  6538. inst.selector.rows = selector;
  6539. inst.selector.opts = opts;
  6540. return inst;
  6541. } );
  6542. _api_register( 'rows().nodes()', function () {
  6543. return this.iterator( 'row', function ( settings, row ) {
  6544. return settings.aoData[ row ].nTr || undefined;
  6545. } );
  6546. } );
  6547. _api_register( 'rows().data()', function () {
  6548. return this.iterator( true, 'rows', function ( settings, rows ) {
  6549. return _pluck_order( settings.aoData, rows, '_aData' );
  6550. } );
  6551. } );
  6552. _api_registerPlural( 'rows().cache()', 'row().cache()', function ( type ) {
  6553. return this.iterator( 'row', function ( settings, row ) {
  6554. var r = settings.aoData[ row ];
  6555. return type === 'search' ? r._aFilterData : r._aSortData;
  6556. } );
  6557. } );
  6558. _api_registerPlural( 'rows().invalidate()', 'row().invalidate()', function ( src ) {
  6559. return this.iterator( 'row', function ( settings, row ) {
  6560. _fnInvalidateRow( settings, row, src );
  6561. } );
  6562. } );
  6563. _api_registerPlural( 'rows().indexes()', 'row().index()', function () {
  6564. return this.iterator( 'row', function ( settings, row ) {
  6565. return row;
  6566. } );
  6567. } );
  6568. _api_registerPlural( 'rows().remove()', 'row().remove()', function () {
  6569. var that = this;
  6570. return this.iterator( 'row', function ( settings, row, thatIdx ) {
  6571. var data = settings.aoData;
  6572. data.splice( row, 1 );
  6573. // Update the _DT_RowIndex parameter on all rows in the table
  6574. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6575. if ( data[i].nTr !== null ) {
  6576. data[i].nTr._DT_RowIndex = i;
  6577. }
  6578. }
  6579. // Remove the target row from the search array
  6580. var displayIndex = $.inArray( row, settings.aiDisplay );
  6581. // Delete from the display arrays
  6582. _fnDeleteIndex( settings.aiDisplayMaster, row );
  6583. _fnDeleteIndex( settings.aiDisplay, row );
  6584. _fnDeleteIndex( that[ thatIdx ], row, false ); // maintain local indexes
  6585. // Check for an 'overflow' they case for displaying the table
  6586. _fnLengthOverflow( settings );
  6587. } );
  6588. } );
  6589. _api_register( 'rows.add()', function ( rows ) {
  6590. var newRows = this.iterator( 'table', function ( settings ) {
  6591. var row, i, ien;
  6592. var out = [];
  6593. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  6594. row = rows[i];
  6595. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  6596. out.push( _fnAddTr( settings, row )[0] );
  6597. }
  6598. else {
  6599. out.push( _fnAddData( settings, row ) );
  6600. }
  6601. }
  6602. return out;
  6603. } );
  6604. // Return an Api.rows() extended instance, so rows().nodes() etc can be used
  6605. var modRows = this.rows( -1 );
  6606. modRows.pop();
  6607. modRows.push.apply( modRows, newRows.toArray() );
  6608. return modRows;
  6609. } );
  6610. /**
  6611. *
  6612. */
  6613. _api_register( 'row()', function ( selector, opts ) {
  6614. return _selector_first( this.rows( selector, opts ) );
  6615. } );
  6616. _api_register( 'row().data()', function ( data ) {
  6617. var ctx = this.context;
  6618. if ( data === undefined ) {
  6619. // Get
  6620. return ctx.length && this.length ?
  6621. ctx[0].aoData[ this[0] ]._aData :
  6622. undefined;
  6623. }
  6624. // Set
  6625. ctx[0].aoData[ this[0] ]._aData = data;
  6626. // Automatically invalidate
  6627. _fnInvalidateRow( ctx[0], this[0], 'data' );
  6628. return this;
  6629. } );
  6630. _api_register( 'row().node()', function () {
  6631. var ctx = this.context;
  6632. return ctx.length && this.length ?
  6633. ctx[0].aoData[ this[0] ].nTr || null :
  6634. null;
  6635. } );
  6636. _api_register( 'row.add()', function ( row ) {
  6637. // Allow a jQuery object to be passed in - only a single row is added from
  6638. // it though - the first element in the set
  6639. if ( row instanceof $ && row.length ) {
  6640. row = row[0];
  6641. }
  6642. var rows = this.iterator( 'table', function ( settings ) {
  6643. if ( row.nodeName && row.nodeName.toUpperCase() === 'TR' ) {
  6644. return _fnAddTr( settings, row )[0];
  6645. }
  6646. return _fnAddData( settings, row );
  6647. } );
  6648. // Return an Api.rows() extended instance, with the newly added row selected
  6649. return this.row( rows[0] );
  6650. } );
  6651. var __details_add = function ( ctx, row, data, klass )
  6652. {
  6653. // Convert to array of TR elements
  6654. var rows = [];
  6655. var addRow = function ( r, k ) {
  6656. // If we get a TR element, then just add it directly - up to the dev
  6657. // to add the correct number of columns etc
  6658. if ( r.nodeName && r.nodeName.toLowerCase() === 'tr' ) {
  6659. rows.push( r );
  6660. }
  6661. else {
  6662. // Otherwise create a row with a wrapper
  6663. var created = $('<tr><td/></tr>').addClass( k );
  6664. $('td', created)
  6665. .addClass( k )
  6666. .html( r )
  6667. [0].colSpan = _fnVisbleColumns( ctx );
  6668. rows.push( created[0] );
  6669. }
  6670. };
  6671. if ( $.isArray( data ) || data instanceof $ ) {
  6672. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6673. addRow( data[i], klass );
  6674. }
  6675. }
  6676. else {
  6677. addRow( data, klass );
  6678. }
  6679. if ( row._details ) {
  6680. row._details.remove();
  6681. }
  6682. row._details = $(rows);
  6683. // If the children were already shown, that state should be retained
  6684. if ( row._detailsShow ) {
  6685. row._details.insertAfter( row.nTr );
  6686. }
  6687. };
  6688. var __details_remove = function ( api, idx )
  6689. {
  6690. var ctx = api.context;
  6691. if ( ctx.length ) {
  6692. var row = ctx[0].aoData[ idx !== undefined ? idx : api[0] ];
  6693. if ( row._details ) {
  6694. row._details.remove();
  6695. row._detailsShow = undefined;
  6696. row._details = undefined;
  6697. }
  6698. }
  6699. };
  6700. var __details_display = function ( api, show ) {
  6701. var ctx = api.context;
  6702. if ( ctx.length && api.length ) {
  6703. var row = ctx[0].aoData[ api[0] ];
  6704. if ( row._details ) {
  6705. row._detailsShow = show;
  6706. if ( show ) {
  6707. row._details.insertAfter( row.nTr );
  6708. }
  6709. else {
  6710. row._details.detach();
  6711. }
  6712. __details_events( ctx[0] );
  6713. }
  6714. }
  6715. };
  6716. var __details_events = function ( settings )
  6717. {
  6718. var api = new _Api( settings );
  6719. var namespace = '.dt.DT_details';
  6720. var drawEvent = 'draw'+namespace;
  6721. var colvisEvent = 'column-visibility'+namespace;
  6722. var destroyEvent = 'destroy'+namespace;
  6723. var data = settings.aoData;
  6724. api.off( drawEvent +' '+ colvisEvent +' '+ destroyEvent );
  6725. if ( _pluck( data, '_details' ).length > 0 ) {
  6726. // On each draw, insert the required elements into the document
  6727. api.on( drawEvent, function ( e, ctx ) {
  6728. if ( settings !== ctx ) {
  6729. return;
  6730. }
  6731. api.rows( {page:'current'} ).eq(0).each( function (idx) {
  6732. // Internal data grab
  6733. var row = data[ idx ];
  6734. if ( row._detailsShow ) {
  6735. row._details.insertAfter( row.nTr );
  6736. }
  6737. } );
  6738. } );
  6739. // Column visibility change - update the colspan
  6740. api.on( colvisEvent, function ( e, ctx, idx, vis ) {
  6741. if ( settings !== ctx ) {
  6742. return;
  6743. }
  6744. // Update the colspan for the details rows (note, only if it already has
  6745. // a colspan)
  6746. var row, visible = _fnVisbleColumns( ctx );
  6747. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6748. row = data[i];
  6749. if ( row._details ) {
  6750. row._details.children('td[colspan]').attr('colspan', visible );
  6751. }
  6752. }
  6753. } );
  6754. // Table destroyed - nuke any child rows
  6755. api.on( destroyEvent, function ( e, ctx ) {
  6756. if ( settings !== ctx ) {
  6757. return;
  6758. }
  6759. for ( var i=0, ien=data.length ; i<ien ; i++ ) {
  6760. if ( data[i]._details ) {
  6761. __details_remove( api, i );
  6762. }
  6763. }
  6764. } );
  6765. }
  6766. };
  6767. // Strings for the method names to help minification
  6768. var _emp = '';
  6769. var _child_obj = _emp+'row().child';
  6770. var _child_mth = _child_obj+'()';
  6771. // data can be:
  6772. // tr
  6773. // string
  6774. // jQuery or array of any of the above
  6775. _api_register( _child_mth, function ( data, klass ) {
  6776. var ctx = this.context;
  6777. if ( data === undefined ) {
  6778. // get
  6779. return ctx.length && this.length ?
  6780. ctx[0].aoData[ this[0] ]._details :
  6781. undefined;
  6782. }
  6783. else if ( data === true ) {
  6784. // show
  6785. this.child.show();
  6786. }
  6787. else if ( data === false ) {
  6788. // remove
  6789. __details_remove( this );
  6790. }
  6791. else if ( ctx.length && this.length ) {
  6792. // set
  6793. __details_add( ctx[0], ctx[0].aoData[ this[0] ], data, klass );
  6794. }
  6795. return this;
  6796. } );
  6797. _api_register( [
  6798. _child_obj+'.show()',
  6799. _child_mth+'.show()' // only when `child()` was called with parameters (without
  6800. ], function ( show ) { // it returns an object and this method is not executed)
  6801. __details_display( this, true );
  6802. return this;
  6803. } );
  6804. _api_register( [
  6805. _child_obj+'.hide()',
  6806. _child_mth+'.hide()' // only when `child()` was called with parameters (without
  6807. ], function () { // it returns an object and this method is not executed)
  6808. __details_display( this, false );
  6809. return this;
  6810. } );
  6811. _api_register( [
  6812. _child_obj+'.remove()',
  6813. _child_mth+'.remove()' // only when `child()` was called with parameters (without
  6814. ], function () { // it returns an object and this method is not executed)
  6815. __details_remove( this );
  6816. return this;
  6817. } );
  6818. _api_register( _child_obj+'.isShown()', function () {
  6819. var ctx = this.context;
  6820. if ( ctx.length && this.length ) {
  6821. // _detailsShown as false or undefined will fall through to return false
  6822. return ctx[0].aoData[ this[0] ]._detailsShow || false;
  6823. }
  6824. return false;
  6825. } );
  6826. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  6827. * Columns
  6828. *
  6829. * {integer} - column index (>=0 count from left, <0 count from right)
  6830. * "{integer}:visIdx" - visible column index (i.e. translate to column index) (>=0 count from left, <0 count from right)
  6831. * "{integer}:visible" - alias for {integer}:visIdx (>=0 count from left, <0 count from right)
  6832. * "{string}:name" - column name
  6833. * "{string}" - jQuery selector on column header nodes
  6834. *
  6835. */
  6836. // can be an array of these items, comma separated list, or an array of comma
  6837. // separated lists
  6838. var __re_column_selector = /^(.+):(name|visIdx|visible)$/;
  6839. // r1 and r2 are redundant - but it means that the parameters match for the
  6840. // iterator callback in columns().data()
  6841. var __columnData = function ( settings, column, r1, r2, rows ) {
  6842. var a = [];
  6843. for ( var row=0, ien=rows.length ; row<ien ; row++ ) {
  6844. a.push( _fnGetCellData( settings, rows[row], column ) );
  6845. }
  6846. return a;
  6847. };
  6848. var __column_selector = function ( settings, selector, opts )
  6849. {
  6850. var
  6851. columns = settings.aoColumns,
  6852. names = _pluck( columns, 'sName' ),
  6853. nodes = _pluck( columns, 'nTh' );
  6854. return _selector_run( selector, function ( s ) {
  6855. var selInt = _intVal( s );
  6856. // Selector - all
  6857. if ( s === '' ) {
  6858. return _range( columns.length );
  6859. }
  6860. // Selector - index
  6861. if ( selInt !== null ) {
  6862. return [ selInt >= 0 ?
  6863. selInt : // Count from left
  6864. columns.length + selInt // Count from right (+ because its a negative value)
  6865. ];
  6866. }
  6867. // Selector = function
  6868. if ( typeof s === 'function' ) {
  6869. var rows = _selector_row_indexes( settings, opts );
  6870. return $.map( columns, function (col, idx) {
  6871. return s(
  6872. idx,
  6873. __columnData( settings, idx, 0, 0, rows ),
  6874. nodes[ idx ]
  6875. ) ? idx : null;
  6876. } );
  6877. }
  6878. // jQuery or string selector
  6879. var match = typeof s === 'string' ?
  6880. s.match( __re_column_selector ) :
  6881. '';
  6882. if ( match ) {
  6883. switch( match[2] ) {
  6884. case 'visIdx':
  6885. case 'visible':
  6886. var idx = parseInt( match[1], 10 );
  6887. // Visible index given, convert to column index
  6888. if ( idx < 0 ) {
  6889. // Counting from the right
  6890. var visColumns = $.map( columns, function (col,i) {
  6891. return col.bVisible ? i : null;
  6892. } );
  6893. return [ visColumns[ visColumns.length + idx ] ];
  6894. }
  6895. // Counting from the left
  6896. return [ _fnVisibleToColumnIndex( settings, idx ) ];
  6897. case 'name':
  6898. // match by name. `names` is column index complete and in order
  6899. return $.map( names, function (name, i) {
  6900. return name === match[1] ? i : null;
  6901. } );
  6902. }
  6903. }
  6904. else {
  6905. // jQuery selector on the TH elements for the columns
  6906. return $( nodes )
  6907. .filter( s )
  6908. .map( function () {
  6909. return $.inArray( this, nodes ); // `nodes` is column index complete and in order
  6910. } )
  6911. .toArray();
  6912. }
  6913. } );
  6914. };
  6915. var __setColumnVis = function ( settings, column, vis, recalc ) {
  6916. var
  6917. cols = settings.aoColumns,
  6918. col = cols[ column ],
  6919. data = settings.aoData,
  6920. row, cells, i, ien, tr;
  6921. // Get
  6922. if ( vis === undefined ) {
  6923. return col.bVisible;
  6924. }
  6925. // Set
  6926. // No change
  6927. if ( col.bVisible === vis ) {
  6928. return;
  6929. }
  6930. if ( vis ) {
  6931. // Insert column
  6932. // Need to decide if we should use appendChild or insertBefore
  6933. var insertBefore = $.inArray( true, _pluck(cols, 'bVisible'), column+1 );
  6934. for ( i=0, ien=data.length ; i<ien ; i++ ) {
  6935. tr = data[i].nTr;
  6936. cells = data[i].anCells;
  6937. if ( tr ) {
  6938. // insertBefore can act like appendChild if 2nd arg is null
  6939. tr.insertBefore( cells[ column ], cells[ insertBefore ] || null );
  6940. }
  6941. }
  6942. }
  6943. else {
  6944. // Remove column
  6945. $( _pluck( settings.aoData, 'anCells', column ) ).detach();
  6946. }
  6947. // Common actions
  6948. col.bVisible = vis;
  6949. _fnDrawHead( settings, settings.aoHeader );
  6950. _fnDrawHead( settings, settings.aoFooter );
  6951. if ( recalc === undefined || recalc ) {
  6952. // Automatically adjust column sizing
  6953. _fnAdjustColumnSizing( settings );
  6954. // Realign columns for scrolling
  6955. if ( settings.oScroll.sX || settings.oScroll.sY ) {
  6956. _fnScrollDraw( settings );
  6957. }
  6958. }
  6959. _fnCallbackFire( settings, null, 'column-visibility', [settings, column, vis] );
  6960. _fnSaveState( settings );
  6961. };
  6962. /**
  6963. *
  6964. */
  6965. _api_register( 'columns()', function ( selector, opts ) {
  6966. // argument shifting
  6967. if ( selector === undefined ) {
  6968. selector = '';
  6969. }
  6970. else if ( $.isPlainObject( selector ) ) {
  6971. opts = selector;
  6972. selector = '';
  6973. }
  6974. opts = _selector_opts( opts );
  6975. var inst = this.iterator( 'table', function ( settings ) {
  6976. return __column_selector( settings, selector, opts );
  6977. } );
  6978. // Want argument shifting here and in _row_selector?
  6979. inst.selector.cols = selector;
  6980. inst.selector.opts = opts;
  6981. return inst;
  6982. } );
  6983. /**
  6984. *
  6985. */
  6986. _api_registerPlural( 'columns().header()', 'column().header()', function ( selector, opts ) {
  6987. return this.iterator( 'column', function ( settings, column ) {
  6988. return settings.aoColumns[column].nTh;
  6989. } );
  6990. } );
  6991. /**
  6992. *
  6993. */
  6994. _api_registerPlural( 'columns().footer()', 'column().footer()', function ( selector, opts ) {
  6995. return this.iterator( 'column', function ( settings, column ) {
  6996. return settings.aoColumns[column].nTf;
  6997. } );
  6998. } );
  6999. /**
  7000. *
  7001. */
  7002. _api_registerPlural( 'columns().data()', 'column().data()', function () {
  7003. return this.iterator( 'column-rows', __columnData );
  7004. } );
  7005. _api_registerPlural( 'columns().dataSrc()', 'column().dataSrc()', function () {
  7006. return this.iterator( 'column', function ( settings, column ) {
  7007. return settings.aoColumns[column].mData;
  7008. } );
  7009. } );
  7010. _api_registerPlural( 'columns().cache()', 'column().cache()', function ( type ) {
  7011. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7012. return _pluck_order( settings.aoData, rows,
  7013. type === 'search' ? '_aFilterData' : '_aSortData', column
  7014. );
  7015. } );
  7016. } );
  7017. _api_registerPlural( 'columns().nodes()', 'column().nodes()', function () {
  7018. return this.iterator( 'column-rows', function ( settings, column, i, j, rows ) {
  7019. return _pluck_order( settings.aoData, rows, 'anCells', column ) ;
  7020. } );
  7021. } );
  7022. _api_registerPlural( 'columns().visible()', 'column().visible()', function ( vis, calc ) {
  7023. return this.iterator( 'column', function ( settings, column ) {
  7024. return vis === undefined ?
  7025. settings.aoColumns[ column ].bVisible :
  7026. __setColumnVis( settings, column, vis, calc );
  7027. } );
  7028. } );
  7029. _api_registerPlural( 'columns().indexes()', 'column().index()', function ( type ) {
  7030. return this.iterator( 'column', function ( settings, column ) {
  7031. return type === 'visible' ?
  7032. _fnColumnIndexToVisible( settings, column ) :
  7033. column;
  7034. } );
  7035. } );
  7036. // _api_register( 'columns().show()', function () {
  7037. // var selector = this.selector;
  7038. // return this.columns( selector.cols, selector.opts ).visible( true );
  7039. // } );
  7040. // _api_register( 'columns().hide()', function () {
  7041. // var selector = this.selector;
  7042. // return this.columns( selector.cols, selector.opts ).visible( false );
  7043. // } );
  7044. _api_register( 'columns.adjust()', function () {
  7045. return this.iterator( 'table', function ( settings ) {
  7046. _fnAdjustColumnSizing( settings );
  7047. } );
  7048. } );
  7049. // Convert from one column index type, to another type
  7050. _api_register( 'column.index()', function ( type, idx ) {
  7051. if ( this.context.length !== 0 ) {
  7052. var ctx = this.context[0];
  7053. if ( type === 'fromVisible' || type === 'toData' ) {
  7054. return _fnVisibleToColumnIndex( ctx, idx );
  7055. }
  7056. else if ( type === 'fromData' || type === 'toVisible' ) {
  7057. return _fnColumnIndexToVisible( ctx, idx );
  7058. }
  7059. }
  7060. } );
  7061. _api_register( 'column()', function ( selector, opts ) {
  7062. return _selector_first( this.columns( selector, opts ) );
  7063. } );
  7064. var __cell_selector = function ( settings, selector, opts )
  7065. {
  7066. var data = settings.aoData;
  7067. var rows = _selector_row_indexes( settings, opts );
  7068. var cells = _pluck_order( data, rows, 'anCells' );
  7069. var allCells = $( [].concat.apply([], cells) );
  7070. var row;
  7071. var columns = settings.aoColumns.length;
  7072. var a, i, ien, j, o, host;
  7073. return _selector_run( selector, function ( s ) {
  7074. var fnSelector = typeof s === 'function';
  7075. if ( s === null || s === undefined || fnSelector ) {
  7076. // All cells and function selectors
  7077. a = [];
  7078. for ( i=0, ien=rows.length ; i<ien ; i++ ) {
  7079. row = rows[i];
  7080. for ( j=0 ; j<columns ; j++ ) {
  7081. o = {
  7082. row: row,
  7083. column: j
  7084. };
  7085. if ( fnSelector ) {
  7086. // Selector - function
  7087. host = settings.aoData[ row ];
  7088. if ( s( o, _fnGetCellData(settings, row, j), host.anCells[j] ) ) {
  7089. a.push( o );
  7090. }
  7091. }
  7092. else {
  7093. // Selector - all
  7094. a.push( o );
  7095. }
  7096. }
  7097. }
  7098. return a;
  7099. }
  7100. // Selector - index
  7101. if ( $.isPlainObject( s ) ) {
  7102. return [s];
  7103. }
  7104. // Selector - jQuery filtered cells
  7105. return allCells
  7106. .filter( s )
  7107. .map( function (i, el) {
  7108. row = el.parentNode._DT_RowIndex;
  7109. return {
  7110. row: row,
  7111. column: $.inArray( el, data[ row ].anCells )
  7112. };
  7113. } )
  7114. .toArray();
  7115. } );
  7116. };
  7117. _api_register( 'cells()', function ( rowSelector, columnSelector, opts ) {
  7118. // Argument shifting
  7119. if ( $.isPlainObject( rowSelector ) ) {
  7120. // Indexes
  7121. if ( typeof rowSelector.row !== undefined ) {
  7122. opts = columnSelector;
  7123. columnSelector = null;
  7124. }
  7125. else {
  7126. opts = rowSelector;
  7127. rowSelector = null;
  7128. }
  7129. }
  7130. if ( $.isPlainObject( columnSelector ) ) {
  7131. opts = columnSelector;
  7132. columnSelector = null;
  7133. }
  7134. // Cell selector
  7135. if ( columnSelector === null || columnSelector === undefined ) {
  7136. return this.iterator( 'table', function ( settings ) {
  7137. return __cell_selector( settings, rowSelector, _selector_opts( opts ) );
  7138. } );
  7139. }
  7140. // Row + column selector
  7141. var columns = this.columns( columnSelector, opts );
  7142. var rows = this.rows( rowSelector, opts );
  7143. var a, i, ien, j, jen;
  7144. var cells = this.iterator( 'table', function ( settings, idx ) {
  7145. a = [];
  7146. for ( i=0, ien=rows[idx].length ; i<ien ; i++ ) {
  7147. for ( j=0, jen=columns[idx].length ; j<jen ; j++ ) {
  7148. a.push( {
  7149. row: rows[idx][i],
  7150. column: columns[idx][j]
  7151. } );
  7152. }
  7153. }
  7154. return a;
  7155. } );
  7156. $.extend( cells.selector, {
  7157. cols: columnSelector,
  7158. rows: rowSelector,
  7159. opts: opts
  7160. } );
  7161. return cells;
  7162. } );
  7163. _api_registerPlural( 'cells().nodes()', 'cell().node()', function () {
  7164. return this.iterator( 'cell', function ( settings, row, column ) {
  7165. return settings.aoData[ row ].anCells[ column ];
  7166. } );
  7167. } );
  7168. _api_register( 'cells().data()', function () {
  7169. return this.iterator( 'cell', function ( settings, row, column ) {
  7170. return _fnGetCellData( settings, row, column );
  7171. } );
  7172. } );
  7173. _api_registerPlural( 'cells().cache()', 'cell().cache()', function ( type ) {
  7174. type = type === 'search' ? '_aFilterData' : '_aSortData';
  7175. return this.iterator( 'cell', function ( settings, row, column ) {
  7176. return settings.aoData[ row ][ type ][ column ];
  7177. } );
  7178. } );
  7179. _api_registerPlural( 'cells().render()', 'cell().render()', function ( type ) {
  7180. return this.iterator( 'cell', function ( settings, row, column ) {
  7181. return _fnGetCellData( settings, row, column, type );
  7182. } );
  7183. } );
  7184. _api_registerPlural( 'cells().indexes()', 'cell().index()', function () {
  7185. return this.iterator( 'cell', function ( settings, row, column ) {
  7186. return {
  7187. row: row,
  7188. column: column,
  7189. columnVisible: _fnColumnIndexToVisible( settings, column )
  7190. };
  7191. } );
  7192. } );
  7193. _api_register( [
  7194. 'cells().invalidate()',
  7195. 'cell().invalidate()'
  7196. ], function ( src ) {
  7197. var selector = this.selector;
  7198. // Use the rows method of the instance to perform the invalidation, rather
  7199. // than doing it here. This avoids needing to handle duplicate rows from
  7200. // the cells.
  7201. this.rows( selector.rows, selector.opts ).invalidate( src );
  7202. return this;
  7203. } );
  7204. _api_register( 'cell()', function ( rowSelector, columnSelector, opts ) {
  7205. return _selector_first( this.cells( rowSelector, columnSelector, opts ) );
  7206. } );
  7207. _api_register( 'cell().data()', function ( data ) {
  7208. var ctx = this.context;
  7209. var cell = this[0];
  7210. if ( data === undefined ) {
  7211. // Get
  7212. return ctx.length && cell.length ?
  7213. _fnGetCellData( ctx[0], cell[0].row, cell[0].column ) :
  7214. undefined;
  7215. }
  7216. // Set
  7217. _fnSetCellData( ctx[0], cell[0].row, cell[0].column, data );
  7218. _fnInvalidateRow( ctx[0], cell[0].row, 'data', cell[0].column );
  7219. return this;
  7220. } );
  7221. /**
  7222. * Get current ordering (sorting) that has been applied to the table.
  7223. *
  7224. * @returns {array} 2D array containing the sorting information for the first
  7225. * table in the current context. Each element in the parent array represents
  7226. * a column being sorted upon (i.e. multi-sorting with two columns would have
  7227. * 2 inner arrays). The inner arrays may have 2 or 3 elements. The first is
  7228. * the column index that the sorting condition applies to, the second is the
  7229. * direction of the sort (`desc` or `asc`) and, optionally, the third is the
  7230. * index of the sorting order from the `column.sorting` initialisation array.
  7231. *//**
  7232. * Set the ordering for the table.
  7233. *
  7234. * @param {integer} order Column index to sort upon.
  7235. * @param {string} direction Direction of the sort to be applied (`asc` or `desc`)
  7236. * @returns {DataTables.Api} this
  7237. *//**
  7238. * Set the ordering for the table.
  7239. *
  7240. * @param {array} order 1D array of sorting information to be applied.
  7241. * @param {array} [...] Optional additional sorting conditions
  7242. * @returns {DataTables.Api} this
  7243. *//**
  7244. * Set the ordering for the table.
  7245. *
  7246. * @param {array} order 2D array of sorting information to be applied.
  7247. * @returns {DataTables.Api} this
  7248. */
  7249. _api_register( 'order()', function ( order, dir ) {
  7250. var ctx = this.context;
  7251. if ( order === undefined ) {
  7252. // get
  7253. return ctx.length !== 0 ?
  7254. ctx[0].aaSorting :
  7255. undefined;
  7256. }
  7257. // set
  7258. if ( typeof order === 'number' ) {
  7259. // Simple column / direction passed in
  7260. order = [ [ order, dir ] ];
  7261. }
  7262. else if ( ! $.isArray( order[0] ) ) {
  7263. // Arguments passed in (list of 1D arrays)
  7264. order = Array.prototype.slice.call( arguments );
  7265. }
  7266. // otherwise a 2D array was passed in
  7267. return this.iterator( 'table', function ( settings ) {
  7268. settings.aaSorting = order.slice();
  7269. } );
  7270. } );
  7271. /**
  7272. * Attach a sort listener to an element for a given column
  7273. *
  7274. * @param {node|jQuery|string} node Identifier for the element(s) to attach the
  7275. * listener to. This can take the form of a single DOM node, a jQuery
  7276. * collection of nodes or a jQuery selector which will identify the node(s).
  7277. * @param {integer} column the column that a click on this node will sort on
  7278. * @param {function} [callback] callback function when sort is run
  7279. * @returns {DataTables.Api} this
  7280. */
  7281. _api_register( 'order.listener()', function ( node, column, callback ) {
  7282. return this.iterator( 'table', function ( settings ) {
  7283. _fnSortAttachListener( settings, node, column, callback );
  7284. } );
  7285. } );
  7286. // Order by the selected column(s)
  7287. _api_register( [
  7288. 'columns().order()',
  7289. 'column().order()'
  7290. ], function ( dir ) {
  7291. var that = this;
  7292. return this.iterator( 'table', function ( settings, i ) {
  7293. var sort = [];
  7294. $.each( that[i], function (j, col) {
  7295. sort.push( [ col, dir ] );
  7296. } );
  7297. settings.aaSorting = sort;
  7298. } );
  7299. } );
  7300. _api_register( 'search()', function ( input, regex, smart, caseInsen ) {
  7301. var ctx = this.context;
  7302. if ( input === undefined ) {
  7303. // get
  7304. return ctx.length !== 0 ?
  7305. ctx[0].oPreviousSearch.sSearch :
  7306. undefined;
  7307. }
  7308. // set
  7309. return this.iterator( 'table', function ( settings ) {
  7310. if ( ! settings.oFeatures.bFilter ) {
  7311. return;
  7312. }
  7313. _fnFilterComplete( settings, $.extend( {}, settings.oPreviousSearch, {
  7314. "sSearch": input+"",
  7315. "bRegex": regex === null ? false : regex,
  7316. "bSmart": smart === null ? true : smart,
  7317. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7318. } ), 1 );
  7319. } );
  7320. } );
  7321. _api_registerPlural(
  7322. 'columns().search()',
  7323. 'column().search()',
  7324. function ( input, regex, smart, caseInsen ) {
  7325. return this.iterator( 'column', function ( settings, column ) {
  7326. var preSearch = settings.aoPreSearchCols;
  7327. if ( input === undefined ) {
  7328. // get
  7329. return preSearch[ column ].sSearch;
  7330. }
  7331. // set
  7332. if ( ! settings.oFeatures.bFilter ) {
  7333. return;
  7334. }
  7335. $.extend( preSearch[ column ], {
  7336. "sSearch": input+"",
  7337. "bRegex": regex === null ? false : regex,
  7338. "bSmart": smart === null ? true : smart,
  7339. "bCaseInsensitive": caseInsen === null ? true : caseInsen
  7340. } );
  7341. _fnFilterComplete( settings, settings.oPreviousSearch, 1 );
  7342. } );
  7343. }
  7344. );
  7345. /*
  7346. * State API methods
  7347. */
  7348. _api_register( 'state()', function () {
  7349. return this.context.length ?
  7350. this.context[0].oSavedState :
  7351. null;
  7352. } );
  7353. _api_register( 'state.clear()', function () {
  7354. return this.iterator( 'table', function ( settings ) {
  7355. // Save an empty object
  7356. settings.fnStateSaveCallback.call( settings.oInstance, settings, {} );
  7357. } );
  7358. } );
  7359. _api_register( 'state.loaded()', function () {
  7360. return this.context.length ?
  7361. this.context[0].oLoadedState :
  7362. null;
  7363. } );
  7364. _api_register( 'state.save()', function () {
  7365. return this.iterator( 'table', function ( settings ) {
  7366. _fnSaveState( settings );
  7367. } );
  7368. } );
  7369. /**
  7370. * Provide a common method for plug-ins to check the version of DataTables being
  7371. * used, in order to ensure compatibility.
  7372. *
  7373. * @param {string} version Version string to check for, in the format "X.Y.Z".
  7374. * Note that the formats "X" and "X.Y" are also acceptable.
  7375. * @returns {boolean} true if this version of DataTables is greater or equal to
  7376. * the required version, or false if this version of DataTales is not
  7377. * suitable
  7378. * @static
  7379. * @dtopt API-Static
  7380. *
  7381. * @example
  7382. * alert( $.fn.dataTable.versionCheck( '1.9.0' ) );
  7383. */
  7384. DataTable.versionCheck = DataTable.fnVersionCheck = function( version )
  7385. {
  7386. var aThis = DataTable.version.split('.');
  7387. var aThat = version.split('.');
  7388. var iThis, iThat;
  7389. for ( var i=0, iLen=aThat.length ; i<iLen ; i++ ) {
  7390. iThis = parseInt( aThis[i], 10 ) || 0;
  7391. iThat = parseInt( aThat[i], 10 ) || 0;
  7392. // Parts are the same, keep comparing
  7393. if (iThis === iThat) {
  7394. continue;
  7395. }
  7396. // Parts are different, return immediately
  7397. return iThis > iThat;
  7398. }
  7399. return true;
  7400. };
  7401. /**
  7402. * Check if a `<table>` node is a DataTable table already or not.
  7403. *
  7404. * @param {node|jquery|string} table Table node, jQuery object or jQuery
  7405. * selector for the table to test. Note that if more than more than one
  7406. * table is passed on, only the first will be checked
  7407. * @returns {boolean} true the table given is a DataTable, or false otherwise
  7408. * @static
  7409. * @dtopt API-Static
  7410. *
  7411. * @example
  7412. * if ( ! $.fn.DataTable.isDataTable( '#example' ) ) {
  7413. * $('#example').dataTable();
  7414. * }
  7415. */
  7416. DataTable.isDataTable = DataTable.fnIsDataTable = function ( table )
  7417. {
  7418. var t = $(table).get(0);
  7419. var is = false;
  7420. $.each( DataTable.settings, function (i, o) {
  7421. if ( o.nTable === t || o.nScrollHead === t || o.nScrollFoot === t ) {
  7422. is = true;
  7423. }
  7424. } );
  7425. return is;
  7426. };
  7427. /**
  7428. * Get all DataTable tables that have been initialised - optionally you can
  7429. * select to get only currently visible tables.
  7430. *
  7431. * @param {boolean} [visible=false] Flag to indicate if you want all (default)
  7432. * or visible tables only.
  7433. * @returns {array} Array of `table` nodes (not DataTable instances) which are
  7434. * DataTables
  7435. * @static
  7436. * @dtopt API-Static
  7437. *
  7438. * @example
  7439. * $.each( $.fn.dataTable.tables(true), function () {
  7440. * $(table).DataTable().columns.adjust();
  7441. * } );
  7442. */
  7443. DataTable.tables = DataTable.fnTables = function ( visible )
  7444. {
  7445. return jQuery.map( DataTable.settings, function (o) {
  7446. if ( !visible || (visible && $(o.nTable).is(':visible')) ) {
  7447. return o.nTable;
  7448. }
  7449. } );
  7450. };
  7451. /**
  7452. * DataTables utility methods
  7453. *
  7454. * This namespace provides helper methods that DataTables uses internally to
  7455. * create a DataTable, but which are not exclusively used only for DataTables.
  7456. * These methods can be used by extension authors to save the duplication of
  7457. * code.
  7458. *
  7459. * @namespace
  7460. */
  7461. DataTable.util = {
  7462. /**
  7463. * Throttle the calls to a function. Arguments and context are maintained
  7464. * for the throttled function.
  7465. *
  7466. * @param {function} fn Function to be called
  7467. * @param {integer} freq Call frequency in mS
  7468. * @return {function} Wrapped function
  7469. */
  7470. throttle: _fnThrottle
  7471. };
  7472. /**
  7473. * Convert from camel case parameters to Hungarian notation. This is made public
  7474. * for the extensions to provide the same ability as DataTables core to accept
  7475. * either the 1.9 style Hungarian notation, or the 1.10+ style camelCase
  7476. * parameters.
  7477. *
  7478. * @param {object} src The model object which holds all parameters that can be
  7479. * mapped.
  7480. * @param {object} user The object to convert from camel case to Hungarian.
  7481. * @param {boolean} force When set to `true`, properties which already have a
  7482. * Hungarian value in the `user` object will be overwritten. Otherwise they
  7483. * won't be.
  7484. */
  7485. DataTable.camelToHungarian = _fnCamelToHungarian;
  7486. /**
  7487. *
  7488. */
  7489. _api_register( '$()', function ( selector, opts ) {
  7490. var
  7491. rows = this.rows( opts ).nodes(), // Get all rows
  7492. jqRows = $(rows);
  7493. return $( [].concat(
  7494. jqRows.filter( selector ).toArray(),
  7495. jqRows.find( selector ).toArray()
  7496. ) );
  7497. } );
  7498. // jQuery functions to operate on the tables
  7499. $.each( [ 'on', 'one', 'off' ], function (i, key) {
  7500. _api_register( key+'()', function ( /* event, handler */ ) {
  7501. var args = Array.prototype.slice.call(arguments);
  7502. // Add the `dt` namespace automatically if it isn't already present
  7503. if ( ! args[0].match(/\.dt\b/) ) {
  7504. args[0] += '.dt';
  7505. }
  7506. var inst = $( this.tables().nodes() );
  7507. inst[key].apply( inst, args );
  7508. return this;
  7509. } );
  7510. } );
  7511. _api_register( 'clear()', function () {
  7512. return this.iterator( 'table', function ( settings ) {
  7513. _fnClearTable( settings );
  7514. } );
  7515. } );
  7516. _api_register( 'settings()', function () {
  7517. return new _Api( this.context, this.context );
  7518. } );
  7519. _api_register( 'data()', function () {
  7520. return this.iterator( 'table', function ( settings ) {
  7521. return _pluck( settings.aoData, '_aData' );
  7522. } ).flatten();
  7523. } );
  7524. _api_register( 'destroy()', function ( remove ) {
  7525. remove = remove || false;
  7526. return this.iterator( 'table', function ( settings ) {
  7527. var orig = settings.nTableWrapper.parentNode;
  7528. var classes = settings.oClasses;
  7529. var table = settings.nTable;
  7530. var tbody = settings.nTBody;
  7531. var thead = settings.nTHead;
  7532. var tfoot = settings.nTFoot;
  7533. var jqTable = $(table);
  7534. var jqTbody = $(tbody);
  7535. var jqWrapper = $(settings.nTableWrapper);
  7536. var rows = $.map( settings.aoData, function (r) { return r.nTr; } );
  7537. var i, ien;
  7538. // Flag to note that the table is currently being destroyed - no action
  7539. // should be taken
  7540. settings.bDestroying = true;
  7541. // Fire off the destroy callbacks for plug-ins etc
  7542. _fnCallbackFire( settings, "aoDestroyCallback", "destroy", [settings] );
  7543. // If not being removed from the document, make all columns visible
  7544. if ( ! remove ) {
  7545. new _Api( settings ).columns().visible( true );
  7546. }
  7547. // Blitz all `DT` namespaced events (these are internal events, the
  7548. // lowercase, `dt` events are user subscribed and they are responsible
  7549. // for removing them
  7550. jqWrapper.unbind('.DT').find(':not(tbody *)').unbind('.DT');
  7551. $(window).unbind('.DT-'+settings.sInstance);
  7552. // When scrolling we had to break the table up - restore it
  7553. if ( table != thead.parentNode ) {
  7554. jqTable.children('thead').detach();
  7555. jqTable.append( thead );
  7556. }
  7557. if ( tfoot && table != tfoot.parentNode ) {
  7558. jqTable.children('tfoot').detach();
  7559. jqTable.append( tfoot );
  7560. }
  7561. // Remove the DataTables generated nodes, events and classes
  7562. jqTable.detach();
  7563. jqWrapper.detach();
  7564. settings.aaSorting = [];
  7565. settings.aaSortingFixed = [];
  7566. _fnSortingClasses( settings );
  7567. $( rows ).removeClass( settings.asStripeClasses.join(' ') );
  7568. $('th, td', thead).removeClass( classes.sSortable+' '+
  7569. classes.sSortableAsc+' '+classes.sSortableDesc+' '+classes.sSortableNone
  7570. );
  7571. if ( settings.bJUI ) {
  7572. $('th span.'+classes.sSortIcon+ ', td span.'+classes.sSortIcon, thead).detach();
  7573. $('th, td', thead).each( function () {
  7574. var wrapper = $('div.'+classes.sSortJUIWrapper, this);
  7575. $(this).append( wrapper.contents() );
  7576. wrapper.detach();
  7577. } );
  7578. }
  7579. if ( ! remove && orig ) {
  7580. // insertBefore acts like appendChild if !arg[1]
  7581. orig.insertBefore( table, settings.nTableReinsertBefore );
  7582. }
  7583. // Add the TR elements back into the table in their original order
  7584. jqTbody.children().detach();
  7585. jqTbody.append( rows );
  7586. // Restore the width of the original table - was read from the style property,
  7587. // so we can restore directly to that
  7588. jqTable
  7589. .css( 'width', settings.sDestroyWidth )
  7590. .removeClass( classes.sTable );
  7591. // If the were originally stripe classes - then we add them back here.
  7592. // Note this is not fool proof (for example if not all rows had stripe
  7593. // classes - but it's a good effort without getting carried away
  7594. ien = settings.asDestroyStripes.length;
  7595. if ( ien ) {
  7596. jqTbody.children().each( function (i) {
  7597. $(this).addClass( settings.asDestroyStripes[i % ien] );
  7598. } );
  7599. }
  7600. /* Remove the settings object from the settings array */
  7601. var idx = $.inArray( settings, DataTable.settings );
  7602. if ( idx !== -1 ) {
  7603. DataTable.settings.splice( idx, 1 );
  7604. }
  7605. } );
  7606. } );
  7607. /**
  7608. * Version string for plug-ins to check compatibility. Allowed format is
  7609. * `a.b.c-d` where: a:int, b:int, c:int, d:string(dev|beta|alpha). `d` is used
  7610. * only for non-release builds. See http://semver.org/ for more information.
  7611. * @member
  7612. * @type string
  7613. * @default Version number
  7614. */
  7615. DataTable.version = "1.10.3";
  7616. /**
  7617. * Private data store, containing all of the settings objects that are
  7618. * created for the tables on a given page.
  7619. *
  7620. * Note that the `DataTable.settings` object is aliased to
  7621. * `jQuery.fn.dataTableExt` through which it may be accessed and
  7622. * manipulated, or `jQuery.fn.dataTable.settings`.
  7623. * @member
  7624. * @type array
  7625. * @default []
  7626. * @private
  7627. */
  7628. DataTable.settings = [];
  7629. /**
  7630. * Object models container, for the various models that DataTables has
  7631. * available to it. These models define the objects that are used to hold
  7632. * the active state and configuration of the table.
  7633. * @namespace
  7634. */
  7635. DataTable.models = {};
  7636. /**
  7637. * Template object for the way in which DataTables holds information about
  7638. * search information for the global filter and individual column filters.
  7639. * @namespace
  7640. */
  7641. DataTable.models.oSearch = {
  7642. /**
  7643. * Flag to indicate if the filtering should be case insensitive or not
  7644. * @type boolean
  7645. * @default true
  7646. */
  7647. "bCaseInsensitive": true,
  7648. /**
  7649. * Applied search term
  7650. * @type string
  7651. * @default <i>Empty string</i>
  7652. */
  7653. "sSearch": "",
  7654. /**
  7655. * Flag to indicate if the search term should be interpreted as a
  7656. * regular expression (true) or not (false) and therefore and special
  7657. * regex characters escaped.
  7658. * @type boolean
  7659. * @default false
  7660. */
  7661. "bRegex": false,
  7662. /**
  7663. * Flag to indicate if DataTables is to use its smart filtering or not.
  7664. * @type boolean
  7665. * @default true
  7666. */
  7667. "bSmart": true
  7668. };
  7669. /**
  7670. * Template object for the way in which DataTables holds information about
  7671. * each individual row. This is the object format used for the settings
  7672. * aoData array.
  7673. * @namespace
  7674. */
  7675. DataTable.models.oRow = {
  7676. /**
  7677. * TR element for the row
  7678. * @type node
  7679. * @default null
  7680. */
  7681. "nTr": null,
  7682. /**
  7683. * Array of TD elements for each row. This is null until the row has been
  7684. * created.
  7685. * @type array nodes
  7686. * @default []
  7687. */
  7688. "anCells": null,
  7689. /**
  7690. * Data object from the original data source for the row. This is either
  7691. * an array if using the traditional form of DataTables, or an object if
  7692. * using mData options. The exact type will depend on the passed in
  7693. * data from the data source, or will be an array if using DOM a data
  7694. * source.
  7695. * @type array|object
  7696. * @default []
  7697. */
  7698. "_aData": [],
  7699. /**
  7700. * Sorting data cache - this array is ostensibly the same length as the
  7701. * number of columns (although each index is generated only as it is
  7702. * needed), and holds the data that is used for sorting each column in the
  7703. * row. We do this cache generation at the start of the sort in order that
  7704. * the formatting of the sort data need be done only once for each cell
  7705. * per sort. This array should not be read from or written to by anything
  7706. * other than the master sorting methods.
  7707. * @type array
  7708. * @default null
  7709. * @private
  7710. */
  7711. "_aSortData": null,
  7712. /**
  7713. * Per cell filtering data cache. As per the sort data cache, used to
  7714. * increase the performance of the filtering in DataTables
  7715. * @type array
  7716. * @default null
  7717. * @private
  7718. */
  7719. "_aFilterData": null,
  7720. /**
  7721. * Filtering data cache. This is the same as the cell filtering cache, but
  7722. * in this case a string rather than an array. This is easily computed with
  7723. * a join on `_aFilterData`, but is provided as a cache so the join isn't
  7724. * needed on every search (memory traded for performance)
  7725. * @type array
  7726. * @default null
  7727. * @private
  7728. */
  7729. "_sFilterRow": null,
  7730. /**
  7731. * Cache of the class name that DataTables has applied to the row, so we
  7732. * can quickly look at this variable rather than needing to do a DOM check
  7733. * on className for the nTr property.
  7734. * @type string
  7735. * @default <i>Empty string</i>
  7736. * @private
  7737. */
  7738. "_sRowStripe": "",
  7739. /**
  7740. * Denote if the original data source was from the DOM, or the data source
  7741. * object. This is used for invalidating data, so DataTables can
  7742. * automatically read data from the original source, unless uninstructed
  7743. * otherwise.
  7744. * @type string
  7745. * @default null
  7746. * @private
  7747. */
  7748. "src": null
  7749. };
  7750. /**
  7751. * Template object for the column information object in DataTables. This object
  7752. * is held in the settings aoColumns array and contains all the information that
  7753. * DataTables needs about each individual column.
  7754. *
  7755. * Note that this object is related to {@link DataTable.defaults.column}
  7756. * but this one is the internal data store for DataTables's cache of columns.
  7757. * It should NOT be manipulated outside of DataTables. Any configuration should
  7758. * be done through the initialisation options.
  7759. * @namespace
  7760. */
  7761. DataTable.models.oColumn = {
  7762. /**
  7763. * Column index. This could be worked out on-the-fly with $.inArray, but it
  7764. * is faster to just hold it as a variable
  7765. * @type integer
  7766. * @default null
  7767. */
  7768. "idx": null,
  7769. /**
  7770. * A list of the columns that sorting should occur on when this column
  7771. * is sorted. That this property is an array allows multi-column sorting
  7772. * to be defined for a column (for example first name / last name columns
  7773. * would benefit from this). The values are integers pointing to the
  7774. * columns to be sorted on (typically it will be a single integer pointing
  7775. * at itself, but that doesn't need to be the case).
  7776. * @type array
  7777. */
  7778. "aDataSort": null,
  7779. /**
  7780. * Define the sorting directions that are applied to the column, in sequence
  7781. * as the column is repeatedly sorted upon - i.e. the first value is used
  7782. * as the sorting direction when the column if first sorted (clicked on).
  7783. * Sort it again (click again) and it will move on to the next index.
  7784. * Repeat until loop.
  7785. * @type array
  7786. */
  7787. "asSorting": null,
  7788. /**
  7789. * Flag to indicate if the column is searchable, and thus should be included
  7790. * in the filtering or not.
  7791. * @type boolean
  7792. */
  7793. "bSearchable": null,
  7794. /**
  7795. * Flag to indicate if the column is sortable or not.
  7796. * @type boolean
  7797. */
  7798. "bSortable": null,
  7799. /**
  7800. * Flag to indicate if the column is currently visible in the table or not
  7801. * @type boolean
  7802. */
  7803. "bVisible": null,
  7804. /**
  7805. * Store for manual type assignment using the `column.type` option. This
  7806. * is held in store so we can manipulate the column's `sType` property.
  7807. * @type string
  7808. * @default null
  7809. * @private
  7810. */
  7811. "_sManualType": null,
  7812. /**
  7813. * Flag to indicate if HTML5 data attributes should be used as the data
  7814. * source for filtering or sorting. True is either are.
  7815. * @type boolean
  7816. * @default false
  7817. * @private
  7818. */
  7819. "_bAttrSrc": false,
  7820. /**
  7821. * Developer definable function that is called whenever a cell is created (Ajax source,
  7822. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  7823. * allowing you to modify the DOM element (add background colour for example) when the
  7824. * element is available.
  7825. * @type function
  7826. * @param {element} nTd The TD node that has been created
  7827. * @param {*} sData The Data for the cell
  7828. * @param {array|object} oData The data for the whole row
  7829. * @param {int} iRow The row index for the aoData data store
  7830. * @default null
  7831. */
  7832. "fnCreatedCell": null,
  7833. /**
  7834. * Function to get data from a cell in a column. You should <b>never</b>
  7835. * access data directly through _aData internally in DataTables - always use
  7836. * the method attached to this property. It allows mData to function as
  7837. * required. This function is automatically assigned by the column
  7838. * initialisation method
  7839. * @type function
  7840. * @param {array|object} oData The data array/object for the array
  7841. * (i.e. aoData[]._aData)
  7842. * @param {string} sSpecific The specific data type you want to get -
  7843. * 'display', 'type' 'filter' 'sort'
  7844. * @returns {*} The data for the cell from the given row's data
  7845. * @default null
  7846. */
  7847. "fnGetData": null,
  7848. /**
  7849. * Function to set data for a cell in the column. You should <b>never</b>
  7850. * set the data directly to _aData internally in DataTables - always use
  7851. * this method. It allows mData to function as required. This function
  7852. * is automatically assigned by the column initialisation method
  7853. * @type function
  7854. * @param {array|object} oData The data array/object for the array
  7855. * (i.e. aoData[]._aData)
  7856. * @param {*} sValue Value to set
  7857. * @default null
  7858. */
  7859. "fnSetData": null,
  7860. /**
  7861. * Property to read the value for the cells in the column from the data
  7862. * source array / object. If null, then the default content is used, if a
  7863. * function is given then the return from the function is used.
  7864. * @type function|int|string|null
  7865. * @default null
  7866. */
  7867. "mData": null,
  7868. /**
  7869. * Partner property to mData which is used (only when defined) to get
  7870. * the data - i.e. it is basically the same as mData, but without the
  7871. * 'set' option, and also the data fed to it is the result from mData.
  7872. * This is the rendering method to match the data method of mData.
  7873. * @type function|int|string|null
  7874. * @default null
  7875. */
  7876. "mRender": null,
  7877. /**
  7878. * Unique header TH/TD element for this column - this is what the sorting
  7879. * listener is attached to (if sorting is enabled.)
  7880. * @type node
  7881. * @default null
  7882. */
  7883. "nTh": null,
  7884. /**
  7885. * Unique footer TH/TD element for this column (if there is one). Not used
  7886. * in DataTables as such, but can be used for plug-ins to reference the
  7887. * footer for each column.
  7888. * @type node
  7889. * @default null
  7890. */
  7891. "nTf": null,
  7892. /**
  7893. * The class to apply to all TD elements in the table's TBODY for the column
  7894. * @type string
  7895. * @default null
  7896. */
  7897. "sClass": null,
  7898. /**
  7899. * When DataTables calculates the column widths to assign to each column,
  7900. * it finds the longest string in each column and then constructs a
  7901. * temporary table and reads the widths from that. The problem with this
  7902. * is that "mmm" is much wider then "iiii", but the latter is a longer
  7903. * string - thus the calculation can go wrong (doing it properly and putting
  7904. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  7905. * a "work around" we provide this option. It will append its value to the
  7906. * text that is found to be the longest string for the column - i.e. padding.
  7907. * @type string
  7908. */
  7909. "sContentPadding": null,
  7910. /**
  7911. * Allows a default value to be given for a column's data, and will be used
  7912. * whenever a null data source is encountered (this can be because mData
  7913. * is set to null, or because the data source itself is null).
  7914. * @type string
  7915. * @default null
  7916. */
  7917. "sDefaultContent": null,
  7918. /**
  7919. * Name for the column, allowing reference to the column by name as well as
  7920. * by index (needs a lookup to work by name).
  7921. * @type string
  7922. */
  7923. "sName": null,
  7924. /**
  7925. * Custom sorting data type - defines which of the available plug-ins in
  7926. * afnSortData the custom sorting will use - if any is defined.
  7927. * @type string
  7928. * @default std
  7929. */
  7930. "sSortDataType": 'std',
  7931. /**
  7932. * Class to be applied to the header element when sorting on this column
  7933. * @type string
  7934. * @default null
  7935. */
  7936. "sSortingClass": null,
  7937. /**
  7938. * Class to be applied to the header element when sorting on this column -
  7939. * when jQuery UI theming is used.
  7940. * @type string
  7941. * @default null
  7942. */
  7943. "sSortingClassJUI": null,
  7944. /**
  7945. * Title of the column - what is seen in the TH element (nTh).
  7946. * @type string
  7947. */
  7948. "sTitle": null,
  7949. /**
  7950. * Column sorting and filtering type
  7951. * @type string
  7952. * @default null
  7953. */
  7954. "sType": null,
  7955. /**
  7956. * Width of the column
  7957. * @type string
  7958. * @default null
  7959. */
  7960. "sWidth": null,
  7961. /**
  7962. * Width of the column when it was first "encountered"
  7963. * @type string
  7964. * @default null
  7965. */
  7966. "sWidthOrig": null
  7967. };
  7968. /*
  7969. * Developer note: The properties of the object below are given in Hungarian
  7970. * notation, that was used as the interface for DataTables prior to v1.10, however
  7971. * from v1.10 onwards the primary interface is camel case. In order to avoid
  7972. * breaking backwards compatibility utterly with this change, the Hungarian
  7973. * version is still, internally the primary interface, but is is not documented
  7974. * - hence the @name tags in each doc comment. This allows a Javascript function
  7975. * to create a map from Hungarian notation to camel case (going the other direction
  7976. * would require each property to be listed, which would at around 3K to the size
  7977. * of DataTables, while this method is about a 0.5K hit.
  7978. *
  7979. * Ultimately this does pave the way for Hungarian notation to be dropped
  7980. * completely, but that is a massive amount of work and will break current
  7981. * installs (therefore is on-hold until v2).
  7982. */
  7983. /**
  7984. * Initialisation options that can be given to DataTables at initialisation
  7985. * time.
  7986. * @namespace
  7987. */
  7988. DataTable.defaults = {
  7989. /**
  7990. * An array of data to use for the table, passed in at initialisation which
  7991. * will be used in preference to any data which is already in the DOM. This is
  7992. * particularly useful for constructing tables purely in Javascript, for
  7993. * example with a custom Ajax call.
  7994. * @type array
  7995. * @default null
  7996. *
  7997. * @dtopt Option
  7998. * @name DataTable.defaults.data
  7999. *
  8000. * @example
  8001. * // Using a 2D array data source
  8002. * $(document).ready( function () {
  8003. * $('#example').dataTable( {
  8004. * "data": [
  8005. * ['Trident', 'Internet Explorer 4.0', 'Win 95+', 4, 'X'],
  8006. * ['Trident', 'Internet Explorer 5.0', 'Win 95+', 5, 'C'],
  8007. * ],
  8008. * "columns": [
  8009. * { "title": "Engine" },
  8010. * { "title": "Browser" },
  8011. * { "title": "Platform" },
  8012. * { "title": "Version" },
  8013. * { "title": "Grade" }
  8014. * ]
  8015. * } );
  8016. * } );
  8017. *
  8018. * @example
  8019. * // Using an array of objects as a data source (`data`)
  8020. * $(document).ready( function () {
  8021. * $('#example').dataTable( {
  8022. * "data": [
  8023. * {
  8024. * "engine": "Trident",
  8025. * "browser": "Internet Explorer 4.0",
  8026. * "platform": "Win 95+",
  8027. * "version": 4,
  8028. * "grade": "X"
  8029. * },
  8030. * {
  8031. * "engine": "Trident",
  8032. * "browser": "Internet Explorer 5.0",
  8033. * "platform": "Win 95+",
  8034. * "version": 5,
  8035. * "grade": "C"
  8036. * }
  8037. * ],
  8038. * "columns": [
  8039. * { "title": "Engine", "data": "engine" },
  8040. * { "title": "Browser", "data": "browser" },
  8041. * { "title": "Platform", "data": "platform" },
  8042. * { "title": "Version", "data": "version" },
  8043. * { "title": "Grade", "data": "grade" }
  8044. * ]
  8045. * } );
  8046. * } );
  8047. */
  8048. "aaData": null,
  8049. /**
  8050. * If ordering is enabled, then DataTables will perform a first pass sort on
  8051. * initialisation. You can define which column(s) the sort is performed
  8052. * upon, and the sorting direction, with this variable. The `sorting` array
  8053. * should contain an array for each column to be sorted initially containing
  8054. * the column's index and a direction string ('asc' or 'desc').
  8055. * @type array
  8056. * @default [[0,'asc']]
  8057. *
  8058. * @dtopt Option
  8059. * @name DataTable.defaults.order
  8060. *
  8061. * @example
  8062. * // Sort by 3rd column first, and then 4th column
  8063. * $(document).ready( function() {
  8064. * $('#example').dataTable( {
  8065. * "order": [[2,'asc'], [3,'desc']]
  8066. * } );
  8067. * } );
  8068. *
  8069. * // No initial sorting
  8070. * $(document).ready( function() {
  8071. * $('#example').dataTable( {
  8072. * "order": []
  8073. * } );
  8074. * } );
  8075. */
  8076. "aaSorting": [[0,'asc']],
  8077. /**
  8078. * This parameter is basically identical to the `sorting` parameter, but
  8079. * cannot be overridden by user interaction with the table. What this means
  8080. * is that you could have a column (visible or hidden) which the sorting
  8081. * will always be forced on first - any sorting after that (from the user)
  8082. * will then be performed as required. This can be useful for grouping rows
  8083. * together.
  8084. * @type array
  8085. * @default null
  8086. *
  8087. * @dtopt Option
  8088. * @name DataTable.defaults.orderFixed
  8089. *
  8090. * @example
  8091. * $(document).ready( function() {
  8092. * $('#example').dataTable( {
  8093. * "orderFixed": [[0,'asc']]
  8094. * } );
  8095. * } )
  8096. */
  8097. "aaSortingFixed": [],
  8098. /**
  8099. * DataTables can be instructed to load data to display in the table from a
  8100. * Ajax source. This option defines how that Ajax call is made and where to.
  8101. *
  8102. * The `ajax` property has three different modes of operation, depending on
  8103. * how it is defined. These are:
  8104. *
  8105. * * `string` - Set the URL from where the data should be loaded from.
  8106. * * `object` - Define properties for `jQuery.ajax`.
  8107. * * `function` - Custom data get function
  8108. *
  8109. * `string`
  8110. * --------
  8111. *
  8112. * As a string, the `ajax` property simply defines the URL from which
  8113. * DataTables will load data.
  8114. *
  8115. * `object`
  8116. * --------
  8117. *
  8118. * As an object, the parameters in the object are passed to
  8119. * [jQuery.ajax](http://api.jquery.com/jQuery.ajax/) allowing fine control
  8120. * of the Ajax request. DataTables has a number of default parameters which
  8121. * you can override using this option. Please refer to the jQuery
  8122. * documentation for a full description of the options available, although
  8123. * the following parameters provide additional options in DataTables or
  8124. * require special consideration:
  8125. *
  8126. * * `data` - As with jQuery, `data` can be provided as an object, but it
  8127. * can also be used as a function to manipulate the data DataTables sends
  8128. * to the server. The function takes a single parameter, an object of
  8129. * parameters with the values that DataTables has readied for sending. An
  8130. * object may be returned which will be merged into the DataTables
  8131. * defaults, or you can add the items to the object that was passed in and
  8132. * not return anything from the function. This supersedes `fnServerParams`
  8133. * from DataTables 1.9-.
  8134. *
  8135. * * `dataSrc` - By default DataTables will look for the property `data` (or
  8136. * `aaData` for compatibility with DataTables 1.9-) when obtaining data
  8137. * from an Ajax source or for server-side processing - this parameter
  8138. * allows that property to be changed. You can use Javascript dotted
  8139. * object notation to get a data source for multiple levels of nesting, or
  8140. * it my be used as a function. As a function it takes a single parameter,
  8141. * the JSON returned from the server, which can be manipulated as
  8142. * required, with the returned value being that used by DataTables as the
  8143. * data source for the table. This supersedes `sAjaxDataProp` from
  8144. * DataTables 1.9-.
  8145. *
  8146. * * `success` - Should not be overridden it is used internally in
  8147. * DataTables. To manipulate / transform the data returned by the server
  8148. * use `ajax.dataSrc`, or use `ajax` as a function (see below).
  8149. *
  8150. * `function`
  8151. * ----------
  8152. *
  8153. * As a function, making the Ajax call is left up to yourself allowing
  8154. * complete control of the Ajax request. Indeed, if desired, a method other
  8155. * than Ajax could be used to obtain the required data, such as Web storage
  8156. * or an AIR database.
  8157. *
  8158. * The function is given four parameters and no return is required. The
  8159. * parameters are:
  8160. *
  8161. * 1. _object_ - Data to send to the server
  8162. * 2. _function_ - Callback function that must be executed when the required
  8163. * data has been obtained. That data should be passed into the callback
  8164. * as the only parameter
  8165. * 3. _object_ - DataTables settings object for the table
  8166. *
  8167. * Note that this supersedes `fnServerData` from DataTables 1.9-.
  8168. *
  8169. * @type string|object|function
  8170. * @default null
  8171. *
  8172. * @dtopt Option
  8173. * @name DataTable.defaults.ajax
  8174. * @since 1.10.0
  8175. *
  8176. * @example
  8177. * // Get JSON data from a file via Ajax.
  8178. * // Note DataTables expects data in the form `{ data: [ ...data... ] }` by default).
  8179. * $('#example').dataTable( {
  8180. * "ajax": "data.json"
  8181. * } );
  8182. *
  8183. * @example
  8184. * // Get JSON data from a file via Ajax, using `dataSrc` to change
  8185. * // `data` to `tableData` (i.e. `{ tableData: [ ...data... ] }`)
  8186. * $('#example').dataTable( {
  8187. * "ajax": {
  8188. * "url": "data.json",
  8189. * "dataSrc": "tableData"
  8190. * }
  8191. * } );
  8192. *
  8193. * @example
  8194. * // Get JSON data from a file via Ajax, using `dataSrc` to read data
  8195. * // from a plain array rather than an array in an object
  8196. * $('#example').dataTable( {
  8197. * "ajax": {
  8198. * "url": "data.json",
  8199. * "dataSrc": ""
  8200. * }
  8201. * } );
  8202. *
  8203. * @example
  8204. * // Manipulate the data returned from the server - add a link to data
  8205. * // (note this can, should, be done using `render` for the column - this
  8206. * // is just a simple example of how the data can be manipulated).
  8207. * $('#example').dataTable( {
  8208. * "ajax": {
  8209. * "url": "data.json",
  8210. * "dataSrc": function ( json ) {
  8211. * for ( var i=0, ien=json.length ; i<ien ; i++ ) {
  8212. * json[i][0] = '<a href="/message/'+json[i][0]+'>View message</a>';
  8213. * }
  8214. * return json;
  8215. * }
  8216. * }
  8217. * } );
  8218. *
  8219. * @example
  8220. * // Add data to the request
  8221. * $('#example').dataTable( {
  8222. * "ajax": {
  8223. * "url": "data.json",
  8224. * "data": function ( d ) {
  8225. * return {
  8226. * "extra_search": $('#extra').val()
  8227. * };
  8228. * }
  8229. * }
  8230. * } );
  8231. *
  8232. * @example
  8233. * // Send request as POST
  8234. * $('#example').dataTable( {
  8235. * "ajax": {
  8236. * "url": "data.json",
  8237. * "type": "POST"
  8238. * }
  8239. * } );
  8240. *
  8241. * @example
  8242. * // Get the data from localStorage (could interface with a form for
  8243. * // adding, editing and removing rows).
  8244. * $('#example').dataTable( {
  8245. * "ajax": function (data, callback, settings) {
  8246. * callback(
  8247. * JSON.parse( localStorage.getItem('dataTablesData') )
  8248. * );
  8249. * }
  8250. * } );
  8251. */
  8252. "ajax": null,
  8253. /**
  8254. * This parameter allows you to readily specify the entries in the length drop
  8255. * down menu that DataTables shows when pagination is enabled. It can be
  8256. * either a 1D array of options which will be used for both the displayed
  8257. * option and the value, or a 2D array which will use the array in the first
  8258. * position as the value, and the array in the second position as the
  8259. * displayed options (useful for language strings such as 'All').
  8260. *
  8261. * Note that the `pageLength` property will be automatically set to the
  8262. * first value given in this array, unless `pageLength` is also provided.
  8263. * @type array
  8264. * @default [ 10, 25, 50, 100 ]
  8265. *
  8266. * @dtopt Option
  8267. * @name DataTable.defaults.lengthMenu
  8268. *
  8269. * @example
  8270. * $(document).ready( function() {
  8271. * $('#example').dataTable( {
  8272. * "lengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
  8273. * } );
  8274. * } );
  8275. */
  8276. "aLengthMenu": [ 10, 25, 50, 100 ],
  8277. /**
  8278. * The `columns` option in the initialisation parameter allows you to define
  8279. * details about the way individual columns behave. For a full list of
  8280. * column options that can be set, please see
  8281. * {@link DataTable.defaults.column}. Note that if you use `columns` to
  8282. * define your columns, you must have an entry in the array for every single
  8283. * column that you have in your table (these can be null if you don't which
  8284. * to specify any options).
  8285. * @member
  8286. *
  8287. * @name DataTable.defaults.column
  8288. */
  8289. "aoColumns": null,
  8290. /**
  8291. * Very similar to `columns`, `columnDefs` allows you to target a specific
  8292. * column, multiple columns, or all columns, using the `targets` property of
  8293. * each object in the array. This allows great flexibility when creating
  8294. * tables, as the `columnDefs` arrays can be of any length, targeting the
  8295. * columns you specifically want. `columnDefs` may use any of the column
  8296. * options available: {@link DataTable.defaults.column}, but it _must_
  8297. * have `targets` defined in each object in the array. Values in the `targets`
  8298. * array may be:
  8299. * <ul>
  8300. * <li>a string - class name will be matched on the TH for the column</li>
  8301. * <li>0 or a positive integer - column index counting from the left</li>
  8302. * <li>a negative integer - column index counting from the right</li>
  8303. * <li>the string "_all" - all columns (i.e. assign a default)</li>
  8304. * </ul>
  8305. * @member
  8306. *
  8307. * @name DataTable.defaults.columnDefs
  8308. */
  8309. "aoColumnDefs": null,
  8310. /**
  8311. * Basically the same as `search`, this parameter defines the individual column
  8312. * filtering state at initialisation time. The array must be of the same size
  8313. * as the number of columns, and each element be an object with the parameters
  8314. * `search` and `escapeRegex` (the latter is optional). 'null' is also
  8315. * accepted and the default will be used.
  8316. * @type array
  8317. * @default []
  8318. *
  8319. * @dtopt Option
  8320. * @name DataTable.defaults.searchCols
  8321. *
  8322. * @example
  8323. * $(document).ready( function() {
  8324. * $('#example').dataTable( {
  8325. * "searchCols": [
  8326. * null,
  8327. * { "search": "My filter" },
  8328. * null,
  8329. * { "search": "^[0-9]", "escapeRegex": false }
  8330. * ]
  8331. * } );
  8332. * } )
  8333. */
  8334. "aoSearchCols": [],
  8335. /**
  8336. * An array of CSS classes that should be applied to displayed rows. This
  8337. * array may be of any length, and DataTables will apply each class
  8338. * sequentially, looping when required.
  8339. * @type array
  8340. * @default null <i>Will take the values determined by the `oClasses.stripe*`
  8341. * options</i>
  8342. *
  8343. * @dtopt Option
  8344. * @name DataTable.defaults.stripeClasses
  8345. *
  8346. * @example
  8347. * $(document).ready( function() {
  8348. * $('#example').dataTable( {
  8349. * "stripeClasses": [ 'strip1', 'strip2', 'strip3' ]
  8350. * } );
  8351. * } )
  8352. */
  8353. "asStripeClasses": null,
  8354. /**
  8355. * Enable or disable automatic column width calculation. This can be disabled
  8356. * as an optimisation (it takes some time to calculate the widths) if the
  8357. * tables widths are passed in using `columns`.
  8358. * @type boolean
  8359. * @default true
  8360. *
  8361. * @dtopt Features
  8362. * @name DataTable.defaults.autoWidth
  8363. *
  8364. * @example
  8365. * $(document).ready( function () {
  8366. * $('#example').dataTable( {
  8367. * "autoWidth": false
  8368. * } );
  8369. * } );
  8370. */
  8371. "bAutoWidth": true,
  8372. /**
  8373. * Deferred rendering can provide DataTables with a huge speed boost when you
  8374. * are using an Ajax or JS data source for the table. This option, when set to
  8375. * true, will cause DataTables to defer the creation of the table elements for
  8376. * each row until they are needed for a draw - saving a significant amount of
  8377. * time.
  8378. * @type boolean
  8379. * @default false
  8380. *
  8381. * @dtopt Features
  8382. * @name DataTable.defaults.deferRender
  8383. *
  8384. * @example
  8385. * $(document).ready( function() {
  8386. * $('#example').dataTable( {
  8387. * "ajax": "sources/arrays.txt",
  8388. * "deferRender": true
  8389. * } );
  8390. * } );
  8391. */
  8392. "bDeferRender": false,
  8393. /**
  8394. * Replace a DataTable which matches the given selector and replace it with
  8395. * one which has the properties of the new initialisation object passed. If no
  8396. * table matches the selector, then the new DataTable will be constructed as
  8397. * per normal.
  8398. * @type boolean
  8399. * @default false
  8400. *
  8401. * @dtopt Options
  8402. * @name DataTable.defaults.destroy
  8403. *
  8404. * @example
  8405. * $(document).ready( function() {
  8406. * $('#example').dataTable( {
  8407. * "srollY": "200px",
  8408. * "paginate": false
  8409. * } );
  8410. *
  8411. * // Some time later....
  8412. * $('#example').dataTable( {
  8413. * "filter": false,
  8414. * "destroy": true
  8415. * } );
  8416. * } );
  8417. */
  8418. "bDestroy": false,
  8419. /**
  8420. * Enable or disable filtering of data. Filtering in DataTables is "smart" in
  8421. * that it allows the end user to input multiple words (space separated) and
  8422. * will match a row containing those words, even if not in the order that was
  8423. * specified (this allow matching across multiple columns). Note that if you
  8424. * wish to use filtering in DataTables this must remain 'true' - to remove the
  8425. * default filtering input box and retain filtering abilities, please use
  8426. * {@link DataTable.defaults.dom}.
  8427. * @type boolean
  8428. * @default true
  8429. *
  8430. * @dtopt Features
  8431. * @name DataTable.defaults.searching
  8432. *
  8433. * @example
  8434. * $(document).ready( function () {
  8435. * $('#example').dataTable( {
  8436. * "searching": false
  8437. * } );
  8438. * } );
  8439. */
  8440. "bFilter": true,
  8441. /**
  8442. * Enable or disable the table information display. This shows information
  8443. * about the data that is currently visible on the page, including information
  8444. * about filtered data if that action is being performed.
  8445. * @type boolean
  8446. * @default true
  8447. *
  8448. * @dtopt Features
  8449. * @name DataTable.defaults.info
  8450. *
  8451. * @example
  8452. * $(document).ready( function () {
  8453. * $('#example').dataTable( {
  8454. * "info": false
  8455. * } );
  8456. * } );
  8457. */
  8458. "bInfo": true,
  8459. /**
  8460. * Enable jQuery UI ThemeRoller support (required as ThemeRoller requires some
  8461. * slightly different and additional mark-up from what DataTables has
  8462. * traditionally used).
  8463. * @type boolean
  8464. * @default false
  8465. *
  8466. * @dtopt Features
  8467. * @name DataTable.defaults.jQueryUI
  8468. *
  8469. * @example
  8470. * $(document).ready( function() {
  8471. * $('#example').dataTable( {
  8472. * "jQueryUI": true
  8473. * } );
  8474. * } );
  8475. */
  8476. "bJQueryUI": false,
  8477. /**
  8478. * Allows the end user to select the size of a formatted page from a select
  8479. * menu (sizes are 10, 25, 50 and 100). Requires pagination (`paginate`).
  8480. * @type boolean
  8481. * @default true
  8482. *
  8483. * @dtopt Features
  8484. * @name DataTable.defaults.lengthChange
  8485. *
  8486. * @example
  8487. * $(document).ready( function () {
  8488. * $('#example').dataTable( {
  8489. * "lengthChange": false
  8490. * } );
  8491. * } );
  8492. */
  8493. "bLengthChange": true,
  8494. /**
  8495. * Enable or disable pagination.
  8496. * @type boolean
  8497. * @default true
  8498. *
  8499. * @dtopt Features
  8500. * @name DataTable.defaults.paging
  8501. *
  8502. * @example
  8503. * $(document).ready( function () {
  8504. * $('#example').dataTable( {
  8505. * "paging": false
  8506. * } );
  8507. * } );
  8508. */
  8509. "bPaginate": true,
  8510. /**
  8511. * Enable or disable the display of a 'processing' indicator when the table is
  8512. * being processed (e.g. a sort). This is particularly useful for tables with
  8513. * large amounts of data where it can take a noticeable amount of time to sort
  8514. * the entries.
  8515. * @type boolean
  8516. * @default false
  8517. *
  8518. * @dtopt Features
  8519. * @name DataTable.defaults.processing
  8520. *
  8521. * @example
  8522. * $(document).ready( function () {
  8523. * $('#example').dataTable( {
  8524. * "processing": true
  8525. * } );
  8526. * } );
  8527. */
  8528. "bProcessing": false,
  8529. /**
  8530. * Retrieve the DataTables object for the given selector. Note that if the
  8531. * table has already been initialised, this parameter will cause DataTables
  8532. * to simply return the object that has already been set up - it will not take
  8533. * account of any changes you might have made to the initialisation object
  8534. * passed to DataTables (setting this parameter to true is an acknowledgement
  8535. * that you understand this). `destroy` can be used to reinitialise a table if
  8536. * you need.
  8537. * @type boolean
  8538. * @default false
  8539. *
  8540. * @dtopt Options
  8541. * @name DataTable.defaults.retrieve
  8542. *
  8543. * @example
  8544. * $(document).ready( function() {
  8545. * initTable();
  8546. * tableActions();
  8547. * } );
  8548. *
  8549. * function initTable ()
  8550. * {
  8551. * return $('#example').dataTable( {
  8552. * "scrollY": "200px",
  8553. * "paginate": false,
  8554. * "retrieve": true
  8555. * } );
  8556. * }
  8557. *
  8558. * function tableActions ()
  8559. * {
  8560. * var table = initTable();
  8561. * // perform API operations with oTable
  8562. * }
  8563. */
  8564. "bRetrieve": false,
  8565. /**
  8566. * When vertical (y) scrolling is enabled, DataTables will force the height of
  8567. * the table's viewport to the given height at all times (useful for layout).
  8568. * However, this can look odd when filtering data down to a small data set,
  8569. * and the footer is left "floating" further down. This parameter (when
  8570. * enabled) will cause DataTables to collapse the table's viewport down when
  8571. * the result set will fit within the given Y height.
  8572. * @type boolean
  8573. * @default false
  8574. *
  8575. * @dtopt Options
  8576. * @name DataTable.defaults.scrollCollapse
  8577. *
  8578. * @example
  8579. * $(document).ready( function() {
  8580. * $('#example').dataTable( {
  8581. * "scrollY": "200",
  8582. * "scrollCollapse": true
  8583. * } );
  8584. * } );
  8585. */
  8586. "bScrollCollapse": false,
  8587. /**
  8588. * Configure DataTables to use server-side processing. Note that the
  8589. * `ajax` parameter must also be given in order to give DataTables a
  8590. * source to obtain the required data for each draw.
  8591. * @type boolean
  8592. * @default false
  8593. *
  8594. * @dtopt Features
  8595. * @dtopt Server-side
  8596. * @name DataTable.defaults.serverSide
  8597. *
  8598. * @example
  8599. * $(document).ready( function () {
  8600. * $('#example').dataTable( {
  8601. * "serverSide": true,
  8602. * "ajax": "xhr.php"
  8603. * } );
  8604. * } );
  8605. */
  8606. "bServerSide": false,
  8607. /**
  8608. * Enable or disable sorting of columns. Sorting of individual columns can be
  8609. * disabled by the `sortable` option for each column.
  8610. * @type boolean
  8611. * @default true
  8612. *
  8613. * @dtopt Features
  8614. * @name DataTable.defaults.ordering
  8615. *
  8616. * @example
  8617. * $(document).ready( function () {
  8618. * $('#example').dataTable( {
  8619. * "ordering": false
  8620. * } );
  8621. * } );
  8622. */
  8623. "bSort": true,
  8624. /**
  8625. * Enable or display DataTables' ability to sort multiple columns at the
  8626. * same time (activated by shift-click by the user).
  8627. * @type boolean
  8628. * @default true
  8629. *
  8630. * @dtopt Options
  8631. * @name DataTable.defaults.orderMulti
  8632. *
  8633. * @example
  8634. * // Disable multiple column sorting ability
  8635. * $(document).ready( function () {
  8636. * $('#example').dataTable( {
  8637. * "orderMulti": false
  8638. * } );
  8639. * } );
  8640. */
  8641. "bSortMulti": true,
  8642. /**
  8643. * Allows control over whether DataTables should use the top (true) unique
  8644. * cell that is found for a single column, or the bottom (false - default).
  8645. * This is useful when using complex headers.
  8646. * @type boolean
  8647. * @default false
  8648. *
  8649. * @dtopt Options
  8650. * @name DataTable.defaults.orderCellsTop
  8651. *
  8652. * @example
  8653. * $(document).ready( function() {
  8654. * $('#example').dataTable( {
  8655. * "orderCellsTop": true
  8656. * } );
  8657. * } );
  8658. */
  8659. "bSortCellsTop": false,
  8660. /**
  8661. * Enable or disable the addition of the classes `sorting\_1`, `sorting\_2` and
  8662. * `sorting\_3` to the columns which are currently being sorted on. This is
  8663. * presented as a feature switch as it can increase processing time (while
  8664. * classes are removed and added) so for large data sets you might want to
  8665. * turn this off.
  8666. * @type boolean
  8667. * @default true
  8668. *
  8669. * @dtopt Features
  8670. * @name DataTable.defaults.orderClasses
  8671. *
  8672. * @example
  8673. * $(document).ready( function () {
  8674. * $('#example').dataTable( {
  8675. * "orderClasses": false
  8676. * } );
  8677. * } );
  8678. */
  8679. "bSortClasses": true,
  8680. /**
  8681. * Enable or disable state saving. When enabled HTML5 `localStorage` will be
  8682. * used to save table display information such as pagination information,
  8683. * display length, filtering and sorting. As such when the end user reloads
  8684. * the page the display display will match what thy had previously set up.
  8685. *
  8686. * Due to the use of `localStorage` the default state saving is not supported
  8687. * in IE6 or 7. If state saving is required in those browsers, use
  8688. * `stateSaveCallback` to provide a storage solution such as cookies.
  8689. * @type boolean
  8690. * @default false
  8691. *
  8692. * @dtopt Features
  8693. * @name DataTable.defaults.stateSave
  8694. *
  8695. * @example
  8696. * $(document).ready( function () {
  8697. * $('#example').dataTable( {
  8698. * "stateSave": true
  8699. * } );
  8700. * } );
  8701. */
  8702. "bStateSave": false,
  8703. /**
  8704. * This function is called when a TR element is created (and all TD child
  8705. * elements have been inserted), or registered if using a DOM source, allowing
  8706. * manipulation of the TR element (adding classes etc).
  8707. * @type function
  8708. * @param {node} row "TR" element for the current row
  8709. * @param {array} data Raw data array for this row
  8710. * @param {int} dataIndex The index of this row in the internal aoData array
  8711. *
  8712. * @dtopt Callbacks
  8713. * @name DataTable.defaults.createdRow
  8714. *
  8715. * @example
  8716. * $(document).ready( function() {
  8717. * $('#example').dataTable( {
  8718. * "createdRow": function( row, data, dataIndex ) {
  8719. * // Bold the grade for all 'A' grade browsers
  8720. * if ( data[4] == "A" )
  8721. * {
  8722. * $('td:eq(4)', row).html( '<b>A</b>' );
  8723. * }
  8724. * }
  8725. * } );
  8726. * } );
  8727. */
  8728. "fnCreatedRow": null,
  8729. /**
  8730. * This function is called on every 'draw' event, and allows you to
  8731. * dynamically modify any aspect you want about the created DOM.
  8732. * @type function
  8733. * @param {object} settings DataTables settings object
  8734. *
  8735. * @dtopt Callbacks
  8736. * @name DataTable.defaults.drawCallback
  8737. *
  8738. * @example
  8739. * $(document).ready( function() {
  8740. * $('#example').dataTable( {
  8741. * "drawCallback": function( settings ) {
  8742. * alert( 'DataTables has redrawn the table' );
  8743. * }
  8744. * } );
  8745. * } );
  8746. */
  8747. "fnDrawCallback": null,
  8748. /**
  8749. * Identical to fnHeaderCallback() but for the table footer this function
  8750. * allows you to modify the table footer on every 'draw' event.
  8751. * @type function
  8752. * @param {node} foot "TR" element for the footer
  8753. * @param {array} data Full table data (as derived from the original HTML)
  8754. * @param {int} start Index for the current display starting point in the
  8755. * display array
  8756. * @param {int} end Index for the current display ending point in the
  8757. * display array
  8758. * @param {array int} display Index array to translate the visual position
  8759. * to the full data array
  8760. *
  8761. * @dtopt Callbacks
  8762. * @name DataTable.defaults.footerCallback
  8763. *
  8764. * @example
  8765. * $(document).ready( function() {
  8766. * $('#example').dataTable( {
  8767. * "footerCallback": function( tfoot, data, start, end, display ) {
  8768. * tfoot.getElementsByTagName('th')[0].innerHTML = "Starting index is "+start;
  8769. * }
  8770. * } );
  8771. * } )
  8772. */
  8773. "fnFooterCallback": null,
  8774. /**
  8775. * When rendering large numbers in the information element for the table
  8776. * (i.e. "Showing 1 to 10 of 57 entries") DataTables will render large numbers
  8777. * to have a comma separator for the 'thousands' units (e.g. 1 million is
  8778. * rendered as "1,000,000") to help readability for the end user. This
  8779. * function will override the default method DataTables uses.
  8780. * @type function
  8781. * @member
  8782. * @param {int} toFormat number to be formatted
  8783. * @returns {string} formatted string for DataTables to show the number
  8784. *
  8785. * @dtopt Callbacks
  8786. * @name DataTable.defaults.formatNumber
  8787. *
  8788. * @example
  8789. * // Format a number using a single quote for the separator (note that
  8790. * // this can also be done with the language.thousands option)
  8791. * $(document).ready( function() {
  8792. * $('#example').dataTable( {
  8793. * "formatNumber": function ( toFormat ) {
  8794. * return toFormat.toString().replace(
  8795. * /\B(?=(\d{3})+(?!\d))/g, "'"
  8796. * );
  8797. * };
  8798. * } );
  8799. * } );
  8800. */
  8801. "fnFormatNumber": function ( toFormat ) {
  8802. return toFormat.toString().replace(
  8803. /\B(?=(\d{3})+(?!\d))/g,
  8804. this.oLanguage.sThousands
  8805. );
  8806. },
  8807. /**
  8808. * This function is called on every 'draw' event, and allows you to
  8809. * dynamically modify the header row. This can be used to calculate and
  8810. * display useful information about the table.
  8811. * @type function
  8812. * @param {node} head "TR" element for the header
  8813. * @param {array} data Full table data (as derived from the original HTML)
  8814. * @param {int} start Index for the current display starting point in the
  8815. * display array
  8816. * @param {int} end Index for the current display ending point in the
  8817. * display array
  8818. * @param {array int} display Index array to translate the visual position
  8819. * to the full data array
  8820. *
  8821. * @dtopt Callbacks
  8822. * @name DataTable.defaults.headerCallback
  8823. *
  8824. * @example
  8825. * $(document).ready( function() {
  8826. * $('#example').dataTable( {
  8827. * "fheaderCallback": function( head, data, start, end, display ) {
  8828. * head.getElementsByTagName('th')[0].innerHTML = "Displaying "+(end-start)+" records";
  8829. * }
  8830. * } );
  8831. * } )
  8832. */
  8833. "fnHeaderCallback": null,
  8834. /**
  8835. * The information element can be used to convey information about the current
  8836. * state of the table. Although the internationalisation options presented by
  8837. * DataTables are quite capable of dealing with most customisations, there may
  8838. * be times where you wish to customise the string further. This callback
  8839. * allows you to do exactly that.
  8840. * @type function
  8841. * @param {object} oSettings DataTables settings object
  8842. * @param {int} start Starting position in data for the draw
  8843. * @param {int} end End position in data for the draw
  8844. * @param {int} max Total number of rows in the table (regardless of
  8845. * filtering)
  8846. * @param {int} total Total number of rows in the data set, after filtering
  8847. * @param {string} pre The string that DataTables has formatted using it's
  8848. * own rules
  8849. * @returns {string} The string to be displayed in the information element.
  8850. *
  8851. * @dtopt Callbacks
  8852. * @name DataTable.defaults.infoCallback
  8853. *
  8854. * @example
  8855. * $('#example').dataTable( {
  8856. * "infoCallback": function( settings, start, end, max, total, pre ) {
  8857. * return start +" to "+ end;
  8858. * }
  8859. * } );
  8860. */
  8861. "fnInfoCallback": null,
  8862. /**
  8863. * Called when the table has been initialised. Normally DataTables will
  8864. * initialise sequentially and there will be no need for this function,
  8865. * however, this does not hold true when using external language information
  8866. * since that is obtained using an async XHR call.
  8867. * @type function
  8868. * @param {object} settings DataTables settings object
  8869. * @param {object} json The JSON object request from the server - only
  8870. * present if client-side Ajax sourced data is used
  8871. *
  8872. * @dtopt Callbacks
  8873. * @name DataTable.defaults.initComplete
  8874. *
  8875. * @example
  8876. * $(document).ready( function() {
  8877. * $('#example').dataTable( {
  8878. * "initComplete": function(settings, json) {
  8879. * alert( 'DataTables has finished its initialisation.' );
  8880. * }
  8881. * } );
  8882. * } )
  8883. */
  8884. "fnInitComplete": null,
  8885. /**
  8886. * Called at the very start of each table draw and can be used to cancel the
  8887. * draw by returning false, any other return (including undefined) results in
  8888. * the full draw occurring).
  8889. * @type function
  8890. * @param {object} settings DataTables settings object
  8891. * @returns {boolean} False will cancel the draw, anything else (including no
  8892. * return) will allow it to complete.
  8893. *
  8894. * @dtopt Callbacks
  8895. * @name DataTable.defaults.preDrawCallback
  8896. *
  8897. * @example
  8898. * $(document).ready( function() {
  8899. * $('#example').dataTable( {
  8900. * "preDrawCallback": function( settings ) {
  8901. * if ( $('#test').val() == 1 ) {
  8902. * return false;
  8903. * }
  8904. * }
  8905. * } );
  8906. * } );
  8907. */
  8908. "fnPreDrawCallback": null,
  8909. /**
  8910. * This function allows you to 'post process' each row after it have been
  8911. * generated for each table draw, but before it is rendered on screen. This
  8912. * function might be used for setting the row class name etc.
  8913. * @type function
  8914. * @param {node} row "TR" element for the current row
  8915. * @param {array} data Raw data array for this row
  8916. * @param {int} displayIndex The display index for the current table draw
  8917. * @param {int} displayIndexFull The index of the data in the full list of
  8918. * rows (after filtering)
  8919. *
  8920. * @dtopt Callbacks
  8921. * @name DataTable.defaults.rowCallback
  8922. *
  8923. * @example
  8924. * $(document).ready( function() {
  8925. * $('#example').dataTable( {
  8926. * "rowCallback": function( row, data, displayIndex, displayIndexFull ) {
  8927. * // Bold the grade for all 'A' grade browsers
  8928. * if ( data[4] == "A" ) {
  8929. * $('td:eq(4)', row).html( '<b>A</b>' );
  8930. * }
  8931. * }
  8932. * } );
  8933. * } );
  8934. */
  8935. "fnRowCallback": null,
  8936. /**
  8937. * __Deprecated__ The functionality provided by this parameter has now been
  8938. * superseded by that provided through `ajax`, which should be used instead.
  8939. *
  8940. * This parameter allows you to override the default function which obtains
  8941. * the data from the server so something more suitable for your application.
  8942. * For example you could use POST data, or pull information from a Gears or
  8943. * AIR database.
  8944. * @type function
  8945. * @member
  8946. * @param {string} source HTTP source to obtain the data from (`ajax`)
  8947. * @param {array} data A key/value pair object containing the data to send
  8948. * to the server
  8949. * @param {function} callback to be called on completion of the data get
  8950. * process that will draw the data on the page.
  8951. * @param {object} settings DataTables settings object
  8952. *
  8953. * @dtopt Callbacks
  8954. * @dtopt Server-side
  8955. * @name DataTable.defaults.serverData
  8956. *
  8957. * @deprecated 1.10. Please use `ajax` for this functionality now.
  8958. */
  8959. "fnServerData": null,
  8960. /**
  8961. * __Deprecated__ The functionality provided by this parameter has now been
  8962. * superseded by that provided through `ajax`, which should be used instead.
  8963. *
  8964. * It is often useful to send extra data to the server when making an Ajax
  8965. * request - for example custom filtering information, and this callback
  8966. * function makes it trivial to send extra information to the server. The
  8967. * passed in parameter is the data set that has been constructed by
  8968. * DataTables, and you can add to this or modify it as you require.
  8969. * @type function
  8970. * @param {array} data Data array (array of objects which are name/value
  8971. * pairs) that has been constructed by DataTables and will be sent to the
  8972. * server. In the case of Ajax sourced data with server-side processing
  8973. * this will be an empty array, for server-side processing there will be a
  8974. * significant number of parameters!
  8975. * @returns {undefined} Ensure that you modify the data array passed in,
  8976. * as this is passed by reference.
  8977. *
  8978. * @dtopt Callbacks
  8979. * @dtopt Server-side
  8980. * @name DataTable.defaults.serverParams
  8981. *
  8982. * @deprecated 1.10. Please use `ajax` for this functionality now.
  8983. */
  8984. "fnServerParams": null,
  8985. /**
  8986. * Load the table state. With this function you can define from where, and how, the
  8987. * state of a table is loaded. By default DataTables will load from `localStorage`
  8988. * but you might wish to use a server-side database or cookies.
  8989. * @type function
  8990. * @member
  8991. * @param {object} settings DataTables settings object
  8992. * @return {object} The DataTables state object to be loaded
  8993. *
  8994. * @dtopt Callbacks
  8995. * @name DataTable.defaults.stateLoadCallback
  8996. *
  8997. * @example
  8998. * $(document).ready( function() {
  8999. * $('#example').dataTable( {
  9000. * "stateSave": true,
  9001. * "stateLoadCallback": function (settings) {
  9002. * var o;
  9003. *
  9004. * // Send an Ajax request to the server to get the data. Note that
  9005. * // this is a synchronous request.
  9006. * $.ajax( {
  9007. * "url": "/state_load",
  9008. * "async": false,
  9009. * "dataType": "json",
  9010. * "success": function (json) {
  9011. * o = json;
  9012. * }
  9013. * } );
  9014. *
  9015. * return o;
  9016. * }
  9017. * } );
  9018. * } );
  9019. */
  9020. "fnStateLoadCallback": function ( settings ) {
  9021. try {
  9022. return JSON.parse(
  9023. (settings.iStateDuration === -1 ? sessionStorage : localStorage).getItem(
  9024. 'DataTables_'+settings.sInstance+'_'+location.pathname
  9025. )
  9026. );
  9027. } catch (e) {}
  9028. },
  9029. /**
  9030. * Callback which allows modification of the saved state prior to loading that state.
  9031. * This callback is called when the table is loading state from the stored data, but
  9032. * prior to the settings object being modified by the saved state. Note that for
  9033. * plug-in authors, you should use the `stateLoadParams` event to load parameters for
  9034. * a plug-in.
  9035. * @type function
  9036. * @param {object} settings DataTables settings object
  9037. * @param {object} data The state object that is to be loaded
  9038. *
  9039. * @dtopt Callbacks
  9040. * @name DataTable.defaults.stateLoadParams
  9041. *
  9042. * @example
  9043. * // Remove a saved filter, so filtering is never loaded
  9044. * $(document).ready( function() {
  9045. * $('#example').dataTable( {
  9046. * "stateSave": true,
  9047. * "stateLoadParams": function (settings, data) {
  9048. * data.oSearch.sSearch = "";
  9049. * }
  9050. * } );
  9051. * } );
  9052. *
  9053. * @example
  9054. * // Disallow state loading by returning false
  9055. * $(document).ready( function() {
  9056. * $('#example').dataTable( {
  9057. * "stateSave": true,
  9058. * "stateLoadParams": function (settings, data) {
  9059. * return false;
  9060. * }
  9061. * } );
  9062. * } );
  9063. */
  9064. "fnStateLoadParams": null,
  9065. /**
  9066. * Callback that is called when the state has been loaded from the state saving method
  9067. * and the DataTables settings object has been modified as a result of the loaded state.
  9068. * @type function
  9069. * @param {object} settings DataTables settings object
  9070. * @param {object} data The state object that was loaded
  9071. *
  9072. * @dtopt Callbacks
  9073. * @name DataTable.defaults.stateLoaded
  9074. *
  9075. * @example
  9076. * // Show an alert with the filtering value that was saved
  9077. * $(document).ready( function() {
  9078. * $('#example').dataTable( {
  9079. * "stateSave": true,
  9080. * "stateLoaded": function (settings, data) {
  9081. * alert( 'Saved filter was: '+data.oSearch.sSearch );
  9082. * }
  9083. * } );
  9084. * } );
  9085. */
  9086. "fnStateLoaded": null,
  9087. /**
  9088. * Save the table state. This function allows you to define where and how the state
  9089. * information for the table is stored By default DataTables will use `localStorage`
  9090. * but you might wish to use a server-side database or cookies.
  9091. * @type function
  9092. * @member
  9093. * @param {object} settings DataTables settings object
  9094. * @param {object} data The state object to be saved
  9095. *
  9096. * @dtopt Callbacks
  9097. * @name DataTable.defaults.stateSaveCallback
  9098. *
  9099. * @example
  9100. * $(document).ready( function() {
  9101. * $('#example').dataTable( {
  9102. * "stateSave": true,
  9103. * "stateSaveCallback": function (settings, data) {
  9104. * // Send an Ajax request to the server with the state object
  9105. * $.ajax( {
  9106. * "url": "/state_save",
  9107. * "data": data,
  9108. * "dataType": "json",
  9109. * "method": "POST"
  9110. * "success": function () {}
  9111. * } );
  9112. * }
  9113. * } );
  9114. * } );
  9115. */
  9116. "fnStateSaveCallback": function ( settings, data ) {
  9117. try {
  9118. (settings.iStateDuration === -1 ? sessionStorage : localStorage).setItem(
  9119. 'DataTables_'+settings.sInstance+'_'+location.pathname,
  9120. JSON.stringify( data )
  9121. );
  9122. } catch (e) {}
  9123. },
  9124. /**
  9125. * Callback which allows modification of the state to be saved. Called when the table
  9126. * has changed state a new state save is required. This method allows modification of
  9127. * the state saving object prior to actually doing the save, including addition or
  9128. * other state properties or modification. Note that for plug-in authors, you should
  9129. * use the `stateSaveParams` event to save parameters for a plug-in.
  9130. * @type function
  9131. * @param {object} settings DataTables settings object
  9132. * @param {object} data The state object to be saved
  9133. *
  9134. * @dtopt Callbacks
  9135. * @name DataTable.defaults.stateSaveParams
  9136. *
  9137. * @example
  9138. * // Remove a saved filter, so filtering is never saved
  9139. * $(document).ready( function() {
  9140. * $('#example').dataTable( {
  9141. * "stateSave": true,
  9142. * "stateSaveParams": function (settings, data) {
  9143. * data.oSearch.sSearch = "";
  9144. * }
  9145. * } );
  9146. * } );
  9147. */
  9148. "fnStateSaveParams": null,
  9149. /**
  9150. * Duration for which the saved state information is considered valid. After this period
  9151. * has elapsed the state will be returned to the default.
  9152. * Value is given in seconds.
  9153. * @type int
  9154. * @default 7200 <i>(2 hours)</i>
  9155. *
  9156. * @dtopt Options
  9157. * @name DataTable.defaults.stateDuration
  9158. *
  9159. * @example
  9160. * $(document).ready( function() {
  9161. * $('#example').dataTable( {
  9162. * "stateDuration": 60*60*24; // 1 day
  9163. * } );
  9164. * } )
  9165. */
  9166. "iStateDuration": 7200,
  9167. /**
  9168. * When enabled DataTables will not make a request to the server for the first
  9169. * page draw - rather it will use the data already on the page (no sorting etc
  9170. * will be applied to it), thus saving on an XHR at load time. `deferLoading`
  9171. * is used to indicate that deferred loading is required, but it is also used
  9172. * to tell DataTables how many records there are in the full table (allowing
  9173. * the information element and pagination to be displayed correctly). In the case
  9174. * where a filtering is applied to the table on initial load, this can be
  9175. * indicated by giving the parameter as an array, where the first element is
  9176. * the number of records available after filtering and the second element is the
  9177. * number of records without filtering (allowing the table information element
  9178. * to be shown correctly).
  9179. * @type int | array
  9180. * @default null
  9181. *
  9182. * @dtopt Options
  9183. * @name DataTable.defaults.deferLoading
  9184. *
  9185. * @example
  9186. * // 57 records available in the table, no filtering applied
  9187. * $(document).ready( function() {
  9188. * $('#example').dataTable( {
  9189. * "serverSide": true,
  9190. * "ajax": "scripts/server_processing.php",
  9191. * "deferLoading": 57
  9192. * } );
  9193. * } );
  9194. *
  9195. * @example
  9196. * // 57 records after filtering, 100 without filtering (an initial filter applied)
  9197. * $(document).ready( function() {
  9198. * $('#example').dataTable( {
  9199. * "serverSide": true,
  9200. * "ajax": "scripts/server_processing.php",
  9201. * "deferLoading": [ 57, 100 ],
  9202. * "search": {
  9203. * "search": "my_filter"
  9204. * }
  9205. * } );
  9206. * } );
  9207. */
  9208. "iDeferLoading": null,
  9209. /**
  9210. * Number of rows to display on a single page when using pagination. If
  9211. * feature enabled (`lengthChange`) then the end user will be able to override
  9212. * this to a custom setting using a pop-up menu.
  9213. * @type int
  9214. * @default 10
  9215. *
  9216. * @dtopt Options
  9217. * @name DataTable.defaults.pageLength
  9218. *
  9219. * @example
  9220. * $(document).ready( function() {
  9221. * $('#example').dataTable( {
  9222. * "pageLength": 50
  9223. * } );
  9224. * } )
  9225. */
  9226. "iDisplayLength": 10,
  9227. /**
  9228. * Define the starting point for data display when using DataTables with
  9229. * pagination. Note that this parameter is the number of records, rather than
  9230. * the page number, so if you have 10 records per page and want to start on
  9231. * the third page, it should be "20".
  9232. * @type int
  9233. * @default 0
  9234. *
  9235. * @dtopt Options
  9236. * @name DataTable.defaults.displayStart
  9237. *
  9238. * @example
  9239. * $(document).ready( function() {
  9240. * $('#example').dataTable( {
  9241. * "displayStart": 20
  9242. * } );
  9243. * } )
  9244. */
  9245. "iDisplayStart": 0,
  9246. /**
  9247. * By default DataTables allows keyboard navigation of the table (sorting, paging,
  9248. * and filtering) by adding a `tabindex` attribute to the required elements. This
  9249. * allows you to tab through the controls and press the enter key to activate them.
  9250. * The tabindex is default 0, meaning that the tab follows the flow of the document.
  9251. * You can overrule this using this parameter if you wish. Use a value of -1 to
  9252. * disable built-in keyboard navigation.
  9253. * @type int
  9254. * @default 0
  9255. *
  9256. * @dtopt Options
  9257. * @name DataTable.defaults.tabIndex
  9258. *
  9259. * @example
  9260. * $(document).ready( function() {
  9261. * $('#example').dataTable( {
  9262. * "tabIndex": 1
  9263. * } );
  9264. * } );
  9265. */
  9266. "iTabIndex": 0,
  9267. /**
  9268. * Classes that DataTables assigns to the various components and features
  9269. * that it adds to the HTML table. This allows classes to be configured
  9270. * during initialisation in addition to through the static
  9271. * {@link DataTable.ext.oStdClasses} object).
  9272. * @namespace
  9273. * @name DataTable.defaults.classes
  9274. */
  9275. "oClasses": {},
  9276. /**
  9277. * All strings that DataTables uses in the user interface that it creates
  9278. * are defined in this object, allowing you to modified them individually or
  9279. * completely replace them all as required.
  9280. * @namespace
  9281. * @name DataTable.defaults.language
  9282. */
  9283. "oLanguage": {
  9284. /**
  9285. * Strings that are used for WAI-ARIA labels and controls only (these are not
  9286. * actually visible on the page, but will be read by screenreaders, and thus
  9287. * must be internationalised as well).
  9288. * @namespace
  9289. * @name DataTable.defaults.language.aria
  9290. */
  9291. "oAria": {
  9292. /**
  9293. * ARIA label that is added to the table headers when the column may be
  9294. * sorted ascending by activing the column (click or return when focused).
  9295. * Note that the column header is prefixed to this string.
  9296. * @type string
  9297. * @default : activate to sort column ascending
  9298. *
  9299. * @dtopt Language
  9300. * @name DataTable.defaults.language.aria.sortAscending
  9301. *
  9302. * @example
  9303. * $(document).ready( function() {
  9304. * $('#example').dataTable( {
  9305. * "language": {
  9306. * "aria": {
  9307. * "sortAscending": " - click/return to sort ascending"
  9308. * }
  9309. * }
  9310. * } );
  9311. * } );
  9312. */
  9313. "sSortAscending": ": activate to sort column ascending",
  9314. /**
  9315. * ARIA label that is added to the table headers when the column may be
  9316. * sorted descending by activing the column (click or return when focused).
  9317. * Note that the column header is prefixed to this string.
  9318. * @type string
  9319. * @default : activate to sort column ascending
  9320. *
  9321. * @dtopt Language
  9322. * @name DataTable.defaults.language.aria.sortDescending
  9323. *
  9324. * @example
  9325. * $(document).ready( function() {
  9326. * $('#example').dataTable( {
  9327. * "language": {
  9328. * "aria": {
  9329. * "sortDescending": " - click/return to sort descending"
  9330. * }
  9331. * }
  9332. * } );
  9333. * } );
  9334. */
  9335. "sSortDescending": ": activate to sort column descending"
  9336. },
  9337. /**
  9338. * Pagination string used by DataTables for the built-in pagination
  9339. * control types.
  9340. * @namespace
  9341. * @name DataTable.defaults.language.paginate
  9342. */
  9343. "oPaginate": {
  9344. /**
  9345. * Text to use when using the 'full_numbers' type of pagination for the
  9346. * button to take the user to the first page.
  9347. * @type string
  9348. * @default First
  9349. *
  9350. * @dtopt Language
  9351. * @name DataTable.defaults.language.paginate.first
  9352. *
  9353. * @example
  9354. * $(document).ready( function() {
  9355. * $('#example').dataTable( {
  9356. * "language": {
  9357. * "paginate": {
  9358. * "first": "First page"
  9359. * }
  9360. * }
  9361. * } );
  9362. * } );
  9363. */
  9364. "sFirst": "First",
  9365. /**
  9366. * Text to use when using the 'full_numbers' type of pagination for the
  9367. * button to take the user to the last page.
  9368. * @type string
  9369. * @default Last
  9370. *
  9371. * @dtopt Language
  9372. * @name DataTable.defaults.language.paginate.last
  9373. *
  9374. * @example
  9375. * $(document).ready( function() {
  9376. * $('#example').dataTable( {
  9377. * "language": {
  9378. * "paginate": {
  9379. * "last": "Last page"
  9380. * }
  9381. * }
  9382. * } );
  9383. * } );
  9384. */
  9385. "sLast": "Last",
  9386. /**
  9387. * Text to use for the 'next' pagination button (to take the user to the
  9388. * next page).
  9389. * @type string
  9390. * @default Next
  9391. *
  9392. * @dtopt Language
  9393. * @name DataTable.defaults.language.paginate.next
  9394. *
  9395. * @example
  9396. * $(document).ready( function() {
  9397. * $('#example').dataTable( {
  9398. * "language": {
  9399. * "paginate": {
  9400. * "next": "Next page"
  9401. * }
  9402. * }
  9403. * } );
  9404. * } );
  9405. */
  9406. "sNext": "Next",
  9407. /**
  9408. * Text to use for the 'previous' pagination button (to take the user to
  9409. * the previous page).
  9410. * @type string
  9411. * @default Previous
  9412. *
  9413. * @dtopt Language
  9414. * @name DataTable.defaults.language.paginate.previous
  9415. *
  9416. * @example
  9417. * $(document).ready( function() {
  9418. * $('#example').dataTable( {
  9419. * "language": {
  9420. * "paginate": {
  9421. * "previous": "Previous page"
  9422. * }
  9423. * }
  9424. * } );
  9425. * } );
  9426. */
  9427. "sPrevious": "Previous"
  9428. },
  9429. /**
  9430. * This string is shown in preference to `zeroRecords` when the table is
  9431. * empty of data (regardless of filtering). Note that this is an optional
  9432. * parameter - if it is not given, the value of `zeroRecords` will be used
  9433. * instead (either the default or given value).
  9434. * @type string
  9435. * @default No data available in table
  9436. *
  9437. * @dtopt Language
  9438. * @name DataTable.defaults.language.emptyTable
  9439. *
  9440. * @example
  9441. * $(document).ready( function() {
  9442. * $('#example').dataTable( {
  9443. * "language": {
  9444. * "emptyTable": "No data available in table"
  9445. * }
  9446. * } );
  9447. * } );
  9448. */
  9449. "sEmptyTable": "No data available in table",
  9450. /**
  9451. * This string gives information to the end user about the information
  9452. * that is current on display on the page. The following tokens can be
  9453. * used in the string and will be dynamically replaced as the table
  9454. * display updates. This tokens can be placed anywhere in the string, or
  9455. * removed as needed by the language requires:
  9456. *
  9457. * * `\_START\_` - Display index of the first record on the current page
  9458. * * `\_END\_` - Display index of the last record on the current page
  9459. * * `\_TOTAL\_` - Number of records in the table after filtering
  9460. * * `\_MAX\_` - Number of records in the table without filtering
  9461. * * `\_PAGE\_` - Current page number
  9462. * * `\_PAGES\_` - Total number of pages of data in the table
  9463. *
  9464. * @type string
  9465. * @default Showing _START_ to _END_ of _TOTAL_ entries
  9466. *
  9467. * @dtopt Language
  9468. * @name DataTable.defaults.language.info
  9469. *
  9470. * @example
  9471. * $(document).ready( function() {
  9472. * $('#example').dataTable( {
  9473. * "language": {
  9474. * "info": "Showing page _PAGE_ of _PAGES_"
  9475. * }
  9476. * } );
  9477. * } );
  9478. */
  9479. "sInfo": "Showing _START_ to _END_ of _TOTAL_ entries",
  9480. /**
  9481. * Display information string for when the table is empty. Typically the
  9482. * format of this string should match `info`.
  9483. * @type string
  9484. * @default Showing 0 to 0 of 0 entries
  9485. *
  9486. * @dtopt Language
  9487. * @name DataTable.defaults.language.infoEmpty
  9488. *
  9489. * @example
  9490. * $(document).ready( function() {
  9491. * $('#example').dataTable( {
  9492. * "language": {
  9493. * "infoEmpty": "No entries to show"
  9494. * }
  9495. * } );
  9496. * } );
  9497. */
  9498. "sInfoEmpty": "Showing 0 to 0 of 0 entries",
  9499. /**
  9500. * When a user filters the information in a table, this string is appended
  9501. * to the information (`info`) to give an idea of how strong the filtering
  9502. * is. The variable _MAX_ is dynamically updated.
  9503. * @type string
  9504. * @default (filtered from _MAX_ total entries)
  9505. *
  9506. * @dtopt Language
  9507. * @name DataTable.defaults.language.infoFiltered
  9508. *
  9509. * @example
  9510. * $(document).ready( function() {
  9511. * $('#example').dataTable( {
  9512. * "language": {
  9513. * "infoFiltered": " - filtering from _MAX_ records"
  9514. * }
  9515. * } );
  9516. * } );
  9517. */
  9518. "sInfoFiltered": "(filtered from _MAX_ total entries)",
  9519. /**
  9520. * If can be useful to append extra information to the info string at times,
  9521. * and this variable does exactly that. This information will be appended to
  9522. * the `info` (`infoEmpty` and `infoFiltered` in whatever combination they are
  9523. * being used) at all times.
  9524. * @type string
  9525. * @default <i>Empty string</i>
  9526. *
  9527. * @dtopt Language
  9528. * @name DataTable.defaults.language.infoPostFix
  9529. *
  9530. * @example
  9531. * $(document).ready( function() {
  9532. * $('#example').dataTable( {
  9533. * "language": {
  9534. * "infoPostFix": "All records shown are derived from real information."
  9535. * }
  9536. * } );
  9537. * } );
  9538. */
  9539. "sInfoPostFix": "",
  9540. /**
  9541. * This decimal place operator is a little different from the other
  9542. * language options since DataTables doesn't output floating point
  9543. * numbers, so it won't ever use this for display of a number. Rather,
  9544. * what this parameter does is modify the sort methods of the table so
  9545. * that numbers which are in a format which has a character other than
  9546. * a period (`.`) as a decimal place will be sorted numerically.
  9547. *
  9548. * Note that numbers with different decimal places cannot be shown in
  9549. * the same table and still be sortable, the table must be consistent.
  9550. * However, multiple different tables on the page can use different
  9551. * decimal place characters.
  9552. * @type string
  9553. * @default
  9554. *
  9555. * @dtopt Language
  9556. * @name DataTable.defaults.language.decimal
  9557. *
  9558. * @example
  9559. * $(document).ready( function() {
  9560. * $('#example').dataTable( {
  9561. * "language": {
  9562. * "decimal": ","
  9563. * "thousands": "."
  9564. * }
  9565. * } );
  9566. * } );
  9567. */
  9568. "sDecimal": "",
  9569. /**
  9570. * DataTables has a build in number formatter (`formatNumber`) which is
  9571. * used to format large numbers that are used in the table information.
  9572. * By default a comma is used, but this can be trivially changed to any
  9573. * character you wish with this parameter.
  9574. * @type string
  9575. * @default ,
  9576. *
  9577. * @dtopt Language
  9578. * @name DataTable.defaults.language.thousands
  9579. *
  9580. * @example
  9581. * $(document).ready( function() {
  9582. * $('#example').dataTable( {
  9583. * "language": {
  9584. * "thousands": "'"
  9585. * }
  9586. * } );
  9587. * } );
  9588. */
  9589. "sThousands": ",",
  9590. /**
  9591. * Detail the action that will be taken when the drop down menu for the
  9592. * pagination length option is changed. The '_MENU_' variable is replaced
  9593. * with a default select list of 10, 25, 50 and 100, and can be replaced
  9594. * with a custom select box if required.
  9595. * @type string
  9596. * @default Show _MENU_ entries
  9597. *
  9598. * @dtopt Language
  9599. * @name DataTable.defaults.language.lengthMenu
  9600. *
  9601. * @example
  9602. * // Language change only
  9603. * $(document).ready( function() {
  9604. * $('#example').dataTable( {
  9605. * "language": {
  9606. * "lengthMenu": "Display _MENU_ records"
  9607. * }
  9608. * } );
  9609. * } );
  9610. *
  9611. * @example
  9612. * // Language and options change
  9613. * $(document).ready( function() {
  9614. * $('#example').dataTable( {
  9615. * "language": {
  9616. * "lengthMenu": 'Display <select>'+
  9617. * '<option value="10">10</option>'+
  9618. * '<option value="20">20</option>'+
  9619. * '<option value="30">30</option>'+
  9620. * '<option value="40">40</option>'+
  9621. * '<option value="50">50</option>'+
  9622. * '<option value="-1">All</option>'+
  9623. * '</select> records'
  9624. * }
  9625. * } );
  9626. * } );
  9627. */
  9628. "sLengthMenu": "Show _MENU_ entries",
  9629. /**
  9630. * When using Ajax sourced data and during the first draw when DataTables is
  9631. * gathering the data, this message is shown in an empty row in the table to
  9632. * indicate to the end user the the data is being loaded. Note that this
  9633. * parameter is not used when loading data by server-side processing, just
  9634. * Ajax sourced data with client-side processing.
  9635. * @type string
  9636. * @default Loading...
  9637. *
  9638. * @dtopt Language
  9639. * @name DataTable.defaults.language.loadingRecords
  9640. *
  9641. * @example
  9642. * $(document).ready( function() {
  9643. * $('#example').dataTable( {
  9644. * "language": {
  9645. * "loadingRecords": "Please wait - loading..."
  9646. * }
  9647. * } );
  9648. * } );
  9649. */
  9650. "sLoadingRecords": "Loading...",
  9651. /**
  9652. * Text which is displayed when the table is processing a user action
  9653. * (usually a sort command or similar).
  9654. * @type string
  9655. * @default Processing...
  9656. *
  9657. * @dtopt Language
  9658. * @name DataTable.defaults.language.processing
  9659. *
  9660. * @example
  9661. * $(document).ready( function() {
  9662. * $('#example').dataTable( {
  9663. * "language": {
  9664. * "processing": "DataTables is currently busy"
  9665. * }
  9666. * } );
  9667. * } );
  9668. */
  9669. "sProcessing": "Processing...",
  9670. /**
  9671. * Details the actions that will be taken when the user types into the
  9672. * filtering input text box. The variable "_INPUT_", if used in the string,
  9673. * is replaced with the HTML text box for the filtering input allowing
  9674. * control over where it appears in the string. If "_INPUT_" is not given
  9675. * then the input box is appended to the string automatically.
  9676. * @type string
  9677. * @default Search:
  9678. *
  9679. * @dtopt Language
  9680. * @name DataTable.defaults.language.search
  9681. *
  9682. * @example
  9683. * // Input text box will be appended at the end automatically
  9684. * $(document).ready( function() {
  9685. * $('#example').dataTable( {
  9686. * "language": {
  9687. * "search": "Filter records:"
  9688. * }
  9689. * } );
  9690. * } );
  9691. *
  9692. * @example
  9693. * // Specify where the filter should appear
  9694. * $(document).ready( function() {
  9695. * $('#example').dataTable( {
  9696. * "language": {
  9697. * "search": "Apply filter _INPUT_ to table"
  9698. * }
  9699. * } );
  9700. * } );
  9701. */
  9702. "sSearch": "Search:",
  9703. /**
  9704. * Assign a `placeholder` attribute to the search `input` element
  9705. * @type string
  9706. * @default
  9707. *
  9708. * @dtopt Language
  9709. * @name DataTable.defaults.language.searchPlaceholder
  9710. */
  9711. "sSearchPlaceholder": "",
  9712. /**
  9713. * All of the language information can be stored in a file on the
  9714. * server-side, which DataTables will look up if this parameter is passed.
  9715. * It must store the URL of the language file, which is in a JSON format,
  9716. * and the object has the same properties as the oLanguage object in the
  9717. * initialiser object (i.e. the above parameters). Please refer to one of
  9718. * the example language files to see how this works in action.
  9719. * @type string
  9720. * @default <i>Empty string - i.e. disabled</i>
  9721. *
  9722. * @dtopt Language
  9723. * @name DataTable.defaults.language.url
  9724. *
  9725. * @example
  9726. * $(document).ready( function() {
  9727. * $('#example').dataTable( {
  9728. * "language": {
  9729. * "url": "http://www.sprymedia.co.uk/dataTables/lang.txt"
  9730. * }
  9731. * } );
  9732. * } );
  9733. */
  9734. "sUrl": "",
  9735. /**
  9736. * Text shown inside the table records when the is no information to be
  9737. * displayed after filtering. `emptyTable` is shown when there is simply no
  9738. * information in the table at all (regardless of filtering).
  9739. * @type string
  9740. * @default No matching records found
  9741. *
  9742. * @dtopt Language
  9743. * @name DataTable.defaults.language.zeroRecords
  9744. *
  9745. * @example
  9746. * $(document).ready( function() {
  9747. * $('#example').dataTable( {
  9748. * "language": {
  9749. * "zeroRecords": "No records to display"
  9750. * }
  9751. * } );
  9752. * } );
  9753. */
  9754. "sZeroRecords": "No matching records found"
  9755. },
  9756. /**
  9757. * This parameter allows you to have define the global filtering state at
  9758. * initialisation time. As an object the `search` parameter must be
  9759. * defined, but all other parameters are optional. When `regex` is true,
  9760. * the search string will be treated as a regular expression, when false
  9761. * (default) it will be treated as a straight string. When `smart`
  9762. * DataTables will use it's smart filtering methods (to word match at
  9763. * any point in the data), when false this will not be done.
  9764. * @namespace
  9765. * @extends DataTable.models.oSearch
  9766. *
  9767. * @dtopt Options
  9768. * @name DataTable.defaults.search
  9769. *
  9770. * @example
  9771. * $(document).ready( function() {
  9772. * $('#example').dataTable( {
  9773. * "search": {"search": "Initial search"}
  9774. * } );
  9775. * } )
  9776. */
  9777. "oSearch": $.extend( {}, DataTable.models.oSearch ),
  9778. /**
  9779. * __Deprecated__ The functionality provided by this parameter has now been
  9780. * superseded by that provided through `ajax`, which should be used instead.
  9781. *
  9782. * By default DataTables will look for the property `data` (or `aaData` for
  9783. * compatibility with DataTables 1.9-) when obtaining data from an Ajax
  9784. * source or for server-side processing - this parameter allows that
  9785. * property to be changed. You can use Javascript dotted object notation to
  9786. * get a data source for multiple levels of nesting.
  9787. * @type string
  9788. * @default data
  9789. *
  9790. * @dtopt Options
  9791. * @dtopt Server-side
  9792. * @name DataTable.defaults.ajaxDataProp
  9793. *
  9794. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9795. */
  9796. "sAjaxDataProp": "data",
  9797. /**
  9798. * __Deprecated__ The functionality provided by this parameter has now been
  9799. * superseded by that provided through `ajax`, which should be used instead.
  9800. *
  9801. * You can instruct DataTables to load data from an external
  9802. * source using this parameter (use aData if you want to pass data in you
  9803. * already have). Simply provide a url a JSON object can be obtained from.
  9804. * @type string
  9805. * @default null
  9806. *
  9807. * @dtopt Options
  9808. * @dtopt Server-side
  9809. * @name DataTable.defaults.ajaxSource
  9810. *
  9811. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9812. */
  9813. "sAjaxSource": null,
  9814. /**
  9815. * This initialisation variable allows you to specify exactly where in the
  9816. * DOM you want DataTables to inject the various controls it adds to the page
  9817. * (for example you might want the pagination controls at the top of the
  9818. * table). DIV elements (with or without a custom class) can also be added to
  9819. * aid styling. The follow syntax is used:
  9820. * <ul>
  9821. * <li>The following options are allowed:
  9822. * <ul>
  9823. * <li>'l' - Length changing</li>
  9824. * <li>'f' - Filtering input</li>
  9825. * <li>'t' - The table!</li>
  9826. * <li>'i' - Information</li>
  9827. * <li>'p' - Pagination</li>
  9828. * <li>'r' - pRocessing</li>
  9829. * </ul>
  9830. * </li>
  9831. * <li>The following constants are allowed:
  9832. * <ul>
  9833. * <li>'H' - jQueryUI theme "header" classes ('fg-toolbar ui-widget-header ui-corner-tl ui-corner-tr ui-helper-clearfix')</li>
  9834. * <li>'F' - jQueryUI theme "footer" classes ('fg-toolbar ui-widget-header ui-corner-bl ui-corner-br ui-helper-clearfix')</li>
  9835. * </ul>
  9836. * </li>
  9837. * <li>The following syntax is expected:
  9838. * <ul>
  9839. * <li>'&lt;' and '&gt;' - div elements</li>
  9840. * <li>'&lt;"class" and '&gt;' - div with a class</li>
  9841. * <li>'&lt;"#id" and '&gt;' - div with an ID</li>
  9842. * </ul>
  9843. * </li>
  9844. * <li>Examples:
  9845. * <ul>
  9846. * <li>'&lt;"wrapper"flipt&gt;'</li>
  9847. * <li>'&lt;lf&lt;t&gt;ip&gt;'</li>
  9848. * </ul>
  9849. * </li>
  9850. * </ul>
  9851. * @type string
  9852. * @default lfrtip <i>(when `jQueryUI` is false)</i> <b>or</b>
  9853. * <"H"lfr>t<"F"ip> <i>(when `jQueryUI` is true)</i>
  9854. *
  9855. * @dtopt Options
  9856. * @name DataTable.defaults.dom
  9857. *
  9858. * @example
  9859. * $(document).ready( function() {
  9860. * $('#example').dataTable( {
  9861. * "dom": '&lt;"top"i&gt;rt&lt;"bottom"flp&gt;&lt;"clear"&gt;'
  9862. * } );
  9863. * } );
  9864. */
  9865. "sDom": "lfrtip",
  9866. /**
  9867. * Search delay option. This will throttle full table searches that use the
  9868. * DataTables provided search input element (it does not effect calls to
  9869. * `dt-api search()`, providing a delay before the search is made.
  9870. * @type integer
  9871. * @default 0
  9872. *
  9873. * @dtopt Options
  9874. * @name DataTable.defaults.searchDelay
  9875. *
  9876. * @example
  9877. * $(document).ready( function() {
  9878. * $('#example').dataTable( {
  9879. * "searchDelay": 200
  9880. * } );
  9881. * } )
  9882. */
  9883. "searchDelay": null,
  9884. /**
  9885. * DataTables features four different built-in options for the buttons to
  9886. * display for pagination control:
  9887. *
  9888. * * `simple` - 'Previous' and 'Next' buttons only
  9889. * * 'simple_numbers` - 'Previous' and 'Next' buttons, plus page numbers
  9890. * * `full` - 'First', 'Previous', 'Next' and 'Last' buttons
  9891. * * `full_numbers` - 'First', 'Previous', 'Next' and 'Last' buttons, plus
  9892. * page numbers
  9893. *
  9894. * Further methods can be added using {@link DataTable.ext.oPagination}.
  9895. * @type string
  9896. * @default simple_numbers
  9897. *
  9898. * @dtopt Options
  9899. * @name DataTable.defaults.pagingType
  9900. *
  9901. * @example
  9902. * $(document).ready( function() {
  9903. * $('#example').dataTable( {
  9904. * "pagingType": "full_numbers"
  9905. * } );
  9906. * } )
  9907. */
  9908. "sPaginationType": "simple_numbers",
  9909. /**
  9910. * Enable horizontal scrolling. When a table is too wide to fit into a
  9911. * certain layout, or you have a large number of columns in the table, you
  9912. * can enable x-scrolling to show the table in a viewport, which can be
  9913. * scrolled. This property can be `true` which will allow the table to
  9914. * scroll horizontally when needed, or any CSS unit, or a number (in which
  9915. * case it will be treated as a pixel measurement). Setting as simply `true`
  9916. * is recommended.
  9917. * @type boolean|string
  9918. * @default <i>blank string - i.e. disabled</i>
  9919. *
  9920. * @dtopt Features
  9921. * @name DataTable.defaults.scrollX
  9922. *
  9923. * @example
  9924. * $(document).ready( function() {
  9925. * $('#example').dataTable( {
  9926. * "scrollX": true,
  9927. * "scrollCollapse": true
  9928. * } );
  9929. * } );
  9930. */
  9931. "sScrollX": "",
  9932. /**
  9933. * This property can be used to force a DataTable to use more width than it
  9934. * might otherwise do when x-scrolling is enabled. For example if you have a
  9935. * table which requires to be well spaced, this parameter is useful for
  9936. * "over-sizing" the table, and thus forcing scrolling. This property can by
  9937. * any CSS unit, or a number (in which case it will be treated as a pixel
  9938. * measurement).
  9939. * @type string
  9940. * @default <i>blank string - i.e. disabled</i>
  9941. *
  9942. * @dtopt Options
  9943. * @name DataTable.defaults.scrollXInner
  9944. *
  9945. * @example
  9946. * $(document).ready( function() {
  9947. * $('#example').dataTable( {
  9948. * "scrollX": "100%",
  9949. * "scrollXInner": "110%"
  9950. * } );
  9951. * } );
  9952. */
  9953. "sScrollXInner": "",
  9954. /**
  9955. * Enable vertical scrolling. Vertical scrolling will constrain the DataTable
  9956. * to the given height, and enable scrolling for any data which overflows the
  9957. * current viewport. This can be used as an alternative to paging to display
  9958. * a lot of data in a small area (although paging and scrolling can both be
  9959. * enabled at the same time). This property can be any CSS unit, or a number
  9960. * (in which case it will be treated as a pixel measurement).
  9961. * @type string
  9962. * @default <i>blank string - i.e. disabled</i>
  9963. *
  9964. * @dtopt Features
  9965. * @name DataTable.defaults.scrollY
  9966. *
  9967. * @example
  9968. * $(document).ready( function() {
  9969. * $('#example').dataTable( {
  9970. * "scrollY": "200px",
  9971. * "paginate": false
  9972. * } );
  9973. * } );
  9974. */
  9975. "sScrollY": "",
  9976. /**
  9977. * __Deprecated__ The functionality provided by this parameter has now been
  9978. * superseded by that provided through `ajax`, which should be used instead.
  9979. *
  9980. * Set the HTTP method that is used to make the Ajax call for server-side
  9981. * processing or Ajax sourced data.
  9982. * @type string
  9983. * @default GET
  9984. *
  9985. * @dtopt Options
  9986. * @dtopt Server-side
  9987. * @name DataTable.defaults.serverMethod
  9988. *
  9989. * @deprecated 1.10. Please use `ajax` for this functionality now.
  9990. */
  9991. "sServerMethod": "GET",
  9992. /**
  9993. * DataTables makes use of renderers when displaying HTML elements for
  9994. * a table. These renderers can be added or modified by plug-ins to
  9995. * generate suitable mark-up for a site. For example the Bootstrap
  9996. * integration plug-in for DataTables uses a paging button renderer to
  9997. * display pagination buttons in the mark-up required by Bootstrap.
  9998. *
  9999. * For further information about the renderers available see
  10000. * DataTable.ext.renderer
  10001. * @type string|object
  10002. * @default null
  10003. *
  10004. * @name DataTable.defaults.renderer
  10005. *
  10006. */
  10007. "renderer": null
  10008. };
  10009. _fnHungarianMap( DataTable.defaults );
  10010. /*
  10011. * Developer note - See note in model.defaults.js about the use of Hungarian
  10012. * notation and camel case.
  10013. */
  10014. /**
  10015. * Column options that can be given to DataTables at initialisation time.
  10016. * @namespace
  10017. */
  10018. DataTable.defaults.column = {
  10019. /**
  10020. * Define which column(s) an order will occur on for this column. This
  10021. * allows a column's ordering to take multiple columns into account when
  10022. * doing a sort or use the data from a different column. For example first
  10023. * name / last name columns make sense to do a multi-column sort over the
  10024. * two columns.
  10025. * @type array|int
  10026. * @default null <i>Takes the value of the column index automatically</i>
  10027. *
  10028. * @name DataTable.defaults.column.orderData
  10029. * @dtopt Columns
  10030. *
  10031. * @example
  10032. * // Using `columnDefs`
  10033. * $(document).ready( function() {
  10034. * $('#example').dataTable( {
  10035. * "columnDefs": [
  10036. * { "orderData": [ 0, 1 ], "targets": [ 0 ] },
  10037. * { "orderData": [ 1, 0 ], "targets": [ 1 ] },
  10038. * { "orderData": 2, "targets": [ 2 ] }
  10039. * ]
  10040. * } );
  10041. * } );
  10042. *
  10043. * @example
  10044. * // Using `columns`
  10045. * $(document).ready( function() {
  10046. * $('#example').dataTable( {
  10047. * "columns": [
  10048. * { "orderData": [ 0, 1 ] },
  10049. * { "orderData": [ 1, 0 ] },
  10050. * { "orderData": 2 },
  10051. * null,
  10052. * null
  10053. * ]
  10054. * } );
  10055. * } );
  10056. */
  10057. "aDataSort": null,
  10058. "iDataSort": -1,
  10059. /**
  10060. * You can control the default ordering direction, and even alter the
  10061. * behaviour of the sort handler (i.e. only allow ascending ordering etc)
  10062. * using this parameter.
  10063. * @type array
  10064. * @default [ 'asc', 'desc' ]
  10065. *
  10066. * @name DataTable.defaults.column.orderSequence
  10067. * @dtopt Columns
  10068. *
  10069. * @example
  10070. * // Using `columnDefs`
  10071. * $(document).ready( function() {
  10072. * $('#example').dataTable( {
  10073. * "columnDefs": [
  10074. * { "orderSequence": [ "asc" ], "targets": [ 1 ] },
  10075. * { "orderSequence": [ "desc", "asc", "asc" ], "targets": [ 2 ] },
  10076. * { "orderSequence": [ "desc" ], "targets": [ 3 ] }
  10077. * ]
  10078. * } );
  10079. * } );
  10080. *
  10081. * @example
  10082. * // Using `columns`
  10083. * $(document).ready( function() {
  10084. * $('#example').dataTable( {
  10085. * "columns": [
  10086. * null,
  10087. * { "orderSequence": [ "asc" ] },
  10088. * { "orderSequence": [ "desc", "asc", "asc" ] },
  10089. * { "orderSequence": [ "desc" ] },
  10090. * null
  10091. * ]
  10092. * } );
  10093. * } );
  10094. */
  10095. "asSorting": [ 'asc', 'desc' ],
  10096. /**
  10097. * Enable or disable filtering on the data in this column.
  10098. * @type boolean
  10099. * @default true
  10100. *
  10101. * @name DataTable.defaults.column.searchable
  10102. * @dtopt Columns
  10103. *
  10104. * @example
  10105. * // Using `columnDefs`
  10106. * $(document).ready( function() {
  10107. * $('#example').dataTable( {
  10108. * "columnDefs": [
  10109. * { "searchable": false, "targets": [ 0 ] }
  10110. * ] } );
  10111. * } );
  10112. *
  10113. * @example
  10114. * // Using `columns`
  10115. * $(document).ready( function() {
  10116. * $('#example').dataTable( {
  10117. * "columns": [
  10118. * { "searchable": false },
  10119. * null,
  10120. * null,
  10121. * null,
  10122. * null
  10123. * ] } );
  10124. * } );
  10125. */
  10126. "bSearchable": true,
  10127. /**
  10128. * Enable or disable ordering on this column.
  10129. * @type boolean
  10130. * @default true
  10131. *
  10132. * @name DataTable.defaults.column.orderable
  10133. * @dtopt Columns
  10134. *
  10135. * @example
  10136. * // Using `columnDefs`
  10137. * $(document).ready( function() {
  10138. * $('#example').dataTable( {
  10139. * "columnDefs": [
  10140. * { "orderable": false, "targets": [ 0 ] }
  10141. * ] } );
  10142. * } );
  10143. *
  10144. * @example
  10145. * // Using `columns`
  10146. * $(document).ready( function() {
  10147. * $('#example').dataTable( {
  10148. * "columns": [
  10149. * { "orderable": false },
  10150. * null,
  10151. * null,
  10152. * null,
  10153. * null
  10154. * ] } );
  10155. * } );
  10156. */
  10157. "bSortable": true,
  10158. /**
  10159. * Enable or disable the display of this column.
  10160. * @type boolean
  10161. * @default true
  10162. *
  10163. * @name DataTable.defaults.column.visible
  10164. * @dtopt Columns
  10165. *
  10166. * @example
  10167. * // Using `columnDefs`
  10168. * $(document).ready( function() {
  10169. * $('#example').dataTable( {
  10170. * "columnDefs": [
  10171. * { "visible": false, "targets": [ 0 ] }
  10172. * ] } );
  10173. * } );
  10174. *
  10175. * @example
  10176. * // Using `columns`
  10177. * $(document).ready( function() {
  10178. * $('#example').dataTable( {
  10179. * "columns": [
  10180. * { "visible": false },
  10181. * null,
  10182. * null,
  10183. * null,
  10184. * null
  10185. * ] } );
  10186. * } );
  10187. */
  10188. "bVisible": true,
  10189. /**
  10190. * Developer definable function that is called whenever a cell is created (Ajax source,
  10191. * etc) or processed for input (DOM source). This can be used as a compliment to mRender
  10192. * allowing you to modify the DOM element (add background colour for example) when the
  10193. * element is available.
  10194. * @type function
  10195. * @param {element} td The TD node that has been created
  10196. * @param {*} cellData The Data for the cell
  10197. * @param {array|object} rowData The data for the whole row
  10198. * @param {int} row The row index for the aoData data store
  10199. * @param {int} col The column index for aoColumns
  10200. *
  10201. * @name DataTable.defaults.column.createdCell
  10202. * @dtopt Columns
  10203. *
  10204. * @example
  10205. * $(document).ready( function() {
  10206. * $('#example').dataTable( {
  10207. * "columnDefs": [ {
  10208. * "targets": [3],
  10209. * "createdCell": function (td, cellData, rowData, row, col) {
  10210. * if ( cellData == "1.7" ) {
  10211. * $(td).css('color', 'blue')
  10212. * }
  10213. * }
  10214. * } ]
  10215. * });
  10216. * } );
  10217. */
  10218. "fnCreatedCell": null,
  10219. /**
  10220. * This parameter has been replaced by `data` in DataTables to ensure naming
  10221. * consistency. `dataProp` can still be used, as there is backwards
  10222. * compatibility in DataTables for this option, but it is strongly
  10223. * recommended that you use `data` in preference to `dataProp`.
  10224. * @name DataTable.defaults.column.dataProp
  10225. */
  10226. /**
  10227. * This property can be used to read data from any data source property,
  10228. * including deeply nested objects / properties. `data` can be given in a
  10229. * number of different ways which effect its behaviour:
  10230. *
  10231. * * `integer` - treated as an array index for the data source. This is the
  10232. * default that DataTables uses (incrementally increased for each column).
  10233. * * `string` - read an object property from the data source. There are
  10234. * three 'special' options that can be used in the string to alter how
  10235. * DataTables reads the data from the source object:
  10236. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10237. * Javascript to read from nested objects, so to can the options
  10238. * specified in `data`. For example: `browser.version` or
  10239. * `browser.name`. If your object parameter name contains a period, use
  10240. * `\\` to escape it - i.e. `first\\.name`.
  10241. * * `[]` - Array notation. DataTables can automatically combine data
  10242. * from and array source, joining the data with the characters provided
  10243. * between the two brackets. For example: `name[, ]` would provide a
  10244. * comma-space separated list from the source array. If no characters
  10245. * are provided between the brackets, the original array source is
  10246. * returned.
  10247. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10248. * execute a function of the name given. For example: `browser()` for a
  10249. * simple function on the data source, `browser.version()` for a
  10250. * function in a nested property or even `browser().version` to get an
  10251. * object property if the function called returns an object. Note that
  10252. * function notation is recommended for use in `render` rather than
  10253. * `data` as it is much simpler to use as a renderer.
  10254. * * `null` - use the original data source for the row rather than plucking
  10255. * data directly from it. This action has effects on two other
  10256. * initialisation options:
  10257. * * `defaultContent` - When null is given as the `data` option and
  10258. * `defaultContent` is specified for the column, the value defined by
  10259. * `defaultContent` will be used for the cell.
  10260. * * `render` - When null is used for the `data` option and the `render`
  10261. * option is specified for the column, the whole data source for the
  10262. * row is used for the renderer.
  10263. * * `function` - the function given will be executed whenever DataTables
  10264. * needs to set or get the data for a cell in the column. The function
  10265. * takes three parameters:
  10266. * * Parameters:
  10267. * * `{array|object}` The data source for the row
  10268. * * `{string}` The type call data requested - this will be 'set' when
  10269. * setting data or 'filter', 'display', 'type', 'sort' or undefined
  10270. * when gathering data. Note that when `undefined` is given for the
  10271. * type DataTables expects to get the raw data for the object back<
  10272. * * `{*}` Data to set when the second parameter is 'set'.
  10273. * * Return:
  10274. * * The return value from the function is not required when 'set' is
  10275. * the type of call, but otherwise the return is what will be used
  10276. * for the data requested.
  10277. *
  10278. * Note that `data` is a getter and setter option. If you just require
  10279. * formatting of data for output, you will likely want to use `render` which
  10280. * is simply a getter and thus simpler to use.
  10281. *
  10282. * Note that prior to DataTables 1.9.2 `data` was called `mDataProp`. The
  10283. * name change reflects the flexibility of this property and is consistent
  10284. * with the naming of mRender. If 'mDataProp' is given, then it will still
  10285. * be used by DataTables, as it automatically maps the old name to the new
  10286. * if required.
  10287. *
  10288. * @type string|int|function|null
  10289. * @default null <i>Use automatically calculated column index</i>
  10290. *
  10291. * @name DataTable.defaults.column.data
  10292. * @dtopt Columns
  10293. *
  10294. * @example
  10295. * // Read table data from objects
  10296. * // JSON structure for each row:
  10297. * // {
  10298. * // "engine": {value},
  10299. * // "browser": {value},
  10300. * // "platform": {value},
  10301. * // "version": {value},
  10302. * // "grade": {value}
  10303. * // }
  10304. * $(document).ready( function() {
  10305. * $('#example').dataTable( {
  10306. * "ajaxSource": "sources/objects.txt",
  10307. * "columns": [
  10308. * { "data": "engine" },
  10309. * { "data": "browser" },
  10310. * { "data": "platform" },
  10311. * { "data": "version" },
  10312. * { "data": "grade" }
  10313. * ]
  10314. * } );
  10315. * } );
  10316. *
  10317. * @example
  10318. * // Read information from deeply nested objects
  10319. * // JSON structure for each row:
  10320. * // {
  10321. * // "engine": {value},
  10322. * // "browser": {value},
  10323. * // "platform": {
  10324. * // "inner": {value}
  10325. * // },
  10326. * // "details": [
  10327. * // {value}, {value}
  10328. * // ]
  10329. * // }
  10330. * $(document).ready( function() {
  10331. * $('#example').dataTable( {
  10332. * "ajaxSource": "sources/deep.txt",
  10333. * "columns": [
  10334. * { "data": "engine" },
  10335. * { "data": "browser" },
  10336. * { "data": "platform.inner" },
  10337. * { "data": "platform.details.0" },
  10338. * { "data": "platform.details.1" }
  10339. * ]
  10340. * } );
  10341. * } );
  10342. *
  10343. * @example
  10344. * // Using `data` as a function to provide different information for
  10345. * // sorting, filtering and display. In this case, currency (price)
  10346. * $(document).ready( function() {
  10347. * $('#example').dataTable( {
  10348. * "columnDefs": [ {
  10349. * "targets": [ 0 ],
  10350. * "data": function ( source, type, val ) {
  10351. * if (type === 'set') {
  10352. * source.price = val;
  10353. * // Store the computed dislay and filter values for efficiency
  10354. * source.price_display = val=="" ? "" : "$"+numberFormat(val);
  10355. * source.price_filter = val=="" ? "" : "$"+numberFormat(val)+" "+val;
  10356. * return;
  10357. * }
  10358. * else if (type === 'display') {
  10359. * return source.price_display;
  10360. * }
  10361. * else if (type === 'filter') {
  10362. * return source.price_filter;
  10363. * }
  10364. * // 'sort', 'type' and undefined all just use the integer
  10365. * return source.price;
  10366. * }
  10367. * } ]
  10368. * } );
  10369. * } );
  10370. *
  10371. * @example
  10372. * // Using default content
  10373. * $(document).ready( function() {
  10374. * $('#example').dataTable( {
  10375. * "columnDefs": [ {
  10376. * "targets": [ 0 ],
  10377. * "data": null,
  10378. * "defaultContent": "Click to edit"
  10379. * } ]
  10380. * } );
  10381. * } );
  10382. *
  10383. * @example
  10384. * // Using array notation - outputting a list from an array
  10385. * $(document).ready( function() {
  10386. * $('#example').dataTable( {
  10387. * "columnDefs": [ {
  10388. * "targets": [ 0 ],
  10389. * "data": "name[, ]"
  10390. * } ]
  10391. * } );
  10392. * } );
  10393. *
  10394. */
  10395. "mData": null,
  10396. /**
  10397. * This property is the rendering partner to `data` and it is suggested that
  10398. * when you want to manipulate data for display (including filtering,
  10399. * sorting etc) without altering the underlying data for the table, use this
  10400. * property. `render` can be considered to be the the read only companion to
  10401. * `data` which is read / write (then as such more complex). Like `data`
  10402. * this option can be given in a number of different ways to effect its
  10403. * behaviour:
  10404. *
  10405. * * `integer` - treated as an array index for the data source. This is the
  10406. * default that DataTables uses (incrementally increased for each column).
  10407. * * `string` - read an object property from the data source. There are
  10408. * three 'special' options that can be used in the string to alter how
  10409. * DataTables reads the data from the source object:
  10410. * * `.` - Dotted Javascript notation. Just as you use a `.` in
  10411. * Javascript to read from nested objects, so to can the options
  10412. * specified in `data`. For example: `browser.version` or
  10413. * `browser.name`. If your object parameter name contains a period, use
  10414. * `\\` to escape it - i.e. `first\\.name`.
  10415. * * `[]` - Array notation. DataTables can automatically combine data
  10416. * from and array source, joining the data with the characters provided
  10417. * between the two brackets. For example: `name[, ]` would provide a
  10418. * comma-space separated list from the source array. If no characters
  10419. * are provided between the brackets, the original array source is
  10420. * returned.
  10421. * * `()` - Function notation. Adding `()` to the end of a parameter will
  10422. * execute a function of the name given. For example: `browser()` for a
  10423. * simple function on the data source, `browser.version()` for a
  10424. * function in a nested property or even `browser().version` to get an
  10425. * object property if the function called returns an object.
  10426. * * `object` - use different data for the different data types requested by
  10427. * DataTables ('filter', 'display', 'type' or 'sort'). The property names
  10428. * of the object is the data type the property refers to and the value can
  10429. * defined using an integer, string or function using the same rules as
  10430. * `render` normally does. Note that an `_` option _must_ be specified.
  10431. * This is the default value to use if you haven't specified a value for
  10432. * the data type requested by DataTables.
  10433. * * `function` - the function given will be executed whenever DataTables
  10434. * needs to set or get the data for a cell in the column. The function
  10435. * takes three parameters:
  10436. * * Parameters:
  10437. * * {array|object} The data source for the row (based on `data`)
  10438. * * {string} The type call data requested - this will be 'filter',
  10439. * 'display', 'type' or 'sort'.
  10440. * * {array|object} The full data source for the row (not based on
  10441. * `data`)
  10442. * * Return:
  10443. * * The return value from the function is what will be used for the
  10444. * data requested.
  10445. *
  10446. * @type string|int|function|object|null
  10447. * @default null Use the data source value.
  10448. *
  10449. * @name DataTable.defaults.column.render
  10450. * @dtopt Columns
  10451. *
  10452. * @example
  10453. * // Create a comma separated list from an array of objects
  10454. * $(document).ready( function() {
  10455. * $('#example').dataTable( {
  10456. * "ajaxSource": "sources/deep.txt",
  10457. * "columns": [
  10458. * { "data": "engine" },
  10459. * { "data": "browser" },
  10460. * {
  10461. * "data": "platform",
  10462. * "render": "[, ].name"
  10463. * }
  10464. * ]
  10465. * } );
  10466. * } );
  10467. *
  10468. * @example
  10469. * // Execute a function to obtain data
  10470. * $(document).ready( function() {
  10471. * $('#example').dataTable( {
  10472. * "columnDefs": [ {
  10473. * "targets": [ 0 ],
  10474. * "data": null, // Use the full data source object for the renderer's source
  10475. * "render": "browserName()"
  10476. * } ]
  10477. * } );
  10478. * } );
  10479. *
  10480. * @example
  10481. * // As an object, extracting different data for the different types
  10482. * // This would be used with a data source such as:
  10483. * // { "phone": 5552368, "phone_filter": "5552368 555-2368", "phone_display": "555-2368" }
  10484. * // Here the `phone` integer is used for sorting and type detection, while `phone_filter`
  10485. * // (which has both forms) is used for filtering for if a user inputs either format, while
  10486. * // the formatted phone number is the one that is shown in the table.
  10487. * $(document).ready( function() {
  10488. * $('#example').dataTable( {
  10489. * "columnDefs": [ {
  10490. * "targets": [ 0 ],
  10491. * "data": null, // Use the full data source object for the renderer's source
  10492. * "render": {
  10493. * "_": "phone",
  10494. * "filter": "phone_filter",
  10495. * "display": "phone_display"
  10496. * }
  10497. * } ]
  10498. * } );
  10499. * } );
  10500. *
  10501. * @example
  10502. * // Use as a function to create a link from the data source
  10503. * $(document).ready( function() {
  10504. * $('#example').dataTable( {
  10505. * "columnDefs": [ {
  10506. * "targets": [ 0 ],
  10507. * "data": "download_link",
  10508. * "render": function ( data, type, full ) {
  10509. * return '<a href="'+data+'">Download</a>';
  10510. * }
  10511. * } ]
  10512. * } );
  10513. * } );
  10514. */
  10515. "mRender": null,
  10516. /**
  10517. * Change the cell type created for the column - either TD cells or TH cells. This
  10518. * can be useful as TH cells have semantic meaning in the table body, allowing them
  10519. * to act as a header for a row (you may wish to add scope='row' to the TH elements).
  10520. * @type string
  10521. * @default td
  10522. *
  10523. * @name DataTable.defaults.column.cellType
  10524. * @dtopt Columns
  10525. *
  10526. * @example
  10527. * // Make the first column use TH cells
  10528. * $(document).ready( function() {
  10529. * $('#example').dataTable( {
  10530. * "columnDefs": [ {
  10531. * "targets": [ 0 ],
  10532. * "cellType": "th"
  10533. * } ]
  10534. * } );
  10535. * } );
  10536. */
  10537. "sCellType": "td",
  10538. /**
  10539. * Class to give to each cell in this column.
  10540. * @type string
  10541. * @default <i>Empty string</i>
  10542. *
  10543. * @name DataTable.defaults.column.class
  10544. * @dtopt Columns
  10545. *
  10546. * @example
  10547. * // Using `columnDefs`
  10548. * $(document).ready( function() {
  10549. * $('#example').dataTable( {
  10550. * "columnDefs": [
  10551. * { "class": "my_class", "targets": [ 0 ] }
  10552. * ]
  10553. * } );
  10554. * } );
  10555. *
  10556. * @example
  10557. * // Using `columns`
  10558. * $(document).ready( function() {
  10559. * $('#example').dataTable( {
  10560. * "columns": [
  10561. * { "class": "my_class" },
  10562. * null,
  10563. * null,
  10564. * null,
  10565. * null
  10566. * ]
  10567. * } );
  10568. * } );
  10569. */
  10570. "sClass": "",
  10571. /**
  10572. * When DataTables calculates the column widths to assign to each column,
  10573. * it finds the longest string in each column and then constructs a
  10574. * temporary table and reads the widths from that. The problem with this
  10575. * is that "mmm" is much wider then "iiii", but the latter is a longer
  10576. * string - thus the calculation can go wrong (doing it properly and putting
  10577. * it into an DOM object and measuring that is horribly(!) slow). Thus as
  10578. * a "work around" we provide this option. It will append its value to the
  10579. * text that is found to be the longest string for the column - i.e. padding.
  10580. * Generally you shouldn't need this!
  10581. * @type string
  10582. * @default <i>Empty string<i>
  10583. *
  10584. * @name DataTable.defaults.column.contentPadding
  10585. * @dtopt Columns
  10586. *
  10587. * @example
  10588. * // Using `columns`
  10589. * $(document).ready( function() {
  10590. * $('#example').dataTable( {
  10591. * "columns": [
  10592. * null,
  10593. * null,
  10594. * null,
  10595. * {
  10596. * "contentPadding": "mmm"
  10597. * }
  10598. * ]
  10599. * } );
  10600. * } );
  10601. */
  10602. "sContentPadding": "",
  10603. /**
  10604. * Allows a default value to be given for a column's data, and will be used
  10605. * whenever a null data source is encountered (this can be because `data`
  10606. * is set to null, or because the data source itself is null).
  10607. * @type string
  10608. * @default null
  10609. *
  10610. * @name DataTable.defaults.column.defaultContent
  10611. * @dtopt Columns
  10612. *
  10613. * @example
  10614. * // Using `columnDefs`
  10615. * $(document).ready( function() {
  10616. * $('#example').dataTable( {
  10617. * "columnDefs": [
  10618. * {
  10619. * "data": null,
  10620. * "defaultContent": "Edit",
  10621. * "targets": [ -1 ]
  10622. * }
  10623. * ]
  10624. * } );
  10625. * } );
  10626. *
  10627. * @example
  10628. * // Using `columns`
  10629. * $(document).ready( function() {
  10630. * $('#example').dataTable( {
  10631. * "columns": [
  10632. * null,
  10633. * null,
  10634. * null,
  10635. * {
  10636. * "data": null,
  10637. * "defaultContent": "Edit"
  10638. * }
  10639. * ]
  10640. * } );
  10641. * } );
  10642. */
  10643. "sDefaultContent": null,
  10644. /**
  10645. * This parameter is only used in DataTables' server-side processing. It can
  10646. * be exceptionally useful to know what columns are being displayed on the
  10647. * client side, and to map these to database fields. When defined, the names
  10648. * also allow DataTables to reorder information from the server if it comes
  10649. * back in an unexpected order (i.e. if you switch your columns around on the
  10650. * client-side, your server-side code does not also need updating).
  10651. * @type string
  10652. * @default <i>Empty string</i>
  10653. *
  10654. * @name DataTable.defaults.column.name
  10655. * @dtopt Columns
  10656. *
  10657. * @example
  10658. * // Using `columnDefs`
  10659. * $(document).ready( function() {
  10660. * $('#example').dataTable( {
  10661. * "columnDefs": [
  10662. * { "name": "engine", "targets": [ 0 ] },
  10663. * { "name": "browser", "targets": [ 1 ] },
  10664. * { "name": "platform", "targets": [ 2 ] },
  10665. * { "name": "version", "targets": [ 3 ] },
  10666. * { "name": "grade", "targets": [ 4 ] }
  10667. * ]
  10668. * } );
  10669. * } );
  10670. *
  10671. * @example
  10672. * // Using `columns`
  10673. * $(document).ready( function() {
  10674. * $('#example').dataTable( {
  10675. * "columns": [
  10676. * { "name": "engine" },
  10677. * { "name": "browser" },
  10678. * { "name": "platform" },
  10679. * { "name": "version" },
  10680. * { "name": "grade" }
  10681. * ]
  10682. * } );
  10683. * } );
  10684. */
  10685. "sName": "",
  10686. /**
  10687. * Defines a data source type for the ordering which can be used to read
  10688. * real-time information from the table (updating the internally cached
  10689. * version) prior to ordering. This allows ordering to occur on user
  10690. * editable elements such as form inputs.
  10691. * @type string
  10692. * @default std
  10693. *
  10694. * @name DataTable.defaults.column.orderDataType
  10695. * @dtopt Columns
  10696. *
  10697. * @example
  10698. * // Using `columnDefs`
  10699. * $(document).ready( function() {
  10700. * $('#example').dataTable( {
  10701. * "columnDefs": [
  10702. * { "orderDataType": "dom-text", "targets": [ 2, 3 ] },
  10703. * { "type": "numeric", "targets": [ 3 ] },
  10704. * { "orderDataType": "dom-select", "targets": [ 4 ] },
  10705. * { "orderDataType": "dom-checkbox", "targets": [ 5 ] }
  10706. * ]
  10707. * } );
  10708. * } );
  10709. *
  10710. * @example
  10711. * // Using `columns`
  10712. * $(document).ready( function() {
  10713. * $('#example').dataTable( {
  10714. * "columns": [
  10715. * null,
  10716. * null,
  10717. * { "orderDataType": "dom-text" },
  10718. * { "orderDataType": "dom-text", "type": "numeric" },
  10719. * { "orderDataType": "dom-select" },
  10720. * { "orderDataType": "dom-checkbox" }
  10721. * ]
  10722. * } );
  10723. * } );
  10724. */
  10725. "sSortDataType": "std",
  10726. /**
  10727. * The title of this column.
  10728. * @type string
  10729. * @default null <i>Derived from the 'TH' value for this column in the
  10730. * original HTML table.</i>
  10731. *
  10732. * @name DataTable.defaults.column.title
  10733. * @dtopt Columns
  10734. *
  10735. * @example
  10736. * // Using `columnDefs`
  10737. * $(document).ready( function() {
  10738. * $('#example').dataTable( {
  10739. * "columnDefs": [
  10740. * { "title": "My column title", "targets": [ 0 ] }
  10741. * ]
  10742. * } );
  10743. * } );
  10744. *
  10745. * @example
  10746. * // Using `columns`
  10747. * $(document).ready( function() {
  10748. * $('#example').dataTable( {
  10749. * "columns": [
  10750. * { "title": "My column title" },
  10751. * null,
  10752. * null,
  10753. * null,
  10754. * null
  10755. * ]
  10756. * } );
  10757. * } );
  10758. */
  10759. "sTitle": null,
  10760. /**
  10761. * The type allows you to specify how the data for this column will be
  10762. * ordered. Four types (string, numeric, date and html (which will strip
  10763. * HTML tags before ordering)) are currently available. Note that only date
  10764. * formats understood by Javascript's Date() object will be accepted as type
  10765. * date. For example: "Mar 26, 2008 5:03 PM". May take the values: 'string',
  10766. * 'numeric', 'date' or 'html' (by default). Further types can be adding
  10767. * through plug-ins.
  10768. * @type string
  10769. * @default null <i>Auto-detected from raw data</i>
  10770. *
  10771. * @name DataTable.defaults.column.type
  10772. * @dtopt Columns
  10773. *
  10774. * @example
  10775. * // Using `columnDefs`
  10776. * $(document).ready( function() {
  10777. * $('#example').dataTable( {
  10778. * "columnDefs": [
  10779. * { "type": "html", "targets": [ 0 ] }
  10780. * ]
  10781. * } );
  10782. * } );
  10783. *
  10784. * @example
  10785. * // Using `columns`
  10786. * $(document).ready( function() {
  10787. * $('#example').dataTable( {
  10788. * "columns": [
  10789. * { "type": "html" },
  10790. * null,
  10791. * null,
  10792. * null,
  10793. * null
  10794. * ]
  10795. * } );
  10796. * } );
  10797. */
  10798. "sType": null,
  10799. /**
  10800. * Defining the width of the column, this parameter may take any CSS value
  10801. * (3em, 20px etc). DataTables applies 'smart' widths to columns which have not
  10802. * been given a specific width through this interface ensuring that the table
  10803. * remains readable.
  10804. * @type string
  10805. * @default null <i>Automatic</i>
  10806. *
  10807. * @name DataTable.defaults.column.width
  10808. * @dtopt Columns
  10809. *
  10810. * @example
  10811. * // Using `columnDefs`
  10812. * $(document).ready( function() {
  10813. * $('#example').dataTable( {
  10814. * "columnDefs": [
  10815. * { "width": "20%", "targets": [ 0 ] }
  10816. * ]
  10817. * } );
  10818. * } );
  10819. *
  10820. * @example
  10821. * // Using `columns`
  10822. * $(document).ready( function() {
  10823. * $('#example').dataTable( {
  10824. * "columns": [
  10825. * { "width": "20%" },
  10826. * null,
  10827. * null,
  10828. * null,
  10829. * null
  10830. * ]
  10831. * } );
  10832. * } );
  10833. */
  10834. "sWidth": null
  10835. };
  10836. _fnHungarianMap( DataTable.defaults.column );
  10837. /**
  10838. * DataTables settings object - this holds all the information needed for a
  10839. * given table, including configuration, data and current application of the
  10840. * table options. DataTables does not have a single instance for each DataTable
  10841. * with the settings attached to that instance, but rather instances of the
  10842. * DataTable "class" are created on-the-fly as needed (typically by a
  10843. * $().dataTable() call) and the settings object is then applied to that
  10844. * instance.
  10845. *
  10846. * Note that this object is related to {@link DataTable.defaults} but this
  10847. * one is the internal data store for DataTables's cache of columns. It should
  10848. * NOT be manipulated outside of DataTables. Any configuration should be done
  10849. * through the initialisation options.
  10850. * @namespace
  10851. * @yodo Really should attach the settings object to individual instances so we
  10852. * don't need to create new instances on each $().dataTable() call (if the
  10853. * table already exists). It would also save passing oSettings around and
  10854. * into every single function. However, this is a very significant
  10855. * architecture change for DataTables and will almost certainly break
  10856. * backwards compatibility with older installations. This is something that
  10857. * will be done in 2.0.
  10858. */
  10859. DataTable.models.oSettings = {
  10860. /**
  10861. * Primary features of DataTables and their enablement state.
  10862. * @namespace
  10863. */
  10864. "oFeatures": {
  10865. /**
  10866. * Flag to say if DataTables should automatically try to calculate the
  10867. * optimum table and columns widths (true) or not (false).
  10868. * Note that this parameter will be set by the initialisation routine. To
  10869. * set a default use {@link DataTable.defaults}.
  10870. * @type boolean
  10871. */
  10872. "bAutoWidth": null,
  10873. /**
  10874. * Delay the creation of TR and TD elements until they are actually
  10875. * needed by a driven page draw. This can give a significant speed
  10876. * increase for Ajax source and Javascript source data, but makes no
  10877. * difference at all fro DOM and server-side processing tables.
  10878. * Note that this parameter will be set by the initialisation routine. To
  10879. * set a default use {@link DataTable.defaults}.
  10880. * @type boolean
  10881. */
  10882. "bDeferRender": null,
  10883. /**
  10884. * Enable filtering on the table or not. Note that if this is disabled
  10885. * then there is no filtering at all on the table, including fnFilter.
  10886. * To just remove the filtering input use sDom and remove the 'f' option.
  10887. * Note that this parameter will be set by the initialisation routine. To
  10888. * set a default use {@link DataTable.defaults}.
  10889. * @type boolean
  10890. */
  10891. "bFilter": null,
  10892. /**
  10893. * Table information element (the 'Showing x of y records' div) enable
  10894. * flag.
  10895. * Note that this parameter will be set by the initialisation routine. To
  10896. * set a default use {@link DataTable.defaults}.
  10897. * @type boolean
  10898. */
  10899. "bInfo": null,
  10900. /**
  10901. * Present a user control allowing the end user to change the page size
  10902. * when pagination is enabled.
  10903. * Note that this parameter will be set by the initialisation routine. To
  10904. * set a default use {@link DataTable.defaults}.
  10905. * @type boolean
  10906. */
  10907. "bLengthChange": null,
  10908. /**
  10909. * Pagination enabled or not. Note that if this is disabled then length
  10910. * changing must also be disabled.
  10911. * Note that this parameter will be set by the initialisation routine. To
  10912. * set a default use {@link DataTable.defaults}.
  10913. * @type boolean
  10914. */
  10915. "bPaginate": null,
  10916. /**
  10917. * Processing indicator enable flag whenever DataTables is enacting a
  10918. * user request - typically an Ajax request for server-side processing.
  10919. * Note that this parameter will be set by the initialisation routine. To
  10920. * set a default use {@link DataTable.defaults}.
  10921. * @type boolean
  10922. */
  10923. "bProcessing": null,
  10924. /**
  10925. * Server-side processing enabled flag - when enabled DataTables will
  10926. * get all data from the server for every draw - there is no filtering,
  10927. * sorting or paging done on the client-side.
  10928. * Note that this parameter will be set by the initialisation routine. To
  10929. * set a default use {@link DataTable.defaults}.
  10930. * @type boolean
  10931. */
  10932. "bServerSide": null,
  10933. /**
  10934. * Sorting enablement flag.
  10935. * Note that this parameter will be set by the initialisation routine. To
  10936. * set a default use {@link DataTable.defaults}.
  10937. * @type boolean
  10938. */
  10939. "bSort": null,
  10940. /**
  10941. * Multi-column sorting
  10942. * Note that this parameter will be set by the initialisation routine. To
  10943. * set a default use {@link DataTable.defaults}.
  10944. * @type boolean
  10945. */
  10946. "bSortMulti": null,
  10947. /**
  10948. * Apply a class to the columns which are being sorted to provide a
  10949. * visual highlight or not. This can slow things down when enabled since
  10950. * there is a lot of DOM interaction.
  10951. * Note that this parameter will be set by the initialisation routine. To
  10952. * set a default use {@link DataTable.defaults}.
  10953. * @type boolean
  10954. */
  10955. "bSortClasses": null,
  10956. /**
  10957. * State saving enablement flag.
  10958. * Note that this parameter will be set by the initialisation routine. To
  10959. * set a default use {@link DataTable.defaults}.
  10960. * @type boolean
  10961. */
  10962. "bStateSave": null
  10963. },
  10964. /**
  10965. * Scrolling settings for a table.
  10966. * @namespace
  10967. */
  10968. "oScroll": {
  10969. /**
  10970. * When the table is shorter in height than sScrollY, collapse the
  10971. * table container down to the height of the table (when true).
  10972. * Note that this parameter will be set by the initialisation routine. To
  10973. * set a default use {@link DataTable.defaults}.
  10974. * @type boolean
  10975. */
  10976. "bCollapse": null,
  10977. /**
  10978. * Width of the scrollbar for the web-browser's platform. Calculated
  10979. * during table initialisation.
  10980. * @type int
  10981. * @default 0
  10982. */
  10983. "iBarWidth": 0,
  10984. /**
  10985. * Viewport width for horizontal scrolling. Horizontal scrolling is
  10986. * disabled if an empty string.
  10987. * Note that this parameter will be set by the initialisation routine. To
  10988. * set a default use {@link DataTable.defaults}.
  10989. * @type string
  10990. */
  10991. "sX": null,
  10992. /**
  10993. * Width to expand the table to when using x-scrolling. Typically you
  10994. * should not need to use this.
  10995. * Note that this parameter will be set by the initialisation routine. To
  10996. * set a default use {@link DataTable.defaults}.
  10997. * @type string
  10998. * @deprecated
  10999. */
  11000. "sXInner": null,
  11001. /**
  11002. * Viewport height for vertical scrolling. Vertical scrolling is disabled
  11003. * if an empty string.
  11004. * Note that this parameter will be set by the initialisation routine. To
  11005. * set a default use {@link DataTable.defaults}.
  11006. * @type string
  11007. */
  11008. "sY": null
  11009. },
  11010. /**
  11011. * Language information for the table.
  11012. * @namespace
  11013. * @extends DataTable.defaults.oLanguage
  11014. */
  11015. "oLanguage": {
  11016. /**
  11017. * Information callback function. See
  11018. * {@link DataTable.defaults.fnInfoCallback}
  11019. * @type function
  11020. * @default null
  11021. */
  11022. "fnInfoCallback": null
  11023. },
  11024. /**
  11025. * Browser support parameters
  11026. * @namespace
  11027. */
  11028. "oBrowser": {
  11029. /**
  11030. * Indicate if the browser incorrectly calculates width:100% inside a
  11031. * scrolling element (IE6/7)
  11032. * @type boolean
  11033. * @default false
  11034. */
  11035. "bScrollOversize": false,
  11036. /**
  11037. * Determine if the vertical scrollbar is on the right or left of the
  11038. * scrolling container - needed for rtl language layout, although not
  11039. * all browsers move the scrollbar (Safari).
  11040. * @type boolean
  11041. * @default false
  11042. */
  11043. "bScrollbarLeft": false
  11044. },
  11045. "ajax": null,
  11046. /**
  11047. * Array referencing the nodes which are used for the features. The
  11048. * parameters of this object match what is allowed by sDom - i.e.
  11049. * <ul>
  11050. * <li>'l' - Length changing</li>
  11051. * <li>'f' - Filtering input</li>
  11052. * <li>'t' - The table!</li>
  11053. * <li>'i' - Information</li>
  11054. * <li>'p' - Pagination</li>
  11055. * <li>'r' - pRocessing</li>
  11056. * </ul>
  11057. * @type array
  11058. * @default []
  11059. */
  11060. "aanFeatures": [],
  11061. /**
  11062. * Store data information - see {@link DataTable.models.oRow} for detailed
  11063. * information.
  11064. * @type array
  11065. * @default []
  11066. */
  11067. "aoData": [],
  11068. /**
  11069. * Array of indexes which are in the current display (after filtering etc)
  11070. * @type array
  11071. * @default []
  11072. */
  11073. "aiDisplay": [],
  11074. /**
  11075. * Array of indexes for display - no filtering
  11076. * @type array
  11077. * @default []
  11078. */
  11079. "aiDisplayMaster": [],
  11080. /**
  11081. * Store information about each column that is in use
  11082. * @type array
  11083. * @default []
  11084. */
  11085. "aoColumns": [],
  11086. /**
  11087. * Store information about the table's header
  11088. * @type array
  11089. * @default []
  11090. */
  11091. "aoHeader": [],
  11092. /**
  11093. * Store information about the table's footer
  11094. * @type array
  11095. * @default []
  11096. */
  11097. "aoFooter": [],
  11098. /**
  11099. * Store the applied global search information in case we want to force a
  11100. * research or compare the old search to a new one.
  11101. * Note that this parameter will be set by the initialisation routine. To
  11102. * set a default use {@link DataTable.defaults}.
  11103. * @namespace
  11104. * @extends DataTable.models.oSearch
  11105. */
  11106. "oPreviousSearch": {},
  11107. /**
  11108. * Store the applied search for each column - see
  11109. * {@link DataTable.models.oSearch} for the format that is used for the
  11110. * filtering information for each column.
  11111. * @type array
  11112. * @default []
  11113. */
  11114. "aoPreSearchCols": [],
  11115. /**
  11116. * Sorting that is applied to the table. Note that the inner arrays are
  11117. * used in the following manner:
  11118. * <ul>
  11119. * <li>Index 0 - column number</li>
  11120. * <li>Index 1 - current sorting direction</li>
  11121. * </ul>
  11122. * Note that this parameter will be set by the initialisation routine. To
  11123. * set a default use {@link DataTable.defaults}.
  11124. * @type array
  11125. * @yodo These inner arrays should really be objects
  11126. */
  11127. "aaSorting": null,
  11128. /**
  11129. * Sorting that is always applied to the table (i.e. prefixed in front of
  11130. * aaSorting).
  11131. * Note that this parameter will be set by the initialisation routine. To
  11132. * set a default use {@link DataTable.defaults}.
  11133. * @type array
  11134. * @default []
  11135. */
  11136. "aaSortingFixed": [],
  11137. /**
  11138. * Classes to use for the striping of a table.
  11139. * Note that this parameter will be set by the initialisation routine. To
  11140. * set a default use {@link DataTable.defaults}.
  11141. * @type array
  11142. * @default []
  11143. */
  11144. "asStripeClasses": null,
  11145. /**
  11146. * If restoring a table - we should restore its striping classes as well
  11147. * @type array
  11148. * @default []
  11149. */
  11150. "asDestroyStripes": [],
  11151. /**
  11152. * If restoring a table - we should restore its width
  11153. * @type int
  11154. * @default 0
  11155. */
  11156. "sDestroyWidth": 0,
  11157. /**
  11158. * Callback functions array for every time a row is inserted (i.e. on a draw).
  11159. * @type array
  11160. * @default []
  11161. */
  11162. "aoRowCallback": [],
  11163. /**
  11164. * Callback functions for the header on each draw.
  11165. * @type array
  11166. * @default []
  11167. */
  11168. "aoHeaderCallback": [],
  11169. /**
  11170. * Callback function for the footer on each draw.
  11171. * @type array
  11172. * @default []
  11173. */
  11174. "aoFooterCallback": [],
  11175. /**
  11176. * Array of callback functions for draw callback functions
  11177. * @type array
  11178. * @default []
  11179. */
  11180. "aoDrawCallback": [],
  11181. /**
  11182. * Array of callback functions for row created function
  11183. * @type array
  11184. * @default []
  11185. */
  11186. "aoRowCreatedCallback": [],
  11187. /**
  11188. * Callback functions for just before the table is redrawn. A return of
  11189. * false will be used to cancel the draw.
  11190. * @type array
  11191. * @default []
  11192. */
  11193. "aoPreDrawCallback": [],
  11194. /**
  11195. * Callback functions for when the table has been initialised.
  11196. * @type array
  11197. * @default []
  11198. */
  11199. "aoInitComplete": [],
  11200. /**
  11201. * Callbacks for modifying the settings to be stored for state saving, prior to
  11202. * saving state.
  11203. * @type array
  11204. * @default []
  11205. */
  11206. "aoStateSaveParams": [],
  11207. /**
  11208. * Callbacks for modifying the settings that have been stored for state saving
  11209. * prior to using the stored values to restore the state.
  11210. * @type array
  11211. * @default []
  11212. */
  11213. "aoStateLoadParams": [],
  11214. /**
  11215. * Callbacks for operating on the settings object once the saved state has been
  11216. * loaded
  11217. * @type array
  11218. * @default []
  11219. */
  11220. "aoStateLoaded": [],
  11221. /**
  11222. * Cache the table ID for quick access
  11223. * @type string
  11224. * @default <i>Empty string</i>
  11225. */
  11226. "sTableId": "",
  11227. /**
  11228. * The TABLE node for the main table
  11229. * @type node
  11230. * @default null
  11231. */
  11232. "nTable": null,
  11233. /**
  11234. * Permanent ref to the thead element
  11235. * @type node
  11236. * @default null
  11237. */
  11238. "nTHead": null,
  11239. /**
  11240. * Permanent ref to the tfoot element - if it exists
  11241. * @type node
  11242. * @default null
  11243. */
  11244. "nTFoot": null,
  11245. /**
  11246. * Permanent ref to the tbody element
  11247. * @type node
  11248. * @default null
  11249. */
  11250. "nTBody": null,
  11251. /**
  11252. * Cache the wrapper node (contains all DataTables controlled elements)
  11253. * @type node
  11254. * @default null
  11255. */
  11256. "nTableWrapper": null,
  11257. /**
  11258. * Indicate if when using server-side processing the loading of data
  11259. * should be deferred until the second draw.
  11260. * Note that this parameter will be set by the initialisation routine. To
  11261. * set a default use {@link DataTable.defaults}.
  11262. * @type boolean
  11263. * @default false
  11264. */
  11265. "bDeferLoading": false,
  11266. /**
  11267. * Indicate if all required information has been read in
  11268. * @type boolean
  11269. * @default false
  11270. */
  11271. "bInitialised": false,
  11272. /**
  11273. * Information about open rows. Each object in the array has the parameters
  11274. * 'nTr' and 'nParent'
  11275. * @type array
  11276. * @default []
  11277. */
  11278. "aoOpenRows": [],
  11279. /**
  11280. * Dictate the positioning of DataTables' control elements - see
  11281. * {@link DataTable.model.oInit.sDom}.
  11282. * Note that this parameter will be set by the initialisation routine. To
  11283. * set a default use {@link DataTable.defaults}.
  11284. * @type string
  11285. * @default null
  11286. */
  11287. "sDom": null,
  11288. /**
  11289. * Search delay (in mS)
  11290. * @type integer
  11291. * @default null
  11292. */
  11293. "searchDelay": null,
  11294. /**
  11295. * Which type of pagination should be used.
  11296. * Note that this parameter will be set by the initialisation routine. To
  11297. * set a default use {@link DataTable.defaults}.
  11298. * @type string
  11299. * @default two_button
  11300. */
  11301. "sPaginationType": "two_button",
  11302. /**
  11303. * The state duration (for `stateSave`) in seconds.
  11304. * Note that this parameter will be set by the initialisation routine. To
  11305. * set a default use {@link DataTable.defaults}.
  11306. * @type int
  11307. * @default 0
  11308. */
  11309. "iStateDuration": 0,
  11310. /**
  11311. * Array of callback functions for state saving. Each array element is an
  11312. * object with the following parameters:
  11313. * <ul>
  11314. * <li>function:fn - function to call. Takes two parameters, oSettings
  11315. * and the JSON string to save that has been thus far created. Returns
  11316. * a JSON string to be inserted into a json object
  11317. * (i.e. '"param": [ 0, 1, 2]')</li>
  11318. * <li>string:sName - name of callback</li>
  11319. * </ul>
  11320. * @type array
  11321. * @default []
  11322. */
  11323. "aoStateSave": [],
  11324. /**
  11325. * Array of callback functions for state loading. Each array element is an
  11326. * object with the following parameters:
  11327. * <ul>
  11328. * <li>function:fn - function to call. Takes two parameters, oSettings
  11329. * and the object stored. May return false to cancel state loading</li>
  11330. * <li>string:sName - name of callback</li>
  11331. * </ul>
  11332. * @type array
  11333. * @default []
  11334. */
  11335. "aoStateLoad": [],
  11336. /**
  11337. * State that was saved. Useful for back reference
  11338. * @type object
  11339. * @default null
  11340. */
  11341. "oSavedState": null,
  11342. /**
  11343. * State that was loaded. Useful for back reference
  11344. * @type object
  11345. * @default null
  11346. */
  11347. "oLoadedState": null,
  11348. /**
  11349. * Source url for AJAX data for the table.
  11350. * Note that this parameter will be set by the initialisation routine. To
  11351. * set a default use {@link DataTable.defaults}.
  11352. * @type string
  11353. * @default null
  11354. */
  11355. "sAjaxSource": null,
  11356. /**
  11357. * Property from a given object from which to read the table data from. This
  11358. * can be an empty string (when not server-side processing), in which case
  11359. * it is assumed an an array is given directly.
  11360. * Note that this parameter will be set by the initialisation routine. To
  11361. * set a default use {@link DataTable.defaults}.
  11362. * @type string
  11363. */
  11364. "sAjaxDataProp": null,
  11365. /**
  11366. * Note if draw should be blocked while getting data
  11367. * @type boolean
  11368. * @default true
  11369. */
  11370. "bAjaxDataGet": true,
  11371. /**
  11372. * The last jQuery XHR object that was used for server-side data gathering.
  11373. * This can be used for working with the XHR information in one of the
  11374. * callbacks
  11375. * @type object
  11376. * @default null
  11377. */
  11378. "jqXHR": null,
  11379. /**
  11380. * JSON returned from the server in the last Ajax request
  11381. * @type object
  11382. * @default undefined
  11383. */
  11384. "json": undefined,
  11385. /**
  11386. * Data submitted as part of the last Ajax request
  11387. * @type object
  11388. * @default undefined
  11389. */
  11390. "oAjaxData": undefined,
  11391. /**
  11392. * Function to get the server-side data.
  11393. * Note that this parameter will be set by the initialisation routine. To
  11394. * set a default use {@link DataTable.defaults}.
  11395. * @type function
  11396. */
  11397. "fnServerData": null,
  11398. /**
  11399. * Functions which are called prior to sending an Ajax request so extra
  11400. * parameters can easily be sent to the server
  11401. * @type array
  11402. * @default []
  11403. */
  11404. "aoServerParams": [],
  11405. /**
  11406. * Send the XHR HTTP method - GET or POST (could be PUT or DELETE if
  11407. * required).
  11408. * Note that this parameter will be set by the initialisation routine. To
  11409. * set a default use {@link DataTable.defaults}.
  11410. * @type string
  11411. */
  11412. "sServerMethod": null,
  11413. /**
  11414. * Format numbers for display.
  11415. * Note that this parameter will be set by the initialisation routine. To
  11416. * set a default use {@link DataTable.defaults}.
  11417. * @type function
  11418. */
  11419. "fnFormatNumber": null,
  11420. /**
  11421. * List of options that can be used for the user selectable length menu.
  11422. * Note that this parameter will be set by the initialisation routine. To
  11423. * set a default use {@link DataTable.defaults}.
  11424. * @type array
  11425. * @default []
  11426. */
  11427. "aLengthMenu": null,
  11428. /**
  11429. * Counter for the draws that the table does. Also used as a tracker for
  11430. * server-side processing
  11431. * @type int
  11432. * @default 0
  11433. */
  11434. "iDraw": 0,
  11435. /**
  11436. * Indicate if a redraw is being done - useful for Ajax
  11437. * @type boolean
  11438. * @default false
  11439. */
  11440. "bDrawing": false,
  11441. /**
  11442. * Draw index (iDraw) of the last error when parsing the returned data
  11443. * @type int
  11444. * @default -1
  11445. */
  11446. "iDrawError": -1,
  11447. /**
  11448. * Paging display length
  11449. * @type int
  11450. * @default 10
  11451. */
  11452. "_iDisplayLength": 10,
  11453. /**
  11454. * Paging start point - aiDisplay index
  11455. * @type int
  11456. * @default 0
  11457. */
  11458. "_iDisplayStart": 0,
  11459. /**
  11460. * Server-side processing - number of records in the result set
  11461. * (i.e. before filtering), Use fnRecordsTotal rather than
  11462. * this property to get the value of the number of records, regardless of
  11463. * the server-side processing setting.
  11464. * @type int
  11465. * @default 0
  11466. * @private
  11467. */
  11468. "_iRecordsTotal": 0,
  11469. /**
  11470. * Server-side processing - number of records in the current display set
  11471. * (i.e. after filtering). Use fnRecordsDisplay rather than
  11472. * this property to get the value of the number of records, regardless of
  11473. * the server-side processing setting.
  11474. * @type boolean
  11475. * @default 0
  11476. * @private
  11477. */
  11478. "_iRecordsDisplay": 0,
  11479. /**
  11480. * Flag to indicate if jQuery UI marking and classes should be used.
  11481. * Note that this parameter will be set by the initialisation routine. To
  11482. * set a default use {@link DataTable.defaults}.
  11483. * @type boolean
  11484. */
  11485. "bJUI": null,
  11486. /**
  11487. * The classes to use for the table
  11488. * @type object
  11489. * @default {}
  11490. */
  11491. "oClasses": {},
  11492. /**
  11493. * Flag attached to the settings object so you can check in the draw
  11494. * callback if filtering has been done in the draw. Deprecated in favour of
  11495. * events.
  11496. * @type boolean
  11497. * @default false
  11498. * @deprecated
  11499. */
  11500. "bFiltered": false,
  11501. /**
  11502. * Flag attached to the settings object so you can check in the draw
  11503. * callback if sorting has been done in the draw. Deprecated in favour of
  11504. * events.
  11505. * @type boolean
  11506. * @default false
  11507. * @deprecated
  11508. */
  11509. "bSorted": false,
  11510. /**
  11511. * Indicate that if multiple rows are in the header and there is more than
  11512. * one unique cell per column, if the top one (true) or bottom one (false)
  11513. * should be used for sorting / title by DataTables.
  11514. * Note that this parameter will be set by the initialisation routine. To
  11515. * set a default use {@link DataTable.defaults}.
  11516. * @type boolean
  11517. */
  11518. "bSortCellsTop": null,
  11519. /**
  11520. * Initialisation object that is used for the table
  11521. * @type object
  11522. * @default null
  11523. */
  11524. "oInit": null,
  11525. /**
  11526. * Destroy callback functions - for plug-ins to attach themselves to the
  11527. * destroy so they can clean up markup and events.
  11528. * @type array
  11529. * @default []
  11530. */
  11531. "aoDestroyCallback": [],
  11532. /**
  11533. * Get the number of records in the current record set, before filtering
  11534. * @type function
  11535. */
  11536. "fnRecordsTotal": function ()
  11537. {
  11538. return _fnDataSource( this ) == 'ssp' ?
  11539. this._iRecordsTotal * 1 :
  11540. this.aiDisplayMaster.length;
  11541. },
  11542. /**
  11543. * Get the number of records in the current record set, after filtering
  11544. * @type function
  11545. */
  11546. "fnRecordsDisplay": function ()
  11547. {
  11548. return _fnDataSource( this ) == 'ssp' ?
  11549. this._iRecordsDisplay * 1 :
  11550. this.aiDisplay.length;
  11551. },
  11552. /**
  11553. * Get the display end point - aiDisplay index
  11554. * @type function
  11555. */
  11556. "fnDisplayEnd": function ()
  11557. {
  11558. var
  11559. len = this._iDisplayLength,
  11560. start = this._iDisplayStart,
  11561. calc = start + len,
  11562. records = this.aiDisplay.length,
  11563. features = this.oFeatures,
  11564. paginate = features.bPaginate;
  11565. if ( features.bServerSide ) {
  11566. return paginate === false || len === -1 ?
  11567. start + records :
  11568. Math.min( start+len, this._iRecordsDisplay );
  11569. }
  11570. else {
  11571. return ! paginate || calc>records || len===-1 ?
  11572. records :
  11573. calc;
  11574. }
  11575. },
  11576. /**
  11577. * The DataTables object for this table
  11578. * @type object
  11579. * @default null
  11580. */
  11581. "oInstance": null,
  11582. /**
  11583. * Unique identifier for each instance of the DataTables object. If there
  11584. * is an ID on the table node, then it takes that value, otherwise an
  11585. * incrementing internal counter is used.
  11586. * @type string
  11587. * @default null
  11588. */
  11589. "sInstance": null,
  11590. /**
  11591. * tabindex attribute value that is added to DataTables control elements, allowing
  11592. * keyboard navigation of the table and its controls.
  11593. */
  11594. "iTabIndex": 0,
  11595. /**
  11596. * DIV container for the footer scrolling table if scrolling
  11597. */
  11598. "nScrollHead": null,
  11599. /**
  11600. * DIV container for the footer scrolling table if scrolling
  11601. */
  11602. "nScrollFoot": null,
  11603. /**
  11604. * Last applied sort
  11605. * @type array
  11606. * @default []
  11607. */
  11608. "aLastSort": [],
  11609. /**
  11610. * Stored plug-in instances
  11611. * @type object
  11612. * @default {}
  11613. */
  11614. "oPlugins": {}
  11615. };
  11616. /**
  11617. * Extension object for DataTables that is used to provide all extension
  11618. * options.
  11619. *
  11620. * Note that the `DataTable.ext` object is available through
  11621. * `jQuery.fn.dataTable.ext` where it may be accessed and manipulated. It is
  11622. * also aliased to `jQuery.fn.dataTableExt` for historic reasons.
  11623. * @namespace
  11624. * @extends DataTable.models.ext
  11625. */
  11626. /**
  11627. * DataTables extensions
  11628. *
  11629. * This namespace acts as a collection area for plug-ins that can be used to
  11630. * extend DataTables capabilities. Indeed many of the build in methods
  11631. * use this method to provide their own capabilities (sorting methods for
  11632. * example).
  11633. *
  11634. * Note that this namespace is aliased to `jQuery.fn.dataTableExt` for legacy
  11635. * reasons
  11636. *
  11637. * @namespace
  11638. */
  11639. DataTable.ext = _ext = {
  11640. /**
  11641. * Element class names
  11642. *
  11643. * @type object
  11644. * @default {}
  11645. */
  11646. classes: {},
  11647. /**
  11648. * Error reporting.
  11649. *
  11650. * How should DataTables report an error. Can take the value 'alert' or
  11651. * 'throw'
  11652. *
  11653. * @type string
  11654. * @default alert
  11655. */
  11656. errMode: "alert",
  11657. /**
  11658. * Feature plug-ins.
  11659. *
  11660. * This is an array of objects which describe the feature plug-ins that are
  11661. * available to DataTables. These feature plug-ins are then available for
  11662. * use through the `dom` initialisation option.
  11663. *
  11664. * Each feature plug-in is described by an object which must have the
  11665. * following properties:
  11666. *
  11667. * * `fnInit` - function that is used to initialise the plug-in,
  11668. * * `cFeature` - a character so the feature can be enabled by the `dom`
  11669. * instillation option. This is case sensitive.
  11670. *
  11671. * The `fnInit` function has the following input parameters:
  11672. *
  11673. * 1. `{object}` DataTables settings object: see
  11674. * {@link DataTable.models.oSettings}
  11675. *
  11676. * And the following return is expected:
  11677. *
  11678. * * {node|null} The element which contains your feature. Note that the
  11679. * return may also be void if your plug-in does not require to inject any
  11680. * DOM elements into DataTables control (`dom`) - for example this might
  11681. * be useful when developing a plug-in which allows table control via
  11682. * keyboard entry
  11683. *
  11684. * @type array
  11685. *
  11686. * @example
  11687. * $.fn.dataTable.ext.features.push( {
  11688. * "fnInit": function( oSettings ) {
  11689. * return new TableTools( { "oDTSettings": oSettings } );
  11690. * },
  11691. * "cFeature": "T"
  11692. * } );
  11693. */
  11694. feature: [],
  11695. /**
  11696. * Row searching.
  11697. *
  11698. * This method of searching is complimentary to the default type based
  11699. * searching, and a lot more comprehensive as it allows you complete control
  11700. * over the searching logic. Each element in this array is a function
  11701. * (parameters described below) that is called for every row in the table,
  11702. * and your logic decides if it should be included in the searching data set
  11703. * or not.
  11704. *
  11705. * Searching functions have the following input parameters:
  11706. *
  11707. * 1. `{object}` DataTables settings object: see
  11708. * {@link DataTable.models.oSettings}
  11709. * 2. `{array|object}` Data for the row to be processed (same as the
  11710. * original format that was passed in as the data source, or an array
  11711. * from a DOM data source
  11712. * 3. `{int}` Row index ({@link DataTable.models.oSettings.aoData}), which
  11713. * can be useful to retrieve the `TR` element if you need DOM interaction.
  11714. *
  11715. * And the following return is expected:
  11716. *
  11717. * * {boolean} Include the row in the searched result set (true) or not
  11718. * (false)
  11719. *
  11720. * Note that as with the main search ability in DataTables, technically this
  11721. * is "filtering", since it is subtractive. However, for consistency in
  11722. * naming we call it searching here.
  11723. *
  11724. * @type array
  11725. * @default []
  11726. *
  11727. * @example
  11728. * // The following example shows custom search being applied to the
  11729. * // fourth column (i.e. the data[3] index) based on two input values
  11730. * // from the end-user, matching the data in a certain range.
  11731. * $.fn.dataTable.ext.search.push(
  11732. * function( settings, data, dataIndex ) {
  11733. * var min = document.getElementById('min').value * 1;
  11734. * var max = document.getElementById('max').value * 1;
  11735. * var version = data[3] == "-" ? 0 : data[3]*1;
  11736. *
  11737. * if ( min == "" && max == "" ) {
  11738. * return true;
  11739. * }
  11740. * else if ( min == "" && version < max ) {
  11741. * return true;
  11742. * }
  11743. * else if ( min < version && "" == max ) {
  11744. * return true;
  11745. * }
  11746. * else if ( min < version && version < max ) {
  11747. * return true;
  11748. * }
  11749. * return false;
  11750. * }
  11751. * );
  11752. */
  11753. search: [],
  11754. /**
  11755. * Internal functions, exposed for used in plug-ins.
  11756. *
  11757. * Please note that you should not need to use the internal methods for
  11758. * anything other than a plug-in (and even then, try to avoid if possible).
  11759. * The internal function may change between releases.
  11760. *
  11761. * @type object
  11762. * @default {}
  11763. */
  11764. internal: {},
  11765. /**
  11766. * Legacy configuration options. Enable and disable legacy options that
  11767. * are available in DataTables.
  11768. *
  11769. * @type object
  11770. */
  11771. legacy: {
  11772. /**
  11773. * Enable / disable DataTables 1.9 compatible server-side processing
  11774. * requests
  11775. *
  11776. * @type boolean
  11777. * @default null
  11778. */
  11779. ajax: null
  11780. },
  11781. /**
  11782. * Pagination plug-in methods.
  11783. *
  11784. * Each entry in this object is a function and defines which buttons should
  11785. * be shown by the pagination rendering method that is used for the table:
  11786. * {@link DataTable.ext.renderer.pageButton}. The renderer addresses how the
  11787. * buttons are displayed in the document, while the functions here tell it
  11788. * what buttons to display. This is done by returning an array of button
  11789. * descriptions (what each button will do).
  11790. *
  11791. * Pagination types (the four built in options and any additional plug-in
  11792. * options defined here) can be used through the `paginationType`
  11793. * initialisation parameter.
  11794. *
  11795. * The functions defined take two parameters:
  11796. *
  11797. * 1. `{int} page` The current page index
  11798. * 2. `{int} pages` The number of pages in the table
  11799. *
  11800. * Each function is expected to return an array where each element of the
  11801. * array can be one of:
  11802. *
  11803. * * `first` - Jump to first page when activated
  11804. * * `last` - Jump to last page when activated
  11805. * * `previous` - Show previous page when activated
  11806. * * `next` - Show next page when activated
  11807. * * `{int}` - Show page of the index given
  11808. * * `{array}` - A nested array containing the above elements to add a
  11809. * containing 'DIV' element (might be useful for styling).
  11810. *
  11811. * Note that DataTables v1.9- used this object slightly differently whereby
  11812. * an object with two functions would be defined for each plug-in. That
  11813. * ability is still supported by DataTables 1.10+ to provide backwards
  11814. * compatibility, but this option of use is now decremented and no longer
  11815. * documented in DataTables 1.10+.
  11816. *
  11817. * @type object
  11818. * @default {}
  11819. *
  11820. * @example
  11821. * // Show previous, next and current page buttons only
  11822. * $.fn.dataTableExt.oPagination.current = function ( page, pages ) {
  11823. * return [ 'previous', page, 'next' ];
  11824. * };
  11825. */
  11826. pager: {},
  11827. renderer: {
  11828. pageButton: {},
  11829. header: {}
  11830. },
  11831. /**
  11832. * Ordering plug-ins - custom data source
  11833. *
  11834. * The extension options for ordering of data available here is complimentary
  11835. * to the default type based ordering that DataTables typically uses. It
  11836. * allows much greater control over the the data that is being used to
  11837. * order a column, but is necessarily therefore more complex.
  11838. *
  11839. * This type of ordering is useful if you want to do ordering based on data
  11840. * live from the DOM (for example the contents of an 'input' element) rather
  11841. * than just the static string that DataTables knows of.
  11842. *
  11843. * The way these plug-ins work is that you create an array of the values you
  11844. * wish to be ordering for the column in question and then return that
  11845. * array. The data in the array much be in the index order of the rows in
  11846. * the table (not the currently ordering order!). Which order data gathering
  11847. * function is run here depends on the `dt-init columns.orderDataType`
  11848. * parameter that is used for the column (if any).
  11849. *
  11850. * The functions defined take two parameters:
  11851. *
  11852. * 1. `{object}` DataTables settings object: see
  11853. * {@link DataTable.models.oSettings}
  11854. * 2. `{int}` Target column index
  11855. *
  11856. * Each function is expected to return an array:
  11857. *
  11858. * * `{array}` Data for the column to be ordering upon
  11859. *
  11860. * @type array
  11861. *
  11862. * @example
  11863. * // Ordering using `input` node values
  11864. * $.fn.dataTable.ext.order['dom-text'] = function ( settings, col )
  11865. * {
  11866. * return this.api().column( col, {order:'index'} ).nodes().map( function ( td, i ) {
  11867. * return $('input', td).val();
  11868. * } );
  11869. * }
  11870. */
  11871. order: {},
  11872. /**
  11873. * Type based plug-ins.
  11874. *
  11875. * Each column in DataTables has a type assigned to it, either by automatic
  11876. * detection or by direct assignment using the `type` option for the column.
  11877. * The type of a column will effect how it is ordering and search (plug-ins
  11878. * can also make use of the column type if required).
  11879. *
  11880. * @namespace
  11881. */
  11882. type: {
  11883. /**
  11884. * Type detection functions.
  11885. *
  11886. * The functions defined in this object are used to automatically detect
  11887. * a column's type, making initialisation of DataTables super easy, even
  11888. * when complex data is in the table.
  11889. *
  11890. * The functions defined take two parameters:
  11891. *
  11892. * 1. `{*}` Data from the column cell to be analysed
  11893. * 2. `{settings}` DataTables settings object. This can be used to
  11894. * perform context specific type detection - for example detection
  11895. * based on language settings such as using a comma for a decimal
  11896. * place. Generally speaking the options from the settings will not
  11897. * be required
  11898. *
  11899. * Each function is expected to return:
  11900. *
  11901. * * `{string|null}` Data type detected, or null if unknown (and thus
  11902. * pass it on to the other type detection functions.
  11903. *
  11904. * @type array
  11905. *
  11906. * @example
  11907. * // Currency type detection plug-in:
  11908. * $.fn.dataTable.ext.type.detect.push(
  11909. * function ( data, settings ) {
  11910. * // Check the numeric part
  11911. * if ( ! $.isNumeric( data.substring(1) ) ) {
  11912. * return null;
  11913. * }
  11914. *
  11915. * // Check prefixed by currency
  11916. * if ( data.charAt(0) == '$' || data.charAt(0) == '&pound;' ) {
  11917. * return 'currency';
  11918. * }
  11919. * return null;
  11920. * }
  11921. * );
  11922. */
  11923. detect: [],
  11924. /**
  11925. * Type based search formatting.
  11926. *
  11927. * The type based searching functions can be used to pre-format the
  11928. * data to be search on. For example, it can be used to strip HTML
  11929. * tags or to de-format telephone numbers for numeric only searching.
  11930. *
  11931. * Note that is a search is not defined for a column of a given type,
  11932. * no search formatting will be performed.
  11933. *
  11934. * Pre-processing of searching data plug-ins - When you assign the sType
  11935. * for a column (or have it automatically detected for you by DataTables
  11936. * or a type detection plug-in), you will typically be using this for
  11937. * custom sorting, but it can also be used to provide custom searching
  11938. * by allowing you to pre-processing the data and returning the data in
  11939. * the format that should be searched upon. This is done by adding
  11940. * functions this object with a parameter name which matches the sType
  11941. * for that target column. This is the corollary of <i>afnSortData</i>
  11942. * for searching data.
  11943. *
  11944. * The functions defined take a single parameter:
  11945. *
  11946. * 1. `{*}` Data from the column cell to be prepared for searching
  11947. *
  11948. * Each function is expected to return:
  11949. *
  11950. * * `{string|null}` Formatted string that will be used for the searching.
  11951. *
  11952. * @type object
  11953. * @default {}
  11954. *
  11955. * @example
  11956. * $.fn.dataTable.ext.type.search['title-numeric'] = function ( d ) {
  11957. * return d.replace(/\n/g," ").replace( /<.*?>/g, "" );
  11958. * }
  11959. */
  11960. search: {},
  11961. /**
  11962. * Type based ordering.
  11963. *
  11964. * The column type tells DataTables what ordering to apply to the table
  11965. * when a column is sorted upon. The order for each type that is defined,
  11966. * is defined by the functions available in this object.
  11967. *
  11968. * Each ordering option can be described by three properties added to
  11969. * this object:
  11970. *
  11971. * * `{type}-pre` - Pre-formatting function
  11972. * * `{type}-asc` - Ascending order function
  11973. * * `{type}-desc` - Descending order function
  11974. *
  11975. * All three can be used together, only `{type}-pre` or only
  11976. * `{type}-asc` and `{type}-desc` together. It is generally recommended
  11977. * that only `{type}-pre` is used, as this provides the optimal
  11978. * implementation in terms of speed, although the others are provided
  11979. * for compatibility with existing Javascript sort functions.
  11980. *
  11981. * `{type}-pre`: Functions defined take a single parameter:
  11982. *
  11983. * 1. `{*}` Data from the column cell to be prepared for ordering
  11984. *
  11985. * And return:
  11986. *
  11987. * * `{*}` Data to be sorted upon
  11988. *
  11989. * `{type}-asc` and `{type}-desc`: Functions are typical Javascript sort
  11990. * functions, taking two parameters:
  11991. *
  11992. * 1. `{*}` Data to compare to the second parameter
  11993. * 2. `{*}` Data to compare to the first parameter
  11994. *
  11995. * And returning:
  11996. *
  11997. * * `{*}` Ordering match: <0 if first parameter should be sorted lower
  11998. * than the second parameter, ===0 if the two parameters are equal and
  11999. * >0 if the first parameter should be sorted height than the second
  12000. * parameter.
  12001. *
  12002. * @type object
  12003. * @default {}
  12004. *
  12005. * @example
  12006. * // Numeric ordering of formatted numbers with a pre-formatter
  12007. * $.extend( $.fn.dataTable.ext.type.order, {
  12008. * "string-pre": function(x) {
  12009. * a = (a === "-" || a === "") ? 0 : a.replace( /[^\d\-\.]/g, "" );
  12010. * return parseFloat( a );
  12011. * }
  12012. * } );
  12013. *
  12014. * @example
  12015. * // Case-sensitive string ordering, with no pre-formatting method
  12016. * $.extend( $.fn.dataTable.ext.order, {
  12017. * "string-case-asc": function(x,y) {
  12018. * return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12019. * },
  12020. * "string-case-desc": function(x,y) {
  12021. * return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12022. * }
  12023. * } );
  12024. */
  12025. order: {}
  12026. },
  12027. /**
  12028. * Unique DataTables instance counter
  12029. *
  12030. * @type int
  12031. * @private
  12032. */
  12033. _unique: 0,
  12034. //
  12035. // Depreciated
  12036. // The following properties are retained for backwards compatiblity only.
  12037. // The should not be used in new projects and will be removed in a future
  12038. // version
  12039. //
  12040. /**
  12041. * Version check function.
  12042. * @type function
  12043. * @depreciated Since 1.10
  12044. */
  12045. fnVersionCheck: DataTable.fnVersionCheck,
  12046. /**
  12047. * Index for what 'this' index API functions should use
  12048. * @type int
  12049. * @deprecated Since v1.10
  12050. */
  12051. iApiIndex: 0,
  12052. /**
  12053. * jQuery UI class container
  12054. * @type object
  12055. * @deprecated Since v1.10
  12056. */
  12057. oJUIClasses: {},
  12058. /**
  12059. * Software version
  12060. * @type string
  12061. * @deprecated Since v1.10
  12062. */
  12063. sVersion: DataTable.version
  12064. };
  12065. //
  12066. // Backwards compatibility. Alias to pre 1.10 Hungarian notation counter parts
  12067. //
  12068. $.extend( _ext, {
  12069. afnFiltering: _ext.search,
  12070. aTypes: _ext.type.detect,
  12071. ofnSearch: _ext.type.search,
  12072. oSort: _ext.type.order,
  12073. afnSortData: _ext.order,
  12074. aoFeatures: _ext.feature,
  12075. oApi: _ext.internal,
  12076. oStdClasses: _ext.classes,
  12077. oPagination: _ext.pager
  12078. } );
  12079. $.extend( DataTable.ext.classes, {
  12080. "sTable": "dataTable",
  12081. "sNoFooter": "no-footer",
  12082. /* Paging buttons */
  12083. "sPageButton": "paginate_button",
  12084. "sPageButtonActive": "current",
  12085. "sPageButtonDisabled": "disabled",
  12086. /* Striping classes */
  12087. "sStripeOdd": "odd",
  12088. "sStripeEven": "even",
  12089. /* Empty row */
  12090. "sRowEmpty": "dataTables_empty",
  12091. /* Features */
  12092. "sWrapper": "dataTables_wrapper",
  12093. "sFilter": "dataTables_filter",
  12094. "sInfo": "dataTables_info",
  12095. "sPaging": "dataTables_paginate paging_", /* Note that the type is postfixed */
  12096. "sLength": "dataTables_length",
  12097. "sProcessing": "dataTables_processing",
  12098. /* Sorting */
  12099. "sSortAsc": "sorting_asc",
  12100. "sSortDesc": "sorting_desc",
  12101. "sSortable": "sorting", /* Sortable in both directions */
  12102. "sSortableAsc": "sorting_asc_disabled",
  12103. "sSortableDesc": "sorting_desc_disabled",
  12104. "sSortableNone": "sorting_disabled",
  12105. "sSortColumn": "sorting_", /* Note that an int is postfixed for the sorting order */
  12106. /* Filtering */
  12107. "sFilterInput": "",
  12108. /* Page length */
  12109. "sLengthSelect": "",
  12110. /* Scrolling */
  12111. "sScrollWrapper": "dataTables_scroll",
  12112. "sScrollHead": "dataTables_scrollHead",
  12113. "sScrollHeadInner": "dataTables_scrollHeadInner",
  12114. "sScrollBody": "dataTables_scrollBody",
  12115. "sScrollFoot": "dataTables_scrollFoot",
  12116. "sScrollFootInner": "dataTables_scrollFootInner",
  12117. /* Misc */
  12118. "sHeaderTH": "",
  12119. "sFooterTH": "",
  12120. // Deprecated
  12121. "sSortJUIAsc": "",
  12122. "sSortJUIDesc": "",
  12123. "sSortJUI": "",
  12124. "sSortJUIAscAllowed": "",
  12125. "sSortJUIDescAllowed": "",
  12126. "sSortJUIWrapper": "",
  12127. "sSortIcon": "",
  12128. "sJUIHeader": "",
  12129. "sJUIFooter": ""
  12130. } );
  12131. (function() {
  12132. // Reused strings for better compression. Closure compiler appears to have a
  12133. // weird edge case where it is trying to expand strings rather than use the
  12134. // variable version. This results in about 200 bytes being added, for very
  12135. // little preference benefit since it this run on script load only.
  12136. var _empty = '';
  12137. _empty = '';
  12138. var _stateDefault = _empty + 'ui-state-default';
  12139. var _sortIcon = _empty + 'css_right ui-icon ui-icon-';
  12140. var _headerFooter = _empty + 'fg-toolbar ui-toolbar ui-widget-header ui-helper-clearfix';
  12141. $.extend( DataTable.ext.oJUIClasses, DataTable.ext.classes, {
  12142. /* Full numbers paging buttons */
  12143. "sPageButton": "fg-button ui-button "+_stateDefault,
  12144. "sPageButtonActive": "ui-state-disabled",
  12145. "sPageButtonDisabled": "ui-state-disabled",
  12146. /* Features */
  12147. "sPaging": "dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi "+
  12148. "ui-buttonset-multi paging_", /* Note that the type is postfixed */
  12149. /* Sorting */
  12150. "sSortAsc": _stateDefault+" sorting_asc",
  12151. "sSortDesc": _stateDefault+" sorting_desc",
  12152. "sSortable": _stateDefault+" sorting",
  12153. "sSortableAsc": _stateDefault+" sorting_asc_disabled",
  12154. "sSortableDesc": _stateDefault+" sorting_desc_disabled",
  12155. "sSortableNone": _stateDefault+" sorting_disabled",
  12156. "sSortJUIAsc": _sortIcon+"triangle-1-n",
  12157. "sSortJUIDesc": _sortIcon+"triangle-1-s",
  12158. "sSortJUI": _sortIcon+"carat-2-n-s",
  12159. "sSortJUIAscAllowed": _sortIcon+"carat-1-n",
  12160. "sSortJUIDescAllowed": _sortIcon+"carat-1-s",
  12161. "sSortJUIWrapper": "DataTables_sort_wrapper",
  12162. "sSortIcon": "DataTables_sort_icon",
  12163. /* Scrolling */
  12164. "sScrollHead": "dataTables_scrollHead "+_stateDefault,
  12165. "sScrollFoot": "dataTables_scrollFoot "+_stateDefault,
  12166. /* Misc */
  12167. "sHeaderTH": _stateDefault,
  12168. "sFooterTH": _stateDefault,
  12169. "sJUIHeader": _headerFooter+" ui-corner-tl ui-corner-tr",
  12170. "sJUIFooter": _headerFooter+" ui-corner-bl ui-corner-br"
  12171. } );
  12172. }());
  12173. var extPagination = DataTable.ext.pager;
  12174. function _numbers ( page, pages ) {
  12175. var
  12176. numbers = [],
  12177. buttons = extPagination.numbers_length,
  12178. half = Math.floor( buttons / 2 ),
  12179. i = 1;
  12180. if ( pages <= buttons ) {
  12181. numbers = _range( 0, pages );
  12182. }
  12183. else if ( page <= half ) {
  12184. numbers = _range( 0, buttons-2 );
  12185. numbers.push( 'ellipsis' );
  12186. numbers.push( pages-1 );
  12187. }
  12188. else if ( page >= pages - 1 - half ) {
  12189. numbers = _range( pages-(buttons-2), pages );
  12190. numbers.splice( 0, 0, 'ellipsis' ); // no unshift in ie6
  12191. numbers.splice( 0, 0, 0 );
  12192. }
  12193. else {
  12194. numbers = _range( page-1, page+2 );
  12195. numbers.push( 'ellipsis' );
  12196. numbers.push( pages-1 );
  12197. numbers.splice( 0, 0, 'ellipsis' );
  12198. numbers.splice( 0, 0, 0 );
  12199. }
  12200. numbers.DT_el = 'span';
  12201. return numbers;
  12202. }
  12203. $.extend( extPagination, {
  12204. simple: function ( page, pages ) {
  12205. return [ 'previous', 'next' ];
  12206. },
  12207. full: function ( page, pages ) {
  12208. return [ 'first', 'previous', 'next', 'last' ];
  12209. },
  12210. simple_numbers: function ( page, pages ) {
  12211. return [ 'previous', _numbers(page, pages), 'next' ];
  12212. },
  12213. full_numbers: function ( page, pages ) {
  12214. return [ 'first', 'previous', _numbers(page, pages), 'next', 'last' ];
  12215. },
  12216. // For testing and plug-ins to use
  12217. _numbers: _numbers,
  12218. numbers_length: 7
  12219. } );
  12220. $.extend( true, DataTable.ext.renderer, {
  12221. pageButton: {
  12222. _: function ( settings, host, idx, buttons, page, pages ) {
  12223. var classes = settings.oClasses;
  12224. var lang = settings.oLanguage.oPaginate;
  12225. var btnDisplay, btnClass, counter=0;
  12226. var attach = function( container, buttons ) {
  12227. var i, ien, node, button;
  12228. var clickHandler = function ( e ) {
  12229. _fnPageChange( settings, e.data.action, true );
  12230. };
  12231. for ( i=0, ien=buttons.length ; i<ien ; i++ ) {
  12232. button = buttons[i];
  12233. if ( $.isArray( button ) ) {
  12234. var inner = $( '<'+(button.DT_el || 'div')+'/>' )
  12235. .appendTo( container );
  12236. attach( inner, button );
  12237. }
  12238. else {
  12239. btnDisplay = '';
  12240. btnClass = '';
  12241. switch ( button ) {
  12242. case 'ellipsis':
  12243. container.append('<span>&hellip;</span>');
  12244. break;
  12245. case 'first':
  12246. btnDisplay = lang.sFirst;
  12247. btnClass = button + (page > 0 ?
  12248. '' : ' '+classes.sPageButtonDisabled);
  12249. break;
  12250. case 'previous':
  12251. btnDisplay = lang.sPrevious;
  12252. btnClass = button + (page > 0 ?
  12253. '' : ' '+classes.sPageButtonDisabled);
  12254. break;
  12255. case 'next':
  12256. btnDisplay = lang.sNext;
  12257. btnClass = button + (page < pages-1 ?
  12258. '' : ' '+classes.sPageButtonDisabled);
  12259. break;
  12260. case 'last':
  12261. btnDisplay = lang.sLast;
  12262. btnClass = button + (page < pages-1 ?
  12263. '' : ' '+classes.sPageButtonDisabled);
  12264. break;
  12265. default:
  12266. btnDisplay = button + 1;
  12267. btnClass = page === button ?
  12268. classes.sPageButtonActive : '';
  12269. break;
  12270. }
  12271. if ( btnDisplay ) {
  12272. node = $('<a>', {
  12273. 'class': classes.sPageButton+' '+btnClass,
  12274. 'aria-controls': settings.sTableId,
  12275. 'data-dt-idx': counter,
  12276. 'tabindex': settings.iTabIndex,
  12277. 'id': idx === 0 && typeof button === 'string' ?
  12278. settings.sTableId +'_'+ button :
  12279. null
  12280. } )
  12281. .html( btnDisplay )
  12282. .appendTo( container );
  12283. _fnBindAction(
  12284. node, {action: button}, clickHandler
  12285. );
  12286. counter++;
  12287. }
  12288. }
  12289. }
  12290. };
  12291. // IE9 throws an 'unknown error' if document.activeElement is used
  12292. // inside an iframe or frame. Try / catch the error. Not good for
  12293. // accessibility, but neither are frames.
  12294. try {
  12295. // Because this approach is destroying and recreating the paging
  12296. // elements, focus is lost on the select button which is bad for
  12297. // accessibility. So we want to restore focus once the draw has
  12298. // completed
  12299. var activeEl = $(document.activeElement).data('dt-idx');
  12300. attach( $(host).empty(), buttons );
  12301. if ( activeEl !== null ) {
  12302. $(host).find( '[data-dt-idx='+activeEl+']' ).focus();
  12303. }
  12304. }
  12305. catch (e) {}
  12306. }
  12307. }
  12308. } );
  12309. var __numericReplace = function ( d, decimalPlace, re1, re2 ) {
  12310. if ( d !== 0 && (!d || d === '-') ) {
  12311. return -Infinity;
  12312. }
  12313. // If a decimal place other than `.` is used, it needs to be given to the
  12314. // function so we can detect it and replace with a `.` which is the only
  12315. // decimal place Javascript recognises - it is not locale aware.
  12316. if ( decimalPlace ) {
  12317. d = _numToDecimal( d, decimalPlace );
  12318. }
  12319. if ( d.replace ) {
  12320. if ( re1 ) {
  12321. d = d.replace( re1, '' );
  12322. }
  12323. if ( re2 ) {
  12324. d = d.replace( re2, '' );
  12325. }
  12326. }
  12327. return d * 1;
  12328. };
  12329. // Add the numeric 'deformatting' functions for sorting. This is done in a
  12330. // function to provide an easy ability for the language options to add
  12331. // additional methods if a non-period decimal place is used.
  12332. function _addNumericSort ( decimalPlace ) {
  12333. $.each(
  12334. {
  12335. // Plain numbers
  12336. "num": function ( d ) {
  12337. return __numericReplace( d, decimalPlace );
  12338. },
  12339. // Formatted numbers
  12340. "num-fmt": function ( d ) {
  12341. return __numericReplace( d, decimalPlace, _re_formatted_numeric );
  12342. },
  12343. // HTML numeric
  12344. "html-num": function ( d ) {
  12345. return __numericReplace( d, decimalPlace, _re_html );
  12346. },
  12347. // HTML numeric, formatted
  12348. "html-num-fmt": function ( d ) {
  12349. return __numericReplace( d, decimalPlace, _re_html, _re_formatted_numeric );
  12350. }
  12351. },
  12352. function ( key, fn ) {
  12353. _ext.type.order[ key+decimalPlace+'-pre' ] = fn;
  12354. }
  12355. );
  12356. }
  12357. // Default sort methods
  12358. $.extend( _ext.type.order, {
  12359. // Dates
  12360. "date-pre": function ( d ) {
  12361. return Date.parse( d ) || 0;
  12362. },
  12363. // html
  12364. "html-pre": function ( a ) {
  12365. return _empty(a) ?
  12366. '' :
  12367. a.replace ?
  12368. a.replace( /<.*?>/g, "" ).toLowerCase() :
  12369. a+'';
  12370. },
  12371. // string
  12372. "string-pre": function ( a ) {
  12373. // This is a little complex, but faster than always calling toString,
  12374. // http://jsperf.com/tostring-v-check
  12375. return _empty(a) ?
  12376. '' :
  12377. typeof a === 'string' ?
  12378. a.toLowerCase() :
  12379. ! a.toString ?
  12380. '' :
  12381. a.toString();
  12382. },
  12383. // string-asc and -desc are retained only for compatibility with the old
  12384. // sort methods
  12385. "string-asc": function ( x, y ) {
  12386. return ((x < y) ? -1 : ((x > y) ? 1 : 0));
  12387. },
  12388. "string-desc": function ( x, y ) {
  12389. return ((x < y) ? 1 : ((x > y) ? -1 : 0));
  12390. }
  12391. } );
  12392. // Numeric sorting types - order doesn't matter here
  12393. _addNumericSort( '' );
  12394. // Built in type detection. See model.ext.aTypes for information about
  12395. // what is required from this methods.
  12396. $.extend( DataTable.ext.type.detect, [
  12397. // Plain numbers - first since V8 detects some plain numbers as dates
  12398. // e.g. Date.parse('55') (but not all, e.g. Date.parse('22')...).
  12399. function ( d, settings )
  12400. {
  12401. var decimal = settings.oLanguage.sDecimal;
  12402. return _isNumber( d, decimal ) ? 'num'+decimal : null;
  12403. },
  12404. // Dates (only those recognised by the browser's Date.parse)
  12405. function ( d, settings )
  12406. {
  12407. // V8 will remove any unknown characters at the start and end of the
  12408. // expression, leading to false matches such as `$245.12` or `10%` being
  12409. // a valid date. See forum thread 18941 for detail.
  12410. if ( d && !(d instanceof Date) && ( ! _re_date_start.test(d) || ! _re_date_end.test(d) ) ) {
  12411. return null;
  12412. }
  12413. var parsed = Date.parse(d);
  12414. return (parsed !== null && !isNaN(parsed)) || _empty(d) ? 'date' : null;
  12415. },
  12416. // Formatted numbers
  12417. function ( d, settings )
  12418. {
  12419. var decimal = settings.oLanguage.sDecimal;
  12420. return _isNumber( d, decimal, true ) ? 'num-fmt'+decimal : null;
  12421. },
  12422. // HTML numeric
  12423. function ( d, settings )
  12424. {
  12425. var decimal = settings.oLanguage.sDecimal;
  12426. return _htmlNumeric( d, decimal ) ? 'html-num'+decimal : null;
  12427. },
  12428. // HTML numeric, formatted
  12429. function ( d, settings )
  12430. {
  12431. var decimal = settings.oLanguage.sDecimal;
  12432. return _htmlNumeric( d, decimal, true ) ? 'html-num-fmt'+decimal : null;
  12433. },
  12434. // HTML (this is strict checking - there must be html)
  12435. function ( d, settings )
  12436. {
  12437. return _empty( d ) || (typeof d === 'string' && d.indexOf('<') !== -1) ?
  12438. 'html' : null;
  12439. }
  12440. ] );
  12441. // Filter formatting functions. See model.ext.ofnSearch for information about
  12442. // what is required from these methods.
  12443. $.extend( DataTable.ext.type.search, {
  12444. html: function ( data ) {
  12445. return _empty(data) ?
  12446. data :
  12447. typeof data === 'string' ?
  12448. data
  12449. .replace( _re_new_lines, " " )
  12450. .replace( _re_html, "" ) :
  12451. '';
  12452. },
  12453. string: function ( data ) {
  12454. return _empty(data) ?
  12455. data :
  12456. typeof data === 'string' ?
  12457. data.replace( _re_new_lines, " " ) :
  12458. data;
  12459. }
  12460. } );
  12461. $.extend( true, DataTable.ext.renderer, {
  12462. header: {
  12463. _: function ( settings, cell, column, classes ) {
  12464. // No additional mark-up required
  12465. // Attach a sort listener to update on sort - note that using the
  12466. // `DT` namespace will allow the event to be removed automatically
  12467. // on destroy, while the `dt` namespaced event is the one we are
  12468. // listening for
  12469. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  12470. if ( settings !== ctx ) { // need to check this this is the host
  12471. return; // table, not a nested one
  12472. }
  12473. var colIdx = column.idx;
  12474. cell
  12475. .removeClass(
  12476. column.sSortingClass +' '+
  12477. classes.sSortAsc +' '+
  12478. classes.sSortDesc
  12479. )
  12480. .addClass( columns[ colIdx ] == 'asc' ?
  12481. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  12482. classes.sSortDesc :
  12483. column.sSortingClass
  12484. );
  12485. } );
  12486. },
  12487. jqueryui: function ( settings, cell, column, classes ) {
  12488. $('<div/>')
  12489. .addClass( classes.sSortJUIWrapper )
  12490. .append( cell.contents() )
  12491. .append( $('<span/>')
  12492. .addClass( classes.sSortIcon+' '+column.sSortingClassJUI )
  12493. )
  12494. .appendTo( cell );
  12495. // Attach a sort listener to update on sort
  12496. $(settings.nTable).on( 'order.dt.DT', function ( e, ctx, sorting, columns ) {
  12497. if ( settings !== ctx ) {
  12498. return;
  12499. }
  12500. var colIdx = column.idx;
  12501. cell
  12502. .removeClass( classes.sSortAsc +" "+classes.sSortDesc )
  12503. .addClass( columns[ colIdx ] == 'asc' ?
  12504. classes.sSortAsc : columns[ colIdx ] == 'desc' ?
  12505. classes.sSortDesc :
  12506. column.sSortingClass
  12507. );
  12508. cell
  12509. .find( 'span.'+classes.sSortIcon )
  12510. .removeClass(
  12511. classes.sSortJUIAsc +" "+
  12512. classes.sSortJUIDesc +" "+
  12513. classes.sSortJUI +" "+
  12514. classes.sSortJUIAscAllowed +" "+
  12515. classes.sSortJUIDescAllowed
  12516. )
  12517. .addClass( columns[ colIdx ] == 'asc' ?
  12518. classes.sSortJUIAsc : columns[ colIdx ] == 'desc' ?
  12519. classes.sSortJUIDesc :
  12520. column.sSortingClassJUI
  12521. );
  12522. } );
  12523. }
  12524. }
  12525. } );
  12526. /*
  12527. * Public helper functions. These aren't used internally by DataTables, or
  12528. * called by any of the options passed into DataTables, but they can be used
  12529. * externally by developers working with DataTables. They are helper functions
  12530. * to make working with DataTables a little bit easier.
  12531. */
  12532. /**
  12533. * Helpers for `columns.render`.
  12534. *
  12535. * The options defined here can be used with the `columns.render` initialisation
  12536. * option to provide a display renderer. The following functions are defined:
  12537. *
  12538. * * `number` - Will format numeric data (defined by `columns.data`) for
  12539. * display, retaining the original unformatted data for sorting and filtering.
  12540. * It takes 4 parameters:
  12541. * * `string` - Thousands grouping separator
  12542. * * `string` - Decimal point indicator
  12543. * * `integer` - Number of decimal points to show
  12544. * * `string` (optional) - Prefix.
  12545. *
  12546. * @example
  12547. * // Column definition using the number renderer
  12548. * {
  12549. * data: "salary",
  12550. * render: $.fn.dataTable.render.number( '\'', '.', 0, '$' )
  12551. * }
  12552. *
  12553. * @namespace
  12554. */
  12555. DataTable.render = {
  12556. number: function ( thousands, decimal, precision, prefix ) {
  12557. return {
  12558. display: function ( d ) {
  12559. var negative = d < 0 ? '-' : '';
  12560. d = Math.abs( parseFloat( d ) );
  12561. var intPart = parseInt( d, 10 );
  12562. var floatPart = precision ?
  12563. decimal+(d - intPart).toFixed( precision ).substring( 2 ):
  12564. '';
  12565. return negative + (prefix||'') +
  12566. intPart.toString().replace(
  12567. /\B(?=(\d{3})+(?!\d))/g, thousands
  12568. ) +
  12569. floatPart;
  12570. }
  12571. };
  12572. }
  12573. };
  12574. /*
  12575. * This is really a good bit rubbish this method of exposing the internal methods
  12576. * publicly... - To be fixed in 2.0 using methods on the prototype
  12577. */
  12578. /**
  12579. * Create a wrapper function for exporting an internal functions to an external API.
  12580. * @param {string} fn API function name
  12581. * @returns {function} wrapped function
  12582. * @memberof DataTable#internal
  12583. */
  12584. function _fnExternApiFunc (fn)
  12585. {
  12586. return function() {
  12587. var args = [_fnSettingsFromNode( this[DataTable.ext.iApiIndex] )].concat(
  12588. Array.prototype.slice.call(arguments)
  12589. );
  12590. return DataTable.ext.internal[fn].apply( this, args );
  12591. };
  12592. }
  12593. /**
  12594. * Reference to internal functions for use by plug-in developers. Note that
  12595. * these methods are references to internal functions and are considered to be
  12596. * private. If you use these methods, be aware that they are liable to change
  12597. * between versions.
  12598. * @namespace
  12599. */
  12600. $.extend( DataTable.ext.internal, {
  12601. _fnExternApiFunc: _fnExternApiFunc,
  12602. _fnBuildAjax: _fnBuildAjax,
  12603. _fnAjaxUpdate: _fnAjaxUpdate,
  12604. _fnAjaxParameters: _fnAjaxParameters,
  12605. _fnAjaxUpdateDraw: _fnAjaxUpdateDraw,
  12606. _fnAjaxDataSrc: _fnAjaxDataSrc,
  12607. _fnAddColumn: _fnAddColumn,
  12608. _fnColumnOptions: _fnColumnOptions,
  12609. _fnAdjustColumnSizing: _fnAdjustColumnSizing,
  12610. _fnVisibleToColumnIndex: _fnVisibleToColumnIndex,
  12611. _fnColumnIndexToVisible: _fnColumnIndexToVisible,
  12612. _fnVisbleColumns: _fnVisbleColumns,
  12613. _fnGetColumns: _fnGetColumns,
  12614. _fnColumnTypes: _fnColumnTypes,
  12615. _fnApplyColumnDefs: _fnApplyColumnDefs,
  12616. _fnHungarianMap: _fnHungarianMap,
  12617. _fnCamelToHungarian: _fnCamelToHungarian,
  12618. _fnLanguageCompat: _fnLanguageCompat,
  12619. _fnBrowserDetect: _fnBrowserDetect,
  12620. _fnAddData: _fnAddData,
  12621. _fnAddTr: _fnAddTr,
  12622. _fnNodeToDataIndex: _fnNodeToDataIndex,
  12623. _fnNodeToColumnIndex: _fnNodeToColumnIndex,
  12624. _fnGetCellData: _fnGetCellData,
  12625. _fnSetCellData: _fnSetCellData,
  12626. _fnSplitObjNotation: _fnSplitObjNotation,
  12627. _fnGetObjectDataFn: _fnGetObjectDataFn,
  12628. _fnSetObjectDataFn: _fnSetObjectDataFn,
  12629. _fnGetDataMaster: _fnGetDataMaster,
  12630. _fnClearTable: _fnClearTable,
  12631. _fnDeleteIndex: _fnDeleteIndex,
  12632. _fnInvalidateRow: _fnInvalidateRow,
  12633. _fnGetRowElements: _fnGetRowElements,
  12634. _fnCreateTr: _fnCreateTr,
  12635. _fnBuildHead: _fnBuildHead,
  12636. _fnDrawHead: _fnDrawHead,
  12637. _fnDraw: _fnDraw,
  12638. _fnReDraw: _fnReDraw,
  12639. _fnAddOptionsHtml: _fnAddOptionsHtml,
  12640. _fnDetectHeader: _fnDetectHeader,
  12641. _fnGetUniqueThs: _fnGetUniqueThs,
  12642. _fnFeatureHtmlFilter: _fnFeatureHtmlFilter,
  12643. _fnFilterComplete: _fnFilterComplete,
  12644. _fnFilterCustom: _fnFilterCustom,
  12645. _fnFilterColumn: _fnFilterColumn,
  12646. _fnFilter: _fnFilter,
  12647. _fnFilterCreateSearch: _fnFilterCreateSearch,
  12648. _fnEscapeRegex: _fnEscapeRegex,
  12649. _fnFilterData: _fnFilterData,
  12650. _fnFeatureHtmlInfo: _fnFeatureHtmlInfo,
  12651. _fnUpdateInfo: _fnUpdateInfo,
  12652. _fnInfoMacros: _fnInfoMacros,
  12653. _fnInitialise: _fnInitialise,
  12654. _fnInitComplete: _fnInitComplete,
  12655. _fnLengthChange: _fnLengthChange,
  12656. _fnFeatureHtmlLength: _fnFeatureHtmlLength,
  12657. _fnFeatureHtmlPaginate: _fnFeatureHtmlPaginate,
  12658. _fnPageChange: _fnPageChange,
  12659. _fnFeatureHtmlProcessing: _fnFeatureHtmlProcessing,
  12660. _fnProcessingDisplay: _fnProcessingDisplay,
  12661. _fnFeatureHtmlTable: _fnFeatureHtmlTable,
  12662. _fnScrollDraw: _fnScrollDraw,
  12663. _fnApplyToChildren: _fnApplyToChildren,
  12664. _fnCalculateColumnWidths: _fnCalculateColumnWidths,
  12665. _fnThrottle: _fnThrottle,
  12666. _fnConvertToWidth: _fnConvertToWidth,
  12667. _fnScrollingWidthAdjust: _fnScrollingWidthAdjust,
  12668. _fnGetWidestNode: _fnGetWidestNode,
  12669. _fnGetMaxLenString: _fnGetMaxLenString,
  12670. _fnStringToCss: _fnStringToCss,
  12671. _fnScrollBarWidth: _fnScrollBarWidth,
  12672. _fnSortFlatten: _fnSortFlatten,
  12673. _fnSort: _fnSort,
  12674. _fnSortAria: _fnSortAria,
  12675. _fnSortListener: _fnSortListener,
  12676. _fnSortAttachListener: _fnSortAttachListener,
  12677. _fnSortingClasses: _fnSortingClasses,
  12678. _fnSortData: _fnSortData,
  12679. _fnSaveState: _fnSaveState,
  12680. _fnLoadState: _fnLoadState,
  12681. _fnSettingsFromNode: _fnSettingsFromNode,
  12682. _fnLog: _fnLog,
  12683. _fnMap: _fnMap,
  12684. _fnBindAction: _fnBindAction,
  12685. _fnCallbackReg: _fnCallbackReg,
  12686. _fnCallbackFire: _fnCallbackFire,
  12687. _fnLengthOverflow: _fnLengthOverflow,
  12688. _fnRenderer: _fnRenderer,
  12689. _fnDataSource: _fnDataSource,
  12690. _fnRowAttributes: _fnRowAttributes,
  12691. _fnCalculateEnd: function () {} // Used by a lot of plug-ins, but redundant
  12692. // in 1.10, so this dead-end function is
  12693. // added to prevent errors
  12694. } );
  12695. // jQuery access
  12696. $.fn.dataTable = DataTable;
  12697. // Legacy aliases
  12698. $.fn.dataTableSettings = DataTable.settings;
  12699. $.fn.dataTableExt = DataTable.ext;
  12700. // With a capital `D` we return a DataTables API instance rather than a
  12701. // jQuery object
  12702. $.fn.DataTable = function ( opts ) {
  12703. return $(this).dataTable( opts ).api();
  12704. };
  12705. // All properties that are available to $.fn.dataTable should also be
  12706. // available on $.fn.DataTable
  12707. $.each( DataTable, function ( prop, val ) {
  12708. $.fn.DataTable[ prop ] = val;
  12709. } );
  12710. // Information about events fired by DataTables - for documentation.
  12711. /**
  12712. * Draw event, fired whenever the table is redrawn on the page, at the same
  12713. * point as fnDrawCallback. This may be useful for binding events or
  12714. * performing calculations when the table is altered at all.
  12715. * @name DataTable#draw.dt
  12716. * @event
  12717. * @param {event} e jQuery event object
  12718. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12719. */
  12720. /**
  12721. * Search event, fired when the searching applied to the table (using the
  12722. * built-in global search, or column filters) is altered.
  12723. * @name DataTable#search.dt
  12724. * @event
  12725. * @param {event} e jQuery event object
  12726. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12727. */
  12728. /**
  12729. * Page change event, fired when the paging of the table is altered.
  12730. * @name DataTable#page.dt
  12731. * @event
  12732. * @param {event} e jQuery event object
  12733. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12734. */
  12735. /**
  12736. * Order event, fired when the ordering applied to the table is altered.
  12737. * @name DataTable#order.dt
  12738. * @event
  12739. * @param {event} e jQuery event object
  12740. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12741. */
  12742. /**
  12743. * DataTables initialisation complete event, fired when the table is fully
  12744. * drawn, including Ajax data loaded, if Ajax data is required.
  12745. * @name DataTable#init.dt
  12746. * @event
  12747. * @param {event} e jQuery event object
  12748. * @param {object} oSettings DataTables settings object
  12749. * @param {object} json The JSON object request from the server - only
  12750. * present if client-side Ajax sourced data is used</li></ol>
  12751. */
  12752. /**
  12753. * State save event, fired when the table has changed state a new state save
  12754. * is required. This event allows modification of the state saving object
  12755. * prior to actually doing the save, including addition or other state
  12756. * properties (for plug-ins) or modification of a DataTables core property.
  12757. * @name DataTable#stateSaveParams.dt
  12758. * @event
  12759. * @param {event} e jQuery event object
  12760. * @param {object} oSettings DataTables settings object
  12761. * @param {object} json The state information to be saved
  12762. */
  12763. /**
  12764. * State load event, fired when the table is loading state from the stored
  12765. * data, but prior to the settings object being modified by the saved state
  12766. * - allowing modification of the saved state is required or loading of
  12767. * state for a plug-in.
  12768. * @name DataTable#stateLoadParams.dt
  12769. * @event
  12770. * @param {event} e jQuery event object
  12771. * @param {object} oSettings DataTables settings object
  12772. * @param {object} json The saved state information
  12773. */
  12774. /**
  12775. * State loaded event, fired when state has been loaded from stored data and
  12776. * the settings object has been modified by the loaded data.
  12777. * @name DataTable#stateLoaded.dt
  12778. * @event
  12779. * @param {event} e jQuery event object
  12780. * @param {object} oSettings DataTables settings object
  12781. * @param {object} json The saved state information
  12782. */
  12783. /**
  12784. * Processing event, fired when DataTables is doing some kind of processing
  12785. * (be it, order, searcg or anything else). It can be used to indicate to
  12786. * the end user that there is something happening, or that something has
  12787. * finished.
  12788. * @name DataTable#processing.dt
  12789. * @event
  12790. * @param {event} e jQuery event object
  12791. * @param {object} oSettings DataTables settings object
  12792. * @param {boolean} bShow Flag for if DataTables is doing processing or not
  12793. */
  12794. /**
  12795. * Ajax (XHR) event, fired whenever an Ajax request is completed from a
  12796. * request to made to the server for new data. This event is called before
  12797. * DataTables processed the returned data, so it can also be used to pre-
  12798. * process the data returned from the server, if needed.
  12799. *
  12800. * Note that this trigger is called in `fnServerData`, if you override
  12801. * `fnServerData` and which to use this event, you need to trigger it in you
  12802. * success function.
  12803. * @name DataTable#xhr.dt
  12804. * @event
  12805. * @param {event} e jQuery event object
  12806. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12807. * @param {object} json JSON returned from the server
  12808. *
  12809. * @example
  12810. * // Use a custom property returned from the server in another DOM element
  12811. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  12812. * $('#status').html( json.status );
  12813. * } );
  12814. *
  12815. * @example
  12816. * // Pre-process the data returned from the server
  12817. * $('#table').dataTable().on('xhr.dt', function (e, settings, json) {
  12818. * for ( var i=0, ien=json.aaData.length ; i<ien ; i++ ) {
  12819. * json.aaData[i].sum = json.aaData[i].one + json.aaData[i].two;
  12820. * }
  12821. * // Note no return - manipulate the data directly in the JSON object.
  12822. * } );
  12823. */
  12824. /**
  12825. * Destroy event, fired when the DataTable is destroyed by calling fnDestroy
  12826. * or passing the bDestroy:true parameter in the initialisation object. This
  12827. * can be used to remove bound events, added DOM nodes, etc.
  12828. * @name DataTable#destroy.dt
  12829. * @event
  12830. * @param {event} e jQuery event object
  12831. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12832. */
  12833. /**
  12834. * Page length change event, fired when number of records to show on each
  12835. * page (the length) is changed.
  12836. * @name DataTable#length.dt
  12837. * @event
  12838. * @param {event} e jQuery event object
  12839. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12840. * @param {integer} len New length
  12841. */
  12842. /**
  12843. * Column sizing has changed.
  12844. * @name DataTable#column-sizing.dt
  12845. * @event
  12846. * @param {event} e jQuery event object
  12847. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12848. */
  12849. /**
  12850. * Column visibility has changed.
  12851. * @name DataTable#column-visibility.dt
  12852. * @event
  12853. * @param {event} e jQuery event object
  12854. * @param {object} o DataTables settings object {@link DataTable.models.oSettings}
  12855. * @param {int} column Column index
  12856. * @param {bool} vis `false` if column now hidden, or `true` if visible
  12857. */
  12858. return $.fn.dataTable;
  12859. }));
  12860. }(window, document));